亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? camconfig.c

?? 一個很棒的視頻服務器
?? C
字號:
/*  camserv - An internet streaming picture application * *  Copyright (C) 1999-2002  Jon Travis (jtravis@p00p.org) * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <stdio.h>#include <stdlib.h>#include <string.h>#include "log.h"#include "camconfig.h"#include "hash.h"#define HASH_MAX_SECTIONS  HASHCOUNT_T_MAX#define HASH_MAX_ENTRIES   HASHCOUNT_T_MAXstruct camconfig_section_st {  char section_name[ MAX_SECTION_NAME + 1 ];  hash_t *entryhash;};struct camconfig_st {  hash_t *mainhash;  /* Hash of CamConfigSection's */};/* * section_new:  Create and initialize a new CamConfigSection structure * * Arguments:    name = New name for the config section * * Return values:  Returns NULL on failure, else a pointer to new *                 CamConfigSection structure. */staticCamConfigSection *section_new( const char *name ){  CamConfigSection *res;  if( (res = malloc( sizeof( *res ))) == NULL )    return NULL;  strncpy( res->section_name, name, sizeof( res->section_name ) -1 );  res->section_name[ sizeof( res->section_name ) - 1 ] = '\0';  if( (res->entryhash = hash_create( HASH_MAX_SECTIONS, NULL, NULL )) == NULL){    free( res );    return NULL;  }  return res;}/* * section_add_pair:  Add or update a key/value pair in a section.   * * Arguments:         section = Section to update key/value pair in. *                    key     = Key to add *                    val     = Value associated with 'key' * * Return values:     Returns -1 on failure, 0 on success. */staticint section_add_pair( CamConfigSection *section, char *key,		      char *value ){  char *keydup, *valdup;  hnode_t *hnode;  if( (hnode = hash_lookup( section->entryhash, key )) != NULL ){    if( (valdup = strdup( value )) == NULL )      return -1;    /* Replacing an existing value */    free( hnode_get( hnode ) );    hnode_put( hnode, valdup );    return 0;  }  if( (keydup = strdup( key )) == NULL )    return -1;  if( (valdup = strdup( value )) == NULL ){    free( keydup );    return -1;  }  if( !hash_alloc_insert( section->entryhash, keydup, valdup )){    free( keydup );    free( valdup );    return -1;  }  return 0;}/* * section_dest:  Destroy a camconfig section, and all the key/value pairs *                held within. * * Argumetns:     section = Section to destroy. */staticvoid section_dest( CamConfigSection *section ){  hscan_t hs;  hnode_t *node;  hash_scan_begin( &hs, section->entryhash );  while( (node = hash_scan_next( &hs ))) {    char *key, *val;    key = hnode_getkey( node );    val = hnode_get( node );    hash_scan_delete( section->entryhash, node );    section->entryhash->freenode( node, section->entryhash->context );    free( key );    free( val );  }  hash_destroy( section->entryhash );  free( section );}/* * camconfig_new:   Create and initialize a new camconfig structure. * * Return values:   Returns NULL on failure, else a valid pointer to a new *                  camconfig structure. */CamConfig *camconfig_new(){  CamConfig *res;  if( (res = malloc( sizeof( *res )))== NULL )    return NULL;  if( (res->mainhash = hash_create( HASH_MAX_SECTIONS, NULL, NULL )) == NULL ){    free( res );    return NULL;  }  return res;}/* * camconfig_dest:  Destroy a camconfig structure, all the sections and *                  key/value pairs within. * * Arguments:       ccfg = camconfig structure to destroy */void camconfig_dest( CamConfig *ccfg ){  hscan_t hs;  hnode_t *node;  hash_scan_begin( &hs, ccfg->mainhash );  while( (node = hash_scan_next( &hs ))) {    char *key;    CamConfigSection *val;    key = hnode_getkey( node );    val = hnode_get( node );    hash_scan_delete( ccfg->mainhash, node );    ccfg->mainhash->freenode( node, ccfg->mainhash->context );    free( key );    section_dest( val );  }  hash_destroy( ccfg->mainhash );  free( ccfg );}/* * camconfig_add_section:  Add a new section into a camconfig structure. *                         Note that duplicate section names are disallowed. * * Arguments:              ccfg = Camconfig structure to add section to. *                         newsec = New section name to add. * * Return valueS:          Returns NULL on failure, else a valid pointer to *                         the new section that was created and added to *                         the camconfig structure. */staticCamConfigSection *camconfig_add_section( CamConfig *ccfg, char *newsec ){  CamConfigSection *res;  char *keyval;  hnode_t *node;  if( hash_lookup( ccfg->mainhash, newsec ) != NULL ){    camserv_log( "camconfig", "Section \"%s\" multi-defined in cfg",		 newsec );    return NULL;  }      if( (res = section_new( newsec )) == NULL )    return NULL;  if( (keyval = strdup( newsec )) == NULL ){    section_dest( res );    return NULL;  }  if( (node = hnode_create( res )) == NULL ){    section_dest( res );    free( keyval );    return NULL;  }  hash_insert( ccfg->mainhash, node, keyval );  return res;}/* * camconfig_read:  Create a camconfig structure, read a file containing *                  sections, and key/value pairs into it, and return it. * * Arguments:       fp = FILE to read camconfig data from. * * Return Values:   Returns NULL on failure, else a valid pointer to a new *                  camconfig structure. */CamConfig *camconfig_read( FILE *fp ){  CamConfigSection *current_section;  CamConfig *ccfg;  char buf[ 1024 ], *cp, *endcp, key[ 1024 ], value[ 1024 ];  int lineno;  if( (ccfg = camconfig_new()) == NULL ){    camserv_log( "camconfig", "Error allocating memory for config!");    return NULL;  }  current_section = NULL;  lineno = 0;  while( fgets( buf, sizeof( buf ), fp ) != NULL ){    lineno++;    if( buf[ 0 ] == '#' || buf[ 0 ] == '\n' )       continue;    if( buf[ 0 ] == '[' ) {  /* Begin a section */      if( (endcp = strrchr( buf, ']' )) == NULL ){	camserv_log( "camconfig", "Malformed section on line: %d", lineno );	continue;      }      cp = &buf[ 1 ];      *endcp = '\0';      if( (current_section = camconfig_add_section( ccfg, cp )) == NULL ){	camserv_log( "camconfig", "Error adding section! (malloc?)");	camconfig_dest( ccfg );	return NULL;      }      continue;    }     /* key-val pair */    if( current_section == NULL ){      camserv_log( "camconfig","Line %d not in a section!", lineno );      continue; /* Non-fatal error */    }    if( sscanf( buf, "%s %[^\n]s", key, value ) != 2 ){      camserv_log( "camconfig", "Malformed input on line %d", lineno );      continue;    }    if( section_add_pair( current_section, key, value ) == -1 ){      camserv_log( "camconfig", "Malloc failure adding key-value pair!" );      camconfig_dest( ccfg );      return NULL;    }  }  return ccfg;}/* * camconfig_set_str:  Set a string value of a key/value pair in the ccfg. * * Arguments:          ccfg = Camconfig struct to set the key/value pair in. *                     section = Section to contain 'key' *                     key  = Key to set (copied in locally) *                     val  = Value associated with the key. (copied in local) * * Return values:      Returns -1 on failure (add to an undefined section, or *                     malloc failure), else 0 on success. */int camconfig_set_str( CamConfig *ccfg, char *secname, char *key, char *val ){  hnode_t *node;  CamConfigSection *section;  /* Can't add to an undefined section! */  if( (node = hash_lookup( ccfg->mainhash, secname )) == NULL )    return -1;    section = hnode_get( node );  return section_add_pair( section, key, val );}/* * camconfig_set_int:  Set an int value of a key/value pair in the ccfg. * * Arguments:          ccfg = Camconfig struct to set the key/value pair in. *                     secname = Section to contain 'key' *                     key  = Key to set (copied in locally) *                     val  = Value associated with the key. * * Return values:      Returns -1 on failure (add to an undefined section, or *                     malloc failure), else 0 on success. */int camconfig_set_int( CamConfig *ccfg, char *secname, char *key, int val ){  char buf[ 1024 ];  sprintf( buf, "%d", val );  return camconfig_set_str( ccfg, secname, key, buf );}/* * camconfig_query_str:  Query a string value from the camconfig structure. * * Arguments:            ccfg = Camconfig struct to get the key/value pair from *                       secname = Section containing 'key' *                       key  = Key of the item * * Return values:        Returns -1 on failure (add to an undefined section, or *                       malloc failure), else 0 on success. */const char *camconfig_query_str( CamConfig *ccfg, char *secname, char *key ){  hnode_t *node;  CamConfigSection *section;  if( (node = hash_lookup( ccfg->mainhash, secname )) == NULL )    return NULL;  section = hnode_get( node );  if( (node = hash_lookup ( section->entryhash, key )) == NULL )    return NULL;  return hnode_get( node );}/* * camconfig_query_int:  Query an int value from the camconfig structure. * * Arguments:            ccfg = Camconfig struct to get the key/value pair from *                       secname = Section containing 'key' *                       key  = Key of the item *                       err  = Location to place an error flag. * * Return values:        On failure, -1 will be returned, and *err will be *                       set to 1, else *err will be 0, and the return value *                       will be a valid integer representation of the value. */int camconfig_query_int( CamConfig *ccfg, char *secname, char *key, int *err){  hnode_t *node;  CamConfigSection *section;  int res;  if( (node = hash_lookup( ccfg->mainhash, secname )) == NULL ){    *err = 1;    return -1;  }  section = hnode_get( node );  if( (node = hash_lookup ( section->entryhash, key )) == NULL ){    *err = 1;    return -1;  }  *err = 0;  sscanf( hnode_get( node ), "%d", &res );  return res;}  /* * camconfig_query_def_float:  Query float value from the camconfig structure, *                             and use a default if it does not exist. * * Arguments:            ccfg = Camconfig struct to get the key/value pair from *                       secname = Section containing 'key' *                       key  = Key of the item *                       def = Default value to return if the key is not found. * * Return values:        On failure, 'def' is returned, else the value  *                       converted to (float) will be returned. */float camconfig_query_def_float( CamConfig *ccfg, char *secname, char *key,				 float def ){  hnode_t *node;  CamConfigSection *section;  if( (node = hash_lookup( ccfg->mainhash, secname )) == NULL ){    camserv_log( "camconfig", "Using default of \"%f\" for [%s]:%s",		 def, secname, key );    return def;  }  section = hnode_get( node );  if( (node = hash_lookup ( section->entryhash, key )) == NULL ){    camserv_log( "camconfig", "Using default of \"%f\" for [%s]:%s",		 def, secname, key );    return def;  }  return atof( hnode_get( node ));}  /* * camconfig_query_def_int:  Query int value from the camconfig structure, *                           and use a default if it does not exist. * * Arguments:            ccfg = Camconfig struct to get the key/value pair from *                       secname = Section containing 'key' *                       key  = Key of the item *                       def = Default value to return if the key is not found. * * Return values:        On failure, 'def' is returned, else the value  *                       converted to (int) will be returned. */int camconfig_query_def_int( CamConfig *ccfg, char *secname, char *key,int def){  int err, res;  res = camconfig_query_int( ccfg, secname, key, &err );  if( err == 1 ){    camserv_log( "camconfig", "Using default of \"%d\" for [%s]:%s",		 def, secname, key );    return def;  }  else     return res;}static void printhash( hash_t *hash ){  hscan_t hs;  hnode_t *hn;  hash_scan_begin(&hs, hash);  while ((hn = hash_scan_next(&hs)))    printf("%s\t%s\n", (char*) hnode_getkey(hn),	   (char*) hnode_get(hn));}static void printcfg( CamConfig *ccfg ){  hscan_t hs;  hnode_t *hn;  hash_scan_begin(&hs, ccfg->mainhash);  while ((hn = hash_scan_next(&hs))){    CamConfigSection *sec;    sec = hnode_get( hn );    printf("-------%s--------\n", sec->section_name );    printhash( sec->entryhash );  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
9191精品国产综合久久久久久| 日韩精品一区二区三区四区视频| 精品无码三级在线观看视频 | 91麻豆精品国产| 亚洲资源中文字幕| 日韩二区在线观看| 成人一区二区在线观看| 99久久99久久精品免费观看| 亚洲精品在线观看网站| 国产午夜亚洲精品不卡| 亚洲四区在线观看| 日欧美一区二区| 色婷婷精品大在线视频| 欧美一区二区在线观看| 玉足女爽爽91| 懂色av中文字幕一区二区三区| 欧美一区二区三区爱爱| 国产一区欧美日韩| 欧美精选午夜久久久乱码6080| 国产精品国产自产拍高清av王其| 蜜臀久久99精品久久久久久9| 91免费看片在线观看| 久久久www免费人成精品| 热久久久久久久| 91麻豆精品国产91久久久久久| 国产在线国偷精品产拍免费yy| 亚洲视频在线一区观看| 在线成人午夜影院| 国产成人自拍在线| 国产欧美精品国产国产专区 | 蜜臀av一区二区三区| 中文字幕av一区二区三区免费看| 免费看黄色91| 国产精品国产三级国产aⅴ中文| 在线观看免费亚洲| 亚洲男人的天堂av| 91一区二区在线| 免费成人在线观看视频| 国产精品二三区| 欧美成人精品高清在线播放| 国产一区二区三区免费播放 | 国产精品久久久久久久蜜臀| 欧美日韩精品福利| 日韩国产欧美在线播放| 国产精品乱子久久久久| 99在线热播精品免费| ...av二区三区久久精品| 91香蕉视频污| 国产乱子伦一区二区三区国色天香| 色拍拍在线精品视频8848| 九九久久精品视频| 午夜av一区二区| 精品国产一区二区三区av性色 | 91精品国产综合久久精品app| 成人免费av在线| 久久国产欧美日韩精品| 中文字幕二三区不卡| 欧美成人女星排行榜| 欧美日韩精品一区二区在线播放| 波多野结衣中文字幕一区二区三区| 亚洲视频狠狠干| 国产日韩欧美一区二区三区乱码| 欧美一级日韩一级| 欧美亚洲高清一区| 亚洲18女电影在线观看| 26uuu精品一区二区在线观看| 成人高清伦理免费影院在线观看| 经典三级一区二区| 毛片av一区二区| 麻豆久久久久久久| 蜜臀av性久久久久蜜臀aⅴ| 日本一区中文字幕| 日韩二区三区四区| 国产精品影视在线观看| 精品一区二区三区免费| 久久99精品久久久久婷婷| 奇米精品一区二区三区四区| 视频一区二区不卡| 日韩精彩视频在线观看| 日韩成人免费电影| 日韩不卡免费视频| 美国毛片一区二区三区| 精品一区二区三区av| 九九热在线视频观看这里只有精品| 久久99国产精品久久99| 国产一区三区三区| 99精品视频一区| 91精品福利在线| 国产一区久久久| 丁香激情综合五月| 91影视在线播放| 欧美精品自拍偷拍动漫精品| 日韩精品一区二区三区在线播放| 久久综合色鬼综合色| 中文一区二区在线观看| 亚洲日本免费电影| 亚洲成人动漫在线免费观看| 男女激情视频一区| 粉嫩绯色av一区二区在线观看| 93久久精品日日躁夜夜躁欧美| 91麻豆精品秘密| 91精品国产欧美一区二区成人| 久久久国际精品| 亚洲人午夜精品天堂一二香蕉| 亚洲成人自拍网| 国产一区二区在线看| 91麻豆swag| 日韩精品一区二| 中文字幕一区在线观看视频| 日欧美一区二区| 不卡的av在线| 欧美一级理论性理论a| 欧洲人成人精品| 精品久久久网站| 亚洲色图清纯唯美| 久久99九九99精品| 99精品国产一区二区三区不卡| 91精品国产入口| 国产精品二区一区二区aⅴ污介绍| 性做久久久久久免费观看| 国产露脸91国语对白| 91久久精品一区二区三| 精品av综合导航| 亚洲一区成人在线| 国产精品99久久久久久久女警| 在线精品视频免费播放| 久久久美女毛片| 日本成人在线电影网| eeuss鲁片一区二区三区在线看| 7777精品伊人久久久大香线蕉的| 国产精品热久久久久夜色精品三区| 日韩激情中文字幕| 99精品欧美一区二区三区小说 | 国产高清精品网站| 911精品国产一区二区在线| 国产精品国产a| 精品中文av资源站在线观看| 欧美日韩一区二区三区视频| 欧美日韩成人综合| 亚洲欧美日韩精品久久久久| 国产麻豆精品在线观看| 欧美一区二区三区视频在线观看| 亚洲欧美欧美一区二区三区| 国产精品一区二区视频| 欧美一区二区三区不卡| 亚洲电影视频在线| 日本乱码高清不卡字幕| 国产精品二区一区二区aⅴ污介绍| 国产在线不卡一卡二卡三卡四卡| 欧美日韩一区二区三区四区| 一区二区三区视频在线看| 日本亚洲免费观看| 欧美午夜精品一区二区蜜桃| 国产精品灌醉下药二区| 成人深夜在线观看| 国产欧美一区二区精品性色| 精彩视频一区二区三区| 欧美不卡一二三| 精品一区二区在线播放| 日韩视频在线你懂得| 日韩国产欧美三级| 91精品国产乱码久久蜜臀| 午夜免费久久看| 在线播放中文一区| 日韩精品一二三四| 欧美一级艳片视频免费观看| 日韩电影在线观看一区| 日韩精品一区二区三区在线播放| 男男gaygay亚洲| 欧美一区二区三级| 美女脱光内衣内裤视频久久网站| 欧美一区二区三区小说| 日韩福利电影在线观看| 欧美成人精品高清在线播放| 国产麻豆视频一区二区| 国产欧美日韩在线| 9色porny自拍视频一区二区| 中文字幕一区在线观看视频| 在线观看日韩电影| 亚洲二区视频在线| 99vv1com这只有精品| 亚洲精品国产一区二区三区四区在线 | 亚洲午夜成aⅴ人片| 欧美日韩一区二区欧美激情 | 亚洲一区二区精品3399| 欧美日韩在线播| 蜜桃久久久久久| 国产精品私房写真福利视频| 91污片在线观看| 日产国产高清一区二区三区| 久久老女人爱爱| 91色porny在线视频| 亚洲高清视频在线| 久久影院午夜片一区| 成人免费视频免费观看| 一区二区三区蜜桃| 日韩精品中文字幕一区| 国产凹凸在线观看一区二区| 亚洲精品免费电影| 精品日韩99亚洲|