c語言讀取配置檔案 openssl庫讀取配置檔案

2021-10-09 04:47:56 字數 1369 閱讀 3002

原始檔:

#include"common.h"//常用標頭檔案

#include//openssl配置檔案標頭檔案

int main()

nconf_load_bio(conf,bp,&line);

#else

ret=nconf_load(conf,"/home/qual/qualsystem/etc/honorcentosmini1/honorcentosmini1.cnf",&line);

if(ret!=1)

#endif

p=nconf_get_string(conf,null,"oracle_name");

if(p==null)

else

p=nconf_get_string(conf,"oracle","oracle_name");//獲取某段某key,字串形式

if(p==null)

printf("[%s]\n",p);

p=nconf_get_string(conf,"oracle","oracle_pawd");

if(p==null)

printf("[%s]\n",p);

ret=nconf_get_number_e(conf,"mysql","mysql_pawd",&result);//獲取某段某key,數字形式

printf("ret[%d]\n",ret);

printf("[%d]\n",result);

ret=nconf_get_number(conf,"oracle","oracle_pawd",&result);//獲取某段某key,數字形式

printf("ret[%d]\n",ret);    

printf("[%d]\n",result);

v=nconf_get_section(conf,"mysql");//獲取某段所有配置

num=sk_conf_value_num(v);

printf("section mysql :\n");

for(i=0;iname,one->value);

}nconf_free(conf);

}make檔案:

$(target):

@echo "/********************begin to make********************/"

@echo "begin make [email protected]"

$(cc) -o $(target) $(target).c $(cominclude)  $(warn) $(thread) $(lib) 

mv $(target) $(bin)

@echo "/********************end to make********************/"

C語言讀取配置檔案

配置檔案 a.txt 1 2 3 ip sadf ip 192.168.246.22 dns 218.85.157.99 讀取規則 1 以 開頭的為注釋,不讀取 2 空行也不讀取 3 兩邊可以有空格 這裡先講下要用到的知識點 1 斷言的使用 assert 巨集用法 注意 assert是巨集,而不是函...

C 讀取配置檔案

1 首先引入標頭檔案 include 2 獲取應用程式的當前路徑 char buf 1000 getcurrentdirectory 1000,buf 得到當前工作路徑3 獲取配置檔案的路徑 char path 1024 definesysconfig config.ini sprintf path...

C 讀取配置檔案

1 利用系統介面,讀取ini配置檔案,詳情可查詢msdn。這裡做簡單宣告 宣告讀ini檔案的api函式 dllimport kernel32 private static extern int getprivateprofilestring string section,string key,str...