| Who | When |
Messages | |
(not accepting new messages)
|
|
|
|
81
|
 |
|
04-23-2009 09:11 AM ET (US)
|
|
Deleted by topic administrator 04-23-2009 12:11 PM
|
| leon
|
80
|
 |
|
04-21-2009 12:43 AM ET (US)
|
|
Deleted by author 04-21-2009 02:19 AM
|
| Claude BIDEAU
|
79
|
 |
|
04-17-2009 04:39 AM ET (US)
|
|
your iniparser are not able to parse line with ':' instead of '=' ; example [section] arg1 : argument one
so I modify your code at line 481 in iniparser.c as following :
} else if (sscanf (line, "%[^=] = \"%[^\"]\"", key, value) == 2 || sscanf (line, "%[^=] = '%[^\']'", key, value) == 2 || sscanf (line, "%[^=] = %[^;#]", key, value) == 2 || sscanf (line, "%[^:] : \"%[^\"]\"", key, value) == 2 || sscanf (line, "%[^:] : '%[^\']'", key, value) == 2 || sscanf (line, "%[^:] : %[^;#]", key, value) == 2) { /* Usual key=value, with or without comments */ /* Usual key:value, with or without comments */ strcpy(key, strstrip(key)); strcpy(key, strlwc(key)); strcpy(value, strstrip(value)); /* * sscanf cannot handle '' or "" as empty values * this is done here */ if (!strcmp(value, "\"\"") || (!strcmp(value, "''"))) { value[0]=0 ; } sta = LINE_VALUE ; } else if (sscanf(line, "%[^=] = %[;#]", key, value)==2 || sscanf(line, "%[^=] %[=]", key, value) == 2 || sscanf(line, "%[^:] : %[;#]", key, value)==2 || sscanf(line, "%[^:] %[:]", key, value) == 2) { /* * Special cases: * key= * key=; * key=# * key: * key:; * key:# */
BR
Claude
|
| |
Messages 78-77 deleted by topic administrator between 04-18-2009 01:29 PM and 04-11-2009 07:41 AM |
| raicuandi
|
76
|
 |
|
04-03-2009 01:16 AM ET (US)
|
|
I just said it is.
|
| simple user
|
75
|
 |
|
04-02-2009 05:44 PM ET (US)
|
|
Load data from ini with comments, change some parameters, then save -- comments will be gone. Is it possible to fix this somehow?
|
| anderl
|
74
|
 |
|
04-01-2009 12:33 PM ET (US)
|
|
Edited by author 04-01-2009 12:35 PM
I'm having a LINKER problem.
I'm using MacOS 10.5.6 Build 9G55 and running into the followong linker problem:
ld: unknown option: -Bsymbolic collect2: ld returned 1 exit status make: *** [libiniparser.so] Error 1
Has anyone come across this or has an idea how to solve it???
Any help or hints are highly appreciated !
Thanks
anderl
|
| raicuandi
|
73
|
 |
|
03-31-2009 12:29 AM ET (US)
|
|
I dealt with preserving comments in similar formats before. Basically, -settable by an option-, you can preserve comments by keeping 2 strings for each entry: one with any comment at the end of the line, and one containing all the comments (incl. new lines) _above_ that entry. This preserves the format and is pretty easy to implement in an existing parser.
|
N. Devillard
|
72
|
 |
|
03-30-2009 12:34 PM ET (US)
|
|
stenyak: iniparser is meant to offer an easy way to parse ini files, it is not really a round-trip tool with a 1-to-1 correspondence between file and in-memory data. This being said: Use iniparser_set() to change setting values Use iniparser_dump_ini() to create a new ini file containing these values You will loose the initial file comments by doing so.
|
|
|
71
|
 |
|
03-30-2009 11:56 AM ET (US)
|
|
Deleted by topic administrator 03-30-2009 12:30 PM
|
| stenyak
|
70
|
 |
|
03-30-2009 11:55 AM ET (US)
|
|
How can i..? a) set values of some settings b) rewrite the .ini file, so that it contains those changes in the settings.
thanks in advance!
|
| Dan S
|
69
|
 |
|
02-04-2009 10:53 AM ET (US)
|
|
Okay, cool! Thanks!
|
|
|
68
|
 |
|
02-04-2009 12:25 AM ET (US)
|
|
Deleted by topic administrator 04-11-2009 07:43 AM
|
| bunder
|
67
|
 |
|
02-03-2009 06:39 PM ET (US)
|
|
Edited by author 02-03-2009 06:50 PM
You can iterate through the keys by using dictionary structure like in iniparser_dump (see iniparser.c). Here is an example for your case:
int main(int argc,char *argv[]) { dictionary *dict;
dict=iniparser_load("test.ini"); if(!dict) return EXIT_FAILURE;
int i; unsigned int hh=dictionary_hash("hosts"); for(i=0;(i<dict->n)&&(hh!=dict->hash[i]);i++); if(i==dict->n) return EXIT_FAILURE; // There is no section "hosts" in ini-file.
for(i++;(i<dict->n)&&strncmp(dict->key[i],"hosts:",6)==0;i++) printf("%s = %s\n",dict->key[i]+6,dict->val[i]);
iniparser_freedict(dict); return EXIT_SUCCESS; }
|
| Dan S
|
66
|
 |
|
02-03-2009 05:00 PM ET (US)
|
|
I just found this library and am interested in using it. One thing I don't see how to do: it is clear how things work if you have a specific key (say, myhostname) and define a value for it (say, foo.bar.com). What doesn't seem possible is some way of iterating through the entries in a section, processing them as you go. For example:
[hosts]
foo = 192.168.1.1 bar = 192.168.1.2 blah = 192.168.1.3
etc...
Am I missing something? This seems like a useful capability, no?
|