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

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

?? appconf.cpp

?? 這是一款2d游戲引擎
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
#include "Core/precomp.h"

/*****************************************************************************\
 * Project:   CppLib: C++ library for Windows/UNIX platfroms                 *
 * File:      config.cpp - implementation of Config class                    *
 *---------------------------------------------------------------------------*
 * Language:  C++                                                            *
 * Platfrom:  any (tested under Windows NT)                                  *
 *---------------------------------------------------------------------------*
 * (c) Karsten Ball黡er & Vadim Zeitlin                                      *
 *     Ballueder@usa.net  Vadim.zeitlin@dptmaths.ens-cachan.fr               *
 *---------------------------------------------------------------------------*
 * Classes:                                                                  *
 *  Config  - manages configuration files or registry database               *
 *---------------------------------------------------------------------------*
 * History:                                                                  *
 *  25.10.97  adapted from wxConfig by Karsten Ball黡er                      *
 *  09.11.97  corrected bug in RegistryConfig::enumSubgroups                 *
 *     --- for further changes see appconf.h or the CVS log ---              *    
\*****************************************************************************/

/**********************************************************************\
 *                                                                    *
 * This library is free software; you can redistribute it and/or      *
 * modify it under the terms of the GNU Library General Public        *
 * License as published by the Free Software Foundation; either       *
 * version 2 of the License, or (at your option) any later version.   *
 *                                                                    *
 * This library 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  *
 * Library General Public License for more details.                   *
 *                                                                    *
 * You should have received a copy of the GNU Library General Public  *
 * License along with this library; if not, write to the Free         *
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
 *                                                                    *
\**********************************************************************/

//static const char
//*cvs_id = "$Id: appconf.cpp,v 1.8 2003/09/05 20:33:06 mbn Exp $";

// MacOSX mostly behaves like unix
#ifdef __APPLE__
#  define __unix__
#endif

// ============================================================================
// headers, constants, private declarations
// ============================================================================

// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------

// standard headers
#ifdef    __WIN32__
#	ifdef  _MSC_VER
    // nonstandard extension used : nameless struct/union
#		pragma warning(disable: 4201)  
#	endif  // VC++

#	include  <windows.h>
#endif    // WIN32

#ifdef	  __unix__
#	include <sys/param.h>
#	include	<sys/stat.h>
#	include <unistd.h>
#	define MAX_PATH	MAXPATHLEN
#endif

#include  <fcntl.h>
#include  <sys/types.h>
#include  <iostream>
#include  <fstream>
#include  <cstring>
#include  <cctype>
#include  <cstdio>
#include  <cstdlib>
#include  <cstdarg>
#include  <cassert>

// our headers
#include  "appconf.h"

// ----------------------------------------------------------------------------
// some debug/error reporting functions
// ----------------------------------------------------------------------------

#if	APPCONF_USE_GETTEXT
#	include	<libintl.h>
#	define	_(x)	dgettext(APPCONF_DOMAIN,x)
#else
#	define	_(x)	(x)
#endif

//using namespace std;

#ifndef   __WXWIN__

// in general, these messages could be treated all differently
// define a standard log function, to be called like printf()
#ifndef LogInfo
#	define   LogInfo     LogError
#endif

// define a standard error log function, to be called like printf()
#ifndef LogWarning
#	define   LogWarning  LogError
#endif

// logs an error message (with a name like that it's really strange)
// message length is limited to 1Kb
void LogError(const char *pszFormat, ...)
{
  char szBuf[1025];

  va_list argptr;
  va_start(argptr, pszFormat);
  vsnprintf(szBuf, 1023, pszFormat, argptr);
  szBuf[1023] = 0;
  va_end(argptr);

  strncat(szBuf, "\n", 1);
  fputs(szBuf, stderr);
}

#endif

#ifdef  __WIN32__

const char *SysError()
{
  static char s_szBuf[1024];

  // get error message from system
  LPVOID lpMsgBuf;
  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                NULL, GetLastError(), 
                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                (LPTSTR)&lpMsgBuf,
                0, NULL);

  // copy it to our buffer and free memory
  strncpy(s_szBuf, (const char *)lpMsgBuf, sizeof(s_szBuf)/sizeof(char));
  LocalFree(lpMsgBuf);

  // returned string is capitalized and ended with '\n' - no good
  s_szBuf[0] = (char)tolower(s_szBuf[0]);
  size_t len = strlen(s_szBuf);
  if ( (len > 0) && (s_szBuf[len - 1] == '\n') )
    s_szBuf[len - 1] = '\0';

  return s_szBuf;
}

