imgtools/buildrom/src/configpaging.cpp
author William Roberts <williamr@symbian.org>
Fri, 22 Oct 2010 12:33:01 +0100
changeset 651 0d0d83e3702d
parent 600 6d08f4a05d93
permissions -rw-r--r--
Enhance buildrom.pm to enable final OBY file to be converted into acceptable input for buildrom (Bug 3862)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     1
/*
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     2
* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     3
* All rights reserved.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     4
* This component and the accompanying materials are made available
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     6
* which accompanies this distribution, and is available
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     8
*
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     9
* Initial Contributors:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    11
*
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    12
* Contributors:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    13
*
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    14
* Description: 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    15
* @internalComponent * @released
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    16
* configpaging mainfile to do configpaging in buildrom.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    17
*
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    18
*/
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    19
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    20
#include <boost/regex.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    21
#include <string>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    22
#include <iostream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    23
#include <map>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    24
#include <vector>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    25
#include <fstream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    26
#include <malloc.h>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    27
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    28
using namespace std;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    29
using namespace boost ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    30
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    31
typedef const char* const_str ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    32
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    33
static const string NULL_STRING("");
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    34
static const char CONSTANT_UNPAGED[] = "unpaged";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    35
static const char CONSTANT_PAGED[] = "paged";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    36
static const char CONSTANT_UNPAGEDCODE[] = "unpagedcode";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    37
static const char CONSTANT_PAGEDCODE[]	= "pagedcode";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    38
static const char CONSTANT_UNPAGEDDATA[] = "unpageddata";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    39
static const char CONSTANT_PAGEDDATA[] = "pageddata";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    40
#ifdef WIN32 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    41
static const char CONSTANT_CONFIG_PATH[] = "epoc32\\rom\\configpaging\\";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    42
static string epocroot("\\");
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    43
static const char SLASH_CHAR = '\\';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    44
#else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    45
#include <strings.h>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    46
#define strnicmp strncasecmp
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    47
#define _alloca alloca
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    48
static const char CONSTANT_CONFIG_PATH[] = "epoc32/rom/configpaging/";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    49
static string epocroot("/");
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    50
static const char SLASH_CHAR = '/';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    51
#endif 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    52
static const char CONSTANT_CONFIG_FILE[] = "configpaging.cfg" ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    53
#define is_undef(s)		(0 == s.length())
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    54
static const int MAJOR_VERSION = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    55
static const int MINOR_VERSION = 2;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    56
static const int BUILD_NUMBER  = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    57
static const char COPYRIGHT[]="Copyright (c) 2010 Nokia Corporation.";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    58
struct ListElement{  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    59
	const_str code ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    60
	const_str data ;	 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    61
}; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    62
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    63
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    64
static string configlist ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    65
static regex e0("^(file|data|dll|secondary)(=|\\s+)",regex::perl|regex::icase);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    66
static regex e1("^(code|data)?pagingoverride=(.*)\\s*",regex::perl);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    67
static regex e2("^(un)?paged(code|data)?(\\s+(un)?paged(code|data)?)?:",regex::perl);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    68
static regex e3("^include\\s*\"(.*)\"",regex::perl);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    69
static regex e4("(\\S+)(\\s+(un)?paged(code|data)?(\\s+(un)?paged(code|data)?)?)?",regex::perl);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    70
static regex e5("\\b(un)?paged(data)?\\b\\s*$",regex::perl|regex::icase);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    71
static regex e6("\\b(un)?paged(code)?\\b\\s*$",regex::perl|regex::icase); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    72
static regex e7("\\b(un)?paged(code|data)?\\b",regex::perl|regex::icase); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    73
//static regex e8("tool=|\\s+)",regex::perl|regex::icase);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    74
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    75
 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    76
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    77
static bool is_obystatement(const char* aLine) {	 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    78
	if(!strnicmp(aLine,"file",4)|| !strnicmp(aLine,"data",4))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    79
		aLine += 4 ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    80
	else if(!strnicmp(aLine,"dll",3))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    81
		aLine += 3;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    82
	else if(!strnicmp(aLine,"secondary",9))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    83
		aLine += 9 ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    84
	else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    85
		return false ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    86
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    87
	return (*aLine =='=' || *aLine == ' '|| *aLine == '\t');
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    88
 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    89
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    90
static void trim(string& aStr){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    91
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    92
	char* data = const_cast<char*>(aStr.data());
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    93
	int length = aStr.length();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    94
	int firstIndex = 0 ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    95
	int lastIndex = length - 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    96
	// remove ending blanks	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    97
	while(lastIndex >= 0 && (data[lastIndex] == ' ' || data[lastIndex] == '\t')){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    98
		lastIndex -- ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    99
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   100
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   101
	// remove heading blanks	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   102
	while((firstIndex < lastIndex ) && (data[firstIndex] == ' ' || data[firstIndex] == '\t')){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   103
		firstIndex ++ ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   104
	}	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   105
	lastIndex++ ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   106
	if(lastIndex < length){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   107
		aStr.erase(lastIndex,length - lastIndex);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   108
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   109
	if(firstIndex > 0){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   110
		aStr.erase(0,firstIndex);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   111
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   112
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   113
static void make_lower(char* aStr,size_t aLength){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   114
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   115
	for(size_t i = 0 ; i < aLength ; i++){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   116
		if(aStr[i] >= 'A' && aStr[i] <= 'Z')
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   117
			aStr[i] |= 0x20 ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   118
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   119
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   120
static bool readConfigFile(const_str& aCodePagingRef, const_str& aDataPagingRef,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   121
		map<string,ListElement>& aListRef, const_str aFileName ) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   122
	ifstream is(aFileName, ios_base::binary | ios_base::in);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   123
	if(!is.is_open()){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   124
		cerr<< "Can not open \""<< aFileName << "\" for reading.\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   125
		return false ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   126
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   127
	const_str filecodepaging = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   128
	const_str filedatapaging = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   129
	match_results<string::const_iterator> what;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   130
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   131
	is.seekg(0,ios::end);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   132
	size_t size = is.tellg();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   133
	is.seekg(0,ios::beg);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   134
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   135
	char *buf = new char[size + 1];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   136
	is.read(buf,size);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   137
	buf[size] = '\n' ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   138
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   139
	char* end = buf + size ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   140
	char* lineStart = buf ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   141
	int lfcr ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   142
	string line ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   143
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   144
	while(lineStart < end ){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   145
		// trim left ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   146
		while(*lineStart == ' ' || *lineStart == '\t' ){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   147
			lineStart++ ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   148
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   149
		char* lineEnd = lineStart;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   150
		while(*lineEnd != '\r' && *lineEnd != '\n'){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   151
			lineEnd++ ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   152
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   153
		if(*lineEnd == '\r' && lineEnd[1] == '\n')
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   154
			lfcr = 2 ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   155
		else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   156
			lfcr = 1 ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   157
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   158
		*lineEnd = 0 ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   159
		// empty line or comment
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   160
		if(lineEnd == lineStart || *lineStart == '#' ){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   161
			lineStart = lineEnd + lfcr ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   162
			continue ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   163
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   164
		size_t lenOfLine = lineEnd - lineStart;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   165
		make_lower(lineStart,lenOfLine);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   166
		line.assign(lineStart,lenOfLine);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   167
			
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   168
		if(regex_search(line, what, e1)){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   169
			string r1 = what[1].str();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   170
			string r2 = what[2].str(); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   171
			if(is_undef(r1)){ //if ($1 eq undef)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   172
				if(r2 == "defaultpaged"){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   173
					aCodePagingRef = CONSTANT_PAGED ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   174
				} else if(r2 == "defaultunpaged"){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   175
					aCodePagingRef = CONSTANT_UNPAGED ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   176
					aDataPagingRef = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   177
				}else{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   178
					cerr << "Configpaging Warning: invalid pagingoverride setting: "<< r2 <<"\n" ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   179
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   180
			}else if(r1 == "code"){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   181
				if(r2 == "defaultpaged"){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   182
					aCodePagingRef = CONSTANT_PAGED ; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   183
				} else if(r2 == "defaultunpaged"){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   184
					aCodePagingRef = CONSTANT_UNPAGED ; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   185
				}else{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   186
					cerr << "Configpaging Warning: invalid codepagingoverride setting: "<< r2 <<"\n" ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   187
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   188
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   189
			else if(r1 == "data" ){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   190
				if(r2 == "defaultpaged"){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   191
					aDataPagingRef = CONSTANT_PAGED ; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   192
				} else if(r2 == "defaultunpaged"){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   193
					aDataPagingRef = CONSTANT_UNPAGED ; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   194
				}else{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   195
					cerr << "Configpaging Warning: invalid datapagingoverride setting: "<< r2 <<"\n" ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   196
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   197
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   198
		}// check e1
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   199
		else if(regex_search(line, what, e2)){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   200
			string r1 = what[1].str();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   201
			string r2 = what[2].str();	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   202
			string r3 = what[3].str();	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   203
			string r4 = what[4].str();	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   204
			string r5 = what[5].str();   
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   205
			filecodepaging = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   206
			filedatapaging = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   207
			if (is_undef(r1)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   208
				if (is_undef(r2)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   209
					filecodepaging = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   210
				}else if (r2 == "code") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   211
					filecodepaging = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   212
				} else if(r2 == "data") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   213
					filedatapaging = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   214
				} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   215
					cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   216
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   217
			} else if (r1 == "un"){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   218
				if (is_undef(r2)) { //$2 eq undef
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   219
					filecodepaging = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   220
					filedatapaging = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   221
				}else if (r2 == "code") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   222
					filecodepaging = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   223
				} else if(r2 == "data") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   224
					filedatapaging = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   225
				} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   226
					cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   227
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   228
			} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   229
				cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   230
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   231
			if (r3.length() > 0){		//$3 ne undef
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   232
				if (is_undef(r4)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   233
					if (is_undef(r5)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   234
						filecodepaging = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   235
					}else if (r5 == "code") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   236
						filecodepaging = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   237
					} else if(r5 == "data") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   238
						filedatapaging = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   239
					} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   240
						cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   241
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   242
				} else if (r4 == "un") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   243
					if (is_undef(r5)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   244
						filecodepaging = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   245
						filedatapaging = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   246
					}else if (r5 == "code") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   247
						filecodepaging = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   248
					} else if(r5 == "data") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   249
						filedatapaging = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   250
					} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   251
						cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   252
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   253
				} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   254
					 cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   255
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   256
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   257
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   258
		else if(regex_search(line, what, e3)){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   259
			string filename = epocroot + CONSTANT_CONFIG_PATH;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   260
			filename += what[1].str();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   261
			readConfigFile(aCodePagingRef, aDataPagingRef, aListRef, filename.c_str()); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   262
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   263
		else if(regex_search(line, what, e4)){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   264
			string r1 = what[1].str();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   265
			string r2 = what[2].str();	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   266
			string r3 = what[3].str();	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   267
			string r4 = what[4].str();	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   268
			string r5 = what[5].str();	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   269
			string r6 = what[6].str();	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   270
			string r7 = what[7].str(); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   271
			ListElement element = {aCodePagingRef, aDataPagingRef};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   272
			if (is_undef(r2)){ //($2 eq undef){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   273
				if (0 != *filecodepaging){//filecodepaging ne "") 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   274
					element.code = filecodepaging;	//$element{code} = $filecodepaging;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   275
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   276
				if ( 0 != *filedatapaging){//$filedatapaging ne "") 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   277
					element.data = filedatapaging ;//element.data = $filedatapaging;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   278
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   279
			} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   280
				if (is_undef(r4)){//$4 eq undef
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   281
					if (is_undef(r3)) {//$3 eq undef
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   282
						element.code = CONSTANT_PAGED; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   283
					} else if (r3 == "un") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   284
						element.code = CONSTANT_UNPAGED; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   285
						element.data = CONSTANT_UNPAGED; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   286
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   287
				} else if (r4 == "code") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   288
					if (is_undef(r3)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   289
						element.code = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   290
					} else if (r3 == "un") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   291
						element.code = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   292
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   293
				} else if (r4 == "data") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   294
					if (is_undef(r3)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   295
						element.data = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   296
					} else if (r3 == "un") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   297
						element.data = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   298
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   299
				} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   300
					cerr << "Configpaging Warning: unrecognized attribute in line: "<< lineStart << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   301
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   302
				if (r5.length() > 0){//$5 ne undef
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   303
					if (is_undef(r7)){ //$7 eq undef
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   304
						if (is_undef(r6)) { //$6 eq undef
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   305
							element.code = CONSTANT_PAGED; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   306
						} else if (r6 == "un") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   307
							element.code = CONSTANT_UNPAGED; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   308
							element.data = CONSTANT_UNPAGED; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   309
						}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   310
					} else if (r7 == "code") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   311
						if (is_undef(r6)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   312
							element.code = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   313
						} else if (r6 == "un") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   314
							element.code = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   315
						}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   316
					} else if (r7 == "data") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   317
						if (is_undef(r6)) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   318
							element.data = CONSTANT_PAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   319
						} else if (r6 == "un") {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   320
							element.data = CONSTANT_UNPAGED;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   321
						}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   322
					} else {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   323
						cerr << "Configpaging Warning: unrecognized attribute in line: "<< lineStart << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   324
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   325
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   326
			}	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   327
			//$$listref{$1} = \%element;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   328
			aListRef.insert(pair<string,ListElement>(r1,element));
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   329
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   330
		lineStart = lineEnd + lfcr ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   331
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   332
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   333
	delete []buf ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   334
	is.close(); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   335
	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   336
	return true ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   337
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   338
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   339
static bool match_icase(const string& a, const string& b){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   340
	int la = a.length();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   341
	int lb = b.length();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   342
	char *copyOfA = (char*)_alloca(la+2);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   343
	*copyOfA = ' ';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   344
	copyOfA++ ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   345
	memcpy(copyOfA ,a.c_str(),la);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   346
	copyOfA[la] = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   347
	char* end = &copyOfA[la];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   348
	make_lower(copyOfA,la);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   349
	while(copyOfA < end){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   350
		char *found = strstr(copyOfA,b.c_str()); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   351
		if(0 == found)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   352
			return false ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   353
		if((found[-1] == ' ' || found[-1] == '\\'|| found[-1] == '/'|| found[-1] == '\t' || found[-1] == '"'|| found[-1] == '=') &&
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   354
					( found[lb] == ' '|| found[lb] == '\t' || found[lb] == '"'|| found[lb] == '\0'))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   355
			return true ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   356
		copyOfA = found + lb ;		 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   357
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   358
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   359
	return false ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   360
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   361
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   362
static void configpaging_single(){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   363
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   364
	const_str codepaging="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   365
	const_str datapaging="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   366
	map<string, ListElement> list ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   367
	vector<string> keys ;//my @keys;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   368
    string line ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   369
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   370
	cerr << "configpaging.exe: Modifying demand paging configuration using "<< configlist <<"\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   371
	readConfigFile(codepaging, datapaging, list, configlist.c_str());
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   372
	match_results<string::const_iterator> what;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   373
	string codepagingadd ,datapagingadd ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   374
	while(true){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   375
		getline(cin,line); 		 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   376
		if(cin.eof()) break ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   377
		if(line == ":q") break ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   378
		trim(line);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   379
		const char* lineData = line.data();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   380
		if(*lineData == '#' ){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   381
			cout << lineData << "\n" ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   382
			continue ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   383
		}		 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   384
		int length = line.length();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   385
		if( length > 2){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   386
			//check rem 			
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   387
			if((lineData[0] == 'R' || lineData[0] == 'r' ) && (lineData[1] == 'E' || lineData[1] == 'e' ) && (lineData[2] == 'M' || lineData[2] == 'm' )){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   388
				cout << lineData << "\n" ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   389
				continue ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   390
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   391
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   392
		codepagingadd = "";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   393
		datapagingadd = ""; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   394
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   395
		if(is_obystatement(lineData)){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   396
			for( map<string,ListElement>::iterator it  = list.begin() ; it != list.end() ; it++){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   397
				if(match_icase(line,it->first) ){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   398
					if (it->second.code == CONSTANT_PAGED ){ 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   399
						codepagingadd += " " ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   400
						codepagingadd += CONSTANT_PAGEDCODE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   401
					} else if (it->second.code == CONSTANT_UNPAGED) {  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   402
						codepagingadd += " " ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   403
						codepagingadd += CONSTANT_UNPAGEDCODE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   404
					} 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   405
					if (it->second.data == CONSTANT_PAGED) {  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   406
						datapagingadd += " " ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   407
						datapagingadd += CONSTANT_PAGEDDATA;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   408
					} else if  (it->second.data == CONSTANT_UNPAGED) {  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   409
						datapagingadd += " " ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   410
						datapagingadd += CONSTANT_UNPAGEDDATA;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   411
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   412
					break ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   413
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   414
			}//for 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   415
			if (codepagingadd.length() == 0 && 0 != *codepaging) {//!$codepagingadd and $codepaging
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   416
				codepagingadd = " " ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   417
				codepagingadd += codepaging ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   418
				codepagingadd += "code";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   419
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   420
			if (datapagingadd.length() == 0 &&  0 != *datapaging) { //!$datapagingadd and $datapaging
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   421
				datapagingadd = " " ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   422
				datapagingadd += datapaging ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   423
				datapagingadd += "data";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   424
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   425
			if (codepagingadd.length() > 0 && datapagingadd.length() == 0){ //$codepagingadd and !$datapagingadd
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   426
				if (regex_search(line,what,e5)){  //$line =~ /\b(un)?paged(data)?\b\s*$/) { //$line =~ /\b(un)?paged(data)?\b\s*$/
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   427
					datapagingadd = " " ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   428
					if(what[1].length() > 0)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   429
					{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   430
						datapagingadd += what[1].str();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   431
						datapagingadd += "pageddata";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   432
					}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   433
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   434
			} else if (datapagingadd.length() > 0 && codepagingadd.length() == 0) {//$datapagingadd and !$codepagingadd
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   435
				if (regex_search(line,what,e6)){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   436
					codepagingadd = " " ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   437
					codepagingadd += what[1].str();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   438
					codepagingadd += "pagedcode";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   439
				}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   440
			}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   441
			if (datapagingadd.length() > 0 || datapagingadd.length() > 0) { // $datapagingadd or $datapagingadd
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   442
				line = regex_replace(line,e7,NULL_STRING);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   443
			} 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   444
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   445
		cout << line << codepagingadd << datapagingadd  << "\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   446
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   447
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   448
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   449
// 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   450
int main(int argc , char* argv[]) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   451
 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   452
	char* tmp = getenv("EPOCROOT"); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   453
	if(tmp && *tmp)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   454
		epocroot = string(tmp);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   455
	char ch = epocroot.at(epocroot.length() - 1);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   456
	if(ch != '\\' && ch != '/')
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   457
		epocroot += SLASH_CHAR;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   458
	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   459
	if(argc > 1 ){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   460
		char* arg = argv[1];
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   461
		if('-' == *arg && (arg[1] | 0x20) == 'v'){
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   462
			cout << "configpaging - The paging configuration plugin for BUILDROM V" ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   463
			cout << MAJOR_VERSION << "."<< MINOR_VERSION << "." << BUILD_NUMBER<< endl;			
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   464
			cout << COPYRIGHT << endl << endl; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   465
			return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   466
		}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   467
		configlist = epocroot + CONSTANT_CONFIG_PATH; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   468
		configlist += string(arg);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   469
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   470
	else{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   471
		configlist = epocroot + CONSTANT_CONFIG_PATH;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   472
		configlist += CONSTANT_CONFIG_FILE;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   473
	}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   474
	configpaging_single(); 	
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   475
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   476
	return 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   477
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   478