Browse CVS Repository
Contents of /hos/tools/cvssync/ReadConfig.cpp
Parent Directory
| Revision Log
| Revision Graph
Revision 1.2 -
( show annotations)
( download)
( as text)
Sat Jul 27 04:48:31 2002 UTC
(21 years, 8 months ago)
by ryuz
Branch: MAIN
CVS Tags: ver_0_04, HEAD
Changes since 1.1: +3 -3 lines
File MIME type: text/x-c++src
change copyright
| 1 |
// --------------------------------------------------------------------------- |
| 2 |
// 設定ファイル読み込み |
| 3 |
// |
| 4 |
// Copyright (C) 2002 by Project HOS |
| 5 |
// --------------------------------------------------------------------------- |
| 6 |
|
| 7 |
|
| 8 |
#include <windows.h> |
| 9 |
#include <tchar.h> |
| 10 |
#include <stdio.h> |
| 11 |
#include "ReadConfig.h" |
| 12 |
|
| 13 |
|
| 14 |
#define READCFG_MAX_LINE 256 |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
// 設定ファイル読み込み |
| 19 |
void ReadConfig(LPCTSTR szFileName, CAssociationVector* pAscVect) |
| 20 |
{ |
| 21 |
TCHAR szIndex[READCFG_MAX_LINE] = _T(""); |
| 22 |
TCHAR szBuf[READCFG_MAX_LINE]; |
| 23 |
FILE* fp; |
| 24 |
|
| 25 |
// ファイルオープン |
| 26 |
if ( (fp = _tfopen(szFileName, "r")) == NULL ) |
| 27 |
{ |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
// 読み込み |
| 32 |
while ( _fgetts(szBuf, READCFG_MAX_LINE, fp) != NULL ) |
| 33 |
{ |
| 34 |
// 1行が長すぎたら終わる |
| 35 |
int iLen = lstrlen(szBuf); |
| 36 |
if ( iLen >= 0 && szBuf[iLen - 1] != _T('\n') ) |
| 37 |
{ |
| 38 |
break; |
| 39 |
} |
| 40 |
|
| 41 |
// 後続の空白文字削除 |
| 42 |
while ( iLen > 0 && _istspace(szBuf[iLen - 1]) ) |
| 43 |
{ |
| 44 |
iLen--; |
| 45 |
} |
| 46 |
szBuf[iLen] = _T('\0'); |
| 47 |
|
| 48 |
if ( iLen > 3 && szBuf[0] == _T('[') && szBuf[iLen - 1] == _T(']') ) |
| 49 |
{ |
| 50 |
// インデックス設定 |
| 51 |
lstrcpy(szIndex, szBuf); |
| 52 |
} |
| 53 |
else if ( szIndex[0] != _T('\0') ) |
| 54 |
{ |
| 55 |
// 空行でなければ連想配列に追加 |
| 56 |
if ( szBuf[0] != _T('\0') ) |
| 57 |
{ |
| 58 |
pAscVect->Add(szIndex, szBuf); |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
// ファイルクローズ |
| 64 |
fclose(fp); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
// --------------------------------------------------------------------------- |
| 69 |
// Copyright (C) 2002 by Ryuji Fuchikami |
| 70 |
// --------------------------------------------------------------------------- |
|