在ANSI C中读取.ini文件 [英] Reading .ini files in ANSI C

查看:90
本文介绍了在ANSI C中读取.ini文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

任何人都知道是否有一些符合ANSI-C标准的代码可以读取

Windows风格的.ini文件?我不在乎写它,但我需要能够从各种操作系统中读取它,所以不应该有任何Windows包含的b $ b。


它看起来不太难,但有一些技巧(比如

多行字符串),所以我愿意节省一些时间(谁不会)。

-

Guillaume Dargaud
http://www.gdargaud.net/

解决方案

Guillaume Dargaud< us ***************************** @ www.gdargaud.netw rote:
< blockquote class =post_quotes>
任何人都知道是否有一些符合ANSI-C标准的代码可以读取

Windows风格的.ini文件?我不在乎写它,但我需要能够从各种操作系统中读取它,所以不应该有任何Windows包含的b $ b。



使用fopen(),fread()和fclose()有什么问题?


这看起来不太难,但有一些技巧(比如

多行字符串),所以我很想节省一些时间(谁那并不)。



啊,你不只是想阅读它而是解析它。

嗯,快速浏览一下Google吧;解析器.ini文件

出现例如 http://ndevilla.free.fr/iniparser

http://sourceforge.net/projects/libini 差不多
顶部。

问候,Jens

-

\ Jens Thoms Toerring ___ jt@toerring.de

\ __________________________ http://toerring.de


文章< 6b ************* @ mid.uni- berlin.de>,

Jens Thoms Toerring< jt@toerring.dewrote:


> Guillaume Dargaud< us *** **************************@www.gdargaud.netw死记硬背:


>任何人都知道是否有一些符合ANSI-C标准的代码可以读取Windows风格的.ini文件?我不在乎写它但我需要能够从各种操作系统中读取它,所以不应该有任何Windows包含。



你真的很想知道为什么人们懒得花点时间发布这些无用的回复。请参阅下面的进一步说明。


>使用fopen(),fread()和fclose()有什么问题?



这只是无用的姿势。你认为有人对它感到好笑。


(哎呀,对不起。我猜Heathfield等人会是)


>它看起来不太难做,但有一些技巧(比如
多行字符串),所以我会喜欢节省一些时间(谁不会)。


啊,你不只是想阅读它而是解析它。
好吧,快速浏览一下Google的解析器.ini文件 http://ndevilla.free.fr/iniparser
http://sourceforge.net/projects/libini 几乎在顶部。



任何人都可以谷歌。关键是要看看是否有人在这条道路上走了一条路(可能是很多人,但可能并不是很多,而且可能来自于CLC regs阵营)并且可以推荐任何东西。请记住,鲟鱼定律

适用于你从谷歌搜索获得的东西,就像它对任何东西一样

其他。


现在,对于一些实际的内容:我很久以前就在路上了 - 我有一个需要在Linux环境中使用INI文件的
a,我在Usenet上寻求帮助,
事实上,
制作的查询与此类似。我得到了,正如你想要的那样,通常的反MS咆哮是健康剂量,但我做了最后得到了指向一个人开发的包的指针

看起来非常好用。但是,我从来没有完全遵循

,它很久以前,所以我不能再多说了。


它很可能有是libini你在上面提到的,但是要做到这一点

请记住,斯特金定律现在也适用于

sourceforge的项目。


6月18日,9:24 * am,Guillaume Dargaud

< use_the_form_on_my_contact_p ... @ www.gdargaud.netw死记硬币:


大家好,

任何人都知道是否有一些符合ANSI-C标准的代码可以读取

Windows风格的.ini文件?我不在乎写它但是我需要能够从各种操作系统中读取它,所以不应该有任何Windows

包括。


它看起来不太难,但有一些技巧(比如

多行字符串),所以我我喜欢节省一些时间(谁也没有)。



Windows应用程序不再使用ini文件(或者至少他们不应该使用
)。现在他们使用注册表。


无论如何,也许这可以帮助:
http://sourceforge.net/ search / index .... de = 0& limit = 100


Hello all,
anybody knows if there''s some ANSI-C conformant code around that can read
Windows-style .ini files ? I don''t care about writing to it but I need to be
able to read it from various OSs, so there shouldn''t be any Windows
includes.

It doesn''t look like it''s too hard to do, but there are a few tricks (like
multiple line strings), so I''d love to save some time (who doesn''t).
--
Guillaume Dargaud
http://www.gdargaud.net/

解决方案

Guillaume Dargaud <us*****************************@www.gdargaud.netw rote:

anybody knows if there''s some ANSI-C conformant code around that can read
Windows-style .ini files ? I don''t care about writing to it but I need to be
able to read it from various OSs, so there shouldn''t be any Windows
includes.

What''s wrong about using fopen(), fread() and fclose()?

It doesn''t look like it''s too hard to do, but there are a few tricks (like
multiple line strings), so I''d love to save some time (who doesn''t).

Ah, you don''t just want to read it but parse it also.
Well, a quick look at Google for "parser .ini files"
comes up with e.g. http://ndevilla.free.fr/iniparser
and http://sourceforge.net/projects/libini nearly at
the top.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de


In article <6b*************@mid.uni-berlin.de>,
Jens Thoms Toerring <jt@toerring.dewrote:

>Guillaume Dargaud <us*****************************@www.gdargaud.netw rote:

>anybody knows if there''s some ANSI-C conformant code around that can read
Windows-style .ini files ? I don''t care about writing to it but I need to be
able to read it from various OSs, so there shouldn''t be any Windows
includes.

You really gotta wonder why people bother to take the time to post these
useless responses. See below for further exposition.

>What''s wrong about using fopen(), fread() and fclose()?

This is just useless posturing. Do you think anyone is amused by it.

(Oops, sorry. I guess Heathfield, et al, would be)

>It doesn''t look like it''s too hard to do, but there are a few tricks (like
multiple line strings), so I''d love to save some time (who doesn''t).


Ah, you don''t just want to read it but parse it also.
Well, a quick look at Google for "parser .ini files"
comes up with e.g. http://ndevilla.free.fr/iniparser
and http://sourceforge.net/projects/libini nearly at
the top.

Anybody can Google. The point is to see if anyone has been down this
road (presumably, many people have, though probably not many from the
CLC regs camp) and can recommend anything. Remember, Sturgeon''s Law
applies to what you get from Googling, as much as it does to anything
else.

Now, for some actual content: I was down the road once long ago - I had
a need to use INI files in a Linux context, and I asked for help on Usenet,
making, in fact, a query quite similar to this one. I got, as you would
expect, a healthy dose of the usual anti-MS ranting, but I did
eventually get a pointer to a package that someone had developed that
looked quite good and useful. However, I never quite followed through
on it, and it was long ago, so I can''t say anything more.

It might well have been the "libini" to which you refer to above, but do
keep in mind that Sturgeon''s Law also applies to the projects at
sourceforge nowadays, as well.


On Jun 18, 9:24*am, "Guillaume Dargaud"
<use_the_form_on_my_contact_p...@www.gdargaud.netw rote:

Hello all,
anybody knows if there''s some ANSI-C conformant code around that can read
Windows-style .ini files ? I don''t care about writing to it but I need tobe
able to read it from various OSs, so there shouldn''t be any Windows
includes.

It doesn''t look like it''s too hard to do, but there are a few tricks (like
multiple line strings), so I''d love to save some time (who doesn''t).

Windows applications don''t use ini files any more (or at least they
are not supposed to). Now they use the registry.

Anyway, maybe this can help:
http://sourceforge.net/search/index....de=0&limit=100


这篇关于在ANSI C中读取.ini文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