• hsmike
    了解作者
  • C/C++
    开发工具
  • 38KB
    文件大小
  • gz
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 40
    下载次数
  • 2014-03-27 21:58
    上传日期
C语言实现的读取和写入配置文件的库,可以复用,还是不错的
iniparser-3.1.tar.gz
  • iniparser
  • test
  • twisted-ofval.ini
    5.2KB
  • twisted-ofkey.ini
    6.2KB
  • iniexample.c
    2.2KB
  • parse.c
    409B
  • Makefile
    404B
  • twisted-genhuge.py
    252B
  • twisted.ini
    1.2KB
  • twisted-errors.ini
    92B
  • html
  • globals_func.html
    3.1KB
  • open.png
    118B
  • closed.png
    126B
  • nav_h.png
    97B
  • iniparser_8h.html
    32.2KB
  • tab_h.png
    192B
  • index.html
    9.6KB
  • doxygen.png
    3.8KB
  • doxygen.css
    12.1KB
  • tab_r.gif
    2.5KB
  • tab_b.png
    178B
  • bc_s.png
    677B
  • tab_b.gif
    35B
  • iniparser_8main.html
    1.2KB
  • tab_a.png
    140B
  • tabs.css
    1.1KB
  • tab_s.png
    189B
  • tab_l.gif
    706B
  • nav_f.png
    159B
  • src
  • dictionary.h
    6.4KB
  • dictionary.c
    11.9KB
  • iniparser.h
    11.3KB
  • iniparser.c
    22.3KB
  • doc
  • iniparser.dox
    2.2KB
  • iniparser.main
    6.9KB
  • Makefile
    275B
  • LICENSE
    1.1KB
  • README
    295B
  • INSTALL
    353B
  • AUTHORS
    246B
  • Makefile
    1.1KB
