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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? configfile.cpp

?? This is a pgm can be used for astronomy
?? CPP
字號(hào):
/*--------------------------------------------------------------------------*\
 * ConfigFile class
 *
 * Input file consists of lines of text of the form
 *   name = value
 * where 'name' is the look up key and 'value' is the resultant value
 *
 * '\' is the escape character and allows values to contain embedded '"' and
 *   '#' characters.
 * To put '"' in a value use '\"'.  To put '\' in a value use '\\'.
 *
 * '\' is also the line continuation char.  If '\' is the last character on
 *   a line, the following line will be appended to that line before the
 *   line is processed.
 *
 * Anything in double quotes is copied literally, except '\', as described
 *   above.
 *
 * Outside of double quotes:
 *   '#' starts a comment; the rest of the line is ignored
 *   White space is ignored
 *
 *--------------------------------------------------------------------------
 *
 * Created by Mark Huss <mark@mhuss.com>
 *
 * Developed and built using the mingw32 gcc compiler 2.95.2
 *
 * THIS SOFTWARE IS NOT COPYRIGHTED
 *
 * This source code is offered for use in the public domain. You may
 * use, modify or distribute it freely.
 *
 * This code is distributed in the hope that it will be useful but
 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 * DISCLAMED. This includes but is not limited to warranties of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
\*--------------------------------------------------------------------------*/

#include "ConfigFile.h"

using namespace std;

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//----------------------------------------------------------------------------
// CFList methods
//----------------------------------------------------------------------------

// C++ version of strdup()
//
char* CFList::strDup( const char* s ) {
  char* p = 0;
  if (s) if (*s) {
    p = new char[strlen(s)+1];
    if (p)
      strcpy( p, s );
  }
  return p;
}

// add a name/value pair to the list
//
void CFList::add(const char* name, const char* value) {
  if (name) if (*name) if (value) if (*value) {
    CFList* p = this;
    while ( 0 != p->m_next)
      p=p->m_next;

    p->m_next = new CFList( name, value );
  }
}

// update the value of a name/value pair in the list
// if name is not found, does an add()
//
void CFList::update(const char* name, const char* value) {
  if (name) if (*name) {
    CFList* p = this;
    bool found=false;

    while (0 != p && !found) {
      if ( !strcmp(p->m_name, name) ) {
        found = true;
        delete [] p->m_value;
        p->m_value = strDup(value);
      }
      p = p->m_next;
    }
    if ( !found )
      add( name, value );
  }
}

// get the string value that corresponds the the spec'd name
// returns null string if not found
// ALWAYS RETURNS A VALID POINTER
//
const char* CFList::value(const char* name) const {
  const CFList* p = this;
  const char* pVal = "";
  if (name) if (*name) {
    while (0 != p) {
      if ( !strcmp(p->m_name, name) ) {
        if ( p->m_value )
          pVal = p->m_value;
        break;
      }
      p = p->m_next;
    }
  }
  return pVal;
}

// get the boolean value that corresponds the the spec'd name
// returns false if not found
//
bool CFList::boolValue(const char* name) const {
  const char* p = value( name );
  return ( 't' == *p || 'T' == *p || ('1' == *p && 0 == *(p+1)) );
}

// get the int value that corresponds the the spec'd name
// returns 0 if not found
//
int CFList::intValue(const char* name) const {
  const char* p = value( name );
  return (*p) ? atoi( p ) : 0;
}

// get the double value that corresponds the the spec'd name
// returns 0.0 if not found
//
double CFList::dblValue(const char* name) const {
  const char* p = value( name );
  return (*p) ? atof( p ) : 0.;
}

// output all keys and values
//
void CFList::dump( FILE* fp ) const {
  const CFList* p = this;
  while ( 0 != p ) {
    fprintf( fp, "%s = %s\n", p->m_name, p->m_value );
    p=p->m_next;
  }
}

//----------------------------------------------------------------------------
// ConfigFile methods
//----------------------------------------------------------------------------

bool ConfigFile::debug = false;

//----------------------------------------------------------------------------
// compact input buffer (one line of the input file)
// eat white space, deal with quoted strings & escaped characters
//
bool ConfigFile::compactBuffer(char* buffer) {
  char* from = buffer;
  while ( (*from) > 0 && (*from) <= ' ' ) {
    from++;
  }
  // skip 'whole line' comments and blank lines
  if ( COMMENT_CHAR == (*from) || 0 == (*from) )
    return false;

  char* to = buffer;
  bool inQuotes = false;

  while ( *from ) {
    char c = *from++;
    if ( ESC_CHAR == c ) {           // deal with escaped chars
      if ( *from )
        *to++ = *from++;
    }
    else if ( c < ' ' )             // skip \n, etc.
      continue;
    else if ( QUOTE_CHAR == c ) {   // toggle quote flag
      inQuotes = !inQuotes;
      *to++ = c;
    }
    else {
      if ( inQuotes )               // if in quotes, copy everything
        *to++ = c;
      else {                        // outside of quotes,
        if ( c <= ' ' )               // if white space, skip it
          ;
        else if ( COMMENT_CHAR == c ) // if comment, ignore rest of line
          break;
        else                        // none of the above, just copy it
          *to++ = c;
      }
    }
  }
  *to = 0;

  if( debug )
    fprintf( stderr, "    compacted line: '%s'\n", buffer);

  return true;
}