#endif

// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
inline size_t Strlen(const char *pc) { return pc == NULL ? 0 : strlen(pc); }
inline Bool   IsValid(char c) { return isalnum(c) || strchr("_/-!.*%", c); }
inline Bool   IsCSym (char c) { return isalnum(c) || ( c == '_');          }
inline size_t Min(size_t n1, size_t n2) { return n1 < n2 ? n1 : n2; }

#define   SIZE(array)       (sizeof(array)/sizeof(array[0]))

#if APPCONF_CASE_SENSITIVE
# define StrCmp(s1,s2)  strcmp((s1),(s2))
#else
# ifdef   __unix__
//strcasecmp is in string.h
#   define  StrCmp(s1,s2)  strcasecmp((s1),(s2))
# else
#   ifdef _MSC_VER
#     define  StrCmp(s1,s2)  _stricmp((s1),(s2))
#   else
#     error "Please define 'stricmp' function for your compiler."
#   endif // compilers
# endif   // strcasecmp/strcimp
#endif

// perform environment variable substitution
char *ExpandEnvVars(const char *psz)
{
  char *szNewValue = new char[strlen(psz)+1];
  strcpy(szNewValue, psz);
  return szNewValue;
  
  // produces internal comp error on rh 5.2 -- mbn
/*
  // don't change the values the enum elements: they must be equal
  // to the matching [closing] delimiter.
  enum Bracket
  { 
    Bracket_None, 
    Bracket_Normal  = ')', 
    Bracket_Curly   = '}' 
  };
          
  // max size for an environment variable name is fixed
  char szVarName[256];

  // first calculate the length of the resulting string
  size_t nNewLen = 0;
  const char *pcIn;
  for ( pcIn = psz; *pcIn != '\0'; pcIn++ ) {
    switch ( *pcIn ) {
      case '$':
        {
          Bracket bracket;
          switch ( *++pcIn ) {
            case '(': 
              bracket = Bracket_Normal; 
              pcIn++;                   // skip the bracket
              break;

            case '{':
              bracket = Bracket_Curly;
              pcIn++;                   // skip the bracket
              break;

            default:
              bracket = Bracket_None;
          }
          const char *pcStart = pcIn;

          while ( IsCSym(*pcIn) ) pcIn++;

          size_t nCopy = Min(pcIn - pcStart, SIZE(szVarName));
          strncpy(szVarName, pcStart, nCopy);
          szVarName[nCopy] = '\0';

          if ( bracket != Bracket_None ) {
            if ( *pcIn != (char)bracket ) {
              // # what to do? we decide to give warning and ignore 
              //   the opening bracket
              LogWarning(_("'%c' expected in '%s' after '${%s'"), 
                         (char)bracket, psz, szVarName);
              pcIn--;
            }
          }
          else {
            // everything is ok but we took one extra character
            pcIn--;
          }

          // Strlen() acceps NULL as well
          nNewLen += Strlen(getenv(szVarName));
        }
        break;

      case '\\':
        pcIn++;
        // fall through

      default:
        nNewLen++;
    }
  }

  // # we always realloc buffer (could reuse the old one if nNewLen < nOldLen)
  char *szNewValue = new char[nNewLen + 1];
  char *pcOut = szNewValue;

  // now copy it to the new location replacing the variables with their values
  for ( pcIn = psz; *pcIn != '\0'; pcIn++ ) {
    switch ( *pcIn ) {
      case '$':
        {
          Bracket bracket;
          switch ( *++pcIn ) {
            case '(': 
              bracket = Bracket_Normal; 
              pcIn++;                   // skip the bracket
              break;

            case '{':
              bracket = Bracket_Curly;
              pcIn++;                   // skip the bracket
              break;

            default:
              bracket = Bracket_None;
          }
          const char *pcStart = pcIn;

          while ( IsCSym(*pcIn) ) pcIn++;

          size_t nCopy = Min(pcIn - pcStart, SIZE(szVarName));
          strncpy(szVarName, pcStart, nCopy);
          szVarName[nCopy] = '\0';

          if ( bracket != Bracket_None ) {
            if ( *pcIn != (char)bracket ) {
              // warning message already given, just ignore opening bracket
              pcIn--;
            }
          }
          else {
            // everything is ok but we took one extra character
            pcIn--;
          }

          const char *pszValue = getenv(szVarName);
          if ( pszValue != NULL ) {
            strcpy(pcOut, pszValue);
            pcOut += strlen(pszValue);
          }
        }
        break;

      case '\\':
        pcIn++;
        // fall through

      default:
        *pcOut++ = *pcIn;
    }
  }

  *pcOut = '\0';

  return szNewValue;
*/
}