内容介绍
/*-------------------------------------------------------------------------*/ /** @file iniparser.c @author N. Devillard @brief Parser for ini files. */ /*--------------------------------------------------------------------------*/ /*---------------------------- Includes ------------------------------------*/ #include <ctype.h> #include "iniparser.h" /*---------------------------- Defines -------------------------------------*/ #define ASCIILINESZ (1024) #define INI_INVALID_KEY ((char*)-1) /*--------------------------------------------------------------------------- Private to this module ---------------------------------------------------------------------------*/ /** * This enum stores the status for each parsed line (internal use only). */ typedef enum _line_status_ { LINE_UNPROCESSED, LINE_ERROR, LINE_EMPTY, LINE_COMMENT, LINE_SECTION, LINE_VALUE } line_status ; /*-------------------------------------------------------------------------*/ /** @brief Convert a string to lowercase. @param s String to convert. @return ptr to statically allocated string. This function returns a pointer to a statically allocated string containing a lowercased version of the input string. Do not free or modify the returned string! Since the returned string is statically allocated, it will be modified at each function call (not re-entrant). */ /*--------------------------------------------------------------------------*/ static char * strlwc(const char * s) { static char l[ASCIILINESZ+1]; int i ; if (s==NULL) return NULL ; memset(l, 0, ASCIILINESZ+1); i=0 ; while (s[i] && i<aSCIILINESZ) { l[i] = (char)tolower((int)s[i]); i++ ; } l[ASCIILINESZ]=(char)0; return l ; } /*-------------------------------------------------------------------------*/ /** @brief Remove blanks at the beginning and the end of a string. @param s String to parse. @return ptr to statically allocated string. This function returns a pointer to a statically allocated string, which is identical to the input string, except that all blank characters at the end and the beg. of the string have been removed. Do not free or modify the returned string! Since the returned string is statically allocated, it will be modified at each function call (not re-entrant). */ /*--------------------------------------------------------------------------*/ static char * strstrip(const char * s) { static char l[ASCIILINESZ+1]; char * last ; if (s==NULL) return NULL ; while (isspace((int)*s) && *s) s++; memset(l, 0, ASCIILINESZ+1); strcpy(l, s); last = l + strlen(l); while (last rel='nofollow' onclick='return false;'> l) { if (!isspace((int)*(last-1))) break ; last -- ; } *last = (char)0; return (char*)l ; } /*-------------------------------------------------------------------------*/ /** @brief Get number of sections in a dictionary @param d Dictionary to examine @return int Number of sections found in dictionary This function returns the number of sections found in a dictionary. The test to recognize sections is done on the string stored in the dictionary: a section name is given as "section" whereas a key is stored as "section:key", thus the test looks for entries that do not contain a colon. This clearly fails in the case a section name contains a colon, but this should simply be avoided. This function returns -1 in case of error. */ /*--------------------------------------------------------------------------*/ int iniparser_getnsec(dictionary * d) { int i ; int nsec ; if (d==NULL) return -1 ; nsec=0 ; for (i=0 ; i<d->size ; i++) { if (d->key[i]==NULL) continue ; if (strchr(d->key[i], ':')==NULL) { nsec ++ ; } } return nsec ; } /*-------------------------------------------------------------------------*/ /** @brief Get name for section n in a dictionary. @param d Dictionary to examine @param n Section number (from 0 to nsec-1). @return Pointer to char string This function locates the n-th section in a dictionary and returns its name as a pointer to a string statically allocated inside the dictionary. Do not free or modify the returned string! This function returns NULL in case of error. */ /*--------------------------------------------------------------------------*/ char * iniparser_getsecname(dictionary * d, int n) { int i ; int foundsec ; if (d==NULL || n<0) return NULL ; foundsec=0 ; for (i=0 ; i<d->size ; i++) { if (d->key[i]==NULL) continue ; if (strchr(d->key[i], ':')==NULL) { foundsec++ ; if (foundsec>n) break ; } } if (foundsec<=n) { return NULL ; } return d->key[i] ; } /*-------------------------------------------------------------------------*/ /** @brief Dump a dictionary to an opened file pointer. @param d Dictionary to dump. @param f Opened file pointer to dump to. @return void This function prints out the contents of a dictionary, one element by line, onto the provided file pointer. It is OK to specify @c stderr or @c stdout as output files. This function is meant for debugging purposes mostly. */ /*--------------------------------------------------------------------------*/ void iniparser_dump(dictionary * d, FILE * f) { int i ; if (d==NULL || f==NULL) return ; for (i=0 ; i<d->size ; i++) { if (d->key[i]==NULL) continue ; if (d->val[i]!=NULL) { fprintf(f, "[%s]=[%s]\n", d->key[i], d->val[i]); } else { fprintf(f, "[%s]=UNDEF\n", d->key[i]); } } return ; } /*-------------------------------------------------------------------------*/ /** @brief Save a dictionary to a loadable ini file @param d Dictionary to dump @param f Opened file pointer to dump to @return void This function dumps a given dictionary into a loadable ini file. It is Ok to specify @c stderr or @c stdout as output files. */ /*--------------------------------------------------------------------------*/ void iniparser_dump_ini(dictionary * d, FILE * f) { int i ; int nsec ; char * secname ; if (d==NULL || f==NULL) return ; nsec = iniparser_getnsec(d); if (nsec<1) { /* No section in file: dump all keys as they are */ for (i=0 ; i<d->size ; i++) { if (d->key[i]==NULL) continue ; fprintf(f, "%s = %s\n", d->key[i], d->val[i]); } return ; } for (i=0 ; i<nsec ; i++) { secname = iniparser_getsecname(d, i) ; iniparser_dumpsection_ini(d, secname, f) ; } fprintf(f, "\n"); return ; } /*-------------------------------------------------------------------------*/ /** @brief Save a dictionary section to a loadable ini file @param d Dictionary to dump @param s Section name of dictionary to dump @param f Opened file pointer to dump to @return void This function dumps a given section of a given dictionary into a loadable ini file. It is Ok to specify @c stderr or @c stdout as output files. */ /*--------------------------------------------------------------------------*/ void iniparser_dumpsection_ini(dictionary * d, char * s, FILE * f) { int j ; char keym[ASCIILINESZ+1]; int seclen ; if (d==NULL || f==NULL) return ; if (! iniparser_find_entry(d, s)) return ; seclen = (int)strlen(s); fprintf(f, "\n[%s]\n", s); sprintf(keym, "%s:", s); for (j=0 ; j<d->size ; j++) { if (d->key[j]==NULL) continue ; if (!strncmp(d->key[j], keym, seclen+1)) { fprintf(f,
评论
    相关推荐
    • iniparser-3.1.tar.gz
      ini配置档的解析库文件,个人使用相对还比较好用。支持SECTION,相同的KEY值等
    • git-gh:git 的 github 扩展
      Git 的 Github 扩展 该项目已在 OSX 10.8.2、Debian 6 和 Ubuntu 12.10 上进行了测试。 要求 json-c == 0.10 iniparser == 3.1 libcurl >= 1.4 在 OSX 上安装 ...tar xf iniparser-3.1.tar.gz cd iniparser m
    • 数字图像处理学:Visual C++实现_10990262.rar
      数字图像处理学:Visual C++实现 1数字图象处理导论 2光学基础与视觉系统 3对设备无关位图的访问 4图象的变换 5图象的增强 6图象复原 7图象重建 8图象分割 9图象纹理分析 10图象腐蚀与膨胀 11图象压缩编码 12图象模式识别
    • sourceinsight.rar
      很好的C语言查看工具,完全破解版相信大家都知道这个查看工具吧,如果没有可以下载下来
    • socket_program_guide.rar
      1.套接字编程原理 1.1 Client/server通信模型 1.2 Windows Sockets规范 1.3 套接字 1.3.1 套接字定义 1.3.2分类 1.3.3 套接字的作用 1.3.4端口与地址 1.3.5 套接口属性 2.基本的Windows Sockets API编程 2.1常用函数 2.2 TCP实例 2.3 UDP实例 2.4 Socket 通信阻塞的解决方法 3.MFC下的Socket编程的类 3.1 CAsyncSocket类 3.2 CSocket类 3.3 Windows Sockets:带存档的套接字的工作方式 3.4 流式套接字通信的操作顺序 3.5 使用 CAsyncSocket 类 3.6 从套接字类派生 3.7 套接字通知 3.8 一个使用CSocket类的网络通信实例 3.8.1 服务器端应用程序设计(ServerDemo) 3.8.2 客户端应用程序设计(项目名称ClientDemo) 4.套接字的托管实现 4.1 System::Net::Sockets 命名空间 4.2 实例:一个新邮件检查器
    • C++Builder.rar
      有视频,有源代码,是很好的学习c++Builder的资料!我是学生,很想加入pudn!
    • VC6 类库参考手册.rar
      可称得上中文版的MSDN吧
    • WIN32API.rar
      windows api 参考手册 chm格式
    • 习题程序.zip
      清华大学版 谭浩强著 c++习题程序答案