comparison mcabber/mcabber/settings.c @ 1729:e6e89b1d7831

Minor style and header updates
author Mikael Berthe <mikael@lilotux.net>
date Sun, 28 Feb 2010 15:19:27 +0100
parents 552da310b83e
children 4e57d6275a86
comparison
equal deleted inserted replaced
1728:15b3834cbe5f 1729:e6e89b1d7831
1 /* 1 /*
2 * settings.c -- Configuration stuff 2 * settings.c -- Configuration stuff
3 * 3 *
4 * Copyright (C) 2005-2009 Mikael Berthe <mikael@lilotux.net> 4 * Copyright (C) 2005-2010 Mikael Berthe <mikael@lilotux.net>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at 8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version. 9 * your option) any later version.
249 *pkey = *pval = NULL; 249 *pkey = *pval = NULL;
250 250
251 key = assignment; 251 key = assignment;
252 // Remove leading spaces in option name 252 // Remove leading spaces in option name
253 while ((!isalnum(*key)) && (*key != '=') && *key) { 253 while ((!isalnum(*key)) && (*key != '=') && *key) {
254 //if (!isblank(*key))
255 // scr_LogPrint("Error in assignment parsing!");
256 key++; 254 key++;
257 } 255 }
258 if (!*key) return FALSE; // Empty assignment 256 if (!*key) return FALSE; // Empty assignment
259 257
260 if (*key == '=') { 258 if (*key == '=') {
261 //scr_LogPrint("Cannot parse assignment!");
262 return FALSE; 259 return FALSE;
263 } 260 }
264 // Ok, key points to the option name 261 // Ok, key points to the option name
265 262
266 for (val = key+1 ; *val && (*val != '=') ; val++) 263 for (val = key+1 ; *val && (*val != '=') ; val++)
267 if (!isalnum(*val) && !isblank(*val) && (*val != '_') && (*val != '-')) { 264 if (!isalnum(*val) && !isblank(*val) && (*val != '_') && (*val != '-')) {
268 // Key should only have alnum chars... 265 // Key should only have alnum chars...
269 //scr_LogPrint("Error in assignment parsing!");
270 return FALSE; 266 return FALSE;
271 } 267 }
272 // Remove trailing spaces in option name: 268 // Remove trailing spaces in option name:
273 for (t = val-1 ; t > key && isblank(*t) ; t--) 269 for (t = val-1 ; t > key && isblank(*t) ; t--)
274 ; 270 ;
275 // Check for embedded whitespace characters 271 // Check for embedded whitespace characters
276 for (p = key; p < t; p++) { 272 for (p = key; p < t; p++) {
277 if (isblank(*p)) { 273 if (isblank(*p)) {
278 //scr_LogPrint("Error in assignment parsing!" 274 // Name should not contain space chars...
279 // " (Name should not contain space chars)");
280 return FALSE; 275 return FALSE;
281 } 276 }
282 } 277 }
283 278
284 *pkey = g_strndup(key, t+1-key); 279 *pkey = g_strndup(key, t+1-key);