Hello there, is there a function in Linux that can handle the reading of an .ini file? Thanks.

Not that I know of, but you could probably roll your own pretty easily. I know there are a lot of libraries people wrote on Google as well...

How complex is the INI file you want to read? (Does it stick to the simple [this is a section header] this=is a value format?)

I'm sure I came across a nice library about a year ago that is pretty advanced. If I can remember what it is I'll post back.

Comments
Can foretell posibilities. Tsk tsk

>[this is a section header]
this=is a value

yeah, with that values. I'm still having a hard time figuring out because the ini file that I generated in windows is compose of wchar_t characters.

>I'm sure I came across a nice library about a year ago that is pretty advanced. If I can remember what it is I'll post back.

I would love to see that library. Thank you in advance. :)

>>yeah, with that values. I'm still having a hard time figuring out because the ini file that I generated in windows is compose of wchar_t characters

Ohhh that is not very good. The sizeof(wchar_t) in Windows compilers is not the same as in *nix compilers. The last time I checked Windows = 2 (short int) while *nix was 4 (long). So to read the file in *nix you will probably have to read each character as a short then convert it in memory to wchar_t (a long).

I doubt you will find any *nix library that will read that windows-generated file because of the size problems I mentioned above. But what you could do is write a program to convert the entire file then use one of those library functions to parse it.

Comments
Lean Mean Detailed Info Producing Machine

I've never heard of an INI file that isn't ASCII encoded. Too bad they don't all just die... (that is, seems odd to me people still use them, because for all their supposed simplicity they can sure give you headaches)...

Alas.

Have you considered storing all your init data in an XML file instead?
There are libraries to support XML, and plenty of tools to deal with XML.

I have considered it but there are restrictions from the input file and I have no control over that.

This question has already been answered. Start a new discussion instead.