//----------------------------------------------------------------------------
// load names & values from the input file
//
int ConfigFile::readAndParseFile( const char* fname ) {
  if( debug ) {
    fprintf( stderr, "> readAndParseFile( %s )\n", fname );
  }

  m_status = NO_ENTRIES;

  m_filename = fname;

  // check for filename
  //
  if ( !fname ) {
    m_status = INVALID_FILE_NAME;
    return m_status;
  }

  // open & read file
  //
  FILE* fp = fopen( m_filename, "r" );
  if ( !fp ) {
    m_status = FILE_NOT_FOUND;
    return m_status;
  }

  char buffer[BUFSIZE];

  while ( true ) {
    memset( buffer, 0, BUFSIZE );

    if ( 0 == fgets( buffer, BUFSIZE, fp ) )
      break;

    // check for and handle line continuation chars
    int len = strlen( buffer );
    while ( true ) {
      char* pEol = &buffer[len-1];
      if ( ESC_CHAR == *pEol ) {
        if ( 0 == fgets( buffer, BUFSIZE, fp ) ) {
          *pEol = 0;
          break;
        }
      }
      else
        break;
    }
    // lose EOL
    if ( buffer[len] <= ' ' )
      buffer[len] = 0;

    if( debug )
      fprintf( stderr, "    original line: '%s'\n", buffer );

    // compact input buffer
    // eat white space, deal with quoted strings & escaped characters
    //
    if (false ==compactBuffer(buffer))
      continue;  // false means empty buffer

    // parse name/value pair and add to Hashtable
    //
    char* line = buffer;

    // minimum valid length is 3 ( 'a=b' )
    if ( strlen(line) >= 3 ) {

      // look for separator
      char* sepIndex = strchr( line, NV_SEP_CHAR );
      if (0 != sepIndex) {
        // separator char found, split into name/value
        int nameLen = sepIndex-line;
        char name[BUFSIZE];
        char value[BUFSIZE];
        memcpy( name, line, nameLen );
        name[nameLen] = 0;
        strcpy( value, sepIndex+1 );

        // remove quote chars from quoted values
        int vlen = strlen(value);
        if ( vlen > 2 &&   // minimum valid length is 3 ( '"c"' )
            QUOTE_CHAR == value[0] &&     // starts with '"'
            QUOTE_CHAR == value[vlen-1] ) // ends with '"'
        {
          strncpy(value, value+1, vlen-2 );  // cut off both ends
          value[vlen-2] = 0;
        }

        if( debug ) {
          fprintf(stderr, "    name='%s', value='%s'\n", name, value);
        }

        // add name/value pair

        m_items.add( name, value );
      }
      // ignore lines with no separators for now
    }
  }
  m_items.update( "ConfigFile", fname );
  m_status = OK;

  return m_status;
}

#if defined(UNIT_TEST)
//----------------------------------------------------------------------------
// unit test bed
//
int main( int argc, char** argv ) {

  ConfigFile cf;
  //cf.debug = true;
  int rc = 0;

  if ( argc > 1 ) {
    cf.filename( argv[1] );
    cf.dump( stdout );
  }
  else {
    fprintf( stderr, "usage: %s <config file>\n", argv[0] );
    rc = 1;
  }

  return rc;

} // end function main()

//----------------------------------------------------------------------------