// ============================================================================
// implementation of the class BaseConfig
// ============================================================================

// ----------------------------------------------------------------------------
// ctor and dtor
// ----------------------------------------------------------------------------

BaseConfig::BaseConfig()
{
   m_szCurrentPath = NULL;
   m_bRecordDefaults = FALSE;
}

BaseConfig::~BaseConfig()
{
  if ( m_szCurrentPath != NULL )
    delete [] m_szCurrentPath;
}

void
BaseConfig::recordDefaults(Bool enable)
{
   m_bRecordDefaults = enable;
}

// ----------------------------------------------------------------------------
// handle long int and double values
// ----------------------------------------------------------------------------

Bool
BaseConfig::writeEntry(const char *szKey, long int Value)
{
   char buffer[APPCONF_STRBUFLEN]; // ugly
   sprintf(buffer, "%ld", Value);
   return writeEntry(szKey,buffer);
}

Bool
BaseConfig::writeEntry(const char *szKey, double Value)
{
   char buffer[APPCONF_STRBUFLEN]; // ugly
   sprintf(buffer,"%g", Value);
   return writeEntry(szKey,buffer);
}	

long int
BaseConfig::readEntry(const char *szKey, long int Default) const
{
   const char *cptr = readEntry(szKey,(const char *)NULL);
   if(cptr)
      return atol(cptr);
   else
   {
      if(m_bRecordDefaults)
	 ((BaseConfig *)this)->writeEntry(szKey,Default);
      return Default;
   }
}

double
BaseConfig::readEntry(const char *szKey, double Default) const
{
   const char *cptr = readEntry(szKey,(const char *)NULL);
   if(cptr)
      return atof(cptr);
   else
   {
      if(m_bRecordDefaults)
	 ((BaseConfig *)this)->writeEntry(szKey,Default);
      return Default;
   }
}

// ----------------------------------------------------------------------------
// set/get current path
// ----------------------------------------------------------------------------

// this function resolves all ".." (but not '/'!) in the path
// returns pointer to dynamically allocated buffer, free with "delete []"
// ## code here is inefficient and difficult to understand, to rewrite
char *BaseConfig::normalizePath(const char *szStartPath, const char *szPath)
{
  char    *szNormPath;

  // array grows in chunks of this size
#define   COMPONENTS_INITIAL    (10)

  char   **aszPathComponents;   // component is something between 2 '/'
  size_t   nComponents = 0,
           nMaxComponents;

  aszPathComponents = new char *[nMaxComponents = COMPONENTS_INITIAL];

  const char *pcStart;   // start of last component
  const char *pcIn;

  // concatenate the two adding APPCONF_PATH_SEPARATOR to the end if not there
  size_t len = Strlen(szStartPath);
  size_t nOldLen = len + Strlen(szPath) + 1;
  szNormPath = new char[nOldLen + 1];
  strcpy(szNormPath, szStartPath);
  szNormPath[len++] = APPCONF_PATH_SEPARATOR;
  szNormPath[len] = '\0';
  strcat(szNormPath, szPath);

  // break combined path in components
  Bool bEnd = FALSE;
  for ( pcStart = pcIn = szNormPath; !bEnd; pcIn++ ) {
    if ( *pcIn == APPCONF_PATH_SEPARATOR || *pcIn == '\0' ) {
      if ( *pcIn == '\0' )
        bEnd = TRUE;

      // another component - is it "." or ".."?
      if ( *pcStart == '.' ) {
        if ( pcIn == pcStart + 1 ) {
          // "./" - ignore
          pcStart = pcIn + 1;
          continue;
        }
        else if ( (pcIn == pcStart + 2) && (*(pcStart + 1) == '.') ) {
          // "../" found - delete last component
          if ( nComponents > 0 ) {
            delete [] aszPathComponents[--nComponents];
          }
          else {
            LogWarning(_("extra '..' in the path '%s'."), szPath);
          }

          pcStart = pcIn + 1;
          continue;
        }
      }
      else if ( pcIn == pcStart ) {
        pcStart = pcIn + 1;
        continue;
      }

      // normal component, add to the list

      // grow array?
      if ( nComponents == nMaxComponents ) {    
        // realloc array
        char **aszOld = aszPathComponents;
        nMaxComponents += COMPONENTS_INITIAL;
        aszPathComponents = new char *[nMaxComponents];

        // move data
        memmove(aszPathComponents, aszOld, 
                sizeof(aszPathComponents[0]) * nComponents);

        // free old
        delete [] aszOld;
      }

      // do add
      aszPathComponents[nComponents] = new char[pcIn - pcStart + 1];
      strncpy(aszPathComponents[nComponents], pcStart, pcIn - pcStart);
      aszPathComponents[nComponents][pcIn - pcStart] = '\0';
      nComponents++;

      pcStart = pcIn + 1;
    }
  }

  if ( nComponents == 0 ) {
    // special case
    szNormPath[0] = '\0';
  }
  else {
    // put all components together
    len = 0;
    for ( size_t n = 0; n < nComponents; n++ ) {
      // add '/' before each new component except the first one
      if ( len != 0 ) {
        szNormPath[len++] = APPCONF_PATH_SEPARATOR;
      }
      szNormPath[len] = '\0';

      // concatenate
      strcat(szNormPath, aszPathComponents[n]);

      // update length
      len += strlen(aszPathComponents[n]);

      // and free memory
      delete [] aszPathComponents[n];
    }
  }

  delete [] aszPathComponents;

  return szNormPath;
}

