comparison mcabber/mcabber/utils.c @ 2111:9023a6f2bf6c

Misc. style updates
author Mikael Berthe <mikael@lilotux.net>
date Sun, 11 May 2014 17:18:18 +0200
parents 1210a22726d3
children 3b26f3a58cb9
comparison
equal deleted inserted replaced
2110:9b4b7941647c 2111:9023a6f2bf6c
77 *ptr = 0; 77 *ptr = 0;
78 } 78 }
79 return alias; 79 return alias;
80 } 80 }
81 81
82 // The caller must free the string after use.
82 char *jid_get_username(const char *fjid) 83 char *jid_get_username(const char *fjid)
83 { 84 {
84 char *ptr; 85 char *ptr;
85 char *username; 86 char *username;
86 87
89 *ptr = 0; 90 *ptr = 0;
90 } 91 }
91 return username; 92 return username;
92 } 93 }
93 94
95 // The caller must free the string after use.
94 char *get_servername(const char *username, const char *servername) 96 char *get_servername(const char *username, const char *servername)
95 { 97 {
96 char *ptr; 98 char *ptr;
97 char *server; 99 char *server;
98 100
99 if ((ptr = strchr(username, JID_DOMAIN_SEPARATOR)) != NULL) { 101 if ((ptr = strchr(username, JID_DOMAIN_SEPARATOR)) != NULL) {
100 server = g_strdup(ptr+1); 102 server = g_strdup(ptr+1);
101 return server; 103 return server;
102 } 104 }
103 105
104 return servername; 106 return g_strdup(servername);
105 } 107 }
106 108
109 // The caller must free the string after use.
107 char *compose_jid(const char *username, const char *servername, 110 char *compose_jid(const char *username, const char *servername,
108 const char *resource) 111 const char *resource)
109 { 112 {
110 char *fjid; 113 char *fjid;
111 114
207 g_free(v); 210 g_free(v);
208 fclose(fp); 211 fclose(fp);
209 return TRUE; 212 return TRUE;
210 } 213 }
211 214
215 // The caller must free the string after use.
212 static gchar *tracelog_level_guard(const gchar *key, const gchar *new_value) 216 static gchar *tracelog_level_guard(const gchar *key, const gchar *new_value)
213 { 217 {
214 int new_level = 0; 218 int new_level = 0;
215 if (new_value) 219 if (new_value)
216 new_level = atoi(new_value); 220 new_level = atoi(new_value);
219 else 223 else
220 DebugEnabled = new_level; 224 DebugEnabled = new_level;
221 return g_strdup(new_value); 225 return g_strdup(new_value);
222 } 226 }
223 227
228 // The caller must free the string after use.
224 static gchar *tracelog_file_guard(const gchar *key, const gchar *new_value) 229 static gchar *tracelog_file_guard(const gchar *key, const gchar *new_value)
225 { 230 {
226 gchar *new_fname = NULL; 231 gchar *new_fname = NULL;
227 232
228 if (new_value) 233 if (new_value)
240 245
241 return g_strdup(new_value); 246 return g_strdup(new_value);
242 } 247 }
243 248
244 // ut_init_debug() 249 // ut_init_debug()
245 // Installs otpion guards before initial config file parsing. 250 // Install option guards before initial config file parsing.
246 void ut_init_debug(void) 251 void ut_init_debug(void)
247 { 252 {
248 DebugEnabled = 0; 253 DebugEnabled = 0;
249 FName = NULL; 254 FName = NULL;
250 settings_set_guard("tracelog_level", tracelog_level_guard); 255 settings_set_guard("tracelog_level", tracelog_level_guard);