#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品区一区二区三| 欧美丰满少妇xxxxx高潮对白| 免费在线观看一区| 色狠狠一区二区| 成人福利视频在线看| 成人午夜大片免费观看| 成人高清视频免费观看| 99视频一区二区| 91在线无精精品入口| 91福利在线导航| 欧美日韩精品一区二区在线播放| 欧美日韩免费一区二区三区| 欧美精品丝袜中出| 久久影院视频免费| 日韩一区欧美一区| 亚洲一区二区三区在线| 日日噜噜夜夜狠狠视频欧美人| 青青草成人在线观看| 国内精品视频666| 成人avav在线| 欧美人与禽zozo性伦| 欧美成人a∨高清免费观看| 久久久久久一二三区| 国产精品不卡在线观看| 亚洲高清一区二区三区| 狠狠色狠狠色综合系列| 不卡的av网站| 日韩免费视频线观看| 1000精品久久久久久久久| 亚洲综合在线视频| 久久99国产精品成人| 色婷婷国产精品综合在线观看| 91精品国产色综合久久不卡电影 | 欧美日产国产精品| 精品伦理精品一区| 一区二区三区欧美| 精品亚洲成a人| 92精品国产成人观看免费| 欧美精品久久久久久久久老牛影院| 精品国产乱码久久久久久久久| 综合在线观看色| 国内精品伊人久久久久av影院 | 色综合久久九月婷婷色综合| 欧美一区二区女人| 亚洲免费在线视频一区 二区| 免费观看日韩av| 色婷婷国产精品综合在线观看| 日韩成人精品视频| 粉嫩av一区二区三区粉嫩| 在线播放国产精品二区一二区四区 | jlzzjlzz亚洲日本少妇| 久久疯狂做爰流白浆xx| 91官网在线观看| 国产日本欧美一区二区| 日本在线不卡视频一二三区| 色天天综合色天天久久| 国产欧美精品区一区二区三区| 青娱乐精品视频在线| 欧美影院一区二区| 中文字幕欧美一区| 国产精品18久久久久久久久久久久| 欧美日韩国产综合久久| 亚洲男同1069视频| av激情成人网| 国产精品久久久久久久久久久免费看| 精品综合久久久久久8888| 7777精品伊人久久久大香线蕉完整版 | 中文字幕欧美日本乱码一线二线| 青娱乐精品在线视频| 欧美精品少妇一区二区三区| 亚洲综合免费观看高清完整版在线 | 国产精品国产三级国产普通话三级 | 欧洲亚洲精品在线| 亚洲日本免费电影| 91亚洲午夜精品久久久久久| 国产精品每日更新| www..com久久爱| 亚洲色欲色欲www| 99久精品国产| 一区二区三区四区亚洲| 欧美视频一区在线| 丝袜脚交一区二区| 欧美mv日韩mv国产网站app| 精品一区二区三区久久久| 日韩精品在线一区| 国产一区二区不卡在线| 国产精品久久久久久久午夜片| 成人免费毛片片v| 精品一区二区三区蜜桃| 久久综合久久久久88| 大美女一区二区三区| 亚洲丝袜自拍清纯另类| 欧美在线看片a免费观看| 日韩电影免费在线观看网站| 欧美sm美女调教| www.成人在线| 亚洲国产视频一区| 精品对白一区国产伦| 粉嫩av亚洲一区二区图片| 亚洲一区二区三区在线播放| 久久午夜免费电影| 久久99久久99| 欧美午夜理伦三级在线观看| 欧美一区二区私人影院日本| 国产日韩欧美精品综合| 亚洲国产sm捆绑调教视频| 蜜臀av一区二区三区| thepron国产精品| 精品国产污污免费网站入口 | 欧美性大战久久久久久久| 亚洲色图制服丝袜| 69堂精品视频| 成人免费视频一区二区| 亚洲高清在线视频| 中文字幕高清不卡| 欧美裸体一区二区三区| 国产99久久精品| 亚洲高清视频中文字幕| 中文字幕乱码亚洲精品一区| 欧美二区三区的天堂| 成人黄色电影在线| 美女看a上一区| 一区二区三区蜜桃| 国产欧美一区二区三区网站| 在线不卡的av| 在线观看免费一区| 国产一区二区三区久久悠悠色av| 亚洲自拍偷拍综合| 国产精品美女久久福利网站| 日韩一区二区免费在线观看| 日本大香伊一区二区三区| 国产精品一区不卡| 老司机免费视频一区二区| 玉米视频成人免费看| 久久久精品tv| 久久综合给合久久狠狠狠97色69| 在线欧美日韩国产| 91一区二区三区在线观看| 国产成人av电影在线| 国产精品一色哟哟哟| 美女视频一区二区| 日韩中文字幕一区二区三区| 一区二区成人在线观看| 亚洲欧洲日韩av| 日本一区二区动态图| 欧美经典一区二区三区| 久久久久久久综合| 日韩欧美一级二级| 日韩欧美成人激情| 精品国产乱子伦一区| 欧美精品一区二| 久久众筹精品私拍模特| 26uuu亚洲综合色欧美| www国产亚洲精品久久麻豆| 欧美哺乳videos| 久久精品夜夜夜夜久久| 国产女人18毛片水真多成人如厕| 国产色产综合色产在线视频| 久久久久国产成人精品亚洲午夜 | 在线免费观看视频一区| 成人av在线电影| 一区二区三区在线播| 成人午夜碰碰视频| 欧美日韩一级片网站| 99综合影院在线| 成人免费毛片a| 色综合久久久久久久| 在线观看免费亚洲| 91麻豆国产自产在线观看| 日本精品一区二区三区高清| 97久久精品人人做人人爽| 一本高清dvd不卡在线观看| 成人午夜在线免费| 91精品国产免费| 亚洲线精品一区二区三区八戒| 亚洲精品成人天堂一二三| 亚洲成av人影院| 韩国毛片一区二区三区| 成人黄色在线网站| 欧美日韩国产区一| 精品第一国产综合精品aⅴ| 国产精品日韩精品欧美在线| 一区二区三区精品视频| 麻豆视频观看网址久久| 国产成人日日夜夜| 日本韩国欧美三级| 日韩免费看的电影| 日韩理论片中文av| 免费av成人在线| 91丝袜国产在线播放| 在线观看视频一区二区| 国产麻豆精品视频| 国产午夜久久久久| 久久精品久久99精品久久| 成人av电影在线播放| 欧美日韩dvd在线观看| 国产精品污www在线观看| 日韩电影在线观看网站| 91在线观看高清| 久久日一线二线三线suv|