void BaseConfig::changeCurrentPath(const char *szPath)
{
  // special case (default value)
  if ( Strlen(szPath) == 0 ) {
    if ( m_szCurrentPath != NULL ) {
      delete [] m_szCurrentPath;
      m_szCurrentPath = NULL;
    }
  }    
  else {
    char *szNormPath;

    // if absolute path, start from top, otherwise from current
    if ( *szPath == APPCONF_PATH_SEPARATOR )
      szNormPath = normalizePath("", szPath + 1);
    else
      szNormPath = normalizePath(m_szCurrentPath ? m_szCurrentPath : "", szPath);

    size_t len = Strlen(szNormPath);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美美女直播网站| 五月天亚洲精品| 色噜噜狠狠色综合中国| 免费观看在线色综合| 国产精品国产三级国产普通话99 | 美女视频一区在线观看| 自拍偷拍欧美精品| 久久久久久久久免费| 欧美日韩精品综合在线| 不卡的av电影在线观看| 亚洲成av人**亚洲成av**| 国产精品久久久久久久久免费樱桃 | 一区二区国产视频| 久久蜜桃香蕉精品一区二区三区| 欧美这里有精品| av电影在线观看不卡| 国模套图日韩精品一区二区 | 极品少妇xxxx精品少妇偷拍| 午夜精品久久久久| 亚洲一区日韩精品中文字幕| 中文字幕巨乱亚洲| 2021国产精品久久精品| 日韩一区二区三免费高清| 欧美性三三影院| 色婷婷精品大在线视频| gogo大胆日本视频一区| 国产精品一区二区在线观看不卡 | 国产精品18久久久| 久久99国产精品久久99| 日韩国产一区二| 天堂av在线一区| 亚洲妇女屁股眼交7| 亚洲一区二区三区自拍| 亚洲狠狠丁香婷婷综合久久久| 椎名由奈av一区二区三区| 国产亚洲欧洲一区高清在线观看| 日韩精品一区二区在线观看| 日韩欧美一区二区在线视频| 欧美一区二区日韩| 欧美va亚洲va| 久久老女人爱爱| 欧美激情自拍偷拍| 亚洲欧美在线aaa| 亚洲免费观看高清完整版在线观看 | 91精品国产综合久久福利| 日韩一级精品视频在线观看| 欧美一区二区三区人| 日韩欧美aaaaaa| 久久久91精品国产一区二区精品 | 日本久久电影网| 欧美伊人久久久久久久久影院| 欧洲人成人精品| 欧美人xxxx| 欧美哺乳videos| 国产色产综合色产在线视频| 中文字幕一区二区三| 夜夜嗨av一区二区三区网页| 午夜精品久久久久久久| 久久99国产精品久久99| 国产91精品露脸国语对白| av午夜一区麻豆| 欧美三级中文字幕在线观看| 欧美一区二区播放| 国产亚洲欧洲一区高清在线观看| 中文字幕佐山爱一区二区免费| 亚洲香蕉伊在人在线观| 老司机午夜精品99久久| 国产**成人网毛片九色| 色噜噜狠狠成人网p站| 欧美一区2区视频在线观看| 久久精子c满五个校花| 亚洲视频一区在线观看| 首页国产丝袜综合| 国产成人亚洲综合a∨婷婷| 色婷婷综合久久久中文一区二区| 欧美欧美欧美欧美首页| 国产视频视频一区| 无码av免费一区二区三区试看 | 日本中文字幕一区| 国产精品123区| 欧美日韩精品三区| 久久精品一区二区三区四区| 亚洲国产综合91精品麻豆| 国内精品国产成人国产三级粉色 | 日韩视频免费观看高清完整版在线观看 | 在线观看国产一区二区| 日韩精品一区二区三区中文不卡 | 成人少妇影院yyyy| 欧美亚洲日本一区| 久久久久久久久久久久久夜| 亚洲成在人线免费| 丁香一区二区三区| 91精品国产一区二区三区香蕉| 国产精品久久久久永久免费观看 | 色综合久久中文字幕综合网| 日韩欧美国产成人一区二区| 亚洲卡通欧美制服中文| 国产传媒欧美日韩成人| 666欧美在线视频| 亚洲精品水蜜桃| 国产成人av福利| 欧美一区二区在线播放| 亚洲人妖av一区二区| 国产乱国产乱300精品| 欧美日韩三级一区二区| 成人欧美一区二区三区1314| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美精品一区在线观看| 日韩高清电影一区| 欧美亚洲另类激情小说| 亚洲欧美一区二区三区国产精品| 黑人巨大精品欧美黑白配亚洲| 欧美另类久久久品| 一区二区三区视频在线看| 99视频精品在线| 欧美国产精品劲爆| 国产99久久久久久免费看农村| 日韩免费一区二区三区在线播放| 亚洲一区二区三区国产| 本田岬高潮一区二区三区| 日韩欧美区一区二| 日韩中文字幕区一区有砖一区| 色综合久久66| 亚洲欧美国产高清| 91色乱码一区二区三区| 日韩一区中文字幕| 91色|porny| 亚洲精品一二三四区| 色婷婷久久久综合中文字幕| 中文字幕五月欧美| 不卡高清视频专区| 1000精品久久久久久久久| 成人深夜视频在线观看| 国产精品色婷婷| 99精品久久99久久久久| 国产精品国产馆在线真实露脸| av电影天堂一区二区在线| 国产精品美女久久久久av爽李琼| 久久国内精品自在自线400部| 4438x亚洲最大成人网| 视频一区二区国产| 日韩视频在线观看一区二区| 日韩高清电影一区| 欧美sm美女调教| 国产成人在线影院| 国产精品国产三级国产普通话99| 99久久伊人久久99| 亚洲男女毛片无遮挡| 欧美日韩一区二区三区不卡| 无码av免费一区二区三区试看| 538在线一区二区精品国产| 免费欧美在线视频| 久久品道一品道久久精品| 春色校园综合激情亚洲| 中文字幕一区二区三区蜜月| 色噜噜夜夜夜综合网| 日韩制服丝袜先锋影音| 欧美va亚洲va香蕉在线| 成人一区二区三区中文字幕| 亚洲精品网站在线观看| 欧美一个色资源| 国产曰批免费观看久久久| 国产精品美女一区二区在线观看| 91丨九色丨尤物| 日韩精品三区四区| 国产日产欧美一区二区三区| 91免费国产在线观看| 日韩中文字幕亚洲一区二区va在线 | 99re热视频这里只精品| 亚洲一区成人在线| 欧美va亚洲va| 91丨porny丨蝌蚪视频| 午夜精品成人在线视频| 久久久久久97三级| 色哟哟欧美精品| 久久不见久久见中文字幕免费| 亚洲欧洲在线观看av| 欧美日本在线播放| 国产成人免费视频精品含羞草妖精| 亚洲视频狠狠干| 精品国内二区三区| 91国偷自产一区二区三区观看| 开心九九激情九九欧美日韩精美视频电影| 久久久亚洲精华液精华液精华液| 99麻豆久久久国产精品免费优播| 日韩成人一级大片| 亚洲人被黑人高潮完整版| 精品国产免费人成在线观看| 99精品黄色片免费大全| 精品一区二区三区在线播放 | 欧美日本一道本| 成人av动漫网站| 国产中文一区二区三区| 亚洲美女在线国产| 国产日韩欧美精品一区| 日韩一区二区三免费高清| 欧美性感一类影片在线播放| 大美女一区二区三区| 蜜臀av性久久久久蜜臀aⅴ流畅 | 亚洲一区免费在线观看|