# HG changeset patch # User jjkang # Date 1277868958 -28800 # Node ID 378360dbbdba5b53de544eed739c3fdbca92ce96 # Parent 22486c9c7b151ce9b2f704f6bf380f4c5de07f2e# Parent 30b30f9da0b71bf7b823e13895ef393d6f1d37dd Merge missed changeset 11 (raptor v2.14 and helium 10.0) diff -r 22486c9c7b15 -r 378360dbbdba bintools/bin2coff/bin2coff.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/bin2coff/bin2coff.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,149 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Add a simple coff header to a binary file +// optionally strip off the first 256 bytes +// This is primarily for generating an image +// file that can be downloaded via the ether +// to cogent using the SmartFirmWare boot rom +// +// + +#include +#include +#include +#include +#include +#include + +// little error functionet +void error(const char* p) +{ + fprintf(stderr, "%s\n", p); + exit(1); +} + +// little usage functionet +void usage(const char* p) +{ + fprintf(stderr, "%s\n", p); + exit(EXIT_FAILURE); +} + + +int main(int argc, char* argv[]) +{ + // check for usage + if (argc < 3 || argc > 4) + { + usage("Usage: bin2coff infile outfile nostrip\nOption nostrip: don't strip off the first 256 bytes"); + } + + // make sure we are not operating on only one file + if (!strcmp(argv[1], argv[2])) + { + usage("Usage: bin2coff must specify different input and output files"); + } + + // try to open the input file + FILE *pInFile; + if((pInFile = fopen(argv[1], "rb" )) == NULL) + { + error("Cannot open input file"); + } + + // open output file + FILE *pOutFile; + if((pOutFile = fopen(argv[2], "wb") ) == NULL) + { + error("Cannot open output file"); + } + + // strip the 256 long header? + // ok, so it's simple, so what + bool stripheader = (argc == 3); + + // how big is the input file + struct stat filelength; + stat(argv[1], &filelength); + unsigned long fsize = filelength.st_size; + if (stripheader) + { + fsize -= 256; + } + + // write out the coff header to the new file + // somewhere to put a simple coff header + unsigned char coffhead[0x58] = {0}; // zero all the elements + + // fill in the constant bits + // this is supposed to be simple, remember + coffhead[1] = 0x0a; + coffhead[2] = 0x01; + coffhead[0x10] = 0x1c; + coffhead[0x12] = 0x0f; + coffhead[0x13] = 0xa1; + coffhead[0x14] = 0x0b; + coffhead[0x15] = 0x01; + coffhead[0x26] = 0x40; // entry point 0x00400000 + coffhead[0x2a] = 0x40; + coffhead[0x30] = 0x2e; + coffhead[0x31] = 0x74; + coffhead[0x32] = 0x65; + coffhead[0x33] = 0x78; + coffhead[0x34] = 0x74; + coffhead[0x3a] = 0x40; + coffhead[0x3e] = 0x40; + coffhead[0x44] = 0x58; + coffhead[0x54] = 0x20; + + // now fill in the text segment size + *(int *) (&coffhead[0x18]) = fsize; + *(int *) (&coffhead[0x40]) = fsize; + + // write out the new file + // first the header + int numwritten=0; + numwritten = fwrite(coffhead, sizeof(char), 0x58, pOutFile); + if (numwritten < 0x58) + { + error("The number of items written is less than 0x58"); + } + + // now the rest of the file + if (stripheader) + { + fpos_t filePositionIndicator = 0x100; + if (fsetpos(pInFile, &filePositionIndicator) !=0) + { + error("The file is not accessible "); + } + } + + static const int buffsize = 1024; + unsigned char fbuff[buffsize]; + while (!feof(pInFile)) + { + int nread = fread(fbuff,sizeof(unsigned char), sizeof(fbuff), pInFile); + int nwritten = fwrite(fbuff, sizeof(unsigned char), nread, pOutFile); + if (nwritten < nread) + { + error("The number of items written is less than number of items read"); + } + } + + fclose(pOutFile); + fclose(pInFile); + + return 0; +} diff -r 22486c9c7b15 -r 378360dbbdba bintools/bin2coff/group/bin2coff.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/bin2coff/group/bin2coff.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,25 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET bin2coff.exe +TARGETTYPE exe +SOURCEPATH ..\..\bin2coff +SOURCE bin2coff.cpp + +OPTION GCC -O2 + + +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba bintools/bin2coff/group/bin2coff.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/bin2coff/group/bin2coff.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,10 @@ +component dev_build_bintools_bin2coff + +source \src\tools\build\bintools\bin2coff +binary \src\tools\build\bintools\bin2coff\group all +exports \src\tools\build\bintools\bin2coff\group + +notes_source \component_defs\release.src + +ipr T + diff -r 22486c9c7b15 -r 378360dbbdba bintools/bin2coff/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/bin2coff/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +bin2coff.mmp + +PRJ_TESTMMPFILES + diff -r 22486c9c7b15 -r 378360dbbdba bintools/elftools/def2dll.pl --- a/bintools/elftools/def2dll.pl Wed Jun 23 17:27:59 2010 +0800 +++ b/bintools/elftools/def2dll.pl Wed Jun 30 11:35:58 2010 +0800 @@ -33,6 +33,11 @@ } } +# Version +my $MajorVersion = 1; +my $MinorVersion = 1; +my $PatchVersion = 0; + use lib $PerlLibPath; use Defutl; @@ -66,6 +71,14 @@ my $interworking = "${oP}apcs /nointer"; $interworking = "${oP}apcs /inter" if ($interworkingp); +my $gDelim; +if ($^O eq "MSWin32") { + $gDelim = '\\'; +} +else { + $gDelim = '/'; +} + my @objectFiles; &main; @@ -91,7 +104,7 @@ sub usage( ) { print "\n"; - print "DEF2DLL -Creates binary objects used to implement the Symbian OS DLL model\n"; + print "DEF2DLL -Creates binary objects used to implement the Symbian OS DLL model v$MajorVersion.$MinorVersion.$PatchVersion\n"; print "\n"; print "Usage: def2dll --deffile= [--path=] [--bldpath=] [--import=] [--linkas=] [--inter] [--export=] [--sym_name_lkup]\n"; @@ -103,7 +116,7 @@ print "\t--linkas= : linkas to file name specified\n"; print "\t--inter : enables interworking on ARM and THUMB\n"; print "\t--export= : export to filename\n"; - print "\t--sym_name_lkup : symbol name ordinal number lookupç\n"; + print "\t--sym_name_lkup : symbol name ordinal number lookup\n"; print "\n"; exit 1; } @@ -148,8 +161,8 @@ my $numkeys = keys %symbolIndexMap; my $failed = 0; - open EXPFILE, ">$path\\$expFile.s" or - die "Error: can't create $path\\$expFile.s\n"; + open EXPFILE, ">$path$gDelim$expFile.s" or + die "Error: can't create $path$gDelim$expFile.s\n"; print EXPFILE "\tEXPORT __DLL_Export_Table__\n\n"; print EXPFILE "\tEXPORT |DLL\#\#ExportTable|\n\n"; @@ -204,9 +217,9 @@ print EXPFILE "\tEND"; close EXPFILE; - $failed = system "armasm $floatingpointmodel $interworking -o $path\\$expFile.exp $path\\$expFile.s"; - unlink ("$path\\$expFile.s") unless $failed; - die "Error: cant create $path\\$expFile.exp\n" if $failed; + $failed = system "armasm $floatingpointmodel $interworking -o $path$gDelim$expFile.exp $path$gDelim$expFile.s"; + unlink ("$path$gDelim$expFile.s") unless $failed; + die "Error: cant create $path$gDelim$expFile.exp\n" if $failed; } my %DataSymbols = (); @@ -216,8 +229,8 @@ my ($bldpath, $dllName) = @_; my $FileName = "VtblExports"; - open VTBLFILE, ">$bldpath\\$FileName.s" or - die "Error: can't create $bldpath\\$FileName.s\n"; + open VTBLFILE, ">$bldpath$gDelim$FileName.s" or + die "Error: can't create $bldpath$gDelim$FileName.s\n"; print VTBLFILE "\tAREA |.directive|, NOALLOC, READONLY, ALIGN=2\n"; printf VTBLFILE "\tDCB \"\#\\#\\n\"\n"; @@ -233,23 +246,23 @@ print VTBLFILE "\tEND"; close VTBLFILE; - my $failed = system "armasm $floatingpointmodel $interworking -o $bldpath\\$FileName.o $bldpath\\$FileName.s"; - unlink ("$bldpath\\$FileName.s"); - die "Error: cant create $bldpath\\$FileName.o\n" if $failed; - push @objectFiles, "$bldpath\\$FileName.o"; + my $failed = system "armasm $floatingpointmodel $interworking -o $bldpath$gDelim$FileName.o $bldpath$gDelim$FileName.s"; + unlink ("$bldpath$gDelim$FileName.s"); + die "Error: cant create $bldpath$gDelim$FileName.o\n" if $failed; + push @objectFiles, "$bldpath$gDelim$FileName.o"; } sub genLibFile ($$$$) { my ($path, $bldpath, $libFile, $dllName) = @_; - my $tempFileName = "$bldpath\\$compName"; - my $viaFileName = sprintf("$bldpath\\_t%x_via_.txt", time); + my $tempFileName = "$bldpath$gDelim$compName"; + my $viaFileName = sprintf("$bldpath${gDelim}_t%x_via_.txt", time); my $keyz = keys %symbolIndexMap; my $failed = 0; my $key; if ($keyz > 0) { - open STUBGEN, "|$ENV{'EPOCROOT'}/epoc32/tools/genstubs" if $exports; + open STUBGEN, "|genstubs" if $exports; foreach $key (sort keys %symbolIndexMap) { my $symbol = $symbolIndexMap{$key}; my $stubFileName = "$tempFileName-$key"; @@ -263,7 +276,7 @@ genVtblExportFile($bldpath, $dllName); } else { # create dummy stub so armar creates a .lib for us - open STUBGEN, "|$ENV{'EPOCROOT'}/epoc32/tools/genstubs"; + open STUBGEN, "|genstubs"; print STUBGEN "$tempFileName-stub.o $tempFileName##stub $dllName##dummy\n"; push @objectFiles, "$tempFileName-stub.o"; } @@ -272,7 +285,7 @@ open VIAFILE, ">$viaFileName" or die "Error: can't create VIA fie $viaFileName\n"; - print VIAFILE "${oP}create \"$path\\$libFile\"\n"; + print VIAFILE "${oP}create \"$path$gDelim$libFile\"\n"; my $objectFile; foreach $objectFile (@objectFiles) { print VIAFILE "\"$objectFile\"\n"; @@ -282,7 +295,7 @@ $failed = system( "armar ${oP}via $viaFileName"); push @objectFiles, $viaFileName; unlink @objectFiles; - die "Error: can't create $path\\$libFile\n" if $failed; + die "Error: can't create $path$gDelim$libFile\n" if $failed; } __END__ diff -r 22486c9c7b15 -r 378360dbbdba bintools/elftools/group/bld.inf --- a/bintools/elftools/group/bld.inf Wed Jun 23 17:27:59 2010 +0800 +++ b/bintools/elftools/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -25,19 +25,20 @@ #ifndef TOOLS2_LINUX ../elf2inf.pl /epoc32/tools/elf2inf.pl ../def2dll.bat /epoc32/tools/def2dll.bat -../def2dll.pl /epoc32/tools/def2dll.pl +A ../deputil.pl /epoc32/tools/deputil.pl ../deputil.pm /epoc32/tools/deputil.pm #endif +../def2dll.pl /epoc32/tools/def2dll.pl ../inc/elfdefs.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(tools/elfdefs.h) PRJ_MMPFILES #ifndef TOOLS2_LINUX +getexports +#endif +elftran genstubs -getexports -elftran -#endif elfdump diff -r 22486c9c7b15 -r 378360dbbdba bintools/elftools/group/release.txt --- a/bintools/elftools/group/release.txt Wed Jun 23 17:27:59 2010 +0800 +++ b/bintools/elftools/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -4,6 +4,11 @@ NOTESRC_RELEASE_REASON ELFtools Release +Version v1.1.0 - def2dll.pl +=============== +Released by Zheng Shen, 12/06/2010 + Minor: port def2dll.pl to Linux + Version V02.02 (Build 002) =============== Released by Zheng Shen, 10/03/2010 diff -r 22486c9c7b15 -r 378360dbbdba bintools/evalid/evalid_test_notes.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/evalid/evalid_test_notes.txt Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,63 @@ +evalid_test_notes.txt + +testfiles.zip contains two matching trees, each divided into +three sub-trees: + +left\ok\... +left\missing\... +left\fail\... + +right\ok\... +right\missing\... +right\fail\... + +Running "evalid left\ok right\ok" should produce 100% OK. +The "ok" trees contain at least one example of each type of file, +and should grow to illustrate any new form of non-significant +difference. + +Running "evalid left\missing right\missing" should report +only failures in the shape of the tree. + +Running "evalid left\fail right\fail" should report differences +in all pairs of files. +The "fail" trees should grow whenever a new form of significant +difference is found, so that we can avoid making EVALID too +tolerant. + + +------------- +Significant Difference test cases + +Most examples are synthetic test cases obtained by copying one or more pairs from +the ok tree into the fail tree, then modifying the right\fail file to introduce +a specific type of difference. The files are usually renamed to indicate the +nature of the difference. Using the pair of files from the ok tree means that the +files have a collection of non-significant differences in addition to the extra +difference introduced. + +Other cases are copies of real examples which showed a signficant difference. + +unknown_format\data\BuildInfo.txt + +- simple example of a text file with different contents + +unknown_format\ksa\layout.bin + +- simple example of a binary file with different contents + +SIS_file\release\armi\urel\gdbstub.sis + +- stub SIS file, currently not correctly recognised? + +Intel_DLL\wins\udeb\C32.dll + +- ??? not recorded why this is different yet + +Intel_DLL\wins\urel\BAFL.dll + +- Compiler generated thunks are laid out in a different order. + This is a known problem with Developer Studio which is triggered + by building the source from a different location. + + diff -r 22486c9c7b15 -r 378360dbbdba bintools/evalid/left_right.reference.log --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/evalid/left_right.reference.log Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,98 @@ +PROBLEM: Directory right\missing\leftonlydir does not exist +OK: left\ok\ARM_library\arm4\udeb\EEXE.LIB and right\ok\ARM_library\arm4\udeb\EEXE.LIB (ARM library) +OK: left\ok\ARM_library\arm4\urel\ALARMSHARED.LIB and right\ok\ARM_library\arm4\urel\ALARMSHARED.LIB (ARM library) +OK: left\ok\ARM_library\arm4\urel\EEXE.LIB and right\ok\ARM_library\arm4\urel\EEXE.LIB (ARM library) +OK: left\ok\ARM_library\thumb\udeb\EEXE.LIB and right\ok\ARM_library\thumb\udeb\EEXE.LIB (ARM library) +OK: left\ok\ARM_library\thumb\urel\ALARMSHARED.LIB and right\ok\ARM_library\thumb\urel\ALARMSHARED.LIB (ARM library) +OK: left\ok\ARM_library\thumb\urel\EEXE.LIB and right\ok\ARM_library\thumb\urel\EEXE.LIB (ARM library) +OK: left\ok\Compressed_E32_DLL\arm4\udeb\ALARMSHARED.DLL and right\ok\Compressed_E32_DLL\arm4\udeb\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: left\ok\Compressed_E32_DLL\arm4\urel\ALARMSHARED.DLL and right\ok\Compressed_E32_DLL\arm4\urel\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: left\ok\Compressed_E32_DLL\thumb\udeb\ALARMSHARED.DLL and right\ok\Compressed_E32_DLL\thumb\udeb\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: left\ok\Compressed_E32_DLL\thumb\urel\ALARMSHARED.DLL and right\ok\Compressed_E32_DLL\thumb\urel\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: left\ok\Compressed_E32_EXE\arm4\udeb\E32STRT.EXE and right\ok\Compressed_E32_EXE\arm4\udeb\E32STRT.EXE (Uncompressed E32 EXE) +OK: left\ok\Compressed_E32_EXE\arm4\urel\E32STRT.EXE and right\ok\Compressed_E32_EXE\arm4\urel\E32STRT.EXE (Uncompressed E32 EXE) +OK: left\ok\Compressed_E32_EXE\thumb\udeb\E32STRT.EXE and right\ok\Compressed_E32_EXE\thumb\udeb\E32STRT.EXE (Uncompressed E32 EXE) +OK: left\ok\Compressed_E32_EXE\thumb\urel\E32STRT.EXE and right\ok\Compressed_E32_EXE\thumb\urel\E32STRT.EXE (Uncompressed E32 EXE) +OK: left\ok\E32_DLL\arm4\udeb\ALARMSHARED.DLL and right\ok\E32_DLL\arm4\udeb\ALARMSHARED.DLL (E32 DLL) +OK: left\ok\E32_DLL\arm4\urel\ALARMSHARED.DLL and right\ok\E32_DLL\arm4\urel\ALARMSHARED.DLL (E32 DLL) +OK: left\ok\E32_DLL\thumb\udeb\ALARMSHARED.DLL and right\ok\E32_DLL\thumb\udeb\ALARMSHARED.DLL (E32 DLL) +OK: left\ok\E32_DLL\thumb\urel\ALARMSHARED.DLL and right\ok\E32_DLL\thumb\urel\ALARMSHARED.DLL (E32 DLL) +OK: left\ok\E32_EXE\arm4\udeb\ALARMSERVER.EXE and right\ok\E32_EXE\arm4\udeb\ALARMSERVER.EXE (E32 EXE) +OK: left\ok\E32_EXE\arm4\urel\ALARMSERVER.EXE and right\ok\E32_EXE\arm4\urel\ALARMSERVER.EXE (E32 EXE) +OK: left\ok\E32_EXE\thumb\udeb\ALARMSERVER.EXE and right\ok\E32_EXE\thumb\udeb\ALARMSERVER.EXE (E32 EXE) +OK: left\ok\E32_EXE\thumb\urel\ALARMSERVER.EXE and right\ok\E32_EXE\thumb\urel\ALARMSERVER.EXE (E32 EXE) +OK: left\ok\identical\console.ini and right\ok\identical\console.ini (identical) +OK: left\ok\Intel_DLL\wins\udeb\ALARMSHARED.DLL and right\ok\Intel_DLL\wins\udeb\ALARMSHARED.DLL (Intel DLL) +OK: left\ok\Intel_DLL\wins\urel\ALARMSHARED.DLL and right\ok\Intel_DLL\wins\urel\ALARMSHARED.DLL (Intel DLL) +OK: left\ok\Intel_DLL\winscw\udeb\ALARMSHARED.DLL and right\ok\Intel_DLL\winscw\udeb\ALARMSHARED.DLL (Intel DLL) +OK: left\ok\Intel_DLL\winscw\urel\ALARMSHARED.DLL and right\ok\Intel_DLL\winscw\urel\ALARMSHARED.DLL (Intel DLL) +OK: left\ok\Intel_exe\wins\udeb\E32STRT.EXE and right\ok\Intel_exe\wins\udeb\E32STRT.EXE (Intel EXE) +OK: left\ok\Intel_exe\wins\urel\E32STRT.EXE and right\ok\Intel_exe\wins\urel\E32STRT.EXE (Intel EXE) +OK: left\ok\Intel_exe\winscw\udeb\E32STRT.EXE and right\ok\Intel_exe\winscw\udeb\E32STRT.EXE (Intel EXE) +OK: left\ok\Intel_exe\winscw\urel\E32STRT.EXE and right\ok\Intel_exe\winscw\urel\E32STRT.EXE (Intel EXE) +OK: left\ok\Intel_library\wins\udeb\ALARMSHARED.LIB and right\ok\Intel_library\wins\udeb\ALARMSHARED.LIB (Intel library) +OK: left\ok\Intel_library\wins\udeb\EEXE.LIB and right\ok\Intel_library\wins\udeb\EEXE.LIB (Intel library) +OK: left\ok\Intel_library\wins\urel\EEXE.LIB and right\ok\Intel_library\wins\urel\EEXE.LIB (Intel library) +OK: left\ok\Intel_library\winscw\udeb\ALARMSHARED.LIB and right\ok\Intel_library\winscw\udeb\ALARMSHARED.LIB (Intel library) +OK: left\ok\Intel_library\winscw\udeb\EEXE.LIB and right\ok\Intel_library\winscw\udeb\EEXE.LIB (Intel library) +OK: left\ok\Intel_library\winscw\urel\EEXE.LIB and right\ok\Intel_library\winscw\urel\EEXE.LIB (Intel library) +OK: left\ok\Intel_object\FNTTRAN.exp and right\ok\Intel_object\FNTTRAN.exp (Intel object) +OK: left\ok\MAP_file\arm4\udeb\ALARMSHARED.DLL.map and right\ok\MAP_file\arm4\udeb\ALARMSHARED.DLL.map (MAP file) +OK: left\ok\MAP_file\arm4\udeb\E32STRT.EXE.map and right\ok\MAP_file\arm4\udeb\E32STRT.EXE.map (MAP file) +OK: left\ok\MAP_file\arm4\urel\ALARMSHARED.DLL.map and right\ok\MAP_file\arm4\urel\ALARMSHARED.DLL.map (MAP file) +OK: left\ok\MAP_file\arm4\urel\E32STRT.EXE.map and right\ok\MAP_file\arm4\urel\E32STRT.EXE.map (MAP file) +OK: left\ok\MAP_file\thumb\udeb\ALARMSHARED.DLL.map and right\ok\MAP_file\thumb\udeb\ALARMSHARED.DLL.map (MAP file) +OK: left\ok\MAP_file\thumb\udeb\E32STRT.EXE.map and right\ok\MAP_file\thumb\udeb\E32STRT.EXE.map (MAP file) +OK: left\ok\MAP_file\thumb\urel\ALARMSHARED.DLL.map and right\ok\MAP_file\thumb\urel\ALARMSHARED.DLL.map (MAP file) +OK: left\ok\MAP_file\thumb\urel\E32STRT.EXE.map and right\ok\MAP_file\thumb\urel\E32STRT.EXE.map (MAP file) +OK: left\ok\MAP_file\winscw\urel\ALARMSHARED.DLL.map and right\ok\MAP_file\winscw\urel\ALARMSHARED.DLL.map (identical) +OK: left\ok\MAP_file\winscw\urel\E32STRT.EXE.map and right\ok\MAP_file\winscw\urel\E32STRT.EXE.map (identical) +OK: left\ok\Preprocessed_text\IRCOMM.rpp and right\ok\Preprocessed_text\IRCOMM.rpp (Preprocessed text) +OK: left\ok\SGML_file\allclasses-frame.html and right\ok\SGML_file\allclasses-frame.html (SGML file) +OK: left\ok\ZIP_file\aifapp_ResourceBundles.jar and right\ok\ZIP_file\aifapp_ResourceBundles.jar (ZIP file) + +Results of evalid left right + +1 missing files + +MISSING: right\missing\leftonlyfile.txt + +30 failed comparisons + +FAILED: left\fail\ARM_library\ARM4_symbol.lib and right\fail\ARM_library\ARM4_symbol.lib (ARM library) +FAILED: left\fail\ARM_library\Thumb_symbol.lib and right\fail\ARM_library\Thumb_symbol.lib (ARM library) +FAILED: left\fail\Intel_DLL\wins\udeb\C32.DLL and right\fail\Intel_DLL\wins\udeb\C32.DLL (Intel DLL) +FAILED: left\fail\Intel_DLL\wins\urel\BAFL.DLL and right\fail\Intel_DLL\wins\urel\BAFL.DLL (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_data.dll and right\fail\Intel_DLL\winscw_data.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_export.dll and right\fail\Intel_DLL\winscw_export.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_import.dll and right\fail\Intel_DLL\winscw_import.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_rdata.dll and right\fail\Intel_DLL\winscw_rdata.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_text.dll and right\fail\Intel_DLL\winscw_text.dll (Intel DLL) +FAILED: left\fail\Intel_DLL\winscw_uid.dll and right\fail\Intel_DLL\winscw_uid.dll (Intel DLL) +FAILED: left\fail\Intel_EXE\winscw_data.exe and right\fail\Intel_EXE\winscw_data.exe (Intel EXE) +FAILED: left\fail\Intel_EXE\winscw_import.exe and right\fail\Intel_EXE\winscw_import.exe (Intel EXE) +FAILED: left\fail\Intel_EXE\winscw_rdata.exe and right\fail\Intel_EXE\winscw_rdata.exe (Intel EXE) +FAILED: left\fail\Intel_EXE\winscw_text.exe and right\fail\Intel_EXE\winscw_text.exe (Intel EXE) +FAILED: left\fail\Intel_EXE\winscw_uid.exe and right\fail\Intel_EXE\winscw_uid.exe (Intel EXE) +FAILED: left\fail\Intel_library\symbol.lib and right\fail\Intel_library\symbol.lib (Intel library) +FAILED: left\fail\Intel_object\symbol.obj and right\fail\Intel_object\symbol.obj (Intel object) +FAILED: left\fail\MAP_file\offset.map and right\fail\MAP_file\offset.map (MAP file) +FAILED: left\fail\MAP_file\size.map and right\fail\MAP_file\size.map (MAP file) +FAILED: left\fail\MAP_file\symbol.map and right\fail\MAP_file\symbol.map (MAP file) +FAILED: left\fail\MAP_file\winscw_offset.map and right\fail\MAP_file\winscw_offset.map (MAP file) +FAILED: left\fail\MAP_file\winscw_symbol.map and right\fail\MAP_file\winscw_symbol.map (MAP file) +FAILED: left\fail\Preprocessed_text\content.rpp and right\fail\Preprocessed_text\content.rpp (Preprocessed text) +FAILED: left\fail\SGML_file\content.html and right\fail\SGML_file\content.html (SGML file) +FAILED: left\fail\SIS_file\release\armi\urel\gdbstub.sis and right\fail\SIS_file\release\armi\urel\gdbstub.sis (SIS file) +FAILED: left\fail\unknown_format\data\BuildInfo.txt and right\fail\unknown_format\data\BuildInfo.txt (unknown format) +FAILED: left\fail\unknown_format\ksa\layout.bin and right\fail\unknown_format\ksa\layout.bin (unknown format) +FAILED: left\fail\ZIP_file\content.zip and right\fail\ZIP_file\content.zip (ZIP file) +FAILED: left\fail\ZIP_file\order.zip and right\fail\ZIP_file\order.zip (ZIP file) +FAILED: left\fail\ZIP_file\size.zip and right\fail\ZIP_file\size.zip (ZIP file) + +---------------- +16:03 06/10/2003 +evalid left right +Failed 32 of 83 comparisons +---------------- + diff -r 22486c9c7b15 -r 378360dbbdba bintools/evalid/right_left.reference.log --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/evalid/right_left.reference.log Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,98 @@ +PROBLEM: Directory left\missing\rightonlydir does not exist +OK: right\ok\ARM_library\arm4\udeb\EEXE.LIB and left\ok\ARM_library\arm4\udeb\EEXE.LIB (ARM library) +OK: right\ok\ARM_library\arm4\urel\ALARMSHARED.LIB and left\ok\ARM_library\arm4\urel\ALARMSHARED.LIB (ARM library) +OK: right\ok\ARM_library\arm4\urel\EEXE.LIB and left\ok\ARM_library\arm4\urel\EEXE.LIB (ARM library) +OK: right\ok\ARM_library\thumb\udeb\EEXE.LIB and left\ok\ARM_library\thumb\udeb\EEXE.LIB (ARM library) +OK: right\ok\ARM_library\thumb\urel\ALARMSHARED.LIB and left\ok\ARM_library\thumb\urel\ALARMSHARED.LIB (ARM library) +OK: right\ok\ARM_library\thumb\urel\EEXE.LIB and left\ok\ARM_library\thumb\urel\EEXE.LIB (ARM library) +OK: right\ok\Compressed_E32_DLL\arm4\udeb\ALARMSHARED.DLL and left\ok\Compressed_E32_DLL\arm4\udeb\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: right\ok\Compressed_E32_DLL\arm4\urel\ALARMSHARED.DLL and left\ok\Compressed_E32_DLL\arm4\urel\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: right\ok\Compressed_E32_DLL\thumb\udeb\ALARMSHARED.DLL and left\ok\Compressed_E32_DLL\thumb\udeb\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: right\ok\Compressed_E32_DLL\thumb\urel\ALARMSHARED.DLL and left\ok\Compressed_E32_DLL\thumb\urel\ALARMSHARED.DLL (Uncompressed E32 DLL) +OK: right\ok\Compressed_E32_EXE\arm4\udeb\E32STRT.EXE and left\ok\Compressed_E32_EXE\arm4\udeb\E32STRT.EXE (Uncompressed E32 EXE) +OK: right\ok\Compressed_E32_EXE\arm4\urel\E32STRT.EXE and left\ok\Compressed_E32_EXE\arm4\urel\E32STRT.EXE (Uncompressed E32 EXE) +OK: right\ok\Compressed_E32_EXE\thumb\udeb\E32STRT.EXE and left\ok\Compressed_E32_EXE\thumb\udeb\E32STRT.EXE (Uncompressed E32 EXE) +OK: right\ok\Compressed_E32_EXE\thumb\urel\E32STRT.EXE and left\ok\Compressed_E32_EXE\thumb\urel\E32STRT.EXE (Uncompressed E32 EXE) +OK: right\ok\E32_DLL\arm4\udeb\ALARMSHARED.DLL and left\ok\E32_DLL\arm4\udeb\ALARMSHARED.DLL (E32 DLL) +OK: right\ok\E32_DLL\arm4\urel\ALARMSHARED.DLL and left\ok\E32_DLL\arm4\urel\ALARMSHARED.DLL (E32 DLL) +OK: right\ok\E32_DLL\thumb\udeb\ALARMSHARED.DLL and left\ok\E32_DLL\thumb\udeb\ALARMSHARED.DLL (E32 DLL) +OK: right\ok\E32_DLL\thumb\urel\ALARMSHARED.DLL and left\ok\E32_DLL\thumb\urel\ALARMSHARED.DLL (E32 DLL) +OK: right\ok\E32_EXE\arm4\udeb\ALARMSERVER.EXE and left\ok\E32_EXE\arm4\udeb\ALARMSERVER.EXE (E32 EXE) +OK: right\ok\E32_EXE\arm4\urel\ALARMSERVER.EXE and left\ok\E32_EXE\arm4\urel\ALARMSERVER.EXE (E32 EXE) +OK: right\ok\E32_EXE\thumb\udeb\ALARMSERVER.EXE and left\ok\E32_EXE\thumb\udeb\ALARMSERVER.EXE (E32 EXE) +OK: right\ok\E32_EXE\thumb\urel\ALARMSERVER.EXE and left\ok\E32_EXE\thumb\urel\ALARMSERVER.EXE (E32 EXE) +OK: right\ok\identical\console.ini and left\ok\identical\console.ini (identical) +OK: right\ok\Intel_DLL\wins\udeb\ALARMSHARED.DLL and left\ok\Intel_DLL\wins\udeb\ALARMSHARED.DLL (Intel DLL) +OK: right\ok\Intel_DLL\wins\urel\ALARMSHARED.DLL and left\ok\Intel_DLL\wins\urel\ALARMSHARED.DLL (Intel DLL) +OK: right\ok\Intel_DLL\winscw\udeb\ALARMSHARED.DLL and left\ok\Intel_DLL\winscw\udeb\ALARMSHARED.DLL (Intel DLL) +OK: right\ok\Intel_DLL\winscw\urel\ALARMSHARED.DLL and left\ok\Intel_DLL\winscw\urel\ALARMSHARED.DLL (Intel DLL) +OK: right\ok\Intel_EXE\wins\udeb\E32STRT.EXE and left\ok\Intel_EXE\wins\udeb\E32STRT.EXE (Intel EXE) +OK: right\ok\Intel_EXE\wins\urel\E32STRT.EXE and left\ok\Intel_EXE\wins\urel\E32STRT.EXE (Intel EXE) +OK: right\ok\Intel_EXE\winscw\udeb\E32STRT.EXE and left\ok\Intel_EXE\winscw\udeb\E32STRT.EXE (Intel EXE) +OK: right\ok\Intel_EXE\winscw\urel\E32STRT.EXE and left\ok\Intel_EXE\winscw\urel\E32STRT.EXE (Intel EXE) +OK: right\ok\Intel_library\wins\udeb\ALARMSHARED.LIB and left\ok\Intel_library\wins\udeb\ALARMSHARED.LIB (Intel library) +OK: right\ok\Intel_library\wins\udeb\EEXE.LIB and left\ok\Intel_library\wins\udeb\EEXE.LIB (Intel library) +OK: right\ok\Intel_library\wins\urel\EEXE.LIB and left\ok\Intel_library\wins\urel\EEXE.LIB (Intel library) +OK: right\ok\Intel_library\winscw\udeb\ALARMSHARED.LIB and left\ok\Intel_library\winscw\udeb\ALARMSHARED.LIB (Intel library) +OK: right\ok\Intel_library\winscw\udeb\EEXE.LIB and left\ok\Intel_library\winscw\udeb\EEXE.LIB (Intel library) +OK: right\ok\Intel_library\winscw\urel\EEXE.LIB and left\ok\Intel_library\winscw\urel\EEXE.LIB (Intel library) +OK: right\ok\Intel_object\FNTTRAN.exp and left\ok\Intel_object\FNTTRAN.exp (Intel object) +OK: right\ok\MAP_file\arm4\udeb\ALARMSHARED.DLL.map and left\ok\MAP_file\arm4\udeb\ALARMSHARED.DLL.map (MAP file) +OK: right\ok\MAP_file\arm4\udeb\E32STRT.EXE.map and left\ok\MAP_file\arm4\udeb\E32STRT.EXE.map (MAP file) +OK: right\ok\MAP_file\arm4\urel\ALARMSHARED.DLL.map and left\ok\MAP_file\arm4\urel\ALARMSHARED.DLL.map (MAP file) +OK: right\ok\MAP_file\arm4\urel\E32STRT.EXE.map and left\ok\MAP_file\arm4\urel\E32STRT.EXE.map (MAP file) +OK: right\ok\MAP_file\thumb\udeb\ALARMSHARED.DLL.map and left\ok\MAP_file\thumb\udeb\ALARMSHARED.DLL.map (MAP file) +OK: right\ok\MAP_file\thumb\udeb\E32STRT.EXE.map and left\ok\MAP_file\thumb\udeb\E32STRT.EXE.map (MAP file) +OK: right\ok\MAP_file\thumb\urel\ALARMSHARED.DLL.map and left\ok\MAP_file\thumb\urel\ALARMSHARED.DLL.map (MAP file) +OK: right\ok\MAP_file\thumb\urel\E32STRT.EXE.map and left\ok\MAP_file\thumb\urel\E32STRT.EXE.map (MAP file) +OK: right\ok\MAP_file\winscw\urel\ALARMSHARED.DLL.map and left\ok\MAP_file\winscw\urel\ALARMSHARED.DLL.map (identical) +OK: right\ok\MAP_file\winscw\urel\E32STRT.EXE.map and left\ok\MAP_file\winscw\urel\E32STRT.EXE.map (identical) +OK: right\ok\Preprocessed_text\IRCOMM.rpp and left\ok\Preprocessed_text\IRCOMM.rpp (Preprocessed text) +OK: right\ok\SGML_file\allclasses-frame.html and left\ok\SGML_file\allclasses-frame.html (SGML file) +OK: right\ok\ZIP_file\aifapp_ResourceBundles.jar and left\ok\ZIP_file\aifapp_ResourceBundles.jar (ZIP file) + +Results of evalid right left + +1 missing files + +MISSING: left\missing\rightonlyfile.txt + +30 failed comparisons + +FAILED: right\fail\ARM_library\ARM4_symbol.lib and left\fail\ARM_library\ARM4_symbol.lib (ARM library) +FAILED: right\fail\ARM_library\Thumb_symbol.lib and left\fail\ARM_library\Thumb_symbol.lib (ARM library) +FAILED: right\fail\Intel_DLL\wins\udeb\C32.DLL and left\fail\Intel_DLL\wins\udeb\C32.DLL (Intel DLL) +FAILED: right\fail\Intel_DLL\wins\urel\BAFL.DLL and left\fail\Intel_DLL\wins\urel\BAFL.DLL (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_data.dll and left\fail\Intel_DLL\winscw_data.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_export.dll and left\fail\Intel_DLL\winscw_export.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_import.dll and left\fail\Intel_DLL\winscw_import.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_rdata.dll and left\fail\Intel_DLL\winscw_rdata.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_text.dll and left\fail\Intel_DLL\winscw_text.dll (Intel DLL) +FAILED: right\fail\Intel_DLL\winscw_uid.dll and left\fail\Intel_DLL\winscw_uid.dll (Intel DLL) +FAILED: right\fail\Intel_EXE\winscw_data.exe and left\fail\Intel_EXE\winscw_data.exe (Intel EXE) +FAILED: right\fail\Intel_EXE\winscw_import.exe and left\fail\Intel_EXE\winscw_import.exe (Intel EXE) +FAILED: right\fail\Intel_EXE\winscw_rdata.exe and left\fail\Intel_EXE\winscw_rdata.exe (Intel EXE) +FAILED: right\fail\Intel_EXE\winscw_text.exe and left\fail\Intel_EXE\winscw_text.exe (Intel EXE) +FAILED: right\fail\Intel_EXE\winscw_uid.exe and left\fail\Intel_EXE\winscw_uid.exe (Intel EXE) +FAILED: right\fail\Intel_library\symbol.lib and left\fail\Intel_library\symbol.lib (Intel library) +FAILED: right\fail\Intel_object\symbol.obj and left\fail\Intel_object\symbol.obj (Intel object) +FAILED: right\fail\MAP_file\offset.map and left\fail\MAP_file\offset.map (MAP file) +FAILED: right\fail\MAP_file\size.map and left\fail\MAP_file\size.map (MAP file) +FAILED: right\fail\MAP_file\symbol.map and left\fail\MAP_file\symbol.map (MAP file) +FAILED: right\fail\MAP_file\winscw_offset.map and left\fail\MAP_file\winscw_offset.map (MAP file) +FAILED: right\fail\MAP_file\winscw_symbol.map and left\fail\MAP_file\winscw_symbol.map (MAP file) +FAILED: right\fail\Preprocessed_text\content.rpp and left\fail\Preprocessed_text\content.rpp (Preprocessed text) +FAILED: right\fail\SGML_file\content.html and left\fail\SGML_file\content.html (SGML file) +FAILED: right\fail\SIS_file\release\armi\urel\gdbstub.sis and left\fail\SIS_file\release\armi\urel\gdbstub.sis (SIS file) +FAILED: right\fail\unknown_format\data\BuildInfo.txt and left\fail\unknown_format\data\BuildInfo.txt (unknown format) +FAILED: right\fail\unknown_format\ksa\layout.bin and left\fail\unknown_format\ksa\layout.bin (unknown format) +FAILED: right\fail\ZIP_file\content.zip and left\fail\ZIP_file\content.zip (ZIP file) +FAILED: right\fail\ZIP_file\order.zip and left\fail\ZIP_file\order.zip (ZIP file) +FAILED: right\fail\ZIP_file\size.zip and left\fail\ZIP_file\size.zip (ZIP file) + +---------------- +16:03 06/10/2003 +evalid right left +Failed 32 of 83 comparisons +---------------- + diff -r 22486c9c7b15 -r 378360dbbdba bintools/evalid/testfiles.zip Binary file bintools/evalid/testfiles.zip has changed diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,33 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +pe_dump.mmp +pediff.mmp +petran.mmp + +PRJ_TESTMMPFILES + diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/group/pe_dump.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/pe_dump.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,25 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +TARGET pe_dump.exe +TARGETTYPE exe +SOURCEPATH ../pe_dump +SOURCE pe_dump.cpp + +USERINCLUDE ../../../imgtools/imglib/inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +OPTION MSVC /GX +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/group/pediff.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/pediff.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,38 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +target pediff.exe +targettype exe +sourcepath ../../../imgtools/imglib/e32uid +source e32uid.cpp +sourcepath ../../../imgtools/imglib/host +source h_mem.cpp h_utl.cpp +sourcepath ../pediff +source pediff.cpp +sourcepath ../../../imgtools/imglib/e32image +source e32image.cpp +sourcepath ../../../imgtools/imglib/e32image/deflate +source decode.cpp encode.cpp deflate.cpp inflate.cpp panic.cpp +source compress.cpp +sourcepath ../../../imgtools/imglib/compress +source pagedcompress.cpp byte_pair.cpp + +userinclude ../../../imgtools/imglib/compress +USERINCLUDE ../../../imgtools/imglib/inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + + +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/group/petools.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/petools.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_bintools_petools + +source /src/tools/build/bintools/petools +exports /src/tools/build/bintools/petools/group +binary /src/tools/build/bintools/petools/group all + +notes_source \component_defs\release.src + +ipr T diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/group/petran.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/group/petran.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,39 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +macro __SUPPORT_PE_FILES__ + +target petran.exe +targettype exe +sourcepath ../../../imgtools/imglib/e32uid +source e32uid.cpp +sourcepath ../../../imgtools/imglib/host +source h_file.cpp h_mem.cpp h_utl.cpp +sourcepath ../pefile +source pe_file.cpp pe_imp.cpp pe_reloc.cpp pe_tran.cpp pe_utl.cpp +sourcepath ../../../imgtools/imglib/e32image +source e32image.cpp tr_main.cpp imgdump.cpp +sourcepath ../../../imgtools/imglib/e32image/deflate +source decode.cpp encode.cpp deflate.cpp inflate.cpp panic.cpp compress.cpp +sourcepath ../../../imgtools/imglib/compress +source byte_pair.cpp pagedCompress.cpp + +userinclude ../../../imgtools/imglib/compress +USERINCLUDE ../../../imgtools/imglib/inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN +USERINCLUDE ../compress + +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/pe_dump/pe_dump.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pe_dump/pe_dump.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,460 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include + +#include "h_ver.h" +#include "pe_defs.h" +#include + +#if defined(__MSVCDOTNET__) || defined (__TOOLS2__) + #include + #include + #include + #include + using namespace std; +#else //__MSVCDOTNET__ + #include + #include + #include + #include +#endif //__MSVCDOTNET__ + +#include + +const int KDiffIdentical=0; +const int KDiffDifferent=2; + +class PeFile + { +public: + PeFile(); + ~PeFile(); + int Open(char *aFileName); + void Close(); + PIMAGE_DOS_HEADER DosHeader(); + PIMAGE_NT_HEADERS Headers(); + PIMAGE_SECTION_HEADER SectionHeaders(); + char *LoadSection(PIMAGE_SECTION_HEADER aSectionHeader); + int NumberOfSections(); + char *LoadExtraData(int aOffsetToExtraData, TUint aFileSize); + + int Errno(); // Should be invoked only if previous call of PeFile's + // member function returns incorrectly + int Errno(int aErrno); // Assign error number for special purpose. +public: + fstream iFile; + PIMAGE_DOS_HEADER iDosHeader; + PIMAGE_NT_HEADERS iHeaders; + PIMAGE_SECTION_HEADER iSectionHeaders; +private: + int errnumber; + }; + +PeFile::PeFile() + //: iDosHeader(NULL), iHeaders(NULL), iSectionHeaders(NULL), errno(KErrNone) + //commented out as SBSv2 reports error: anachronistic old-style base class initializer +{ + iDosHeader = NULL ; + iHeaders = NULL ; + iSectionHeaders = NULL ; + errnumber = KErrNone; + + return; +} + +PeFile::~PeFile() + { + delete iDosHeader; + delete iHeaders; + delete [] iSectionHeaders; + } + +int PeFile::Open(char *aFileName) +{ +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) + iFile.open(aFileName, ios::in | ios::binary); +#else //!__MSVCDOTNET__ + iFile.open(aFileName, ios::in | ios::binary | ios::nocreate); +#endif //__MSVCDOTNET__ + if (!iFile.is_open()) + { + errnumber = KErrNotFound; + return KErrNotFound; + } + return KErrNone; +} + +void PeFile::Close() + { + iFile.close(); + } + + +PIMAGE_DOS_HEADER PeFile::DosHeader() + { + if (iDosHeader) + return iDosHeader; + + iDosHeader=new IMAGE_DOS_HEADER; + if (!iDosHeader) { + errnumber = KErrNoMemory; + return NULL; + } + + memset(iDosHeader, 0, sizeof(IMAGE_DOS_HEADER)); + + iFile.seekg(0); + iFile.read((char *)iDosHeader, sizeof(IMAGE_DOS_HEADER)); + if (iDosHeader->e_magic!=IMAGE_DOS_SIGNATURE) { + errnumber = KErrCorrupt; + return NULL; + } + return iDosHeader; + } + +PIMAGE_NT_HEADERS PeFile::Headers() + { + if (iHeaders) + return iHeaders; + PIMAGE_DOS_HEADER d=DosHeader(); + if (d==NULL) + return NULL; + + iHeaders=new IMAGE_NT_HEADERS; + if (!iHeaders) { + errnumber = KErrNoMemory; + return NULL; + } + + memset(iHeaders, 0, sizeof(IMAGE_NT_HEADERS)); + + iFile.seekg(d->e_lfanew); + if (iFile.eof()) { + errnumber = KErrCorrupt; // File size is too small. + return NULL; + } + + iFile.read((char *)iHeaders, sizeof(IMAGE_NT_HEADERS)); + return iHeaders; + } + +PIMAGE_SECTION_HEADER PeFile::SectionHeaders() + { + if (iSectionHeaders) + return iSectionHeaders; + PIMAGE_NT_HEADERS h=Headers(); + if (h==NULL) { + errnumber = KErrNoMemory; + return NULL; + } + + int numSec; + if ((numSec = NumberOfSections()) < 0) { + return NULL; + } + else { + iSectionHeaders=new IMAGE_SECTION_HEADER [numSec]; + if (!iSectionHeaders) { + errnumber = KErrNoMemory; + return NULL; + } + } + + iFile.seekg(DosHeader()->e_lfanew+sizeof(IMAGE_NT_HEADERS)); + int i=sizeof(IMAGE_SECTION_HEADER)*numSec; + iFile.read((char *)iSectionHeaders, i); + if (iFile.gcount() != i) { // The size of header is incorrect. + printf("Error: Cannot load section headers in offset: 0x%x \n", + (int) (DosHeader()->e_lfanew + sizeof(IMAGE_NT_HEADERS))); + errnumber = KErrCorrupt; + return NULL; + } + + return iSectionHeaders; + } + +int PeFile::NumberOfSections() + { + if (Headers()) + return iHeaders->FileHeader.NumberOfSections; + else + return -1; + } + +char *PeFile::LoadSection(PIMAGE_SECTION_HEADER h) + { + char *section=new char [h->SizeOfRawData]; + if (section==NULL){ + errnumber = KErrNoMemory; + return NULL; + } + + try + { + memset(section, 0, h->SizeOfRawData); + } + catch(...) + { + } + + iFile.seekg(h->PointerToRawData); + iFile.read(section, h->SizeOfRawData); + + // Guarantee we have loaded the section correctly. + unsigned int actNum = iFile.gcount(); + if (actNum != h->SizeOfRawData) { // The size of section is incorrect. + printf("Error: Cannot load section in offset: 0x%x \n", + (int)h->PointerToRawData); + errnumber = KErrCorrupt; + return NULL; + } + + return section; + } + +char* PeFile::LoadExtraData(int aOffset, TUint aFileSize) + { + TUint sizeOfExtraData = 0; + if(aFileSize >= (TUint)aOffset) + sizeOfExtraData=aFileSize-aOffset; + if(sizeOfExtraData>0){ + char* buffer=new char [sizeOfExtraData]; + if (!buffer) { + errnumber = KErrNoMemory; + return NULL; + } + + memset(buffer, 0, sizeOfExtraData); + iFile.seekg(aOffset); + iFile.read(buffer, sizeOfExtraData); // Should be OK if the file size is correct. + + // Guarantee we have loaded the data correctly. + unsigned int actNum = iFile.gcount(); + if (actNum != sizeOfExtraData){ // Shouldn't be here is the file size is correct. + printf("Error: Cannot load extra section in offset: 0x%x \n", aOffset); + errnumber = KErrCorrupt; + return NULL; + } + + return buffer; + } + else { + errnumber = KErrCorrupt; + return NULL; + } + +} + +int PeFile::Errno() { + return errnumber; +} + +int PeFile::Errno(int aErrno) { + return (errnumber = aErrno); +} + + +void dump(TUint *aData, TInt aLength) + { + TUint *p=aData; + TInt i=0; + char line[256]; + unsigned char *cp=(unsigned char*)aData; + TInt j=0; + memset(line,' ',sizeof(line)); + while (i127) + { + c = '.'; + } + *linep++ = c; + } + } + *linep='\0'; + printf("%s\n", line+(ccount*9)); + } + } + +int pecmp(char *aFileName) + { + + PeFile peFile; + if (peFile.Open(aFileName)!=KErrNone) + { + cout << "Cannot open file '"<FileHeader.TimeDateStamp=0; + headers->OptionalHeader.CheckSum = 0; // Fix for TOOLS2 + + printf("NT Headers:\n"); + dump((TUint*)headers, sizeof(IMAGE_NT_HEADERS)); + + int numberofsections=peFile.NumberOfSections(); + if (numberofsections==-1) + { + cout << "Not a valid PE file.\n"; + return KErrGeneral; + } + + PIMAGE_SECTION_HEADER sectionheaders=peFile.SectionHeaders(); + + printf("Section Headers:\n"); + dump((TUint*)sectionheaders, sizeof(IMAGE_SECTION_HEADER)*peFile.NumberOfSections()); + + TUint exportDirVa=headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + TUint debugDirVa=headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress; + int SizeOfHeaders=headers->OptionalHeader.SizeOfHeaders; + int offsetToExtraData=0; + int i; + for (i=0; iSizeOfRawData == 0) + { + continue; + } + char *section=peFile.LoadSection(h); + if (section==NULL) + { + switch(peFile.Errno()){ + case KErrNoMemory: + cout << "Error: Out of memory\n"; + return KErrNoMemory; + default: + cout << "Not a valid PE file.\n"; + } + return KErrGeneral; + } + char name[9]; + for (int j=0; j<9; j++) + name[j]=h->Name[j]; + name[8]=0; + + if (debugDirVa>=h->VirtualAddress && debugDirVaVirtualAddress+h->SizeOfRawData) + { + // Debug data in this section + PIMAGE_DEBUG_DIRECTORY dd=(PIMAGE_DEBUG_DIRECTORY)(section+debugDirVa-h->VirtualAddress); + TInt debugDirSize=headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size; + while (debugDirSize>0) + { + dd->TimeDateStamp=0; + // size & location in file of debug data is not significant + // unless it's also mapped (AddressOfRawData != 0). If that's + // true, then the data will be visible in one of the sections + // anyway... + dd->SizeOfData=0; + dd->PointerToRawData=0; + dd++; + debugDirSize-=sizeof(IMAGE_DEBUG_DIRECTORY); + } + } + if (exportDirVa>=h->VirtualAddress && exportDirVaVirtualAddress+h->SizeOfRawData) + { + // Export directory in this section + PIMAGE_EXPORT_DIRECTORY ed=(PIMAGE_EXPORT_DIRECTORY)(section+exportDirVa-h->VirtualAddress); + ed->TimeDateStamp=0; + } + if (strcmp(".rsrc",name)==0) + { + int *t=(int *)(section+4); + *t=0; + } + + offsetToExtraData=offsetToExtraData+h->SizeOfRawData; + printf("Raw data:\n"); + dump((TUint*)section, h->SizeOfRawData); + + delete section; + } + struct stat buf; + stat (aFileName,&buf); + TUint fileSize=buf.st_size; + offsetToExtraData=offsetToExtraData+SizeOfHeaders; + TUint sizeOfExtraData = 0; + if(buf.st_size >= offsetToExtraData) + sizeOfExtraData=buf.st_size-offsetToExtraData; + char* extraData=peFile.LoadExtraData(offsetToExtraData, fileSize); + if(sizeOfExtraData>0){ + char* nsisSign; + nsisSign=extraData+8; + if(strncmp (nsisSign,"NullsoftInst",12) == 0){ + printf("\n\n Extra Data:\n"); + dump((TUint*)extraData, sizeOfExtraData); + } + } + peFile.Close(); + return KErrNone; + } + +int main(int argc, char *argv[]) + { + int r=KErrArgument; + if (argc==2) + { + r=pecmp(argv[1]); + } + if (r==KErrArgument) + { + cout << "\nPE_DUMP - PE file dumper V"; + cout << MajorVersion << '.' << setfill('0') << setw(2) << MinorVersion; + cout << '(' << setw(3) << Build << ")\n"; + cout << Copyright; + cout << "Syntax: "< + #include + #include + using namespace std; +#else //!__MSVCDOTNET__ + #include + #include + #include +#endif //__MSVCDOTNET__ + +const int KDiffIdentical=0; +const int KDiffDifferent=2; + +class PeFile + { +public: + PeFile(); + ~PeFile(); + int Open(char *aFileName); + void Close(); + PIMAGE_DOS_HEADER DosHeader(); + PIMAGE_NT_HEADERS Headers(); + PIMAGE_SECTION_HEADER SectionHeaders(); + char *LoadSection(PIMAGE_SECTION_HEADER aSectionHeader); + int NumberOfSections(); +public: + fstream iFile; + PIMAGE_DOS_HEADER iDosHeader; + PIMAGE_NT_HEADERS iHeaders; + PIMAGE_SECTION_HEADER iSectionHeaders; + }; + +PeFile::PeFile() + : iDosHeader(NULL), iHeaders(NULL), iSectionHeaders(NULL) + {} + +PeFile::~PeFile() + { + + delete iDosHeader; + delete iHeaders; + delete [] iSectionHeaders; + } + +int PeFile::Open(char *aFileName) + { + iFile.open(aFileName, ios::in | ios::binary); + if (!iFile.is_open()) + return KErrNotFound; + return KErrNone; + } + +void PeFile::Close() + { + + iFile.close(); + } + + +PIMAGE_DOS_HEADER PeFile::DosHeader() + { + if (iDosHeader) + return iDosHeader; + iDosHeader=new IMAGE_DOS_HEADER; + iFile.seekg(0); + iFile.read((char *)iDosHeader, sizeof(IMAGE_DOS_HEADER)); + if (iDosHeader->e_magic!=IMAGE_DOS_SIGNATURE) + return NULL; + return iDosHeader; + } + +PIMAGE_NT_HEADERS PeFile::Headers() + { + if (iHeaders) + return iHeaders; + PIMAGE_DOS_HEADER d=DosHeader(); + if (d==NULL) + return NULL; + iHeaders=new IMAGE_NT_HEADERS; + iFile.seekg(d->e_lfanew); + if (iFile.eof()) + return NULL; + iFile.read((char *)iHeaders, sizeof(IMAGE_NT_HEADERS)); + return iHeaders; + } + +PIMAGE_SECTION_HEADER PeFile::SectionHeaders() + { + if (iSectionHeaders) + return iSectionHeaders; + PIMAGE_NT_HEADERS h=Headers(); + if (h==NULL) + return NULL; + iSectionHeaders=new IMAGE_SECTION_HEADER [NumberOfSections()]; + iFile.seekg(DosHeader()->e_lfanew+sizeof(IMAGE_NT_HEADERS)); + int i=sizeof(IMAGE_SECTION_HEADER)*NumberOfSections(); + iFile.read((char *)iSectionHeaders, i); + return iSectionHeaders; + } + +int PeFile::NumberOfSections() + { + if (Headers()) + return iHeaders->FileHeader.NumberOfSections; + else + return -1; + } + +char *PeFile::LoadSection(PIMAGE_SECTION_HEADER h) + { + char *section=new char [h->SizeOfRawData]; + memset(section, 0, h->SizeOfRawData); + if (section==NULL) + return NULL; + iFile.seekg(h->PointerToRawData); + iFile.read(section, h->SizeOfRawData); + return section; + } + +int pecmp(char *aFileName1, char *aFileName2) + { + + PeFile file1, file2; + if (file1.Open(aFileName1)!=KErrNone) + { + cout << "Cannot open file '"<FileHeader.TimeDateStamp==headers2->FileHeader.TimeDateStamp); + headers1->FileHeader.TimeDateStamp=0; + headers2->FileHeader.TimeDateStamp=0; + + int r=memcmp(headers1, headers2, sizeof(IMAGE_NT_HEADERS)); + if (r) + { + cout << "PE file headers are different.\n"; + return KDiffDifferent; + } + + PIMAGE_SECTION_HEADER sectionheaders1=file1.SectionHeaders(); + PIMAGE_SECTION_HEADER sectionheaders2=file2.SectionHeaders(); + // file one and two have the same number of sections + int numberofsections=file1.NumberOfSections(); + if (numberofsections==-1) + { + cout << "Not a valid PE file.\n"; + return KErrGeneral; + } + r=memcmp(sectionheaders1, sectionheaders2, sizeof(IMAGE_SECTION_HEADER)*file1.NumberOfSections()); + if (r) + { + cout << "The files are different: PE section headers are different.\n"; + return KDiffDifferent; + } + + TUint exportDirVa=headers1->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + TUint debugDirVa=headers1->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress; + + int i; + for (i=0; iName[j]; + name[8]=0; + + if (debugDirVa>=h->VirtualAddress && debugDirVaVirtualAddress+h->SizeOfRawData) + { + // Debug data in this section + PIMAGE_DEBUG_DIRECTORY dd1=(PIMAGE_DEBUG_DIRECTORY)(section1+debugDirVa-h->VirtualAddress); + PIMAGE_DEBUG_DIRECTORY dd2=(PIMAGE_DEBUG_DIRECTORY)(section2+debugDirVa-h->VirtualAddress); + TInt debugDirSize=headers1->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size; + while (debugDirSize>0) + { + if (sameTime) + sameTime=(dd1->TimeDateStamp==dd2->TimeDateStamp); + dd1->TimeDateStamp=0; + dd2->TimeDateStamp=0; + // size & location in file of debug data is not significant + // unless it's also mapped (AddressOfRawData != 0). If that's + // true, then the data will be visible in one of the sections + // anyway... + dd1->SizeOfData=0; + dd2->SizeOfData=0; + dd1->PointerToRawData=0; + dd2->PointerToRawData=0; + dd1++; + dd2++; + debugDirSize-=sizeof(IMAGE_DEBUG_DIRECTORY); + } + } + if (exportDirVa>=h->VirtualAddress && exportDirVaVirtualAddress+h->SizeOfRawData) + { + // Export directory in this section + PIMAGE_EXPORT_DIRECTORY ed1=(PIMAGE_EXPORT_DIRECTORY)(section1+exportDirVa-h->VirtualAddress); + PIMAGE_EXPORT_DIRECTORY ed2=(PIMAGE_EXPORT_DIRECTORY)(section2+exportDirVa-h->VirtualAddress); + if (sameTime) + sameTime=(ed1->TimeDateStamp==ed2->TimeDateStamp); + ed1->TimeDateStamp=0; + ed2->TimeDateStamp=0; + } + if (strcmp(".rsrc",name)==0) + { + int *t1=(int *)(section1+4); + int *t2=(int *)(section2+4); + if (sameTime) + sameTime=(*t1==*t2); + *t1=0; + *t2=0; + } + + r=memcmp(section1, section2, h->SizeOfRawData); + if (r) + { + cout << name << " sections are different.\n"; + return KDiffDifferent; + } + delete section1; + delete section2; + } + + if (sameTime) + cout << "PE files are identical (time/data stamps also identical).\n"; + else + cout << "PE files are identical except for time/date stamps.\n"; + file1.Close(); + file2.Close(); + return KDiffIdentical; + } + +int e32cmp(char *aFileName1, char *aFileName2) + { + char* f1 = NormaliseFileName(aFileName1); + char* f2 = NormaliseFileName(aFileName2); + + E32ImageFile e32image1; + E32ImageFile e32image2; + TInt r = e32image1.Open(f1); + if (r != KErrNone) + { + if (r<0) + fprintf(stderr, "%s is not a valid E32Image file (error %d)\n", f1, r); + else + r = -1; + return r; + } + r = e32image2.Open(f2); + if (r != KErrNone) + { + if (r<0) + fprintf(stderr, "%s is not a valid E32Image file (error %d)\n", f2, r); + else + r = -1; + return r; + } + + + + int sametime=(e32image1.iHdr->iTimeLo==e32image2.iHdr->iTimeLo) + &&(e32image1.iHdr->iTimeHi==e32image2.iHdr->iTimeHi); + e32image1.iHdr->iTimeLo=0; + e32image1.iHdr->iTimeHi=0; + e32image1.iOrigHdr->iTimeLo=0; + e32image1.iOrigHdr->iTimeHi=0; + e32image2.iHdr->iTimeLo=0; + e32image2.iHdr->iTimeHi=0; + e32image2.iOrigHdr->iTimeLo=0; + e32image2.iOrigHdr->iTimeHi=0; + e32image1.iHdr->iToolsVersion=e32image2.iHdr->iToolsVersion; + e32image1.iOrigHdr->iToolsVersion=e32image2.iOrigHdr->iToolsVersion; + e32image1.iHdr->iHeaderCrc=0; + e32image2.iHdr->iHeaderCrc=0; + + int ohs1 = e32image1.iOrigHdr->TotalSize(); + int ohs2 = e32image2.iOrigHdr->TotalSize(); + int orighdrcmp = (ohs1==ohs2) ? memcmp(e32image1.iOrigHdr, e32image2.iOrigHdr, ohs1) : 1; + + int hs1 = e32image1.iHdr->TotalSize(); + int hs2 = e32image2.iHdr->TotalSize(); + int hdrcmp = (hs1==hs2) ? memcmp(e32image1.iHdr, e32image2.iHdr, hs1) : 1; + + int rs1 = e32image1.iSize - ohs1; + int rs2 = e32image2.iSize - ohs2; + int rcmp = (rs1==rs2) ? memcmp(e32image1.iData + ohs1, e32image2.iData + ohs2, rs1) : 1; + + if (orighdrcmp==0 && rcmp==0) + { + if (sametime) + printf("E32 image files are identical\n"); + else + printf("E32 image files are identical apart from timestamps and Header CRC \n"); + return KDiffIdentical; + } + if (hdrcmp==0 && rcmp==0) + { + printf("E32 image files are functionally equivalent but have different headers\n"); + return KDiffDifferent; + } + printf("E32 image files are different\n"); + return KDiffDifferent; + } + + +int main(int argc, char *argv[]) + { + cout << "\nPEDIFF - PE file compare V"; + cout << MajorVersion << '.' << setfill('0') << setw(2) << MinorVersion; + cout << '(' << setw(3) << Build << ")\n"; + cout << Copyright; + + int r=KErrArgument; + if ((argc==3) || (argc==4)) + { + if (argc==3) + r=pecmp(argv[1], argv[2]); + else if (strcmp("-e32", argv[1])==0) + r=e32cmp(argv[2], argv[3]); + } + if (r==KErrArgument) + { + cout << "Syntax: "< +#include +#include +#include +#include "e32image.h" +#include "pe_defs.h" +#include "pe_file.h" +#include "h_utl.h" + +TBool hadText, hadReloc = EFalse; +TUint32 PEFile::iRomMemBase=0; +TUint32 PEFile::iRomLinearBase=0; + +extern char* gX86imp; +extern int gX86num_imp_dlls; + +PEFile::PEFile() + :iMemBase(0),iEntryPoint(0),iImageSize(0),iCodeSize(0),iDataSize(0), + iHeapReservedSize(0),iHeapCommittedSize(0),iStackReservedSize(0),iStackCommittedSize(0), + iBssSize(0),iBssOffset(0),iSectionAlign(0),iExpDirectoryOffset(0),iDataOffset(0), + iImageIsDll(EFalse), + iHeader(0),iExpDirectory(0),iImpDescriptor(0),iFileName(0),iFileHandle(0), + iLinkedBase(0),iStartOfHeaders(0),iSizeOfHeaders(0),iNumSections(0), + iRomRunAddr(0),iRamRunAddr(0),iRomDelta(0),iRamDelta(0),iHadDataSection(EFalse), + iBssSectionLinkedAddr(0),iBssSectionAddr(0),iBssSectionSize(0), + iDataSectionLinkedAddr(0),iDataSectionAddr(0),iDataSectionSize(0), + iCodeSectionAddr(0),iCodeSectionSize(0), + iRDataSectionAddr(0),iRDataSectionSize(0), + iCRTSectionAddr(0),iCRTSectionSize(0), + iExportDataDir(0) +// +// Constructor +// + { + + for (TInt i=0; ie_lfanew; + else + iStartOfHeaders = 0; + + if (!HFile::Seek(iFileHandle, iStartOfHeaders)) + { + Print(EPeError,"File %s is not large enough to contain valid headers.\n",iFileName); + HFile::Close(iFileHandle); + return EFalse; + } + + if (!HFile::Read(iFileHandle,iHeader,sizeof(IMAGE_NT_HEADERS))) + { + Print(EPeError,"Unable to read NT headers.\n"); + HFile::Close(iFileHandle); + return EFalse; + } + + if (!IsValidNTHeader(iHeader)) + { + Print(EPeError,"Invalid NT header.\n"); + HFile::Close(iFileHandle); + return EFalse; + } + + if (!(IsValidFileHeader((PIMAGE_FILE_HEADER)&iHeader->FileHeader))) + { + Print(EPeError,"Invalid file header.\n"); + HFile::Close(iFileHandle); + return EFalse; + } + +// PIMAGE_NT_HEADERS pNTHeader = iHeader; + PIMAGE_FILE_HEADER pFileHeader = (PIMAGE_FILE_HEADER)&iHeader->FileHeader; + PIMAGE_OPTIONAL_HEADER pOptionalHeader = (PIMAGE_OPTIONAL_HEADER)&iHeader->OptionalHeader; +// PIMAGE_SECTION_HEADER pSectionHeader = (PIMAGE_SECTION_HEADER)(iHeader+1); + + iImageSize = pOptionalHeader->SizeOfImage; + iCodeSize = pOptionalHeader->SizeOfCode; + iDataSize = pOptionalHeader->SizeOfInitializedData; + iEntryPoint = pOptionalHeader->AddressOfEntryPoint; + iHeapReservedSize = pOptionalHeader->SizeOfHeapReserve; + iHeapCommittedSize = pOptionalHeader->SizeOfHeapCommit; + iStackReservedSize = 0x2000; + iStackCommittedSize = 0x2000; + iBssSize = pOptionalHeader->SizeOfUninitializedData; + iSectionAlign = pOptionalHeader->SectionAlignment; + if (pFileHeader->Characteristics & IMAGE_FILE_DLL) + iImageIsDll = ETrue; + else + iImageIsDll = EFalse; + iLinkedBase=pOptionalHeader->ImageBase; + iNumSections = pFileHeader->NumberOfSections; + iSizeOfHeaders = pOptionalHeader->SizeOfHeaders; + iExportDataDir=pOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; + iExportDirSize=pOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size; +// + iCpu=pFileHeader->Machine; + HMem::Free(iHeader); + iHeader=0; + return ETrue; + } + +void PEFile::Close() +// +// close the pe file +// + { + HFile::Close(iFileHandle); + } + +TInt PEFile::ReadExportDirectory() +// +// Read in just the export directory +// + { + + if (iExportDataDir==0) + return KErrNotFound; + TInt r=ReadSectionHeaders(); + if (r!=KErrNone) + return r; + iSectionData[KConstSection]=ReadSectionData(iSectionHeader[KConstSection]); + iExpDirectoryOffset=iSectionHeader[KConstSection]->VirtualAddress; + iExpDirectory=(PIMAGE_EXPORT_DIRECTORY)(iSectionData[KConstSection]+iExportDataDir-iExpDirectoryOffset); + return KErrNone; + } + +TInt PEFile::ReadSectionHeaders() +// +// Read in the section headers +// + { + + TInt i; + for (i=0; iName); + delete header; + } + } + return KErrNone; + } + +char *PEFile::ReadSectionData(PIMAGE_SECTION_HEADER aPeHeader) +// +// Read in the data for this section +// + { + char *section=NULL; + if (aPeHeader) + { + section=(char *)HMem::Alloc(NULL, aPeHeader->SizeOfRawData); + if (section==NULL) + return NULL; + HFile::Seek(iFileHandle, aPeHeader->PointerToRawData); + HFile::Read(iFileHandle, section, aPeHeader->SizeOfRawData); + } + return section; + } + +TInt PEFile::ReadData() +// +// +// + { + + TInt i; + for (i=0; iName); + } + else + iSectionData[i]=NULL; + } + return KErrNone; + } + +TInt PEFile::NumberOfImports() const +// +// Count the total number of imports for this image +// + { + +// if (gX86imp) +// return gX86num_imp_dlls; + char *importData=iSectionData[KImportSection]; + PIMAGE_SECTION_HEADER importHeader=iSectionHeader[KImportSection]; + if (importData==NULL) + return 0; + TInt n=0; + TUint *src=(TUint *)importData; + while (*src) + { + TUint vaoffset=src[4]; + if (!gLittleEndian) ByteSwap(vaoffset); + TUint offset=vaoffset-importHeader->VirtualAddress; // find the offset into the section of import addr table + TUint *p=(TUint *)(importData+offset); + while (*p++) + n++; + src+=5; // sizeof pe import block/4 + } + return n; + } + +TInt PEFile::NumberOfImportDlls() const +// +// Count the number of referenced Dlls +// + { + + char *importData=iSectionData[KImportSection]; +// PIMAGE_SECTION_HEADER importHeader=iSectionHeader[KImportSection]; + if (importData==NULL) + return 0; + TInt n=0; + while (*(TUint *)importData) + { + n++; + importData+=5*4; // size of pe import block + } + return n; + } + +TInt PEFile::NumberOfExports() const +// +// Count the number of exported symbols +// + { + + if (iExportDataDir==0) + return 0; + return ((PIMAGE_EXPORT_DIRECTORY)iSectionData[KExportSection])->NumberOfFunctions; + } + +TInt PEFile::NumberOfRelocs() +// +// Count the number of reloctions +// + { + + if (iSectionData[KRelocSection]==NULL) + return 0; + char *relocs=iSectionData[KRelocSection]; + TInt n=0; + TInt dudrelocs=0; + TInt blocksize; + TUint page; + TInt size=iSectionHeader[KRelocSection]->Misc.VirtualSize; + + TUint *rrelocs=(TUint *)relocs; + TUint ssize=size; + if (!gLittleEndian) ByteSwap(rrelocs, ssize); + + while (size>0) + { + page=*(TUint *)relocs; + blocksize=*(TInt *)(relocs+4); + if (blocksize==0) + break; + size-=blocksize; + TUint16 *p=(TUint16 *)(relocs+8); + relocs+=blocksize; + blocksize-=8; + while (blocksize>0) + { + TInt rtype=(*p&0xf000)>>12; + if (rtype==IMAGE_REL_BASED_HIGHLOW) + { + TUint va=page+(*p&0xfff); + + // va is the address requiring relocation, so it must be in a section and can't have been offset + TInt section=FindSectionByVa(va+iLinkedBase); + if (section==KTextSection || section==KConstSection || section==KDataSection || section==KCrtSection) + n++; + else + dudrelocs++; + } + else if (rtype!=IMAGE_REL_BASED_ABSOLUTE) // used for padding + Print(EWarning, "Relocation type other than IMAGE_REL_BASED_HIGHLOW has been ignored.\n"); + *p++; + blocksize-=2; + } + } +#if defined(_DEBUG) + if (dudrelocs>0) + Print(EWarning, "Image '%s' has %d relocations pointing at uninitialised data.\n", iFileName, dudrelocs); +#endif + + if (!gLittleEndian) ByteSwap(rrelocs, ssize); + return n; + } + +void PEFile::GetRelocs(TUint *aReloc, TUint *aRelocSection, TInt /*aNumberOfRelocs*/) +// +// load the relocs from the reloc section into relocation and relocsection arrays +// + { + + TUint *relocation=aReloc; + TUint *relocsection=aRelocSection; + char *aRelocData=iSectionData[KRelocSection]; + + TUint16 *relocs=(TUint16 *)aRelocData; + TInt relocsize=iSectionHeader[KRelocSection]->Misc.VirtualSize; + TUint offset; + TUint page; + TInt i=0; + + TUint *rrelocs=(TUint *)aRelocData; + TUint ssize=relocsize; + if (!gLittleEndian) ByteSwap(rrelocs, ssize); + + while (relocsize>0) + { + page=*(TUint *)relocs; + relocs+=2; + TInt size=*(TUint *)relocs; + if (size==0) + break; + relocsize-=size; + relocs+=2; + size-=8; + while (size>0) + { + offset=*relocs++; + TInt type=offset&0xf000; + if (type==0x3000) + { + TUint va=page+(offset&0xfff); + + // va is the address requiring relocation, so it must be in a section and can't have been offset + TInt section=FindSectionByVa(va+iLinkedBase); + if (section==KTextSection || section==KConstSection || section==KDataSection || section==KCrtSection) + { + relocsection[i]=section; + relocation[i++]=va; + } + } + size-=2; + } + } + + if (!gLittleEndian) ByteSwap(rrelocs, ssize); + } + +TInt PEFile::Normalise() +// +// Remove the MSVC anomalies +// + { + + // MSVC puts export data in with .rdata + if (iExportDataDir && iSectionHeader[KExportSection]==NULL) + { + if (!PEFile::VirtualAddressInSection(iExportDataDir+iLinkedBase, iSectionHeader[KConstSection])) + return Print(EError, "Can't find exports in this PE file.\n"); + else + { + iSectionHeader[KExportSection]=new IMAGE_SECTION_HEADER; + iSectionHeader[KExportSection]->VirtualAddress=iExportDataDir; + iSectionHeader[KExportSection]->Misc.VirtualSize=iExportDirSize; + iSectionHeader[KExportSection]->SizeOfRawData=iExportDirSize; + iSectionData[KExportSection]=new char [iExportDirSize]; + if (iSectionData[KExportSection]==NULL) + return Print(EError, "Out of memory.\n"); + memcpy(iSectionData[KExportSection], iSectionData[KConstSection]+iExportDataDir-iSectionHeader[KConstSection]->VirtualAddress, iExportDirSize); + // adjust .rdata so it does not include .edata + iSectionHeader[KConstSection]->Misc.VirtualSize-=iExportDirSize; + iSectionHeader[KConstSection]->SizeOfRawData-=iExportDirSize; + char *c=new char [iSectionHeader[KConstSection]->SizeOfRawData]; + if (c==NULL) + return Print(EError, "Out of memory.\n"); + memcpy(c, iSectionData[KConstSection], iSectionHeader[KConstSection]->SizeOfRawData); + delete iSectionData[KConstSection]; + iSectionData[KConstSection]=c; + } + } + // Stupid compilers generate .idata sections even when there are no imports + if (iSectionHeader[KImportSection]) + { + if (NumberOfImports()==0) + { + delete iSectionHeader[KImportSection]; + delete iSectionData[KImportSection]; + iSectionHeader[KImportSection]=NULL; + iSectionData[KImportSection]=NULL; + } + } + return KErrNone; + } + + +TInt PEFile::HasInitialisedData(PIMAGE_SECTION_HEADER aHeader) +// +// Returns true if the pe file section contains any initialised data +// + { + + if (aHeader==NULL) + return FALSE; + if (aHeader->SizeOfRawData==0) + return FALSE; + return TRUE; + } + +void PEFile::CopySectionData(TAny *source, TAny *dest, TUint32 fileLength, TUint32 memLength) + { + + if (fileLength <= memLength) + { + Print(EScreen," Copying %08x bytes from file at %08x to memory at %08x\n", fileLength, source, dest); + HMem::Copy(dest,source,fileLength); + dest = (TAny *)((TUint32)dest + fileLength); + TUint32 remainingSize = memLength - fileLength; + Print(EScreen," Zeroing remaining %08x bytes at %08x\n", remainingSize, dest); + HMem::Set(dest, 0, remainingSize); + } + else + { + Print(EScreen," Copying %08x bytes from file at %08x to memory at %08x\n", memLength, source, dest); + HMem::Copy(dest,source,memLength); + } + } + + +TBool PEFile::ProcessRelocData(TAny *relocData,TInt dataSize) + { + + TBool hadBadRelocs=EFalse; + PIMAGE_BASE_RELOCATION pRelocData = (PIMAGE_BASE_RELOCATION)((TUint32)relocData); + Print(ELog," Info on .reloc section...\n"); + + while (pRelocData->SizeOfBlock != 0) + { + TUint16 relocType; + TUint32 relocOffset; + TUint32 *relocAddr; + + Print(ELog," Virtual address: %08x size: %08x\n",pRelocData->VirtualAddress, pRelocData->SizeOfBlock); + + TUint numEntries = (pRelocData->SizeOfBlock-sizeof(*pRelocData))/sizeof(TUint16); + TUint16 *pEntry = (TUint16 *)((TUint32)pRelocData+sizeof(*pRelocData)); + + for (TUint i=0; i>12); + // The rest of the field is the offset + relocOffset = (*pEntry & 0x0FFF); + switch (relocType) + { + case 0: // Just padding + pEntry++; + break; + + case 1: + case 2: + case 4: + case 5: + Print(EPeError,".reloc section, relocation type not handled.\n"); + return EFalse; + break; + + case 3: + { + if (pRelocData->VirtualAddress==0) // Defect in .reloc section of arm ekern.exe + { + pEntry++; + break; + } + TUint thisReloc=0; + relocAddr = (TUint32 *)((TUint32)iMemBase + (TUint32)pRelocData->VirtualAddress + relocOffset); + TUint32 reloc = *relocAddr; + + if (IsInCode((TUint32)relocAddr) || IsInData((TUint32)relocAddr)) + { + if (IsInDataReloc(reloc)) + { + if (iImageIsDll) + { + Print(EPeError,"Dlls should have no RAM (data) relocations.\n"); + return(EFalse); + } + thisReloc=reloc+iRamDelta; + } + else + thisReloc=reloc+iRomDelta; + *relocAddr = thisReloc; // this line here to enable breaking on values of thisReloc + } + else + hadBadRelocs=ETrue; + pEntry++; + } + break; + default: + Print(EPeError,".reloc section, invalid relocation type.\n"); + return(EFalse); + } + } + dataSize-=pRelocData->SizeOfBlock; + if(dataSize<=0) + break; + pRelocData = (PIMAGE_BASE_RELOCATION)((TUint32)pRelocData+pRelocData->SizeOfBlock); + } + + if (hadBadRelocs) + Print(EPeError,"File %s has relocation in invalid section\n",iFileName); + return(ETrue); + } + +TBool PEFile::IsInCode(TUint32 anAddr) + { + if ((anAddr>=iCodeSectionAddr) && (anAddr<(iCodeSectionAddr+iCodeSectionSize))) + return(ETrue); + if ((anAddr>=iRDataSectionAddr) && (anAddr<(iRDataSectionAddr+iRDataSectionSize))) + return(ETrue); + if ((anAddr>=iCRTSectionAddr) && (anAddr<(iCRTSectionAddr+iCRTSectionSize))) + return(ETrue); + return(EFalse); + } + +TBool PEFile::IsInData(TUint32 anAddr) + { + if ((anAddr>=iDataSectionAddr) && (anAddr<(iDataSectionAddr+iDataSectionSize))) + return(ETrue); + if ((anAddr>=iBssSectionAddr) && (anAddr<(iBssSectionAddr+iBssSectionSize))) + return(ETrue); + return(EFalse); + } + +TBool PEFile::IsInDataReloc(TUint32 anAddr) + { + if ((anAddr>=iDataSectionLinkedAddr) && (anAddr<(iDataSectionLinkedAddr+iDataSectionSize))) + return(ETrue); + if ((anAddr>=iBssSectionLinkedAddr) && (anAddr<(iBssSectionLinkedAddr+iBssSectionSize))) + return(ETrue); + return(EFalse); + } + + +TBool PEFile::IsValidDOSHeader(PIMAGE_DOS_HEADER aDOSHeader) + { + if (aDOSHeader->e_magic!=IMAGE_DOS_SIGNATURE) + { + Print(EPeError,"File does not have valid DOS MZ signature.\n"); + return EFalse; + } + else + return ETrue; + } + + + +TBool PEFile::IsValidNTHeader(PIMAGE_NT_HEADERS aNTHeader) + { + if (aNTHeader->Signature != IMAGE_NT_SIGNATURE ) + { + Print(EPeError,"File does not have valid NT PE signature.\n"); + return EFalse; + } + else + return ETrue; + } + + +TBool PEFile::IsValidFileHeader(PIMAGE_FILE_HEADER aFileHeader) + { + if ((aFileHeader->Machine != IMAGE_FILE_MACHINE_I386) + && (aFileHeader->Machine != 0xa00) + && (aFileHeader->Machine != 0xb00) + && (aFileHeader->Machine !=IMAGE_FILE_MACHINE_ALPHA)) + { + Print(EPeError,"File is not a valid i386, ARM, M*Core or ALPHA executable.\n"); + return EFalse; + } + + if (aFileHeader->SizeOfOptionalHeader == 0) + { + Print(EPeError,"Optional header is 0 bytes in length - this is probably an object, not an executable\n"); + return EFalse; + } + + if (!(aFileHeader->Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE)) + { + Print(EPeError,"File is not a valid executable - probably linker error\n"); + return EFalse; + } + + return ETrue; + } + + +// Get details of the next import to fix-up in the current file. Fill in the name of the dll +//it is imported from, the ordinal number and the address to write back to. +#define ORDINAL_DONE 0x40000000 + +TImportStat PEFile::GetNextImport(char * &aDllName, TUint16 &aOrdinal, TUint32 * &aThunk) + { + PIMAGE_THUNK_DATA pLookupTable = 0; + TUint32 *pThunk = 0; + TUint32 rawOrdinal = ORDINAL_DONE; + TImportStat res = EImpDone; + PIMAGE_IMPORT_DESCRIPTOR impDesc = iImpDescriptor; + char *expDllName = 0; + + if (impDesc == 0) + return EImpDone; // This file imports nothing + + while ((rawOrdinal & ORDINAL_DONE) && ((impDesc->TimeDateStamp!=0 ) || (impDesc->Name!=0))) + { + expDllName = (char *)(iMemBase + impDesc->Name); + pLookupTable = (PIMAGE_THUNK_DATA)(iMemBase + impDesc->Characteristics); + pThunk = (TUint32 *)(iMemBase + (TUint32)impDesc->FirstThunk); + while ((rawOrdinal & ORDINAL_DONE) && (pLookupTable->u1.AddressOfData != 0)) + { + if (pLookupTable->u1.Ordinal & IMAGE_ORDINAL_FLAG ) + rawOrdinal = pLookupTable->u1.Ordinal; + else + { + Print(EPeError,"in file %s\n",iFileName); + Print(EPeError,"It is importing a symbol by name from %s\n",expDllName); + return EImpError; + } + pThunk++; + pLookupTable++; + } + impDesc++; + } + + if (!(rawOrdinal & ORDINAL_DONE)) + { + pThunk--; + pLookupTable--; + res = EImpSuccess; + aDllName = expDllName; + aThunk = pThunk; + aOrdinal = (TUint16)(rawOrdinal & 0xFFFF); + pLookupTable->u1.Ordinal |= ORDINAL_DONE; + } + + return res; + } + +TUint32 PEFile::GetFixUp(const TUint16 aOrdinal) +// +// Look through export directory to find fix-up for given ordinal +// + { + + TUint32 ordBase = iExpDirectory->Base; + TUint32 *functions = (TUint32 *)((TUint32)iExpDirectory->AddressOfFunctions + iMemBase); + TUint32 fixupAddr = functions[aOrdinal-ordBase] + iRomRunAddr; + return fixupAddr; + } + +TUint PEFile::GetNumberOfExportedFunctions() + { + + return iExpDirectory->NumberOfFunctions; + } + + +TUint PEFile::GetOrdinalBase() + { + + return iExpDirectory->Base; + } + + +TBool PEFile::ExportSectionExists() + { + + if (iExpDirectory) + return ETrue; + else + return EFalse; + } + + +TBool PEFile::ImportSectionExists() + { + + if (iImpDescriptor) + return ETrue; + else + return EFalse; + } + + +TUint PEFile::RoundToSectionSize(TUint aSize) +// +// Round to the nearest size in sections +// + { + TUint sAlign = iSectionAlign; + return ((aSize+sAlign-1)/sAlign)*sAlign ; + } + + +void PEFile::DumpPeHeaders() +// +// Print out loads of stuff from the PE header +// + { + TInt err = HFile::Open(iFileName, &iFileHandle); + if (err!=0) + return; + + iHeader = (PIMAGE_NT_HEADERS)(HMem::Alloc(0,iSizeOfHeaders-iStartOfHeaders)); + if (!iHeader) + return; + + if (!HFile::Seek(iFileHandle, iStartOfHeaders)) + return; + + if (!HFile::Read(iFileHandle, iHeader, iSizeOfHeaders-iStartOfHeaders)) + return; + + PIMAGE_FILE_HEADER pFileHeader = (PIMAGE_FILE_HEADER)&iHeader->FileHeader; + PIMAGE_OPTIONAL_HEADER pOptionalHeader = (PIMAGE_OPTIONAL_HEADER)&iHeader->OptionalHeader; + PIMAGE_SECTION_HEADER pSectionHeader = (PIMAGE_SECTION_HEADER)(iHeader+1); + + printf("File header\n"); + printf("-----------\n\n"); + char *szMachine=0; + switch( pFileHeader->Machine ) + { + case 0xa00: + szMachine = (char *)"ARM"; break; + case 0xb00: + szMachine = (char *)"M*Core"; break; + case IMAGE_FILE_MACHINE_I386: + szMachine = (char *)"i386"; break; + case IMAGE_FILE_MACHINE_I860: + szMachine = (char *)"i860"; break; + case IMAGE_FILE_MACHINE_R3000: + szMachine = (char *)"R3000"; break; + case IMAGE_FILE_MACHINE_R4000: + szMachine = (char *)"R4000"; break; + case IMAGE_FILE_MACHINE_ALPHA: + szMachine = (char *)"Alpha"; break; + case IMAGE_FILE_MACHINE_POWERPC: + szMachine = (char *)"IBM PowerPC"; break; + default: + printf ("ERROR - machine not specified.\n"); + szMachine = (char *)"unknown"; + break; + } + + printf("\n Machine: %s (Id=%04x)",szMachine, pFileHeader->Machine); + if ((pFileHeader->Machine != 0xa00) // ARM + && (pFileHeader->Machine != 0xb00)) // M*Core + printf("..........ERROR!!"); + printf("\n Number of sections : %04x",pFileHeader->NumberOfSections); + printf("\n Time date stamp : %08lx",pFileHeader->TimeDateStamp); + if (pFileHeader->TimeDateStamp == 0) + printf("..........ERROR!!"); + printf("\n Pointer to symbol table : %08lx",pFileHeader->PointerToSymbolTable); + printf("\n Number of symbols : %08lx",pFileHeader->NumberOfSymbols); + printf("\n Size of optional header : %08x",pFileHeader->SizeOfOptionalHeader); + if (pFileHeader->SizeOfOptionalHeader == 0) + printf("..........ERROR!!"); + printf("\n Characteristics : %08x\n",pFileHeader->Characteristics); + if (pFileHeader->Characteristics & IMAGE_FILE_RELOCS_STRIPPED) + printf("\n Relocations stripped..........ERROR!!"); + if (pFileHeader->Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE) + printf("\n Executable image."); + else + printf("\n Not executable image..........ERROR!!"); + if (pFileHeader->Characteristics & IMAGE_FILE_CHAR_REVERSED_LO) + printf("\n Bytes reversed lo..........ERROR!!"); + if (pFileHeader->Characteristics & IMAGE_FILE_32BIT_MACHINE) + printf("\n 32bit image."); + else + printf("\n Not 32bit image..........ERROR!!"); + if (pFileHeader->Characteristics & IMAGE_FILE_SYSTEM) + printf("\n System file."); + if (pFileHeader->Characteristics & IMAGE_FILE_DLL) + printf("\n Dll file."); + if (pFileHeader->Characteristics & IMAGE_FILE_CHAR_REVERSED_HI) + printf("\n Bytes reversed hi..........ERROR!!"); + + + printf ("\n\n\nOptional Header\n"); + printf ("------------------"); + + printf("\n Magic = %04x", pOptionalHeader->Magic); + printf("\n Major Linker Version = %02x", pOptionalHeader->MajorLinkerVersion); + printf("\n Minor Linker Version = %02x", pOptionalHeader->MinorLinkerVersion); + printf("\n Size of code (bytes) = %08lx", pOptionalHeader->SizeOfCode); + printf("\n Size of initialized data (bytes) = %08lx", pOptionalHeader->SizeOfInitializedData); + printf("\n Size of uninitialized data (bytes) = %08lx", pOptionalHeader->SizeOfUninitializedData); + printf("\n Entrypoint RVA = %08lx", pOptionalHeader->AddressOfEntryPoint); + if (pOptionalHeader->AddressOfEntryPoint & 0x80000000) + printf("..........ERROR!!"); + printf("\n Base of code = %08lx", pOptionalHeader->BaseOfCode); + if (pOptionalHeader->BaseOfCode & 0x80000000) + printf("..........ERROR!!"); + printf("\n Base of data = %08lx", pOptionalHeader->BaseOfData); + if (pOptionalHeader->BaseOfData & 0x80000000) + printf("..........ERROR!!"); + printf("\n Image base = %08lx", pOptionalHeader->ImageBase); + if (pOptionalHeader->ImageBase & 0x80000000) + printf("..........ERROR!!"); + printf("\n Section alignment (bytes) = %08lx",pOptionalHeader->SectionAlignment); + if (pOptionalHeader->SectionAlignment & 0x80000000) + printf("..........ERROR!!\n"); + printf("\n File alignment (bytes) = %08lx", pOptionalHeader->FileAlignment); + if (pOptionalHeader->FileAlignment & 0x80000000) + printf("..........ERROR!!"); + printf("\n Major Operating System Version = %04x", pOptionalHeader->MajorOperatingSystemVersion); + printf("\n Minor Operating System Version = %04x", pOptionalHeader->MinorOperatingSystemVersion); + printf("\n Major Image Version = %04x", pOptionalHeader->MajorImageVersion); + printf("\n Minor Image Version = %04x", pOptionalHeader->MinorImageVersion); + printf("\n Major Subsystem Version = %04x", pOptionalHeader->MajorSubsystemVersion); + printf("\n Minor Subsystem Version = %04x", pOptionalHeader->MinorSubsystemVersion); + + printf("\n Size of image (bytes) = %08lx", pOptionalHeader->SizeOfImage); + if (pOptionalHeader->SizeOfImage & 0x80000000) + printf("..........ERROR!!"); + printf("\n Size of headers (bytes) = %08lx",pOptionalHeader->SizeOfHeaders); + if (pOptionalHeader->SizeOfHeaders & 0x80000000) + printf("..........ERROR!!"); + printf("\n CheckSum = %04lx", pOptionalHeader->CheckSum); + printf("\n Subsystem = %04x", pOptionalHeader->Subsystem); + printf("\n Dll Characteristics = %04x", pOptionalHeader->DllCharacteristics); + printf("\n Size Of Stack Reserve = %04lx", pOptionalHeader->SizeOfStackReserve); + printf("\n Size Of Stack Commit = %04lx", pOptionalHeader->SizeOfStackCommit); + printf("\n Size Of Heap Reserve = %04lx", pOptionalHeader->SizeOfHeapReserve); + printf("\n Size Of Heap Commit = %04lx", pOptionalHeader->SizeOfHeapCommit); + printf("\n Loader Flags = %04lx", pOptionalHeader->LoaderFlags); + printf("\n Number Of Rva and Sizes = %04lx", pOptionalHeader->NumberOfRvaAndSizes); + + printf("\n\n\nSection Headers\n"); + printf("---------------\n\n"); + + for (TUint i=0;iName); + printf("\n Virtual size : %08lx", pSectionHeader->Misc.VirtualSize); + printf("\n RVA of section data : %08lx", pSectionHeader->VirtualAddress); + if (pSectionHeader->VirtualAddress & 0x80000000) + printf("..........ERROR!!"); + printf("\n Size of raw data : %08lx", pSectionHeader->SizeOfRawData); + printf("\n Pointer to raw data : %08lx", pSectionHeader->PointerToRawData); + printf("\n Characteristics: %08lx\n", pSectionHeader->Characteristics); + if (pSectionHeader->Characteristics & IMAGE_SCN_LNK_REMOVE) + printf("\nERROR - Section should have been removed by linker.\n"); + + // read the section in + TUint32 filePos = pSectionHeader->PointerToRawData; + TUint32 fileLength = pSectionHeader->SizeOfRawData; +// TUint32 memLength = pSectionHeader->Misc.VirtualSize; + TAny *sectionFile = HMem::Alloc((TAny *)0, fileLength); // get a buffer + HFile::Seek(iFileHandle, filePos); + HFile::Read(iFileHandle, sectionFile, fileLength); // and read the file into the buffer +// TAny *sectionMem = (TAny *)((TUint32)iMemBase + pSectionHeader->VirtualAddress); + + if (strnicmp((const char *)pSectionHeader->Name, ".text", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + hadText = ETrue; + if (!(pSectionHeader->Characteristics & IMAGE_SCN_CNT_CODE)) + printf("\nERROR - Code section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_EXECUTE)) + printf("\nERROR - Code section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_READ)) + printf("\nERROR - Code section has incorrect characteristics.\n"); + } + else if (strnicmp((const char *)pSectionHeader->Name, ".data", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + if (iImageIsDll) + { + printf ("\nERROR - DLL has data section.\n"); + } + else + { + if (!(pSectionHeader->Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA)) + printf("\nERROR - data section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_WRITE)) + printf("\nERROR - data section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_READ)) + printf("\nERROR - data section has incorrect characteristics.\n"); + } + } + else if (strnicmp((const char *)pSectionHeader->Name, ".rdata", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + } + else if (strnicmp((const char *)pSectionHeader->Name, ".bss", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + if (iImageIsDll) + { + printf ("\nERROR - DLL has bss section.\n"); + } + else + { + if (!(pSectionHeader->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)) + printf("\nERROR - BSS section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_WRITE)) + printf("\nERROR - BSS section has incorrect characteristics.\n"); + else if (!(pSectionHeader->Characteristics & IMAGE_SCN_MEM_READ)) + printf("\nERROR - BSS section has incorrect characteristics.\n"); + } + } + else if (strnicmp((const char *)pSectionHeader->Name, ".reloc", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + hadReloc = ETrue; + } + else if (strnicmp((const char *)pSectionHeader->Name, ".idata", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + } + else if (strnicmp((const char *)pSectionHeader->Name, ".edata", IMAGE_SIZEOF_SHORT_NAME) == 0) + { + iExpDirectory = (PIMAGE_EXPORT_DIRECTORY)(sectionFile); + if (iImageIsDll) + { + printf("\n Ordinal base = %08lx", iExpDirectory->Base); + printf("\n Number of functions = %08lx", iExpDirectory->NumberOfFunctions); + printf("\n Number of names = %08lx", iExpDirectory->NumberOfNames); + printf("\n Export address table RVA = %08lx", (TUint32)iExpDirectory->AddressOfFunctions); + printf("\n Name pointer RVA = %08lx", (TUint32)iExpDirectory->AddressOfNames); + printf("\n Ordinal table RVA = %08lx", (TUint32)iExpDirectory->AddressOfNameOrdinals); + } + else + { + printf("\nERROR - non-DLL with export section."); + } + } + else + { + printf("\nERROR - unexpected section."); + } + + HMem::Free(sectionFile); + return; + } + diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/pefile/pe_imp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pefile/pe_imp.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,235 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include +#include +#include "h_utl.h" +#include "pe_file.h" + +TInt E32ImageFile_PE::CopyImportAddrTable(char *aPtr, PEFile &aPeFile) +// +// Copy the import address table entries +// + { + + TUint *ptr=(TUint *)aPtr; + char *importsection=aPeFile.iSectionData[KImportSection]; + TUint *src=(TUint *)importsection; + while (*src) + { + TUint vaoffset=src[4]; + if (!gLittleEndian) ByteSwap(vaoffset); + TUint offset=vaoffset-aPeFile.iSectionHeader[KImportSection]->VirtualAddress; // find the offset into the section of import addr table + vaoffset=src[3]; + if (!gLittleEndian) ByteSwap(vaoffset); + TUint exportername=vaoffset-aPeFile.iSectionHeader[KImportSection]->VirtualAddress; + TUint *p=(TUint *)(importsection+offset); + while (*p) + { + if ((*p&0x80000000)==0) + { + Print(EError, "%s exporting symbol by name\n", importsection+exportername); + return KErrGeneral; + } + *ptr++=(*p++)&0x7fffffff; // mask out the high bit (- indicates export by ordinal) + } + src+=5; + } + *ptr++=0; + return KErrNone; + } + +extern char* gX86imp; +extern int gX86num_imports; +extern int gX86num_imp_dlls; +extern int gX86imp_size; +int* gX86imp_relocs=NULL; + +TInt CrunchImportSection(TAny* aSection, TInt aNumImpDlls, TInt aNumImports) + { + // Remove lists of ordinals from import section + TInt* d = (TInt*)aSection; + TInt orig_size = *d; + TInt offset_correction = aNumImports*sizeof(TUint); + *d -= offset_correction; // reduce total section size + TInt *dd = d+1; + TInt *ss = d+1; + + TInt i; + for (i=0; i>2; + *s=rdata[rdata_int_offset]&0x7fffffffu; // rdata offset to ordinal + gX86imp_relocs[rdata_int_offset]=j<<2; + ++j; + ++s; + } + } + *(TInt*)section = bytecount; + aSize = CrunchImportSection(section, gX86num_imp_dlls, total_imports); + return section; + } + PIMAGE_SECTION_HEADER aHeader=aPeFile.iSectionHeader[KImportSection]; + TUint *aSrc=(TUint *)aPeFile.iSectionData[KImportSection]; + + TInt nimportdlls=aPeFile.NumberOfImportDlls(); + if (nimportdlls==0) + { + aSize=0; + return NULL; + } + E32ImportBlock *block=new E32ImportBlock [nimportdlls]; + char **name=new char* [nimportdlls]; + TUint **import=new TUint* [nimportdlls]; + + TInt bytecount=sizeof(E32ImportSection)+sizeof(E32ImportBlock)*nimportdlls; + TUint *src=aSrc; + TInt i; + for (i=0; iVirtualAddress; // find the offset into the section of import addr table + TUint *p=aSrc+offset/4; + block[i].iNumberOfImports=0; + while (*p++) + block[i].iNumberOfImports++; + total_imports += block[i].iNumberOfImports; + import[i]=new TUint [block[i].iNumberOfImports]; + TInt j; + p=aSrc+offset/4; + for (j=0; jVirtualAddress; + name[i]=((char *)aSrc)+offset; + bytecount+=strlen(name[i])+1; + src+=5; + } + + bytecount=ALIGN4(bytecount); + char *section=new char [bytecount]; + char *s=section+sizeof(E32ImportSection); + for (i=0; iiOffsetOfDllName=s-section; + strcpy(s, name[i]); + s+=strlen(name[i])+1; + t += ((E32ImportBlock *)t)->iNumberOfImports * sizeof(TUint) + sizeof(E32ImportBlock); + } + while ((s-section)VirtualAddress; + + while (iatVirtualAddress; + } + else + { + n++; + iat+=4; + } + } + + // Flag errors brought about by a corrupt input binary + if (iat>va) + { + Print(EError, "%s is corrupt - problem processing import address table.\n", this->iFileName); + return (TUint)KErrGeneral; + } + + return iHdr->iTextSize+n*sizeof(TUint); + } + diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/pefile/pe_reloc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pefile/pe_reloc.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,374 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include +#include +#include "pe_file.h" +#include "h_utl.h" +#include + +extern char* gX86imp; +extern int gX86num_imp_dlls; +extern int gX86imp_size; +extern int gX86num_imports; +extern int* gX86imp_relocs; + +TInt sizeOfCodeRelocs(TUint *relocs, TUint *relocsection, TInt nrelocs) + { + + TInt bytecount=0; + TInt page=-1; + TInt i; + for (i=0; iiNumberOfRelocs=ncoderelocs; + ((E32RelocSection *)section)->iSize=bytecount; + return section; + } + +char *E32ImageFile_PE::CreateDataRelocs(TUint *relocs, TUint *relocsection, TInt nrelocs, TInt &aSize) + { + + TInt bytecount=sizeOfDataRelocs(relocs, relocsection, nrelocs); + aSize=0; + if (bytecount==0) + return NULL; + aSize=bytecount+sizeof(E32RelocSection); + + char *section=new char [bytecount+sizeof(E32RelocSection)]; + char *data=section+sizeof(E32RelocSection); + char *startofblock=data; + + TInt ndatarelocs=0; + TInt page=-1; + TInt pagesize=8; + TInt i; + for (i=0; iiNumberOfRelocs=ndatarelocs; + ((E32RelocSection *)section)->iSize=bytecount; + return section; + } + +void checkreloc(PEFile &aPeFile, TUint va, TUint reloc) + { + + // Allow the section find routine to use heuristics to resolve addresses + // which have been offset by the compiler + TInt s = aPeFile.FindSectionByVa(va, 1); + switch(s) + { + case KTextSection: + case KConstSection: + case KDataSection: + case KCrtSection: + case KBssSection: + case KImportSection: + return; + default: + break; + } + Print(EAlways, "bad relocation: [%08x] = %08x\n", reloc, va); + } + +void E32ImageFile_PE::FixRelocs(PEFile &aPeFile, TUint *relocation, TUint *relocsection, TInt aNumberOfRelocs) + { + + TUint *data; + TInt i; +#if 0 + Print(EAlways, "Linked base %08x\n", aPeFile.iLinkedBase); + for (i=0; iVirtualAddress; + TUint finish = start + aPeFile.iSectionHeader[i]->Misc.VirtualSize; + Print(EAlways, "Section %d %08x-%08x\n", i, start, finish); + } +#endif + for (i=0; iVirtualAddress; + data=(TUint *)(aPeFile.iSectionData[KTextSection]+relocation[i]); + if (!gLittleEndian) ByteSwap(*data); + checkreloc(aPeFile, *data, relocation[i]+aPeFile.iSectionHeader[KTextSection]->VirtualAddress); + *data=FixAddress(aPeFile, *data); + if (!gLittleEndian) ByteSwap(*data); + break; + case KConstSection: + relocation[i]-=aPeFile.iSectionHeader[KConstSection]->VirtualAddress; + data=(TUint *)(aPeFile.iSectionData[KConstSection]+relocation[i]); + if (!gLittleEndian) ByteSwap(*data); + checkreloc(aPeFile, *data, relocation[i]+aPeFile.iSectionHeader[KConstSection]->VirtualAddress); + relocation[i]+=ConstOffset(); + *data=FixAddress(aPeFile, *data); + if (!gLittleEndian) ByteSwap(*data); + break; + case KCrtSection: + relocation[i]-=aPeFile.iSectionHeader[KCrtSection]->VirtualAddress; + data=(TUint *)(aPeFile.iSectionData[KCrtSection]+relocation[i]); + if (!gLittleEndian) ByteSwap(*data); + checkreloc(aPeFile, *data, relocation[i]+aPeFile.iSectionHeader[KCrtSection]->VirtualAddress); + relocation[i]+=iCrtOffset; + *data=FixAddress(aPeFile, *data); + if (!gLittleEndian) ByteSwap(*data); + break; + case KDataSection: + relocation[i]-=aPeFile.iSectionHeader[KDataSection]->VirtualAddress; + data=(TUint *)(aPeFile.iSectionData[KDataSection]+relocation[i]); + if (!gLittleEndian) ByteSwap(*data); + checkreloc(aPeFile, *data, relocation[i]+aPeFile.iSectionHeader[KDataSection]->VirtualAddress); + *data=FixAddress(aPeFile, *data); + if (!gLittleEndian) ByteSwap(*data); + break; + default: + Print(EWarning, "Relocation in invalid section.\n"); + break; + } + } + reorderRelocs(relocation, relocsection, aNumberOfRelocs); + } + +TUint E32ImageFile_PE::FixAddress(PEFile &aPeFile, TUint va) +// +// Fix the given virtual address for the new headers +// + { + + // Allow the section find routine to use heuristics to resolve addresses + // which have been offset by the compiler + TInt section=aPeFile.FindSectionByVa(va, 1); + switch(section) + { + case KTextSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KTextSection]->VirtualAddress; + va+=iHdr->iCodeBase; + break; + case KConstSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KConstSection]->VirtualAddress; + if (gX86imp) + { + TUint old_iat_size=(gX86num_imports+gX86num_imp_dlls)<<2; + if (vaiTextSize; +// fprintf(stderr,"IAT OFF %x ",va); + va=gX86imp_relocs[va>>2]+iHdr->iCodeBase+offset; +// fprintf(stderr,"-> %x\n",va); + break; + } + } + va+=iHdr->iCodeBase+ConstOffset(); +// fprintf(stderr,"const reloc -> %x\n",va); + break; + case KDataSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KDataSection]->VirtualAddress; + va+=iHdr->iDataBase; //DataOffset(); + break; + case KCrtSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KCrtSection]->VirtualAddress; + va+=iHdr->iCodeBase+iCrtOffset; + break; + case KBssSection: + va-=aPeFile.iLinkedBase; + va-=aPeFile.iSectionHeader[KBssSection]->VirtualAddress; + va+=iHdr->iDataBase+iHdr->iDataSize; + break; + case KImportSection: + va-=aPeFile.iLinkedBase; + va=FixImportThunk(aPeFile, va-aPeFile.iSectionHeader[KImportSection]->VirtualAddress); + va+=iHdr->iCodeBase; + break; + default: + if (va < 0x10000u) + { + // assume it's a relocation relative to an omitted section + break; + } + Print(EWarning, "Address to relocate cannot be resolved to .text, .rdata, .idata or data sections\n"); + Print(EWarning, "Problem address = %08x (section %d)\n", va, section); + break; + } + // va is now an offset from the start of the text + return va; + } + + diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/pefile/pe_tran.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pefile/pe_tran.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,453 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include +#include "e32image.h" +#include +#include +#include "pe_defs.h" +#include "pe_file.h" +#include "h_ver.h" +#include "h_utl.h" + +int gAlignConstSection=FALSE; +TUint gConstSectionAddressMask=0; +static TUint gRequiredConstPadding; + +extern char* gX86imp; +extern int gX86num_imp_dlls; +extern int gX86imp_size; +extern int gX86num_imports; + +E32ImageFile* E32ImageFile::New() + { + return new E32ImageFile_PE; + } + +E32ImageFile_PE::E32ImageFile_PE() + { + } + +E32ImageFile_PE::~E32ImageFile_PE() + { + } + +TUint E32ImageFile_PE::ImportAddressTableOffset() +// +// Return the offset of the iat +// + { + return iHdr->iTextSize; + } + +TUint E32ImageFile_PE::ConstOffset() +// +// return the offset of the const data +// + { + return iConstOffset; + } + +void E32ImageFile_PE::CreateExportDirectory(char *aPtr, PEFile &aPeFile) +// +// create a new format export directory +// + { + + if (iHdr->iExportDirCount==0) + return; + TUint *src=(TUint *)aPeFile.iSectionData[KExportSection]; + TUint *dst=(TUint *)aPtr; + PIMAGE_EXPORT_DIRECTORY dir=(PIMAGE_EXPORT_DIRECTORY)src; + src+=(((TInt)dir->AddressOfFunctions)-((TInt)aPeFile.iSectionHeader[KExportSection]->VirtualAddress))/4; + TUint i; + for (i=0; iNumberOfFunctions; i++) + { + TUint va=*src++; + dst[i]=va; + } + FixExportDirectory(dst, aPeFile); + } + +void E32ImageFile_PE::FixExportDirectory(TUint *aExportDir, PEFile &aPeFile) +// +// Fix the export directory +// + { + + TUint lb = aPeFile.iLinkedBase; + TUint *exportdir=aExportDir; + TInt n; + for (n=0; n<(TInt)iHdr->iExportDirCount; n++) + { + TUint va=*exportdir; + if (!gLittleEndian) ByteSwap(va); + + // va is the address of an exported item, so assume it can't have been offset + TInt i=aPeFile.FindSectionByVa(va+lb); + if (i==KTextSection) + va=va-aPeFile.iSectionHeader[i]->VirtualAddress; + else if (i==KConstSection) + va=va-aPeFile.iSectionHeader[i]->VirtualAddress+ConstOffset(); + else if (i==KDataSection) + va=va-aPeFile.iSectionHeader[i]->VirtualAddress+DataOffset(); + else if (i==KBssSection) + va=va-aPeFile.iSectionHeader[i]->VirtualAddress+BssOffset(); + else + { + if (va == 0) + Print(EWarning, "No export specified for ordinal %d\n", n+1, va); + else + Print(EError, "Export %d (address %08x) is not from .text, .rdata, or data sections\n", n+1, va); + } + if (!gLittleEndian) ByteSwap(va); + *exportdir++=va; + } + } + +TInt E32ImageFile_PE::DoCodeHeader(PEFile &aPeFile) +// +// Calculate the code parts of the pefile +// + { + + // .text + TInt size=ALIGN4(aPeFile.iSectionHeader[KTextSection]->Misc.VirtualSize); + + // .rdata + iConstOffset=0; + if (gAlignConstSection) + { + // Compute the amount of padding to put before the + // const section to align it correctly + TUint oldAddressBits = aPeFile.iSectionHeader[KConstSection]->VirtualAddress & gConstSectionAddressMask; + TUint oldConstAddress = size; + TUint newConstAddress = oldConstAddress; + // slow but sure + while ((newConstAddress & gConstSectionAddressMask) != oldAddressBits) + { + newConstAddress++; + } + gRequiredConstPadding = newConstAddress - oldConstAddress; + size += gRequiredConstPadding; + } + if (aPeFile.iSectionHeader[KConstSection]) + { + iConstOffset = size; + size += ALIGN4(aPeFile.iSectionHeader[KConstSection]->Misc.VirtualSize); + } + + // .crt + iCrtOffset=0; + if (aPeFile.iSectionHeader[KCrtSection]) + { + iCrtOffset = size; + size += ALIGN4(aPeFile.iSectionHeader[KCrtSection]->Misc.VirtualSize); + } + + iHdr->iTextSize=size; // The "text" part of the E32 code section combines PE's .text + .rdata + .crt. + // The remainder of the E32 code section is the IAT + export directory. + + // Import Address Table (IAT) + TInt nimports=gX86imp?gX86num_imports:aPeFile.NumberOfImports(); + if (nimports!=0) + size+=nimports*4+4; // null terminated + + // Export Dir + if (iHdr->iExportDirCount) + { + iHdr->iExportDirOffset = iHdr->iCodeOffset + size; + size += ALIGN4(iHdr->iExportDirCount*4); + } + iHdr->iCodeSize=size; + return size; + } + +TInt E32ImageFile_PE::DoDataHeader(PEFile &aPeFile, TUint aDataBase) +// +// +// + { + + if (aDataBase == (TUint)0) + aDataBase=iHdr->iCodeBase+iHdr->iCodeSize; + TInt size=0; + if (PEFile::HasInitialisedData(aPeFile.iSectionHeader[KDataSection])) + { + size=ALIGN4(aPeFile.iSectionHeader[KDataSection]->Misc.VirtualSize); + iHdr->iDataBase=aDataBase; + iHdr->iDataOffset = iHdr->iCodeOffset + iHdr->iCodeSize; + TInt bsssize=aPeFile.iSectionHeader[KDataSection]->Misc.VirtualSize-aPeFile.iSectionHeader[KDataSection]->SizeOfRawData; + // drop any uninitialised data + if (bsssize>0) + { + iHdr->iBssSize+=bsssize; + size=ALIGN4(aPeFile.iSectionHeader[KDataSection]->SizeOfRawData); + } + iHdr->iDataSize=size; + } + else if (aPeFile.iSectionHeader[KDataSection]) + { // just .bss + iHdr->iDataBase=aDataBase; + TInt bsssize=aPeFile.iSectionHeader[KDataSection]->Misc.VirtualSize; + iHdr->iBssSize+=bsssize; + } + if (aPeFile.iSectionHeader[KBssSection]) + { + iHdr->iBssSize+=ALIGN4(aPeFile.iSectionHeader[KBssSection]->Misc.VirtualSize); + if (iHdr->iDataBase==0) // .bss but no .data + iHdr->iDataBase=aDataBase; + } + return size; + } + +TInt E32ImageFile_PE::CopyCode(char *p, PEFile &aPeFile) +// +// Copies the files code sections to p +// returns the number of bytes copied or KErrGeneral +// + { + + // text + TInt size=aPeFile.iSectionHeader[KTextSection]->Misc.VirtualSize; + memcpy(p, aPeFile.iSectionData[KTextSection], size); + TInt text_offset=ALIGN4(size); + p+=text_offset; + + // rdata + if (aPeFile.iSectionData[KConstSection]) + { + if (gAlignConstSection) + { + // add padding ahead of const section + p += gRequiredConstPadding; + } + TInt size=ALIGN4(aPeFile.iSectionHeader[KConstSection]->Misc.VirtualSize); + memcpy(p, aPeFile.iSectionData[KConstSection], size); + p+=size; + } + if (aPeFile.iSectionData[KCrtSection]) + { + TInt size=ALIGN4(aPeFile.iSectionHeader[KCrtSection]->Misc.VirtualSize); + memcpy(p, aPeFile.iSectionData[KCrtSection], size); + p+=size; + } + + // iat + TInt nimports=gX86imp?gX86num_imports:aPeFile.NumberOfImports(); +// TInt nimports=aPeFile.NumberOfImports(); + if (nimports) + { + if (gX86imp) + { + TUint *rdata=(TUint*)aPeFile.iSectionData[KConstSection]; + int i; + int* s=(int*)gX86imp; + s++; + for (i=0; i>2]&0x7fffffffu; // rdata offset to ordinal + ++s; + p+=4; + } + } + *(int*)p=0; + p+=4; + } + else + { + TInt r=CopyImportAddrTable(p, aPeFile); + p+=ALIGN4(nimports*4+4); + if (r!=KErrNone) + return Print(EError, "%s is importing symbols by name.\n", iFileName); + } + } + // export dir + CreateExportDirectory(p, aPeFile); + p+=iHdr->iExportDirCount*4; + return iHdr->iCodeSize; + } + +TInt E32ImageFile_PE::CopyData(char *p, PEFile &aPeFile) + { + + if (iHdr->iDataSize) + memcpy(p, aPeFile.iSectionData[KDataSection], iHdr->iDataSize); + return iHdr->iDataSize; + } + +TInt E32ImageFile_PE::Translate(const char* aFileName, TUint aDataBase, TBool aAllowDllData, TBool /*aSymLkupEnabled*/) +// +// Translate a PE format file to a E32Image file +// + { + iSource = EPeFile; + PEFile pefile; + if (!pefile.Init((const char * const)aFileName)) + return KErrGeneral; + TInt r=pefile.ReadSectionHeaders(); + if (r!=KErrNone) return r; + r=pefile.ReadData(); + if (r!=KErrNone) return r; + pefile.Close(); + r=pefile.Normalise(); + if (r!=KErrNone) return r; + iFileName = strdup(aFileName); + + Adjust(ALIGN4(sizeof(E32ImageHeaderV))); // fixed for now because holes not supported + SetDefaultHeader(); + if (gX86imp) + iHdr->iDllRefTableCount=gX86num_imp_dlls; + else + iHdr->iDllRefTableCount=pefile.NumberOfImportDlls(); + iHdr->iExportDirCount=pefile.NumberOfExports(); + iHdr->iCodeBase=pefile.iLinkedBase; + TInt nimports=gX86imp?gX86num_imports:pefile.NumberOfImports(); + + TInt importSectionSize; + char *newImportSection=CreateImportSection(pefile, importSectionSize); + + TInt size = ALIGN4(sizeof(E32ImageHeaderV)); // fixed for now because holes not supported + iHdr->iCodeOffset = size; + TInt pos = size; + size+=DoCodeHeader(pefile); + TInt t=DoDataHeader(pefile, aDataBase); + if (t>0) + { + iHdr->iDataOffset = size; + size += t; + } + if (importSectionSize!=0) + { + iHdr->iImportOffset = size; + size += importSectionSize; + } + + char *newCodeRelocs=NULL; + char *newDataRelocs=NULL; + TInt codeRelocSize=0, dataRelocSize=0; + TInt nrelocs=pefile.NumberOfRelocs(); + if (nrelocs) + { + TUint *relocs=new TUint [nrelocs]; + TUint *relocsection=new TUint [nrelocs]; + pefile.GetRelocs(relocs, relocsection, nrelocs); + FixRelocs(pefile, relocs, relocsection, nrelocs); + newCodeRelocs=CreateCodeRelocs(relocs, relocsection, nrelocs, codeRelocSize); + newDataRelocs=CreateDataRelocs(relocs, relocsection, nrelocs, dataRelocSize); + if (codeRelocSize) + { + iHdr->iCodeRelocOffset = size; + size += codeRelocSize; + } + if (dataRelocSize) + { + iHdr->iDataRelocOffset = size; + size += dataRelocSize; + } + delete [] relocs; + delete [] relocsection; + } + + Adjust(size); + t=CopyCode(iData + pos, pefile); + if (t<0) + return KErrGeneral; + pos += t; + pos += CopyData(iData + pos, pefile); + if (nimports) + { + memcpy(iData + pos, newImportSection, importSectionSize); + pos += importSectionSize; + } + if (codeRelocSize) + { + memcpy(iData + pos, newCodeRelocs, codeRelocSize); + pos += codeRelocSize; + } + if (dataRelocSize) + { + memcpy(iData + pos, newDataRelocs, dataRelocSize); + pos += dataRelocSize; + } + + // locate the entry point + // entry point must be in the text section + TInt entryPointSectionIndex=pefile.FindSectionByVa(pefile.iEntryPoint+pefile.iLinkedBase); + TUint entryPointOffset=pefile.iEntryPoint-pefile.iSectionHeader[entryPointSectionIndex]->VirtualAddress; + if (entryPointSectionIndex!=KTextSection) + return Print(EError, "Entry Point not in code section\n"); + + // Arrange a header for this E32 Image + switch (pefile.iCpu) + { + case IMAGE_FILE_MACHINE_I386: + iHdr->iCpuIdentifier = (TUint16)ECpuX86; + break; + case 0x0a00: + iHdr->iCpuIdentifier = (TUint16)ECpuArmV4; + break; + case 0x0b00: + iHdr->iCpuIdentifier = (TUint16)ECpuMCore; + break; + default: + iHdr->iCpuIdentifier = (TUint16)ECpuUnknown; + break; + } + + // Import format is PE-derived without redundant ordinal lists + // ABI is GCC98r2 ABI (on ARM) + iHdr->iFlags |= KImageImpFmt_PE2; + + if (pefile.iImageIsDll) + { + iHdr->iFlags|=KImageDll; + if (iHdr->iDataSize && !aAllowDllData) + return Print(EError, "Dll '%s' has initialised data.\n", iFileName); + if (iHdr->iBssSize && !aAllowDllData) + return Print(EError, "Dll '%s' has uninitialised data.\n", iFileName); + } + iHdr->iHeapSizeMin=pefile.iHeapCommittedSize; + iHdr->iHeapSizeMax=pefile.iHeapReservedSize; + iHdr->iStackSize=pefile.iStackCommittedSize; + iHdr->iEntryPoint=entryPointOffset; + r = DetermineEntryPointType(); + if (r == KErrCorrupt) + return Print(EError, "File '%s': Bad Entry Point.\n", iFileName); + else if (r == KErrNotSupported) + return Print(EError, "File '%s': Bad Entry Point Type.\n", iFileName); + + delete [] newImportSection; + delete [] newCodeRelocs; + delete [] newDataRelocs; + + return KErrNone; + } + +TBool E32ImageFile_PE::Translate(PEFile &aPeFile) +// +// +// + { + + return Translate((const char*)aPeFile.iFileName, (TUint)0, EFalse, EFalse); + } + diff -r 22486c9c7b15 -r 378360dbbdba bintools/petools/pefile/pe_utl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bintools/petools/pefile/pe_utl.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,94 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include "pe_file.h" +#include +#include "e32image.h" +#include "h_utl.h" + +TInt PEFile::CmpSectionName(PIMAGE_SECTION_HEADER apSectionHeader, char *aName) +// +// Returns true if the name of the pe section is the same as aName +// + { + + return (strnicmp((const char *)apSectionHeader->Name, aName, IMAGE_SIZEOF_SHORT_NAME)==0); + } + +TInt PEFile::VirtualAddressInSection(TUint aVA, PIMAGE_SECTION_HEADER aHeader) +// +// Returns true if the virtual address is in the section +// + { + + TUint start = iLinkedBase + aHeader->VirtualAddress; + TUint finish = start + aHeader->Misc.VirtualSize; + return (aVA>=start) && (aVAVirtualAddress; + TUint finish = start + aHeader->Misc.VirtualSize; + if (aVA>=start) + { + if (aVA= 0x1000u) + s = -1; // too far for comfort + } + return s; + } diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/cpp-2.9-psion-98r2/Copying --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/cpp-2.9-psion-98r2/Copying Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/cpp-2.9-psion-98r2/c++filt.exe Binary file cpptoolsplat/cpp-2.9-psion-98r2/c++filt.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/cpp-2.9-psion-98r2/cpp.exe Binary file cpptoolsplat/cpp-2.9-psion-98r2/cpp.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/cpp-2.9-psion-98r2/cygwin1.dll Binary file cpptoolsplat/cpp-2.9-psion-98r2/cygwin1.dll has changed diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/cpp-2.9-psion-98r2/diff.exe Binary file cpptoolsplat/cpp-2.9-psion-98r2/diff.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/cpp-2.9-psion-98r2/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/cpp-2.9-psion-98r2/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,24 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_EXPORTS + +../tail.exe /epoc32/gcc/bin/tail.exe +../c++filt.exe /epoc32/gcc/bin/c++filt.exe +../Copying /epoc32/gcc/bin/Copying +../cpp.exe /epoc32/gcc/bin/cpp.exe +../cygwin1.dll /epoc32/gcc/bin/cygwin1.dll +../diff.exe /epoc32/gcc/bin/diff.exe + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/cpp-2.9-psion-98r2/group/cpp-2.9-psion-98r2.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/cpp-2.9-psion-98r2/group/cpp-2.9-psion-98r2.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_cpptoolsplat_cpp-2.9-psion-98r2 + +source \src\tools\build\cpptoolsplat\cpp-2.9-psion-98r2 +exports \src\tools\build\cpptoolsplat\cpp-2.9-psion-98r2\group +notes_source \component_defs\release.src + +ipr T +ipr O \src\tools\build\cpptoolsplat\cpp-2.9-psion-98r2 + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/cpp-2.9-psion-98r2/tail.exe Binary file cpptoolsplat/cpp-2.9-psion-98r2/tail.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/gcce-3.4.3/arm-none-symbianelf-2005-q1c.exe Binary file cpptoolsplat/gcce-3.4.3/arm-none-symbianelf-2005-q1c.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/gcce-3.4.3/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/gcce-3.4.3/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,19 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_EXPORTS + +../arm-none-symbianelf-2005-q1c.exe /epoc32/tools/distrib/arm-none-symbianelf-2005-q1c.exe + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/gcce-3.4.3/group/gcce-3.4.3.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/gcce-3.4.3/group/gcce-3.4.3.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,10 @@ +component dev_build_cpptoolsplat_gcce-3.4.3 + +source /src/tools/build/cpptoolsplat/gcce-3.4.3 +exports /src/tools/build/cpptoolsplat/gcce-3.4.3/group + +notes_source ./release.txt + +ipr T +ipr O /src/tools/build/cpptoolsplat/gcce-3.4.3 + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/gcce-3.4.3/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/gcce-3.4.3/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +NOTESRC_RELEASER +Nokia Corporation + +NOTESRC_RELEASE_REASON +gcce-3.4.3 Release + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/gcce-4.3.2/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/gcce-4.3.2/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,19 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_EXPORTS + +../arm-none-symbianelf-2008-q3-67.exe /epoc32/tools/distrib/arm-none-symbianelf-2008-q3-67.exe + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/gcce-4.3.2/group/gcce-4.3.2.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/gcce-4.3.2/group/gcce-4.3.2.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,10 @@ +component dev_build_cpptoolsplat_gcce-4.3.2 + +source /src/tools/build/cpptoolsplat/gcce-4.3.2 +exports /src/tools/build/cpptoolsplat/gcce-4.3.2/group + +notes_source ./release.txt + +ipr T +ipr O /src/tools/build/cpptoolsplat/gcce-4.3.2 + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/gcce-4.3.2/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/gcce-4.3.2/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,7 @@ +NOTESRC_RELEASER +Symbian Software Ltd. (kits.notify@symbian.com) + +NOTESRC_RELEASE_REASON +gcce-4.3.2 Release + + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/mingw-gcc-3.4.5/gcc_mingw.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/mingw-gcc-3.4.5/gcc_mingw.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,79 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// This is the preinclude file for the MinGW GCC compiler +// +// + +/** + @file + @publishedAll + @released +*/ + +// compiler and STLport things first +#define _STLP_THREADS +#define _STLP_DESIGNATED_DLL + +// Pick up relevant macros under __GCC32__, since __GCC32__ is not a valid macro for TOOLS2 + +#define __NO_CLASS_CONSTS__ +#define __NORETURN__ __attribute__ ((noreturn)) +#ifdef __GCCV3__ +#define __NORETURN_TERMINATOR() +#else +#define __NORETURN_TERMINATOR() abort() +#endif +#define IMPORT_C +#if !defined __WINS__ && defined _WIN32 /* VC++ Browser Hack */ +#define EXPORT_C +/** @internalTechnology */ +#define asm(x) +#else +#define EXPORT_C __declspec(dllexport) +#endif +#define NONSHARABLE_CLASS(x) class x +#define NONSHARABLE_STRUCT(x) struct x +#define __NO_THROW +#define __DOUBLE_WORDS_SWAPPED__ +typedef long long Int64; +typedef unsigned long long Uint64; +#define I64LIT(x) x##LL +#define UI64LIT(x) x##ULL +#define TEMPLATE_SPECIALIZATION template<> +#define __TText_defined +typedef wchar_t __TText; + + +#include + +// A few extras for compiling on Windows +//#ifdef __TOOLS2_WINDOWS__ +//#define _STLP_LITTLE_ENDIAN +//#define __MINGW__ +//#endif + +// Symbian things next /////////////////////////////////////////////////////// + +#ifdef __PRODUCT_INCLUDE__ +#include __PRODUCT_INCLUDE__ +#endif + +// Do not use inline new in e32cmn.h +#define __PLACEMENT_NEW_INLINE +#define __PLACEMENT_VEC_NEW_INLINE +// avoid e32tools/filesystem/include/mingw.inl nonsense +#define _MINGW_INL + +// the end of the pre-include + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/mingw-gcc-3.4.5/gcc_mingw_3_4_2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/mingw-gcc-3.4.5/gcc_mingw_3_4_2.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,79 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// This is the preinclude file for the MinGW GCC compiler +// +// + +/** + @file + @publishedAll + @released +*/ + +// compiler and STLport things first +#define _STLP_THREADS +#define _STLP_DESIGNATED_DLL + +// Pick up relevant macros under __GCC32__, since __GCC32__ is not a valid macro for TOOLS2 + +#define __NO_CLASS_CONSTS__ +#define __NORETURN__ __attribute__ ((noreturn)) +#ifdef __GCCV3__ +#define __NORETURN_TERMINATOR() +#else +#define __NORETURN_TERMINATOR() abort() +#endif +#define IMPORT_C +#if !defined __WINS__ && defined _WIN32 /* VC++ Browser Hack */ +#define EXPORT_C +/** @internalTechnology */ +#define asm(x) +#else +#define EXPORT_C __declspec(dllexport) +#endif +#define NONSHARABLE_CLASS(x) class x +#define NONSHARABLE_STRUCT(x) struct x +#define __NO_THROW +#define __DOUBLE_WORDS_SWAPPED__ +typedef long long Int64; +typedef unsigned long long Uint64; +#define I64LIT(x) x##LL +#define UI64LIT(x) x##ULL +#define TEMPLATE_SPECIALIZATION template<> +#define __TText_defined +typedef wchar_t __TText; + + +#include + +// A few extras for compiling on Windows +//#ifdef __TOOLS2_WINDOWS__ +//#define _STLP_LITTLE_ENDIAN +//#define __MINGW__ +//#endif + +// Symbian things next /////////////////////////////////////////////////////// + +#ifdef __PRODUCT_INCLUDE__ +#include __PRODUCT_INCLUDE__ +#endif + +// Do not use inline new in e32cmn.h +#define __PLACEMENT_NEW_INLINE +#define __PLACEMENT_VEC_NEW_INLINE +// avoid e32tools/filesystem/include/mingw.inl nonsense +#define _MINGW_INL + +// the end of the pre-include + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/mingw-gcc-3.4.5/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/mingw-gcc-3.4.5/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,21 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_EXPORTS + +../gcc_mingw_3_4_2.h /epoc32/include/gcc_mingw/gcc_mingw_3_4_2.h +../gcc_mingw.h /epoc32/include/gcc_mingw/gcc_mingw.h +:zip ../mingw-symbian-001.zip /epoc32/gcc_mingw + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/mingw-gcc-3.4.5/group/mingw-gcc-3.4.5.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/mingw-gcc-3.4.5/group/mingw-gcc-3.4.5.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_cpptoolsplat_mingw-gcc-3.4.5 + +source \src\tools\build\cpptoolsplat\mingw-gcc-3.4.5 +exports \src\tools\build\cpptoolsplat\mingw-gcc-3.4.5\group +notes_source \component_defs\release.src + +ipr T +ipr O \src\tools\build\cpptoolsplat\mingw-gcc-3.4.5 + diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/mingw-gcc-3.4.5/mingw-symbian-001.zip Binary file cpptoolsplat/mingw-gcc-3.4.5/mingw-symbian-001.zip has changed diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/stlport/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/stlport/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,29 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS +TOOLS2 + +PRJ_EXTENSIONS +START EXTENSION tools/stlport + OPTION STLPORT_VERSION 5.1.0 + OPTION STL_REL_LIB_NAME libstlport.5.1.a + OPTION STL_DEB_LIB_NAME libstlportg.5.1.a + OPTION SOURCE_ARCHIVE ../source/STLport-5.1.0.zip +END + +PRJ_EXPORTS + +:zip ../source/STLport-5.1.0_exports.zip /epoc32/include/tools/stlport \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/stlport/group/stlport.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/stlport/group/stlport.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,8 @@ +component dev_build_cpptoolsplat_stlport + +source \src\tools\build\cpptoolsplat\stlport +binary \src\tools\build\cpptoolsplat\stlport\group all +exports \src\tools\build\cpptoolsplat\stlport\group +notes_source \component_defs\release.src + +ipr T diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/stlport/source/README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cpptoolsplat/stlport/source/README.txt Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,3 @@ +The File has been manually configured, in order for it to recognise the g++ compiler. + +The Change is made to the _STLP_NATIVE_INCLUDE_PATH macro, by uncommenting it, and removing the path (../include) being pointed to by it. \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/stlport/source/STLport-5.1.0.zip Binary file cpptoolsplat/stlport/source/STLport-5.1.0.zip has changed diff -r 22486c9c7b15 -r 378360dbbdba cpptoolsplat/stlport/source/STLport-5.1.0_exports.zip Binary file cpptoolsplat/stlport/source/STLport-5.1.0_exports.zip has changed diff -r 22486c9c7b15 -r 378360dbbdba deprecated/eruntest/eruntest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/eruntest/eruntest.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,327 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include + +#ifdef __MSVCDOTNET__ + #include + #include + using namespace std; +#else //!__MSVCDOTNET__ + #include + #include +#endif //__MSVCDOTNET__ + +#include +#include + +#if defined(__VC32__) && !defined(__MSVCDOTNET__) +#pragma warning( disable : 4710 ) // 'fn': function not inlined +#endif // old MSVC + +const unsigned int KMaxLineLen=256; +const unsigned int KTimeout=600000; // 10 minutes + + +void NumFileLines(ifstream& inStream, unsigned int &aNumLines) + { + // finds out how many lines are in the file specified + + aNumLines=0; + inStream.clear(); + inStream.seekg(0); + + char str[KMaxLineLen]; + while (!inStream.eof()) + { + inStream.getline(str, KMaxLineLen); + aNumLines++; + } + } + +void GetTestData(ifstream& inStream, char (*aDataArray)[KMaxLineLen], unsigned int &aNumTests) + { + // fill the test data structure from the file stream + + aNumTests=0; + inStream.clear(); + inStream.seekg(0); + + char str[KMaxLineLen]=""; + while (!inStream.eof()) + { + bool charsPresent=0; + inStream.getline(str, KMaxLineLen); + if (strlen(str)) + { + unsigned int len=strlen(str); + for (unsigned int i=0; iKMaxLineLen) + r=1; + + if (!r) + if (KMaxLineLen > (strlen(KTestOutFileName)+strlen(tmpDir))) + { + strcpy(aOutFile, tmpDir); + strcat(aOutFile, KTestOutFileName); + } + else + r=1; + return(r); + } + +void RemoveLeadingSpaces(char* aStr) + { + // removes leading whitespace from a string + + int spaces=0; + while (isspace(aStr[spaces])) + spaces++; + int newLen=strlen(aStr)-spaces; + for (int j=0;j<=newLen;j++) + aStr[j]=aStr[j+spaces]; + } + +int TestSucceeded(char* aLastLineBut1) + { + // checks whether an EPOC RTest has succeeded by comparing the + // last line but 1 in the EPOCWIND.OUT file with a template success + // string + + int r=0; + const char KSuccessResult[20]="RTEST: SUCCESS :"; + + char testStr[KMaxLineLen]; + strcpy(testStr,aLastLineBut1); + RemoveLeadingSpaces(testStr); + testStr[strlen(KSuccessResult)]='\0'; + if (strcmp(testStr, KSuccessResult)==0) + r=1; + return(r); + } + +int GetPenultimateLines(char* aFile, char* aLastLineBut1, char* aLastLineBut2) + { + // Gets the two penultimate lines in a file. + // Returns 0 if successful, 1 otherwise. + + int r=0; + + aLastLineBut1[0]='\0'; + aLastLineBut2[0]='\0'; + + ifstream fileStream(aFile); + if (!fileStream) + r=1; + + if (!r) + { + char lastLine[KMaxLineLen]=""; + while (!fileStream.eof()) + { + strcpy(aLastLineBut2, aLastLineBut1); + strcpy(aLastLineBut1, lastLine); + fileStream.getline(lastLine, KMaxLineLen); + } + } + return(r); + } + +int main(int argc, char *argv[]) + { + FILE *stream = NULL; + if (argc != 2) + { + cerr << "Syntax: eruntest " << endl; + return(1); + } + // Check if input file exists + if( (stream = fopen(argv[1], "r" )) == NULL) + { + cerr << "ERROR: Cannot open input file " << argv[1] << endl; + return(1); + } + else + fclose(stream); +// stream the input file + ifstream inFile(argv[1]); + + // get the number of lines in the input file + unsigned int numLines=0; + NumFileLines(inFile, numLines); + + // allocate space for the tests names + char (*pTests)[KMaxLineLen]; + pTests = new char[numLines][KMaxLineLen]; + if (!pTests) + { + cerr << "ERROR: Out of memory" << endl; + return(1); + } + + // populate the data structure for the tests + unsigned int numTests=0; + GetTestData(inFile, pTests, numTests); + + // Get the test output file name + char testOutFile[KMaxLineLen]; + if (GetTestOutFileName(testOutFile)!=0) + { + cerr << "Error getting temporary path" << endl; + return(1); + } + + // Get the current directory + char currentDir[KMaxLineLen]=""; + GetCurrentDirectory(KMaxLineLen, currentDir); + strcat(currentDir, "\\"); + + // Retrieve the STARTUPINFO structure for the current process + STARTUPINFO startUpInfo; + PROCESS_INFORMATION procInfo; + GetStartupInfo(&startUpInfo); + + unsigned failCount=0; + unsigned timeoutCount=0; + unsigned cantStartCount=0; + unsigned unknownCount=0; + + // run each test in turn + for (unsigned int i=0; i" << endl; + unknownCount++; + } + else + { + // make the comparison + if (TestSucceeded(lastLineBut1)) + cout << "PASSED: " << currentDir << pTests[i] << endl; + else + { + cout << "FAILED(RTest): " << currentDir << pTests[i] << endl; + cout << " " << lastLineBut2 << endl; + cout << " " << lastLineBut1 << endl; + cout << endl; + failCount++; + } + } + break; + case WAIT_FAILED: + cout << "FAILED: " << currentDir << pTests[i] << endl; + if (GetPenultimateLines(testOutFile, lastLineBut1, lastLineBut2)!=0) + { + cout << " " << endl; + } + else + { + cout << " " << lastLineBut2 << endl; + cout << " " << lastLineBut1 << endl; + cout << endl; + } + failCount++; + break; + case WAIT_TIMEOUT: + cout << "TIMED OUT: " << currentDir << pTests[i] << endl; + if (GetPenultimateLines(testOutFile, lastLineBut1, lastLineBut2)!=0) + { + cout << " " << endl; + } + else + { + cout << " " << lastLineBut2 << endl; + cout << " " << lastLineBut1 << endl; + cout << endl; + } + timeoutCount++; + if (!TerminateProcess(procInfo.hProcess, 1)) + { + cout << "FROZEN: " << currentDir << endl; + cout << " Cannot terminate - kill via Task Manager" << endl; + cout << endl; + } + break; + } + } + + delete [] pTests; + + cout << endl; + cout << "TotalErrors " << dec << (failCount+timeoutCount+unknownCount+cantStartCount) << endl; + cout << " Failures " << dec << failCount << endl; + cout << " Timeouts " << dec << timeoutCount << endl; + cout << " Unknown " << dec << unknownCount << endl; + cout << " Can't start " << dec << cantStartCount << endl; + cout << endl; + + return(0); + } diff -r 22486c9c7b15 -r 378360dbbdba deprecated/eruntest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/eruntest/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +eruntest.mmp + +PRJ_TESTMMPFILES + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/eruntest/group/eruntest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/eruntest/group/eruntest.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,24 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET eruntest.exe +TARGETTYPE exe +SOURCEPATH ../../eruntest +SOURCE eruntest.cpp + + + +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba deprecated/eruntest/group/eruntest.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/eruntest/group/eruntest.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_deprecated_eruntest + +source /src/tools/build/deprecated/eruntest +exports /src/tools/build/deprecated/eruntest/group +binary /src/tools/build/deprecated/eruntest/group all + +notes_source \component_defs\release.src + +ipr T diff -r 22486c9c7b15 -r 378360dbbdba deprecated/etouch/etouch.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/etouch/etouch.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,46 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#if defined(__MSVCDOTNET__) || defined (__TOOLS2__) + #include + using namespace std; +#else //!__MSVCDOTNET__ + #include +#endif //__MSVCDOTNET__ + +#if defined(__VC32__) || defined(__TOOLS2__) + #include +#else + #include +#endif + +#if defined(__VC32__) && !defined(__MSVCDOTNET__) +#pragma warning( disable : 4710 ) // 'fn': function not inlined +#endif // old MSVC + +int main(int argc,char *argv[]) +// +// Collect the filename from the command line +// and change its date/time stamp to the current date/time +// + { + + if (argc!=2) + { + cout << "Syntax: etouch filename" << endl; + return(1); + } + return(utime(argv[1],NULL)==(-1) ? 1 : 0); + } diff -r 22486c9c7b15 -r 378360dbbdba deprecated/etouch/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/etouch/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +etouch.mmp + +PRJ_TESTMMPFILES + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/etouch/group/etouch.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/etouch/group/etouch.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,23 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET etouch.exe +TARGETTYPE exe +SOURCEPATH ../../etouch +SOURCE etouch.cpp + + +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba deprecated/etouch/group/etouch.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/etouch/group/etouch.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_deprecated_etouch + +source /src/tools/build/deprecated/etouch +exports /src/tools/build/deprecated/etouch/group +binary /src/tools/build/deprecated/etouch/group all + +notes_source \component_defs\release.src + +ipr T diff -r 22486c9c7b15 -r 378360dbbdba deprecated/fix_eabi_think_offsets/fix_eabi_thunk_offsets.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/fix_eabi_think_offsets/fix_eabi_thunk_offsets.bat Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,427 @@ +:: Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +:: All rights reserved. +:: This component and the accompanying materials are made available +:: under the terms of "Eclipse Public License v1.0" +:: which accompanies this distribution, and is available +:: at the URL "http://www.eclipse.org/legal/epl-v10.html". +:: +:: Initial Contributors: +:: Nokia Corporation - initial contribution. +:: +:: Contributors: +:: +:: Description: +:: + +@rem = '--*-Perl-*-- +@echo off +if "%OS%" == "Windows_NT" goto WinNT +perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 +goto endofperl +:WinNT +perl -x -S "%0" %* +if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl +if %errorlevel% == 9009 echo You do not have Perl in your PATH. +goto endofperl +@rem '; +#!perl +#line 28 + +use strict; +use Getopt::Long; + +my $toolVersion = "1.0"; + +my $update = 0; +my $use_perforce = 0; +my $verbose = 0; +my $defFile; + +# 1. Check arguments, output help etc. + +GetOptions ( + 'update' => \$update, # modify the files + 'perforce' => \$use_perforce, # apply "p4 edit" to changed files + 'v+' => \$verbose, # print extra diagnostic info + 'match=s' => \$defFile # only process DEF files matching a pattern + ); + +if (@ARGV == 0) + { + print STDERR "\nfix_eabi_thunk_offsets.bat - Version $toolVersion\n"; + + print STDERR << 'END_OF_HELP'; + +Usage: fix_eabi_think_offsets [-update] [-perforce] [-match exp] build_log ... + +Parse the output from one or more build logs, extracting MAKEDEF errors and +warnings which relate to EABI virtual function override thunks. Using this +information, prepare modified DEF files in which each "missing" export is +replaced by a corresponding "unfrozen" export. + +-update Overwrite the existing .def files with the modified versions +-perforce Apply "p4 edit" to each of the modified .def files +-match exp Process only .def files with names that contain "\exp" + +NOTE: The tool assumes that the original build source layout is replicated on +the drive where it is being executed. + +Build logs will sometimes contain corrupted warning messages, in which case +the tool will probably report that there is nothing to replace some missing +symbol. It may help to edit the log file and try again: it is always safe to +run this tool more than once on the same log file. + +END_OF_HELP + + exit(1); + } + +my $parseWarnings = 1; +my $parseErrors = 1; + + +# 2. Parse the build logs, extracting the Makedef warnings & errors + +my $line; +my $header; +my $parseWarning = 0; +my $parseError = 0; +my $variant; +my $component; +my $sourceDefFile; +my @errorOutput; +my @warningOutput; + +my %DefFiles; +my %TempDefFiles; + +sub newDefFile($) + { + my ($defFile) = @_; + if (!defined $DefFiles{$defFile}) + { + @{$DefFiles{$defFile}} = \(); + } + } + +while ($line = <>) + { + if ($line =~ /^Chdir /) + { + $component = $line; + $component =~ s/^Chdir //; + $component =~ s/\s//g; + next; + } + + if (($line =~ /^ make/) && ($line =~ / CFG\=/)) + { + $variant = $line; + $variant =~ s/^.*CFG\=//; + $variant =~ s/ .*$//; + $variant =~ s/\s//g; + next; + } + + if ($parseWarnings && ($line =~ /MAKEDEF WARNING:/)) + { + $parseWarning = 1; + $parseError = 0; + $header = $line; + next; + } + + if ($parseErrors && ($line =~ /MAKEDEF ERROR:/)) + { + $parseWarning = 0; + $parseError = 1; + $header = $line; + next; + } + + if ($line !~ /^ /) + { + $parseWarning = 0; + $parseError = 0; + next; + } + + if ($parseWarning) + { + if ($header) + { + if ($defFile && ($header !~ /\\$defFile/i)) + { + $parseWarning = 0; + $parseError = 0; + next; + } + + $sourceDefFile = $header; + $sourceDefFile =~ s/^.*not yet Frozen in//; + $sourceDefFile =~ s/://; + $sourceDefFile =~ s/\s//g; + + push @warningOutput, "--\n$sourceDefFile ($variant)\n$component\n$header"; + newDefFile($sourceDefFile); + $header = ""; + } + + next if ($line =~ /\*\*\*/); + if ($line =~ /^ (\S.*}\.def)(\(\d+\) : \S+.*)$/) + { + push @{$DefFiles{$sourceDefFile}}, "W$2"; + $TempDefFiles{$1} = $sourceDefFile; + } + push @warningOutput, $line; + + next; + } + + if ($parseError) + { + if ($defFile && ($line !~ /\\$defFile/i)) + { + $parseWarning = 0; + $parseError = 0; + next; + } + + if ($header) + { + $sourceDefFile = $line; + $sourceDefFile =~ s/\(.*$//; + $sourceDefFile =~ s/\s//g; + + push @errorOutput, "--\n$sourceDefFile ($variant)\n$component\n$header"; + newDefFile($sourceDefFile); + $header = ""; + } + + next if ($line =~ /\*\*\*/); + if ($line =~ /(\(\d+\) : \S+.*)$/) + { + push @{$DefFiles{$sourceDefFile}}, "E$1"; + } + push @errorOutput, $line; + + next; + } + + # Catch a orphaned warning line... + + if ($line =~ /^ (\S.*}\.def)(\(\d+\) : \S+.*)$/) + { + my $tempDefFile = $1; + my $newline = $2; + + next if ($defFile && ($tempDefFile !~ /\\$defFile/i)); + + my $sourceDefFile = $TempDefFiles{$tempDefFile}; + push @{$DefFiles{$sourceDefFile}}, "W$newline"; + push @warningOutput, $line; + } + + } + +close BUILD_LOG; + +# 3. Process the information for each DEF file + +my %Classes; +my @DefFileList; + +foreach my $def (sort keys %DefFiles) + { + my @replacements; + my @errors; + my @warnings; + my $problems = 0; + + print "\n----\n$def\n"; + if ($verbose > 1) + { + print "Information extracted from Makedef warnings and errors:\n"; + # printed inside the following loop... + } + + # Process into lists of errors and warnings which can be sorted + + my $previousline = ""; + foreach $line (sort @{$DefFiles{$def}}) + { + next if ($line eq $previousline); # skip duplicates + $previousline = $line; + print "\t$line\n" if ($verbose > 1); + + if ($line =~ /^(.)\((\d+)\) : (((_ZTh|_ZTv)([n0-9_]+)_(NK?(\d+)(\S+)))\s.*)$/) + { + my $msgtype = $1; + my $lineno = $2; + my $defline = $3; + my $symbol = $4; + my $thunkprefix = $5; + my $thunkoffset = $6; + my $unthunked = $7; + my $topnamelen = $8; + my $restofsymbol = $9; + + if ($msgtype eq "E") + { + push @errors, "$unthunked\@$thunkprefix $thunkoffset $lineno $symbol"; + } + else + { + push @warnings, "$unthunked\@$thunkprefix $thunkoffset $symbol"; + } + + my $class = substr $restofsymbol, 0, $topnamelen; + $Classes{$class} = 1; + } + else + { + print "WARNING: Ignored - not a thunk: $line\n"; + } + } + + # Match up the errors and warnings for related symbols + + @errors = sort @errors; + @warnings = sort @warnings; + my $error; + my $warning; + while (scalar @errors && scalar @warnings) + { + # Unpack the first entry in each of the lists + + $error = shift @errors; + my ($ekey, $eoffset, $eline, $esymbol) = split / /, $error; + $warning = shift @warnings; + my ($wkey, $woffset, $wsymbol) = split / /, $warning; + + # Are they for the same thunk? + + if ($ekey lt $wkey) + { + # no - unmatched error, so put back the warning + unshift @warnings, $warning; + print "Nothing to replace missing symbol on $eline : $esymbol\n"; + $problems += 1; + next; + } + + if ($ekey gt $wkey) + { + # no - unmatched warning, so put back the error + unshift @errors, $error; + print "Nothing missing for replacement symbol : $wsymbol\n"; + $problems += 1; + next; + } + + # Yes - create replacement instruction + + push @replacements, "$eline $esymbol => $wsymbol"; + } + + # drain remaining problems, if any + + foreach my $error (@errors) + { + my ($ekey, $eoffset, $eline, $esymbol) = split / /, $error; + print "Nothing to replace missing symbol on $eline : $esymbol\n"; + $problems += 1; + } + foreach my $warning (@warnings) + { + my ($wkey, $woffset, $wsymbol) = split / /, $warning; + print "Nothing missing for replacement symbol : $wsymbol\n"; + $problems += 1; + } + + if ($verbose) + { + print "\nSubstitions identified:\n\t"; + print join("\n\t", sort @replacements); + print "\n"; + } + + open DEFFILE, "<$def" or print "Can't open $def: $!\n" and next; + my @deflines = ; + close DEFFILE; + my $changedlines = 0; + + foreach my $fix (@replacements) + { + my ($lineno, $before, $to, $after) = split ' ', $fix; + + my $line = @deflines[$lineno-1]; + if ($line =~ /\s($after)\s/) + { + print "$lineno - already fixed\n"; + next; + } + if ($line =~ /\s($before)\s/) + { + $line =~ s/(\s)$before(\s)/$1$after$2/; + @deflines[$lineno-1] = $line; + print "Changed $lineno to $line" if ($verbose > 1); + $changedlines += 1; + next; + } + print "$lineno doesn't contain $before\n"; + $problems += 1; + } + print "\n"; + + if ($problems != 0) + { + print "WARNING: $problems thunks could not be repaired\n"; + } + + if ($changedlines == 0) + { + print "Nothing to change\n"; + next; + } + print "Will change $changedlines lines\n\n"; + + # Now update the file (and edit in Perforce if required) + + if ($update) + { + chmod 0666, $def; # make it writeable + + open DEFFILE, ">$def" or print "Can't open $def for writing: $!\n" and next; + print DEFFILE @deflines; + close DEFFILE; + + print "Updated $def\n"; + push @DefFileList, $def; + + if ($use_perforce) + { + print "* p4 edit $def\n"; + system "p4 edit $def"; + print "\n"; + } + } + } + +# 5. More diagnostic information + +if (scalar @DefFileList) + { + print "\nList of updated def files\n"; + print join("\n", @DefFileList); + print "\n"; + } + +if ($verbose && scalar keys %Classes != 0) + { + print "\nList of affected classes:\n"; + print join("\n", sort keys %Classes), "\n"; + } + +__END__ +:endofperl diff -r 22486c9c7b15 -r 378360dbbdba deprecated/fix_eabi_think_offsets/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/fix_eabi_think_offsets/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,19 @@ +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS +TOOLS2 + +PRJ_EXPORTS diff -r 22486c9c7b15 -r 378360dbbdba deprecated/fix_eabi_think_offsets/group/fix_eabi_thunk_offsets.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/fix_eabi_think_offsets/group/fix_eabi_thunk_offsets.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,10 @@ +component dev_build_sbsv1_fix_eabi_thunk_offsets + +source \src\tools\build\sbsv1\fix_eabi_thunk_offsets +binary \src\tools\build\sbsv1\fix_eabi_thunk_offsets\group all +exports \src\tools\build\sbsv1\fix_eabi_thunk_offsets\group + +notes_source \component_defs\release.src + +ipr T + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/rommask/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/rommask/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +rommask.mmp + +PRJ_TESTMMPFILES + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/rommask/group/rommask.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/rommask/group/rommask.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,24 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET rommask.exe +TARGETTYPE exe +SOURCEPATH ../../rommask +SOURCE rommask.cpp +USERINCLUDE ../../../imgtools/imglib/inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba deprecated/rommask/group/rommask.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/rommask/group/rommask.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_deprecated_rommask + +source /src/tools/build/deprecated/rommask +exports /src/tools/build/deprecated/rommask/group +binary /src/tools/build/deprecated/rommask/group all + +notes_source \component_defs\release.src + +ipr T diff -r 22486c9c7b15 -r 378360dbbdba deprecated/rommask/rommask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/rommask/rommask.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,395 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) +#include +#else //!__MSVCDOTNET__ +#include +#endif //__MSVCDOTNET__ + +#include "h_utl.h" +#include "h_ver.h" + +// ROMMASK.EXE cl parameters +char *gRomImage=NULL; +char *gOutputRom=NULL; +int gRomSize=0; +char gFormat='P'; +const int KMaxSections=8; +int gNumberOfSections=0; +int gSectionSize[KMaxSections]; +int gHeader=ETrue; +int gVerbose=EFalse; + + +TInt MaskPlain(TInt aRomSize,ifstream& aPsionImageFile,ofstream& aMaskRomImageFile) +// +// Create a plain mask rom image file +// + { + + const char KMaskRomFillCharacter='\377'; + const TInt KBufferSize=1024; + char empty[KBufferSize]; + for (TInt y=0;y=argc) + error=KErrArgument; + if (error==KErrNone) + { + int val; +// if (!isNumber(argv[param])) +// return KErrArgument; + +#ifdef __TOOLS2__ +istringstream s(argv[param]); +#else +istrstream s(argv[param], strlen(argv[param])); +#endif + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) + s >> setbase(0); +#endif //__MSVCDOTNET__ + + s>>val; + if (!s.fail()) + return val; + } + cerr << "Error: Integer argument required for "; + cerr << argv[param-1]; + cerr << "\r\n"; + return -1; + } + +char *getStringArg(int argc, char *argv[], int param) + { + + if (param>=argc) + { + cerr << "Error: String argument required for "; + cerr << argv[param-1]; + cerr << "\r\n"; + return NULL; + } + return argv[param]; + } + +char getCharArg(int argc, char *argv[], int param) + { + + char *p=getStringArg(argc,argv,param); + if (p!=NULL) + return p[0]; + return '\000'; + } + +TInt processCommandLine(int argc, char *argv[]) + { + + if (argc==1) + return KErrArgument; + int param=1; + while (param=KMaxSections) + { + cerr << "Error: Too many sections\r\n"; + return KErrGeneral; + } + param++; + gSectionSize[gNumberOfSections]=getIntegerArg(argc, argv, param); + if (gSectionSize[gNumberOfSections]==-1) + return KErrGeneral; + if (gSectionSize[gNumberOfSections]==0) + { + cerr << "Error: Section is zero bytes long\r\n"; + return KErrGeneral; + } + if (gSectionSize[gNumberOfSections]>64) + { + cerr << "Error: Section too big\r\n"; + return KErrGeneral; + } + gNumberOfSections++; + } + break; + case 'f': + case 'F': + param++; + gRomSize=getCharArg(argc, argv, param); + break; + case 'l': + case 'L': + cerr << "Error: Use -verbose instead of -log"; + break; + case 'v': + case 'V': + gVerbose=ETrue; + break; + case 'o': + case 'O': + param++; + gOutputRom=getStringArg(argc, argv, param); + break; + case 'n': + case 'N': + // -no-header + gHeader=EFalse; + break; + default: + cout << "Error: Unrecognised switch '"<64) + { + cerr << "Error: Rom too big\r\n"; + return KErrGeneral; + } + if (gRomSize==0) + { + cerr << "Error: No rom size specified\r\n"; + return KErrArgument; + } + if (gFormat!='P' && gFormat!='M') + { + cerr << "Error: Invalid mask rom format specified\r\n"; + return KErrArgument; + } + + return KErrNone; + } + +TInt Align1M(TInt aVal) + { + return (aVal+0xfffff) & 0x7ff00000; + } + +TInt main(int argc, char *argv[]) + { + + const TInt KPsionImageFileHeaderSize=0x100; + + cout << "\r\nROMMASK - Rom masker V" << MajorVersion << "." << MinorVersion << "(Build " << Build << ")\r\n"; + cout << Copyright; + + char HelpText[] = + "Syntax: ROMMASK -romimage -output \r\n" + " [-verbose] [-size ]\r\n" + " [-no-header] [-format ] [-section ]*\r\n" + "Format: MOTOROLA (ascii s-record format)\r\n" + " PLAIN (plain binary format) default\r\n"; + int r=processCommandLine(argc, argv); + if (r==KErrArgument) + { + cout << HelpText; + return(KErrArgument); + } + +// Open the psion image file + + ifstream PsionImageFile; + char*& PsionImageFileName=gRomImage; + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) + PsionImageFile.open(PsionImageFileName, ios::in | ios::binary); +#else //!__MSVCDOTNET__ + PsionImageFile.open(PsionImageFileName, ios::nocreate | ios::binary); +#endif //__MSVCDOTNET__ + + if (!PsionImageFile) + { + cerr << "Error: Cannot open psion image file (" << PsionImageFileName << ")\r\n"; + return(KErrArgument); + } + + gRomSize*=1024*1024; // in Mb + // resolve sections to cover whole rom + int size=0; + int i; + for (i=0; igRomSize) + { + cerr << "Error: Sections too big for rom"; + return KErrGeneral; + } + +// Create the mask rom image file + + ofstream MaskRomImageFile; + char*& MaskRomImageFileName=gOutputRom; + + MaskRomImageFile.open(MaskRomImageFileName); + if (!MaskRomImageFile) + { + cerr << "Error: Cannot create mask rom image file (" << MaskRomImageFileName << ")\r\n"; + PsionImageFile.close(); + return(KErrArgument); + } + + if (gHeader) + { + PsionImageFile.ignore(KPsionImageFileHeaderSize); + int count=PsionImageFile.gcount(); + if (count!=KPsionImageFileHeaderSize) + { + cerr << "Error: Corrupt Psion image file\r\n"; + return(KErrGeneral); + } + } + + r=KErrNone; + for (i=0; i +#include + +#include +#include +#include +#include "h_utl.h" +#include "h_ver.h" + +// need to pretend we've done e32image.h, to avoid clashes with winnt.h +#define __E32IMAGE_H__ +struct E32ImageFile + { + }; +class CBytePair; +#include "r_rom.h" + +#define READ_BUFFER_SIZE 0x1000 // allows for exuberant T_REPRO without delays in it +#define WRITE_BUFFER_SIZE 0x1000 + +TRomLoad TheRomHeader; +TUint ImageDataSize=0; +TUint FileSize=0; +TText PortNumber='1'; +TUint BaudRate=115200; +TBool Kick=EFalse; +TBool UseHex=EFalse; +TBool Verbose=EFalse; +TBool RawImage=EFalse; +TText* BootstrapName=NULL; + +const TUint KReproWrapperSize = 0x100; // REPRO protocol assumes a wrapper size of 256 bytes + +HANDLE comPort; +TUint32 BytesWritten; + +TText *processCommandLine(int argc, char *argv[]) +// +// Process the command line arguments, printing a helpful message if none are supplied +// + { + + char HelpText[] = + "* Syntax: W32REPRO [options] filename[.bin]\n" + "* \n" + "* Option: -P port number, defaults to COM1,\n" + "* Option: -K kick the other end, to force another repro attempt\n" + "* Option: -B baud rate, minimum 9600, defaults to 115200\n" + "* Option: -RAW raw image with no header\n" + "* Option: -BOOT bootstrap with transmitted at 9600 baud\n" + "* Option: -HEX use base 16 (for use with ReproC)\n" + "* Option: -V display raw protocol messages\n" + "* \n" + "* All messages from W32REPRO begin with '*', every thing else comes from the\n" + "* machine being reprogrammed.\n"; + + TText *filename=NULL; + if (argc == 1) + { + cout << HelpText; + return NULL; + } + for (int i=1; i=9600) + { + BaudRate=rate; + } + else + { + cout << "**** Invalid baud rate: " << argv[i] << "\n*\n"; + cout << HelpText; + return NULL; + } + } + else if (argv[i][1] == '?') + { + cout << HelpText; + return NULL; + } + else + { + cout << "**** Unrecognised argument " << argv[i] << "\n*\n"; + cout << HelpText; + return NULL; + } + } + else // Must be the image filename + filename=(TText *)argv[i]; + } + if (filename==NULL) + { + cout << "**** Missing image filename\n*\n"; + cout << HelpText; + } + return filename; + } + +TInt openComPort() +// +// Open the com port and configure it +// + { + char port[5]="COM1"; + port[3]=PortNumber; + comPort=CreateFile(port,GENERIC_READ+GENERIC_WRITE,0,0,OPEN_EXISTING,0,NULL); + if (comPort==INVALID_HANDLE_VALUE) + return Print(EError,"* Cannot open %s\n",port); + + DCB settings; + if (!GetCommState(comPort,&settings)) + return Print(EError,"* Cannot read settings for %s\n",port); + + if (!SetupComm(comPort,READ_BUFFER_SIZE,WRITE_BUFFER_SIZE)) + return Print(EError,"* Cannot set buffer sizes for %s\n",port); + + settings.fBinary=TRUE; + settings.fParity=FALSE; + settings.fAbortOnError=TRUE; // overrides EV_ERR + settings.BaudRate=BaudRate; + settings.ByteSize=8; + settings.Parity=NOPARITY; + settings.StopBits=ONESTOPBIT; + settings.fRtsControl=RTS_CONTROL_ENABLE; + settings.fDtrControl=DTR_CONTROL_ENABLE; + settings.fOutxCtsFlow=FALSE; + settings.fOutxDsrFlow=FALSE; + settings.fDsrSensitivity=FALSE; + settings.fOutX=FALSE; // no XON/XOFF for transmission + settings.fInX=FALSE; // no XON/XOFF for reception + settings.fNull=FALSE; // don't discard null bytes + + settings.EvtChar='\001'; // REPRO command separator + + if (!SetCommState(comPort,&settings)) + return Print(EError,"* Cannot configure %s\n",port); + + if (!SetCommMask(comPort,EV_RXFLAG+EV_ERR)) + return Print(EError,"* Cannot set CommMask for %s\n",port); + + COMMTIMEOUTS timeouts = { + //20,0,0, // allow up to 20 milliseconds between characters, i.e. buffer them properly + MAXDWORD,0,0, // return immediately + 0,0 // no write timeouts + }; + if (!SetCommTimeouts(comPort,&timeouts)) + return Print(EError,"* Cannot set timeouts for %s\n",port); + + if (!SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_HIGHEST)) + Print(EError,"* Failed to raise priority of this thread err=%d\n",GetLastError()); + if (!SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS)) + Print(EError,"* Failed to raise priority of this process err=%d\n",GetLastError()); + + Print(EScreen,"* Using %s at %d baud\n\n",port,BaudRate); + return KErrNone; + } + +BOOL WriteToComPort(char* data, DWORD length, char* comment) + { + if (Verbose) + { + if (comment==NULL) + Print(EScreen, "* TX=%*s\n", length, data); + else + Print(EScreen, "* TX <%d bytes of %s>\n", length, comment); + } + return WriteFile(comPort, data, length, &BytesWritten, NULL); + } + +TInt Bootstrap9600() + { + DCB settings; + if (!GetCommState(comPort,&settings)) + return Print(EError,"* Cannot read COM settings\n"); + + settings.BaudRate=9600; + if (!SetCommState(comPort,&settings)) + return Print(EError,"* Cannot reconfigure to 9600 baud\n"); + + FILE* bootstrapFile=fopen((const char*)BootstrapName,"rb"); + if (bootstrapFile==NULL) + return Print(EError,"* Cannot open bootstrap file %s for input (errno=%d)\n",BootstrapName,errno); + + Print(EScreen,"* Sending bootstrap %s at 9600 baud\n",BootstrapName,BaudRate); + + char bootdata[WRITE_BUFFER_SIZE]; + TUint32 imageBytes=0; + + while (!feof(bootstrapFile)) + { + imageBytes=fread(bootdata,1,WRITE_BUFFER_SIZE,bootstrapFile); + if (imageBytes==0 && feof(bootstrapFile)) + break; + if (imageBytes!=WRITE_BUFFER_SIZE && ferror(bootstrapFile)) + { + return Print(ESevereError,"* Read only %d bytes of bootstrap err=%d\n",imageBytes,ferror(bootstrapFile)); + } + if (!WriteToComPort(bootdata,imageBytes,"bootstrap data")) + return Print(ESevereError,"* Wrote only %d of %d bytes of bootstrap err=%d\n", + BytesWritten,imageBytes,GetLastError()); + } + fclose(bootstrapFile); + + settings.BaudRate=BaudRate; + if (!SetCommState(comPort,&settings)) + return Print(EError,"* Cannot reconfigure to %d baud\n",BaudRate); + + Print(EScreen,"* Bootstrap downloaded\n\n"); + + return KErrNone; + } + +TInt main(int argc, char *argv[]) + { + TInt err=KErrNone; + + Print(EScreen,"\n* W32REPRO - Win32 version of PREPRO"); + Print(EScreen," V%02d.%02d (Build %03d)\n",MajorVersion,MinorVersion,Build); + Print(EScreen,"* %s",Copyright); + + TText *imageFileName = processCommandLine(argc, argv); + if (imageFileName==NULL) + return KErrGeneral; + + FILE* romFile=fopen((const char*)imageFileName,"rb"); + if (romFile==NULL) + return Print(EError,"* Cannot open ROM Image file %s for input (errno=%d)\n",imageFileName,errno); + + if (RawImage) + TheRomHeader.wrapSize=0; + else + { + if (fread(&TheRomHeader,sizeof(TheRomHeader),1,romFile)!=1) + return Print(EError,"* Cannot read ROM Image header\n"); + if (TheRomHeader.wrapSize!=KRomWrapperSize) + return Print(EError,"* Incorrect ROM header - wrong wrapper size\n"); + } + if (fseek(romFile,0,SEEK_END)!=0) + return Print(EError,"* Cannot seek in ROM Image file\n"); + FileSize=ftell(romFile); + ImageDataSize=FileSize-TheRomHeader.wrapSize; + + Print(EAlways,"\n* ROM Image %s - 0x%06x bytes\n",imageFileName,ImageDataSize); + + err=openComPort(); + if (err!=KErrNone) + return err; + + if (BootstrapName != NULL) + { + err=Bootstrap9600(); + if (err!=KErrNone) + return err; + } + + char romdata[WRITE_BUFFER_SIZE]; + if (Kick) + { + memset(romdata,'!',64); // string of non-numeric characters, won't harm old REPRO + WriteToComPort(romdata,64,NULL); + } + // + // Wait around for REPRO on the other end to send us commands + // + char command[READ_BUFFER_SIZE+1]; + char* cp=command; + TInt length=READ_BUFFER_SIZE; + TUint expectedOffset=0; + TInt done=0; + while (!done) + { + TUint32 bytesRead=0,imageBytes=0,offset=0; + + TUint32 event; + if (!WaitCommEvent(comPort,&event,NULL)) + { + if (GetLastError()!=ERROR_OPERATION_ABORTED) + Print(EAlways,"\n* Unexpected WaitCommEvent failure %d event %x\n",GetLastError(),event); + TUint32 commError; + if (!ClearCommError(comPort,&commError,NULL)) + { + Print(ESevereError,"\n* Failed to clear CommError - give up now!\n"); + return KErrGeneral; + } + if (commError!=CE_OVERRUN) + Print(EAlways,"\n* Unexpected comms error %x\n",commError); + } + if (!ReadFile(comPort,cp,length,&bytesRead,NULL)) + { + if (GetLastError()!=ERROR_OPERATION_ABORTED) + Print(EAlways,"\n* Unexpected ReadFile failure %d bytes %d\n",GetLastError(),bytesRead); + } + if (bytesRead==0) + continue; + + char* next; + char* end = cp+bytesRead; + *end='\0'; // stick a terminator on the end, just in case + + for (cp=(char*)command; (next=(char*)memchr(cp,'\001',end-cp))!=NULL ;cp=next+1) + { + *next='\0'; // drop the terminator + if (Verbose) + Print(EScreen, " * RX=%s\n", cp); + switch (cp[0]) + { + case 'D': // disconnect after successful REPRO + Print(EScreen,"* Disconnect\n"); + done=1; + break; + case 'M': // print message + Print(EScreen,"%s",cp+1); + break; + case 'P': // panic + Print(ESevereError,"%s",cp+1); + break; + case 'R': // request for data from the image at specified address + if (end-next>1) + break; // must be the last command in the buffer + offset=strtoul(cp+1,NULL,UseHex?16:10)-KReproWrapperSize; // REPRO assumes wrapSize=256 + if ((offset&4095)!=0) + { + Print(ESevereError,"* Image offset %x not a multiple of 4k (%s)\n", offset,cp); + break; + } + if (offset>expectedOffset) + { + Print(ESevereError,"* Image offset %x should have been %x\n", offset,expectedOffset); + break; + } + Print(EScreen,"%x \r",offset); // in case we lost the message + expectedOffset=offset+WRITE_BUFFER_SIZE; // what we expect next time + offset+=TheRomHeader.wrapSize; // offset into the file + if (fseek(romFile,offset,SEEK_SET)!=0) + { + Print(ESevereError,"* Can't seek to file offset %x", offset); + break; + } + + memset(romdata,0xff,WRITE_BUFFER_SIZE); + imageBytes=fread(romdata,1,WRITE_BUFFER_SIZE,romFile); + if (imageBytes!=WRITE_BUFFER_SIZE && offset+imageBytes!=FileSize) + { + Print(ESevereError,"* Read only %d bytes of image data err=%d\n",imageBytes,ferror(romFile)); + break; + } + if (!WriteToComPort(romdata,WRITE_BUFFER_SIZE,"image data")) + Print(ESevereError,"* Wrote only %d bytes of image data err=%x\n",BytesWritten,GetLastError()); + break; + case 'S': // request for the size of the image + if (end-next>1) + break; // must be the last command in the buffer + if (next-cp==1) + { + sprintf((char*)romdata,"%010d\n",ImageDataSize+KReproWrapperSize); + if (!WriteToComPort(romdata,strlen(romdata),NULL) + || BytesWritten!=strlen(romdata)) + Print(ESevereError,"* Failed to write file size\n"); + expectedOffset=0; // because we are starting again + break; + } + // otherwise fall through + default: + Print(EAlways,"\n* Unrecognised command >%s<\n", cp); + } + } + if (cp + + + + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/winc/tools_redistribution_cedar.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/winc/tools_redistribution_cedar.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,15 @@ +component tools_redistribution_cedar + +source \sf\os\buildtools\dist_os\redistributionwinceka2\winc + +source \sf\os\buildtools\dist_os\redistributionwinceka2\bld.inf +source \sf\os\buildtools\dist_os\redistributionwinceka2\tools_redistribution_cedar.mrp + +binary \sf\os\buildtools\dist_os\redistributionwinceka2 all +#binary \sf\os\buildtools\dist_os\redistributionwinceka2 cwtools +#exports \sf\os\buildtools\dist_os\redistributionwinceka2 + +notes_source \component_defs\release.src + +ipr T + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/winc/tools_redistribution_winc.history.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/winc/tools_redistribution_winc.history.xml Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,5 @@ + + + + + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/winc/tools_redistribution_winc.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/winc/tools_redistribution_winc.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,389 @@ +component tools_redistribution_winc + +# IainW: Workaround - the following are all exported from winc.zip, but we can't yet have more than one exported file from the same place +# They are all IPR category E + +source \sf\os\buildtools\dist_os\redistributionwinceka2\tools_redistribution_winc.mrp + +binary \epoc32\release\winc\udeb\accesspointmonitor.exe +binary \epoc32\release\winc\udeb\agnmodel.dll +binary \epoc32\release\winc\udeb\agnversit.dll +binary \epoc32\release\winc\udeb\aiftool.exe +binary \epoc32\release\winc\udeb\alarmclient.dll +binary \epoc32\release\winc\udeb\alarmserver.dll +binary \epoc32\release\winc\udeb\alarmshared.dll +binary \epoc32\release\winc\udeb\apgrfx.dll +binary \epoc32\release\winc\udeb\apmime.dll +binary \epoc32\release\winc\udeb\apparc.dll +binary \epoc32\release\winc\udeb\bafl.dll +binary \epoc32\release\winc\udeb\bifu.dll +binary \epoc32\release\winc\udeb\big5.cpl +binary \epoc32\release\winc\udeb\big5_shared.dll +binary \epoc32\release\winc\udeb\bitgdi.dll +binary \epoc32\release\winc\udeb\bmtran.dll +binary \epoc32\release\winc\udeb\charconv.dll +binary \epoc32\release\winc\udeb\cnftool.exe +binary \epoc32\release\winc\udeb\conarc.dll +binary \epoc32\release\winc\udeb\connmngmntbox.exe +binary \epoc32\release\winc\udeb\connmngmntbox.tlb +binary \epoc32\release\winc\udeb\connmngmnthelpbox.dll +binary \epoc32\release\winc\udeb\connmngmnthelpbox.lib +binary \epoc32\release\winc\udeb\connmngmnthelpbox.tlb +binary \epoc32\release\winc\udeb\connmngmntres.dll +binary \epoc32\release\winc\udeb\contprosap.dll +binary \epoc32\release\winc\udeb\contprosap.lib +binary \epoc32\release\winc\udeb\contprosap.tlb +binary \epoc32\release\winc\udeb\contprosapres.dll +binary \epoc32\release\winc\udeb\contprosapres.lib +binary \epoc32\release\winc\udeb\contprotest.exe +binary \epoc32\release\winc\udeb\convnames.dll +binary \epoc32\release\winc\udeb\convutils.dll +binary \epoc32\release\winc\udeb\csbmsto.dll +binary \epoc32\release\winc\udeb\csdbcust.dll +binary \epoc32\release\winc\udeb\csdbi.dll +binary \epoc32\release\winc\udeb\csdbw.dll +binary \epoc32\release\winc\udeb\cshlpwtr.exe +binary \epoc32\release\winc\udeb\cssup.dll +binary \epoc32\release\winc\udeb\dbwriter.dll +binary \epoc32\release\winc\udeb\dlog.dll +binary \epoc32\release\winc\udeb\dlogfl.dll +binary \epoc32\release\winc\udeb\dlogsr.dll +binary \epoc32\release\winc\udeb\dlogwn.dll +binary \epoc32\release\winc\udeb\ealm.dll +binary \epoc32\release\winc\udeb\ealwl.dll +binary \epoc32\release\winc\udeb\ecdrv.pdd +binary \epoc32\release\winc\udeb\ecomm.ldd +binary \epoc32\release\winc\udeb\econs.dll +binary \epoc32\release\winc\udeb\edbms.dll +binary \epoc32\release\winc\udeb\edev.lib +binary \epoc32\release\winc\udeb\edll.lib +binary \epoc32\release\winc\udeb\eexe.lib +binary \epoc32\release\winc\udeb\efile.dll +binary \epoc32\release\winc\udeb\efsrv.dll +binary \epoc32\release\winc\udeb\ehwa.ldd +binary \epoc32\release\winc\udeb\ehwac.pdd +binary \epoc32\release\winc\udeb\ekdata.dll +binary \epoc32\release\winc\udeb\ekern.dll +binary \epoc32\release\winc\udeb\ektran.dll +binary \epoc32\release\winc\udeb\elocal.fsy +binary \epoc32\release\winc\udeb\elocl.01 +binary \epoc32\release\winc\udeb\elocl.02 +binary \epoc32\release\winc\udeb\elocl.03 +binary \epoc32\release\winc\udeb\elocl.04 +binary \epoc32\release\winc\udeb\elocl.05 +binary \epoc32\release\winc\udeb\elocl.10 +binary \epoc32\release\winc\udeb\elocl.18 +binary \epoc32\release\winc\udeb\elocl.19 +binary \epoc32\release\winc\udeb\elocl.29 +binary \epoc32\release\winc\udeb\elocl.31 +binary \epoc32\release\winc\udeb\elocl.32 +binary \epoc32\release\winc\udeb\elocl.dll +binary \epoc32\release\winc\udeb\elocl.loc +binary \epoc32\release\winc\udeb\elocl.sc +binary \epoc32\release\winc\udeb\esock.dll +binary \epoc32\release\winc\udeb\estor.dll +binary \epoc32\release\winc\udeb\etext.dll +binary \epoc32\release\winc\udeb\eucjp_packed.cpl +binary \epoc32\release\winc\udeb\euniw.dll +binary \epoc32\release\winc\udeb\euser.dll +binary \epoc32\release\winc\udeb\exdll.lib +binary \epoc32\release\winc\udeb\fbscli.dll +binary \epoc32\release\winc\udeb\fbserv.dll +binary \epoc32\release\winc\udeb\field.dll +binary \epoc32\release\winc\udeb\fntstr.dll +binary \epoc32\release\winc\udeb\form.dll +binary \epoc32\release\winc\udeb\form_and_etext_editor.dll +binary \epoc32\release\winc\udeb\gb12345.cpl +binary \epoc32\release\winc\udeb\gb2312.cpl +binary \epoc32\release\winc\udeb\gb2312_shared.dll +binary \epoc32\release\winc\udeb\gbk.cpl +binary \epoc32\release\winc\udeb\gbk_shared.dll +binary \epoc32\release\winc\udeb\gdi.dll +binary \epoc32\release\winc\udeb\general.pdl +binary \epoc32\release\winc\udeb\hal.dll +binary \epoc32\release\winc\udeb\hz.cpl +binary \epoc32\release\winc\udeb\iso2022jp.cpl +binary \epoc32\release\winc\udeb\iso2022jp1.cpl +binary \epoc32\release\winc\udeb\iso885910.cpl +binary \epoc32\release\winc\udeb\iso885913.cpl +binary \epoc32\release\winc\udeb\iso885914.cpl +binary \epoc32\release\winc\udeb\iso885915.cpl +binary \epoc32\release\winc\udeb\iso88592.cpl +binary \epoc32\release\winc\udeb\iso88593.cpl +binary \epoc32\release\winc\udeb\iso88594.cpl +binary \epoc32\release\winc\udeb\iso88595.cpl +binary \epoc32\release\winc\udeb\iso88596.cpl +binary \epoc32\release\winc\udeb\iso88597.cpl +binary \epoc32\release\winc\udeb\iso88598.cpl +binary \epoc32\release\winc\udeb\iso88599.cpl +binary \epoc32\release\winc\udeb\iwzlib.dll +binary \epoc32\release\winc\udeb\iwzlib.lib +binary \epoc32\release\winc\udeb\jis.cpl +binary \epoc32\release\winc\udeb\jisbase_shared.dll +binary \epoc32\release\winc\udeb\jisx0201.dll +binary \epoc32\release\winc\udeb\jisx0208.dll +binary \epoc32\release\winc\udeb\jisx0212.dll +binary \epoc32\release\winc\udeb\linebreak.dll +binary \epoc32\release\winc\udeb\listcomportsbox.dll +binary \epoc32\release\winc\udeb\listcomportsbox.lib +binary \epoc32\release\winc\udeb\listcomportsbox.tlb +binary \epoc32\release\winc\udeb\mednand.pdd +binary \epoc32\release\winc\udeb\mrouterdeveloper.exe +binary \epoc32\release\winc\udeb\mroutersocket.dll +binary \epoc32\release\winc\udeb\mroutersocket.lib +binary \epoc32\release\winc\udeb\mroutersocket.tlb +binary \epoc32\release\winc\udeb\palette.dll +binary \epoc32\release\winc\udeb\pccustomservertest2.exe +binary \epoc32\release\winc\udeb\pdrstr.dll +binary \epoc32\release\winc\udeb\plp.prt +binary \epoc32\release\winc\udeb\plpcli.dll +binary \epoc32\release\winc\udeb\plpconfig.dll +binary \epoc32\release\winc\udeb\plpexe.dll +binary \epoc32\release\winc\udeb\plplog.dll +binary \epoc32\release\winc\udeb\plpremlink.dll +binary \epoc32\release\winc\udeb\plprfs.rsy +binary \epoc32\release\winc\udeb\plpsvr.dll +binary \epoc32\release\winc\udeb\plpvariant.dll +binary \epoc32\release\winc\udeb\powermgrcli.dll +binary \epoc32\release\winc\udeb\print.dll +binary \epoc32\release\winc\udeb\rpcs.rsy +binary \epoc32\release\winc\udeb\rtsock.dll +binary \epoc32\release\winc\udeb\rtsock.lib +binary \epoc32\release\winc\udeb\rtsock.tlb +binary \epoc32\release\winc\udeb\scdv.dll +binary \epoc32\release\winc\udeb\scrfs.exe +binary \epoc32\release\winc\udeb\scrfs.tlb +binary \epoc32\release\winc\udeb\scrfsproxy.dll +binary \epoc32\release\winc\udeb\scrfsproxy.lib +binary \epoc32\release\winc\udeb\shiftjis.cpl +binary \epoc32\release\winc\udeb\shiftjis_shared.dll +binary \epoc32\release\winc\udeb\socktest.exe +binary \epoc32\release\winc\udeb\tagma.dll +binary \epoc32\release\winc\udeb\testaccesspointlists.exe +binary \epoc32\release\winc\udeb\undo.dll +binary \epoc32\release\winc\udeb\vcal.dll +binary \epoc32\release\winc\udeb\vcard.dll +binary \epoc32\release\winc\udeb\versit.dll +binary \epoc32\release\winc\udeb\wldcomp.exe +binary \epoc32\release\winc\udeb\worldclient.dll +binary \epoc32\release\winc\udeb\worldserver.dll +binary \epoc32\release\winc\udeb\wpeng.dll +binary \epoc32\release\winc\udeb\ws32.dll +binary \epoc32\release\winc\udeb\xmllx.dll +binary \epoc32\release\winc\udeb\z\system\charconv\big5.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\builtin.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\eucjp_packed.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\gb12345.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\gb2312.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\gbk.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\hz.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso2022jp.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso2022jp1.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso885910.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso885913.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso885914.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso885915.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88592.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88593.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88594.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88595.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88596.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88597.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88598.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\iso88599.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\jis.rsc +binary \epoc32\release\winc\udeb\z\system\charconv\shiftjis.rsc +binary \epoc32\release\winc\udeb\z\system\printers\general.pdr +binary \epoc32\release\winc\udeb\z\system\printers\general.r01 +binary \epoc32\release\winc\udeb\z\system\printers\general.r10 +binary \epoc32\release\winc\urel\agnmodel.dll +binary \epoc32\release\winc\urel\agnversit.dll +binary \epoc32\release\winc\urel\aiftool.exe +binary \epoc32\release\winc\urel\alarmclient.dll +binary \epoc32\release\winc\urel\alarmserver.dll +binary \epoc32\release\winc\urel\alarmshared.dll +binary \epoc32\release\winc\urel\apgrfx.dll +binary \epoc32\release\winc\urel\apmime.dll +binary \epoc32\release\winc\urel\apparc.dll +binary \epoc32\release\winc\urel\bafl.dll +binary \epoc32\release\winc\urel\bifu.dll +binary \epoc32\release\winc\urel\big5.cpl +binary \epoc32\release\winc\urel\big5_shared.dll +binary \epoc32\release\winc\urel\bitgdi.dll +binary \epoc32\release\winc\urel\bmtran.dll +binary \epoc32\release\winc\urel\charconv.dll +binary \epoc32\release\winc\urel\cnftool.exe +binary \epoc32\release\winc\urel\conarc.dll +binary \epoc32\release\winc\urel\connmngmntbox.exe +binary \epoc32\release\winc\urel\connmngmntbox.tlb +binary \epoc32\release\winc\urel\connmngmnthelpbox.dll +binary \epoc32\release\winc\urel\connmngmnthelpbox.lib +binary \epoc32\release\winc\urel\connmngmnthelpbox.tlb +binary \epoc32\release\winc\urel\connmngmntres.dll +binary \epoc32\release\winc\urel\contprosap.dll +binary \epoc32\release\winc\urel\contprosap.lib +binary \epoc32\release\winc\urel\contprosap.tlb +binary \epoc32\release\winc\urel\contprosapres.dll +binary \epoc32\release\winc\urel\contprosapres.lib +binary \epoc32\release\winc\urel\convnames.dll +binary \epoc32\release\winc\urel\convutils.dll +binary \epoc32\release\winc\urel\csbmsto.dll +binary \epoc32\release\winc\urel\csdbcust.dll +binary \epoc32\release\winc\urel\csdbi.dll +binary \epoc32\release\winc\urel\csdbw.dll +binary \epoc32\release\winc\urel\cshlpwtr.exe +binary \epoc32\release\winc\urel\cssup.dll +binary \epoc32\release\winc\urel\dbwriter.dll +binary \epoc32\release\winc\urel\dlog.dll +binary \epoc32\release\winc\urel\dlogfl.dll +binary \epoc32\release\winc\urel\dlogsr.dll +binary \epoc32\release\winc\urel\dlogwn.dll +binary \epoc32\release\winc\urel\ealm.dll +binary \epoc32\release\winc\urel\ealwl.dll +binary \epoc32\release\winc\urel\ecdrv.pdd +binary \epoc32\release\winc\urel\ecomm.ldd +binary \epoc32\release\winc\urel\econs.dll +binary \epoc32\release\winc\urel\edbms.dll +binary \epoc32\release\winc\urel\edev.lib +binary \epoc32\release\winc\urel\edll.lib +binary \epoc32\release\winc\urel\eexe.lib +binary \epoc32\release\winc\urel\efile.dll +binary \epoc32\release\winc\urel\efsrv.dll +binary \epoc32\release\winc\urel\ehwa.ldd +binary \epoc32\release\winc\urel\ehwac.pdd +binary \epoc32\release\winc\urel\ekdata.dll +binary \epoc32\release\winc\urel\ekern.dll +binary \epoc32\release\winc\urel\ektran.dll +binary \epoc32\release\winc\urel\elocal.fsy +binary \epoc32\release\winc\urel\elocl.01 +binary \epoc32\release\winc\urel\elocl.02 +binary \epoc32\release\winc\urel\elocl.03 +binary \epoc32\release\winc\urel\elocl.04 +binary \epoc32\release\winc\urel\elocl.05 +binary \epoc32\release\winc\urel\elocl.10 +binary \epoc32\release\winc\urel\elocl.18 +binary \epoc32\release\winc\urel\elocl.19 +binary \epoc32\release\winc\urel\elocl.29 +binary \epoc32\release\winc\urel\elocl.31 +binary \epoc32\release\winc\urel\elocl.32 +binary \epoc32\release\winc\urel\elocl.dll +binary \epoc32\release\winc\urel\elocl.loc +binary \epoc32\release\winc\urel\elocl.sc +binary \epoc32\release\winc\urel\esock.dll +binary \epoc32\release\winc\urel\estor.dll +binary \epoc32\release\winc\urel\etext.dll +binary \epoc32\release\winc\urel\eucjp_packed.cpl +binary \epoc32\release\winc\urel\euniw.dll +binary \epoc32\release\winc\urel\euser.dll +binary \epoc32\release\winc\urel\exdll.lib +binary \epoc32\release\winc\urel\fbscli.dll +binary \epoc32\release\winc\urel\fbserv.dll +binary \epoc32\release\winc\urel\field.dll +binary \epoc32\release\winc\urel\fntstr.dll +binary \epoc32\release\winc\urel\form.dll +binary \epoc32\release\winc\urel\form_and_etext_editor.dll +binary \epoc32\release\winc\urel\gb12345.cpl +binary \epoc32\release\winc\urel\gb2312.cpl +binary \epoc32\release\winc\urel\gb2312_shared.dll +binary \epoc32\release\winc\urel\gbk.cpl +binary \epoc32\release\winc\urel\gbk_shared.dll +binary \epoc32\release\winc\urel\gdi.dll +binary \epoc32\release\winc\urel\general.pdl +binary \epoc32\release\winc\urel\hal.dll +binary \epoc32\release\winc\urel\hz.cpl +binary \epoc32\release\winc\urel\iso2022jp.cpl +binary \epoc32\release\winc\urel\iso2022jp1.cpl +binary \epoc32\release\winc\urel\iso885910.cpl +binary \epoc32\release\winc\urel\iso885913.cpl +binary \epoc32\release\winc\urel\iso885914.cpl +binary \epoc32\release\winc\urel\iso885915.cpl +binary \epoc32\release\winc\urel\iso88592.cpl +binary \epoc32\release\winc\urel\iso88593.cpl +binary \epoc32\release\winc\urel\iso88594.cpl +binary \epoc32\release\winc\urel\iso88595.cpl +binary \epoc32\release\winc\urel\iso88596.cpl +binary \epoc32\release\winc\urel\iso88597.cpl +binary \epoc32\release\winc\urel\iso88598.cpl +binary \epoc32\release\winc\urel\iso88599.cpl +binary \epoc32\release\winc\urel\iwzlib.dll +binary \epoc32\release\winc\urel\iwzlib.lib +binary \epoc32\release\winc\urel\jis.cpl +binary \epoc32\release\winc\urel\jisbase_shared.dll +binary \epoc32\release\winc\urel\jisx0201.dll +binary \epoc32\release\winc\urel\jisx0208.dll +binary \epoc32\release\winc\urel\jisx0212.dll +binary \epoc32\release\winc\urel\linebreak.dll +binary \epoc32\release\winc\urel\listcomportsbox.dll +binary \epoc32\release\winc\urel\listcomportsbox.lib +binary \epoc32\release\winc\urel\listcomportsbox.tlb +binary \epoc32\release\winc\urel\mednand.pdd +binary \epoc32\release\winc\urel\mroutersocket.dll +binary \epoc32\release\winc\urel\mroutersocket.lib +binary \epoc32\release\winc\urel\mroutersocket.tlb +binary \epoc32\release\winc\urel\palette.dll +binary \epoc32\release\winc\urel\pdrstr.dll +binary \epoc32\release\winc\urel\plp.prt +binary \epoc32\release\winc\urel\plpcli.dll +binary \epoc32\release\winc\urel\plpconfig.dll +binary \epoc32\release\winc\urel\plpexe.dll +binary \epoc32\release\winc\urel\plplog.dll +binary \epoc32\release\winc\urel\plpremlink.dll +binary \epoc32\release\winc\urel\plprfs.rsy +binary \epoc32\release\winc\urel\plpsvr.dll +binary \epoc32\release\winc\urel\plpvariant.dll +binary \epoc32\release\winc\urel\powermgrcli.dll +binary \epoc32\release\winc\urel\print.dll +binary \epoc32\release\winc\urel\rpcs.rsy +binary \epoc32\release\winc\urel\rtsock.dll +binary \epoc32\release\winc\urel\rtsock.lib +binary \epoc32\release\winc\urel\rtsock.tlb +binary \epoc32\release\winc\urel\scdv.dll +binary \epoc32\release\winc\urel\scrfs.exe +binary \epoc32\release\winc\urel\scrfs.tlb +binary \epoc32\release\winc\urel\scrfsproxy.dll +binary \epoc32\release\winc\urel\scrfsproxy.lib +binary \epoc32\release\winc\urel\shiftjis.cpl +binary \epoc32\release\winc\urel\shiftjis_shared.dll +binary \epoc32\release\winc\urel\tagma.dll +binary \epoc32\release\winc\urel\undo.dll +binary \epoc32\release\winc\urel\vcal.dll +binary \epoc32\release\winc\urel\vcard.dll +binary \epoc32\release\winc\urel\versit.dll +binary \epoc32\release\winc\urel\wldcomp.exe +binary \epoc32\release\winc\urel\worldclient.dll +binary \epoc32\release\winc\urel\worldserver.dll +binary \epoc32\release\winc\urel\wpeng.dll +binary \epoc32\release\winc\urel\ws32.dll +binary \epoc32\release\winc\urel\xmllx.dll +binary \epoc32\release\winc\urel\z\system\charconv\big5.rsc +binary \epoc32\release\winc\urel\z\system\charconv\builtin.rsc +binary \epoc32\release\winc\urel\z\system\charconv\eucjp_packed.rsc +binary \epoc32\release\winc\urel\z\system\charconv\gb12345.rsc +binary \epoc32\release\winc\urel\z\system\charconv\gb2312.rsc +binary \epoc32\release\winc\urel\z\system\charconv\gbk.rsc +binary \epoc32\release\winc\urel\z\system\charconv\hz.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso2022jp.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso2022jp1.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso885910.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso885913.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso885914.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso885915.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88592.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88593.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88594.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88595.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88596.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88597.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88598.rsc +binary \epoc32\release\winc\urel\z\system\charconv\iso88599.rsc +binary \epoc32\release\winc\urel\z\system\charconv\jis.rsc +binary \epoc32\release\winc\urel\z\system\charconv\shiftjis.rsc +binary \epoc32\release\winc\urel\z\system\printers\general.pdr +binary \epoc32\release\winc\urel\z\system\printers\general.r01 +binary \epoc32\release\winc\urel\z\system\printers\general.r10 +notes_source \component_defs\release.src + + + +ipr T + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/winc/winc/winc.zip Binary file deprecated/winc/winc/winc.zip has changed diff -r 22486c9c7b15 -r 378360dbbdba deprecated/wveconv/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/wveconv/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,31 @@ +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Base tools (e.g. petran) +// +// + +/** + @file +*/ + + +PRJ_PLATFORMS +TOOLS2 + + +PRJ_MMPFILES +wveconv.mmp + +PRJ_TESTMMPFILES + diff -r 22486c9c7b15 -r 378360dbbdba deprecated/wveconv/group/wveconv.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/wveconv/group/wveconv.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,25 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET wveconv.exe +TARGETTYPE exe +SOURCEPATH ../../wveconv +SOURCE wveconv.cpp + + + + +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba deprecated/wveconv/group/wveconv.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/wveconv/group/wveconv.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,9 @@ +component dev_build_deprecated_wveconv + +source /src/tools/build/deprecated/wveconv +exports /src/tools/build/deprecated/wveconv/group +binary /src/tools/build/deprecated/wveconv/group all + +notes_source \component_defs\release.src + +ipr T diff -r 22486c9c7b15 -r 378360dbbdba deprecated/wveconv/wveconv.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deprecated/wveconv/wveconv.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,250 @@ +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Psion3a WVE to Series5 sound file convertor +// +// + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) +#include +#include +using namespace std; +#else //!__MSVCDOTNET__ +#include +#include +#ifdef __CW32__ +using std::streampos; +#endif //__CW32__ +#endif //__MSVCDOTNET__ + +#include + +#if defined(__VC32__) && !defined(__MSVCDOTNET__) +#pragma warning( disable : 4710 ) // 'fn': function not inlined +#endif // old MSVC + +#define KUidRecordApp 0x1000007e + +#define KUid1 0x10000037 +#define KUid2 0x1000006d +#define KUid3 KUidRecordApp +#define KUidCheckSum 0x5508accf + +#define KUidAppStream 0x10000089 +#define KUidSampleStream 0x10000052 + + +int ErrorNotWveFile() + { + cout << "The specified input file is not a Series 3a WVE file" << endl ; + return(0); + } + +int ErrorNotFound() + { + cout << "Unable to open input file" << endl ; + return(0); + } + +int ReadInt32(ifstream& inStream) + { + char ch[4]; + inStream.read(&ch[0],4); + return *(int*)&ch[0]; + } + +int ReadInt16(ifstream& inStream) + { + char ch[4]; + inStream.read(&ch[0],2); + ch[2]=0; + ch[3]=0; + return *(int*)&ch[0]; + } + +int WriteWord(ofstream& outStream,unsigned int aWord) + { + outStream.write((char*)&aWord,4); + return 0; + } + +int WriteByte(ofstream& outStream,const char aByte) + { + outStream.write((char*)&aByte,1); + return 0; + } + +int WriteText(ofstream& outStream,const char* aText) + { + char ch; + while((ch=*aText++)!=0) + outStream << ch; + return 0; + } + +void ShowHelp() + { + cout << "WveConv 0.04"; + cout << endl ; + cout << "Converts a Psion 3a WVE file to an EPOC sound file" << endl ; + cout << endl ; + cout << "Usage: WVECONV S3AFILE.WVE [EPOCFILE]" << endl ; + cout << endl ; + cout << "If [EPOCFILE] is omitted, the input filename" << endl ; + cout << "without the extension will be used" << endl ; + } + +int ConvertFile(const char* inputFile,const char* outputFile) + { + ifstream inStream(inputFile,ios::in|ios::binary); + ofstream outStream(outputFile,ios::out|ios::binary); + + if(!inStream.is_open()) + return(ErrorNotFound()); + + const char* appName="Record.app"; + char header[16]; + + inStream.read(&header[0],16); + + if(strcmp(header,"ALawSoundFile**")!=0) + return(ErrorNotWveFile()); + + int compressedLength=0; + int trailingSilence=0; + int compressorUid=0; + int sampleLength=0; + int repeatCount=0; + int versionNumber=0; +// +// extract the sample length, repeat count and trailing silence... +// + versionNumber=ReadInt16(inStream); + sampleLength=ReadInt32(inStream); + trailingSilence=ReadInt16(inStream); + repeatCount=ReadInt16(inStream); + if(repeatCount==0) // 0 and 1 are the same on Series 3 + repeatCount=1; + + trailingSilence*=31250; + + compressedLength=sampleLength; + + cout << "Converting " << inputFile << " to " << outputFile << endl << endl; + cout << "Version number :" << versionNumber << endl ; + cout << "Sample length :" << sampleLength << " bytes" << endl ; + cout << "Repeat count :" << repeatCount << endl ; + cout << "Trailing silence:" << trailingSilence << " uS" << endl ; + + inStream.seekg((streampos)0x20); +// +// Write out the header... +// + unsigned int rootstreamid=0x14; + unsigned int appstreamid=0x25; + unsigned int samplestreamid=0x34; + +// checked uid header + + WriteWord(outStream,KUid1); + WriteWord(outStream,KUid2); + WriteWord(outStream,KUidRecordApp); + WriteWord(outStream,KUidCheckSum); + +// root stream id + + WriteWord(outStream,rootstreamid); + +//stream dictionary @ 0x14 root stream + + WriteByte(outStream,4); // two entries in dictionary + WriteWord(outStream,KUidSampleStream); // sample stream + WriteWord(outStream,samplestreamid); + WriteWord(outStream,KUidAppStream); // appid stream + WriteWord(outStream,appstreamid); + +// record app identifier stream @ 0x25 + + WriteWord(outStream,KUidRecordApp); + WriteByte(outStream,42); + WriteText(outStream,appName); + +// sample header @ 0x34 + + WriteWord(outStream,sampleLength); + WriteWord(outStream,compressorUid); + WriteWord(outStream,repeatCount-1); // repeats are zero based on Series 5 + WriteWord(outStream,trailingSilence); + WriteWord(outStream,compressedLength); +// +// Copy the sample data... +// + streampos newPos=0x20; // start of sample data in 3a file... + inStream.seekg(newPos); + + char buffer[256]; + int count; + int actualLength=0; + do + { + inStream.read(&buffer[0],256); + if((count=inStream.gcount())!=0) + { + outStream.write(&buffer[0],count); + actualLength+=count; + } + } while(count); +// +// should check actualLength==sampleLength...but what the heck +// + outStream.close(); + inStream.close(); + return 0; + } + +int main(int aNumArgs,char* aArgs[]) + { + if(aNumArgs<=1 || aArgs[1][0]=='?' || aArgs[1][0]=='/') + { + ShowHelp(); + return 0; + } + char inputFile[255]; + char outputFile[255]; + + strcpy(inputFile,aArgs[1]); + + if(aNumArgs==3) + strcpy(outputFile,aArgs[2]); + + if(aNumArgs==2 || outputFile[0]==0) + { + strcpy(outputFile,inputFile); +// +// remove the extension +// + int len=strlen(outputFile); + for(;;) + { + if(--len<0) + break; + if(outputFile[len]=='.') + { + outputFile[len]=0; + break; + } + } + } + return(ConvertFile(inputFile,outputFile)); + } + diff -r 22486c9c7b15 -r 378360dbbdba e32tools/e32lib/e32image/Makefile.elftran.bak --- a/e32tools/e32lib/e32image/Makefile.elftran.bak Wed Jun 23 17:27:59 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -# Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of the License "Symbian Foundation License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - -CXX = g++296 -CXXFLAGS = -D__SUPPORT_ELF_FILES__ -D__LINUX__ -D__GCC32__ -D__TOOLS__ -D EKA2 \ - -I $(EPOCROOT)epoc32/include -I ../inc -I ../elftools/inc -SOURCE = elf_file.cpp elf_dlld.cpp elf_imp.cpp elf_reloc.cpp elf_tran.cpp \ - e32uid.cpp \ - h_file.cpp h_mem.cpp h_utl.cpp \ - e32image.cpp tr_main.cpp imgdump.cpp \ - decode.cpp encode.cpp deflate.cpp inflate.cpp panic.cpp compress.cpp -BLDDIR = ../build-elftran -OBJECT = $(addprefix $(BLDDIR)/, $(notdir $(SOURCE:.cpp=.o))) -TARGET = $(BLDDIR)/elftran - -VPATH = ../host ../e32uid ../e32image ../e32image/deflate ../elftools/elftran - -_dummy := $(shell mkdir -p $(BLDDIR)) - -all: $(TARGET) - -$(TARGET): $(OBJECT) - $(CXX) $^ -o $@ - strip $@ - -$(OBJECT): $(BLDDIR)/%.o: %.cpp - $(CXX) $(CXXFLAGS) -c $< -o $@ - -clean: - rm -f $(OBJECT) $(TARGET) - -rmdir $(BLDDIR) - -.PHONY: all clean - diff -r 22486c9c7b15 -r 378360dbbdba e32tools/e32lib/seclib/seclib.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/e32lib/seclib/seclib.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,41 @@ +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32tools/inc/seclib.h +// Get the capabilities of an emulator / e32image. +// Image security information structure. +// +// + +/** + @internalTechnology + @prototype +*/ +struct SBinarySecurityInfo + { + TUint32 iSecureId; + TUint32 iVendorId; + TUint8 iCapabilities[KCapabilitySetMaxSize]; + TBool iE32Image; + }; + +/** + * Extracts security information from an image. + * + * @internalTechnology + * @prototype + */ +TInt GetSecurityInfo(const char* aFileName, SBinarySecurityInfo& aInfo); +#ifndef __LINUX__ +TInt GetSecurityInfo(const wchar_t* aFileName, SBinarySecurityInfo& aInfo); +#endif diff -r 22486c9c7b15 -r 378360dbbdba e32tools/elf2e32/group/elf2e32.mmp --- a/e32tools/elf2e32/group/elf2e32.mmp Wed Jun 23 17:27:59 2010 +0800 +++ b/e32tools/elf2e32/group/elf2e32.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -19,15 +19,21 @@ sourcepath ../source source deffile.cpp deflatecompress.cpp dll_fb_target.cpp dll_rebuild_target.cpp e32exporttable.cpp -source filedump.cpp e32imagefile.cpp elf2e32.cpp elffilesupplied.cpp errorhandler.cpp exetarget.cpp exexp_fb_target.cpp -source exexp_rebuild_target.cpp export_type_fb_target.cpp export_type_rebuild_target.cpp export_type_target.cpp h_utl.cpp +source filedump.cpp elf2e32.cpp elffilesupplied.cpp errorhandler.cpp exetarget.cpp exexp_fb_target.cpp +source exexp_rebuild_target.cpp export_type_fb_target.cpp export_type_rebuild_target.cpp export_type_target.cpp source huffman.cpp imgdump.cpp inflate.cpp librarytarget.cpp main.cpp messagehandler.cpp messageimplementation.cpp source parameterlistinterface.cpp parametermanager.cpp pl_common.cpp pl_dllsymbol.cpp pl_dso_handler.cpp pl_elfconsumer.cpp source pl_elfexecutable.cpp pl_elfexports.cpp pl_elfimportrelocation.cpp pl_elfimports.cpp pl_elflocalrelocation.cpp pl_elfproducer.cpp source pl_elfrelocation.cpp pl_elfrelocations.cpp pl_symbol.cpp polydll_fb_target.cpp polydll_rebuild_target.cpp usecasebase.cpp -source byte_pair.cpp pagedcompress.cpp checksum.cpp stdexe_target.cpp +source checksum.cpp stdexe_target.cpp e32imagefile.cpp + +sourcepath ../../../imgtools/imglib/host +source h_utl.cpp +sourcepath ../../../imgtools/imglib/compress +source byte_pair.cpp pagedcompress.cpp userinclude ../source ../include ../../../bintools/elftools/inc +userinclude ../../../imgtools/imglib/compress ../../../imgtools/imglib/inc OS_LAYER_SYSTEMINCLUDE_SYMBIAN option GCC -O2 -w diff -r 22486c9c7b15 -r 378360dbbdba e32tools/elf2e32/group/release.txt --- a/e32tools/elf2e32/group/release.txt Wed Jun 23 17:27:59 2010 +0800 +++ b/e32tools/elf2e32/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -4,6 +4,11 @@ NOTESRC_RELEASE_REASON Postlinker(elf2e32) Release +version 2.2 build(004) +=============== +Released by Lorence Wang, 11/06/2010 + 1) elf2e32 use new bytepair in imglib + version 2.2 build(003) =============== Released by Lorence Wang, 26/04/2010 diff -r 22486c9c7b15 -r 378360dbbdba e32tools/elf2e32/include/h_ver.h --- a/e32tools/elf2e32/include/h_ver.h Wed Jun 23 17:27:59 2010 +0800 +++ b/e32tools/elf2e32/include/h_ver.h Wed Jun 30 11:35:58 2010 +0800 @@ -18,7 +18,7 @@ const TInt MajorVersion=2; const TInt MinorVersion=2; -const TInt Build=3; +const TInt Build=4; #endif diff -r 22486c9c7b15 -r 378360dbbdba e32tools/elf2e32/source/e32imagefile.cpp --- a/e32tools/elf2e32/source/e32imagefile.cpp Wed Jun 23 17:27:59 2010 +0800 +++ b/e32tools/elf2e32/source/e32imagefile.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -33,6 +33,7 @@ #include "h_ver.h" #include "checksum.h" #include "errorhandler.h" +#include "byte_pair.h" #include #include @@ -57,25 +58,6 @@ return (T)res; } -// Need a default constructor for TVersion, but don't want all the other stuff in h_utl.cpp -/** -Default constructor for TVersion class. -@internalComponent -@released -*/ -TVersion::TVersion(){} - -/** -Constructor for TVersion class. -@internalComponent -@released -*/ -TVersion::TVersion(TInt aMajor, TInt aMinor, TInt aBuild): - iMajor((TInt8)aMajor), iMinor((TInt8)aMinor), iBuild((TInt16)aBuild) -{ -} - - /** Constructor for E32ImageChunkDesc class. @internalComponent @@ -1406,7 +1388,7 @@ @internalComponent @released */ -void CompressPages(TUint8 * bytes, TInt size, ofstream& os); +void CompressPages(TUint8 * bytes, TInt size, ostream& os, CBytePair *aBPE); /** @@ -1436,15 +1418,16 @@ os->write(iE32Image, aHeaderSize); // Compress and write out code part + CBytePair bpe; int srcStart = GetExtendedE32ImageHeaderSize(); - CompressPages( (TUint8*)iE32Image + srcStart, iHdr->iCodeSize, *os); + CompressPages( (TUint8*)iE32Image + srcStart, iHdr->iCodeSize, *os, &bpe); // Compress and write out data part srcStart += iHdr->iCodeSize; int srcLen = GetE32ImageSize() - srcStart; - CompressPages((TUint8*)iE32Image + srcStart, srcLen, *os); + CompressPages((TUint8*)iE32Image + srcStart, srcLen, *os, &bpe); } else if (compression == 0) @@ -1702,7 +1685,7 @@ } -int DecompressPages(TUint8 * bytes, ifstream& is); +int DecompressPages(TUint8 * bytes, istream& is, CBytePair *aBPE); /** @@ -1773,13 +1756,13 @@ oh = aImage.iOrigHdr; // Read and decompress code part of the image - - unsigned int uncompressedCodeSize = DecompressPages((TUint8 *) (aImage.iData + orighdrsz), is); + CBytePair bpe; + unsigned int uncompressedCodeSize = DecompressPages((TUint8 *) (aImage.iData + orighdrsz), is, &bpe); // Read and decompress data part of the image - unsigned int uncompressedDataSize = DecompressPages((TUint8 *) (aImage.iData + orighdrsz + uncompressedCodeSize), is); + unsigned int uncompressedDataSize = DecompressPages((TUint8 *) (aImage.iData + orighdrsz + uncompressedCodeSize), is, &bpe); if (uncompressedCodeSize + uncompressedDataSize != uncompsize) MessageHandler::GetInstance()->ReportMessage(WARNING, BYTEPAIRINCONSISTENTSIZEERROR); diff -r 22486c9c7b15 -r 378360dbbdba e32tools/elf2e32/source/h_utl.h.bak --- a/e32tools/elf2e32/source/h_utl.h.bak Wed Jun 23 17:27:59 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "Symbian Foundation License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". -// Initial Contributors: -// Nokia Corporation - initial contribution. -// Contributors: -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "Symbian Foundation License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". -// Initial Contributors: -// Nokia Corporation - initial contribution. -// Contributors: -// - - - #ifndef __H_UTL_H__ - #define __H_UTL_H__ - -#include "e32defwrap.h" -#include -#include - -#ifdef __TOOLS2__ -#include -#include -using namespace std; -#else -#include -#endif - - /** - Convert string to number. - @internalComponent - @released - */ - template - TInt Val(T& aVal, char* aStr) - { - - - T x; - #ifdef __TOOLS2__ - istringstream val(aStr); - #else - istrstream val(aStr,strlen(aStr)); - #endif - val >> x; - if (!val.eof() || val.fail()) - return KErrGeneral; - aVal=x; - return KErrNone; - - /*T x; - istrstream val(aStr,strlen(aStr)); - val >> x; - if (!val.eof() || val.fail()) - return KErrGeneral; - aVal=x; - return KErrNone;*/ - } - - - //enum for decompose flag - enum TDecomposeFlag - { - EUidPresent=1, - EVerPresent=2 - }; - - /** - class for FileNameInfo - @internalComponent - @released - */ - class TFileNameInfo - { - public: - TFileNameInfo(const char* aFileName, TBool aLookForUid); - public: - const char* iFileName; - TInt iTotalLength; - TInt iBaseLength; - TInt iExtPos; - TUint32 iUid3; - TUint32 iModuleVersion; - TUint32 iFlags; - }; - - extern char* NormaliseFileName(const char* aName); - - - - #ifdef __LINUX__ - // Case insensitive comparison functions are named differently on Linux - #define stricmp strcasecmp - #define strnicmp strncasecmp - - // Convert the provided string to Uppercase - char* strupr(char *a); - #endif // __LINUX__ - - #endif // __H_UTL_H__ - - - - - - - - - diff -r 22486c9c7b15 -r 378360dbbdba e32tools/elf2e32/source/parametermanager.cpp --- a/e32tools/elf2e32/source/parametermanager.cpp Wed Jun 23 17:27:59 2010 +0800 +++ b/e32tools/elf2e32/source/parametermanager.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -18,7 +18,7 @@ // // This must go before ParameterManager.h -#define __INCLUDE_CAPABILITY_NAMES__ +#define __REFERENCE_CAPABILITY_NAMES__ #include #include "pl_common.h" diff -r 22486c9c7b15 -r 378360dbbdba e32tools/uidcrc/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Base tools (e.g. petran) +* +*/ + + +/** + @file +*/ + +PRJ_PLATFORMS +TOOLS2 + +PRJ_MMPFILES +uidcrc diff -r 22486c9c7b15 -r 378360dbbdba e32tools/uidcrc/group/uidcrc.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/group/uidcrc.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +TARGET uidcrc.exe +TARGETTYPE exe +SOURCEPATH ../src +SOURCE uidcrc.cpp e32uid.cpp +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +VENDORID 0x70000001 + +option GCC -O2 -Wno-uninitialized diff -r 22486c9c7b15 -r 378360dbbdba e32tools/uidcrc/group/uidcrc.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/group/uidcrc.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,5 @@ +component dev_build_e32tools_uidcrc + +source /src/tools/build/e32tools/uidcrc +binary /src/tools/build/e32tools/uidcrc/group all + diff -r 22486c9c7b15 -r 378360dbbdba e32tools/uidcrc/src/e32uid.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/src/e32uid.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,253 @@ +/* +* Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#if defined(__MSVCDOTNET__) || defined(__TOOLS2__) + #include + using namespace std; +#endif + +typedef unsigned char BYTE; // TUint8 +typedef unsigned short WORD; // TUint16 +typedef unsigned int UINT; // TUint + +#include +#include +#include +#include "e32uid.h" + +const UINT crcTab[256] = + { + 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,0x8108,0x9129,0xa14a, + 0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294, + 0x72f7,0x62d6,0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,0x2462, + 0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,0xa56a,0xb54b,0x8528,0x9509, + 0xe5ee,0xf5cf,0xc5ac,0xd58d,0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695, + 0x46b4,0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,0x48c4,0x58e5, + 0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948, + 0x9969,0xa90a,0xb92b,0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12, + 0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,0x6ca6,0x7c87,0x4ce4, + 0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b, + 0x8d68,0x9d49,0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,0xff9f, + 0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,0x9188,0x81a9,0xb1ca,0xa1eb, + 0xd10c,0xc12d,0xf14e,0xe16f,0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046, + 0x6067,0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,0x02b1,0x1290, + 0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e, + 0xe54f,0xd52c,0xc50d,0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405, + 0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,0x26d3,0x36f2,0x0691, + 0x16b0,0x6657,0x7676,0x4615,0x5634,0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9, + 0xb98a,0xa9ab,0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,0xcb7d, + 0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,0x4a75,0x5a54,0x6a37,0x7a16, + 0x0af1,0x1ad0,0x2ab3,0x3a92,0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8, + 0x8dc9,0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,0xef1f,0xff3e, + 0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,0x6e17,0x7e36,0x4e55,0x5e74,0x2e93, + 0x3eb2,0x0ed1,0x1ef0 + }; + +void Crc(WORD& aCrc,const void* aPtr,int aLength) +// +// Perform a CCITT CRC checksum. +// + { + + const BYTE* pB=(const BYTE*)aPtr; + const BYTE* pE=pB+aLength; + UINT crc=aCrc; + while (pB>8)^*pB++)&0xff]; + aCrc=(WORD)crc; + } + +UINT checkSum(const void* aPtr) +// +// Checksum every other byte +// + { + + const BYTE* pB=(const BYTE*)aPtr; + const BYTE* pE=pB+(KMaxCheckedUid*sizeof(TUid)); + BYTE buf[(KMaxCheckedUid*sizeof(TUid))>>1]; + BYTE* pT=(&buf[0]); + while (pB>1); + return(crc); + } + +int TUid::operator==(const TUid& aUid) const +// +// Compare UID's for equality +// + { + + return(iUid==aUid.iUid); + } + +int TUid::operator!=(const TUid& aUid) const +// +// Compare UID's for equality +// + { + + return(iUid!=aUid.iUid); + } + +TUidType::TUidType() +// +// Constructor +// + { + + memset(this,0,sizeof(TUidType)); + } + +TUidType::TUidType(TUid aUid1) +// +// Constructor +// + { + + + memset(this,0,sizeof(TUidType)); + iUid[0]=aUid1; + } + +TUidType::TUidType(TUid aUid1,TUid aUid2) +// +// Constructor +// + { + + iUid[0]=aUid1; + iUid[1]=aUid2; + iUid[2]=KNullUid; + } + +TUidType::TUidType(TUid aUid1,TUid aUid2,TUid aUid3) +// +// Constructor +// + { + + + iUid[0]=aUid1; + iUid[1]=aUid2; + iUid[2]=aUid3; + } + +int TUidType::operator==(const TUidType& aUidType) const +// +// TRUE if equal. +// + { + + return(iUid[0]==aUidType.iUid[0] && + iUid[1]==aUidType.iUid[1] && + iUid[2]==aUidType.iUid[2]); + } + +int TUidType::operator!=(const TUidType& aUidType) const +// +// TRUE if not equal. +// + { + + + return(!(*this==aUidType)); + } + +const TUid& TUidType::operator[](int anIndex) const +// +// Array operator. +// + { + + return(iUid[anIndex]); + } + +TUid TUidType::MostDerived() const +// +// Return the most derived type +// + { + + if (iUid[2]!=KNullUid) + return(iUid[2]); + if (iUid[1]!=KNullUid) + return(iUid[1]); + return(iUid[0]); + } + +int TUidType::IsPresent(TUid aUid) const +// +// TRUE if aUid is present as any type. +// + { + + return(iUid[0]==aUid || iUid[1]==aUid || iUid[2]==aUid); + } + +int TUidType::IsValid() const +// +// TRUE if one of the type is not NULL. +// + { + + return(MostDerived()!=KNullUid); + } + +TCheckedUid::TCheckedUid() +// +// Constructor +// + { + + memset(this,0,sizeof(TCheckedUid)); + } + +TCheckedUid::TCheckedUid(const TUidType& aUidType) +// +// Constructor +// + { + + Set(aUidType); + } + +void TCheckedUid::Set(const TUidType& aUidType) +// +// Set from a aUidType +// + { + + iType=aUidType; + iCheck=Check(); + } + +UINT TCheckedUid::Check() const +// +// Return the checksum of the UIDs +// + { + + return((checkSum(((BYTE*)this)+1)<<16)|checkSum((BYTE*)this)); + } + diff -r 22486c9c7b15 -r 378360dbbdba e32tools/uidcrc/src/uidcrc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/e32tools/uidcrc/src/uidcrc.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include +using namespace std; + +#include +#include +#include +#include +#include + +// Get round the privateness of the checksum etc. +// See also PE_TRAN.CPP TE32ImageUids + +class TCheckedUidX : public TCheckedUid + { +public: + inline TCheckedUidX(TUint uids[3]) + : TCheckedUid(TUidType(TUid::Uid(uids[1]),TUid::Uid(uids[2]),TUid::Uid(uids[3]))) + {} + inline TUint CRC() + { return Check(); } + }; + +int usage() + { + fprintf(stderr, "uidcrc [ ]\n"); + return -1; + } + +int main(int argc, char* argv[]) + { + if (argc<4 || argc>5) + return usage(); + + TUint uids[5]; + int i=0; + + for (i=1; i<4; i++) + { + char* endptr = "failed"; + uids[i] = strtoul(argv[i],&endptr,0); + if (*endptr!='\0') + { + fprintf(stderr, "invalid uid%d >%s<\n",i,argv[i]); + return -1; + } + } + + TCheckedUidX checked(uids); + uids[4] = checked.CRC(); + + if (argc==5) + { + FILE* fp=fopen(argv[4], "wb"); + if (fp==0) + { + fprintf(stderr, "cannot open %s for writing\n", argv[4]); + return -1; + } + for (i=1; i<5; i++) + { + TUint word=uids[i]; + unsigned char bytes[4]; + bytes[0] = (unsigned char)( word &0xFF); + bytes[1] = (unsigned char)((word>> 8)&0xFF); + bytes[2] = (unsigned char)((word>>16)&0xFF); + bytes[3] = (unsigned char)((word>>24)&0xFF); + fwrite(bytes, 4, 1, fp); + } + fclose(fp); + return 0; + } + + printf("0x%08x 0x%08x 0x%08x 0x%08x\n", uids[1], uids[2], uids[3], uids[4]); + return 0; + } diff -r 22486c9c7b15 -r 378360dbbdba hostenv/unzip-5.40/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/unzip-5.40/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,22 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS + +PRJ_EXPORTS + +../unzip.exe /tools/unzip-5.40/unzip.exe + +PRJ_MMPFILES diff -r 22486c9c7b15 -r 378360dbbdba hostenv/unzip-5.40/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/unzip-5.40/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,5 @@ +NOTESRC_RELEASER +Symbian Software Ltd. + +NOTESRC_RELEASE_REASON +Unzip tools. diff -r 22486c9c7b15 -r 378360dbbdba hostenv/unzip-5.40/group/unzip-5.40.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/unzip-5.40/group/unzip-5.40.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,23 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +component dev_build_hostenv_unzip-5.40 + +source \src\tools\build\hostenv\unzip-5.40 +exports \src\tools\build\hostenv\unzip-5.40\group + +notes_source \src\tools\build\hostenv\unzip-5.40\group\release.txt + +ipr T \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba hostenv/unzip-5.40/unzip.exe Binary file hostenv/unzip-5.40/unzip.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba hostenv/zip-2.2/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/zip-2.2/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,22 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS + +PRJ_EXPORTS + +../zip.exe /tools/zip-2.2/zip.exe + +PRJ_MMPFILES diff -r 22486c9c7b15 -r 378360dbbdba hostenv/zip-2.2/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/zip-2.2/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,5 @@ +NOTESRC_RELEASER +Symbian Software Ltd. + +NOTESRC_RELEASE_REASON +Zip tools. diff -r 22486c9c7b15 -r 378360dbbdba hostenv/zip-2.2/group/zip-2.2.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hostenv/zip-2.2/group/zip-2.2.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,23 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +component dev_build_hostenv_zip-2.2 + +source \src\tools\build\hostenv\zip-2.2 +exports \src\tools\build\hostenv\zip-2.2\group + +notes_source \src\tools\build\hostenv\zip-2.2\group\release.txt + +ipr T \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba hostenv/zip-2.2/zip.exe Binary file hostenv/zip-2.2/zip.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/group/configpaging.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/group/configpaging.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,34 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +TARGET configpaging.exe +TARGETTYPE exe +SOURCEPATH ../src +SOURCE configpaging.cpp +SYSTEMINCLUDE /epoc32/include +SYSTEMINCLUDE /epoc32/include/tools/stlport +SYSTEMINCLUDE ../../imglib/boostlibrary + +STATICLIBRARY boost_regex-1.39 +STATICLIBRARY stlport.5.1 +#ifdef TOOLS2_LINUX +OPTION GCC -pthread -O2 -Wno-uninitialized +#else +OPTION GCC -mthreads -O2 -Wno-uninitialized +#endif + + +VENDORID 0x70000001 diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/group/release.txt --- a/imgtools/buildrom/group/release.txt Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/buildrom/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -1,3 +1,24 @@ +Version 3.26.0 (BUILDROM) +=============== +Released by Lorence Wang 28/06/2010 + 1) Prepend EPOCROOT to epoc32 feature + +Version 3.25.2 (BUILDROM) +=============== +Reoleased by Jason Cui 11/06/2010 + 1) Empty Directory Support in FAT Image + +Version 3.24.2 (BUILDROM) +=============== +Reoleased by Jason Cui 09/06/2010 + 1) DPDEF145499: buildrom cannot support romname + +Version 3.24.1 (buildrom) +=============== +Released by Lorence Wang, 31/05/2010 + 1) DPDEF145359 Buildrom cannot find dso file in linux + 2) DPDEF145470 buildrom with "-wordir=pathname" has error + Version 3.24.0 (buildrom) =============== Released by Lorence Wang, 20/05/2010 diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/src/configpaging.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/src/configpaging.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,478 @@ +/* +* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* @internalComponent * @released +* configpaging mainfile to do configpaging in buildrom. +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace boost ; + +typedef const char* const_str ; + +static const string NULL_STRING(""); +static const char CONSTANT_UNPAGED[] = "unpaged"; +static const char CONSTANT_PAGED[] = "paged"; +static const char CONSTANT_UNPAGEDCODE[] = "unpagedcode"; +static const char CONSTANT_PAGEDCODE[] = "pagedcode"; +static const char CONSTANT_UNPAGEDDATA[] = "unpageddata"; +static const char CONSTANT_PAGEDDATA[] = "pageddata"; +#ifdef WIN32 +static const char CONSTANT_CONFIG_PATH[] = "epoc32\\rom\\configpaging\\"; +static string epocroot("\\"); +static const char SLASH_CHAR = '\\'; +#else +#include +#define strnicmp strncasecmp +#define _alloca alloca +static const char CONSTANT_CONFIG_PATH[] = "epoc32/rom/configpaging/"; +static string epocroot("/"); +static const char SLASH_CHAR = '/'; +#endif +static const char CONSTANT_CONFIG_FILE[] = "configpaging.cfg" ; +#define is_undef(s) (0 == s.length()) +static const int MAJOR_VERSION = 1; +static const int MINOR_VERSION = 2; +static const int BUILD_NUMBER = 0; +static const char COPYRIGHT[]="Copyright (c) 2010 Nokia Corporation."; +struct ListElement{ + const_str code ; + const_str data ; +}; + + +static string configlist ; +static regex e0("^(file|data|dll|secondary)(=|\\s+)",regex::perl|regex::icase); +static regex e1("^(code|data)?pagingoverride=(.*)\\s*",regex::perl); +static regex e2("^(un)?paged(code|data)?(\\s+(un)?paged(code|data)?)?:",regex::perl); +static regex e3("^include\\s*\"(.*)\"",regex::perl); +static regex e4("(\\S+)(\\s+(un)?paged(code|data)?(\\s+(un)?paged(code|data)?)?)?",regex::perl); +static regex e5("\\b(un)?paged(data)?\\b\\s*$",regex::perl|regex::icase); +static regex e6("\\b(un)?paged(code)?\\b\\s*$",regex::perl|regex::icase); +static regex e7("\\b(un)?paged(code|data)?\\b",regex::perl|regex::icase); +//static regex e8("tool=|\\s+)",regex::perl|regex::icase); + + + +static bool is_obystatement(const char* aLine) { + if(!strnicmp(aLine,"file",4)|| !strnicmp(aLine,"data",4)) + aLine += 4 ; + else if(!strnicmp(aLine,"dll",3)) + aLine += 3; + else if(!strnicmp(aLine,"secondary",9)) + aLine += 9 ; + else + return false ; + + return (*aLine =='=' || *aLine == ' '|| *aLine == '\t'); + +} +static void trim(string& aStr){ + + char* data = const_cast(aStr.data()); + int length = aStr.length(); + int firstIndex = 0 ; + int lastIndex = length - 1; + // remove ending blanks + while(lastIndex >= 0 && (data[lastIndex] == ' ' || data[lastIndex] == '\t')){ + lastIndex -- ; + } + + // remove heading blanks + while((firstIndex < lastIndex ) && (data[firstIndex] == ' ' || data[firstIndex] == '\t')){ + firstIndex ++ ; + } + lastIndex++ ; + if(lastIndex < length){ + aStr.erase(lastIndex,length - lastIndex); + } + if(firstIndex > 0){ + aStr.erase(0,firstIndex); + } +} +static void make_lower(char* aStr,size_t aLength){ + + for(size_t i = 0 ; i < aLength ; i++){ + if(aStr[i] >= 'A' && aStr[i] <= 'Z') + aStr[i] |= 0x20 ; + } +} +static bool readConfigFile(const_str& aCodePagingRef, const_str& aDataPagingRef, + map& aListRef, const_str aFileName ) { + ifstream is(aFileName, ios_base::binary | ios_base::in); + if(!is.is_open()){ + cerr<< "Can not open \""<< aFileName << "\" for reading.\n"; + return false ; + } + const_str filecodepaging = ""; + const_str filedatapaging = ""; + match_results what; + + is.seekg(0,ios::end); + size_t size = is.tellg(); + is.seekg(0,ios::beg); + + char *buf = new char[size + 1]; + is.read(buf,size); + buf[size] = '\n' ; + + char* end = buf + size ; + char* lineStart = buf ; + int lfcr ; + string line ; + + while(lineStart < end ){ + // trim left ; + while(*lineStart == ' ' || *lineStart == '\t' ){ + lineStart++ ; + } + char* lineEnd = lineStart; + while(*lineEnd != '\r' && *lineEnd != '\n'){ + lineEnd++ ; + } + if(*lineEnd == '\r' && lineEnd[1] == '\n') + lfcr = 2 ; + else + lfcr = 1 ; + + *lineEnd = 0 ; + // empty line or comment + if(lineEnd == lineStart || *lineStart == '#' ){ + lineStart = lineEnd + lfcr ; + continue ; + } + size_t lenOfLine = lineEnd - lineStart; + make_lower(lineStart,lenOfLine); + line.assign(lineStart,lenOfLine); + + if(regex_search(line, what, e1)){ + string r1 = what[1].str(); + string r2 = what[2].str(); + if(is_undef(r1)){ //if ($1 eq undef) + if(r2 == "defaultpaged"){ + aCodePagingRef = CONSTANT_PAGED ; + } else if(r2 == "defaultunpaged"){ + aCodePagingRef = CONSTANT_UNPAGED ; + aDataPagingRef = CONSTANT_UNPAGED; + }else{ + cerr << "Configpaging Warning: invalid pagingoverride setting: "<< r2 <<"\n" ; + } + }else if(r1 == "code"){ + if(r2 == "defaultpaged"){ + aCodePagingRef = CONSTANT_PAGED ; + } else if(r2 == "defaultunpaged"){ + aCodePagingRef = CONSTANT_UNPAGED ; + }else{ + cerr << "Configpaging Warning: invalid codepagingoverride setting: "<< r2 <<"\n" ; + } + } + else if(r1 == "data" ){ + if(r2 == "defaultpaged"){ + aDataPagingRef = CONSTANT_PAGED ; + } else if(r2 == "defaultunpaged"){ + aDataPagingRef = CONSTANT_UNPAGED ; + }else{ + cerr << "Configpaging Warning: invalid datapagingoverride setting: "<< r2 <<"\n" ; + } + } + }// check e1 + else if(regex_search(line, what, e2)){ + string r1 = what[1].str(); + string r2 = what[2].str(); + string r3 = what[3].str(); + string r4 = what[4].str(); + string r5 = what[5].str(); + filecodepaging = ""; + filedatapaging = ""; + if (is_undef(r1)) { + if (is_undef(r2)) { + filecodepaging = CONSTANT_PAGED; + }else if (r2 == "code") { + filecodepaging = CONSTANT_PAGED; + } else if(r2 == "data") { + filedatapaging = CONSTANT_PAGED; + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } else if (r1 == "un"){ + if (is_undef(r2)) { //$2 eq undef + filecodepaging = CONSTANT_UNPAGED; + filedatapaging = CONSTANT_UNPAGED; + }else if (r2 == "code") { + filecodepaging = CONSTANT_UNPAGED; + } else if(r2 == "data") { + filedatapaging = CONSTANT_UNPAGED; + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + if (r3.length() > 0){ //$3 ne undef + if (is_undef(r4)) { + if (is_undef(r5)) { + filecodepaging = CONSTANT_PAGED; + }else if (r5 == "code") { + filecodepaging = CONSTANT_PAGED; + } else if(r5 == "data") { + filedatapaging = CONSTANT_PAGED; + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } else if (r4 == "un") { + if (is_undef(r5)) { + filecodepaging = CONSTANT_UNPAGED; + filedatapaging = CONSTANT_UNPAGED; + }else if (r5 == "code") { + filecodepaging = CONSTANT_UNPAGED; + } else if(r5 == "data") { + filedatapaging = CONSTANT_UNPAGED; + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } else { + cerr << "Configpaging Warning: unrecognized line: "<< lineStart << "\n"; + } + } + } + else if(regex_search(line, what, e3)){ + string filename = epocroot + CONSTANT_CONFIG_PATH; + filename += what[1].str(); + readConfigFile(aCodePagingRef, aDataPagingRef, aListRef, filename.c_str()); + } + else if(regex_search(line, what, e4)){ + string r1 = what[1].str(); + string r2 = what[2].str(); + string r3 = what[3].str(); + string r4 = what[4].str(); + string r5 = what[5].str(); + string r6 = what[6].str(); + string r7 = what[7].str(); + ListElement element = {aCodePagingRef, aDataPagingRef}; + if (is_undef(r2)){ //($2 eq undef){ + if (0 != *filecodepaging){//filecodepaging ne "") + element.code = filecodepaging; //$element{code} = $filecodepaging; + } + if ( 0 != *filedatapaging){//$filedatapaging ne "") + element.data = filedatapaging ;//element.data = $filedatapaging; + } + } else { + if (is_undef(r4)){//$4 eq undef + if (is_undef(r3)) {//$3 eq undef + element.code = CONSTANT_PAGED; + } else if (r3 == "un") { + element.code = CONSTANT_UNPAGED; + element.data = CONSTANT_UNPAGED; + } + } else if (r4 == "code") { + if (is_undef(r3)) { + element.code = CONSTANT_PAGED; + } else if (r3 == "un") { + element.code = CONSTANT_UNPAGED; + } + } else if (r4 == "data") { + if (is_undef(r3)) { + element.data = CONSTANT_PAGED; + } else if (r3 == "un") { + element.data = CONSTANT_UNPAGED; + } + } else { + cerr << "Configpaging Warning: unrecognized attribute in line: "<< lineStart << "\n"; + } + if (r5.length() > 0){//$5 ne undef + if (is_undef(r7)){ //$7 eq undef + if (is_undef(r6)) { //$6 eq undef + element.code = CONSTANT_PAGED; + } else if (r6 == "un") { + element.code = CONSTANT_UNPAGED; + element.data = CONSTANT_UNPAGED; + } + } else if (r7 == "code") { + if (is_undef(r6)) { + element.code = CONSTANT_PAGED; + } else if (r6 == "un") { + element.code = CONSTANT_UNPAGED; + } + } else if (r7 == "data") { + if (is_undef(r6)) { + element.data = CONSTANT_PAGED; + } else if (r6 == "un") { + element.data = CONSTANT_UNPAGED; + } + } else { + cerr << "Configpaging Warning: unrecognized attribute in line: "<< lineStart << "\n"; + } + } + } + //$$listref{$1} = \%element; + aListRef.insert(pair(r1,element)); + } + lineStart = lineEnd + lfcr ; + } + + delete []buf ; + is.close(); + + return true ; +} + +static bool match_icase(const string& a, const string& b){ + int la = a.length(); + int lb = b.length(); + char *copyOfA = (char*)_alloca(la+2); + *copyOfA = ' '; + copyOfA++ ; + memcpy(copyOfA ,a.c_str(),la); + copyOfA[la] = 0; + char* end = ©OfA[la]; + make_lower(copyOfA,la); + while(copyOfA < end){ + char *found = strstr(copyOfA,b.c_str()); + if(0 == found) + return false ; + if((found[-1] == ' ' || found[-1] == '\\'|| found[-1] == '/'|| found[-1] == '\t' || found[-1] == '"'|| found[-1] == '=') && + ( found[lb] == ' '|| found[lb] == '\t' || found[lb] == '"'|| found[lb] == '\0')) + return true ; + copyOfA = found + lb ; + } + + return false ; +} + +static void configpaging_single(){ + + const_str codepaging=""; + const_str datapaging=""; + map list ; + vector keys ;//my @keys; + string line ; + + cerr << "configpaging.exe: Modifying demand paging configuration using "<< configlist <<"\n"; + readConfigFile(codepaging, datapaging, list, configlist.c_str()); + match_results what; + string codepagingadd ,datapagingadd ; + while(true){ + getline(cin,line); + if(cin.eof()) break ; + if(line == ":q") break ; + trim(line); + const char* lineData = line.data(); + if(*lineData == '#' ){ + cout << lineData << "\n" ; + continue ; + } + int length = line.length(); + if( length > 2){ + //check rem + if((lineData[0] == 'R' || lineData[0] == 'r' ) && (lineData[1] == 'E' || lineData[1] == 'e' ) && (lineData[2] == 'M' || lineData[2] == 'm' )){ + cout << lineData << "\n" ; + continue ; + } + } + codepagingadd = ""; + datapagingadd = ""; + + if(is_obystatement(lineData)){ + for( map::iterator it = list.begin() ; it != list.end() ; it++){ + if(match_icase(line,it->first) ){ + if (it->second.code == CONSTANT_PAGED ){ + codepagingadd += " " ; + codepagingadd += CONSTANT_PAGEDCODE; + } else if (it->second.code == CONSTANT_UNPAGED) { + codepagingadd += " " ; + codepagingadd += CONSTANT_UNPAGEDCODE; + } + if (it->second.data == CONSTANT_PAGED) { + datapagingadd += " " ; + datapagingadd += CONSTANT_PAGEDDATA; + } else if (it->second.data == CONSTANT_UNPAGED) { + datapagingadd += " " ; + datapagingadd += CONSTANT_UNPAGEDDATA; + } + break ; + } + }//for + if (codepagingadd.length() == 0 && 0 != *codepaging) {//!$codepagingadd and $codepaging + codepagingadd = " " ; + codepagingadd += codepaging ; + codepagingadd += "code"; + } + if (datapagingadd.length() == 0 && 0 != *datapaging) { //!$datapagingadd and $datapaging + datapagingadd = " " ; + datapagingadd += datapaging ; + datapagingadd += "data"; + } + if (codepagingadd.length() > 0 && datapagingadd.length() == 0){ //$codepagingadd and !$datapagingadd + if (regex_search(line,what,e5)){ //$line =~ /\b(un)?paged(data)?\b\s*$/) { //$line =~ /\b(un)?paged(data)?\b\s*$/ + datapagingadd = " " ; + if(what[1].length() > 0) + { + datapagingadd += what[1].str(); + datapagingadd += "pageddata"; + } + } + } else if (datapagingadd.length() > 0 && codepagingadd.length() == 0) {//$datapagingadd and !$codepagingadd + if (regex_search(line,what,e6)){ + codepagingadd = " " ; + codepagingadd += what[1].str(); + codepagingadd += "pagedcode"; + } + } + if (datapagingadd.length() > 0 || datapagingadd.length() > 0) { // $datapagingadd or $datapagingadd + line = regex_replace(line,e7,NULL_STRING); + } + } + cout << line << codepagingadd << datapagingadd << "\n"; + + } +} +// +int main(int argc , char* argv[]) { + + char* tmp = getenv("EPOCROOT"); + if(tmp && *tmp) + epocroot = string(tmp); + char ch = epocroot.at(epocroot.length() - 1); + if(ch != '\\' && ch != '/') + epocroot += SLASH_CHAR; + + if(argc > 1 ){ + char* arg = argv[1]; + if('-' == *arg && (arg[1] | 0x20) == 'v'){ + cout << "configpaging - The paging configuration plugin for BUILDROM V" ; + cout << MAJOR_VERSION << "."<< MINOR_VERSION << "." << BUILD_NUMBER<< endl; + cout << COPYRIGHT << endl << endl; + return 0; + } + configlist = epocroot + CONSTANT_CONFIG_PATH; + configlist += string(arg); + } + else{ + configlist = epocroot + CONSTANT_CONFIG_PATH; + configlist += CONSTANT_CONFIG_FILE; + } + configpaging_single(); + + return 0; +} + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/buildrom --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/buildrom Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,2 @@ +#!/bin/sh +perl -S buildrom.pl $@ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/buildrom.pm --- a/imgtools/buildrom/tools/buildrom.pm Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/buildrom/tools/buildrom.pm Wed Jun 30 11:35:58 2010 +0800 @@ -65,7 +65,7 @@ my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. my $BuildromMajorVersion = 3 ; -my $BuildromMinorVersion = 24; +my $BuildromMinorVersion = 26; my $BuildromPatchVersion = 0; @@ -150,7 +150,7 @@ -I -- Use for the referenced IBY/OBY files -argfile=xxx -- specify argument-file name containing list of command-line arguments to buildrom -lowmem -- use memory-mapped file for image build to reduce physical memory consumption - -chechcase -- check character case of path/name in oby/iby files, + -checkcase -- check character case of path/name in oby/iby files, the result will be checkcase.log, this option is only valid on windows. -workdir=xxx -- specify a directory to contain generated files. @@ -226,7 +226,7 @@ my $thisdir=cwd; $thisdir=~s-\\-\/-go; # separator from Perl 5.005_02+ is forward slash $thisdir.= "\/" unless $thisdir =~ /\/$/; -$thisdir=~s-^(.:)?\/--o; # remove drive letter and leading backslash +$thisdir =~ s-\/-\\-g if (&is_windows); my $rominclude = $epocroot."epoc32\/rom\/include\/"; $rominclude = &get_epocdrive().$rominclude unless $rominclude =~ /^.:/; @@ -341,7 +341,7 @@ my $checkcase = 0; my $checkcase_platform = ""; my $checkcase_test = 0; -my $invokecmddir = ""; +my $opt_workdir = 0; sub match_obyfile { @@ -354,7 +354,6 @@ # search for the oby file in the list of include directories my @otherDirs = ($rominclude); - push (@otherDirs, $invokecmddir) if ($invokecmddir ne ""); if ($featureVariant{'VALID'}) { @@ -762,28 +761,7 @@ if ( $arg =~ /^-k$/i || $arg =~ /^-keepgoing$/i ) { $opt_k = 1; - next; - }elsif ($arg =~ /^-workdir=(.*)/) - { - my $workdir=$1; - if( $workdir =~ m/ / ) - { - print "* Warning: $workdir contains whitespace, hence the files will be created in default location \n"; - $workdir = ""; - } - if ($workdir ne "") - { - $invokecmddir = cwd; - $invokecmddir=~s-\\-\/-go; # separator from Perl 5.005_02+ is forward slash - $invokecmddir.= "\/" unless $invokecmddir =~ /\/$/; - $workdir =~ s-\\-\/-g; - chdir "$workdir" or die "cannot change to directory $workdir\n"; - $thisdir=cwd; - $thisdir=~s-\\-\/-go; # separator from Perl 5.005_02+ is forward slash - $thisdir.= "\/" unless $thisdir =~ /\/$/; - $thisdir=~s-^(.:)?\/--o; # remove drive letter and leading backslash - } - next; + last; } } foreach my $arg (@argList) @@ -1023,6 +1001,22 @@ } if ($arg =~ /^-workdir=(.*)/) { + my $workdir = $1; + if (!-d $workdir) + { + die "directory $workdir does not exist\n"; + } + my $currentdir = cwd; + chdir "$workdir" or die "cannot change to directory $workdir\n"; + $thisdir=cwd; + $thisdir=~s-\\-\/-go; # separator from Perl 5.005_02+ is forward slash + $thisdir.= "\/" unless $thisdir =~ /\/$/; + if(&is_windows) + { + $thisdir =~ s-\/-\\-g; + } + $opt_workdir = 1; + chdir "$currentdir"; next; } if($arg =~/^-c(.*)/) @@ -1253,7 +1247,8 @@ sub preprocessing_phase { - unlink "tmp1.oby"; + my $temp1OBYFile = $thisdir."tmp1.oby"; + unlink "$temp1OBYFile"; # Macro "ROM_FEATURE_MANAGEMENT" is defined when "-f|fr" or "-fm" is used if (defined ($featureXml)) @@ -1283,14 +1278,13 @@ { # no feature variant so use the standard includes $cppargs .= " -I. -I \"$rominclude\""; - $cppargs .= " -I \"$invokecmddir\"" if ($invokecmddir ne ""); } - print "* cpp -Wno-endif-labels -o tmp1.oby $cppargs\n" if ($opt_v); + print "* cpp -Wno-endif-labels -o $temp1OBYFile $cppargs\n" if ($opt_v); is_existinpath("cpp", romutl::DIE_NOT_FOUND); $errors = 0; - open CPP, "| cpp -Wno-endif-labels -o tmp1.oby $cppargs" or die "* Can't execute cpp"; + open CPP, "| cpp -Wno-endif-labels -o $temp1OBYFile $cppargs" or die "* Can't execute cpp"; foreach my $arg (@obyfiles) { print CPP "\n#line 1 \"$arg\"\n"; @@ -1312,9 +1306,8 @@ } close CPP; my $cpp_status = $?; - die "* cpp failed\n" if ($cpp_status != 0 || !-f "tmp1.oby"); - - my $temp1OBYFile = "tmp1.oby"; + die "* cpp failed\n" if ($cpp_status != 0 || !-f "$temp1OBYFile"); + if( defined ($image_content)) { #Read the OBY file that was generated by the pre-processor @@ -1400,11 +1393,11 @@ @substitutionOrder = ("TODAY", "RIGHT_NOW", "EPOCROOT"); } + my $temp1OBYFile = $thisdir."tmp1.oby"; - open TMP1, "tmp1.oby" or die("* Can't open tmp1.oby\n"); + open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n"); while ($line=) { - if(($line =~ /^\s*romsize\s*=/i) || ( $line=~ /^\s*rom_image/i) || ($line =~ /^\s*data_image/i)) { $onlysmrimage = 0; @@ -1415,7 +1408,7 @@ if ($enforceFeatureManager && (!$featuremanager) && (!$noFeatureManager) ) { my $defaultFeatureDbFlag = 0; - open TMP1, "tmp1.oby" or die("* Can't open tmp1.oby\n"); + open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n"); while ($line=) { if ($line=~/^\s*defaultfeaturedb\s*=?\s*(\S+)/i) @@ -1439,11 +1432,20 @@ } } - open TMP1, "tmp1.oby" or die("* Can't open tmp1.oby\n"); + open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n"); while ($line=) { track_source($line); $line =~ s-\\-\/-g; + + my $tempstring = $epocroot."epoc32"; + if(($line !~ /^\s*\#/) && ($line =~ /\/epoc32/i) + && ($line !~ /EPOCROOT##\/?epoc32/i) && ($line !~ /$tempstring/i)) + { + print "add EPOCROOT for line: $line\n" if ($opt_v); + $line =~ s-\/epoc32-EPOCROOT##epoc32-ig; + } + # # Recognise keywords in lines that we process before substitution # @@ -1802,6 +1804,7 @@ sub dump_obydata { my ($dumpfile, $comment) = @_; + $dumpfile = $thisdir.$dumpfile; unlink($dumpfile); open DUMPFILE, ">$dumpfile" or die("* Can't create $dumpfile\n"); print "* Writing $dumpfile - $comment\n"; @@ -2536,7 +2539,7 @@ } } my @spiargs; #arguments passed to createSpi - push @spiargs, ("-t$targetspi", "-d\/$thisdir", "-hide@hidedatainspi"); + push @spiargs, ("-t$targetspi", "-d$thisdir", "-hide@hidedatainspi"); if($existingspi ne "") { push @spiargs, $existingspi; } &spitool::createSpi(@spiargs, @dataforspi); # external call to } @@ -2702,7 +2705,7 @@ while(defined $spiarray[$imageIdx][$spiIdx]) { if($spiarray[$imageIdx][$spiIdx]{spifile} =~ /(.+)\.(.*)$/) { my $targetspi="$1-$imageIdx-$spiIdx\.$2"; - push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[$imageIdx][$spiIdx]{spi} . "\"\n"; + push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[$imageIdx][$spiIdx]{spi} . "\"\n"; } $spiIdx++; } @@ -2729,7 +2732,7 @@ while(defined $spiarray[0][$k]) { if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) { my $targetspi="$1-0-$k\.$2"; - push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n"; + push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n"; } $k++; } @@ -2739,7 +2742,7 @@ while(defined $spiarray[$romimage][$j]) { #put in SPI files for current ROM_IMAGE if($spiarray[$romimage][$j]{spifile} =~ /(.+)\.(.*)$/) { my $targetspi="$1-$romimage-$j\.$2"; - push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[$romimage][$j]{spidir} . $targetspi . "\"\n"; + push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[$romimage][$j]{spidir} . $targetspi . "\"\n"; } $j++; } @@ -2749,7 +2752,7 @@ while(defined $spiarray[0][$k]) { if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) { my $targetspi="$1-0-$k\.$2"; - push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n"; + push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n"; } $k++; } @@ -2766,7 +2769,7 @@ while(defined $spiarray[0][$k]) { if($spiarray[0][$k]{spifile} =~ /(.+)\.(.*)$/) { my $targetspi="$1-0-$k\.$2"; - push @newobydata, "data=" . "\/$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n"; + push @newobydata, "data=" . "$thisdir" . $targetspi . " \"" . $spiarray[0][$k]{spidir} . $targetspi . "\"\n"; } $k++; } @@ -2940,7 +2943,7 @@ my $j=0; while(defined $featurefilearray[$i][$j]) { - my $targetfeaturefile = $featurefilearray[$i][$j]{cfgfile}; + my $targetfeaturefile = $thisdir.$featurefilearray[$i][$j]{cfgfile}; if (!(&featuresutil::createFeatureFile($i,$j,$targetfeaturefile,\@featureslist,$featuremanager))) { $featurefilearray[$i][$j]{cfgfile}= undef; @@ -2971,7 +2974,7 @@ my $targetfeaturefile=$featurefilearray[0][$k]{cfgfile}; if (defined $targetfeaturefile) { - push @newobydata, "data=" . "\/$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile . "\"\n"; + push @newobydata, "data=" . "$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile . "\"\n"; } $k++; } @@ -2994,7 +2997,7 @@ if (defined $targetfeaturefile) { - push @newobydata, "data=" . "\/$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[$romimage][$j]{cfgdir} . $destinationfeaturefile . "\"\t\t" . $exattribute . "\n"; + push @newobydata, "data=" . "$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[$romimage][$j]{cfgdir} . $destinationfeaturefile . "\"\t\t" . $exattribute . "\n"; } $j++; } @@ -3015,7 +3018,7 @@ my $targetfeaturefile = $featurefilearray[0][$k]{cfgfile}; if (defined $targetfeaturefile) { - push @newobydata, "data=" . "\/$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile . "\"\n"; + push @newobydata, "data=" . "$thisdir" . $targetfeaturefile . " \"" . $featurefilearray[0][$k]{cfgdir} . $targetfeaturefile . "\"\n"; } $k++; } @@ -3128,14 +3131,6 @@ } last if $fileExists; } - # for -workdir option, to support relative path to the call path - if (!$fileExists && ($invokecmddir ne "") && ($filename !~ /^([\\\/]|.:)/)) - { - if (-e $invokecmddir.$filename) - { - $fileExists = $invokecmddir.$filename; - } - } # edit the OBY line to use the actual file name which we found. # (maybe) warn if an alternative to the original was selected. @@ -3160,7 +3155,7 @@ # it is a manatory ROMBUILD keyword, in which case it is better # to let ROMBUILD report the missing file rather than report the # missing keyword. - if ($what !~ /^bootbinary|variant|primary|secondary|hide/i) + if ($what !~ /^bootbinary|variant|primary|secondary|hide|dir/i) { $line = "REM MISSING " . $line; print_source_error("Missing file: '$filename' in statement '$what='"); @@ -3502,6 +3497,10 @@ { return $line; } + elsif($line =~ /^\s*dir\s*=.*/i) + { + return $line; + } elsif($line =~ /^\s*bootbinary\s*=(.*)/i) { } @@ -3521,7 +3520,8 @@ $romfile = $4; $tail = $5; } - elsif ($line =~ /(\S+)\s*=\s*"([^"]+)"\s+"\/?(.*)"(.*)$/) + elsif ($line =~ /(\S+)\s*=\s*"([^"]+)"\s+"\/?(.*)"(.*)$/ + || $line =~ /(\S+)\s*=\s*"([^"]+)"\s+\/?(\S+)(.*)$/) { if ($line !~ /^REM MISSING/i) { @@ -3810,8 +3810,8 @@ if($opt_v) { - my $logWin = "logwin.oby"; - my $logLinux = "loglinux.oby"; + my $logWin = $thisdir."logwin.oby"; + my $logLinux = $thisdir."loglinux.oby"; unlink($logWin); unlink($logLinux); open LOGWIN, ">$logWin" or die("* Can't create $logWin\n"); @@ -3847,7 +3847,7 @@ # # Track ROMNAME, allowing overrides # - if ($line=~/romname\s*=\s*"?(\S+)\.(\S+)"?\s*/i) + if ($line=~/romname\s*[=\s]\s*"?(\S+)\.(\S+)"?\s*/i) { if ($romname ne "" && $opt_o eq "") { @@ -3855,6 +3855,11 @@ } $rombasename = $1; $romname = "$1.$2"; + if ($opt_workdir) + { + $rombasename = $thisdir.$rombasename; + $romname = $thisdir.$romname; + } next; } # @@ -3899,6 +3904,17 @@ # Handle ROMNAME and possible -o override if ($opt_o ne "") { + if ($opt_workdir && $opt_o !~ /^[\\\/]/ && $opt_o !~ /^.:/) + { + $opt_o = $thisdir.$opt_o; + } + if (&is_windows) + { + $opt_o =~ s-\/-\\-g; + }else + { + $opt_o =~ s-\\-\/-g; + } $romname=$opt_o; if ($opt_o=~/(\S+)\.(\S+)/) { @@ -4669,7 +4685,7 @@ } if( $aDllFile =~ /(.*)\.[^.]+$/ ){ my $proxydsofile = "$1.dso"; - $proxydsofile =~ s-$abiDir\/(.*)\/-armv5\/LIB\/-ig; + $proxydsofile =~ s-$abiDir\/(.*)\/-armv5\/lib\/-ig; open PIPE, "getexports -d $proxydsofile|" or die "Can't open file $proxydsofile\n"; while (){ my $line = $_; diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/cdf.dtd.bak --- a/imgtools/buildrom/tools/cdf.dtd.bak Wed Jun 23 17:27:59 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/checkepocroot.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/checkepocroot.pl Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,118 @@ +#!/usr/bin/perl + +use Getopt::Long; + +use constant TOOL_VERSION=>"0.1"; + +my $help; +my $dir; +my $convert; +my $logfile; +&processcmdline(); + +open (LOG, ">$logfile") or die "cannot open log file $logfile\n"; +&checkdir($dir); +close LOG; + +sub processcmdline +{ + GetOptions("h" => \$help, "l=s" => \$logfile, "c" => \$convert); + + if ($help) + { + print_usage(); + exit 0; + } + $logfile = "checkepocroot.log" if (!defined $logfile); + + $dir = shift @ARGV; + if (!defined $dir || !-d $dir) + { + print_usage(); + die "\nERROR: directory missing!!\n" if (!defined $dir); + die "\nERROR: directory $dir does not exist!!\n" if (!-d $dir); + } +} + +sub checkdir +{ + my $path = shift; + return if (!-d $path); + opendir(DIR,$path); + my @entries = readdir(DIR); + closedir(DIR); + my $entry; + foreach $entry (@entries) { + next if (($entry eq ".") || ($entry eq "..")); + my $item = "$path/$entry"; + if (-d $item) { + &checkdir($item); + }else { + next if ($entry !~ /.*\.[a-z]by$/i); + + &convobyfile($item, "$item.bak"); + } + } +} + +sub convobyfile +{ + my $src = shift; + my $dst = shift; + open (SRC, "<$src"); + open (DST, ">$dst") if($convert); + + my $line; + while($line = ) + { + if ($line =~ /[\\\/]epoc32/) + { + print "Found content in file $src\n"; + print LOG "Found content in file $src\n"; + print "current line is $line"; + print LOG "current line is $line"; + if ($line =~ /EPOCROOT##[\\\/]?epoc32/) + { + print "Error: this line already contain EPOCROOT\n"; + next; + } + if($convert) + { + $line =~ s-[\\\/]epoc32-EPOCROOT##epoc32-g; + print "converted line is $line"; + print LOG "converted line is $line"; + } + print "\n"; + print LOG "\n"; + } + print DST $line if($convert); + } + close SRC; + if($convert) + { + close DST; + + unlink "$src"; + rename ("$dst", "$src"); + } +} + +sub print_usage +{ + print "\nCheckepocroot - Check epocroot tool V".TOOL_VERSION."\n"; + print "Copyright (c) 2010 Nokia Corporation.\n\n"; + print <] + +Check oby/iby files cursively in the . +When it find epoc32 without EPOCROOT## in the files, it will report the line in log file. If with -c option it will add EPOCROOT## to the epoc32. +The is the directory contain all the oby/iby files. Usually it should be /epoc32/rom/ and it will be checked cursively. + +Options: + -l - the log file to record the log, + if not specfied it is \"checkepocroot.log\" + -h - displays this help + -c - convert the back slash to forward slash. +USAGE_EOF +} \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/checkincludeslash.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/checkincludeslash.pl Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,120 @@ +#!/usr/bin/perl + +use Getopt::Long; + +use constant TOOL_VERSION=>"0.1"; + +my $help; +my $dir; +my $convert; +my $logfile; +&processcmdline(); + +open (LOG, ">$logfile") or die "cannot open log file $logfile\n"; +&checkdir($dir); +close LOG; + +sub processcmdline +{ + GetOptions("h" => \$help, "l=s" => \$logfile, "c" => \$convert); + + if ($help) + { + print_usage(); + exit 0; + } + $logfile = "checkincludeslash.log" if (!defined $logfile); + + $dir = shift @ARGV; + if (!defined $dir || !-d $dir) + { + print_usage(); + die "\nERROR: directory missing!!\n" if (!defined $dir); + die "\nERROR: directory $dir does not exist!!\n" if (!-d $dir); + } +} + +sub checkdir +{ + my $path = shift; + return if (!-d $path); + opendir(DIR,$path); + my @entries = readdir(DIR); + closedir(DIR); + my $entry; + foreach $entry (@entries) { + next if (($entry eq ".") || ($entry eq "..")); + my $item = "$path/$entry"; + if (-d $item) { + &checkdir($item); + }else { + next if ($entry !~ /.*\.[a-z]by$/i); + + &convobyfile($item, "$item.bak"); + } + } +} + +sub convobyfile +{ + my $src = shift; + my $dst = shift; + open (SRC, "<$src"); + open (DST, ">$dst") if($convert); + + my $line; + while($line = ) + { + if ($line =~ /#\s*include\s*(<|\")(.*\\.*)(>|\")/) + { + print "Found content in file $src\n"; + print LOG "Found content in file $src\n"; + print "current line is $line"; + print LOG "current line is $line"; + if($convert) + { + my $path = $2; + my $pathorg = $path; + $pathorg =~ s-\\-\\\\-g; + $path =~ s-\\-\/-g; + $line =~ s-$pathorg-$path-g; + print "converted line is $line"; + print LOG "converted line is $line"; + } + print "\n"; + print LOG "\n"; + } + print DST $line if($convert); + } + close SRC; + if($convert) + { + close DST; + + unlink "$src"; + rename ("$dst", "$src"); + } +} + +sub print_usage +{ + print "\nCheckincludeslash - Check back slash tool V".TOOL_VERSION."\n"; + print "Copyright (c) 2010 Nokia Corporation.\n\n"; + print <] + +Check oby/iby files cursively in the . +When it find back slash in include line in the files like \"\#include \", +it will report the line in log file. If with -c option it will convert the back slash +to forward slash like \"\#include \". +The is the directory contain all the oby/iby files. +Usually it should be /epoc32/rom/ and it will be checked cursively. + +Options: + -l - the log file to record the log, + if not specfied it is \"checkincludeslash.log\" + -h - displays this help + -c - convert the back slash to forward slash. +USAGE_EOF +} \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/datadriveimage.pm --- a/imgtools/buildrom/tools/datadriveimage.pm Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/buildrom/tools/datadriveimage.pm Wed Jun 30 11:35:58 2010 +0800 @@ -229,7 +229,7 @@ else { print "$source copied to $destfile\n" if($verboseOpt); - return $destfile; + return "\"".$destfile."\""; } } @@ -288,21 +288,23 @@ open (OBEY ,$obyfile) or die($obyfile."\n"); while(my $line =) { - if( $line =~ /^(file|data)\s*=\s*(\S+)\s+(\S+)/i ) + if( $line =~ /^(file|data)\s*=\s*(\"[^"]+\")\s+(\"[^"]+\")/i || + $line =~ /^(file|data)\s*=\s*(\"[^"]+\")\s+(\S+)/i || + $line =~ /^(file|data)\s*=\s*(\S+)\s+(\"[^"]+\")/i || + $line =~ /^(file|data)\s*=\s*(\S+)\s+(\S+)/i ) { my $keyWord=$1; my $source=$2; my $dest=$3; - if( $source !~ /(\S+):(\S+)/ ) + if( $source !~ /(\S+):([^"]+)/ ) { $source = get_drive().$2; } my $var = ©FilesToFolders( $source,$dest,$dir,$verboseOpt); if($var) { - $var = $keyWord."=".$var; - $line =~ s/^(\S+)=(\S+)/$var/; + $line = $keyWord."=".$var."\t".$dest."\n"; push(@$nonsisFileArray,$line); } else diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/directory.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/directory.bat Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,4 @@ +@echo off + +cd %1 +echo %cd% \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/experimental/metarombuild.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/experimental/metarombuild.pl Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,298 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +#! perl + +# This script builds ROMs which are specified in a supplied XML file +# To use this script \epoc32\tools\buildrom must be installed on the drive +# with \epoc32\tools in the path + +# Note: The TargetBoard attribute is no longer used but is still needed because of the structure of this script! + +use strict; +use XML::Simple; +use Getopt::Long; +use Cwd; +use Cwd 'abs_path'; +use File::Copy; +use File::Path; + +# Get command line arguments +my ($romspec, $boards, $roms, $logdir, $buildnum, $publish, $help, $version) = ProcessCommandLine(); + +Usage() if ($help); +Version() if ($version); + +die "Romspec xml file must be specified using the -romspec option\n" if (!$romspec); + +# Construct arrays of boards and roms if they were specified +my @boards = split /,/, $boards if ($boards); +my @roms = split /,/, $roms if ($roms); + +# Use the XML::Simple module to parse the romspec and pass the result +# into the $Roms hash reference +my $xml = new XML::Simple; +my $Roms = $xml->XMLin($romspec); + +my $RomList = %$Roms->{'Rom'}; + +my $RomBuildStage = 1; + +foreach my $rom (sort keys %$RomList) +{ + my $board = $RomList->{$rom}->{'TargetBoard'}; + if( (@boards == 0 and @roms == 0) or grep $rom, @roms or grep $board, @boards) + { + BuildRom($RomBuildStage, $RomList, $rom, $logdir, $buildnum ,$publish); + $RomBuildStage++; + } +} + +##################################################### +#### Run buildrom on the specified ROM using ######## +#### info from the romspec.xml ######## +##################################################### +sub BuildRom +{ + my $Stage = shift; # BuildRom stage + my $RomList = shift; # Hash of the romspec.xml + my $rom = shift; # Rom to be built + my $logdir = shift; # logs directory + my $buildnum = shift; # build number + my $publish = shift; # Publish Location + my $type = $ENV{Type}; # type of Build Master or Release + my $builddir = $ENV{BuildDir}; # Build Directory + my $Epocroot = $ENV{EPOCROOT}; # EpocRoot; + my $InFileList=""; # i.e. Platsec, Techview, obyfiles + my $XmlFileList=""; + my $MacroList=""; # for the buildrom -D option + my $TargetBoard = $RomList->{$rom}->{'TargetBoard'}; + my $ImageFile = " -o".$RomList->{$rom}->{'ImageFile'}->{'name'}; # for the buildrom -o option + + # Construct the list of InFiles to pass to buildrom + my $InFiles = %$RomList->{$rom}->{'InFile'}; + foreach my $infile (sort keys %$InFiles) + { + if ($infile eq "name") + { + $InFileList = " ".$InFiles->{'name'} unless (lc($InFiles->{'name'}) eq lc($TargetBoard)); + } + else + { + $InFileList .= " ".$infile unless(lc($infile) eq lc($TargetBoard)); + } + } + my $RomXmlFlag='-f'; + my $XmlFiles = %$RomList->{$rom}->{'XMLFile'}; + foreach my $XmlFlags (keys %$XmlFiles) + { + if ($XmlFlags eq "flag") + { + $RomXmlFlag= $XmlFiles->{'flag'}; + } + } + foreach my $XmlFile (keys %$XmlFiles) + { + if ($XmlFile eq "name") + { + $XmlFileList = "$RomXmlFlag"."$Epocroot"."epoc32\\rom\\include\\".$XmlFiles->{'name'}; + } + else + { + $XmlFileList .= "$RomXmlFlag"."$Epocroot"."epoc32\\rom\\include\\".$XmlFile unless(lc($XmlFile) eq lc($TargetBoard)); + } + } + + # Get the ROM macro if one is defined + if ( defined $RomList->{$rom}->{'Macro'} ) + { + if (defined $RomList->{$rom}->{'Macro'}->{'name'} ) + { + if ( $RomList->{$rom}->{'Macro'}->{'value'} ne "" ) + { + $MacroList = " -D".$RomList->{$rom}->{'Macro'}->{'name'}."=".$RomList->{$rom}->{'Macro'}->{'value'}; + } + else + { + $MacroList = " -D".$RomList->{$rom}->{'Macro'}->{'name'}; + } + } + else + { + my $Macros = %$RomList->{$rom}->{'Macro'}; + foreach my $macro (keys %$Macros) + { + if ( $Macros->{$macro}->{'value'} ne "" ) + { + $MacroList .= " -D".$macro."=".$Macros->{$macro}->{'value'}; + } + else + { + $MacroList .= " -D".$macro; + } + } + } + } + + # Call buildrom + my $buildrom_command = "buildrom $InFileList $MacroList $XmlFileList $ImageFile 2>&1"; + my $gHiResTimer = 0; + if (eval "require Time::HiRes;") + { + $gHiResTimer = 1; + } + else + { + print "Cannot load HiResTimer Module\n"; + } + open TVROMLOG, ">> $logdir\\techviewroms$buildnum.log"; + print TVROMLOG "===------------------------------------------------\n"; + print TVROMLOG "-- Stage=$Stage\n"; + print TVROMLOG "===----------------------------------------------\n"; + print TVROMLOG "-- Stage=$Stage started ".localtime()."\n"; + print TVROMLOG "=== Stage=$Stage == Build $rom\n"; + print TVROMLOG "-- Stage=$Stage == $TargetBoard $InFileList\n"; + print TVROMLOG "-- $buildrom_command\n"; + print TVROMLOG "-- MetaromBuild Executed ID $Stage $buildrom_command \n"; + print TVROMLOG "++ Started at ".localtime()."\n"; + if ($gHiResTimer == 1) + { + print TVROMLOG "+++ HiRes Start ".Time::HiRes::time()."\n"; + } + else + { + # Add the HiRes timer unavailable statement + print TVROMLOG "+++ HiRes Time Unavailable\n"; + } + my $command_output = `$buildrom_command`; + print TVROMLOG $command_output; + if ($?) + { + print TVROMLOG "ERROR: $buildrom_command returned an error code $?\n"; + } + if (($command_output =~m/\d\sFile/g) and ($command_output!~/Failed/ig) and ($command_output!~/Unsucessful/ig)) + { + print TVROMLOG "Rom Built Sucessfully\n"; + } + else + { + print TVROMLOG "ERROR: $buildrom_command failed .Please check log techviewroms$buildnum.log for details\n"; + } + if ($gHiResTimer == 1) + { + print TVROMLOG "+++ HiRes End ".Time::HiRes::time()."\n"; + } + else + { + # Add the HiRes timer unavailable statement + print TVROMLOG "+++ HiRes Time Unavailable\n"; + } + print TVROMLOG "++ Finished at ".localtime()."\n"; + print TVROMLOG "=== Stage=$Stage finished ".localtime()."\n"; + close TVROMLOG; + + # Publishing of Logs and Roms##################### + my $ImageFileXML = $ImageFile ; + $ImageFileXML =~s/^\s-o//i; + $ImageFileXML =~/(.*\d.techview)/; + my $ImageFileXMLresult = $1; + my $cwdir = abs_path ( $ENV { 'PWD' } ); + $cwdir =~s/\//\\/g; + $rom =~ /(\w+).*/; + my $data = $1; + if(($publish ne "")) + { + if($rom =~ /(\w+).*/) + { + my $data = $1; + if(not -d "$publish\\$1") + { + mkpath "$publish\\$1" || die "ERROR: Cannot create $publish\\$1"; # If folder doesnt exist create it + } + opendir(DIR, $cwdir) || die "can't opendir $cwdir: $!"; + my @file_array =readdir(DIR); + foreach ($ImageFileXMLresult) + { + foreach my $ImageFileConcat (@file_array) + { + $ImageFileConcat =~/(.*\d.techview)/; + my $Image = $1; + + if ($ImageFileXMLresult eq $Image) + { + copy ("$cwdir\\$ImageFileConcat" , "$publish\\$data\\");# or die "Cannot copy file:$!"; + } + } + closedir DIR; + } + } + } + else + { + print"Publish Option not used \n"; + } +} + +######################################## +##### Process the command line ######### +######################################## +sub ProcessCommandLine +{ + my ($romspec, $boards, $roms, $publish, $help, $version); + + GetOptions('romspec=s' => \$romspec, + 'roms=s' => \$roms, + 'boards=s' => \$boards, + 'logdir=s' => \$logdir, + 'buildnum=s' => \$buildnum, + 'publish=s' => \$publish, + 'help' => \$help, + 'version' => \$version)|| die Usage(); + + return ($romspec, $boards, $roms, $logdir, $buildnum, $publish, $help, $version); +} + + +sub Usage +{ + print < [options] + + When no options are specified, all ROMs specified in the romspec wil be built. + + Options: + -logdir + -buildnum + -publish + -help + -version + +USAGE_EOF +exit 0; +} + +sub Version +{ + print < - - - - - - - - - - - - - - - - - diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/features --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/features Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,2 @@ +#!/bin/sh +perl -S features.pl $@ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/featureuids.dtd.bak --- a/imgtools/buildrom/tools/featureuids.dtd.bak Wed Jun 23 17:27:59 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ - - - - - - - - - - - - diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/flexmodload.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/flexmodload.pm Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,45 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Runtime module-loading routine for loading e32toolp modules into 'main' module +# +# + + +package flexmodload; + +use romutl; + +require Exporter; +@ISA=qw(Exporter); + +@EXPORT=qw( + FlexLoad_ModuleL +); + +sub FlexLoad_ModuleL (@) { +# Loads a module into the 'main' package, including all the functions the module defines for export + + my @ModBaseList=@_; + my $ModBase; + foreach $ModBase (@ModBaseList) { + $ModBase=lc $ModBase; + + package main; + require $ModBase.".pm" or die "ERROR: Can't load function from \"$ModBase.pm\"\n"; + my $Package=ucfirst lc $ModBase; + $Package->import; + } +} + +1; diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/imageContent.dtd.bak --- a/imgtools/buildrom/tools/imageContent.dtd.bak Wed Jun 23 17:27:59 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/romosvariant.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/romosvariant.pm Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,74 @@ +# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Collection of utilitiy functions which is copied from Symbian OS perl modules. +# It provides platform related information to ROM Tools including buildrom, +# features.pl, etc. +# + +package romosvariant; + +require Exporter; +@ISA=qw(Exporter); +@EXPORT=qw( + os_name + is_windows + is_linux + env_delimiter + path_delimiter +); + +use strict; + +sub os_name +{ + return $^O; +} + +sub is_windows +{ + if ($^O =~ /^MSWin32$/i){ + return 1; + }else{ + return 0; + } +} + +sub is_linux +{ + if ($^O =~ /^MSWin32$/i){ + return 0; + }else{ + return 1; + } +} + +sub env_delimiter +{ + if ($^O =~ /^MSWin32$/i){ + return ";"; + }else{ + return ":"; + } +} + +sub path_delimiter +{ + if ($^O =~ /^MSWin32$/i){ + return "\\"; + }else{ + return "\/"; + } +} + +1; diff -r 22486c9c7b15 -r 378360dbbdba imgtools/buildrom/tools/romutl.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/buildrom/tools/romutl.pm Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,1697 @@ +# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Collection of utilitiy functions which is copied from Symbian OS perl modules. +# It provides platform related information to ROM Tools including buildrom, +# features.pl, etc. +# + +package romutl; + +require Exporter; +@ISA=qw(Exporter); +@EXPORT=qw( + init_plat + init_bsfs + init_platwithbpabi + + get_epocroot + get_drive + get_epocdrive + get_versionedname + get_bpabiplatlist + get_platlist + get_platcustomizes + get_platroot + get_makeeabspath + get_variantmacrolist + get_variantmacroHRHfile + get_abiv2mode + get_variantfullpath + get_BVbinname + get_variant + + is_existinpath + + set_verbose + + check_varfile + split_path + append_driveandquote + write_32bit +); + + +# EPOCROOT with proper format +my $epocroot; +my $epocdrive = ""; +my $drive = ""; + +BEGIN { + require 5.005_03; # check user has a version of perl that will cope + + $epocroot = $ENV{EPOCROOT}; + $epocroot = "\/" if (!$epocroot); # use "\" if EPOCROOT is not specified + $epocroot =~ s/\\/\//g; + $epocroot .= "\/" unless $epocroot =~ /\/$/; +} + +use strict; +use Cwd; +use File::Spec; +use romosvariant; + +my $verbose=0; + +######################## +#Init +# + +#die "ERROR: EPOCROOT must specify an existing directory." if (!-d $epocroot); +#die "ERROR: EPOCROOT must not be a UNC path\n" if ($epocroot =~ /^\\\\/); + +$drive=$1 if (cwd =~ /^(.:)/); + +if ($epocroot =~ /^(.:)/) +{ + $epocdrive=$1; +} +else +{ +# current working directory is different to SDK's + $epocdrive=$drive +} + +##################################### +# General functions +# + +sub get_epocroot +{ + return $epocroot; +} + +sub get_epocdrive +{ + return $epocdrive; +} + +sub get_drive +{ + return $drive; +} + +sub set_verbose +{ + $verbose = shift; +} + +use constant QUIET_NOT_FOUND => 0; # return 0 if file not found in the PATH +use constant DIE_NOT_FOUND => 1; # issue error and die if file not found in the PATH +use constant ERROR_NOT_FOUND => 2; # issue error and return 0 if file not found in the PATH + +# Simulate shell to locate executable file in the PATH +# +# WARNING: don't use this func in a deep loop because of the +# less efficient implementation +# +# usage: is_existinpath [] +# +# flag == DIE_NOT_FOUND die and display error when not found +# flag == ERROR_NOT_FOUND display error and return 0 when not found +# else return 0 when not found +# return 1 when found + +sub is_existinpath +{ + my ($filename, $flag)=@_; + return 0 unless defined $filename; + return 0 if ($filename =~ /\\/); + return 0 if ($filename =~ /\//); + + my @paths; + my $delimiter = &env_delimiter; + @paths = split(/$delimiter/, $ENV{PATH}); + unshift @paths, "\."; + + foreach my $path (@paths) + { + next if ($path =~ /^\s*$/); + chomp $path; + $path =~ s/\\/\//g; + $path .= "\/" unless ($path =~ /\/$/); + $path = $path.$filename; + foreach my $ext ("", ".bat", ".cmd", ".exe", ".com", ".pl", ".py") + { + return 1 if (-e $path.$ext); + } + } + die "Error: Cannot found \"$filename\" in the PATH.\n" if ($flag == DIE_NOT_FOUND); + print "Error: Cannot found \"$filename\" in the PATH.\n" if ($flag == ERROR_NOT_FOUND); + return 0; +} + +######################################### +# Symbian variant functions and variables +# +# copy from e32variant.pm +# + +my $toolspath = $epocroot . "epoc32\/tools\/"; +# SPPR begin +# enable includation of spp_variant.cfg if it exist +my $spp_cfgFile = $toolspath . "variant\/spp_variant.cfg"; +my $cfgFile = $toolspath . "variant\/variant.cfg"; # default location +$cfgFile = $spp_cfgFile if -e $spp_cfgFile; # use spp_variant.cfg +# SPPR End + +my $variantABIV2Keyword = &get_abiv2mode; # if variant ABIv2 mode enabled + +my $hrhdrive = $epocdrive; # variant hrh drive +my $hrhfile; # variant hrh file +my @macros; # variant macros + +if ($cfgFile =~ /^(.:)/i) +{ + $hrhdrive = lc($1); +} + +# returns the variant specific macro definitions as a list +sub get_variantmacrolist{ + + return @macros if (@macros); + + my $vfile = get_variantmacroHRHfile(); + + if($vfile) + { + my $VariantFilePath = split_path('Path',$vfile); + chop( $VariantFilePath ); + $VariantFilePath = &append_driveandquote($VariantFilePath); + $vfile = &append_driveandquote($vfile); + my $e32Path = &append_driveandquote($epocroot."epoc32\/include"); + + open CPPPIPE,"cpp -I $e32Path -I $VariantFilePath -undef -dM $vfile |" or die "ERROR: Can't invoke CPP.EXE\n"; + while(){ + if($_ =~ /(\#define)(\s+)(.+)/){ + push @macros, $3; + } + } + close CPPPIPE; + } + return @macros; +} + +# return hrh filename defined in variant cfg file +# notice: abort if hrh file located in different drive to cfg file +sub get_variantmacroHRHfile{ + + return $hrhfile if ($hrhfile); + if(-e $cfgFile){ + open(FILE, $cfgFile) || die "\nCould not open: " . $cfgFile ."\n"; + while () { + # strip comments + s/^([^#]*)#.*$/$1/o; + # skip blank lines + if (/^\s*$/o) { + next; + } + # get the hrh file + if($_ =~ /\.hrh/xi){ + $hrhfile = $_; + last; + } + } + close FILE; + die "\nERROR: No variant file specified in $cfgFile!\n" unless $hrhfile; + $hrhfile =~ s/\s+//g; + $hrhfile=~s/^(.:)//io; # remove drive letter + my $paths_drive = lc($1); + + chomp $hrhfile; + $hrhfile = get_makeeabspath($epocroot."epoc32\/", $epocroot, $hrhfile); # assume relative to EPOCROOT + + + if($paths_drive){ + die "\nERROR: Variant file specified in $cfgFile is not on the same drive as \/epoc32\/\n" + unless ($paths_drive eq $hrhdrive); + } + die "\nERROR: $cfgFile specifies $hrhfile which doesn't exist!\n" unless (-e $hrhfile); + + # make sure it is in unix syntax + $hrhfile=~ s/\\/\//g; + } + return $hrhfile; +} + +# get status of EANBLE_ABIV2_MODE +# 1=enabled 0=disabled +sub get_abiv2mode{ + + return $variantABIV2Keyword if (defined $variantABIV2Keyword); + + $variantABIV2Keyword=0; + if(-e $cfgFile){ + open(FILE, $cfgFile) || die "\nCould not open: " . $cfgFile ."\n"; + while () { + # strip comments + s/^([^#]*)#.*$/$1/o; + # skip blank lines + if (/^\s*$/o) { + next; + } + # get the hrh file + if($_ =~ /^ENABLE_ABIV2_MODE$/xi){ + $variantABIV2Keyword=1; + last; + } + } + close FILE; + } + + return $variantABIV2Keyword; +} + +############################# +# Path utilities +# +# copy from pathutl.pm +# + +#args: $_[0] Start EPOCPath Abs FilePath/Path $_[1]... list of (Abs/Rel FilePath/Path) +# Variant of MakAbs which also maps "+\\" to "${EPOCPath}" +sub get_makeeabspath ($@) { + return undef unless $_[0]=~m-^(.:)?[\\\/]-o; + my ($EPOCPath,$Path,@List)=@_; + my $BasePath=&split_path("Path",$Path); + undef $Path; + my $p; + foreach $p (@List) { + $p =~ s-\\-\/-g; + if ($p=~m-^\/?epoc32\/(.*)$-io) { # change - special case for existing \\epoc32 references + $p=$EPOCPath.$1; + next; + } + if ($p=~m-^\s*\+\/(.*)$-o) { + $p=$EPOCPath.$1; + next; + } + if ($p=~m-^\.{2}-o) { + $p=&strip_path($BasePath.$p); + next; + } + if ($p=~m-^[^\.\/]-o) { + $p=$BasePath.$p unless ($p =~ m-^.:-o); + next; + } + if ($p=~m-^(.:)?\/-o) { + next; + } + if ($p=~m-^\.\/(.*)$-o) { + $p=&strip_path($BasePath.$1); + next; + } + return undef; + } + return wantarray ? @List : $List[0]; +} + +#args: $_[0] Abs FilePath/Path +# Remove excess occurrences of '..' and '.' from a path +sub strip_path ($) { + return undef unless $_[0]=~m-^(.:)?[\/\\]-o; + my $P=$_[0]; + while ($P=~s-([\/\\])\.[\/\\]-$1-go) { } + while ($P=~s-[\\](?!\.{2}\\)[^\\]*\\\.{2}(?=\\)--go) { } + $P; +} + +#args: $_[0] 'Path' or 'Base' or 'Ext' $_[1] Abs/Rel FilePath/Path +# return the section of a file path required - Path, Base, Ext or File +sub split_path ($$) { + my ($Sect,$P)=@_; + + return '' if !$P; + $Sect= ucfirst lc $Sect; + if ($Sect eq 'Path') { + if ($P=~/^(.*[\\\/])/o) { + return $1; + } + return ''; + } + undef; +} + +sub append_driveandquote ($) { +# Take a path, or list of paths, and prefix with drive based on 1. epocroot, 2.CWD. +# Relative paths are just quoted. + my @List=@_; + my $Path; + + + foreach $Path (@List) { + next if ($Path !~ /^[\/\\]/); # skip prefix with drive letter or relative path + $Path=$epocdrive.$Path; + } + + foreach $Path (@List) { + chomp $Path; + $Path="\"".$Path."\""; + } + + return wantarray ? @List : $List[0]; +} + + +############################### +# General Utilities +# +# copy from genutl.pm +# + +# return name with well formated version id in hex +sub get_versionedname($) { + my ($name) = @_; + if ($name =~ /(.*)\{\s*(\d+)\s*\.\s*(\d+)\s*\}(.*?)$/i) { + my $a = $1; + my $b = $4; + my $major = $2; + my $minor = $3; + return $a.sprintf("{%04x%04x}",$major,$minor).$b if ($major<32768 and $minor<32768); + } + return $name; +} + + +############################### +# BPABI Platform Utilities +# +# copy from bpabiutl.pm +# + +my @BPABIPlats; + + +# Identify the BPABI platforms to be supported based on the compiler configuration files +# present in the location specified by the environment variable "SYMBIAN_COMPILATION_CONFIG_DIR" +# and in the directory $EPOCROOT\epoc32\tools\compilation_config +sub get_bpabiplatlist +{ + return @BPABIPlats if (scalar(@BPABIPlats)); + + my @CompilerConfigPath; + + if (exists($ENV{'SYMBIAN_COMPILATION_CONFIG_DIR'})) + { + my $Path = $ENV{SYMBIAN_COMPILATION_CONFIG_DIR}; + @CompilerConfigPath = split(/;/, $Path); + } + + push @CompilerConfigPath, "${epocroot}epoc32\/tools\/compilation_config"; + + my $ConfigDir; + + foreach $ConfigDir (@CompilerConfigPath) + { + opendir DIR, "$ConfigDir"; + my @Plats=grep /\.mk$/i, readdir DIR; + my $Plat; + foreach $Plat (@Plats) + { +# The platform name will be same as the name of the configuration file +# with the suffix '.mk' removed + $Plat =~ s/\.mk//; + if ($variantABIV2Keyword) { + if ($Plat =~ /^armv5_abiv2$/i) { + $Plat = "ARMV5"; + } + } + else { + if ($Plat =~ /^armv5$/i) { + $Plat = "ARMV5_ABIV2"; + } + } + unless (grep /$Plat$/i, @BPABIPlats) { + $Plat = uc $Plat; + push @BPABIPlats, $Plat; + } + } + } + closedir DIR; + return @BPABIPlats; +} + +############################# +# Platform Utilities +# +# copy from e32plat.pm +# +my %Plat=( + ARM4=>{ + ABI=>'ARM4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + }, + ARM4SMP=>{ + ABI=>'ARM4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + SMP=>1, + StatLink=>'ARM4SMP', + }, + ARM4T=>{ + ABI=>'ARM4T', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + }, + ARMI=>{ + ASSP=>'MARM', + Generic=>1, + ASSPABI=>'', + }, + SARM4=>{ + ABI=>'ARM4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + Single=>1, + }, + SARMI=>{ + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + Single=>1, + }, + STHUMB=>{ + ABI=>'THUMB', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + Single=>1, + }, + THUMB=>{ + ABI=>'THUMB', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + }, + TOOLS=>{ + ABI=>'TOOLS', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'TOOLS', + OS=>'TOOLS', + MakeMod=>'Cl_win', + MakeCmd=>'nmake', + }, + TOOLS2=>{ + ABI=>'TOOLS2', + ASSPABI=>'', + Compiler=>'GCC32', + CPU=>'TOOLS2', + OS=>'TOOLS2', + MakeMod=>'Cl_mingw', + MakeCmd=>'make', + }, + CWTOOLS=>{ + ABI=>'TOOLS', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'TOOLS', + OS=>'TOOLS', + MakeMod=>'Cl_tools', + MakeCmd=>'make', + }, + VC6TOOLS=>{ + ABI=>'TOOLS', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'TOOLS', + Ext=>'.DSP', + MakeMod=>'Ide_vc6', + MakeCmd=>'nmake', + OS=>'TOOLS', + Real=>'TOOLS', + UsrHdrsOnly=>1, + }, + WINS=>{ + ABI=>'WINS', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'WINS', + MakeMod=>'Cl_win', + MakeCmd=>'nmake', + OS=>'WINS', + }, + VC6=>{ + ABI=>'WINS', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'WINS', + Ext=>'.DSP', + MakeMod=>'Ide_vc6', + MakeCmd=>'nmake', + OS=>'WINS', + Real=>'WINS', + UsrHdrsOnly=>1, + }, + WINSCW=>{ + ABI=>'WINSCW', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'WINS', + MakeMod=>'Cl_codewarrior', + OS=>'WINS', + DefFile=>'WINS', # use the MSVC def files + }, + CW_IDE=>{ + ABI=>'WINSCW', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'WINS', + Ext=>'.xml', + MakeMod=>'Ide_cw', + MakeCmd=>'make', + OS=>'WINS', + Real=>'WINSCW', + DefFile=>'WINS', # use the MSVC def files + UsrHdrsOnly=>1, + SupportsMultiplePlatforms=>1, # supports more than one real platform + }, + X86=>{ + ABI=>'X86', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'X86', + MakeMod=>'Cl_x86', + MakeCmd=>'nmake', + OS=>'EPOC32', + DefFile=>'X86', + Generic=>1, + }, + X86SMP=>{ + ABI=>'X86', + ASSPABI=>'', + Compiler=>'VC32', + CPU=>'X86', + MakeMod=>'Cl_x86', + MakeCmd=>'nmake', + OS=>'EPOC32', + DefFile=>'X86', + Generic=>1, + SMP=>1, + StatLink=>'X86SMP', + }, + X86GCC=>{ + ABI=>'X86gcc', + ASSPABI=>'', + Compiler=>'X86GCC', + CPU=>'X86', + MakeMod=>'Cl_x86gcc', + OS=>'EPOC32', + DefFile=>'x86gcc', + Generic=>1, + }, + X86GMP=>{ + ABI=>'X86gcc', + ASSPABI=>'', + Compiler=>'X86GCC', + CPU=>'X86', + MakeMod=>'Cl_x86gcc', + OS=>'EPOC32', + DefFile=>'x86gcc', + Generic=>1, + SMP=>1, + StatLink=>'X86GMP', + }, + ARMV4=>{ + ABI=>'ARMV4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'Cl_arm', + Compiler=>'ARMCC', + DefFile=>'EABI', + EABI=>1, + }, + ARMV4SMP=>{ + ABI=>'ARMV4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'Cl_arm', + Compiler=>'ARMCC', + DefFile=>'EABI', + EABI=>1, + SMP=>1, + StatLink=>'ARMV4SMP', + }, + ARMV5_ABIV1=>{ + ABI=>'ARMV5', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'Cl_arm', + Compiler=>'ARMCC', + DefFile=>'EABI', + EABI=>1, + SupportsFeatureVariants=>1, + }, + ABIV2=>{ + ABI=>'ARMV5', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'Cl_bpabi', + DefFile=>'EABI', + EABI=>1, + SupportsFeatureVariants=>1, + }, + GCCXML=>{ + ABI=>'ARM4', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'cl_gccxml', + }, + VS6=>{ + ABI=>'WINSCW', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'WINS', + MakeMod=>'Cl_vscw', + OS=>'WINS', + Real=>'WINSCW', + DefFile=>'WINS', # use the MSVC def files + Ext=>'.mak' + }, + VS2003=>{ + ABI=>'WINSCW', + ASSPABI=>'', + Compiler=>'CW32', + CPU=>'WINS', + MakeMod=>'Cl_vscw', + OS=>'WINS', + Real=>'WINSCW', + DefFile=>'WINS', # use the MSVC def files + Ext=>'.mak' + }, + EDG=>{ + ABI=>'ARMV5', + ASSP=>'MARM', + ASSPABI=>'', + Generic=>1, + MakeMod=>'cl_edg', + }, + + # ASSP platforms should be described using .ASSP files + # Do not add additional ASSP platforms to this file. +); + +my $init_bsfs_done = 0; +my $init_plat_done = 0; +my @PlatList; # Platlist returned by list_plat() + +# initialize BSF platforms into %Plat +sub init_bsfs($) { + return $init_bsfs_done if ($init_bsfs_done); + + my ($Path)=@_; +# get a list of modules + opendir DIR, $Path; + my @BSFs=grep s/^([^\.].*)\.BSF$/$1/, map { uc $_ } sort readdir DIR; + closedir DIR; + + my $BSF; + foreach $BSF (@BSFs) { + my $File=$Path.lc($BSF).'.bsf'; +# check whether the assp is already defined + if (defined %{$Plat{$BSF}}) { + warn( + "$File : warning: Platform \"$BSF\" already defined\n", + " ... skipping this spec\n" + ); + delete $Plat{$BSF}; + next; + } +# open the module + unless (open FILE, $File) { + delete $Plat{$BSF}; + warn "warning: Can't open BSF specification \"$File\"\n"; + next; + } + my $line1 = ; + $line1 = uc($line1); + unless ($line1 =~ /^\#\\#/) { + warn "warning: \"$File\" Invalid BSF specification - missing ##\n"; + delete $Plat{$BSF}; + close FILE; + next; + } + my $custom; + while ($custom = ) { + #skip blank lines and comments + delete $Plat{$BSF}; + last unless ($custom =~ /^$|^\#/); + } + $custom = uc $custom; + unless ($custom =~ /^\s*CUSTOMIZES\s+(\S+)/) { + warn "warning: \"$File\" Invalid BSF specification - 'customizes' missing\n"; + delete $Plat{$BSF}; + close FILE; + next; + } + my $root = $1; + my $platname = ''; + my $CustomizedPlatName = ''; + + # In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist + my $Armv5Flag = 0; + if (!$variantABIV2Keyword && $root =~ /^ARMV5$/i) { + $Armv5Flag = 1; + } + + # Support for Hierarchy of Customizations (BSF file customization of another BSF file) + # 1. Check whether the BSF file customizes another BSF file. + # 2. If so, check whether the root BSF file has already been read. + # 3. If not read, then defer the current BSF file reading until the root file is read. + my $rootPlatFound = 0; + if (defined %{$Plat{$root}} || $Armv5Flag) + { + # BSF platform customizes another valid BSF platform + if (defined $Plat{$root}{'CUSTOMIZES'}) + { + $rootPlatFound = 1; + $platname = $root; + $CustomizedPlatName = $root; + + # Set the root platform name which is same as of customizes platform + $Plat{$BSF}{'ROOTPLATNAME'} = $Plat{$root}{'ROOTPLATNAME'}; + } + # BSF platform customizes to one of the existing ABI platforms + else + { + # All BPABI platforms inherits from ABIV2 platform listed in the platlist + if (grep /^$root$/i, @BPABIPlats) { + $platname = "ABIV2"; + } + elsif ($Armv5Flag) { + # In v1 mode, ARMV5 platform implies ARMV5_ABIV1 platform listed in the platlist + $platname = "ARMV5_ABIV1"; + } + else { + $platname = $root; + } + + $CustomizedPlatName=$root; + + # BSF File check Begins + # The following check is included to handle the existing BSF files which has to behave in different manner + # in default v1 mode and v2 mode. The following code changes the BSF name and the custmoized platform name + # to the implied names. This is done to support switching between v1 and v2 modes by enabling the keyword in + # the variant configuration file. + # In v1 mode, the ARMV6_ABIV1 => ARMV6 platform and ARMV6 => ARMV6_ABIV2 platform. + if (!$variantABIV2Keyword) { + if ($BSF =~ /^ARMV6_ABIV1$/i) { + $BSF = "ARMV6"; + $CustomizedPlatName = "ARMV5"; + } + elsif ($BSF =~ /^ARMV6$/i) { + $BSF = "ARMV6_ABIV2"; + $CustomizedPlatName = "ARMV5_ABIV2"; + $platname = "ABIV2"; + } + } + # BSF File check Ends + + # Set the root platform name + $Plat{$BSF}{'ROOTPLATNAME'} = $CustomizedPlatName; + } + } + else + { + my $rootbsf = $Path.$root.".bsf"; + if ( -e $rootbsf ) { + # BSF file customizes another BSF file which has not been read yet. + # So defer current BSF file reading until the root BSF file is read. + delete $Plat{$BSF}; + push(@BSFs, $BSF); + next; + } + } + # If the customizes platform is not a valid BSF platform or BPABI platorm or ARMV5 or ARMV5_ABIV1, + # then throw warning. + unless ($rootPlatFound || $root =~ /^ARMV5(_ABIV1)?$/ || (grep /^$root$/i, @BPABIPlats)) { + warn "warning: \"$File\" Invalid BSF specification - customization restricted to ARMV5, ABIv2 and valid BSF platforms\n"; + close FILE; + delete $Plat{$BSF}; + next; + } + + my ( $key, $value); + while (($key, $value) = each %{$Plat{$platname}}) { + $Plat{$BSF}{$key}=$value; + } + + push @{$Plat{$CustomizedPlatName}{'CUSTOMIZATIONS'}}, $BSF; + $Plat{$BSF}{'CUSTOMIZES'} = $CustomizedPlatName; + while () { + next if (/^$|^\#/); + if (/^\s*SMP\s*$/i) { + $Plat{$BSF}{'SMP'} = 1; + $Plat{$BSF}{'StatLink'} = lc $BSF; + next; + } + $Plat{$BSF}{'CUSTOMIZATION_DATA'} .= $_; + } + # BSF file statements will have newline character("\n") at the end, except for the last statement. + # So append "\n" for the last BSF file statement. + # "\n" will be used to split BSF statements to support hierarchy of customizations. + $Plat{$BSF}{'CUSTOMIZATION_DATA'} .= "\n"; + close FILE; + } + $init_bsfs_done = 1; +} + +# setup Plat with bpabi platforms +sub init_platwithbpabi() +{ + foreach my $Candidate (&get_bpabiplatlist) + { +# All BPABI platforms inherit from ABIV2 properties as listed in the platlist +# and Platlist is updated to include the BPABI platforms. + my ( $key, $value); + while (($key, $value) = each %{$Plat{ABIV2}}) { + $Plat{$Candidate}{$key}=$value; + } + } +} + +# initialize %Plat with BSF/Bpabi/ASSP +sub init_plat ($) { # takes path to ASSP modules + + return $init_plat_done if ($init_plat_done); + + my ($Path)=@_; + + my %PlatHashKeys=( + ABI=>1, + ASSPABI=>1, + SINGLE=>1, + Compiler=>1, + CPU=>1, + MakeMod=>1, + MakeCmd=>1, + OS=>1, + DefFile=>1, + ASSP=>1, + ); + +# Include the list of BPABI platforms + &init_platwithbpabi; + + init_bsfs($Path); + +# get a list of modules + opendir DIR, $Path; + my @_ASSPs=grep s/^([^\.].*)\.ASSP$/$1/, map { uc $_ } readdir DIR; + closedir DIR; + + my @ASSPs; + foreach (@_ASSPs) { + next if (!$ENV{USEARMCC} and /EDG$/i); + push @ASSPs, $_; + } + +# open each module in turn, and add it to the array + my $ASSP; + foreach $ASSP (@ASSPs) { + my $File=$Path.$ASSP.'.assp'; +# check whether the assp is already defined + if (defined %{$Plat{$ASSP}}) { + warn( + "$File : warning: ASSP \"$ASSP\" already defined\n", + " ... skipping this module\n" + ); + + next; + } +# open the module + unless (open FILE, $File) { + warn "warning: Can't open assp module \"$File\"\n"; + next; + } + my %Data=(); + my %SingleData=(); + my $MatchingSingle=""; + my @Errors=(); + while () { +# strip comments + s/^([^#]*)#.*$/$1/o; +# skip blank lines + if (/^\s*$/o) { + next; + } +# get the key-value pair + unless (/^\s*(\w+)\s+(\w+)\s*$/o) { + push @Errors, "$File($.) : warning: syntax error - only key-value pairs allowed\n"; + next; + } + my ($Key, $Val)=($1, $2); + if ($PlatHashKeys{$Key}!=1) { + push @Errors, "$File($.) : warning: unrecognized keyword - $Key\n"; + next; + } + if ($Key eq "SINGLE") { + $SingleData{Single} = 1; + $SingleData{ASSP} = $ASSP; + $MatchingSingle = uc $2; + } else { + $Data{$Key}=$Val; + $SingleData{$Key}=$Val; + } + } + close FILE; + if (@Errors) { + warn( + @Errors, + " ... skipping this module\n" + ); + next; + } +# change - Allow ASSPs to pick up all the options of the ABI they specify, +# in particular the compiler they need. + $Data{'ASSP'} = $ASSP unless $Data{'ASSP'}; + if ($Plat{$Data{'ABI'}}) { + foreach (keys %{$Plat{$Data{'ABI'}}}) { + $Data{$_} = $Plat{$Data{'ABI'}}{$_} unless ($_ =~ /^GENERIC$/i) or $Data{$_}; + } + } + + %{$Plat{$ASSP}}=%Data; + if ($MatchingSingle ne "") { + foreach (keys %Data) { + $SingleData{$_} = $Data{$_} unless ($_ =~ /^GENERIC$/i) or $SingleData{$_}; + } + %{$Plat{$MatchingSingle}}=%SingleData; + } + } + $init_plat_done=1; +} + +# return list of supported platforms +# should be invoked atfer init_plat +sub get_platlist () { + + return @PlatList if (scalar(@PlatList)); + + &init_plat; + + my $Key; + foreach $Key (keys %Plat) { + if (!$variantABIV2Keyword && $Key =~ /^armv5_abiv1$/i) { + $Key = 'ARMV5'; + } + unless (grep /^$Key$/i, @PlatList) { + push @PlatList, $Key; + } + } + return @PlatList +} + +# return customizes BSF plat if any +sub get_platcustomizes($) { + my ($plat) = @_; + return $Plat{$plat}{'CUSTOMIZES'} ? $Plat{$plat}{'CUSTOMIZES'} : ""; +} + +# return root of a specific plat +sub get_platroot($) { + my ($plat) = @_; + + my $RootName = $Plat{$plat}{'ROOTPLATNAME'}; + + if ($RootName) { + return $RootName; + } + else { + # A non-BSF platform is its own root. + return $plat; + } +} + +################################# +# featurevariant map functions +# +# copy from featurevariantmap.pm + +my $featureListDir = "${epocroot}epoc32\/include\/variant\/featurelists"; + +# Usage: get_BVbinname("my.dll", "myvar") +# +# Look for a binary using its "final" name. We will use the feature +# variant map and the feature variant name to deduce the "variant" +# binary name and test for its existence. +# +# "my.dll" - the final target (full path) +# "myvar" - the feature variant name +# +# returns the file name if found, or "" otherwise. + +sub get_BVbinname +{ + my $binName = shift; + my $varName = shift; + + # look for the vmap file + my $vmapFile = "$binName.$varName.vmap"; + + if (! -e $vmapFile) + { + # compatible to old BV + $vmapFile = "$binName.vmap"; + } + + if (-e $vmapFile) + { + my $key = get_vmapkey($varName, $vmapFile); + + if ($key) + { + $binName =~ /^(.*)\.([^\.]*)$/; + $binName = "$1.$key.$2"; + } + else + { + print "ERROR: No \'$varName\' variant for $binName in $vmapFile\n"; + return ""; # file not found + } + } + + # check that the actual binary exists + if (-e $binName) + { + return $binName; + } + return ""; # file not found +} + +# internal functions +sub get_vmapkey +{ + my @res = get_vmapdata(@_); + return $res[0]; +} + +# Usage: featurevariantmap->GetDataFromVMAP("myvar", "mydll.vmap") +# +# Opens the vmap file indicated and returns the data for the requested variant +# +# "myvar" - the feature variant name +# "my.vmap" - the final target vmap file (full path) +# +# Returns a list ( hash, features ) for the variant in the vmap or undef if not found + +sub get_vmapdata +{ + my $varName = shift; + my $fileName = shift; + + if (!open(VMAP, $fileName)) + { + print "ERROR: Could not read VMAP from $fileName\n"; + return ""; + } + while () + { + chomp; + if (/(\w{32})\s+$varName\s+(.*)$/i or /(\w{32})\s+$varName$/i) + { + my ( $hash, $features ) = ( $1, $2 ? $2 : '' ); + close(VMAP); + return ( $hash, $features ); + } + } + close(VMAP); + return; +} + +###################################### +# Feature variant parser +# +# copy from featurevariantparser.pm +# + + +# Parses .VAR files and returns key variables. +# The following hashes can be used with this module: +# NAME -> Returns the name of the variant file (without the extension) +# FULLPATH -> Returns the full path of the variant file (including the extension) +# VALID -> Set to 1 if the variant file is valid, otherwise set to 0 +# VIRTUAL -> Set to 1 if the variant is a grouping node, otherwise set to 0 +# ROM_INCLUDES -> Returns a pointer to the list of ROM_INCLUDES (including Parent nodes). +# VARIANT_HRH -> Returns the full VARIANT_HRH file path used by the VAR file. + + +my $defaultDir = "${epocroot}epoc32\/tools\/variant"; +my $pathregex = '.+[^\s]' ; # Regex to match all characters (including \ or /), excluding whitespaces. + +my @rominclude; +my @parents; +my @childNodes; +my $virtual; +my $childNodeStatus; +my $varianthrh; + +my $dir; #var directory +my $fullpath; #full path of var file +my $fulldir; # + +# Wrapper function to return all the correct variables +# Arguments : (Variant Name, Variant Directory(optional)) +# Returns a Hash. +sub get_variant +{ + @rominclude = (); + @parents = (); + @childNodes = (); + $dir = ""; + $fullpath = ""; + $varianthrh = ""; + $virtual = 0; + $childNodeStatus = 0; + + + my %data; + my $romincs = ""; + + $data{'VALID'} = 0; + + my ( $varname, $dirname ) = @_; + + my $fullvarpath = get_variantfullpath( $varname, $dirname ); + + if ( $dirname ) + { + $fulldir = $dirname; + } + else + { + $fulldir = $defaultDir; + } + + $data{'FULLPATH'} = "$fullvarpath"; + $data{'NAME'} = "$varname"; + + # If the variant file exists, check the syntax and setup variables. + if ( -e $fullvarpath ) + { + if ( check_varfile( $fullvarpath, $varname ) ) + { + $data{'VALID'} = 1; + } + } + else + { + print "ERROR: $fullvarpath" . " does not exist\n"; + } + + my $count = 0; + + # If VAR file is valid, setup all other variables. + if ( $data{'VALID'} ) + { + + $romincs = find_varrominc($fullvarpath); + + # Remove empty elements from the ROM_INCLUDE list + @$romincs = grep /\S/, @$romincs; + + # Fix paths for all ROM_INCLUDES + for ( my $i = 0 ; $i < scalar(@$romincs) ; $i++ ) + { + @$romincs[$i] = get_fixpath( @$romincs[$i] ); + } + + $data{'ROM_INCLUDES'} = clone_list($romincs); + $data{'VARIANT_HRH'} = $varianthrh; + $data{'VIRTUAL'} = $virtual; + } + + # If variant file is not valid, return reference to a blank array + else + { + $data{'ROM_INCLUDES'} = []; + $data{'VARIANT_HRH'} = ""; + } + + return %data; +} + +# Method to construct a full variant path from the variant file and directory +sub get_variantfullpath +{ + + my $vardirectory = $_[1]; + my $varname = $_[0]; + + my $dir; + + # Check if a directory is supplied + if ($vardirectory) + { + $dir = "$vardirectory"; + } + + else + { + $dir = $defaultDir; + } + my $filename = "$varname" . "\.var"; + $fullpath = File::Spec->catfile( File::Spec->rel2abs($dir), $filename ); + + if ( !File::Spec->file_name_is_absolute($fullpath) ) + { + $fullpath = File::Spec->rel2abs($fullpath); + } + + return $fullpath; +} + +# Checks the variant file for the correct syntax and reports any errors +# Also sets up some variables(VIRTUAL ,VARIANT_HRH and VARIANT) whilst file is being parsed. + +# Usage: check_varfile(,) . Note: without .var +sub check_varfile +{ + + my $fullpath = $_[0]; + my $varname = $_[1]; + my $varianthrhpresent = 0; + + open( READVAR, "<$fullpath" ); + my $exp = "#"; + my $line = ""; + + while () + { + s/\r\n/\n/g; + + $line = $.; + + # Checks for a valid argument supplied to EXTENDS keyword. Checks for one and only one argument supplied. + if (/^EXTENDS/) + { + if ( !m/^EXTENDS\s+./ ) + { + print "\nERROR: Invalid format supplied to argument EXTENDS on line " + . "$." + . " in file " + . "$fullpath"; + return 0; + } + my $str = get_extends($_); + if ( $str =~ /\s+/ ) + { + print "\nERROR: Cannot extend from two nodes. Error in line " + . "$." + . " in file " + . "$fullpath"; + return 0; + } + + $childNodeStatus = 1; + } + + # Checks for the grammar of BUILD_INCLUDE, i.e. KEYWORD MODIFIER VALUE + elsif (/^BUILD_INCLUDE/) + { + # skip build inc checking + } + + # Checks for the grammar of ROM_INCLUDE, i.e. KEYWORD MODIFIER VALUE + elsif (/^ROM_INCLUDE/) + { + + if (!m/^ROM_INCLUDE\s+(append|prepend|set)\s+$pathregex/) + { + print "\nERROR: Invalid syntax supplied to keyword ROM_INCLUDE on line " + . "$." + . " in file " + . "$fullpath"; + return 0; + } + + if (m/^ROM_INCLUDE\s+(append|prepend|set)\s+$pathregex\s+$pathregex/) + { + print "\nERROR: Too many arguments supplied to keyword ROM_INCLUDE on line " + . "$." + . " in file " + . "$fullpath"; + return 0; + } + } + + # Checks for a valid VARIANT name + elsif (/^VARIANT[^_HRH]/) + { + if ( !m/^VARIANT\s+\w+/ ) + { + print "\nERROR: VARIANT name not specified on line " . "$." + . " in file " + . "$fullpath"; + return 0; + } + if ( uc("$varname") ne uc( get_variantname($_) ) ) + { + print "\nERROR: VARIANT filename does not match variant name specified on line " + . "$line" + . " in file " + . "$fullpath" + . "\nVariant value extracted from the VAR file is " . "$_"; + } + + } + + # Checks that keyword VIRTUAL is declared correctly + elsif (/^VIRTUAL/) + { + if (m/^VIRTUAL\s+\w+/) + { + print "\nERROR: Invalid declaration of VIRTUAL on line " . "$." + . " in file " + . "$fullpath"; + return 0; + } + + $virtual = 1; + } + + # Checks if VARIANT_HRH is declared correctly. + elsif (/^VARIANT_HRH/) + { + $varianthrhpresent = 1; + my $lineno = $.; + if ( !m/^VARIANT_HRH\s+./ ) + { + print "\nERROR: Invalid format supplied to argument VARIANT_HRH on line " + . "$lineno" + . " in file " + . "$fullpath"; + return 0; + } + + my $str = get_hrhname($_); + if ( $str =~ /\s+/ ) + { + print "\nERROR: Cannot have 2 or more hrh files. Error in line " + . "$lineno" + . " in file " + . "$fullpath"; + return 0; + } + + unless( -e get_fixpath($str) ) + { + print "\nERROR: VARIANT HRH file : " + . get_fixpath($str) + . " specified on line " + . "$lineno" + . " does not exist"; + return 0; + } + + $varianthrh = get_fixpath( get_hrhname($_) ); + + } + + # If none of the valid keywords are found + else + { + + # Do nothing if a comment or blank line is found + if ( (m/$exp\s+\S/) || (m/$exp\S/) || ( !m/./ ) || (m/^\n/) ) + { + } + + # Unsupported keyword + else + { + + print "\nERROR: Invalid keyword " . '"' . "$_" . '"' + . " found on line " . "$." + . " in file " + . "$fullpath"; + return 0; + } + } + } + + close(READVAR); + + # If no HRH file defined, check if the default one exists + if ( !$varianthrhpresent ) + { + print "\nINFO: No VARIANT_HRH defined in VAR file, using ${epocroot}epoc32\/include\/variant\/$varname\.hrh" if ($verbose); + my $str = + get_hrhname( + "VARIANT_HRH ${epocroot}epoc32\/include\/variant\/$varname\.hrh" + ); + + if ( ! -e $str ) + { + print "\nERROR: VARIANT HRH file : " . "$str " . "does not exist\n"; + return 0; + } + else + { + $varianthrh = $str; + } + } + return 1; +} + +# Extract the value of the VARIANT keyword +sub get_variantname +{ + + $_[0] =~ m/^VARIANT\s+(\w+)/i; + return $1; +} + +# Extracts the value of the HRH file from the VARIANT_HRH line supplied +sub get_hrhname +{ + + $_[0] =~ m/^VARIANT_HRH\s+($pathregex)/; + return $1; + +} + +# Method to find the immediate parent node of a child node +sub get_extends +{ + + $_[0] =~ m/^EXTENDS\s+(\w+)/; + return $1; +} + + +# Method to correct all the slashes, and also append EPOCROOT if the path begins with a \ or / +# If path doesn't start with \ or /, returns an abosulte canonical path +sub get_fixpath +{ + + my $arr = $_[0]; + + if ( $arr =~ m/^\// ) + { + $arr =~ s/^\/?//; + return File::Spec->canonpath( "$epocroot" . "$arr" ); + } + + elsif ( $arr =~ m/^\\/ ) + { + $arr =~ s/^\\?//; + return File::Spec->canonpath( "$epocroot" . "$arr" ); + } + + else + { + return File::Spec->rel2abs( File::Spec->canonpath("$arr") ); + } + +} + +# Method to find the ROMINCLUDE values of the VAR file. +sub find_varrominc +{ + + my $filename = $_[0]; + + my $parentNodes; + + # Construct a list of parent nodes if node is a child + if ($childNodeStatus) + { + $parentNodes = find_varparentnode("$filename"); + } + + if ($parentNodes) + { + + # Go through and build the list of all parent ROM_INCLUDES + for ( my $i = scalar(@$parentNodes) - 1 ; $i >= 0 ; $i-- ) + { + my $t = get_variantfullpath( @$parentNodes[$i], $fulldir ); + open( NEWHANDLE, "<$t" ); + + while () + { + if (/ROM_INCLUDE/) + { + get_varrominc($_); + } + } + close(NEWHANDLE); + } + } + + # Append the ROM_INCLUDES of the VAR file in the end + open( NEWHANDLE, "<$filename" ); + + while () + { + if (/ROM_INCLUDE/) + { + get_varrominc($_); + } + } + + undef(@parents); # Flush out parent array; + return \@rominclude; + +} + +# Constructs a list of Parent nodes for a given Child node. +sub find_varparentnode +{ + + my $filename = $_[0]; + my $hasparents = 0; + + open( READHANDLE, "<$filename" ); + while () + { + if (/EXTENDS/) + { + $hasparents = 1; + push( @parents, get_extends($_) ); + + } + } + + close(READHANDLE); + + if ( $hasparents == 1 ) + { + find_varparentnode( + get_variantfullpath( @parents[ scalar(@parents) - 1 ], $fulldir ) + ); + } + else + { + return \@parents; + } + +} + +# Method to extract the ROM_INCLUDE value of a node. +sub get_varrominc +{ + +# If modifier append is found, push the rominclude to the end of the array list. + if (/^ROM_INCLUDE\s+append\s+($pathregex)/) + { + push( @rominclude, ($1) ); + } + +# If modifier prepend is found, push the rominclude to the beginning of the array list. + if (/^ROM_INCLUDE\s+prepend\s+($pathregex)/) + { + unshift( @rominclude, ($1) ); + } + +# If keyword set is found, then empty the rominclude variable and push the new value + if (/^ROM_INCLUDE\s+set\s+($pathregex)/) + { + undef(@rominclude); + push( @rominclude, ($1) ); + } + +} + +# Helper method that clones a reference to a simple list +sub clone_list + { + my $ref = shift; + + # Check the reference is a list + die "Not a list ref" if ref($ref) ne 'ARRAY'; + + # Create a new list object + my @list; + foreach my $entry ( @$ref ) + { + # Only clone lists of scalars + die "Not a scalar" if ref($entry); + + # Add the entry to the new list + push @list, $entry; + } + + # return a reference to the copy + return \@list; + } + +############################## +# write helper +# +# copy from writer.pm +sub write_32bit # little-endian +{ + my $fileHandle=shift; + my $integer=shift; + &write_8bit($fileHandle, $integer&0x000000ff); + &write_8bit($fileHandle, ($integer>>8)&0x000000ff); + &write_8bit($fileHandle, ($integer>>16)&0x000000ff); + &write_8bit($fileHandle, ($integer>>24)&0x000000ff); +} + +sub write_8bit +{ + my $fileHandle=shift; + my $integer=shift; + if ($integer&0xffffff00) + { + die("Error: the integer ".sprintf("0x%08x", $integer)." is too large to write into 8 bits\n"); + } + printf $fileHandle "%c", $integer; +} + + +1; + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/bin/mingw_make.exe Binary file imgtools/imaker/bin/mingw_make.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/buildrom_plugins/group/bld.inf --- a/imgtools/imaker/buildrom_plugins/group/bld.inf Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/buildrom_plugins/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -18,11 +18,12 @@ PRJ_EXPORTS -../plugincommon.pm +/tools/ // -../hide.pm +/tools/ // -../localise.pm +/tools/ // -../localise_all_resources.pm +/tools/ // -../obyparse.pm +/tools/ // -../override.pm +/tools/ // +../plugincommon.pm +/tools/rom/imaker/ // +../hide.pm +/tools/rom/imaker/ // +../localise.pm +/tools/rom/imaker/ // +../localise_all_resources.pm +/tools/rom/imaker/ // +../obyparse.pm +/tools/rom/imaker/ // +../override.pm +/tools/rom/imaker/ // +../stubsischeck.pm +/tools/rom/imaker/ // // END OF BLD.INF diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/buildrom_plugins/localise.pm --- a/imgtools/imaker/buildrom_plugins/localise.pm Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/buildrom_plugins/localise.pm Wed Jun 30 11:35:58 2010 +0800 @@ -13,7 +13,7 @@ # # Description: # Adds a LOCALISE macro that enables configuration of localised files. -# The localised language selection is done with a ADD_LANGUAGE macro. +# The localised language selection is done with a LANGUAGE_CODE macro. # @@ -26,14 +26,14 @@ # target => the target file. The section that needs to be localised should be marked with ??. # languages => a space delimited list of language codes # -# Syntax: ADD_LANGUAGE -# ADD_LANGUAGE lang +# Syntax: LANGUAGE_CODE +# LANGUAGE_CODE lang # # Example: # Add languages -# ADD_LANGUAGE 01 -# ADD_LANGUAGE 02 -# ADD_LANGUAGE 03 +# LANGUAGE_CODE 01 +# LANGUAGE_CODE 02 +# LANGUAGE_CODE 03 # # Use Case 1: # Localises a App resoure file. @@ -45,9 +45,9 @@ # # Use Case 2: # Localise all resource files under a section -# ADD_LANGUAGE 01 -# ADD_LANGUAGE 02 -# ADD_LANGUAGE 03 +# LANGUAGE_CODE 01 +# LANGUAGE_CODE 02 +# LANGUAGE_CODE 03 # # LOCALISE_ALL_RESOURCES_BEGIN # // All resource files will be localised @@ -107,6 +107,7 @@ my $verbose=0; my $errors=0; my $localise_all_resource=0; +my %qt_langs = (); sub localise_info { @@ -120,17 +121,10 @@ my $obydata = shift; do_localise_all_resources_extension(\@{$obydata}); - undef @newobydata; foreach $line (@{$obydata}) { - # Ignore REM statements, to avoid processing "REM __SCALABLE_IMAGE( ... )" - if ($line =~ /^\s*REM/i) - { - push @newobydata, $line; - next; - } - # ADD_LANGUAGE xx + # LANGUAGE_CODE xx if (is_addlanguage_entry($line)) { my $code = get_lang_from_addlanguage_entry($line); @@ -144,10 +138,28 @@ { print "adding language $code\n" if $verbose; $languages{$code} = 1; - push @newobydata, "REM handled $line"; + push @newobydata, $line; next; } } + # Ignore REM statements, to avoid processing "REM __SCALABLE_IMAGE( ... )" + if ($line =~ /^\s*REM/i) + { + push @newobydata, $line; + next; + } + # Read QT to Symbian language id mappings + if ($line =~ /^\s*QT_TO_SYMBIAN_LANGID\s+(.+?)\s*$/i) + { + push(@newobydata, "REM handled $line"); + open(FILE, $1) or + die("ERROR: localise.pm can't open QT to Symbian language id mapping file `$1'\n"); + map { + $qt_langs{$2} = $1 if (!/^\s*#/ && /^\s*(\S+?)\s*=\s*(\d+)\s*$/); + } ; + close(FILE); + next; + } # LOCALISE macro if (is_localise_entry($line)) { @@ -245,14 +257,23 @@ for (my $i=0; $i<$count; $i++) { push(@data, $lang); } - my $output = sprintf($res,@data); + + my $output; + if (($res =~ m/\.qm["']?$/i) && %qt_langs) + { + $output = sprintf($res, $qt_langs{sprintf("%s", @data)}); + } + else + { + $output = sprintf($res,@data); + } return $output; } -# match ADD_LANGUAGE 01 +# match LANGUAGE_CODE 01 sub is_addlanguage_entry($) { my $entry = shift; - if ( $entry =~ m/^\s*ADD_LANGUAGE\s+(\S+)\s*/i ) + if ( $entry =~ m/^\s*REM\s+handled\s+LANGUAGE_CODE\s+(\S+)\s*$/i ) { return 1; } @@ -262,7 +283,7 @@ sub get_lang_from_addlanguage_entry($) { my $entry = shift; - if ( $entry =~ m/^\s*ADD_LANGUAGE\s+(\S+)/i ) + if ( $entry =~ m/^\s*REM\s+handled\s+LANGUAGE_CODE\s+(\S+)\s*$/i ) { return $1; } diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/buildrom_plugins/localise_all_resources.pm --- a/imgtools/imaker/buildrom_plugins/localise_all_resources.pm Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/buildrom_plugins/localise_all_resources.pm Wed Jun 30 11:35:58 2010 +0800 @@ -13,7 +13,7 @@ # # Description: # Adds a LOCALISE macro that enables configuration of localised files. -# The localised language selection is done with a ADD_LANGUAGE macro. +# The localised language selection is done with a LANGUAGE_CODE macro. # @@ -26,14 +26,14 @@ # target => the target file. The section that needs to be localised should be marked with ??. # languages => a space delimited list of language codes # -# Syntax: ADD_LANGUAGE -# ADD_LANGUAGE lang +# Syntax: LANGUAGE_CODE +# LANGUAGE_CODE lang # # Example: # Add languages -# ADD_LANGUAGE 01 -# ADD_LANGUAGE 02 -# ADD_LANGUAGE 03 +# LANGUAGE_CODE 01 +# LANGUAGE_CODE 02 +# LANGUAGE_CODE 03 # # Use Case 1: # Localises a App resoure file. @@ -45,9 +45,9 @@ # # Use Case 2: # Localise all resource files under a section -# ADD_LANGUAGE 01 -# ADD_LANGUAGE 02 -# ADD_LANGUAGE 03 +# LANGUAGE_CODE 01 +# LANGUAGE_CODE 02 +# LANGUAGE_CODE 03 # # LOCALISE_ALL_RESOURCES_BEGIN # // All resource files will be localised @@ -64,19 +64,6 @@ # ############################################################################### -# -# Version 4 -# Path corrections to widget support. -# -# Version 3 -# Support for Idle widgets. -# -# Version 2 -# Localises also *.hlp to *.h%s. -# -# Version 1 -# Initial version. - package localise_all_resources; use strict; @@ -169,6 +156,15 @@ push @newobydata, "$line\n"; next; } + # localise all qm files inside the localise_all_resources section + # qt resource files .ts + if ( is_qt_resource_entry($line) ) + { + # match data/file=foobar.qm resource/foobar.qm + $line = create_localise_entry_from_qt_resource($line); + push @newobydata, "$line\n"; + next; + } # help files .hlp if ( is_help_entry_hlp($line) ) { @@ -262,6 +258,19 @@ return 0; } +sub is_qt_resource_entry($) +{ + my $entry = shift; + my $type = get_type_from_entry($entry); + my $source = get_source_from_entry($entry); + my $target = get_target_from_entry($entry); + if ($source =~ m/\.qm[\"|\']?$/i && + $target =~ m/\.qm[\"|\']?$/i ) + { + return 1; + } + return 0; +} # # match sub is_help_entry_xhtml($) @@ -270,8 +279,8 @@ my $type = get_type_from_entry($entry); my $source = get_source_from_entry($entry); my $target = get_target_from_entry($entry); - if ($source =~ m/\\01\\/i && - $target =~ m/\\01\\/i ) + if ($source =~ m/[\/\\]01[\/\\]/i && + $target =~ m/[\/\\]01[\/\\]/i ) { return 1; } @@ -301,10 +310,10 @@ my $type = get_type_from_entry($entry); my $source = get_source_from_entry($entry); my $target = get_target_from_entry($entry); - if (($source =~ m/\\01\\.*\.dtd/i && - $target =~ m/\\01\\.*\.dtd/i ) || - ($source =~ m/\\00\\.*\.dtd/i && - $target =~ m/\\00\\.*\.dtd/i )) + if (($source =~ m/[\/\\]01[\/\\].*\.dtd/i && + $target =~ m/[\/\\]01[\/\\].*\.dtd/i ) || + ($source =~ m/[\/\\]00[\/\\].*\.dtd/i && + $target =~ m/[\/\\]00[\/\\].*\.dtd/i )) { return 1; } @@ -390,6 +399,20 @@ return "$type=LOCALISE($source, $target)"; } +# create localise entry from qt resource entry +sub create_localise_entry_from_qt_resource($) +{ + my $entry = shift; + my $type = get_type_from_entry($entry); + my $source = get_source_from_entry($entry); + my $target = get_target_from_entry($entry); + #convert the .qm to _xx.qm + $source =~ s/\.qm/\_%s.qm/i; + $target =~ s/\.qm/\_%s.qm/i; + #print "create_localise_entry_from_resource: $source\n"; + return "$type=LOCALISE($source, $target)"; +} + # create localise entry from resource entry sub create_localise_entry_from_help($) { @@ -398,8 +421,8 @@ my $source = get_source_from_entry($entry); my $target = get_target_from_entry($entry); #convert the \\01\\ to \\%02d\\ - $source =~ s/\\01\\/\\%02d\\/i; - $target =~ s/\\01\\/\\%02d\\/i; + $source =~ s/([\/\\])01([\/\\])/$1%02d$2/i; + $target =~ s/([\/\\])01([\/\\])/$1%02d$2/i; #print "create_localise_entry_from_resource: $source\n"; return "$type=LOCALISE($source, $target)"; } @@ -468,8 +491,8 @@ { my $entry = shift; - $entry =~ s/\\01\\/\\%02d\\/ig; - $entry =~ s/\\00\\/\\%02d\\/ig; + $entry =~ s/([\/\\])01([\/\\])/$1%02d$2/ig; + $entry =~ s/([\/\\])00([\/\\])/$1%02d$2/ig; #print "create_localise_entry_from_resource: $source\n"; return $entry; diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/buildrom_plugins/obyparse.pm --- a/imgtools/imaker/buildrom_plugins/obyparse.pm Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/buildrom_plugins/obyparse.pm Wed Jun 30 11:35:58 2010 +0800 @@ -33,87 +33,92 @@ @EXPORT = qw(&obyparse_info &obyparse_init &obyparse_process); } -my $conf = ""; +my $conf; sub obyparse_info() { return({ name => "obyparse", - invocation => "InvocationPoint2", + invocation => "InvocationPoint2", # tmp6.oby initialize => "obyparse::obyparse_init", single => "obyparse::obyparse_process"}); } sub obyparse_init($) { - plugin_init("obyparse.pm", $conf = shift()); + plugin_init(&obyparse_info, $conf = shift(), 0); } sub obyparse_readconffile($$$$$); - +sub obyparse_findincfiles(); +sub obyparse_findspifiles(); sub obyparse_process($) { - plugin_start("obyparse.pm", $conf); + plugin_start(&obyparse_info, $conf); - my $obydata = shift(); - my %targets = (); - my %patchdata = (); - my ($romfiles, $rofs1files, $udebfiles, $urelfiles) = (undef, undef, "", ""); - my $fname = ""; + my ($obydata, $romfiles, $rofs1files, $udebfiles, $urelfiles, $fname) = (shift(), undef, undef, "", "", ""); + my %targets = my %patchdata = (); + + obyparse_findincfiles(); + obyparse_findspifiles(); + plugin_reset(); foreach (@$obydata) { - next if (my $parse = parse_obyline($_)) < 0; + next if !(my $parse = parse_obyline($_)); - if (($parse == 1) && ($gKeyword =~ FILEBITMAPSPECKEYWORD)) { - ($fname = lc($gTarget)) =~ /^(?:.*\\)?(.+?)$/; - my $tname = $1; - $targets{$fname} = $targets{$tname} = [$gLnum - 1, !$gRomid && ($gKeyword =~ ROFSBITMAPFILESPECKEYWORD)]; + if (($parse == 2) && ($gKeyword =~ FILEBITMAPSPECKEYWORD)) { + $targets{$gTgtCmp} = $targets{File::Basename::basename($gTgtCmp)} = [$gLnum - 1, + !$gRomid && ($gKeyword =~ ROFSBITMAPFILESPECKEYWORD) && ($gAttrib !~ /paging_unmovable/i)] + if ($gImgid == $gRomidCmp); + dprint(2, "Removed attribute paging_unmovable: `$_'") + if ($gAttrib =~ /paging_unmovable/i) && (s/\s+paging_unmovable\s*(?=\s|^)//i); next; } next if !/^\s*OBYPARSE_(ROM|ROFS1|UDEB|UREL)\s+(.+?)\s*$/i; (my $rule, $fname) = (uc($1), $2); + $_ = "$gHandlestr $_"; + next if $gRomid && ($gImgid != $gRomidCmp); + + dprint(2, "#$gLnum: `$gLine'"); my $files = ($rule eq "ROM" ? \$romfiles : ($rule eq "ROFS1" ? \$rofs1files : ($rule eq "UDEB" ? \$udebfiles : \$urelfiles))); $$files = "" if !defined($$files); - dprint(2, "#$gLnum: `$gLine'"); if ($fname ne "*") { my $basedir = ""; ($basedir, $fname) = ($1, $2) if $fname =~ /^(.*[\/\\])(.+?)$/; dprint(3, "Found " . obyparse_readconffile($basedir, $fname, $rule, $files, 0) . " entries"); - } - else { + } else { + dprint(3, "Move/change all possible components to $rule"); $$files = ".*"; - dprint(3, "Move/change all possible components to $rule"); } - $_ = "$gHandlestr $_"; } $romfiles = qr/^($romfiles)$/i if defined($romfiles); $rofs1files = qr/^($rofs1files)$/i if defined($rofs1files); ($udebfiles, $urelfiles) = (qr/^($udebfiles)$/i, qr/^($urelfiles)$/i); - ($gLnum, $gRomid) = (0, 0); - my ($rofs1cnt, $udebcnt, $urelcnt, $offset, @torofs1) = (0, 0, 0, 0, ()); + my ($rofs1ofs, $udebcnt, $urelcnt, @torofs1) = (0, 0, 0, ()); + plugin_reset(); foreach (@$obydata) { my $parse = parse_obyline($_); - $offset++ if $gRomid < 2; - next if $parse != 1; + $rofs1ofs++ if ($gRomid < 2); + next if ($parse != 2) || ($gImgid != $gRomidCmp); if ($gKeyword =~ /^patchdata$/i) { - $gSource =~ /^(.+?)(?:@.+)?$/; - $fname = lc($1); + $gSrcCmp =~ /^(.+?)(?:@.+)?$/; + next if !exists($targets{$fname = $1}); $patchdata{$fname} = $targets{$fname}[0] if !exists($patchdata{$fname}); + next if !$targets{$fname}[1]; } - else { - $gTarget =~ /^(?:.*\\)?(.+?)$/; - $fname = $1; + elsif ($gKeyword =~ FILEBITMAPSPECKEYWORD) { + $fname = File::Basename::basename($gTgtCmp); if ($fname =~ $urelfiles && s/(?<=[\/\\])udeb(?=[\/\\])/urel/i) { $urelcnt++; dprint(2, "Changed to UREL: `$_'"); @@ -122,67 +127,105 @@ $udebcnt++; dprint(2, "Changed to UDEB: `$_'"); } - } - - next if $gRomid || !defined($romfiles) && !defined($rofs1files); - - if (($gKeyword =~ ROFSBITMAPFILESPECKEYWORD) || - ($gKeyword =~ /^patchdata$/i) && exists($targets{$fname}) && $targets{$fname}[1]) { + next if !$targets{$gTgtCmp}[1]; } - elsif ($gKeyword =~ /^(?:alias|rename)/i && exists($targets{lc($gSource)}) && $targets{lc($gSource)}[1]) { - $gSource =~ /^(?:.*\\)?(.+?)$/; - $fname = $1; + elsif ($gKeyword =~ DIRECTORYKEYWORD) { + $fname = File::Basename::basename($gTgtCmp); + next if !(exists($targets{$gTgtCmp}) && $targets{$gTgtCmp}[1]) && + !(exists($targets{$fname}) && $targets{$fname}[1]); } - else { - next; - } - if (defined($rofs1files) && ($fname =~ $rofs1files) || defined($romfiles) && ($fname !~ $romfiles)) { - $rofs1cnt++; + else { next } + + if (!$gRomid && (defined($rofs1files) && ($fname =~ $rofs1files) || defined($romfiles) && ($fname !~ $romfiles))) { push(@torofs1, $_); - $_ = "$gHandlestr =>ROFS1 $_"; + $_ = "$gHandlestr $_"; } } - dprint(3, "Moved $rofs1cnt entries to ROFS1") if $rofs1cnt; + dprint(3, "Moved " . scalar(@torofs1) . " entries to ROFS1") if @torofs1; dprint(3, "Changed $udebcnt components to UDEB") if $udebcnt; dprint(3, "Changed $urelcnt components to UREL") if $urelcnt; - dprint(2, "Found " . keys(%patchdata) . " ROM-patched components:") if %patchdata; + dprint(3, "Finding ROM-patched components"); foreach (sort({$a <=> $b} values(%patchdata))) { - ${$obydata}[$_] =~ /^(?:$gHandlestr =>ROFS1 )?(.+)$/; + ${$obydata}[$_] =~ /^(?:$gHandlestr )?(.+)$/; parse_keyline($1); dprint(2, "`$gSource'"); } + dprint(3, "Found " . keys(%patchdata) . " ROM-patched components"); - splice(@$obydata, $offset, 0, @torofs1) if @torofs1; + splice(@$obydata, $rofs1ofs, 0, @torofs1) if @torofs1; plugin_end(); } +sub obyparse_findincfiles() +{ + my ($drive, $indent, $prev, $tmpoby, %files) = + (Cwd::cwd() =~ /^([a-z]:)/i ? $1 : "", -2, "", "$gWorkdir/tmp1.oby", ()); + + dprint(3, "Finding include hierarchy from `$tmpoby'"); + open(FILE, $tmpoby) or dprint(-3, "$gPluginname can't open `$tmpoby'"), return; + + while (my $line = ) { + next if ($line !~ /^#\s+\d+\s+"(.+?)"(?:\s+(\d))?$/); + my ($file, $flag) = ($1, defined($2) ? $2 : 0); + next if ($file =~ /^<.*>$/); + $indent -= 2, $prev = $file, next if ($flag == 2); + next if (!$flag && $file eq $prev || $flag > 1); + $indent += 2 if $flag; + ($prev = $file) =~ /^(.*[\/\\])?(.+?)$/; + (my $dir, $file) = ("", $2); + $dir = abspath(defined($1) ? $1 : "."); + dprint(2, ("." x $indent) . "`$prev' !!!"), next if ($dir eq ""); + $dir =~ s/^$drive|\/$//gi; + $files{lc($file = "$dir/$file")} = 1; + dprint(2, ("." x $indent) . "`$file'"); + } + close(FILE); + dprint(3, "Found " . keys(%files) . " different include files"); +} + +sub obyparse_findspifiles() +{ + my ($spicnt, $tmpoby) = (0, "$gWorkdir/tmp5.oby"); + + dprint(3, "Finding SPI input files from `$tmpoby'"); + open(FILE, $tmpoby) or dprint(-3, "$gPluginname can't open `$tmpoby'"), return; + + while (my $line = ) { + next if (parse_obyline($line) != 2) || ($gKeyword !~ /^spidata/i); + $spicnt++; + dprint(2, "`$gSource'" . ($gKeyword =~ /^spidata$/i ? "" : " ($gKeyword)")); + } + close(FILE); + dprint(3, "Found $spicnt SPI input files"); +} sub obyparse_readconffile($$$$$) { my ($basedir, $file, $type, $files, $indent) = @_; - $file = $basedir . $file; + $file = "$basedir$file"; my $filecnt = 0; - dprint(3, "Reading $type files") if $type; - dprint(3, ("." x $indent) . "`$file'"); + dprint(3, "Reading $type files from $file") if $type; + dprint(2, ("." x $indent) . "`$file'"); - open(FILE, $file) or die("ERROR: Can't open `$file'\n"); + open(FILE, $file) or dprint(3, "Error: $gPluginname can't open $file", 1), die("\n"); + my @files = ; + close(FILE); - foreach my $line () { - if ($line =~ /^\s*#include\s+(.+?)\s*$/i) { + foreach (@files) { + if (/^\s*#include\s+(.+?)\s*$/i) { $filecnt += obyparse_readconffile($basedir, $1, "", $files, $indent + 2); next; } - next if ($line =~ /^\s*$/) || ($line =~ /^\s*(?:#|\/\/|REM\s)/i); + next if (/^\s*$/) || (/^\s*(?:#|\/\/|REM\s)/i); $filecnt++; - (my $fname = $line) =~ s/^\s+|\s+$//g; - $fname =~ s/(.)/{'*' => '.*', '?' => '.', '[' => '[', ']' => ']'}->{$1} || "\Q$1\E"/ge; + (my $fname = $_) =~ s/^\s+|\s+$//g; + $fname =~ s/(.)/{"*" => ".*", "?" => "."}->{$1} || "\Q$1\E"/eg; $$files .= ($$files eq "" ? "" : "|") . $fname; } - close(FILE); return($filecnt); } diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/buildrom_plugins/override.pm --- a/imgtools/imaker/buildrom_plugins/override.pm Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/buildrom_plugins/override.pm Wed Jun 30 11:35:58 2010 +0800 @@ -53,6 +53,7 @@ use strict; use warnings; +use File::Basename; use plugincommon; # OVERRIDE TARGET FOUND OVERRIDE TARGET NOT FOUND @@ -70,31 +71,30 @@ @EXPORT = qw(&override_info &override_init &override_process); } -my $conf = ""; +my $conf; sub override_info { return({ name => "override", - invocation => "InvocationPoint2", + invocation => "InvocationPoint2", # tmp6.oby initialize => "override::override_init", single => "override::override_process"}); } sub override_init { - plugin_init("override.pm", $conf = shift()); + plugin_init(&override_info, $conf = shift(), 0); } sub override_process { - plugin_start("override.pm", $conf); + plugin_start(&override_info, $conf); my $obydata = shift(); my %targets = (); my @overrides = (); my @oconfstack = (REPLACE_WARN); - my @romelemcnt = (0, 0, 0, 0, 0, 0, 0, 0); # Go through all the tmp6.oby (InvocationPoint2) lines and store # normal targets' data to %targets and override targets' data to @overrides @@ -103,34 +103,35 @@ foreach (@{$obydata}) { - my $parse = parse_obyline($_); + next if !(my $parse = parse_obyline($_)); - if ($parse == 2) { - # REM ROM_IMAGE[id] + if (($parse == 2) && ($gKeyword =~ /-?override$/i)) { + # Override entry + $_ = "$gHandlestr $_", next if ($gImgid != $gRomidCmp); dprint(2, "#$gLnum: `$gLine'"); + push(@overrides, [$gLnum - 1, $oconfstack[$#oconfstack]]); + next; + } + if (($parse == 2) && ($gKeyword =~ FILEBITMAPSPECKEYWORD)) { + # Normal file specification entry + $targets{$gTgtCmp} = $targets{File::Basename::basename($gTgtCmp)} = $gLnum - 1 + if ($gImgid == $gRomidCmp); + next; } - elsif (/^\s*OVERRIDE_(?:(END)|(REPLACE\/ADD)|(REPLACE\/SKIP)|(REPLACE\/WARN)|SKIP\/ADD)\s*$/i) { - # Override configuration keyword - if (defined($1)) { - # OVERRIDE_END - pop(@oconfstack); - } else { - # OVERRIDE_REPLACE/ADD|REPLACE/SKIP|REPLACE/WARN|SKIP/ADD - push(@oconfstack, defined($2) ? REPLACE_ADD : (defined($3) ? REPLACE_SKIP : (defined($4) ? REPLACE_WARN : SKIP_ADD))); - } - dprint(2, "#$gLnum: `$gLine'"); - $_ = "$gHandlestr $gLine"; + + next if !/^\s*OVERRIDE_(?:(END)|(REPLACE\/ADD)|(REPLACE\/SKIP)|(REPLACE\/WARN)|SKIP\/ADD)\s*$/i; + + # Override configuration keyword + $_ = "$gHandlestr $_"; + next if $gRomid && ($gImgid != $gRomidCmp); + if (defined($1)) { + # OVERRIDE_END + pop(@oconfstack); + } else { + # OVERRIDE_REPLACE/ADD|REPLACE/SKIP|REPLACE/WARN|SKIP/ADD + push(@oconfstack, defined($2) ? REPLACE_ADD : (defined($3) ? REPLACE_SKIP : (defined($4) ? REPLACE_WARN : SKIP_ADD))); } - elsif ($parse == 1 && $gKeyword =~ /-override/i) { - # Override entry - dprint(2, "#$gLnum: `$gLine'"); - push(@overrides, [$gLnum - 1, $gRomid, $oconfstack[$#oconfstack]]); - } - elsif ($parse == 1 && $gKeyword =~ FILESPECKEYWORD) { - # Normal file specification entry - $targets{lc("$gTarget/$gRomid")} = $gLnum - 1; - $romelemcnt[$gRomid]++; - } + dprint(2, "#$gLnum: `$gLine'"); } # Loop through all overrides and handle them @@ -138,64 +139,50 @@ foreach (@overrides) { - my ($lnum, $romid, $type) = @{$_}; - parse_keyline(${$obydata}[$lnum], 1); - dprint(2, "Handling : `$gLine' ($romid, " . ("REPLACE/ADD", "REPLACE/SKIP", "REPLACE/WARN", "SKIP/ADD")[$type] . ")"); - ${$obydata}[$lnum] = "$gHandlestr $gLine"; - (my $target = $gTarget) =~ s/^"(.*)"$/$1/; + my ($tlnum, $olnum, $type) = (0, @$_); + parse_keyline(${$obydata}[$olnum]); + dprint(2, "Handling : `$gLine' (" . ("REPLACE/ADD", "REPLACE/SKIP", "REPLACE/WARN", "SKIP/ADD")[$type] . ")"); + ${$obydata}[$olnum] = "$gHandlestr ${$obydata}[$olnum]"; - if (exists($targets{lc("$target/$romid")})) { + if (defined($tlnum = $targets{$gTgtCmp}) || defined($tlnum = $targets{File::Basename::basename($gTgtCmp)})) { # Override target found - my ($line, $keyword, $source, $attrib) = ($gLine, $gKeyword, $gSource, $gAttrib); - parse_keyline(${$obydata}[$lnum = $targets{lc("$target/$romid")}], 1); - dprint(2, "Target : `$gLine' ($romid, #" . ($lnum + 1) . ")"); + parse_keyline(${$obydata}[$tlnum]); + dprint(2, "Target : `$gLine' (#" . ($tlnum + 1) . ")"); if ($type == SKIP_ADD) { dprint(2, "Do nothing : Target found and override type SKIP"); } - elsif ($source =~ /^"?empty"?$/i) { + elsif ($source =~ /^empty$/i) { # Empty keyword -> comment line out - ${$obydata}[$lnum] = "$gHandlestr $gLine"; - dprint(1, "Remove ROM_IMAGE[$romid] `$gLine' due to `$line'"); - dprint(2, "Replace with: `${$obydata}[$lnum]' (Override source EMPTY)"); + ${$obydata}[$tlnum] = "$gHandlestr ${$obydata}[$tlnum]"; + dprint(1, "Remove `$gLine' due to `$line'"); + dprint(2, "Replace with: `${$obydata}[$tlnum]' (Override source EMPTY)"); } else { # Replace existing line with new line - $keyword =~ s/-override//i; + $keyword =~ s/-?override$//i; $attrib = ($attrib eq "" ? $gAttrib : ($attrib =~ /^\s*empty$/i ? "" : $attrib)); - $line = ${$obydata}[$lnum] = "$keyword=$source $gTarget$attrib\n"; - dprint(1, "Replace ROM_IMAGE[$romid] `$gLine' with `$line'"); + $line = ${$obydata}[$tlnum] = ($keyword ne "" ? $keyword : $gKeyword) . + ($source =~ /\s/ ? "=\"$source\"" : "=$source") . " " . + ($gTarget =~ /\s/ ? "\"$gTarget\"" : $gTarget) . "$attrib\n"; + dprint(1, "Replace `$gLine' with `$line'"); dprint(2, "Replace with: `$line'"); } } - else { - # Override target not found - - if (!$romelemcnt[$romid] && $type != REPLACE_ADD && $type != SKIP_ADD) { - # Ignore override non-XXX/ADD targets on empty ROM_IMAGE sections - dprint(2, "Do nothing : Target not found, override target's ROM_IMAGE[$romid] section is empty"); - next; - } - # Check if override target exists in different ROM section - my $warn = ""; - foreach my $tromid (0 .. 7) { - $warn = "Override target `$target' found from ROM_IMAGE[$tromid] while override is for ROM_IMAGE[$romid]", last - if exists($targets{lc("$target/$tromid")}); - } + else { # Override target not found if ($type == REPLACE_SKIP) { - dprint(2, "Do nothing : Target not found " . ($warn ? "from ROM_IMAGE[$romid] " : "") . "and override type SKIP"); + dprint(2, "Do nothing : Target not found and override type SKIP"); } elsif ($type == REPLACE_WARN) { - dprint(-3, $warn ? "$warn, ignoring `$target'" : "Ignoring override target `$target', target not found"); + dprint(-3, "Ignoring override target `$gTarget', target not found"); dprint(2, "Do nothing : Target not found and override type WARN"); } else { # OVERRIDE_XXX/ADD - (my $line = $gLine) =~ s/^(\S+?)-override/$1/i; - ${$obydata}[$lnum] = $line; - dprint(-3, $warn) if $warn; - dprint(1, "Add ROM_IMAGE[$romid] `$line' from `$gLine'"); + (my $line = $gLine) =~ s/^(\S*?)-?override/$1/i; + $line = ${$obydata}[$olnum] = ($1 ne "" ? "" : "data") . $line; + dprint(1, "Add `$line' from `$gLine'"); dprint(2, "Add new : `$line' (Target not found, override type ADD)"); } } diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/buildrom_plugins/plugincommon.pm --- a/imgtools/imaker/buildrom_plugins/plugincommon.pm Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/buildrom_plugins/plugincommon.pm Wed Jun 30 11:35:58 2010 +0800 @@ -21,6 +21,8 @@ use strict; use warnings; +use Cwd; +use File::Basename; use constant FILESPECSTATEMENT => qr/^\s*(\S+?)\s*[=\s]\s*(?:"(.+?)"|(\S+))\s+(?:"(.+?)"|(\S+))(\s+.+?)?\s*$/; @@ -34,6 +36,10 @@ use constant ROFSBITMAPFILESPECKEYWORD => qr/^(?:data|file|filecompress|fileuncompress|BITMAP|AUTO-BITMAP|COMPRESSED-BITMAP)/i; +use constant HIDESTATEMENT => qr/^\s*(hide\S*?)\s*[=\s]\s*(?:"(.+?)"|(\S+))()\s*$/; + +use constant DIRECTORYKEYWORD => qr/^(?:alias|hide|rename)/i; + BEGIN { @@ -43,38 +49,62 @@ @ISA = qw(Exporter); @EXPORT = qw( FILESPECSTATEMENT FILESPECKEYWORD FILEBITMAPSPECKEYWORD ROFSFILESPECKEYWORD ROFSBITMAPFILESPECKEYWORD - &dprint &plugin_init &plugin_start &plugin_end &parse_keyline &parse_obyline + HIDESTATEMENT DIRECTORYKEYWORD + &abspath &dprint &plugin_reset &plugin_init &plugin_start &plugin_end &parse_keyline &parse_obyline &is_entry &get_type_from_entry &get_source_from_entry &get_target_from_entry - $gPluginname $gLogfile $gDebug $gHandlestr - $gLine $gLnum $gRomid $gKeyword $gSource $gTarget $gAttrib); + $gPluginname $gImgid $gLogfile $gWorkdir $gDebug $gFeatvar $gHandlestr + $gLine $gLnum $gRomid $gRomidCmp $gKeyword $gSource $gTarget $gAttrib $gSrcCmp $gTgtCmp); $| = 1; } -our ($gPluginname, $gLogfile, $gDebug, $gHandlestr) = ("", "", "", 0); -our ($gLine, $gLnum, $gRomid, $gKeyword, $gSource, $gTarget, $gAttrib) = ("", 0, 0, "", "", "", ""); +our ($gPluginname, $gImgid, $gLogfile, $gWorkdir, $gDebug, $gFeatvar, $gHandlestr); +our ($gLine, $gLnum, $gRomid, $gRomidCmp, $gKeyword, $gSource, $gTarget, $gAttrib, $gSrcCmp, $gTgtCmp); my $duration = 0; -sub dprint($$) +sub abspath($) { - my ($log, $str) = @_; - $str =~ s/\n//g; - $str = ($log < 0 ? "Warning: " : "") . "$str\n"; + my $path = shift(); + eval { local $SIG{__DIE__}; $path = Cwd::abs_path($path) }; + return($path); +} + +sub dprint($$;$) +{ + my ($log, $str, $nonl) = @_; + ($str = ($log < 0 ? "Warning: " : "") . $str) =~ s/\n//g; + $str .= "\n" if !$nonl; $log = abs($log); print($str) if (($log == 1) && !$gDebug) || (($log == 2) && $gDebug) || ($log > 2); print(LOG $str) if $gLogfile && ($log > 1); } -sub plugin_init($$;$) +sub plugin_reset() +{ + ($gLine, $gLnum, $gRomid, $gRomidCmp, $gKeyword, $gSource, $gTarget, $gAttrib, $gSrcCmp, $gTgtCmp) = + ("", 0, 0, 0, "", "", "", "", "", ""); +} + +sub plugin_init($$$) { - ($gPluginname, $gDebug, my $start) = @_; - $gDebug = "" if !defined($gDebug); - $gDebug =~ s/^(?:(.*?);|(.*))//; - $gLogfile = (defined($1) ? $1 : $2); - my $warn = ""; + my ($pluginfo, $opt, $start) = @_; + $gPluginname = "$pluginfo->{name}.pm"; + plugin_reset(); + ($gImgid, $gLogfile, $gWorkdir, $gDebug, $gFeatvar, my $warn) = (0, "", undef, 0, "", ""); + foreach (split(/;+/, $opt)) { + if (s/^\s*-i//i) { $gImgid = (/^CORE$/ ? 0 : (/^ROFS(\d)$/ ? $1 : -1)) } + elsif (s/^\s*-l//i) { $gLogfile = abspath(File::Basename::dirname($_)) . "/" . File::Basename::basename($_) } + elsif (s/^\s*-w//i) { $gWorkdir = abspath($_) } + elsif (s/^\s*-d//i) { $gDebug = ($_ ? 1 : 0) } + elsif (s/^\s*-f//i) { $gFeatvar = $_ } + else { $warn .= ", `$_'" } + } + $warn = "Unknown parameter(s):$warn." if ($warn =~ s/^,//); (open(LOG, ">>$gLogfile") or - ($warn = "Can't write to `$gLogfile'.", $gLogfile = "")) if $gLogfile; + (($warn .= ($warn ? " " : "") . "Can't write to `$gLogfile'."), $gLogfile = "")) if $gLogfile; dprint(3, "$gPluginname: " . ($start ? "-" x (77 - length($gPluginname)) : - "Initializing; logfile = `$gLogfile', debug = " . ($gDebug ? 1 : 0))); + "Initializing; $pluginfo->{invocation}, image id = " . ($gImgid < 0 ? "d" : $gImgid) . + ", logfile = `$gLogfile'" . (defined($gWorkdir) ? ", workdir = `$gWorkdir'" : "") . + ", debug = $gDebug" . ($gFeatvar ne "" ? ", feature variant = `$gFeatvar'" : ""))); dprint(-3, $warn) if $warn; close(LOG) if !$start; } @@ -83,7 +113,7 @@ { $duration = time(); plugin_init(shift(), shift(), 1); - ($gHandlestr, $gLnum, $gRomid) = ("REM handled $gPluginname:", 0, 0); + $gHandlestr = "REM handled $gPluginname:"; } sub plugin_end() @@ -93,27 +123,29 @@ close(LOG); } -sub get_keyline($) +sub parse_keyline(;$) { - my $quote = shift(); + ($gLine = shift()) =~ s/^\s+|\s+$//g if defined($_[0]); + return(-1) if ($gLine !~ FILESPECSTATEMENT) && ($gLine !~ HIDESTATEMENT); ($gKeyword, $gSource, $gTarget, $gAttrib) = - ($1, defined($2) ? ($quote ? "\"$2\"" : $2) : $3, defined($4) ? ($quote ? "\"$4\"" : $4) : $5, defined($6) ? $6 : ""); + ($1, defined($2) ? $2 : $3, defined($4) ? $4 : $5, defined($6) ? $6 : ""); + ($gSrcCmp, $gTgtCmp) = (lc($gSource), lc($gTarget)); + ($gTgtCmp = ($gKeyword =~ DIRECTORYKEYWORD ? $gSrcCmp : $gTgtCmp)) =~ tr/\\/\//; + $gTgtCmp =~ s/^\/+//; + return(2); } -sub parse_keyline($;$) -{ - ($gLine = shift()) =~ s/^\s+|\s+$//g; - get_keyline(shift()), return(1) if $gLine =~ FILESPECSTATEMENT; - return(0); -} - -sub parse_obyline($;$) +sub parse_obyline($) { ($gLine = shift()) =~ s/^\s+|\s+$//g; $gLnum++; - $gRomid = $1, return(2) if $gLine =~ /^REM\s+ROM_IMAGE\[(\d+)\]/i; - return(-1) if $gLine eq "" || $gLine =~ /^(?:#|REM\s)/i; - return(parse_keyline($gLine, shift())); + if ($gLine =~ /^REM\s+(ROM|DATA)_IMAGE\[(\d+)\]/i) { + $gRomid = $2; + $gRomidCmp = ($gImgid >= 0 ? ($1 eq "ROM" ? ($2 != 1 ? $2 : 0) : 99) : ($1 eq "DATA" ? -$2 - 1 : 99)); + return(1); + } + return(0) if ($gLine =~ /^(?:#|REM\s)/i) || ($gLine eq ""); + return(parse_keyline()); } diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/buildrom_plugins/s60ibymacros.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imaker/buildrom_plugins/s60ibymacros.pm Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,123 @@ +# ============================================================================ +# Name : s60ibymacros.pm +# Part of : build_RnD +# Description : S60 specific IBY file macro handling +# Version : %version: 1 % +# +# Copyright © 2006 Nokia. All rights reserved. +# This material, including documentation and any related computer +# programs, is protected by copyright controlled by Nokia. All +# rights are reserved. Copying, including reproducing, storing, +# adapting or translating, any or all of this material requires the +# prior written consent of Nokia. This material also contains +# confidential information which may not be disclosed to others +# without the prior written consent of Nokia. +# ============================================================================ +# +# 07.08.2006 Juha Ristimäki +# Initial version. +# + +package s60ibymacros; + +BEGIN + { + use Exporter (); + our ( $VERSION, @ISA, @EXPORT ); + # set the version for version checking + $VERSION = 1.00; + + @ISA = qw( Exporter ); + @EXPORT = qw( &s60ibymacros_info &DoS60IbyModifications ); + } + +my %s60ibymacros_infostruct = + ( + name => "s60ibymacros", + invocation => "InvocationPoint1", + single => "s60ibymacros::DoS60IbyModifications" + ); + +my @newobydata; + +sub s60ibymacros_info + { + return \%s60ibymacros_infostruct; + } + +sub DoS60IbyModifications + { + my $obydata = shift; + + undef @newobydata; + foreach $line (@{$obydata}) + { + if ($line =~ /^\s*REM/i) + { + # Ignore REM statements, to avoid processing "REM __SCALABLE_IMAGE( ... )" + push @newobydata, $line; + } + elsif( ! ( HandleIconMacros($line) || HandleCenrepMacros($line) ) ) + { + push @newobydata, $line; + } + } + @{$obydata} = @newobydata; + } + +sub HandleCenrepMacros + { + my $line = shift; + if ( $line =~ m/^.*__CENREP_TXT_FILES\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/i ) + # __CENREP_TXT_FILES(dataz_, source dir, target dir) + { + my $sourcepath="$1\\$2"; + my $targetpath=$3; + my $s60extras_export_list_filename = "$sourcepath"."\\s60extras_export_list.txt"; + + open(DH, $s60extras_export_list_filename); + my @dlist = ; + chop @dlist; + close(DH); + + my $cenreptxtfile; + foreach $cenreptxtfile (@dlist) + { + if ($cenreptxtfile =~ /^\S+\.txt/) + { + push @newobydata, "data=$sourcepath\\$cenreptxtfile $targetpath\\$cenreptxtfile\n"; + } + } + return 1; + } + } + +sub HandleIconMacros + { + my $line = shift; + if ( $line =~ m/^.*__SCALABLE_IMAGE\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/i ) + # __SCALABLE_IMAGE(emulator directory, file rom dir, dataz_, resource rom dir, + # filename, resource filename) + { + + my $sourcepath="$1\\$2"; + my $targetpath=$3; + my $filename=$4; + + if( -e "$sourcepath\\$filename.mbm" ) + { + push @newobydata, "AUTO-BITMAP=$sourcepath\\$filename.mbm $targetpath\\$filename.mbm\n"; + } + if( -e "$sourcepath\\$filename.mif" ) + { + push @newobydata, "data=$sourcepath\\$filename.mif $targetpath\\$filename.mif\n"; + } + elsif( ! -e "$sourcepath\\$filename.mbm ") + { + print STDERR "* Invalid image file name: $sourcepath\\$filename.mbm or .mif\n"; + } + return 1; + } + } + +1; # Return a true value from the file \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/buildrom_plugins/stubsischeck.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imaker/buildrom_plugins/stubsischeck.pm Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,101 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Check included sis/sisx file validity. +# + + + +package stubsischeck; + +use strict; +use warnings; +use File::Basename; +use plugincommon; + +BEGIN +{ + use Exporter(); + our($VERSION, @ISA, @EXPORT); + $VERSION = 1.00; + @ISA = qw(Exporter); + @EXPORT = qw(&stubsischeck_info &stubsischeck_init &stubsischeck_process); +} + +my $conf; + +sub stubsischeck_info() +{ + return({ + name => "stubsischeck", + invocation => "InvocationPoint3", # tmp9.oby + initialize => "stubsischeck::stubsischeck_init", + single => "stubsischeck::stubsischeck_process"}); +} + +sub stubsischeck_init($) +{ + plugin_init(&stubsischeck_info, $conf = shift(), 0); +} + +sub stubsischeck_process($) +{ + plugin_start(&stubsischeck_info, $conf); + my $obydata = shift(); + my %uids = (); + + dprint(3, "Finding and checking stub sis files..."); + + foreach (@{$obydata}) { + next if (parse_obyline($_) != 2) || ($gImgid != $gRomidCmp) || + ($gKeyword !~ FILESPECKEYWORD) || ($gSrcCmp !~ /\.sisx?$/) || !-e($gSource); + + my ($basename, $uiddata) = (File::Basename::basename($gSrcCmp), ""); + dprint(2, "Checking `$gSource'", 1); + + # Find out whether or not this is stub sis file + open(FILE, $gSource) or + dprint(2, ""), dprint(-3, "$gPluginname can't open `$gSource'"), next; + binmode(FILE); + sysread(FILE, $uiddata, 0x1C); + close(FILE); + + my $uid = unpack("V", substr($uiddata, 0x00, 4)); + if ($uid == 0x0000000D) { + my $puid = sprintf("0x%08X", unpack("V", substr($uiddata, 0x18, 4))); + dprint(2, ", pUID: $puid"); + + # Quick-and-dirty way to check duplicate UIDs + if (exists($uids{$puid}) && ($basename ne $uids{$puid})) { + dprint(3, "Error: `$gSource': Duplicate pUID $puid, see `$uids{$puid}'"); + } else { + $uids{$puid} = $basename; + } + } elsif ($uid == 0x10201A7A) { + dprint(2, ": Normal (non-stub) sis file"); + } else { + dprint(2, ""); + if (unpack("V", substr($uiddata, 0x08, 4)) == 0x10000419) { # UID3 + dprint(-3, "`$gSource': Legacy (pre Symbian 9.x) sis file"); + } else { + dprint(3, "Error: `$gSource': Sis file with unknown UID ($uid)"); + } + } + } + plugin_end(); +} + +1; + +__END__ # OF STUBSISCHECK.PM diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/config/example_image_conf_naming.mk --- a/imgtools/imaker/config/example_image_conf_naming.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/config/example_image_conf_naming.mk Wed Jun 30 11:35:58 2010 +0800 @@ -21,4 +21,4 @@ ROFS2_DIR = $(WORKDIR)/$(TYPE)/langpack/$(LANGPACK_NAME) ROFS2_NAME = $(PRODUCT_TYPE).$(BUILD_NUMBER)_$(LANGPACK_ID)_$(TYPE) -LANGPACK_SWVERINFO = $(CORE_VERSION).$(LANGPACK_ID)\\\n$(DAY)-$(MONTH)-$(YEAR2)\\\n(c) $(PRODUCT_MANUFACT) +LANGPACK_SWVERINFO = $(CORE_VERSION).$(LANGPACK_ID)\n$(DAY)-$(MONTH)-$(YEAR2)\n(c) $(PRODUCT_MANUFACT) diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/doc/S60_iMaker_User_Guide.pdf Binary file imgtools/imaker/doc/S60_iMaker_User_Guide.pdf has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/doc/iMaker_User_Guide.pdf Binary file imgtools/imaker/doc/iMaker_User_Guide.pdf has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/group/bld.inf --- a/imgtools/imaker/group/bld.inf Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -18,26 +18,29 @@ PRJ_EXPORTS +../src/imaker +/tools/ // ../src/imaker.cmd +/tools/ // ../src/imaker.mk +/tools/rom/imaker/ // ../src/imaker.pl +/tools/rom/imaker/ // -../src/imaker.pm +/tools/rom/imaker/ // -../src/imaker_public.mk +/tools/rom/imaker/ // -../src/imaker_version.mk +/tools/rom/imaker/ // - ../src/imaker_core.mk +/tools/rom/imaker/ // +../src/imaker_emmc.mk +/tools/rom/imaker/ // +../src/imaker_fat.mk +/tools/rom/imaker/ // ../src/imaker_help.mk +/tools/rom/imaker/ // ../src/imaker_image.mk +/tools/rom/imaker/ // +../src/imaker_memcard.mk +/tools/rom/imaker/ // ../src/imaker_minienv.mk +/tools/rom/imaker/ // ../src/imaker_odp.mk +/tools/rom/imaker/ // +../src/imaker_rofs.mk +/tools/rom/imaker/ // ../src/imaker_rofs2.mk +/tools/rom/imaker/ // ../src/imaker_rofs3.mk +/tools/rom/imaker/ // ../src/imaker_rofs4.mk +/tools/rom/imaker/ // +../src/imaker_smr.mk +/tools/rom/imaker/ // ../src/imaker_tools.mk +/tools/rom/imaker/ // ../src/imaker_uda.mk +/tools/rom/imaker/ // ../src/imaker_variant.mk +/tools/rom/imaker/ // +../src/imaker_version.mk +/tools/rom/imaker/ // -// GNU make port to mingw32 (http://www.mingw.org/) +// GNU make port to mingw32 (http://sourceforge.net/projects/mingw/files/ -> GNU Make) ../bin/mingw_make.exe +/tools/rom/imaker/ // // Buildrom plugins diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imaker/src/imaker Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: iMaker wrapper for Linux (Bash) +# + + +export IMAKER_CMDARG= +for arg in "$@"; do + if [ -z "$IMAKER_CMDARG" ]; then IMAKER_CMDARG="'$arg'" + else IMAKER_CMDARG="$IMAKER_CMDARG '$arg'"; fi +done +if [ -z "$IMAKER_DIR" ]; then + export IMAKER_DIR="`dirname "$0"`/rom/imaker" + if [ -e "`dirname "$0"`/imaker.pl" ]; then IMAKER_DIR="`dirname "$0"`"; fi +fi +export IMAKER_TOOL="$0" + +if [ -z "$PERL" ]; then export PERL="perl"; fi +$PERL -x "$IMAKER_DIR/imaker.pl" +IMAKER_ERROR=$? + +if [ $IMAKER_ERROR -ne 0 ]; then + $PERL -v >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Perl is not properly installed! Environment variable PERL can be used to set the Perl exe." + fi +fi + +exit $IMAKER_ERROR + +# END OF IMAKER diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker.cmd --- a/imgtools/imaker/src/imaker.cmd Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker.cmd Wed Jun 30 11:35:58 2010 +0800 @@ -1,39 +1,40 @@ -@echo off -rem -rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -rem All rights reserved. -rem This component and the accompanying materials are made available -rem under the terms of the License "Eclipse Public License v1.0" -rem which accompanies this distribution, and is available -rem at the URL "http://www.eclipse.org/legal/epl-v10.html". -rem -rem Initial Contributors: -rem Nokia Corporation - initial contribution. -rem -rem Contributors: -rem -rem Description: iMaker wrapper for Windows -rem +@rem +@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +@rem All rights reserved. +@rem This component and the accompanying materials are made available +@rem under the terms of the License "Eclipse Public License v1.0" +@rem which accompanies this distribution, and is available +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +@rem +@rem Initial Contributors: +@rem Nokia Corporation - initial contribution. +@rem +@rem Contributors: +@rem +@rem Description: iMaker wrapper for Windows +@rem +@echo off setlocal -set MAKE= set IMAKER_CMDARG=%* -if "%EPOCROOT%"=="" set EPOCROOT=\ -if "%CONFIGROOT%"=="" set CONFIGROOT=%EPOCROOT%epoc32\rom\config -if "%ITOOL_DIR%"=="" set ITOOL_DIR=%EPOCROOT%epoc32\tools\rom -if "%IMAKER_DIR%"=="" set IMAKER_DIR=%ITOOL_DIR%\imaker -if "%IMAKER_MAKE%"=="" set IMAKER_MAKE=%IMAKER_DIR%\mingw_make.exe -if "%IMAKER_MAKESHELL%"=="" set IMAKER_MAKESHELL=%COMSPEC% -if "%IMAKER_MAKESHELL%"=="" set IMAKER_MAKESHELL=cmd.exe -if "%IMAKER_CYGWIN%"=="" set IMAKER_CYGWIN=0 -if "%PERL%"=="" set PERL=perl +if "%IMAKER_DIR%"=="" ( + set IMAKER_DIR=%~dp0rom\imaker + if exist %~dp0imaker.pl set IMAKER_DIR=%~dp0 +) +set IMAKER_TOOL=%~f0 + +if "%PERL%"=="" set PERL=perl call %PERL% -x %IMAKER_DIR%\imaker.pl set IMAKER_ERROR=%errorlevel% -if %IMAKER_ERROR% geq 1 ( + +if %IMAKER_ERROR% neq 0 ( call %PERL% -v >nul 2>&1 - if errorlevel 1 echo Perl is not properly installed! Environment variable PERL can be used to set the Perl exe. + if errorlevel 1 ( + echo Perl is not properly installed! Environment variable PERL can be used to set the Perl exe. + ) ) + if 0%IMAKER_EXITSHELL% equ 0 exit /b %IMAKER_ERROR% exit %IMAKER_ERROR% endlocal diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker.mk --- a/imgtools/imaker/src/imaker.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker.mk Wed Jun 30 11:35:58 2010 +0800 @@ -32,8 +32,6 @@ empty := space := $(empty) # $(space) := $(space) -squot := '\'' -' := '\'' \t := $(empty) # Tabulator! # Newline @@ -71,10 +69,11 @@ firstwords = $(if $2,$(wordlist 1,$(words $(wordlist $1,$(words $2),$2)),$2),$(wordlist 1,$(words $(wordlist 2,$(words $1),$1)),$1)) restwords = $(if $2,$(wordlist $1,$(words $2),$2),$(wordlist 2,$(words $1),$1)) restelems = $(call restoreelem,$(subst $( ),|,$(call restwords,$1,$(call getwords,$2)))) +findword = $(and $1,$2,$(if $(filter $1,$(word 1,$2)),$(words $3 +),$(call findword,$1,$(call restwords,$2),$3 +))) substm = $(eval __i_str := $3)$(strip $(foreach w,$1,$(eval __i_str := $(subst $w,$2,$(__i_str)))))$(__i_str) substs = $(subst $(ichar)\,$2,$(subst $1,$2,$(subst $2,$(ichar)\,$3))) -quote = $(call substs,\t,\\\t,$(call substs,\n,\\\n,$1)) -quoteval = $(subst \#,\\\#,$(subst $$,$$$$,$1)) +quote = $(call substs,\t,\\t,$(call substs,\n,\\n,$1)) +quoteval = $(subst \#,\\#,$(subst $$,$$$$,$1)) sstrip = $(subst $( ),,$(strip $1)) strlen = $(call _str2chars,$1)$(words $(__i_str)) @@ -84,43 +83,44 @@ $(foreach c,$(charset)$(ichar),$(eval __i_str := $(subst $c,$c ,$(__i_str))))) tr =\ - $(strip $(eval __i_tr := $3)\ - $(foreach c,\ - $(join $(addsuffix :,$1),$2),\ - $(eval __i_tr := $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),$(__i_tr))))$(__i_tr)) + $(strip $(eval __i_tr := $(subst $( ),$(ichar),$3))\ + $(foreach c,$(join $(addsuffix :,$1),$2),\ + $(eval __i_tr := $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),$(__i_tr)))))$(subst $(ichar),$( ),$(__i_tr)) -pquote = q$(pchar)$1$(pchar) -peval = @PEVAL{$(call substs,|,\|,$1)}LAVEP@ -phex = $(call peval,sprintf(q(%0$(if $2,$2,8)X),$(subst 0x0x,0x,$1))) -pabs2rel = $(call peval,GetRelFname($(call pquote,$1$), $(call pquote,$2))) -pfilesize = $(call peval,-s $(call pquote,$1) || 0) -prepeat = $(call peval,$(call pquote,$2) x ($1)) -pstr2xml = $(call peval,Str2Xml($(call pquote,$1))) -pmatch = $(call peval,$(call pquote,$1) =~ m$(pchar)$2$(pchar)m $(if $3,$3,&& $$1 || q(???))) -pgrep = $(call peval,\ +pquote = q$(pchar)$1$(pchar) +peval = @PEVAL{$(call substs,|,\|,$1)}LAVEP@ +phex = $(call peval,Int2Hex($(subst 0x0x,0x,$1),$2)) +pfilesize = $(call peval,-s $(call pquote,$1) || 0) +prepeat = $(call peval,$(call pquote,$2) x ($1)) +pstr2xml = $(call peval,Str2Xml(Quote($(call pquote,$1)))) +pmatch = $(call peval,$(call pquote,$1) =~ m$(pchar)$(subst \\,\,$2)$(pchar)m $(if $3,$3,&& $$1 || q(???))) +pgrep = $(call peval,\ $(eval __i_notfound := $(call pquote,$(if $4,$4,???)))\ open(F, $(call pquote,$1)) or return($(__i_notfound));\ $$_ = $(if $2,Uni2Ascii)(join(q(), ));\ $$_ = Quote($(if $3,m$(pchar)$3$(pchar)m ? $$1 : $(__i_notfound),$$_));\ - s/\n/\\\n/g; s/\t/\\\t/g;\ close(F); return($$_)) -getlastdir = $(foreach file,$1,$(notdir $(patsubst %/,%,$(file)))) -upddrive = $(if $2,$2,$(EPOCDRIVE))$(if $(filter %:,$(call substr,1,2,$1)),$(call substr,3,,$1),$1) -dir2inc = $(foreach dir,$1,-I$(call upddrive,$(dir))) -findfile = $(foreach file,$1,$(eval __i_ffile := $(call _findfile,$(addsuffix /$(file),$2)))$(if $(__i_ffile),$(__i_ffile),$(file))) -_findfile = $(if $1,$(eval __i_ffile := $(wildcard $(word 1,$1)))$(if $(__i_ffile),$(__i_ffile),$(call _findfile,$(call restwords,$1)))) +getlastdir = $(foreach file,$1,$(notdir $(patsubst %/,%,$(file)))) +upddrive = $(if $2,$2,$(EPOCDRIVE))$(if $(filter %:,$(call substr,1,2,$1)),$(call substr,3,,$1),$1) +updoutdrive = $(call upddrive,$1,$(OUTDRIVE)) +dir2inc = $(foreach dir,$1,-I$(call upddrive,$(dir))) +findfile = $(foreach file,$1,$(eval __i_ffile := $(call _findfile,$(addsuffix /$(file),$(if $2,$2,$(FEATVAR_IDIR)))))$(if $(__i_ffile),$(__i_ffile),$(if $3,,$(file)))) +_findfile = $(if $1,$(eval __i_ffile := $(wildcard $(word 1,$1)))$(if $(__i_ffile),$(__i_ffile),$(call _findfile,$(call restwords,$1)))) +isabspath = $(if $(filter / \,$(if $(filter %:,$(call substr,1,2,$1)),$(call substr,3,3,$1),$(call substr,1,1,$1))),$1) +includechk = $(foreach file,$(subst \ ,$(ichar),$1),\ + $(if $(wildcard $(subst $(ichar),\ ,$(file))),$(eval include $(subst $(ichar),\ ,$(file))),\ + $(error File `$(subst $(ichar), ,$(file))' not found.$(\n)MAKEFILE_LIST =$(MAKEFILE_LIST)))) filterwcard = $(shell $(PERL) -Xe '\ (my $$re = q$(ichar)$1$(ichar)) =~ s/(.)/{q(*)=>q(.*),q(?)=>q(.),q([)=>q([),q(])=>q(])}->{$$1} || qq(\Q$$1\E)/ge;\ print(map(qq( $$_), sort({lc($$a) cmp lc($$b)} grep(/^$$re$$/, split(/\s+/, q$(ichar)$2$(ichar))))))') -cppdef2var =\ - $(if $(wildcard $1),\ - $(eval __i_def2var := $(shell $(PERL) -Xe '\ - print(join(q(|), map(/^\s*\#define\s+(\S+)\s*(.*?)\s*$$/ ? qq($$1?=) . ($$2 eq q() ? 1 : $$2) : (),\ - sort({lc($$a) cmp lc($$b)} qx$(pchar)$(CPP) -nostdinc -undef -dM $(call dir2inc,$2) $(call upddrive,$1)$(pchar)))))'))\ - $(foreach assign,$(call getwords,$(__i_def2var)),$(eval $(call restoreelem,$(assign)))),\ +cppdef2var = $(if $(wildcard $1),\ + $(foreach assign,$(call getwords,$(shell $(CPP) -nostdinc -undef -dM $(call dir2inc,$2) $(call upddrive,$1) |\ + $(PERL) -Xne $(call iif,$(USE_UNIX),',")print(qq($$1?=) . ($$2 eq q() ? 1 : $$2) . q(|))\ + if /^\s*\#define\s+($(or $(call sstrip,$3),\S+))\s*(.*?)\s*$$/$(call iif,$(USE_UNIX),',"))),\ + $(eval $(call restoreelem,$(assign)))),\ $(eval include $1)) mac2cppdef = $(foreach def,$1,$(if\ @@ -128,8 +128,14 @@ $(\n)$(if $(filter -D%,$(def)),\#undef $(word 1,$(__i_def))$(\n)\#define,define ) $(word 1,$(__i_def)) $(word 2,$(__i_def)),\ $(if $(filter -U%,$(def)),$(\n)\#undef $(patsubst -U%,%,$(def))))) -EPOCDRIVE := $(eval EPOCDRIVE := $(call substr,1,2,$(CURDIR)))$(if $(filter %:,$(EPOCDRIVE)),$(EPOCDRIVE)) -EPOC32 := $(patsubst %/,%,$(subst \,/,$(EPOCROOT)))/epoc32 +USE_UNIX := $(if $(findstring cmd.exe,$(call lcase,$(SHELL)))$(findstring mingw,$(call lcase,$(MAKE))),0,1) +DONOTHING := $(call iif,$(USE_UNIX),\#,rem) +NULL := $(call iif,$(USE_UNIX),/dev/null,nul) +PATHSEPCHAR := $(call iif,$(USE_UNIX),:,;) +CURDIR := $(CURDIR:/=/.) +EPOCDRIVE := $(or $(filter %:,$(call substr,1,2,$(EPOCROOT))),$(filter %:,$(call substr,1,2,$(CURDIR)))) +EPOC_ROOT := $(patsubst %/,%,$(subst \,/,$(if $(filter %:,$(call substr,1,2,$(EPOCROOT))),,$(EPOCDRIVE))$(EPOCROOT))) +EPOC32 := $(EPOC_ROOT)/epoc32 E32ROM := $(EPOC32)/rom E32ROMCFG := $(E32ROM)/config E32ROMINC := $(E32ROM)/include @@ -138,18 +144,15 @@ E32INCCFG := $(E32INC)/config E32TOOLS := $(EPOC32)/tools E32GCCBIN := $(EPOC32)/gcc/bin - -ITOOL_DIR ?= $(E32TOOLS)/rom -ITOOL_PATH := -IMAKER_DIR ?= $(ITOOL_DIR)/imaker -IMAKER_TOOL := $(IMAKER_DIR)/imaker.pl +E32DATA := $(EPOC32)/data +E32DATAZ := $(E32DATA)/z -CPP ?= $(if $(wildcard $(E32TOOLS)/scpp.exe),$(E32TOOLS)/scpp.exe,cpp) -PERL ?= perl -PYTHON ?= python -USE_UNIX := $(if $(findstring cmd.exe,$(call lcase,$(SHELL)))$(findstring mingw,$(call lcase,$(MAKE))),0,1) -NULL := $(call iif,$(USE_UNIX),/dev/null,nul) -DONOTHING := $(call iif,$(USE_UNIX),\#,rem) +IMAKER_TOOL := $(IMAKER_DIR)/imaker.pl +IMAKER_CONFMK = +IMAKER_DEFAULTMK = $(call findfile,image_conf_default.mk,,1) + +CPP ?= cpp +PYTHON ?= python YEAR := $(call substr,1,4,$(TIMESTAMP)) YEAR2 := $(call substr,3,4,$(TIMESTAMP)) @@ -157,18 +160,33 @@ DAY := $(call substr,7,8,$(TIMESTAMP)) WEEK := $(call substr,15,,$(TIMESTAMP)) -CURDIR := $(call substr,$(call select,$(call substr,1,2,$(CURDIR)),$(EPOCDRIVE),3,1),,$(CURDIR)) -CURDIR := $(CURDIR:/=/.) -USER := $(or $(USERNAME),$(shell $(PERL) -Xe 'print(getlogin())')) +.DEFAULT_GOAL = help +DEFAULT_GOALS = -MAKECMDGOALS ?= $(.DEFAULT_GOAL) -TARGET = $(word 1,$(MAKECMDGOALS)) -TARGETNAME = $(word 1,$(subst -, ,$(TARGET))) -TARGETID = $(subst $( ),_,$(call restwords,$(subst _, ,$(TARGETNAME)))) -TARGETEXT = $(findstring -,$(TARGET))$(subst $( ),-,$(call restwords,$(subst -, ,$(TARGET)))) +TARGET = $(word 1,$(subst [, [,$(MAKECMDGOALS))) +TARGETNAME = $(word 1,$(subst -, ,$(TARGET))) +TARGETID = $(subst $( ),_,$(call restwords,$(subst _, ,$(TARGETNAME)))) +TARGETID1 = $(word 2,$(subst _, ,$(TARGETNAME))) +TARGETID2 = $(word 3,$(subst _, ,$(TARGETNAME))) +TARGETID2- = $(subst $( ),_,$(call restwords,3,$(subst _, ,$(TARGETNAME)))) +TARGETID3 = $(word 4,$(subst _, ,$(TARGETNAME))) +TARGETID3- = $(subst $( ),_,$(call restwords,4,$(subst _, ,$(TARGETNAME)))) +TARGETEXT = $(addprefix -,$(subst $( ),-,$(call restwords,$(subst -, ,$(TARGET))))) +TARGETEXT2 = $(word 3,$(subst -, ,$(TARGET))) +TARGETEXT2- = $(addprefix -,$(subst $( ),-,$(call restwords,3,$(subst -, ,$(TARGET))))) +TARGETEXT3 = $(word 4,$(subst -, ,$(TARGET))) +TARGETEXT3- = $(addprefix -,$(subst $( ),-,$(call restwords,4,$(subst -, ,$(TARGET))))) + +TOPTARGET = $(TARGET) +TOPTARGETNAME = $(word 1,$(subst -, ,$(TOPTARGET))) +TOPTARGETID = $(subst $( ),_,$(call restwords,$(subst _, ,$(TOPTARGETNAME)))) +TOPTARGETEXT = $(addprefix -,$(subst $( ),-,$(call restwords,$(subst -, ,$(TOPTARGET))))) + +TARGET_EXPORT = TOPTARGET? IMAGE_TYPE CLEAN = 1 BUILD = 1 +FILTERCMD = KEEPGOING = 0 KEEPTEMP = 0 PRINTCMD = 0 @@ -177,35 +195,38 @@ SKIPPOST = 0 VERBOSE = 1 -CONFIGROOT ?= $(E32ROMCFG) +NAME = imaker +WORKDIR = $(CURDIR) +WORKTMPDIR = $($(or $(addsuffix _,$(IMAGE_TYPE)),WORK)DIR)/temp# To be removed! -LABEL = -NAME = $(PRODUCT_NAME)$(LABEL) -WORKDIR = $(if $(PRODUCT_NAME),$(E32ROMBLD)/$(PRODUCT_NAME),$(CURDIR)) -WORKPREFIX = $(WORKDIR)/$(NAME) -WORKNAME = $(WORKPREFIX) +OUTDIR = $(WORKDIR) +OUTPREFIX = $(OUTDIR)/$(NAME)# Temporary? +OUTDRIVE = $(or $(filter %:,$(call substr,1,2,$(OUTDIR))),$(filter %:,$(call substr,1,2,$(CURDIR)))) +OUTTMPDIR = $($(or $(addsuffix _,$(IMAGE_TYPE)),OUT)DIR)/temp -CLEAN_WORKAREA = del | $(WORKDIR)/* | deldir | $(WORKDIR)/* -ALL.CLEAN.STEPS = $(ALL.IMAGE.STEPS) WORKAREA +ALL.CLEAN.STEPS = $(ALL.IMAGE.STEPS) ############################################################################### # -CMDFILE = $(WORKPREFIX)$(if $(notdir $(WORKPREFIX)),_)$(call substm,* : ?,@,$(TARGET)).icmd -#LOGFILE = $(if $(IMAGE_TYPE),$($(IMAGE_TYPE)_PREFIX)_$(call lcase,$(IMAGE_TYPE))_imaker,$(WORKDIR)/log/$(basename $(notdir $(CMDFILE)))).log -export LOGFILE ?= $(WORKDIR)/log/$(basename $(notdir $(CMDFILE))).log +LOGFILE = $($(or $(addsuffix _,$(IMAGE_TYPE)),WORK)PREFIX)_imaker_$(call substm,* / : ? \,@,$(TARGET)).log BUILD_EMPTY = echo-q | Empty target, nothing to build. -CLEAN_IMAKERPRE = $(CLEAN_IMAKEREVAL) | del | "$(CMDFILE)" "$(IMAKER_VARXML)" BUILD_IMAKERPRE =\ - $(call testnewapi,$(strip $(API_TEST))) |\ - $(if $(filter help% print-%,$(MAKECMDGOALS)),,$(if $(and $(IMAKER_VARXML),$(IMAKER_VARLIST)),\ - write | $(IMAKER_VARXML) | $(call def2str,$(IMAKER_XMLINFO)))) + $(BUILD_TOOLSET) |\ + logfile | "$(LOGFILE)" |\ + filtercmd | $(FILTERCMD) -IMAKER_VARXML = $(if $(IMAGE_TYPE),$($(IMAGE_TYPE)_PREFIX)_$(TARGET)_config.xml) -IMAKER_VARLIST = NAME WORKDIR +CLEAN_IMAKERPOST = $(call iif,$(KEEPTEMP),,deldir | "$(OUTTMPDIR)" |) del | "$(IMAKER_VARXML)" +BUILD_IMAKERPOST = $(and $(subst IMAKERPRE EMPTY IMAKERPOST,,$(IMAKER_STEPS)),$(IMAKER_VARXML),$(IMAKER_VARLIST),\ + write | "$(IMAKER_VARXML)" | $(call def2str,$(IMAKER_XMLINFO))\n) + +IMAKER_VARXML = $(if $(IMAGE_TYPE),$($(IMAGE_TYPE)_PREFIX)_$(TARGET).iconfig.xml) +IMAKER_VARLIST = PRODUCT_NAME TYPE\ + $(and $(IMAGE_TYPE),$(filter $(call lcase,$(IMAGE_TYPE) $(IMAGE_TYPE))-%,$@),\ + $(addprefix $(IMAGE_TYPE)_,NAME ID VERSION DIR IMG)) define IMAKER_XMLINFO @@ -217,101 +238,64 @@ endef -BUILD_PRINTVAR = $(call peval,DPrint(1,\ - $(foreach var1,$(subst $(,), ,$(subst print-,,$(filter print-%,$(MAKECMDGOALS)))),\ - $(foreach var2,$(call filterwcard,$(var1),$(filter-out BUILD_PRINTVAR,$(filter $(word 1,$(call substm,* ? [, ,$(var1)))%,$(.VARIABLES)))),\ - $(call pquote,$(var2) = `$(call def2str,$($(var2)))$').qq(\n),))); return(q())) - IMAKER_EVAL = $(strip\ - $(foreach file,$(call getwords,$(value MKFILE_LIST)),$(eval __i_file := $(call restoreelem,$(file)))$(eval -include $(__i_file)))\ - $(foreach file,$(call getwords,$(value CPPFILE_LIST)),$(eval __i_file := $(call restoreelem,$(file)))$(call cppdef2var,$(__i_file),$(FEATVAR_IDIR)))\ $(LANGUAGE_EVAL)\ - $(eval ITOOL_PATH := $(if $(ITOOL_PATH),$(ITOOL_PATH)$(,))$(ITOOL_DIR)$(,))\ - $(eval ITOOL_PATH := $(ITOOL_PATH)$(call iif,$(USE_IINTPRSIS),$(USE_IINTPRSIS)$(,))$(call iif,$(USE_IREADIMG),$(USE_IREADIMG)$(,))$(call iif,$(USE_IROMBLD),$(USE_IROMBLD)$(,)))\ - $(eval ITOOL_PATH := $(call pathconv,$(subst $(,),$(call iif,$(USE_UNIX),:,;),$(ITOOL_PATH)$(call upddrive,$(E32TOOLS))$(,)$(call upddrive,$(E32GCCBIN)))))\ - $(eval PATH := $(ITOOL_PATH)$(call iif,$(USE_UNIX),:,;)$(PATH))) + $(foreach file,$(call getwords,$(value CPPFILE_LIST)),$(eval __i_file := $(call restoreelem,$(file)))$(call cppdef2var,$(__i_file),$(FEATVAR_IDIR),$(CPPFILE_FILTER)))) -IMAKER_CMDARG := $(value IMAKER_CMDARG) -IMAKER_MAKECMD := $(value IMAKER_MAKECMD) -IMAKER_PERLCMD := -IMAKER_SUBMAKE := +IMAKER_EXPORT = PATH +IMAKER_PRINTVAR = 17 $$@|@ IMAKER_STEPS IMAKER_MKLEVEL IMAKER_MKRESTARTS MAKELEVEL MAKE_RESTARTS MAKEFILE_LIST CPPFILE_LIST FEATVAR_IDIR + +__i_evaled := +__i_tgtind := define IMAKER - $(if $(and $(filter-out help-config,$(filter help-% print-%,$(MAKECMDGOALS))),$(IMAKER_PERLCMD)),-$(DONOTHING), - $(if $(IMAKER_PERLCMD),,$(IMAKER_EVAL)) - $(eval __i_steps := $1) - $(if $(findstring |,$(__i_steps)), - $(eval IMAKER_PERLCMD := -) - $(foreach target,$(call getwords,$(__i_steps)),$(if $(call restoreelem,$(target)), - $(eval IMAKER_SUBMAKE += $(words $(IMAKER_SUBMAKE) x)) - $(subst $(MAKECMDGOALS) |,,$(IMAKER_MAKECMD) |)IMAKER_SUBMAKE="$(IMAKER_SUBMAKE)" $(call restoreelem,$(target)) $(call restwords,$(MAKECMDGOALS))$(\n))), - $(eval __i_steps := $(if $(strip $(__i_steps)),$(foreach step,$(__i_steps),\ - $(eval __i_step := $(word 1,$(subst :, ,$(step))))$(eval __i_attrib := $(word 2,$(subst :, ,$(step))))\ - $(if $(call defined,STEPS_$(__i_step)),\ - $(foreach step2,$(STEPS_$(__i_step)),$(if $(__i_attrib),$(word 1,$(subst :, ,$(step2))):$(__i_attrib),$(step2))),\ - $(step))),EMPTY:b)) - $(eval __i_steps := IMAKERPRE:cbk$(call sstrip,$(foreach step,$(__i_steps),\ - $(eval __i_step := $(word 1,$(subst :, ,$(step))))$(eval __i_attrib := $(word 2,$(subst :, ,$(step))))\ - -$(__i_step):$(or $(findstring c,$(__i_attrib)),$(call iif,$(CLEAN),c))$(or $(findstring b,$(__i_attrib)),$(call iif,$(BUILD),b))\ - $(or $(findstring k,$(__i_attrib)),$(call iif,$(KEEPGOING),k))))) - $(eval IMAKER_STEPS := $(__i_steps)) - $(eval __i_steps :=\ - $(if $(filter print-%,$(MAKECMDGOALS)),IMAKERPRE:cbk-PRINTVAR:b,\ - $(if $(filter-out help-config,$(filter help-%,$(MAKECMDGOALS))),IMAKERPRE:cbk-HELPDYNAMIC:b-HELP:b,$(__i_steps)))) - $(eval IMAKER_PERLCMD := $(PERL) -x $(IMAKER_TOOL)\ - --cmdfile "$(CMDFILE)"\ - $(if $(LOGFILE),--logfile "$(if $(word 2,$(IMAKER_SUBMAKE))$(IMAKER_PERLCMD)$(MAKE_RESTARTS),>>$(LOGFILE:>>%=%),$(LOGFILE))")\ - $(call iif,$(PRINTCMD),--printcmd)\ - --step "$(__i_steps)"\ - $(if $(VERBOSE),--verbose "$(call select,$(VERBOSE),debug,127,$(VERBOSE))")\ - $(if $(WORKDIR),--workdir "$(WORKDIR)")) - -$(PERL) -Xe '$(if $(wildcard $(WORKDIR)),,use File::Path; eval { mkpath(q$(ichar)$(WORKDIR)$(ichar)) };)\ - open(ICMD, q$(ichar)>$(CMDFILE)$(ichar));\ - $(eval __i_submake := $(words $(IMAKER_SUBMAKE)))\ - print(ICMD $(foreach var,IMAKER_VERSION IMAKER_CMDARG IMAKER_MAKECMD IMAKER_PERLCMD $(if $(IMAKER_SUBMAKE),IMAKER_SUBMAKE|__i_submake)\ - IMAKER_EXITSHELL SHELL MAKE MAKEFLAGS MAKECMDGOALS $$@|@ MAKELEVEL MAKE_RESTARTS MAKEFILE_LIST .INCLUDE_DIRS FEATVAR_IDIR CPPFILE_LIST\ - EPOCROOT ITOOL_DIR IMAKER_DIR ITOOL_PATH PATH,\ - sprintf(qq(\# %-17s),q($(word 1,$(subst |, ,$(var))))).q$(ichar)= `$($(or $(word 2,$(subst |, ,$(var))),$(var)))$'$(ichar).qq(\n),));\ - close(ICMD)' - $(foreach step,$(subst -, ,$(__i_steps)),\ - $(eval __i_step := $(word 1,$(subst :, ,$(step))))$(eval __i_attrib := $(subst $(__i_step),,$(step)))\ - $(eval __i_clean := $(findstring c,$(__i_attrib)))$(eval __i_build := $(findstring b,$(__i_attrib)))\ - -$(PERL) -Xe 'open(ICMD, q$(ichar)>>$(CMDFILE)$(ichar));\ - print(ICMD qq(\n)\ - $(if $(eval __i_imgtype := $(IMAGE_TYPE))$(__i_imgtype),,\ - $(eval IMAGE_TYPE += $(foreach type,CORE ROFS2 ROFS3 ROFS4 ROFS5 ROFS6 UDA,$(findstring $(type),$(step))))\ - $(eval IMAGE_TYPE := $(word 1,$(IMAGE_TYPE))))\ - $(if $(__i_clean),.q$(ichar)CLEAN_$(__i_step)=$(CLEAN_$(__i_step))$(ichar).qq(\n))\ - $(if $(__i_build),.q$(ichar)BUILD_$(__i_step)=$(BUILD_$(__i_step))$(ichar).qq(\n)));\ - $(eval IMAGE_TYPE := $(__i_imgtype))\ - close(ICMD)'$(\n)) - $(IMAKER_PERLCMD) - $(eval IMAKER_CMDARG :=)) - ) + $(if $(and $(filter-out help-config,$(filter help-% print-%,$(MAKECMDGOALS))),$(__i_evaled)),, + $(info #iMaker$(ichar)BEGIN) + $(if $(__i_evaled),,$(IMAKER_EVAL)) + $(eval __i_evaled := 1) + $(eval __i_steps := $(if $(MAKECMDGOALS),$1,$(or\ + $(if $(DEFAULT_GOALS),$(if $(PRODUCT_NAME),,$(TARGET_PRODUCT)) $(DEFAULT_GOALS)),$(filter help,$(.DEFAULT_GOAL))))) + $(if $(call restoreelem,$(call getwords,$(__i_steps))),,$(eval __i_steps :=)) + $(if $(__i_tgtind),$(eval __i_steps := $(call getelem,$(__i_tgtind),$(__i_steps)))) + $(eval __i_tgts := $(subst $(__i_steps),,$(call ucase,$(__i_steps)))) + $(if $(or $(filter-out help-config,$(filter help-% print-%,$(MAKECMDGOALS))),$(call not,$(__i_tgts))), + $(eval IMAKER_STEPS := $(if $(filter help% print-%,$(TARGET))$(__i_tgts),,IMAKERPRE )$(or $(strip\ + $(eval __i_ind := $(call findword,RESTART,$(__i_steps)))$(if $(__i_ind),$(call iif,$(IMAKER_MKRESTARTS),\ + $(call restwords,$(call restwords,$(__i_ind),$(__i_steps))),$(wordlist 1,$(__i_ind),$(__i_steps))),$(__i_steps))),EMPTY)) + $(if $(filter-out IMAKERPRE,$(word 1,$(IMAKER_STEPS)))$(filter RESTART,$(lastword $(IMAKER_STEPS))),, + $(eval IMAKER_STEPS += IMAKERPOST)) + $(eval __i_steps := $(if $(filter print-%,$(MAKECMDGOALS)),PRINTVAR,\ + $(if $(filter-out help-config,$(filter help-%,$(MAKECMDGOALS))),HELP,$(IMAKER_STEPS)))) + , + $(if $(and $(__i_tgts),$(__i_tgtind)),$(eval IMAKER_STEPS := $(__i_steps)), + $(eval __i_ind :=) + $(eval IMAKER_STEPS :=) + $(foreach step,$(call getwords,$(__i_steps)), + $(eval __i_ind += +) + $(eval __i_steps := $(call restoreelem,$(step))) + $(if $(__i_steps),$(eval IMAKER_STEPS += $(if $(IMAKER_STEPS),|)\ + $(if $(subst $(__i_steps),,$(call ucase,$(__i_steps))),$(__i_steps),$(TARGETNAME)[$(words $(__i_ind))]))))) + $(eval __i_steps :=) + ) + $(foreach var,VERBOSE IMAGE_TYPE KEEPGOING PRINTCMD,$(info #iMaker$(ichar)$(var)=$($(var)))) + $(foreach var,$(sort $(IMAKER_EXPORT)),$(info #iMaker$(ichar)env $(var)=$($(var)))) + $(foreach var,$(TARGET_EXPORT),$(info #iMaker$(ichar)var $(var)=$($(patsubst %?,%,$(or $(word 2,$(subst :, ,$(var))),$(var)))))) + $(foreach var,$(call restwords,$(IMAKER_PRINTVAR)),$(info #iMaker$(ichar)print $(word 1,$(IMAKER_PRINTVAR))\ + $(word 1,$(subst |, ,$(var)))=$($(or $(word 2,$(subst |, ,$(var))),$(var))))) + $(info #iMaker$(ichar)STEPS=$(or $(__i_steps),target:$(IMAKER_STEPS))) + $(foreach step,$(__i_steps), + $(if $(call defined,INIT_$(step)),$(info #iMaker$(ichar)INIT_$(step)=$(INIT_$(step)))) + $(if $(call true,$(CLEAN)),$(info #iMaker$(ichar)CLEAN_$(step)=$(CLEAN_$(step)))) + $(if $(call true,$(BUILD)), + $(info #iMaker$(ichar)BUILD_$(step)=$(BUILD_$(step))) + $(if $(REPORT_$(step)),$(info #iMaker$(ichar)REPORT_$(step)=$(REPORT_$(step))))) + ) + $(info #iMaker$(ichar)END) + )-@$(DONOTHING) endef ############################################################################### -# Test if old variables are in use - -define API_TEST -# OLD_VARIABLE1 NEW_VARIABLE1 -# OLD_VARIABLEn NEW_VARIABLEn - - CUSTVARIANT_MKNAME VARIANT_MKNAME - CUSTVARIANT_CONFML VARIANT_CONFML - CUSTVARIANT_CONFCP VARIANT_CONFCP -endef - -testnewapi = $(if $1,\ - $(if $(call defined,$(word 1,$1)),\ - warning | 1 | ***************************************\n |\ - warning | 1 | Old-style variable found: $(word 1,$1) ($(origin $(word 1,$1)))\n |\ - warning | 1 | Instead$(,) start using $(word 2,$1)\n |)\ - $(call testnewapi,$(call restwords,3,$1))) - - -############################################################################### # Targets .PHONY: version clean @@ -326,25 +310,36 @@ clean:\ ;@$(call IMAKER,$$(ALL.CLEAN.STEPS)) -print-%: ;@$(call IMAKER) - -step-% : ;@$(call IMAKER,$(subst -, ,$*)) +step-%: ;@$(call IMAKER,$(subst -, ,$*)) #============================================================================== -include $(addprefix $(IMAKER_DIR)/imaker_,$(addsuffix .mk,help image minienv public tools version)) +$(call includechk,$(addprefix $(IMAKER_DIR)/imaker_,$(addsuffix .mk,help image minienv tools version))) +include $(wildcard $(IMAKER_DIR)/imaker_extension.mk) +include $(wildcard $(IMAKER_EXPORTMK)) --include $(IMAKER_DIR)/imaker_extension.mk - +$(call includechk,$(LANGPACK_SYSLANGMK)) +$(call includechk,$(IMAKER_DEFAULTMK)) +$(call includechk,$(IMAKER_CONFMK)) +$(call includechk,$(BUILD_INFOMK)) +$(call includechk,$(BUILD_NAMEMK)) +$(call includechk,$(LANGPACK_MK)) +$(call includechk,$(VARIANT_MK)) +$(call includechk,$(call select,$(USE_CONE),mk,$(if $(filter cone-pre,$(TARGET)),,$(subst $( ),\ ,$(CONE_MK))))) -############################################################################### -# +.DEFAULT_GOAL := $(if $(DEFAULT_GOALS),help,$(.DEFAULT_GOAL)) + +%-dir: FILTERCMD = ^cd\|mkcd\|mkdir$$ +%-dir: $$* ; -else -ifeq ($(__IMAKER_MK__),1) -__IMAKER_MK__ := 2 +$(foreach ind,1 2 3 4 5 6 7 8 9,\ + $(eval %[$(ind)]: __i_tgtind = $(ind))\ + $(eval %[$(ind)]: $$$$* ;)) --include $(IMAKER_DIR)/imaker_extension.mk +include $(wildcard $(IMAKER_DIR)/imaker_extension.mk) +include $(wildcard $(IMAKER_EXPORTMK)) + +$(sort $(MAKEFILE_LIST)): ; ############################################################################### @@ -352,8 +347,8 @@ else $(error Do not include imaker.mk, it is handled by iMaker!) -endif endif # __IMAKER_MK__ + # END OF IMAKER.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker.pl --- a/imgtools/imaker/src/imaker.pl Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker.pl Wed Jun 30 11:35:58 2010 +0800 @@ -11,157 +11,2183 @@ # # Contributors: # -# Description: iMaker main Perl script +# Description: iMaker main Perl script & common routines # # -$(error >>>MAKECMDGOALS=$(MAKECMDGOALS)<<<) +$(error |MAKE=$(MAKE)|MAKE_VERSION=$(MAKE_VERSION)|SHELL=$(SHELL)|MAKECMDGOALS=$(MAKECMDGOALS)|) # #!perl +#line 24 + +use subs qw(CORE::GLOBAL::die); use strict; use warnings; -use Getopt::Long qw(:config pass_through no_auto_abbrev); +use Cwd; +use Digest::MD5 qw(md5_hex); +use File::Basename; +use File::Copy; +use File::Find; +use File::Path; +use File::Spec; +use File::Temp qw(tempfile); +use POSIX qw(strftime); +use Text::ParseWords; +use Time::Local; -my $error = ""; -my $perlver; -my $start; +sub InitMkglobals(); +sub PrintEnv($); +sub Max(@); +sub Min(@); +sub Trim($;$); +sub Quote($); +sub Unquote($); +sub Int2Hex($;$); +sub Byte2Str($@); +sub Str2Byte($); +sub Str2Xml($); +sub Ascii2Uni($); +sub Uni2Ascii($); +sub GetTimestamp(); +sub Sec2Min($); +sub Wcard2Restr($); +sub Wcard2Regex($); +sub ParseCmdWords($); +sub DPrint($@); +sub Echo($$$); +sub PathConv($;$$$); +sub ParseFiles($); +sub GlobFiles($;$); +sub GetBasename($); +sub GetDirname($); +sub GetAbsDirname($;$$$); +sub GetAbsFname($;$$$); +sub GetRelFname($;$$); +sub GetWriteFname($); +sub GetFreeDrive(;$); +sub SubstDrive($$); +sub UnsubstDrive($); +sub Search($$$$$$\@\$); +sub Find($$$$$\$); +sub ChangeDir($); +sub DeleteDir($;$); +sub FindDir($$$$); +sub MakeDir($); +sub MakeChangeDir($); +sub SetWorkdir($); +sub OpenFile(*$$;$); +sub Test($); +sub CutFile($$$$$); +sub Copy($$;$); +sub CopyIby($$); +sub DeleteFile($;$); +sub FindFile($$$$); +sub HeadFile($$$); +sub TailFile($$$); +sub TypeFile($;$); +sub ReadFile($$); +sub WriteFile($$$;$$); +sub UnzipFile($$); +sub Zip($$$$@); +sub Move($$); +sub Touch($@); +sub SetLogfile($); +sub RunSystemCmd($;$$$); +sub ParseSystemCmd($$$$$); +sub GenExclfile($$$$$); +sub GenIbyfile($$$); +sub GenObyfile($$$$@); +sub GenMakefile($$$$$); +sub GenWidgetConf($$$$); +sub AddImageHeader($$$$$); +sub Sleep($); +sub FindSOSFiles($$$$); +sub CheckTool(@); +sub OpCacheInstall($$$); +sub SisInstall($$$$$$$$); +sub GetIPar(;$); +sub PEval($); +sub PeekICmd($); +sub SkipICmd(); +sub GetICmd(); +sub EndICmd(); +sub SplitStep($); +sub RunStep($); +sub RunIExtCmd($); +sub GetConfmkList(;$); +sub GetFeatvarIncdir($); +sub SetVerbose($;$); +sub CloseLog(); +sub RunIMakerCmd($$$$$@); +sub RunMakeCmd($$); +sub HandleCmdArg($); +sub HandleExtCmdArg($); +sub MenuRuncmd($); +sub Menu($); +sub Install($$$); + +use constant READBUFSIZE => 2097152; # 2 MB +use constant STARTSTR => '>>>[START]=========8<==========8<==========8<==========8<==========8<=========='; +use constant ENDSTR => '==========>8==========>8==========>8==========>8==========>8===========[END]<<<'; + +# device[VARID]==... !! +# +use constant BOOTBINARYSTATEMENT => qr/^\s*bootbinary\s*(?:=+|\s)\s*(?:"(.+?)"|(\S+))/i; + +use constant FILESPECSTATEMENT => + qr/^\s*(?:data|device|dll|extension|file|primary|secondary|variant)\S*?\s*(?:=+|\s)\s*(?:"(.+?)"|(\S+))\s+(?:"(.+?)"|(\S+))(\s+.+?)?\s*$/i; + +our ($gArgv, $gCmdcnt, @gCmdoutbuf, %gConfmkList, $gEpocdrive, $gEpocroot, $gError, $gErrwarn, $gEvalerr, + %gExportvar, $gFiltercmd, @gFindresult, $gICmd, @gIcmd, $gImakerext, $gImgtype, $gKeepgoing, @gLogbuf, + $gLogfile, %gLogfiles, $gMakecmd, @gMakeinfo, $gOutfilter, $gParamcnt, $gPrintcmd, @gReport, $gStartmk, + $gStarttime, $gStep, @gStepDur, %gStepIcmd, %gSubstdrv, $gTgterr, %gTool, $gVerbose, $gWinOS, $gWorkdir, + $gWorkdrive, @iVar); + + +############################################################################### +# + +sub InitMkglobals() +{ + $gCmdcnt = 0; + @gCmdoutbuf = (); + $gFiltercmd = qr/\S/; + @gFindresult = (); + $gICmd = ""; + @gIcmd = (); + $gImgtype = ""; + $gOutfilter = ""; + $gParamcnt = 0; + $gPrintcmd = 0; + $gStep = ""; + @gStepDur = (); + %gStepIcmd = (); + @iVar = (); # General purpose variable to be used from $(call peval,...) +} BEGIN { - ($start, $perlver) = (time(), sprintf("%vd", $^V)); + ($gArgv, $gEvalerr, $gStarttime, $gWinOS) = (scalar(@ARGV), 0, time(), $^O =~ /MSWin/i); + $_ = "default input and pattern-searching space"; + eval("use Archive::Zip qw(:ERROR_CODES)"); + eval("use constant AZ_OK => -1") if $@; + eval("use Archive::Zip::Tree"); + if ($gWinOS) { eval(" + use Win32API::File qw(:DDD_); + use Win32::File; + use constant WIN32_FILE_HIDDEN => Win32::File::HIDDEN"); + } else { eval(" + use constant DDD_REMOVE_DEFINITION => -1; + use constant WIN32_FILE_HIDDEN => -1"); + } +} + +INIT { + $gWorkdir = Cwd::cwd(); + $gWorkdrive = ($gWorkdir =~ /^([a-z]:)/i ? uc($1) : ""); + $ENV{EPOCROOT} = ($gWinOS ? "\\" : "$gWorkdir/") if !$ENV{EPOCROOT}; + $ENV{IMAKER_CMDARG} = "" if !defined($ENV{IMAKER_CMDARG}); + $ENV{IMAKER_CYGWIN} = 0 if !$ENV{IMAKER_CYGWIN}; + + InitMkglobals(); + %gConfmkList = (); + $gEpocdrive = ($ENV{EPOCROOT} =~ /^([a-z]:)/i ? uc($1) : $gWorkdrive); + ($gEpocroot = GetAbsDirname($ENV{EPOCROOT})) =~ s/\/+$//; + $gError = 0; + $gErrwarn = 0; + %gExportvar = (); $gExportvar{""} = 0; + $gKeepgoing = 0; + @gLogbuf = (); + $gLogfile = ""; + %gLogfiles = (); + $gMakecmd = ""; + @gMakeinfo = ("?", "?", "?"); + @gReport = (); + $gStartmk = 0; + %gSubstdrv = (); + $gTgterr = 0; + %gTool = (); map{ $gTool{$_} => $_ } ("cpp", "elf2e32", "interpretsis", "opcache", "unzip"); + $gVerbose = 1; + select(STDERR); $|++; select(STDOUT); $|++; - if (!@ARGV) { - warn("Warning: iMaker is running under Cygwin!\n") + + # Overload die + *CORE::GLOBAL::die = sub { + $gError = 1 if !$gEvalerr; + return if (PeekICmd("iferror") && !$gEvalerr); + CORE::die(@_) if ($gEvalerr || !$gKeepgoing); + $gErrwarn = 1; + warn(@_); + }; + + # Handler for __DIE__ signal + $SIG{__DIE__} = sub { + return if $gEvalerr; + $gErrwarn = 1; + warn(@_); + exit(1); + }; + + # Handler for __WARN__ signal + $SIG{__WARN__} = sub { + if (($gEvalerr != 1) && ($gKeepgoing < 3) && ($_[0] ne "\n")) { + select(STDERR); + my $msg = ($gStep ? "($gStep): " : "") . $_[0]; + if ($gErrwarn && ($gKeepgoing < 2)) { + DPrint(0, "*** Error: $msg") } + else { DPrint(127, "Warning: $msg") } + select(STDOUT); + } + $gErrwarn = 0; + }; + + if (!$gArgv) { + warn("iMaker is running under Cygwin!\n") if (!$ENV{IMAKER_CYGWIN} && $^O =~ /cygwin/i); - warn("Warning: iMaker uses Perl version $perlver! Recommended versions are 5.6.1 and 5.8.8.\n") - if ($perlver !~ /^5\.(6\.1|8\.8)$/); + my $perlver = sprintf("%vd", $^V); + warn("iMaker uses Perl version $perlver! Recommended versions are 5.6.1, 5.8.x and 5.10.x.\n") + if ($perlver !~ /^5\.(?:6\.1|(?:8|10)\.\d+)$/); } - unshift(@INC, defined($ENV{IMAKER_DIR}) ? $ENV{IMAKER_DIR} : ($0 =~ /^(.*)[\/\\]/ ? $1 : ".")); } -use imaker; - ############################################################################### # Main program { - if (!@ARGV) { - $ENV{CONFIGROOT} = imaker::GetAbsDirname($ENV{CONFIGROOT}); - $ENV{ITOOL_DIR} = imaker::GetAbsDirname($ENV{ITOOL_DIR}, 0, 1); - $ENV{IMAKER_DIR} = imaker::GetAbsDirname($ENV{IMAKER_DIR}, 0, 1); - $ENV{PATH} = join(";", grep(!/[\\\/]cygwin[\\\/]/i, split(/;+/, $ENV{PATH}))) - if $imaker::gWinOS && !$ENV{IMAKER_CYGWIN}; + if ($gArgv) { + my $iopt = shift(@ARGV); + print(map("$_\n", GetFeatvarIncdir("@ARGV"))), exit(0) if ($iopt eq "--incdir"); + print(map("$_\n", @ARGV)), exit(0) if ($iopt eq "--splitarg"); + die("Unknown internal imaker.pl option: `$iopt'.\n"); + } + + delete($ENV{MAKE}) if $gWinOS; + map { delete($ENV{$_}) } qw(MAKECMDGOALS MAKEFILES MAKEFLAGS MAKELEVEL MAKE_VERSION); + + $ENV{CONFIGROOT} = GetAbsDirname($ENV{CONFIGROOT} || "$gEpocroot/epoc32/rom/config"); + $ENV{ITOOL_DIR} = GetAbsDirname($ENV{ITOOL_DIR} || "$gEpocroot/epoc32/tools/rom"); + $ENV{IMAKER_DIR} = GetAbsDirname($ENV{IMAKER_DIR}); + + $ENV{IMAKER_EXPORTMK} = ""; + $ENV{IMAKER_MAKE} = ($gWinOS ? "$ENV{IMAKER_DIR}/mingw_make.exe" : $ENV{MAKE} || "make") if !$ENV{IMAKER_MAKE}; + $ENV{IMAKER_MAKESHELL} = ($ENV{COMSPEC} || "cmd.exe") if (!$ENV{IMAKER_MAKESHELL} && $gWinOS); + $ENV{IMAKER_MKCONF} = $ENV{CONFIGROOT} . ',image_conf_(.+?)\.mk$,_(?:ncp)?\d+\.mk$,1' if !$ENV{IMAKER_MKCONF}; + + my $pathsep = ($gWinOS ? ";" : ":"); + $ENV{PATH} = join(";", grep(!/[\\\/]cygwin[\\\/]/i, split(/;+/, $ENV{PATH}))) if (!$ENV{IMAKER_CYGWIN} && $gWinOS); + ($ENV{PATH} = Trim($ENV{PATH})) =~ s/"$/";/ if $gWinOS; # http://savannah.gnu.org/bugs/index.php?25412 + $ENV{PATH} = PathConv("$ENV{ITOOL_DIR}", $gWinOS) . $pathsep . PathConv("$gEpocroot/epoc32/tools", $gWinOS) . + $pathsep . ($gWinOS ? PathConv("$gEpocroot/epoc32/gcc/bin", 1) . ";" : "") . $ENV{PATH}; + + $ENV{PERL5LIB} = $ENV{IMAKER_DIR} . ($ENV{PERL5LIB} ? "$pathsep$ENV{PERL5LIB}" : ""); + + die($@) if !defined($gImakerext = do("$ENV{IMAKER_DIR}/imaker_extension.pm")) && $@; + + my ($version, $verfile) = ("", "$ENV{IMAKER_DIR}/imaker_version.mk"); + open(FILE, "<$verfile") and map { $version = $1 if /^\s*IMAKER_VERSION\s*[+:?]?=\s*(.*?)\s*$/ } ; + close(FILE); + if ($version) { DPrint(1, "$version\n") } + else { warn("Can't read iMaker version from `$verfile'.\n") } + + if ($ENV{IMAKER_CMDARG} =~ /^\s*--?(install|clean)=?(.*?)\s*$/i) { + Install(lc($1) eq "clean", "$ENV{IMAKER_DIR}/../group/bld.inf", $2); + exit(0); + } + + $gMakecmd = "$ENV{IMAKER_MAKE} -R --no-print-directory" . + ($ENV{IMAKER_MAKESHELL} ? " SHELL=\"$ENV{IMAKER_MAKESHELL}\"" : ""); + my $cmdout = qx($gMakecmd -f "$0" 2>&1); + ($cmdout = (defined($cmdout) ? $cmdout : "")) =~ s/\n+$//; + die("Can't run Make properly: `$cmdout'\n") + if ($cmdout !~ /\|MAKE=(.*?)\|MAKE_VERSION=(.*?)\|SHELL=(.*?)\|/); + @gMakeinfo = ($1, $2, $3); + warn(($gMakeinfo[1] eq "" ? "Can't resolve Make version" : "iMaker uses Make version $gMakeinfo[1]") . + ", recommended version is 3.81.\n") if ($gMakeinfo[1] !~ /^\s*3\.81/); + + RunIMakerCmd("$gMakecmd TIMESTAMP=" . GetTimestamp() . + " -I \"$ENV{CONFIGROOT}\" -f \"$ENV{IMAKER_DIR}/imaker.mk\"", $ENV{IMAKER_CMDARG}, "", 0, 0, ()); +} + + +############################################################################### +# + +sub PrintEnv($) +{ + return if !@gMakeinfo; + DPrint(shift(), "=" x 79 . "\n" . + "User : " . (getlogin() || "?") . "@" . ($ENV{HOSTNAME} || $ENV{COMPUTERNAME} || "?") . " on $^O\n" . + "Time : " . localtime() . "\n" . + "Current dir : `$gWorkdir'\n" . + "iMaker tool : `$ENV{IMAKER_TOOL}' -> `$0'\n" . + "Cmdline args: `$ENV{IMAKER_CMDARG}'\n" . + "Perl : `$^X' version " . sprintf("%vd\n", $^V) . + "PERL5LIB : `$ENV{PERL5LIB}'\n" . + "PERL5OPT : `" . (defined($ENV{PERL5OPT}) ? "$ENV{PERL5OPT}'\n" : "'\n") . + "Make : `$gMakeinfo[0]' version $gMakeinfo[1]\n" . + "Make shell : `$gMakeinfo[2]'\n" . + "EPOCROOT : `$ENV{EPOCROOT}'\n" . + "CONFIGROOT : `$ENV{CONFIGROOT}'\n" . + "PATH : `$ENV{PATH}'\n"); + @gMakeinfo = (); +} + +sub Max(@) +{ + my $max = (shift() || 0); + map { $max = $_ if $_ > $max } @_; + return($max); +} + +sub Min(@) +{ + my $min = (shift() || 0); + map { $min = $_ if $_ < $min } @_; + return($min); +} + +sub Trim($;$) +{ + (my $str = shift()) =~ s/^\s+|\s+$//g; + $str =~ s/\s+(?=\s)//g if shift(); + return($str); +} + +sub Quote($) +{ + local $_ = shift(); + return("") if !defined(); + s/\\( |n|t)/\\\\$1/g; + return($_); +} + +sub Unquote($) +{ + local $_ = shift(); + return("") if !defined(); + s/(?'"', '&'=>'&', "'"=>''', '<'=>'<', '>'=>'>'}->{$1} || $1/ge; + return($str); +} + +sub Ascii2Uni($) +{ + (local $_ = shift()) =~ s/(?".*", "?"=>"."}->{$1} || "\Q$1\E"/ge; + return($wcard); +} + +sub Wcard2Regex($) +{ + my $restr = Wcard2Restr(shift()); + return(qr/$restr/i); +} + +sub ParseCmdWords($) +{ + my $line = Trim(shift()); + $line =~ s/\\/\\\\/g if $gWinOS; + return(Text::ParseWords::parse_line('\s+', 0, $line)); +} + + +############################################################################### +# + +sub DPrint($@) +{ + my ($verbose, @outlist) = @_; + map { tr/\x00\x1F/#/ } @outlist; + print(@outlist) if !$verbose || ($verbose & $gVerbose); + push(@gLogbuf, @outlist) if ($verbose < 32) || ($verbose & $gVerbose); + return if ($gLogfile eq "" || !@gLogbuf); + print(LOG @gLogbuf); + @gLogbuf = (); +} - my ($version, $verfile) = ("", "$ENV{IMAKER_DIR}/imaker_version.mk"); - open(FILE, "<$verfile") and map { $version = $1 if /^\s*IMAKER_VERSION\s*[+:?]?=\s*(.*?)\s*$/ } ; - close(FILE); - $version and print("$version\n") or - warn("Can't read iMaker version from `$verfile'.\n"); +sub Echo($$$) +{ + return if SkipICmd(); + my ($verbose, $str) = (shift(), shift()); + DPrint($verbose, shift() ? "$str\n" : Unquote($str)); +} + + +############################################################################### +# File operations + +sub PathConv($;$$$) +{ + my $path = shift(); + if (shift()) { $path =~ tr-\/-\\- } + else { $path =~ tr-\\-\/- } + return($path) if (!$gWinOS || $path =~ /^(?:\/\/|\\\\)/); + my $drive = shift(); + return(ucfirst(($path =~ /^[a-z]:/i ? "" : ($_[0] ? $_[0] : $gWorkdrive)) . $path)) + if !$drive; + $drive = $gWorkdrive if !($drive = shift()); + $path =~ s/^$drive//i; + return($path); +} + +sub ParseFiles($) +{ + my ($file, @files) = (" " . shift() . " ", ()); + push(@files, defined($1) ? $1 : (defined($2) ? $2 : ())) while ($file =~ /\s(?:"\s*"|"+(.+?)"+|((\\\s|\S)+))(?=\s)/g); + return(@files); +} + +sub GlobFiles($;$) +{ + return(@gFindresult) if (my $file = shift()) =~ /^__find__$/i; + return(map(/[\*\?]/ ? sort({lc($a) cmp lc($b)} grep(!/[\/\\]\.\.?$/, + glob(scalar(s/\*/\{\.\*\,\*\}/g, /\s/) ? "\"$_\"" : $_))) : $_, (shift() ? $file : ParseFiles($file)))); +} + +sub GetBasename($) +{ + return((File::Basename::fileparse(shift()))[0]); +} + +sub GetDirname($) +{ + (my $dir = shift()) =~ s/^>>?(?!>)//; + return((File::Basename::fileparse($dir))[1]); +} + +sub GetAbsDirname($;$$$) +{ + (my $dir = shift()) =~ s/^>>?(?!>)//; + $dir = "." if ($dir eq ""); + my $absdir = ""; + eval { local $gEvalerr = 1; $absdir = Cwd::abs_path($dir) }; + return(PathConv($absdir || File::Spec->rel2abs($dir, + $dir !~ /^$gWorkdrive/i && $dir =~ /^([a-z]:)/i ? "$1/" : ""), shift(), shift(), shift())); +} + +sub GetAbsFname($;$$$) +{ + my $file = shift(); + return($file) if ($file eq "" || $file =~ /STD(IN|OUT|ERR)$/); + my $append = ($file =~ s/^>>(?!>)// ? ">>" : ""); + return($append . PathConv(File::Spec->catpath("", GetAbsDirname(GetDirname($file)), GetBasename($file)), shift(), shift(), shift())); +} + +sub GetRelFname($;$$) +{ + my ($file, $base) = (shift(), shift()); + my $append = ($file =~ s/^>>(?!>)// ? ">>" : ""); + ($file = PathConv(File::Spec->abs2rel($file, GetAbsDirname(defined($base) && ($base ne "") ? $base : ".")), + shift(), 1, "[a-z]:")) =~ s/^[\/\\]+//; + return("$append$file"); +} + +sub GetWriteFname($) +{ + (my $file = shift()) =~ s/^>?/>/; + return($file); +} + +sub GetFreeDrive(;$) +{ + my $drives = Win32API::File::GetLogicalDrives(); + for my $drive ("F".."Z", "A".."E") { + return("$drive:") if !($drives & (2 ** (ord($drive) - ord("A")))); + } + return("") if shift(); + die("GetFreeDrive: No free drive available.\n"); +} + +sub SubstDrive($$) +{ + my ($drive, $path) = (uc(shift()), GetAbsDirname(shift())); + DPrint(16, "SubstDrive: `$drive' => `$path'\n"); + $gSubstdrv{$drive} = 1, return if !(Win32API::File::GetLogicalDrives() & (2 ** (ord($drive) - ord("A")))) && + Win32API::File::DefineDosDevice(0, $drive, $path); + die("Can't substitute `$drive' => `$path'\n"); +} + +sub UnsubstDrive($) +{ + return if (my $drive = uc(shift())) eq ""; + DPrint(16, "UnsubstDrive: `$drive'\n"); + delete($gSubstdrv{$drive}), return if Win32API::File::DefineDosDevice(DDD_REMOVE_DEFINITION, $drive, []) && + !(Win32API::File::GetLogicalDrives() & (2 ** (ord($drive) - ord("A")))); + warn("Can't remove substituted drive `$drive'\n"); +} - my $cmdarg = " " . imaker::HandleCmdArg($ENV{IMAKER_CMDARG}) . " "; - my $makecmd = "$ENV{IMAKER_MAKE} -R --no-print-directory" . - ($ENV{IMAKER_MAKESHELL} ? " SHELL=\"$ENV{IMAKER_MAKESHELL}\"" : ""); - my $cmdout = qx($makecmd -f $0 $cmdarg 2>&1); - my $targets = ($cmdout =~ />>>MAKECMDGOALS=(.*?)<</; + DPrint(16, defined($print) ? $print : ($file =~ /^>/ ? "Write" : "Read") . "File: `$file'\n"); + return(open($fhandle, $file)) if !$binmode; + return(open($fhandle, $file) and binmode($fhandle)); +} - die("Can't run `$ENV{IMAKER_MAKE}' properly:\n$cmdout") if !defined($targets); - map { $cmdarg =~ s/\s+\Q$_\E\s+/ / } split(/\s+/, $targets); +sub Test($) +{ + if (-d(my $file = shift())) { + DPrint(16, "TestDir: `" . GetAbsDirname($file) . "'\n"); + } elsif (-f($file)) { + DPrint(16, "TestFile: `" . GetAbsFname($file) . "'\n"); + } else { + DPrint(16, "Test: `$file'\n"); + die("File or directory `$file' doesn't exist.\n"); + } +} + +sub CutFile($$$$$) +{ + my ($msg, $src, $dest, $head, $len) = @_; + my ($buf, $srctmp) = (undef, "$src.tmp"); + + OpenFile(*INFILE, $src, 1, $msg) or + die("Can't read file `$src'.\n"), return; + + my $out = GetWriteFname($head ? $dest : $srctmp); + OpenFile(*OUTFILE, $out, 1) or die("Can't write to `$out'.\n"), return; + while ($len > 0) { + read(INFILE, $buf, $len < READBUFSIZE ? $len : READBUFSIZE); + print(OUTFILE $buf); + $len -= READBUFSIZE; + } + close(OUTFILE); + + $out = GetWriteFname($head ? $srctmp : $dest); + OpenFile(*OUTFILE, $out, 1) or die("Can't write to `$out'.\n"), return; + print(OUTFILE $buf) while read(INFILE, $buf, READBUFSIZE); + close(OUTFILE); + close(INFILE); + Move($srctmp, $src); +} + +sub Copy($$;$) +{ + my ($src, $dest, $dir) = @_; + $dir = defined($dir) && $dir; + my $file = !($dir || -d($src)); + $src = ($file ? GetAbsFname($src) : GetAbsDirname($src)); + $dest = ($file ? GetAbsFname(-d($dest) ? "$dest/" . GetBasename($src) : $dest) : + GetAbsDirname($dir ? $dest : "$dest/" . GetBasename($src))); + if ($file && ($dest =~ /^>>[^>]/)) { + OpenFile(*FILE, $dest, 1, "AppendFile: `$src' => `$dest'\n") + or die("Can't append to `$dest'.\n"), return; + File::Copy::copy($src, *FILE) and + close(FILE) and return; + } + elsif ($file) { + MakeDir(GetDirname($dest)); + DPrint(16, "CopyFile: `$src' => `$dest'\n"); + warn("CopyFile: Destination file `$dest' already exists\n") if -f($dest); + File::Copy::copy($src, $dest) and return; + } else { + DPrint(16, "CopyDir: `$src' => `$dest'\n"); + return if !RunSystemCmd(!$gWinOS ? "cp \"$src\"/* \"$dest\" -frv" : + 'xcopy "' . PathConv($src, 1) . '" "' . PathConv($dest, 1) . '" /e /h /i /q /y /z', 2); + } + die("Can't copy `$src' to `$dest'.\n"); +} + +sub CopyIby($$) +{ + my ($file, $dir) = (GetAbsFname(shift()), shift()); + OpenFile(*FILE, $file, 0) or die("Can't read file `$file'.\n"), return; + map { + Copy(defined($1) ? $1 : $2, "$dir/" . (defined($3) ? $3 : $4)) if $_ =~ FILESPECSTATEMENT; + } ; + close(FILE); +} + +sub DeleteFile($;$) +{ + return if !-f(my $file = GetAbsFname(shift())); + DPrint(16, "DeleteFile: `$file'\n"); + for my $sec (0, 1, 2) { + warn("Can't delete file `$file', retrying in $sec second(s)...\n"), sleep($sec) if $sec; + unlink($file); + return if !-f($file); + } + $file = "Can't delete file `$file'.\n"; + shift() ? warn($file) : die($file); +} + +sub FindFile($$$$) +{ + my ($dir, $inclpat, $exclpat, $opt) = @_; + $opt = "" if !defined($opt); + my @find = Find($opt !~ /f/ ? $dir : GetDirname($dir), $opt !~ /f/ ? $inclpat : GetBasename($dir), + $exclpat, $opt =~ /r/, 0, local $_); + push(@gFindresult, $opt !~ /f/ ? @find : map("|$_|$inclpat", @find)); +} + +sub HeadFile($$$) +{ + my ($src, $dest, $len) = (GetAbsFname(shift()), GetAbsFname(shift()), shift()); + $len = hex($len) if $len =~ /^0x/; + CutFile("HeadFile: Cut first $len bytes from `$src' => `$dest'\n", $src, $dest, 1, $len); +} - my $tmptarg = $targets = " $targets"; - my $hptarg = 0; - while ($tmptarg =~ /(\s+(help-\S+))/g) { - $hptarg = $1, $targets =~ s/\Q$hptarg\E(.*)$/ $1$hptarg/ if $2 ne "help-config"; +sub TailFile($$$) +{ + my ($src, $dest, $len) = (GetAbsFname(shift()), GetAbsFname(shift()), shift()); + $len = hex($len) if $len =~ /^0x/; + CutFile("TailFile: Cut last $len bytes from `$src' => `$dest'\n", $src, $dest, 0, (-s($src) ? -s($src) : 0) - $len); +} + +sub TypeFile($;$) +{ + my ($file, $str, $mode) = (GetAbsFname(shift()), "", shift() || ""); + OpenFile(*FILE, $file, $mode, "TypeFile: `$file'" . + ($gOutfilter && ($mode ne "b") ? ", filter: `/$gOutfilter/i'" : "") . "\n") or + die("Can't read file `$file'.\n"), return; + DPrint(8, STARTSTR . "\n"); + read(FILE, $str, -s($file)); + if ($mode eq "b") { + DPrint(1, Byte2Str(0, map(ord(), split(//, $str)))); + } else { + $str = Uni2Ascii($str) if $mode eq "u"; + DPrint(1, map("$_\n", grep(!$gOutfilter || /$gOutfilter/i, split(/\n/, $str)))); + $gOutfilter = ""; + } + DPrint(8, ENDSTR . "\n"); + close(FILE); +} + +sub ReadFile($$) +{ + my ($file, $warn) = (GetAbsFname(shift()), shift()); + OpenFile(*RFILE, $file, 0) or + ($warn ? (warn("Can't read file `$file'.\n"), return(())) : die("Can't read file `$file'.\n")); + my @file = map(chomp() ? $_ : $_, grep(!/^\s*$/, )); + close(RFILE); + return(@file); +} + +sub WriteFile($$$;$$) +{ + my ($file, $str, $mode, $opt) = (GetAbsFname(shift()), shift(), shift() || "", shift()); + OpenFile(*WFILE, GetWriteFname($file), $mode) or + die("Can't write to `$file'.\n"), return; + if ($mode eq "b") { + my @byte = Str2Byte($str); + DPrint(64, Byte2Str($file =~ s/^>>(?!>)// ? -s($file) : 0, @byte)); + print(WFILE map(chr(), @byte)); + } else { + $opt = "" if !defined($opt); + $str = Unquote($str) if ($opt !~ /q/); + $str =~ s/(?<=\S)\/\//\//g if ($opt =~ /c/); + DPrint(16, $str) if shift(); + $str = Ascii2Uni($str) if ($mode eq "u"); + print(WFILE $str); + } + close(WFILE); +} + +sub UnzipFile($$) +{ + my ($zipfile, $dir) = (GetAbsFname(shift()), GetAbsDirname(shift())); + DPrint(16, "UnzipFile: `$zipfile'"); + Archive::Zip::setErrorHandler(sub{}); + my ($error, $zip) = (0, Archive::Zip->new()); + if ($zip->read($zipfile) != AZ_OK) { + DPrint(16, " to directory `$dir'\n"); + die("Can't read zip archive `$zipfile'.\n"); + return; + } + my @files = map($_->fileName(), grep(!$_->isDirectory(), $zip->members())); + DPrint(16, ", " . @files . " files to directory `$dir'\n"); + foreach my $file (@files) { + DPrint(16, "ExtractFile: `$dir/$file'"); + eval { local $gEvalerr = 1; $error = ($zip->extractMember($file, "$dir/$file") != AZ_OK) }; + DPrint(16, $error ? " Failed\n" : "\n"); + die("Can't extract file `$file' to directory `$dir'.\n") if $error; + $error = 0; + } +} + +sub Zip($$$$@) +{ + my ($zipfile, $dir, $opt, $prefix) = (GetAbsFname(shift()), shift(), shift(), shift()); + + $opt = (defined($opt) ? ", options: `$opt'" : ""); + $prefix = GetAbsDirname($prefix) if $prefix ne ""; + my %files = (); + foreach my $file (@_) { + my $zname = ""; + ($file, $zname) = ($1, $2) if ($file =~ /^\|(.*)\|(.*)$/); + next if !($file = (!$dir ? (-f($file) ? GetAbsFname($file) : "") : (-d($file) ? GetAbsDirname($file) : ""))); + ($zname = ($zname eq "" ? $file : (!$dir ? + GetAbsFname($zname) : GetAbsDirname($zname)))) =~ s/^(?:$gEpocroot|[a-z]:)?\/+//i; + if ($opt !~ /j/) { + $zname =~ s/^.*?\/+/$prefix\// if ($prefix ne ""); + } else { + $zname = ($dir ? "" : GetBasename($file)) if ($prefix eq "") || !s/^$prefix//; } - $hptarg = $1, $targets =~ s/\Q$hptarg\E(.*)$/ $1$hptarg/ while $tmptarg =~ /(\s+print-\S+)/g; - $targets =~ s/^\s+|\s+(?=\s)|\s$//g; + $files{lc($zname)} = [$file, $zname]; + } + + DPrint(16, ($dir ? "ZipDir: `$zipfile'$opt, " . keys(%files) . " directories" : + "ZipFile: `$zipfile'$opt, " . keys(%files) . " files") . ($prefix ? ", prefix: $prefix\n" : "\n")); + + Archive::Zip::setErrorHandler(sub{}); + my ($error, $zip) = (0, Archive::Zip->new()); + $zip->read($zipfile) if (my $ziptmp = ($zipfile =~ s/^>>(?!>)// ? "$zipfile.tmp" : "")); + $zip->zipfileComment("iMaker-generated zip archive `$zipfile'$opt."); - my $mainmk = "-f $ENV{IMAKER_DIR}/imaker.mk"; - $makecmd .= " -I " . imaker::GetAbsDirname($ENV{CONFIGROOT}, 0, 1) . " $mainmk"; + foreach my $file (sort({lc($$a[0]) cmp lc($$b[0])} values(%files))) { + DPrint(16, "Add" . ($dir ? "Dir" : "File") . ": `$$file[0]' => `$$file[1]'") if ($opt !~ /q/); + eval { + my $warn = 0; + local $gEvalerr = 1; local $SIG{__WARN__} = sub{ $warn = 1 }; + $error = ($dir ? $zip->addTree($$file[0], $$file[1]) != AZ_OK : + !$zip->addFile($$file[0], $$file[1])) || $warn; + }; + DPrint(16, $error ? " Failed\n" : "\n") if ($opt !~ /q/); + warn("Can't add " . ($dir ? "directory tree" : "file") . "`$$file[0]' to zip archive `$zipfile'.\n") if $error; + $error = 0; + } + ($zip->writeToFileNamed($ziptmp ? $ziptmp : $zipfile) == AZ_OK) or + die("Can't create zip archive `$zipfile'.\n"); + Move($ziptmp, $zipfile) if $ziptmp; +} + +sub Move($$) +{ + my ($src, $dest) = @_; + my $dir = -d($src); + $src = ($dir ? GetAbsDirname($src) : GetAbsFname($src)); + MakeDir(GetDirname($dest)); + $dest = ($dir ? GetAbsDirname($dest) : GetAbsFname($dest)); + DPrint(16, "Move" . ($dir ? "Dir" : "File") . ": `$src' => `$dest'\n"); + File::Copy::move($src, $dest) or + die("Can't move `$src' to `$dest'.\n"); +} + +sub Touch($@) +{ + my $time = (shift() =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/ ? + Time::Local::timelocal($6, $5, $4, $3, $2 - 1, $1 - 1900) : time); + if (@_ != 1) { + DPrint(16, "Touch: " . scalar(@_) . " files/dirs, " . + POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime($time)) . "\n"); + utime($time, $time, @_) == @_ or + die("Can't touch all the " . scalar(@_) . " files/dirs.\n"); + return; + } + my $file = shift(); + my $dir = -d($file); + $file = ($dir ? GetAbsDirname($file) : GetAbsFname($file)); + DPrint(16, "Touch" . ($dir ? "Dir" : "File") . ": `$file', " . + POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime($time)) . "\n"); + utime($time, $time, $file) == 1 or + die("Can't touch " . ($dir ? "directory" : "file") . " `$file'.\n"); +} + +sub SetLogfile($) +{ + return if !(my $file = GetAbsFname(shift())); + my $append = (($file =~ s/^>>(?!>)//) || exists($gLogfiles{$file}) ? ">>" : ""); + CloseLog(); + OpenFile(*LOG, GetWriteFname($file = "$append$file"), 0) or + warn("Can't log to file `$file'.\n"), return; + $gLogfiles{$gLogfiles{__prev__} = $gLogfile = $file} = 1; +} + + +############################################################################### +# + +sub RunSystemCmd($;$$$) +{ + return if ($gICmd !~ $gFiltercmd); + my ($cmd, $keepgoing, $null, $file) = @_; + DPrint(1, "$cmd\n"), return if $gPrintcmd; + local $gError = 0 if ($keepgoing = (defined($keepgoing) && ($keepgoing =~ /^[123]$/) ? $keepgoing : 0)); + local $gKeepgoing = Max($gKeepgoing, $keepgoing) if $keepgoing; + $file = (defined($file) ? GetAbsFname($file) : ""); + @gCmdoutbuf = (); + DPrint(4, local $_ = "RunSystemCmd(" . GetAbsDirname(".") . "): `$cmd'" . + ($keepgoing ? ", keep going" . ($keepgoing > 1 ? "($keepgoing)" : "") : "") . + ($file ? ", redirect to `$file'" : "") . ($null ? ", redirect stdout to null" : "") . + ($gOutfilter ? ", filter: `/$gOutfilter/i'" : "") . "\n"); + OpenFile(*CMDFILE, GetWriteFname($file), 0) or + (die("Can't write to `$file'.\n"), $file = "") if $file; + print(CMDFILE $_) if $file; + my $dur = time(); + open(CMD, "$cmd 2>&1 |"); + DPrint(8, STARTSTR . "\n"); + while ($_ = ) { + chomp(); + push(@gCmdoutbuf, $_); + next if ($gOutfilter && !/$gOutfilter/i); + DPrint(8, "$_\n") if !$null; + print(CMDFILE "$_\n") if $file; + } + close(CMD); + my $error = ($? >> 8); + close(CMDFILE) if $file; + push(@gStepDur, $dur = time() - $dur); + $gOutfilter = ""; + print(map("$_\n", @gCmdoutbuf)) if ($error && !$gKeepgoing && !$null && $gVerbose && !($gVerbose & 8)); + $dur = Sec2Min($dur); + DPrint(8, substr(ENDSTR, 0, -16) . $dur . substr(ENDSTR, length($dur) - 16) . "\n"); + die("Command `$cmd' failed ($error) in `" . GetAbsDirname(".") . "'.\n") if $error; + return($error); +} + + +############################################################################### +# + +sub ParseSystemCmd($$$$$) +{ + return if SkipICmd(); + my ($title, $inclre, $exclre, $file, $lines) = @_; + ($inclre, $exclre) = (eval("qr$inclre"), $exclre ne "" ? eval("qr$exclre") : qr/^$/); + $lines = ($lines ? $lines - 1 : 0); - foreach my $target ($hptarg || $targets eq "" ? $targets : split(/\s/, $targets)) { - ($cmdarg, $target) = imaker::Menu($makecmd, $mainmk, $cmdarg) if $target eq "menu"; - system($ENV{IMAKER_MAKECMD} = "$makecmd TIMESTAMP=" . imaker::GetTimestamp() . " $cmdarg $mainmk $target") - if $target ne "menu"; - $error = ($? >> 8) if ($? >> 8); + my @parse = (); + for (my $i = 0; $i < @gCmdoutbuf; $i++) { + next if ($gCmdoutbuf[$i] !~ $inclre); + push(@parse, join(" | ", @gCmdoutbuf[$i .. $i + $lines])) if ($gCmdoutbuf[$i] !~ $exclre); + $i += $lines; + } + return if !@parse; + if (!$file) { + DPrint(1, "$title\n", map(sprintf("%" . length(@parse) . "s", $_) . ") $parse[$_ - 1]\n", 1 .. @parse)); + } else { + WriteFile($title, join("\n", @parse), "", "q"); + } +} + + +############################################################################### +# + +sub GenExclfile($$$$$) +{ + return if SkipICmd(); + + my ($exclfile, $base, $prefix, $exclfiles, @exclfiles) = (shift(), GetAbsDirname(shift()), shift(), "", ()); + + if (!-f($exclfile)) { + WriteFile($exclfile, "", ""); + } else { + OpenFile(*FILE, $exclfile, 1) or die("Can't read file `$exclfile'.\n"), return; + read(FILE, $exclfiles, -s($exclfile)); + close(FILE); + @exclfiles = split(/\n/, Uni2Ascii($exclfiles)); + } + + my $findfiles = 0; + my @addfiles = map($_ ne "**" ? $_ : "*", grep(!(($_ eq "*") && ++$findfiles), + map(Trim(Unquote(Trim($_))), grep(!/^\s*(?:#.*)?$/, split(/(?>([^>].*)$/ && -f($1) ? "" : "// Generated `$ibyfile'") . + "\n\n/* Custom override configuration\n" . join("\n", @ibyconf) . "\n*/\n$ibystr" . + ($oride ? "OVERRIDE_END\n" : ""), "", "q"); +} + +sub GenObyfile($$$$@) +{ + return if SkipICmd(); + + my ($ibyfile, $srcdir, $subdir, $finddir) = (GetAbsFname(shift()), shift(), shift(), shift()); + my ($header, $footer, $body, %files) = ("", "", "", ()); + + foreach my $dir (split(/\s+/, $srcdir)) { + $dir = GetAbsDirname($dir); + my ($found, $total, $lines) = (0, 0, ""); + my @param = @_; + while (@param) { + my ($filepat, $format, @lines) = (shift(@param), shift(@param), ()); + $header = $format, next if $filepat =~ /^__header__$/i; + $footer = $format, next if $filepat =~ /^__footer__$/i; + foreach my $src (Find($dir, $filepat, "", $subdir, $finddir, $total)) { + next if $files{$src}; + $files{$src} = 1; + (my $line = $format) =~ s/%1/$src/g; + $line =~ s/%2/GetRelFname($src, $dir, 1)/ge; + $line =~ s/%3/GetAbsFname($src)/ge; + if ($line =~ /%4/) { + my $attrib = ""; + if ($gWinOS) { + Win32::File::GetAttributes($src, $attrib); + $attrib = (($attrib & WIN32_FILE_HIDDEN) ? "attrib=H" : ""); + } + $line =~ s/%4/$attrib/ge; + } + push(@lines, Trim($line)); + } + $found += @lines; + $lines .= "//\n// Format: `$format', " . @lines . ($finddir ? " empty directories" : " files") . + ": `$filepat'\n" . (@lines ? "//\n" . join("\n", @lines) . "\n" : ""); + } + $body .= "\n// Collected entries $found/$total from directory `$dir'" . + ($subdir ? " and subdirectories" : "") . "\n$lines"; } - #========================================================================== + my $append = ($ibyfile =~ s/^>>(?!>)// && -f($ibyfile) && ">>" || ""); + (my $fname = "__" . uc(GetBasename($ibyfile)) . "__") =~ s/\W/_/g; + my @previby = (); + + if ($append) { + OpenFile(*FILE, $ibyfile, 0) or die("Can't read file `$ibyfile'.\n"), return; + @previby = ; + close(FILE); + $previby[0] =~ s/(, collected )(\d+)( entries)$/$1.($2 + keys(%files)).$3/e; + $previby[@previby - 1] = ""; + } + WriteFile($ibyfile, join("", @previby) . ($append ? "// Appended" : "// Generated") . + " `$append$ibyfile', collected " . keys(%files) . " entries\n" . + ($append ? "" : "\n#ifndef $fname\n#define $fname\n") . + ($header ? Unquote("\\n$header\\n") : "") . $body . ($footer ? Unquote("\\n$footer\\n") : "") . + "\n#endif // $fname\n", "", "q"); +} + +sub GenWidgetConf($$$$) +{ + return if SkipICmd(); + my ($wgzini, $ini, $dir) = (shift(), GetAbsFname(shift()), GetAbsDirname(shift())); + my @ini = ($ini eq "" ? () : ReadFile($ini, 0)); + my $files = ($dir eq "" ? "" : join("\n", Find($dir, "*", '/\/(?:' . join("|", + map(GetBasename($_), ($ini, map(!/^\s*[#[]/ && /^\s*(?:"(.+?)"|(\S+))/ && + -e(local $_ = (defined($1) ? $1 : $2)) ? $_ : (), @ini)))) . ')$/i', 0, 0, local $_))); + + WriteFile($wgzini, Unquote(shift()) . + (@ini ? "# Copied lines from `$ini':\n" . join("\n", @ini) : "") . "\n" . + ($files ? (@ini ? "\n" : "") . "# Collected files from `$dir':\n$files\n" : ""), "", "q"); +} + + +############################################################################### +# + +sub GenMakefile($$$$$) +{ + return if SkipICmd(); + my ($hdrfile, $mkfile, $filter, $prepros, $assignop) = + (GetAbsFname(shift()), GetAbsFname(shift()), shift(), shift(), shift()); + ChangeDir(GetDirname($hdrfile)); + RunSystemCmd("$prepros " . GetBasename($hdrfile)); + my $maxdef = Max(map(/^\s*\#define\s+($filter)/ && length($1), @gCmdoutbuf)); + WriteFile($mkfile, join('\n', + map(/^\s*\#define\s+($filter)\s*(.*?)\s*$/ ? sprintf("%-${maxdef}s $assignop %s", $1, $2 eq "" ? 1 : $2) : (), sort(@gCmdoutbuf))) . '\n', ""); +} + + +############################################################################### +# + +sub AddImageHeader($$$$$) +{ + return if SkipICmd(); + my ($file, $hdrfile, $hdrstr, $hdrsize, $align) = + (GetAbsFname(shift()), GetAbsFname(shift()), shift(), shift(), shift()); + + $hdrstr =~ s/\/\*.*?\*\///g; + $hdrstr =~ s/,\s*$//; + WriteFile($hdrfile, $hdrstr, "b"); + die("Invalid image header size: " . sprintf("0x%X", -s($hdrfile)) . " (!=$hdrsize).\n"), return + if -s($hdrfile) ne hex($hdrsize); + + $align = Max(hex($align), hex($hdrsize)) - hex($hdrsize); + WriteFile(">>$hdrfile", ("0," x ($align - 1)) . "0", "b") if $align; + Copy($file, ">>$hdrfile") if $file ne ""; +} + + +############################################################################### +# - my ($opt_cmdfile, $opt_incdir, $opt_logfile, $opt_printcmd, $opt_step, $opt_verbose, $opt_workdir) = - ( "", "", "", 0, "", 1, "."); - Getopt::Long::GetOptions( - "cmdfile=s" => \$opt_cmdfile, - "incdir=s" => \$opt_incdir, - "logfile=s" => \$opt_logfile, - "printcmd" => \$opt_printcmd, - "step=s" => \$opt_step, - "verbose=s" => \$opt_verbose, - "workdir=s" => \$opt_workdir, - "<>" => sub { $error .= ($error ? ", `@_'" : "Unknown imaker.pl option: `@_'") }); +sub Sleep($) +{ + return if SkipICmd(); + sleep(shift()); +} + + +############################################################################### +# + +sub FindSOSFiles($$$$) +{ + return if SkipICmd(); + + my ($dirs, $imgoby, $pluglog, $opt) = @_; + my ($file, %files) = ("", ()); + local $_; + + foreach my $dir (GlobFiles($dirs)) { + my ($featvar, @pluglog) = ("", Find($dir = GetAbsDirname($dir), $pluglog, "", 1, 0, $_)); + + foreach $file (@pluglog) { + OpenFile(*FILE, $file, 0) or warn("Can't read file `$file'.\n"), last; + while () { + last if !/^.+?\.pm: Initializing; /; + $featvar = $1, last if / feature variant = `(.+)'$/; + } + close(FILE); + last if ($featvar ne ""); + } - if ($opt_incdir) { - my $bsf = ($opt_incdir =~ s/:bsf$//); - print(map("$_\n", imaker::GetFeatvarIncdir($opt_incdir, $bsf))); - exit; + foreach $file (Find($dir, $imgoby, "", 1, 0, $_)) { + OpenFile(*FILE, $file, 0) or warn("Can't read file `$file'.\n"), last; + while () { + next if ($_ !~ FILESPECSTATEMENT) && ($_ !~ BOOTBINARYSTATEMENT); + $file = GetAbsFname(defined($1) ? $1 : $2); + $files{lc($file)} = $file if !exists($files{lc($file)}); + next if ($file !~ s/\.[0-9a-f]{32}\./\./i); + $file .= (-f("$file.$featvar.vmap") ? ".$featvar.vmap" : ".vmap"); + $files{lc($file)} = $file if !exists($files{lc($file)}); + } + close(FILE); + } + + my ($incfile, $spifile, $plugfile, $patchfile) = (0, 0, 0, 0); + foreach $file (@pluglog) { + OpenFile(*FILE, $file, 0) or warn("Can't read file `$file'.\n"), last; + while () { + $incfile = 1, next if /^Finding include hierarchy from /; + $incfile = 0, next if ($incfile && /^Found \d+ different include files$/); + $spifile = 1, next if /^Finding SPI input files from /; + $spifile = 0, next if ($spifile && /^Found \d+ SPI input files$/); + $plugfile = 1, next if /^Reading (ROM|ROFS1|UDEB|UREL) files from /; + $plugfile = 0, next if ($plugfile && /^Found \d+ entries$/); + $patchfile = 1, next if /^Finding ROM-patched components$/; + $patchfile = 0, next if ($patchfile && /^Found \d+ ROM-patched components$/); + $files{lc($file)} = $file, next + if (($incfile || $spifile || $plugfile) && /`(.+)'$/ && !exists($files{lc($file = GetAbsFname($1))})); + next if (!$patchfile || !/^`(.+)'$/); + $file = GetAbsFname($1) . ".map"; + $files{lc($file)} = $file, next if -f($file); + $file =~ s/(\..*?\.map)$/\.\*$1/; + foreach (glob($file =~ /\s/ ? "\"$file\"" : $file)) { + ($file = lc()) =~ s/\.map$//; + $files{lc()} = $_, last if exists($files{$file}); + } + } + close(FILE); + } + + $dir .= "/" if $dir !~ /\/$/; + foreach $file (keys(%files)) { + delete($files{$file}) if ($file =~ /^$dir/i); + } } - $opt_verbose = imaker::SetVerbose($opt_verbose); + @gFindresult = () if (!defined($opt) || $opt !~ /a/); + push(@gFindresult, values(%files)); +} + + +############################################################################### +# + +sub CheckTool(@) +{ + return if SkipICmd(); + my ($maxtlen, $maxvlen, @tools) = (4, 9, ()); + while (@_) { + my ($tool, $vquery, $getver, $version, $md5sum) = (shift(), shift(), shift(), " -", " ?"); + if (length($vquery) > 1) { + RunSystemCmd($vquery, 3, 1); + $version = (join("\n", @gCmdoutbuf) =~ eval($getver =~ /^\// ? "qr$getver" : "qr/$getver/ims") ? + (defined($1) && defined($2) && "`$1 $2'" || defined($1) && "`$1'" || " ?") : " ?"); + } + OpenFile(*FILE, $tool, 1) and $md5sum = "`" . md5_hex() . "'"; + close(FILE); + $maxtlen = Max($maxtlen, length($tool)); + $maxvlen = Max($maxvlen, length($version)); + push(@tools, "`$tool'", $version, $md5sum); + } + $maxtlen += 2; + @_ = (" Tool", " Version", " MD5 Checksum", "-" x $maxtlen, "-" x $maxvlen, "-" x 34, @tools); + DPrint(1, sprintf("%-${maxtlen}s %-${maxvlen}s ", shift(), shift()) . shift() . "\n") while(@_); +} + + +############################################################################### +# + +sub OpCacheInstall($$$) +{ + return if SkipICmd(); + my ($ini, $conf, $tmpdir) = @_; + my %opt = (-e => "", -i => "", -m => "", -o => "", -u => ""); - imaker::DPrint(2, "=" x 79 . "\nTIME: " . localtime() . ", USER: " . getlogin() . - ", HOST: " . ($ENV{HOSTNAME} || $ENV{COMPUTERNAME} || "?") . "\n$^X (v$perlver-$^O)\n"); + foreach $conf ("opcache_config=$conf", ($ini ne "" ? grep(!/^\s*#/, ReadFile($ini, 0)) : ())) { + (local $_, my $error, my %tmpopt) = ($conf, 0, %opt); + if (!($error = !(s/^\s*opcache_config\s*[=\s]//i || s/^\s*opcache_content\s*[=\s]/-i /i))) { + my @opt = ParseCmdWords($_); + while (@opt) { + last if ($error = ((($_ = shift(@opt)) !~ /^-[eimou]$/i) || + !defined($tmpopt{$_} = shift(@opt)))); + $tmpopt{$_} =~ s/EPOCROOT/$gEpocroot/g; + } + } + die("OpCacheInstall: Invalid configuration entry: `$conf'\n"), next if $error; + %opt = %tmpopt; + } + if (-d($opt{-i})) { + $opt{-i} = GetAbsDirname($opt{-i}); + } elsif (-f($opt{-i})) { + DeleteDir($tmpdir); + MakeDir($tmpdir); + RunSystemCmd("$gTool{unzip} x -y \"" . GetAbsFname($opt{-i}) . "\"" . + " -o\"" . ($tmpdir = GetAbsDirname($tmpdir)) . "\"", 0, 1); + $opt{-i} = $tmpdir; + } + RunSystemCmd("$gTool{opcache} -u \"$opt{-u}\" -e \"$opt{-e}\" -m \"" . + GetAbsFname($opt{-m}) . "\" -i \"$opt{-i}\" -o \"" . GetAbsDirname($opt{-o}) . "\""); +} + + +############################################################################### +# + +sub SisInstall($$$$$$$$) +{ + return if SkipICmd(); + + my ($ini, $intini, $conf, $hda, $hdata, $idata, $outdir, $log) = + (GetAbsFname(shift()), GetAbsFname(shift()), shift(), GetAbsFname(shift()), + shift(), shift(), GetAbsDirname(shift()), shift()); + my %gopt = (-d => "C", -k => "5.4", -w => "info", '--ignore-err' => 0); - imaker::SetLogfile($opt_logfile); - die("$error.\n") if $error; + my %haldata = (); + map { $haldata{uc($1)} = $2 if /^\s*(\S+)\s+(\S+)\s*$/ } split(/(?>$log"); + my $errmsg = join(" | ", grep(s/^ERR\s*:\s*//, @gCmdoutbuf)); + + $_ = join(", ", map(/^INFO:\s+Installing file:\s+\w:\\sys\\bin\\(.+?.exe)\s*$/io && + ($_ = $1) && (qx($gTool{elf2e32} --dump=h --e32input "$outdir/sys/bin/$_") =~ + /^Uids:\s+.+?\s+([0-9a-f]+)\s+\(/imo) ? "$_: " . uc($1) : (), @gCmdoutbuf)); + DPrint(16, "SisInstall: `" . GetBasename($opt{-s}) . "', exe UIDs: $_\n") + if ($_ && (!($error ||= $errmsg) || $opt{'--ignore-err'})); + + warn("Installation of SIS file `$opt{-s}' failed" . ($errmsg ? ": `$errmsg'.\n" : ".\n")) + if ($gErrwarn = $error); + next if (!$error || $opt{'--ignore-err'}); + $clean = 1; + warn("Removing installation of SIS file `$opt{-s}'.\n"); + RunSystemCmd("$icmd -x $puid", 3, 1, ">>$log"); + } } - die("$error.\n") if $error; + return if !$clean; + my $i = 0; + foreach (Find($outdir, "*", "", 1, 1, $_)) { + if (($i <= $#dir) && ($_ eq $dir[$i])) { $i++ } + else { DeleteDir($_) } + } +} + + +############################################################################### +# + +sub GetIPar(;$) +{ + my $par = shift(@gIcmd); + $par = ((my $empty = !defined($par)) ? "" : PEval($par)); + $gParamcnt = 0 if shift(); + DPrint(32, "iPar: $gParamcnt. `$par'\n") if $gParamcnt && ($gICmd =~ $gFiltercmd); + $gParamcnt++; + return($empty ? undef : $par); +} - imaker::SetWorkdir($opt_workdir); - imaker::ReadICmdFile($opt_cmdfile); +sub PEval($) +{ + local $_ = shift(); + while (/\@PEVAL{.*}LAVEP\@/) { + my $start = rindex($_, '@PEVAL{', my $end = index($_, '}LAVEP@') + 7); + my ($expr, $eval, $evalerr) = (substr($_, $start + 7, $end - $start - 14), undef, ""); + eval { + local $_; + local $gEvalerr = (SkipICmd() ? 1 : 2); + $eval = eval($expr); + ($evalerr = $@) =~ s/^(.+?) at .*/$1/s; + }; +# DPrint(64, "PEval: Evaluate `$expr' = `" . (defined($eval) ? $eval : "") . "'\n"); + if (!defined($eval)) { + $eval = ""; + warn("PEval: Evaluation of `$expr' failed: $evalerr.\n") if !SkipICmd(); + } + substr($_, $start, $end - $start) = $eval; + } + return($_); +} + +sub PeekICmd($) +{ + return(defined($gIcmd[0]) && $gIcmd[0] =~ /^$_[0]$/i); +} + +sub SkipICmd() +{ + return($gPrintcmd || defined($gICmd) && ($gICmd !~ $gFiltercmd)); +} - my (@step, @stepdur) = (split(/-+/, lc($opt_step)), ()); - my ($durstr, $maxslen, $maxdlen) = ("", 6, 8); +sub GetICmd() +{ + $gICmd = GetIPar(1); + DPrint(32, "iCmd: " . ++$gCmdcnt . ". `$gICmd'\n") if defined($gICmd) && ($gICmd ne "") && ($gICmd =~ $gFiltercmd); +} + +sub EndICmd() +{ + GetICmd(), return(1) if !defined($gIcmd[0]) || PeekICmd("end"); + return(0); +} + + +############################################################################### +# + +sub SplitStep($) +{ + (my $step = shift()) =~ s/(?>?([^>].*)$/ ? $1 : $gLogfile, "f") : (), + SplitStep($gStepIcmd{"REPORT_$gStep"})) if exists($gStepIcmd{"REPORT_$gStep"}); + + foreach my $step ("INIT_$gStep", "CLEAN_$gStep", "BUILD_$gStep") { + next if (!exists($gStepIcmd{$step}) || $gStepIcmd{$step} =~ /^\s*$/); + DPrint(64, "$step = `$gStepIcmd{$step}'\n"); + @gIcmd = SplitStep($gStepIcmd{$step}); + my ($file, $iferror, @iffi) = ("", 0, ()); - foreach my $stepnum (0 .. $#step) { - $step[$stepnum] =~ /^(\w+):?([cbk\d]+)?$/; - my $step = uc($1); - $_ = (defined($2) ? $2 : ""); - my @dur = imaker::MakeStep($step, /c/, /b/, /k/, /(\d+)/ ? $1 : $opt_verbose, $opt_printcmd); - imaker::SetVerbose($opt_verbose); - my ($cmddur, $stepdur) = (0, pop(@dur)); - $durstr = imaker::Sec2Min($stepdur); - if (@dur) { - $durstr .= " ("; - foreach my $dur (@dur) { - $cmddur += $dur; - $durstr .= imaker::Sec2Min($dur) . " + "; + while (GetICmd(), defined($gICmd)) { + next if (local $_ = lc($gICmd)) eq ""; + if (/^if$/) { + push(@iffi, (my $if = GetIPar()), $gFiltercmd); + $gFiltercmd = qr/^X$/ if !$if; + } + elsif (/^else$/) { + $gFiltercmd = ($iffi[$#iffi - 1] ? qr/^X$/ : $iffi[$#iffi]); + } + elsif (/^fi$/) { + $gFiltercmd = pop(@iffi); + pop(@iffi); + } + elsif (/^(error|warning)$/) { + my ($errwarn, $msg) = (GetIPar(), GetIPar() . "\n"); + next if SkipICmd(); + die($msg) if $errwarn && /e/; + warn($msg) if $errwarn && /w/; + } + elsif (/^echo(\d+)?(-q)?$/) { + Echo((defined($1) && ($1 < 128) ? $1 : 1), GetIPar(), defined($2)); + } + elsif (/^filter$/) { + $gOutfilter = GetIPar(); + } + elsif (/^cmd(tee)?(-(k[0123]?|n)+)?$/) { + RunSystemCmd(GetIPar(), (/k(\d)/ ? int($1) : (/k/ ? 1 : 0)), /n/, /tee/ ? GetIPar() : ""); + } + elsif (/^parse(f)?(?:-(\d+))?$/) { + ParseSystemCmd(GetIPar(), GetIPar(), GetIPar(), $1, $2); + } + elsif (/^(cd|copy(dir|iby)?|del(dir)?|find(dir)?(-[afr]+)?|headb|logfile|mkcd|mkdir|move|tailb|test|touch|type[bu]?|unzip|workdir|write[bu]?(-[cq]+)?|zip(dir)?(-[jq]+)?)$/) { + my @files = GlobFiles(GetIPar()); + my $par1 = GetIPar() if /^(?:copy|find|head|move|tail|touch|(un)?zip|write)/; + my $par2 = GetIPar() if /^(?:find|head|tail|zip)/; + next if SkipICmd(); + @gFindresult = () if /find(?:dir)?(-[afr]+)?/ && (!defined($1) || ($1 !~ /a/)); + Touch($par1, @files), next if /touch/; + foreach $file (@files) { + ChangeDir($file) if /^cd/; + DeleteDir($file) if /deldir/; + FindDir($file, $par1, $par2, $1) if /finddir(-[ar]+)?/; + MakeDir($file) if /mkdir/; + MakeChangeDir($file) if /mkcd/; + SetWorkdir($file) if /workdir/; + Zip($file, 1, $1, $par2, GlobFiles($par1)) if /zipdir(-[jq]+)?/; + DeleteFile($file) if /del/; + FindFile($file, $par1, $par2, $1) if /find(-[afr]+)?$/; + HeadFile($file, $par1, $par2) if /headb/; + SetLogfile($file) if /logfile/; + TailFile($file, $par1, $par2) if /tailb/; + TypeFile($file, $1) if /type(b|u)?/; + UnzipFile($file, $par1) if /unzip/; + WriteFile($file, $par1, $1, $2) if /write(b|u)?(-[cq]+)?/; + Zip($file, 0, $1, $par2, GlobFiles($par1)) if /^zip(-[jq]+)?$/; + Copy($file, $par1, $1) if /copy(dir)?$/; + CopyIby($file, $par1) if /copyiby/; + Move($file, $par1) if /move/; + Test($file) if /test/; + } + } + elsif (/^filtercmd$/) { + $gFiltercmd = GetIPar(); + $gFiltercmd = ($gFiltercmd eq "" ? qr/\S/ : qr/$gFiltercmd/i); + } + elsif (/^genexclst$/) { + GenExclfile(GetIPar(), GetIPar(), GetIPar(), GetIPar(), GetIPar()); + } + elsif (/^geniby(-[dr]+)?$/) { + my ($opt, $iby, $dir, @par) = ($1 || "", GetIPar(), GetIPar(), ()); + push(@par, GetIPar(), GetIPar()) while !EndICmd(); + GenObyfile($iby, $dir, $opt =~ /r/, $opt =~ /d/ ? 2 : 0, @par); + } + elsif (/^genorideiby$/) { + GenIbyfile(GetIPar(), GetIPar(), GetIPar()); + } + elsif (/^genmk$/) { + GenMakefile(GetIPar(), GetIPar(), GetIPar(), GetIPar(), GetIPar()); + } + elsif (/^genwgzcfg$/) { + GenWidgetConf(GetIPar(), GetIPar(), GetIPar(), GetIPar()); + } + elsif (/^iferror$/) { + $iferror++; + $gError = 0, next if $gError; + while (defined($gIcmd[0])) { + GetICmd(), last if PeekICmd("endif") && !--$iferror; + $iferror++ if shift(@gIcmd) =~ /^iferror$/i; + } + } + elsif (/^endif$/ && $iferror--) { + } + elsif (/^imghdr$/) { + AddImageHeader(GetIPar(), GetIPar(), GetIPar(), GetIPar(), GetIPar()); + } + elsif (/^pause$/) { + DPrint(0, "Press Enter to continue...\n"); + getc(); + } + elsif (/^sleep$/) { + Sleep(GetIPar()); + } + elsif (/^sosfind(-a)?$/) { + my $opt = $1; + FindSOSFiles(GetIPar(), GetIPar(), GetIPar(), $opt); + } + elsif (/^tool-(\w+)$/) { + $gTool{$1} = GetIPar(); +# DPrint(2, "SetTool: $1: `$gTool{$1}'\n"); + } + elsif (/^toolchk$/) { + my @tools = (); + push(@tools, GetIPar(), GetIPar(), GetIPar()) while !EndICmd(); + CheckTool(@tools); + } + elsif (/^opcache$/) { + OpCacheInstall(GetIPar(), GetIPar(), GetIPar()); + } + elsif (/^sisinst$/) { + SisInstall(GetIPar(), GetIPar(), GetIPar(), GetIPar(), + GetIPar(), GetIPar(), GetIPar(), GetIPar()); + } + elsif (!$gImakerext || !RunIExtCmd($_)) { + die("Unknown iMaker command `$gICmd'.\n"); } - $durstr .= imaker::Sec2Min($stepdur - $cmddur) . ")"; + } + } + DPrint(2, "EXIT: `$gStep', duration: " . Sec2Min($dur = time() - $dur) . "\n"); + push(@gStepDur, $dur); +} + + +############################################################################### +# + +sub GetConfmkList(;$) +{ + if (!%gConfmkList) { + my ($dir, $incl, $excl, $depth) = split(/,/, $ENV{IMAKER_MKCONF}); + $dir = GetAbsDirname($dir, 0, 1, $gEpocdrive); + ($incl, $excl) = (qr/$incl/, qr/$excl/); + local $_; + DPrint(16, "FindFile: GetConfmkList: `$ENV{IMAKER_MKCONF}'"); + find(sub { $gConfmkList{$1} = $File::Find::name + if (/$incl/ && !/$excl/ && (($File::Find::name =~ tr/\///) > (($dir =~ tr/\///) + $depth))); + }, $dir); + DPrint(16, ", found " . keys(%gConfmkList) . " files\n"); + $gConfmkList{""} = "" if !%gConfmkList; + } + return(sort({lc($a) cmp lc($b)} grep($_ ne "", values(%gConfmkList)))) if shift(); +} + +sub GetFeatvarIncdir($) +{ + open(FILE, "$gEpocroot/epoc32/tools/variant/" . shift() . ".var") or + return("Invalid SBV feature variant"); + my @featdata = ; + close(FILE); + my @incdir = ("@featdata" =~ /^\s*EXTENDS\s+(.+?)\s*$/m ? GetFeatvarIncdir($1) : ()); + @incdir = () if ("@incdir" =~ /^Invalid/); + foreach (@featdata) { + next if !/^\s*ROM_INCLUDE\s+(\S+)\s+(.+?)\s*$/; + if ($1 eq "set") { @incdir = ($2) } + elsif ($1 eq "prepend") { unshift(@incdir, $2) } + elsif ($1 eq "append") { push(@incdir, $2) } + } + return(map("$_/" =~ /^$gEpocroot\// ? $_ : $gEpocroot . PathConv($_, 0, 1, $gEpocdrive), + map(PathConv($_, 0, 0, $gEpocdrive), @incdir))); +} + + +############################################################################### +# + +sub SetVerbose($;$) +{ + my $verbose = Trim(shift()); + $verbose = 127 if $verbose =~ /^debug$/i; + $gVerbose = int($1), return if ($verbose =~ /^(\d+)$/) && ($1 < 128); + $gVerbose = 1; + warn("Verbose level `$verbose' is not integer between 0 - 127\n") if !shift(); +} + +sub CloseLog() +{ + close(LOG) if $gLogfile; + $gLogfile = ""; +} + + +############################################################################### +# + +sub RunIMakerCmd($$$$$@) +{ + my ($makecmd, $cmdarg, $tgtext, $mklevel, $skipsteps, %prevtgt) = @_; + $ENV{IMAKER_MKLEVEL} = $mklevel; + + ($cmdarg, my $hptgt, my @targets) = HandleCmdArg($cmdarg); + + foreach my $tgt (@targets) { + my $skipstep = ($tgt =~ s/#$//) || $skipsteps; + (my $target = "$tgt$tgtext") =~ s/(\[\d+\])(.+)$/$2$1/; + if ($target eq "menu") { + ($cmdarg, $target) = Menu($cmdarg); + next if ($target eq "menu"); + ($cmdarg) = HandleCmdArg($cmdarg); } - $step = sprintf("%" . length(@step."") . "s", $stepnum + 1) . ". $step"; - push(@stepdur, $step, $durstr); - $maxslen = imaker::Max($maxslen, length($step)); - $maxdlen = imaker::Max($maxdlen, length($durstr)); + $prevtgt{$target =~ /^([^-]+)/ ? $1 : $target} = 1; + push(@gReport, Trim((($target !~ /^(.+)\[\d+\]$/) || ($gVerbose & 64) ? $target : $1) . + ($skipstep ? "#" : "") . " $hptgt"), -1, -$mklevel - 1); + my $tgtind = $#gReport; + my @targets = RunMakeCmd("$makecmd $cmdarg" . ($target eq "defaultgoals" ? "" : " \"$target\"") . + join("", map(" \"$_\"", split(/\s+/, $hptgt))), $skipstep); + $gReport[$tgtind - 2] .= " (intermediate)" if @targets; + $gReport[$tgtind - 1] = pop(@gStepDur); + $gReport[$tgtind] = $mklevel + 1 if !$gError; + delete(@gReport[$tgtind - 2 .. $tgtind]) if (@targets && !$gError && !($gVerbose & 64)); + map { + RunIMakerCmd($makecmd, "$cmdarg $_ $hptgt", $target =~ /(-.*)$/ ? $1 : "", $mklevel + 1, $skipstep, %prevtgt) + if !exists($prevtgt{$_}); + } @targets; + } +} + +sub RunMakeCmd($$) +{ + ($gStartmk, $gMakecmd, $gError) = (time(), Trim(shift()), 0); + my ($skipstep, $mkstart, $start, $restart, $cwd, %env) = (shift(), 0, 0, 0, Cwd::cwd(), %ENV); + my @stepdur = my @targets = (); + $ENV{IMAKER_MKRESTARTS} = -1; + + do { + InitMkglobals(); + ($gTgterr, my $printvar, my @steps) = (1, "", ()); + $ENV{IMAKER_MKRESTARTS}++; + + if ($gExportvar{""}) { + if (!$ENV{IMAKER_EXPORTMK}) { + (my $tmpfh, $ENV{IMAKER_EXPORTMK}) = File::Temp::tempfile( + File::Spec->tmpdir() . "/imaker_temp_XXXXXXXX", SUFFIX => ".mk", UNLINK => 1); + close($tmpfh); + $ENV{IMAKER_EXPORTMK} =~ tr-\\-\/-; + } + WriteFile($ENV{IMAKER_EXPORTMK}, "# Generated temporary makefile `$ENV{IMAKER_EXPORTMK}'\n" . + "ifndef __IMAKER_EXPORTMK__\n__IMAKER_EXPORTMK__ := 1\n" . + join("", map(/^([^:]+)(?:\:(.+))?$/ && !defined($2) ? "$1=$gExportvar{$_}\n" : + "ifeq (\$(filter $1,\$(TARGETNAME)),)\n$2=$gExportvar{$_}\nendif\n", + sort({($a =~ /([^:]+)$/ && uc($1)) cmp ($b =~ /([^:]+)$/ && uc($1))} + grep(!/^(?:|.*[+:?])$/, keys(%gExportvar))))) . + "else\n" . + join("", map(/^\d{3}(.+[+:?])$/ ? "$1=$gExportvar{$_}\n" : (), sort({$a cmp $b} keys(%gExportvar)))) . + "endif # __IMAKER_EXPORTMK__\n", "", "q", 1); + $gExportvar{""} = 0; + } + + open(MCMD, "$gMakecmd 2>&1 |"); + while (local $_ = ) { + chomp(); + DPrint(1, "$_\n"), next if !s/^#iMaker\x1E//; +# DPrint(64, "#iMaker#$_\n"); + + if (/^BEGIN$/) { + $mkstart = time(); + $start = $mkstart if !$start; + next; + } + if (/^STEPS=(.*)$/) { + my $steps = $1; + @steps = split(/\s+/, $steps), next if ($steps !~ s/^target://); + @targets = grep($_ ne "", map(Trim($_), split(/(?> 8); + die("Command `$gMakecmd' failed in `" . GetAbsDirname(".") . "'.\n") if ($gTgterr = $gError); + CloseLog(); + } until !$restart; + push(@gStepDur, time() - $gStartmk); + return(@targets); +} + + +############################################################################### +# + +sub HandleCmdArg($) +{ + my $cmdarg = shift(); + my $origarg = $cmdarg = (defined($cmdarg) ? $cmdarg : ""); + + my @cmdout = qx($ENV{PERL} -x $0 --splitarg $cmdarg); + die("Can't parse Make arguments: `$cmdarg'.\n") if $?; + + map { + chomp(); + s/ /\x1E/g; + s/\"/\\\"/g; + s/(\\+)$/$1$1/; + } @cmdout; + $cmdarg = " " . join(" ", @cmdout) . " "; + + if ($cmdarg =~ /^.* VERBOSE\x1E*=(\S*) /) { + (my $verbose = $1) =~ s/\x1E/ /g; + SetVerbose($verbose, 1); } - imaker::DPrint(2, "=" x 79 . "\n"); - @stepdur = ("Step", "Duration", "=" x $maxslen, "=" x $maxdlen, @stepdur, - "-" x $maxslen, "-" x $maxdlen, "Total", imaker::Sec2Min(time() - $start)); - imaker::DPrint(2, sprintf("%-${maxslen}s %-${maxdlen}s ", shift(@stepdur), shift(@stepdur)) . "\n") - while(@stepdur); + if ($cmdarg =~ /\s+--?conf=(\S*)\s+/) { + (my $prj = $1) =~ /(.*?)(?:;(.*))?$/; + ($prj, my $conf) = ($1, defined($2) ? $2 : ""); + $cmdarg =~ s/\s+--?conf=\S*\s+/ USE_CONE=mk CONE_PRJ=$prj CONE_CONF=$conf cone-pre defaultgoals /; + } + + $cmdarg = " " . HandleExtCmdArg($cmdarg) . " " if $gImakerext; + + $gMakecmd = "$ENV{IMAKER_MAKE} -f $0" . join("", map(" \"$_\"", split(/\s+/, Trim($cmdarg)))); + warn("Can't parse Make targets.\n") + if (!(my $targets = (qx($gMakecmd 2>&1) =~ /\|MAKECMDGOALS=(.*?)\|/ ? " $1 " : "")) && + ($cmdarg !~ /\s-(?:-?v(?:ersion?|ersi?|er?)?|versio\S+)\s/)); + + GetConfmkList() if + grep(!/^(help(-.+)?|print-.+)$/ || /^help-config$/, my @targets = split(/\s+/, Trim($targets))); + + my ($mkfile, $mkfiles, $hptgt) = ("", "", ""); + map { + $cmdarg =~ s/\s+\Q$_\E\s+/ /; + if (exists($gConfmkList{$_})) { + ($mkfile = $gConfmkList{$_}) =~ s/ /\x1E/g; + $mkfiles .= " -f $mkfile"; + $targets =~ s/\s+\Q$_\E\s+/ /; + } + } @targets; + $cmdarg = "$mkfiles$cmdarg"; + + map { $targets =~ s/\s\Q$_\E\s/ /; $hptgt .= " $_" } + grep(/^help-.+$/ && !/^help-config$/, @targets); + map { $targets =~ s/\s\Q$_\E\s/ /; $hptgt .= " $_" } + grep(/^print-.+$/, @targets); + $hptgt = Trim($hptgt); - imaker::CloseLog(); + if ($targets =~ s/ default(?= )//g) { + ($targets = Trim($targets)) =~ s/ /\x1E/g; + $cmdarg .= "TARGET_DEFAULT=$targets" if ($targets ne ""); + $targets = "default"; + } + @targets = ("defaultgoals@targets") if + !(@targets = map(s/\x1E/ /g ? $_ : $_, split(/\s+/, Trim($targets)))) || ("@targets" eq "#"); + + $mkfiles = ""; + while ($cmdarg =~ s/\s+(-f\s?|--(?:file?|fi?|makefile?|makefi?|make?)[=\s]|IMAKER_CONFMK\x1E*=)(\S+)\s+/ /) { + $mkfile = $2; + ($mkfile = GetAbsFname(scalar($mkfile =~ s/\x1E/ /g, $mkfile))) =~ s/ /\\\x1E/g + if ($1 !~ /^IMAKER_CONFMK/); + $mkfiles .= ($mkfiles eq "" ? "" : chr(0x1E)) . $mkfile; + } + while ($cmdarg =~ s/\s+(\S+?)\x1E*([+:?])=\x1E*(\S+?)\s+/ /) { + ($gExportvar{sprintf("%03s", ++$gExportvar{""}) . "$1$2"} = $3) =~ s/\x1E/ /g; + } + $cmdarg = join(" ", map(scalar(s/\x1E/ /g, "\"$_\""), split(/\s+/, Trim($cmdarg . + ($mkfiles eq "" && ($ENV{IMAKER_MKLEVEL} || grep(/^default$/, @targets)) ? "" : " IMAKER_CONFMK=$mkfiles"))))); + + DPrint(2, "HandleCmdArg: `$origarg' => `$cmdarg', `" . join(" ", @targets) . "', `$hptgt'\n"); + return($cmdarg, $hptgt, @targets); +} + + +############################################################################### +# + +sub MenuRuncmd($) +{ + $ENV{IMAKER_CMDARG} = shift(); + return(map(chomp() ? $_ : $_, qx($ENV{PERL} -x $0 2>&1))); } +sub Menu($) +{ + (my $cmdarg = " " . shift() . " ") =~ s/\s+"IMAKER_CONFMK="\s+/ /; + my ($prodind, $product, @product) = (0, "", ()); + my ($tgtind, $target, $tgtcols, $tgtrows, @target) = (0, "", 4, 0, ()); + my ($vartype, $varudeb, $varsym); + my $cfgfile = "./imaker_menu.cfg"; + + $cmdarg = ($cmdarg =~ /^\s*$/ ? "" : " " . Trim($cmdarg)); + open(FILE, "<$cfgfile") and + (($prodind, $tgtind, $vartype, $varudeb, $varsym) = map(chomp() ? $_ : $_, )) and close(FILE); + ($prodind, $tgtind, $vartype, $varudeb, $varsym) = + ($prodind || 0, $tgtind || 0, $vartype || "rnd", $varudeb || 0, $varsym || 0); + + while (1) { + print("\nPRODUCTS\n--------\n"); + # + if (!@product) { + @product = sort({lc($a) cmp lc($b)} grep($_ ne "", keys(%gConfmkList))); + $prodind = 0 if ($prodind > @product); + } + $product = ($prodind ? " $product[$prodind - 1]" : ""); + my $maxlen = Max(map(length($_), @product)); + map { + printf(" %" . (length(@product)) . "s) %-${maxlen}s %s\n", $_ + 1, $product[$_], $gConfmkList{$product[$_]}); + } (0 .. $#product); + print(" NO PRODUCTS FOUND!\n") if !@product; + + print("\nTARGETS\n-------\n"); + # + if (!@target) { + @target = grep(s/^== (.+) ==$/$1/, MenuRuncmd("$product PRINTCMD=0 VERBOSE=1 help-target-*-wiki")); + $tgtind = 0 if ($tgtind > @target); + $tgtrows = int($#target / $tgtcols + 1); + my $maxind = 0; + map { + if (!($_ % $tgtrows)) { + $maxind = length(Min($_ + $tgtrows, $#target + 1)) + 1; + $maxlen = Max(map(length(), @target[$_ .. Min($_ + $tgtrows - 1, $#target)])); + } + $target[$_] = sprintf("%${maxind}s) %-${maxlen}s", "t" . ($_ + 1), $target[$_]); + } (0 .. $#target); + } + ($target = ($tgtind ? $target[$tgtind - 1] : "")) =~ s/^.+?(\S+)\s*$/$1/; + foreach my $row (1 .. $tgtrows) { + foreach my $col (1 .. $tgtcols) { + my $ind = ($col - 1) * $tgtrows + $row - 1; + print(($ind < @target ? " $target[$ind]" : "") . ($col != $tgtcols ? " " : "\n")); + } + } + print(" NO TARGETS FOUND!\n") if !@target; + + print("\nCONFIGURATION\n-------------\n"); + # + print( + " Product: " . ($prodind ? $product[$prodind - 1] : "NOT SELECTED!") . "\n" . + " Target : " . ($tgtind ? $target : "NOT SELECTED!") . "\n" . + " Type : " . ucfirst($vartype) . "\n" . + " Debug : " . ($varudeb ? ($varudeb =~ /full/i ? "Full debug" : "Enabled") : "Disabled") . "\n" . + " Symbols: " . ($varsym ? "Created\n" : "Not created\n")); + + print("\nOPTIONS\n-------\n"); + # + print( + " t) Toggle type between rnd/prd/subcon\n" . + " u) Toggle debug between urel/udeb/udeb full\n" . + " s) Toggle symbol creation on/off\n" . + " r) Reset configuration\n" . + " h) Print usage information\n" . + " x) Exit\n\n" . + "Hit Enter to run: imaker$product$cmdarg TYPE=$vartype USE_UDEB=$varudeb USE_SYMGEN=$varsym $target\n"); + + print("\nSelection: "); + # + my $input = ; + ($input = (defined($input) ? $input : "?")) =~ s/^\s*(.*?)\s*$/\L$1\E/; + + if ($input =~ /^(\d+)$/ && ($1 > 0) && ($1 <= @product) && ($1 != $prodind)) { + $prodind = $1; + ($tgtind, @target) = (0, ()); + } + elsif ($input =~ /^t(\d+)$/ && ($1 > 0) && ($1 <= @target) && ($1 != $tgtind)) { + $tgtind = $1; + } + elsif ($input eq "t") { + $vartype = ($vartype =~ /rnd/i ? "prd" : ($vartype =~ /prd/i ? "subcon" : "rnd")); + } + elsif ($input eq "u") { + $varudeb = (!$varudeb ? 1 : ($varudeb !~ /full/i ? "full" : 0)); + } + elsif ($input eq "s") { + $varsym = ($varsym ? 0 : 1); + } + elsif ($input eq "r") { + ($prodind, @product) = (0, ()); + ($tgtind, @target) = (0, ()); + ($vartype, $varudeb, $varsym) = ("rnd", 0, 0); + } + elsif ($input eq "h") { + print("\nTODO: Help"); + sleep(2); + } + elsif ($input =~ /^(x|)$/) { + open(FILE, ">$cfgfile") and + print(FILE map("$_\n", ($prodind, $tgtind, $vartype, $varudeb, $varsym))) and close(FILE); + return(("", "menu")) if ($input eq "x"); + $cmdarg = "$product$cmdarg TYPE=$vartype USE_UDEB=$varudeb USE_SYMGEN=$varsym"; + $ENV{IMAKER_CMDARG} = Trim("$cmdarg $target"); + return(($cmdarg, $target eq "" ? "defaultgoals" : $target)); + } + } +} + + +############################################################################### +# + +sub Install($$$) +{ + my ($clean, $bldinf, $destdir) = @_; + my $srcdir = GetDirname($bldinf = GetAbsFname($bldinf)); + $destdir = GetAbsDirname($destdir) if $destdir; + + print(($clean ? "\nCleaning" : "\nInstalling") . " `$bldinf'" . ($destdir ? " to `$destdir'\n" : "\n")); + + my $export = 0; + foreach (grep(!/^\s*\/\//, ReadFile($bldinf, 0))) { + $export = 1, next if /^\s*PRJ_EXPORTS\s*$/i; + next if !$export; + Install($clean, "$srcdir$1", $destdir), next if /^\s*#include\s+"(.+)"\s*$/; + die("Unknown line `$_'.\n") if !/^\s*(\S+)\s+(.+?)\s*$/; + my ($src, $dest) = ("$srcdir$1", $2); + $dest = "$gEpocroot/epoc32$dest" if ($dest =~ s/^\+//); + $dest .= GetBasename($src) if ($dest =~ s/\s+\/\/$//); + ($src, $dest) = (GetAbsFname($src), GetAbsFname($dest)); + next if ($destdir && ($dest !~ /^$gEpocroot\/epoc32\/tools\//i)); + $dest = "$destdir/" . GetBasename($dest) if $destdir; + print(($clean ? "Delete" : "Copy `$src' =>") . " `$dest'\n"); + unlink($dest); + die("Deletion failed.\n") if ($clean && -e($dest)); + next if $clean; + File::Path::mkpath(GetDirname($dest)); + File::Copy::copy($src, $dest) or die("Copying failed.\n"); + chmod(0777, $dest); + } +} + + +############################################################################### +# + +END { + if (!$gArgv) { + (my $keepgoing, $gStartmk) = ($gKeepgoing, time() - $gStartmk); + $gKeepgoing = 1; + SetLogfile($gLogfiles{__prev__}) if %gLogfiles; + PrintEnv(0) if $gError; + die("Command `$gMakecmd' failed in `" . GetAbsDirname(".") . "'.\n") + if ($gTgterr && !$keepgoing); + + map { UnsubstDrive($_) } sort({$a cmp $b} keys(%gSubstdrv)); + + @gIcmd = @gReport; + (my $report, @gReport) = (2, ()); + my ($maxtlen, $maxvlen, %uniq) = (0, 0, ()); + while (@gIcmd) { + my ($tgtvar, $durval, $type) = (GetIPar(1), GetIPar(1), GetIPar(1)); + if ($type =~ /^-?\d+$/) { + push(@gReport, [$tgtvar, $durval, $type]); + ($maxtlen, %uniq) = (Max($maxtlen, length($tgtvar)), ()); + } else { + $report = 1, push(@gReport, [$tgtvar, $durval, $type]) + if ($tgtvar ne "") && !($uniq{"$tgtvar|$durval"}++); + $maxvlen = Max($maxvlen, length($tgtvar)); + } + } + + my ($tgtcnt, $warn) = (0, 0); + DPrint($report, "=" x 79 . "\n" . join("\n", map(@$_[2] =~ /^-?\d+$/ ? + ($tgtcnt++ ? "-" x 79 . "\n" : "") . + "Target: " . sprintf("%-${maxtlen}s", @$_[0]) . + " Duration: " . Sec2Min(@$_[1] < 0 ? $gStartmk : @$_[1]) . + " Status: " . (@$_[2] < 0 ? ($warn = "FAILED") : "OK") + : sprintf("%-${maxvlen}s", @$_[0]) . " = `@$_[1]'" . + ((@$_[2] =~ /^[fd]$/i) && !-e(@$_[1]) ? " - DOESN'T EXIST" : ""), @gReport)) . + (@gReport ? "\n" . "-" x 79 . "\n" : "") . + "Total duration: " . Sec2Min(time() - $gStarttime) . + " Status: " . ($gError && !$keepgoing ? "FAILED" : "OK" . + ($warn ? " (with keep-going)" : "")) . + "\n" . "=" x 79 . "\n"); + + warn("\$_ has been changed in an uncontrolled manner!\n") + if !/^default input and pattern-searching space$/; + CloseLog(); + exit(1) if ($gError && !$keepgoing); + } +} + + __END__ # OF IMAKER.PL diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker.pm --- a/imgtools/imaker/src/imaker.pm Wed Jun 23 17:27:59 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1462 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of the License "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: iMaker common Perl routines -# - - - -use subs qw(CORE::GLOBAL::die); - -package imaker; - -use strict; -use warnings; -use Archive::Zip qw(:ERROR_CODES); -use Archive::Zip::Tree; -use Cwd; -use Digest::MD5 qw(md5_hex); -use File::Basename; -use File::Copy; -use File::Find; -use File::Path; -use File::Spec; -use POSIX qw(strftime); -use Time::Local; -use XML::Simple; - -sub Max(@); -sub Min(@); -sub Quote($); -sub Unquote($); -sub Byte2Str($@); -sub Str2Byte($); -sub Str2Xml($); -sub Ascii2Uni($); -sub Uni2Ascii($); -sub GetTimestamp(); -sub Sec2Min($); -sub Wcard2Restr($); -sub Wcard2Regex($); -sub DPrint($@); -sub Echo($$$); -sub PathConv($;$$); -sub ParseFiles($); -sub GlobFiles($); -sub GetBasename($); -sub GetDirname($); -sub GetAbsDirname($;$$); -sub GetAbsFname($;$$); -sub GetRelFname($;$$$); -sub GetWriteFname($); -sub GetFreeDrive(); -sub Search($$$$$\@\$); -sub Find($$$$$\$); -sub ChangeDir($); -sub DeleteDir($;$); -sub FindDir($$$$); -sub MakeDir($); -sub MakeChangeDir($); -sub SetWorkdir($); -sub OpenFile(*$$;$); -sub Test($); -sub CutFile($$$$$); -sub Copy($$;$); -sub DeleteFile($;$); -sub FindFile($$$$); -sub HeadFile($$$); -sub TailFile($$$); -sub TypeFile($;$); -sub WriteFile($$$;$); -sub UnzipFile($$); -sub Zip($$$$@); -sub Move($$); -sub Touch($$); -sub SetLogfile($); -sub WidgetUnzip($$$); -sub RunSystemCmd($$;$); -sub ParseSystemCmd($$$); -sub GenExclfile($$$$$); -sub GenIbyfile($$$@); -sub GenMakefile($$$$$); -sub AddImageHeader($$$$$); -sub Sleep($); -sub FindSOSFiles($$$$$); -sub CheckTool(@); -sub GetIPar(); -sub PeekICmd($); -sub GetICmd(); -sub EndICmd(); -sub RunICmd(); -sub RunIExtCmd($); -sub GetFeatvarIncdir($;$); -sub SetVerbose($); -sub ReadICmdFile($); -sub CloseLog(); -sub MakeStep($$$$$$); -sub HandleCmdArg($); -sub HandleExtCmdArg($); -sub MenuRuncmd($); -sub Menu($$$); - -use constant READBUFSIZE => 2097152; # 2 MB - -our $STARTSTR = '>>>[START]=========8<==========8<==========8<==========8<==========8<=========='; -our $ENDSTR = '==========>8==========>8==========>8==========>8==========>8===========[END]<<<'; - -our $gBuflog = 1; -our $gCmdcnt = 0; -our @gCmdoutbuf = (); -our $gEpoc32; -our @gFindresult = (); -our $gError = 0; -our @gIcmd = (); -our $gImakerext = 0; -our $gKeepgoing = 0; -our @gLogbuf = (); -our $gLogfile = ""; -our $gMakestep = ""; -our $gOutfilter = ""; -our $gParamcnt = 0; -our $gPrintcmd = 0; -our @gStepDur = (); -our %gStepIcmd = (); -our $gVerbose = 1; -our $gWarn = 0; -our $gWinOS = ($^O =~ /win/i); -our $gWorkdir = ""; -our $gWorkdrive = (Cwd::cwd() =~ /^([a-z]:)/i ? $1 : ""); -our @iVar = (); # General purpose variable to be used from $(call peval,...) - -BEGIN { - ($gEpoc32 = "$ENV{EPOCROOT}epoc32") =~ tr/\\/\//; - push(@INC, "$gEpoc32/tools"); - eval { require featurevariantparser }; -} - - -############################################################################### -# - -sub Max(@) -{ - my $max = (shift() || 0); - map { $max = $_ if $_ > $max } @_; - return($max); -} - -sub Min(@) -{ - my $min = (shift() || 0); - map { $min = $_ if $_ < $min } @_; - return($min); -} - -sub Quote($) -{ - local $_ = shift(); - return("") if !defined(); - s/\\( |n|t)/\\\\$1/g; - return($_); -} - -sub Unquote($) -{ - local $_ = shift(); - return("") if !defined(); - s/(?'"', '&'=>'&', "'"=>''', '<'=>'<', '>'=>'>'}->{$1} || $1/ge; - return($str); -} - -sub Ascii2Uni($) -{ - (local $_ = shift()) =~ s/(?".*", "?"=>"."}->{$1} || "\Q$1\E"/ge; - return($wcard); -} - -sub Wcard2Regex($) -{ - my $restr = Wcard2Restr(shift()); - return(qr/$restr/i); -} - - -############################################################################### -# - -sub DPrint($@) -{ - my ($verbose, @outlist) = @_; - map { tr/\x00\x1F/#/ } @outlist; - print(@outlist) if !$verbose || ($verbose & $gVerbose); - push(@gLogbuf, @outlist) if ($verbose < 32) || ($verbose & $gVerbose); - return if $gBuflog && !$gLogfile; - print(LOG @gLogbuf) if $gBuflog; - @gLogbuf = (); -} - -sub Echo($$$) -{ - return if $gPrintcmd; - my ($verbose, $str) = (shift(), shift()); - DPrint($verbose, shift() ? "$str\n" : Unquote($str)); -} - - -############################################################################### -# - -# Overload die -*CORE::GLOBAL::die = sub { - $gError = 1; - return if PeekICmd("iferror"); - CORE::die(@_) if !$gKeepgoing; - warn(@_); -}; - -# Handler for __DIE__ signal -$SIG{__DIE__} = sub { - select(STDERR); - DPrint(0, "*** Error: " . ($gMakestep ? "($gMakestep): " : "") . $_[0]); - select(STDOUT); - exit(1); -}; - -# Handler for __WARN__ signal -$SIG{__WARN__} = sub { - select(STDERR); - my $msg = ($gMakestep ? "($gMakestep): " : "") . $_[0]; - if ($gError) { DPrint(0, "*** Error: $msg") } - else { DPrint(127, "Warning: $msg") } - select(STDOUT); - $gError = $gWarn = 0; -}; - - -############################################################################### -# File operations - -sub PathConv($;$$) -{ - my $path = shift(); - if (shift()) { $path =~ tr-\/-\\- } - else { $path =~ tr-\\-\/- } - if (shift()) { $path =~ s/^(?![a-z]:)/$gWorkdrive/i } - else { $path =~ s/^$gWorkdrive//i } - $path =~ s/^([a-z]:)/\u$1/; - return($path); -} - -sub ParseFiles($) -{ - my ($file, @files) = (shift(), ()); - push(@files, defined($1) ? $1 : (defined($2) ? $2 : ())) while $file =~ /""|"+(.+?)"+|((\\\s|\S)+)/g; - return(@files); -} - -sub GlobFiles($) -{ - return(@gFindresult) if (my $file = shift()) =~ /^__find__$/i; - return(map(/[\*\?]/ ? glob(/\s/ ? "\"$_\"" : $_) : $_, ParseFiles($file))); -} - -sub GetBasename($) -{ - return((File::Basename::fileparse(shift()))[0]); -} - -sub GetDirname($) -{ - (my $dir = shift()) =~ s/^>>?(?!>)//; - return((File::Basename::fileparse($dir))[1]); -} - -sub GetAbsDirname($;$$) -{ - (my $dir = shift()) =~ s/^>>?(?!>)//; - my $absdir = ""; - eval { local $SIG{__DIE__}; $absdir = Cwd::abs_path($dir) }; - return(PathConv($absdir || File::Spec->rel2abs($dir, - $dir !~ /^$gWorkdrive/i && $dir =~ /^([a-z]:)/i ? "$1/" : ""), shift(), shift())); -} - -sub GetAbsFname($;$$) -{ - my $file = shift(); - return($file) if $file eq "" || $file =~ /STD(IN|OUT|ERR)$/; - my $append = ($file =~ s/^>>(?!>)// ? ">>" : ""); - return($append . PathConv(File::Spec->catpath("", GetAbsDirname(GetDirname($file)), GetBasename($file)), shift(), shift())); -} - -sub GetRelFname($;$$$) -{ - my ($file, $base) = (shift(), shift()); - my $append = ($file =~ s/^>>(?!>)// ? ">>" : ""); - return($append . PathConv(File::Spec->abs2rel($file, GetAbsDirname(defined($base) && ($base ne "") ? $base : ".")), shift(), shift())); -} - -sub GetWriteFname($) -{ - (my $file = shift()) =~ s/^>?/>/; - return($file); -} - -sub GetFreeDrive() -{ - for my $drive ("F", "A".."E", "G".."Z") { - return("$drive:") if - !system("subst $drive: . >nul") and !system("subst $drive: /d >nul"); - } - die("No free drive letter available.\n"); -} - -sub Search($$$$$\@\$) -{ - my ($dir, $inclre, $exclre, $subdir, $finddir, $files, $total) = @_; - my @dir = (); - - map { - my $isfile = -f(); - my $isdir = !$isfile && -d(); - if ($finddir ? $isdir : $isfile) { - ++$$total; - my $fname = File::Basename::basename($_); - push(@$files, $_) if ($fname =~ /$inclre/ && $fname !~ /$exclre/); - } - push(@dir, $_) if $isdir && $subdir; - } sort({lc($a) cmp lc($b)} ($dir =~ /\s/ ? <"$dir/*"> : <$dir/*>)); - - map { Search($_, $inclre, $exclre, 1, $finddir, @$files, $$total) } @dir; -} - -sub Find($$$$$\$) -{ - my ($dir, $inclpat, $exclpat, $subdir, $finddir, $total) = @_; - ($dir, $$total) = (GetAbsDirname($dir), 0); - my ($inclre, $exclre, @files) = ("", "", ()); - if ($inclpat =~ /^\//) { - $inclre = eval("qr$inclpat"); - $inclpat = ""; - } else { - $inclre = join("|", map(Wcard2Restr($_), split(/\s+/, $inclpat))); - $inclre = qr/^($inclre)$/i; - } - if ($exclpat =~ /^\//) { - $exclre = eval("qr$exclpat"); - $exclpat = ""; - } else { - $exclre = join("|", map(Wcard2Restr($_), split(/\s+/, $exclpat))); - $exclre = qr/^($exclre)$/i; - } - DPrint(16, "Find" . ($finddir ? "Dir" : "File") . ": Directory `$dir'" . ($subdir ? " and subdirectories" : "") . - ", pattern `" . ($inclpat ne "" ? "$inclpat' $inclre" : "$inclre'") . - ($exclre eq qr/^()$/i ? "" : " excluding `" . ($exclpat ne "" ? "$exclpat' $exclre" : "$exclre'"))); - Search($dir, $inclre, $exclre, $subdir, $finddir, @files, $$total); - DPrint(16, ", found " . @files . "/$$total " . ($finddir ? "directories\n" : "files\n")); - return(@files); -} - -sub ChangeDir($) -{ - if ((my $dir = GetAbsDirname(shift())) ne GetAbsDirname(".")) { - DPrint(16, "ChangeDir: `$dir'\n"); - chdir($dir) or die("Can't change to directory `$dir'.\n"); - } -} - -sub DeleteDir($;$) -{ - return if !-d(my $dir = GetAbsDirname(shift())); - DPrint(16, "DeleteDir: `$dir'\n"); - for my $sec (0, 2, 5) { - warn("Can't delete directory `$dir', retrying in $sec seconds...\n"), sleep($sec) if $sec; - eval { local $SIG{__DIE__}; local $SIG{__WARN__} = sub{}; File::Path::rmtree($dir) }; - return if !-d($dir); - } - $dir = "Can't delete directory `$dir'.\n"; - shift() ? warn($dir) : die($dir); -} - -sub FindDir($$$$) -{ - my ($dir, $inclpat, $exclpat, $opt) = @_; - @gFindresult = () if (($opt = (defined($opt) ? $opt : "")) !~ /a/); - push(@gFindresult, Find($dir, $inclpat, $exclpat, $opt =~ /r/, 1, local $_)); -} - -sub MakeDir($) -{ - my $dir = GetAbsDirname(shift()); - return if -d($dir); - eval { local $SIG{__DIE__}; File::Path::mkpath($dir) }; - if (-d($dir)) { - DPrint(16, "MakeDir: `" . GetAbsDirname($dir) ."'\n"); - } else { - DPrint(16, "MakeDir: `$dir'\n"); - die("Can't create directory `$dir'.\n"); - } -} - -sub MakeChangeDir($) -{ - MakeDir(my $dir = shift()); - ChangeDir($dir); -} - -sub SetWorkdir($) -{ - MakeChangeDir(shift()); - $gWorkdrive = (Cwd::cwd() =~ /^([a-z]:)/i ? $1 : ""); - $gWorkdir = GetAbsDirname("."); -} - -sub OpenFile(*$$;$) -{ - my ($fhandle, $file, $binmode, $print) = @_; - MakeDir(GetDirname($file)) if $file =~ /^>/; - DPrint(16, defined($print) ? $print : ($file =~ /^>/ ? "Write" : "Read") . "File: `$file'\n"); - return(open($fhandle, $file)) if !$binmode; - return(open($fhandle, $file) and binmode($fhandle)); -} - -sub Test($) -{ - if (-d(my $file = shift())) { - DPrint(16, "TestDir: `" . GetAbsDirname($file) . "'\n"); - } elsif (-f($file)) { - DPrint(16, "TestFile: `" . GetAbsFname($file) . "'\n"); - } else { - DPrint(16, "Test: `$file'\n"); - die("File or directory `$file' doesn't exist.\n"); - } -} - -sub CutFile($$$$$) -{ - my ($msg, $src, $dest, $head, $len) = @_; - my ($buf, $srctmp) = (undef, "$src.CUT"); - - OpenFile(*INFILE, $src, 1, $msg) or - die("Can't read file `$src'.\n"), return; - - my $out = GetWriteFname($head ? $dest : $srctmp); - OpenFile(*OUTFILE, $out, 1) or die("Can't write to `$out'.\n"), return; - while ($len > 0) { - read(INFILE, $buf, $len < READBUFSIZE ? $len : READBUFSIZE); - print(OUTFILE $buf); - $len -= READBUFSIZE; - } - close(OUTFILE); - - $out = GetWriteFname($head ? $srctmp : $dest); - OpenFile(*OUTFILE, $out, 1) or die("Can't write to `$out'.\n"), return; - print(OUTFILE $buf) while read(INFILE, $buf, READBUFSIZE); - close(OUTFILE); - close(INFILE); - Move($srctmp, $src); -} - -sub Copy($$;$) -{ - my ($src, $dest, $dir) = @_; - my $append = ($dest =~ /^>>[^>]/); - $dir = defined($dir) && $dir || !$append && -d($src); - $src = ($dir ? GetAbsDirname($src) : GetAbsFname($src)); - $dest = ($dir ? GetAbsDirname($dest) : GetAbsFname($dest)); - if ($append) { - my $buf; - OpenFile(*INFILE, $src, 1, "AppendFile: `$src' => `$dest'\n") or die("Can't read file `$src'.\n"), return; - OpenFile(*OUTFILE, $dest, 1, "") or die("Can't write to `$dest'.\n"), return; - print(OUTFILE $buf) while read(INFILE, $buf, READBUFSIZE); - return if close(INFILE) && close(OUTFILE); - } - elsif (!$dir) { - DPrint(16, "CopyFile: `$src' => `$dest'\n"); - warn("CopyFile: Destination file `$dest' already exists\n") if -f($dest); - File::Copy::copy($src, $dest) and return; - } else { - DPrint(16, "CopyDir: `$src' => `$dest'\n"); -# warn("CopyDir: Destination directory `$dest' already exists\n") if -d($dest); - !RunSystemCmd('xcopy "' . PathConv($src, 1) . '" "' . PathConv("$dest/" . GetBasename($src), 1) . '" /e /i /y /z', "") and return; - } - die("Can't copy `$src' to `$dest'.\n"); -} - -sub DeleteFile($;$) -{ - return if !-f(my $file = GetAbsFname(shift())); - DPrint(16, "DeleteFile: `$file'\n"); - for my $sec (0, 1, 2) { - warn("Can't delete file `$file', retrying in $sec second(s)...\n"), sleep($sec) if $sec; - unlink($file); - return if !-f($file); - } - $file = "Can't delete file `$file'.\n"; - shift() ? warn($file) : die($file); -} - -sub FindFile($$$$) -{ - my ($dir, $inclpat, $exclpat, $opt) = @_; - @gFindresult = () if (($opt = (defined($opt) ? $opt : "")) !~ /a/); - push(@gFindresult, Find($dir, $inclpat, $exclpat, $opt =~ /r/, 0, local $_)); -} - -sub HeadFile($$$) -{ - my ($src, $dest, $len) = (GetAbsFname(shift()), GetAbsFname(shift()), shift()); - $len = hex($len) if $len =~ /^0x/; - CutFile("HeadFile: Cut first $len bytes from `$src' => `$dest'\n", $src, $dest, 1, $len); -} - -sub TailFile($$$) -{ - my ($src, $dest, $len) = (GetAbsFname(shift()), GetAbsFname(shift()), shift()); - $len = hex($len) if $len =~ /^0x/; - CutFile("TailFile: Cut last $len bytes from `$src' => `$dest'\n", $src, $dest, 0, (-s($src) ? -s($src) : 0) - $len); -} - -sub TypeFile($;$) -{ - my ($file, $str, $mode) = (GetAbsFname(shift()), "", shift() || ""); - OpenFile(*FILE, $file, $mode, "TypeFile: `$file'" . - ($gOutfilter && ($mode ne "b") ? ", filter: `/$gOutfilter/i'" : "") . "\n") or - die("Can't read file `$file'.\n"), return; - DPrint(8, "$STARTSTR\n"); - read(FILE, $str, -s($file)); - if ($mode eq "b") { - DPrint(1, Byte2Str(0, map(ord(), split(//, $str)))); - } else { - $str = Uni2Ascii($str) if $mode eq "u"; - DPrint(1, map("$_\n", grep(!$gOutfilter || /$gOutfilter/i, split(/\n/, $str)))); - $gOutfilter = ""; - } - DPrint(8, "$ENDSTR\n"); - close(FILE); -} - -sub WriteFile($$$;$) -{ - my ($file, $str, $mode) = (GetAbsFname(shift()), shift(), shift() || ""); - OpenFile(*FILE, GetWriteFname($file), $mode) or - die("Can't write to `$file'.\n"), return; - if ($mode eq "b") { - my @byte = Str2Byte($str); - DPrint(64, Byte2Str($file =~ s/^>>(?!>)// ? -s($file) : 0, @byte)); - print(FILE map(chr(), @byte)); - } else { - $str = Unquote($str) if !shift(); - $str = Ascii2Uni($str) if $mode eq "u"; - print(FILE $str); - } - close(FILE); -} - -sub UnzipFile($$) -{ - my ($zipfile, $dir) = (GetAbsFname(shift()), GetAbsDirname(shift())); - DPrint(16, "UnzipFile: `$zipfile'"); - Archive::Zip::setErrorHandler(sub{}); - my ($error, $zip) = (0, Archive::Zip->new()); - if ($zip->read($zipfile) != AZ_OK) { - DPrint(16, " to directory `$dir'\n"); - die("Can't read zip archive `$zipfile'.\n"); - return; - } - my @files = map($_->fileName(), grep(!$_->isDirectory(), $zip->members())); - DPrint(16, ", " . @files . " files to directory `$dir'\n"); - foreach my $file (@files) { - DPrint(16, "ExtractFile: `$dir/$file'"); - eval { local $SIG{__DIE__}; $error = ($zip->extractMember($file, "$dir/$file") != AZ_OK) }; - DPrint(16, $error ? " Failed\n" : "\n"); - die("Can't extract file `$file' to directory `$dir'.\n") if $error; - $error = 0; - } -} - -sub Zip($$$$@) -{ - my ($zipfile, $dir, $opt, $prefix) = (GetAbsFname(shift()), shift(), shift(), shift()); - - $opt = (defined($opt) ? ", options: `$opt'" : ""); - $prefix = GetAbsDirname($prefix) if $prefix ne ""; - my %files = (); - map { - my $key = lc(); - $files{$key} = $_ if !exists($files{$key}); - } ($dir ? map(GetAbsDirname($_), grep(-d(), @_)) : map(GetAbsFname($_), grep(-f(), @_))); - - DPrint(16, ($dir ? "ZipDir: `$zipfile'$opt, " . keys(%files) . " directories" : - "ZipFile: `$zipfile'$opt, " . keys(%files) . " files") . ($prefix ? ", prefix: $prefix\n" : "\n")); - - Archive::Zip::setErrorHandler(sub{}); - my ($error, $zip) = (0, Archive::Zip->new()); - $zip->zipfileComment("iMaker-created zip archive `$zipfile'$opt."); - - foreach my $file (sort({lc($a) cmp lc($b)} values(%files))) { - my $newfile = $file; - if ($opt !~ /j/) { - $newfile =~ s/^.*?\/+/$prefix\// if $prefix ne ""; - } else { - $newfile = ($dir ? "" : GetBasename($file)) if ($prefix eq "") || ($newfile !~ s/^$prefix//); - } - DPrint(16, "Add" . ($dir ? "Dir" : "File") . ": `$file'" . ($file ne $newfile ? " => `$newfile'" : "")) if $opt !~ /q/; - eval { - local $SIG{__DIE__}; local $SIG{__WARN__} = sub{ $gWarn = 1 }; - $error = ($dir ? $zip->addTree($file, $newfile) != AZ_OK : - !$zip->addFile($file, $newfile)) || $gWarn; - }; - DPrint(16, $error ? " Failed\n" : "\n") if $opt !~ /q/; - warn("Can't add " . ($dir ? "directory tree" : "file") . "`$file' to zip archive `$zipfile'.\n") if $error; - $error = 0; - } - ($zip->writeToFileNamed($zipfile) == AZ_OK) or - die("Can't create zip archive `$zipfile'.\n"); -} - -sub Move($$) -{ - my ($src, $dest) = @_; - my $dir = -d($src); - $src = ($dir ? GetAbsDirname($src) : GetAbsFname($src)); - MakeDir(GetDirname($dest)); - $dest = ($dir ? GetAbsDirname($dest) : GetAbsFname($dest)); - DPrint(16, "Move" . ($dir ? "Dir" : "File") . ": `$src' => `$dest'\n"); - File::Copy::move($src, $dest) or - die("Can't move `$src' to `$dest'.\n"); -} - -sub Touch($$) -{ - my ($file, $time) = (shift(), shift() =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/ ? - Time::Local::timelocal($6, $5, $4, $3, $2 - 1, $1 - 1900) : time); - my $dir = -d($file); - $file = ($dir ? GetAbsDirname($file) : GetAbsFname($file)); - DPrint(16, "Touch" . ($dir ? "Dir" : "File") . ": `$file': " . - POSIX::strftime("%Y-%m-%d,%H:%M:%S", localtime($time)) . "\n"); - utime($time, $time, $file) or - die("Can't touch " . ($dir ? "directory" : "file") . " `$file'.\n"); -} - -sub SetLogfile($) -{ - $gBuflog = 0, return if !(my $file = GetAbsFname(shift())); - CloseLog(); - OpenFile(*LOG, GetWriteFname($file), 0) or - warn("Can't log to file `$file'.\n"), return; - $gLogfile = $file; -} - - -############################################################################### -# - -sub WidgetUnzip($$$) -{ - my ($wgzfile, $outdir, $plist) = (GetAbsFname(shift()), GetAbsDirname(shift()), shift()); - - my $tmpdir = "$outdir/wgz_unzip_temp"; - DeleteDir($tmpdir); - UnzipFile($wgzfile, $tmpdir); - - for my $dir (Find($tmpdir, "*", "", 0, 1, local $_)) { - my $xml = undef; - eval { local $SIG{__DIE__}; local $SIG{__WARN__} = sub{}; $xml = XMLin("$dir/$plist") }; - die("Can't find/parse XML file `$dir/$plist'.\n"), next if !defined($xml); - my $id = ""; - for my $ind (0 .. @{$xml->{dict}{key}} - 1) { - $id = $xml->{dict}{string}[$ind], last if $xml->{dict}{key}[$ind] =~ /^\s*Identifier\s*$/i; - } - die("Can't find Identifier from XML file `$dir/$plist'.\n"), next if $id eq ""; - Move($dir, "$outdir/$id/" . GetBasename($dir)); - } - DeleteDir($tmpdir); -} - - -############################################################################### -# - -sub RunSystemCmd($$;$) -{ - my ($cmd, $file, $ignorerr) = @_; - DPrint(1, "$cmd\n"), return if $gPrintcmd; - my $null = ($file =~ /^null$/i); - $file = ($null ? "" : GetAbsFname($file)); - @gCmdoutbuf = (); - DPrint(4, "RunSystemCmd(" . GetAbsDirname(".") . "): `$cmd'" . - ($file ? ", redirect to: `$file'" : ($null ? ", redirect to null" : "")) . - ($gOutfilter ? ", filter: `/$gOutfilter/i'" : "") . "\n"); - OpenFile(*FILE, GetWriteFname($file), 0) or - (die("Can't write to `$file'.\n"), $file = "") if $file; - my $dur = time(); - open(CMD, "$cmd 2>&1 |"); - DPrint(8, "$STARTSTR\n"); - while (my $line = ) { - chomp($line); - push(@gCmdoutbuf, $line); - DPrint(8, "$line\n") if !$null && (!$gOutfilter || ($line =~ /$gOutfilter/i)); - print(FILE "$line\n") if $file; - } - close(CMD); - close(FILE) if $file; - push(@gStepDur, $dur = time() - $dur); - $gOutfilter = ""; - my $error = ($? >> 8) && !$ignorerr && !$null; - print(map("$_\n", @gCmdoutbuf)) if $error && $gVerbose && !($gVerbose & 8); - $dur = Sec2Min($dur); - DPrint(8, substr($ENDSTR, 0, -16) . $dur . substr($ENDSTR, length($dur) - 16) . "\n"); - die("Command `$cmd' failed (" . ($? >> 8). ").\n") if $error; -} - - -############################################################################### -# - -sub ParseSystemCmd($$$) -{ - return if $gPrintcmd; - my ($title, $regex, $file) = @_; - $regex = ($regex =~ /^\// ? eval("qr$regex") : Wcard2Regex($regex)); - return if !(my @parse = grep(/$regex/, @gCmdoutbuf)); - if (!$file) { - Echo(1, $title, 0); - DPrint(1, map(sprintf("%" . length(@parse) . "s", $_) . ") $parse[$_ - 1]\n", 1 .. @parse)); - return; - } - OpenFile(*FILE, GetWriteFname($file = $title), 0) or - die("Can't write to `$file'.\n"), return; - print(FILE join("\n", @parse)); - close(FILE); -} - - -############################################################################### -# - -sub GenExclfile($$$$$) -{ - return if $gPrintcmd; - - my ($exclfile, $base, $prefix, $addfiles) = (shift(), shift(), shift(), shift()); - my ($file, $rmfiles, %files) = ("", "", ()); - - WriteFile($exclfile, "", ""); - $base = GetAbsDirname($base); - - foreach $file (ParseFiles(shift())) { - $file =~ tr/\\/\//; - $file =~ s/^\///; - $file =~ s/\/$/\/\*/; - $rmfiles .= ($rmfiles eq "" ? "" : "|") . Wcard2Restr($file); - } - $rmfiles = qr/^(?:$rmfiles)$/i; - - foreach $file (ParseFiles($addfiles)) { - $file =~ tr/\\/\//; - $file =~ /^\/?(?:(.*)\/)?(.+?)$/; - (my $dir, $file) = ($base . (defined($1) ? "/$1" : ""), $2); - map { - $files{$_} = 1 if ($_ = GetRelFname($_, $base)) !~ $rmfiles; - } ($file =~ /[\*\?]/ ? Find($dir, $file, "", 1, 0, local $_) : "$dir/$file"); - } - - map { - $files{"$_/"} = 1 while (s/^(.*)\/.*?$/$1/) && !exists($files{"$_/"}); - } keys(%files); - $files{""} = 1; - - WriteFile($exclfile, join("", map(($_ = "$prefix$_\n") =~ tr/\//\\/ ? $_ : $_, sort({lc($a) cmp lc($b)} keys(%files)))), "u", 1); -} - -sub GenIbyfile($$$@) -{ - return if $gPrintcmd; - - my ($ibyfile, $srcdir, $subdir) = (GetAbsFname(shift()), shift(), shift()); - my ($header, $footer, $body, %files) = ("", "", "", ()); - - foreach my $dir (split(/\s+/, $srcdir)) { - $dir = GetAbsDirname($dir); - my ($found, $total, $lines) = (0, 0, ""); - my @param = @_; - while (@param) { - my ($filepat, $format, @lines) = (shift(@param), shift(@param), ()); - $header = $format, next if $filepat =~ /^__header__$/i; - $footer = $format, next if $filepat =~ /^__footer__$/i; - foreach my $src (Find($dir, $filepat, "", $subdir, 0, $total)) { - next if $files{$src}; - $files{$src} = 1; - (my $line = $format) =~ s/%1/$src/g; - $line =~ s/%2/GetRelFname($src, $dir, 1)/ge; - $line =~ s/%3/GetRelFname($src, GetDirname($ibyfile))/ge; - push(@lines, $line); - } - $found += @lines; - $lines .= "//\n// Format: `$format', " . @lines . " files: `$filepat'\n" . - (@lines ? "//\n" . join("\n", @lines) . "\n" : ""); - } - $body .= "\n// Collected files $found/$total from directory `$dir'" . - ($subdir ? " and subdirectories" : "") . "\n$lines"; - } - - my $append = ($ibyfile =~ s/^>>(?!>)// && -f($ibyfile) && ">>" || ""); - (my $fname = "__" . uc(GetBasename($ibyfile)) . "__") =~ s/\W/_/g; - my @previby = (); - - if ($append) { - OpenFile(*FILE, $ibyfile, 0) or die("Can't read file `$ibyfile'.\n"), return; - @previby = ; - close(FILE); - $previby[0] =~ s/(, collected )(\d+)( files)$/$1.($2 + keys(%files)).$3/e; - $previby[@previby - 1] = ""; - } - - OpenFile(*FILE, GetWriteFname($ibyfile), 0) or - die("Can't write to `$ibyfile'.\n"), return; - print(FILE @previby, ($append ? "// Appended" : "// Generated") . " `$append$ibyfile', " . - "collected " . keys(%files) . " files\n" . - ($append ? "" : "\n#ifndef $fname\n#define $fname\n") . - ($header ? Unquote("\\n$header\\n") : "") . $body . ($footer ? Unquote("\\n$footer\\n") : "") . - "\n#endif // $fname\n"); - close(FILE); -} - - -############################################################################### -# - -sub GenMakefile($$$$$) -{ - return if $gPrintcmd; - my ($hdrfile, $mkfile, $filter, $prepros, $assignop) = - (GetAbsFname(shift()), GetAbsFname(shift()), shift(), shift(), shift()); - ChangeDir(GetDirname($hdrfile)); - RunSystemCmd("$prepros " . GetBasename($hdrfile), ""); - my $maxdef = Max(map(/^\s*\#define\s+($filter)/ && length($1), @gCmdoutbuf)); - WriteFile($mkfile, join('\n', - map(/^\s*\#define\s+($filter)\s*(.*?)\s*$/ ? sprintf("%-${maxdef}s $assignop %s", $1, $2 eq "" ? 1 : $2) : (), sort(@gCmdoutbuf))) . '\n', ""); -} - - -############################################################################### -# - -sub AddImageHeader($$$$$) -{ - return if $gPrintcmd; - my ($file, $hdrfile, $hdrstr, $hdrsize, $align) = - (GetAbsFname(shift()), GetAbsFname(shift()), shift(), shift(), shift()); - - $hdrstr =~ s/\/\*.*?\*\///g; - $hdrstr =~ s/,\s*$//; - WriteFile($hdrfile, $hdrstr, "b"); - die("Invalid image header size: " . sprintf("0x%X", -s($hdrfile)) . " (!=$hdrsize).\n"), return - if -s($hdrfile) ne hex($hdrsize); - - $align = Max(hex($align), hex($hdrsize)) - hex($hdrsize); - WriteFile(">>$hdrfile", ("0," x ($align - 1)) . "0", "b") if $align; - Copy($file, ">>$hdrfile") if $file ne ""; -} - - -############################################################################### -# - -sub Sleep($) -{ - sleep(shift()) if !$gPrintcmd; -} - - -############################################################################### -# - -sub FindSOSFiles($$$$$) -{ - my ($dirs, $tmpoby, $imgoby, $pluglog, $opt) = @_; - my ($file, %files) = ("", ()); - local $_; - - foreach my $dir (GlobFiles($dirs)) { - $dir = GetAbsDirname($dir); - - foreach $file (Find($dir, $tmpoby, "", 1, 0, $_)) { - OpenFile(*FILE, $file, 0) or warn("Can't read file `$file'.\n"), last; - (my $dir = GetDirname($file) . "/") =~ s/\/+$/\//; - while () { - next if !/^#\s+\d+\s+"(.+?)"/; - $_ = $1; - $file = GetAbsFname(/^(?:[a-z]:)?[\/\\]/i ? $_ : "$dir$_"); - $files{lc($file)} = $file if !exists($files{lc($file)}); - } - close(FILE); - } - - foreach $file (Find($dir, $imgoby, "", 1, 0, $_)) { - OpenFile(*FILE, $file, 0) or warn("Can't read file `$file'.\n"), last; - while () { - next if !/^\s*(?:bootbinary|data|device|dll|extension|file|primary|secondary|variant)\S*?\s*[=\s]\s*(?:"(.+?)"|(\S+))/i; - $file = GetAbsFname(defined($1) ? $1 : $2); - $files{lc($file)} = $file if !exists($files{lc($file)}); - next if ($file !~ s/\.[0-9a-f]{32}\./\./i); - $file .= ".vmap"; - $files{lc($file)} = $file if !exists($files{lc($file)}); - } - close(FILE); - } - - my ($plugfile, $patched) = (0, 0); - foreach $file (Find($dir, $pluglog, "", 1, 0, $_)) { - OpenFile(*FILE, $file, 0) or warn("Can't read file `$file'.\n"), last; - while () { - $plugfile = 1, next if /^Reading (ROM|ROFS1|UDEB|UREL) files$/; - $plugfile = 0, next if ($plugfile && /^Found \d+ entries$/); - if ($plugfile) { - next if !/`(.+)'$/; - $file = GetAbsFname($1); - $files{lc($file)} = $file if !exists($files{lc($file)}); - next; - } - $patched = $1, next if /^Found (\d+) ROM-patched components:$/; - next if (!$patched || !/^`(.+)'$/); - $patched--; - $file = GetAbsFname($1) . ".map"; - $files{lc($file)} = $file, next if -f($file); - $file =~ s/(\..*?\.map)$/\.\*$1/; - foreach (glob($file =~ /\s/ ? "\"$file\"" : $file)) { - ($file = lc()) =~ s/\.map$//; - $files{lc()} = $_, last if exists($files{$file}); - } - } - close(FILE); - } - - $dir .= "/" if $dir !~ /\/$/; - foreach $file (keys(%files)) { - delete($files{$file}) if ($file =~ /^$dir/i); - } - } - - @gFindresult = () if (!defined($opt) || $opt !~ /a/); - push(@gFindresult, values(%files)); -} - - -############################################################################### -# - -sub CheckTool(@) -{ - return if $gPrintcmd; - my ($maxtlen, $maxvlen, @tools) = (4, 9, ()); - while (@_) { - my ($tool, $vquery, $getver, $version, $md5sum) = (shift(), shift(), shift(), " -", " ?"); - if (length($vquery) > 1) { - RunSystemCmd($vquery, "null"); - $version = (join("\n", @gCmdoutbuf) =~ eval($getver =~ /^\// ? "qr$getver" : "qr/$getver/ims") ? - (defined($1) && defined($2) && "`$1 $2'" || defined($1) && "`$1'" || " ?") : " ?"); - } - OpenFile(*FILE, $tool, 1) and $md5sum = "`" . md5_hex() . "'"; - close(FILE); - $maxtlen = Max($maxtlen, length($tool)); - $maxvlen = Max($maxvlen, length($version)); - push(@tools, "`$tool'", $version, $md5sum); - } - $maxtlen += 2; - @_ = (" Tool", " Version", " MD5 Checksum", "-" x $maxtlen, "-" x $maxvlen, "-" x 34, @tools); - DPrint(1, sprintf("%-${maxtlen}s %-${maxvlen}s ", shift(), shift()) . shift() . "\n") while(@_); -} - - -############################################################################### -# - -sub GetIPar() -{ - local $_ = shift(@gIcmd); - $_ = "" if (my $empty = !defined()); - - while (/\@PEVAL{.*}LAVEP\@/) { - my $start = rindex($_, '@PEVAL{', my $end = index($_, '}LAVEP@') + 7); - my ($expr, $eval, $evalerr) = (substr($_, $start + 7, $end - $start - 14), undef, ""); - eval { - local ($_, $SIG{__DIE__}); - local $SIG{__WARN__} = sub{} if $gPrintcmd; - $eval = eval($expr); - ($evalerr = $@) =~ s/^(.+?) at .*/$1/s; - }; -# DPrint(64, "GetIPar: Evaluate `$expr' = `" . (defined($eval) ? $eval : "") . "'\n"); - if (!defined($eval)) { - $eval = ""; - warn("GetIPar: Evaluation `$expr' failed: $evalerr.\n") if !$gPrintcmd; - } - substr($_, $start, $end - $start) = $eval; - } - DPrint(32, "iPar: $gParamcnt. `$_'\n") if $gParamcnt; - $gParamcnt++; - return($empty ? undef : $_); -} - -sub PeekICmd($) -{ - return(defined($gIcmd[0]) && $gIcmd[0] =~ /^$_[0]$/i); -} - -sub GetICmd() -{ - $gParamcnt = 0; - my $cmd = GetIPar(); - DPrint(32, "iCmd: " . ++$gCmdcnt . ". `$cmd'\n") if defined($cmd) && $cmd ne ""; - return($cmd); -} - -sub EndICmd() -{ - GetICmd(), return(1) if !defined($gIcmd[0]) || PeekICmd("end"); - return(0); -} - -sub RunICmd() -{ - my ($cmd, $file, $iferror) = ("", "", 0); - while (defined($cmd = GetICmd())) { - next if $cmd eq ""; - local $_ = lc($cmd); - if (/^(error|warning)$/) { - my ($errwarn, $msg) = (GetIPar(), Unquote(GetIPar())); - die($msg) if $errwarn && /e/; - warn($msg) if $errwarn && /w/; - } - elsif (/^echo(\d+)?(-q)?$/) { - my ($verbose, $quote) = (defined($1) && ($1 < 128) ? $1 : 1, defined($2)); - Echo($verbose, GetIPar(), $quote); - } - elsif (/^filter$/) { - $gOutfilter = GetIPar(); - } - elsif (/^cmd(tee)?$/) { - $file = $1; - RunSystemCmd(GetIPar(), $file ? GetIPar() : ""); - } - elsif (/^parse(f)?$/) { - $file = $1; - ParseSystemCmd(GetIPar(), GetIPar(), $file); - } - elsif (/^(cd|copy(dir)?|del(dir)?|find(dir)?(-[ar]+)?|headb|logfile|mkcd|mkdir|move|tailb|test|touch|type[bu]?|unzip|workdir|write[bu]?(-q)?|zip(dir)?(-[jq]+)?)$/) { - my @files = GlobFiles(GetIPar()); - my $par1 = GetIPar() if /^(?:copy|find|head|move|tail|touch|(un)?zip|write)/; - my $par2 = GetIPar() if /^(?:find|head|tail|zip)/; - next if $gPrintcmd; - foreach $file (@files) { - ChangeDir($file) if /^cd/; - DeleteDir($file) if /deldir/; - FindDir($file, $par1, $par2, $1) if /finddir(-[ar]+)?/; - MakeDir($file) if /mkdir/; - MakeChangeDir($file) if /mkcd/; - SetWorkdir($file) if /workdir/; - Zip($file, 1, $1, $par2, GlobFiles($par1)) if /zipdir(-[jq]+)?/; - DeleteFile($file) if /del/; - FindFile($file, $par1, $par2, $1) if /find(-[ar]+)?$/; - HeadFile($file, $par1, $par2) if /headb/; - SetLogfile($file) if /logfile/; - TailFile($file, $par1, $par2) if /tailb/; - TypeFile($file, $1) if /type(b|u)?/; - UnzipFile($file, $par1) if /unzip/; - WriteFile($file, $par1, $1, $2) if /write(b|u)?(-q)?/; - Zip($file, 0, $1, $par2, GlobFiles($par1)) if /^zip(-[jq]+)?$/; - Copy($file, $par1, $1) if /copy(dir)?/; - Move($file, $par1) if /move/; - Test($file) if /test/; - Touch($file, $par1) if /touch/; - } - } - elsif (/^genexclst$/) { - GenExclfile(GetIPar(), GetIPar(), GetIPar(), GetIPar(), GetIPar()); - } - elsif (/^geniby(-r)?$/) { - my ($sub, $iby, $dir, @par) = ($1, GetIPar(), GetIPar(), ()); - push(@par, GetIPar(), GetIPar()) while !EndICmd(); - GenIbyfile($iby, $dir, $sub, @par); - } - elsif (/^genmk$/) { - GenMakefile(GetIPar(), GetIPar(), GetIPar(), GetIPar(), GetIPar()); - } - elsif (/^iferror$/) { - $iferror++; - $gError = 0, next if $gError; - while (defined($gIcmd[0])) { - GetICmd(), last if PeekICmd("endif") && !--$iferror; - $iferror++ if shift(@gIcmd) =~ /^iferror$/i; - } - } - elsif (/^endif$/ && $iferror--) { - } - elsif (/^imghdr$/) { - AddImageHeader(GetIPar(), GetIPar(), GetIPar(), GetIPar(), GetIPar()); - } - elsif (/^pause$/) { - DPrint(0, "Press Enter to continue...\n"); - getc(); - } - elsif (/^sleep$/) { - Sleep(GetIPar()); - } - elsif (/^sosfind(-a)?$/) { - my $opt = $1; - FindSOSFiles(GetIPar(), GetIPar(), GetIPar(), GetIPar(), $opt); - } - elsif (/^toolchk$/) { - my @tools = (); - push(@tools, GetIPar(), GetIPar(), GetIPar()) while !EndICmd(); - CheckTool(@tools); - } - elsif (/^wgunzip$/) { - ($file, my $dir, my $fname) = (GetIPar(), GetIPar(), GetIPar()); - map { WidgetUnzip($_, $dir, $fname) } GlobFiles($file); - } - elsif (!$gImakerext || !RunIExtCmd($_)) { - die("Unknown iMaker command `$cmd'.\n"); - } - } -} - - -############################################################################### -# - -sub GetFeatvarIncdir($;$) -{ - my ($varname, $nbv) = @_; - my %featvar = (); - my @incdir = ("Invalid SBV feature variant"); - my $valid = 0; - local $_; - - open(OLDERR, ">&STDERR"); - open(STDERR, $gWinOS ? ">nul" : ">/dev/null"); - select(STDERR); - eval { - local $SIG{__DIE__}; - %featvar = featurevariantparser->GetVariant($varname); - $valid = $featvar{VALID}; - }; - close(STDERR); - open(STDERR, ">&OLDERR"); - close(OLDERR); - select(STDOUT); - - return(grep(tr/\\/\// || 1, @{$featvar{ROM_INCLUDES}})) if $valid; - return(@incdir) if !$nbv; - - # N*kia Binary Variation - foreach my $file (<$gEpoc32/tools/*.bsf>) { - (my $varname = lc($file)) =~ s/^.*\/(.+?)\.bsf$/$1/; - open(FILE, $file); - while (my $line = ) { - $featvar{$varname}{CUSTOMIZES} = lc($1) if $line =~ /^\s*CUSTOMIZES\s+(\S+)\s*$/i; - $featvar{$varname}{VARIANT} = (uc($1) || 1) if $line =~ /^\s*(VIRTUAL)?VARIANT\s*$/i; - } - close(FILE); - } - $varname = lc($varname); - my @variant = (); - while ($featvar{$varname}{VARIANT}) { - unshift(@variant, $varname) if $featvar{$varname}{VARIANT} ne "VIRTUAL"; - $varname = $featvar{$varname}{CUSTOMIZES}; - } - while (@variant) { - map { push(@incdir, join("/", $_, @variant)) } ("$gEpoc32/rom", "$gEpoc32/include"); - pop(@variant); - } - return(@incdir); -} - - -############################################################################### -# - -sub SetVerbose($) -{ - my $verbose = shift(); - return($gVerbose = int($1)) if ($verbose =~ /^(\d+)$/) && ($1 < 128); - $gVerbose = 1; - warn("Verbose level `$verbose' is not integer between 0 - 127\n"); - return(1); -} - -sub ReadICmdFile($) -{ - my ($file, $steps) = (GetAbsFname(shift()), ""); - OpenFile(*FILE, $file, 0) or - die("Can't read iMaker command file `$file'.\n"), return; - while () { - DPrint(2, $_), next if /^\s*#/; - next if !/^\s*(\S+?)\s*=(.*)$/; - $gStepIcmd{my $step = $1} = (my $icmd = $2); - $steps .= ($steps ? ", " : "") . $step . ($icmd =~ /^\s*$/ ? " (empty)" : ""); - } - close(FILE); - DPrint(2, "Steps: $steps\n"); -} - -sub CloseLog() -{ - close(LOG) if $gLogfile; - $gLogfile = ""; -} - -sub MakeStep($$$$$$) -{ - (my $step, my $clean, my $build, $gKeepgoing, my $verbose, $gPrintcmd) = @_; - (my $dur, @gStepDur) = (time(), ()); - - SetVerbose($verbose); - ChangeDir($gWorkdir); - - $gMakestep = "S:$step,C:" . ($clean ? 1 : 0) . ",B:" . ($build ? 1 : 0) . - ",K:" . ($gKeepgoing ? 1 : 0) . ",V:$gVerbose"; - DPrint(2, "=" x 79 . "\nENTER: `$gMakestep'\n"); - map { - if (defined($gStepIcmd{$_})) { - DPrint(64, "$_ = `$gStepIcmd{$_}'\n"); - $gStepIcmd{$_} =~ s/(?)) and close(FILE); - - while (1) { - system($gWinOS ? "cls" : "clear"); - - print("\nPRODUCTS\n--------\n"); - # - if (!@product) { - map { - push(@product, [ucfirst($1), $_]) if /image_conf_(.+?)\./; - } MenuRuncmd("$makecmd $mainmk $quietopt help-config"); - } - $prodmk = ($prodind ? " -f $product[$prodind - 1][1]" : ""); - my $maxlen = Max(map(length(@$_[0]), @product)); - map { - printf(" %" . (length(@product)) . "s) %-${maxlen}s %s\n", $_ + 1, $product[$_][0], $product[$_][1]); - } (0 .. $#product); - print(" NO PRODUCTS FOUND!\n") if !@product; - - print("\nTARGETS\n-------\n"); - # - if (!@target) { - @target = MenuRuncmd("$makecmd$prodmk $mainmk $quietopt help-target-*-list"); - $targrows = int($#target / $targcols + 1); - my $maxind = 0; - map { - if (!($_ % $targrows)) { - $maxind = length(Min($_ + $targrows, $#target + 1)) + 1; - $maxlen = Max(map(length(), @target[$_ .. Min($_ + $targrows - 1, $#target)])); - } - $target[$_] = sprintf("%${maxind}s) %-${maxlen}s", "t" . ($_ + 1), $target[$_]); - } (0 .. $#target); - } - ($target = ($targind ? $target[$targind - 1] : "")) =~ s/^.+?(\S+)\s*$/$1/; - foreach my $row (1 .. $targrows) { - foreach my $col (1 .. $targcols) { - my $ind = ($col - 1) * $targrows + $row - 1; - print(($ind < @target ? " $target[$ind]" : "") . ($col != $targcols ? " " : "\n")); - } - } - print(" NO TARGETS FOUND!\n") if !@target; - - print("\nCONFIGURATION\n-------------\n"); - # - if (!$vartype) { - ($vartype, $varudeb, $varsym) = map(/^\S+\s+=\s+`(.*)'$/ ? $1 : (), - MenuRuncmd("$makecmd$prodmk $mainmk $quietopt TIMESTAMP=" . GetTimestamp() . - " $target print-TYPE,USE_UDEB,USE_SYMGEN")); - $varudeb =~ s/0//g; - $varsym =~ s/0//g; - } - print( - " Product: " . ($prodind ? $product[$prodind - 1][0] : "NOT SELECTED!") . "\n" . - " Target : " . ($targind ? $target : "NOT SELECTED!") . "\n" . - " Type : " . ucfirst($vartype) . "\n" . - " Tracing: " . ($varudeb ? ($varudeb =~ /full/i ? "Full debug" : "Enabled") : "Disabled") . "\n" . - " Symbols: " . ($varsym ? "Created\n" : "Not created\n")); - - print("\nOPTIONS\n-------\n"); - # - print( - " t) Toggle between rnd/prd/subcon\n" . - " u) Toggle between urel/udeb/udeb full\n" . - " s) Toggle symbol creation on/off\n" . - " r) Reset configuration\n" . - " h) Print usage information\n" . - " x) Exit\n\n" . - "Hit Enter to run: imaker$prodmk$cmdarg TYPE=$vartype USE_UDEB=$varudeb USE_SYMGEN=$varsym $target\n"); - - print("\nSelection: "); - # - (my $input = ) =~ s/^\s*(.*?)\s*$/\L$1\E/; - - if ($input =~ /^(\d+)$/ && ($1 > 0) && ($1 <= @product) && ($1 != $prodind)) { - $prodind = $1; - ($targind, @target) = (0, ()); - } - elsif ($input =~ /^t(\d+)$/ && ($1 > 0) && ($1 <= @target) && ($1 != $targind)) { - $targind = $1; - } - elsif ($input eq "t") { - $vartype = ($vartype =~ /rnd/i ? "prd" : ($vartype =~ /prd/i ? "subcon" : "rnd")); - } - elsif ($input eq "u") { - $varudeb = (!$varudeb ? 1 : ($varudeb !~ /full/i ? "full" : 0)); - } - elsif ($input eq "s") { - $varsym = !$varsym; - } - elsif ($input eq "r") { - ($prodind, @product) = (0, ()); - ($targind, @target) = (0, ()); - ($vartype, $varudeb, $varsym) = ("", 0, 0); - } - elsif ($input eq "h") { - print("\nTODO: Help"); - sleep(2); - } - elsif ($input =~ /^(x|)$/) { - open(FILE, ">$cfgfile") and - print(FILE map("$_\n", ($prodind, $targind, $vartype, $varudeb, $varsym))) and close(FILE); - return($input eq "x" ? ("", "menu") : - ("$prodmk$cmdarg TYPE=$vartype USE_UDEB=$varudeb USE_SYMGEN=$varsym", $target)); - } - } -} - - -############################################################################### -# - -die($@) if !defined($gImakerext = do("imaker_extension.pm")) && $@; - -1; - -__END__ # OF IMAKER.PM diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_core.mk --- a/imgtools/imaker/src/imaker_core.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_core.mk Wed Jun 30 11:35:58 2010 +0800 @@ -23,10 +23,10 @@ # \___\___/|_|_\___| # -USE_NOROMHDR = 0 - CORE_TITLE = Core (ROM$(call iif,$(USE_ROFS1), & ROFS1)) -CORE_DIR = $(WORKDIR)/core +CORE_DRIVE = Z +CORE_ROOT = $(OUTDIR)/core +CORE_DIR = $(CORE_ROOT) CORE_NAME = $(NAME) CORE_PREFIX = $(CORE_DIR)/$(CORE_NAME) CORE_IDIR = @@ -38,13 +38,14 @@ CORE_INLINE = CORE_TIME = $(DAY)/$(MONTH)/$(YEAR) -CORE_OBYGEN = +CORE_DEFHRH = $(CORE_PREFIX)_core_define.hrh +CORE_FEAXML = $(E32ROMINC)/featuredatabase.xml $(E32INC)/s60features.xml $(E32INC)/s60customswfeatures.xml +CORE_FEAIBY = $(CORE_DIR)/feature.iby $(CORE_DIR)/s60features.iby $(CORE_DIR)/s60customswfeatures.iby -CORE_VERIBY = $(CORE_PREFIX)_core_version.iby -CORE_ROMVER = 0.01(0) -CORE_VERSION = V $(subst .,,$(COREPLAT_VERSION)).$(subst .,,$(S60_VERSION)).$(BUILD_YEAR).$(BUILD_WEEK).$(BUILD_NUMBER)$(if $(TYPE), $(call ucase,$(TYPE))) +CORE_ROMVER = +CORE_VERSION = $(SW_VERSION) CORE_SWVERFILE = $(CORE_PREFIX)_core_sw.txt -CORE_SWVERINFO = $(CORE_VERSION)\\\n$(DAY)-$(MONTH)-$(YEAR2)\\\n$(PRODUCT_TYPE)\\\n(c) $(PRODUCT_MANUFACT) +CORE_SWVERINFO = $(CORE_VERSION)\n$(BUILD_YEAR)-$(BUILD_MONTH)-$(BUILD_DAY)\n$(PRODUCT_TYPE)\n(c) $(PRODUCT_MANUFACT) CORE_MODELFILE = $(CORE_PREFIX)_core_model.txt CORE_MODELINFO = S60 CORE_IMEISVFILE = $(CORE_PREFIX)_core_imeisv.txt @@ -53,10 +54,35 @@ CORE_PLATINFO = SymbianOSMajorVersion=$(word 1,$(subst ., ,$(SOS_VERSION)))\nSymbianOSMinorVersion=$(word 2,$(subst ., ,$(SOS_VERSION)))\n CORE_PRODFILE = $(CORE_PREFIX)_core_product.txt CORE_PRODINFO = Manufacturer=$(PRODUCT_MANUFACT)\nModel=$(PRODUCT_MODEL)\nProduct=$(PRODUCT_TYPE)\nRevision=$(PRODUCT_REVISION) +CORE_ID = general CORE_FWIDFILE = $(CORE_PREFIX)_core_fwid.txt CORE_FWID = core -CORE_FWIDVER = $(CORE_VERSION) $(PRODUCT_TYPE) +CORE_FWIDVER = $(subst -,,$(PRODUCT_TYPE))_$(CORE_VERSION)_$(CORE_ID)$(SW_TYPEINFO) CORE_FWIDINFO = id=$(CORE_FWID)\nversion=$(CORE_FWIDVER)\n +CORE_PURPFILE = $(CORE_PREFIX)_core_purpose.txt +CORE_PURPINFO = MCL +CORE_DEVATTRFILE = $(CORE_PREFIX)_core_deviceattrib.ini + +define CORE_DEVATTRINFO + [Device] + 0x10286358 = $(PRODUCT_MANUFACT) + 0x10286359 = $(PRODUCT_MODEL) + 0x1028635A = $(PRODUCT_TYPE) + 0x1028635B = $(PRODUCT_REVISION) + + [UI] + 0x1028635D = S60 + 0x1028635E = $(word 1,$(subst ., ,$(S60_VERSION))) + 0x1028635F = $(word 2,$(subst ., ,$(S60_VERSION))) + 0x10286360 = $(S60_VERSION) + + [OS] + 0x10286361 = $(word 1,$(subst ., ,$(SOS_VERSION))) + 0x10286362 = $(word 2,$(subst ., ,$(SOS_VERSION))) + 0x10286363 = $(SOS_VERSION) +endef + +CORE_IMG = $(ROM_IMG) $(call iif,$(USE_ROFS1),$(ROFS1_IMG)) CORE_PLUGINLOG = $(CORE_PREFIX)_core_bldromplugin.log CORE_NDPROMFILE = $(E32ROMBLD)/romfiles.txt @@ -70,62 +96,69 @@ CORE_PAGEFILE = $(ODP_PAGEFILE) CORE_UDEBFILE = $(TRACE_UDEBFILE) +CORE_OBYGEN = +CORE_ORIDEIBY = $(CORE_PREFIX)_core_override.iby +CORE_ORIDEFILES = $(IMAGE_ORIDEFILES) +CORE_ORIDECONF = $(IMAGE_ORIDECONF) + CORE_ICHKLOG = $(CORE_PREFIX)_core_imgcheck.log CORE_ICHKOPT = $(IMGCHK_OPT) -CORE_ICHKIMG = $(ROM_IMG) $(call iif,$(USE_ROFS1),$(ROFS1_IMG)) +CORE_ICHKIMG = $(CORE_IMG) CORE_I2FDIR = $(CORE_DIR)/img2file +CORE_CONECONF = +CORE_CONEOPT = --all-layers --impl-tag=target:core + #============================================================================== ROM_BUILDOPT = $(call iif,$(USE_NOROMHDR),-no-header) -ROM_CHECKSUM = 0x12345678 ROM_IMGHDRSIZE = 256 ROM_HEADER = ROM_FOOTER = -ROM_IMG = $(CORE_PREFIX).rom.img -ROM_INC = $(CORE_PREFIX).rom.inc -ROM_LOG = $(CORE_PREFIX).rom.log -ROM_OUTOBY = $(CORE_PREFIX).rom.oby -ROM_SYM = $(CORE_PREFIX).rom.symbol +ROM_PREFIX = $(CORE_PREFIX).rom +ROM_IMG = $(ROM_PREFIX).img +ROM_INC = $(ROM_PREFIX).inc +ROM_LOG = $(ROM_PREFIX).log +ROM_OUTOBY = $(ROM_PREFIX).oby +ROM_SYM = $(ROM_PREFIX).symbol -ROFS1_HEADER = -ROFS1_IMG = $(CORE_PREFIX).rofs1.img -ROFS1_LOG = $(CORE_PREFIX).rofs1.log -ROFS1_OUTOBY = $(CORE_PREFIX).rofs1.oby -ROFS1_SYM = $(CORE_PREFIX).rofs1.symbol +ROFS1_PREFIX = $(CORE_PREFIX) +ROFS1_PAGEFILE = #============================================================================== define CORE_MSTOBYINFO - $(BLDROM_HDRINFO) + $(call BLDROM_HDRINFO,CORE) - $(BLDROM_PLUGINFO) + $(call BLDROM_PLUGINFO,CORE) - // Core header - // + /* Core header + */ $(CORE_HDRINFO) - // Core ROM - // + /* Core ROM + */ ROM_IMAGE[0] { $(ROM_HDRINFO) + #ifndef _IMAGE_INCLUDE_HEADER_ONLY $(BLR.CORE.OBY) $(CORE_INLINE) $(ROM_FOOTERINFO) } $(call iif,$(USE_ROFS1), - // Core ROFS1 - // - ROM_IMAGE 1 rofs1 non-xip size=$(ROFS_MAXSIZE) + /* Core ROFS1 + */ + ROM_IMAGE 1 rofs1 non-xip size=$(ROFS1_MAXSIZE) ROM_IMAGE[1] { $(ROFS1_HDRINFO) - // Content to be moved from ROM to ROFS1 + /* Content to be moved from ROM to ROFS1 */ } ) + #endif // _IMAGE_INCLUDE_HEADER_ONLY endef define CORE_HDRINFO @@ -143,124 +176,200 @@ define ROM_FOOTERINFO $(if $(ROM_BUILDOPT),ROMBUILD_OPTION $(ROM_BUILDOPT)) - romname $(notdir $(ROM_IMG)) $(if $(CORE_TIME),time=$(CORE_TIME)) - $(if $(ROM_CHECKSUM),romchecksum=$(ROM_CHECKSUM)) + $(if $(CORE_ROMVER),version=$(CORE_ROMVER)) $(ROM_FOOTER) endef define ROFS1_HDRINFO - $(call ODP_CODEINFO,1) + $(ODP_ROFSINFO) $(ROFS1_HEADER) $(if $(CORE_TIME),time=$(CORE_TIME)) endef -define CORE_VERIBYINFO - // Generated `$(CORE_VERIBY)$' for Core image creation - $(if $(CORE_ROMVER), - - version=$(CORE_ROMVER)) +define CORE_ORIDEINFO + // Generated `$(CORE_ORIDEIBY)' for $(CORE_TITLE) image creation - OVERRIDE_REPLACE/ADD - data-override=$(CORE_SWVERFILE) RESOURCE_FILES_DIR\versions\sw.txt - data-override=$(CORE_MODELFILE) RESOURCE_FILES_DIR\versions\model.txt - data-override=$(CORE_IMEISVFILE) RESOURCE_FILES_DIR\versions\imeisv.txt - data-override=$(CORE_PLATFILE) RESOURCE_FILES_DIR\versions\platform.txt - data-override=$(CORE_PRODFILE) RESOURCE_FILES_DIR\versions\product.txt - $(call iif,$(USE_FOTA), - data-override=$(CORE_FWIDFILE) RESOURCE_FILES_DIR\versions\fwid1.txt) - OVERRIDE_END + $(call iif,$(USE_ROFS1),\ + OVERRIDE_REPLACE/ADD + $(if $(CORE_SWVERINFO), + data-override="$(CORE_SWVERFILE)" "$(IMAGE_VERSDIR)\sw.txt") + $(if $(CORE_MODELINFO), + data-override="$(CORE_MODELFILE)" "$(IMAGE_VERSDIR)\model.txt") + $(if $(CORE_IMEISVINFO), + data-override="$(CORE_IMEISVFILE)" "$(IMAGE_VERSDIR)\imeisv.txt") + $(if $(CORE_PLATINFO), + data-override="$(CORE_PLATFILE)" "$(IMAGE_VERSDIR)\platform.txt") + $(if $(CORE_PRODINFO), + data-override="$(CORE_PRODFILE)" "$(IMAGE_VERSDIR)\product.txt") + $(if $(CORE_PURPINFO), + data-override="$(CORE_PURPFILE)" "$(IMAGE_VERSDIR)\purpose.txt") + $(if $(CORE_FWIDINFO), + data-override="$(CORE_FWIDFILE)" "$(IMAGE_VERSDIR)\fwid1.txt") + $(if $(CORE_DEVATTRINFO), + data-override="$(CORE_DEVATTRFILE)" "$(IMAGE_VERSDIR)\deviceattributes.ini") + OVERRIDE_END + ) endef #============================================================================== CLEAN_COREFILE =\ - del | "$(CORE_MSTOBY)" "$(CORE_VERIBY)" "$(CORE_SWVERFILE)" "$(CORE_MODELFILE)"\ - "$(CORE_IMEISVFILE)" "$(CORE_PLATFILE)" "$(CORE_PRODFILE)" "$(CORE_FWIDFILE)" |\ + del | "$(CORE_MSTOBY)" "$(CORE_ORIDEIBY)" "$(CORE_SWVERFILE)" "$(CORE_MODELFILE)"\ + "$(CORE_IMEISVFILE)" "$(CORE_PLATFILE)" "$(CORE_PRODFILE)" "$(CORE_PURPFILE)"\ + "$(CORE_FWIDFILE)" "$(CORE_DEVATTRFILE)" |\ del | $(call getgenfiles,$(CORE_OBYGEN)) BUILD_COREFILE =\ - echo-q | Generating file(s) for Core image creation |\ - write | $(CORE_MSTOBY) | $(call def2str,$(CORE_MSTOBYINFO)) |\ - $(call iif,$(USE_ROFS1),$(call iif,$(USE_VERGEN),\ - write | $(CORE_VERIBY) | $(call def2str,$(CORE_VERIBYINFO)) |\ - writeu | $(CORE_SWVERFILE) | $(CORE_SWVERINFO) |\ - writeu | $(CORE_MODELFILE) | $(CORE_MODELINFO) |\ - writeu | $(CORE_IMEISVFILE) | $(CORE_IMEISVINFO) |\ - writeu | $(CORE_PLATFILE) | $(CORE_PLATINFO) |\ - writeu | $(CORE_PRODFILE) | $(CORE_PRODINFO) |\ - writeu | $(CORE_FWIDFILE) | $(CORE_FWIDINFO) |))\ + echo-q | Generating file(s) for $(CORE_TITLE) image creation |\ + write-c | "$(CORE_MSTOBY)" | $(call def2str,$(CORE_MSTOBYINFO))\n |\ + $(call iif,$(USE_ROFS1),\ + $(if $(CORE_SWVERINFO),\ + writeu | "$(CORE_SWVERFILE)" | $(call quote,$(CORE_SWVERINFO)) |)\ + $(if $(CORE_MODELINFO),\ + writeu | "$(CORE_MODELFILE)" | $(CORE_MODELINFO) |)\ + $(if $(CORE_IMEISVINFO),\ + writeu | "$(CORE_IMEISVFILE)" | $(CORE_IMEISVINFO) |)\ + $(if $(CORE_PLATINFO),\ + writeu | "$(CORE_PLATFILE)" | $(CORE_PLATINFO) |)\ + $(if $(CORE_PRODINFO),\ + writeu | "$(CORE_PRODFILE)" | $(CORE_PRODINFO) |)\ + $(if $(CORE_PURPINFO),\ + writeu | "$(CORE_PURPFILE)" | $(CORE_PURPINFO) |)\ + $(if $(CORE_FWIDINFO),\ + writeu | "$(CORE_FWIDFILE)" | $(CORE_FWIDINFO) |)\ + $(if $(CORE_DEVATTRINFO),\ + writeu | "$(CORE_DEVATTRFILE)" | $(call def2str,$(CORE_DEVATTRINFO)) |)\ + )\ + $(if $(CORE_ORIDEINFO),\ + write-c | "$(CORE_ORIDEIBY)" | $(call def2str,$(CORE_ORIDEINFO)) |)\ + $(if $(CORE_ORIDECONF),\ + genorideiby | >>$(CORE_ORIDEIBY) | $(call def2str,$(CORE_ORIDEFILES) | $(CORE_ORIDECONF)) |)\ $(CORE_OBYGEN) ############################################################################### # Core pre-build step -CLEAN_COREPRE = $(if $(filter 1,$(USE_VARIANTBLD)),$(CLEAN_CUSTVARIANT) |) $(CLEAN_COREFILE) +CLEAN_COREPRE =\ + $(if $(filter 1,$(USE_VARIANTBLD)),$(CLEAN_VARIANT) |)\ + $(CLEAN_COREFILE) | $(CLEAN_DEFHRH) | $(CLEAN_FEATMAN) + BUILD_COREPRE =\ - $(if $(filter 1,$(USE_VARIANTBLD)),$(BUILD_CUSTVARIANT) |)\ - mkcd | $(CORE_DIR) |\ - $(BUILD_COREFILE) + $(if $(filter 1,$(USE_VARIANTBLD)),$(BUILD_VARIANT) |)\ + mkdir | "$(CORE_DIR)" |\ + $(BUILD_COREFILE) |\ + $(BUILD_DEFHRH) |\ + $(BUILD_FEATMAN) #============================================================================== # Core build step -BLR.CORE.IDIR = $(call dir2inc,$(CORE_IDIR) $(call iif,$(USE_FEATVAR),,$(FEATVAR_IDIR))) -BLR.CORE.HBY = $(call includeiby, $(CORE_HBY)) -BLR.CORE.OBY = $(call includeiby,$(CORE_OBY) $(if $(filter 1,$(USE_VARIANTBLD)),$(VARIANT_OBY)) $(BLDROBY) $(call iif,$(USE_ROFS1),$(call iif,$(USE_VERGEN),$(CORE_VERIBY)))) -BLR.CORE.OPT = $(CORE_OPT) $(if $(filter 1,$(USE_PAGEDCODE)),$(if $(ODP_CODECOMP),-c$(ODP_CODECOMP))) -o$(notdir $(CORE_NAME).img) $(BLDROPT) -BLR.CORE.POST =\ - move | $(CORE_PREFIX).log | $(ROM_LOG) |\ - move | $(CORE_PREFIX).oby | $(ROM_OUTOBY) |\ - test | $(ROM_IMG) | $(call iif,$(USE_PAGEDROM),test | $(ROM_INC) |)\ - $(call iif,$(USE_ROFS1),test | $(ROFS1_IMG)) +BLR.CORE.IDIR = $(call dir2inc,$(CORE_IDIR) $(call iif,$(USE_FEATVAR),,$(FEATVAR_IDIR))) +BLR.CORE.HBY = $(call includeiby, $(CORE_HBY)) +BLR.CORE.OBY =\ + $(call includeiby,$(CORE_OBY))\ + $(and $(call true,$(SYMBIAN_FEATURE_MANAGER)),$(CORE_FEAIBY),$(call mac2cppdef,-U__FEATURE_IBY__)$(call includeiby,$(CORE_FEAIBY)))\ + $(call includeiby,$(if $(filter 1,$(USE_VARIANTBLD)),$(VARIANT_OBY)) $(BLDROBY) $(CORE_ORIDEIBY)) +BLR.CORE.OPT = $(CORE_OPT) $(if $(filter 1,$(USE_PAGEDCODE)),$(if $(ODP_CODECOMP),-c$(ODP_CODECOMP))) -o$(call pathconv,$(ROM_IMG)) $(BLDROPT) +BLR.CORE.POST =\ + test | "$(ROM_IMG)" $(call iif,$(USE_PAGEDROM),"$(ROM_INC)") |\ + $(call iif,$(USE_ROFS1),\ + move | "$(ROM_PREFIX).rofs1.img" | $(ROFS1_IMG) |\ + move | "$(ROM_PREFIX).rofs1.log" | $(ROFS1_LOG) |\ + move | "$(ROM_PREFIX).rofs1.oby" | $(ROFS1_OUTOBY) |\ + $(call iif,$(USE_SYMGEN),move | "$(ROM_PREFIX).rofs1.symbol" | $(ROFS1_SYM))) -CLEAN_CORE = $(CLEAN_BLDROM) -BUILD_CORE = $(BUILD_BLDROM) +CLEAN_CORE = $(call CLEAN_BLDROM,CORE) +BUILD_CORE = $(call BUILD_BLDROM,CORE) + +REPORT_CORE =\ + $(CORE_TITLE) dir | $(CORE_DIR) | d |\ + Core ROM image | $(ROM_IMG) | f\ + $(call iif,$(USE_SYMGEN),| Core ROM symbols | $(ROM_SYM) | f)\ + $(call iif,$(USE_ROFS1),|\ + Core ROFS1 image | $(ROFS1_IMG) | f\ + $(call iif,$(USE_SYMGEN),| Core ROFS1 symbols | $(ROFS1_SYM) | f)) #============================================================================== # Core post-build step -CLEAN_COREPOST = $(CLEAN_IMGCHK) | $(CLEAN_CORESYM) -BUILD_COREPOST =\ - $(call iif,$(USE_IMGCHK),$(BUILD_IMGCHK) |)\ - $(call iif,$(USE_SYMGEN),$(BUILD_CORESYM)) +CLEAN_COREPOST = $(CLEAN_IMGCHK) +BUILD_COREPOST = $(call iif,$(USE_IMGCHK),$(BUILD_IMGCHK)) + + +############################################################################### +# Core symbol generation + +MAKSYM_CMD = $(MAKSYM_TOOL) $(call pathconv,"$(ROM_LOG)" "$(ROM_SYM)") CLEAN_CORESYM = del | "$(ROM_SYM)" "$(ROFS1_SYM)" BUILD_CORESYM =\ echo-q | Creating $(CORE_TITLE) symbol file(s) |\ - cmd | $(MAKSYM_TOOL) $(call pathconv,$(ROM_LOG) $(ROM_SYM)) |\ - $(call iif,$(USE_ROFS1),cmd | $(MAKSYMROFS_TOOL) $(call pathconv,$(ROFS1_LOG) $(ROFS1_SYM))) + cmd | $(MAKSYM_CMD) |\ + $(call iif,$(USE_ROFS1),cmd | $(MAKSYMROFS_TOOL) $(call pathconv,"$(ROFS1_LOG)" "$(ROFS1_SYM)")) + +REPORT_CORESYM =\ + Core ROM symbols | $(ROM_SYM) | f\ + $(call iif,$(USE_ROFS1),| Core ROFS1 symbols | $(ROFS1_SYM) | f) + -#============================================================================== +############################################################################### +# Steps -SOS.CORE.STEPS = $(call iif,$(SKIPPRE),,COREPRE) $(call iif,$(SKIPBLD),,CORE) $(call iif,$(SKIPPOST),,COREPOST) +SOS.CORE.STEPS =\ + $(call iif,$(SKIPPRE),,$(and $(filter 1,$(USE_VARIANTBLD)),$(call true,$(USE_CONE)),CONEGEN RESTART) COREPRE)\ + $(call iif,$(SKIPBLD),,CORE) $(call iif,$(SKIPPOST),,COREPOST) + ALL.CORE.STEPS = $(SOS.CORE.STEPS) +CORE_PRESTEPS = $(call iif,$(USE_SMR),smr |) +CORE_STEPS = $(CORE_PRESTEPS) $(ALL.CORE.STEPS) +CORE_IMGSTEPS = $(CORE_PRESTEPS) $(SOS.CORE.STEPS) + ############################################################################### # Targets -.PHONY: core core-all core-image core-pre core-check core-symbol core-i2file +.PHONY: core $(addprefix core-,all check cone i2file image pre symbol) -core core-% rom-% rofs1-%: IMAGE_TYPE = CORE -core-all : USE_SYMGEN = 1 +core core% rom% rofs1%: IMAGE_TYPE = CORE +core-all : USE_SYMGEN = 1 -core core-all: ;@$(call IMAKER,$$(ALL.CORE.STEPS)) -core-image : ;@$(call IMAKER,$$(SOS.CORE.STEPS)) +core core-all: ;@$(call IMAKER,$$(CORE_STEPS)) +core-image : ;@$(call IMAKER,$$(CORE_IMGSTEPS)) -core-pre : ;@$(call IMAKER,COREPRE) -core-check : ;@$(call IMAKER,IMGCHK) -core-symbol : ;@$(call IMAKER,CORESYM) +core-cone : ;@$(call IMAKER,CONEGEN) +core-pre : ;@$(call IMAKER,COREPRE) +core-check : ;@$(call IMAKER,IMGCHK) +core-symbol: ;@$(call IMAKER,CORESYM) +core-i2file: ;@$(call IMAKER,I2FILE) -core-i2file : ;@$(call IMAKER,COREI2F) - -core-trace-% : LABEL = _trace_$* -core-trace-% : USE_UDEB = 1 -core-trace-% : CORE_UDEBFILE = $(call findfile,$(TRACE_PREFIX)$*$(TRACE_SUFFIX),$(TRACE_IDIR)) -core-trace-% :\ +core-trace-%: LABEL = _$* +core-trace-%: USE_UDEB = 1 +core-trace-%: CORE_UDEBFILE = $(call findfile,$(TRACE_PREFIX)$*$(TRACE_SUFFIX),$(TRACE_IDIR)) +core-trace-%:\ ;@$(if $(wildcard $(CORE_UDEBFILE)),,$(error Can't make target `$@', file `$(CORE_UDEBFILE)' not found))\ $(call IMAKER,$$(ALL.CORE.STEPS)) +############################################################################### +# Helps + +$(call add_help,CORE_PURPFILE,v,(string),The (generated) _core_purpose.txt file name.) +$(call add_help,CORE_PURPINFO,v,(string),The content string for the purpose.txt file.) + +$(call add_help,core,t,Create $$(CORE_TITLE) image.) +$(call add_help,core-dir,t,Create directory structure for $$(CORE_TITLE) creation.) +$(call add_help,core-i2file,t,Extract all files from $$(CORE_TITLE) image.) +$(call add_help,core-image,t,Create $$(CORE_TITLE) image (.img) file(s).) +$(call add_help,core-pre,t,Run pre-step, create files etc. for $$(CORE_TITLE) creation.) +$(call add_help,core-symbol,t,Create $$(CORE_TITLE) symbol file(s).) + +BUILD_HELPDYNAMIC +=\ + $(foreach file,$(call reverse,$(wildcard $(addsuffix /$(TRACE_PREFIX)*$(TRACE_SUFFIX),$(TRACE_IDIR)))),\ + $(call add_help,core-trace-$(patsubst $(TRACE_PREFIX)%$(TRACE_SUFFIX),%,$(notdir $(file))),t,\ + Create $(CORE_TITLE) image with traces for $(file).)) + + # END OF IMAKER_CORE.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_emmc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imaker/src/imaker_emmc.mk Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,39 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: iMaker eMMC (Embedded Mass Memory) image configuration +# + + + +############################################################################### +# __ __ __ __ ___ +# ___| \/ | \/ |/ __| +# / -_) |\/| | |\/| | (__ +# \___|_| |_|_| |_|\___| +# + +EMMC_TITLE = eMMC + +EMMC_DRIVE = E +EMMC_FATTYPE = 32# FAT32 +EMMC_SIZE = 16777216# kB (= 16 GB) +EMMC_CLUSTERSIZE = 16# kB +EMMC_FATTABLE = 2 + +EMMC_SWVERFILE = $(EMMC_DATADIR)/Resource/Versions/User Content Package_Mass_Memory.txt +EMMC_SWVERINFO = # Don't generate sw version file +EMMC_EXCLFILE = # Don't generate exclude list + + +# END OF IMAKER_EMMC.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_fat.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imaker/src/imaker_fat.mk Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,296 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: iMaker FAT (File Allocation Table) image configuration +# + + + +############################################################################### +# ___ _ _____ +# | __|/_\|_ _| +# | _|/ _ \ | | +# |_|/_/ \_\|_| +# + +USE_FILEDISK = 0 +USE_FSIMAGE = 0 +USE_SOSUDA = 1 + +FATEMPTY_CMD = + + +############################################################################### +# + +define FAT_EVAL +$1_TITLE = $1 +$1_ROOT = $$(OUTDIR)/$2 +$1_DIR = $$($1_ROOT) +$1_NAME = $$(NAME) +$1_PREFIX = $$($1_DIR)/$$($1_NAME) +$1_IDIR = +$1_HBY = +$1_OBY = +$1_OPT = $$(BLDROM_OPT) -D_EABI=$$(ARM_VERSION) +$1_MSTOBY = $$($1_PREFIX)_$2_master.oby +$1_HEADER = +$1_INLINE = +$1_FOOTER = +$1_TIME = $$(DAY)/$$(MONTH)/$$(YEAR) + +$1_DEFHRH = $$($1_PREFIX)_$2_define.hrh +$1_FEAXML = +$1_FEAIBY = + +$1_ROMVER = $$(CORE_ROMVER) +$1_ID = $$(if $$(filter $2_%,$$(TARGETNAME)),$$(TARGETID1),00) +$1_REVISION = 01 +$1_VERSION = $$(CORE_VERSION).$$($1_ID).$$($1_REVISION) +$1_SWVERFILE = $$($1_DATADIR)/Resource/Versions/User Content Package_$1.txt +$1_SWVERINFO = $$($1_VERSION) + +$1_IMG = $$($1_PREFIX).$2.img +$1_LOG = $$($1_PREFIX).$2.log +$1_OUTOBY = $$($1_PREFIX).$2.oby + +$1_PLUGINLOG = $$($1_PREFIX)_$2_bldromplugin.log +$1_UDEBFILE = $$(TRACE_UDEBFILE) + +$1_OBYGEN = +$1_ORIDEIBY = $$($1_PREFIX)_$2_override.iby +$1_ORIDEFILES = $$(IMAGE_ORIDEFILES) +$1_ORIDECONF = $$(IMAGE_ORIDECONF) + +$1_CONECONF = $$(PRODUCT_NAME)_$2_$$($1_ID)$$(addprefix _,$$($1_VARNAME))_root.confml +$1_CONEOPT = --all-layers --impl-tag=target:$2 + +$1_DRIVE = C +$1_FATTYPE = 16# FAT16 +$1_SIZE = 20480# kB +$1_SIZEB = $$(call peval,$$($1_SIZE) * 1024)# B +$1_DISKSIZE = $$($1_SIZE)# kB +$1_SECTORSIZE = 512# B +$1_CLUSTERSIZE = 4# kB +$1_FATTABLE = 1 +$1_VOLUME = + +$1_TOUCH = 0#$$(YEAR)$$(MONTH)$$(DAY)000000 +$1_CPDIR = +$1_ZIP = +$1_DATADIR = $$($1_DIR)/datadrive + +$1_VARNAME = $$(if $$(filter $2_%,$$(TARGETNAME)),$$(TARGETID2-)) +$1_VARROOT = $$(or $$(wildcard $$(PRODUCT_DIR)/$2),$$(or $$(if $$(PRODUCT_MSTNAME),$$(wildcard $$(PRODUCT_MSTDIR)/$2)),$$(PRODUCT_DIR)/$2)) +$1_VARDIR = $$(if $$(and $$(call true,$$(USE_CONE)),$$(call true,$$(IMAKER_MKRESTARTS))),$$(CONE_OUTDIR),$$($1_VARROOT)/$2_$$($1_ID)$$(addprefix _,$$($1_VARNAME))$$(call iif,$$(USE_CONE),/content)) + +$1_EXCLFILE = $$($1_DATADIR)/private/100059C9/excludelist.txt + +define $1_EXCLADD +* +endef + +define $1_EXCLRM +endef + +$1EMPTY_TITLE = $$($1_TITLE) Empty +$1EMPTY_IMG = $$($1_PREFIX).$2empty.img +$1EMPTY_CMD = $$(FATEMPTY_CMD) + +#============================================================================== + +define $1_MSTOBYINFO + $$(call BLDROM_HDRINFO,$1) + + ROM_IMAGE 0 non-xip size=0x00000000 + + DATA_IMAGE 0 $$(basename $$($1_IMG)) size=$$(call peval,$$($1_DISKSIZE) * 1024) fat$$(if $$(filter %32,$$($1_FATTYPE)),32,16) + + $$(call BLDROM_PLUGINFO,$1) + + /* $1 header + */ + $$($1_HDRINFO) + + DATA_IMAGE[0] { + $$(if $$($1_VOLUME),volume=$$($1_VOLUME)) + fattable=$$($1_FATTABLE) + #ifndef _IMAGE_INCLUDE_HEADER_ONLY + $$(BLR.$1.OBY) + $$($1_INLINE) + $$($1_FOOTERINFO) + } + #endif // _IMAGE_INCLUDE_HEADER_ONLY +endef + +define $1_HDRINFO + $$(DEFINE) _IMAGE_WORKDIR $$($1_DIR) + $$(call mac2cppdef,$$(BLR.$1.OPT)) + $$(BLR.$1.HBY) + $$($1_HEADER) + $$(if $$(filter $3,$$(USE_VARIANTBLD)),$$(VARIANT_HEADER)) +endef + +define $1_FOOTERINFO + $$(if $$($1_TIME),time=$$($1_TIME)) + $$(if $$($1_ROMVER),version=$$($1_ROMVER)) + $$($1_FOOTER) +endef + +$1_ORIDEINFO = + +#============================================================================== +# FAT pre-build + +CLEAN_$1PRE =\ + $$(if $$(filter $3,$$(USE_VARIANTBLD)),$$(CLEAN_VARIANT),deldir | "$$($1_DATADIR)") |\ + $$(CLEAN_$1FILE) | $$(CLEAN_DEFHRH) | $$(CLEAN_FEATMAN) + +BUILD_$1PRE =\ + echo-q | Preparing $$($1_TITLE) FAT image creation |\ + $$(if $$(filter $3,$$(USE_VARIANTBLD)),$$(BUILD_VARIANT) |,\ + mkdir | "$$($1_DATADIR)" |\ + $$(if $$($1_ZIP),\ + $$(eval __i_zip := $$(foreach zip,$$($1_ZIP),$$(zip)$$(if $$(filter %.zip,$$(call lcase,$$(zip))),,/*.zip)))\ + echo-q | Extracting `$$(__i_zip)' to `$$($1_DATADIR)' |\ + unzip | "$$(__i_zip)" | $$($1_DATADIR) |)\ + $$(if $$($1_CPDIR),\ + copydir | "$$($1_CPDIR)" | $$($1_DATADIR) |))\ + mkdir | "$$($1_DIR)" |\ + $$(BUILD_$1FILE) |\ + $$(call iif,$$(BLR.$1.OBY),$$(BUILD_DEFHRH) |)\ + $$(BUILD_FEATMAN) + +CLEAN_$1FILE =\ + del | "$$($1_MSTOBY)" "$$($1_ORIDEIBY)" "$$($1_SWVERFILE)" |\ + del | $$(call getgenfiles,$$($1_OBYGEN)) + +BUILD_$1FILE =\ + echo-q | Generating file(s) for $$($1_TITLE) FAT image creation |\ + $$(call iif,$$(BLR.$1.OBY),\ + write-c | "$$($1_MSTOBY)" | $$(call def2str,$$($1_MSTOBYINFO))\n |)\ + $$(if $$($1_SWVERINFO),\ + writeu | "$$($1_SWVERFILE)" | $$(call quote,$$($1_SWVERINFO)) |)\ + $$(if $$($1_ORIDEINFO),\ + write-c | "$$($1_ORIDEIBY)" | $$(call def2str,$$($1_ORIDEINFO)) |)\ + $$(if $$($1_ORIDECONF),\ + genorideiby | >>$$($1_ORIDEIBY) | $$(call def2str,$$($1_ORIDEFILES) | $$($1_ORIDECONF)) |)\ + $$($1_OBYGEN) + +#============================================================================== +# FAT build + +BLR.$1.IDIR = $$(call dir2inc,$$($1_IDIR) $$(call iif,$$(USE_FEATVAR),,$$(FEATVAR_IDIR))) +BLR.$1.HBY = $$(call includeiby,$$(IMAGE_HBY) $$($1_HBY)) +BLR.$1.OBY = $$(call includeiby,$$($1_OBY))\ + $$(and $$(call true,$$(SYMBIAN_FEATURE_MANAGER)),$$($1_FEAIBY),$$(call mac2cppdef,-U__FEATURE_IBY__)$$(call includeiby,$$($1_FEAIBY)))\ + $$(call includeiby,$$(and $$(filter $3,$$(USE_VARIANTBLD)),$$(call true,$$(VARIANT_INCDIR)$$(USE_SOSUDA)),$$(VARIANT_OBY))\ + $$(if $$(strip $$($1_ORIDEINFO)$$($1_ORIDECONF)),$$($1_ORIDEIBY))) +BLR.$1.OPT = $$($1_OPT) -noimage -o$$(call pathconv,$$($1_PREFIX)).dummy0.img $$(BLDROPT) +BLR.$1.POST = $$(call iif,$$(USE_SOSUDA),,copyiby | "$$($1_OUTOBY)" | $$($1_DATADIR)) + +CLEAN_$1 = $$(call CLEAN_BLDROM,$1) | $$(CLEAN_FILEDISK) | $$(CLEAN_WINIMAGE) | $$(CLEAN_FSIMAGE) +BUILD_$1 =\ + $$(call iif,$$(BLR.$1.OBY),$$(call BUILD_BLDROM,$1) |)\ + $$(if $$($1_EXCLFILE),\ + genexclst | $$($1_EXCLFILE) | $$($1_DATADIR) | $$($1_DRIVE): |\ + $$(call def2str,$$($1_EXCLADD) | $$($1_EXCLRM)) |)\ + $$(call iif,$$($1_TOUCH),\ + finddir-r | "$$($1_DATADIR)" | * ||\ + find-ar | "$$($1_DATADIR)" | * ||\ + touch | __find__ | $$($1_TOUCH) |)\ + echo-q | Creating $$($1_TITLE) FAT image |\ + $$(call iif,$$(USE_SOSUDA),$$(BUILD_ROFSBLDFAT),\ + $$(call iif,$$(USE_FSIMAGE),$$(BUILD_FSIMAGE),\ + $$(call iif,$$(USE_FILEDISK),$$(BUILD_FILEDISK),$$(BUILD_WINIMAGE)))) + +REPORT_$1 =\ + $$($1_TITLE) dir | $$($1_DIR) | d |\ + $$($1_TITLE) image | $$($1_IMG) | f + +#============================================================================== +# FAT post-build + +CLEAN_$1POST = +BUILD_$1POST = +REPORT_$1POST = + +#============================================================================== +# Empty FAT + +CLEAN_$1EMPTY = del | "$$($1EMPTY_IMG)" +BUILD_$1EMPTY = $$(if $$($1EMPTY_CMD),\ + echo-q | Creating $$($1EMPTY_TITLE) FAT image |\ + mkdir | "$$($1_DIR)" |\ + cmd | $$($1EMPTY_CMD)) + +REPORT_$1EMPTY = $$($1EMPTY_TITLE) image | $$($1EMPTY_IMG) | f + +#============================================================================== +# FAT steps + +SOS.$1.STEPS =\ + $$(call iif,$$(SKIPPRE),,$$(and $$(filter $3,$$(USE_VARIANTBLD)),$$(call true,$$(USE_CONE)),CONEGEN RESTART) $1PRE)\ + $$(call iif,$$(SKIPBLD),,$1) $$(call iif,$$(SKIPPOST),,$1POST) + +SOS.$1EMPTY.STEPS = $$(if $$(BUILD_$1EMPTY),$1EMPTY) + +ALL.$1.STEPS = $$(SOS.$1.STEPS) +ALL.$1EMPTY.STEPS = $$(SOS.$1EMPTY.STEPS) + +#============================================================================== +# Targets + +.PHONY: $2 $2-cone $2-image $2-pre $2empty $2empty-image variant$2 + +$2 $2% : IMAGE_TYPE = $1 + +$2 : ;@$$(call IMAKER,$$$$(ALL.$1.STEPS)) +$2-image: ;@$$(call IMAKER,$$$$(SOS.$1.STEPS)) +$2-cone : ;@$$(call IMAKER,CONEGEN) +$2-pre : ;@$$(call IMAKER,$1PRE) + +$2empty : ;@$$(call IMAKER,$$$$(ALL.$1EMPTY.STEPS)) +$2empty-image: ;@$$(call IMAKER,$$$$(SOS.$1EMPTY.STEPS)) + +variant$2 variant$2% : USE_CONE = 0 +variant$2 variant$2% $2_%: USE_VARIANTBLD = $3 +variant$2 variant$2% $2_%: $2$$(TARGETEXT) ; + +#============================================================================== +# Helps + +$(call add_help,$2,t,Create $$($1_TITLE) image.) +$(call add_help,$2-dir,t,Create directory structure for $$($1_TITLE) creation.) +$(call add_help,$2-image,t,Create $$($1_TITLE) image (.img) file.) +$(call add_help,$2-pre,t,Run pre-step, create files etc. for $$($1_TITLE) creation.) +$(call add_help,variant$2,t,Create $$($1_TITLE) image from a variant directory. Be sure to define the VARIANT_DIR.) + +BUILD_HELPDYNAMIC +=\ + $$(call add_help,$$(call getlastdir,$$(wildcard $$($1_VARROOT)/$2_*/)),t,$$($1_TITLE) variant target.)\ + $$(eval include $$(wildcard $$($1_VARROOT)/$2_*/$$(VARIANT_MKNAME))) + +endef # FAT_EVAL + + +############################################################################### +# + +$(eval $(call FAT_EVAL,EMMC,emmc,e)) +$(eval $(call FAT_EVAL,MCARD,mcard,m)) +$(eval $(call FAT_EVAL,UDA,uda,u)) + +$(call includechk,$(addprefix $(IMAKER_DIR)/imaker_,emmc.mk memcard.mk uda.mk)) + + +# END OF IMAKER_FAT.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_help.mk --- a/imgtools/imaker/src/imaker_help.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_help.mk Wed Jun 30 11:35:58 2010 +0800 @@ -25,14 +25,15 @@ add_help =\ $(if $(filter help%,$(MAKECMDGOALS)),\ - $(eval __i_type := $(call select,$(call substr,1,1,$(strip $2)),t,t,v))\ - $(eval __i_isvar := $(call equal,$(__i_type),v))\ + $(eval __i_type := $(if $(filter t% T%,$2),t,v))\ + $(eval __i_isvar := $(filter v,$(__i_type)))\ $(foreach name,$1,\ $(eval HELP.$(name).TYPE := $(__i_type))\ $(if $(__i_isvar),$(eval HELP.$(name).VALUES = $3))\ - $(eval HELP.$(name).DESC = $(strip $(eval __i_desc := $(if $(__i_isvar),$4,$3))\ + $(eval HELP.$(name).DESC = $(strip $(eval __i_desc = $(if $(__i_isvar),$$4,$$3))\ $(foreach p,$(if $(__i_isvar),,4) 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20,\ - $(if $(call defined,$p),$(eval __i_desc := $(__i_desc)$(,)$($p)))))$(__i_desc)))) + $(if $(call defined,$p),$(eval __i_desc = $(value __i_desc)$(,)$$($p))))\ + $(subst $$1,$(name),$(subst $$2,$(__i_type),$(__i_desc))))))) get_helpitems =\ $(strip $(eval __i_list := $(filter HELP.%.TYPE,$(.VARIABLES)))\ @@ -40,26 +41,19 @@ #============================================================================== -.PHONY: help help-config help-target help-variable +.PHONY: help help-config -.DEFAULT_GOAL := help - -help:: ;@$(call IMAKER,HELPUSAGE:b) +help:: ;@$(call IMAKER,HELPUSAGE) -help-config: ;@$(call IMAKER,HELPCFG:b) - -help-target help-variable: $$@-* ; +help-config: ;@$(call IMAKER,HELPCFG) -help-target-%-list help-target-%-wiki help-target-% \ -help-variable-%-list help-variable-%-value help-variable-%-all help-variable-%-wiki help-variable-% \ -help-%-list help-%:\ - ;@$(call IMAKER) +help-%: ;@$(call IMAKER,HELP) # Help usage info define HELP_USAGE Print help data on documented iMaker API items; targets and variables. - Wildcards *, ? and [] can be used with % patterns. + Wildcards *, ? and [..] can be used with % patterns. help : Print this message. help-% : $(HELP.help-%.DESC) @@ -85,15 +79,10 @@ BUILD_HELPUSAGE = echo | $(call def2str,$(HELP_USAGE))\n -BUILD_HELPDYNAMIC =\ - $(foreach file,$(call reverse,$(wildcard $(addsuffix /$(TRACE_PREFIX)*$(TRACE_SUFFIX),$(TRACE_IDIR)))),\ - $(call add_help,core-trace-$(patsubst $(TRACE_PREFIX)%$(TRACE_SUFFIX),%,$(notdir $(file))),t,Core image with traces for $(file).))\ - $(call add_help,$(call getlastdir,$(wildcard $(LANGPACK_ROOT)/$(LANGPACK_PREFIX)*/)),t,Language variant target.)\ - $(call add_help,$(call getlastdir,$(wildcard $(CUSTVARIANT_ROOT)/$(CUSTVARIANT_PREFIX)*/)),t,Customer variant target.)\ - $(eval include $(wildcard $(LANGPACK_ROOT)/$(LANGPACK_PREFIX)*/$(LANGPACK_MKNAME)))\ - $(eval include $(wildcard $(CUSTVARIANT_ROOT)/$(CUSTVARIANT_PREFIX)*/$(VARIANT_MKNAME))) +BUILD_HELPDYNAMIC = BUILD_HELP =\ + $(BUILD_HELPDYNAMIC)\ $(eval __i_var := $(filter help-%,$(MAKECMDGOALS)))\ $(if $(filter help-target help-variable,$(__i_var)),$(eval __i_var := $(__i_var)-*))\ $(eval __i_helpgoal := $(__i_var))\ @@ -107,15 +96,15 @@ $(call peval,\ my @var = ($(foreach var,$(foreach var2,$(subst $(,), ,$(__i_var)),$(call filterwcard,$(var2),$(__i_list))),{\ n=>$(call pquote,$(var))\ - $(eval __i_isvar := $(call equal,$(HELP.$(var).TYPE),v))\ + $(eval __i_isvar := $(filter v,$(HELP.$(var).TYPE)))\ $(if $(__i_value),$(if $(__i_isvar),$(,)v=>$(call pquote,$(call def2str,$($(var))))))\ $(,)t=>q($(HELP.$(var).TYPE))\ $(if $(__i_desc),\ $(,)d=>$(call pquote,$(HELP.$(var).DESC))\ $(if $(__i_isvar),$(,)V=>$(call pquote,$(HELP.$(var).VALUES)))) }$(,)));\ - imaker:DPrint(1, map($(if $(__i_desc),$(if $(__i_wiki),,q(-) x 40 . qq(\n) .))\ + DPrint(1, map($(if $(__i_desc),$(if $(__i_wiki),,q(-) x 40 . qq(\n) .))\ qq($(if $(__i_wiki),== $$_->{n} ==,$$_->{n}))\ - $(if $(__i_value),. ($$_->{t} eq q(v) ? qq( = `$$_->{v}$') : q())) . qq(\n)\ + $(if $(__i_value),. ($$_->{t} eq q(v) ? qq( = `$$_->{v}') : q())) . qq(\n)\ $(if $(__i_desc),.\ qq($(__i_wiki)Type : ) . ($$_->{t} eq q(t) ? qq(Target\n) : qq(Variable\n)) .\ qq($(__i_wiki)Description: $$_->{d}\n) .\ @@ -124,42 +113,44 @@ BUILD_HELPCFG =\ echo | Finding available configuration file(s):\n\ - $(call get_cfglist,$(CONFIGROOT),image_conf_.*\.mk,2)\n + $(call peval,return(join(q(), map(Quote(qq($$_\n)), GetConfmkList(1))))) + + +############################################################################### +# print-% -get_cfglist =\ - $(call peval,\ - use File::Find;\ - my ($$dir, @conf) = (GetAbsDirname($(call pquote,$1)), ());\ - find(sub {\ - push(@conf, $$File::Find::name) if\ - /$2$$/s && (($$File::Find::name =~ tr/\///) > (($$dir =~ tr/\///) + $3));\ - }, $$dir);\ - return(join(q(\n), map(Quote($$_), sort({lc($$a) cmp lc($$b)} @conf))))) +BUILD_PRINTVAR = $(call peval,DPrint(1,\ + $(foreach var1,$(subst $(,), ,$(subst print-,,$(filter print-%,$(MAKECMDGOALS)))),\ + $(foreach var2,$(call filterwcard,$(var1),$(filter-out BUILD_PRINTVAR,$(filter $(word 1,$(call substm,* ? [, ,$(var1)))%,$(.VARIABLES)))),\ + $(call pquote,$(var2) = `$(call def2str,$($(var2)))').qq(\n),))); return(q())) + +print-%: ;@$(call IMAKER,PRINTVAR) + +$(call add_help,print-%,t,Print the value(s) of the given variable(s). Wildcards *, ? and [..] can be used in variable names.) ############################################################################### # Helps $(call add_help,CONFIGROOT,v,(string),Define the default configuration root directory.) -$(call add_help,USE_OVERRIDE,v,([0|1]),Define whether the override.pm Buildrom.pl plugin is used.) $(call add_help,USE_PAGING,v,((0|rom|code[:[(1|2|3)]+]?)),Define the usage of On Demand Pagin (ODP). (E.g. 0,rom,code).) $(call add_help,USE_ROFS,v,([[dummy|]0..6][,[dummy|]0..6]*),Define the rofs sections in use. A comma separated list can be given of possible values. (E.g. 1,2,3).) $(call add_help,USE_ROMFILE,v,([0|1]),Define whether the \epoc32\rombuild\romfiles.txt is used. Files in romfiles are automatically moved to ROM, everything else in core is moved to ROFS1.) $(call add_help,USE_SYMGEN,v,([0|1]),Generate the rom symbol file. 0=Do not generate, 1=Generate) $(call add_help,USE_UDEB,v,([0|1|full]),Include the usage of the debug binary *.txt to define the list of binaries that are taken from udeb folder instead of the urel.) -$(call add_help,USE_VERGEN,v,([0|1]),Use iMaker version info generation) -$(call add_help,KEEPTEMP,v,([0|1]),Keep the buildrom.pl temp files (copied to the WORKDIR). E.g. tmp1.oby tmp2.oby..tmp9.oby) +$(call add_help,KEEPTEMP,v,([0|1]),Keep the buildrom.pl temp files (copied to the OUTDIR). E.g. tmp1.oby tmp2.oby..tmp9.oby) $(call add_help,LABEL,v,(string),A label to the NAME of the image) $(call add_help,NAME,v,(string),The name of the image) $(call add_help,TYPE,v,(rnd|prd|subcon),Defines the image type.) -$(call add_help,WORKDIR,v,(string),The working directory for the image creation) +$(call add_help,OUTDIR,v,(string),The output directory for the image creation.) +$(call add_help,WORKDIR,v,(string),The working directory for the image creation. Deprecated, please use OUTDIR.) $(call add_help,PRODUCT_NAME,v,(string),Name of the product) $(call add_help,PRODUCT_MODEL,v,(string),The model of the product) $(call add_help,PRODUCT_REVISION,v,(string),The revision of the product.) $(call add_help,BLDROM_OPT,v,(string),The default buildrom.pl options) $(call add_help,BLDROPT,v,(string),For passing extra parameters (from command line) to the buildrom.pl) $(call add_help,BLDROBY,v,(string),For passing extra oby files (from command line) to the buildrom.pl) -$(call add_help,SOS_VERSION,v,([0-9]+.[0-9]+),Symbian OS version number. The value is used in the version info generation (platform.txt).(see USE_VERGEN)) +$(call add_help,SOS_VERSION,v,([0-9]+.[0-9]+),Symbian OS version number. The value is used in the version info generation (platform.txt).) $(call add_help,COREPLAT_NAME,v,(string),Name of the core platform) $(call add_help,CORE_DIR,v,(string),The working directory, when creating core image) $(call add_help,CORE_NAME,v,(string),The name of the core image) @@ -209,28 +200,20 @@ $(call add_help,ROFS3_TIME,v,(string),The time defined to the rofs3 image.) $(call add_help,ROFS3_VERIBY,v,(string),The (generated) version iby file name for the rofs3 image. This file included the version text files and other version parameters.) $(call add_help,ROFS3_ROMVER,v,(string),The rofs3 ROM version string) -$(call add_help,ROFS3_CUSTSWFILE,v,(string),The (generated) source file name for customersw.txt.) -$(call add_help,ROFS3_CUSTSWINFO,v,(string),The content string for the customersw.txt.) +$(call add_help,ROFS3_SWVERFILE,v,(string),The (generated) source file name for customersw.txt.) +$(call add_help,ROFS3_SWVERINFO,v,(string),The content string for the customersw.txt.) $(call add_help,ROFS3_FWIDFILE,v,(string),The (generated) _rofs3_fwid.txt file name.) $(call add_help,ROFS3_FWIDINFO,v,(string),The content string for the fwid3.txt file.) $(call add_help,VARIANT_DIR,v,(string),Configure the directory where to included the customer variant content. By default all content under $(VARIANT_CPDIR) is included to the image as it exists in the folder.) -$(call add_help,VARIANT_CONFML,v,(string),Configure what is the ConfigurationTool input confml file, when configuration tool is ran.) -$(call add_help,VARIANT_CONFCP,v,(string),Configure which ConfigurationTool generated configurations dirs are copied to output.) +$(call add_help,PRODUCT_VARDIR,v,(string),Overrides the VARIANT_DIR for product variant, see the instructions of VARIANT_DIR for details.) +$(call add_help,TARGET_DEFAULT,v,(string),Configure actual target(s) for target default.) # Targets $(call add_help,version,t,Print the version information) $(call add_help,clean,t,Clean all target files.) -$(call add_help,core,t,Create the core image (ROM,ROFS1)) -$(call add_help,rofs2,t,Create the rofs2 image) -$(call add_help,rofs3,t,Create the rofs3 image) $(call add_help,variant,t,Create the variant image (rofs2,rofs3)) -$(call add_help,uda,t,Create the User Data area (uda) image.) $(call add_help,image,t,Create only the image file(s) (*.img)) -$(call add_help,core-image,t,Create the core image files (rom.img, rofs1.img)) -$(call add_help,rofs2-image,t,Create the rofs2 image file (rofs2.img)) -$(call add_help,rofs3-image,t,Create the rofs3 image file (rofs3.img)) -$(call add_help,variant-image,t,Create the variant image files (rofs3.img,rofs3.img)) -$(call add_help,uda-image,t,Create the User Data area (uda) image.) +$(call add_help,variant-image,t,Create the variant image files (rofs2.img, rofs3.img)) $(call add_help,toolinfo,t,Print info about the tool) $(call add_help,romsymbol,t,Create the rom symbol file) $(call add_help,all,t,Create all image sections and symbol files.) @@ -240,7 +223,7 @@ $(call add_help,step-%,t,\ Generic target to execute any step inside the iMaker configuration. Any step (e.g. BUILD_*,CLEAN_*) can be executed with step-STEPNAME.\ Example: step-ROFS2PRE executes the CLEAN_ROFS2PRE and BUILD_ROFS2PRE commands.) -$(call add_help,print-%,t,Print the value of the given variable to the screen.) +$(call add_help,default,t,Default target, uses variable TARGET_DEFAULT to get actual target(s), current default = $$(TARGET_DEFAULT).) $(call add_help,help,t,Print help on help targets.) $(call add_help,help-%,t,Print help on help items matching the pattern.) diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_image.mk --- a/imgtools/imaker/src/imaker_image.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_image.mk Wed Jun 30 11:35:58 2010 +0800 @@ -17,31 +17,36 @@ USE_FEATVAR = $(call select,$(word 1,$(getsbvrominc)),invalid,0,1) -USE_FOTA = 0 USE_IMGCHK = 0 -USE_IINTPRSIS = 0 -USE_IREADIMG = 0 -USE_IROMBLD = 0 -USE_OVERRIDE = 1 +USE_NOROMHDR = 0 +USE_QTLOCLZTN = 0 USE_ROFS = 1,2,3 USE_ROFSFILE = $(call iif,$(USE_PAGING),1,0) USE_ROMFILE = 1 +USE_SMR = 0 USE_SYMGEN = 0 USE_UDEB = 0 -USE_VERGEN = 0 -$(foreach rofs,1 2 3 4 5 6,\ - $(eval USE_ROFS$(rofs) = $$(if $$(findstring $(rofs),$$(filter-out :%,$$(subst :, :,$$(subst $$(,), ,$$(USE_ROFS))))),1,0))) +# Temporary +USE_BLRWORKDIR = 0 #============================================================================== TYPE = rnd -BUILD_INFOMK = image_conf_buildinfo.mk -BUILD_NAMEMK = image_conf_naming.mk +MAJOR_VERSION = 001 +MINOR_VERSION = 000 +SW_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION) +SW_TYPEINFO = $(call select,$(TYPE),rnd,RD) + +BUILD_INFOMK = $(call findfile,image_conf_buildinfo.mk,,1) +BUILD_NAMEMK = $(call findfile,image_conf_naming.mk,,1) BUILD_YEAR = $(YEAR) +BUILD_MONTH = $(MONTH) BUILD_WEEK = $(WEEK) -BUILD_NUMBER = xx +BUILD_DAY = $(DAY) +BUILD_ID = 001 +BUILD_NUMBER = 001 COREPLAT_NAME = COREPLAT_DIR = $(CONFIGROOT)/$(COREPLAT_NAME) @@ -49,24 +54,31 @@ PLATFORM_NAME = $(subst .,,$(COREPLAT_VERSION)$(S60_VERSION)) PLATFORM_DIR = $(CONFIGROOT)/$(PLATFORM_NAME) PRODUCT_MSTNAME = +PRODUCT_MSTDIR = $(if $(PRODUCT_MSTNAME),$(PLATFORM_DIR)/$(PRODUCT_MSTNAME)) PRODUCT_NAME = PRODUCT_MANUFACT = Nokia PRODUCT_MODEL = N00 PRODUCT_TYPE = PRODUCT_REVISION = 01 -PRODUCT_DIR = $(PLATFORM_DIR)/$(if $(PRODUCT_MSTNAME),$(PRODUCT_MSTNAME)/)$(PRODUCT_NAME) +PRODUCT_DIR = $(if $(PRODUCT_NAME),$(PLATFORM_DIR)/$(if $(PRODUCT_MSTNAME),$(PRODUCT_MSTNAME)/)$(PRODUCT_NAME)) FEATURE_VARIANT = $(PRODUCT_NAME) FEATVAR_IDIR = $(call getrominc) +FEATVAR_HRH = $(call findfile,feature_settings.hrh) -LABEL = -NAME = $(PRODUCT_NAME)$(LABEL) -WORKDIR = $(if $(PRODUCT_NAME),$(E32ROMBLD)/$(PRODUCT_NAME),$(CURDIR)) -WORKPREFIX = $(WORKDIR)/$(NAME) -WORKNAME = $(WORKPREFIX) +LABEL = +NAME = $(or $(PRODUCT_NAME),imaker)$(LABEL) +WORKDIR = $(if $(PRODUCT_NAME),$(E32ROMBLD)/$(PRODUCT_NAME),$(CURDIR)) -IMAGE_HBY = -IMAGE_TYPE = +IMAGE_TYPE = +IMAGE_ID = $(or $(subst CORE,1,$(subst ROFS,,$(filter CORE ROFS%,$(IMAGE_TYPE)))),\ + $(call lcase,$(call substr,1,1,$(filter EMMC MCARD UDA,$(IMAGE_TYPE))))) +IMAGE_PREFIX = $($(IMAGE_TYPE)_PREFIX)_$(call lcase,$(IMAGE_TYPE)) +IMAGE_HBY = +IMAGE_VERSDIR = RESOURCE_FILES_DIR\versions + +IMAGE_ORIDEFILES = +IMAGE_ORIDECONF = TRACE_IDIR = $(addsuffix /traces,$(FEATVAR_IDIR)) TRACE_PREFIX = @@ -75,72 +87,63 @@ OVERRIDE_CONF = OVERRIDE_REPLACE/WARN #OVERRIDE_REPLACE/ADD, OVERRIDE_REPLACE/SKIP, OVERRIDE_SKIP/ADD -GENIBY_FILEPAT = *.dll *.exe *.agt *.csy *.fsy *.tsy *.drv *.nif *.pgn *.prt +#GENIBY_FILEPAT = *.dll *.exe *.agt *.csy *.fsy *.tsy *.drv *.nif *.pgn *.prt ARM_VERSION = ARMV5 -SOS_VERSION = #9.3, 9.4, 9.5 -S60_VERSION = #3.2, 5.0 - -ROFS_MAXSIZE = 0x10000000 - -CPPFILE_LIST = -MKFILE_LIST = $(call findfile,$(BUILD_INFOMK) $(BUILD_NAMEMK) $(LANGPACK_SYSLANGMK),$(FEATVAR_IDIR)) | $(VARIANT_MK) - +SOS_VERSION = #9.5 +S60_VERSION = -############################################################################### -# +CPPFILE_FILTER = FF_WDP_\S+|SYMBIAN_\S+ +CPPFILE_LIST = $(if $(FEATURE_VARIANT),$(FEATVAR_HRH)) -SOS.IMAGE.STEPS =\ - $(filter-out %POST,$(SOS.CORE.STEPS) $(SOS.VARIANT.STEPS))\ - $(filter %POST,$(SOS.CORE.STEPS) $(SOS.VARIANT.STEPS)) - -ALL.IMAGE.STEPS = $(SOS.IMAGE.STEPS) - -CLEAN_WORKAREA = del | $(WORKDIR)/* | deldir | $(WORKDIR)/* -ALL.CLEAN.STEPS = $(ALL.IMAGE.STEPS) WORKAREA +TARGET_PRODUCT = +TARGET_DEFAULT = all ############################################################################### # Internal macros and definitions -getrominc = $(if $(call true,$(USE_FEATVAR)),$(getsbvrominc),$(CONFIGROOT) $(E32ROM)) +getrominc =\ + $(if $(call true,$(USE_FEATVAR)),$(getsbvrominc),$(if $(word 5,$(__i_getrominc)),$(call restwords,5,$(__i_getrominc))\ + ,$(PRODUCT_DIR) $(PRODUCT_MSTDIR) $(CONFIGROOT)) $(E32ROM) $(E32ROMINC) $(E32INC)/oem $(E32INC)) + +# ,$(PRODUCT_DIR) $(PRODUCT_MSTDIR) $(CONFIGROOT)) $(E32INC)/config $(E32ROM) $(E32ROMINC) $(E32INC)/internal $(E32INC)) getsbvrominc =\ - $(if $(call equal,$(__i_featvar),$(FEATURE_VARIANT)),,$(eval __i_featvar := $(FEATURE_VARIANT))\ - $(eval __i_getrominc := $(shell $(PERL) -x $(IMAKER_TOOL) --incdir $(__i_featvar))))$(__i_getrominc) + $(if $(and $(FEATURE_VARIANT),$(call equal,$(__i_featvar),$(FEATURE_VARIANT))),,$(eval __i_featvar := $(FEATURE_VARIANT))\ + $(eval __i_getrominc := $(if $(__i_featvar),$(shell $(PERL) -x $(IMAKER_TOOL) --incdir $(__i_featvar)),invalid)))$(__i_getrominc) -includeiby = $(call peval,\ +includeiby = $(if $(strip $1),$(call peval,\ my @files = ();\ while ($(call pquote,$1) =~ /(?:([1-6]):)?(?:<(.+?)>|"+(.+?)"+|(\S+))/g) {\ my $$rom = (defined($$1) ? $$1 : q());\ - push(@files, ($$rom ? q(ROM_IMAGE[).$$rom.q(] {\\\n) : q()) . q(\#include ).\ - (defined($$2) ? qq(<$$2>) : q(").GetRelFname(defined($$3) ? $$3 : $$4, $(call pquote,$2)).q(")) . ($$rom ? q(\\\n}) : q()))\ + push(@files, ($$rom ? q(ROM_IMAGE[).$$rom.q(] {\n) : q()) . q(\#include ).\ + (defined($$2) ? qq(<$$2>) : q(").GetAbsFname(defined($$3) ? $$3 : $$4).q(")) . ($$rom ? q(\n}) : q()))\ }\ - return(join(q(\\\n), @files))) + return(join(q(), map(q(\n) . $$_, @files))))) define BLDROM_HDRINFO - // Generated master oby for $($(IMAGE_TYPE)_TITLE) image creation + // Generated master oby for $($1_TITLE) image creation // - // Filename: $($(IMAGE_TYPE)_MSTOBY) - // Work dir: $(call peval,GetAbsDirname(q(.))) - // Command : $(BLDROM_CMD) + // Filename: $($1_MSTOBY) + // Command : $(call BLDROM_CMD,$1) endef define BLDROM_PLUGINFO - // Buildrom plugins - // - $(call iif,$(USE_OVERRIDE), - externaltool=override:$($(IMAGE_TYPE)_PLUGINLOG);$(if $(filter debug 127,$(VERBOSE)),debug,0) - $(OVERRIDE_CONF)) - externaltool=obyparse:$($(IMAGE_TYPE)_PLUGINLOG);$(if $(filter debug 127,$(VERBOSE)),debug,0) - $(call iif,$(call select,$(IMAGE_TYPE),CORE,$(USE_ROFS1)), + /* Buildrom plugins + */ + externaltool=override:-i$1;-l$($1_PLUGINLOG)$(if $(filter debug 127,$(VERBOSE)),;-ddebug) + $(OVERRIDE_CONF) + externaltool=obyparse:-i$1;-l$($1_PLUGINLOG);-w$($1_DIR)$(if $(filter debug 127,$(VERBOSE)),;-ddebug);-f$(FEATURE_VARIANT) + externaltool=stubsischeck:-i$1;-l$($1_PLUGINLOG)$(if $(filter debug 127,$(VERBOSE)),;-ddebug) + $(call iif,$(if $(filter CORE,$1),$(USE_ROFS1)), $(call iif,$(USE_ROMFILE), OBYPARSE_ROM $(CORE_ROMFILE)) $(call iif,$(USE_ROFSFILE), OBYPARSE_ROFS1 $(CORE_ROFSFILE)) ) $(call iif,$(USE_UDEB), - OBYPARSE_UDEB $(call select,$(USE_UDEB),full,*,$($(IMAGE_TYPE)_UDEBFILE))) + OBYPARSE_UDEB $(call select,$(USE_UDEB),full,*,$($1_UDEBFILE))) endef getgenfiles = $(if $1,\ @@ -148,54 +151,60 @@ $(if $(__i_cmd),"$(call getelem,2,$1)")\ $(call getgenfiles,$(call restelems,$(if $(filter geniby%,$(__i_cmd)),7,$(if $(filter write%,$(__i_cmd)),4,2)),$1))) -# TEMPORARY -_buildoby = $(if $1,\ - $(eval __i_elem1 := $(call getelem,1,$1))\ - $(if $(filter geniby%,$(call lcase,$(__i_elem1))),$1,\ - geniby | $(__i_elem1) | $(call getelem,2,$1) | $(call getelem,3,$1) | \#include "%3" | end |\ - $(call _buildoby,$(call restelems,4,$1)))) -# TEMPORARY - #============================================================================== -BLDROM_CMD = $(BLDROM_TOOL) $(filter-out --D% -U%,$(BLR.$(IMAGE_TYPE).OPT)) $(BLR.$(IMAGE_TYPE).IDIR) $($(IMAGE_TYPE)_MSTOBY) +BLDROM_CMD = $(BLDROM_TOOL)\ + $(filter-out --D% -U% $(filter-out $(BLDROM_CMDDOPT),$(filter -D%,$(BLR.$1.OPT))),$(BLR.$1.OPT))\ + $(BLR.$1.IDIR) $(subst \,/,$($1_MSTOBY)) + +BLDROM_CMDDOPT = -DFEATUREVARIANT=% -D_FULL_DEBUG -D_PLAT=% CLEAN_BLDROM =\ - del | "$($(IMAGE_TYPE)_PREFIX).*" "$($(IMAGE_TYPE)_DIR)/tmp?.oby" "$($(IMAGE_TYPE)_DIR)/ecom*.s??" "$($(IMAGE_TYPE)_PLUGINLOG)" |\ - $(BLR.$(IMAGE_TYPE).CLEAN) + del | $(foreach file,dir *.img *.inc *.log *.oby *.symbol,"$($1_PREFIX).$(file)")\ + $(foreach file,ecom*.s?? features.dat loglinux.oby logwin.oby tmp?.oby,"$($1_DIR)/$(file)")\ + "$($1_PLUGINLOG)" |\ + $(BLR.$1.CLEAN) BUILD_BLDROM =\ - $(if $(BLR.$(IMAGE_TYPE).BUILD),$(BLR.$(IMAGE_TYPE).BUILD),\ - echo-q | Creating $($(IMAGE_TYPE)_TITLE) SOS image |\ - cd | $($(IMAGE_TYPE)_DIR) |\ - cmd | $(strip $(BLDROM_CMD)) | $(BLDROM_PARSE) |\ - copy | tmp1.oby | $($(IMAGE_TYPE)_PREFIX).tmp1.oby |\ - $(call iif,$(KEEPTEMP),,del | "tmp?.oby" "$($(IMAGE_TYPE)_PREFIX).dummy*" |)\ - $(BLR.$(IMAGE_TYPE).POST)) + $(or $(BLR.$1.BUILD),\ + echo-q | Creating $($1_TITLE) SOS $(if $(filter -noimage,$(BLR.$1.OPT)),oby,image) |\ + $(call iif,$(USE_BLRWORKDIR),,cd | "$($1_DIR)" |)\ + cmd | $(strip $(call BLDROM_CMD,$1)) | $(BLDROM_PARSE) |\ + move | "$($1_DIR)/tmp1.oby" | $($1_PREFIX).tmp1.oby |\ + $(call iif,$(KEEPTEMP),,del | "$($1_DIR)/tmp?.oby" "$($1_PREFIX).dummy*" |)\ + $(BLR.$1.POST)) -CLEAN_MAKSYMROFS = del | $($(IMAGE_TYPE)_SYM) -BUILD_MAKSYMROFS =\ - echo-q | Creating $($(IMAGE_TYPE)_TITLE) symbol file |\ - cmd | $(MAKSYMROFS_TOOL) $(call pathconv,$($(IMAGE_TYPE)_LOG) $($(IMAGE_TYPE)_SYM)) + +############################################################################### +# Steps + +IMAGE_STEPS = core $(VARIANT_STEPS) + +VARIANT_STEPS = $(call iif,$(USE_ROFS2),langpack_$(or $(TARGETID),01))\ + $(foreach rofs,3 4 5 6,$(call iif,$(USE_ROFS$(rofs)),rofs$(rofs))) ############################################################################### # Targets -.PHONY:\ - all flash flash-all image image-all\ - i2file +.PHONY: default all flash image variant #i2file variant-i2file + +default default-%:\ + ;@$(call IMAKER,$$(if $$(PRODUCT_NAME),,$$(TARGET_PRODUCT)) $$(TARGET_DEFAULT)) -all flash-all image-all: USE_SYMGEN = 1 -all flash flash-all : ;@$(call IMAKER,$$(ALL.IMAGE.STEPS)) +all : ;@$(call IMAKER,flash-all) +image: ;@$(call IMAKER,flash-image) + +flash flash-% image-%: ;@$(call IMAKER,$$(IMAGE_STEPS)) -image image-all: ;@$(call IMAKER,$$(SOS.IMAGE.STEPS)) +variant variant_% variant-%: ;@$(call IMAKER,$$(VARIANT_STEPS)) -i2file: ;@$(call IMAKER,$(call ucase,$@)) +#i2file : ;@$(call IMAKER,$(call ucase,$@)) +#variant-i2file: ;@$(call IMAKER,VARIANTI2F) #============================================================================== -include $(addprefix $(IMAKER_DIR)/imaker_,$(addsuffix .mk,core odp rofs2 rofs3 rofs4 uda variant)) +$(call includechk,$(addprefix $(IMAKER_DIR)/imaker_,fat.mk odp.mk rofs.mk smr.mk core.mk variant.mk)) # END OF IMAKER_IMAGE.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_memcard.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imaker/src/imaker_memcard.mk Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,39 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: iMaker Memory MMC/SD card image configuration +# + + + +############################################################################### +# __ __ ___ _ +# | \/ |___ _ __ / __|__ _ _ _ __| | +# | |\/| / -_) ' \ (__/ _` | '_/ _` | +# |_| |_\___|_|_|_\___\__,_|_| \__,_| +# + +MCARD_TITLE = MemCard + +MCARD_DRIVE = F +MCARD_FATTYPE = 32# FAT32 +MCARD_SIZE = 2097152# kB (= 2 GB) +MCARD_CLUSTERSIZE = 16# kB +MCARD_FATTABLE = 2 + +MCARD_SWVERFILE = #$(MCARD_DATADIR)/Resource/Versions/User Content Package_Mass_Memory.txt +MCARD_SWVERINFO = # Don't generate sw version file +MCARD_EXCLFILE = # Don't generate exclude list + + +# END OF IMAKER_MEMCARD.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_minienv.mk --- a/imgtools/imaker/src/imaker_minienv.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_minienv.mk Wed Jun 30 11:35:58 2010 +0800 @@ -23,58 +23,156 @@ # |_| |_|_|_||_|_|___|_||_\_/ # -MINIENV_ZIP = $(WORKPREFIX)_minienv.zip -MINIENV_EXCLBIN = *.axf *.bin *.cmt *.fpsx *.hex *.out *.pmd *.ppu *.zip -MINIENV_INCLBIN = *.axf *.bin *.fpsx *.hex *.out -MINIENV_SOSDIR = $(WORKDIR) +MINIENV_ZIP = $(EPOC_ROOT)/$(MINIENV_MFBSNAME)_$(MINIENV_MFBVER).jar +MINIENV_EXCLBIN = *.axf *.bin *.cmt *.fpsx *.hex *.out *.pmd *.ppu *.zip +MINIENV_INCLBIN = *.axf *.bin *.fpsx *.hex *.out +MINIENV_SOSDIR = $(OUTDIR) + +MINIENV_MFFILE = $(EPOC_ROOT)/META-INF/MANIFEST.MF +MINIENV_MFTMP = $(OUTTMPDIR)/META-INF/MANIFEST.MF + +MINIENV_MFBNAME = Minienv for $(PRODUCT_MODEL) +MINIENV_MFBSNAME = com.nokia.tools.griffin.minienv.$(PRODUCT_MODEL) +MINIENV_MFBVER = $(MAJOR_VERSION).$(MINOR_VERSION).0 +MINIENV_MFPATH = epoc32/tools +MINIENV_MFSWVER = $(word 1,$(subst ., ,$(MINIENV_MFBVER))).* +MINIENV_MFCFGFLT = (&(product_type=$(PRODUCT_TYPE))(sw_version=$(MINIENV_MFSWVER))) +#MINIENV_MFCFGFLT = (&(product_type=$(PRODUCT_TYPE))(sw_version=$(MAJOR_VERSION).$(MINOR_VERSION))) -CLEAN_MINIENV = del | $(MINIENV_ZIP) -BUILD_MINIENV =\ - echo-q | Creating minimal flash image creation environment $(MINIENV_ZIP) |\ - $(MINIENV_TOOL) | $(MINIENV_CONF) |\ - zip-q | $(MINIENV_ZIP) | __find__ | +define MINIENV_MFINFO + Manifest-Version: 1.0 + Bundle-ManifestVersion: 2.0 + Bundle-Name: $(MINIENV_MFBNAME) + Bundle-SymbolicName: $(MINIENV_MFBSNAME);singleton:=true + Bundle-Version: $(MINIENV_MFBVER) + Griffin-ExportDirectory: $(MINIENV_MFPATH) + Griffin-ConfigurationFilter: $(MINIENV_MFCFGFLT) + + Name: epoc32/tools/imaker.cmd + Require-Bundle: com.nokia.tools.griffin.theme +endef + +MINIENV_META = find-af | $(MINIENV_MFTMP) | $(MINIENV_MFFILE) | + +#============================================================================== MINIENV_IMAKER =\ - find | $(E32TOOLS) | imaker.cmd localise.pm localise_all_resources.pm obyparse.pm override.pm plugincommon.pm | |\ - find-a | $(IMAKER_DIR) | * | + find-a | $(E32TOOLS) | imaker imaker.cmd ||\ + find-a | $(IMAKER_DIR) | * ||\ + find-ar | $(CONFIGROOT)/assets/image | * | -MINIENV_TOOL =\ - $(MINIENV_IMAKER) |\ - find-a | $(ITOOL_DIR) | * | |\ +MINIENV_ITOOL =\ + find-a | $(ITOOL_DIR) | *.exe *.pl *.py imgcheck.* | *upct* + +MINIENV_BLDROM =\ find-a | $(E32TOOLS) |\ - cli.cmd s60ibymacros.pm\ - armutl.pm bpabiutl.pm buildrom.* checksource.pm configpaging.pm datadriveimage.pm e32plat.pm\ - e32variant.pm externaltools.pm featurevariantmap.pm featurevariantparser.pm genutl.pm maksym.*\ - maksymrofs.* modload.pm pathutl.pm rofsbuild.exe rombuild.exe spitool.* uidcrc.exe winutl.pm\ - *.bsf | gcc*.bsf |\ - find-a | $(E32TOOLS)/variant | * | |\ - find-ar | $(E32GCCBIN) | * | |\ - find-ar | $(CONFT_TOOLDIR) | * | + armutl.pm bpabiutl.pm buildrom.* checksource.pm configpaging.* datadriveimage.pm e32plat.pm e32variant.pm\ + externaltools.pm flexmodload.pm genutl.pm maksym.* maksymrofs.* modload.pm pathutl.pm rofsbuild.exe rombuild.exe\ + romosvariant.pm romutl.pm spitool.* uidcrc.exe winutl.pm feature* genericparser.pm rvct_*2set.pm writer.pm mingwm10.dll ||\ + find-ar | $(E32TOOLS)/build/lib/XML | * | + +MINIENV_CONE = find-a | $(E32TOOLS) | cone cone.cmd || find-ar | $(CONE_TOOLDIR) | * | + +MINIENV_CPP = find-a | $(E32GCCBIN) | cpp.exe cygwin1.dll | + +MINIENV_TOOL1 =\ + $(MINIENV_ITOOL) |\ + $(MINIENV_BLDROM) |\ + $(MINIENV_CONE) |\ + $(MINIENV_CPP) |\ + find-a | $(E32TOOLS) |\ + featuredatabase.dtd s60ibymacros.pm\ + bmconv.exe dumpsis.exe elf2e32.exe interpretsis.exe mifconv.exe petran.exe svgtbinencode.exe\ + xerces-c_2_*.dll ||\ + find-a | $(E32TOOLS)/variant | * || + +MINIENV_TOOL2 =\ + find-ar | $(dir $(WIDGET_TOOL)) $(WIDGET_HSTOOLDIR) | * ||\ + find-a | $(E32DATAZ)/private/10282f06 $(EPOC32)/winscw/c/private/10282f06 | Widget_lproj.xml || + +MINIENV_TOOL = $(foreach tool,$(sort $(filter $(addprefix MINIENV_TOOL,0 1 2 3 4 5 6 7 8 9),$(.VARIABLES))),$($(tool)) |) -MINIENV_CONF =\ - find-a | $(E32INC) | *.hrh | |\ - find-ar | $(E32INCCFG) | * | |\ - find-ar | $(E32INC)/oem | * | |\ - find-ar | $(E32INC)/variant | * | |\ - find-a | $(E32ROM) | * | |\ - find-ar | $(E32ROMCFG) | * | $(MINIENV_EXCLBIN) |\ - find-ar | $(E32ROM)/configpaging | * | |\ - find-ar | $(E32ROMINC) | * | |\ - find-ar | $(E32ROM)/variant | * | |\ - find-ar | $(OST_DICTDIR) | $(OST_DICTPAT) | |\ - find-ar | $(EPOC32)/data/Z/resource/plugins | * | |\ - find-a | $(COREPLAT_DIR) | $(MINIENV_INCLBIN) | |\ - find-ar | $(PRODUCT_DIR) | $(MINIENV_INCLBIN) | |\ - sosfind-a | $(MINIENV_SOSDIR) | *.tmp1.oby | *.rom.oby *.rofs?.oby | *_bldromplugin.log +MINIENV_CONF1 =\ + find-a | $(E32INC) | *.hrh ||\ + find-ar | $(E32INCCFG) | * ||\ + find-ar | $(E32ROM)/configpaging | * ||\ + find-a | $(sort $(dir $(CORE_FEAXML))) | $(notdir $(CORE_FEAXML)) ||\ + find-a | $(CONFIGROOT) | *.mk ||\ + find-a | $(PLATFORM_DIR) | *.mk mem*.hrh ||\ + find-ar | $(PRODUCT_DIR) | *.mk mem*.hrh ||\ + find-a | $(E32INC)/mw | ThirdPartyBitmap.pal ||\ + find-a | $(E32ROMINC)/customervariant/mw | Certificates_Operator.iby ||\ + find-a | $(E32DATAZ)/private/101f72a6 | * ||\ + find-a | $(E32DATAZ)/private/10202be9 | cccccc00_empty.cre ||\ + find-a | $(E32DATAZ)/private/200009F3 | defaultimportfile.mde ||\ + find-a | $(E32DATAZ)/private/20019119 | config.xml ||\ + find-a | $(E32DATAZ)/resource | swicertstore*.dat ||\ + find-a | $(E32DATAZ)/system/data | SkinExclusions.ini ||\ + find-ar | $(E32DATAZ)/system/data/midp2/security/trustroots | * ||\ + find-a | $(E32DATAZ)/system/sounds/audiothemes | at_nokia.xml ||\ + find-a | $(EPOC32)/release/armv5/urel | R1_Mobile_4_0_Operator.cfg ||\ + find-a | $(EPOC32)/release/armv5/urel/z/private/100059C9 | ScriptInit.txt ||\ + find-a | $(EPOC_ROOT)/ext/app/firsttimeuse/StartupSettings3/tools | APConf.txt ||\ + find-af | $(SISINST_HALHDA) |||\ + find-ar | $(CONFIGROOT) | * | *.pmd isa.out dsp.hex *.cmt fota_updapp.bin *.axf DCT_ISA*.zip | + +MINIENV_CONF2 =\ + sosfind-a | $(MINIENV_SOSDIR) | *.rom.oby *.rofs?.oby *.uda.oby *.emmc.oby *.mcard.oby | *_bldromplugin.log + +MINIENV_CONF3 =\ + find-ar | $(OST_DICTDIR) | $(OST_DICTPAT) ||\ + find-a | $(COREPLAT_DIR) | $(MINIENV_INCLBIN) ||\ + find-ar | $(PRODUCT_DIR) | $(MINIENV_INCLBIN) || + +# find-a | $(CONFIGROOT) | *.confml ||\ +# find-ar | $(CONFIGROOT)/assets | * ||\ +# find-a | $(PLATFORM_DIR) | *.confml ||\ +# find-ar | $(PRODUCT_DIR) | *.confml ||\ + +MINIENV_CONF = $(foreach conf,$(sort $(filter $(addprefix MINIENV_CONF,0 1 2 3 4 5 6 7 8 9),$(.VARIABLES))),$($(conf)) |) + +#============================================================================== + +CLEAN_MINIENV = $(if $(MINIENV_META),$(CLEAN_MINIENVMETA) |) del | "$(MINIENV_ZIP)" +BUILD_MINIENV =\ + $(if $(MINIENV_META),$(BUILD_MINIENVMETA) |)\ + echo-q | Creating minimal flash image creation environment |\ + find ||||\ + $(MINIENV_META) |\ + $(MINIENV_IMAKER) |\ + $(MINIENV_TOOL) |\ + $(MINIENV_CONF) |\ + zip$(if $(filter debug 127,$(VERBOSE)),,-q) | "$(MINIENV_ZIP)" | __find__ | + +REPORT_MINIENV =\ + Minienv input SOS dir | $(MINIENV_SOSDIR) | d |\ + Minienv archive | $(MINIENV_ZIP) | f + +CLEAN_MINIENVMETA = del | "$(MINIENV_MFTMP)" +BUILD_MINIENVMETA =\ + echo-q | Creating manifest file |\ + write | "$(MINIENV_MFTMP)" | $(call def2str,$(MINIENV_MFINFO))\n ############################################################################### # Targets -.PHONY:\ - minienv +.PHONY: minienv minienv-conf minienv-imaker minienv-tool core-minienv + +minienv-conf: MINIENV_IMAKER = +minienv-conf: MINIENV_TOOL = + +minienv-imaker: MINIENV_TOOL = +minienv-imaker: minienv-tool ; -minienv: ;@$(call IMAKER,$(call ucase,$@)) +minienv-itool: MINIENV_TOOL = $(MINIENV_ITOOL) +minienv-itool: minienv-tool ; + +minienv-tool: MINIENV_META = +minienv-tool: MINIENV_CONF = + +minienv: MINIENV_CONF3 = +minienv minienv-conf minienv-tool core-minienv: ;@$(call IMAKER,MINIENV) # END OF IMAKER_MINIENV.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_odp.mk --- a/imgtools/imaker/src/imaker_odp.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_odp.mk Wed Jun 30 11:35:58 2010 +0800 @@ -18,46 +18,71 @@ USE_PAGING = 0 -USE_PAGEDROM = $(if $(filter rom code code:%,$(call lcase,$(USE_PAGING))),1,0) +USE_PAGEDROM = $(if $(or $(call true,$(USE_PAGEDCODE)$(USE_PAGEDDATA)),$(filter rom,$(call lcase,$(USE_PAGING)))),1,0) USE_PAGEDCODE = $(call _getcodedp) +USE_PAGEDDATA = $(if $(filter data,$(call lcase,$(USE_PAGING))),1,0) ODP_CONFDIR = $(E32ROM)/configpaging -ODP_PAGEFILE = configpaging.cfg +ODP_PAGEFILE = $(call iif,$(USE_PAGEDDATA),configpaging_wdp.cfg,configpaging.cfg) ODP_CODECOMP = bytepair -# Min Max Young/Old NAND page read NAND page read -# live live page ratio delay CPU overhead -# pages pages (microseconds) (microseconds) -ODP_ROMCONF = 1024 2048 3 0 0 +ODP_ROMCONF =\ + $(or $(SYMBIAN_ODP_NUMBER_OF_MIN_LIVE_PAGES),1024)\ + $(or $(SYMBIAN_ODP_NUMBER_OF_MAX_LIVE_PAGES),2048)\ + $(or $(SYMBIAN_ODP_YOUNG_OLD_PAGE_RATIO),3)\ + $(or $(SYMBIAN_ODP_NAND_PAGE_READ_DELAY),0)\ + $(or $(SYMBIAN_ODP_NAND_PAGE_NAND_PAGE_READ_CPU_OVERHEAD),0) -# Section for Rombuild phase on all Demand Paging builds +# Section for Rombuild on all Demand Paging builds # define ODP_ROMINFO + $(call iif,$(USE_PAGEDDATA), + #if defined(FF_WDP_EMMC) && defined(FF_WDP_NAND) + #error ERROR: Both of the flags FF_WDP_EMMC and FF_WDP_NAND are defined! + #elif !defined(FF_WDP_EMMC) && !defined(FF_WDP_NAND) + #error ERROR: One of the flags FF_WDP_EMMC or FF_WDP_NAND should be defined! + #endif + , + #undef FF_WDP_EMMC + #undef FF_WDP_NAND + ) $(call iif,$(USE_PAGEDROM), #define PAGED_ROM ROMBUILD_OPTION -geninc - demandpagingconfig $(strip $(ODP_ROMCONF)) - pagingoverride defaultpaged pagedrom compress + demandpagingconfig $(strip $(ODP_ROMCONF)) + codepagingoverride defaultpaged + $(call iif,$(USE_PAGEDDATA), + datapagingoverride defaultunpaged + , + datapagingoverride nopaging) ) $(if $(filter 1,$(USE_PAGEDCODE)), #define PAGED_CODE - pagingpolicy defaultpaged + codepagingpolicy defaultpaged + $(call iif,$(USE_PAGEDDATA), + datapagingpolicy defaultunpaged + , + datapagingpolicy nopaging) ) $(if $(CORE_PAGEFILE),$(call iif,$(USE_PAGEDROM)$(filter 1,$(USE_PAGEDCODE)), - externaltool=configpaging:$(CORE_PAGEFILE)) - ) + externaltool=configpaging:$(CORE_PAGEFILE))) endef -# Section for Rofsbuild phase on Code DP enabled builds +# Section for Rofsbuild on Code/Data DP enabled builds # -define ODP_CODEINFO - $(if $(filter $1,$(USE_PAGEDCODE)), +define ODP_ROFSINFO + $(if $(filter $(IMAGE_ID),$(USE_PAGEDCODE)), #define PAGED_CODE - $(if $(ROFS$1_PAGEFILE), - externaltool=configpaging:$(ROFS$1_PAGEFILE)) - pagingoverride defaultpaged + codepagingoverride defaultpaged + $(call iif,$(USE_PAGEDDATA), + datapagingoverride defaultunpaged + , + datapagingoverride nopaging + ) + $(if $(ROFS$(IMAGE_ID)_PAGEFILE), + externaltool=configpaging:$(ROFS$(IMAGE_ID)_PAGEFILE)) ) endef @@ -66,10 +91,11 @@ # Internal stuff _getcodedp = $(or $(strip\ - $(if $(filter code code:,$(eval __i_paging := $(call lcase,$(call sstrip,$(USE_PAGING))))$(__i_paging)),\ - $(foreach rofs,1 2 3 4 5 6,$(call iif,$(USE_ROFS$(rofs)),$(rofs))),\ - $(if $(filter code:%,$(__i_paging)),\ - $(foreach rofs,1 2 3 4 5 6,$(findstring $(rofs),$(__i_paging)))))),0) + $(eval __i_paging := $(call lcase,$(USE_PAGING)))\ + $(foreach rofs,$(if $(filter code:%,$(__i_paging)),\ + $(foreach rofs,1 2 3 4 5 6,$(findstring $(rofs),$(__i_paging))),\ + $(if $(or $(call true,$(USE_PAGEDDATA)),$(filter code,$(__i_paging))),1 2 3 4 5 6)),\ + $(call iif,$(USE_ROFS$(rofs)),$(rofs)))),0) # END OF IMAKER_ODP.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_public.mk --- a/imgtools/imaker/src/imaker_public.mk Wed Jun 23 17:27:59 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of the License "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: iMaker public interface -# - - - -#============================================================================== -# Product variant variables - -FEATVARIANT_CONFML = $(wildcard $(PRODUCT_DIR)/$(FEATURE_VARIANT).confml) - -PRODVARIANT_DIR = $(PRODUCT_DIR) -PRODVARIANT_CONFML = $(or $(FEATVARIANT_CONFML),$(PRODUCT_DIR)/$(PRODUCT_NAME).confml) -PRODVARIANT_CONFCP =\ - $(PLATFORM_NAME) $(PRODUCT_MSTNAME) $(PRODUCT_NAME)\ - $(if $(FEATVARIANT_CONFML),$(call select,$(PRODUCT_NAME),$(FEATURE_VARIANT),,$(FEATURE_VARIANT))) - -#============================================================================== -# Customer variant variables -# Root for customer variant (custvariant) package settings - -CUSTVARIANT_ROOT = $(PRODUCT_DIR)/customer -CUSTVARIANT_PREFIX = custvariant_ -CUSTVARIANT_NAME = -CUSTVARIANT_ID = -CUSTVARIANT_DIR = $(CUSTVARIANT_ROOT)/$(CUSTVARIANT_NAME) -CUSTVARIANT_COMPLP = - -#============================================================================== -# The Target specific override settings - -$(CUSTVARIANT_PREFIX)%: CUSTVARIANT_NAME = $(TARGETNAME) -$(CUSTVARIANT_PREFIX)%: CUSTVARIANT_ID = $(TARGETID) -$(CUSTVARIANT_PREFIX)%: VARIANT_DIR = $(CUSTVARIANT_DIR) -$(CUSTVARIANT_PREFIX)%: variantrofs3_$(TARGETID)$(TARGETEXT) ; - -#============================================================================== -# Helps - -$(call add_help,PRODVARIANT_DIR,v,(string),Overrides the VARIANT_DIR for product variant, see the instructions of VARIANT_CONFCP for details.) -$(call add_help,PRODVARIANT_CONFML,v,(string),Overrides the VARIANT_CONFML for product variant, see the instructions of VARIANT_CONFML for details.) -$(call add_help,PRODVARIANT_CONFCP,v,(string),Overrides the VARIANT_CONFCP for product variant, see the instructions of VARIANT_CONFCP for details.) -$(call add_help,CUSTVARIANT_DIR,v,(string),Overrides the VARIANT_DIR for customer variant, see the instructions of VARIANT_CONFCP for details.) -$(call add_help,CUSTVARIANT_COMPLP,v,(string),Compatible language variant.) diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_rofs.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imaker/src/imaker_rofs.mk Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,261 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: iMaker generic ROFS image configuration +# + + + +############################################################################### +# ___ ___ ___ ___ +# | _ \/ _ \| __/ __| +# | / (_) | _|\__ \ +# |_|_\\___/|_| |___/ +# + +ROFS_MAXSIZE = 0x10000000 + +define ROFS_EVAL +USE_$1 = $$(call userofs,$3) + +$1_TITLE = $1 +$1_DRIVE = Z +$1_ROOT = $$(OUTDIR)/$2 +$1_DIR = $$($1_ROOT) +$1_NAME = $$(NAME) +$1_PREFIX = $$($1_DIR)/$$($1_NAME) +$1_IDIR = +$1_HBY = +$1_OBY = +$1_OPT = +$1_MAXSIZE = $$(ROFS_MAXSIZE) +$1_MSTOBY = $$($1_PREFIX)_$2_master.oby +$1_HEADER = +$1_INLINE = +$1_FOOTER = +$1_TIME = $$(DAY)/$$(MONTH)/$$(YEAR) + +$1_DEFHRH = $$($1_PREFIX)_$2_define.hrh +$1_FEAXML = +$1_FEAIBY = + +$1_ROMVER = $$(CORE_ROMVER) +$1_ID = $$(if $$(filter $2_%,$$(TARGETNAME)),$$(TARGETID1),00) +$1_REVISION = 01 +$1_VERSION = $$(CORE_VERSION).$$($1_ID).$$($1_REVISION) +$1_SWVERFILE = $$($1_PREFIX)_$2_sw.txt +$1_SWVERTGT = $$(IMAGE_VERSDIR)\$2sw.txt +$1_SWVERINFO = $$($1_VERSION)\n$$(BUILD_YEAR)-$$(BUILD_MONTH)-$$(BUILD_DAY) +$1_FWIDFILE = $$($1_PREFIX)_$2_fwid.txt +$1_FWID = $2 +$1_FWIDVER = $$($1_VERSION)$$(SW_TYPEINFO) +$1_FWIDINFO = id=$$($1_FWID)\nversion=$$($1_FWIDVER)\n + +$1_IMG = $$($1_PREFIX).$2.img +$1_LOG = $$($1_PREFIX).$2.log +$1_OUTOBY = $$($1_PREFIX).$2.oby +$1_SYM = $$($1_PREFIX).$2.symbol + +$1_PLUGINLOG = $$($1_PREFIX)_$2_bldromplugin.log +$1_PAGEFILE = $$(ODP_PAGEFILE) +$1_UDEBFILE = $$(TRACE_UDEBFILE) + +$1_OBYGEN = +$1_ORIDEIBY = $$($1_PREFIX)_$2_override.iby +$1_ORIDEFILES = $$(IMAGE_ORIDEFILES) +$1_ORIDECONF = $$(IMAGE_ORIDECONF) + +$1_ICHKLOG = $$($1_PREFIX)_$2_imgcheck.log +$1_ICHKOPT = $$(IMGCHK_OPT) +$1_ICHKIMG = $$($1_IMG) + +$1_I2FDIR = $$($1_DIR)/img2file + +$1_CONECONF = $$(PRODUCT_NAME)_$2_$$($1_ID)$$(addprefix _,$$($1_VARNAME))_root.confml +$1_CONEOPT = --all-layers --impl-tag=target:$2 + +$1_VARNAME = $$(if $$(filter $2_%,$$(TARGETNAME)),$$(TARGETID2-)) +$1_VARROOT = $$(or $$(wildcard $$(PRODUCT_DIR)/$2),$$(or $$(if $$(PRODUCT_MSTNAME),$$(wildcard $$(PRODUCT_MSTDIR)/$2)),$$(PRODUCT_DIR)/$2)) +$1_VARDIR = $$(if $$(and $$(call true,$$(USE_CONE)),$$(call true,$$(IMAKER_MKRESTARTS))),$$(CONE_OUTDIR),$$($1_VARROOT)/$2_$$($1_ID)$$(addprefix _,$$($1_VARNAME))$$(call iif,$$(USE_CONE),/content)) + +#============================================================================== + +define $1_MSTOBYINFO + $$(call BLDROM_HDRINFO,$1) + + ROM_IMAGE 0 non-xip size=0x00000000 + $$(foreach rofs,1 2 3 4 5 6, + ROM_IMAGE $$(rofs) $$(if $$(filter $$(rofs),$3), rofs,dummy)$$(rofs) non-xip size=$$($1_MAXSIZE)) + + $$(call BLDROM_PLUGINFO,$1) + + /* $1 header + */ + $$($1_HDRINFO) + + ROM_IMAGE[$3] { + $$(ODP_ROFSINFO) + #ifndef _IMAGE_INCLUDE_HEADER_ONLY + $$(BLR.$1.OBY) + $$($1_INLINE) + $$($1_FOOTERINFO) + } + #endif // _IMAGE_INCLUDE_HEADER_ONLY +endef + +define $1_HDRINFO + $$(DEFINE) _IMAGE_WORKDIR $$($1_DIR) + $$(call mac2cppdef,$$(BLR.$1.OPT)) + $$(BLR.$1.HBY) + $$($1_HEADER) + $$(if $$(filter $3,$$(USE_VARIANTBLD)),$$(VARIANT_HEADER)) +endef + +define $1_FOOTERINFO + $$(if $$($1_TIME),time=$$($1_TIME)) + $$(if $$($1_ROMVER),version=$$($1_ROMVER)) + $$($1_FOOTER) +endef + +define $1_ORIDEINFO + // Generated `$$($1_ORIDEIBY)' for $$($1_TITLE) image creation + + $$(if $$($1_SWVERINFO)$$($1_FWIDINFO), + OVERRIDE_REPLACE/ADD + $$(if $$($1_SWVERINFO), + data-override="$$($1_SWVERFILE)" "$$($1_SWVERTGT)") + $$(if $$($1_FWIDINFO), + data-override="$$($1_FWIDFILE)" "$$(IMAGE_VERSDIR)\fwid$3.txt") + OVERRIDE_END + ) +endef + +#============================================================================== +# ROFS pre-build + +CLEAN_$1PRE =\ + $$(if $$(filter $3,$$(USE_VARIANTBLD)),$$(CLEAN_VARIANT) |)\ + $$(CLEAN_$1FILE) | $$(CLEAN_DEFHRH) | $$(CLEAN_FEATMAN) + +BUILD_$1PRE =\ + $$(if $$(filter $3,$$(USE_VARIANTBLD)),$$(BUILD_VARIANT) |)\ + mkdir | "$$($1_DIR)" |\ + $$(BUILD_$1FILE) |\ + $$(BUILD_DEFHRH) |\ + $$(BUILD_FEATMAN) + +CLEAN_$1FILE =\ + del | "$$($1_MSTOBY)" "$$($1_ORIDEIBY)" "$$($1_SWVERFILE)" "$$($1_FWIDFILE)" |\ + del | $$(call getgenfiles,$$($1_OBYGEN)) + +BUILD_$1FILE =\ + echo-q | Generating file(s) for $$($1_TITLE) image creation |\ + write-c | "$$($1_MSTOBY)" | $$(call def2str,$$($1_MSTOBYINFO))\n |\ + $$(if $$($1_SWVERINFO),\ + writeu | "$$($1_SWVERFILE)" | $$(call quote,$$($1_SWVERINFO)) |)\ + $$(if $$($1_FWIDINFO),\ + writeu | "$$($1_FWIDFILE)" | $$($1_FWIDINFO) |)\ + $$(if $$($1_ORIDEINFO),\ + write-c | "$$($1_ORIDEIBY)" | $$(call def2str,$$($1_ORIDEINFO)) |)\ + $$(if $$($1_ORIDECONF),\ + genorideiby | >>$$($1_ORIDEIBY) | $$(call def2str,$$($1_ORIDEFILES) | $$($1_ORIDECONF)) |)\ + $$($1_OBYGEN) + +#============================================================================== +# ROFS build + +$1_DUMMY = $$(call rofsdummy,$1) + +BLR.$1.BUILD = $$(if $$(filter d%,$$(USE_$1)),echo-q | Creating dummy $$($1_TITLE) SOS image | write-q | "$$($1_IMG)" | $$($1_DUMMY)) +BLR.$1.IDIR = $$(call dir2inc,$$($1_IDIR) $$(call iif,$$(USE_FEATVAR),,$$(FEATVAR_IDIR))) +BLR.$1.HBY = $$(call includeiby,$$(IMAGE_HBY) $$($1_HBY)) +BLR.$1.OBY = $$(call includeiby,$$($1_OBY))\ + $$(and $$(call true,$$(SYMBIAN_FEATURE_MANAGER)),$$($1_FEAIBY),$$(call mac2cppdef,-U__FEATURE_IBY__)$$(call includeiby,$$($1_FEAIBY)))\ + $$(call includeiby,$$(if $$(filter $3,$$(USE_VARIANTBLD)),$$(VARIANT_OBY)) $$($1_ORIDEIBY)) +BLR.$1.OPT = $$($1_OPT) $$(if $$(filter $3,$$(USE_PAGEDCODE)),$$(if $$(ODP_CODECOMP),-c$$(ODP_CODECOMP))) -o$$(call pathconv,$$($1_PREFIX)).img $$(BLDROPT) +BLR.$1.POST = $$(call iif,$$(KEEPTEMP),,del | "$$($1_PREFIX).???") + +CLEAN_$1 = $$(call CLEAN_BLDROM,$1) +BUILD_$1 = $$(call BUILD_BLDROM,$1) + +REPORT_$1 =\ + $$($1_TITLE) dir | $$($1_DIR) | d |\ + $$($1_TITLE) image | $$($1_IMG) | f\ + $$(call iif,$$(USE_SYMGEN),| $$(REPORT_MAKSYMROFS)) + +#============================================================================== +# ROFS post-build + +CLEAN_$1POST = $$(CLEAN_IMGCHK) +BUILD_$1POST = $$(call iif,$$(USE_IMGCHK),$$(BUILD_IMGCHK)) +REPORT_$1POST = + +#============================================================================== +# ROFS steps + +SOS.$1.STEPS = $$(call iif,$$(USE_$1),\ + $$(call iif,$$(SKIPPRE),,$$(and $$(filter $3,$$(USE_VARIANTBLD)),$$(call true,$$(USE_CONE)),CONEGEN RESTART) $1PRE)\ + $$(call iif,$$(SKIPBLD),,$1) $$(call iif,$$(SKIPPOST),,$1POST)) + +ALL.$1.STEPS = $$(SOS.$1.STEPS) + +#============================================================================== +# Targets + +.PHONY: $2 $(addprefix $2-,all check cone i2file image pre symbol) variant$2 + +$2 $2%: IMAGE_TYPE = $1 +$2-all: USE_SYMGEN = 1 + +$2 $2-all: ;@$$(call IMAKER,$$$$(ALL.$1.STEPS)) +$2-image : ;@$$(call IMAKER,$$$$(SOS.$1.STEPS)) + +$2-cone : ;@$$(call IMAKER,CONEGEN) +$2-pre : ;@$$(call IMAKER,$1PRE) +$2-check : ;@$$(call IMAKER,IMGCHK) +$2-symbol: ;@$$(call IMAKER,MAKSYMROFS) +$2-i2file: ;@$$(call IMAKER,I2FILE) + +variant$2 variant$2% : USE_CONE = 0 +variant$2 variant$2% $2_%: USE_VARIANTBLD = $3 +variant$2 variant$2% $2_%: $2$$(TARGETEXT) ; + +#============================================================================== +# Helps + +$(call add_help,$2,t,Create $$($1_TITLE) image.) +$(call add_help,$2-dir,t,Create directory structure for $$($1_TITLE) creation.) +$(call add_help,$2-i2file,t,Extract all files from $$($1_TITLE) image.) +$(call add_help,$2-image,t,Create $$($1_TITLE) image (.img) file.) +$(call add_help,$2-pre,t,Run pre-step, create files etc. for $$($1_TITLE) creation.) +$(call add_help,$2-symbol,t,Create $$($1_TITLE) symbol file.) +$(call add_help,variant$2,t,Create $$($1_TITLE) image from a variant directory. Be sure to define the VARIANT_DIR.) + +endef # ROFS_EVAL + + +############################################################################### +# + +userofs = $(eval __i_rofs := $(filter-out :%,$(subst :, :,$(subst $(,), ,$(USE_ROFS)))))$(if\ + $(filter $1,$(__i_rofs)),1,$(if $(filter d$1 D$1,$(__i_rofs)),dummy,0)) + +rofsdummy = $(if $(filter d%,$(USE_$1)),$(call prepeat,\ + $(call peval,$(call pquote,$(USE_ROFS)) =~ /d$1:(\d*)/i && $$1 || 100),X)) + +$(foreach rofs,1 2 3 4 5 6,$(eval $(call ROFS_EVAL,ROFS$(rofs),rofs$(rofs),$(rofs)))) + +$(call includechk,$(addprefix $(IMAKER_DIR)/imaker_rofs,2.mk 3.mk 4.mk)) + + +# END OF IMAKER_ROFS.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_rofs2.mk --- a/imgtools/imaker/src/imaker_rofs2.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_rofs2.mk Wed Jun 30 11:35:58 2010 +0800 @@ -23,145 +23,74 @@ # |_|_\\___/|_| |___/ /___| # -USE_NEWLOCLZTN = $(if $(filter 5%,$(S60_VERSION)),1,0) - -ROFS2_TITLE = ROFS2 -ROFS2_DIR = $(WORKDIR)/rofs2 -ROFS2_NAME = $(NAME) -ROFS2_PREFIX = $(ROFS2_DIR)/$(ROFS2_NAME) -ROFS2_IDIR = -ROFS2_HBY = -ROFS2_OBY = -ROFS2_OPT = -ROFS2_MSTOBY = $(ROFS2_PREFIX)_rofs2_master.oby -ROFS2_HEADER = -ROFS2_INLINE = -ROFS2_FOOTER = -ROFS2_TIME = $(DAY)/$(MONTH)/$(YEAR) - -ROFS2_OBYGEN = - -ROFS2_VERIBY = $(ROFS2_PREFIX)_rofs2_version.iby -ROFS2_ROMVER = 0.01(0) -ROFS2_VERSION = $(CORE_VERSION) -ROFS2_FWIDFILE = $(ROFS2_PREFIX)_rofs2_fwid.txt -ROFS2_FWID = language -ROFS2_FWIDVER = $(LANGPACK_ID) -ROFS2_FWIDINFO = id=$(ROFS2_FWID)\nversion=$(ROFS2_FWIDVER)\n - -ROFS2_IMG = $(ROFS2_PREFIX).rofs2.img -ROFS2_LOG = $(ROFS2_PREFIX).rofs2.log -ROFS2_OUTOBY = $(ROFS2_PREFIX).rofs2.oby -ROFS2_SYM = $(ROFS2_PREFIX).rofs2.symbol +ROFS2_FEAXML = $(E32ROMINC)/featuredatabase.xml $(E32INC)/s60features.xml +ROFS2_FEAIBY = $(ROFS2_DIR)/feature.iby $(ROFS2_DIR)/s60features.iby -ROFS2_PLUGINLOG = $(ROFS2_PREFIX)_rofs2_bldromplugin.log -ROFS2_PAGEFILE = $(ODP_PAGEFILE) -ROFS2_UDEBFILE = $(TRACE_UDEBFILE) - -ROFS2_ICHKLOG = $(ROFS2_PREFIX)_rofs2_imgcheck.log -ROFS2_ICHKOPT = $(IMGCHK_OPT) -ROFS2_ICHKIMG = $(ROFS2_IMG) $(CORE_ICHKIMG) - -ROFS2_I2FDIR = $(ROFS2_DIR)/img2file - -#============================================================================== - -define ROFS2_MSTOBYINFO - $(BLDROM_HDRINFO) +ROFS2_ID = $(LANGPACK_ID) +ROFS2_REVISION = $(LANGPACK_REVISION) +ROFS2_SWVERINFO = $(ROFS2_VERSION)\n$(BUILD_YEAR)-$(BUILD_MONTH)-$(BUILD_DAY)\n$(PRODUCT_TYPE)\n(c) $(PRODUCT_MANUFACT) +ROFS2_SWVERTGT = $(IMAGE_VERSDIR)\langsw.txt +ROFS2_FWID = language - ROM_IMAGE 0 non-xip size=0x00000000 - ROM_IMAGE 1 dummy1 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 2 rofs2 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 3 dummy3 non-xip size=$(ROFS_MAXSIZE) +ROFS2_ICHKIMG += $(CORE_ICHKIMG) - $(BLDROM_PLUGINFO) +ROFS2_CONECONF = $(PRODUCT_NAME)_langpack_$(LANGPACK_ID)_root.confml - // ROFS2 header - // - $(ROFS2_HDRINFO) - ROM_IMAGE[2] { - $(call ODP_CODEINFO,2) - $(BLR.ROFS2.OBY) - $(ROFS2_INLINE) - $(ROFS2_FOOTERINFO) - } -endef +############################################################################### +# ROFS2 pre define ROFS2_HDRINFO $(DEFINE) _IMAGE_WORKDIR $(ROFS2_DIR) $(call mac2cppdef,$(BLR.ROFS2.OPT)) - $(call iif,$(USE_NEWLOCLZTN), - $(foreach lang,$(call getlangbyid,$(LANGPACK_LANGS)), - #define __LOCALES_$(lang)_IBY__) - $(foreach lang,$(call getlangbyid,$(LANGPACK_LANGS)), - ADD_LANGUAGE $(lang)) - ) + $(foreach lang,$(call getlangbyid,$(LANGPACK_LANGS)), + #define __LOCALES_$(lang)_IBY__) + $(foreach lang,$(call getlangbyid,$(LANGPACK_LANGS)), + LANGUAGE_CODE $(lang)) + $(call iif,$(USE_QTLOCLZTN),QT_TO_SYMBIAN_LANGID $(LANGPACK_SYSLANGINI)) $(BLR.ROFS2.HBY) $(ROFS2_HEADER) $(if $(filter 2,$(USE_VARIANTBLD)),$(VARIANT_HEADER)) endef -define ROFS2_FOOTERINFO - $(if $(ROFS2_TIME),time=$(ROFS2_TIME)) - $(ROFS2_FOOTER) -endef - -define ROFS2_VERIBYINFO - // Generated `$(ROFS2_VERIBY)$' for ROFS2 image creation - $(if $(ROFS2_ROMVER), +ROFS2_ORIDEINFO += $(LANGPACK_ORIDEINFO) - version=$(ROFS2_ROMVER)) - +define LANGPACK_ORIDEINFO OVERRIDE_REPLACE/ADD - $(call iif,$(USE_NEWLOCLZTN), - data-override=$(LANGPACK_LANGFILE) RESOURCE_FILES_DIR\Bootdata\languages.txt - data-override=$(LANGPACK_IDFILE) RESOURCE_FILES_DIR\versions\lang.txt - data-override=$(LANGPACK_SWVERFILE) RESOURCE_FILES_DIR\versions\langsw.txt - ) - $(call iif,$(USE_FOTA), - data-override=$(ROFS2_FWIDFILE) RESOURCE_FILES_DIR\versions\fwid2.txt) + data-override="$(LANGPACK_LANGFILE)" "RESOURCE_FILES_DIR\Bootdata\languages.txt" + data-override="$(LANGPACK_IDFILE)" "$(IMAGE_VERSDIR)\lang.txt" OVERRIDE_END endef #============================================================================== -CLEAN_ROFS2FILE =\ - del | "$(ROFS2_MSTOBY)" "$(ROFS2_VERIBY)" "$(ROFS2_FWIDFILE)" |\ - $(CLEAN_LANGFILE) |\ - del | $(call getgenfiles,$(call _buildoby,$(ROFS2_OBYGEN))) - -BUILD_ROFS2FILE =\ - echo-q | Generating file(s) for ROFS2 image creation |\ - write | $(ROFS2_MSTOBY) | $(call def2str,$(ROFS2_MSTOBYINFO)) |\ - $(call iif,$(USE_VERGEN),\ - write | $(ROFS2_VERIBY) | $(call def2str,$(ROFS2_VERIBYINFO)) |\ - writeu | $(ROFS2_FWIDFILE) | $(ROFS2_FWIDINFO) |)\ - $(call iif,$(USE_NEWLOCLZTN),$(BUILD_LANGFILE)) |\ - $(call _buildoby,$(ROFS2_OBYGEN)) +CLEAN_ROFS2FILE += | $(CLEAN_LANGFILE) +BUILD_ROFS2FILE += | $(BUILD_LANGFILE) ############################################################################### -# +# Language package -LANGPACK_SYSLANGMK = system_languages.mk +LANGPACK_SYSLANGMK = $(call findfile,system_languages.mk,,1) +LANGPACK_SYSLANGINI = $(E32DATAZ)/resource/system_languages.ini -LANGPACK_ROOT = $(PRODUCT_DIR)/language +LANGPACK_ROOT = $(or $(wildcard $(PRODUCT_DIR)/language),$(or $(if $(PRODUCT_MSTNAME),$(wildcard $(PRODUCT_MSTDIR)/language)),$(PRODUCT_DIR)/language)) LANGPACK_PREFIX = langpack_ LANGPACK_MKNAME = language_variant.mk -LANGPACK_NAME = -LANGPACK_DIR = $(LANGPACK_ROOT)/$(LANGPACK_NAME) -LANGPACK_CONFML = $(or $(wildcard $(LANGPACK_DIR)/$(CONFT_CFGNAME).confml),$(PRODVARIANT_CONFML)) -LANGPACK_CONFCP = $(PRODVARIANT_CONFCP) $(if $(wildcard $(LANGPACK_DIR)/$(CONFT_CFGNAME).confml),$(CONFT_CFGNAME)) +LANGPACK_NAME = $(LANGPACK_PREFIX)$(LANGPACK_ID) +LANGPACK_DIR = $(if $(and $(call true,$(USE_CONE)),$(call true,$(IMAKER_MKRESTARTS))),$(CONE_OUTDIR),$(LANGPACK_ROOT)/$(LANGPACK_NAME)$(call iif,$(USE_CONE),/content)) +LANGPACK_DIRS = $(wildcard $(LANGPACK_ROOT)/$(LANGPACK_PREFIX)*$(call iif,$(USE_CONE),/content)) +LANGPACK_MK = $(or $(wildcard $(LANGPACK_DIR)/$(LANGPACK_MKNAME)),$(wildcard $(LANGPACK_ROOT)/$(LANGPACK_NAME)/content/$(LANGPACK_MKNAME))) LANGPACK_IDFILE = $(ROFS2_PREFIX)_rofs2_lang.txt -LANGPACK_ID = 01 +LANGPACK_IDINFO = $(ROFS2_VERSION) +LANGPACK_ID = $(if $(filter $(LANGPACK_PREFIX)%,$(TARGETNAME)),$(TARGETID1),01) +LANGPACK_REVISION = 01 LANGPACK_LANGFILE = $(ROFS2_PREFIX)_rofs2_languages.txt LANGPACK_LANGS = English LANGPACK_DEFAULTLANG = $(word 1,$(LANGPACK_LANGS)) LANGPACK_DEFAULTREGION = Western -LANGPACK_SWVERFILE = $(ROFS2_PREFIX)_rofs2_langsw.txt -LANGPACK_SWVERINFO = $(CORE_SWVERINFO) +LANGPACK_REGIONS = china japan western LANGPACK_INFOFILE = $(ROFS2_PREFIX)_rofs2_$(LANGPACK_NAME)_info.txt LANGPACK_LANGNAMES = $(call getlangname,$(LANGPACK_LANGS)) @@ -172,38 +101,37 @@ #============================================================================== -CLEAN_LANGFILE = del | "$(LANGPACK_LANGFILE)" "$(LANGPACK_IDFILE)" "$(LANGPACK_SWVERFILE)" "$(LANGPACK_INFOFILE)" +CLEAN_LANGFILE = del | "$(LANGPACK_LANGFILE)" "$(LANGPACK_IDFILE)" "$(LANGPACK_INFOFILE)" BUILD_LANGFILE =\ echo-q | Generating language files for Language Package image creation |\ $(if $(strip $(LANGUAGE_SYSLANGS)),,\ - error | 1 | No system languages defined\n |)\ + error | 1 | No system languages defined. |)\ $(if $(strip $(LANGPACK_LANGS)),,\ - error | 1 | No languages defined in the language pack\n |)\ + error | 1 | No languages defined in the language pack. |)\ $(call select,$(words $(LANGPACK_LANGS)),$(words $(LANGPACK_LANGIDS)),,\ - error | 1 | Not all languages of the language pack defined in the system languages\n |)\ + error | 1 | Not all languages of the language pack defined in the system languages. |)\ $(call select,$(words $(LANGPACK_LANGS)),$(words $(call getlangbyid,$(LANGPACK_LANGS))),,\ - error | 1 | Duplicate language defined in the language pack\n |)\ + error | 1 | Duplicate language defined in the language pack. |)\ $(if $(strip $(LANGPACK_DEFAULTLANG)),,\ - error | 1 | No default language defined\n |)\ + error | 1 | No default language defined. |)\ $(if $(word 2,$(LANGPACK_DEFAULTLANG)),\ - error | 1 | More than one default language defined\n |)\ + error | 1 | More than one default language defined. |)\ $(if $(filter $(call lcase,$(LANGPACK_DEFAULTLANG)),$(call lcase,$(LANGPACK_LANGS))),,\ - error | 1 | Default language not defined in the language pack languages\n |)\ + error | 1 | Default language not defined in the language pack languages. |)\ $(if $(word 2,$(sort $(call getlangregion,$(LANGPACK_LANGS)))),\ - error | 1 | Not all languages of the language pack belong to the same region\n |)\ + error | 1 | Not all languages of the language pack belong to the same region. |)\ \ - writeu | $(LANGPACK_LANGFILE) | $(LANGPACK_LANGINFO) |\ - writeu | $(LANGPACK_IDFILE) | $(LANGPACK_ID) |\ - writeu | $(LANGPACK_SWVERFILE) | $(LANGPACK_SWVERINFO) |\ + writeu | "$(LANGPACK_LANGFILE)" | $(LANGPACK_LANGINFO) |\ + writeu | "$(LANGPACK_IDFILE)" | $(LANGPACK_IDINFO) |\ $(if $(LANGPACK_NAME),\ - write | $(LANGPACK_INFOFILE) | $(call def2str,$(LANGPACK_INFO))) + write | "$(LANGPACK_INFOFILE)" | $(call def2str,$(LANGPACK_INFO))) LANGPACK_LANGINFO =\ $(foreach lang,$(LANGPACK_LANGIDS),\ $(lang)$(call select,$(lang),$(LANGPACK_DEFLANGID),$(,)d)\n) define LANGPACK_INFO - Generated `$(LANGPACK_INFOFILE)$' for documenting the language selections + Generated `$(LANGPACK_INFOFILE)' for documenting the language selections Name : $(LANGPACK_NAME) Default Lang.: $(LANGPACK_DEFLANGNAME) ($(LANGPACK_DEFLANGID)) @@ -214,79 +142,25 @@ ############################################################################### -# ROFS2 pre +# Targets -CLEAN_ROFS2PRE = $(if $(filter 2,$(USE_VARIANTBLD)),$(CLEAN_CUSTVARIANT) |) $(CLEAN_ROFS2FILE) -BUILD_ROFS2PRE =\ - $(if $(filter 2,$(USE_VARIANTBLD)),$(BUILD_CUSTVARIANT) |)\ - mkcd | $(ROFS2_DIR) |\ - $(BUILD_ROFS2FILE) - -#============================================================================== -# ROFS2 build +LANGPACK_EXPORT = $(if $(filter $(LANGPACK_PREFIX)%,$(TARGETNAME)),$(addprefix $(LANGPACK_PREFIX)%:LANGPACK_,ID NAME)) +TARGET_EXPORT += $(LANGPACK_EXPORT) -BLR.ROFS2.IDIR = $(call dir2inc,$(ROFS2_IDIR) $(call iif,$(USE_FEATVAR),,$(FEATVAR_IDIR))) -BLR.ROFS2.HBY = $(call includeiby,$(IMAGE_HBY) $(ROFS2_HBY)) -BLR.ROFS2.OBY = $(call includeiby,$(ROFS2_OBY) $(if $(filter 2,$(USE_VARIANTBLD)),$(VARIANT_OBY)) $(call iif,$(USE_VERGEN),$(ROFS2_VERIBY))) -BLR.ROFS2.OPT = $(ROFS2_OPT) $(if $(filter 2,$(USE_PAGEDCODE)),$(if $(ODP_CODECOMP),-c$(ODP_CODECOMP))) -o$(notdir $(ROFS2_NAME).img) $(BLDROPT) -BLR.ROFS2.POST = $(call iif,$(KEEPTEMP),,del | $(ROFS2_PREFIX).???) - -CLEAN_ROFS2 = $(CLEAN_BLDROM) -BUILD_ROFS2 = $(BUILD_BLDROM) +# langpack_all langpack_china langpack_japan langpack_western +.PHONY: $(addprefix $(LANGPACK_PREFIX),all $(LANGPACK_REGIONS)) -#============================================================================== -# ROFS2 post +$(addprefix $(LANGPACK_PREFIX),all $(LANGPACK_REGIONS)) \ +$(addsuffix -%,$(addprefix $(LANGPACK_PREFIX),all $(LANGPACK_REGIONS))):\ + ;@$(call IMAKER,$$(call getlpacksbyregion,$(LANGPACK_ID))) -CLEAN_ROFS2POST = $(CLEAN_IMGCHK) | $(CLEAN_MAKSYMROFS) -BUILD_ROFS2POST =\ - $(call iif,$(USE_IMGCHK),$(BUILD_IMGCHK) |)\ - $(call iif,$(USE_SYMGEN),$(BUILD_MAKSYMROFS)) - -#============================================================================== - -SOS.ROFS2.STEPS = $(call iif,$(USE_ROFS2),$(call iif,$(SKIPPRE),,ROFS2PRE) $(call iif,$(SKIPBLD),,ROFS2) $(call iif,$(SKIPPOST),,ROFS2POST)) -ALL.ROFS2.STEPS = $(SOS.ROFS2.STEPS) +$(LANGPACK_PREFIX)%: rofs2_$$* ; ############################################################################### -# Targets - -.PHONY: rofs2 rofs2-all rofs2-image rofs2-pre rofs2-check rofs2-symbol rofs2-i2file - -rofs2 rofs2-% : IMAGE_TYPE = ROFS2 -rofs2-all : USE_SYMGEN = 1 - -rofs2 rofs2-all: ;@$(call IMAKER,$$(ALL.ROFS2.STEPS)) -rofs2-image : ;@$(call IMAKER,$$(SOS.ROFS2.STEPS)) - -rofs2-pre : ;@$(call IMAKER,ROFS2PRE) -rofs2-check : ;@$(call IMAKER,IMGCHK) -rofs2-symbol : ;@$(call IMAKER,MAKSYMROFS) - -rofs2-i2file : USE_ROFS = 2 -rofs2-i2file : ;@$(call IMAKER,VARIANTI2F) - -# langpack_% -$(LANGPACK_PREFIX)%: LANGPACK_NAME = $(TARGETNAME) -$(LANGPACK_PREFIX)%: LANGPACK_ID = $(TARGETID) -$(LANGPACK_PREFIX)%: VARIANT_DIR = $(LANGPACK_DIR) -$(LANGPACK_PREFIX)%: VARIANT_MKNAME = $(LANGPACK_MKNAME) -$(LANGPACK_PREFIX)%: VARIANT_CONFML = $(LANGPACK_CONFML) -$(LANGPACK_PREFIX)%: VARIANT_CONFCP = $(LANGPACK_CONFCP) -$(LANGPACK_PREFIX)%: variantrofs2_$(TARGETID)$(TARGETEXT) ; - -# langpack_all langpack_china langpack_japan langpack_western -.PHONY: $(addprefix $(LANGPACK_PREFIX),all china japan western) - -$(addprefix $(LANGPACK_PREFIX),all china japan western):\ - ;@$(call IMAKER,$$(addsuffix |,$$(call getlpacksbyregion,$(LANGPACK_ID)))) - -#============================================================================== # Helps -$(call add_help,LANGPACK_DIR,v,(string),Overrides the VARIANT_DIR for language pack, see the instructions of VARIANT_CONFCP for details.) -$(call add_help,LANGPACK_CONFML,v,(string),Overrides the VARIANT_CONFML for language pack, see the instructions of VARIANT_CONFML for details.) -$(call add_help,LANGPACK_CONFCP,v,(string),Overrides the VARIANT_CONFCP for language pack, see the instructions of VARIANT_CONFCP for details.) +$(call add_help,LANGPACK_DIR,v,(string),Overrides the VARIANT_DIR for language pack, see the instructions of VARIANT_DIR for details.) $(call add_help,LANGPACK_LANGS,v,(string),Languages are the languages that are taken to the image (SC language is is defaulting to 01 in languages.txt)) $(call add_help,LANGPACK_DEFAULTLANG,v,(string),Default language is the language where the device will boot to (SIM language overrides this selection)) $(call add_help,LANGPACK_ID,v,(string),Language id used in the lang.txt generation) @@ -296,6 +170,12 @@ $(call add_help,$(LANGPACK_PREFIX)japan,t,Create language packages that belong to Japan region.) $(call add_help,$(LANGPACK_PREFIX)western,t,Create language packages that belong to Western region.) +LANGPACK_HELP =\ + $(call add_help,$(call getlpfrompath,$(LANGPACK_DIRS)),t,Language variant target.)\ + $(eval include $(wildcard $(addsuffix /$(LANGPACK_MKNAME),$(LANGPACK_DIRS)))) + +BUILD_HELPDYNAMIC += $(LANGPACK_HELP) + ############################################################################### # Functions @@ -315,19 +195,20 @@ # Get all language pack targets that belong to a given region getlpacksbyregion = $(strip\ - $(foreach file,$(wildcard $(LANGPACK_ROOT)/$(LANGPACK_PREFIX)*/$(LANGPACK_MKNAME)),\ + $(foreach file,$(wildcard $(addsuffix /$(LANGPACK_MKNAME),$(LANGPACK_DIRS))),\ $(eval include $(file))\ - $(if $(call select,$1,all,1)$(call select,$1,$(LANGPACK_REGION),1),\ - $(notdir $(patsubst %/,%,$(dir $(file))))))) + $(if $(call select,$1,all,1)$(call select,$1,$(LANGPACK_REGION),1),$(call getlpfrompath,$(file))))) + +# Get language pack target(s) from given path(s) +getlpfrompath = $(filter $(LANGPACK_PREFIX)%,$(call substm,/ \, ,$1)) ############################################################################### # Internal stuff LANGUAGE_EVAL =\ - $(eval -include $(call findfile,$(LANGPACK_SYSLANGMK),$(FEATVAR_IDIR)))\ $(eval LANGUAGE_ID-NAME :=)$(eval LANGUAGE_ID-REGION :=)\ - $(call _evallangdata,$(subst $(\n), | ,$(LANGUAGE_SYSLANGS))) + $(call _evallangdata,$(strip $(subst $(\n), | ,$(LANGUAGE_SYSLANGS)))) _evallangdata = $(if $1,\ $(eval __i_ldata := $(call getelem,1,$1))\ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_rofs3.mk --- a/imgtools/imaker/src/imaker_rofs3.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_rofs3.mk Wed Jun 30 11:35:58 2010 +0800 @@ -23,166 +23,55 @@ # |_|_\\___/|_| |___/ |___/ # -ROFS3_TITLE = ROFS3 -ROFS3_DIR = $(WORKDIR)/rofs3 -ROFS3_NAME = $(NAME) -ROFS3_PREFIX = $(ROFS3_DIR)/$(ROFS3_NAME) -ROFS3_IDIR = -ROFS3_HBY = -ROFS3_OBY = -ROFS3_OPT = -ROFS3_MSTOBY = $(ROFS3_PREFIX)_rofs3_master.oby -ROFS3_HEADER = -ROFS3_INLINE = -ROFS3_FOOTER = -ROFS3_TIME = $(DAY)/$(MONTH)/$(YEAR) - -ROFS3_OBYGEN = #geniby | $(ROFS3_PREFIX)_rofs3_collected.oby | $(E32ROMINC)/customervariant/* | *.iby | \#include "%3" | end - -ROFS3_VERIBY = $(ROFS3_PREFIX)_rofs3_version.iby -ROFS3_ROMVER = 0.01(0) -ROFS3_VERSION = $(CORE_VERSION) -ROFS3_CUSTSWFILE = $(ROFS3_PREFIX)_rofs3_customersw.txt -ROFS3_CUSTSWINFO = $(ROFS3_VERSION)\\\n$(DAY)-$(MONTH)-$(YEAR2) -ROFS3_FWIDFILE = $(ROFS3_PREFIX)_rofs3_fwid.txt -ROFS3_FWID = customer -ROFS3_FWIDVER = $(ROFS3_VERSION) Customer -ROFS3_FWIDINFO = id=$(ROFS3_FWID)\nversion=$(ROFS3_FWIDVER)\n - -ROFS3_IMG = $(ROFS3_PREFIX).rofs3.img -ROFS3_LOG = $(ROFS3_PREFIX).rofs3.log -ROFS3_OUTOBY = $(ROFS3_PREFIX).rofs3.oby -ROFS3_SYM = $(ROFS3_PREFIX).rofs3.symbol - -ROFS3_PLUGINLOG = $(ROFS3_PREFIX)_rofs3_bldromplugin.log -ROFS3_PAGEFILE = $(ODP_PAGEFILE) -ROFS3_UDEBFILE = $(TRACE_UDEBFILE) - -ROFS3_ICHKLOG = $(ROFS3_PREFIX)_rofs3_imgcheck.log -ROFS3_ICHKOPT = $(IMGCHK_OPT) -ROFS3_ICHKIMG = $(ROFS3_IMG) $(ROFS2_ICHKIMG) - -ROFS3_I2FDIR = $(ROFS3_DIR)/img2file - -#============================================================================== - -define ROFS3_MSTOBYINFO - $(BLDROM_HDRINFO) - - ROM_IMAGE 0 non-xip size=0x00000000 - ROM_IMAGE 1 dummy1 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 2 dummy2 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 3 rofs3 non-xip size=$(ROFS_MAXSIZE) - - $(BLDROM_PLUGINFO) +ROFS3_FEAXML = $(E32INC)/s60customswfeatures.xml +ROFS3_FEAIBY = $(ROFS3_DIR)/s60customswfeatures.iby - // ROFS3 header - // - $(ROFS3_HDRINFO) - - ROM_IMAGE[3] { - $(call ODP_CODEINFO,3) - $(BLR.ROFS3.OBY) - $(ROFS3_INLINE) - $(ROFS3_FOOTERINFO) - } -endef - -define ROFS3_HDRINFO - $(DEFINE) _IMAGE_WORKDIR $(ROFS3_DIR) - $(call mac2cppdef,$(BLR.ROFS3.OPT)) - $(BLR.ROFS3.HBY) - $(ROFS3_HEADER) - $(if $(filter 3,$(USE_VARIANTBLD)),$(VARIANT_HEADER)) -endef - -define ROFS3_FOOTERINFO - $(if $(ROFS3_TIME),time=$(ROFS3_TIME)) - $(ROFS3_FOOTER) -endef +ROFS3_ID = $(CUSTVARIANT_ID) +ROFS3_REVISION = $(CUSTVARIANT_REVISION) +ROFS3_SWVERTGT = $(IMAGE_VERSDIR)\customersw.txt +ROFS3_FWID = customer -define ROFS3_VERIBYINFO - // Generated `$(ROFS3_VERIBY)$' for ROFS3 image creation - $(if $(ROFS3_ROMVER), - - version=$(ROFS3_ROMVER)) - - OVERRIDE_REPLACE/ADD - $(if $(ROFS3_CUSTSWINFO), - data-override=$(ROFS3_CUSTSWFILE) RESOURCE_FILES_DIR\versions\customersw.txt) - $(call iif,$(USE_FOTA), - data-override=$(ROFS3_FWIDFILE) RESOURCE_FILES_DIR\versions\fwid3.txt) - OVERRIDE_END -endef +ROFS3_ICHKIMG += $(ROFS2_ICHKIMG) -#============================================================================== - -CLEAN_ROFS3FILE =\ - del | "$(ROFS3_MSTOBY)" "$(ROFS3_VERIBY)" "$(ROFS3_CUSTSWFILE)" "$(ROFS3_FWIDFILE)" |\ - del | $(call getgenfiles,$(ROFS3_OBYGEN)) - -BUILD_ROFS3FILE =\ - echo-q | Generating file(s) for ROFS3 image creation |\ - write | $(ROFS3_MSTOBY) | $(call def2str,$(ROFS3_MSTOBYINFO)) |\ - $(call iif,$(USE_VERGEN),\ - write | $(ROFS3_VERIBY) | $(call def2str,$(ROFS3_VERIBYINFO)) |\ - writeu | $(ROFS3_CUSTSWFILE) | $(ROFS3_CUSTSWINFO) |\ - writeu | $(ROFS3_FWIDFILE) | $(ROFS3_FWIDINFO) |)\ - $(ROFS3_OBYGEN) +ROFS3_CONECONF = $(PRODUCT_NAME)_custvariant_$(CUSTVARIANT_ID)$(addprefix _,$(CUSTVARIANT_NAME))_root.confml +ROFS3_CONEOPT = --layer-wildcard=*/custvariant* --impl-tag=target:rofs3 ############################################################################### -# ROFS3 pre - -CLEAN_ROFS3PRE = $(if $(filter 3,$(USE_VARIANTBLD)),$(CLEAN_CUSTVARIANT) |) $(CLEAN_ROFS3FILE) -BUILD_ROFS3PRE =\ - $(if $(filter 3,$(USE_VARIANTBLD)),$(BUILD_CUSTVARIANT) |)\ - mkcd | $(ROFS3_DIR) |\ - $(BUILD_ROFS3FILE) - -#============================================================================== -# ROFS3 build +# Customer variant -BLR.ROFS3.IDIR = $(call dir2inc,$(ROFS3_IDIR) $(call iif,$(USE_FEATVAR),,$(FEATVAR_IDIR))) -BLR.ROFS3.HBY = $(call includeiby,$(IMAGE_HBY) $(ROFS3_HBY)) -BLR.ROFS3.OBY = $(call includeiby,$(ROFS3_OBY) $(if $(filter 3,$(USE_VARIANTBLD)),$(VARIANT_OBY)) $(call iif,$(USE_VERGEN),$(ROFS3_VERIBY))) -BLR.ROFS3.OPT = $(ROFS3_OPT) $(if $(filter 3,$(USE_PAGEDCODE)),$(if $(ODP_CODECOMP),-c$(ODP_CODECOMP))) -o$(notdir $(ROFS3_NAME).img) $(BLDROPT) -BLR.ROFS3.POST = $(call iif,$(KEEPTEMP),,del | $(ROFS3_PREFIX).???) - -CLEAN_ROFS3 = $(CLEAN_BLDROM) -BUILD_ROFS3 = $(BUILD_BLDROM) +CUSTVARIANT_ROOT = $(PRODUCT_DIR)/customer +CUSTVARIANT_ROOT2 = $(if $(PRODUCT_MSTNAME),$(PRODUCT_MSTDIR)/customer) +#CUSTVARIANT_ROOT3 = $(PLATFORM_DIR)/country +CUSTVARIANT_PREFIX = custvariant_ +CUSTVARIANT_ID = $(if $(filter $(CUSTVARIANT_PREFIX)%,$(TARGETNAME)),$(TARGETID1),00) +CUSTVARIANT_NAME = $(if $(filter $(CUSTVARIANT_PREFIX)%,$(TARGETNAME)),$(TARGETID2-),vanilla) +CUSTVARIANT_REVISION = 01 +CUSTVARIANT_DIR = $(if $(and $(call true,$(USE_CONE)),$(call true,$(IMAKER_MKRESTARTS))),$(CONE_OUTDIR),$(strip\ + $(eval __i_custvardir :=)$(foreach croot,$(sort $(filter CUSTVARIANT_ROOT%,$(.VARIABLES))),\ + $(if $(__i_custvardir),,$(eval __i_custvardir := $(if $(wildcard $($(croot))),\ + $(wildcard $($(croot))/$(CUSTVARIANT_PREFIX)$(CUSTVARIANT_ID)$(addprefix _,$(CUSTVARIANT_NAME)))))))\ + )$(or $(__i_custvardir),$(CUSTVARIANT_ROOT)/$(CUSTVARIANT_PREFIX)$(CUSTVARIANT_ID)$(addprefix _,$(CUSTVARIANT_NAME)))$(call iif,$(USE_CONE),/content)) +CUSTVARIANT_COMPLP = -#============================================================================== -# ROFS3 post +CUSTVARIANT_EXPORT = $(if $(filter $(CUSTVARIANT_PREFIX)%,$(TARGETNAME)),$(addprefix $(CUSTVARIANT_PREFIX)%:CUSTVARIANT_,ID NAME)) +TARGET_EXPORT += $(CUSTVARIANT_EXPORT) -CLEAN_ROFS3POST = $(CLEAN_IMGCHK) | $(CLEAN_MAKSYMROFS) -BUILD_ROFS3POST =\ - $(call iif,$(USE_IMGCHK),$(BUILD_IMGCHK) |)\ - $(call iif,$(USE_SYMGEN),$(BUILD_MAKSYMROFS)) - -#============================================================================== - -SOS.ROFS3.STEPS = $(call iif,$(USE_ROFS3),$(call iif,$(SKIPPRE),,ROFS3PRE) $(call iif,$(SKIPBLD),,ROFS3) $(call iif,$(SKIPPOST),,ROFS3POST)) -ALL.ROFS3.STEPS = $(SOS.ROFS3.STEPS) +# custvariant_% +$(CUSTVARIANT_PREFIX)%: rofs3_$$* ; ############################################################################### -# Targets +# Helps -.PHONY: rofs3 rofs3-all rofs3-image rofs3-pre rofs3-check rofs3-symbol rofs3-i2file - -rofs3 rofs3-% : IMAGE_TYPE = ROFS3 -rofs3-all : USE_SYMGEN = 1 +$(call add_help,CUSTVARIANT_DIR,v,(string),Overrides the VARIANT_DIR for customer variant, see the instructions of VARIANT_DIR for details.) +$(call add_help,CUSTVARIANT_COMPLP,v,(string),Compatible language variant.) -rofs3 rofs3-all: ;@$(call IMAKER,$$(ALL.ROFS3.STEPS)) -rofs3-image : ;@$(call IMAKER,$$(SOS.ROFS3.STEPS)) +CUSTVARIANT_HELP = $(call add_help,$(foreach croot,$(filter CUSTVARIANT_ROOT%,$(.VARIABLES)),\ + $(if $(wildcard $($(croot))),$(call getlastdir,$(filter %/,$(wildcard $($(croot))/$(CUSTVARIANT_PREFIX)*/))))),\ + t,Customer $$(subst $$(CUSTVARIANT_PREFIX),,$$1) variant target.) -rofs3-pre : ;@$(call IMAKER,ROFS3PRE) -rofs3-check : ;@$(call IMAKER,IMGCHK) -rofs3-symbol : ;@$(call IMAKER,MAKSYMROFS) - -rofs3-i2file : USE_ROFS = 3 -rofs3-i2file : ;@$(call IMAKER,VARIANTI2F) +BUILD_HELPDYNAMIC += $(CUSTVARIANT_HELP) # END OF IMAKER_ROFS3.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_rofs4.mk --- a/imgtools/imaker/src/imaker_rofs4.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_rofs4.mk Wed Jun 30 11:35:58 2010 +0800 @@ -23,141 +23,5 @@ # |_|_\\___/|_| |___/ |_| # -ROFS4_TITLE = ROFS4 -ROFS4_DIR = $(WORKDIR)/rofs4 -ROFS4_NAME = $(NAME) -ROFS4_PREFIX = $(ROFS4_DIR)/$(ROFS4_NAME) -ROFS4_IDIR = -ROFS4_HBY = -ROFS4_OBY = -ROFS4_OPT = -ROFS4_MSTOBY = $(ROFS4_PREFIX)_rofs4_master.oby -ROFS4_HEADER = -ROFS4_INLINE = -ROFS4_FOOTER = -ROFS4_TIME = $(DAY)/$(MONTH)/$(YEAR) - -ROFS4_OBYGEN = - -ROFS4_VERSION = $(CORE_VERSION) - -ROFS4_IMG = $(ROFS4_PREFIX).rofs4.img -ROFS4_LOG = $(ROFS4_PREFIX).rofs4.log -ROFS4_OUTOBY = $(ROFS4_PREFIX).rofs4.oby -ROFS4_SYM = $(ROFS4_PREFIX).rofs4.symbol - -ROFS4_PLUGINLOG = $(ROFS4_PREFIX)_rofs4_bldromplugin.log -ROFS4_PAGEFILE = $(ODP_PAGEFILE) -ROFS4_UDEBFILE = $(TRACE_UDEBFILE) - -ROFS4_ICHKLOG = $(ROFS4_PREFIX)_rofs4_imgcheck.log -ROFS4_ICHKOPT = $(IMGCHK_OPT) -ROFS4_ICHKIMG = $(ROFS4_IMG) $(ROFS2_ICHKIMG) - -ROFS4_I2FDIR = $(ROFS4_DIR)/img2file - -#============================================================================== - -define ROFS4_MSTOBYINFO - $(BLDROM_HDRINFO) - - ROM_IMAGE 0 non-xip size=0x00000000 - ROM_IMAGE 1 dummy1 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 2 dummy2 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 3 dummy3 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 4 rofs4 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 5 dummy5 non-xip size=$(ROFS_MAXSIZE) - ROM_IMAGE 6 dummy6 non-xip size=$(ROFS_MAXSIZE) - - $(BLDROM_PLUGINFO) - - // ROFS4 header - // - $(ROFS4_HDRINFO) - - ROM_IMAGE[4] { - $(call ODP_CODEINFO,4) - $(BLR.ROFS4.OBY) - $(ROFS4_INLINE) - $(ROFS4_FOOTERINFO) - } -endef - -define ROFS4_HDRINFO - $(DEFINE) _IMAGE_WORKDIR $(ROFS4_DIR) - $(call mac2cppdef,$(BLR.ROFS4.OPT)) - $(BLR.ROFS4.HBY) - $(ROFS4_HEADER) -endef - -define ROFS4_FOOTERINFO - $(if $(ROFS4_TIME),time=$(ROFS4_TIME)) - $(ROFS4_FOOTER) -endef - -#============================================================================== - -CLEAN_ROFS4FILE =\ - del | "$(ROFS4_MSTOBY)" |\ - del | $(call getgenfiles,$(ROFS4_OBYGEN)) - -BUILD_ROFS4FILE =\ - echo-q | Generating file(s) for $(ROFS4_TITLE) image creation |\ - write | $(ROFS4_MSTOBY) | $(call def2str,$(ROFS4_MSTOBYINFO)) |\ - $(ROFS4_OBYGEN) - - -############################################################################### -# ROFS4 pre - -CLEAN_ROFS4PRE = $(CLEAN_ROFS4FILE) -BUILD_ROFS4PRE =\ - mkcd | $(ROFS4_DIR) |\ - $(BUILD_ROFS4FILE) - -#============================================================================== -# ROFS4 build - -BLR.ROFS4.IDIR = $(call dir2inc,$(ROFS4_IDIR) $(call iif,$(USE_FEATVAR),,$(FEATVAR_IDIR))) -BLR.ROFS4.HBY = $(call includeiby,$(IMAGE_HBY) $(ROFS4_HBY)) -BLR.ROFS4.OBY = $(call includeiby,$(ROFS4_OBY)) -BLR.ROFS4.OPT = $(ROFS4_OPT) $(if $(filter 4,$(USE_PAGEDCODE)),$(if $(ODP_CODECOMP),-c$(ODP_CODECOMP))) -o$(ROFS4_NAME).img $(BLDROPT) -BLR.ROFS4.POST = $(call iif,$(KEEPTEMP),,del | $(ROFS4_PREFIX).???) - -CLEAN_ROFS4 = $(CLEAN_BLDROM) -BUILD_ROFS4 = $(BUILD_BLDROM) - -#============================================================================== -# ROFS4 post - -CLEAN_ROFS4POST = $(CLEAN_IMGCHK) | $(CLEAN_MAKSYMROFS) -BUILD_ROFS4POST =\ - $(call iif,$(USE_IMGCHK),$(BUILD_IMGCHK) |)\ - $(call iif,$(USE_SYMGEN),$(BUILD_MAKSYMROFS)) - -#============================================================================== - -SOS.ROFS4.STEPS = $(call iif,$(USE_ROFS4),$(call iif,$(SKIPPRE),,ROFS4PRE) $(call iif,$(SKIPBLD),,ROFS4) $(call iif,$(SKIPPOST),,ROFS4POST)) -ALL.ROFS4.STEPS = $(SOS.ROFS4.STEPS) - - -############################################################################### -# Targets - -.PHONY: rofs4 rofs4-all rofs4-image rofs4-pre rofs4-check rofs4-symbol rofs4-i2file - -rofs4 rofs4-% : IMAGE_TYPE = ROFS4 -rofs4-all : USE_SYMGEN = 1 - -rofs4 rofs4-all: ;@$(call IMAKER,$$(ALL.ROFS4.STEPS)) -rofs4-image : ;@$(call IMAKER,$$(SOS.ROFS4.STEPS)) - -rofs4-pre : ;@$(call IMAKER,ROFS4PRE) -rofs4-check : ;@$(call IMAKER,IMGCHK) -rofs4-symbol : ;@$(call IMAKER,MAKSYMROFS) - -rofs4-i2file : USE_ROFS = 4 -rofs4-i2file : ;@$(call IMAKER,VARIANTI2F) - # END OF IMAKER_ROFS4.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_smr.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imaker/src/imaker_smr.mk Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,127 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: iMaker SMR image configuration +# + + + +############################################################################### +# ___ __ __ ___ +# / __| \/ | _ \ +# \__ \ |\/| | / +# |___/_| |_|_|_\ +# + +SMR_TITLE = SMR +SMR_DIR = $(CORE_DIR)/smr +SMR_NAME = $(NAME) +SMR_PREFIX = $(SMR_DIR)/$(SMR_NAME) +SMR_IDIR = +SMR_HBY = +SMR_OBY = +SMR_OPT = $(BLDROM_OPT) -s -D_EABI=$(ARM_VERSION) +SMR_MSTOBY = $(SMR_PREFIX)_smr_master.oby +SMR_HEADER = + +SMR_OBYGEN = + +SMR_IMG = $(SMR_PREFIX).smr.img +SMR_LOG = $(SMR_PREFIX).smr.log +SMR_OUTOBY = $(SMR_PREFIX).smr.oby + +SMR_CONECONF = +SMR_CONEOPT = --all-layers --impl-tag=target:smr + +#============================================================================== + +define SMR_MSTOBYINFO + $(call BLDROM_HDRINFO,SMR) + + ROM_IMAGE 0 non-xip size=0x00000000 + + /* $(SMR_TITLE) header + */ + $(SMR_HDRINFO) + + SMR_IMAGE { + $(BLR.SMR.OBY) + imagename=$(notdir $(SMR_IMG)) + } +endef + +define SMR_HDRINFO + $(DEFINE) _IMAGE_WORKDIR $(SMR_DIR) + $(call mac2cppdef,$(BLR.SMR.OPT)) + $(BLR.SMR.HBY) + $(SMR_HEADER) + $(if $(filter 1,$(USE_VARIANTBLD)),$(VARIANT_HEADER)) +endef + + +############################################################################### +# SMR pre-build step + +CLEAN_SMRPRE =\ + $(if $(filter 1,$(USE_VARIANTBLD)),$(CLEAN_VARIANT) |)\ + del | "$(SMR_MSTOBY)" | del | $(call getgenfiles,$(SMR_OBYGEN)) + +BUILD_SMRPRE =\ + $(if $(filter 1,$(USE_VARIANTBLD)),$(BUILD_VARIANT) |)\ + mkdir | "$(SMR_DIR)" |\ + echo-q | Generating file(s) for $(SMR_TITLE) image creation |\ + write-c | "$(SMR_MSTOBY)" | $(call def2str,$(SMR_MSTOBYINFO)) |\ + $(SMR_OBYGEN) + +#============================================================================== +# SMR build step + +BLR.SMR.IDIR = $(call dir2inc,$(SMR_IDIR) $(call iif,$(USE_FEATVAR),,$(FEATVAR_IDIR))) +BLR.SMR.HBY = $(call includeiby,$(IMAGE_HBY) $(SMR_HBY)) +BLR.SMR.OBY = $(call includeiby,$(SMR_OBY))\ + $(call includeiby,$(if $(filter 1,$(USE_VARIANTBLD)),$(VARIANT_OBY)) $(BLDROBY)) +BLR.SMR.OPT = $(SMR_OPT) -o$(call pathconv,$(SMR_PREFIX)).img $(BLDROPT) +BLR.SMR.POST =\ + move | "$(SMR_OUTOBY).log" | $(SMR_LOG) |\ + test | "$(SMR_IMG)" + +CLEAN_SMR = $(call CLEAN_BLDROM,SMR) +BUILD_SMR = $(call BUILD_BLDROM,SMR) + +REPORT_SMR =\ + $(SMR_TITLE) dir | $(SMR_DIR) | d |\ + $(SMR_TITLE) image | $(SMR_IMG) | f + +#============================================================================== + +SOS.SMR.STEPS = $(call iif,$(USE_SMR),\ + $(call iif,$(SKIPPRE),,$(and $(filter 1,$(USE_VARIANTBLD)),$(call true,$(USE_CONE)),CONEGEN RESTART) SMRPRE)\ + $(call iif,$(SKIPBLD),,SMR) $(call iif,$(SKIPPOST),,SMRPOST)) + +ALL.SMR.STEPS = $(SOS.SMR.STEPS) + + +############################################################################### +# Targets + +.PHONY: smr smr-all smr-image smr-cone smr-pre + +smr smr%: IMAGE_TYPE = SMR + +smr smr-all: ;@$(call IMAKER,$$(ALL.SMR.STEPS)) +smr-image : ;@$(call IMAKER,$$(SOS.SMR.STEPS)) +smr-cone : ;@$(call IMAKER,CONEGEN) +smr-pre : ;@$(call IMAKER,SMRPRE) + + +# END OF IMAKER_SMR.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_tools.mk --- a/imgtools/imaker/src/imaker_tools.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_tools.mk Wed Jun 30 11:35:58 2010 +0800 @@ -19,124 +19,308 @@ ############################################################################### # External tools -BLDROM_TOOL = buildrom +BLDROM_TOOL = $(PERL) -S buildrom.pl +FEATMAN_TOOL = $(PERL) -S features.pl ROMBLD_TOOL = rombuild ROFSBLD_TOOL = rofsbuild -MAKSYM_TOOL = maksym -MAKSYMROFS_TOOL = maksymrofs +MAKSYM_TOOL = $(PERL) -S maksym.pl +MAKSYMROFS_TOOL = $(PERL) -S maksymrofs.pl +ELF2E32_TOOL = elf2e32 IMGCHK_TOOL = imgcheck INTPRSIS_TOOL = interpretsis READIMG_TOOL = readimage -UNZIP_TOOL = unzip ZIP_TOOL = zip 7ZIP_TOOL = 7za -FILEDISK_TOOL = filedisk -WINIMAGE_TOOL = "c:/program files/winimage/winimage.exe" +UNZIP_TOOL = $(7ZIP_TOOL) + +BUILD_TOOLSET =\ + tool-cpp | $(CPP) |\ + tool-elf2e32 | $(ELF2E32_TOOL) |\ + tool-interpretsis | $(INTPRSIS_TOOL) |\ + tool-opcache | $(OPC_TOOL) |\ + tool-unzip | $(UNZIP_TOOL) + +#============================================================================== + +BLDROM_JOBS = + +BLDROM_OPT =\ + -loglevel1 $(call iif,$(KEEPTEMP),-p) -v $(call iif,$(USE_SYMGEN),,-nosymbols) $(addprefix -j,$(BLDROM_JOBS))\ + $(call iif,$(USE_BLRWORKDIR),-workdir="$($(IMAGE_TYPE)_DIR)")\ + $(call iif,$(USE_FEATVAR),-DFEATUREVARIANT=$(FEATURE_VARIANT))\ + $(call iif,$(SYMBIAN_FEATURE_MANAGER),\ + $(if $($(IMAGE_TYPE)_FEAXML),-fm=$(subst $( ),$(,),$(strip $($(IMAGE_TYPE)_FEAXML)))) -D__FEATURE_IBY__)\ + $(if $(IMAGE_TYPE),-D_IMAGE_TYPE_$(IMAGE_TYPE)) $(if $(TYPE),-D_IMAGE_TYPE_$(call ucase,$(TYPE))) + +BLDROM_PARSE =\ + parse | Missing files: | /Missing file:/i ||\ + parse | Errors: | /ERROR:\|ERR :/i ||\ + parse-4 | Erroneous links: | /WARNING: Kernel\/variant\/extension/i ||\ + parse | Warnings: | /WARNING:\|WARN:/i |\ + /WARNING: the value of attribute .+ has been overridden\|WARNING: Kernel\/variant\/extension\|Warning: Can't open .+\.map/i + +# parse | Can't locate: | /Can't locate\|couldn't be located/i | +#Unrecognised option -NO-HEADER0 + +# For passing extra parameters (from command line) +BLDROPT = +BLDROBY = #============================================================================== -BLDROM_OPT =\ - -loglevel1 $(call iif,$(KEEPTEMP),-p) -v -nosymbols\ - $(call iif,$(USE_FEATVAR),-DFEATUREVARIANT=$(FEATURE_VARIANT))\ - $(if $(IMAGE_TYPE),-D_IMAGE_TYPE_$(IMAGE_TYPE)) $(if $(TYPE),-D_IMAGE_TYPE_$(call ucase,$(TYPE))) +DEFHRH_IDIR = . $($(IMAGE_TYPE)_IDIR) $(FEATVAR_IDIR) +DEFHRH_CMD = $(CPP) -nostdinc -undef -dM -D_IMAGE_INCLUDE_HEADER_ONLY\ + $(call dir2inc,$(DEFHRH_IDIR)) -include $(call upddrive,$(FEATVAR_HRH)) $(call updoutdrive,$($(IMAGE_TYPE)_MSTOBY)) \|\ + $(PERL) -we $(call iif,$(USE_UNIX),',")print(sort({lc($$a) cmp lc($$b)} ))$(call iif,$(USE_UNIX),',")\ + >>$($(IMAGE_TYPE)_DEFHRH) + +define DEFHRH_HDRINFO + // Generated file for documenting feature variant definitions + // + // Filename: $($(IMAGE_TYPE)_DEFHRH) + // Command : $(DEFHRH_CMD) +endef + +CLEAN_DEFHRH = del | "$($(IMAGE_TYPE)_DEFHRH)" +BUILD_DEFHRH =\ + $(if $($(IMAGE_TYPE)_DEFHRH),\ + write | "$($(IMAGE_TYPE)_DEFHRH)" | $(call def2str,$(DEFHRH_HDRINFO))\n\n |\ + cmd | $(DEFHRH_CMD)) + +#============================================================================== -BLDROM_PARSE =\ - parse | \nMissing file(s):\n | Missing file: |\ - parse | \nWarning(s):\n | /WARNING:\|WARN:/i |\ - parse | \nError(s):\n | /ERROR:\|ERR :/i |\ - parse | \nCan$'t locate:\n | Can$'t locate | parse | \ncouldn$'t be located:\n | couldn$'t be located +FEATMAN_OPT = $($(IMAGE_TYPE)_FEAXML) --ibyfile=$($(IMAGE_TYPE)_DIR) --verbose +FEATMAN_CMD = $(FEATMAN_TOOL) $(FEATMAN_OPT) + +CLEAN_FEATMAN = del | $(foreach file,$($(IMAGE_TYPE)_FEAIBY),"$(file)") +BUILD_FEATMAN =\ + $(call iif,$(SYMBIAN_FEATURE_MANAGER),$(if $($(IMAGE_TYPE)_FEAXML),\ + echo-q | Generating Feature manager file(s) |\ + write | $($(IMAGE_TYPE)_FEAIBY) | |\ + cmd | $(FEATMAN_CMD))) -#* Writing tmp7.oby - result of problem-suppression phase -#Can't open \epoc32\release\ARMV5\urel\apgrfx.dll.map -#Unrecognised option -NO-HEADER0 +#============================================================================== +# ROFS symbol generation + +MAKSYMROFS_CMD = $(MAKSYMROFS_TOOL) $(call pathconv,"$($(IMAGE_TYPE)_LOG)" "$($(IMAGE_TYPE)_SYM)") -# For passing extra paramters (from command line) -BLDROPT = -BLDROBY = +CLEAN_MAKSYMROFS = del | "$($(IMAGE_TYPE)_SYM)" +BUILD_MAKSYMROFS =\ + echo-q | Creating $($(IMAGE_TYPE)_TITLE) symbol file |\ + cmd | $(MAKSYMROFS_CMD) + +REPORT_MAKSYMROFS = $($(IMAGE_TYPE)_TITLE) symbols | $($(IMAGE_TYPE)_SYM) | f ############################################################################### -# S60 Configuration Tool CLI +# ConE + +USE_CONE = 0 + +CONE_TOOL = $(call iif,$(USE_UNIX),,call )cone +CONE_TOOLDIR = $(or $(wildcard $(E32TOOLS)/configurationengine),$(E32TOOLS)/cone) +CONE_OUTDIR = $(OUTTMPDIR)/cone +CONE_PRJ = $(CONFIGROOT) +CONE_CONF = $($(IMAGE_TYPE)_CONECONF) +CONE_RNDCONF = $(COREPLAT_NAME)/$(PRODUCT_NAME)/rnd/root.confml +CONE_ADDCONF = $(call select,$(TYPE),rnd,$(if $(wildcard $(CONE_PRJ)/$(CONE_RNDCONF)),$(CONE_RNDCONF))) +CONE_LOG = $($(or $(addsuffix _,$(IMAGE_TYPE)),WORK)PREFIX)_cone_$(call substm,* / : ? \,@,$(TARGET)).log +CONE_VERBOSE = $(if $(filter debug 127,$(VERBOSE)),5) +CONE_GOPT = generate --project="$(CONE_PRJ)"\ + $(if $(CONE_CONF),--configuration="$(CONE_CONF)") $(addprefix --add=,$(CONE_ADDCONF))\ + $(if $(CONE_LOG),--log-file="$(CONE_LOG)") $(addprefix --verbose=,$(CONE_VERBOSE)) +CONE_PARSE = parse-2 | ConE errors: | /ERROR\s*:/i | + +#============================================================================== -CONFT_TOOL = cli.cmd -CONFT_TOOLDIR = $(or $(wildcard /s60/tools/toolsextensions/ConfigurationTool),/ext/tools/toolsextensions/ConfigurationTool) +CONE_MK = $(if $(CONE_PRJ),$(CONE_PRJ).mk) +CONE_MKOPT = $(CONE_GOPT) --impl=imaker.* --all-layers --set=imaker.makefilename="$(CONE_MK)" --output=. +CONE_MKCMD = $(CONE_TOOL) $(CONE_MKOPT) + +CLEAN_CONEPRE = del | "$(CONE_MK)" "$(CONE_LOG)" +BUILD_CONEPRE =\ + echo-q | Creating ConE makefile `$(CONE_MK)' |\ + cmd | $(CONE_MKCMD) | $(CONE_PARSE) |\ + test | "$(CONE_MK)" + +#============================================================================== + +CONE_IMPLS = +CONE_IMPLOPT = $(addprefix --impl=,$(subst $(,), ,$(CONE_IMPLS))) +CONE_LAYERS = +CONE_LAYEROPT = $(addprefix --layer=,$(subst $(,), ,$(CONE_LAYERS))) +CONE_REPFILE = $(basename $(CONE_LOG)).html +CONE_REPDATADIR = $(OUTDIR)/cone-repdata +CONE_REPDATAFILE = $(CONE_REPDATADIR)/$(IMAGE_TYPE).dat +CONE_RTMPLFILE = + +CONE_GENOPT = $(CONE_GOPT)\ + $(CONE_IMPLOPT) $(CONE_LAYEROPT) --add-setting-file=imaker_variantdir.cfg\ + $(if $(CONE_REPFILE),$(call select,$(USE_CONE),mk,--report-data-output="$(CONE_REPDATAFILE)",--report="$(CONE_REPFILE)"))\ + $($(IMAGE_TYPE)_CONEOPT) --output="$(CONE_OUTDIR)" +CONE_GENCMD = $(CONE_TOOL) $(CONE_GENOPT) -CONFT_DIR = $(WORKDIR)/ct -CONFT_TMPDIR = $(CONFT_DIR)/_temp -CONFT_CFGNAME = variant -CONFT_CONFML = $(call iif,$(USE_VARIANTBLD),$(VARIANT_CONFML),$(WORKDIR)/$(CONFT_CFGNAME).confml) -CONFT_IMPL = $(CONFIGROOT)/confml_data/s60;$(CONFIGROOT)/confml_data/customsw -CONFT_IBYML = $(CONFT_TOOLDIR)/ibyml -CONFT_OUTDIR = $(call iif,$(USE_VARIANTBLD),$(VARIANT_OUTDIR),$(CONFT_DIR)/cenrep) -CONFT_CRLOG = $(call iif,$(USE_VARIANTBLD),$(VARIANT_PREFIX)_,$(CONFT_DIR))cenrep.log -CONFT_ECLCONF = -configuration $(CONFT_TMPDIR) -data $(CONFT_TMPDIR) -CONFT_CONF = $(CONFT_ECLCONF)\ - -master $(CONFT_CONFML) -impl $(CONFT_IMPL) $(if $(CONFT_IBYML),-ibyml $(CONFT_IBYML)) -output $(CONFT_DIR)\ - -report $(CONFT_CRLOG) -ignore_errors -CONFT_CONFCP = $(call iif,$(USE_VARIANTBLD),$(VARIANT_CONFCP),$(CONFT_CFGNAME)) +CLEAN_CONEGEN = del | "$(CONE_LOG)" "$(CONE_REPFILE)" | deldir | "$(CONE_OUTDIR)" +BUILD_CONEGEN =\ + echo-q | Generating $($(IMAGE_TYPE)_TITLE) content with ConE |\ + mkdir | "$(CONE_OUTDIR)" |\ + cmd | $(CONE_GENCMD) | $(CONE_PARSE) + +REPORT_CONEGEN =\ + ConE log | $(CONE_LOG) | f\ + $(if $(CONE_REPFILE),| ConE report | $(CONE_REPFILE) | f) + +#============================================================================== + +CLEAN_CONEREPPRE = deldir | "$(CONE_REPDATADIR)" +BUILD_CONEREPPRE = + +CONE_REPGENOPT =\ + report --input-data-dir="$(CONE_REPDATADIR)"\ + $(if $(CONE_RTMPLFILE),--template="$(CONE_RTMPLFILE)")\ + --report="$(CONE_REPFILE)" --log-file="$(CONE_LOG)" $(addprefix --verbose=,$(CONE_VERBOSE)) +CONE_REPGENCMD = $(CONE_TOOL) $(CONE_REPGENOPT) -CONFT_CMD = $(CONFT_TOOL) $(CONFT_CONF) -CONFT_PARSE = parse | \nWarnings, errors and problems:\n | /warning:\|error:\|problem/i +CLEAN_CONEREPGEN = del | "$(CONE_REPFILE)" +BUILD_CONEREPGEN = $(if $(CONE_REPFILE),\ + echo-q | Generating report with ConE to `$(CONE_REPFILE)' |\ + cmd | $(CONE_REPGENCMD)) + +REPORT_CONEREPGEN = $(if $(CONE_REPFILE),ConE report | $(CONE_REPFILE) | f) -CLEAN_CENREP =\ - del | $(CONFT_CRLOG) |\ - deldir | "$(CONFT_DIR)" "$(CONFT_TMPDIR)" $(call iif,$(USE_VARIANTBLD),,"$(CONFT_OUTDIR)") +#============================================================================== + +CONE_XCF = $(ICDP_XCF) + +CONE_XCFOPT = $(CONE_GOPT) --impl=xcf.gcfml --all-layers --output="$(dir $(CONE_XCF))" +CONE_XCFCMD = $(CONE_TOOL) $(CONE_XCFOPT) -BUILD_CENREP =\ - echo-q | Calling S60 Configuration Tool |\ - mkcd | $(CONFT_DIR) |\ - deldir | $(CONFT_TMPDIR) |\ - cmd | $(CONFT_CMD) | $(CONFT_PARSE) |\ - $(foreach dir,$(CONFT_CONFCP),\ - finddir | $(CONFT_DIR)/$(dir) | * | |\ - copy | __find__ | $(CONFT_OUTDIR) |)\ - $(call iif,$(KEEPTEMP),,deldir | $(CONFT_TMPDIR)) +CLEAN_CONEXCF = del | "$(CONE_XCF)" "$(CONE_LOG)" +BUILD_CONEXCF =\ + echo-q | Creating XCF file `$(CONE_XCF)' |\ + cmd | $(CONE_XCFCMD) | $(CONE_PARSE) |\ + test | "$(CONE_XCF)" + +#============================================================================== + +.PHONY: cone-pre cone-gen cone-rep-pre cone-rep-gen + +cone-pre: ;@$(call IMAKER,CONEPRE) +cone-gen: ;@$(call IMAKER,CONEGEN) +cone-rep-pre: ;@$(call IMAKER,CONEREPPRE) +cone-rep-gen: ;@$(call IMAKER,CONEREPGEN) ############################################################################### -# Interpretsis +# SIS pre-installation + +SISINST_INI = $(wildcard $(VARIANT_DIR)/sis_config.ini) +SISINST_DIR = $(VARIANT_SISDIR) +SISINST_OUTDIR = $(VARIANT_OUTDIR) +SISINST_CFGINI = $(IMAGE_PREFIX)_sis.ini +SISINST_LOG = $(IMAGE_PREFIX)_sis.log +SISINST_CONF = -d $(if $(filter Z z,$(or $($(IMAGE_TYPE)_DRIVE),Z)),C,$($(IMAGE_TYPE)_DRIVE)) -e -k 5.4 -s "$(SISINST_DIR)" +SISINST_HALHDA = + +# sf/os/kernelhwsrv/halservices/hal/inc/hal_data.h: +define SISINST_HALINFO + EManufacturer_Ericsson 0x00000000 + EManufacturer_Motorola 0x00000001 + EManufacturer_Nokia 0x00000002 + EManufacturer_Panasonic 0x00000003 + EManufacturer_Psion 0x00000004 + EManufacturer_Intel 0x00000005 + EManufacturer_Cogent 0x00000006 + EManufacturer_Cirrus 0x00000007 + EManufacturer_Linkup 0x00000008 + EManufacturer_TexasInstruments 0x00000009 -SISINST_DIR = $(WORKDIR)/sisinst -SISINST_SISDIR = $(call iif,$(USE_VARIANTBLD),$(VARIANT_SISDIR)) -SISINST_OUTDIR = $(call iif,$(USE_VARIANTBLD),$(VARIANT_OUTDIR),$(SISINST_DIR)/output) -#SISINST_ZDIR = $(SISINST_DIR)/z_drive -SISINST_ZDIR = $(EPOC32)/data/Z + EDeviceFamily_Crystal 0 + EDeviceFamily_Pearl 1 + EDeviceFamily_Quartz 2 + + ECPU_ARM 0 + ECPU_MCORE 1 + ECPU_X86 2 + + ECPUABI_ARM4 0 + ECPUABI_ARMI 1 + ECPUABI_THUMB 2 + ECPUABI_MCORE 3 + ECPUABI_MSVC 4 + ECPUABI_ARM5T 5 + ECPUABI_X86 6 + + ESystemStartupReason_Cold 0 + ESystemStartupReason_Warm 1 + ESystemStartupReason_Fault 2 + + EKeyboard_Keypad 0x1 + EKeyboard_Full 0x2 -SISINST_HALINI = $(wildcard $(PRODUCT_DIR)/interpretsis.ini) -SISINST_CONF = -w info -z $(SISINST_ZDIR) $(if $(SISINST_HALINI),-i $(SISINST_HALINI)) -c $(SISINST_OUTDIR) -s $(SISINST_SISDIR) -SISINST_CMD = $(INTPRSIS_TOOL) $(SISINST_CONF) -SISINST_PARSE =\ - parse | \nWarning(s):\n | /^WARN:/ |\ - parse | \nError(s):\n | /^ERR :/ + EMouseState_Invisible 0 + EMouseState_Visible 1 -#CLEAN_SISINSTPRE = deldir | $(SISINST_ZDIR) -#BUILD_SISINSTPRE =\ -# mkdir | $(SISINST_ZDIR) |\ -# $(foreach img,$(ROM_IMG) $(foreach rofs,1 2 3 4 5 6,$(call iif,$(USE_ROFS$(rofs)),$(ROFS$(rofs)_IMG))),\ -# cmd | $(READIMG_TOOL) -z $(SISINST_ZDIR) $(img) |) + EMachineUid_Series5mx 0x1000118a + EMachineUid_Brutus 0x10005f60 + EMachineUid_Cogent 0x10005f61 + EMachineUid_Win32Emulator 0x10005f62 + EMachineUid_WinC 0x10005f63 + EMachineUid_CL7211_Eval 0x1000604f + EMachineUid_LinkUp 0x00000000 + EMachineUid_Assabet 0x100093f3 + EMachineUid_Zylonite 0x101f7f27 + EMachineUid_IQ80310 0x1000a681 + EMachineUid_Lubbock 0x101f7f26 + EMachineUid_Integrator 0x1000AAEA + EMachineUid_Helen 0x101F3EE3 + EMachineUid_X86PC 0x100000ad + EMachineUid_OmapH2 0x1020601C + EMachineUid_OmapH4 0x102734E3 + EMachineUid_NE1_TB 0x102864F7 + EMachineUid_EmuBoard 0x1200afed + EMachineUid_OmapH6 0x10286564 + EMachineUid_OmapZoom 0x10286565 + EMachineUid_STE8500 0x101FF810 -CLEAN_SISINST = deldir | "$(SISINST_DIR)" $(call iif,$(USE_VARIANTBLD),,"$(SISINST_OUTDIR)") + EPowerBatteryStatus_Zero 0 + EPowerBatteryStatus_Replace 1 + EPowerBatteryStatus_Low 2 + EPowerBatteryStatus_Good 3 + + EPowerBackupStatus_Zero 0 + EPowerBackupStatus_Replace 1 + EPowerBackupStatus_Low 2 + EPowerBackupStatus_Good 3 +endef + +define SISINST_CFGINFO + $(foreach lang,$(LANGPACK_LANGIDS), + DEVICE_SUPPORTED_LANGUAGE = $(lang)) +endef + +CLEAN_SISINST = del | "$(SISINST_CFGINI)" "$(SISINST_LOG)" BUILD_SISINST =\ - echo-q | Installing SIS |\ - mkdir | $(SISINST_OUTDIR) |\ - cmd | $(SISINST_CMD) | $(SISINST_PARSE) + echo-q | Installing SIS file(s) |\ + sisinst | $(SISINST_INI) | $(SISINST_CFGINI) | $(SISINST_CONF) |\ + $(SISINST_HALHDA) | $(strip $(call def2str,$(SISINST_HALINFO) | $(SISINST_CFGINFO))) |\ + $(SISINST_OUTDIR) | $(SISINST_LOG) ############################################################################### # Operator Cache Tool -OPC_TOOL = $(ITOOL_DIR)/opcache_tool.py -OPC_CONF = -u $(OPC_URL) -e $(OPC_EXPDATE) -m $(OPC_MMAPFILE) -i $(OPC_RAWDIR) -o $(OPC_OUTDIR)/$(OPC_CACHEDIR) -OPC_CMD = $(PYTHON) $(OPC_TOOL) $(OPC_CONF) -OPC_DIR = $(WORKDIR)/opcache -OPC_RAWDIR = $(call iif,$(USE_VARIANTBLD),$(VARIANT_OPCDIR)) -OPC_OUTDIR = $(call iif,$(USE_VARIANTBLD),$(VARIANT_OUTDIR),$(OPC_DIR)/output) -OPC_CACHEDIR = cache -OPC_MMAPFILE = $(OPC_DIR)/mimemap.dat - +OPC_TOOL = $(PYTHON) $(ITOOL_DIR)/opcache_tool.py +OPC_INI = $(wildcard $(VARIANT_DIR)/opcache_config.ini) +OPC_DIR = $(VARIANT_OPCDIR) +OPC_OUTDIR = $(VARIANT_OUTDIR)/$(OPC_CACHEDIR) +OPC_TMPDIR = $(OUTTMPDIR)/opcache +OPC_CACHEDIR = system/cache/op OPC_URL = http://www.someoperator.com/Cache_OpCache -OPC_EXPDATE = 3 +OPC_EXPDATE = 2012-01-01 +OPC_MIMEFILE = $(IMAGE_PREFIX)_opcachemime.dat +OPC_CONF = -u "$(OPC_URL)" -e "$(OPC_EXPDATE)" -m "$(OPC_MIMEFILE)" -i "$(OPC_DIR)" -o "$(OPC_OUTDIR)" define OPC_MIMEMAP .bmp: image/bmp @@ -159,30 +343,12 @@ .xhtml: application/xhtml+xml endef -CLEAN_OPCACHE = del | $(OPC_MMAPFILE) | deldir | "$(OPC_DIR)" $(call iif,$(USE_VARIANTBLD),,"$(OPC_OUTDIR)") +CLEAN_OPCACHE = del | "$(OPC_MIMEFILE)" BUILD_OPCACHE =\ - echo-q | Creating Operator Cache content |\ - write | $(OPC_MMAPFILE) |\ - $(call def2str,\# Generated `$(OPC_MMAPFILE)$' for Operator Cache content creation$(\n)$(\n)$(OPC_MIMEMAP)) |\ - test | $(OPC_RAWDIR)/* |\ - mkdir | $(OPC_OUTDIR)/$(OPC_CACHEDIR) |\ - cmd | $(OPC_CMD) - - -############################################################################### -# Widget Pre-installation - -WIDGET_WGZIP = $(WORKDIR)/*.wgz -WIDGET_WGZDIR = $(EPOC32)/release/winscw/udeb/z/data/WidgetBURTemp -WIDGET_WGZIBY = $(E32ROMINC)/widgetbackupfiles.iby -WIDGET_WGZPXML = Info.plist - -CLEAN_WGZPREINST = del | $(WIDGET_WGZIBY) | deldir | $(WIDGET_WGZDIR) -BUILD_WGZPREINST =\ - echo-q | Widget Pre-installation |\ - echo-q | Unzip $(WIDGET_WGZIP) file(s) to $(WIDGET_WGZDIR), generating $(WIDGET_WGZIBY) |\ - wgunzip | $(WIDGET_WGZIP) | $(WIDGET_WGZDIR) | $(WIDGET_WGZPXML) |\ - geniby-r | $(WIDGET_WGZIBY) | $(WIDGET_WGZDIR) | * | data="%1" "data/WidgetBURTemp/%2" | end + echo-q | Creating Operator Cache content |\ + mkdir | "$(OPC_OUTDIR)" |\ + write | "$(OPC_MIMEFILE)" | $(call def2str,$(OPC_MIMEMAP))\n |\ + opcache | $(OPC_INI) | $(OPC_CONF) | $(OPC_TMPDIR) ############################################################################### @@ -226,28 +392,276 @@ ############################################################################### # Image to files; extract files from .img using Readimage tool -I2FILE_DIR = $(WORKDIR)/img2file +CLEAN_I2FILE = deldir | "$($(IMAGE_TYPE)_I2FDIR)" +BUILD_I2FILE =\ + echo-q | Extracting files from $($(IMAGE_TYPE)_TITLE) SOS image to $($(IMAGE_TYPE)_I2FDIR) |\ + mkcd | "$($(IMAGE_TYPE)_I2FDIR)" |\ + $(foreach img,$($(IMAGE_TYPE)_IMG),\ + cmd | $(READIMG_TOOL) -s $(img) |\ + cmd | $(READIMG_TOOL) -z . $(img) |) + + +############################################################################### +# Rofsbuild FAT + +ROFSBLD_FATOPT = -datadrive="$($(IMAGE_TYPE)_OUTOBY)" $(addprefix -j,$(BLDROM_JOBS)) $(call iif,$(KEEPGOING),-k) -loglevel2 -slog + +CLEAN_ROFSBLDFAT = del | "$($(IMAGE_TYPE)_LOG)" +BUILD_ROFSBLDFAT =\ + cmd | $(ROFSBLD_TOOL) $(ROFSBLD_FATOPT) |\ + move | "$($(IMAGE_TYPE)_OUTOBY).log" | $($(IMAGE_TYPE)_LOG) + + +############################################################################### +# Filedisk + +FILEDISK_TOOL = filedisk +FILEDISK_OPT = /mount 0 $(call peval,GetAbsFname($(call pquote,$($(IMAGE_TYPE)_IMG)),1)) $(call peval,$$iVar[0] = GetFreeDrive()) +FILEDISK_SLEEP = 1 -CLEAN_COREI2F = deldir | $(CORE_I2FDIR) -BUILD_COREI2F = $(call _buildi2file,CORE,$(CORE_I2FDIR),$(ROM_IMG) $(call iif,$(USE_ROFS1),$(ROFS1_IMG))) +CLEAN_FILEDISK = del | "$($(IMAGE_TYPE)EMPTY_IMG)" +BUILD_FILEDISK =\ + $(if $($(IMAGE_TYPE)EMPTY_CMD),\ + cmd | $($(IMAGE_TYPE)EMPTY_CMD) |\ + move | "$($(IMAGE_TYPE)EMPTY_IMG)" | $($(IMAGE_TYPE)_IMG) |)\ + cmd | $(FILEDISK_TOOL) $(FILEDISK_OPT) |\ + copydir | "$($(IMAGE_TYPE)_DATADIR)" | $(call peval,$$iVar[0])/ |\ + cmd | $(FILEDISK_TOOL) /status $(call peval,$$iVar[0]) |\ + sleep | $(FILEDISK_SLEEP) |\ + cmd | $(FILEDISK_TOOL) /umount $(call peval,$$iVar[0]) + + +############################################################################### +# WinImage + +WINIMAGE_TOOL = "c:/program files/winimage/winimage.exe" +WINIMAGE_OPT = $(call pathconv,$($(IMAGE_TYPE)_IMG)) /i $(call pathconv,$($(IMAGE_TYPE)_DATADIR)) /h /q + +CLEAN_WINIMAGE = del | "$($(IMAGE_TYPE)EMPTY_IMG)" +BUILD_WINIMAGE =\ + $(if $($(IMAGE_TYPE)EMPTY_CMD),\ + cmd | $($(IMAGE_TYPE)EMPTY_CMD) |\ + move | "$($(IMAGE_TYPE)EMPTY_IMG)" | $($(IMAGE_TYPE)_IMG) |)\ + cmd | $(WINIMAGE_TOOL) $(WINIMAGE_OPT) + + +############################################################################### +# Widget Pre-installation -CLEAN_VARIANTI2F = $(foreach rofs,2 3 4 5 6,$(call iif,$(USE_ROFS$(rofs)),deldir | $(ROFS$(rofs)_I2FDIR) |)) -BUILD_VARIANTI2F =\ - $(foreach rofs,2 3 4 5 6,$(call iif,$(USE_ROFS$(rofs)),\ - $(call _buildi2file,ROFS$(rofs),$(ROFS$(rofs)_I2FDIR),$(ROFS$(rofs)_IMG)))) +WIDGET_TOOLDIR = $(E32TOOLS)/widget_tools +WIDGET_TOOL = $(WIDGET_TOOLDIR)/widgetpreinstaller/installwidgets.pl +WIDGET_DIR = $(VARIANT_WGZDIR) +WIDGET_TMPDIR = $(OUTTMPDIR)/widget +WIDGET_OUTDIR = $(VARIANT_OUTDIR) +WIDGET_IDIR = $(WIDGET_DIR) $(VARIANT_DIR) $(FEATVAR_IDIR) +WIDGET_INI = $(call findfile,widget_config.ini,$(WIDGET_IDIR),1) +WIDGET_CFGINI = $(IMAGE_PREFIX)_widget.ini +WIDGET_LANGOPT = $(LANGPACK_DEFLANGID) +WIDGET_OPT = -verbose $(if $(filter debug 127,$(VERBOSE)),-debug) -epocroot "$(WIDGET_TMPDIR)" $(call iif,$(WIDGET_LANGOPT),-localization $(WIDGET_LANGOPT)) +WIDGET_CMD = $(PERL) $(WIDGET_TOOL) $(WIDGET_OPT) "$(WIDGET_CFGINI)" + +define WIDGET_HDRINFO + # Generated configuration file for Widget pre-installation + # + # Filename: $(WIDGET_CFGINI) + # Command : $(WIDGET_CMD) + + $(if $(WIDGET_INI),,[drive-$(call lcase,$($(IMAGE_TYPE)_DRIVE))]) +endef + +WIDGET_HSINI = $(IMAGE_PREFIX)_hsplugin.ini +WIDGET_HSCINI = $(IMAGE_PREFIX)_hsplugincwrt.ini +WIDGET_HSOPT = "$(WIDGET_TMPDIR)" "$(WIDGET_HSINI)" +WIDGET_HSCOPT = "$(WIDGET_TMPDIR)" "$(WIDGET_HSCINI)" +WIDGET_HSCMD = $(call iif,$(USE_UNIX),,call )$(WIDGET_TOOLDIR)/hspluginpreinstaller/HSPluginPreInstaller $(WIDGET_HSOPT) +WIDGET_HSCCMD = $(call iif,$(USE_UNIX),,call )$(WIDGET_TOOLDIR)/hspluginpreinstaller/HSPluginPreInstaller $(WIDGET_HSCOPT) + +WIDGET_HSVIEWDIR = $(if $(VARIANT_CPDIR),$(wildcard $(subst \,/,$(VARIANT_CPDIR))/private/200159c0/install)) +WIDGET_HSWIDEDIR = $(E32DATAZ)/private/200159c0/install/wideimage_2001f489 +WIDGET_HSOUTDIR = $(subst \,/,$(WIDGET_OUTDIR))/private/200159c0/install + +define WIDGET_HSINFO + # Generated configuration file for Home Screen plugin pre-installation for$(if $1, $1) widgets + # + # Filename: $(WIDGET_HS$(if $1,C)INI) + # Command : $(WIDGET_HS$(if $1,C)CMD) + + WIDGET_REGISTRY_PATH=$(subst \,/,$(WIDGET_OUTDIR))/private/10282f06/$1WidgetEntryStore.xml + + VIEW_CONFIGURATION_PATH=$(WIDGET_HSVIEWDIR) + + WIDEIMAGE_PATH=$(WIDGET_HSWIDEDIR) + + OUTPUT_DIR=$(WIDGET_HSOUTDIR) +endef + +CLEAN_WIDGET =\ + del | "$(WIDGET_CFGINI)" "$(WIDGET_HSINI)" "$(WIDGET_HSCINI)" |\ + deldir | "$(WIDGET_TMPDIR)" + +BUILD_WIDGET =\ + echo-q | Installing widget(s) |\ + genwgzcfg | $(WIDGET_CFGINI) | $(WIDGET_INI) | $(WIDGET_DIR) | $(call def2str,$(WIDGET_HDRINFO)) |\ + $(and $(WIDGET_HSINFO),$(WIDGET_HSVIEWDIR),\ + write | "$(WIDGET_HSINI)" | $(call def2str,$(call WIDGET_HSINFO))\n |\ + write | "$(WIDGET_HSCINI)" | $(call def2str,$(call WIDGET_HSINFO,CWRT))\n |)\ + mkdir | "$(WIDGET_TMPDIR)" |\ + cmd | (cd $(call pathconv,$(WIDGET_TMPDIR))) & $(WIDGET_CMD) |\ + copydir | "$(WIDGET_TMPDIR)/epoc32/$(if $(filter CORE ROFS%,$(IMAGE_TYPE)),release/winscw/udeb/z,winscw/?)" |\ + $(WIDGET_OUTDIR) |\ + $(and $(WIDGET_HSINFO),$(WIDGET_HSVIEWDIR),\ + mkdir | "$(WIDGET_HSOUTDIR)" |\ + cmd | $(WIDGET_HSCMD) |\ + cmd | $(WIDGET_HSCCMD) |)\ + $(call iif,$(KEEPTEMP),,deldir | "$(WIDGET_TMPDIR)") + + +############################################################################### +# Data package 2.0 creation / iCreatorDP + +#USE_DPGEN = 0 -CLEAN_I2FILE = deldir | $(I2FILE_DIR) | $(CLEAN_COREI2F) | $(CLEAN_VARIANTI2F) -BUILD_I2FILE =\ - $(BUILD_COREI2F) | $(BUILD_VARIANTI2F) |\ - copy | $(CORE_I2FDIR)/* | $(I2FILE_DIR) |\ - $(foreach rofs,2 3 4 5 6,$(call iif,$(USE_ROFS$(rofs)),copy | $(ROFS$(rofs)_I2FDIR)/* | $(I2FILE_DIR) |)) +ICDP_TOOL = iCreatorDP.py +ICDP_TOOLDIR = $(EPOC_ROOT)/iCreatorDP +ICDP_OPT = --xcfs="$(ICDP_XCF)" --wa="$(ICDP_WRKDIR)" --ba="$(ICDP_BLDDIR)" --i="$(ICDP_IMGDIR)" --build +ICDP_OUTDIR = $(EPOC_ROOT)/output +ICDP_XCF = $(ICDP_OUTDIR)/griffin.xcf +ICDP_WRKDIR = $(ICDP_OUTDIR)/DP_WA +ICDP_BLDDIR = $(ICDP_OUTDIR)/DP_OUT +ICDP_IMGDIR = $(ICDP_OUTDIR)/images +ICDP_VPLDIR = $(ICDP_OUTDIR)/VPL +ICDP_CMD = $(PYTHON) $(ICDP_TOOL) $(ICDP_OPT) + +ICDP_CUSTIMG = $(ICDP_IMGDIR)/customer.fpsx +ICDP_UDAIMG = $(ICDP_IMGDIR)/customer_uda.fpsx + +#ICDP_IMGLIST = "$(ICDP_IMGDIR)/customer.fpsx" "$(ICDP_IMGDIR)/customer_uda.fpsx" + +CLEAN_DPPRE = $(CLEAN_CONEXCF) | del | "$(ICDP_CUSTIMG)" +BUILD_DPPRE =\ + $(BUILD_CONEXCF) |\ + echo-q | Copying images |\ + mkdir | "$(ICDP_IMGDIR)" |\ + copy | "$(ROFS3_FLASH)" | $(ICDP_CUSTIMG) |\ +# copy | $(UDA_FLASH) | $(ICDP_UDAIMG) + +CLEAN_DPBLD = deldir | "$(ICDP_BLDDIR)" +BUILD_DPBLD =\ + echo-q | Generating data package |\ + cd | "$(ICDP_TOOLDIR)" |\ + cmd | $(ICDP_CMD) + +CLEAN_DPPOST = deldir | "$(ICDP_VPLDIR)" +BUILD_DPPOST =\ + find-r | "$(ICDP_BLDDIR)" | *.zip | |\ + unzip | __find__ | $(ICDP_VPLDIR) + +#============================================================================== + +.PHONY: datapack datapack-pre + +datapack : ;@$(call IMAKER,$$(call iif,$$(SKIPPRE),,DPPRE) $$(call iif,$$(SKIPBLD),,DPBLD) $$(call iif,$$(SKIPPOST),,DPPOST)) +datapack-pre: ;@$(call IMAKER,DPPRE) + + +############################################################################### +# Data package copying functionality for Griffin + +#DP_SRCDIR = $(EPOC_ROOT)/output/images +DP_CORESRC = +DP_LANGSRC = +DP_CUSTSRC = +DP_UDASRC = +DP_DCPSRC = +DP_VPLSRC = +DP_SIGNSRC = + +DP_OUTDIR = $(EPOC_ROOT)/output/VPL +DP_CORETGT = $(DP_OUTDIR)/core.fpsx +DP_LANGTGT = $(DP_OUTDIR)/lang.fpsx +DP_CUSTTGT = $(DP_OUTDIR)/customer.fpsx +DP_UDATGT = $(DP_OUTDIR)/uda.fpsx +DP_DCPTGT = $(DP_OUTDIR)/carbidev.dcp +DP_VPLTGT = $(DP_OUTDIR)/carbidev.vpl +DP_SIGNTGT = $(DP_OUTDIR)/carbidev_signature.bin -_buildi2file =\ - echo-q | Extracting files from $($1_TITLE) SOS image to $2 |\ - mkcd | $2 |\ - $(foreach img,$3,\ - cmd | $(READIMG_TOOL) -s $(img) |\ - cmd | $(READIMG_TOOL) -z . $(img) |) +DP_MK = $(OUTPREFIX)_dpcopy.mk +DP_MKLOG = $(basename $(DP_MK))_cone.log +DP_MKOPT =\ + generate --project="$(CONE_PRJ)" $(if $(CONE_CONF),--configuration="$(CONE_CONF)")\ + --impl=dp.makeml --all-layers --set=imaker.makefilename="$(DP_MK)"\ + --log-file="$(DP_MKLOG)" $(addprefix --verbose=,$(CONE_VERBOSE)) +DP_MKCMD = $(CONE_TOOL) $(DP_MKOPT) + +CLEAN_DPCOPYPRE = del | "$(DP_MK)" "$(DP_MKLOG)" +BUILD_DPCOPYPRE =\ + echo-q | Generating makefile `$(DP_MK)' for Data Package copy |\ + cmd | $(DP_MKCMD) |\ + test | "$(DP_MK)" + +CLEAN_DPCOPY = deldir | "$(DP_OUTDIR)" + +BUILD_DPCOPY =\ + echo-q | Copying Data Package contents |\ + mkdir | "$(DP_OUTDIR)" |\ + $(foreach type,CORE LANG CUST UDA DCP VPL SIGN,\ + copy | "$(DP_$(type)SRC)" | $(DP_$(type)TGT) |) + +#============================================================================== + +.PHONY: dpcopy dpcopy-pre + +dpcopy : ;@$(call IMAKER,DPCOPY) +dpcopy-pre: ;@$(call IMAKER,DPCOPYPRE) + + +############################################################################### +# PlatSim + +USE_PLATSIM = 0 + +PLATSIM_TOOL = pscli.exe +PLATSIM_TOOLDIR = /rd_sw/platsim +PLATSIM_TOOL_INSTANCESDIR = $(PLATSIM_TOOLDIR)/instances +PLATSIM_IMAGESDIR = $(PLATSIM_TOOLDIR)/HW77/images +PLATSIM_INSTANCE = 1 +RUN_PLATSIM = 0 +PLATSIM_IMAGES = $(CORE_FLASH) +PLATSIM_IMAGESRC = $(patsubst %\,%,$(call pathconv,$(dir $(PLATSIM_IMAGES)))) + +PLATSIM_INSTANCES = $(notdir $(foreach entry,$(wildcard $(PLATSIM_TOOL_INSTANCESDIR)/*),$(call isdir,$(entry)))) +define isdir +$(if $(wildcard $1/*),$1) +endef + +BUILD_PLATLAUNCH =\ + echo-q | Launching PlatSim instance $(PLATSIM_INSTANCE) |\ + cd | $(PLATSIM_TOOLDIR) |\ + cmd | $(PLATSIM_TOOL) --launch $(PLATSIM_INSTANCE) + +BUILD_PLATSHUTDOWN =\ + echo-q | Stopping PlatSim instance $(PLATSIM_INSTANCE) |\ + cd | $(PLATSIM_TOOLDIR) |\ + cmd | $(PLATSIM_TOOL) --console --shutdown $(PLATSIM_INSTANCE) + +BUILD_PLATCREATE =\ + echo-q | Creating new PlatSim instance $(PLATSIM_INSTANCE) |\ + cmd | $(PLATSIM_TOOL) --console --create $(PLATSIM_INSTANCE) |\ + cmd | $(PLATSIM_TOOL) --set $(PLATSIM_INSTANCE):imaker_$(PLATSIM_INSTANCE) + +BUILD_PLATUPDATE =\ + echo-q | Updating PlatSim instance $(PLATSIM_INSTANCE) |\ + cmd | $(PLATSIM_TOOL) --console --set $(PLATSIM_INSTANCE):$(PLATSIM_IMAGESRC):$(notdir $(PLATSIM_IMAGES)) + +BUILD_PLATBLD =\ + cd | $(PLATSIM_TOOLDIR) |\ + $(if $(filter $(PLATSIM_INSTANCE),$(PLATSIM_INSTANCES)),\ + echo-q | Platsim instance $(PLATSIM_INSTANCE) exists | $(BUILD_PLATSHUTDOWN),\ + $(BUILD_PLATCREATE)) |\ + $(BUILD_PLATUPDATE) |\ + $(call iif,$(RUN_PLATSIM),$(BUILD_PLATLAUNCH)) + +$(call add_help,USE_PLATSIM,v,(string),Define that the configuration is a PlatSim configuration.) ############################################################################### @@ -269,7 +683,6 @@ $(IMGCHK_TOOL) | $(IMGCHK_TOOL) -h | IMGCHECK.+? V(.+?)\s*$$ | $(INTPRSIS_TOOL) | $(INTPRSIS_TOOL) -h | INTERPRETSIS\s+Version\s+(.+?)\s*$$ | $(READIMG_TOOL) | $(READIMG_TOOL) | Readimage.+? V(.+?)\s*$$ | - $(CONFT_TOOL) | $(CONFT_TOOL) -version | ^.+?\n(.+?)\n(.+?)\n endef BUILD_TOOLINFO = echo-q | | toolchk | $(strip $(TOOL_INFO)) | end @@ -282,9 +695,9 @@ ############################################################################### # Targets -.PHONY: checkdep opcache sisinst toolinfo wgzpreinst +.PHONY: checkdep opcache sisinst toolinfo -chkdep opcache sisinst toolinfo wgzpreinst:\ +chkdep opcache sisinst toolinfo:\ ;@$(call IMAKER,$(call ucase,$@)) diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_uda.mk --- a/imgtools/imaker/src/imaker_uda.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_uda.mk Wed Jun 30 11:35:58 2010 +0800 @@ -23,205 +23,11 @@ # \___/|___/_/ \_\ # -USE_FILEDISK = 0 -USE_SOSUDA = 0 -USE_UDAFGEN = 0 - -UDA_TITLE = UDA -UDA_DIR = $(WORKDIR)/uda -UDA_NAME = $(NAME) -UDA_PREFIX = $(UDA_DIR)/$(UDA_NAME) -UDA_IDIR = -UDA_HBY = -UDA_OBY = -UDA_OPT = $(BLDROM_OPT) -D_EABI=$(ARM_VERSION) -UDA_MSTOBY = $(UDA_PREFIX)_uda_master.oby -UDA_HEADER = -UDA_INLINE = -UDA_FOOTER = -UDA_TIME = $(DAY)/$(MONTH)/$(YEAR) - -UDA_CPDIR = -UDA_ZIP = -UDA_DATADIR = $(UDA_DIR)/datadrive -UDA_SISCONFFILE = $(UDA_PREFIX)_uda_sisconf.txt -UDA_SISCONF =\ - -d $(UDA_DRIVE): -c $(UDA_DATADIR) $(if $(SISINST_SISDIR),-s $(SISINST_SISDIR))\ - -z $(SISINST_ZDIR) $(if $(SISINST_HALINI),-i $(SISINST_HALINI)) -w info - -UDA_VERSION = $(CORE_VERSION) -UDA_SWVERFILE = "$(UDA_DATADIR)/Resource/Versions/User Content Package_UDA.txt" -UDA_SWVERINFO = $(UDA_VERSION) -UDA_EXCLFILE = $(UDA_DATADIR)/private/100059C9/excludelist.txt -UDA_TOUCH = $(call iif,$(USE_SOSUDA),,$(YEAR)$(MONTH)$(DAY)000000) - -UDA_IMG = $(UDA_PREFIX).uda.img -UDA_LOG = $(UDA_PREFIX).uda.log -UDA_OUTOBY = $(UDA_PREFIX).uda.oby -UDA_EMPTYIMG = $(UDA_PREFIX).udaempty.img - -UDA_PLUGINLOG = $(UDA_PREFIX)_uda_bldromplugin.log -UDA_UDEBFILE = $(TRACE_UDEBFILE) - UDA_DRIVE = C -UDA_FATTYPE = fat16 -UDA_FATSIZE = 20480 - -define UDA_EXCLADD -* -endef - -define UDA_EXCLRM -endef - -#============================================================================== - -UDA_FDISKCONF = /mount 0 -UDA_FDISKCMD =\ - $(FILEDISK_TOOL) $(UDA_FDISKCONF) $(call peval,GetAbsFname($(call pquote,$(UDA_IMG)),1,1)) $(call peval,$$iVar[0] = GetFreeDrive()) |\ - copy | $(UDA_DATADIR)/* | $(call peval,$$iVar[0])/ |\ - cmd | $(FILEDISK_TOOL) /status $(call peval,$$iVar[0]) |\ - sleep | 1 |\ - cmd | $(FILEDISK_TOOL) /umount $(call peval,$$iVar[0]) - -UDA_WINIMGCMD = $(WINIMAGE_TOOL) $(call pathconv,$(UDA_IMG)) /i $(call pathconv,$(UDA_DATADIR)) /h /q - -UDA_CMD = $(call iif,$(USE_FILEDISK),$(UDA_FDISKCMD),$(UDA_WINIMGCMD)) -UDA_EMPTYCMD = - -#============================================================================== - -define UDA_MSTOBYINFO - $(BLDROM_HDRINFO) - - ROM_IMAGE 0 non-xip size=0x00000000 - - DATA_IMAGE 0 $(basename $(UDA_IMG)) size=$(call peval,$(UDA_FATSIZE) * 1024) $(UDA_FATTYPE) - - // UDA header - // - $(UDA_HDRINFO) - - DATA_IMAGE[0] { - $(BLR.UDA.OBY) - $(UDA_INLINE) - $(UDA_FOOTERINFO) - } -endef - -define UDA_HDRINFO - $(DEFINE) _IMAGE_WORKDIR $(UDA_DIR) - $(call mac2cppdef,$(BLR.UDA.OPT)) - $(BLR.UDA.HBY) - $(UDA_HEADER) - $(if $(filter u U,$(USE_VARIANTBLD)),$(VARIANT_HEADER)) -endef - -define UDA_FOOTERINFO - $(if $(UDA_TIME),time=$(UDA_TIME)) - $(UDA_FOOTER) -endef - -#============================================================================== - -CLEAN_UDAFILE =\ - del | "$(UDA_MSTOBY)" "$(UDA_SISCONFFILE)" "$(UDA_SWVERFILE)" "$(UDA_EXCLFILE)" - -BUILD_UDAFILE =\ - echo-q | Generating file(s) for UDA image creation |\ - $(call iif,$(USE_SOSUDA),\ - write | $(UDA_MSTOBY) | $(call def2str,$(UDA_MSTOBYINFO)) |\ - write | $(UDA_SISCONFFILE) | $(call quote,$(UDA_SISCONF)) |)\ - $(call iif,$(USE_UDAFGEN),\ - $(if $(UDA_SWVERINFO),\ - writeu | $(UDA_SWVERFILE) | $(UDA_SWVERINFO) |)\ - $(if $(UDA_EXCLFILE),\ - genexclst | $(UDA_EXCLFILE) | $(UDA_DATADIR) | $(UDA_DRIVE):/ |\ - "$(subst $(\n)," ",$(UDA_EXCLADD))" | "$(subst $(\n)," ",$(UDA_EXCLRM))")\ - ) - - -############################################################################### -# UDA pre - -CLEAN_UDAPRE = $(if $(filter u U,$(USE_VARIANTBLD)),$(CLEAN_CUSTVARIANT),deldir | $(UDA_DATADIR)) | $(CLEAN_UDAFILE) - -BUILD_UDAPRE =\ - echo-q | Preparing UDA image creation |\ - $(if $(filter u U,$(USE_VARIANTBLD)),$(BUILD_CUSTVARIANT) |,\ - mkdir | $(UDA_DATADIR) |\ - $(if $(UDA_ZIP),\ - $(eval __i_zip := $(foreach zip,$(UDA_ZIP),$(zip)$(if $(filter %.zip,$(call lcase,$(zip))),,/*.zip)))\ - echo-q | Extracting `$(__i_zip)$' to `$(UDA_DATADIR)$' |\ - unzip | $(__i_zip) | $(UDA_DATADIR) |)\ - $(if $(UDA_CPDIR),\ - copy | $(UDA_CPDIR)/* | $(UDA_DATADIR) |))\ - mkcd | $(UDA_DIR) |\ - $(BUILD_UDAFILE) |\ - $(call iif,$(USE_FILEDISK),\ - cmd | attrib -r -a -s -h $(call pathconv,$(UDA_DATADIR)) /s /d |)\ - $(if $(UDA_TOUCH),\ - finddir-r | $(UDA_DATADIR) | * | |\ - find-ar | $(UDA_DATADIR) | * | |\ - touch | __find__ | $(UDA_TOUCH)) - -#============================================================================== -# UDA build - -BLR.UDA.IDIR = $(call dir2inc,$(UDA_IDIR) $(call iif,$(USE_FEATVAR),,$(FEATVAR_IDIR))) -BLR.UDA.HBY = $(call includeiby,$(IMAGE_HBY) $(UDA_HBY)) -BLR.UDA.OBY = $(call includeiby,$(UDA_OBY) $(if $(filter u U,$(USE_VARIANTBLD)),$(VARIANT_OBY))) -BLR.UDA.OPT = $(UDA_OPT) -p -retainfolder -pfile=$(UDA_SISCONFFILE) -o$(UDA_NAME).dummy0.img $(BLDROPT) -BLR.UDA.POST =\ - move | $(UDA_OUTOBY).log | $(UDA_LOG) - -BLR.UDA.CLEAN = del | "$(UDA_EMPTYIMG)" "$(UDA_IMG)" -BLR.UDA.BUILD =\ - $(call iif,$(USE_SOSUDA),,\ - echo-q | Creating $(UDA_TITLE) SOS image |\ - $(if $(UDA_EMPTYCMD),\ - cmd | $(UDA_EMPTYCMD) |\ - move | $(UDA_EMPTYIMG) | $(UDA_IMG) |)\ - cmd | $(UDA_CMD)) - -CLEAN_UDA = $(CLEAN_BLDROM) -BUILD_UDA = $(BUILD_BLDROM) - -# UDA Empty -# -CLEAN_UDAEMPTY = del | $(UDA_EMPTYIMG) -BUILD_UDAEMPTY =\ - echo-q | Creating empty UDA FAT image |\ - mkdir | $(UDA_DIR) |\ - cmd | $(UDA_EMPTYCMD) - -#============================================================================== -# UDA post - -#============================================================================== - -SOS.UDA.STEPS = $(call iif,$(SKIPPRE),,UDAPRE) UDA $(SOS.UDAEMPTY.STEPS) -SOS.UDAEMPTY.STEPS = UDAEMPTY - -ALL.UDA.STEPS = $(SOS.UDA.STEPS) -ALL.UDAEMPTY.STEPS = $(SOS.UDAEMPTY.STEPS) - -#============================================================================== - -.PHONY: uda uda-image uda-pre uda-empty uda-empty-image variantuda - -uda uda-%: IMAGE_TYPE = UDA - -uda : ;@$(call IMAKER,$$(ALL.UDA.STEPS)) -uda-image: ;@$(call IMAKER,$$(SOS.UDA.STEPS)) -uda-pre : ;@$(call IMAKER,UDAPRE) - -uda-empty: ;@$(call IMAKER,$$(ALL.UDAEMPTY.STEPS)) -uda-empty-image: ;@$(call IMAKER,$$(SOS.UDAEMPTY.STEPS)) - -variantuda variantuda%: USE_CUSTVARIANTBLD = 1 -variantuda variantuda%: USE_VARIANTBLD = u -variantuda variantuda%: uda$(TARGETEXT) ; +UDA_FATTYPE = 16# FAT16 +UDA_SIZE = 20480# kB +UDA_CLUSTERSIZE = 4# kB +UDA_FATTABLE = 1 # END OF IMAKER_UDA.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_variant.mk --- a/imgtools/imaker/src/imaker_variant.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_variant.mk Wed Jun 30 11:35:58 2010 +0800 @@ -11,7 +11,7 @@ # # Contributors: # -# Description: iMaker Variant image configuration +# Description: iMaker Variant Build image configuration # @@ -25,107 +25,82 @@ USE_VARIANTBLD = 0 +PRODUCT_VARDIR = $(if $(and $(call true,$(USE_CONE)),$(call true,$(IMAKER_MKRESTARTS))),$(CONE_OUTDIR),$(PRODUCT_DIR)) + VARIANT_NAME = $(TARGETNAME) VARIANT_ID = $(TARGETID) -VARIANT_DIR = $(call iif,$(USE_CUSTVARIANTBLD),,$(PRODVARIANT_DIR)) -VARIANT_OUTDIR = $(if $(filter u U,$(USE_VARIANTBLD)),$(UDA_DATADIR),$($(IMAGE_TYPE)_DIR)/variant) +VARIANT_DIR = $(if $(filter $(LANGPACK_PREFIX)%,$(TARGETNAME)),$(LANGPACK_DIR),$(if\ + $(filter $(CUSTVARIANT_PREFIX)%,$(TARGETNAME)),$(CUSTVARIANT_DIR),$(if\ + $(filter emmc_% mcard_% uda_%,$(TARGETNAME)),$($(IMAGE_TYPE)_VARDIR),$(if\ + $(filter variant%,$(TARGETNAME)),,$(PRODUCT_VARDIR))))) +VARIANT_OUTDIR = $(if $(filter CORE ROFS%,$(IMAGE_TYPE)),$($(IMAGE_TYPE)_DIR)/variant,$($(IMAGE_TYPE)_DATADIR)) VARIANT_MKNAME = variant.mk VARIANT_MK = $(if $(VARIANT_DIR),$(wildcard $(VARIANT_DIR)/$(VARIANT_MKNAME))) -VARIANT_PREFIX = $($(IMAGE_TYPE)_PREFIX)_$(call lcase,$(IMAGE_TYPE)) -VARIANT_HBY = $(VARIANT_PREFIX)_customervariant.hby +VARIANT_HBY = $(IMAGE_PREFIX)_$(if $(filter CORE ROFS%,$(IMAGE_TYPE)),variant,datadrive).hby VARIANT_HEADER = $(if $(VARIANT_INCDIR),$(call includeiby,$(VARIANT_HBY))) -VARIANT_OBY = $(VARIANT_PREFIX)_customervariant.oby -VARIANT_OVERRIDE = $(if $(filter 1 2,$(USE_VARIANTBLD)),1,0) -VARIANT_OBYDATA = data$(call iif,$(VARIANT_OVERRIDE),-override)="%1" "%2" +VARIANT_OBY = $(basename $(VARIANT_HBY)).oby +VARIANT_OVERRIDE = $(if $(filter CORE ROFS%,$(IMAGE_TYPE)),OVERRIDE_REPLACE/ADD) +VARIANT_OBYDATA = data$(call iif,$(VARIANT_OVERRIDE),-override)="%1" "%2"$(if $(filter CORE ROFS%,$(IMAGE_TYPE)),, %4) -VARIANT_CONFML = $(call iif,$(USE_CUSTVARIANTBLD),$(wildcard $(VARIANT_DIR)/$(CONFT_CFGNAME).confml),$(PRODVARIANT_CONFML)) -VARIANT_CONFCP = $(call iif,$(USE_CUSTVARIANTBLD),$(if $(VARIANT_CONFML),$(CONFT_CFGNAME)),$(PRODVARIANT_CONFCP)) -VARIANT_CPDIR = $(wildcard $(VARIANT_DIR)/content) -VARIANT_INCDIR = $(wildcard $(VARIANT_DIR)/include) -VARIANT_SISDIR = $(wildcard $(VARIANT_DIR)/sis) -VARIANT_OPCDIR = $(wildcard $(VARIANT_DIR)/opcache) -VARIANT_ZIPDIR = $(wildcard $(VARIANT_DIR)/zip) +VARIANT_CPDIR = $(if $(wildcard $(VARIANT_DIR)/content/*),$(VARIANT_DIR)/content) +VARIANT_INCDIR = $(if $(wildcard $(VARIANT_DIR)/include/*),$(VARIANT_DIR)/include) +VARIANT_SISDIR = $(if $(wildcard $(VARIANT_DIR)/sis/*),$(VARIANT_DIR)/sis) +VARIANT_OPCDIR = $(if $(wildcard $(VARIANT_DIR)/opcache/*),$(VARIANT_DIR)/opcache) +VARIANT_WGZDIR = $(if $(wildcard $(VARIANT_DIR)/widget/*),$(VARIANT_DIR)/widget) +VARIANT_ZIPDIR = $(if $(wildcard $(VARIANT_DIR)/zip/*),$(VARIANT_DIR)/zip) #============================================================================== -CLEAN_CUSTVARIANT =\ - del | "$(VARIANT_HBY)" "$(VARIANT_OBY)" | deldir | $(VARIANT_OUTDIR) |\ - $(if $(VARIANT_CONFML),$(CLEAN_CENREP) |)\ - $(if $(VARIANT_SISDIR),$(CLEAN_SISINST) |)\ - $(if $(VARIANT_OPCDIR),$(CLEAN_OPCACHE) |) +CLEAN_VARIANT =\ + del | "$(VARIANT_HBY)" "$(VARIANT_OBY)" | deldir | "$(VARIANT_OUTDIR)" |\ + $(CLEAN_SISINST) | $(CLEAN_OPCACHE) | $(CLEAN_WIDGET) -BUILD_CUSTVARIANT =\ - echo-q | Variant target USE_VARIANTBLD = $(call iif,$(USE_VARIANTBLD),`$(USE_VARIANTBLD)$',-) |\ - echo-q | Variant directory VARIANT_DIR = $(or $(filter -,$(VARIANT_DIR)),$(if $(VARIANT_DIR),`$(VARIANT_DIR)$',-)) |\ - echo-q | Variant config makefile VARIANT_MK = $(if $(VARIANT_MK),`$(VARIANT_MK)$',-) |\ - echo-q | Variant include directory VARIANT_INCDIR = $(if $(VARIANT_INCDIR),`$(VARIANT_INCDIR)$',-) |\ - echo-q | Variant confml file VARIANT_CONFML = $(if $(VARIANT_CONFML),`$(VARIANT_CONFML)$',-) |\ - echo-q | Variant CenRep configs VARIANT_CONFCP = $(if $(VARIANT_CONFCP),`$(VARIANT_CONFCP)$',-) |\ - echo-q | Variant SIS directory VARIANT_SISDIR = $(if $(VARIANT_SISDIR),`$(VARIANT_SISDIR)$',-) |\ - echo-q | Variant operator cache dir VARIANT_OPCDIR = $(if $(VARIANT_OPCDIR),`$(VARIANT_OPCDIR)$',-) |\ - echo-q | Variant zip content dir VARIANT_ZIPDIR = $(if $(VARIANT_ZIPDIR),`$(VARIANT_ZIPDIR)$',-) |\ - echo-q | Variant copy content dir VARIANT_CPDIR = $(if $(VARIANT_CPDIR),`$(VARIANT_CPDIR)$',-) |\ - echo-q | Variant output directory VARIANT_OUTDIR = $(if $(VARIANT_OUTDIR),`$(VARIANT_OUTDIR)$',-) |\ +BUILD_VARIANT =\ + echo-q | Variant target USE_VARIANTBLD = $(call iif,$(USE_VARIANTBLD),`$(USE_VARIANTBLD)',-) |\ + echo-q | Variant directory VARIANT_DIR = $(or $(filter -,$(VARIANT_DIR)),$(if $(VARIANT_DIR),`$(VARIANT_DIR)',-)) |\ + echo-q | Variant config makefile VARIANT_MK = $(if $(VARIANT_MK),`$(VARIANT_MK)',-) |\ + echo-q | Variant include directory VARIANT_INCDIR = $(if $(VARIANT_INCDIR),`$(VARIANT_INCDIR)',-) |\ + echo-q | Variant SIS conf SISINST_INI = $(if $(SISINST_INI),`$(SISINST_INI)',-) |\ + echo-q | Variant SIS directory VARIANT_SISDIR = $(if $(VARIANT_SISDIR),`$(VARIANT_SISDIR)',-) |\ + echo-q | Variant operator cache conf OPC_INI = $(if $(OPC_INI),`$(OPC_INI)',-) |\ + echo-q | Variant operator cache dir VARIANT_OPCDIR = $(if $(VARIANT_OPCDIR),`$(VARIANT_OPCDIR)',-) |\ + echo-q | Variant widget preinst conf WIDGET_INI = $(if $(WIDGET_INI),`$(WIDGET_INI)',-) |\ + echo-q | Variant widget preinst dir VARIANT_WGZDIR = $(if $(VARIANT_WGZDIR),`$(VARIANT_WGZDIR)',-) |\ + echo-q | Variant zip content dir VARIANT_ZIPDIR = $(if $(VARIANT_ZIPDIR),`$(VARIANT_ZIPDIR)',-) |\ + echo-q | Variant copy content dir VARIANT_CPDIR = $(if $(VARIANT_CPDIR),`$(VARIANT_CPDIR)',-) |\ + echo-q | Variant output directory VARIANT_OUTDIR = $(if $(VARIANT_OUTDIR),`$(VARIANT_OUTDIR)',-) |\ $(if $(VARIANT_DIR),,\ - error | 1 | Variable VARIANT_DIR is not set while making target $@!\n |)\ - $(if $(word 2,$(USE_VARIANTBLD))$(filter-out 0 1 2 3 4 5 6 u U,$(USE_VARIANTBLD)),\ - error | 1 | Variable USE_VARIANTBLD is incorrectly defined. Possible values are 1 - 3 (6) and u.\n |)\ - mkdir | $(VARIANT_OUTDIR) |\ + error | 1 | Variable VARIANT_DIR is not set while making target $(TARGETNAME). |)\ + $(if $(wildcard $(subst \,/,$(VARIANT_DIR))),,\ + error | 1 | Variable VARIANT_DIR does not point to an existing directory ($(VARIANT_DIR)). |)\ + $(if $(word 2,$(USE_VARIANTBLD))$(filter-out 0 1 2 3 4 5 6 e E m M u U,$(USE_VARIANTBLD)),\ + error | 1 | Variable USE_VARIANTBLD is incorrectly defined. Possible values are 1 - 6$(,) e$(,) m and u. |)\ + mkdir | "$(VARIANT_OUTDIR)" |\ $(if $(VARIANT_INCDIR),\ echo-q | Generating oby(s) for Variant image creation |\ - geniby | $(VARIANT_HBY) | $(VARIANT_INCDIR) | *.hrh | \#include "%3" | end |\ + geniby | $(VARIANT_HBY) | $(VARIANT_INCDIR) |\ + __header__ | define _IMAGE_VARINCDIR $(call quote,$(VARIANT_INCDIR)) | *.hrh | \#include "%3" | end |\ geniby | $(VARIANT_OBY) | $(VARIANT_INCDIR) | *.iby | \#include "%3" | end |)\ - $(if $(wildcard $(VARIANT_CONFML)),\ - $(BUILD_CENREP) |)\ - $(if $(VARIANT_SISDIR),\ - $(call iif,$(USE_SOSUDA),\ - geniby-r | >>$(VARIANT_OBY) | $(VARIANT_SISDIR) | *.sis* | sisfile="%1" | end,\ - $(BUILD_SISINST)) |)\ - $(if $(VARIANT_OPCDIR),\ + $(if $(or $(SISINST_INI),$(VARIANT_SISDIR)),\ + $(BUILD_SISINST) |)\ + $(if $(or $(OPC_INI),$(VARIANT_OPCDIR)),\ $(BUILD_OPCACHE) |)\ - $(if $(VARIANT_ZIPDIR),$(if $(wildcard $(VARIANT_ZIPDIR)/*),\ + $(if $(or $(WIDGET_INI),$(VARIANT_WGZDIR)),\ + $(BUILD_WIDGET) |)\ + $(if $(VARIANT_ZIPDIR),\ echo-q | Extracting zip content directory |\ - cmd | $(7ZIP_TOOL) x -y $(VARIANT_ZIPDIR)/* -o$(VARIANT_OUTDIR) |))\ + cmd | $(7ZIP_TOOL) x -y $(VARIANT_ZIPDIR)/* -o$(VARIANT_OUTDIR) |)\ $(if $(VARIANT_CPDIR),\ - echo-q | Copying copy content directory |\ - copy | $(VARIANT_CPDIR)/* | $(VARIANT_OUTDIR) |)\ - $(if $(filter u U,$(USE_VARIANTBLD)),,\ - geniby-r | >>$(VARIANT_OBY) | $(VARIANT_OUTDIR) | * | $(VARIANT_OBYDATA) | end |)\ - write | >>$(VARIANT_OBY) | | - -#============================================================================== - -variantrofs%: USE_CUSTVARIANTBLD = 1 + echo-q | Copying copy content directory |\ + copydir | "$(VARIANT_CPDIR)" | $(VARIANT_OUTDIR) |)\ + $(call iif,$(filter CORE ROFS%,$(IMAGE_TYPE))$(USE_SOSUDA),\ + geniby-r | >>$(VARIANT_OBY) | $(VARIANT_OUTDIR) |\ + $(call iif,$(VARIANT_OVERRIDE),__header__ | $(VARIANT_OVERRIDE) |)\ + * | $(VARIANT_OBYDATA) |\ + $(call iif,$(VARIANT_OVERRIDE),__footer__ | OVERRIDE_END |) end) -$(foreach rofs,2 3 4 5 6,\ - $(eval .PHONY: variantrofs$(rofs))\ - $(eval variantrofs$(rofs) variantrofs$(rofs)%: USE_VARIANTBLD = $(rofs))\ - $(eval variantrofs$(rofs) variantrofs$(rofs)%: rofs$(rofs)$(TARGETEXT) ;)\ -) - -$(call add_help,variantrofs2,t,Create an image from a variant with rofs2. Be sure to define the VARIANT_DIR.) -$(call add_help,variantrofs3,t,Create an image from a customer variant folder. Be sure to define the VARIANT_DIR.) -$(call add_help,variantuda,t,Create an image from a variant userdata folder. Be sure to define the VARIANT_DIR.) - -#============================================================================== - -SOS.VARIANT.STEPS = $(foreach rofs,2 3 4 5 6,$(SOS.ROFS$(rofs).STEPS)) -ALL.VARIANT.STEPS = $(SOS.VARIANT.STEPS) - -#============================================================================== -# Targets - -.PHONY: variant variant-image variant-symbol variant-i2file - -variant: ;@$(call IMAKER,$$(ALL.VARIANT.STEPS)) - -variant-image: ;@$(call IMAKER,$$(SOS.VARIANT.STEPS)) - -variant-symbol:\ - ;@$(call IMAKER,$(foreach rofs,2 3 4 5 6,$(call iif,$(USE_ROFS$(rofs)),ROFS$(rofs)SYM))) - -variant-i2file: ;@$(call IMAKER,VARIANTI2F) +# geniby-dr | >>$(VARIANT_OBY) | $(VARIANT_OUTDIR) | * | dir="%2" | end # END OF IMAKER_VARIANT.MK diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imaker/src/imaker_version.mk --- a/imgtools/imaker/src/imaker_version.mk Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imaker/src/imaker_version.mk Wed Jun 30 11:35:58 2010 +0800 @@ -14,4 +14,4 @@ # Description: iMaker version string # -IMAKER_VERSION = iMaker 09.06.01, 05-Feb-2009. +IMAKER_VERSION = iMaker 10.24.01, 14-Jun-2010. diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/linux/libboost_filesystem-1.39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_filesystem-1.39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/linux/libboost_regex-1.39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_regex-1.39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/linux/libboost_regex-mgw34-mt-p-1_39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_regex-mgw34-mt-p-1_39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/linux/libboost_system-1.39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_system-1.39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/linux/libboost_thread-1.39.a Binary file imgtools/imglib/boostlibrary/binary/linux/libboost_thread-1.39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/windows/libboost_filesystem-1.39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_filesystem-1.39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/windows/libboost_regex-1.39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_regex-1.39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/windows/libboost_regex-mgw34-mt-p-1_39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_regex-mgw34-mt-p-1_39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/windows/libboost_system-1.39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_system-1.39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/binary/windows/libboost_thread-1.39.a Binary file imgtools/imglib/boostlibrary/binary/windows/libboost_thread-1.39.a has changed diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/cerrno.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/cerrno.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,331 @@ +// Boost cerrno.hpp header -------------------------------------------------// + +// Copyright Beman Dawes 2005. +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_CERRNO_HPP +#define BOOST_CERRNO_HPP + +#include + +// supply errno values likely to be missing, particularly on Windows + +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT 9901 +#endif + +#ifndef EADDRINUSE +#define EADDRINUSE 9902 +#endif + +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL 9903 +#endif + +#ifndef EISCONN +#define EISCONN 9904 +#endif + +#ifndef EBADMSG +#define EBADMSG 9905 +#endif + +#ifndef ECONNABORTED +#define ECONNABORTED 9906 +#endif + +#ifndef EALREADY +#define EALREADY 9907 +#endif + +#ifndef ECONNREFUSED +#define ECONNREFUSED 9908 +#endif + +#ifndef ECONNRESET +#define ECONNRESET 9909 +#endif + +#ifndef EDESTADDRREQ +#define EDESTADDRREQ 9910 +#endif + +#ifndef EHOSTUNREACH +#define EHOSTUNREACH 9911 +#endif + +#ifndef EIDRM +#define EIDRM 9912 +#endif + +#ifndef EMSGSIZE +#define EMSGSIZE 9913 +#endif + +#ifndef ENETDOWN +#define ENETDOWN 9914 +#endif + +#ifndef ENETRESET +#define ENETRESET 9915 +#endif + +#ifndef ENETUNREACH +#define ENETUNREACH 9916 +#endif + +#ifndef ENOBUFS +#define ENOBUFS 9917 +#endif + +#ifndef ENOLINK +#define ENOLINK 9918 +#endif + +#ifndef ENODATA +#define ENODATA 9919 +#endif + +#ifndef ENOMSG +#define ENOMSG 9920 +#endif + +#ifndef ENOPROTOOPT +#define ENOPROTOOPT 9921 +#endif + +#ifndef ENOSR +#define ENOSR 9922 +#endif + +#ifndef ENOTSOCK +#define ENOTSOCK 9923 +#endif + +#ifndef ENOSTR +#define ENOSTR 9924 +#endif + +#ifndef ENOTCONN +#define ENOTCONN 9925 +#endif + +#ifndef ENOTSUP +#define ENOTSUP 9926 +#endif + +#ifndef ECANCELED +#define ECANCELED 9927 +#endif + +#ifndef EINPROGRESS +#define EINPROGRESS 9928 +#endif + +#ifndef EOPNOTSUPP +#define EOPNOTSUPP 9929 +#endif + +#ifndef EWOULDBLOCK +#define EWOULDBLOCK 9930 +#endif + +#ifndef EOWNERDEAD +#define EOWNERDEAD 9931 +#endif + +#ifndef EPROTO +#define EPROTO 9932 +#endif + +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT 9933 +#endif + +#ifndef ENOTRECOVERABLE +#define ENOTRECOVERABLE 9934 +#endif + +#ifndef ETIME +#define ETIME 9935 +#endif + +#ifndef ETXTBSY +#define ETXTBSY 9936 +#endif + +#ifndef ETIMEDOUT +#define ETIMEDOUT 9938 +#endif + +#ifndef ELOOP +#define ELOOP 9939 +#endif + +#ifndef EOVERFLOW +#define EOVERFLOW 9940 +#endif + +#ifndef EPROTOTYPE +#define EPROTOTYPE 9941 +#endif + +#ifndef ENOSYS +#define ENOSYS 9942 +#endif + +#ifndef EINVAL +#define EINVAL 9943 +#endif + +#ifndef ERANGE +#define ERANGE 9944 +#endif + +#ifndef EILSEQ +#define EILSEQ 9945 +#endif + +// Windows Mobile doesn't appear to define these: + +#ifndef E2BIG +#define E2BIG 9946 +#endif + +#ifndef EDOM +#define EDOM 9947 +#endif + +#ifndef EFAULT +#define EFAULT 9948 +#endif + +#ifndef EBADF +#define EBADF 9949 +#endif + +#ifndef EPIPE +#define EPIPE 9950 +#endif + +#ifndef EXDEV +#define EXDEV 9951 +#endif + +#ifndef EBUSY +#define EBUSY 9952 +#endif + +#ifndef ENOTEMPTY +#define ENOTEMPTY 9953 +#endif + +#ifndef ENOEXEC +#define ENOEXEC 9954 +#endif + +#ifndef EEXIST +#define EEXIST 9955 +#endif + +#ifndef EFBIG +#define EFBIG 9956 +#endif + +#ifndef ENAMETOOLONG +#define ENAMETOOLONG 9957 +#endif + +#ifndef ENOTTY +#define ENOTTY 9958 +#endif + +#ifndef EINTR +#define EINTR 9959 +#endif + +#ifndef ESPIPE +#define ESPIPE 9960 +#endif + +#ifndef EIO +#define EIO 9961 +#endif + +#ifndef EISDIR +#define EISDIR 9962 +#endif + +#ifndef ECHILD +#define ECHILD 9963 +#endif + +#ifndef ENOLCK +#define ENOLCK 9964 +#endif + +#ifndef ENOSPC +#define ENOSPC 9965 +#endif + +#ifndef ENXIO +#define ENXIO 9966 +#endif + +#ifndef ENODEV +#define ENODEV 9967 +#endif + +#ifndef ENOENT +#define ENOENT 9968 +#endif + +#ifndef ESRCH +#define ESRCH 9969 +#endif + +#ifndef ENOTDIR +#define ENOTDIR 9970 +#endif + +#ifndef ENOMEM +#define ENOMEM 9971 +#endif + +#ifndef EPERM +#define EPERM 9972 +#endif + +#ifndef EACCES +#define EACCES 9973 +#endif + +#ifndef EROFS +#define EROFS 9974 +#endif + +#ifndef EDEADLK +#define EDEADLK 9975 +#endif + +#ifndef EAGAIN +#define EAGAIN 9976 +#endif + +#ifndef ENFILE +#define ENFILE 9977 +#endif + +#ifndef EMFILE +#define EMFILE 9978 +#endif + +#ifndef EMLINK +#define EMLINK 9979 +#endif + +#endif // include guard diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/enable_shared_from_this.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/enable_shared_from_this.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,18 @@ +#ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED +#define BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED + +// +// enable_shared_from_this.hpp +// +// Copyright (c) 2002 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// +// http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html +// + +#include + +#endif // #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/filesystem.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,20 @@ +// boost/filesystem/filesystem.hpp -----------------------------------------// + +// Copyright Beman Dawes 2005 + +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_FILESYSTEM_HPP +#define BOOST_FILESYSTEM_FILESYSTEM_HPP + +#include // includes path.hpp +#include + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/filesystem/config.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/config.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,113 @@ +// boost/filesystem/config.hpp ---------------------------------------------// + +// Copyright Beman Dawes 2003 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_CONFIG_HPP +#define BOOST_FILESYSTEM_CONFIG_HPP + +#define BOOST_FILESYSTEM_I18N // aid users wishing to compile several versions + +// ability to change namespace aids path_table.cpp ------------------------// +#ifndef BOOST_FILESYSTEM_NAMESPACE +# define BOOST_FILESYSTEM_NAMESPACE filesystem +#endif + +// This header implements separate compilation features as described in +// http://www.boost.org/more/separate_compilation.html + +#include +#include + +// determine platform ------------------------------------------------------// + +// BOOST_CYGWIN_PATH implies BOOST_WINDOWS_PATH and BOOST_POSIX_API + +# if defined(BOOST_CYGWIN_PATH) +# if defined(BOOST_POSIX_PATH) +# error BOOST_POSIX_PATH is invalid when BOOST_CYGWIN_PATH is defined +# endif +# if defined(BOOST_WINDOWS_API) +# error BOOST_WINDOWS_API is invalid when BOOST_CYGWIN_PATH is defined +# endif +# define BOOST_WINDOWS_PATH +# define BOOST_POSIX_API +# endif + +// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use + +# if defined( BOOST_WINDOWS_API ) && defined( BOOST_POSIX_API ) +# error both BOOST_WINDOWS_API and BOOST_POSIX_API are defined +# elif !defined( BOOST_WINDOWS_API ) && !defined( BOOST_POSIX_API ) +# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) +# define BOOST_WINDOWS_API +# else +# define BOOST_POSIX_API +# endif +# endif + +// BOOST_WINDOWS_PATH enables Windows path syntax recognition + +# if !defined(BOOST_POSIX_PATH) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)) +# define BOOST_WINDOWS_PATH +# endif + +// narrow support only for badly broken compilers or libraries -------------// + +# if defined(BOOST_NO_STD_WSTRING) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STD_LOCALE) || BOOST_WORKAROUND(__BORLANDC__, <0x610) +# define BOOST_FILESYSTEM_NARROW_ONLY +# endif + +// enable dynamic linking on Windows ---------------------------------------// + +# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)) && BOOST_WORKAROUND(__BORLANDC__, <0x610) && defined(__WIN32__) +# error Dynamic linking Boost.Filesystem does not work for Borland; use static linking instead +# endif + +#ifdef BOOST_HAS_DECLSPEC // defined in config system +// we need to import/export our code only if the user has specifically +// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost +// libraries to be dynamically linked, or BOOST_FILESYSTEM_DYN_LINK +// if they want just this one to be dynamically liked: +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK) +// export if this is our own source, otherwise import: +#ifdef BOOST_FILESYSTEM_SOURCE +# define BOOST_FILESYSTEM_DECL __declspec(dllexport) +#else +# define BOOST_FILESYSTEM_DECL __declspec(dllimport) +#endif // BOOST_FILESYSTEM_SOURCE +#endif // DYN_LINK +#endif // BOOST_HAS_DECLSPEC +// +// if BOOST_FILESYSTEM_DECL isn't defined yet define it now: +#ifndef BOOST_FILESYSTEM_DECL +#define BOOST_FILESYSTEM_DECL +#endif + +// enable automatic library variant selection ------------------------------// + +#if !defined(BOOST_FILESYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_FILESYSTEM_NO_LIB) +// +// Set the name of our library, this will get undef'ed by auto_link.hpp +// once it's done with it: +// +#define BOOST_LIB_NAME boost_filesystem +// +// If we're importing code from a dll, then tell auto_link.hpp about it: +// +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK) +# define BOOST_DYN_LINK +#endif +// +// And include the header that does the work: +// +#include +#endif // auto-linking disabled + +#endif // BOOST_FILESYSTEM_CONFIG_HPP diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/filesystem/convenience.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/convenience.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,306 @@ +// boost/filesystem/convenience.hpp ----------------------------------------// + +// Copyright Beman Dawes, 2002-2005 +// Copyright Vladimir Prus, 2002 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_CONVENIENCE_HPP +#define BOOST_FILESYSTEM_CONVENIENCE_HPP + +#include +#include +#include +#include + +#include // must be the last #include + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY +# define BOOST_FS_FUNC(BOOST_FS_TYPE) \ + template typename boost::enable_if, \ + BOOST_FS_TYPE>::type +# define BOOST_FS_FUNC_STRING BOOST_FS_FUNC(typename Path::string_type) +# define BOOST_FS_TYPENAME typename +# else +# define BOOST_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE + typedef boost::filesystem::path Path; +# define BOOST_FS_FUNC_STRING inline std::string +# define BOOST_FS_TYPENAME +# endif + +namespace boost +{ + namespace filesystem + { + + BOOST_FS_FUNC(bool) create_directories(const Path& ph) + { + if (ph.empty() || exists(ph)) + { + if ( !ph.empty() && !is_directory(ph) ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::create_directories", ph, + make_error_code( boost::system::posix::file_exists ) ) ); + return false; + } + + // First create branch, by calling ourself recursively + create_directories(ph.parent_path()); + // Now that parent's path exists, create the directory + create_directory(ph); + return true; + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + + BOOST_FS_FUNC_STRING extension(const Path& ph) + { + typedef BOOST_FS_TYPENAME Path::string_type string_type; + string_type filename = ph.filename(); + + BOOST_FS_TYPENAME string_type::size_type n = filename.rfind('.'); + if (n != string_type::npos) + return filename.substr(n); + else + return string_type(); + } + + BOOST_FS_FUNC_STRING basename(const Path& ph) + { + typedef BOOST_FS_TYPENAME Path::string_type string_type; + string_type filename = ph.filename(); + BOOST_FS_TYPENAME string_type::size_type n = filename.rfind('.'); + return filename.substr(0, n); + } + + + BOOST_FS_FUNC(Path) change_extension( const Path & ph, + const BOOST_FS_TYPENAME Path::string_type & new_extension ) + { return ph.parent_path() / (basename(ph) + new_extension); } + +# endif + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // "do-the-right-thing" overloads ---------------------------------------// + + inline bool create_directories(const path& ph) + { return create_directories(ph); } + inline bool create_directories(const wpath& ph) + { return create_directories(ph); } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + inline std::string extension(const path& ph) + { return extension(ph); } + inline std::wstring extension(const wpath& ph) + { return extension(ph); } + + inline std::string basename(const path& ph) + { return basename( ph ); } + inline std::wstring basename(const wpath& ph) + { return basename( ph ); } + + inline path change_extension( const path & ph, const std::string& new_ex ) + { return change_extension( ph, new_ex ); } + inline wpath change_extension( const wpath & ph, const std::wstring& new_ex ) + { return change_extension( ph, new_ex ); } +# endif + +# endif + + + // basic_recursive_directory_iterator helpers --------------------------// + + namespace detail + { + template< class Path > + struct recur_dir_itr_imp + { + typedef basic_directory_iterator< Path > element_type; + std::stack< element_type, std::vector< element_type > > m_stack; + int m_level; + bool m_no_push; + bool m_no_throw; + + recur_dir_itr_imp() : m_level(0), m_no_push(false), m_no_throw(false) {} + }; + + } // namespace detail + + // basic_recursive_directory_iterator ----------------------------------// + + template< class Path > + class basic_recursive_directory_iterator + : public boost::iterator_facade< + basic_recursive_directory_iterator, + basic_directory_entry, + boost::single_pass_traversal_tag > + { + public: + typedef Path path_type; + + basic_recursive_directory_iterator(){} // creates the "end" iterator + + explicit basic_recursive_directory_iterator( const Path & dir_path ); + basic_recursive_directory_iterator( const Path & dir_path, + system::error_code & ec ); + + int level() const { return m_imp->m_level; } + + void pop(); + void no_push() + { + BOOST_ASSERT( m_imp.get() && "attempt to no_push() on end iterator" ); + m_imp->m_no_push = true; + } + + file_status status() const + { + BOOST_ASSERT( m_imp.get() + && "attempt to call status() on end recursive_iterator" ); + return m_imp->m_stack.top()->status(); + } + + file_status symlink_status() const + { + BOOST_ASSERT( m_imp.get() + && "attempt to call symlink_status() on end recursive_iterator" ); + return m_imp->m_stack.top()->symlink_status(); + } + + private: + + // shared_ptr provides shallow-copy semantics required for InputIterators. + // m_imp.get()==0 indicates the end iterator. + boost::shared_ptr< detail::recur_dir_itr_imp< Path > > m_imp; + + friend class boost::iterator_core_access; + + typename boost::iterator_facade< + basic_recursive_directory_iterator, + basic_directory_entry, + boost::single_pass_traversal_tag >::reference + dereference() const + { + BOOST_ASSERT( m_imp.get() && "attempt to dereference end iterator" ); + return *m_imp->m_stack.top(); + } + + void increment(); + + bool equal( const basic_recursive_directory_iterator & rhs ) const + { return m_imp == rhs.m_imp; } + + }; + + typedef basic_recursive_directory_iterator recursive_directory_iterator; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_recursive_directory_iterator wrecursive_directory_iterator; +# endif + + // basic_recursive_directory_iterator implementation -------------------// + + // constructors + template + basic_recursive_directory_iterator:: + basic_recursive_directory_iterator( const Path & dir_path ) + : m_imp( new detail::recur_dir_itr_imp ) + { + m_imp->m_stack.push( basic_directory_iterator( dir_path ) ); + if ( m_imp->m_stack.top () == basic_directory_iterator() ) + { m_imp.reset (); } + } + + template + basic_recursive_directory_iterator:: + basic_recursive_directory_iterator( const Path & dir_path, + system::error_code & ec ) + : m_imp( new detail::recur_dir_itr_imp ) + { + m_imp->m_no_throw = true; + m_imp->m_stack.push( basic_directory_iterator( dir_path, ec ) ); + if ( m_imp->m_stack.top () == basic_directory_iterator() ) + { m_imp.reset (); } + } + + // increment + template + void basic_recursive_directory_iterator::increment() + { + BOOST_ASSERT( m_imp.get() && "increment on end iterator" ); + + static const basic_directory_iterator end_itr; + + if ( m_imp->m_no_push ) + { m_imp->m_no_push = false; } + else if ( is_directory( m_imp->m_stack.top()->status() ) ) + { + system::error_code ec; +#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610)) + if( m_imp->m_no_throw ) { + m_imp->m_stack.push( + basic_directory_iterator( *m_imp->m_stack.top(), ec ) + ); + } + else { + m_imp->m_stack.push( + basic_directory_iterator( *m_imp->m_stack.top() ) + ); + } +#else + m_imp->m_stack.push( + m_imp->m_no_throw + ? basic_directory_iterator( *m_imp->m_stack.top(), ec ) + : basic_directory_iterator( *m_imp->m_stack.top() ) ); +#endif + if ( m_imp->m_stack.top() != end_itr ) + { + ++m_imp->m_level; + return; + } + m_imp->m_stack.pop(); + } + + while ( !m_imp->m_stack.empty() + && ++m_imp->m_stack.top() == end_itr ) + { + m_imp->m_stack.pop(); + --m_imp->m_level; + } + + if ( m_imp->m_stack.empty() ) m_imp.reset(); // done, so make end iterator + } + + // pop + template + void basic_recursive_directory_iterator::pop() + { + BOOST_ASSERT( m_imp.get() && "pop on end iterator" ); + BOOST_ASSERT( m_imp->m_level > 0 && "pop with level < 1" ); + + static const basic_directory_iterator end_itr; + + do + { + m_imp->m_stack.pop(); + --m_imp->m_level; + } + while ( !m_imp->m_stack.empty() + && ++m_imp->m_stack.top() == end_itr ); + + if ( m_imp->m_stack.empty() ) m_imp.reset(); // done, so make end iterator + } + + } // namespace filesystem +} // namespace boost + +#undef BOOST_FS_FUNC_STRING +#undef BOOST_FS_FUNC + +#include // pops abi_prefix.hpp pragmas +#endif // BOOST_FILESYSTEM_CONVENIENCE_HPP diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/filesystem/exception.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/exception.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,9 @@ +// boost/filesystem/exception.hpp -------------------------------------------// + +// Copyright Beman Dawes 2003 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// This header is no long used. The contents have been moved to path.hpp. +// It is provided so that user code #includes do not have to be changed. diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/filesystem/fstream.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/fstream.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,584 @@ +// boost/filesystem/fstream.hpp --------------------------------------------// + +// Copyright Beman Dawes 2002. +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_FSTREAM_HPP +#define BOOST_FILESYSTEM_FSTREAM_HPP + +#include // for 8.3 hack (see below) +#include +#include + +#include +#include + +#include // must be the last #include + +// NOTE: fstream.hpp for Boost 1.32.0 and earlier supplied workarounds for +// various compiler problems. They have been removed to ease development of the +// basic i18n functionality. Once the new interface is stable, the workarounds +// will be reinstated for any compilers that otherwise can support the rest of +// the library after internationalization. + +namespace boost +{ + namespace filesystem + { + namespace detail + { +# if defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_NARROW_ONLY) +# if !defined(BOOST_DINKUMWARE_STDLIB) || BOOST_DINKUMWARE_STDLIB < 405 + // The 8.3 hack: + // C++98 does not supply a wchar_t open, so try to get an equivalent + // narrow char name based on the short, so-called 8.3, name. + // Not needed for Dinkumware 405 and later as they do supply wchar_t open. + BOOST_FILESYSTEM_DECL bool create_file_api( const std::wstring & ph, + std::ios_base::openmode mode ); // true if succeeds + BOOST_FILESYSTEM_DECL std::string narrow_path_api( + const std::wstring & ph ); // return is empty if fails + + inline std::string path_proxy( const std::wstring & file_ph, + std::ios_base::openmode mode ) + // Return a non-existant path if cannot supply narrow short path. + // An empty path doesn't work because some Dinkumware versions + // assert the path is non-empty. + { + std::string narrow_ph; + bool created_file( false ); + if ( !exists( file_ph ) + && (mode & std::ios_base::out) != 0 + && create_file_api( file_ph, mode ) ) + { + created_file = true; + } + narrow_ph = narrow_path_api( file_ph ); + if ( narrow_ph.empty() ) + { + if ( created_file ) remove_api( file_ph ); + narrow_ph = "\x01"; + } + return narrow_ph; + } +# else + // Dinkumware 405 and later does supply wchar_t functions + inline const std::wstring & path_proxy( const std::wstring & file_ph, + std::ios_base::openmode ) + { return file_ph; } +# endif +# endif + + inline const std::string & path_proxy( const std::string & file_ph, + std::ios_base::openmode ) + { return file_ph; } + + } // namespace detail + + template < class charT, class traits = std::char_traits > + class basic_filebuf : public std::basic_filebuf + { + private: // disallow copying + basic_filebuf( const basic_filebuf & ); + const basic_filebuf & operator=( const basic_filebuf & ); + public: + basic_filebuf() {} + virtual ~basic_filebuf() {} + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template + typename boost::enable_if, + basic_filebuf *>::type + open( const Path & file_ph, std::ios_base::openmode mode ); + + basic_filebuf * + open( const wpath & file_ph, std::ios_base::openmode mode ); +# endif + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + basic_filebuf * + open( const path & file_ph, std::ios_base::openmode mode ); +# endif + }; + + template < class charT, class traits = std::char_traits > + class basic_ifstream : public std::basic_ifstream + { + private: // disallow copying + basic_ifstream( const basic_ifstream & ); + const basic_ifstream & operator=( const basic_ifstream & ); + public: + basic_ifstream() {} + + // use two signatures, rather than one signature with default second + // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416) + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template + explicit basic_ifstream( const Path & file_ph, + typename boost::enable_if >::type* dummy = 0 ); + + template + basic_ifstream( const Path & file_ph, std::ios_base::openmode mode, + typename boost::enable_if >::type* dummy = 0 ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph, std::ios_base::openmode mode ); + + explicit basic_ifstream( const wpath & file_ph ); + basic_ifstream( const wpath & file_ph, std::ios_base::openmode mode ); + void open( const wpath & file_ph ); + void open( const wpath & file_ph, std::ios_base::openmode mode ); +# endif + + explicit basic_ifstream( const path & file_ph ); + basic_ifstream( const path & file_ph, std::ios_base::openmode mode ); +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + void open( const path & file_ph ); + void open( const path & file_ph, std::ios_base::openmode mode ); +# endif + virtual ~basic_ifstream() {} + }; + + template < class charT, class traits = std::char_traits > + class basic_ofstream : public std::basic_ofstream + { + private: // disallow copying + basic_ofstream( const basic_ofstream & ); + const basic_ofstream & operator=( const basic_ofstream & ); + public: + basic_ofstream() {} + + // use two signatures, rather than one signature with default second + // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416) + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + template + explicit basic_ofstream( const Path & file_ph, + typename boost::enable_if >::type* dummy = 0 ); + explicit basic_ofstream( const wpath & file_ph ); + + template + basic_ofstream( const Path & file_ph, std::ios_base::openmode mode, + typename boost::enable_if >::type* dummy = 0 ); + basic_ofstream( const wpath & file_ph, std::ios_base::openmode mode ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph ); + void open( const wpath & file_ph ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph, std::ios_base::openmode mode ); + void open( const wpath & file_ph, std::ios_base::openmode mode ); + +# endif + + explicit basic_ofstream( const path & file_ph ); + basic_ofstream( const path & file_ph, std::ios_base::openmode mode ); +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + void open( const path & file_ph ); + void open( const path & file_ph, std::ios_base::openmode mode ); +# endif + virtual ~basic_ofstream() {} + }; + + template < class charT, class traits = std::char_traits > + class basic_fstream : public std::basic_fstream + { + private: // disallow copying + basic_fstream( const basic_fstream & ); + const basic_fstream & operator=( const basic_fstream & ); + public: + basic_fstream() {} + + // use two signatures, rather than one signature with default second + // argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416) + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + template + explicit basic_fstream( const Path & file_ph, + typename boost::enable_if >::type* dummy = 0 ); + explicit basic_fstream( const wpath & file_ph ); + + template + basic_fstream( const Path & file_ph, std::ios_base::openmode mode, + typename boost::enable_if >::type* dummy = 0 ); + basic_fstream( const wpath & file_ph, std::ios_base::openmode mode ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph ); + void open( const wpath & file_ph ); + + template + typename boost::enable_if, void>::type + open( const Path & file_ph, std::ios_base::openmode mode ); + void open( const wpath & file_ph, std::ios_base::openmode mode ); + +# endif + + explicit basic_fstream( const path & file_ph ); + basic_fstream( const path & file_ph, std::ios_base::openmode mode ); +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + void open( const path & file_ph ); + void open( const path & file_ph, std::ios_base::openmode mode ); +# endif + virtual ~basic_fstream() {} + + }; + + typedef basic_filebuf filebuf; + typedef basic_ifstream ifstream; + typedef basic_ofstream ofstream; + typedef basic_fstream fstream; + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_filebuf wfilebuf; + typedef basic_ifstream wifstream; + typedef basic_fstream wfstream; + typedef basic_ofstream wofstream; +# endif + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + +// basic_filebuf definitions -----------------------------------------------// + + template + template + typename boost::enable_if, + basic_filebuf *>::type + basic_filebuf::open( const Path & file_ph, + std::ios_base::openmode mode ) + { + return (std::basic_filebuf::open( detail::path_proxy( + file_ph.external_file_string(), mode ).c_str(), mode ) + == 0) ? 0 : this; + } + + template + basic_filebuf * + basic_filebuf::open( const wpath & file_ph, + std::ios_base::openmode mode ) + { + return this->BOOST_NESTED_TEMPLATE open( file_ph, mode ); + } + +// basic_ifstream definitions ----------------------------------------------// + + template template + basic_ifstream::basic_ifstream(const Path & file_ph, + typename boost::enable_if >::type* ) + : std::basic_ifstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in ).c_str(), std::ios_base::in ) {} + + template + basic_ifstream::basic_ifstream( const wpath & file_ph ) + : std::basic_ifstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in ).c_str(), std::ios_base::in ) {} + + template template + basic_ifstream::basic_ifstream( const Path & file_ph, + std::ios_base::openmode mode, + typename boost::enable_if >::type* ) + : std::basic_ifstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in ) {} + + template + basic_ifstream::basic_ifstream( const wpath & file_ph, + std::ios_base::openmode mode ) + : std::basic_ifstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in ) {} + + template template + typename boost::enable_if, void>::type + basic_ifstream::open( const Path & file_ph ) + { + std::basic_ifstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in ).c_str(), std::ios_base::in ); + } + + template + void basic_ifstream::open( const wpath & file_ph ) + { + std::basic_ifstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in ).c_str(), std::ios_base::in ); + } + + template template + typename boost::enable_if, void>::type + basic_ifstream::open( const Path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ifstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in ); + } + + template + void basic_ifstream::open( const wpath & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ifstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in ); + } + +// basic_ofstream definitions ----------------------------------------------// + + template template + basic_ofstream::basic_ofstream(const Path & file_ph, + typename boost::enable_if >::type* ) + : std::basic_ofstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::out ).c_str(), std::ios_base::out ) {} + + template + basic_ofstream::basic_ofstream( const wpath & file_ph ) + : std::basic_ofstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::out ).c_str(), std::ios_base::out ) {} + + template template + basic_ofstream::basic_ofstream( const Path & file_ph, + std::ios_base::openmode mode, + typename boost::enable_if >::type* ) + : std::basic_ofstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::out ) {} + + template + basic_ofstream::basic_ofstream( const wpath & file_ph, + std::ios_base::openmode mode ) + : std::basic_ofstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::out ) {} + + template template + typename boost::enable_if, void>::type + basic_ofstream::open( const Path & file_ph ) + { + std::basic_ofstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::out ).c_str(), std::ios_base::out ); + } + + template + void basic_ofstream::open( const wpath & file_ph ) + { + std::basic_ofstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::out ).c_str(), std::ios_base::out ); + } + + template template + typename boost::enable_if, void>::type + basic_ofstream::open( const Path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ofstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::out ); + } + + template + void basic_ofstream::open( const wpath & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ofstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::out ); + } + +// basic_fstream definitions -----------------------------------------------// + + template template + basic_fstream::basic_fstream(const Path & file_ph, + typename boost::enable_if >::type* ) + : std::basic_fstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in|std::ios_base::out ).c_str(), + std::ios_base::in|std::ios_base::out ) {} + + template + basic_fstream::basic_fstream( const wpath & file_ph ) + : std::basic_fstream( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in|std::ios_base::out ).c_str(), + std::ios_base::in|std::ios_base::out ) {} + + template template + basic_fstream::basic_fstream( const Path & file_ph, + std::ios_base::openmode mode, + typename boost::enable_if >::type* ) + : std::basic_fstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ) {} + + template + basic_fstream::basic_fstream( const wpath & file_ph, + std::ios_base::openmode mode ) + : std::basic_fstream( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ) {} + + template template + typename boost::enable_if, void>::type + basic_fstream::open( const Path & file_ph ) + { + std::basic_fstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in|std::ios_base::out ).c_str(), + std::ios_base::in|std::ios_base::out ); + } + + template + void basic_fstream::open( const wpath & file_ph ) + { + std::basic_fstream::open( + detail::path_proxy( file_ph.external_file_string(), + std::ios_base::in|std::ios_base::out ).c_str(), + std::ios_base::in|std::ios_base::out ); + } + + template template + typename boost::enable_if, void>::type + basic_fstream::open( const Path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_fstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ); + } + + template + void basic_fstream::open( const wpath & file_ph, + std::ios_base::openmode mode ) + { + std::basic_fstream::open( + detail::path_proxy( file_ph.external_file_string(), + mode ).c_str(), mode | std::ios_base::in | std::ios_base::out ); + } + +# endif + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + template + basic_filebuf * + basic_filebuf::open( const path & file_ph, + std::ios_base::openmode mode ) + { + return std::basic_filebuf::open( + file_ph.file_string().c_str(), mode ) == 0 ? 0 : this; + } +# endif + + template + basic_ifstream::basic_ifstream( const path & file_ph ) + : std::basic_ifstream( + file_ph.file_string().c_str(), std::ios_base::in ) {} + + template + basic_ifstream::basic_ifstream( const path & file_ph, + std::ios_base::openmode mode ) + : std::basic_ifstream( + file_ph.file_string().c_str(), mode ) {} + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + template + void basic_ifstream::open( const path & file_ph ) + { + std::basic_ifstream::open( + file_ph.file_string().c_str(), std::ios_base::in ); + } + + template + void basic_ifstream::open( const path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ifstream::open( + file_ph.file_string().c_str(), mode ); + } +# endif + + template + basic_ofstream::basic_ofstream( const path & file_ph ) + : std::basic_ofstream( + file_ph.file_string().c_str(), std::ios_base::out ) {} + + template + basic_ofstream::basic_ofstream( const path & file_ph, + std::ios_base::openmode mode ) + : std::basic_ofstream( + file_ph.file_string().c_str(), mode ) {} + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + template + void basic_ofstream::open( const path & file_ph ) + { + std::basic_ofstream::open( + file_ph.file_string().c_str(), std::ios_base::out ); + } + + template + void basic_ofstream::open( const path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_ofstream::open( + file_ph.file_string().c_str(), mode ); + } +# endif + + template + basic_fstream::basic_fstream( const path & file_ph ) + : std::basic_fstream( + file_ph.file_string().c_str(), + std::ios_base::in|std::ios_base::out ) {} + + + template + basic_fstream::basic_fstream( const path & file_ph, + std::ios_base::openmode mode ) + : std::basic_fstream( + file_ph.file_string().c_str(), mode ) {} + +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this + template + void basic_fstream::open( const path & file_ph ) + { + std::basic_fstream::open( + file_ph.file_string().c_str(), std::ios_base::in|std::ios_base::out ); + } + + template + void basic_fstream::open( const path & file_ph, + std::ios_base::openmode mode ) + { + std::basic_fstream::open( + file_ph.file_string().c_str(), mode ); + } +# endif + } // namespace filesystem +} // namespace boost + +#include // pops abi_prefix.hpp pragmas +#endif // BOOST_FILESYSTEM_FSTREAM_HPP diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/filesystem/operations.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/operations.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,1173 @@ +// boost/filesystem/operations.hpp -----------------------------------------// + +// Copyright 2002-2005 Beman Dawes +// Copyright 2002 Jan Langer +// Copyright 2001 Dietmar Kuehl +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/filesystem + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_OPERATIONS_HPP +#define BOOST_FILESYSTEM_OPERATIONS_HPP + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include // for pair +#include + +#ifdef BOOST_WINDOWS_API +# include +# if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0500 +# define BOOST_FS_HARD_LINK // Default for Windows 2K or later +# endif +#endif + +#include // must be the last #include + +# ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::time_t; } +# endif + +//----------------------------------------------------------------------------// + +namespace boost +{ + namespace filesystem + { + +// typedef boost::filesystem::path Path; needs to be in namespace boost::filesystem +# ifndef BOOST_FILESYSTEM_NARROW_ONLY +# define BOOST_FS_FUNC(BOOST_FS_TYPE) \ + template typename boost::enable_if, \ + BOOST_FS_TYPE>::type +# define BOOST_INLINE_FS_FUNC(BOOST_FS_TYPE) \ + template inline typename boost::enable_if, \ + BOOST_FS_TYPE>::type +# define BOOST_FS_TYPENAME typename +# else +# define BOOST_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE +# define BOOST_INLINE_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE + typedef boost::filesystem::path Path; +# define BOOST_FS_TYPENAME +# endif + + template class basic_directory_iterator; + + // BOOST_FILESYSTEM_NARROW_ONLY needs this: + typedef basic_directory_iterator directory_iterator; + + template class basic_directory_entry; + + enum file_type + { + status_unknown, + file_not_found, + regular_file, + directory_file, + // the following will never be reported by some operating or file systems + symlink_file, + block_file, + character_file, + fifo_file, + socket_file, + type_unknown // file does exist, but isn't one of the above types or + // we don't have strong enough permission to find its type + }; + + class file_status + { + public: + explicit file_status( file_type v = status_unknown ) : m_value(v) {} + + void type( file_type v ) { m_value = v; } + file_type type() const { return m_value; } + + private: + // the internal representation is unspecified so that additional state + // information such as permissions can be added in the future; this + // implementation just uses status_type as the internal representation + + file_type m_value; + }; + + inline bool status_known( file_status f ) { return f.type() != status_unknown; } + inline bool exists( file_status f ) { return f.type() != status_unknown && f.type() != file_not_found; } + inline bool is_regular_file(file_status f){ return f.type() == regular_file; } + inline bool is_directory( file_status f ) { return f.type() == directory_file; } + inline bool is_symlink( file_status f ) { return f.type() == symlink_file; } + inline bool is_other( file_status f ) { return exists(f) && !is_regular_file(f) && !is_directory(f) && !is_symlink(f); } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + inline bool is_regular( file_status f ) { return f.type() == regular_file; } +# endif + + struct space_info + { + // all values are byte counts + boost::uintmax_t capacity; + boost::uintmax_t free; // <= capacity + boost::uintmax_t available; // <= free + }; + + namespace detail + { + typedef std::pair< system::error_code, bool > + query_pair; + + typedef std::pair< system::error_code, boost::uintmax_t > + uintmax_pair; + + typedef std::pair< system::error_code, std::time_t > + time_pair; + + typedef std::pair< system::error_code, space_info > + space_pair; + + template< class Path > + struct directory_pair + { + typedef std::pair< system::error_code, + typename Path::external_string_type > type; + }; + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + BOOST_FILESYSTEM_DECL bool + symbolic_link_exists_api( const std::string & ); // deprecated +# endif + + BOOST_FILESYSTEM_DECL file_status + status_api( const std::string & ph, system::error_code & ec ); +# ifndef BOOST_WINDOWS_API + BOOST_FILESYSTEM_DECL file_status + symlink_status_api( const std::string & ph, system::error_code & ec ); +# endif + BOOST_FILESYSTEM_DECL query_pair + is_empty_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL query_pair + equivalent_api( const std::string & ph1, const std::string & ph2 ); + BOOST_FILESYSTEM_DECL uintmax_pair + file_size_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL space_pair + space_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL time_pair + last_write_time_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL system::error_code + last_write_time_api( const std::string & ph, std::time_t new_value ); + BOOST_FILESYSTEM_DECL system::error_code + get_current_path_api( std::string & ph ); + BOOST_FILESYSTEM_DECL system::error_code + set_current_path_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL query_pair + create_directory_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL system::error_code + create_hard_link_api( const std::string & to_ph, + const std::string & from_ph ); + BOOST_FILESYSTEM_DECL system::error_code + create_symlink_api( const std::string & to_ph, + const std::string & from_ph ); + BOOST_FILESYSTEM_DECL system::error_code + remove_api( const std::string & ph ); + BOOST_FILESYSTEM_DECL system::error_code + rename_api( const std::string & from, const std::string & to ); + BOOST_FILESYSTEM_DECL system::error_code + copy_file_api( const std::string & from, const std::string & to ); + +# if defined(BOOST_WINDOWS_API) + + BOOST_FILESYSTEM_DECL system::error_code + get_full_path_name_api( const std::string & ph, std::string & target ); + +# if !defined(BOOST_FILESYSTEM_NARROW_ONLY) + + BOOST_FILESYSTEM_DECL boost::filesystem::file_status + status_api( const std::wstring & ph, system::error_code & ec ); + BOOST_FILESYSTEM_DECL query_pair + is_empty_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL query_pair + equivalent_api( const std::wstring & ph1, const std::wstring & ph2 ); + BOOST_FILESYSTEM_DECL uintmax_pair + file_size_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL space_pair + space_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL system::error_code + get_full_path_name_api( const std::wstring & ph, std::wstring & target ); + BOOST_FILESYSTEM_DECL time_pair + last_write_time_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL system::error_code + last_write_time_api( const std::wstring & ph, std::time_t new_value ); + BOOST_FILESYSTEM_DECL system::error_code + get_current_path_api( std::wstring & ph ); + BOOST_FILESYSTEM_DECL system::error_code + set_current_path_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL query_pair + create_directory_api( const std::wstring & ph ); +# ifdef BOOST_FS_HARD_LINK + BOOST_FILESYSTEM_DECL system::error_code + create_hard_link_api( const std::wstring & existing_ph, + const std::wstring & new_ph ); +# endif + BOOST_FILESYSTEM_DECL system::error_code + create_symlink_api( const std::wstring & to_ph, + const std::wstring & from_ph ); + BOOST_FILESYSTEM_DECL system::error_code + remove_api( const std::wstring & ph ); + BOOST_FILESYSTEM_DECL system::error_code + rename_api( const std::wstring & from, const std::wstring & to ); + BOOST_FILESYSTEM_DECL system::error_code + copy_file_api( const std::wstring & from, const std::wstring & to ); + +# endif +# endif + + template + bool remove_aux( const Path & ph, file_status f ); + + template + unsigned long remove_all_aux( const Path & ph, file_status f ); + + } // namespace detail + +// operations functions ----------------------------------------------------// + + // The non-template overloads enable automatic conversion from std and + // C-style strings. See basic_path constructors. The enable_if for the + // templates implements the famous "do-the-right-thing" rule. + +// query functions ---------------------------------------------------------// + + BOOST_INLINE_FS_FUNC(file_status) + status( const Path & ph, system::error_code & ec ) + { return detail::status_api( ph.external_file_string(), ec ); } + + BOOST_FS_FUNC(file_status) + status( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::status", ph, ec ) ); + return result; + } + + BOOST_INLINE_FS_FUNC(file_status) + symlink_status( const Path & ph, system::error_code & ec ) +# ifdef BOOST_WINDOWS_API + { return detail::status_api( ph.external_file_string(), ec ); } +# else + { return detail::symlink_status_api( ph.external_file_string(), ec ); } +# endif + + BOOST_FS_FUNC(file_status) + symlink_status( const Path & ph ) + { + system::error_code ec; + file_status result( symlink_status( ph, ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::symlink_status", ph, ec ) ); + return result; + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + inline bool symbolic_link_exists( const path & ph ) + { return is_symlink( symlink_status(ph) ); } +# endif + + BOOST_FS_FUNC(bool) exists( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::exists", ph, ec ) ); + return exists( result ); + } + + BOOST_FS_FUNC(bool) is_directory( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_directory", ph, ec ) ); + return is_directory( result ); + } + + BOOST_FS_FUNC(bool) is_regular_file( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_regular_file", ph, ec ) ); + return is_regular_file( result ); + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + BOOST_FS_FUNC(bool) is_regular( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_regular", ph, ec ) ); + return is_regular( result ); + } +# endif + + BOOST_FS_FUNC(bool) is_other( const Path & ph ) + { + system::error_code ec; + file_status result( detail::status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_other", ph, ec ) ); + return is_other( result ); + } + + BOOST_FS_FUNC(bool) is_symlink( +# ifdef BOOST_WINDOWS_API + const Path & ) + { + return false; +# else + const Path & ph) + { + system::error_code ec; + file_status result( detail::symlink_status_api( ph.external_file_string(), ec ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_symlink", ph, ec ) ); + return is_symlink( result ); +# endif + } + + // VC++ 7.0 and earlier has a serious namespace bug that causes a clash + // between boost::filesystem::is_empty and the unrelated type trait + // boost::is_empty. + +# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 + BOOST_FS_FUNC(bool) is_empty( const Path & ph ) +# else + BOOST_FS_FUNC(bool) _is_empty( const Path & ph ) +# endif + { + detail::query_pair result( + detail::is_empty_api( ph.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::is_empty", ph, result.first ) ); + return result.second; + } + + BOOST_FS_FUNC(bool) equivalent( const Path & ph1, const Path & ph2 ) + { + detail::query_pair result( detail::equivalent_api( + ph1.external_file_string(), ph2.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::equivalent", ph1, ph2, result.first ) ); + return result.second; + } + + BOOST_FS_FUNC(boost::uintmax_t) file_size( const Path & ph ) + { + detail::uintmax_pair result + ( detail::file_size_api( ph.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::file_size", ph, result.first ) ); + return result.second; + } + + BOOST_FS_FUNC(space_info) space( const Path & ph ) + { + detail::space_pair result + ( detail::space_api( ph.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::space", ph, result.first ) ); + return result.second; + } + + BOOST_FS_FUNC(std::time_t) last_write_time( const Path & ph ) + { + detail::time_pair result + ( detail::last_write_time_api( ph.external_file_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::last_write_time", ph, result.first ) ); + return result.second; + } + + +// operations --------------------------------------------------------------// + + BOOST_FS_FUNC(bool) create_directory( const Path & dir_ph ) + { + detail::query_pair result( + detail::create_directory_api( dir_ph.external_directory_string() ) ); + if ( result.first ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::create_directory", + dir_ph, result.first ) ); + return result.second; + } + +#if !defined(BOOST_WINDOWS_API) || defined(BOOST_FS_HARD_LINK) + BOOST_FS_FUNC(void) + create_hard_link( const Path & to_ph, const Path & from_ph ) + { + system::error_code ec( + detail::create_hard_link_api( + to_ph.external_file_string(), + from_ph.external_file_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::create_hard_link", + to_ph, from_ph, ec ) ); + } + + BOOST_FS_FUNC(system::error_code) + create_hard_link( const Path & to_ph, const Path & from_ph, + system::error_code & ec ) + { + ec = detail::create_hard_link_api( + to_ph.external_file_string(), + from_ph.external_file_string() ); + return ec; + } +#endif + + BOOST_FS_FUNC(void) + create_symlink( const Path & to_ph, const Path & from_ph ) + { + system::error_code ec( + detail::create_symlink_api( + to_ph.external_file_string(), + from_ph.external_file_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::create_symlink", + to_ph, from_ph, ec ) ); + } + + BOOST_FS_FUNC(system::error_code) + create_symlink( const Path & to_ph, const Path & from_ph, + system::error_code & ec ) + { + ec = detail::create_symlink_api( + to_ph.external_file_string(), + from_ph.external_file_string() ); + return ec; + } + + BOOST_FS_FUNC(bool) remove( const Path & ph ) + { + system::error_code ec; + file_status f = symlink_status( ph, ec ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::remove", ph, ec ) ); + return detail::remove_aux( ph, f ); + } + + BOOST_FS_FUNC(unsigned long) remove_all( const Path & ph ) + { + system::error_code ec; + file_status f = symlink_status( ph, ec ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::remove_all", ph, ec ) ); + return exists( f ) ? detail::remove_all_aux( ph, f ) : 0; + } + + BOOST_FS_FUNC(void) rename( const Path & from_path, const Path & to_path ) + { + system::error_code ec( detail::rename_api( + from_path.external_directory_string(), + to_path.external_directory_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::rename", + from_path, to_path, ec ) ); + } + + BOOST_FS_FUNC(void) copy_file( const Path & from_path, const Path & to_path ) + { + system::error_code ec( detail::copy_file_api( + from_path.external_directory_string(), + to_path.external_directory_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::copy_file", + from_path, to_path, ec ) ); + } + + template< class Path > + Path current_path() + { + typename Path::external_string_type ph; + system::error_code ec( detail::get_current_path_api( ph ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::current_path", ec ) ); + return Path( Path::traits_type::to_internal( ph ) ); + } + + BOOST_FS_FUNC(void) current_path( const Path & ph ) + { + system::error_code ec( detail::set_current_path_api( + ph.external_directory_string() ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::current_path", ph, ec ) ); + } + + template< class Path > + const Path & initial_path() + { + static Path init_path; + if ( init_path.empty() ) init_path = current_path(); + return init_path; + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + // legacy support + inline path current_path() // overload supports pre-i18n apps + { return current_path(); } + inline const path & initial_path() // overload supports pre-i18n apps + { return initial_path(); } +# endif + + BOOST_FS_FUNC(Path) system_complete( const Path & ph ) + { +# ifdef BOOST_WINDOWS_API + if ( ph.empty() ) return ph; + BOOST_FS_TYPENAME Path::external_string_type sys_ph; + system::error_code ec( detail::get_full_path_name_api( ph.external_file_string(), + sys_ph ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::system_complete", ph, ec ) ); + return Path( Path::traits_type::to_internal( sys_ph ) ); +# else + return (ph.empty() || ph.is_complete()) + ? ph : current_path() / ph; +# endif + } + + BOOST_FS_FUNC(Path) + complete( const Path & ph, + const Path & base/* = initial_path() */) + { + BOOST_ASSERT( base.is_complete() + && (ph.is_complete() || !ph.has_root_name()) + && "boost::filesystem::complete() precondition not met" ); +# ifdef BOOST_WINDOWS_PATH + if (ph.empty() || ph.is_complete()) return ph; + if ( !ph.has_root_name() ) + return ph.has_root_directory() + ? Path( base.root_name() ) / ph + : base / ph; + return base / ph; +# else + return (ph.empty() || ph.is_complete()) ? ph : base / ph; +# endif + } + + // VC++ 7.1 had trouble with default arguments, so separate one argument + // signatures are provided as workarounds; the effect is the same. + BOOST_FS_FUNC(Path) complete( const Path & ph ) + { return complete( ph, initial_path() ); } + + BOOST_FS_FUNC(void) + last_write_time( const Path & ph, const std::time_t new_time ) + { + system::error_code ec( detail::last_write_time_api( ph.external_file_string(), + new_time ) ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::last_write_time", ph, ec ) ); + } + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // "do-the-right-thing" overloads ---------------------------------------// + + inline file_status status( const path & ph ) + { return status( ph ); } + inline file_status status( const wpath & ph ) + { return status( ph ); } + + inline file_status status( const path & ph, system::error_code & ec ) + { return status( ph, ec ); } + inline file_status status( const wpath & ph, system::error_code & ec ) + { return status( ph, ec ); } + + inline file_status symlink_status( const path & ph ) + { return symlink_status( ph ); } + inline file_status symlink_status( const wpath & ph ) + { return symlink_status( ph ); } + + inline file_status symlink_status( const path & ph, system::error_code & ec ) + { return symlink_status( ph, ec ); } + inline file_status symlink_status( const wpath & ph, system::error_code & ec ) + { return symlink_status( ph, ec ); } + + inline bool exists( const path & ph ) { return exists( ph ); } + inline bool exists( const wpath & ph ) { return exists( ph ); } + + inline bool is_directory( const path & ph ) + { return is_directory( ph ); } + inline bool is_directory( const wpath & ph ) + { return is_directory( ph ); } + + inline bool is_regular_file( const path & ph ) + { return is_regular_file( ph ); } + inline bool is_regular_file( const wpath & ph ) + { return is_regular_file( ph ); } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + inline bool is_regular( const path & ph ) + { return is_regular( ph ); } + inline bool is_regular( const wpath & ph ) + { return is_regular( ph ); } +# endif + + inline bool is_other( const path & ph ) + { return is_other( ph ); } + inline bool is_other( const wpath & ph ) + { return is_other( ph ); } + + inline bool is_symlink( const path & ph ) + { return is_symlink( ph ); } + inline bool is_symlink( const wpath & ph ) + { return is_symlink( ph ); } + + inline bool is_empty( const path & ph ) + { return is_empty( ph ); } + inline bool is_empty( const wpath & ph ) + { return is_empty( ph ); } + + inline bool equivalent( const path & ph1, const path & ph2 ) + { return equivalent( ph1, ph2 ); } + inline bool equivalent( const wpath & ph1, const wpath & ph2 ) + { return equivalent( ph1, ph2 ); } + + inline boost::uintmax_t file_size( const path & ph ) + { return file_size( ph ); } + inline boost::uintmax_t file_size( const wpath & ph ) + { return file_size( ph ); } + + inline space_info space( const path & ph ) + { return space( ph ); } + inline space_info space( const wpath & ph ) + { return space( ph ); } + + inline std::time_t last_write_time( const path & ph ) + { return last_write_time( ph ); } + inline std::time_t last_write_time( const wpath & ph ) + { return last_write_time( ph ); } + + inline bool create_directory( const path & dir_ph ) + { return create_directory( dir_ph ); } + inline bool create_directory( const wpath & dir_ph ) + { return create_directory( dir_ph ); } + +#if !defined(BOOST_WINDOWS_API) || defined(BOOST_FS_HARD_LINK) + inline void create_hard_link( const path & to_ph, + const path & from_ph ) + { return create_hard_link( to_ph, from_ph ); } + inline void create_hard_link( const wpath & to_ph, + const wpath & from_ph ) + { return create_hard_link( to_ph, from_ph ); } + + inline system::error_code create_hard_link( const path & to_ph, + const path & from_ph, system::error_code & ec ) + { return create_hard_link( to_ph, from_ph, ec ); } + inline system::error_code create_hard_link( const wpath & to_ph, + const wpath & from_ph, system::error_code & ec ) + { return create_hard_link( to_ph, from_ph, ec ); } +#endif + + inline void create_symlink( const path & to_ph, + const path & from_ph ) + { return create_symlink( to_ph, from_ph ); } + inline void create_symlink( const wpath & to_ph, + const wpath & from_ph ) + { return create_symlink( to_ph, from_ph ); } + + inline system::error_code create_symlink( const path & to_ph, + const path & from_ph, system::error_code & ec ) + { return create_symlink( to_ph, from_ph, ec ); } + inline system::error_code create_symlink( const wpath & to_ph, + const wpath & from_ph, system::error_code & ec ) + { return create_symlink( to_ph, from_ph, ec ); } + + inline bool remove( const path & ph ) + { return remove( ph ); } + inline bool remove( const wpath & ph ) + { return remove( ph ); } + + inline unsigned long remove_all( const path & ph ) + { return remove_all( ph ); } + inline unsigned long remove_all( const wpath & ph ) + { return remove_all( ph ); } + + inline void rename( const path & from_path, const path & to_path ) + { return rename( from_path, to_path ); } + inline void rename( const wpath & from_path, const wpath & to_path ) + { return rename( from_path, to_path ); } + + inline void copy_file( const path & from_path, const path & to_path ) + { return copy_file( from_path, to_path ); } + inline void copy_file( const wpath & from_path, const wpath & to_path ) + { return copy_file( from_path, to_path ); } + + inline path system_complete( const path & ph ) + { return system_complete( ph ); } + inline wpath system_complete( const wpath & ph ) + { return system_complete( ph ); } + + inline path complete( const path & ph, + const path & base/* = initial_path()*/ ) + { return complete( ph, base ); } + inline wpath complete( const wpath & ph, + const wpath & base/* = initial_path()*/ ) + { return complete( ph, base ); } + + inline path complete( const path & ph ) + { return complete( ph, initial_path() ); } + inline wpath complete( const wpath & ph ) + { return complete( ph, initial_path() ); } + + inline void last_write_time( const path & ph, const std::time_t new_time ) + { last_write_time( ph, new_time ); } + inline void last_write_time( const wpath & ph, const std::time_t new_time ) + { last_write_time( ph, new_time ); } + + inline void current_path( const path & ph ) + { current_path( ph ); } + inline void current_path( const wpath & ph ) + { current_path( ph ); } + +# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY + + namespace detail + { + template + bool remove_aux( const Path & ph, file_status f ) + { + if ( exists( f ) ) + { + system::error_code ec = remove_api( ph.external_file_string() ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::remove", ph, ec ) ); + return true; + } + return false; + } + + template + unsigned long remove_all_aux( const Path & ph, file_status f ) + { + static const boost::filesystem::basic_directory_iterator end_itr; + unsigned long count = 1; + if ( !boost::filesystem::is_symlink( f ) // don't recurse symbolic links + && boost::filesystem::is_directory( f ) ) + { + for ( boost::filesystem::basic_directory_iterator itr( ph ); + itr != end_itr; ++itr ) + { + boost::system::error_code ec; + boost::filesystem::file_status fn = boost::filesystem::symlink_status( itr->path(), ec ); + if ( ec ) + boost::throw_exception( basic_filesystem_error( + "boost::filesystem:remove_all", ph, ec ) ); + count += remove_all_aux( itr->path(), fn ); + } + } + remove_aux( ph, f ); + return count; + } + +// test helper -------------------------------------------------------------// + + // not part of the documented interface because false positives are possible; + // there is no law that says that an OS that has large stat.st_size + // actually supports large file sizes. + BOOST_FILESYSTEM_DECL bool possible_large_file_size_support(); + +// directory_iterator helpers ----------------------------------------------// + +// forwarding functions avoid need for BOOST_FILESYSTEM_DECL for class +// basic_directory_iterator, and so avoid iterator_facade DLL template +// problems. They also overload to the proper external path character type. + + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_first( void *& handle, +#if defined(BOOST_POSIX_API) + void *& buffer, +#endif + const std::string & dir_path, + std::string & target, file_status & fs, file_status & symlink_fs ); + // eof: return==0 && handle==0 + + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_increment( void *& handle, +#if defined(BOOST_POSIX_API) + void *& buffer, +#endif + std::string & target, file_status & fs, file_status & symlink_fs ); + // eof: return==0 && handle==0 + + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_close( void *& handle +#if defined(BOOST_POSIX_API) + , void *& buffer +#endif + ); + // Effects: none if handle==0, otherwise close handle, set handle=0 + +# if defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_NARROW_ONLY) + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_first( void *& handle, const std::wstring & ph, + std::wstring & target, file_status & fs, file_status & symlink_fs ); + BOOST_FILESYSTEM_DECL system::error_code + dir_itr_increment( void *& handle, std::wstring & target, + file_status & fs, file_status & symlink_fs ); +# endif + + template< class Path > + class dir_itr_imp + { + public: + basic_directory_entry m_directory_entry; + void * m_handle; +# ifdef BOOST_POSIX_API + void * m_buffer; // see dir_itr_increment implementation +# endif + dir_itr_imp() : m_handle(0) +# ifdef BOOST_POSIX_API + , m_buffer(0) +# endif + {} + + ~dir_itr_imp() { dir_itr_close( m_handle +#if defined(BOOST_POSIX_API) + , m_buffer +#endif + ); } + }; + + BOOST_FILESYSTEM_DECL system::error_code not_found_error(); + + } // namespace detail + +// basic_directory_iterator ------------------------------------------------// + + template< class Path > + class basic_directory_iterator + : public boost::iterator_facade< + basic_directory_iterator, + basic_directory_entry, + boost::single_pass_traversal_tag > + { + public: + typedef Path path_type; + + basic_directory_iterator(){} // creates the "end" iterator + + explicit basic_directory_iterator( const Path & dir_path ); + basic_directory_iterator( const Path & dir_path, system::error_code & ec ); + + private: + + // shared_ptr provides shallow-copy semantics required for InputIterators. + // m_imp.get()==0 indicates the end iterator. + boost::shared_ptr< detail::dir_itr_imp< Path > > m_imp; + + friend class boost::iterator_core_access; + + typename boost::iterator_facade< + basic_directory_iterator, + basic_directory_entry, + boost::single_pass_traversal_tag >::reference dereference() const + { + BOOST_ASSERT( m_imp.get() && "attempt to dereference end iterator" ); + return m_imp->m_directory_entry; + } + + void increment(); + + bool equal( const basic_directory_iterator & rhs ) const + { return m_imp == rhs.m_imp; } + + system::error_code m_init( const Path & dir_path ); + }; + + typedef basic_directory_iterator< path > directory_iterator; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_directory_iterator< wpath > wdirectory_iterator; +# endif + + // basic_directory_iterator implementation ---------------------------// + + template + system::error_code basic_directory_iterator::m_init( + const Path & dir_path ) + { + if ( dir_path.empty() ) + { + m_imp.reset(); + return detail::not_found_error(); + } + typename Path::external_string_type name; + file_status fs, symlink_fs; + system::error_code ec( detail::dir_itr_first( m_imp->m_handle, +#if defined(BOOST_POSIX_API) + m_imp->m_buffer, +#endif + dir_path.external_directory_string(), + name, fs, symlink_fs ) ); + + if ( ec ) + { + m_imp.reset(); + return ec; + } + + if ( m_imp->m_handle == 0 ) m_imp.reset(); // eof, so make end iterator + else // not eof + { + m_imp->m_directory_entry.assign( dir_path + / Path::traits_type::to_internal( name ), fs, symlink_fs ); + if ( name[0] == dot::value // dot or dot-dot + && (name.size() == 1 + || (name[1] == dot::value + && name.size() == 2)) ) + { increment(); } + } + return boost::system::error_code(); + } + + template + basic_directory_iterator::basic_directory_iterator( + const Path & dir_path ) + : m_imp( new detail::dir_itr_imp ) + { + system::error_code ec( m_init(dir_path) ); + if ( ec ) + { + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::basic_directory_iterator constructor", + dir_path, ec ) ); + } + } + + template + basic_directory_iterator::basic_directory_iterator( + const Path & dir_path, system::error_code & ec ) + : m_imp( new detail::dir_itr_imp ) + { + ec = m_init(dir_path); + } + + template + void basic_directory_iterator::increment() + { + BOOST_ASSERT( m_imp.get() && "attempt to increment end iterator" ); + BOOST_ASSERT( m_imp->m_handle != 0 && "internal program error" ); + + typename Path::external_string_type name; + file_status fs, symlink_fs; + system::error_code ec; + + for (;;) + { + ec = detail::dir_itr_increment( m_imp->m_handle, +#if defined(BOOST_POSIX_API) + m_imp->m_buffer, +#endif + name, fs, symlink_fs ); + if ( ec ) + { + boost::throw_exception( basic_filesystem_error( + "boost::filesystem::basic_directory_iterator increment", + m_imp->m_directory_entry.path().parent_path(), ec ) ); + } + if ( m_imp->m_handle == 0 ) { m_imp.reset(); return; } // eof, make end + if ( !(name[0] == dot::value // !(dot or dot-dot) + && (name.size() == 1 + || (name[1] == dot::value + && name.size() == 2))) ) + { + m_imp->m_directory_entry.replace_filename( + Path::traits_type::to_internal( name ), fs, symlink_fs ); + return; + } + } + } + + // basic_directory_entry -----------------------------------------------// + + template + class basic_directory_entry + { + public: + typedef Path path_type; + typedef typename Path::string_type string_type; + + // compiler generated copy-ctor, copy assignment, and destructor apply + + basic_directory_entry() {} + explicit basic_directory_entry( const path_type & p, + file_status st = file_status(), file_status symlink_st=file_status() ) + : m_path(p), m_status(st), m_symlink_status(symlink_st) + {} + + void assign( const path_type & p, + file_status st, file_status symlink_st ) + { m_path = p; m_status = st; m_symlink_status = symlink_st; } + + void replace_filename( const string_type & s, + file_status st, file_status symlink_st ) + { + m_path.remove_filename(); + m_path /= s; + m_status = st; + m_symlink_status = symlink_st; + } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + void replace_leaf( const string_type & s, + file_status st, file_status symlink_st ) + { replace_filename( s, st, symlink_st ); } +# endif + + const Path & path() const { return m_path; } + file_status status() const; + file_status status( system::error_code & ec ) const; + file_status symlink_status() const; + file_status symlink_status( system::error_code & ec ) const; + + // conversion simplifies the most common use of basic_directory_entry + operator const path_type &() const { return m_path; } + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + // deprecated functions preserve common use cases in legacy code + typename Path::string_type filename() const + { + return path().filename(); + } + typename Path::string_type leaf() const + { + return path().filename(); + } + typename Path::string_type string() const + { + return path().string(); + } +# endif + + private: + path_type m_path; + mutable file_status m_status; // stat()-like + mutable file_status m_symlink_status; // lstat()-like + // note: m_symlink_status is not used by Windows implementation + + }; // basic_directory_status + + typedef basic_directory_entry directory_entry; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_directory_entry wdirectory_entry; +# endif + + // basic_directory_entry implementation --------------------------------// + + template + file_status + basic_directory_entry::status() const + { + if ( !status_known( m_status ) ) + { +# ifndef BOOST_WINDOWS_API + if ( status_known( m_symlink_status ) + && !is_symlink( m_symlink_status ) ) + { m_status = m_symlink_status; } + else { m_status = boost::filesystem::status( m_path ); } +# else + m_status = boost::filesystem::status( m_path ); +# endif + } + return m_status; + } + + template + file_status + basic_directory_entry::status( system::error_code & ec ) const + { + if ( !status_known( m_status ) ) + { +# ifndef BOOST_WINDOWS_API + if ( status_known( m_symlink_status ) + && !is_symlink( m_symlink_status ) ) + { ec = boost::system::error_code();; m_status = m_symlink_status; } + else { m_status = boost::filesystem::status( m_path, ec ); } +# else + m_status = boost::filesystem::status( m_path, ec ); +# endif + } + else ec = boost::system::error_code();; + return m_status; + } + + template + file_status + basic_directory_entry::symlink_status() const + { +# ifndef BOOST_WINDOWS_API + if ( !status_known( m_symlink_status ) ) + { m_symlink_status = boost::filesystem::symlink_status( m_path ); } + return m_symlink_status; +# else + return status(); +# endif + } + + template + file_status + basic_directory_entry::symlink_status( system::error_code & ec ) const + { +# ifndef BOOST_WINDOWS_API + if ( !status_known( m_symlink_status ) ) + { m_symlink_status = boost::filesystem::symlink_status( m_path, ec ); } + else ec = boost::system::error_code();; + return m_symlink_status; +# else + return status( ec ); +# endif + } + } // namespace filesystem +} // namespace boost + +#undef BOOST_FS_FUNC + + +#include // pops abi_prefix.hpp pragmas +#endif // BOOST_FILESYSTEM_OPERATIONS_HPP diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/filesystem/path.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/filesystem/path.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,1507 @@ +// boost/filesystem/path.hpp -----------------------------------------------// + +// Copyright Beman Dawes 2002-2005 +// Copyright Vladimir Prus 2002 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/filesystem + +// basic_path's stem(), extension(), and replace_extension() are based on +// basename(), extension(), and change_extension() from the original +// filesystem/convenience.hpp header by Vladimir Prus. + +//----------------------------------------------------------------------------// + +#ifndef BOOST_FILESYSTEM_PATH_HPP +#define BOOST_FILESYSTEM_PATH_HPP + +#include +#include +#include +#include +#include +#include +#include + +#include +#include // for lexicographical_compare +#include // needed by basic_path inserter and extractor +#include +#include + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY +# include +# endif + +#include // must be the last #include + +//----------------------------------------------------------------------------// + +namespace boost +{ + namespace BOOST_FILESYSTEM_NAMESPACE + { + template class basic_path; + + struct path_traits; + typedef basic_path< std::string, path_traits > path; + + struct path_traits + { + typedef std::string internal_string_type; + typedef std::string external_string_type; + static external_string_type to_external( const path &, + const internal_string_type & src ) { return src; } + static internal_string_type to_internal( + const external_string_type & src ) { return src; } + }; + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + struct BOOST_FILESYSTEM_DECL wpath_traits; + + typedef basic_path< std::wstring, wpath_traits > wpath; + + struct BOOST_FILESYSTEM_DECL wpath_traits + { + typedef std::wstring internal_string_type; +# ifdef BOOST_WINDOWS_API + typedef std::wstring external_string_type; + static external_string_type to_external( const wpath &, + const internal_string_type & src ) { return src; } + static internal_string_type to_internal( + const external_string_type & src ) { return src; } +# else + typedef std::string external_string_type; + static external_string_type to_external( const wpath & ph, + const internal_string_type & src ); + static internal_string_type to_internal( + const external_string_type & src ); +# endif + static void imbue( const std::locale & loc ); + static bool imbue( const std::locale & loc, const std::nothrow_t & ); + }; + +# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // path traits ---------------------------------------------------------// + + template struct is_basic_path + { BOOST_STATIC_CONSTANT( bool, value = false ); }; + template<> struct is_basic_path + { BOOST_STATIC_CONSTANT( bool, value = true ); }; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template<> struct is_basic_path + { BOOST_STATIC_CONSTANT( bool, value = true ); }; +# endif + + // These only have to be specialized if Path::string_type::value_type + // is not convertible from char, although specializations may eliminate + // compiler warnings. See ticket 2543. + template struct slash + { BOOST_STATIC_CONSTANT( char, value = '/' ); }; + + template struct dot + { BOOST_STATIC_CONSTANT( char, value = '.' ); }; + + template struct colon + { BOOST_STATIC_CONSTANT( char, value = ':' ); }; + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template<> struct slash + { BOOST_STATIC_CONSTANT( wchar_t, value = L'/' ); }; + template<> struct dot + { BOOST_STATIC_CONSTANT( wchar_t, value = L'.' ); }; + template<> struct colon + { BOOST_STATIC_CONSTANT( wchar_t, value = L':' ); }; +# endif + +# ifdef BOOST_WINDOWS_PATH + template struct path_alt_separator + { BOOST_STATIC_CONSTANT( char, value = '\\' ); }; +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + template<> struct path_alt_separator + { BOOST_STATIC_CONSTANT( wchar_t, value = L'\\' ); }; +# endif +# endif + + // workaround for VC++ 7.0 and earlier issues with nested classes + namespace detail + { + template + class iterator_helper + { + public: + typedef typename Path::iterator iterator; + static void do_increment( iterator & ph ); + static void do_decrement( iterator & ph ); + }; + } + + // basic_path ----------------------------------------------------------// + + template + class basic_path + { + // invariant: m_path valid according to the portable generic path grammar + + // validate template arguments +// TODO: get these working +// BOOST_STATIC_ASSERT( ::boost::is_same::value ); +// BOOST_STATIC_ASSERT( ::boost::is_same::value || ::boost::is_same::value ); + + public: + // compiler generates copy constructor and copy assignment + + typedef basic_path path_type; + typedef String string_type; + typedef typename String::value_type value_type; + typedef Traits traits_type; + typedef typename Traits::external_string_type external_string_type; + + // constructors/destructor + basic_path() {} + basic_path( const string_type & s ) { operator/=( s ); } + basic_path( const value_type * s ) { operator/=( s ); } +# ifndef BOOST_NO_MEMBER_TEMPLATES + template + basic_path( InputIterator first, InputIterator last ) + { append( first, last ); } +# endif + ~basic_path() {} + + // assignments + basic_path & operator=( const string_type & s ) + { +# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, >= 310) + m_path.clear(); +# else + m_path.erase( m_path.begin(), m_path.end() ); +# endif + operator/=( s ); + return *this; + } + basic_path & operator=( const value_type * s ) + { +# if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, >= 310) + m_path.clear(); +# else + m_path.erase( m_path.begin(), m_path.end() ); +# endif + operator/=( s ); + return *this; + } +# ifndef BOOST_NO_MEMBER_TEMPLATES + template + basic_path & assign( InputIterator first, InputIterator last ) + { m_path.clear(); append( first, last ); return *this; } +# endif + + // modifiers + basic_path & operator/=( const basic_path & rhs ) { return operator /=( rhs.string().c_str() ); } + basic_path & operator/=( const string_type & rhs ) { return operator /=( rhs.c_str() ); } + basic_path & operator/=( const value_type * s ); +# ifndef BOOST_NO_MEMBER_TEMPLATES + template + basic_path & append( InputIterator first, InputIterator last ); +# endif + + void swap( basic_path & rhs ) + { + m_path.swap( rhs.m_path ); +# ifdef BOOST_CYGWIN_PATH + std::swap( m_cygwin_root, rhs.m_cygwin_root ); +# endif + } + + basic_path & remove_filename(); + basic_path & replace_extension( const string_type & new_extension = string_type() ); + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + basic_path & remove_leaf() { return remove_filename(); } +# endif + + // observers + const string_type & string() const { return m_path; } + const string_type file_string() const; + const string_type directory_string() const { return file_string(); } + + const external_string_type external_file_string() const { return Traits::to_external( *this, file_string() ); } + const external_string_type external_directory_string() const { return Traits::to_external( *this, directory_string() ); } + + basic_path root_path() const; + string_type root_name() const; + string_type root_directory() const; + basic_path relative_path() const; + basic_path parent_path() const; + string_type filename() const; + string_type stem() const; + string_type extension() const; + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + string_type leaf() const { return filename(); } + basic_path branch_path() const { return parent_path(); } + bool has_leaf() const { return !m_path.empty(); } + bool has_branch_path() const { return !parent_path().empty(); } +# endif + + bool empty() const { return m_path.empty(); } // name consistent with std containers + bool is_complete() const; + bool has_root_path() const; + bool has_root_name() const; + bool has_root_directory() const; + bool has_relative_path() const { return !relative_path().empty(); } + bool has_filename() const { return !m_path.empty(); } + bool has_parent_path() const { return !parent_path().empty(); } + + // iterators + class iterator : public boost::iterator_facade< + iterator, + string_type const, + boost::bidirectional_traversal_tag > + { + private: + friend class boost::iterator_core_access; + friend class boost::BOOST_FILESYSTEM_NAMESPACE::basic_path; + + const string_type & dereference() const + { return m_name; } + bool equal( const iterator & rhs ) const + { return m_path_ptr == rhs.m_path_ptr && m_pos == rhs.m_pos; } + + friend class boost::BOOST_FILESYSTEM_NAMESPACE::detail::iterator_helper; + + void increment() + { + boost::BOOST_FILESYSTEM_NAMESPACE::detail::iterator_helper::do_increment( + *this ); + } + void decrement() + { + boost::BOOST_FILESYSTEM_NAMESPACE::detail::iterator_helper::do_decrement( + *this ); + } + + string_type m_name; // current element + const basic_path * m_path_ptr; // path being iterated over + typename string_type::size_type m_pos; // position of name in + // path_ptr->string(). The + // end() iterator is indicated by + // pos == path_ptr->m_path.size() + }; // iterator + + typedef iterator const_iterator; + + iterator begin() const; + iterator end() const; + + private: + // Note: This is an implementation for POSIX and Windows, where there + // are only minor differences between generic and native path grammars. + // Private members might be quite different in other implementations, + // particularly where there were wide differences between portable and + // native path formats, or between file_string() and + // directory_string() formats, or simply that the implementation + // was willing expend additional memory to achieve greater speed for + // some operations at the expense of other operations. + + string_type m_path; // invariant: portable path grammar + // on Windows, backslashes converted to slashes + +# ifdef BOOST_CYGWIN_PATH + bool m_cygwin_root; // if present, m_path[0] was slash. note: initialization + // done by append +# endif + + void m_append_separator_if_needed(); + void m_append( value_type value ); // converts Windows alt_separator + + // Was qualified; como433beta8 reports: + // warning #427-D: qualified name is not allowed in member declaration + friend class iterator; + friend class boost::BOOST_FILESYSTEM_NAMESPACE::detail::iterator_helper; + + // Deprecated features ease transition for existing code. Don't use these + // in new code. +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + public: + typedef bool (*name_check)( const std::string & name ); + basic_path( const string_type & str, name_check ) { operator/=( str ); } + basic_path( const typename string_type::value_type * s, name_check ) + { operator/=( s );} + string_type native_file_string() const { return file_string(); } + string_type native_directory_string() const { return directory_string(); } + static bool default_name_check_writable() { return false; } + static void default_name_check( name_check ) {} + static name_check default_name_check() { return 0; } + basic_path & canonize(); + basic_path & normalize(); +# endif + }; + + // basic_path non-member functions ---------------------------------------// + + template< class String, class Traits > + inline void swap( basic_path & lhs, + basic_path & rhs ) { lhs.swap( rhs ); } + + template< class String, class Traits > + bool operator<( const basic_path & lhs, const basic_path & rhs ) + { + return std::lexicographical_compare( + lhs.begin(), lhs.end(), rhs.begin(), rhs.end() ); + } + + template< class String, class Traits > + bool operator<( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) + { + basic_path tmp( lhs ); + return std::lexicographical_compare( + tmp.begin(), tmp.end(), rhs.begin(), rhs.end() ); + } + + template< class String, class Traits > + bool operator<( const typename basic_path::string_type & lhs, + const basic_path & rhs ) + { + basic_path tmp( lhs ); + return std::lexicographical_compare( + tmp.begin(), tmp.end(), rhs.begin(), rhs.end() ); + } + + template< class String, class Traits > + bool operator<( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { + basic_path tmp( rhs ); + return std::lexicographical_compare( + lhs.begin(), lhs.end(), tmp.begin(), tmp.end() ); + } + + template< class String, class Traits > + bool operator<( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { + basic_path tmp( rhs ); + return std::lexicographical_compare( + lhs.begin(), lhs.end(), tmp.begin(), tmp.end() ); + } + + // operator == uses string compare rather than !(lhs < rhs) && !(rhs < lhs) because + // the result is the same yet the direct string compare is much more efficient that + // lexicographical_compare, and lexicographical_compare used twice at that. + + template< class String, class Traits > + inline bool operator==( const basic_path & lhs, const basic_path & rhs ) + { + return lhs.string() == rhs.string(); + } + + template< class String, class Traits > + inline bool operator==( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) + { + return lhs == rhs.string(); + } + + template< class String, class Traits > + inline bool operator==( const typename basic_path::string_type & lhs, + const basic_path & rhs ) + { + return lhs == rhs.string(); + } + + template< class String, class Traits > + inline bool operator==( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { + return lhs.string() == rhs; + } + + template< class String, class Traits > + inline bool operator==( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { + return lhs.string() == rhs; + } + + template< class String, class Traits > + inline bool operator!=( const basic_path & lhs, + const basic_path & rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator!=( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator!=( const typename basic_path::string_type & lhs, + const basic_path & rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator!=( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator!=( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { return !(lhs == rhs); } + + template< class String, class Traits > + inline bool operator>( const basic_path & lhs, const basic_path & rhs ) { return rhs < lhs; } + + template< class String, class Traits > + inline bool operator>( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) { return rhs < basic_path(lhs); } + + template< class String, class Traits > + inline bool operator>( const typename basic_path::string_type & lhs, + const basic_path & rhs ) { return rhs < basic_path(lhs); } + + template< class String, class Traits > + inline bool operator>( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { return basic_path(rhs) < lhs; } + + template< class String, class Traits > + inline bool operator>( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { return basic_path(rhs) < lhs; } + + template< class String, class Traits > + inline bool operator<=( const basic_path & lhs, const basic_path & rhs ) { return !(rhs < lhs); } + + template< class String, class Traits > + inline bool operator<=( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) { return !(rhs < basic_path(lhs)); } + + template< class String, class Traits > + inline bool operator<=( const typename basic_path::string_type & lhs, + const basic_path & rhs ) { return !(rhs < basic_path(lhs)); } + + template< class String, class Traits > + inline bool operator<=( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { return !(basic_path(rhs) < lhs); } + + template< class String, class Traits > + inline bool operator<=( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { return !(basic_path(rhs) < lhs); } + + template< class String, class Traits > + inline bool operator>=( const basic_path & lhs, const basic_path & rhs ) { return !(lhs < rhs); } + + template< class String, class Traits > + inline bool operator>=( const typename basic_path::string_type::value_type * lhs, + const basic_path & rhs ) { return !(lhs < basic_path(rhs)); } + + template< class String, class Traits > + inline bool operator>=( const typename basic_path::string_type & lhs, + const basic_path & rhs ) { return !(lhs < basic_path(rhs)); } + + template< class String, class Traits > + inline bool operator>=( const basic_path & lhs, + const typename basic_path::string_type::value_type * rhs ) + { return !(basic_path(lhs) < rhs); } + + template< class String, class Traits > + inline bool operator>=( const basic_path & lhs, + const typename basic_path::string_type & rhs ) + { return !(basic_path(lhs) < rhs); } + + // operator / + + template< class String, class Traits > + inline basic_path operator/( + const basic_path & lhs, + const basic_path & rhs ) + { return basic_path( lhs ) /= rhs; } + + template< class String, class Traits > + inline basic_path operator/( + const basic_path & lhs, + const typename String::value_type * rhs ) + { return basic_path( lhs ) /= + basic_path( rhs ); } + + template< class String, class Traits > + inline basic_path operator/( + const basic_path & lhs, const String & rhs ) + { return basic_path( lhs ) /= + basic_path( rhs ); } + + template< class String, class Traits > + inline basic_path operator/( + const typename String::value_type * lhs, + const basic_path & rhs ) + { return basic_path( lhs ) /= rhs; } + + template< class String, class Traits > + inline basic_path operator/( + const String & lhs, const basic_path & rhs ) + { return basic_path( lhs ) /= rhs; } + + // inserters and extractors --------------------------------------------// + +// bypass VC++ 7.0 and earlier, and broken Borland compilers +# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__BORLANDC__, < 0x610) + template< class Path > + std::basic_ostream< typename Path::string_type::value_type, + typename Path::string_type::traits_type > & + operator<< + ( std::basic_ostream< typename Path::string_type::value_type, + typename Path::string_type::traits_type >& os, const Path & ph ) + { + os << ph.string(); + return os; + } + + template< class Path > + std::basic_istream< typename Path::string_type::value_type, + typename Path::string_type::traits_type > & + operator>> + ( std::basic_istream< typename Path::string_type::value_type, + typename Path::string_type::traits_type >& is, Path & ph ) + { + typename Path::string_type str; + is >> str; + ph = str; + return is; + } +# elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + template< class String, class Traits > + std::basic_ostream< BOOST_DEDUCED_TYPENAME String::value_type, + BOOST_DEDUCED_TYPENAME String::traits_type > & + operator<< + ( std::basic_ostream< BOOST_DEDUCED_TYPENAME String::value_type, + BOOST_DEDUCED_TYPENAME String::traits_type >& os, + const basic_path< String, Traits > & ph ) + { + os << ph.string(); + return os; + } + + template< class String, class Traits > + std::basic_istream< BOOST_DEDUCED_TYPENAME String::value_type, + BOOST_DEDUCED_TYPENAME String::traits_type > & + operator>> + ( std::basic_istream< BOOST_DEDUCED_TYPENAME String::value_type, + BOOST_DEDUCED_TYPENAME String::traits_type> & is, + basic_path< String, Traits > & ph ) + { + String str; + is >> str; + ph = str; + return is; + } +# endif + + // basic_filesystem_error helpers --------------------------------------// + + // Originally choice of implementation was done via specialization of + // basic_filesystem_error::what(). Several compilers (GCC, aCC, etc.) + // couldn't handle that, so the choice is now accomplished by overloading. + + namespace detail + { + // BOOST_FILESYSTEM_DECL version works for VC++ but not GCC. Go figure! + inline + const char * what( const char * sys_err_what, + const path & path1_arg, const path & path2_arg, std::string & target ) + { + try + { + if ( target.empty() ) + { + target = sys_err_what; + if ( !path1_arg.empty() ) + { + target += ": \""; + target += path1_arg.file_string(); + target += "\""; + } + if ( !path2_arg.empty() ) + { + target += ", \""; + target += path2_arg.file_string(); + target += "\""; + } + } + return target.c_str(); + } + catch (...) + { + return sys_err_what; + } + } + + template + const char * what( const char * sys_err_what, + const Path & /*path1_arg*/, const Path & /*path2_arg*/, std::string & /*target*/ ) + { + return sys_err_what; + } + } + + // basic_filesystem_error ----------------------------------------------// + + template + class basic_filesystem_error : public system::system_error + { + // see http://www.boost.org/more/error_handling.html for design rationale + public: + // compiler generates copy constructor and copy assignment + + typedef Path path_type; + + basic_filesystem_error( const std::string & what_arg, + system::error_code ec ); + + basic_filesystem_error( const std::string & what_arg, + const path_type & path1_arg, system::error_code ec ); + + basic_filesystem_error( const std::string & what_arg, const path_type & path1_arg, + const path_type & path2_arg, system::error_code ec ); + + ~basic_filesystem_error() throw() {} + + const path_type & path1() const + { + static const path_type empty_path; + return m_imp_ptr.get() ? m_imp_ptr->m_path1 : empty_path ; + } + const path_type & path2() const + { + static const path_type empty_path; + return m_imp_ptr.get() ? m_imp_ptr->m_path2 : empty_path ; + } + + const char * what() const throw() + { + if ( !m_imp_ptr.get() ) + return system::system_error::what(); + return detail::what( system::system_error::what(), m_imp_ptr->m_path1, + m_imp_ptr->m_path2, m_imp_ptr->m_what ); + } + + private: + struct m_imp + { + path_type m_path1; // may be empty() + path_type m_path2; // may be empty() + std::string m_what; // not built until needed + }; + boost::shared_ptr m_imp_ptr; + }; + + typedef basic_filesystem_error filesystem_error; + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + typedef basic_filesystem_error wfilesystem_error; +# endif + + // path::name_checks -----------------------------------------------------// + + BOOST_FILESYSTEM_DECL bool portable_posix_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool windows_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool portable_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool portable_directory_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool portable_file_name( const std::string & name ); + BOOST_FILESYSTEM_DECL bool native( const std::string & name ); + inline bool no_check( const std::string & ) + { return true; } + +// implementation -----------------------------------------------------------// + + namespace detail + { + + // is_separator helper ------------------------------------------------// + + template + inline bool is_separator( typename Path::string_type::value_type c ) + { + return c == slash::value +# ifdef BOOST_WINDOWS_PATH + || c == path_alt_separator::value +# endif + ; + } + + // filename_pos helper ----------------------------------------------------// + + template + typename String::size_type filename_pos( + const String & str, // precondition: portable generic path grammar + typename String::size_type end_pos ) // end_pos is past-the-end position + // return 0 if str itself is filename (or empty) + { + typedef typename + boost::BOOST_FILESYSTEM_NAMESPACE::basic_path path_type; + + // case: "//" + if ( end_pos == 2 + && str[0] == slash::value + && str[1] == slash::value ) return 0; + + // case: ends in "/" + if ( end_pos && str[end_pos-1] == slash::value ) + return end_pos-1; + + // set pos to start of last element + typename String::size_type pos( + str.find_last_of( slash::value, end_pos-1 ) ); +# ifdef BOOST_WINDOWS_PATH + if ( pos == String::npos ) + pos = str.find_last_of( path_alt_separator::value, end_pos-1 ); + if ( pos == String::npos ) + pos = str.find_last_of( colon::value, end_pos-2 ); +# endif + + return ( pos == String::npos // path itself must be a filename (or empty) + || (pos == 1 && str[0] == slash::value) ) // or net + ? 0 // so filename is entire string + : pos + 1; // or starts after delimiter + } + + // first_element helper -----------------------------------------------// + // sets pos and len of first element, excluding extra separators + // if src.empty(), sets pos,len, to 0,0. + + template + void first_element( + const String & src, // precondition: portable generic path grammar + typename String::size_type & element_pos, + typename String::size_type & element_size, +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1310 ) // VC++ 7.1 + typename String::size_type size = String::npos +# else + typename String::size_type size = -1 +# endif + ) + { + if ( size == String::npos ) size = src.size(); + element_pos = 0; + element_size = 0; + if ( src.empty() ) return; + + typedef typename boost::BOOST_FILESYSTEM_NAMESPACE::basic_path path_type; + + typename String::size_type cur(0); + + // deal with // [network] + if ( size >= 2 && src[0] == slash::value + && src[1] == slash::value + && (size == 2 + || src[2] != slash::value) ) + { + cur += 2; + element_size += 2; + } + + // leading (not non-network) separator + else if ( src[0] == slash::value ) + { + ++element_size; + // bypass extra leading separators + while ( cur+1 < size + && src[cur+1] == slash::value ) + { + ++cur; + ++element_pos; + } + return; + } + + // at this point, we have either a plain name, a network name, + // or (on Windows only) a device name + + // find the end + while ( cur < size +# ifdef BOOST_WINDOWS_PATH + && src[cur] != colon::value +# endif + && src[cur] != slash::value ) + { + ++cur; + ++element_size; + } + +# ifdef BOOST_WINDOWS_PATH + if ( cur == size ) return; + // include device delimiter + if ( src[cur] == colon::value ) + { ++element_size; } +# endif + + return; + } + + // root_directory_start helper ----------------------------------------// + + template + typename String::size_type root_directory_start( + const String & s, // precondition: portable generic path grammar + typename String::size_type size ) + // return npos if no root_directory found + { + typedef typename boost::BOOST_FILESYSTEM_NAMESPACE::basic_path path_type; + +# ifdef BOOST_WINDOWS_PATH + // case "c:/" + if ( size > 2 + && s[1] == colon::value + && s[2] == slash::value ) return 2; +# endif + + // case "//" + if ( size == 2 + && s[0] == slash::value + && s[1] == slash::value ) return String::npos; + + // case "//net {/}" + if ( size > 3 + && s[0] == slash::value + && s[1] == slash::value + && s[2] != slash::value ) + { + typename String::size_type pos( + s.find( slash::value, 2 ) ); + return pos < size ? pos : String::npos; + } + + // case "/" + if ( size > 0 && s[0] == slash::value ) return 0; + + return String::npos; + } + + // is_non_root_slash helper -------------------------------------------// + + template + bool is_non_root_slash( const String & str, + typename String::size_type pos ) // pos is position of the slash + { + typedef typename + boost::BOOST_FILESYSTEM_NAMESPACE::basic_path + path_type; + + assert( !str.empty() && str[pos] == slash::value + && "precondition violation" ); + + // subsequent logic expects pos to be for leftmost slash of a set + while ( pos > 0 && str[pos-1] == slash::value ) + --pos; + + return pos != 0 + && (pos <= 2 || str[1] != slash::value + || str.find( slash::value, 2 ) != pos) +# ifdef BOOST_WINDOWS_PATH + && (pos !=2 || str[1] != colon::value) +# endif + ; + } + } // namespace detail + + // decomposition functions ----------------------------------------------// + + template + String basic_path::filename() const + { + typename String::size_type end_pos( + detail::filename_pos( m_path, m_path.size() ) ); + return (m_path.size() + && end_pos + && m_path[end_pos] == slash::value + && detail::is_non_root_slash< String, Traits >(m_path, end_pos)) + ? String( 1, dot::value ) + : m_path.substr( end_pos ); + } + + template + String basic_path::stem() const + { + string_type name = filename(); + typename string_type::size_type n = name.rfind('.'); + return name.substr(0, n); + } + + template + String basic_path::extension() const + { + string_type name = filename(); + typename string_type::size_type n = name.rfind('.'); + if (n != string_type::npos) + return name.substr(n); + else + return string_type(); + } + + template + basic_path basic_path::parent_path() const + { + typename String::size_type end_pos( + detail::filename_pos( m_path, m_path.size() ) ); + + bool filename_was_separator( m_path.size() + && m_path[end_pos] == slash::value ); + + // skip separators unless root directory + typename string_type::size_type root_dir_pos( detail::root_directory_start + ( m_path, end_pos ) ); + for ( ; + end_pos > 0 + && (end_pos-1) != root_dir_pos + && m_path[end_pos-1] == slash::value + ; + --end_pos ) {} + + return (end_pos == 1 && root_dir_pos == 0 && filename_was_separator) + ? path_type() + : path_type( m_path.substr( 0, end_pos ) ); + } + + template + basic_path basic_path::relative_path() const + { + iterator itr( begin() ); + for ( ; itr.m_pos != m_path.size() + && (itr.m_name[0] == slash::value +# ifdef BOOST_WINDOWS_PATH + || itr.m_name[itr.m_name.size()-1] + == colon::value +# endif + ); ++itr ) {} + + return basic_path( m_path.substr( itr.m_pos ) ); + } + + template + String basic_path::root_name() const + { + iterator itr( begin() ); + + return ( itr.m_pos != m_path.size() + && ( + ( itr.m_name.size() > 1 + && itr.m_name[0] == slash::value + && itr.m_name[1] == slash::value + ) +# ifdef BOOST_WINDOWS_PATH + || itr.m_name[itr.m_name.size()-1] + == colon::value +# endif + ) ) + ? *itr + : String(); + } + + template + String basic_path::root_directory() const + { + typename string_type::size_type start( + detail::root_directory_start( m_path, m_path.size() ) ); + + return start == string_type::npos + ? string_type() + : m_path.substr( start, 1 ); + } + + template + basic_path basic_path::root_path() const + { + // even on POSIX, root_name() is non-empty() on network paths + return basic_path( root_name() ) /= root_directory(); + } + + // path query functions -------------------------------------------------// + + template + inline bool basic_path::is_complete() const + { +# ifdef BOOST_WINDOWS_PATH + return has_root_name() && has_root_directory(); +# else + return has_root_directory(); +# endif + } + + template + inline bool basic_path::has_root_path() const + { + return !root_path().empty(); + } + + template + inline bool basic_path::has_root_name() const + { + return !root_name().empty(); + } + + template + inline bool basic_path::has_root_directory() const + { + return !root_directory().empty(); + } + + // append ---------------------------------------------------------------// + + template + void basic_path::m_append_separator_if_needed() + // requires: !empty() + { + if ( +# ifdef BOOST_WINDOWS_PATH + *(m_path.end()-1) != colon::value && +# endif + *(m_path.end()-1) != slash::value ) + { + m_path += slash::value; + } + } + + template + void basic_path::m_append( value_type value ) + { +# ifdef BOOST_CYGWIN_PATH + if ( m_path.empty() ) m_cygwin_root = (value == slash::value); +# endif + +# ifdef BOOST_WINDOWS_PATH + // for BOOST_WINDOWS_PATH, convert alt_separator ('\') to separator ('/') + m_path += ( value == path_alt_separator::value + ? slash::value + : value ); +# else + m_path += value; +# endif + } + + // except that it wouldn't work for BOOST_NO_MEMBER_TEMPLATES compilers, + // the append() member template could replace this code. + template + basic_path & basic_path::operator /= + ( const value_type * next_p ) + { + // ignore escape sequence on POSIX or Windows + if ( *next_p == slash::value + && *(next_p+1) == slash::value + && *(next_p+2) == colon::value ) next_p += 3; + + // append slash::value if needed + if ( !empty() && *next_p != 0 + && !detail::is_separator( *next_p ) ) + { m_append_separator_if_needed(); } + + for ( ; *next_p != 0; ++next_p ) m_append( *next_p ); + return *this; + } + +# ifndef BOOST_NO_MEMBER_TEMPLATES + template template + basic_path & basic_path::append( + InputIterator first, InputIterator last ) + { + // append slash::value if needed + if ( !empty() && first != last + && !detail::is_separator( *first ) ) + { m_append_separator_if_needed(); } + + // song-and-dance to avoid violating InputIterator requirements + // (which prohibit lookahead) in detecting a possible escape sequence + // (escape sequences are simply ignored on POSIX and Windows) + bool was_escape_sequence(true); + std::size_t append_count(0); + typename String::size_type initial_pos( m_path.size() ); + + for ( ; first != last && *first; ++first ) + { + if ( append_count == 0 && *first != slash::value ) + was_escape_sequence = false; + if ( append_count == 1 && *first != slash::value ) + was_escape_sequence = false; + if ( append_count == 2 && *first != colon::value ) + was_escape_sequence = false; + m_append( *first ); + ++append_count; + } + + // erase escape sequence if any + if ( was_escape_sequence && append_count >= 3 ) + m_path.erase( initial_pos, 3 ); + + return *this; + } +# endif + +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED + + // canonize ------------------------------------------------------------// + + template + basic_path & basic_path::canonize() + { + static const typename string_type::value_type dot_str[] + = { dot::value, 0 }; + + if ( m_path.empty() ) return *this; + + path_type temp; + + for ( iterator itr( begin() ); itr != end(); ++itr ) + { + temp /= *itr; + }; + + if ( temp.empty() ) temp /= dot_str; + m_path = temp.m_path; + return *this; + } + + // normalize ------------------------------------------------------------// + + template + basic_path & basic_path::normalize() + { + static const typename string_type::value_type dot_str[] + = { dot::value, 0 }; + + if ( m_path.empty() ) return *this; + + path_type temp; + iterator start( begin() ); + iterator last( end() ); + iterator stop( last-- ); + for ( iterator itr( start ); itr != stop; ++itr ) + { + // ignore "." except at start and last + if ( itr->size() == 1 + && (*itr)[0] == dot::value + && itr != start + && itr != last ) continue; + + // ignore a name and following ".." + if ( !temp.empty() + && itr->size() == 2 + && (*itr)[0] == dot::value + && (*itr)[1] == dot::value ) // dot dot + { + string_type lf( temp.filename() ); + if ( lf.size() > 0 + && (lf.size() != 1 + || (lf[0] != dot::value + && lf[0] != slash::value)) + && (lf.size() != 2 + || (lf[0] != dot::value + && lf[1] != dot::value +# ifdef BOOST_WINDOWS_PATH + && lf[1] != colon::value +# endif + ) + ) + ) + { + temp.remove_filename(); + // if not root directory, must also remove "/" if any + if ( temp.m_path.size() > 0 + && temp.m_path[temp.m_path.size()-1] + == slash::value ) + { + typename string_type::size_type rds( + detail::root_directory_start( temp.m_path, + temp.m_path.size() ) ); + if ( rds == string_type::npos + || rds != temp.m_path.size()-1 ) + { temp.m_path.erase( temp.m_path.size()-1 ); } + } + + iterator next( itr ); + if ( temp.empty() && ++next != stop + && next == last && *last == dot_str ) temp /= dot_str; + continue; + } + } + + temp /= *itr; + }; + + if ( temp.empty() ) temp /= dot_str; + m_path = temp.m_path; + return *this; + } + +# endif + + // modifiers ------------------------------------------------------------// + + template + basic_path & basic_path::remove_filename() + { + m_path.erase( + detail::filename_pos( m_path, m_path.size() ) ); + return *this; + } + + template + basic_path & + basic_path::replace_extension( const string_type & new_ext ) + { + // erase existing extension if any + string_type old_ext = extension(); + if ( !old_ext.empty() ) + m_path.erase( m_path.size() - old_ext.size() ); + + if ( !new_ext.empty() && new_ext[0] != dot::value ) + m_path += dot::value; + + m_path += new_ext; + + return *this; + } + + + // path conversion functions --------------------------------------------// + + template + const String + basic_path::file_string() const + { +# ifdef BOOST_WINDOWS_PATH + // for Windows, use the alternate separator, and bypass extra + // root separators + + typename string_type::size_type root_dir_start( + detail::root_directory_start( m_path, m_path.size() ) ); + bool in_root( root_dir_start != string_type::npos ); + String s; + for ( typename string_type::size_type pos( 0 ); + pos != m_path.size(); ++pos ) + { + // special case // [net] + if ( pos == 0 && m_path.size() > 1 + && m_path[0] == slash::value + && m_path[1] == slash::value + && ( m_path.size() == 2 + || !detail::is_separator( m_path[2] ) + ) ) + { + ++pos; + s += path_alt_separator::value; + s += path_alt_separator::value; + continue; + } + + // bypass extra root separators + if ( in_root ) + { + if ( s.size() > 0 + && s[s.size()-1] == path_alt_separator::value + && m_path[pos] == slash::value + ) continue; + } + + if ( m_path[pos] == slash::value ) + s += path_alt_separator::value; + else + s += m_path[pos]; + + if ( pos > root_dir_start + && m_path[pos] == slash::value ) + { in_root = false; } + } +# ifdef BOOST_CYGWIN_PATH + if ( m_cygwin_root ) s[0] = slash::value; +# endif + return s; +# else + return m_path; +# endif + } + + // iterator functions ---------------------------------------------------// + + template + typename basic_path::iterator basic_path::begin() const + { + iterator itr; + itr.m_path_ptr = this; + typename string_type::size_type element_size; + detail::first_element( m_path, itr.m_pos, element_size ); + itr.m_name = m_path.substr( itr.m_pos, element_size ); + return itr; + } + + template + typename basic_path::iterator basic_path::end() const + { + iterator itr; + itr.m_path_ptr = this; + itr.m_pos = m_path.size(); + return itr; + } + + namespace detail + { + // do_increment ------------------------------------------------------// + + template + void iterator_helper::do_increment( iterator & itr ) + { + typedef typename Path::string_type string_type; + typedef typename Path::traits_type traits_type; + + assert( itr.m_pos < itr.m_path_ptr->m_path.size() && "basic_path::iterator increment past end()" ); + + bool was_net( itr.m_name.size() > 2 + && itr.m_name[0] == slash::value + && itr.m_name[1] == slash::value + && itr.m_name[2] != slash::value ); + + // increment to position past current element + itr.m_pos += itr.m_name.size(); + + // if end reached, create end iterator + if ( itr.m_pos == itr.m_path_ptr->m_path.size() ) + { + itr.m_name.erase( itr.m_name.begin(), itr.m_name.end() ); // VC++ 6.0 lib didn't supply clear() + return; + } + + // process separator (Windows drive spec is only case not a separator) + if ( itr.m_path_ptr->m_path[itr.m_pos] == slash::value ) + { + // detect root directory + if ( was_net + # ifdef BOOST_WINDOWS_PATH + // case "c:/" + || itr.m_name[itr.m_name.size()-1] == colon::value + # endif + ) + { + itr.m_name = slash::value; + return; + } + + // bypass separators + while ( itr.m_pos != itr.m_path_ptr->m_path.size() + && itr.m_path_ptr->m_path[itr.m_pos] == slash::value ) + { ++itr.m_pos; } + + // detect trailing separator, and treat it as ".", per POSIX spec + if ( itr.m_pos == itr.m_path_ptr->m_path.size() + && detail::is_non_root_slash< string_type, traits_type >( + itr.m_path_ptr->m_path, itr.m_pos-1 ) ) + { + --itr.m_pos; + itr.m_name = dot::value; + return; + } + } + + // get next element + typename string_type::size_type end_pos( + itr.m_path_ptr->m_path.find( slash::value, itr.m_pos ) ); + itr.m_name = itr.m_path_ptr->m_path.substr( itr.m_pos, end_pos - itr.m_pos ); + } + + // do_decrement ------------------------------------------------------// + + template + void iterator_helper::do_decrement( iterator & itr ) + { + assert( itr.m_pos && "basic_path::iterator decrement past begin()" ); + + typedef typename Path::string_type string_type; + typedef typename Path::traits_type traits_type; + + typename string_type::size_type end_pos( itr.m_pos ); + + typename string_type::size_type root_dir_pos( + detail::root_directory_start( + itr.m_path_ptr->m_path, end_pos ) ); + + // if at end and there was a trailing non-root '/', return "." + if ( itr.m_pos == itr.m_path_ptr->m_path.size() + && itr.m_path_ptr->m_path.size() > 1 + && itr.m_path_ptr->m_path[itr.m_pos-1] == slash::value + && detail::is_non_root_slash< string_type, traits_type >( + itr.m_path_ptr->m_path, itr.m_pos-1 ) + ) + { + --itr.m_pos; + itr.m_name = dot::value; + return; + } + + // skip separators unless root directory + for ( + ; + end_pos > 0 + && (end_pos-1) != root_dir_pos + && itr.m_path_ptr->m_path[end_pos-1] == slash::value + ; + --end_pos ) {} + + itr.m_pos = detail::filename_pos + ( itr.m_path_ptr->m_path, end_pos ); + itr.m_name = itr.m_path_ptr->m_path.substr( itr.m_pos, end_pos - itr.m_pos ); + } + } // namespace detail + + // basic_filesystem_error implementation --------------------------------// + + template + basic_filesystem_error::basic_filesystem_error( + const std::string & what_arg, system::error_code ec ) + : system::system_error(ec, what_arg) + { + try + { + m_imp_ptr.reset( new m_imp ); + } + catch (...) { m_imp_ptr.reset(); } + } + + template + basic_filesystem_error::basic_filesystem_error( + const std::string & what_arg, const path_type & path1_arg, + system::error_code ec ) + : system::system_error(ec, what_arg) + { + try + { + m_imp_ptr.reset( new m_imp ); + m_imp_ptr->m_path1 = path1_arg; + } + catch (...) { m_imp_ptr.reset(); } + } + + template + basic_filesystem_error::basic_filesystem_error( + const std::string & what_arg, const path_type & path1_arg, + const path_type & path2_arg, system::error_code ec ) + : system::system_error(ec, what_arg) + { + try + { + m_imp_ptr.reset( new m_imp ); + m_imp_ptr->m_path1 = path1_arg; + m_imp_ptr->m_path2 = path2_arg; + } + catch (...) { m_imp_ptr.reset(); } + } + + } // namespace BOOST_FILESYSTEM_NAMESPACE +} // namespace boost + +#include // pops abi_prefix.hpp pragmas + +#endif // BOOST_FILESYSTEM_PATH_HPP diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/none.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/none.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,28 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_NONE_17SEP2003_HPP +#define BOOST_NONE_17SEP2003_HPP + +#include "boost/none_t.hpp" + +// NOTE: Borland users have to include this header outside any precompiled headers +// (bcc<=5.64 cannot include instance data in a precompiled header) +// -- * To be verified, now that there's no unnamed namespace + +namespace boost { + +none_t const none = ((none_t)0) ; + +} // namespace boost + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/none_t.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/none_t.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,24 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_NONE_T_17SEP2003_HPP +#define BOOST_NONE_T_17SEP2003_HPP + +namespace boost { + +namespace detail { struct none_helper{}; } + +typedef int detail::none_helper::*none_t ; + +} // namespace boost + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/optional.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/optional.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,18 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_OPTIONAL_FLC_19NOV2002_HPP +#define BOOST_OPTIONAL_FLC_19NOV2002_HPP + +#include "boost/optional/optional.hpp" + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/optional/optional.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/optional/optional.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,922 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP +#define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP + +#include +#include + +#include "boost/config.hpp" +#include "boost/assert.hpp" +#include "boost/type.hpp" +#include "boost/type_traits/alignment_of.hpp" +#include "boost/type_traits/type_with_alignment.hpp" +#include "boost/type_traits/remove_reference.hpp" +#include "boost/type_traits/is_reference.hpp" +#include "boost/mpl/if.hpp" +#include "boost/mpl/bool.hpp" +#include "boost/mpl/not.hpp" +#include "boost/detail/reference_content.hpp" +#include "boost/none.hpp" +#include "boost/utility/compare_pointees.hpp" + +#include "boost/optional/optional_fwd.hpp" + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1200) +// VC6.0 has the following bug: +// When a templated assignment operator exist, an implicit conversion +// constructing an optional is used when assigment of the form: +// optional opt ; opt = T(...); +// is compiled. +// However, optional's ctor is _explicit_ and the assignemt shouldn't compile. +// Therefore, for VC6.0 templated assignment is disabled. +// +#define BOOST_OPTIONAL_NO_CONVERTING_ASSIGNMENT +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300) +// VC7.0 has the following bug: +// When both a non-template and a template copy-ctor exist +// and the templated version is made 'explicit', the explicit is also +// given to the non-templated version, making the class non-implicitely-copyable. +// +#define BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION,<=700) +// AFAICT only VC7.1 correctly resolves the overload set +// that includes the in-place factory taking functions, +// so for the other VC versions, in-place factory support +// is disabled +#define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT +#endif + +#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551) +// BCB (5.5.1) cannot parse the nested template struct in an inplace factory. +#define BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT +#endif + +#if !defined(BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT) \ + && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581) ) +// BCB (up to 5.64) has the following bug: +// If there is a member function/operator template of the form +// template mfunc( Expr expr ) ; +// some calls are resolved to this even if there are other better matches. +// The effect of this bug is that calls to converting ctors and assignments +// are incrorrectly sink to this general catch-all member function template as shown above. +#define BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION +#endif + +// Daniel Wallin discovered that bind/apply.hpp badly interacts with the apply<> +// member template of a factory as used in the optional<> implementation. +// He proposed this simple fix which is to move the call to apply<> outside +// namespace boost. +namespace boost_optional_detail +{ + template + void construct(Factory const& factory, void* address) + { + factory.BOOST_NESTED_TEMPLATE apply(address); + } +} + + +namespace boost { + +class in_place_factory_base ; +class typed_in_place_factory_base ; + +namespace optional_detail { + +// This local class is used instead of that in "aligned_storage.hpp" +// because I've found the 'official' class to ICE BCB5.5 +// when some types are used with optional<> +// (due to sizeof() passed down as a non-type template parameter) +template +class aligned_storage +{ + // Borland ICEs if unnamed unions are used for this! + union dummy_u + { + char data[ sizeof(T) ]; + BOOST_DEDUCED_TYPENAME type_with_alignment< + ::boost::alignment_of::value >::type aligner_; + } dummy_ ; + + public: + + void const* address() const { return &dummy_.data[0]; } + void * address() { return &dummy_.data[0]; } +} ; + +template +struct types_when_isnt_ref +{ + typedef T const& reference_const_type ; + typedef T & reference_type ; + typedef T const* pointer_const_type ; + typedef T * pointer_type ; + typedef T const& argument_type ; +} ; +template +struct types_when_is_ref +{ + typedef BOOST_DEDUCED_TYPENAME remove_reference::type raw_type ; + + typedef raw_type& reference_const_type ; + typedef raw_type& reference_type ; + typedef raw_type* pointer_const_type ; + typedef raw_type* pointer_type ; + typedef raw_type& argument_type ; +} ; + +struct optional_tag {} ; + +template +class optional_base : public optional_tag +{ + private : + + typedef +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + BOOST_DEDUCED_TYPENAME +#endif + ::boost::detail::make_reference_content::type internal_type ; + + typedef aligned_storage storage_type ; + + typedef types_when_isnt_ref types_when_not_ref ; + typedef types_when_is_ref types_when_ref ; + + typedef optional_base this_type ; + + protected : + + typedef T value_type ; + + typedef mpl::true_ is_reference_tag ; + typedef mpl::false_ is_not_reference_tag ; + + typedef BOOST_DEDUCED_TYPENAME is_reference::type is_reference_predicate ; + + typedef BOOST_DEDUCED_TYPENAME mpl::if_::type types ; + + typedef bool (this_type::*unspecified_bool_type)() const; + + typedef BOOST_DEDUCED_TYPENAME types::reference_type reference_type ; + typedef BOOST_DEDUCED_TYPENAME types::reference_const_type reference_const_type ; + typedef BOOST_DEDUCED_TYPENAME types::pointer_type pointer_type ; + typedef BOOST_DEDUCED_TYPENAME types::pointer_const_type pointer_const_type ; + typedef BOOST_DEDUCED_TYPENAME types::argument_type argument_type ; + + // Creates an optional uninitialized. + // No-throw + optional_base() + : + m_initialized(false) {} + + // Creates an optional uninitialized. + // No-throw + optional_base ( none_t ) + : + m_initialized(false) {} + + // Creates an optional initialized with 'val'. + // Can throw if T::T(T const&) does + optional_base ( argument_type val ) + : + m_initialized(false) + { + construct(val); + } + + // Creates an optional initialized with 'val' IFF cond is true, otherwise creates an uninitialzed optional. + // Can throw if T::T(T const&) does + optional_base ( bool cond, argument_type val ) + : + m_initialized(false) + { + if ( cond ) + construct(val); + } + + // Creates a deep copy of another optional + // Can throw if T::T(T const&) does + optional_base ( optional_base const& rhs ) + : + m_initialized(false) + { + if ( rhs.is_initialized() ) + construct(rhs.get_impl()); + } + + + // This is used for both converting and in-place constructions. + // Derived classes use the 'tag' to select the appropriate + // implementation (the correct 'construct()' overload) + template + explicit optional_base ( Expr const& expr, Expr const* tag ) + : + m_initialized(false) + { + construct(expr,tag); + } + + + + // No-throw (assuming T::~T() doesn't) + ~optional_base() { destroy() ; } + + // Assigns from another optional (deep-copies the rhs value) + void assign ( optional_base const& rhs ) + { + if (is_initialized()) + { + if ( rhs.is_initialized() ) + assign_value(rhs.get_impl(), is_reference_predicate() ); + else destroy(); + } + else + { + if ( rhs.is_initialized() ) + construct(rhs.get_impl()); + } + } + + // Assigns from another _convertible_ optional (deep-copies the rhs value) + template + void assign ( optional const& rhs ) + { + if (is_initialized()) + { + if ( rhs.is_initialized() ) + assign_value(static_cast(rhs.get()), is_reference_predicate() ); + else destroy(); + } + else + { + if ( rhs.is_initialized() ) + construct(static_cast(rhs.get())); + } + } + + // Assigns from a T (deep-copies the rhs value) + void assign ( argument_type val ) + { + if (is_initialized()) + assign_value(val, is_reference_predicate() ); + else construct(val); + } + + // Assigns from "none", destroying the current value, if any, leaving this UNINITIALIZED + // No-throw (assuming T::~T() doesn't) + void assign ( none_t ) { destroy(); } + +#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT + template + void assign_expr ( Expr const& expr, Expr const* tag ) + { + if (is_initialized()) + assign_expr_to_initialized(expr,tag); + else construct(expr,tag); + } +#endif + + public : + + // Destroys the current value, if any, leaving this UNINITIALIZED + // No-throw (assuming T::~T() doesn't) + void reset() { destroy(); } + + // Replaces the current value -if any- with 'val' + void reset ( argument_type val ) { assign(val); } + + // Returns a pointer to the value if this is initialized, otherwise, + // returns NULL. + // No-throw + pointer_const_type get_ptr() const { return m_initialized ? get_ptr_impl() : 0 ; } + pointer_type get_ptr() { return m_initialized ? get_ptr_impl() : 0 ; } + + bool is_initialized() const { return m_initialized ; } + + protected : + + void construct ( argument_type val ) + { + new (m_storage.address()) internal_type(val) ; + m_initialized = true ; + } + +#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT + // Constructs in-place using the given factory + template + void construct ( Expr const& factory, in_place_factory_base const* ) + { + BOOST_STATIC_ASSERT ( ::boost::mpl::not_::value ) ; + boost_optional_detail::construct(factory, m_storage.address()); + m_initialized = true ; + } + + // Constructs in-place using the given typed factory + template + void construct ( Expr const& factory, typed_in_place_factory_base const* ) + { + BOOST_STATIC_ASSERT ( ::boost::mpl::not_::value ) ; + factory.apply(m_storage.address()) ; + m_initialized = true ; + } + + template + void assign_expr_to_initialized ( Expr const& factory, in_place_factory_base const* tag ) + { + destroy(); + construct(factory,tag); + } + + // Constructs in-place using the given typed factory + template + void assign_expr_to_initialized ( Expr const& factory, typed_in_place_factory_base const* tag ) + { + destroy(); + construct(factory,tag); + } +#endif + + // Constructs using any expression implicitely convertible to the single argument + // of a one-argument T constructor. + // Converting constructions of optional from optional uses this function with + // 'Expr' being of type 'U' and relying on a converting constructor of T from U. + template + void construct ( Expr const& expr, void const* ) + { + new (m_storage.address()) internal_type(expr) ; + m_initialized = true ; + } + + // Assigns using a form any expression implicitely convertible to the single argument + // of a T's assignment operator. + // Converting assignments of optional from optional uses this function with + // 'Expr' being of type 'U' and relying on a converting assignment of T from U. + template + void assign_expr_to_initialized ( Expr const& expr, void const* ) + { + assign_value(expr, is_reference_predicate()); + } + +#ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION + // BCB5.64 (and probably lower versions) workaround. + // The in-place factories are supported by means of catch-all constructors + // and assignment operators (the functions are parameterized in terms of + // an arbitrary 'Expr' type) + // This compiler incorrectly resolves the overload set and sinks optional and optional + // to the 'Expr'-taking functions even though explicit overloads are present for them. + // Thus, the following overload is needed to properly handle the case when the 'lhs' + // is another optional. + // + // For VC<=70 compilers this workaround dosen't work becasue the comnpiler issues and error + // instead of choosing the wrong overload + // + // Notice that 'Expr' will be optional or optional (but not optional_base<..>) + template + void construct ( Expr const& expr, optional_tag const* ) + { + if ( expr.is_initialized() ) + { + // An exception can be thrown here. + // It it happens, THIS will be left uninitialized. + new (m_storage.address()) internal_type(expr.get()) ; + m_initialized = true ; + } + } +#endif + + void assign_value ( argument_type val, is_not_reference_tag ) { get_impl() = val; } + void assign_value ( argument_type val, is_reference_tag ) { construct(val); } + + void destroy() + { + if ( m_initialized ) + destroy_impl(is_reference_predicate()) ; + } + + unspecified_bool_type safe_bool() const { return m_initialized ? &this_type::is_initialized : 0 ; } + + reference_const_type get_impl() const { return dereference(get_object(), is_reference_predicate() ) ; } + reference_type get_impl() { return dereference(get_object(), is_reference_predicate() ) ; } + + pointer_const_type get_ptr_impl() const { return cast_ptr(get_object(), is_reference_predicate() ) ; } + pointer_type get_ptr_impl() { return cast_ptr(get_object(), is_reference_predicate() ) ; } + + private : + + // internal_type can be either T or reference_content + internal_type const* get_object() const { return static_cast(m_storage.address()); } + internal_type * get_object() { return static_cast (m_storage.address()); } + + // reference_content lacks an implicit conversion to T&, so the following is needed to obtain a proper reference. + reference_const_type dereference( internal_type const* p, is_not_reference_tag ) const { return *p ; } + reference_type dereference( internal_type* p, is_not_reference_tag ) { return *p ; } + reference_const_type dereference( internal_type const* p, is_reference_tag ) const { return p->get() ; } + reference_type dereference( internal_type* p, is_reference_tag ) { return p->get() ; } + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581)) + void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->internal_type::~internal_type() ; m_initialized = false ; } +#else + void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->T::~T() ; m_initialized = false ; } +#endif + + void destroy_impl ( is_reference_tag ) { m_initialized = false ; } + + // If T is of reference type, trying to get a pointer to the held value must result in a compile-time error. + // Decent compilers should disallow conversions from reference_content* to T*, but just in case, + // the following olverloads are used to filter out the case and guarantee an error in case of T being a reference. + pointer_const_type cast_ptr( internal_type const* p, is_not_reference_tag ) const { return p ; } + pointer_type cast_ptr( internal_type * p, is_not_reference_tag ) { return p ; } + pointer_const_type cast_ptr( internal_type const* p, is_reference_tag ) const { return &p->get() ; } + pointer_type cast_ptr( internal_type * p, is_reference_tag ) { return &p->get() ; } + + bool m_initialized ; + storage_type m_storage ; +} ; + +} // namespace optional_detail + +template +class optional : public optional_detail::optional_base +{ + typedef optional_detail::optional_base base ; + + typedef BOOST_DEDUCED_TYPENAME base::unspecified_bool_type unspecified_bool_type ; + + public : + + typedef optional this_type ; + + typedef BOOST_DEDUCED_TYPENAME base::value_type value_type ; + typedef BOOST_DEDUCED_TYPENAME base::reference_type reference_type ; + typedef BOOST_DEDUCED_TYPENAME base::reference_const_type reference_const_type ; + typedef BOOST_DEDUCED_TYPENAME base::pointer_type pointer_type ; + typedef BOOST_DEDUCED_TYPENAME base::pointer_const_type pointer_const_type ; + typedef BOOST_DEDUCED_TYPENAME base::argument_type argument_type ; + + // Creates an optional uninitialized. + // No-throw + optional() : base() {} + + // Creates an optional uninitialized. + // No-throw + optional( none_t none_ ) : base(none_) {} + + // Creates an optional initialized with 'val'. + // Can throw if T::T(T const&) does + optional ( argument_type val ) : base(val) {} + + // Creates an optional initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional. + // Can throw if T::T(T const&) does + optional ( bool cond, argument_type val ) : base(cond,val) {} + +#ifndef BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR + // NOTE: MSVC needs templated versions first + + // Creates a deep copy of another convertible optional + // Requires a valid conversion from U to T. + // Can throw if T::T(U const&) does + template + explicit optional ( optional const& rhs ) + : + base() + { + if ( rhs.is_initialized() ) + this->construct(rhs.get()); + } +#endif + +#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT + // Creates an optional with an expression which can be either + // (a) An instance of InPlaceFactory (i.e. in_place(a,b,...,n); + // (b) An instance of TypedInPlaceFactory ( i.e. in_place(a,b,...,n); + // (c) Any expression implicitely convertible to the single type + // of a one-argument T's constructor. + // (d*) Weak compilers (BCB) might also resolved Expr as optional and optional + // even though explicit overloads are present for these. + // Depending on the above some T ctor is called. + // Can throw is the resolved T ctor throws. + template + explicit optional ( Expr const& expr ) : base(expr,&expr) {} +#endif + + // Creates a deep copy of another optional + // Can throw if T::T(T const&) does + optional ( optional const& rhs ) : base(rhs) {} + + // No-throw (assuming T::~T() doesn't) + ~optional() {} + +#if !defined(BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT) && !defined(BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION) + // Assigns from an expression. See corresponding constructor. + // Basic Guarantee: If the resolved T ctor throws, this is left UNINITIALIZED + template + optional& operator= ( Expr expr ) + { + this->assign_expr(expr,&expr); + return *this ; + } +#endif + + +#ifndef BOOST_OPTIONAL_NO_CONVERTING_ASSIGNMENT + // Assigns from another convertible optional (converts && deep-copies the rhs value) + // Requires a valid conversion from U to T. + // Basic Guarantee: If T::T( U const& ) throws, this is left UNINITIALIZED + template + optional& operator= ( optional const& rhs ) + { + this->assign(rhs); + return *this ; + } +#endif + + // Assigns from another optional (deep-copies the rhs value) + // Basic Guarantee: If T::T( T const& ) throws, this is left UNINITIALIZED + // (NOTE: On BCB, this operator is not actually called and left is left UNMODIFIED in case of a throw) + optional& operator= ( optional const& rhs ) + { + this->assign( rhs ) ; + return *this ; + } + + // Assigns from a T (deep-copies the rhs value) + // Basic Guarantee: If T::( T const& ) throws, this is left UNINITIALIZED + optional& operator= ( argument_type val ) + { + this->assign( val ) ; + return *this ; + } + + // Assigns from a "none" + // Which destroys the current value, if any, leaving this UNINITIALIZED + // No-throw (assuming T::~T() doesn't) + optional& operator= ( none_t none_ ) + { + this->assign( none_ ) ; + return *this ; + } + + // Returns a reference to the value if this is initialized, otherwise, + // the behaviour is UNDEFINED + // No-throw + reference_const_type get() const { BOOST_ASSERT(this->is_initialized()) ; return this->get_impl(); } + reference_type get() { BOOST_ASSERT(this->is_initialized()) ; return this->get_impl(); } + + // Returns a copy of the value if this is initialized, 'v' otherwise + reference_const_type get_value_or ( reference_const_type v ) const { return this->is_initialized() ? get() : v ; } + reference_type get_value_or ( reference_type v ) { return this->is_initialized() ? get() : v ; } + + // Returns a pointer to the value if this is initialized, otherwise, + // the behaviour is UNDEFINED + // No-throw + pointer_const_type operator->() const { BOOST_ASSERT(this->is_initialized()) ; return this->get_ptr_impl() ; } + pointer_type operator->() { BOOST_ASSERT(this->is_initialized()) ; return this->get_ptr_impl() ; } + + // Returns a reference to the value if this is initialized, otherwise, + // the behaviour is UNDEFINED + // No-throw + reference_const_type operator *() const { return this->get() ; } + reference_type operator *() { return this->get() ; } + + // implicit conversion to "bool" + // No-throw + operator unspecified_bool_type() const { return this->safe_bool() ; } + + // This is provided for those compilers which don't like the conversion to bool + // on some contexts. + bool operator!() const { return !this->is_initialized() ; } +} ; + +// Returns optional(v) +template +inline +optional make_optional ( T const& v ) +{ + return optional(v); +} + +// Returns optional(cond,v) +template +inline +optional make_optional ( bool cond, T const& v ) +{ + return optional(cond,v); +} + +// Returns a reference to the value if this is initialized, otherwise, the behaviour is UNDEFINED. +// No-throw +template +inline +BOOST_DEDUCED_TYPENAME optional::reference_const_type +get ( optional const& opt ) +{ + return opt.get() ; +} + +template +inline +BOOST_DEDUCED_TYPENAME optional::reference_type +get ( optional& opt ) +{ + return opt.get() ; +} + +// Returns a pointer to the value if this is initialized, otherwise, returns NULL. +// No-throw +template +inline +BOOST_DEDUCED_TYPENAME optional::pointer_const_type +get ( optional const* opt ) +{ + return opt->get_ptr() ; +} + +template +inline +BOOST_DEDUCED_TYPENAME optional::pointer_type +get ( optional* opt ) +{ + return opt->get_ptr() ; +} + +// Returns a reference to the value if this is initialized, otherwise, the behaviour is UNDEFINED. +// No-throw +template +inline +BOOST_DEDUCED_TYPENAME optional::reference_const_type +get_optional_value_or ( optional const& opt, BOOST_DEDUCED_TYPENAME optional::reference_const_type v ) +{ + return opt.get_value_or(v) ; +} + +template +inline +BOOST_DEDUCED_TYPENAME optional::reference_type +get_optional_value_or ( optional& opt, BOOST_DEDUCED_TYPENAME optional::reference_type v ) +{ + return opt.get_value_or(v) ; +} + +// Returns a pointer to the value if this is initialized, otherwise, returns NULL. +// No-throw +template +inline +BOOST_DEDUCED_TYPENAME optional::pointer_const_type +get_pointer ( optional const& opt ) +{ + return opt.get_ptr() ; +} + +template +inline +BOOST_DEDUCED_TYPENAME optional::pointer_type +get_pointer ( optional& opt ) +{ + return opt.get_ptr() ; +} + +// optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values). +// WARNING: This is UNLIKE pointers. Use equal_pointees()/less_pointess() in generic code instead. + + +// +// optional vs optional cases +// + +template +inline +bool operator == ( optional const& x, optional const& y ) +{ return equal_pointees(x,y); } + +template +inline +bool operator < ( optional const& x, optional const& y ) +{ return less_pointees(x,y); } + +template +inline +bool operator != ( optional const& x, optional const& y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( optional const& x, optional const& y ) +{ return y < x ; } + +template +inline +bool operator <= ( optional const& x, optional const& y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( optional const& x, optional const& y ) +{ return !( x < y ) ; } + + +// +// optional vs T cases +// +template +inline +bool operator == ( optional const& x, T const& y ) +{ return equal_pointees(x, optional(y)); } + +template +inline +bool operator < ( optional const& x, T const& y ) +{ return less_pointees(x, optional(y)); } + +template +inline +bool operator != ( optional const& x, T const& y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( optional const& x, T const& y ) +{ return y < x ; } + +template +inline +bool operator <= ( optional const& x, T const& y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( optional const& x, T const& y ) +{ return !( x < y ) ; } + +// +// T vs optional cases +// + +template +inline +bool operator == ( T const& x, optional const& y ) +{ return equal_pointees( optional(x), y ); } + +template +inline +bool operator < ( T const& x, optional const& y ) +{ return less_pointees( optional(x), y ); } + +template +inline +bool operator != ( T const& x, optional const& y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( T const& x, optional const& y ) +{ return y < x ; } + +template +inline +bool operator <= ( T const& x, optional const& y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( T const& x, optional const& y ) +{ return !( x < y ) ; } + + +// +// optional vs none cases +// + +template +inline +bool operator == ( optional const& x, none_t ) +{ return equal_pointees(x, optional() ); } + +template +inline +bool operator < ( optional const& x, none_t ) +{ return less_pointees(x,optional() ); } + +template +inline +bool operator != ( optional const& x, none_t y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( optional const& x, none_t y ) +{ return y < x ; } + +template +inline +bool operator <= ( optional const& x, none_t y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( optional const& x, none_t y ) +{ return !( x < y ) ; } + +// +// none vs optional cases +// + +template +inline +bool operator == ( none_t x, optional const& y ) +{ return equal_pointees(optional() ,y); } + +template +inline +bool operator < ( none_t x, optional const& y ) +{ return less_pointees(optional() ,y); } + +template +inline +bool operator != ( none_t x, optional const& y ) +{ return !( x == y ) ; } + +template +inline +bool operator > ( none_t x, optional const& y ) +{ return y < x ; } + +template +inline +bool operator <= ( none_t x, optional const& y ) +{ return !( y < x ) ; } + +template +inline +bool operator >= ( none_t x, optional const& y ) +{ return !( x < y ) ; } + +// +// The following swap implementation follows the GCC workaround as found in +// "boost/detail/compressed_pair.hpp" +// +namespace optional_detail { + +// GCC < 3.2 gets the using declaration at namespace scope (FLC, DWA) +#if BOOST_WORKAROUND(__GNUC__, < 3) \ + || BOOST_WORKAROUND(__GNUC__, == 3) && __GNUC_MINOR__ <= 2 + using std::swap; +#define BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE +#endif + +// optional's swap: +// If both are initialized, calls swap(T&, T&). If this swap throws, both will remain initialized but their values are now unspecified. +// If only one is initialized, calls U.reset(*I), THEN I.reset(). +// If U.reset(*I) throws, both are left UNCHANGED (U is kept uinitialized and I is never reset) +// If both are uninitialized, do nothing (no-throw) +template +inline +void optional_swap ( optional& x, optional& y ) +{ + if ( !x && !!y ) + { + x.reset(*y); + y.reset(); + } + else if ( !!x && !y ) + { + y.reset(*x); + x.reset(); + } + else if ( !!x && !!y ) + { +// GCC > 3.2 and all other compilers have the using declaration at function scope (FLC) +#ifndef BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE + // allow for Koenig lookup + using std::swap ; +#endif + swap(*x,*y); + } +} + +} // namespace optional_detail + +template inline void swap ( optional& x, optional& y ) +{ + optional_detail::optional_swap(x,y); +} + + +} // namespace boost + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/optional/optional_fwd.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/optional/optional_fwd.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,22 @@ +// Copyright (C) 2003, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP +#define BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP + +namespace boost { + +template class optional ; + +} // namespace boost + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/optional/optional_io.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/optional/optional_io.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,84 @@ +// Copyright (C) 2005, Fernando Luis Cacciola Carballal. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// fernando_cacciola@hotmail.com +// +#ifndef BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP +#define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP + +#if defined __GNUC__ +# if (__GNUC__ == 2 && __GNUC_MINOR__ <= 97) +# define BOOST_OPTIONAL_NO_TEMPLATED_STREAMS +# endif +#endif // __GNUC__ + +#if defined BOOST_OPTIONAL_NO_TEMPLATED_STREAMS +# include +#else +# include +# include +#endif + + +#include "boost/optional/optional.hpp" +#include "boost/utility/value_init.hpp" + +namespace boost +{ + +#if defined (BOOST_NO_TEMPLATED_STREAMS) +template +inline std::ostream& operator<<(std::ostream& out, optional const& v) +#else +template +inline +std::basic_ostream& +operator<<(std::basic_ostream& out, optional const& v) +#endif +{ + if ( out.good() ) + { + if ( !v ) + out << "--" ; + else out << ' ' << *v ; + } + + return out; +} + +#if defined (BOOST_NO_TEMPLATED_STREAMS) +template +inline std::istream& operator>>(std::istream& in, optional& v) +#else +template +inline +std::basic_istream& +operator>>(std::basic_istream& in, optional& v) +#endif +{ + if ( in.good() ) + { + int d = in.get(); + if ( d == ' ' ) + { + T x ; + in >> x; + v = x ; + } + else + v = optional() ; + } + + return in; +} + +} // namespace boost + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org/libs/regex for documentation. + * FILE regex.cpp + * VERSION see + * DESCRIPTION: Declares boost::basic_regex<> and associated + * functions and classes. This header is the main + * entry point for the template regex code. + */ + + +/* start with C compatibility API */ + +#ifndef BOOST_RE_REGEX_HPP +#define BOOST_RE_REGEX_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +#include + +#endif // include + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/concepts.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/concepts.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,870 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE concepts.hpp + * VERSION see + * DESCRIPTION: Declares regular expression concepts. + */ + +#ifndef BOOST_REGEX_CONCEPTS_HPP_INCLUDED +#define BOOST_REGEX_CONCEPTS_HPP_INCLUDED + +#include +#include +#include +#include +#include +#ifndef BOOST_TEST_TR1_REGEX +#include +#endif +#include +#include +#include + +namespace boost{ + +// +// bitmask_archetype: +// this can be either an integer type, an enum, or a std::bitset, +// we use the latter as the architype as it offers the "strictest" +// of the possible interfaces: +// +typedef std::bitset<512> bitmask_archetype; +// +// char_architype: +// A strict model for the character type interface. +// +struct char_architype +{ + // default constructable: + char_architype(); + // copy constructable / assignable: + char_architype(const char_architype&); + char_architype& operator=(const char_architype&); + // constructable from an integral value: + char_architype(unsigned long val); + // comparable: + bool operator==(const char_architype&)const; + bool operator!=(const char_architype&)const; + bool operator<(const char_architype&)const; + bool operator<=(const char_architype&)const; + bool operator>=(const char_architype&)const; + bool operator>(const char_architype&)const; + // conversion to integral type: + operator long()const; +}; +// +// char_architype can not be used with basic_string: +// +} // namespace boost +namespace std{ + template<> struct char_traits + { + // The intent is that this template is not instantiated, + // but this typedef gives us a chance of compilation in + // case it is: + typedef boost::char_architype char_type; + }; +} +namespace boost{ +// +// regex_traits_architype: +// A strict interpretation of the regular expression traits class requirements. +// +template +struct regex_traits_architype +{ +public: + regex_traits_architype(); + typedef charT char_type; + // typedef std::size_t size_type; + typedef std::vector string_type; + typedef copy_constructible_archetype > locale_type; + typedef bitmask_archetype char_class_type; + + static std::size_t length(const char_type* ) { return 0; } + + charT translate(charT ) const { return charT(); } + charT translate_nocase(charT ) const { return static_object::get(); } + + template + string_type transform(ForwardIterator , ForwardIterator ) const + { return static_object::get(); } + template + string_type transform_primary(ForwardIterator , ForwardIterator ) const + { return static_object::get(); } + + template + char_class_type lookup_classname(ForwardIterator , ForwardIterator ) const + { return static_object::get(); } + template + string_type lookup_collatename(ForwardIterator , ForwardIterator ) const + { return static_object::get(); } + + bool isctype(charT, char_class_type) const + { return false; } + int value(charT, int) const + { return 0; } + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return static_object::get(); } + +private: + // this type is not copyable: + regex_traits_architype(const regex_traits_architype&); + regex_traits_architype& operator=(const regex_traits_architype&); +}; + +// +// alter this to std::tr1, to test a std implementation: +// +#ifndef BOOST_TEST_TR1_REGEX +namespace global_regex_namespace = ::boost; +#else +namespace global_regex_namespace = ::std::tr1; +#endif + +template +struct BitmaskConcept +{ + void constraints() + { + function_requires >(); + function_requires >(); + + m_mask1 = m_mask2 | m_mask3; + m_mask1 = m_mask2 & m_mask3; + m_mask1 = m_mask2 ^ m_mask3; + + m_mask1 = ~m_mask2; + + m_mask1 |= m_mask2; + m_mask1 &= m_mask2; + m_mask1 ^= m_mask2; + } + Bitmask m_mask1, m_mask2, m_mask3; +}; + +template +struct RegexTraitsConcept +{ + RegexTraitsConcept(); + // required typedefs: + typedef typename traits::char_type char_type; + // typedef typename traits::size_type size_type; + typedef typename traits::string_type string_type; + typedef typename traits::locale_type locale_type; + typedef typename traits::char_class_type char_class_type; + + void constraints() + { + //function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); + + std::size_t n = traits::length(m_pointer); + ignore_unused_variable_warning(n); + + char_type c = m_ctraits.translate(m_char); + ignore_unused_variable_warning(c); + c = m_ctraits.translate_nocase(m_char); + + //string_type::foobar bar; + string_type s1 = m_ctraits.transform(m_pointer, m_pointer); + ignore_unused_variable_warning(s1); + + string_type s2 = m_ctraits.transform_primary(m_pointer, m_pointer); + ignore_unused_variable_warning(s2); + + char_class_type cc = m_ctraits.lookup_classname(m_pointer, m_pointer); + ignore_unused_variable_warning(cc); + + string_type s3 = m_ctraits.lookup_collatename(m_pointer, m_pointer); + ignore_unused_variable_warning(s3); + + bool b = m_ctraits.isctype(m_char, cc); + ignore_unused_variable_warning(b); + + int v = m_ctraits.value(m_char, 16); + ignore_unused_variable_warning(v); + + locale_type l(m_ctraits.getloc()); + m_traits.imbue(l); + ignore_unused_variable_warning(l); + } + traits m_traits; + const traits m_ctraits; + const char_type* m_pointer; + char_type m_char; +private: + RegexTraitsConcept& operator=(RegexTraitsConcept&); +}; + +// +// helper class to compute what traits class a regular expression type is using: +// +template +struct regex_traits_computer; + +template +struct regex_traits_computer< global_regex_namespace::basic_regex > +{ + typedef traits type; +}; + +// +// BaseRegexConcept does not test anything dependent on basic_string, +// in case our charT does not have an associated char_traits: +// +template +struct BaseRegexConcept +{ + typedef typename Regex::value_type value_type; + //typedef typename Regex::size_type size_type; + typedef typename Regex::flag_type flag_type; + typedef typename Regex::locale_type locale_type; + typedef input_iterator_archetype input_iterator_type; + + // derived test types: + typedef const value_type* pointer_type; + typedef bidirectional_iterator_archetype BidiIterator; + typedef global_regex_namespace::sub_match sub_match_type; + typedef global_regex_namespace::match_results match_results_type; + typedef output_iterator_archetype OutIterator; + typedef typename regex_traits_computer::type traits_type; + typedef global_regex_namespace::regex_iterator regex_iterator_type; + typedef global_regex_namespace::regex_token_iterator regex_token_iterator_type; + + void global_constraints() + { + // + // test non-template components: + // + function_requires >(); + global_regex_namespace::regex_constants::syntax_option_type opts + = global_regex_namespace::regex_constants::icase + | global_regex_namespace::regex_constants::nosubs + | global_regex_namespace::regex_constants::optimize + | global_regex_namespace::regex_constants::collate + | global_regex_namespace::regex_constants::ECMAScript + | global_regex_namespace::regex_constants::basic + | global_regex_namespace::regex_constants::extended + | global_regex_namespace::regex_constants::awk + | global_regex_namespace::regex_constants::grep + | global_regex_namespace::regex_constants::egrep; + ignore_unused_variable_warning(opts); + + function_requires >(); + global_regex_namespace::regex_constants::match_flag_type mopts + = global_regex_namespace::regex_constants::match_default + | global_regex_namespace::regex_constants::match_not_bol + | global_regex_namespace::regex_constants::match_not_eol + | global_regex_namespace::regex_constants::match_not_bow + | global_regex_namespace::regex_constants::match_not_eow + | global_regex_namespace::regex_constants::match_any + | global_regex_namespace::regex_constants::match_not_null + | global_regex_namespace::regex_constants::match_continuous + | global_regex_namespace::regex_constants::match_prev_avail + | global_regex_namespace::regex_constants::format_default + | global_regex_namespace::regex_constants::format_sed + | global_regex_namespace::regex_constants::format_no_copy + | global_regex_namespace::regex_constants::format_first_only; + ignore_unused_variable_warning(mopts); + + BOOST_STATIC_ASSERT((::boost::is_enum::value)); + global_regex_namespace::regex_constants::error_type e1 = global_regex_namespace::regex_constants::error_collate; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_ctype; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_escape; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_backref; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_brack; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_paren; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_brace; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_badbrace; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_range; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_space; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_badrepeat; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_complexity; + ignore_unused_variable_warning(e1); + e1 = global_regex_namespace::regex_constants::error_stack; + ignore_unused_variable_warning(e1); + + BOOST_STATIC_ASSERT((::boost::is_base_and_derived::value )); + const global_regex_namespace::regex_error except(e1); + e1 = except.code(); + + typedef typename Regex::value_type value_type; + function_requires< RegexTraitsConcept > >(); + function_requires< BaseRegexConcept > >(); + } + void constraints() + { + global_constraints(); + + BOOST_STATIC_ASSERT((::boost::is_same< flag_type, global_regex_namespace::regex_constants::syntax_option_type>::value)); + flag_type opts + = Regex::icase + | Regex::nosubs + | Regex::optimize + | Regex::collate + | Regex::ECMAScript + | Regex::basic + | Regex::extended + | Regex::awk + | Regex::grep + | Regex::egrep; + ignore_unused_variable_warning(opts); + + function_requires >(); + function_requires >(); + + // Regex constructors: + Regex e1(m_pointer); + ignore_unused_variable_warning(e1); + Regex e2(m_pointer, m_flags); + ignore_unused_variable_warning(e2); + Regex e3(m_pointer, m_size, m_flags); + ignore_unused_variable_warning(e3); + Regex e4(in1, in2); + ignore_unused_variable_warning(e4); + Regex e5(in1, in2, m_flags); + ignore_unused_variable_warning(e5); + + // assign etc: + Regex e; + e = m_pointer; + e = e1; + e.assign(e1); + e.assign(m_pointer); + e.assign(m_pointer, m_flags); + e.assign(m_pointer, m_size, m_flags); + e.assign(in1, in2); + e.assign(in1, in2, m_flags); + + // access: + const Regex ce; + unsigned i = ce.mark_count(); + ignore_unused_variable_warning(i); + m_flags = ce.flags(); + e.imbue(ce.getloc()); + e.swap(e1); + + global_regex_namespace::swap(e, e1); + + // sub_match: + BOOST_STATIC_ASSERT((::boost::is_base_and_derived, sub_match_type>::value)); + typedef typename sub_match_type::value_type sub_value_type; + typedef typename sub_match_type::difference_type sub_diff_type; + typedef typename sub_match_type::iterator sub_iter_type; + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + bool b = m_sub.matched; + ignore_unused_variable_warning(b); + BidiIterator bi = m_sub.first; + ignore_unused_variable_warning(bi); + bi = m_sub.second; + ignore_unused_variable_warning(bi); + sub_diff_type diff = m_sub.length(); + ignore_unused_variable_warning(diff); + // match_results tests: + typedef typename match_results_type::value_type mr_value_type; + typedef typename match_results_type::const_reference mr_const_reference; + typedef typename match_results_type::reference mr_reference; + typedef typename match_results_type::const_iterator mr_const_iterator; + typedef typename match_results_type::iterator mr_iterator; + typedef typename match_results_type::difference_type mr_difference_type; + typedef typename match_results_type::size_type mr_size_type; + typedef typename match_results_type::allocator_type mr_allocator_type; + typedef typename match_results_type::char_type mr_char_type; + typedef typename match_results_type::string_type mr_string_type; + + match_results_type m1; + mr_allocator_type at; + match_results_type m2(at); + match_results_type m3(m1); + m1 = m2; + + int ival = 0; + + mr_size_type mrs = m_cresults.size(); + ignore_unused_variable_warning(mrs); + mrs = m_cresults.max_size(); + ignore_unused_variable_warning(mrs); + b = m_cresults.empty(); + ignore_unused_variable_warning(b); + mr_difference_type mrd = m_cresults.length(); + ignore_unused_variable_warning(mrd); + mrd = m_cresults.length(ival); + ignore_unused_variable_warning(mrd); + mrd = m_cresults.position(); + ignore_unused_variable_warning(mrd); + mrd = m_cresults.position(mrs); + ignore_unused_variable_warning(mrd); + + mr_const_reference mrcr = m_cresults[ival]; + ignore_unused_variable_warning(mrcr); + mr_const_reference mrcr2 = m_cresults.prefix(); + ignore_unused_variable_warning(mrcr2); + mr_const_reference mrcr3 = m_cresults.suffix(); + ignore_unused_variable_warning(mrcr3); + mr_const_iterator mrci = m_cresults.begin(); + ignore_unused_variable_warning(mrci); + mrci = m_cresults.end(); + ignore_unused_variable_warning(mrci); + + mr_allocator_type at2 = m_cresults.get_allocator(); + m_results.swap(m_results); + global_regex_namespace::swap(m_results, m_results); + + // regex_match: + b = global_regex_namespace::regex_match(m_in, m_in, m_results, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_in, m_in, m_results, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_in, m_in, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_in, m_in, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_pointer, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_pointer, e, m_mft); + ignore_unused_variable_warning(b); + // regex_search: + b = global_regex_namespace::regex_search(m_in, m_in, m_results, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_in, m_in, m_results, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_in, m_in, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_in, m_in, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_pointer, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_pointer, e, m_mft); + ignore_unused_variable_warning(b); + + // regex_iterator: + typedef typename regex_iterator_type::regex_type rit_regex_type; + typedef typename regex_iterator_type::value_type rit_value_type; + typedef typename regex_iterator_type::difference_type rit_difference_type; + typedef typename regex_iterator_type::pointer rit_pointer; + typedef typename regex_iterator_type::reference rit_reference; + typedef typename regex_iterator_type::iterator_category rit_iterator_category; + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_convertible::value)); + // this takes care of most of the checks needed: + function_requires >(); + regex_iterator_type iter1(m_in, m_in, e); + ignore_unused_variable_warning(iter1); + regex_iterator_type iter2(m_in, m_in, e, m_mft); + ignore_unused_variable_warning(iter2); + + // regex_token_iterator: + typedef typename regex_token_iterator_type::regex_type rtit_regex_type; + typedef typename regex_token_iterator_type::value_type rtit_value_type; + typedef typename regex_token_iterator_type::difference_type rtit_difference_type; + typedef typename regex_token_iterator_type::pointer rtit_pointer; + typedef typename regex_token_iterator_type::reference rtit_reference; + typedef typename regex_token_iterator_type::iterator_category rtit_iterator_category; + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_same::value)); + BOOST_STATIC_ASSERT((::boost::is_convertible::value)); + // this takes care of most of the checks needed: + function_requires >(); + regex_token_iterator_type ti1(m_in, m_in, e); + ignore_unused_variable_warning(ti1); + regex_token_iterator_type ti2(m_in, m_in, e, 0); + ignore_unused_variable_warning(ti2); + regex_token_iterator_type ti3(m_in, m_in, e, 0, m_mft); + ignore_unused_variable_warning(ti3); + std::vector subs; + regex_token_iterator_type ti4(m_in, m_in, e, subs); + ignore_unused_variable_warning(ti4); + regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft); + ignore_unused_variable_warning(ti5); + static const int i_array[3] = { 1, 2, 3, }; + regex_token_iterator_type ti6(m_in, m_in, e, i_array); + ignore_unused_variable_warning(ti6); + regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft); + ignore_unused_variable_warning(ti7); + } + + pointer_type m_pointer; + flag_type m_flags; + std::size_t m_size; + input_iterator_type in1, in2; + const sub_match_type m_sub; + const value_type m_char; + match_results_type m_results; + const match_results_type m_cresults; + OutIterator m_out; + BidiIterator m_in; + global_regex_namespace::regex_constants::match_flag_type m_mft; + global_regex_namespace::match_results m_pmatch; + + BaseRegexConcept(); + BaseRegexConcept(const BaseRegexConcept&); + BaseRegexConcept& operator=(const BaseRegexConcept&); +}; + +// +// RegexConcept: +// Test every interface in the std: +// +template +struct RegexConcept +{ + typedef typename Regex::value_type value_type; + //typedef typename Regex::size_type size_type; + typedef typename Regex::flag_type flag_type; + typedef typename Regex::locale_type locale_type; + + // derived test types: + typedef const value_type* pointer_type; + typedef std::basic_string string_type; + typedef boost::bidirectional_iterator_archetype BidiIterator; + typedef global_regex_namespace::sub_match sub_match_type; + typedef global_regex_namespace::match_results match_results_type; + typedef output_iterator_archetype OutIterator; + + + void constraints() + { + function_requires >(); + // string based construct: + Regex e1(m_string); + ignore_unused_variable_warning(e1); + Regex e2(m_string, m_flags); + ignore_unused_variable_warning(e2); + + // assign etc: + Regex e; + e = m_string; + e.assign(m_string); + e.assign(m_string, m_flags); + + // sub_match: + string_type s(m_sub); + ignore_unused_variable_warning(s); + s = m_sub.str(); + ignore_unused_variable_warning(s); + int i = m_sub.compare(m_string); + ignore_unused_variable_warning(i); + + int i2 = m_sub.compare(m_sub); + ignore_unused_variable_warning(i2); + i2 = m_sub.compare(m_pointer); + ignore_unused_variable_warning(i2); + + bool b = m_sub == m_sub; + ignore_unused_variable_warning(b); + b = m_sub != m_sub; + ignore_unused_variable_warning(b); + b = m_sub <= m_sub; + ignore_unused_variable_warning(b); + b = m_sub <= m_sub; + ignore_unused_variable_warning(b); + b = m_sub > m_sub; + ignore_unused_variable_warning(b); + b = m_sub >= m_sub; + ignore_unused_variable_warning(b); + + b = m_sub == m_pointer; + ignore_unused_variable_warning(b); + b = m_sub != m_pointer; + ignore_unused_variable_warning(b); + b = m_sub <= m_pointer; + ignore_unused_variable_warning(b); + b = m_sub <= m_pointer; + ignore_unused_variable_warning(b); + b = m_sub > m_pointer; + ignore_unused_variable_warning(b); + b = m_sub >= m_pointer; + ignore_unused_variable_warning(b); + + b = m_pointer == m_sub; + ignore_unused_variable_warning(b); + b = m_pointer != m_sub; + ignore_unused_variable_warning(b); + b = m_pointer <= m_sub; + ignore_unused_variable_warning(b); + b = m_pointer <= m_sub; + ignore_unused_variable_warning(b); + b = m_pointer > m_sub; + ignore_unused_variable_warning(b); + b = m_pointer >= m_sub; + ignore_unused_variable_warning(b); + + b = m_sub == m_char; + ignore_unused_variable_warning(b); + b = m_sub != m_char; + ignore_unused_variable_warning(b); + b = m_sub <= m_char; + ignore_unused_variable_warning(b); + b = m_sub <= m_char; + ignore_unused_variable_warning(b); + b = m_sub > m_char; + ignore_unused_variable_warning(b); + b = m_sub >= m_char; + ignore_unused_variable_warning(b); + + b = m_char == m_sub; + ignore_unused_variable_warning(b); + b = m_char != m_sub; + ignore_unused_variable_warning(b); + b = m_char <= m_sub; + ignore_unused_variable_warning(b); + b = m_char <= m_sub; + ignore_unused_variable_warning(b); + b = m_char > m_sub; + ignore_unused_variable_warning(b); + b = m_char >= m_sub; + ignore_unused_variable_warning(b); + + b = m_sub == m_string; + ignore_unused_variable_warning(b); + b = m_sub != m_string; + ignore_unused_variable_warning(b); + b = m_sub <= m_string; + ignore_unused_variable_warning(b); + b = m_sub <= m_string; + ignore_unused_variable_warning(b); + b = m_sub > m_string; + ignore_unused_variable_warning(b); + b = m_sub >= m_string; + ignore_unused_variable_warning(b); + + b = m_string == m_sub; + ignore_unused_variable_warning(b); + b = m_string != m_sub; + ignore_unused_variable_warning(b); + b = m_string <= m_sub; + ignore_unused_variable_warning(b); + b = m_string <= m_sub; + ignore_unused_variable_warning(b); + b = m_string > m_sub; + ignore_unused_variable_warning(b); + b = m_string >= m_sub; + ignore_unused_variable_warning(b); + + // match results: + m_string = m_results.str(); + ignore_unused_variable_warning(m_string); + m_string = m_results.str(0); + ignore_unused_variable_warning(m_string); + m_out = m_cresults.format(m_out, m_string); + m_out = m_cresults.format(m_out, m_string, m_mft); + m_string = m_cresults.format(m_string); + ignore_unused_variable_warning(m_string); + m_string = m_cresults.format(m_string, m_mft); + ignore_unused_variable_warning(m_string); + + // regex_match: + b = global_regex_namespace::regex_match(m_string, m_smatch, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_string, m_smatch, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_string, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_match(m_string, e, m_mft); + ignore_unused_variable_warning(b); + + // regex_search: + b = global_regex_namespace::regex_search(m_string, m_smatch, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_string, m_smatch, e, m_mft); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_string, e); + ignore_unused_variable_warning(b); + b = global_regex_namespace::regex_search(m_string, e, m_mft); + ignore_unused_variable_warning(b); + + // regex_replace: + m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string, m_mft); + m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string); + m_string = global_regex_namespace::regex_replace(m_string, e, m_string, m_mft); + ignore_unused_variable_warning(m_string); + m_string = global_regex_namespace::regex_replace(m_string, e, m_string); + ignore_unused_variable_warning(m_string); + + } + + flag_type m_flags; + string_type m_string; + const sub_match_type m_sub; + match_results_type m_results; + pointer_type m_pointer; + value_type m_char; + const match_results_type m_cresults; + OutIterator m_out; + BidiIterator m_in; + global_regex_namespace::regex_constants::match_flag_type m_mft; + global_regex_namespace::match_results m_smatch; + + RegexConcept(); + RegexConcept(const RegexConcept&); + RegexConcept& operator=(const RegexConcept&); +}; + +#ifndef BOOST_REGEX_TEST_STD +// +// BoostRegexConcept: +// Test every interface in the Boost implementation: +// +template +struct BoostRegexConcept +{ + typedef typename Regex::value_type value_type; + typedef typename Regex::size_type size_type; + typedef typename Regex::flag_type flag_type; + typedef typename Regex::locale_type locale_type; + + // derived test types: + typedef const value_type* pointer_type; + typedef std::basic_string string_type; + typedef typename Regex::const_iterator const_iterator; + typedef bidirectional_iterator_archetype BidiIterator; + typedef global_regex_namespace::sub_match sub_match_type; + typedef global_regex_namespace::match_results match_results_type; + + void constraints() + { + global_regex_namespace::regex_constants::match_flag_type mopts + = global_regex_namespace::regex_constants::match_default + | global_regex_namespace::regex_constants::match_not_bol + | global_regex_namespace::regex_constants::match_not_eol + | global_regex_namespace::regex_constants::match_not_bow + | global_regex_namespace::regex_constants::match_not_eow + | global_regex_namespace::regex_constants::match_any + | global_regex_namespace::regex_constants::match_not_null + | global_regex_namespace::regex_constants::match_continuous + | global_regex_namespace::regex_constants::match_partial + | global_regex_namespace::regex_constants::match_prev_avail + | global_regex_namespace::regex_constants::format_default + | global_regex_namespace::regex_constants::format_sed + | global_regex_namespace::regex_constants::format_perl + | global_regex_namespace::regex_constants::format_no_copy + | global_regex_namespace::regex_constants::format_first_only; + + (void)mopts; + + function_requires >(); + const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate); + std::ptrdiff_t pt = except.position(); + ignore_unused_variable_warning(pt); + const Regex ce, ce2; +#ifndef BOOST_NO_STD_LOCALE + m_stream << ce; +#endif + unsigned i = ce.error_code(); + ignore_unused_variable_warning(i); + pointer_type p = ce.expression(); + ignore_unused_variable_warning(p); + int i2 = ce.compare(ce2); + ignore_unused_variable_warning(i2); + bool b = ce == ce2; + ignore_unused_variable_warning(b); + b = ce.empty(); + ignore_unused_variable_warning(b); + b = ce != ce2; + ignore_unused_variable_warning(b); + b = ce < ce2; + ignore_unused_variable_warning(b); + b = ce > ce2; + ignore_unused_variable_warning(b); + b = ce <= ce2; + ignore_unused_variable_warning(b); + b = ce >= ce2; + ignore_unused_variable_warning(b); + i = ce.status(); + ignore_unused_variable_warning(i); + size_type s = ce.max_size(); + ignore_unused_variable_warning(s); + s = ce.size(); + ignore_unused_variable_warning(s); + const_iterator pi = ce.begin(); + ignore_unused_variable_warning(pi); + pi = ce.end(); + ignore_unused_variable_warning(pi); + string_type s2 = ce.str(); + ignore_unused_variable_warning(s2); + + m_string = m_sub + m_sub; + ignore_unused_variable_warning(m_string); + m_string = m_sub + m_pointer; + ignore_unused_variable_warning(m_string); + m_string = m_pointer + m_sub; + ignore_unused_variable_warning(m_string); + m_string = m_sub + m_string; + ignore_unused_variable_warning(m_string); + m_string = m_string + m_sub; + ignore_unused_variable_warning(m_string); + m_string = m_sub + m_char; + ignore_unused_variable_warning(m_string); + m_string = m_char + m_sub; + ignore_unused_variable_warning(m_string); + +#ifndef BOOST_NO_STD_LOCALE + m_stream << m_sub; + m_stream << m_cresults; +#endif + } + + std::basic_ostream m_stream; + sub_match_type m_sub; + pointer_type m_pointer; + string_type m_string; + const value_type m_char; + match_results_type m_results; + const match_results_type m_cresults; + + BoostRegexConcept(); + BoostRegexConcept(const BoostRegexConcept&); + BoostRegexConcept& operator=(const BoostRegexConcept&); +}; + +#endif // BOOST_REGEX_TEST_STD + +} + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/config.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/config.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,417 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE config.hpp + * VERSION see + * DESCRIPTION: regex extended config setup. + */ + +#ifndef BOOST_REGEX_CONFIG_HPP +#define BOOST_REGEX_CONFIG_HPP +/* + * Borland C++ Fix/error check + * this has to go *before* we include any std lib headers: + */ +#if defined(__BORLANDC__) +# include +#endif + +/***************************************************************************** + * + * Include all the headers we need here: + * + ****************************************************************************/ + +#ifdef __cplusplus + +# ifndef BOOST_REGEX_USER_CONFIG +# define BOOST_REGEX_USER_CONFIG +# endif + +# include BOOST_REGEX_USER_CONFIG + +# include + +#else + /* + * C build, + * don't include because that may + * do C++ specific things in future... + */ +# include +# include +# ifdef _MSC_VER +# define BOOST_MSVC _MSC_VER +# endif +#endif + +/***************************************************************************** + * + * Boilerplate regex config options: + * + ****************************************************************************/ + +/* Obsolete macro, use BOOST_VERSION instead: */ +#define BOOST_RE_VERSION 320 + +/* fix: */ +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +/* + * Fix for gcc prior to 3.4: std::ctype doesn't allow + * masks to be combined, for example: + * std::use_facet >.is(std::ctype_base::lower|std::ctype_base::upper, L'a'); + * returns *false*. + */ +#ifdef __GLIBCPP__ +# define BOOST_REGEX_BUGGY_CTYPE_FACET +#endif + +/* + * Intel C++ before 8.0 ends up with unresolved externals unless we turn off + * extern template support: + */ +#if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800) +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +#endif +/* + * Visual C++ doesn't support external templates with C++ extensions turned off: + */ +#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS) +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +#endif + +/* + * If there isn't good enough wide character support then there will + * be no wide character regular expressions: + */ +#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) +# if !defined(BOOST_NO_WREGEX) +# define BOOST_NO_WREGEX +# endif +#else +# if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) + /* STLPort on IRIX is misconfigured: does not compile + * as a temporary fix include instead and prevent inclusion + * of STLPort version of */ +# include +# define __STLPORT_CWCTYPE +# define _STLP_CWCTYPE +# endif + +#ifdef __cplusplus +# include +#endif + +#endif + +/* + * If Win32 support has been disabled for boost in general, then + * it is for regex in particular: + */ +#if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32) +# define BOOST_REGEX_NO_W32 +#endif + +/* disable our own file-iterators and mapfiles if we can't + * support them: */ +#if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)) +# define BOOST_REGEX_NO_FILEITER +#endif + +/* backwards compatibitity: */ +#if defined(BOOST_RE_NO_LIB) +# define BOOST_REGEX_NO_LIB +#endif + +#if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__)) +/* gcc on win32 has problems if you include + (sporadically generates bad code). */ +# define BOOST_REGEX_NO_W32 +#endif +#if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS) +# define BOOST_REGEX_NO_W32 +#endif + +/***************************************************************************** + * + * Wide character workarounds: + * + ****************************************************************************/ + +/* + * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users + * code may be built with wchar_t as unsigned short: basically when we're building + * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions + * of the non-inline functions in the library, so that users can still link to the lib, + * irrespective of whether their own code is built with /Zc:wchar_t. + */ +#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && !defined(BOOST_RWSTD_VER) +# define BOOST_REGEX_HAS_OTHER_WCHAR_T +# ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4251 4231 4660) +# endif +# ifdef _DLL +# include + extern template class __declspec(dllimport) std::basic_string; +# endif +# ifdef BOOST_MSVC +# pragma warning(pop) +# endif +#endif + + +/***************************************************************************** + * + * Set up dll import/export options: + * + ****************************************************************************/ + +#if defined(BOOST_HAS_DECLSPEC) && (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK) +# if defined(BOOST_REGEX_SOURCE) +# define BOOST_REGEX_DECL __declspec(dllexport) +# define BOOST_REGEX_BUILD_DLL +# else +# define BOOST_REGEX_DECL __declspec(dllimport) +# endif +#endif + +#ifndef BOOST_REGEX_DECL +# define BOOST_REGEX_DECL +#endif + +#if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus) +# define BOOST_LIB_NAME boost_regex +# if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) +# define BOOST_DYN_LINK +# endif +# ifdef BOOST_REGEX_DIAG +# define BOOST_LIB_DIAGNOSTIC +# endif +# include +#endif + +/***************************************************************************** + * + * Set up function call type: + * + ****************************************************************************/ + +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS) +#if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) +# define BOOST_REGEX_CALL __cdecl +#else +# define BOOST_REGEX_CALL __fastcall +#endif +# define BOOST_REGEX_CCALL __cdecl +#endif + +#if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32) +# define BOOST_REGEX_CALL __fastcall +# define BOOST_REGEX_CCALL __stdcall +#endif + +#ifndef BOOST_REGEX_CALL +# define BOOST_REGEX_CALL +#endif +#ifndef BOOST_REGEX_CCALL +#define BOOST_REGEX_CCALL +#endif + +/***************************************************************************** + * + * Set up localisation model: + * + ****************************************************************************/ + +/* backwards compatibility: */ +#ifdef BOOST_RE_LOCALE_C +# define BOOST_REGEX_USE_C_LOCALE +#endif + +#ifdef BOOST_RE_LOCALE_CPP +# define BOOST_REGEX_USE_CPP_LOCALE +#endif + +/* Win32 defaults to native Win32 locale: */ +#if defined(_WIN32) && !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_REGEX_NO_W32) +# define BOOST_REGEX_USE_WIN32_LOCALE +#endif +/* otherwise use C++ locale if supported: */ +#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE) +# define BOOST_REGEX_USE_CPP_LOCALE +#endif +/* otherwise use C+ locale: */ +#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) +# define BOOST_REGEX_USE_C_LOCALE +#endif + +#ifndef BOOST_REGEX_MAX_STATE_COUNT +# define BOOST_REGEX_MAX_STATE_COUNT 100000000 +#endif + + +/***************************************************************************** + * + * Error Handling for exception free compilers: + * + ****************************************************************************/ + +#ifdef BOOST_NO_EXCEPTIONS +/* + * If there are no exceptions then we must report critical-errors + * the only way we know how; by terminating. + */ +#include +#include +#include + +# define BOOST_REGEX_NOEH_ASSERT(x)\ +if(0 == (x))\ +{\ + std::string s("Error: critical regex++ failure in: ");\ + s.append(#x);\ + std::runtime_error e(s);\ + boost::throw_exception(e);\ +} +#else +/* + * With exceptions then error handling is taken care of and + * there is no need for these checks: + */ +# define BOOST_REGEX_NOEH_ASSERT(x) +#endif + + +/***************************************************************************** + * + * Stack protection under MS Windows: + * + ****************************************************************************/ + +#if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3) +# if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \ + && !defined(__GNUC__) \ + && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \ + && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003)) +# define BOOST_REGEX_HAS_MS_STACK_GUARD +# endif +#elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD) +# undef BOOST_REGEX_HAS_MS_STACK_GUARD +#endif + +#if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD) + +namespace boost{ +namespace re_detail{ + +BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page(); + +} +} + +#endif + + +/***************************************************************************** + * + * Algorithm selection and configuration: + * + ****************************************************************************/ + +#if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE) +# if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)) +# define BOOST_REGEX_RECURSIVE +# else +# define BOOST_REGEX_NON_RECURSIVE +# endif +#endif + +#ifdef BOOST_REGEX_NON_RECURSIVE +# ifdef BOOST_REGEX_RECURSIVE +# error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE" +# endif +# ifndef BOOST_REGEX_BLOCKSIZE +# define BOOST_REGEX_BLOCKSIZE 4096 +# endif +# if BOOST_REGEX_BLOCKSIZE < 512 +# error "BOOST_REGEX_BLOCKSIZE must be at least 512" +# endif +# ifndef BOOST_REGEX_MAX_BLOCKS +# define BOOST_REGEX_MAX_BLOCKS 1024 +# endif +# ifdef BOOST_REGEX_HAS_MS_STACK_GUARD +# undef BOOST_REGEX_HAS_MS_STACK_GUARD +# endif +# ifndef BOOST_REGEX_MAX_CACHE_BLOCKS +# define BOOST_REGEX_MAX_CACHE_BLOCKS 16 +# endif +#endif + + +/***************************************************************************** + * + * helper memory allocation functions: + * + ****************************************************************************/ + +#if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE) +namespace boost{ namespace re_detail{ + +BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block(); +BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*); + +}} /* namespaces */ +#endif + +/***************************************************************************** + * + * Diagnostics: + * + ****************************************************************************/ + +#ifdef BOOST_REGEX_CONFIG_INFO +BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info(); +#endif + +#if defined(BOOST_REGEX_DIAG) +# pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL)) +# pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL)) +# pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL)) +#ifdef BOOST_REGEX_USE_C_LOCALE +# pragma message ("Using C locale in regex traits class") +#elif BOOST_REGEX_USE_CPP_LOCALE +# pragma message ("Using C++ locale in regex traits class") +#else +# pragma message ("Using Win32 locale in regex traits class") +#endif +#if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) +# pragma message ("Dynamic linking enabled") +#endif +#if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB) +# pragma message ("Auto-linking disabled") +#endif +#ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES +# pragma message ("Extern templates disabled") +#endif + +#endif + +#endif + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/config/borland.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/config/borland.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,72 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE boost/regex/config/borland.hpp + * VERSION see + * DESCRIPTION: regex borland-specific config setup. + */ + + +#if defined(__BORLANDC__) +# if (__BORLANDC__ == 0x550) || (__BORLANDC__ == 0x551) + // problems with std::basic_string and dll RTL: +# if defined(_RTLDLL) && defined(_RWSTD_COMPILE_INSTANTIATE) +# ifdef BOOST_REGEX_BUILD_DLL +# error _RWSTD_COMPILE_INSTANTIATE must not be defined when building regex++ as a DLL +# else +# pragma message("Defining _RWSTD_COMPILE_INSTANTIATE when linking to the DLL version of the RTL may produce memory corruption problems in std::basic_string, as a result of separate versions of basic_string's static data in the RTL and you're exe/dll: be warned!!") +# endif +# endif +# ifndef _RTLDLL + // this is harmless for a staic link: +# define _RWSTD_COMPILE_INSTANTIATE +# endif + // external templates cause problems for some reason: +# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES +# endif +# if (__BORLANDC__ <= 0x540) && !defined(BOOST_REGEX_NO_LIB) && !defined(_NO_VCL) + // C++ Builder 4 and earlier, we can't tell whether we should be using + // the VCL runtime or not, do a static link instead: +# define BOOST_REGEX_STATIC_LINK +# endif + // + // VCL support: + // if we're building a console app then there can't be any VCL (can there?) +# if !defined(__CONSOLE__) && !defined(_NO_VCL) +# define BOOST_REGEX_USE_VCL +# endif + // + // if this isn't Win32 then don't automatically select link + // libraries: + // +# ifndef _Windows +# ifndef BOOST_REGEX_NO_LIB +# define BOOST_REGEX_NO_LIB +# endif +# ifndef BOOST_REGEX_STATIC_LINK +# define BOOST_REGEX_STATIC_LINK +# endif +# endif + +#if __BORLANDC__ < 0x600 +// +// string workarounds: +// +#include +#undef strcmp +#undef strcpy +#endif + +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/config/cwchar.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/config/cwchar.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,207 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE boost/regex/config/cwchar.hpp + * VERSION see + * DESCRIPTION: regex wide character string fixes. + */ + +#ifndef BOOST_REGEX_CONFIG_CWCHAR_HPP +#define BOOST_REGEX_CONFIG_CWCHAR_HPP + +#include +#include +#include + +#if defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) +// apparently this is required for the RW STL on Linux: +#undef iswalnum +#undef iswalpha +#undef iswblank +#undef iswcntrl +#undef iswdigit +#undef iswgraph +#undef iswlower +#undef iswprint +#undef iswprint +#undef iswpunct +#undef iswspace +#undef iswupper +#undef iswxdigit +#undef iswctype +#undef towlower +#undef towupper +#undef towctrans +#undef wctrans +#undef wctype +#endif + +namespace std{ + +#ifndef BOOST_NO_STDC_NAMESPACE +extern "C"{ +#endif + +#ifdef iswalnum +inline int (iswalnum)(wint_t i) +{ return iswalnum(i); } +#undef iswalnum +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswalnum; +#endif + +#ifdef iswalpha +inline int (iswalpha)(wint_t i) +{ return iswalpha(i); } +#undef iswalpha +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswalpha; +#endif + +#ifdef iswcntrl +inline int (iswcntrl)(wint_t i) +{ return iswcntrl(i); } +#undef iswcntrl +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswcntrl; +#endif + +#ifdef iswdigit +inline int (iswdigit)(wint_t i) +{ return iswdigit(i); } +#undef iswdigit +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswdigit; +#endif + +#ifdef iswgraph +inline int (iswgraph)(wint_t i) +{ return iswgraph(i); } +#undef iswgraph +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswgraph; +#endif + +#ifdef iswlower +inline int (iswlower)(wint_t i) +{ return iswlower(i); } +#undef iswlower +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswlower; +#endif + +#ifdef iswprint +inline int (iswprint)(wint_t i) +{ return iswprint(i); } +#undef iswprint +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswprint; +#endif + +#ifdef iswpunct +inline int (iswpunct)(wint_t i) +{ return iswpunct(i); } +#undef iswpunct +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswpunct; +#endif + +#ifdef iswspace +inline int (iswspace)(wint_t i) +{ return iswspace(i); } +#undef iswspace +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswspace; +#endif + +#ifdef iswupper +inline int (iswupper)(wint_t i) +{ return iswupper(i); } +#undef iswupper +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswupper; +#endif + +#ifdef iswxdigit +inline int (iswxdigit)(wint_t i) +{ return iswxdigit(i); } +#undef iswxdigit +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::iswxdigit; +#endif + +#ifdef towlower +inline wint_t (towlower)(wint_t i) +{ return towlower(i); } +#undef towlower +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::towlower; +#endif + +#ifdef towupper +inline wint_t (towupper)(wint_t i) +{ return towupper(i); } +#undef towupper +#elif defined(BOOST_NO_STDC_NAMESPACE) +using :: towupper; +#endif + +#ifdef wcscmp +inline int (wcscmp)(const wchar_t *p1, const wchar_t *p2) +{ return wcscmp(p1,p2); } +#undef wcscmp +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::wcscmp; +#endif + +#ifdef wcscoll +inline int (wcscoll)(const wchar_t *p1, const wchar_t *p2) +{ return wcscoll(p1,p2); } +#undef wcscoll +#elif defined(BOOST_NO_STDC_NAMESPACE) && !defined(UNDER_CE) +using ::wcscoll; +#endif + +#ifdef wcscpy +inline wchar_t *(wcscpy)(wchar_t *p1, const wchar_t *p2) +{ return wcscpy(p1,p2); } +#undef wcscpy +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::wcscpy; +#endif + +#ifdef wcslen +inline size_t (wcslen)(const wchar_t *p) +{ return wcslen(p); } +#undef wcslen +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::wcslen; +#endif + +#ifdef wcsxfrm +size_t wcsxfrm(wchar_t *p1, const wchar_t *p2, size_t s) +{ return wcsxfrm(p1,p2,s); } +#undef wcsxfrm +#elif defined(BOOST_NO_STDC_NAMESPACE) +using ::wcsxfrm; +#endif + + +#ifndef BOOST_NO_STDC_NAMESPACE +} // extern "C" +#endif + +} // namespace std + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/icu.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/icu.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,1017 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE icu.hpp + * VERSION see + * DESCRIPTION: Unicode regular expressions on top of the ICU Library. + */ + +#ifndef BOOST_REGEX_ICU_HPP +#define BOOST_REGEX_ICU_HPP + +#include +#include +#include +#include +#include +#include +#include + + +namespace boost{ + +namespace re_detail{ + +// +// Implementation details: +// +class BOOST_REGEX_DECL icu_regex_traits_implementation +{ + typedef UChar32 char_type; + typedef std::size_t size_type; + typedef std::vector string_type; + typedef U_NAMESPACE_QUALIFIER Locale locale_type; + typedef boost::uint_least32_t char_class_type; +public: + icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& l) + : m_locale(l) + { + UErrorCode success = U_ZERO_ERROR; + m_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success)); + if(U_SUCCESS(success) == 0) + init_error(); + m_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::IDENTICAL); + success = U_ZERO_ERROR; + m_primary_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success)); + if(U_SUCCESS(success) == 0) + init_error(); + m_primary_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::PRIMARY); + } + U_NAMESPACE_QUALIFIER Locale getloc()const + { + return m_locale; + } + string_type do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const; + string_type transform(const char_type* p1, const char_type* p2) const + { + return do_transform(p1, p2, m_collator.get()); + } + string_type transform_primary(const char_type* p1, const char_type* p2) const + { + return do_transform(p1, p2, m_primary_collator.get()); + } +private: + void init_error() + { + std::runtime_error e("Could not initialize ICU resources"); + boost::throw_exception(e); + } + U_NAMESPACE_QUALIFIER Locale m_locale; // The ICU locale that we're using + boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_collator; // The full collation object + boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_primary_collator; // The primary collation object +}; + +inline boost::shared_ptr get_icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& loc) +{ + return boost::shared_ptr(new icu_regex_traits_implementation(loc)); +} + +} + +class BOOST_REGEX_DECL icu_regex_traits +{ +public: + typedef UChar32 char_type; + typedef std::size_t size_type; + typedef std::vector string_type; + typedef U_NAMESPACE_QUALIFIER Locale locale_type; +#ifdef BOOST_NO_INT64_T + typedef std::bitset<64> char_class_type; +#else + typedef boost::uint64_t char_class_type; +#endif + + struct boost_extensions_tag{}; + + icu_regex_traits() + : m_pimpl(re_detail::get_icu_regex_traits_implementation(U_NAMESPACE_QUALIFIER Locale())) + { + } + static size_type length(const char_type* p); + + ::boost::regex_constants::syntax_type syntax_type(char_type c)const + { + return ((c < 0x7f) && (c > 0)) ? re_detail::get_default_syntax_type(static_cast(c)) : regex_constants::syntax_char; + } + ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c) const + { + return ((c < 0x7f) && (c > 0)) ? re_detail::get_default_escape_syntax_type(static_cast(c)) : regex_constants::syntax_char; + } + char_type translate(char_type c) const + { + return c; + } + char_type translate_nocase(char_type c) const + { + return ::u_tolower(c); + } + char_type translate(char_type c, bool icase) const + { + return icase ? translate_nocase(c) : translate(c); + } + char_type tolower(char_type c) const + { + return ::u_tolower(c); + } + char_type toupper(char_type c) const + { + return ::u_toupper(c); + } + string_type transform(const char_type* p1, const char_type* p2) const + { + return m_pimpl->transform(p1, p2); + } + string_type transform_primary(const char_type* p1, const char_type* p2) const + { + return m_pimpl->transform_primary(p1, p2); + } + char_class_type lookup_classname(const char_type* p1, const char_type* p2) const; + string_type lookup_collatename(const char_type* p1, const char_type* p2) const; + bool isctype(char_type c, char_class_type f) const; + int toi(const char_type*& p1, const char_type* p2, int radix)const + { + return re_detail::global_toi(p1, p2, radix, *this); + } + int value(char_type c, int radix)const + { + return u_digit(c, static_cast< ::int8_t>(radix)); + } + locale_type imbue(locale_type l) + { + locale_type result(m_pimpl->getloc()); + m_pimpl = re_detail::get_icu_regex_traits_implementation(l); + return result; + } + locale_type getloc()const + { + return locale_type(); + } + std::string error_string(::boost::regex_constants::error_type n) const + { + return re_detail::get_default_error_string(n); + } +private: + icu_regex_traits(const icu_regex_traits&); + icu_regex_traits& operator=(const icu_regex_traits&); + + // + // define the bitmasks offsets we need for additional character properties: + // + enum{ + offset_blank = U_CHAR_CATEGORY_COUNT, + offset_space = U_CHAR_CATEGORY_COUNT+1, + offset_xdigit = U_CHAR_CATEGORY_COUNT+2, + offset_underscore = U_CHAR_CATEGORY_COUNT+3, + offset_unicode = U_CHAR_CATEGORY_COUNT+4, + offset_any = U_CHAR_CATEGORY_COUNT+5, + offset_ascii = U_CHAR_CATEGORY_COUNT+6 + }; + + // + // and now the masks: + // + static const char_class_type mask_blank; + static const char_class_type mask_space; + static const char_class_type mask_xdigit; + static const char_class_type mask_underscore; + static const char_class_type mask_unicode; + static const char_class_type mask_any; + static const char_class_type mask_ascii; + + static char_class_type lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2); + + boost::shared_ptr< ::boost::re_detail::icu_regex_traits_implementation> m_pimpl; +}; + +} // namespace boost + +// +// template instances: +// +#define BOOST_REGEX_CHAR_T UChar32 +#undef BOOST_REGEX_TRAITS_T +#define BOOST_REGEX_TRAITS_T , icu_regex_traits +#define BOOST_REGEX_ICU_INSTANCES +#ifdef BOOST_REGEX_ICU_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#undef BOOST_REGEX_TRAITS_T +#undef BOOST_REGEX_ICU_INSTANCES +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif + +namespace boost{ + +// types: +typedef basic_regex< ::UChar32, icu_regex_traits> u32regex; +typedef match_results u32match; +typedef match_results u16match; + +// +// Construction of 32-bit regex types from UTF-8 and UTF-16 primitives: +// +namespace re_detail{ + +#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<1>*) +{ + typedef boost::u8_to_u32_iterator conv_type; + return u32regex(conv_type(i), conv_type(j), opt); +} + +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<2>*) +{ + typedef boost::u16_to_u32_iterator conv_type; + return u32regex(conv_type(i), conv_type(j), opt); +} + +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<4>*) +{ + return u32regex(i, j, opt); +} +#else +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<1>*) +{ + typedef boost::u8_to_u32_iterator conv_type; + typedef std::vector vector_type; + vector_type v; + conv_type a(i), b(j); + while(a != b) + { + v.push_back(*a); + ++a; + } + if(v.size()) + return u32regex(&*v.begin(), v.size(), opt); + return u32regex(static_cast(0), static_cast(0), opt); +} + +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<2>*) +{ + typedef boost::u16_to_u32_iterator conv_type; + typedef std::vector vector_type; + vector_type v; + conv_type a(i), b(j); + while(a != b) + { + v.push_back(*a); + ++a; + } + if(v.size()) + return u32regex(&*v.begin(), v.size(), opt); + return u32regex(static_cast(0), static_cast(0), opt); +} + +template +inline u32regex do_make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt, + const boost::mpl::int_<4>*) +{ + typedef std::vector vector_type; + vector_type v; + while(i != j) + { + v.push_back((UCHAR32)(*i)); + ++a; + } + if(v.size()) + return u32regex(&*v.begin(), v.size(), opt); + return u32regex(static_cast(0), static_cast(0), opt); +} +#endif +} + +// +// Construction from an iterator pair: +// +template +inline u32regex make_u32regex(InputIterator i, + InputIterator j, + boost::regex_constants::syntax_option_type opt) +{ + return re_detail::do_make_u32regex(i, j, opt, static_cast const*>(0)); +} +// +// construction from UTF-8 nul-terminated strings: +// +inline u32regex make_u32regex(const char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(p, p + std::strlen(p), opt, static_cast const*>(0)); +} +inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(p, p + std::strlen(reinterpret_cast(p)), opt, static_cast const*>(0)); +} +// +// construction from UTF-16 nul-terminated strings: +// +#ifndef BOOST_NO_WREGEX +inline u32regex make_u32regex(const wchar_t* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast const*>(0)); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(p, p + u_strlen(p), opt, static_cast const*>(0)); +} +#endif +// +// construction from basic_string class-template: +// +template +inline u32regex make_u32regex(const std::basic_string& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(s.begin(), s.end(), opt, static_cast const*>(0)); +} +// +// Construction from ICU string type: +// +inline u32regex make_u32regex(const UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl) +{ + return re_detail::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast const*>(0)); +} + +// +// regex_match overloads that widen the character type as appropriate: +// +namespace re_detail{ +template +void copy_results(MR1& out, MR2 const& in) +{ + // copy results from an adapted MR2 match_results: + out.set_size(in.size(), in.prefix().first.base(), in.suffix().second.base()); + out.set_base(in.base().base()); + for(int i = 0; i < (int)in.size(); ++i) + { + if(in[i].matched) + { + out.set_first(in[i].first.base(), i); + out.set_second(in[i].second.base(), i); + } + } +} + +template +inline bool do_regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + boost::mpl::int_<4> const*) +{ + return ::boost::regex_match(first, last, m, e, flags); +} +template +bool do_regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + boost::mpl::int_<2> const*) +{ + typedef u16_to_u32_iterator conv_type; + typedef match_results match_type; + typedef typename match_type::allocator_type alloc_type; + match_type what; + bool result = ::boost::regex_match(conv_type(first), conv_type(last), what, e, flags); + // copy results across to m: + if(result) copy_results(m, what); + return result; +} +template +bool do_regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + boost::mpl::int_<1> const*) +{ + typedef u8_to_u32_iterator conv_type; + typedef match_results match_type; + typedef typename match_type::allocator_type alloc_type; + match_type what; + bool result = ::boost::regex_match(conv_type(first), conv_type(last), what, e, flags); + // copy results across to m: + if(result) copy_results(m, what); + return result; +} +} // namespace re_detail + +template +inline bool u32regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(first, last, m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const UChar* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast const*>(0)); +} +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) +inline bool u32regex_match(const wchar_t* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast const*>(0)); +} +#endif +inline bool u32regex_match(const char* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const unsigned char* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const std::string& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); +} +#ifndef BOOST_NO_STD_WSTRING +inline bool u32regex_match(const std::wstring& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); +} +#endif +inline bool u32regex_match(const UnicodeString& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast const*>(0)); +} +// +// regex_match overloads that do not return what matched: +// +template +inline bool u32regex_match(BidiIterator first, BidiIterator last, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(first, last, m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const UChar* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast const*>(0)); +} +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) +inline bool u32regex_match(const wchar_t* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast const*>(0)); +} +#endif +inline bool u32regex_match(const char* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const unsigned char* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast const*>(0)); +} +inline bool u32regex_match(const std::string& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); +} +#ifndef BOOST_NO_STD_WSTRING +inline bool u32regex_match(const std::wstring& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast const*>(0)); +} +#endif +inline bool u32regex_match(const UnicodeString& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast const*>(0)); +} + +// +// regex_search overloads that widen the character type as appropriate: +// +namespace re_detail{ +template +inline bool do_regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + BidiIterator base, + boost::mpl::int_<4> const*) +{ + return ::boost::regex_search(first, last, m, e, flags, base); +} +template +bool do_regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + BidiIterator base, + boost::mpl::int_<2> const*) +{ + typedef u16_to_u32_iterator conv_type; + typedef match_results match_type; + typedef typename match_type::allocator_type alloc_type; + match_type what; + bool result = ::boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base)); + // copy results across to m: + if(result) copy_results(m, what); + return result; +} +template +bool do_regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + BidiIterator base, + boost::mpl::int_<1> const*) +{ + typedef u8_to_u32_iterator conv_type; + typedef match_results match_type; + typedef typename match_type::allocator_type alloc_type; + match_type what; + bool result = ::boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base)); + // copy results across to m: + if(result) copy_results(m, what); + return result; +} +} + +template +inline bool u32regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(first, last, m, e, flags, first, static_cast const*>(0)); +} +template +inline bool u32regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const u32regex& e, + match_flag_type flags, + BidiIterator base) +{ + return re_detail::do_regex_search(first, last, m, e, flags, base, static_cast const*>(0)); +} +inline bool u32regex_search(const UChar* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast const*>(0)); +} +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) +inline bool u32regex_search(const wchar_t* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast const*>(0)); +} +#endif +inline bool u32regex_search(const char* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast const*>(0)); +} +inline bool u32regex_search(const unsigned char* p, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast const*>(0)); +} +inline bool u32regex_search(const std::string& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); +} +#ifndef BOOST_NO_STD_WSTRING +inline bool u32regex_search(const std::wstring& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); +} +#endif +inline bool u32regex_search(const UnicodeString& s, + match_results& m, + const u32regex& e, + match_flag_type flags = match_default) +{ + return re_detail::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast const*>(0)); +} +template +inline bool u32regex_search(BidiIterator first, BidiIterator last, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(first, last, m, e, flags, first, static_cast const*>(0)); +} +inline bool u32regex_search(const UChar* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast const*>(0)); +} +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) && !defined(BOOST_NO_WREGEX) +inline bool u32regex_search(const wchar_t* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast const*>(0)); +} +#endif +inline bool u32regex_search(const char* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast const*>(0)); +} +inline bool u32regex_search(const unsigned char* p, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast const*>(0)); +} +inline bool u32regex_search(const std::string& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); +} +#ifndef BOOST_NO_STD_WSTRING +inline bool u32regex_search(const std::wstring& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast const*>(0)); +} +#endif +inline bool u32regex_search(const UnicodeString& s, + const u32regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return re_detail::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast const*>(0)); +} + +// +// overloads for regex_replace with utf-8 and utf-16 data types: +// +namespace re_detail{ +template +inline std::pair< boost::u8_to_u32_iterator, boost::u8_to_u32_iterator > + make_utf32_seq(I i, I j, mpl::int_<1> const*) +{ + return std::pair< boost::u8_to_u32_iterator, boost::u8_to_u32_iterator >(boost::u8_to_u32_iterator(i), boost::u8_to_u32_iterator(j)); +} +template +inline std::pair< boost::u16_to_u32_iterator, boost::u16_to_u32_iterator > + make_utf32_seq(I i, I j, mpl::int_<2> const*) +{ + return std::pair< boost::u16_to_u32_iterator, boost::u16_to_u32_iterator >(boost::u16_to_u32_iterator(i), boost::u16_to_u32_iterator(j)); +} +template +inline std::pair< I, I > + make_utf32_seq(I i, I j, mpl::int_<4> const*) +{ + return std::pair< I, I >(i, j); +} +template +inline std::pair< boost::u8_to_u32_iterator, boost::u8_to_u32_iterator > + make_utf32_seq(const charT* p, mpl::int_<1> const*) +{ + return std::pair< boost::u8_to_u32_iterator, boost::u8_to_u32_iterator >(boost::u8_to_u32_iterator(p), boost::u8_to_u32_iterator(p+std::strlen((const char*)p))); +} +template +inline std::pair< boost::u16_to_u32_iterator, boost::u16_to_u32_iterator > + make_utf32_seq(const charT* p, mpl::int_<2> const*) +{ + return std::pair< boost::u16_to_u32_iterator, boost::u16_to_u32_iterator >(boost::u16_to_u32_iterator(p), boost::u16_to_u32_iterator(p+u_strlen((const UChar*)p))); +} +template +inline std::pair< const charT*, const charT* > + make_utf32_seq(const charT* p, mpl::int_<4> const*) +{ + return std::pair< const charT*, const charT* >(p, p+icu_regex_traits::length((UChar32 const*)p)); +} +template +inline OutputIterator make_utf32_out(OutputIterator o, mpl::int_<4> const*) +{ + return o; +} +template +inline utf16_output_iterator make_utf32_out(OutputIterator o, mpl::int_<2> const*) +{ + return o; +} +template +inline utf8_output_iterator make_utf32_out(OutputIterator o, mpl::int_<1> const*) +{ + return o; +} + +template +OutputIterator do_regex_replace(OutputIterator out, + std::pair const& in, + const u32regex& e, + const std::pair& fmt, + match_flag_type flags + ) +{ + // unfortunately we have to copy the format string in order to pass in onward: + std::vector f; +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS + f.assign(fmt.first, fmt.second); +#else + f.clear(); + I2 pos = fmt.first; + while(pos != fmt.second) + f.push_back(*pos++); +#endif + + regex_iterator i(in.first, in.second, e, flags); + regex_iterator j; + if(i == j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(in.first, in.second, out); + } + else + { + I1 last_m = in.first; + while(i != j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(i->prefix().first, i->prefix().second, out); + if(f.size()) + out = ::boost::re_detail::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits()); + else + out = ::boost::re_detail::regex_format_imp(out, *i, static_cast(0), static_cast(0), flags, e.get_traits()); + last_m = (*i)[0].second; + if(flags & regex_constants::format_first_only) + break; + ++i; + } + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(last_m, in.second, out); + } + return out; +} +template +inline const BaseIterator& extract_output_base(const BaseIterator& b) +{ + return b; +} +template +inline BaseIterator extract_output_base(const utf8_output_iterator& b) +{ + return b.base(); +} +template +inline BaseIterator extract_output_base(const utf16_output_iterator& b) +{ + return b.base(); +} +} // re_detail + +template +inline OutputIterator u32regex_replace(OutputIterator out, + BidirectionalIterator first, + BidirectionalIterator last, + const u32regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + return re_detail::extract_output_base +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + +#endif + ( + re_detail::do_regex_replace( + re_detail::make_utf32_out(out, static_cast const*>(0)), + re_detail::make_utf32_seq(first, last, static_cast const*>(0)), + e, + re_detail::make_utf32_seq(fmt, static_cast const*>(0)), + flags) + ); +} + +template +inline OutputIterator u32regex_replace(OutputIterator out, + Iterator first, + Iterator last, + const u32regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + return re_detail::extract_output_base +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + +#endif + ( + re_detail::do_regex_replace( + re_detail::make_utf32_out(out, static_cast const*>(0)), + re_detail::make_utf32_seq(first, last, static_cast const*>(0)), + e, + re_detail::make_utf32_seq(fmt.begin(), fmt.end(), static_cast const*>(0)), + flags) + ); +} + +template +inline OutputIterator u32regex_replace(OutputIterator out, + Iterator first, + Iterator last, + const u32regex& e, + const UnicodeString& fmt, + match_flag_type flags = match_default) +{ + return re_detail::extract_output_base +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + +#endif + ( + re_detail::do_regex_replace( + re_detail::make_utf32_out(out, static_cast const*>(0)), + re_detail::make_utf32_seq(first, last, static_cast const*>(0)), + e, + re_detail::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast const*>(0)), + flags) + ); +} + +template +std::basic_string u32regex_replace(const std::basic_string& s, + const u32regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + u32regex_replace(i, s.begin(), s.end(), e, fmt, flags); + return result; +} + +template +std::basic_string u32regex_replace(const std::basic_string& s, + const u32regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + u32regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); + return result; +} + +namespace re_detail{ + +class unicode_string_out_iterator +{ + UnicodeString* out; +public: + unicode_string_out_iterator(UnicodeString& s) : out(&s) {} + unicode_string_out_iterator& operator++() { return *this; } + unicode_string_out_iterator& operator++(int) { return *this; } + unicode_string_out_iterator& operator*() { return *this; } + unicode_string_out_iterator& operator=(UChar v) + { + *out += v; + return *this; + } + typedef std::ptrdiff_t difference_type; + typedef UChar value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::output_iterator_tag iterator_category; +}; + +} + +inline UnicodeString u32regex_replace(const UnicodeString& s, + const u32regex& e, + const UChar* fmt, + match_flag_type flags = match_default) +{ + UnicodeString result; + re_detail::unicode_string_out_iterator i(result); + u32regex_replace(i, s.getBuffer(), s.getBuffer()+s.length(), e, fmt, flags); + return result; +} + +inline UnicodeString u32regex_replace(const UnicodeString& s, + const u32regex& e, + const UnicodeString& fmt, + match_flag_type flags = match_default) +{ + UnicodeString result; + re_detail::unicode_string_out_iterator i(result); + re_detail::do_regex_replace( + re_detail::make_utf32_out(i, static_cast const*>(0)), + re_detail::make_utf32_seq(s.getBuffer(), s.getBuffer()+s.length(), static_cast const*>(0)), + e, + re_detail::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast const*>(0)), + flags); + return result; +} + +} // namespace boost. + +#include +#include + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/mfc.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/mfc.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,190 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE mfc.hpp + * VERSION see + * DESCRIPTION: Overloads and helpers for using MFC/ATL string types with Boost.Regex. + */ + +#ifndef BOOST_REGEX_MFC_HPP +#define BOOST_REGEX_MFC_HPP + +#include +#include + +namespace boost{ + +// +// define the types used for TCHAR's: +typedef basic_regex tregex; +typedef match_results tmatch; +typedef regex_iterator tregex_iterator; +typedef regex_token_iterator tregex_token_iterator; + +#if _MSC_VER >= 1310 +#define SIMPLE_STRING_PARAM class B, bool b +#define SIMPLE_STRING_ARG_LIST B, b +#else +#define SIMPLE_STRING_PARAM class B +#define SIMPLE_STRING_ARG_LIST B +#endif + +// +// define regex creation functions: +// +template +inline basic_regex +make_regex(const ATL::CSimpleStringT& s, ::boost::regex_constants::syntax_option_type f = boost::regex_constants::normal) +{ + basic_regex result(s.GetString(), s.GetString() + s.GetLength(), f); + return result; +} +// +// regex_match overloads: +// +template +inline bool regex_match(const ATL::CSimpleStringT& s, + match_results& what, + const basic_regex& e, + boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + return ::boost::regex_match(s.GetString(), + s.GetString() + s.GetLength(), + what, + e, + f); +} + +template +inline bool regex_match(const ATL::CSimpleStringT& s, + const basic_regex& e, + boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + return ::boost::regex_match(s.GetString(), + s.GetString() + s.GetLength(), + e, + f); +} +// +// regex_search overloads: +// +template +inline bool regex_search(const ATL::CSimpleStringT& s, + match_results& what, + const basic_regex& e, + boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + return ::boost::regex_search(s.GetString(), + s.GetString() + s.GetLength(), + what, + e, + f); +} + +template +inline bool regex_search(const ATL::CSimpleStringT& s, + const basic_regex& e, + boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + return ::boost::regex_search(s.GetString(), + s.GetString() + s.GetLength(), + e, + f); +} +// +// regex_iterator creation: +// +template +inline regex_iterator +make_regex_iterator(const ATL::CSimpleStringT& s, const basic_regex& e, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + regex_iterator result(s.GetString(), s.GetString() + s.GetLength(), e, f); + return result; +} + +template +inline regex_token_iterator + make_regex_token_iterator(const ATL::CSimpleStringT& s, const basic_regex& e, int sub = 0, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + regex_token_iterator result(s.GetString(), s.GetString() + s.GetLength(), e, sub, f); + return result; +} + +template +inline regex_token_iterator +make_regex_token_iterator(const ATL::CSimpleStringT& s, const basic_regex& e, const std::vector& subs, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + regex_token_iterator result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f); + return result; +} + +template +inline regex_token_iterator +make_regex_token_iterator(const ATL::CSimpleStringT& s, const basic_regex& e, const int (& subs)[N], ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default) +{ + regex_token_iterator result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f); + return result; +} + +template +OutputIterator regex_replace(OutputIterator out, + BidirectionalIterator first, + BidirectionalIterator last, + const basic_regex& e, + const ATL::CSimpleStringT& fmt, + match_flag_type flags = match_default) +{ + return ::boost::regex_replace(out, first, last, e, fmt.GetString(), flags); +} + +namespace re_detail{ + +template +class mfc_string_out_iterator +{ + ATL::CSimpleStringT* out; +public: + mfc_string_out_iterator(ATL::CSimpleStringT& s) : out(&s) {} + mfc_string_out_iterator& operator++() { return *this; } + mfc_string_out_iterator& operator++(int) { return *this; } + mfc_string_out_iterator& operator*() { return *this; } + mfc_string_out_iterator& operator=(B v) + { + out->AppendChar(v); + return *this; + } + typedef std::ptrdiff_t difference_type; + typedef B value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::output_iterator_tag iterator_category; +}; + +} + +template +ATL::CSimpleStringT regex_replace(const ATL::CSimpleStringT& s, + const basic_regex& e, + const ATL::CSimpleStringT& fmt, + match_flag_type flags = match_default) +{ + ATL::CSimpleStringT result(s.GetManager()); + re_detail::mfc_string_out_iterator i(result); + regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags); + return result; +} + +} // namespace boost. + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/pattern_except.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/pattern_except.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,100 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE pattern_except.hpp + * VERSION see + * DESCRIPTION: Declares pattern-matching exception classes. + */ + +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#define BOOST_RE_PAT_EXCEPT_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +#include +#include +#include + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4275) +#endif +class BOOST_REGEX_DECL regex_error : public std::runtime_error +{ +public: + explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0); + explicit regex_error(regex_constants::error_type err); + ~regex_error() throw(); + regex_constants::error_type code()const + { return m_error_code; } + std::ptrdiff_t position()const + { return m_position; } + void raise()const; +private: + regex_constants::error_type m_error_code; + std::ptrdiff_t m_position; +}; + +typedef regex_error bad_pattern; +typedef regex_error bad_expression; + +namespace re_detail{ + +BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex); + +template +void raise_error(const traits& t, regex_constants::error_type code) +{ + (void)t; // warning suppression + std::runtime_error e(t.error_string(code)); + ::boost::re_detail::raise_runtime_error(e); +} + +} + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/pending/object_cache.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/pending/object_cache.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,163 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE object_cache.hpp + * VERSION see + * DESCRIPTION: Implements a generic object cache. + */ + +#ifndef BOOST_REGEX_OBJECT_CACHE_HPP +#define BOOST_REGEX_OBJECT_CACHE_HPP + +#include +#include +#include +#include +#include +#include +#ifdef BOOST_HAS_THREADS +#include +#endif + +namespace boost{ + +template +class object_cache +{ +public: + typedef std::pair< ::boost::shared_ptr, Key const*> value_type; + typedef std::list list_type; + typedef typename list_type::iterator list_iterator; + typedef std::map map_type; + typedef typename map_type::iterator map_iterator; + typedef typename list_type::size_type size_type; + static boost::shared_ptr get(const Key& k, size_type max_cache_size); + +private: + static boost::shared_ptr do_get(const Key& k, size_type max_cache_size); + + struct data + { + list_type cont; + map_type index; + }; + + // Needed by compilers not implementing the resolution to DR45. For reference, + // see http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45. + friend struct data; +}; + +template +boost::shared_ptr object_cache::get(const Key& k, size_type max_cache_size) +{ +#ifdef BOOST_HAS_THREADS + static boost::static_mutex mut = BOOST_STATIC_MUTEX_INIT; + + boost::static_mutex::scoped_lock l(mut); + if(l) + { + return do_get(k, max_cache_size); + } + // + // what do we do if the lock fails? + // for now just throw, but we should never really get here... + // + ::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock")); + return boost::shared_ptr(); +#else + return do_get(k, max_cache_size); +#endif +} + +template +boost::shared_ptr object_cache::do_get(const Key& k, size_type max_cache_size) +{ + typedef typename object_cache::data object_data; + typedef typename map_type::size_type map_size_type; + static object_data s_data; + + // + // see if the object is already in the cache: + // + map_iterator mpos = s_data.index.find(k); + if(mpos != s_data.index.end()) + { + // + // Eureka! + // We have a cached item, bump it up the list and return it: + // + if(--(s_data.cont.end()) != mpos->second) + { + // splice out the item we want to move: + list_type temp; + temp.splice(temp.end(), s_data.cont, mpos->second); + // and now place it at the end of the list: + s_data.cont.splice(s_data.cont.end(), temp, temp.begin()); + BOOST_ASSERT(*(s_data.cont.back().second) == k); + // update index with new position: + mpos->second = --(s_data.cont.end()); + BOOST_ASSERT(&(mpos->first) == mpos->second->second); + BOOST_ASSERT(&(mpos->first) == s_data.cont.back().second); + } + return s_data.cont.back().first; + } + // + // if we get here then the item is not in the cache, + // so create it: + // + boost::shared_ptr result(new Object(k)); + // + // Add it to the list, and index it: + // + s_data.cont.push_back(value_type(result, static_cast(0))); + s_data.index.insert(std::make_pair(k, --(s_data.cont.end()))); + s_data.cont.back().second = &(s_data.index.find(k)->first); + map_size_type s = s_data.index.size(); + BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); + BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); + BOOST_ASSERT(s_data.index.find(k)->first == k); + if(s > max_cache_size) + { + // + // We have too many items in the list, so we need to start + // popping them off the back of the list, but only if they're + // being held uniquely by us: + // + list_iterator pos = s_data.cont.begin(); + list_iterator last = s_data.cont.end(); + while((pos != last) && (s > max_cache_size)) + { + if(pos->first.unique()) + { + list_iterator condemmed(pos); + ++pos; + // now remove the items from our containers, + // then order has to be as follows: + BOOST_ASSERT(s_data.index.find(*(condemmed->second)) != s_data.index.end()); + s_data.index.erase(*(condemmed->second)); + s_data.cont.erase(condemmed); + --s; + } + else + --pos; + } + BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); + BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); + BOOST_ASSERT(s_data.index.find(k)->first == k); + } + return result; +} + +} + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/pending/static_mutex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/pending/static_mutex.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,184 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE static_mutex.hpp + * VERSION see + * DESCRIPTION: Declares static_mutex lock type, there are three different + * implementations: POSIX pthreads, WIN32 threads, and portable, + * these are described in more detail below. + */ + +#ifndef BOOST_REGEX_STATIC_MUTEX_HPP +#define BOOST_REGEX_STATIC_MUTEX_HPP + +#include +#include // dll import/export options. + +#ifdef BOOST_HAS_PTHREADS +#include +#endif + +#if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER) +// +// pthreads version: +// simple wrap around a pthread_mutex_t initialized with +// PTHREAD_MUTEX_INITIALIZER. +// +namespace boost{ + +class BOOST_REGEX_DECL scoped_static_mutex_lock; + +class static_mutex +{ +public: + typedef scoped_static_mutex_lock scoped_lock; + pthread_mutex_t m_mutex; +}; + +#define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, } + +class BOOST_REGEX_DECL scoped_static_mutex_lock +{ +public: + scoped_static_mutex_lock(static_mutex& mut, bool lk = true); + ~scoped_static_mutex_lock(); + inline bool locked()const + { + return m_have_lock; + } + inline operator void const*()const + { + return locked() ? this : 0; + } + void lock(); + void unlock(); +private: + static_mutex& m_mutex; + bool m_have_lock; +}; + + +} // namespace boost +#elif defined(BOOST_HAS_WINTHREADS) +// +// Win32 version: +// Use a 32-bit int as a lock, along with a test-and-set +// implementation using InterlockedCompareExchange. +// + +#include + +namespace boost{ + +class BOOST_REGEX_DECL scoped_static_mutex_lock; + +class static_mutex +{ +public: + typedef scoped_static_mutex_lock scoped_lock; + boost::int32_t m_mutex; +}; + +#define BOOST_STATIC_MUTEX_INIT { 0, } + +class BOOST_REGEX_DECL scoped_static_mutex_lock +{ +public: + scoped_static_mutex_lock(static_mutex& mut, bool lk = true); + ~scoped_static_mutex_lock(); + operator void const*()const; + bool locked()const; + void lock(); + void unlock(); +private: + static_mutex& m_mutex; + bool m_have_lock; + scoped_static_mutex_lock(const scoped_static_mutex_lock&); + scoped_static_mutex_lock& operator=(const scoped_static_mutex_lock&); +}; + +inline scoped_static_mutex_lock::operator void const*()const +{ + return locked() ? this : 0; +} + +inline bool scoped_static_mutex_lock::locked()const +{ + return m_have_lock; +} + +} // namespace + +#else +// +// Portable version of a static mutex based on Boost.Thread library: +// This has to use a single mutex shared by all instances of static_mutex +// because boost::call_once doesn't alow us to pass instance information +// down to the initialisation proceedure. In fact the initialisation routine +// may need to be called more than once - but only once per instance. +// +// Since this preprocessor path is almost never taken, we hide these header +// dependencies so that build tools don't find them. +// +#define B1 +#define B2 +#include B1 +#include B2 +#undef B1 +#undef B2 + +namespace boost{ + +class BOOST_REGEX_DECL scoped_static_mutex_lock; +extern "C" BOOST_REGEX_DECL void free_static_mutex(); + +class BOOST_REGEX_DECL static_mutex +{ +public: + typedef scoped_static_mutex_lock scoped_lock; + static void init(); + static boost::recursive_mutex* m_pmutex; + static boost::once_flag m_once; +}; + +#define BOOST_STATIC_MUTEX_INIT { } + +class BOOST_REGEX_DECL scoped_static_mutex_lock +{ +public: + scoped_static_mutex_lock(static_mutex& mut, bool lk = true); + ~scoped_static_mutex_lock(); + operator void const*()const; + bool locked()const; + void lock(); + void unlock(); +private: + boost::recursive_mutex::scoped_lock* m_plock; + bool m_have_lock; +}; + +inline scoped_static_mutex_lock::operator void const*()const +{ + return locked() ? this : 0; +} + +inline bool scoped_static_mutex_lock::locked()const +{ + return m_have_lock; +} + +} // namespace + +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/pending/unicode_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/pending/unicode_iterator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,692 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE unicode_iterator.hpp + * VERSION see + * DESCRIPTION: Iterator adapters for converting between different Unicode encodings. + */ + +/**************************************************************************** + +Contents: +~~~~~~~~~ + +1) Read Only, Input Adapters: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +template +class u32_to_u8_iterator; + +Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-8. + +template +class u8_to_u32_iterator; + +Adapts sequence of UTF-8 code points to "look like" a sequence of UTF-32. + +template +class u32_to_u16_iterator; + +Adapts sequence of UTF-32 code points to "look like" a sequence of UTF-16. + +template +class u16_to_u32_iterator; + +Adapts sequence of UTF-16 code points to "look like" a sequence of UTF-32. + +2) Single pass output iterator adapters: + +template +class utf8_output_iterator; + +Accepts UTF-32 code points and forwards them on as UTF-8 code points. + +template +class utf16_output_iterator; + +Accepts UTF-32 code points and forwards them on as UTF-16 code points. + +****************************************************************************/ + +#ifndef BOOST_REGEX_UNICODE_ITERATOR_HPP +#define BOOST_REGEX_UNICODE_ITERATOR_HPP +#include +#include +#include +#include +#include +#include +#ifndef BOOST_NO_STD_LOCALE +#include +#include +#endif +#include // CHAR_BIT + +namespace boost{ + +namespace detail{ + +static const ::boost::uint16_t high_surrogate_base = 0xD7C0u; +static const ::boost::uint16_t low_surrogate_base = 0xDC00u; +static const ::boost::uint32_t ten_bit_mask = 0x3FFu; + +inline bool is_high_surrogate(::boost::uint16_t v) +{ + return (v & 0xFC00u) == 0xd800u; +} +inline bool is_low_surrogate(::boost::uint16_t v) +{ + return (v & 0xFC00u) == 0xdc00u; +} +template +inline bool is_surrogate(T v) +{ + return (v & 0xF800u) == 0xd800; +} + +inline unsigned utf8_byte_count(boost::uint8_t c) +{ + // if the most significant bit with a zero in it is in position + // 8-N then there are N bytes in this UTF-8 sequence: + boost::uint8_t mask = 0x80u; + unsigned result = 0; + while(c & mask) + { + ++result; + mask >>= 1; + } + return (result == 0) ? 1 : ((result > 4) ? 4 : result); +} + +inline unsigned utf8_trailing_byte_count(boost::uint8_t c) +{ + return utf8_byte_count(c) - 1; +} + +inline void invalid_utf32_code_point(::boost::uint32_t val) +{ +#ifndef BOOST_NO_STD_LOCALE + std::stringstream ss; + ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-16 sequence"; + std::out_of_range e(ss.str()); +#else + std::out_of_range e("Invalid UTF-32 code point encountered while trying to encode UTF-16 sequence"); +#endif + boost::throw_exception(e); +} + + +} // namespace detail + +template +class u32_to_u16_iterator + : public boost::iterator_facade, U16Type, std::bidirectional_iterator_tag, const U16Type> +{ + typedef boost::iterator_facade, U16Type, std::bidirectional_iterator_tag, const U16Type> base_type; + +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename std::iterator_traits::value_type base_value_type; + + BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32); + BOOST_STATIC_ASSERT(sizeof(U16Type)*CHAR_BIT == 16); +#endif + +public: + typename base_type::reference + dereference()const + { + if(m_current == 2) + extract_current(); + return m_values[m_current]; + } + bool equal(const u32_to_u16_iterator& that)const + { + if(m_position == that.m_position) + { + // Both m_currents must be equal, or both even + // this is the same as saying their sum must be even: + return (m_current + that.m_current) & 1u ? false : true; + } + return false; + } + void increment() + { + // if we have a pending read then read now, so that we know whether + // to skip a position, or move to a low-surrogate: + if(m_current == 2) + { + // pending read: + extract_current(); + } + // move to the next surrogate position: + ++m_current; + // if we've reached the end skip a position: + if(m_values[m_current] == 0) + { + m_current = 2; + ++m_position; + } + } + void decrement() + { + if(m_current != 1) + { + // decrementing an iterator always leads to a valid position: + --m_position; + extract_current(); + m_current = m_values[1] ? 1 : 0; + } + else + { + m_current = 0; + } + } + BaseIterator base()const + { + return m_position; + } + // construct: + u32_to_u16_iterator() : m_position(), m_current(0) + { + m_values[0] = 0; + m_values[1] = 0; + m_values[2] = 0; + } + u32_to_u16_iterator(BaseIterator b) : m_position(b), m_current(2) + { + m_values[0] = 0; + m_values[1] = 0; + m_values[2] = 0; + } +private: + + void extract_current()const + { + // begin by checking for a code point out of range: + ::boost::uint32_t v = *m_position; + if(v >= 0x10000u) + { + if(v > 0x10FFFFu) + detail::invalid_utf32_code_point(*m_position); + // split into two surrogates: + m_values[0] = static_cast(v >> 10) + detail::high_surrogate_base; + m_values[1] = static_cast(v & detail::ten_bit_mask) + detail::low_surrogate_base; + m_current = 0; + BOOST_ASSERT(detail::is_high_surrogate(m_values[0])); + BOOST_ASSERT(detail::is_low_surrogate(m_values[1])); + } + else + { + // 16-bit code point: + m_values[0] = static_cast(*m_position); + m_values[1] = 0; + m_current = 0; + // value must not be a surrogate: + if(detail::is_surrogate(m_values[0])) + detail::invalid_utf32_code_point(*m_position); + } + } + BaseIterator m_position; + mutable U16Type m_values[3]; + mutable unsigned m_current; +}; + +template +class u16_to_u32_iterator + : public boost::iterator_facade, U32Type, std::bidirectional_iterator_tag, const U32Type> +{ + typedef boost::iterator_facade, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type; + // special values for pending iterator reads: + BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu); + +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename std::iterator_traits::value_type base_value_type; + + BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 16); + BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32); +#endif + +public: + typename base_type::reference + dereference()const + { + if(m_value == pending_read) + extract_current(); + return m_value; + } + bool equal(const u16_to_u32_iterator& that)const + { + return m_position == that.m_position; + } + void increment() + { + // skip high surrogate first if there is one: + if(detail::is_high_surrogate(*m_position)) ++m_position; + ++m_position; + m_value = pending_read; + } + void decrement() + { + --m_position; + // if we have a low surrogate then go back one more: + if(detail::is_low_surrogate(*m_position)) + --m_position; + m_value = pending_read; + } + BaseIterator base()const + { + return m_position; + } + // construct: + u16_to_u32_iterator() : m_position() + { + m_value = pending_read; + } + u16_to_u32_iterator(BaseIterator b) : m_position(b) + { + m_value = pending_read; + } +private: + static void invalid_code_point(::boost::uint16_t val) + { +#ifndef BOOST_NO_STD_LOCALE + std::stringstream ss; + ss << "Misplaced UTF-16 surrogate U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-32 sequence"; + std::out_of_range e(ss.str()); +#else + std::out_of_range e("Misplaced UTF-16 surrogate encountered while trying to encode UTF-32 sequence"); +#endif + boost::throw_exception(e); + } + void extract_current()const + { + m_value = static_cast(static_cast< ::boost::uint16_t>(*m_position)); + // if the last value is a high surrogate then adjust m_position and m_value as needed: + if(detail::is_high_surrogate(*m_position)) + { + // precondition; next value must have be a low-surrogate: + BaseIterator next(m_position); + ::boost::uint16_t t = *++next; + if((t & 0xFC00u) != 0xDC00u) + invalid_code_point(t); + m_value = (m_value - detail::high_surrogate_base) << 10; + m_value |= (static_cast(static_cast< ::boost::uint16_t>(t)) & detail::ten_bit_mask); + } + // postcondition; result must not be a surrogate: + if(detail::is_surrogate(m_value)) + invalid_code_point(static_cast< ::boost::uint16_t>(m_value)); + } + BaseIterator m_position; + mutable U32Type m_value; +}; + +template +class u32_to_u8_iterator + : public boost::iterator_facade, U8Type, std::bidirectional_iterator_tag, const U8Type> +{ + typedef boost::iterator_facade, U8Type, std::bidirectional_iterator_tag, const U8Type> base_type; + +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename std::iterator_traits::value_type base_value_type; + + BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 32); + BOOST_STATIC_ASSERT(sizeof(U8Type)*CHAR_BIT == 8); +#endif + +public: + typename base_type::reference + dereference()const + { + if(m_current == 4) + extract_current(); + return m_values[m_current]; + } + bool equal(const u32_to_u8_iterator& that)const + { + if(m_position == that.m_position) + { + // either the m_current's must be equal, or one must be 0 and + // the other 4: which means neither must have bits 1 or 2 set: + return (m_current == that.m_current) + || (((m_current | that.m_current) & 3) == 0); + } + return false; + } + void increment() + { + // if we have a pending read then read now, so that we know whether + // to skip a position, or move to a low-surrogate: + if(m_current == 4) + { + // pending read: + extract_current(); + } + // move to the next surrogate position: + ++m_current; + // if we've reached the end skip a position: + if(m_values[m_current] == 0) + { + m_current = 4; + ++m_position; + } + } + void decrement() + { + if((m_current & 3) == 0) + { + --m_position; + extract_current(); + m_current = 3; + while(m_current && (m_values[m_current] == 0)) + --m_current; + } + else + --m_current; + } + BaseIterator base()const + { + return m_position; + } + // construct: + u32_to_u8_iterator() : m_position(), m_current(0) + { + m_values[0] = 0; + m_values[1] = 0; + m_values[2] = 0; + m_values[3] = 0; + m_values[4] = 0; + } + u32_to_u8_iterator(BaseIterator b) : m_position(b), m_current(4) + { + m_values[0] = 0; + m_values[1] = 0; + m_values[2] = 0; + m_values[3] = 0; + m_values[4] = 0; + } +private: + + void extract_current()const + { + boost::uint32_t c = *m_position; + if(c > 0x10FFFFu) + detail::invalid_utf32_code_point(c); + if(c < 0x80u) + { + m_values[0] = static_cast(c); + m_values[1] = static_cast(0u); + m_values[2] = static_cast(0u); + m_values[3] = static_cast(0u); + } + else if(c < 0x800u) + { + m_values[0] = static_cast(0xC0u + (c >> 6)); + m_values[1] = static_cast(0x80u + (c & 0x3Fu)); + m_values[2] = static_cast(0u); + m_values[3] = static_cast(0u); + } + else if(c < 0x10000u) + { + m_values[0] = static_cast(0xE0u + (c >> 12)); + m_values[1] = static_cast(0x80u + ((c >> 6) & 0x3Fu)); + m_values[2] = static_cast(0x80u + (c & 0x3Fu)); + m_values[3] = static_cast(0u); + } + else + { + m_values[0] = static_cast(0xF0u + (c >> 18)); + m_values[1] = static_cast(0x80u + ((c >> 12) & 0x3Fu)); + m_values[2] = static_cast(0x80u + ((c >> 6) & 0x3Fu)); + m_values[3] = static_cast(0x80u + (c & 0x3Fu)); + } + m_current= 0; + } + BaseIterator m_position; + mutable U8Type m_values[5]; + mutable unsigned m_current; +}; + +template +class u8_to_u32_iterator + : public boost::iterator_facade, U32Type, std::bidirectional_iterator_tag, const U32Type> +{ + typedef boost::iterator_facade, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type; + // special values for pending iterator reads: + BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu); + +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef typename std::iterator_traits::value_type base_value_type; + + BOOST_STATIC_ASSERT(sizeof(base_value_type)*CHAR_BIT == 8); + BOOST_STATIC_ASSERT(sizeof(U32Type)*CHAR_BIT == 32); +#endif + +public: + typename base_type::reference + dereference()const + { + if(m_value == pending_read) + extract_current(); + return m_value; + } + bool equal(const u8_to_u32_iterator& that)const + { + return m_position == that.m_position; + } + void increment() + { + // skip high surrogate first if there is one: + unsigned c = detail::utf8_byte_count(*m_position); + std::advance(m_position, c); + m_value = pending_read; + } + void decrement() + { + // Keep backtracking until we don't have a trailing character: + unsigned count = 0; + while((*--m_position & 0xC0u) == 0x80u) ++count; + // now check that the sequence was valid: + if(count != detail::utf8_trailing_byte_count(*m_position)) + invalid_sequnce(); + m_value = pending_read; + } + BaseIterator base()const + { + return m_position; + } + // construct: + u8_to_u32_iterator() : m_position() + { + m_value = pending_read; + } + u8_to_u32_iterator(BaseIterator b) : m_position(b) + { + m_value = pending_read; + } +private: + static void invalid_sequnce() + { + std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character"); + boost::throw_exception(e); + } + void extract_current()const + { + m_value = static_cast(static_cast< ::boost::uint8_t>(*m_position)); + // we must not have a continuation character: + if((m_value & 0xC0u) == 0x80u) + invalid_sequnce(); + // see how many extra byts we have: + unsigned extra = detail::utf8_trailing_byte_count(*m_position); + // extract the extra bits, 6 from each extra byte: + BaseIterator next(m_position); + for(unsigned c = 0; c < extra; ++c) + { + ++next; + m_value <<= 6; + m_value += static_cast(*next) & 0x3Fu; + } + // we now need to remove a few of the leftmost bits, but how many depends + // upon how many extra bytes we've extracted: + static const boost::uint32_t masks[4] = + { + 0x7Fu, + 0x7FFu, + 0xFFFFu, + 0x1FFFFFu, + }; + m_value &= masks[extra]; + // check the result: + if(m_value > static_cast(0x10FFFFu)) + invalid_sequnce(); + } + BaseIterator m_position; + mutable U32Type m_value; +}; + +template +class utf16_output_iterator +{ +public: + typedef void difference_type; + typedef void value_type; + typedef boost::uint32_t* pointer; + typedef boost::uint32_t& reference; + typedef std::output_iterator_tag iterator_category; + + utf16_output_iterator(const BaseIterator& b) + : m_position(b){} + utf16_output_iterator(const utf16_output_iterator& that) + : m_position(that.m_position){} + utf16_output_iterator& operator=(const utf16_output_iterator& that) + { + m_position = that.m_position; + return *this; + } + const utf16_output_iterator& operator*()const + { + return *this; + } + void operator=(boost::uint32_t val)const + { + push(val); + } + utf16_output_iterator& operator++() + { + return *this; + } + utf16_output_iterator& operator++(int) + { + return *this; + } + BaseIterator base()const + { + return m_position; + } +private: + void push(boost::uint32_t v)const + { + if(v >= 0x10000u) + { + // begin by checking for a code point out of range: + if(v > 0x10FFFFu) + detail::invalid_utf32_code_point(v); + // split into two surrogates: + *m_position++ = static_cast(v >> 10) + detail::high_surrogate_base; + *m_position++ = static_cast(v & detail::ten_bit_mask) + detail::low_surrogate_base; + } + else + { + // 16-bit code point: + // value must not be a surrogate: + if(detail::is_surrogate(v)) + detail::invalid_utf32_code_point(v); + *m_position++ = static_cast(v); + } + } + mutable BaseIterator m_position; +}; + +template +class utf8_output_iterator +{ +public: + typedef void difference_type; + typedef void value_type; + typedef boost::uint32_t* pointer; + typedef boost::uint32_t& reference; + typedef std::output_iterator_tag iterator_category; + + utf8_output_iterator(const BaseIterator& b) + : m_position(b){} + utf8_output_iterator(const utf8_output_iterator& that) + : m_position(that.m_position){} + utf8_output_iterator& operator=(const utf8_output_iterator& that) + { + m_position = that.m_position; + return *this; + } + const utf8_output_iterator& operator*()const + { + return *this; + } + void operator=(boost::uint32_t val)const + { + push(val); + } + utf8_output_iterator& operator++() + { + return *this; + } + utf8_output_iterator& operator++(int) + { + return *this; + } + BaseIterator base()const + { + return m_position; + } +private: + void push(boost::uint32_t c)const + { + if(c > 0x10FFFFu) + detail::invalid_utf32_code_point(c); + if(c < 0x80u) + { + *m_position++ = static_cast(c); + } + else if(c < 0x800u) + { + *m_position++ = static_cast(0xC0u + (c >> 6)); + *m_position++ = static_cast(0x80u + (c & 0x3Fu)); + } + else if(c < 0x10000u) + { + *m_position++ = static_cast(0xE0u + (c >> 12)); + *m_position++ = static_cast(0x80u + ((c >> 6) & 0x3Fu)); + *m_position++ = static_cast(0x80u + (c & 0x3Fu)); + } + else + { + *m_position++ = static_cast(0xF0u + (c >> 18)); + *m_position++ = static_cast(0x80u + ((c >> 12) & 0x3Fu)); + *m_position++ = static_cast(0x80u + ((c >> 6) & 0x3Fu)); + *m_position++ = static_cast(0x80u + (c & 0x3Fu)); + } + } + mutable BaseIterator m_position; +}; + +} // namespace boost + +#endif // BOOST_REGEX_UNICODE_ITERATOR_HPP + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/regex_traits.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_traits.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits classes. + */ + +#ifndef BOOST_REGEX_TRAITS_HPP +#define BOOST_REGEX_TRAITS_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +# include +#endif + +# ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED +# include +# endif + +#endif // include + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/user.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/user.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,90 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE user.hpp + * VERSION see + * DESCRIPTION: User settable options. + */ + +// define if you want the regex library to use the C locale +// even on Win32: +// #define BOOST_REGEX_USE_C_LOCALE + +// define this is you want the regex library to use the C++ +// locale: +// #define BOOST_REGEX_USE_CPP_LOCALE + +// define this if the runtime library is a dll, and you +// want BOOST_REGEX_DYN_LINK to set up dll exports/imports +// with __declspec(dllexport)/__declspec(dllimport.) +// #define BOOST_REGEX_HAS_DLL_RUNTIME + +// define this if you want to dynamically link to regex, +// if the runtime library is also a dll (Probably Win32 specific, +// and has no effect unless BOOST_REGEX_HAS_DLL_RUNTIME is set): +// #define BOOST_REGEX_DYN_LINK + +// define this if you don't want the lib to automatically +// select its link libraries: +// #define BOOST_REGEX_NO_LIB + +// define this if templates with switch statements cause problems: +// #define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE + +// define this to disable Win32 support when available: +// #define BOOST_REGEX_NO_W32 + +// define this if bool is not a real type: +// #define BOOST_REGEX_NO_BOOL + +// define this if no template instances are to be placed in +// the library rather than users object files: +// #define BOOST_REGEX_NO_EXTERNAL_TEMPLATES + +// define this if the forward declarations in regex_fwd.hpp +// cause more problems than they are worth: +// #define BOOST_REGEX_NO_FWD + +// define this if your compiler supports MS Windows structured +// exception handling. +// #define BOOST_REGEX_HAS_MS_STACK_GUARD + +// define this if you want to use the recursive algorithm +// even if BOOST_REGEX_HAS_MS_STACK_GUARD is not defined. +// #define BOOST_REGEX_RECURSIVE + +// define this if you want to use the non-recursive +// algorithm, even if the recursive version would be the default. +// #define BOOST_REGEX_NON_RECURSIVE + +// define this if you want to set the size of the memory blocks +// used by the non-recursive algorithm. +// #define BOOST_REGEX_BLOCKSIZE 4096 + +// define this if you want to set the maximum number of memory blocks +// used by the non-recursive algorithm. +// #define BOOST_REGEX_MAX_BLOCKS 1024 + +// define this if you want to set the maximum number of memory blocks +// cached by the non-recursive algorithm: Normally this is 16, but can be +// higher if you have multiple threads all using boost.regex, or lower +// if you don't want boost.regex to cache memory. +// #define BOOST_REGEX_MAX_CACHE_BLOCKS 16 + +// define this if you want to be able to access extended capture +// information in your sub_match's (caution this will slow things +// down quite a bit). +// #define BOOST_REGEX_MATCH_EXTRA + +// define this if you want to enable support for Unicode via ICU. +// #define BOOST_HAS_ICU diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,669 @@ +/* + * + * Copyright (c) 1998-2004 + * John Maddock + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org/ for most recent version. + * FILE basic_regex.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex. + */ + +#ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP +#define BOOST_REGEX_V4_BASIC_REGEX_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660 4800) +#endif + +namespace re_detail{ + +// +// forward declaration, we will need this one later: +// +template +class basic_regex_parser; + +// +// class regex_data: +// represents the data we wish to expose to the matching algorithms. +// +template +struct regex_data +{ + typedef regex_constants::syntax_option_type flag_type; + typedef std::size_t size_type; + + regex_data(const ::boost::shared_ptr< + ::boost::regex_traits_wrapper >& t) + : m_ptraits(t), m_expression(0), m_expression_len(0) {} + regex_data() + : m_ptraits(new ::boost::regex_traits_wrapper()), m_expression(0), m_expression_len(0) {} + + ::boost::shared_ptr< + ::boost::regex_traits_wrapper + > m_ptraits; // traits class instance + flag_type m_flags; // flags with which we were compiled + int m_status; // error code (0 implies OK). + const charT* m_expression; // the original expression + std::ptrdiff_t m_expression_len; // the length of the original expression + size_type m_mark_count; // the number of marked sub-expressions + re_detail::re_syntax_base* m_first_state; // the first state of the machine + unsigned m_restart_type; // search optimisation type + unsigned char m_startmap[1 << CHAR_BIT]; // which characters can start a match + unsigned int m_can_be_null; // whether we can match a null string + re_detail::raw_storage m_data; // the buffer in which our states are constructed + typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character + std::vector< + std::pair< + std::size_t, std::size_t> > m_subs; // Position of sub-expressions within the *string*. +}; +// +// class basic_regex_implementation +// pimpl implementation class for basic_regex. +// +template +class basic_regex_implementation + : public regex_data +{ +public: + typedef regex_constants::syntax_option_type flag_type; + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef typename traits::locale_type locale_type; + typedef const charT* const_iterator; + + basic_regex_implementation(){} + basic_regex_implementation(const ::boost::shared_ptr< + ::boost::regex_traits_wrapper >& t) + : regex_data(t) {} + void assign(const charT* arg_first, + const charT* arg_last, + flag_type f) + { + regex_data* pdat = this; + basic_regex_parser parser(pdat); + parser.parse(arg_first, arg_last, f); + } + + locale_type BOOST_REGEX_CALL imbue(locale_type l) + { + return this->m_ptraits->imbue(l); + } + locale_type BOOST_REGEX_CALL getloc()const + { + return this->m_ptraits->getloc(); + } + std::basic_string BOOST_REGEX_CALL str()const + { + std::basic_string result; + if(this->m_status == 0) + result = std::basic_string(this->m_expression, this->m_expression_len); + return result; + } + const_iterator BOOST_REGEX_CALL expression()const + { + return this->m_expression; + } + std::pair BOOST_REGEX_CALL subexpression(std::size_t n)const + { + if(n == 0) + throw std::out_of_range("0 is not a valid subexpression index."); + const std::pair& pi = this->m_subs.at(n - 1); + std::pair p(expression() + pi.first, expression() + pi.second); + return p; + } + // + // begin, end: + const_iterator BOOST_REGEX_CALL begin()const + { + return (!this->m_status ? 0 : this->m_expression); + } + const_iterator BOOST_REGEX_CALL end()const + { + return (!this->m_status ? 0 : this->m_expression + this->m_expression_len); + } + flag_type BOOST_REGEX_CALL flags()const + { + return this->m_flags; + } + size_type BOOST_REGEX_CALL size()const + { + return this->m_expression_len; + } + int BOOST_REGEX_CALL status()const + { + return this->m_status; + } + size_type BOOST_REGEX_CALL mark_count()const + { + return this->m_mark_count; + } + const re_detail::re_syntax_base* get_first_state()const + { + return this->m_first_state; + } + unsigned get_restart_type()const + { + return this->m_restart_type; + } + const unsigned char* get_map()const + { + return this->m_startmap; + } + const ::boost::regex_traits_wrapper& get_traits()const + { + return *(this->m_ptraits); + } + bool can_be_null()const + { + return this->m_can_be_null; + } + const regex_data& get_data()const + { + basic_regex_implementation const* p = this; + return *static_cast*>(p); + } +}; + +} // namespace re_detail +// +// class basic_regex: +// represents the compiled +// regular expression: +// + +#ifdef BOOST_REGEX_NO_FWD +template > +#else +template +#endif +class basic_regex : public regbase +{ +public: + // typedefs: + typedef std::size_t traits_size_type; + typedef typename traits::string_type traits_string_type; + typedef charT char_type; + typedef traits traits_type; + + typedef charT value_type; + typedef charT& reference; + typedef const charT& const_reference; + typedef const charT* const_iterator; + typedef const_iterator iterator; + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef regex_constants::syntax_option_type flag_type; + // locale_type + // placeholder for actual locale type used by the + // traits class to localise *this. + typedef typename traits::locale_type locale_type; + +public: + explicit basic_regex(){} + explicit basic_regex(const charT* p, flag_type f = regex_constants::normal) + { + assign(p, f); + } + basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + { + assign(p1, p2, f); + } + basic_regex(const charT* p, size_type len, flag_type f) + { + assign(p, len, f); + } + basic_regex(const basic_regex& that) + : m_pimpl(that.m_pimpl) {} + ~basic_regex(){} + basic_regex& BOOST_REGEX_CALL operator=(const basic_regex& that) + { + return assign(that); + } + basic_regex& BOOST_REGEX_CALL operator=(const charT* ptr) + { + return assign(ptr); + } + + // + // assign: + basic_regex& assign(const basic_regex& that) + { + m_pimpl = that.m_pimpl; + return *this; + } + basic_regex& assign(const charT* p, flag_type f = regex_constants::normal) + { + return assign(p, p + traits::length(p), f); + } + basic_regex& assign(const charT* p, size_type len, flag_type f) + { + return assign(p, p + len, f); + } +private: + basic_regex& do_assign(const charT* p1, + const charT* p2, + flag_type f); +public: + basic_regex& assign(const charT* p1, + const charT* p2, + flag_type f = regex_constants::normal) + { + return do_assign(p1, p2, f); + } +#if !defined(BOOST_NO_MEMBER_TEMPLATES) + + template + unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + { + return set_expression(p.data(), p.data() + p.size(), f); + } + + template + explicit basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal) + { + assign(p, f); + } + + template + basic_regex(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal) + { + typedef typename traits::string_type seq_type; + seq_type a(arg_first, arg_last); + if(a.size()) + assign(&*a.begin(), &*a.begin() + a.size(), f); + else + assign(static_cast(0), static_cast(0), f); + } + + template + basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + return assign(p.data(), p.data() + p.size(), regex_constants::normal); + } + + template + basic_regex& BOOST_REGEX_CALL assign( + const std::basic_string& s, + flag_type f = regex_constants::normal) + { + return assign(s.data(), s.data() + s.size(), f); + } + + template + basic_regex& BOOST_REGEX_CALL assign(InputIterator arg_first, + InputIterator arg_last, + flag_type f = regex_constants::normal) + { + typedef typename traits::string_type seq_type; + seq_type a(arg_first, arg_last); + if(a.size()) + { + const charT* p1 = &*a.begin(); + const charT* p2 = &*a.begin() + a.size(); + return assign(p1, p2, f); + } + return assign(static_cast(0), static_cast(0), f); + } +#else + unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + { + return set_expression(p.data(), p.data() + p.size(), f); + } + + basic_regex(const std::basic_string& p, flag_type f = regex_constants::normal) + { + assign(p, f); + } + + basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + return assign(p.data(), p.data() + p.size(), regex_constants::normal); + } + + basic_regex& BOOST_REGEX_CALL assign( + const std::basic_string& s, + flag_type f = regex_constants::normal) + { + return assign(s.data(), s.data() + s.size(), f); + } + +#endif + + // + // locale: + locale_type BOOST_REGEX_CALL imbue(locale_type l); + locale_type BOOST_REGEX_CALL getloc()const + { + return m_pimpl.get() ? m_pimpl->getloc() : locale_type(); + } + // + // getflags: + // retained for backwards compatibility only, "flags" + // is now the preferred name: + flag_type BOOST_REGEX_CALL getflags()const + { + return flags(); + } + flag_type BOOST_REGEX_CALL flags()const + { + return m_pimpl.get() ? m_pimpl->flags() : 0; + } + // + // str: + std::basic_string BOOST_REGEX_CALL str()const + { + return m_pimpl.get() ? m_pimpl->str() : std::basic_string(); + } + // + // begin, end, subexpression: + std::pair BOOST_REGEX_CALL subexpression(std::size_t n)const + { + if(!m_pimpl.get()) + throw std::logic_error("Can't access subexpressions in an invalid regex."); + return m_pimpl->subexpression(n); + } + const_iterator BOOST_REGEX_CALL begin()const + { + return (m_pimpl.get() ? m_pimpl->begin() : 0); + } + const_iterator BOOST_REGEX_CALL end()const + { + return (m_pimpl.get() ? m_pimpl->end() : 0); + } + // + // swap: + void BOOST_REGEX_CALL swap(basic_regex& that)throw() + { + m_pimpl.swap(that.m_pimpl); + } + // + // size: + size_type BOOST_REGEX_CALL size()const + { + return (m_pimpl.get() ? m_pimpl->size() : 0); + } + // + // max_size: + size_type BOOST_REGEX_CALL max_size()const + { + return UINT_MAX; + } + // + // empty: + bool BOOST_REGEX_CALL empty()const + { + return (m_pimpl.get() ? 0 != m_pimpl->status() : true); + } + + size_type BOOST_REGEX_CALL mark_count()const + { + return (m_pimpl.get() ? m_pimpl->mark_count() : 0); + } + + int status()const + { + return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty); + } + + int BOOST_REGEX_CALL compare(const basic_regex& that) const + { + if(m_pimpl.get() == that.m_pimpl.get()) + return 0; + if(!m_pimpl.get()) + return -1; + if(!that.m_pimpl.get()) + return 1; + if(status() != that.status()) + return status() - that.status(); + if(flags() != that.flags()) + return flags() - that.flags(); + return str().compare(that.str()); + } + bool BOOST_REGEX_CALL operator==(const basic_regex& e)const + { + return compare(e) == 0; + } + bool BOOST_REGEX_CALL operator != (const basic_regex& e)const + { + return compare(e) != 0; + } + bool BOOST_REGEX_CALL operator<(const basic_regex& e)const + { + return compare(e) < 0; + } + bool BOOST_REGEX_CALL operator>(const basic_regex& e)const + { + return compare(e) > 0; + } + bool BOOST_REGEX_CALL operator<=(const basic_regex& e)const + { + return compare(e) <= 0; + } + bool BOOST_REGEX_CALL operator>=(const basic_regex& e)const + { + return compare(e) >= 0; + } + + // + // The following are deprecated as public interfaces + // but are available for compatibility with earlier versions. + const charT* BOOST_REGEX_CALL expression()const + { + return (m_pimpl.get() && !m_pimpl->status() ? m_pimpl->expression() : 0); + } + unsigned int BOOST_REGEX_CALL set_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + { + assign(p1, p2, f | regex_constants::no_except); + return status(); + } + unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal) + { + assign(p, f | regex_constants::no_except); + return status(); + } + unsigned int BOOST_REGEX_CALL error_code()const + { + return status(); + } + // + // private access methods: + // + const re_detail::re_syntax_base* get_first_state()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_first_state(); + } + unsigned get_restart_type()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_restart_type(); + } + const unsigned char* get_map()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_map(); + } + const ::boost::regex_traits_wrapper& get_traits()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_traits(); + } + bool can_be_null()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->can_be_null(); + } + const re_detail::regex_data& get_data()const + { + BOOST_ASSERT(0 != m_pimpl.get()); + return m_pimpl->get_data(); + } + +private: + shared_ptr > m_pimpl; +}; + +// +// out of line members; +// these are the only members that mutate the basic_regex object, +// and are designed to provide the strong exception guarentee +// (in the event of a throw, the state of the object remains unchanged). +// +template +basic_regex& basic_regex::do_assign(const charT* p1, + const charT* p2, + flag_type f) +{ + shared_ptr > temp; + if(!m_pimpl.get()) + { + temp = shared_ptr >(new re_detail::basic_regex_implementation()); + } + else + { + temp = shared_ptr >(new re_detail::basic_regex_implementation(m_pimpl->m_ptraits)); + } + temp->assign(p1, p2, f); + temp.swap(m_pimpl); + return *this; +} + +template +typename basic_regex::locale_type BOOST_REGEX_CALL basic_regex::imbue(locale_type l) +{ + shared_ptr > temp(new re_detail::basic_regex_implementation()); + locale_type result = temp->imbue(l); + temp.swap(m_pimpl); + return result; +} + +// +// non-members: +// +template +void swap(basic_regex& e1, basic_regex& e2) +{ + e1.swap(e2); +} + +#ifndef BOOST_NO_STD_LOCALE +template +std::basic_ostream& + operator << (std::basic_ostream& os, + const basic_regex& e) +{ + return (os << e.str()); +} +#else +template +std::ostream& operator << (std::ostream& os, const basic_regex& e) +{ + return (os << e.str()); +} +#endif + +// +// class reg_expression: +// this is provided for backwards compatibility only, +// it is deprecated, no not use! +// +#ifdef BOOST_REGEX_NO_FWD +template > +#else +template +#endif +class reg_expression : public basic_regex +{ +public: + typedef typename basic_regex::flag_type flag_type; + typedef typename basic_regex::size_type size_type; + explicit reg_expression(){} + explicit reg_expression(const charT* p, flag_type f = regex_constants::normal) + : basic_regex(p, f){} + reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal) + : basic_regex(p1, p2, f){} + reg_expression(const charT* p, size_type len, flag_type f) + : basic_regex(p, len, f){} + reg_expression(const reg_expression& that) + : basic_regex(that) {} + ~reg_expression(){} + reg_expression& BOOST_REGEX_CALL operator=(const reg_expression& that) + { + return this->assign(that); + } + +#if !defined(BOOST_NO_MEMBER_TEMPLATES) + template + explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + : basic_regex(p, f) + { + } + + template + reg_expression(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal) + : basic_regex(arg_first, arg_last, f) + { + } + + template + reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + this->assign(p); + return *this; + } +#else + explicit reg_expression(const std::basic_string& p, flag_type f = regex_constants::normal) + : basic_regex(p, f) + { + } + + reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string& p) + { + this->assign(p); + return *this; + } +#endif + +}; + +#ifdef BOOST_MSVC +#pragma warning (pop) +#endif + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex_creator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex_creator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,1332 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE basic_regex_creator.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_creator which fills in + * the data members of a regex_data object. + */ + +#ifndef BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP +#define BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace boost{ + +namespace re_detail{ + +template +struct digraph : public std::pair +{ + digraph() : std::pair(0, 0){} + digraph(charT c1) : std::pair(c1, 0){} + digraph(charT c1, charT c2) : std::pair(c1, c2) + {} +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + digraph(const digraph& d) : std::pair(d.first, d.second){} +#endif + template + digraph(const Seq& s) : std::pair() + { + BOOST_ASSERT(s.size() <= 2); + BOOST_ASSERT(s.size()); + this->first = s[0]; + this->second = (s.size() > 1) ? s[1] : 0; + } +}; + +template +class basic_char_set +{ +public: + typedef digraph digraph_type; + typedef typename traits::string_type string_type; + typedef typename traits::char_class_type mask_type; + + basic_char_set() + { + m_negate = false; + m_has_digraphs = false; + m_classes = 0; + m_negated_classes = 0; + m_empty = true; + } + + void add_single(const digraph_type& s) + { + m_singles.insert(m_singles.end(), s); + if(s.second) + m_has_digraphs = true; + m_empty = false; + } + void add_range(const digraph_type& first, const digraph_type& end) + { + m_ranges.insert(m_ranges.end(), first); + m_ranges.insert(m_ranges.end(), end); + if(first.second) + { + m_has_digraphs = true; + add_single(first); + } + if(end.second) + { + m_has_digraphs = true; + add_single(end); + } + m_empty = false; + } + void add_class(mask_type m) + { + m_classes |= m; + m_empty = false; + } + void add_negated_class(mask_type m) + { + m_negated_classes |= m; + m_empty = false; + } + void add_equivalent(const digraph_type& s) + { + m_equivalents.insert(m_equivalents.end(), s); + if(s.second) + { + m_has_digraphs = true; + add_single(s); + } + m_empty = false; + } + void negate() + { + m_negate = true; + //m_empty = false; + } + + // + // accessor functions: + // + bool has_digraphs()const + { + return m_has_digraphs; + } + bool is_negated()const + { + return m_negate; + } + typedef typename std::vector::const_iterator list_iterator; + list_iterator singles_begin()const + { + return m_singles.begin(); + } + list_iterator singles_end()const + { + return m_singles.end(); + } + list_iterator ranges_begin()const + { + return m_ranges.begin(); + } + list_iterator ranges_end()const + { + return m_ranges.end(); + } + list_iterator equivalents_begin()const + { + return m_equivalents.begin(); + } + list_iterator equivalents_end()const + { + return m_equivalents.end(); + } + mask_type classes()const + { + return m_classes; + } + mask_type negated_classes()const + { + return m_negated_classes; + } + bool empty()const + { + return m_empty; + } +private: + std::vector m_singles; // a list of single characters to match + std::vector m_ranges; // a list of end points of our ranges + bool m_negate; // true if the set is to be negated + bool m_has_digraphs; // true if we have digraphs present + mask_type m_classes; // character classes to match + mask_type m_negated_classes; // negated character classes to match + bool m_empty; // whether we've added anything yet + std::vector m_equivalents; // a list of equivalence classes +}; + +template +class basic_regex_creator +{ +public: + basic_regex_creator(regex_data* data); + std::ptrdiff_t getoffset(void* addr) + { + return getoffset(addr, m_pdata->m_data.data()); + } + std::ptrdiff_t getoffset(const void* addr, const void* base) + { + return static_cast(addr) - static_cast(base); + } + re_syntax_base* getaddress(std::ptrdiff_t off) + { + return getaddress(off, m_pdata->m_data.data()); + } + re_syntax_base* getaddress(std::ptrdiff_t off, void* base) + { + return static_cast(static_cast(static_cast(base) + off)); + } + void init(unsigned l_flags) + { + m_pdata->m_flags = l_flags; + m_icase = l_flags & regex_constants::icase; + } + regbase::flag_type flags() + { + return m_pdata->m_flags; + } + void flags(regbase::flag_type f) + { + m_pdata->m_flags = f; + if(m_icase != static_cast(f & regbase::icase)) + { + m_icase = static_cast(f & regbase::icase); + } + } + re_syntax_base* append_state(syntax_element_type t, std::size_t s = sizeof(re_syntax_base)); + re_syntax_base* insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s = sizeof(re_syntax_base)); + re_literal* append_literal(charT c); + re_syntax_base* append_set(const basic_char_set& char_set); + re_syntax_base* append_set(const basic_char_set& char_set, mpl::false_*); + re_syntax_base* append_set(const basic_char_set& char_set, mpl::true_*); + void finalize(const charT* p1, const charT* p2); +protected: + regex_data* m_pdata; // pointer to the basic_regex_data struct we are filling in + const ::boost::regex_traits_wrapper& + m_traits; // convenience reference to traits class + re_syntax_base* m_last_state; // the last state we added + bool m_icase; // true for case insensitive matches + unsigned m_repeater_id; // the state_id of the next repeater + bool m_has_backrefs; // true if there are actually any backrefs + unsigned m_backrefs; // bitmask of permitted backrefs + boost::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for; + typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character + typename traits::char_class_type m_mask_space; // mask used to determine if a character is a word character + typename traits::char_class_type m_lower_mask; // mask used to determine if a character is a lowercase character + typename traits::char_class_type m_upper_mask; // mask used to determine if a character is an uppercase character + typename traits::char_class_type m_alpha_mask; // mask used to determine if a character is an alphabetic character +private: + basic_regex_creator& operator=(const basic_regex_creator&); + basic_regex_creator(const basic_regex_creator&); + + void fixup_pointers(re_syntax_base* state); + void create_startmaps(re_syntax_base* state); + int calculate_backstep(re_syntax_base* state); + void create_startmap(re_syntax_base* state, unsigned char* l_map, unsigned int* pnull, unsigned char mask); + unsigned get_restart_type(re_syntax_base* state); + void set_all_masks(unsigned char* bits, unsigned char); + bool is_bad_repeat(re_syntax_base* pt); + void set_bad_repeat(re_syntax_base* pt); + syntax_element_type get_repeat_type(re_syntax_base* state); + void probe_leading_repeat(re_syntax_base* state); +}; + +template +basic_regex_creator::basic_regex_creator(regex_data* data) + : m_pdata(data), m_traits(*(data->m_ptraits)), m_last_state(0), m_repeater_id(0), m_has_backrefs(false), m_backrefs(0) +{ + m_pdata->m_data.clear(); + m_pdata->m_status = ::boost::regex_constants::error_ok; + static const charT w = 'w'; + static const charT s = 's'; + static const charT l[5] = { 'l', 'o', 'w', 'e', 'r', }; + static const charT u[5] = { 'u', 'p', 'p', 'e', 'r', }; + static const charT a[5] = { 'a', 'l', 'p', 'h', 'a', }; + m_word_mask = m_traits.lookup_classname(&w, &w +1); + m_mask_space = m_traits.lookup_classname(&s, &s +1); + m_lower_mask = m_traits.lookup_classname(l, l + 5); + m_upper_mask = m_traits.lookup_classname(u, u + 5); + m_alpha_mask = m_traits.lookup_classname(a, a + 5); + m_pdata->m_word_mask = m_word_mask; + BOOST_ASSERT(m_word_mask != 0); + BOOST_ASSERT(m_mask_space != 0); + BOOST_ASSERT(m_lower_mask != 0); + BOOST_ASSERT(m_upper_mask != 0); + BOOST_ASSERT(m_alpha_mask != 0); +} + +template +re_syntax_base* basic_regex_creator::append_state(syntax_element_type t, std::size_t s) +{ + // if the state is a backref then make a note of it: + if(t == syntax_element_backref) + this->m_has_backrefs = true; + // append a new state, start by aligning our last one: + m_pdata->m_data.align(); + // set the offset to the next state in our last one: + if(m_last_state) + m_last_state->next.i = m_pdata->m_data.size() - getoffset(m_last_state); + // now actually extent our data: + m_last_state = static_cast(m_pdata->m_data.extend(s)); + // fill in boilerplate options in the new state: + m_last_state->next.i = 0; + m_last_state->type = t; + return m_last_state; +} + +template +re_syntax_base* basic_regex_creator::insert_state(std::ptrdiff_t pos, syntax_element_type t, std::size_t s) +{ + // append a new state, start by aligning our last one: + m_pdata->m_data.align(); + // set the offset to the next state in our last one: + if(m_last_state) + m_last_state->next.i = m_pdata->m_data.size() - getoffset(m_last_state); + // remember the last state position: + std::ptrdiff_t off = getoffset(m_last_state) + s; + // now actually insert our data: + re_syntax_base* new_state = static_cast(m_pdata->m_data.insert(pos, s)); + // fill in boilerplate options in the new state: + new_state->next.i = s; + new_state->type = t; + m_last_state = getaddress(off); + return new_state; +} + +template +re_literal* basic_regex_creator::append_literal(charT c) +{ + re_literal* result; + // start by seeing if we have an existing re_literal we can extend: + if((0 == m_last_state) || (m_last_state->type != syntax_element_literal)) + { + // no existing re_literal, create a new one: + result = static_cast(append_state(syntax_element_literal, sizeof(re_literal) + sizeof(charT))); + result->length = 1; + *static_cast(static_cast(result+1)) = m_traits.translate(c, m_icase); + } + else + { + // we have an existing re_literal, extend it: + std::ptrdiff_t off = getoffset(m_last_state); + m_pdata->m_data.extend(sizeof(charT)); + m_last_state = result = static_cast(getaddress(off)); + charT* characters = static_cast(static_cast(result+1)); + characters[result->length] = m_traits.translate(c, m_icase); + ++(result->length); + } + return result; +} + +template +inline re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set) +{ + typedef mpl::bool_< (sizeof(charT) == 1) > truth_type; + return char_set.has_digraphs() + ? append_set(char_set, static_cast(0)) + : append_set(char_set, static_cast(0)); +} + +template +re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set, mpl::false_*) +{ + typedef typename traits::string_type string_type; + typedef typename basic_char_set::list_iterator item_iterator; + typedef typename traits::char_class_type mask_type; + + re_set_long* result = static_cast*>(append_state(syntax_element_long_set, sizeof(re_set_long))); + // + // fill in the basics: + // + result->csingles = static_cast(::boost::re_detail::distance(char_set.singles_begin(), char_set.singles_end())); + result->cranges = static_cast(::boost::re_detail::distance(char_set.ranges_begin(), char_set.ranges_end())) / 2; + result->cequivalents = static_cast(::boost::re_detail::distance(char_set.equivalents_begin(), char_set.equivalents_end())); + result->cclasses = char_set.classes(); + result->cnclasses = char_set.negated_classes(); + if(flags() & regbase::icase) + { + // adjust classes as needed: + if(((result->cclasses & m_lower_mask) == m_lower_mask) || ((result->cclasses & m_upper_mask) == m_upper_mask)) + result->cclasses |= m_alpha_mask; + if(((result->cnclasses & m_lower_mask) == m_lower_mask) || ((result->cnclasses & m_upper_mask) == m_upper_mask)) + result->cnclasses |= m_alpha_mask; + } + + result->isnot = char_set.is_negated(); + result->singleton = !char_set.has_digraphs(); + // + // remember where the state is for later: + // + std::ptrdiff_t offset = getoffset(result); + // + // now extend with all the singles: + // + item_iterator first, last; + first = char_set.singles_begin(); + last = char_set.singles_end(); + while(first != last) + { + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (first->second ? 3 : 2))); + p[0] = m_traits.translate(first->first, m_icase); + if(first->second) + { + p[1] = m_traits.translate(first->second, m_icase); + p[2] = 0; + } + else + p[1] = 0; + ++first; + } + // + // now extend with all the ranges: + // + first = char_set.ranges_begin(); + last = char_set.ranges_end(); + while(first != last) + { + // first grab the endpoints of the range: + digraph c1 = *first; + c1.first = this->m_traits.translate(c1.first, this->m_icase); + c1.second = this->m_traits.translate(c1.second, this->m_icase); + ++first; + digraph c2 = *first; + c2.first = this->m_traits.translate(c2.first, this->m_icase); + c2.second = this->m_traits.translate(c2.second, this->m_icase); + ++first; + string_type s1, s2; + // different actions now depending upon whether collation is turned on: + if(flags() & regex_constants::collate) + { + // we need to transform our range into sort keys: +#if BOOST_WORKAROUND(__GNUC__, < 3) + string_type in(3, charT(0)); + in[0] = c1.first; + in[1] = c1.second; + s1 = this->m_traits.transform(in.c_str(), (in[1] ? in.c_str()+2 : in.c_str()+1)); + in[0] = c2.first; + in[1] = c2.second; + s2 = this->m_traits.transform(in.c_str(), (in[1] ? in.c_str()+2 : in.c_str()+1)); +#else + charT a1[3] = { c1.first, c1.second, charT(0), }; + charT a2[3] = { c2.first, c2.second, charT(0), }; + s1 = this->m_traits.transform(a1, (a1[1] ? a1+2 : a1+1)); + s2 = this->m_traits.transform(a2, (a2[1] ? a2+2 : a2+1)); +#endif + if(s1.size() == 0) + s1 = string_type(1, charT(0)); + if(s2.size() == 0) + s2 = string_type(1, charT(0)); + } + else + { + if(c1.second) + { + s1.insert(s1.end(), c1.first); + s1.insert(s1.end(), c1.second); + } + else + s1 = string_type(1, c1.first); + if(c2.second) + { + s2.insert(s2.end(), c2.first); + s2.insert(s2.end(), c2.second); + } + else + s2.insert(s2.end(), c2.first); + } + if(s1 > s2) + { + // Oops error: + return 0; + } + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (s1.size() + s2.size() + 2) ) ); + re_detail::copy(s1.begin(), s1.end(), p); + p[s1.size()] = charT(0); + p += s1.size() + 1; + re_detail::copy(s2.begin(), s2.end(), p); + p[s2.size()] = charT(0); + } + // + // now process the equivalence classes: + // + first = char_set.equivalents_begin(); + last = char_set.equivalents_end(); + while(first != last) + { + string_type s; + if(first->second) + { +#if BOOST_WORKAROUND(__GNUC__, < 3) + string_type in(3, charT(0)); + in[0] = first->first; + in[1] = first->second; + s = m_traits.transform_primary(in.c_str(), in.c_str()+2); +#else + charT cs[3] = { first->first, first->second, charT(0), }; + s = m_traits.transform_primary(cs, cs+2); +#endif + } + else + s = m_traits.transform_primary(&first->first, &first->first+1); + if(s.empty()) + return 0; // invalid or unsupported equivalence class + charT* p = static_cast(this->m_pdata->m_data.extend(sizeof(charT) * (s.size()+1) ) ); + re_detail::copy(s.begin(), s.end(), p); + p[s.size()] = charT(0); + ++first; + } + // + // finally reset the address of our last state: + // + m_last_state = result = static_cast*>(getaddress(offset)); + return result; +} + +namespace{ + +template +inline bool char_less(T t1, T t2) +{ + return t1 < t2; +} +template<> +inline bool char_less(char t1, char t2) +{ + return static_cast(t1) < static_cast(t2); +} +template<> +inline bool char_less(signed char t1, signed char t2) +{ + return static_cast(t1) < static_cast(t2); +} +} + +template +re_syntax_base* basic_regex_creator::append_set( + const basic_char_set& char_set, mpl::true_*) +{ + typedef typename traits::string_type string_type; + typedef typename basic_char_set::list_iterator item_iterator; + + re_set* result = static_cast(append_state(syntax_element_set, sizeof(re_set))); + bool negate = char_set.is_negated(); + std::memset(result->_map, 0, sizeof(result->_map)); + // + // handle singles first: + // + item_iterator first, last; + first = char_set.singles_begin(); + last = char_set.singles_end(); + while(first != last) + { + for(unsigned int i = 0; i < (1 << CHAR_BIT); ++i) + { + if(this->m_traits.translate(static_cast(i), this->m_icase) + == this->m_traits.translate(first->first, this->m_icase)) + result->_map[i] = true; + } + ++first; + } + // + // OK now handle ranges: + // + first = char_set.ranges_begin(); + last = char_set.ranges_end(); + while(first != last) + { + // first grab the endpoints of the range: + charT c1 = this->m_traits.translate(first->first, this->m_icase); + ++first; + charT c2 = this->m_traits.translate(first->first, this->m_icase); + ++first; + // different actions now depending upon whether collation is turned on: + if(flags() & regex_constants::collate) + { + // we need to transform our range into sort keys: + charT c3[2] = { c1, charT(0), }; + string_type s1 = this->m_traits.transform(c3, c3+1); + c3[0] = c2; + string_type s2 = this->m_traits.transform(c3, c3+1); + if(s1 > s2) + { + // Oops error: + return 0; + } + BOOST_ASSERT(c3[1] == charT(0)); + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + c3[0] = static_cast(i); + string_type s3 = this->m_traits.transform(c3, c3 +1); + if((s1 <= s3) && (s3 <= s2)) + result->_map[i] = true; + } + } + else + { + if(char_less(c2, c1)) + { + // Oops error: + return 0; + } + // everything in range matches: + std::memset(result->_map + static_cast(c1), true, 1 + static_cast(c2) - static_cast(c1)); + } + } + // + // and now the classes: + // + typedef typename traits::char_class_type mask_type; + mask_type m = char_set.classes(); + if(flags() & regbase::icase) + { + // adjust m as needed: + if(((m & m_lower_mask) == m_lower_mask) || ((m & m_upper_mask) == m_upper_mask)) + m |= m_alpha_mask; + } + if(m != 0) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + if(this->m_traits.isctype(static_cast(i), m)) + result->_map[i] = true; + } + } + // + // and now the negated classes: + // + m = char_set.negated_classes(); + if(flags() & regbase::icase) + { + // adjust m as needed: + if(((m & m_lower_mask) == m_lower_mask) || ((m & m_upper_mask) == m_upper_mask)) + m |= m_alpha_mask; + } + if(m != 0) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + if(0 == this->m_traits.isctype(static_cast(i), m)) + result->_map[i] = true; + } + } + // + // now process the equivalence classes: + // + first = char_set.equivalents_begin(); + last = char_set.equivalents_end(); + while(first != last) + { + string_type s; + BOOST_ASSERT(static_cast(0) == first->second); + s = m_traits.transform_primary(&first->first, &first->first+1); + if(s.empty()) + return 0; // invalid or unsupported equivalence class + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + charT c[2] = { (static_cast(i)), charT(0), }; + string_type s2 = this->m_traits.transform_primary(c, c+1); + if(s == s2) + result->_map[i] = true; + } + ++first; + } + if(negate) + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + { + result->_map[i] = !(result->_map[i]); + } + } + return result; +} + +template +void basic_regex_creator::finalize(const charT* p1, const charT* p2) +{ + // we've added all the states we need, now finish things off. + // start by adding a terminating state: + append_state(syntax_element_match); + // extend storage to store original expression: + std::ptrdiff_t len = p2 - p1; + m_pdata->m_expression_len = len; + charT* ps = static_cast(m_pdata->m_data.extend(sizeof(charT) * (1 + (p2 - p1)))); + m_pdata->m_expression = ps; + re_detail::copy(p1, p2, ps); + ps[p2 - p1] = 0; + // fill in our other data... + // successful parsing implies a zero status: + m_pdata->m_status = 0; + // get the first state of the machine: + m_pdata->m_first_state = static_cast(m_pdata->m_data.data()); + // fixup pointers in the machine: + fixup_pointers(m_pdata->m_first_state); + // create nested startmaps: + create_startmaps(m_pdata->m_first_state); + // create main startmap: + std::memset(m_pdata->m_startmap, 0, sizeof(m_pdata->m_startmap)); + m_pdata->m_can_be_null = 0; + + m_bad_repeats = 0; + create_startmap(m_pdata->m_first_state, m_pdata->m_startmap, &(m_pdata->m_can_be_null), mask_all); + // get the restart type: + m_pdata->m_restart_type = get_restart_type(m_pdata->m_first_state); + // optimise a leading repeat if there is one: + probe_leading_repeat(m_pdata->m_first_state); +} + +template +void basic_regex_creator::fixup_pointers(re_syntax_base* state) +{ + while(state) + { + switch(state->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + // set the state_id of this repeat: + static_cast(state)->state_id = m_repeater_id++; + // fall through: + case syntax_element_alt: + std::memset(static_cast(state)->_map, 0, sizeof(static_cast(state)->_map)); + static_cast(state)->can_be_null = 0; + // fall through: + case syntax_element_jump: + static_cast(state)->alt.p = getaddress(static_cast(state)->alt.i, state); + // fall through again: + default: + if(state->next.i) + state->next.p = getaddress(state->next.i, state); + else + state->next.p = 0; + } + state = state->next.p; + } +} + +template +void basic_regex_creator::create_startmaps(re_syntax_base* state) +{ + // non-recursive implementation: + // create the last map in the machine first, so that earlier maps + // can make use of the result... + // + // This was originally a recursive implementation, but that caused stack + // overflows with complex expressions on small stacks (think COM+). + + // start by saving the case setting: + bool l_icase = m_icase; + std::vector > v; + + while(state) + { + switch(state->type) + { + case syntax_element_toggle_case: + // we need to track case changes here: + m_icase = static_cast(state)->icase; + state = state->next.p; + continue; + case syntax_element_alt: + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + // just push the state onto our stack for now: + v.push_back(std::pair(m_icase, state)); + state = state->next.p; + break; + case syntax_element_backstep: + // we need to calculate how big the backstep is: + static_cast(state)->index + = this->calculate_backstep(state->next.p); + if(static_cast(state)->index < 0) + { + // Oops error: + if(0 == this->m_pdata->m_status) // update the error code if not already set + this->m_pdata->m_status = boost::regex_constants::error_bad_pattern; + // + // clear the expression, we should be empty: + // + this->m_pdata->m_expression = 0; + this->m_pdata->m_expression_len = 0; + // + // and throw if required: + // + if(0 == (this->flags() & regex_constants::no_except)) + { + std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_bad_pattern); + boost::regex_error e(message, boost::regex_constants::error_bad_pattern, 0); + e.raise(); + } + } + // fall through: + default: + state = state->next.p; + } + } + // now work through our list, building all the maps as we go: + while(v.size()) + { + const std::pair& p = v.back(); + m_icase = p.first; + state = p.second; + v.pop_back(); + + // Build maps: + m_bad_repeats = 0; + create_startmap(state->next.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_take); + m_bad_repeats = 0; + create_startmap(static_cast(state)->alt.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_skip); + // adjust the type of the state to allow for faster matching: + state->type = this->get_repeat_type(state); + } + // restore case sensitivity: + m_icase = l_icase; +} + +template +int basic_regex_creator::calculate_backstep(re_syntax_base* state) +{ + typedef typename traits::char_class_type mask_type; + int result = 0; + while(state) + { + switch(state->type) + { + case syntax_element_startmark: + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + { + state = static_cast(state->next.p)->alt.p->next.p; + continue; + } + else if(static_cast(state)->index == -3) + { + state = state->next.p->next.p; + continue; + } + break; + case syntax_element_endmark: + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + return result; + break; + case syntax_element_literal: + result += static_cast(state)->length; + break; + case syntax_element_wild: + case syntax_element_set: + result += 1; + break; + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_backref: + case syntax_element_rep: + case syntax_element_combining: + case syntax_element_long_set_rep: + case syntax_element_backstep: + { + re_repeat* rep = static_cast(state); + // adjust the type of the state to allow for faster matching: + state->type = this->get_repeat_type(state); + if((state->type == syntax_element_dot_rep) + || (state->type == syntax_element_char_rep) + || (state->type == syntax_element_short_set_rep)) + { + if(rep->max != rep->min) + return -1; + result += static_cast(rep->min); + state = rep->alt.p; + continue; + } + else if((state->type == syntax_element_long_set_rep)) + { + BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + if(static_cast*>(rep->next.p)->singleton == 0) + return -1; + if(rep->max != rep->min) + return -1; + result += static_cast(rep->min); + state = rep->alt.p; + continue; + } + } + return -1; + case syntax_element_long_set: + if(static_cast*>(state)->singleton == 0) + return -1; + result += 1; + break; + case syntax_element_jump: + state = static_cast(state)->alt.p; + continue; + default: + break; + } + state = state->next.p; + } + return -1; +} + +template +void basic_regex_creator::create_startmap(re_syntax_base* state, unsigned char* l_map, unsigned int* pnull, unsigned char mask) +{ + int not_last_jump = 1; + + // track case sensitivity: + bool l_icase = m_icase; + + while(state) + { + switch(state->type) + { + case syntax_element_toggle_case: + l_icase = static_cast(state)->icase; + state = state->next.p; + break; + case syntax_element_literal: + { + // don't set anything in *pnull, set each element in l_map + // that could match the first character in the literal: + if(l_map) + { + l_map[0] |= mask_init; + charT first_char = *static_cast(static_cast(static_cast(state) + 1)); + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(m_traits.translate(static_cast(i), l_icase) == first_char) + l_map[i] |= mask; + } + } + return; + } + case syntax_element_end_line: + { + // next character must be a line separator (if there is one): + if(l_map) + { + l_map[0] |= mask_init; + l_map['\n'] |= mask; + l_map['\r'] |= mask; + l_map['\f'] |= mask; + l_map[0x85] |= mask; + } + // now figure out if we can match a NULL string at this point: + if(pnull) + create_startmap(state->next.p, 0, pnull, mask); + return; + } + case syntax_element_backref: + // can be null, and any character can match: + if(pnull) + *pnull |= mask; + // fall through: + case syntax_element_wild: + { + // can't be null, any character can match: + set_all_masks(l_map, mask); + return; + } + case syntax_element_match: + { + // must be null, any character can match: + set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; + return; + } + case syntax_element_word_start: + { + // recurse, then AND with all the word characters: + create_startmap(state->next.p, l_map, pnull, mask); + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(!m_traits.isctype(static_cast(i), m_word_mask)) + l_map[i] &= static_cast(~mask); + } + } + return; + } + case syntax_element_word_end: + { + // recurse, then AND with all the word characters: + create_startmap(state->next.p, l_map, pnull, mask); + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(m_traits.isctype(static_cast(i), m_word_mask)) + l_map[i] &= static_cast(~mask); + } + } + return; + } + case syntax_element_buffer_end: + { + // we *must be null* : + if(pnull) + *pnull |= mask; + return; + } + case syntax_element_long_set: + if(l_map) + { + typedef typename traits::char_class_type mask_type; + if(static_cast*>(state)->singleton) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + charT c = static_cast(i); + if(&c != re_is_set_member(&c, &c + 1, static_cast*>(state), *m_pdata, m_icase)) + l_map[i] |= mask; + } + } + else + set_all_masks(l_map, mask); + } + return; + case syntax_element_set: + if(l_map) + { + l_map[0] |= mask_init; + for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) + { + if(static_cast(state)->_map[ + static_cast(m_traits.translate(static_cast(i), l_icase))]) + l_map[i] |= mask; + } + } + return; + case syntax_element_jump: + // take the jump: + state = static_cast(state)->alt.p; + not_last_jump = -1; + break; + case syntax_element_alt: + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + re_alt* rep = static_cast(state); + if(rep->_map[0] & mask_init) + { + if(l_map) + { + // copy previous results: + l_map[0] |= mask_init; + for(unsigned int i = 0; i <= UCHAR_MAX; ++i) + { + if(rep->_map[i] & mask_any) + l_map[i] |= mask; + } + } + if(pnull) + { + if(rep->can_be_null & mask_any) + *pnull |= mask; + } + } + else + { + // we haven't created a startmap for this alternative yet + // so take the union of the two options: + if(is_bad_repeat(state)) + { + set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; + return; + } + set_bad_repeat(state); + create_startmap(state->next.p, l_map, pnull, mask); + if((state->type == syntax_element_alt) + || (static_cast(state)->min == 0) + || (not_last_jump == 0)) + create_startmap(rep->alt.p, l_map, pnull, mask); + } + } + return; + case syntax_element_soft_buffer_end: + // match newline or null: + if(l_map) + { + l_map[0] |= mask_init; + l_map['\n'] |= mask; + l_map['\r'] |= mask; + } + if(pnull) + *pnull |= mask; + return; + case syntax_element_endmark: + // need to handle independent subs as a special case: + if(static_cast(state)->index < 0) + { + // can be null, any character can match: + set_all_masks(l_map, mask); + if(pnull) + *pnull |= mask; + return; + } + else + { + state = state->next.p; + break; + } + + case syntax_element_startmark: + // need to handle independent subs as a special case: + if(static_cast(state)->index == -3) + { + state = state->next.p->next.p; + break; + } + // otherwise fall through: + default: + state = state->next.p; + } + ++not_last_jump; + } +} + +template +unsigned basic_regex_creator::get_restart_type(re_syntax_base* state) +{ + // + // find out how the machine starts, so we can optimise the search: + // + while(state) + { + switch(state->type) + { + case syntax_element_startmark: + case syntax_element_endmark: + state = state->next.p; + continue; + case syntax_element_start_line: + return regbase::restart_line; + case syntax_element_word_start: + return regbase::restart_word; + case syntax_element_buffer_start: + return regbase::restart_buf; + case syntax_element_restart_continue: + return regbase::restart_continue; + default: + state = 0; + continue; + } + } + return regbase::restart_any; +} + +template +void basic_regex_creator::set_all_masks(unsigned char* bits, unsigned char mask) +{ + // + // set mask in all of bits elements, + // if bits[0] has mask_init not set then we can + // optimise this to a call to memset: + // + if(bits) + { + if(bits[0] == 0) + (std::memset)(bits, mask, 1u << CHAR_BIT); + else + { + for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) + bits[i] |= mask; + } + bits[0] |= mask_init; + } +} + +template +bool basic_regex_creator::is_bad_repeat(re_syntax_base* pt) +{ + switch(pt->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + unsigned state_id = static_cast(pt)->state_id; + if(state_id > sizeof(m_bad_repeats) * CHAR_BIT) + return true; // run out of bits, assume we can't traverse this one. + static const boost::uintmax_t one = 1uL; + return m_bad_repeats & (one << state_id); + } + default: + return false; + } +} + +template +void basic_regex_creator::set_bad_repeat(re_syntax_base* pt) +{ + switch(pt->type) + { + case syntax_element_rep: + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + { + unsigned state_id = static_cast(pt)->state_id; + static const boost::uintmax_t one = 1uL; + if(state_id <= sizeof(m_bad_repeats) * CHAR_BIT) + m_bad_repeats |= (one << state_id); + } + default: + break; + } +} + +template +syntax_element_type basic_regex_creator::get_repeat_type(re_syntax_base* state) +{ + typedef typename traits::char_class_type mask_type; + if(state->type == syntax_element_rep) + { + // check to see if we are repeating a single state: + if(state->next.p->next.p->next.p == static_cast(state)->alt.p) + { + switch(state->next.p->type) + { + case re_detail::syntax_element_wild: + return re_detail::syntax_element_dot_rep; + case re_detail::syntax_element_literal: + return re_detail::syntax_element_char_rep; + case re_detail::syntax_element_set: + return re_detail::syntax_element_short_set_rep; + case re_detail::syntax_element_long_set: + if(static_cast*>(state->next.p)->singleton) + return re_detail::syntax_element_long_set_rep; + break; + default: + break; + } + } + } + return state->type; +} + +template +void basic_regex_creator::probe_leading_repeat(re_syntax_base* state) +{ + // enumerate our states, and see if we have a leading repeat + // for which failed search restarts can be optimised; + do + { + switch(state->type) + { + case syntax_element_startmark: + if(static_cast(state)->index >= 0) + { + state = state->next.p; + continue; + } + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + { + // skip past the zero width assertion: + state = static_cast(state->next.p)->alt.p->next.p; + continue; + } + if(static_cast(state)->index == -3) + { + // Have to skip the leading jump state: + state = state->next.p->next.p; + continue; + } + return; + case syntax_element_endmark: + case syntax_element_start_line: + case syntax_element_end_line: + case syntax_element_word_boundary: + case syntax_element_within_word: + case syntax_element_word_start: + case syntax_element_word_end: + case syntax_element_buffer_start: + case syntax_element_buffer_end: + case syntax_element_restart_continue: + state = state->next.p; + break; + case syntax_element_dot_rep: + case syntax_element_char_rep: + case syntax_element_short_set_rep: + case syntax_element_long_set_rep: + if(this->m_has_backrefs == 0) + static_cast(state)->leading = true; + // fall through: + default: + return; + } + }while(state); +} + + +} // namespace re_detail + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex_parser.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/basic_regex_parser.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,2140 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE basic_regex_parser.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_parser. + */ + +#ifndef BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP +#define BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +namespace re_detail{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4244 4800) +#endif + +template +class basic_regex_parser : public basic_regex_creator +{ +public: + basic_regex_parser(regex_data* data); + void parse(const charT* p1, const charT* p2, unsigned flags); + void fail(regex_constants::error_type error_code, std::ptrdiff_t position); + + bool parse_all(); + bool parse_basic(); + bool parse_extended(); + bool parse_literal(); + bool parse_open_paren(); + bool parse_basic_escape(); + bool parse_extended_escape(); + bool parse_match_any(); + bool parse_repeat(std::size_t low = 0, std::size_t high = (std::numeric_limits::max)()); + bool parse_repeat_range(bool isbasic); + bool parse_alt(); + bool parse_set(); + bool parse_backref(); + void parse_set_literal(basic_char_set& char_set); + bool parse_inner_set(basic_char_set& char_set); + bool parse_QE(); + bool parse_perl_extension(); + bool add_emacs_code(bool negate); + bool unwind_alts(std::ptrdiff_t last_paren_start); + digraph get_next_set_literal(basic_char_set& char_set); + charT unescape_character(); + regex_constants::syntax_option_type parse_options(); + +private: + typedef bool (basic_regex_parser::*parser_proc_type)(); + typedef typename traits::string_type string_type; + typedef typename traits::char_class_type char_class_type; + parser_proc_type m_parser_proc; // the main parser to use + const charT* m_base; // the start of the string being parsed + const charT* m_end; // the end of the string being parsed + const charT* m_position; // our current parser position + unsigned m_mark_count; // how many sub-expressions we have + std::ptrdiff_t m_paren_start; // where the last seen ')' began (where repeats are inserted). + std::ptrdiff_t m_alt_insert_point; // where to insert the next alternative + bool m_has_case_change; // true if somewhere in the current block the case has changed +#if defined(BOOST_MSVC) && defined(_M_IX86) + // This is an ugly warning suppression workaround (for warnings *inside* std::vector + // that can not otherwise be suppressed)... + BOOST_STATIC_ASSERT(sizeof(long) >= sizeof(void*)); + std::vector m_alt_jumps; // list of alternative in the current scope. +#else + std::vector m_alt_jumps; // list of alternative in the current scope. +#endif + + basic_regex_parser& operator=(const basic_regex_parser&); + basic_regex_parser(const basic_regex_parser&); +}; + +template +basic_regex_parser::basic_regex_parser(regex_data* data) + : basic_regex_creator(data), m_mark_count(0), m_paren_start(0), m_alt_insert_point(0), m_has_case_change(false) +{ +} + +template +void basic_regex_parser::parse(const charT* p1, const charT* p2, unsigned l_flags) +{ + // pass l_flags on to base class: + this->init(l_flags); + // set up pointers: + m_position = m_base = p1; + m_end = p2; + // empty strings are errors: + if((p1 == p2) && + ( + ((l_flags & regbase::main_option_type) != regbase::perl_syntax_group) + || (l_flags & regbase::no_empty_expressions) + ) + ) + { + fail(regex_constants::error_empty, 0); + return; + } + // select which parser to use: + switch(l_flags & regbase::main_option_type) + { + case regbase::perl_syntax_group: + m_parser_proc = &basic_regex_parser::parse_extended; + break; + case regbase::basic_syntax_group: + m_parser_proc = &basic_regex_parser::parse_basic; + break; + case regbase::literal: + m_parser_proc = &basic_regex_parser::parse_literal; + break; + } + + // parse all our characters: + bool result = parse_all(); + // + // Unwind our alternatives: + // + unwind_alts(-1); + // reset l_flags as a global scope (?imsx) may have altered them: + this->flags(l_flags); + // if we haven't gobbled up all the characters then we must + // have had an unexpected ')' : + if(!result) + { + fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_position)); + return; + } + // if an error has been set then give up now: + if(this->m_pdata->m_status) + return; + // fill in our sub-expression count: + this->m_pdata->m_mark_count = 1 + m_mark_count; + this->finalize(p1, p2); +} + +template +void basic_regex_parser::fail(regex_constants::error_type error_code, std::ptrdiff_t position) +{ + if(0 == this->m_pdata->m_status) // update the error code if not already set + this->m_pdata->m_status = error_code; + m_position = m_end; // don't bother parsing anything else + // get the error message: + std::string message = this->m_pdata->m_ptraits->error_string(error_code); + // and raise the exception, this will do nothing if exceptions are disabled: +#ifndef BOOST_NO_EXCEPTIONS + if(0 == (this->flags() & regex_constants::no_except)) + { + boost::regex_error e(message, error_code, position); + e.raise(); + } +#else + (void)position; // suppress warnings. +#endif +} + +template +bool basic_regex_parser::parse_all() +{ + bool result = true; + while(result && (m_position != m_end)) + { + result = (this->*m_parser_proc)(); + } + return result; +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4702) +#endif +template +bool basic_regex_parser::parse_basic() +{ + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_escape: + return parse_basic_escape(); + case regex_constants::syntax_dot: + return parse_match_any(); + case regex_constants::syntax_caret: + ++m_position; + this->append_state(syntax_element_start_line); + break; + case regex_constants::syntax_dollar: + ++m_position; + this->append_state(syntax_element_end_line); + break; + case regex_constants::syntax_star: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(); + } + case regex_constants::syntax_plus: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line) || !(this->flags() & regbase::emacs_ex)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(1); + } + case regex_constants::syntax_question: + if(!(this->m_last_state) || (this->m_last_state->type == syntax_element_start_line) || !(this->flags() & regbase::emacs_ex)) + return parse_literal(); + else + { + ++m_position; + return parse_repeat(0, 1); + } + case regex_constants::syntax_open_set: + return parse_set(); + case regex_constants::syntax_newline: + if(this->flags() & regbase::newline_alt) + return parse_alt(); + else + return parse_literal(); + default: + return parse_literal(); + } + return true; +} + +template +bool basic_regex_parser::parse_extended() +{ + bool result = true; + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_open_mark: + return parse_open_paren(); + case regex_constants::syntax_close_mark: + return false; + case regex_constants::syntax_escape: + return parse_extended_escape(); + case regex_constants::syntax_dot: + return parse_match_any(); + case regex_constants::syntax_caret: + ++m_position; + this->append_state( + (this->flags() & regex_constants::no_mod_m ? syntax_element_buffer_start : syntax_element_start_line)); + break; + case regex_constants::syntax_dollar: + ++m_position; + this->append_state( + (this->flags() & regex_constants::no_mod_m ? syntax_element_buffer_end : syntax_element_end_line)); + break; + case regex_constants::syntax_star: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(); + case regex_constants::syntax_question: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(0,1); + case regex_constants::syntax_plus: + if(m_position == this->m_base) + { + fail(regex_constants::error_badrepeat, 0); + return false; + } + ++m_position; + return parse_repeat(1); + case regex_constants::syntax_open_brace: + ++m_position; + return parse_repeat_range(false); + case regex_constants::syntax_close_brace: + fail(regex_constants::error_brace, this->m_position - this->m_end); + return false; + case regex_constants::syntax_or: + return parse_alt(); + case regex_constants::syntax_open_set: + return parse_set(); + case regex_constants::syntax_newline: + if(this->flags() & regbase::newline_alt) + return parse_alt(); + else + return parse_literal(); + case regex_constants::syntax_hash: + // + // If we have a mod_x flag set, then skip until + // we get to a newline character: + // + if((this->flags() + & (regbase::no_perl_ex|regbase::mod_x)) + == regbase::mod_x) + { + while((m_position != m_end) && !is_separator(*m_position++)){} + return true; + } + // Otherwise fall through: + default: + result = parse_literal(); + break; + } + return result; +} +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +bool basic_regex_parser::parse_literal() +{ + // append this as a literal provided it's not a space character + // or the perl option regbase::mod_x is not set: + if( + ((this->flags() + & (regbase::main_option_type|regbase::mod_x|regbase::no_perl_ex)) + != regbase::mod_x) + || !this->m_traits.isctype(*m_position, this->m_mask_space)) + this->append_literal(*m_position); + ++m_position; + return true; +} + +template +bool basic_regex_parser::parse_open_paren() +{ + // + // skip the '(' and error check: + // + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + // + // begin by checking for a perl-style (?...) extension: + // + if( + ((this->flags() & (regbase::main_option_type | regbase::no_perl_ex)) == 0) + || ((this->flags() & (regbase::main_option_type | regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) + ) + { + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_question) + return parse_perl_extension(); + } + // + // update our mark count, and append the required state: + // + unsigned markid = 0; + if(0 == (this->flags() & regbase::nosubs)) + { + markid = ++m_mark_count; + if(this->flags() & regbase::save_subexpression_location) + this->m_pdata->m_subs.push_back(std::pair(std::distance(m_base, m_position) - 1, 0)); + } + re_brace* pb = static_cast(this->append_state(syntax_element_startmark, sizeof(re_brace))); + pb->index = markid; + std::ptrdiff_t last_paren_start = this->getoffset(pb); + // back up insertion point for alternations, and set new point: + std::ptrdiff_t last_alt_point = m_alt_insert_point; + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + // + // back up the current flags in case we have a nested (?imsx) group: + // + regex_constants::syntax_option_type opts = this->flags(); + bool old_case_change = m_has_case_change; + m_has_case_change = false; // no changes to this scope as yet... + // + // now recursively add more states, this will terminate when we get to a + // matching ')' : + // + parse_all(); + // + // Unwind pushed alternatives: + // + if(0 == unwind_alts(last_paren_start)) + return false; + // + // restore flags: + // + if(m_has_case_change) + { + // the case has changed in one or more of the alternatives + // within the scoped (...) block: we have to add a state + // to reset the case sensitivity: + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = opts & regbase::icase; + } + this->flags(opts); + m_has_case_change = old_case_change; + // + // we either have a ')' or we have run out of characters prematurely: + // + if(m_position == m_end) + { + this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end)); + return false; + } + BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); + if(markid && (this->flags() & regbase::save_subexpression_location)) + this->m_pdata->m_subs.at(markid - 1).second = std::distance(m_base, m_position); + ++m_position; + // + // append closing parenthesis state: + // + pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); + pb->index = markid; + this->m_paren_start = last_paren_start; + // + // restore the alternate insertion point: + // + this->m_alt_insert_point = last_alt_point; + // + // allow backrefs to this mark: + // + if((markid > 0) && (markid < sizeof(unsigned) * CHAR_BIT)) + this->m_backrefs |= 1u << (markid - 1); + + return true; +} + +template +bool basic_regex_parser::parse_basic_escape() +{ + ++m_position; + bool result = true; + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::syntax_open_mark: + return parse_open_paren(); + case regex_constants::syntax_close_mark: + return false; + case regex_constants::syntax_plus: + if(this->flags() & regex_constants::bk_plus_qm) + { + ++m_position; + return parse_repeat(1); + } + else + return parse_literal(); + case regex_constants::syntax_question: + if(this->flags() & regex_constants::bk_plus_qm) + { + ++m_position; + return parse_repeat(0, 1); + } + else + return parse_literal(); + case regex_constants::syntax_open_brace: + if(this->flags() & regbase::no_intervals) + return parse_literal(); + ++m_position; + return parse_repeat_range(true); + case regex_constants::syntax_close_brace: + if(this->flags() & regbase::no_intervals) + return parse_literal(); + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + case regex_constants::syntax_or: + if(this->flags() & regbase::bk_vbar) + return parse_alt(); + else + result = parse_literal(); + break; + case regex_constants::syntax_digit: + return parse_backref(); + case regex_constants::escape_type_start_buffer: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_buffer_start); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_end_buffer: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_buffer_end); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_word_assert: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_boundary); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_not_word_assert: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_within_word); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_left_word: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_start); + } + else + result = parse_literal(); + break; + case regex_constants::escape_type_right_word: + if(this->flags() & regbase::emacs_ex) + { + ++m_position; + this->append_state(syntax_element_word_end); + } + else + result = parse_literal(); + break; + default: + if(this->flags() & regbase::emacs_ex) + { + bool negate = true; + switch(*m_position) + { + case 'w': + negate = false; + // fall through: + case 'W': + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(this->m_word_mask); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; + } + case 's': + negate = false; + // fall through: + case 'S': + return add_emacs_code(negate); + case 'c': + case 'C': + // not supported yet: + fail(regex_constants::error_escape, m_position - m_base); + return false; + default: + break; + } + } + result = parse_literal(); + break; + } + return result; +} + +template +bool basic_regex_parser::parse_extended_escape() +{ + ++m_position; + bool negate = false; // in case this is a character class escape: \w \d etc + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::escape_type_not_class: + negate = true; + // fall through: + case regex_constants::escape_type_class: + { + typedef typename traits::char_class_type mask_type; + mask_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(m); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; + } + // + // not a class, just a regular unknown escape: + // + this->append_literal(unescape_character()); + break; + } + case regex_constants::syntax_digit: + return parse_backref(); + case regex_constants::escape_type_left_word: + ++m_position; + this->append_state(syntax_element_word_start); + break; + case regex_constants::escape_type_right_word: + ++m_position; + this->append_state(syntax_element_word_end); + break; + case regex_constants::escape_type_start_buffer: + ++m_position; + this->append_state(syntax_element_buffer_start); + break; + case regex_constants::escape_type_end_buffer: + ++m_position; + this->append_state(syntax_element_buffer_end); + break; + case regex_constants::escape_type_word_assert: + ++m_position; + this->append_state(syntax_element_word_boundary); + break; + case regex_constants::escape_type_not_word_assert: + ++m_position; + this->append_state(syntax_element_within_word); + break; + case regex_constants::escape_type_Z: + ++m_position; + this->append_state(syntax_element_soft_buffer_end); + break; + case regex_constants::escape_type_Q: + return parse_QE(); + case regex_constants::escape_type_C: + return parse_match_any(); + case regex_constants::escape_type_X: + ++m_position; + this->append_state(syntax_element_combining); + break; + case regex_constants::escape_type_G: + ++m_position; + this->append_state(syntax_element_restart_continue); + break; + case regex_constants::escape_type_not_property: + negate = true; + // fall through: + case regex_constants::escape_type_property: + { + ++m_position; + char_class_type m; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // maybe have \p{ddd} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + const charT* base = m_position; + // skip forward until we find enclosing brace: + while((m_position != m_end) && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + m = this->m_traits.lookup_classname(++base, m_position++); + } + else + { + m = this->m_traits.lookup_classname(m_position, m_position+1); + ++m_position; + } + if(m != 0) + { + basic_char_set char_set; + if(negate) + char_set.negate(); + char_set.add_class(m); + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + return true; + } + fail(regex_constants::error_ctype, m_position - m_base); + } + default: + this->append_literal(unescape_character()); + break; + } + return true; +} + +template +bool basic_regex_parser::parse_match_any() +{ + // + // we have a '.' that can match any character: + // + ++m_position; + static_cast( + this->append_state(syntax_element_wild, sizeof(re_dot)) + )->mask = static_cast(this->flags() & regbase::no_mod_s + ? re_detail::force_not_newline + : this->flags() & regbase::mod_s ? + re_detail::force_newline : re_detail::dont_care); + return true; +} + +template +bool basic_regex_parser::parse_repeat(std::size_t low, std::size_t high) +{ + bool greedy = true; + std::size_t insert_point; + // + // when we get to here we may have a non-greedy ? mark still to come: + // + if((m_position != m_end) + && ( + (0 == (this->flags() & (regbase::main_option_type | regbase::no_perl_ex))) + || ((regbase::basic_syntax_group|regbase::emacs_ex) == (this->flags() & (regbase::main_option_type | regbase::emacs_ex))) + ) + ) + { + // OK we have a perl regex, check for a '?': + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_question) + { + greedy = false; + ++m_position; + } + } + if(0 == this->m_last_state) + { + fail(regex_constants::error_badrepeat, ::boost::re_detail::distance(m_base, m_position)); + return false; + } + if(this->m_last_state->type == syntax_element_endmark) + { + // insert a repeat before the '(' matching the last ')': + insert_point = this->m_paren_start; + } + else if((this->m_last_state->type == syntax_element_literal) && (static_cast(this->m_last_state)->length > 1)) + { + // the last state was a literal with more than one character, split it in two: + re_literal* lit = static_cast(this->m_last_state); + charT c = (static_cast(static_cast(lit+1)))[lit->length - 1]; + --(lit->length); + // now append new state: + lit = static_cast(this->append_state(syntax_element_literal, sizeof(re_literal) + sizeof(charT))); + lit->length = 1; + (static_cast(static_cast(lit+1)))[0] = c; + insert_point = this->getoffset(this->m_last_state); + } + else + { + // repeat the last state whatever it was, need to add some error checking here: + switch(this->m_last_state->type) + { + case syntax_element_start_line: + case syntax_element_end_line: + case syntax_element_word_boundary: + case syntax_element_within_word: + case syntax_element_word_start: + case syntax_element_word_end: + case syntax_element_buffer_start: + case syntax_element_buffer_end: + case syntax_element_alt: + case syntax_element_soft_buffer_end: + case syntax_element_restart_continue: + case syntax_element_jump: + case syntax_element_startmark: + case syntax_element_backstep: + // can't legally repeat any of the above: + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + default: + // do nothing... + break; + } + insert_point = this->getoffset(this->m_last_state); + } + // + // OK we now know what to repeat, so insert the repeat around it: + // + re_repeat* rep = static_cast(this->insert_state(insert_point, syntax_element_rep, re_repeater_size)); + rep->min = low; + rep->max = high; + rep->greedy = greedy; + rep->leading = false; + // store our repeater position for later: + std::ptrdiff_t rep_off = this->getoffset(rep); + // and append a back jump to the repeat: + re_jump* jmp = static_cast(this->append_state(syntax_element_jump, sizeof(re_jump))); + jmp->alt.i = rep_off - this->getoffset(jmp); + this->m_pdata->m_data.align(); + // now fill in the alt jump for the repeat: + rep = static_cast(this->getaddress(rep_off)); + rep->alt.i = this->m_pdata->m_data.size() - rep_off; + return true; +} + +template +bool basic_regex_parser::parse_repeat_range(bool isbasic) +{ + // + // parse a repeat-range: + // + std::size_t min, max; + int v; + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + // fail if at end: + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + // get min: + v = this->m_traits.toi(m_position, m_end, 10); + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + if(v < 0) + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + else if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + min = v; + // see if we have a comma: + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_comma) + { + // move on and error check: + ++m_position; + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + // get the value if any: + v = this->m_traits.toi(m_position, m_end, 10); + max = (v >= 0) ? v : (std::numeric_limits::max)(); + } + else + { + // no comma, max = min: + max = min; + } + // skip whitespace: + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + // OK now check trailing }: + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + if(isbasic) + { + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_escape) + { + ++m_position; + if(this->m_position == this->m_end) + { + fail(regex_constants::error_brace, this->m_position - this->m_base); + return false; + } + } + else + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_brace) + ++m_position; + else + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + // + // finally go and add the repeat, unless error: + // + if(min > max) + { + fail(regex_constants::error_badbrace, this->m_position - this->m_base); + return false; + } + return parse_repeat(min, max); +} + +template +bool basic_regex_parser::parse_alt() +{ + // + // error check: if there have been no previous states, + // or if the last state was a '(' then error: + // + if( + ((this->m_last_state == 0) || (this->m_last_state->type == syntax_element_startmark)) + && + !( + ((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) + && + ((this->flags() & regbase::no_empty_expressions) == 0) + ) + ) + { + fail(regex_constants::error_empty, this->m_position - this->m_base); + return false; + } + ++m_position; + // + // we need to append a trailing jump: + // + re_syntax_base* pj = this->append_state(re_detail::syntax_element_jump, sizeof(re_jump)); + std::ptrdiff_t jump_offset = this->getoffset(pj); + // + // now insert the alternative: + // + re_alt* palt = static_cast(this->insert_state(this->m_alt_insert_point, syntax_element_alt, re_alt_size)); + jump_offset += re_alt_size; + this->m_pdata->m_data.align(); + palt->alt.i = this->m_pdata->m_data.size() - this->getoffset(palt); + // + // update m_alt_insert_point so that the next alternate gets + // inserted at the start of the second of the two we've just created: + // + this->m_alt_insert_point = this->m_pdata->m_data.size(); + // + // the start of this alternative must have a case changes state + // if the current block has messed around with case changes: + // + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = this->m_icase; + } + // + // push the alternative onto our stack, a recursive + // implementation here is easier to understand (and faster + // as it happens), but causes all kinds of stack overflow problems + // on programs with small stacks (COM+). + // + m_alt_jumps.push_back(jump_offset); + return true; +} + +template +bool basic_regex_parser::parse_set() +{ + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + basic_char_set char_set; + + const charT* base = m_position; // where the '[' was + const charT* item_base = m_position; // where the '[' or '^' was + + while(m_position != m_end) + { + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_caret: + if(m_position == base) + { + char_set.negate(); + ++m_position; + item_base = m_position; + } + else + parse_set_literal(char_set); + break; + case regex_constants::syntax_close_set: + if(m_position == item_base) + { + parse_set_literal(char_set); + break; + } + else + { + ++m_position; + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_range, m_position - m_base); + return false; + } + } + return true; + case regex_constants::syntax_open_set: + if(parse_inner_set(char_set)) + break; + return true; + case regex_constants::syntax_escape: + { + // + // look ahead and see if this is a character class shortcut + // \d \w \s etc... + // + ++m_position; + if(this->m_traits.escape_syntax_type(*m_position) + == regex_constants::escape_type_class) + { + char_class_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + char_set.add_class(m); + ++m_position; + break; + } + } + else if(this->m_traits.escape_syntax_type(*m_position) + == regex_constants::escape_type_not_class) + { + // negated character class: + char_class_type m = this->m_traits.lookup_classname(m_position, m_position+1); + if(m != 0) + { + char_set.add_negated_class(m); + ++m_position; + break; + } + } + // not a character class, just a regular escape: + --m_position; + parse_set_literal(char_set); + break; + } + default: + parse_set_literal(char_set); + break; + } + } + return m_position != m_end; +} + +template +bool basic_regex_parser::parse_inner_set(basic_char_set& char_set) +{ + // + // we have either a character class [:name:] + // a collating element [.name.] + // or an equivalence class [=name=] + // + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_dot: + // + // a collating element is treated as a literal: + // + --m_position; + parse_set_literal(char_set); + return true; + case regex_constants::syntax_colon: + { + // check that character classes are actually enabled: + if((this->flags() & (regbase::main_option_type | regbase::no_char_classes)) + == (regbase::basic_syntax_group | regbase::no_char_classes)) + { + --m_position; + parse_set_literal(char_set); + return true; + } + // skip the ':' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching ':]' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_colon)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + // + // check for negated class: + // + bool negated = false; + if(this->m_traits.syntax_type(*name_first) == regex_constants::syntax_caret) + { + ++name_first; + negated = true; + } + typedef typename traits::char_class_type mask_type; + mask_type m = this->m_traits.lookup_classname(name_first, name_last); + if(m == 0) + { + if(char_set.empty() && (name_last - name_first == 1)) + { + // maybe a special case: + ++m_position; + if( (m_position != m_end) + && (this->m_traits.syntax_type(*m_position) + == regex_constants::syntax_close_set)) + { + if(this->m_traits.escape_syntax_type(*name_first) + == regex_constants::escape_type_left_word) + { + ++m_position; + this->append_state(syntax_element_word_start); + return false; + } + if(this->m_traits.escape_syntax_type(*name_first) + == regex_constants::escape_type_right_word) + { + ++m_position; + this->append_state(syntax_element_word_end); + return false; + } + } + } + fail(regex_constants::error_ctype, name_first - m_base); + return false; + } + if(negated == false) + char_set.add_class(m); + else + char_set.add_negated_class(m); + ++m_position; + break; + } + case regex_constants::syntax_equal: + { + // skip the '=' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching '=]' + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_brack, m_position - m_base); + return false; + } + string_type m = this->m_traits.lookup_collatename(name_first, name_last); + if((0 == m.size()) || (m.size() > 2)) + { + fail(regex_constants::error_collate, name_first - m_base); + return false; + } + digraph d; + d.first = m[0]; + if(m.size() > 1) + d.second = m[1]; + else + d.second = 0; + char_set.add_equivalent(d); + ++m_position; + break; + } + default: + --m_position; + parse_set_literal(char_set); + break; + } + return true; +} + +template +void basic_regex_parser::parse_set_literal(basic_char_set& char_set) +{ + digraph start_range(get_next_set_literal(char_set)); + if(m_end == m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_dash) + { + // we have a range: + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set) + { + digraph end_range = get_next_set_literal(char_set); + char_set.add_range(start_range, end_range); + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_dash) + { + if(m_end == ++m_position) + { + fail(regex_constants::error_brack, m_position - m_base); + return; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_set) + { + // trailing - : + --m_position; + return; + } + fail(regex_constants::error_range, m_position - m_base); + return; + } + return; + } + --m_position; + } + char_set.add_single(start_range); +} + +template +digraph basic_regex_parser::get_next_set_literal(basic_char_set& char_set) +{ + digraph result; + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_dash: + if(!char_set.empty()) + { + // see if we are at the end of the set: + if((++m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_range, m_position - m_base); + return result; + } + --m_position; + } + result.first = *m_position++; + return result; + case regex_constants::syntax_escape: + // check to see if escapes are supported first: + if(this->flags() & regex_constants::no_escape_in_lists) + { + result = *m_position++; + break; + } + ++m_position; + result = unescape_character(); + break; + case regex_constants::syntax_open_set: + { + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, m_position - m_base); + return result; + } + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_dot) + { + --m_position; + result.first = *m_position; + ++m_position; + return result; + } + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, m_position - m_base); + return result; + } + const charT* name_first = m_position; + // skip at least one character, then find the matching ':]' + if(m_end == ++m_position) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_dot)) + ++m_position; + const charT* name_last = m_position; + if(m_end == m_position) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + if((m_end == ++m_position) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_set)) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + ++m_position; + string_type s = this->m_traits.lookup_collatename(name_first, name_last); + if(s.empty() || (s.size() > 2)) + { + fail(regex_constants::error_collate, name_first - m_base); + return result; + } + result.first = s[0]; + if(s.size() > 1) + result.second = s[1]; + else + result.second = 0; + return result; + } + default: + result = *m_position++; + } + return result; +} + +// +// does a value fit in the specified charT type? +// +template +bool valid_value(charT, int v, const mpl::true_&) +{ + return (v >> (sizeof(charT) * CHAR_BIT)) == 0; +} +template +bool valid_value(charT, int, const mpl::false_&) +{ + return true; // v will alsways fit in a charT +} +template +bool valid_value(charT c, int v) +{ + return valid_value(c, v, mpl::bool_<(sizeof(charT) < sizeof(int))>()); +} + +template +charT basic_regex_parser::unescape_character() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + charT result(0); + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + switch(this->m_traits.escape_syntax_type(*m_position)) + { + case regex_constants::escape_type_control_a: + result = charT('\a'); + break; + case regex_constants::escape_type_e: + result = charT(27); + break; + case regex_constants::escape_type_control_f: + result = charT('\f'); + break; + case regex_constants::escape_type_control_n: + result = charT('\n'); + break; + case regex_constants::escape_type_control_r: + result = charT('\r'); + break; + case regex_constants::escape_type_control_t: + result = charT('\t'); + break; + case regex_constants::escape_type_control_v: + result = charT('\v'); + break; + case regex_constants::escape_type_word_assert: + result = charT('\b'); + break; + case regex_constants::escape_type_ascii_control: + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + /* + if((*m_position < charT('@')) + || (*m_position > charT(125)) ) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + */ + result = static_cast(*m_position % 32); + break; + case regex_constants::escape_type_hex: + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + // maybe have \x{ddd} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + int i = this->m_traits.toi(m_position, m_end, 16); + if((m_position == m_end) + || (i < 0) + || ((std::numeric_limits::is_specialized) && (charT(i) > (std::numeric_limits::max)())) + || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + { + fail(regex_constants::error_badbrace, m_position - m_base); + return result; + } + ++m_position; + result = charT(i); + } + else + { + std::ptrdiff_t len = (std::min)(static_cast(2), m_end - m_position); + int i = this->m_traits.toi(m_position, m_position + len, 16); + if((i < 0) + || !valid_value(charT(0), i)) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + result = charT(i); + } + return result; + case regex_constants::syntax_digit: + { + // an octal escape sequence, the first character must be a zero + // followed by up to 3 octal digits: + std::ptrdiff_t len = (std::min)(::boost::re_detail::distance(m_position, m_end), static_cast(4)); + const charT* bp = m_position; + int val = this->m_traits.toi(bp, bp + 1, 8); + if(val != 0) + { + // Oops not an octal escape after all: + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + val = this->m_traits.toi(m_position, m_position + len, 8); + if(val < 0) + { + fail(regex_constants::error_escape, m_position - m_base); + return result; + } + return static_cast(val); + } + case regex_constants::escape_type_named_char: + { + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // maybe have \N{name} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + const charT* base = m_position; + // skip forward until we find enclosing brace: + while((m_position != m_end) && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + string_type s = this->m_traits.lookup_collatename(++base, m_position++); + if(s.empty()) + { + fail(regex_constants::error_collate, m_position - m_base); + return false; + } + if(s.size() == 1) + { + return s[0]; + } + } + // fall through is a failure: + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + default: + result = *m_position; + break; + } + ++m_position; + return result; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool basic_regex_parser::parse_backref() +{ + BOOST_ASSERT(m_position != m_end); + const charT* pc = m_position; + int i = this->m_traits.toi(pc, pc + 1, 10); + if((i == 0) || (((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) && (this->flags() & regbase::no_bk_refs))) + { + // not a backref at all but an octal escape sequence: + charT c = unescape_character(); + this->append_literal(c); + } + else if((i > 0) && (this->m_backrefs & (1u << (i-1)))) + { + m_position = pc; + re_brace* pb = static_cast(this->append_state(syntax_element_backref, sizeof(re_brace))); + pb->index = i; + } + else + { + fail(regex_constants::error_backref, m_position - m_end); + return false; + } + return true; +} + +template +bool basic_regex_parser::parse_QE() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + // + // parse a \Q...\E sequence: + // + ++m_position; // skip the Q + const charT* start = m_position; + const charT* end; + do + { + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape)) + ++m_position; + if(m_position == m_end) + { + // a \Q...\E sequence may terminate with the end of the expression: + end = m_position; + break; + } + if(++m_position == m_end) // skip the escape + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // check to see if it's a \E: + if(this->m_traits.escape_syntax_type(*m_position) == regex_constants::escape_type_E) + { + ++m_position; + end = m_position - 2; + break; + } + // otherwise go round again: + }while(true); + // + // now add all the character between the two escapes as literals: + // + while(start != end) + { + this->append_literal(*start); + ++start; + } + return true; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool basic_regex_parser::parse_perl_extension() +{ + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + // + // treat comments as a special case, as these + // are the only ones that don't start with a leading + // startmark state: + // + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_hash) + { + while((m_position != m_end) + && (this->m_traits.syntax_type(*m_position++) != regex_constants::syntax_close_mark)) + {} + return true; + } + // + // backup some state, and prepare the way: + // + int markid = 0; + std::ptrdiff_t jump_offset = 0; + re_brace* pb = static_cast(this->append_state(syntax_element_startmark, sizeof(re_brace))); + std::ptrdiff_t last_paren_start = this->getoffset(pb); + // back up insertion point for alternations, and set new point: + std::ptrdiff_t last_alt_point = m_alt_insert_point; + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + std::ptrdiff_t expected_alt_point = m_alt_insert_point; + bool restore_flags = true; + regex_constants::syntax_option_type old_flags = this->flags(); + bool old_case_change = m_has_case_change; + m_has_case_change = false; + // + // select the actual extension used: + // + switch(this->m_traits.syntax_type(*m_position)) + { + case regex_constants::syntax_colon: + // + // a non-capturing mark: + // + pb->index = markid = 0; + ++m_position; + break; + case regex_constants::syntax_equal: + pb->index = markid = -1; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::syntax_not: + pb->index = markid = -2; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::escape_type_left_word: + { + // a lookbehind assertion: + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + regex_constants::syntax_type t = this->m_traits.syntax_type(*m_position); + if(t == regex_constants::syntax_not) + pb->index = markid = -2; + else if(t == regex_constants::syntax_equal) + pb->index = markid = -1; + else + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->append_state(syntax_element_backstep, sizeof(re_brace)); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + } + case regex_constants::escape_type_right_word: + // + // an independent sub-expression: + // + pb->index = markid = -3; + ++m_position; + jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump))); + this->m_pdata->m_data.align(); + m_alt_insert_point = this->m_pdata->m_data.size(); + break; + case regex_constants::syntax_open_mark: + { + // a conditional expression: + pb->index = markid = -4; + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + int v = this->m_traits.toi(m_position, m_end, 10); + if(v > 0) + { + re_brace* br = static_cast(this->append_state(syntax_element_assert_backref, sizeof(re_brace))); + br->index = v; + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + } + else + { + // verify that we have a lookahead or lookbehind assert: + if(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_question) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if(this->m_traits.syntax_type(*m_position) == regex_constants::escape_type_left_word) + { + if(++m_position == m_end) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not)) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + m_position -= 3; + } + else + { + if((this->m_traits.syntax_type(*m_position) != regex_constants::syntax_equal) + && (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_not)) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + m_position -= 2; + } + } + break; + } + case regex_constants::syntax_close_mark: + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + default: + // + // lets assume that we have a (?imsx) group and try and parse it: + // + regex_constants::syntax_option_type opts = parse_options(); + if(m_position == m_end) + return false; + // make a note of whether we have a case change: + m_has_case_change = ((opts & regbase::icase) != (this->flags() & regbase::icase)); + pb->index = markid = 0; + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark) + { + // update flags and carry on as normal: + this->flags(opts); + restore_flags = false; + old_case_change |= m_has_case_change; // defer end of scope by one ')' + } + else if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_colon) + { + // update flags and carry on until the matching ')' is found: + this->flags(opts); + ++m_position; + } + else + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + + // finally append a case change state if we need it: + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = opts & regbase::icase; + } + + } + // + // now recursively add more states, this will terminate when we get to a + // matching ')' : + // + parse_all(); + // + // Unwind alternatives: + // + if(0 == unwind_alts(last_paren_start)) + return false; + // + // we either have a ')' or we have run out of characters prematurely: + // + if(m_position == m_end) + { + this->fail(regex_constants::error_paren, ::boost::re_detail::distance(m_base, m_end)); + return false; + } + BOOST_ASSERT(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark); + ++m_position; + // + // restore the flags: + // + if(restore_flags) + { + // append a case change state if we need it: + if(m_has_case_change) + { + static_cast( + this->append_state(syntax_element_toggle_case, sizeof(re_case)) + )->icase = old_flags & regbase::icase; + } + this->flags(old_flags); + } + // + // set up the jump pointer if we have one: + // + if(jump_offset) + { + this->m_pdata->m_data.align(); + re_jump* jmp = static_cast(this->getaddress(jump_offset)); + jmp->alt.i = this->m_pdata->m_data.size() - this->getoffset(jmp); + if(this->m_last_state == jmp) + { + // Oops... we didn't have anything inside the assertion: + fail(regex_constants::error_empty, m_position - m_base); + return false; + } + } + // + // verify that if this is conditional expression, that we do have + // an alternative, if not add one: + // + if(markid == -4) + { + re_syntax_base* b = this->getaddress(expected_alt_point); + // Make sure we have exactly one alternative following this state: + if(b->type != syntax_element_alt) + { + re_alt* alt = static_cast(this->insert_state(expected_alt_point, syntax_element_alt, sizeof(re_alt))); + alt->alt.i = this->m_pdata->m_data.size() - this->getoffset(alt); + } + else if(this->getaddress(static_cast(b)->alt.i, b)->type == syntax_element_alt) + { + fail(regex_constants::error_bad_pattern, m_position - m_base); + return false; + } + // check for invalid repetition of next state: + b = this->getaddress(expected_alt_point); + b = this->getaddress(static_cast(b)->next.i, b); + if((b->type != syntax_element_assert_backref) + && (b->type != syntax_element_startmark)) + { + fail(regex_constants::error_badrepeat, m_position - m_base); + return false; + } + } + // + // append closing parenthesis state: + // + pb = static_cast(this->append_state(syntax_element_endmark, sizeof(re_brace))); + pb->index = markid; + this->m_paren_start = last_paren_start; + // + // restore the alternate insertion point: + // + this->m_alt_insert_point = last_alt_point; + // + // and the case change data: + // + m_has_case_change = old_case_change; + return true; +} + +template +bool basic_regex_parser::add_emacs_code(bool negate) +{ + // + // parses an emacs style \sx or \Sx construct. + // + if(++m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + basic_char_set char_set; + if(negate) + char_set.negate(); + + static const charT s_punct[5] = { 'p', 'u', 'n', 'c', 't', }; + + switch(*m_position) + { + case 's': + case ' ': + char_set.add_class(this->m_mask_space); + break; + case 'w': + char_set.add_class(this->m_word_mask); + break; + case '_': + char_set.add_single(digraph(charT('$'))); + char_set.add_single(digraph(charT('&'))); + char_set.add_single(digraph(charT('*'))); + char_set.add_single(digraph(charT('+'))); + char_set.add_single(digraph(charT('-'))); + char_set.add_single(digraph(charT('_'))); + char_set.add_single(digraph(charT('<'))); + char_set.add_single(digraph(charT('>'))); + break; + case '.': + char_set.add_class(this->m_traits.lookup_classname(s_punct, s_punct+5)); + break; + case '(': + char_set.add_single(digraph(charT('('))); + char_set.add_single(digraph(charT('['))); + char_set.add_single(digraph(charT('{'))); + break; + case ')': + char_set.add_single(digraph(charT(')'))); + char_set.add_single(digraph(charT(']'))); + char_set.add_single(digraph(charT('}'))); + break; + case '"': + char_set.add_single(digraph(charT('"'))); + char_set.add_single(digraph(charT('\''))); + char_set.add_single(digraph(charT('`'))); + break; + case '\'': + char_set.add_single(digraph(charT('\''))); + char_set.add_single(digraph(charT(','))); + char_set.add_single(digraph(charT('#'))); + break; + case '<': + char_set.add_single(digraph(charT(';'))); + break; + case '>': + char_set.add_single(digraph(charT('\n'))); + char_set.add_single(digraph(charT('\f'))); + break; + default: + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + if(0 == this->append_set(char_set)) + { + fail(regex_constants::error_ctype, m_position - m_base); + return false; + } + ++m_position; + return true; +} + +template +regex_constants::syntax_option_type basic_regex_parser::parse_options() +{ + // we have a (?imsx-imsx) group, convert it into a set of flags: + regex_constants::syntax_option_type f = this->flags(); + bool breakout = false; + do + { + switch(*m_position) + { + case 's': + f |= regex_constants::mod_s; + f &= ~regex_constants::no_mod_s; + break; + case 'm': + f &= ~regex_constants::no_mod_m; + break; + case 'i': + f |= regex_constants::icase; + break; + case 'x': + f |= regex_constants::mod_x; + break; + default: + breakout = true; + continue; + } + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + } + while(!breakout); + + if(*m_position == static_cast('-')) + { + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + do + { + switch(*m_position) + { + case 's': + f &= ~regex_constants::mod_s; + f |= regex_constants::no_mod_s; + break; + case 'm': + f |= regex_constants::no_mod_m; + break; + case 'i': + f &= ~regex_constants::icase; + break; + case 'x': + f &= ~regex_constants::mod_x; + break; + default: + breakout = true; + continue; + } + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } + } + while(!breakout); + } + return f; +} + +template +bool basic_regex_parser::unwind_alts(std::ptrdiff_t last_paren_start) +{ + // + // If we didn't actually add any states after the last + // alternative then that's an error: + // + if((this->m_alt_insert_point == static_cast(this->m_pdata->m_data.size())) + && m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start) + && + !( + ((this->flags() & regbase::main_option_type) == regbase::perl_syntax_group) + && + ((this->flags() & regbase::no_empty_expressions) == 0) + ) + ) + { + fail(regex_constants::error_empty, this->m_position - this->m_base); + return false; + } + // + // Fix up our alternatives: + // + while(m_alt_jumps.size() && (m_alt_jumps.back() > last_paren_start)) + { + // + // fix up the jump to point to the end of the states + // that we've just added: + // + std::ptrdiff_t jump_offset = m_alt_jumps.back(); + m_alt_jumps.pop_back(); + this->m_pdata->m_data.align(); + re_jump* jmp = static_cast(this->getaddress(jump_offset)); + BOOST_ASSERT(jmp->type == syntax_element_jump); + jmp->alt.i = this->m_pdata->m_data.size() - jump_offset; + } + return true; +} + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace re_detail +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/c_regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/c_regex_traits.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,211 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE c_regex_traits.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits class that wraps the global C locale. + */ + +#ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_C_REGEX_TRAITS_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif + +#include + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::strlen; using ::tolower; +} +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + +template +struct c_regex_traits; + +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef char char_type; + typedef std::size_t size_type; + typedef std::string string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::strlen)(p); + } + + char translate(char c) const + { + return c; + } + char translate_nocase(char c) const + { + return static_cast((std::tolower)(static_cast(c))); + } + + static string_type BOOST_REGEX_CALL transform(const char* p1, const char* p2); + static string_type BOOST_REGEX_CALL transform_primary(const char* p1, const char* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const char* p1, const char* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const char* p1, const char* p2); + + static bool BOOST_REGEX_CALL isctype(char, char_class_type); + static int BOOST_REGEX_CALL value(char, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#ifndef BOOST_NO_WREGEX +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef wchar_t char_type; + typedef std::size_t size_type; + typedef std::wstring string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::wcslen)(p); + } + + wchar_t translate(wchar_t c) const + { + return c; + } + wchar_t translate_nocase(wchar_t c) const + { + return (std::towlower)(c); + } + + static string_type BOOST_REGEX_CALL transform(const wchar_t* p1, const wchar_t* p2); + static string_type BOOST_REGEX_CALL transform_primary(const wchar_t* p1, const wchar_t* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const wchar_t* p1, const wchar_t* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const wchar_t* p1, const wchar_t* p2); + + static bool BOOST_REGEX_CALL isctype(wchar_t, char_class_type); + static int BOOST_REGEX_CALL value(wchar_t, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +// +// Provide an unsigned short version as well, so the user can link to this +// no matter whether they build with /Zc:wchar_t or not (MSVC specific). +// +template<> +struct BOOST_REGEX_DECL c_regex_traits +{ + c_regex_traits(){} + typedef unsigned short char_type; + typedef std::size_t size_type; + typedef std::basic_string string_type; + struct locale_type{}; + typedef boost::uint32_t char_class_type; + + static size_type length(const char_type* p) + { + return (std::wcslen)((const wchar_t*)p); + } + + unsigned short translate(unsigned short c) const + { + return c; + } + unsigned short translate_nocase(unsigned short c) const + { + return (std::towlower)((wchar_t)c); + } + + static string_type BOOST_REGEX_CALL transform(const unsigned short* p1, const unsigned short* p2); + static string_type BOOST_REGEX_CALL transform_primary(const unsigned short* p1, const unsigned short* p2); + + static char_class_type BOOST_REGEX_CALL lookup_classname(const unsigned short* p1, const unsigned short* p2); + static string_type BOOST_REGEX_CALL lookup_collatename(const unsigned short* p1, const unsigned short* p2); + + static bool BOOST_REGEX_CALL isctype(unsigned short, char_class_type); + static int BOOST_REGEX_CALL value(unsigned short, int); + + locale_type imbue(locale_type l) + { return l; } + locale_type getloc()const + { return locale_type(); } + +private: + // this type is not copyable: + c_regex_traits(const c_regex_traits&); + c_regex_traits& operator=(const c_regex_traits&); +}; + +#endif + +#endif // BOOST_NO_WREGEX + +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/char_regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/char_regex_traits.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,81 @@ +/* + * + * Copyright (c) 2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE char_regex_traits.cpp + * VERSION see + * DESCRIPTION: Declares deprecated traits classes char_regex_traits<>. + */ + + +#ifndef BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP +#define BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + +namespace deprecated{ +// +// class char_regex_traits_i +// provides case insensitive traits classes (deprecated): +template +class char_regex_traits_i : public regex_traits {}; + +template<> +class char_regex_traits_i : public regex_traits +{ +public: + typedef char char_type; + typedef unsigned char uchar_type; + typedef unsigned int size_type; + typedef regex_traits base_type; + +}; + +#ifndef BOOST_NO_WREGEX +template<> +class char_regex_traits_i : public regex_traits +{ +public: + typedef wchar_t char_type; + typedef unsigned short uchar_type; + typedef unsigned int size_type; + typedef regex_traits base_type; + +}; +#endif +} // namespace deprecated +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // include + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/cpp_regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/cpp_regex_traits.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,1062 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE cpp_regex_traits.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits class cpp_regex_traits. + */ + +#ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED + +#include + +#ifndef BOOST_NO_STD_LOCALE + +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#include +#endif +#ifdef BOOST_HAS_THREADS +#include +#endif +#ifndef BOOST_REGEX_PRIMARY_TRANSFORM +#include +#endif +#ifndef BOOST_REGEX_OBJECT_CACHE_HPP +#include +#endif + +#include +#include +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4786) +#endif + +namespace boost{ + +// +// forward declaration is needed by some compilers: +// +template +class cpp_regex_traits; + +namespace re_detail{ + +// +// class parser_buf: +// acts as a stream buffer which wraps around a pair of pointers: +// +template > +class parser_buf : public ::std::basic_streambuf +{ + typedef ::std::basic_streambuf base_type; + typedef typename base_type::int_type int_type; + typedef typename base_type::char_type char_type; + typedef typename base_type::pos_type pos_type; + typedef ::std::streamsize streamsize; + typedef typename base_type::off_type off_type; +public: + parser_buf() : base_type() { setbuf(0, 0); } + const charT* getnext() { return this->gptr(); } +protected: + std::basic_streambuf* setbuf(char_type* s, streamsize n); + typename parser_buf::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which); + typename parser_buf::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which); +private: + parser_buf& operator=(const parser_buf&); + parser_buf(const parser_buf&); +}; + +template +std::basic_streambuf* +parser_buf::setbuf(char_type* s, streamsize n) +{ + this->setg(s, s, s + n); + return this; +} + +template +typename parser_buf::pos_type +parser_buf::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) +{ + if(which & ::std::ios_base::out) + return pos_type(off_type(-1)); + std::ptrdiff_t size = this->egptr() - this->eback(); + std::ptrdiff_t pos = this->gptr() - this->eback(); + charT* g = this->eback(); + switch(way) + { + case ::std::ios_base::beg: + if((off < 0) || (off > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + off, g + size); + break; + case ::std::ios_base::end: + if((off < 0) || (off > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + size - off, g + size); + break; + case ::std::ios_base::cur: + { + std::ptrdiff_t newpos = static_cast(pos + off); + if((newpos < 0) || (newpos > size)) + return pos_type(off_type(-1)); + else + this->setg(g, g + newpos, g + size); + break; + } + default: ; + } +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4244) +#endif + return static_cast(this->gptr() - this->eback()); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +typename parser_buf::pos_type +parser_buf::seekpos(pos_type sp, ::std::ios_base::openmode which) +{ + if(which & ::std::ios_base::out) + return pos_type(off_type(-1)); + off_type size = static_cast(this->egptr() - this->eback()); + charT* g = this->eback(); + if(off_type(sp) <= size) + { + this->setg(g, g + off_type(sp), g + size); + } + return pos_type(off_type(-1)); +} + +// +// class cpp_regex_traits_base: +// acts as a container for locale and the facets we are using. +// +template +struct cpp_regex_traits_base +{ + cpp_regex_traits_base(const std::locale& l) + { imbue(l); } + std::locale imbue(const std::locale& l); + + std::locale m_locale; + std::ctype const* m_pctype; +#ifndef BOOST_NO_STD_MESSAGES + std::messages const* m_pmessages; +#endif + std::collate const* m_pcollate; + + bool operator<(const cpp_regex_traits_base& b)const + { + if(m_pctype == b.m_pctype) + { +#ifndef BOOST_NO_STD_MESSAGES + if(m_pmessages == b.m_pmessages) + { + } + return m_pmessages < b.m_pmessages; +#else + return m_pcollate < b.m_pcollate; +#endif + } + return m_pctype < b.m_pctype; + } + bool operator==(const cpp_regex_traits_base& b)const + { + return (m_pctype == b.m_pctype) +#ifndef BOOST_NO_STD_MESSAGES + && (m_pmessages == b.m_pmessages) +#endif + && (m_pcollate == b.m_pcollate); + } +}; + +template +std::locale cpp_regex_traits_base::imbue(const std::locale& l) +{ + std::locale result(m_locale); + m_locale = l; + m_pctype = &BOOST_USE_FACET(std::ctype, l); +#ifndef BOOST_NO_STD_MESSAGES + m_pmessages = &BOOST_USE_FACET(std::messages, l); +#endif + m_pcollate = &BOOST_USE_FACET(std::collate, l); + return result; +} + +// +// class cpp_regex_traits_char_layer: +// implements methods that require specialisation for narrow characters: +// +template +class cpp_regex_traits_char_layer : public cpp_regex_traits_base +{ + typedef std::basic_string string_type; + typedef std::map map_type; + typedef typename map_type::const_iterator map_iterator_type; +public: + cpp_regex_traits_char_layer(const std::locale& l) + : cpp_regex_traits_base(l) + { + init(); + } + cpp_regex_traits_char_layer(const cpp_regex_traits_base& b) + : cpp_regex_traits_base(b) + { + init(); + } + void init(); + + regex_constants::syntax_type syntax_type(charT c)const + { + map_iterator_type i = m_char_map.find(c); + return ((i == m_char_map.end()) ? 0 : i->second); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + map_iterator_type i = m_char_map.find(c); + if(i == m_char_map.end()) + { + if(this->m_pctype->is(std::ctype_base::lower, c)) return regex_constants::escape_type_class; + if(this->m_pctype->is(std::ctype_base::upper, c)) return regex_constants::escape_type_not_class; + return 0; + } + return i->second; + } + +private: + string_type get_default_message(regex_constants::syntax_type); + // TODO: use a hash table when available! + map_type m_char_map; +}; + +template +void cpp_regex_traits_char_layer::init() +{ + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: +#ifndef BOOST_NO_STD_MESSAGES +#ifndef __IBMCPP__ + typename std::messages::catalog cat = static_cast::catalog>(-1); +#else + typename std::messages::catalog cat = reinterpret_cast::catalog>(-1); +#endif + std::string cat_name(cpp_regex_traits::get_catalog_name()); + if(cat_name.size()) + { + cat = this->m_pmessages->open( + cat_name, + this->m_locale); + if((int)cat < 0) + { + std::string m("Unable to open message catalog: "); + std::runtime_error err(m + cat_name); + boost::re_detail::raise_runtime_error(err); + } + } + // + // if we have a valid catalog then load our messages: + // + if((int)cat >= 0) + { +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + string_type mss = this->m_pmessages->get(cat, 0, i, get_default_message(i)); + for(typename string_type::size_type j = 0; j < mss.size(); ++j) + { + m_char_map[mss[j]] = i; + } + } + this->m_pmessages->close(cat); +#ifndef BOOST_NO_EXCEPTIONS + } + catch(...) + { + this->m_pmessages->close(cat); + throw; + } +#endif + } + else + { +#endif + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + const char* ptr = get_default_syntax(i); + while(ptr && *ptr) + { + m_char_map[this->m_pctype->widen(*ptr)] = i; + ++ptr; + } + } +#ifndef BOOST_NO_STD_MESSAGES + } +#endif +} + +template +typename cpp_regex_traits_char_layer::string_type + cpp_regex_traits_char_layer::get_default_message(regex_constants::syntax_type i) +{ + const char* ptr = get_default_syntax(i); + string_type result; + while(ptr && *ptr) + { + result.append(1, this->m_pctype->widen(*ptr)); + ++ptr; + } + return result; +} + +// +// specialised version for narrow characters: +// +template <> +class BOOST_REGEX_DECL cpp_regex_traits_char_layer : public cpp_regex_traits_base +{ + typedef std::string string_type; +public: + cpp_regex_traits_char_layer(const std::locale& l) + : cpp_regex_traits_base(l) + { + init(); + } + cpp_regex_traits_char_layer(const cpp_regex_traits_base& l) + : cpp_regex_traits_base(l) + { + init(); + } + + regex_constants::syntax_type syntax_type(char c)const + { + return m_char_map[static_cast(c)]; + } + regex_constants::escape_syntax_type escape_syntax_type(char c) const + { + return m_char_map[static_cast(c)]; + } + +private: + regex_constants::syntax_type m_char_map[1u << CHAR_BIT]; + void init(); +}; + +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +enum +{ + char_class_space=1<<0, + char_class_print=1<<1, + char_class_cntrl=1<<2, + char_class_upper=1<<3, + char_class_lower=1<<4, + char_class_alpha=1<<5, + char_class_digit=1<<6, + char_class_punct=1<<7, + char_class_xdigit=1<<8, + char_class_alnum=char_class_alpha|char_class_digit, + char_class_graph=char_class_alnum|char_class_punct, + char_class_blank=1<<9, + char_class_word=1<<10, + char_class_unicode=1<<11 +}; + +#endif + +// +// class cpp_regex_traits_implementation: +// provides pimpl implementation for cpp_regex_traits. +// +template +class cpp_regex_traits_implementation : public cpp_regex_traits_char_layer +{ +public: + typedef typename cpp_regex_traits::char_class_type char_class_type; + typedef typename std::ctype::mask native_mask_type; +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + BOOST_STATIC_CONSTANT(char_class_type, mask_blank = 1u << 24); + BOOST_STATIC_CONSTANT(char_class_type, mask_word = 1u << 25); + BOOST_STATIC_CONSTANT(char_class_type, mask_unicode = 1u << 26); +#endif + + typedef std::basic_string string_type; + typedef charT char_type; + //cpp_regex_traits_implementation(); + cpp_regex_traits_implementation(const std::locale& l) + : cpp_regex_traits_char_layer(l) + { + init(); + } + cpp_regex_traits_implementation(const cpp_regex_traits_base& l) + : cpp_regex_traits_char_layer(l) + { + init(); + } + std::string error_string(regex_constants::error_type n) const + { + if(!m_error_strings.empty()) + { + std::map::const_iterator p = m_error_strings.find(n); + return (p == m_error_strings.end()) ? std::string(get_default_error_string(n)) : p->second; + } + return get_default_error_string(n); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + char_class_type result = lookup_classname_imp(p1, p2); + if(result == 0) + { + string_type temp(p1, p2); + this->m_pctype->tolower(&*temp.begin(), &*temp.begin() + temp.size()); + result = lookup_classname_imp(&*temp.begin(), &*temp.begin() + temp.size()); + } + return result; + } + string_type lookup_collatename(const charT* p1, const charT* p2) const; + string_type transform_primary(const charT* p1, const charT* p2) const; + string_type transform(const charT* p1, const charT* p2) const; +private: + std::map m_error_strings; // error messages indexed by numberic ID + std::map m_custom_class_names; // character class names + std::map m_custom_collate_names; // collating element names + unsigned m_collate_type; // the form of the collation string + charT m_collate_delim; // the collation group delimiter + // + // helpers: + // + char_class_type lookup_classname_imp(const charT* p1, const charT* p2) const; + void init(); +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +public: + bool isctype(charT c, char_class_type m)const; +#endif +}; + +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET +#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) + +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_blank; +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_word; +template +typename cpp_regex_traits_implementation::char_class_type const cpp_regex_traits_implementation::mask_unicode; + +#endif +#endif + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform_primary(const charT* p1, const charT* p2) const +{ + // + // PRECONDITIONS: + // + // A bug in gcc 3.2 (and maybe other versions as well) treats + // p1 as a null terminated string, for efficiency reasons + // we work around this elsewhere, but just assert here that + // we adhere to gcc's (buggy) preconditions... + // + BOOST_ASSERT(*p2 == 0); + + string_type result; + // + // swallowing all exceptions here is a bad idea + // however at least one std lib will always throw + // std::bad_alloc for certain arguments... + // + try{ + // + // What we do here depends upon the format of the sort key returned by + // sort key returned by this->transform: + // + switch(m_collate_type) + { + case sort_C: + case sort_unknown: + // the best we can do is translate to lower case, then get a regular sort key: + { + result.assign(p1, p2); + this->m_pctype->tolower(&*result.begin(), &*result.begin() + result.size()); + result = this->m_pcollate->transform(&*result.begin(), &*result.begin() + result.size()); + break; + } + case sort_fixed: + { + // get a regular sort key, and then truncate it: + result.assign(this->m_pcollate->transform(p1, p2)); + result.erase(this->m_collate_delim); + break; + } + case sort_delim: + // get a regular sort key, and then truncate everything after the delim: + result.assign(this->m_pcollate->transform(p1, p2)); + std::size_t i; + for(i = 0; i < result.size(); ++i) + { + if(result[i] == m_collate_delim) + break; + } + result.erase(i); + break; + } + }catch(...){} + while(result.size() && (charT(0) == *result.rbegin())) + result.erase(result.size() - 1); + if(result.empty()) + { + // character is ignorable at the primary level: + result = string_type(1, charT(0)); + } + return result; +} + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform(const charT* p1, const charT* p2) const +{ + // + // PRECONDITIONS: + // + // A bug in gcc 3.2 (and maybe other versions as well) treats + // p1 as a null terminated string, for efficiency reasons + // we work around this elsewhere, but just assert here that + // we adhere to gcc's (buggy) preconditions... + // + BOOST_ASSERT(*p2 == 0); + // + // swallowing all exceptions here is a bad idea + // however at least one std lib will always throw + // std::bad_alloc for certain arguments... + // + string_type result; + try{ + result = this->m_pcollate->transform(p1, p2); + // + // Borland's STLPort version returns a NULL-terminated + // string that has garbage at the end - each call to + // std::collate::transform returns a different string! + // So as a workaround, we'll truncate the string at the first NULL + // which _seems_ to work.... +#if BOOST_WORKAROUND(__BORLANDC__, < 0x580) + result.erase(result.find(charT(0))); +#else + // + // some implementations (Dinkumware) append unnecessary trailing \0's: + while(result.size() && (charT(0) == *result.rbegin())) + result.erase(result.size() - 1); +#endif + BOOST_ASSERT(std::find(result.begin(), result.end(), charT(0)) == result.end()); + } + catch(...) + { + } + return result; +} + + +template +typename cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::lookup_collatename(const charT* p1, const charT* p2) const +{ + typedef typename std::map::const_iterator iter_type; + if(m_custom_collate_names.size()) + { + iter_type pos = m_custom_collate_names.find(string_type(p1, p2)); + if(pos != m_custom_collate_names.end()) + return pos->second; + } +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) + std::string name(p1, p2); +#else + std::string name; + const charT* p0 = p1; + while(p0 != p2) + name.append(1, char(*p0++)); +#endif + name = lookup_default_collate_name(name); +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) + if(name.size()) + return string_type(name.begin(), name.end()); +#else + if(name.size()) + { + string_type result; + typedef std::string::const_iterator iter; + iter b = name.begin(); + iter e = name.end(); + while(b != e) + result.append(1, charT(*b++)); + return result; + } +#endif + if(p2 - p1 == 1) + return string_type(1, *p1); + return string_type(); +} + +template +void cpp_regex_traits_implementation::init() +{ +#ifndef BOOST_NO_STD_MESSAGES +#ifndef __IBMCPP__ + typename std::messages::catalog cat = static_cast::catalog>(-1); +#else + typename std::messages::catalog cat = reinterpret_cast::catalog>(-1); +#endif + std::string cat_name(cpp_regex_traits::get_catalog_name()); + if(cat_name.size()) + { + cat = this->m_pmessages->open( + cat_name, + this->m_locale); + if((int)cat < 0) + { + std::string m("Unable to open message catalog: "); + std::runtime_error err(m + cat_name); + boost::re_detail::raise_runtime_error(err); + } + } + // + // if we have a valid catalog then load our messages: + // + if((int)cat >= 0) + { + // + // Error messages: + // + for(boost::regex_constants::error_type i = static_cast(0); + i <= boost::regex_constants::error_unknown; + i = static_cast(i + 1)) + { + const char* p = get_default_error_string(i); + string_type default_message; + while(*p) + { + default_message.append(1, this->m_pctype->widen(*p)); + ++p; + } + string_type s = this->m_pmessages->get(cat, 0, i+200, default_message); + std::string result; + for(std::string::size_type j = 0; j < s.size(); ++j) + { + result.append(1, this->m_pctype->narrow(s[j], 0)); + } + m_error_strings[i] = result; + } + // + // Custom class names: + // +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + static const char_class_type masks[14] = + { + std::ctype::alnum, + std::ctype::alpha, + std::ctype::cntrl, + std::ctype::digit, + std::ctype::graph, + std::ctype::lower, + std::ctype::print, + std::ctype::punct, + std::ctype::space, + std::ctype::upper, + std::ctype::xdigit, + cpp_regex_traits_implementation::mask_blank, + cpp_regex_traits_implementation::mask_word, + cpp_regex_traits_implementation::mask_unicode, + }; +#else + static const char_class_type masks[14] = + { + ::boost::re_detail::char_class_alnum, + ::boost::re_detail::char_class_alpha, + ::boost::re_detail::char_class_cntrl, + ::boost::re_detail::char_class_digit, + ::boost::re_detail::char_class_graph, + ::boost::re_detail::char_class_lower, + ::boost::re_detail::char_class_print, + ::boost::re_detail::char_class_punct, + ::boost::re_detail::char_class_space, + ::boost::re_detail::char_class_upper, + ::boost::re_detail::char_class_xdigit, + ::boost::re_detail::char_class_blank, + ::boost::re_detail::char_class_word, + ::boost::re_detail::char_class_unicode, + }; +#endif + static const string_type null_string; + for(unsigned int j = 0; j <= 13; ++j) + { + string_type s(this->m_pmessages->get(cat, 0, j+300, null_string)); + if(s.size()) + this->m_custom_class_names[s] = masks[j]; + } + } +#endif + // + // get the collation format used by m_pcollate: + // + m_collate_type = re_detail::find_sort_syntax(this, &m_collate_delim); +} + +template +typename cpp_regex_traits_implementation::char_class_type + cpp_regex_traits_implementation::lookup_classname_imp(const charT* p1, const charT* p2) const +{ +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + static const char_class_type masks[20] = + { + 0, + std::ctype::alnum, + std::ctype::alpha, + cpp_regex_traits_implementation::mask_blank, + std::ctype::cntrl, + std::ctype::digit, + std::ctype::digit, + std::ctype::graph, + std::ctype::lower, + std::ctype::lower, + std::ctype::print, + std::ctype::punct, + std::ctype::space, + std::ctype::space, + std::ctype::upper, + cpp_regex_traits_implementation::mask_unicode, + std::ctype::upper, + std::ctype::alnum | cpp_regex_traits_implementation::mask_word, + std::ctype::alnum | cpp_regex_traits_implementation::mask_word, + std::ctype::xdigit, + }; +#else + static const char_class_type masks[20] = + { + 0, + ::boost::re_detail::char_class_alnum, + ::boost::re_detail::char_class_alpha, + ::boost::re_detail::char_class_blank, + ::boost::re_detail::char_class_cntrl, + ::boost::re_detail::char_class_digit, + ::boost::re_detail::char_class_digit, + ::boost::re_detail::char_class_graph, + ::boost::re_detail::char_class_lower, + ::boost::re_detail::char_class_lower, + ::boost::re_detail::char_class_print, + ::boost::re_detail::char_class_punct, + ::boost::re_detail::char_class_space, + ::boost::re_detail::char_class_space, + ::boost::re_detail::char_class_upper, + ::boost::re_detail::char_class_unicode, + ::boost::re_detail::char_class_upper, + ::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word, + ::boost::re_detail::char_class_alnum | ::boost::re_detail::char_class_word, + ::boost::re_detail::char_class_xdigit, + }; +#endif + if(m_custom_class_names.size()) + { + typedef typename std::map, char_class_type>::const_iterator map_iter; + map_iter pos = m_custom_class_names.find(string_type(p1, p2)); + if(pos != m_custom_class_names.end()) + return pos->second; + } + std::size_t state_id = 1 + re_detail::get_default_class_id(p1, p2); + BOOST_ASSERT(state_id < sizeof(masks) / sizeof(masks[0])); + return masks[state_id]; +} + +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +template +bool cpp_regex_traits_implementation::isctype(const charT c, char_class_type mask) const +{ + return + ((mask & ::boost::re_detail::char_class_space) && (m_pctype->is(std::ctype::space, c))) + || ((mask & ::boost::re_detail::char_class_print) && (m_pctype->is(std::ctype::print, c))) + || ((mask & ::boost::re_detail::char_class_cntrl) && (m_pctype->is(std::ctype::cntrl, c))) + || ((mask & ::boost::re_detail::char_class_upper) && (m_pctype->is(std::ctype::upper, c))) + || ((mask & ::boost::re_detail::char_class_lower) && (m_pctype->is(std::ctype::lower, c))) + || ((mask & ::boost::re_detail::char_class_alpha) && (m_pctype->is(std::ctype::alpha, c))) + || ((mask & ::boost::re_detail::char_class_digit) && (m_pctype->is(std::ctype::digit, c))) + || ((mask & ::boost::re_detail::char_class_punct) && (m_pctype->is(std::ctype::punct, c))) + || ((mask & ::boost::re_detail::char_class_xdigit) && (m_pctype->is(std::ctype::xdigit, c))) + || ((mask & ::boost::re_detail::char_class_blank) && (m_pctype->is(std::ctype::space, c)) && !::boost::re_detail::is_separator(c)) + || ((mask & ::boost::re_detail::char_class_word) && (c == '_')) + || ((mask & ::boost::re_detail::char_class_unicode) && ::boost::re_detail::is_extended(c)); +} +#endif + + +template +inline boost::shared_ptr > create_cpp_regex_traits(const std::locale& l BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(charT)) +{ + cpp_regex_traits_base key(l); + return ::boost::object_cache, cpp_regex_traits_implementation >::get(key, 5); +} + +} // re_detail + +template +class cpp_regex_traits +{ +private: + typedef std::ctype ctype_type; +public: + typedef charT char_type; + typedef std::size_t size_type; + typedef std::basic_string string_type; + typedef std::locale locale_type; + typedef boost::uint_least32_t char_class_type; + + struct boost_extensions_tag{}; + + cpp_regex_traits() + : m_pimpl(re_detail::create_cpp_regex_traits(std::locale())) + { } + static size_type length(const char_type* p) + { + return std::char_traits::length(p); + } + regex_constants::syntax_type syntax_type(charT c)const + { + return m_pimpl->syntax_type(c); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + return m_pimpl->escape_syntax_type(c); + } + charT translate(charT c) const + { + return c; + } + charT translate_nocase(charT c) const + { + return m_pimpl->m_pctype->tolower(c); + } + charT translate(charT c, bool icase) const + { + return icase ? m_pimpl->m_pctype->tolower(c) : c; + } + charT tolower(charT c) const + { + return m_pimpl->m_pctype->tolower(c); + } + charT toupper(charT c) const + { + return m_pimpl->m_pctype->toupper(c); + } + string_type transform(const charT* p1, const charT* p2) const + { + return m_pimpl->transform(p1, p2); + } + string_type transform_primary(const charT* p1, const charT* p2) const + { + return m_pimpl->transform_primary(p1, p2); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_classname(p1, p2); + } + string_type lookup_collatename(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_collatename(p1, p2); + } + bool isctype(charT c, char_class_type f) const + { +#ifndef BOOST_REGEX_BUGGY_CTYPE_FACET + typedef typename std::ctype::mask ctype_mask; + + static const ctype_mask mask_base = + static_cast( + std::ctype::alnum + | std::ctype::alpha + | std::ctype::cntrl + | std::ctype::digit + | std::ctype::graph + | std::ctype::lower + | std::ctype::print + | std::ctype::punct + | std::ctype::space + | std::ctype::upper + | std::ctype::xdigit); + + if((f & mask_base) + && (m_pimpl->m_pctype->is( + static_cast(f & mask_base), c))) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_unicode) && re_detail::is_extended(c)) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_word) && (c == '_')) + return true; + else if((f & re_detail::cpp_regex_traits_implementation::mask_blank) + && m_pimpl->m_pctype->is(std::ctype::space, c) + && !re_detail::is_separator(c)) + return true; + return false; +#else + return m_pimpl->isctype(c, f); +#endif + } + int toi(const charT*& p1, const charT* p2, int radix)const; + int value(charT c, int radix)const + { + const charT* pc = &c; + return toi(pc, pc + 1, radix); + } + locale_type imbue(locale_type l) + { + std::locale result(getloc()); + m_pimpl = re_detail::create_cpp_regex_traits(l); + return result; + } + locale_type getloc()const + { + return m_pimpl->m_locale; + } + std::string error_string(regex_constants::error_type n) const + { + return m_pimpl->error_string(n); + } + + // + // extension: + // set the name of the message catalog in use (defaults to "boost_regex"). + // + static std::string catalog_name(const std::string& name); + static std::string get_catalog_name(); + +private: + boost::shared_ptr > m_pimpl; + // + // catalog name handler: + // + static std::string& get_catalog_name_inst(); + +#ifdef BOOST_HAS_THREADS + static static_mutex& get_mutex_inst(); +#endif +}; + + +template +int cpp_regex_traits::toi(const charT*& first, const charT* last, int radix)const +{ + re_detail::parser_buf sbuf; // buffer for parsing numbers. + std::basic_istream is(&sbuf); // stream for parsing numbers. + + // we do NOT want to parse any thousands separators inside the stream: + last = std::find(first, last, BOOST_USE_FACET(std::numpunct, is.getloc()).thousands_sep()); + + sbuf.pubsetbuf(const_cast(static_cast(first)), static_cast(last-first)); + is.clear(); + if(std::abs(radix) == 16) is >> std::hex; + else if(std::abs(radix) == 8) is >> std::oct; + else is >> std::dec; + int val; + if(is >> val) + { + first = first + ((last - first) - sbuf.in_avail()); + return val; + } + else + return -1; +} + +template +std::string cpp_regex_traits::catalog_name(const std::string& name) +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + get_catalog_name_inst() = name; + return result; +} + +template +std::string& cpp_regex_traits::get_catalog_name_inst() +{ + static std::string s_name; + return s_name; +} + +template +std::string cpp_regex_traits::get_catalog_name() +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + return result; +} + +#ifdef BOOST_HAS_THREADS +template +static_mutex& cpp_regex_traits::get_mutex_inst() +{ + static static_mutex s_mutex = BOOST_STATIC_MUTEX_INIT; + return s_mutex; +} +#endif + + +} // boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/cregex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/cregex.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,329 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE cregex.cpp + * VERSION see + * DESCRIPTION: Declares POSIX API functions + * + boost::RegEx high level wrapper. + */ + +#ifndef BOOST_RE_CREGEX_HPP_INCLUDED +#define BOOST_RE_CREGEX_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#include +#include + +#ifdef __cplusplus +#include +#else +#include +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +/* include these defs only for POSIX compatablity */ +#ifdef __cplusplus +namespace boost{ +extern "C" { +#endif + +#if defined(__cplusplus) && !defined(BOOST_NO_STDC_NAMESPACE) +typedef std::ptrdiff_t regoff_t; +typedef std::size_t regsize_t; +#else +typedef ptrdiff_t regoff_t; +typedef size_t regsize_t; +#endif + +typedef struct +{ + unsigned int re_magic; +#ifdef __cplusplus + std::size_t re_nsub; /* number of parenthesized subexpressions */ +#else + size_t re_nsub; +#endif + const char* re_endp; /* end pointer for REG_PEND */ + void* guts; /* none of your business :-) */ + match_flag_type eflags; /* none of your business :-) */ +} regex_tA; + +#ifndef BOOST_NO_WREGEX +typedef struct +{ + unsigned int re_magic; +#ifdef __cplusplus + std::size_t re_nsub; /* number of parenthesized subexpressions */ +#else + size_t re_nsub; +#endif + const wchar_t* re_endp; /* end pointer for REG_PEND */ + void* guts; /* none of your business :-) */ + match_flag_type eflags; /* none of your business :-) */ +} regex_tW; +#endif + +typedef struct +{ + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; + +/* regcomp() flags */ +typedef enum{ + REG_BASIC = 0000, + REG_EXTENDED = 0001, + REG_ICASE = 0002, + REG_NOSUB = 0004, + REG_NEWLINE = 0010, + REG_NOSPEC = 0020, + REG_PEND = 0040, + REG_DUMP = 0200, + REG_NOCOLLATE = 0400, + REG_ESCAPE_IN_LISTS = 01000, + REG_NEWLINE_ALT = 02000, + REG_PERLEX = 04000, + + REG_PERL = REG_EXTENDED | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS | REG_PERLEX, + REG_AWK = REG_EXTENDED | REG_ESCAPE_IN_LISTS, + REG_GREP = REG_BASIC | REG_NEWLINE_ALT, + REG_EGREP = REG_EXTENDED | REG_NEWLINE_ALT, + + REG_ASSERT = 15, + REG_INVARG = 16, + REG_ATOI = 255, /* convert name to number (!) */ + REG_ITOA = 0400 /* convert number to name (!) */ +} reg_comp_flags; + +/* regexec() flags */ +typedef enum{ + REG_NOTBOL = 00001, + REG_NOTEOL = 00002, + REG_STARTEND = 00004 +} reg_exec_flags; + +// +// POSIX error codes: +// +typedef unsigned reg_error_t; +typedef reg_error_t reg_errcode_t; // backwards compatibility + +static const reg_error_t REG_NOERROR = 0; /* Success. */ +static const reg_error_t REG_NOMATCH = 1; /* Didn't find a match (for regexec). */ + + /* POSIX regcomp return error codes. (In the order listed in the + standard.) */ +static const reg_error_t REG_BADPAT = 2; /* Invalid pattern. */ +static const reg_error_t REG_ECOLLATE = 3; /* Undefined collating element. */ +static const reg_error_t REG_ECTYPE = 4; /* Invalid character class name. */ +static const reg_error_t REG_EESCAPE = 5; /* Trailing backslash. */ +static const reg_error_t REG_ESUBREG = 6; /* Invalid back reference. */ +static const reg_error_t REG_EBRACK = 7; /* Unmatched left bracket. */ +static const reg_error_t REG_EPAREN = 8; /* Parenthesis imbalance. */ +static const reg_error_t REG_EBRACE = 9; /* Unmatched \{. */ +static const reg_error_t REG_BADBR = 10; /* Invalid contents of \{\}. */ +static const reg_error_t REG_ERANGE = 11; /* Invalid range end. */ +static const reg_error_t REG_ESPACE = 12; /* Ran out of memory. */ +static const reg_error_t REG_BADRPT = 13; /* No preceding re for repetition op. */ +static const reg_error_t REG_EEND = 14; /* unexpected end of expression */ +static const reg_error_t REG_ESIZE = 15; /* expression too big */ +static const reg_error_t REG_ERPAREN = 8; /* = REG_EPAREN : unmatched right parenthesis */ +static const reg_error_t REG_EMPTY = 17; /* empty expression */ +static const reg_error_t REG_E_MEMORY = 15; /* = REG_ESIZE : out of memory */ +static const reg_error_t REG_ECOMPLEXITY = 18; /* complexity too high */ +static const reg_error_t REG_ESTACK = 19; /* out of stack space */ +static const reg_error_t REG_E_UNKNOWN = 20; /* unknown error */ +static const reg_error_t REG_ENOSYS = 20; /* = REG_E_UNKNOWN : Reserved. */ + +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int); +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t); +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, regsize_t, regmatch_t*, int); +BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA*); + +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW*, const wchar_t*, int); +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int, const regex_tW*, wchar_t*, regsize_t); +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW*, const wchar_t*, regsize_t, regmatch_t*, int); +BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*); +#endif + +#ifdef UNICODE +#define regcomp regcompW +#define regerror regerrorW +#define regexec regexecW +#define regfree regfreeW +#define regex_t regex_tW +#else +#define regcomp regcompA +#define regerror regerrorA +#define regexec regexecA +#define regfree regfreeA +#define regex_t regex_tA +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef __cplusplus +} // extern "C" +} // namespace +#endif + +// +// C++ high level wrapper goes here: +// +#if defined(__cplusplus) +#include +#include +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +class RegEx; + +namespace re_detail{ + +class RegExData; +struct pred1; +struct pred2; +struct pred3; +struct pred4; + +} // namespace re_detail + +#if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_DISABLE_WIN32) +typedef bool (__cdecl *GrepCallback)(const RegEx& expression); +typedef bool (__cdecl *GrepFileCallback)(const char* file, const RegEx& expression); +typedef bool (__cdecl *FindFilesCallback)(const char* file); +#else +typedef bool (*GrepCallback)(const RegEx& expression); +typedef bool (*GrepFileCallback)(const char* file, const RegEx& expression); +typedef bool (*FindFilesCallback)(const char* file); +#endif + +class BOOST_REGEX_DECL RegEx +{ +private: + re_detail::RegExData* pdata; +public: + RegEx(); + RegEx(const RegEx& o); + ~RegEx(); + explicit RegEx(const char* c, bool icase = false); + explicit RegEx(const std::string& s, bool icase = false); + RegEx& operator=(const RegEx& o); + RegEx& operator=(const char* p); + RegEx& operator=(const std::string& s){ return this->operator=(s.c_str()); } + unsigned int SetExpression(const char* p, bool icase = false); + unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); } + std::string Expression()const; + unsigned int error_code()const; + // + // now matching operators: + // + bool Match(const char* p, match_flag_type flags = match_default); + bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); } + bool Search(const char* p, match_flag_type flags = match_default); + bool Search(const std::string& s, match_flag_type flags = match_default) { return Search(s.c_str(), flags); } + unsigned int Grep(GrepCallback cb, const char* p, match_flag_type flags = match_default); + unsigned int Grep(GrepCallback cb, const std::string& s, match_flag_type flags = match_default) { return Grep(cb, s.c_str(), flags); } + unsigned int Grep(std::vector& v, const char* p, match_flag_type flags = match_default); + unsigned int Grep(std::vector& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); } + unsigned int Grep(std::vector& v, const char* p, match_flag_type flags = match_default); + unsigned int Grep(std::vector& v, const std::string& s, match_flag_type flags = match_default) { return Grep(v, s.c_str(), flags); } +#ifndef BOOST_REGEX_NO_FILEITER + unsigned int GrepFiles(GrepFileCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default); + unsigned int GrepFiles(GrepFileCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return GrepFiles(cb, files.c_str(), recurse, flags); } + unsigned int FindFiles(FindFilesCallback cb, const char* files, bool recurse = false, match_flag_type flags = match_default); + unsigned int FindFiles(FindFilesCallback cb, const std::string& files, bool recurse = false, match_flag_type flags = match_default) { return FindFiles(cb, files.c_str(), recurse, flags); } +#endif + + std::string Merge(const std::string& in, const std::string& fmt, + bool copy = true, match_flag_type flags = match_default); + std::string Merge(const char* in, const char* fmt, + bool copy = true, match_flag_type flags = match_default); + + std::size_t Split(std::vector& v, std::string& s, match_flag_type flags = match_default, unsigned max_count = ~0); + // + // now operators for returning what matched in more detail: + // + std::size_t Position(int i = 0)const; + std::size_t Length(int i = 0)const; + bool Matched(int i = 0)const; + std::size_t Marks()const; + std::string What(int i = 0)const; + std::string operator[](int i)const { return What(i); } + + static const std::size_t npos; + + friend struct re_detail::pred1; + friend struct re_detail::pred2; + friend struct re_detail::pred3; + friend struct re_detail::pred4; +}; + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif + +#endif // include guard + + + + + + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/error_type.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/error_type.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,58 @@ +/* + * + * Copyright (c) 2003-2005 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE error_type.hpp + * VERSION see + * DESCRIPTION: Declares regular expression error type enumerator. + */ + +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#define BOOST_REGEX_ERROR_TYPE_HPP + +#ifdef __cplusplus +namespace boost{ +#endif + +#ifdef __cplusplus +namespace regex_constants{ + +enum error_type{ + + error_ok = 0, // not used + error_no_match = 1, // not used + error_bad_pattern = 2, + error_collate = 3, + error_ctype = 4, + error_escape = 5, + error_backref = 6, + error_brack = 7, + error_paren = 8, + error_brace = 9, + error_badbrace = 10, + error_range = 11, + error_space = 12, + error_badrepeat = 13, + error_end = 14, // not used + error_size = 15, + error_right_paren = 16, // not used + error_empty = 17, + error_complexity = 18, + error_stack = 19, + error_unknown = 20 +}; + +} +} +#endif // __cplusplus + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/fileiter.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/fileiter.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,455 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE fileiter.hpp + * VERSION see + * DESCRIPTION: Declares various platform independent file and + * directory iterators, plus binary file input in + * the form of class map_file. + */ + +#ifndef BOOST_RE_FILEITER_HPP_INCLUDED +#define BOOST_RE_FILEITER_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#include + +#ifndef BOOST_REGEX_NO_FILEITER + +#if (defined(__CYGWIN__) || defined(__CYGWIN32__)) && !defined(BOOST_REGEX_NO_W32) +#error "Sorry, can't mix with STL code and gcc compiler: if you ran configure, try again with configure --disable-ms-windows" +#define BOOST_REGEX_FI_WIN32_MAP +#define BOOST_REGEX_FI_POSIX_DIR +#elif (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) && !defined(BOOST_REGEX_NO_W32) +#define BOOST_REGEX_FI_WIN32_MAP +#define BOOST_REGEX_FI_WIN32_DIR +#else +#define BOOST_REGEX_FI_POSIX_MAP +#define BOOST_REGEX_FI_POSIX_DIR +#endif + +#if defined(BOOST_REGEX_FI_WIN32_MAP)||defined(BOOST_REGEX_FI_WIN32_DIR) +#include +#endif + +#if defined(BOOST_REGEX_FI_WIN32_DIR) + +#include + +namespace boost{ + namespace re_detail{ + +#ifndef BOOST_NO_ANSI_APIS +typedef WIN32_FIND_DATAA _fi_find_data; +#else +typedef WIN32_FIND_DATAW _fi_find_data; +#endif +typedef HANDLE _fi_find_handle; + + } // namespace re_detail + +} // namespace boost + +#define _fi_invalid_handle INVALID_HANDLE_VALUE +#define _fi_dir FILE_ATTRIBUTE_DIRECTORY + +#elif defined(BOOST_REGEX_FI_POSIX_DIR) + +#include +#include +#include +#include +#include +#include +#include + +#if defined(__SUNPRO_CC) +using std::list; +#endif + +#ifndef MAX_PATH +#define MAX_PATH 256 +#endif + +namespace boost{ + namespace re_detail{ + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +struct _fi_find_data +{ + unsigned dwFileAttributes; + char cFileName[MAX_PATH]; +}; + +struct _fi_priv_data; + +typedef _fi_priv_data* _fi_find_handle; +#define _fi_invalid_handle 0 +#define _fi_dir 1 + +_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData); +bool _fi_FindNextFile(_fi_find_handle hFindFile, _fi_find_data* lpFindFileData); +bool _fi_FindClose(_fi_find_handle hFindFile); + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + + } // namespace re_detail +} // namespace boost + +#ifdef FindFirstFile + #undef FindFirstFile +#endif +#ifdef FindNextFile + #undef FindNextFile +#endif +#ifdef FindClose + #undef FindClose +#endif + +#define FindFirstFileA _fi_FindFirstFile +#define FindNextFileA _fi_FindNextFile +#define FindClose _fi_FindClose + +#endif + +namespace boost{ + namespace re_detail{ + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +#ifdef BOOST_REGEX_FI_WIN32_MAP // win32 mapfile + +class BOOST_REGEX_DECL mapfile +{ + HANDLE hfile; + HANDLE hmap; + const char* _first; + const char* _last; +public: + + typedef const char* iterator; + + mapfile(){ hfile = hmap = 0; _first = _last = 0; } + mapfile(const char* file){ hfile = hmap = 0; _first = _last = 0; open(file); } + ~mapfile(){ close(); } + void open(const char* file); + void close(); + const char* begin(){ return _first; } + const char* end(){ return _last; } + size_t size(){ return _last - _first; } + bool valid(){ return (hfile != 0) && (hfile != INVALID_HANDLE_VALUE); } +}; + + +#else + +class BOOST_REGEX_DECL mapfile_iterator; + +class BOOST_REGEX_DECL mapfile +{ + typedef char* pointer; + std::FILE* hfile; + long int _size; + pointer* _first; + pointer* _last; + mutable std::list condemed; + enum sizes + { + buf_size = 4096 + }; + void lock(pointer* node)const; + void unlock(pointer* node)const; +public: + + typedef mapfile_iterator iterator; + + mapfile(){ hfile = 0; _size = 0; _first = _last = 0; } + mapfile(const char* file){ hfile = 0; _size = 0; _first = _last = 0; open(file); } + ~mapfile(){ close(); } + void open(const char* file); + void close(); + iterator begin()const; + iterator end()const; + unsigned long size()const{ return _size; } + bool valid()const{ return hfile != 0; } + friend class mapfile_iterator; +}; + +class BOOST_REGEX_DECL mapfile_iterator +#if !defined(BOOST_NO_STD_ITERATOR) || defined(BOOST_MSVC_STD_ITERATOR) +: public std::iterator +#endif +{ + typedef mapfile::pointer internal_pointer; + internal_pointer* node; + const mapfile* file; + unsigned long offset; + long position()const + { + return file ? ((node - file->_first) * mapfile::buf_size + offset) : 0; + } + void position(long pos) + { + if(file) + { + node = file->_first + (pos / mapfile::buf_size); + offset = pos % mapfile::buf_size; + } + } +public: + typedef std::ptrdiff_t difference_type; + typedef char value_type; + typedef const char* pointer; + typedef const char& reference; + typedef std::random_access_iterator_tag iterator_category; + + mapfile_iterator() { node = 0; file = 0; offset = 0; } + mapfile_iterator(const mapfile* f, long arg_position) + { + file = f; + node = f->_first + arg_position / mapfile::buf_size; + offset = arg_position % mapfile::buf_size; + if(file) + file->lock(node); + } + mapfile_iterator(const mapfile_iterator& i) + { + file = i.file; + node = i.node; + offset = i.offset; + if(file) + file->lock(node); + } + ~mapfile_iterator() + { + if(file && node) + file->unlock(node); + } + mapfile_iterator& operator = (const mapfile_iterator& i); + char operator* ()const + { + BOOST_ASSERT(node >= file->_first); + BOOST_ASSERT(node < file->_last); + return file ? *(*node + sizeof(int) + offset) : char(0); + } + char operator[] (long off)const + { + mapfile_iterator tmp(*this); + tmp += off; + return *tmp; + } + mapfile_iterator& operator++ (); + mapfile_iterator operator++ (int); + mapfile_iterator& operator-- (); + mapfile_iterator operator-- (int); + + mapfile_iterator& operator += (long off) + { + position(position() + off); + return *this; + } + mapfile_iterator& operator -= (long off) + { + position(position() - off); + return *this; + } + + friend inline bool operator==(const mapfile_iterator& i, const mapfile_iterator& j) + { + return (i.file == j.file) && (i.node == j.node) && (i.offset == j.offset); + } + + friend inline bool operator!=(const mapfile_iterator& i, const mapfile_iterator& j) + { + return !(i == j); + } + + friend inline bool operator<(const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() < j.position(); + } + friend inline bool operator>(const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() > j.position(); + } + friend inline bool operator<=(const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() <= j.position(); + } + friend inline bool operator>=(const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() >= j.position(); + } + + friend mapfile_iterator operator + (const mapfile_iterator& i, long off); + friend mapfile_iterator operator + (long off, const mapfile_iterator& i) + { + mapfile_iterator tmp(i); + return tmp += off; + } + friend mapfile_iterator operator - (const mapfile_iterator& i, long off); + friend inline long operator - (const mapfile_iterator& i, const mapfile_iterator& j) + { + return i.position() - j.position(); + } +}; + +#endif + +// _fi_sep determines the directory separator, either '\\' or '/' +BOOST_REGEX_DECL extern const char* _fi_sep; + +struct file_iterator_ref +{ + _fi_find_handle hf; + _fi_find_data _data; + long count; +}; + + +class BOOST_REGEX_DECL file_iterator +{ + char* _root; + char* _path; + char* ptr; + file_iterator_ref* ref; + +public: + typedef std::ptrdiff_t difference_type; + typedef const char* value_type; + typedef const char** pointer; + typedef const char*& reference; + typedef std::input_iterator_tag iterator_category; + + file_iterator(); + file_iterator(const char* wild); + ~file_iterator(); + file_iterator(const file_iterator&); + file_iterator& operator=(const file_iterator&); + const char* root()const { return _root; } + const char* path()const { return _path; } + const char* name()const { return ptr; } + _fi_find_data* data() { return &(ref->_data); } + void next(); + file_iterator& operator++() { next(); return *this; } + file_iterator operator++(int); + const char* operator*() { return path(); } + + friend inline bool operator == (const file_iterator& f1, const file_iterator& f2) + { + return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle)); + } + + friend inline bool operator != (const file_iterator& f1, const file_iterator& f2) + { + return !(f1 == f2); + } + +}; + +// dwa 9/13/00 - suppress unused parameter warning +inline bool operator < (const file_iterator&, const file_iterator&) +{ + return false; +} + + +class BOOST_REGEX_DECL directory_iterator +{ + char* _root; + char* _path; + char* ptr; + file_iterator_ref* ref; + +public: + typedef std::ptrdiff_t difference_type; + typedef const char* value_type; + typedef const char** pointer; + typedef const char*& reference; + typedef std::input_iterator_tag iterator_category; + + directory_iterator(); + directory_iterator(const char* wild); + ~directory_iterator(); + directory_iterator(const directory_iterator& other); + directory_iterator& operator=(const directory_iterator& other); + + const char* root()const { return _root; } + const char* path()const { return _path; } + const char* name()const { return ptr; } + _fi_find_data* data() { return &(ref->_data); } + void next(); + directory_iterator& operator++() { next(); return *this; } + directory_iterator operator++(int); + const char* operator*() { return path(); } + + static const char* separator() { return _fi_sep; } + + friend inline bool operator == (const directory_iterator& f1, const directory_iterator& f2) + { + return ((f1.ref->hf == _fi_invalid_handle) && (f2.ref->hf == _fi_invalid_handle)); + } + + + friend inline bool operator != (const directory_iterator& f1, const directory_iterator& f2) + { + return !(f1 == f2); + } + + }; + +inline bool operator < (const directory_iterator&, const directory_iterator&) +{ + return false; +} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + + +} // namespace re_detail +using boost::re_detail::directory_iterator; +using boost::re_detail::file_iterator; +using boost::re_detail::mapfile; +} // namespace boost + +#endif // BOOST_REGEX_NO_FILEITER +#endif // BOOST_RE_FILEITER_HPP + + + + + + + + + + + + + + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/instances.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/instances.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,215 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE instances.cpp + * VERSION see + * DESCRIPTION: Defines those template instances that are placed in the + * library rather than in the users object files. + */ + +// +// note no include guard, we may include this multiple times: +// +#ifndef BOOST_REGEX_NO_EXTERNAL_TEMPLATES + +namespace boost{ + +// +// this header can be included multiple times, each time with +// a different character type, BOOST_REGEX_CHAR_T must be defined +// first: +// +#ifndef BOOST_REGEX_CHAR_T +# error "BOOST_REGEX_CHAR_T not defined" +#endif + +#ifndef BOOST_REGEX_TRAITS_T +# define BOOST_REGEX_TRAITS_T , boost::regex_traits +#endif + +// +// what follows is compiler specific: +// + +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x600) + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +# ifndef BOOST_REGEX_INSTANTIATE +# pragma option push -Jgx +# endif + +template class BOOST_REGEX_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >; +template class BOOST_REGEX_DECL match_results< const BOOST_REGEX_CHAR_T* >; +#ifndef BOOST_NO_STD_ALLOCATOR +template class BOOST_REGEX_DECL ::boost::re_detail::perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >; +#endif + +# ifndef BOOST_REGEX_INSTANTIATE +# pragma option pop +# endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#elif defined(BOOST_MSVC) || defined(__ICL) + +# ifndef BOOST_REGEX_INSTANTIATE +# ifdef __GNUC__ +# define template __extension__ extern template +# else +# if BOOST_MSVC > 1310 +# define BOOST_REGEX_TEMPLATE_DECL +# endif +# define template extern template +# endif +# endif + +#ifndef BOOST_REGEX_TEMPLATE_DECL +# define BOOST_REGEX_TEMPLATE_DECL BOOST_REGEX_DECL +#endif + +# ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4251 4231 4660) +# endif + +template class BOOST_REGEX_TEMPLATE_DECL basic_regex< BOOST_REGEX_CHAR_T BOOST_REGEX_TRAITS_T >; + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template class BOOST_REGEX_TEMPLATE_DECL match_results< const BOOST_REGEX_CHAR_T* >; +#endif +#ifndef BOOST_NO_STD_ALLOCATOR +template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >; +#endif +#if !(defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB <= 1))\ + && !(defined(BOOST_INTEL_CXX_VERSION) && (BOOST_INTEL_CXX_VERSION <= 800))\ + && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))\ + && !defined(BOOST_REGEX_ICU_INSTANCES) +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template class BOOST_REGEX_TEMPLATE_DECL match_results< std::basic_string::const_iterator >; +#endif +#ifndef BOOST_NO_STD_ALLOCATOR +template class BOOST_REGEX_TEMPLATE_DECL ::boost::re_detail::perl_matcher< std::basic_string::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >; +#endif +#endif + + +# ifdef BOOST_MSVC +# pragma warning(pop) +# endif + +# ifdef template +# undef template +# endif + +#undef BOOST_REGEX_TEMPLATE_DECL + +#elif (defined(__GNUC__) && (__GNUC__ >= 3)) + +# ifndef BOOST_REGEX_INSTANTIATE +# define template __extension__ extern template +# endif + +#if !defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_REGEX_ICU_INSTANCES) +namespace re_detail{ +template BOOST_REGEX_DECL +std::locale cpp_regex_traits_base::imbue(const std::locale& l); + +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform_primary(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::transform(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::string_type + cpp_regex_traits_implementation::lookup_collatename(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +template BOOST_REGEX_DECL +void cpp_regex_traits_implementation::init(); +template BOOST_REGEX_DECL +cpp_regex_traits_implementation::char_class_type + cpp_regex_traits_implementation::lookup_classname_imp(const BOOST_REGEX_CHAR_T* p1, const BOOST_REGEX_CHAR_T* p2) const; +#ifdef BOOST_REGEX_BUGGY_CTYPE_FACET +template BOOST_REGEX_DECL +bool cpp_regex_traits_implementation::isctype(const BOOST_REGEX_CHAR_T c, char_class_type mask) const; +#endif +} // namespace +template BOOST_REGEX_DECL +int cpp_regex_traits::toi(const BOOST_REGEX_CHAR_T*& first, const BOOST_REGEX_CHAR_T* last, int radix)const; +template BOOST_REGEX_DECL +std::string cpp_regex_traits::catalog_name(const std::string& name); +template BOOST_REGEX_DECL +std::string& cpp_regex_traits::get_catalog_name_inst(); +template BOOST_REGEX_DECL +std::string cpp_regex_traits::get_catalog_name(); +#ifdef BOOST_HAS_THREADS +template BOOST_REGEX_DECL +static_mutex& cpp_regex_traits::get_mutex_inst(); +#endif +#endif + +template BOOST_REGEX_DECL basic_regex& + basic_regex::do_assign( + const BOOST_REGEX_CHAR_T* p1, + const BOOST_REGEX_CHAR_T* p2, + flag_type f); +template BOOST_REGEX_DECL basic_regex::locale_type BOOST_REGEX_CALL + basic_regex::imbue(locale_type l); + +template BOOST_REGEX_DECL void BOOST_REGEX_CALL + match_results::maybe_assign( + const match_results& m); + +namespace re_detail{ +template BOOST_REGEX_DECL void perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::construct_init( + const basic_regex& e, match_flag_type f); +template BOOST_REGEX_DECL bool perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::match(); +template BOOST_REGEX_DECL bool perl_matcher::allocator_type BOOST_REGEX_TRAITS_T >::find(); +} // namespace + +#if (defined(__GLIBCPP__) || defined(__GLIBCXX__)) \ + && !defined(BOOST_REGEX_ICU_INSTANCES)\ + && !defined(__SGI_STL_PORT)\ + && !defined(_STLPORT_VERSION) +// std:basic_string<>::const_iterator instances as well: +template BOOST_REGEX_DECL void BOOST_REGEX_CALL + match_results::const_iterator>::maybe_assign( + const match_results::const_iterator>& m); + +namespace re_detail{ +template BOOST_REGEX_DECL void perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::construct_init( + const basic_regex& e, match_flag_type f); +template BOOST_REGEX_DECL bool perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::match(); +template BOOST_REGEX_DECL bool perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::find(); +} // namespace +#endif + +# ifdef template +# undef template +# endif + + +#endif + +} // namespace boost + +#endif // BOOST_REGEX_NO_EXTERNAL_TEMPLATES + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/iterator_category.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/iterator_category.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_match.hpp + * VERSION see + * DESCRIPTION: Iterator traits for selecting an iterator type as + * an integral constant expression. + */ + + +#ifndef BOOST_REGEX_ITERATOR_CATEGORY_HPP +#define BOOST_REGEX_ITERATOR_CATEGORY_HPP + +#include +#include +#include + +namespace boost{ +namespace detail{ + +template +struct is_random_imp +{ +private: + typedef typename std::iterator_traits::iterator_category cat; +public: + BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible::value)); +}; + +template +struct is_random_pointer_imp +{ + BOOST_STATIC_CONSTANT(bool, value = true); +}; + +template +struct is_random_imp_selector +{ + template + struct rebind + { + typedef is_random_imp type; + }; +}; + +template <> +struct is_random_imp_selector +{ + template + struct rebind + { + typedef is_random_pointer_imp type; + }; +}; + +} + +template +struct is_random_access_iterator +{ +private: + typedef detail::is_random_imp_selector< ::boost::is_pointer::value> selector; + typedef typename selector::template rebind bound_type; + typedef typename bound_type::type answer; +public: + BOOST_STATIC_CONSTANT(bool, value = answer::value); +}; + +#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION +template +const bool is_random_access_iterator::value; +#endif + +} + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/iterator_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/iterator_traits.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,135 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE iterator_traits.cpp + * VERSION see + * DESCRIPTION: Declares iterator traits workarounds. + */ + +#ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP +#define BOOST_REGEX_V4_ITERATOR_TRAITS_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +namespace re_detail{ + +#if defined(BOOST_NO_STD_ITERATOR_TRAITS) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + +template +struct regex_iterator_traits +{ + typedef typename T::iterator_category iterator_category; + typedef typename T::value_type value_type; +#if !defined(BOOST_NO_STD_ITERATOR) + typedef typename T::difference_type difference_type; + typedef typename T::pointer pointer; + typedef typename T::reference reference; +#else + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type& reference; +#endif +}; + +template +struct pointer_iterator_traits +{ + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef std::random_access_iterator_tag iterator_category; +}; +template +struct const_pointer_iterator_traits +{ + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef const T* pointer; + typedef const T& reference; + typedef std::random_access_iterator_tag iterator_category; +}; + +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +// +// the follwoing are needed for ICU support: +// +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; + +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +#endif + +#if defined(__SGI_STL_PORT) && defined(__STL_DEBUG) +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +#ifndef BOOST_NO_STD_WSTRING +template<> +struct regex_iterator_traits : pointer_iterator_traits{}; +template<> +struct regex_iterator_traits : const_pointer_iterator_traits{}; +#endif // BOOST_NO_WSTRING +#endif // stport + +#else + +template +struct regex_iterator_traits : public std::iterator_traits {}; + +#endif + +} // namespace re_detail +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/match_flags.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/match_flags.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,138 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE match_flags.hpp + * VERSION see + * DESCRIPTION: Declares match_flags type. + */ + +#ifndef BOOST_REGEX_V4_MATCH_FLAGS +#define BOOST_REGEX_V4_MATCH_FLAGS + +#ifdef __cplusplus +# include +#endif + +#ifdef __cplusplus +namespace boost{ + namespace regex_constants{ +#endif + +typedef enum _match_flags +{ + match_default = 0, + match_not_bol = 1, // first is not start of line + match_not_eol = match_not_bol << 1, // last is not end of line + match_not_bob = match_not_eol << 1, // first is not start of buffer + match_not_eob = match_not_bob << 1, // last is not end of buffer + match_not_bow = match_not_eob << 1, // first is not start of word + match_not_eow = match_not_bow << 1, // last is not end of word + match_not_dot_newline = match_not_eow << 1, // \n is not matched by '.' + match_not_dot_null = match_not_dot_newline << 1, // '\0' is not matched by '.' + match_prev_avail = match_not_dot_null << 1, // *--first is a valid expression + match_init = match_prev_avail << 1, // internal use + match_any = match_init << 1, // don't care what we match + match_not_null = match_any << 1, // string can't be null + match_continuous = match_not_null << 1, // each grep match must continue from + // uninterupted from the previous one + match_partial = match_continuous << 1, // find partial matches + + match_stop = match_partial << 1, // stop after first match (grep) V3 only + match_not_initial_null = match_stop, // don't match initial null, V4 only + match_all = match_stop << 1, // must find the whole of input even if match_any is set + match_perl = match_all << 1, // Use perl matching rules + match_posix = match_perl << 1, // Use POSIX matching rules + match_nosubs = match_posix << 1, // don't trap marked subs + match_extra = match_nosubs << 1, // include full capture information for repeated captures + match_single_line = match_extra << 1, // treat text as single line and ignor any \n's when matching ^ and $. + match_unused1 = match_single_line << 1, // unused + match_unused2 = match_unused1 << 1, // unused + match_unused3 = match_unused2 << 1, // unused + match_max = match_unused3, + + format_perl = 0, // perl style replacement + format_default = 0, // ditto. + format_sed = match_max << 1, // sed style replacement. + format_all = format_sed << 1, // enable all extentions to sytax. + format_no_copy = format_all << 1, // don't copy non-matching segments. + format_first_only = format_no_copy << 1, // Only replace first occurance. + format_is_if = format_first_only << 1, // internal use only. + format_literal = format_is_if << 1 // treat string as a literal + +} match_flags; + +#if (defined(_MSC_VER) && (_MSC_VER < 1300)) || defined(__BORLANDC__) +typedef unsigned long match_flag_type; +#else +typedef match_flags match_flag_type; + + +#ifdef __cplusplus +inline match_flags operator&(match_flags m1, match_flags m2) +{ return static_cast(static_cast(m1) & static_cast(m2)); } +inline match_flags operator|(match_flags m1, match_flags m2) +{ return static_cast(static_cast(m1) | static_cast(m2)); } +inline match_flags operator^(match_flags m1, match_flags m2) +{ return static_cast(static_cast(m1) ^ static_cast(m2)); } +inline match_flags operator~(match_flags m1) +{ return static_cast(~static_cast(m1)); } +inline match_flags& operator&=(match_flags& m1, match_flags m2) +{ m1 = m1&m2; return m1; } +inline match_flags& operator|=(match_flags& m1, match_flags m2) +{ m1 = m1|m2; return m1; } +inline match_flags& operator^=(match_flags& m1, match_flags m2) +{ m1 = m1^m2; return m1; } +#endif +#endif + +#ifdef __cplusplus +} // namespace regex_constants +// +// import names into boost for backwards compatiblity: +// +using regex_constants::match_flag_type; +using regex_constants::match_default; +using regex_constants::match_not_bol; +using regex_constants::match_not_eol; +using regex_constants::match_not_bob; +using regex_constants::match_not_eob; +using regex_constants::match_not_bow; +using regex_constants::match_not_eow; +using regex_constants::match_not_dot_newline; +using regex_constants::match_not_dot_null; +using regex_constants::match_prev_avail; +//using regex_constants::match_init; +using regex_constants::match_any; +using regex_constants::match_not_null; +using regex_constants::match_continuous; +using regex_constants::match_partial; +//using regex_constants::match_stop; +using regex_constants::match_all; +using regex_constants::match_perl; +using regex_constants::match_posix; +using regex_constants::match_nosubs; +using regex_constants::match_extra; +using regex_constants::match_single_line; +//using regex_constants::match_max; +using regex_constants::format_all; +using regex_constants::format_sed; +using regex_constants::format_perl; +using regex_constants::format_default; +using regex_constants::format_no_copy; +using regex_constants::format_first_only; +//using regex_constants::format_is_if; + +} // namespace boost +#endif // __cplusplus +#endif // include guard + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/match_results.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/match_results.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,427 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE match_results.cpp + * VERSION see + * DESCRIPTION: Declares template class match_results. + */ + +#ifndef BOOST_REGEX_V4_MATCH_RESULTS_HPP +#define BOOST_REGEX_V4_MATCH_RESULTS_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660) +#endif + +template +class match_results +{ +private: +#ifndef BOOST_NO_STD_ALLOCATOR + typedef std::vector, Allocator> vector_type; +#else + typedef std::vector > vector_type; +#endif +public: + typedef sub_match value_type; +#if !defined(BOOST_NO_STD_ALLOCATOR) && !(defined(BOOST_MSVC) && defined(_STLPORT_VERSION)) + typedef typename Allocator::const_reference const_reference; +#else + typedef const value_type& const_reference; +#endif + typedef const_reference reference; + typedef typename vector_type::const_iterator const_iterator; + typedef const_iterator iterator; + typedef typename re_detail::regex_iterator_traits< + BidiIterator>::difference_type difference_type; + typedef typename Allocator::size_type size_type; + typedef Allocator allocator_type; + typedef typename re_detail::regex_iterator_traits< + BidiIterator>::value_type char_type; + typedef std::basic_string string_type; + + // construct/copy/destroy: + explicit match_results(const Allocator& a = Allocator()) +#ifndef BOOST_NO_STD_ALLOCATOR + : m_subs(a), m_base() {} +#else + : m_subs(), m_base() { (void)a; } +#endif + match_results(const match_results& m) + : m_subs(m.m_subs), m_base(m.m_base) {} + match_results& operator=(const match_results& m) + { + m_subs = m.m_subs; + m_base = m.m_base; + return *this; + } + ~match_results(){} + + // size: + size_type size() const + { return empty() ? 0 : m_subs.size() - 2; } + size_type max_size() const + { return m_subs.max_size(); } + bool empty() const + { return m_subs.size() < 2; } + // element access: + difference_type length(int sub = 0) const + { + sub += 2; + if((sub < (int)m_subs.size()) && (sub > 0)) + return m_subs[sub].length(); + return 0; + } + difference_type position(size_type sub = 0) const + { + sub += 2; + if(sub < m_subs.size()) + { + const sub_match& s = m_subs[sub]; + if(s.matched || (sub == 2)) + { + return ::boost::re_detail::distance((BidiIterator)(m_base), (BidiIterator)(s.first)); + } + } + return ~static_cast(0); + } + string_type str(int sub = 0) const + { + sub += 2; + string_type result; + if(sub < (int)m_subs.size() && (sub > 0)) + { + const sub_match& s = m_subs[sub]; + if(s.matched) + { + result = s.str(); + } + } + return result; + } + const_reference operator[](int sub) const + { + sub += 2; + if(sub < (int)m_subs.size() && (sub >= 0)) + { + return m_subs[sub]; + } + return m_null; + } + + const_reference prefix() const + { + return (*this)[-1]; + } + + const_reference suffix() const + { + return (*this)[-2]; + } + const_iterator begin() const + { + return (m_subs.size() > 2) ? (m_subs.begin() + 2) : m_subs.end(); + } + const_iterator end() const + { + return m_subs.end(); + } + // format: + template + OutputIterator format(OutputIterator out, + const string_type& fmt, + match_flag_type flags = format_default) const + { + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, *this, fmt.data(), fmt.data() + fmt.size(), flags, traits); + } + string_type format(const string_type& fmt, + match_flag_type flags = format_default) const + { + string_type result; + re_detail::string_out_iterator i(result); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, *this, fmt.data(), fmt.data() + fmt.size(), flags, traits); + return result; + } + // format with locale: + template + OutputIterator format(OutputIterator out, + const string_type& fmt, + match_flag_type flags, + const RegexT& re) const + { + return ::boost::re_detail::regex_format_imp(out, *this, fmt.data(), fmt.data() + fmt.size(), flags, re.get_traits()); + } + template + string_type format(const string_type& fmt, + match_flag_type flags, + const RegexT& re) const + { + string_type result; + re_detail::string_out_iterator i(result); + ::boost::re_detail::regex_format_imp(i, *this, fmt.data(), fmt.data() + fmt.size(), flags, re.get_traits()); + return result; + } + + allocator_type get_allocator() const + { +#ifndef BOOST_NO_STD_ALLOCATOR + return m_subs.get_allocator(); +#else + return allocator_type(); +#endif + } + void swap(match_results& that) + { + std::swap(m_subs, that.m_subs); + std::swap(m_base, that.m_base); + } + bool operator==(const match_results& that)const + { + return (m_subs == that.m_subs) && (m_base == that.m_base); + } + bool operator!=(const match_results& that)const + { return !(*this == that); } + +#ifdef BOOST_REGEX_MATCH_EXTRA + typedef typename sub_match::capture_sequence_type capture_sequence_type; + + const capture_sequence_type& captures(int i)const + { + return (*this)[i].captures(); + } +#endif + + // + // private access functions: + void BOOST_REGEX_CALL set_second(BidiIterator i) + { + BOOST_ASSERT(m_subs.size() > 2); + m_subs[2].second = i; + m_subs[2].matched = true; + m_subs[0].first = i; + m_subs[0].matched = (m_subs[0].first != m_subs[0].second); + m_null.first = i; + m_null.second = i; + m_null.matched = false; + } + + void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true) + { + pos += 2; + BOOST_ASSERT(m_subs.size() > pos); + m_subs[pos].second = i; + m_subs[pos].matched = m; + if(pos == 2) + { + m_subs[0].first = i; + m_subs[0].matched = (m_subs[0].first != m_subs[0].second); + m_null.first = i; + m_null.second = i; + m_null.matched = false; + } + } + void BOOST_REGEX_CALL set_size(size_type n, BidiIterator i, BidiIterator j) + { + value_type v(j); + size_type len = m_subs.size(); + if(len > n + 2) + { + m_subs.erase(m_subs.begin()+n+2, m_subs.end()); + std::fill(m_subs.begin(), m_subs.end(), v); + } + else + { + std::fill(m_subs.begin(), m_subs.end(), v); + if(n+2 != len) + m_subs.insert(m_subs.end(), n+2-len, v); + } + m_subs[1].first = i; + } + void BOOST_REGEX_CALL set_base(BidiIterator pos) + { + m_base = pos; + } + BidiIterator base()const + { + return m_base; + } + void BOOST_REGEX_CALL set_first(BidiIterator i) + { + // set up prefix: + m_subs[1].second = i; + m_subs[1].matched = (m_subs[1].first != i); + // set up $0: + m_subs[2].first = i; + // zero out everything else: + for(size_type n = 3; n < m_subs.size(); ++n) + { + m_subs[n].first = m_subs[n].second = m_subs[0].second; + m_subs[n].matched = false; + } + } + void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos) + { + BOOST_ASSERT(pos+2 < m_subs.size()); + if(pos) + m_subs[pos+2].first = i; + else + set_first(i); + } + void BOOST_REGEX_CALL maybe_assign(const match_results& m); + + +private: + vector_type m_subs; // subexpressions + BidiIterator m_base; // where the search started from + sub_match m_null; // a null match +}; + +template +void BOOST_REGEX_CALL match_results::maybe_assign(const match_results& m) +{ + const_iterator p1, p2; + p1 = begin(); + p2 = m.begin(); + // + // Distances are measured from the start of *this* match, unless this isn't + // a valid match in which case we use the start of the whole sequence. Note that + // no subsequent match-candidate can ever be to the left of the first match found. + // This ensures that when we are using bidirectional iterators, that distances + // measured are as short as possible, and therefore as efficient as possible + // to compute. Finally note that we don't use the "matched" data member to test + // whether a sub-expression is a valid match, because partial matches set this + // to false for sub-expression 0. + // + BidiIterator l_end = this->suffix().second; + BidiIterator l_base = (p1->first == l_end) ? this->prefix().first : (*this)[0].first; + difference_type len1 = 0; + difference_type len2 = 0; + difference_type base1 = 0; + difference_type base2 = 0; + std::size_t i; + for(i = 0; i < size(); ++i, ++p1, ++p2) + { + // + // Leftmost takes priority over longest; handle special cases + // where distances need not be computed first (an optimisation + // for bidirectional iterators: ensure that we don't accidently + // compute the length of the whole sequence, as this can be really + // expensive). + // + if(p1->first == l_end) + { + if(p2->first != l_end) + { + // p2 must be better than p1, and no need to calculate + // actual distances: + base1 = 1; + base2 = 0; + break; + } + else + { + // *p1 and *p2 are either unmatched or match end-of sequence, + // either way no need to calculate distances: + if((p1->matched == false) && (p2->matched == true)) + break; + if((p1->matched == true) && (p2->matched == false)) + return; + continue; + } + } + else if(p2->first == l_end) + { + // p1 better than p2, and no need to calculate distances: + return; + } + base1 = ::boost::re_detail::distance(l_base, p1->first); + base2 = ::boost::re_detail::distance(l_base, p2->first); + BOOST_ASSERT(base1 >= 0); + BOOST_ASSERT(base2 >= 0); + if(base1 < base2) return; + if(base2 < base1) break; + + len1 = ::boost::re_detail::distance((BidiIterator)p1->first, (BidiIterator)p1->second); + len2 = ::boost::re_detail::distance((BidiIterator)p2->first, (BidiIterator)p2->second); + BOOST_ASSERT(len1 >= 0); + BOOST_ASSERT(len2 >= 0); + if((len1 != len2) || ((p1->matched == false) && (p2->matched == true))) + break; + if((p1->matched == true) && (p2->matched == false)) + return; + } + if(i == size()) + return; + if(base2 < base1) + *this = m; + else if((len2 > len1) || ((p1->matched == false) && (p2->matched == true)) ) + *this = m; +} + +template +void swap(match_results& a, match_results& b) +{ + a.swap(b); +} + +#ifndef BOOST_NO_STD_LOCALE +template +std::basic_ostream& + operator << (std::basic_ostream& os, + const match_results& s) +{ + return (os << s.str()); +} +#else +template +std::ostream& operator << (std::ostream& os, + const match_results& s) +{ + return (os << s.str()); +} +#endif + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/mem_block_cache.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/mem_block_cache.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,99 @@ + /* + * Copyright (c) 2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE mem_block_cache.hpp + * VERSION see + * DESCRIPTION: memory block cache used by the non-recursive matcher. + */ + +#ifndef BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP +#define BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP + +#include +#ifdef BOOST_HAS_THREADS +#include +#endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost{ +namespace re_detail{ + +struct mem_block_node +{ + mem_block_node* next; +}; + +struct mem_block_cache +{ + // this member has to be statically initialsed: + mem_block_node* next; + unsigned cached_blocks; +#ifdef BOOST_HAS_THREADS + boost::static_mutex mut; +#endif + + ~mem_block_cache() + { + while(next) + { + mem_block_node* old = next; + next = next->next; + ::operator delete(old); + } + } + void* get() + { +#ifdef BOOST_HAS_THREADS + boost::static_mutex::scoped_lock g(mut); +#endif + if(next) + { + mem_block_node* result = next; + next = next->next; + --cached_blocks; + return result; + } + return ::operator new(BOOST_REGEX_BLOCKSIZE); + } + void put(void* p) + { +#ifdef BOOST_HAS_THREADS + boost::static_mutex::scoped_lock g(mut); +#endif + if(cached_blocks >= BOOST_REGEX_MAX_CACHE_BLOCKS) + { + ::operator delete(p); + } + else + { + mem_block_node* old = static_cast(p); + old->next = next; + next = old; + ++cached_blocks; + } + } +}; + +extern mem_block_cache block_cache; + +} +} // namespace boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,556 @@ +/* + * + * Copyright (c) 2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + +#ifndef BOOST_REGEX_MATCHER_HPP +#define BOOST_REGEX_MATCHER_HPP + +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace boost{ +namespace re_detail{ + +// +// error checking API: +// +BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex_constants::syntax_option_type ef, match_flag_type mf); +// +// function can_start: +// +template +inline bool can_start(charT c, const unsigned char* map, unsigned char mask) +{ + return ((c < static_cast(0)) ? true : ((c >= static_cast(1 << CHAR_BIT)) ? true : map[c] & mask)); +} +inline bool can_start(char c, const unsigned char* map, unsigned char mask) +{ + return map[(unsigned char)c] & mask; +} +inline bool can_start(signed char c, const unsigned char* map, unsigned char mask) +{ + return map[(unsigned char)c] & mask; +} +inline bool can_start(unsigned char c, const unsigned char* map, unsigned char mask) +{ + return map[c] & mask; +} +inline bool can_start(unsigned short c, const unsigned char* map, unsigned char mask) +{ + return ((c >= (1 << CHAR_BIT)) ? true : map[c] & mask); +} +#if !defined(__hpux) // WCHAR_MIN not usable in pp-directives. +#if defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +inline bool can_start(wchar_t c, const unsigned char* map, unsigned char mask) +{ + return ((c >= static_cast(1u << CHAR_BIT)) ? true : map[c] & mask); +} +#endif +#endif +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) +inline bool can_start(unsigned int c, const unsigned char* map, unsigned char mask) +{ + return (((c >= static_cast(1u << CHAR_BIT)) ? true : map[c] & mask)); +} +#endif + + +// +// Unfortunately Rogue Waves standard library appears to have a bug +// in std::basic_string::compare that results in eroneous answers +// in some cases (tested with Borland C++ 5.1, Rogue Wave lib version +// 0x020101) the test case was: +// {39135,0} < {0xff,0} +// which succeeds when it should not. +// +#ifndef _RWSTD_VER +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310) +template +inline int string_compare(const std::basic_string& s, const C* p) +{ + if(0 == *p) + { + if(s.empty() || ((s.size() == 1) && (s[0] == 0))) + return 0; + } + return s.compare(p); +} +#endif +#else +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310) +template +inline int string_compare(const std::basic_string& s, const C* p) +{ + if(0 == *p) + { + if(s.empty() || ((s.size() == 1) && (s[0] == 0))) + return 0; + } + return s.compare(p); +} +#endif +inline int string_compare(const std::string& s, const char* p) +{ return std::strcmp(s.c_str(), p); } +# ifndef BOOST_NO_WREGEX +inline int string_compare(const std::wstring& s, const wchar_t* p) +{ return std::wcscmp(s.c_str(), p); } +#endif +#endif +template +inline int string_compare(const Seq& s, const C* p) +{ + std::size_t i = 0; + while((i < s.size()) && (p[i] == s[i])) + { + ++i; + } + return (i == s.size()) ? -p[i] : s[i] - p[i]; +} +# define STR_COMP(s,p) string_compare(s,p) + +template +inline const charT* re_skip_past_null(const charT* p) +{ + while (*p != static_cast(0)) ++p; + return ++p; +} + +template +iterator BOOST_REGEX_CALL re_is_set_member(iterator next, + iterator last, + const re_set_long* set_, + const regex_data& e, bool icase) +{ + const charT* p = reinterpret_cast(set_+1); + iterator ptr; + unsigned int i; + //bool icase = e.m_flags & regex_constants::icase; + + if(next == last) return next; + + typedef typename traits_type::string_type traits_string_type; + const ::boost::regex_traits_wrapper& traits_inst = *(e.m_ptraits); + + // dwa 9/13/00 suppress incorrect MSVC warning - it claims this is never + // referenced + (void)traits_inst; + + // try and match a single character, could be a multi-character + // collating element... + for(i = 0; i < set_->csingles; ++i) + { + ptr = next; + if(*p == static_cast(0)) + { + // treat null string as special case: + if(traits_inst.translate(*ptr, icase) != *p) + { + while(*p == static_cast(0))++p; + continue; + } + return set_->isnot ? next : (ptr == next) ? ++next : ptr; + } + else + { + while(*p && (ptr != last)) + { + if(traits_inst.translate(*ptr, icase) != *p) + break; + ++p; + ++ptr; + } + + if(*p == static_cast(0)) // if null we've matched + return set_->isnot ? next : (ptr == next) ? ++next : ptr; + + p = re_skip_past_null(p); // skip null + } + } + + charT col = traits_inst.translate(*next, icase); + + + if(set_->cranges || set_->cequivalents) + { + traits_string_type s1; + // + // try and match a range, NB only a single character can match + if(set_->cranges) + { + if((e.m_flags & regex_constants::collate) == 0) + s1.assign(1, col); + else + { + charT a[2] = { col, charT(0), }; + s1 = traits_inst.transform(a, a + 1); + } + for(i = 0; i < set_->cranges; ++i) + { + if(STR_COMP(s1, p) >= 0) + { + do{ ++p; }while(*p); + ++p; + if(STR_COMP(s1, p) <= 0) + return set_->isnot ? next : ++next; + } + else + { + // skip first string + do{ ++p; }while(*p); + ++p; + } + // skip second string + do{ ++p; }while(*p); + ++p; + } + } + // + // try and match an equivalence class, NB only a single character can match + if(set_->cequivalents) + { + charT a[2] = { col, charT(0), }; + s1 = traits_inst.transform_primary(a, a +1); + for(i = 0; i < set_->cequivalents; ++i) + { + if(STR_COMP(s1, p) == 0) + return set_->isnot ? next : ++next; + // skip string + do{ ++p; }while(*p); + ++p; + } + } + } + if(traits_inst.isctype(col, set_->cclasses) == true) + return set_->isnot ? next : ++next; + if((set_->cnclasses != 0) && (traits_inst.isctype(col, set_->cnclasses) == false)) + return set_->isnot ? next : ++next; + return set_->isnot ? ++next : next; +} + +template +class repeater_count +{ + repeater_count** stack; + repeater_count* next; + int state_id; + std::size_t count; // the number of iterations so far + BidiIterator start_pos; // where the last repeat started +public: + repeater_count(repeater_count** s) + { + stack = s; + next = 0; + state_id = -1; + count = 0; + } + repeater_count(int i, repeater_count** s, BidiIterator start) + : start_pos(start) + { + state_id = i; + stack = s; + next = *stack; + *stack = this; + if(state_id > next->state_id) + count = 0; + else + { + repeater_count* p = next; + while(p->state_id != state_id) + p = p->next; + count = p->count; + start_pos = p->start_pos; + } + } + ~repeater_count() + { + *stack = next; + } + std::size_t get_count() { return count; } + int get_id() { return state_id; } + std::size_t operator++() { return ++count; } + bool check_null_repeat(const BidiIterator& pos, std::size_t max) + { + // this is called when we are about to start a new repeat, + // if the last one was NULL move our count to max, + // otherwise save the current position. + bool result = (count == 0) ? false : (pos == start_pos); + if(result) + count = max; + else + start_pos = pos; + return result; + } +}; + +struct saved_state; + +enum saved_state_type +{ + saved_type_end = 0, + saved_type_paren = 1, + saved_type_recurse = 2, + saved_type_assertion = 3, + saved_state_alt = 4, + saved_state_repeater_count = 5, + saved_state_extra_block = 6, + saved_state_greedy_single_repeat = 7, + saved_state_rep_slow_dot = 8, + saved_state_rep_fast_dot = 9, + saved_state_rep_char = 10, + saved_state_rep_short_set = 11, + saved_state_rep_long_set = 12, + saved_state_non_greedy_long_repeat = 13, + saved_state_count = 14 +}; + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4251 4231 4660) +#endif + +template +class perl_matcher +{ +public: + typedef typename traits::char_type char_type; + typedef perl_matcher self_type; + typedef bool (self_type::*matcher_proc_type)(void); + typedef std::size_t traits_size_type; + typedef typename is_byte::width_type width_type; + typedef typename regex_iterator_traits::difference_type difference_type; + + perl_matcher(BidiIterator first, BidiIterator end, + match_results& what, + const basic_regex& e, + match_flag_type f, + BidiIterator l_base) + : m_result(what), base(first), last(end), + position(first), backstop(l_base), re(e), traits_inst(e.get_traits()), + m_independent(false), next_count(&rep_obj), rep_obj(&next_count) + { + construct_init(e, f); + } + + bool match(); + bool find(); + + void setf(match_flag_type f) + { m_match_flags |= f; } + void unsetf(match_flag_type f) + { m_match_flags &= ~f; } + +private: + void construct_init(const basic_regex& e, match_flag_type f); + + bool find_imp(); + bool match_imp(); +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD + typedef bool (perl_matcher::*protected_proc_type)(); + bool protected_call(protected_proc_type); +#endif + void estimate_max_state_count(std::random_access_iterator_tag*); + void estimate_max_state_count(void*); + bool match_prefix(); + bool match_all_states(); + + // match procs, stored in s_match_vtable: + bool match_startmark(); + bool match_endmark(); + bool match_literal(); + bool match_start_line(); + bool match_end_line(); + bool match_wild(); + bool match_match(); + bool match_word_boundary(); + bool match_within_word(); + bool match_word_start(); + bool match_word_end(); + bool match_buffer_start(); + bool match_buffer_end(); + bool match_backref(); + bool match_long_set(); + bool match_set(); + bool match_jump(); + bool match_alt(); + bool match_rep(); + bool match_combining(); + bool match_soft_buffer_end(); + bool match_restart_continue(); + bool match_long_set_repeat(); + bool match_set_repeat(); + bool match_char_repeat(); + bool match_dot_repeat_fast(); + bool match_dot_repeat_slow(); + bool match_backstep(); + bool match_assert_backref(); + bool match_toggle_case(); +#ifdef BOOST_REGEX_RECURSIVE + bool backtrack_till_match(std::size_t count); +#endif + + // find procs stored in s_find_vtable: + bool find_restart_any(); + bool find_restart_word(); + bool find_restart_line(); + bool find_restart_buf(); + bool find_restart_lit(); + +private: + // final result structure to be filled in: + match_results& m_result; + // temporary result for POSIX matches: + scoped_ptr > m_temp_match; + // pointer to actual result structure to fill in: + match_results* m_presult; + // start of sequence being searched: + BidiIterator base; + // end of sequence being searched: + BidiIterator last; + // current character being examined: + BidiIterator position; + // where to restart next search after failed match attempt: + BidiIterator restart; + // where the current search started from, acts as base for $` during grep: + BidiIterator search_base; + // how far we can go back when matching lookbehind: + BidiIterator backstop; + // the expression being examined: + const basic_regex& re; + // the expression's traits class: + const ::boost::regex_traits_wrapper& traits_inst; + // the next state in the machine being matched: + const re_syntax_base* pstate; + // matching flags in use: + match_flag_type m_match_flags; + // how many states we have examined so far: + boost::uintmax_t state_count; + // max number of states to examine before giving up: + boost::uintmax_t max_state_count; + // whether we should ignore case or not: + bool icase; + // set to true when (position == last), indicates that we may have a partial match: + bool m_has_partial_match; + // set to true whenever we get a match: + bool m_has_found_match; + // set to true whenever we're inside an independent sub-expression: + bool m_independent; + // the current repeat being examined: + repeater_count* next_count; + // the first repeat being examined (top of linked list): + repeater_count rep_obj; + // the mask to pass when matching word boundaries: + typename traits::char_class_type m_word_mask; + // the bitmask to use when determining whether a match_any matches a newline or not: + unsigned char match_any_mask; + +#ifdef BOOST_REGEX_NON_RECURSIVE + // + // additional members for non-recursive version: + // + typedef bool (self_type::*unwind_proc_type)(bool); + + void extend_stack(); + bool unwind(bool); + bool unwind_end(bool); + bool unwind_paren(bool); + bool unwind_recursion_stopper(bool); + bool unwind_assertion(bool); + bool unwind_alt(bool); + bool unwind_repeater_counter(bool); + bool unwind_extra_block(bool); + bool unwind_greedy_single_repeat(bool); + bool unwind_slow_dot_repeat(bool); + bool unwind_fast_dot_repeat(bool); + bool unwind_char_repeat(bool); + bool unwind_short_set_repeat(bool); + bool unwind_long_set_repeat(bool); + bool unwind_non_greedy_repeat(bool); + void destroy_single_repeat(); + void push_matched_paren(int index, const sub_match& sub); + void push_recursion_stopper(); + void push_assertion(const re_syntax_base* ps, bool positive); + void push_alt(const re_syntax_base* ps); + void push_repeater_count(int i, repeater_count** s); + void push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int state_id); + void push_non_greedy_repeat(const re_syntax_base* ps); + + + // pointer to base of stack: + saved_state* m_stack_base; + // pointer to current stack position: + saved_state* m_backup_state; + // determines what value to return when unwinding from recursion, + // allows for mixed recursive/non-recursive algorithm: + bool m_recursive_result; + // how many memory blocks have we used up?: + unsigned used_block_count; +#endif + + // these operations aren't allowed, so are declared private, + // bodies are provided to keep explicit-instantiation requests happy: + perl_matcher& operator=(const perl_matcher&) + { + return *this; + } + perl_matcher(const perl_matcher& that) + : m_result(that.m_result), re(that.re), traits_inst(that.traits_inst), rep_obj(0) {} +}; + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace re_detail + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +// +// include the implementation of perl_matcher: +// +#ifdef BOOST_REGEX_RECURSIVE +#include +#else +#include +#endif +// this one has to be last: +#include + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_common.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_common.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,971 @@ +/* + * + * Copyright (c) 2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE perl_matcher_common.cpp + * VERSION see + * DESCRIPTION: Definitions of perl_matcher member functions that are + * common to both the recursive and non-recursive versions. + */ + +#ifndef BOOST_REGEX_V4_PERL_MATCHER_COMMON_HPP +#define BOOST_REGEX_V4_PERL_MATCHER_COMMON_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef __BORLANDC__ +# pragma option push -w-8008 -w-8066 +#endif +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace boost{ +namespace re_detail{ + +template +void perl_matcher::construct_init(const basic_regex& e, match_flag_type f) +{ + typedef typename regex_iterator_traits::iterator_category category; + typedef typename basic_regex::flag_type expression_flag_type; + + if(e.empty()) + { + // precondition failure: e is not a valid regex. + std::invalid_argument ex("Invalid regular expression object"); + boost::throw_exception(ex); + } + pstate = 0; + m_match_flags = f; + estimate_max_state_count(static_cast(0)); + expression_flag_type re_f = re.flags(); + icase = re_f & regex_constants::icase; + if(!(m_match_flags & (match_perl|match_posix))) + { + if((re_f & (regbase::main_option_type|regbase::no_perl_ex)) == 0) + m_match_flags |= match_perl; + else if((re_f & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) + m_match_flags |= match_perl; + else + m_match_flags |= match_posix; + } + if(m_match_flags & match_posix) + { + m_temp_match.reset(new match_results()); + m_presult = m_temp_match.get(); + } + else + m_presult = &m_result; +#ifdef BOOST_REGEX_NON_RECURSIVE + m_stack_base = 0; + m_backup_state = 0; +#endif + // find the value to use for matching word boundaries: + m_word_mask = re.get_data().m_word_mask; + // find bitmask to use for matching '.': + match_any_mask = static_cast((f & match_not_dot_newline) ? re_detail::test_not_newline : re_detail::test_newline); +} + +template +void perl_matcher::estimate_max_state_count(std::random_access_iterator_tag*) +{ + // + // How many states should we allow our machine to visit before giving up? + // This is a heuristic: it takes the greater of O(N^2) and O(NS^2) + // where N is the length of the string, and S is the number of states + // in the machine. It's tempting to up this to O(N^2S) or even O(N^2S^2) + // but these take unreasonably amounts of time to bale out in pathological + // cases. + // + // Calculate NS^2 first: + // + static const boost::uintmax_t k = 100000; + boost::uintmax_t dist = boost::re_detail::distance(base, last); + if(dist == 0) + dist = 1; + boost::uintmax_t states = re.size(); + if(states == 0) + states = 1; + states *= states; + if((std::numeric_limits::max)() / dist < states) + { + max_state_count = (std::numeric_limits::max)() - 2; + return; + } + states *= dist; + if((std::numeric_limits::max)() - k < states) + { + max_state_count = (std::numeric_limits::max)() - 2; + return; + } + states += k; + + max_state_count = states; + + // + // Now calculate N^2: + // + states = dist; + if((std::numeric_limits::max)() / dist < states) + { + max_state_count = (std::numeric_limits::max)() - 2; + return; + } + states *= dist; + if((std::numeric_limits::max)() - k < states) + { + max_state_count = (std::numeric_limits::max)() - 2; + return; + } + states += k; + // + // N^2 can be a very large number indeed, to prevent things getting out + // of control, cap the max states: + // + if(states > BOOST_REGEX_MAX_STATE_COUNT) + states = BOOST_REGEX_MAX_STATE_COUNT; + // + // If (the possibly capped) N^2 is larger than our first estimate, + // use this instead: + // + if(states > max_state_count) + max_state_count = states; +} + +template +inline void perl_matcher::estimate_max_state_count(void*) +{ + // we don't know how long the sequence is: + max_state_count = BOOST_REGEX_MAX_STATE_COUNT; +} + +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD +template +inline bool perl_matcher::protected_call( + protected_proc_type proc) +{ + ::boost::re_detail::concrete_protected_call + > + obj(this, proc); + return obj.execute(); + +} +#endif + +template +inline bool perl_matcher::match() +{ +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD + return protected_call(&perl_matcher::match_imp); +#else + return match_imp(); +#endif +} + +template +bool perl_matcher::match_imp() +{ + // initialise our stack if we are non-recursive: +#ifdef BOOST_REGEX_NON_RECURSIVE + save_state_init init(&m_stack_base, &m_backup_state); + used_block_count = BOOST_REGEX_MAX_BLOCKS; +#if !defined(BOOST_NO_EXCEPTIONS) + try{ +#endif +#endif + + // reset our state machine: + position = base; + search_base = base; + state_count = 0; + m_match_flags |= regex_constants::match_all; + m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last); + m_presult->set_base(base); + if(m_match_flags & match_posix) + m_result = *m_presult; + verify_options(re.flags(), m_match_flags); + if(0 == match_prefix()) + return false; + return m_result[0].second == last; + +#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_NO_EXCEPTIONS) + } + catch(...) + { + // unwind all pushed states, apart from anything else this + // ensures that all the states are correctly destructed + // not just the memory freed. + while(unwind(true)){} + throw; + } +#endif +} + +template +inline bool perl_matcher::find() +{ +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD + return protected_call(&perl_matcher::find_imp); +#else + return find_imp(); +#endif +} + +template +bool perl_matcher::find_imp() +{ + static matcher_proc_type const s_find_vtable[7] = + { + &perl_matcher::find_restart_any, + &perl_matcher::find_restart_word, + &perl_matcher::find_restart_line, + &perl_matcher::find_restart_buf, + &perl_matcher::match_prefix, + &perl_matcher::find_restart_lit, + &perl_matcher::find_restart_lit, + }; + + // initialise our stack if we are non-recursive: +#ifdef BOOST_REGEX_NON_RECURSIVE + save_state_init init(&m_stack_base, &m_backup_state); + used_block_count = BOOST_REGEX_MAX_BLOCKS; +#if !defined(BOOST_NO_EXCEPTIONS) + try{ +#endif +#endif + + state_count = 0; + if((m_match_flags & regex_constants::match_init) == 0) + { + // reset our state machine: + search_base = position = base; + pstate = re.get_first_state(); + m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last); + m_presult->set_base(base); + m_match_flags |= regex_constants::match_init; + } + else + { + // start again: + search_base = position = m_result[0].second; + // If last match was null and match_not_null was not set then increment + // our start position, otherwise we go into an infinite loop: + if(((m_match_flags & match_not_null) == 0) && (m_result.length() == 0)) + { + if(position == last) + return false; + else + ++position; + } + // reset $` start: + m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last); + //if((base != search_base) && (base == backstop)) + // m_match_flags |= match_prev_avail; + } + if(m_match_flags & match_posix) + { + m_result.set_size(re.mark_count(), base, last); + m_result.set_base(base); + } + + verify_options(re.flags(), m_match_flags); + // find out what kind of expression we have: + unsigned type = (m_match_flags & match_continuous) ? + static_cast(regbase::restart_continue) + : static_cast(re.get_restart_type()); + + // call the appropriate search routine: + matcher_proc_type proc = s_find_vtable[type]; + return (this->*proc)(); + +#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_NO_EXCEPTIONS) + } + catch(...) + { + // unwind all pushed states, apart from anything else this + // ensures that all the states are correctly destructed + // not just the memory freed. + while(unwind(true)){} + throw; + } +#endif +} + +template +bool perl_matcher::match_prefix() +{ + m_has_partial_match = false; + m_has_found_match = false; + pstate = re.get_first_state(); + m_presult->set_first(position); + restart = position; + match_all_states(); + if(!m_has_found_match && m_has_partial_match && (m_match_flags & match_partial)) + { + m_has_found_match = true; + m_presult->set_second(last, 0, false); + position = last; + } +#ifdef BOOST_REGEX_MATCH_EXTRA + if(m_has_found_match && (match_extra & m_match_flags)) + { + // + // we have a match, reverse the capture information: + // + for(unsigned i = 0; i < m_presult->size(); ++i) + { + typename sub_match::capture_sequence_type & seq = ((*m_presult)[i]).get_captures(); + std::reverse(seq.begin(), seq.end()); + } + } +#endif + if(!m_has_found_match) + position = restart; // reset search postion + return m_has_found_match; +} + +template +bool perl_matcher::match_endmark() +{ + int index = static_cast(pstate)->index; + if(index > 0) + { + if((m_match_flags & match_nosubs) == 0) + m_presult->set_second(position, index); + } + else if((index < 0) && (index != -4)) + { + // matched forward lookahead: + pstate = 0; + return true; + } + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_literal() +{ + unsigned int len = static_cast(pstate)->length; + const char_type* what = reinterpret_cast(static_cast(pstate) + 1); + // + // compare string with what we stored in + // our records: + for(unsigned int i = 0; i < len; ++i, ++position) + { + if((position == last) || (traits_inst.translate(*position, icase) != what[i])) + return false; + } + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_start_line() +{ + if(position == backstop) + { + if((m_match_flags & match_prev_avail) == 0) + { + if((m_match_flags & match_not_bol) == 0) + { + pstate = pstate->next.p; + return true; + } + return false; + } + } + else if(m_match_flags & match_single_line) + return false; + + // check the previous value character: + BidiIterator t(position); + --t; + if(position != last) + { + if(is_separator(*t) && !((*t == static_cast('\r')) && (*position == static_cast('\n'))) ) + { + pstate = pstate->next.p; + return true; + } + } + else if(is_separator(*t)) + { + pstate = pstate->next.p; + return true; + } + return false; +} + +template +bool perl_matcher::match_end_line() +{ + if(position != last) + { + if(m_match_flags & match_single_line) + return false; + // we're not yet at the end so *first is always valid: + if(is_separator(*position)) + { + if((position != backstop) || (m_match_flags & match_prev_avail)) + { + // check that we're not in the middle of \r\n sequence + BidiIterator t(position); + --t; + if((*t == static_cast('\r')) && (*position == static_cast('\n'))) + { + return false; + } + } + pstate = pstate->next.p; + return true; + } + } + else if((m_match_flags & match_not_eol) == 0) + { + pstate = pstate->next.p; + return true; + } + return false; +} + +template +bool perl_matcher::match_wild() +{ + if(position == last) + return false; + if(is_separator(*position) && ((match_any_mask & static_cast(pstate)->mask) == 0)) + return false; + if((*position == char_type(0)) && (m_match_flags & match_not_dot_null)) + return false; + pstate = pstate->next.p; + ++position; + return true; +} + +template +bool perl_matcher::match_match() +{ + if((m_match_flags & match_not_null) && (position == (*m_presult)[0].first)) + return false; + if((m_match_flags & match_all) && (position != last)) + return false; + if((m_match_flags & regex_constants::match_not_initial_null) && (position == search_base)) + return false; + m_presult->set_second(position); + pstate = 0; + m_has_found_match = true; + if((m_match_flags & match_posix) == match_posix) + { + m_result.maybe_assign(*m_presult); + if((m_match_flags & match_any) == 0) + return false; + } +#ifdef BOOST_REGEX_MATCH_EXTRA + if(match_extra & m_match_flags) + { + for(unsigned i = 0; i < m_presult->size(); ++i) + if((*m_presult)[i].matched) + ((*m_presult)[i]).get_captures().push_back((*m_presult)[i]); + } +#endif + return true; +} + +template +bool perl_matcher::match_word_boundary() +{ + bool b; // indcates whether next character is a word character + if(position != last) + { + // prev and this character must be opposites: + #if defined(BOOST_REGEX_USE_C_LOCALE) && defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) + b = traits::isctype(*position, m_word_mask); + #else + b = traits_inst.isctype(*position, m_word_mask); + #endif + } + else + { + b = (m_match_flags & match_not_eow) ? true : false; + } + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) + { + if(m_match_flags & match_not_bow) + b ^= true; + else + b ^= false; + } + else + { + --position; + b ^= traits_inst.isctype(*position, m_word_mask); + ++position; + } + if(b) + { + pstate = pstate->next.p; + return true; + } + return false; // no match if we get to here... +} + +template +bool perl_matcher::match_within_word() +{ + if(position == last) + return false; + // both prev and this character must be m_word_mask: + bool prev = traits_inst.isctype(*position, m_word_mask); + { + bool b; + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) + return false; + else + { + --position; + b = traits_inst.isctype(*position, m_word_mask); + ++position; + } + if(b == prev) + { + pstate = pstate->next.p; + return true; + } + } + return false; +} + +template +bool perl_matcher::match_word_start() +{ + if(position == last) + return false; // can't be starting a word if we're already at the end of input + if(!traits_inst.isctype(*position, m_word_mask)) + return false; // next character isn't a word character + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) + { + if(m_match_flags & match_not_bow) + return false; // no previous input + } + else + { + // otherwise inside buffer: + BidiIterator t(position); + --t; + if(traits_inst.isctype(*t, m_word_mask)) + return false; // previous character not non-word + } + // OK we have a match: + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_word_end() +{ + if((position == backstop) && ((m_match_flags & match_prev_avail) == 0)) + return false; // start of buffer can't be end of word + BidiIterator t(position); + --t; + if(traits_inst.isctype(*t, m_word_mask) == false) + return false; // previous character wasn't a word character + + if(position == last) + { + if(m_match_flags & match_not_eow) + return false; // end of buffer but not end of word + } + else + { + // otherwise inside buffer: + if(traits_inst.isctype(*position, m_word_mask)) + return false; // next character is a word character + } + pstate = pstate->next.p; + return true; // if we fall through to here then we've succeeded +} + +template +bool perl_matcher::match_buffer_start() +{ + if((position != backstop) || (m_match_flags & match_not_bob)) + return false; + // OK match: + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_buffer_end() +{ + if((position != last) || (m_match_flags & match_not_eob)) + return false; + // OK match: + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_backref() +{ + // + // Compare with what we previously matched. + // Note that this succeeds if the backref did not partisipate + // in the match, this is in line with ECMAScript, but not Perl + // or PCRE. + // + BidiIterator i = (*m_presult)[static_cast(pstate)->index].first; + BidiIterator j = (*m_presult)[static_cast(pstate)->index].second; + while(i != j) + { + if((position == last) || (traits_inst.translate(*position, icase) != traits_inst.translate(*i, icase))) + return false; + ++i; + ++position; + } + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_long_set() +{ + typedef typename traits::char_class_type char_class_type; + // let the traits class do the work: + if(position == last) + return false; + BidiIterator t = re_is_set_member(position, last, static_cast*>(pstate), re.get_data(), icase); + if(t != position) + { + pstate = pstate->next.p; + position = t; + return true; + } + return false; +} + +template +bool perl_matcher::match_set() +{ + if(position == last) + return false; + if(static_cast(pstate)->_map[static_cast(traits_inst.translate(*position, icase))]) + { + pstate = pstate->next.p; + ++position; + return true; + } + return false; +} + +template +bool perl_matcher::match_jump() +{ + pstate = static_cast(pstate)->alt.p; + return true; +} + +template +bool perl_matcher::match_combining() +{ + if(position == last) + return false; + if(is_combining(traits_inst.translate(*position, icase))) + return false; + ++position; + while((position != last) && is_combining(traits_inst.translate(*position, icase))) + ++position; + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_soft_buffer_end() +{ + if(m_match_flags & match_not_eob) + return false; + BidiIterator p(position); + while((p != last) && is_separator(traits_inst.translate(*p, icase)))++p; + if(p != last) + return false; + pstate = pstate->next.p; + return true; +} + +template +bool perl_matcher::match_restart_continue() +{ + if(position == search_base) + { + pstate = pstate->next.p; + return true; + } + return false; +} + +template +bool perl_matcher::match_backstep() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + if( ::boost::is_random_access_iterator::value) + { + std::ptrdiff_t maxlen = ::boost::re_detail::distance(backstop, position); + if(maxlen < static_cast(pstate)->index) + return false; + std::advance(position, -static_cast(pstate)->index); + } + else + { + int c = static_cast(pstate)->index; + while(c--) + { + if(position == backstop) + return false; + --position; + } + } + pstate = pstate->next.p; + return true; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +inline bool perl_matcher::match_assert_backref() +{ + // return true if marked sub-expression N has been matched: + bool result = (*m_presult)[static_cast(pstate)->index].matched; + pstate = pstate->next.p; + return result; +} + +template +bool perl_matcher::match_toggle_case() +{ + // change our case sensitivity: + this->icase = static_cast(pstate)->icase; + pstate = pstate->next.p; + return true; +} + + +template +bool perl_matcher::find_restart_any() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + const unsigned char* _map = re.get_map(); + while(true) + { + // skip everything we can't match: + while((position != last) && !can_start(*position, _map, (unsigned char)mask_any) ) + ++position; + if(position == last) + { + // run out of characters, try a null match if possible: + if(re.can_be_null()) + return match_prefix(); + break; + } + // now try and obtain a match: + if(match_prefix()) + return true; + if(position == last) + return false; + ++position; + } + return false; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::find_restart_word() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + // do search optimised for word starts: + const unsigned char* _map = re.get_map(); + if((m_match_flags & match_prev_avail) || (position != base)) + --position; + else if(match_prefix()) + return true; + do + { + while((position != last) && traits_inst.isctype(*position, m_word_mask)) + ++position; + while((position != last) && !traits_inst.isctype(*position, m_word_mask)) + ++position; + if(position == last) + break; + + if(can_start(*position, _map, (unsigned char)mask_any) ) + { + if(match_prefix()) + return true; + } + if(position == last) + break; + } while(true); + return false; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::find_restart_line() +{ + // do search optimised for line starts: + const unsigned char* _map = re.get_map(); + if(match_prefix()) + return true; + while(position != last) + { + while((position != last) && !is_separator(*position)) + ++position; + if(position == last) + return false; + ++position; + if(position == last) + { + if(re.can_be_null() && match_prefix()) + return true; + return false; + } + + if( can_start(*position, _map, (unsigned char)mask_any) ) + { + if(match_prefix()) + return true; + } + if(position == last) + return false; + //++position; + } + return false; +} + +template +bool perl_matcher::find_restart_buf() +{ + if((position == base) && ((m_match_flags & match_not_bob) == 0)) + return match_prefix(); + return false; +} + +template +bool perl_matcher::find_restart_lit() +{ +#if 0 + if(position == last) + return false; // can't possibly match if we're at the end already + + unsigned type = (m_match_flags & match_continuous) ? + static_cast(regbase::restart_continue) + : static_cast(re.get_restart_type()); + + const kmp_info* info = access::get_kmp(re); + int len = info->len; + const char_type* x = info->pstr; + int j = 0; + while (position != last) + { + while((j > -1) && (x[j] != traits_inst.translate(*position, icase))) + j = info->kmp_next[j]; + ++position; + ++j; + if(j >= len) + { + if(type == regbase::restart_fixed_lit) + { + std::advance(position, -j); + restart = position; + std::advance(restart, len); + m_result.set_first(position); + m_result.set_second(restart); + position = restart; + return true; + } + else + { + restart = position; + std::advance(position, -j); + if(match_prefix()) + return true; + else + { + for(int k = 0; (restart != position) && (k < j); ++k, --restart) + {} // dwa 10/20/2000 - warning suppression for MWCW + if(restart != last) + ++restart; + position = restart; + j = 0; //we could do better than this... + } + } + } + } + if((m_match_flags & match_partial) && (position == last) && j) + { + // we need to check for a partial match: + restart = position; + std::advance(position, -j); + return match_prefix(); + } +#endif + return false; +} + +} // namespace re_detail + +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#ifdef __BORLANDC__ +# pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_non_recursive.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_non_recursive.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,1400 @@ +/* + * + * Copyright (c) 2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE perl_matcher_common.cpp + * VERSION see + * DESCRIPTION: Definitions of perl_matcher member functions that are + * specific to the non-recursive implementation. + */ + +#ifndef BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP +#define BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP + +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace boost{ +namespace re_detail{ + +template +inline void inplace_destroy(T* p) +{ + (void)p; // warning suppression + p->~T(); +} + +struct saved_state +{ + union{ + unsigned int state_id; + // this padding ensures correct alignment on 64-bit platforms: + std::size_t padding1; + std::ptrdiff_t padding2; + void* padding3; + }; + saved_state(unsigned i) : state_id(i) {} +}; + +template +struct saved_matched_paren : public saved_state +{ + int index; + sub_match sub; + saved_matched_paren(int i, const sub_match& s) : saved_state(1), index(i), sub(s){}; +}; + +template +struct saved_position : public saved_state +{ + const re_syntax_base* pstate; + BidiIterator position; + saved_position(const re_syntax_base* ps, BidiIterator pos, int i) : saved_state(i), pstate(ps), position(pos){}; +}; + +template +struct saved_assertion : public saved_position +{ + bool positive; + saved_assertion(bool p, const re_syntax_base* ps, BidiIterator pos) + : saved_position(ps, pos, saved_type_assertion), positive(p){}; +}; + +template +struct saved_repeater : public saved_state +{ + repeater_count count; + saved_repeater(int i, repeater_count** s, BidiIterator start) + : saved_state(saved_state_repeater_count), count(i,s,start){} +}; + +struct saved_extra_block : public saved_state +{ + saved_state *base, *end; + saved_extra_block(saved_state* b, saved_state* e) + : saved_state(saved_state_extra_block), base(b), end(e) {} +}; + +struct save_state_init +{ + saved_state** stack; + save_state_init(saved_state** base, saved_state** end) + : stack(base) + { + *base = static_cast(get_mem_block()); + *end = reinterpret_cast(reinterpret_cast(*base)+BOOST_REGEX_BLOCKSIZE); + --(*end); + (void) new (*end)saved_state(0); + BOOST_ASSERT(*end > *base); + } + ~save_state_init() + { + put_mem_block(*stack); + *stack = 0; + } +}; + +template +struct saved_single_repeat : public saved_state +{ + std::size_t count; + const re_repeat* rep; + BidiIterator last_position; + saved_single_repeat(std::size_t c, const re_repeat* r, BidiIterator lp, int arg_id) + : saved_state(arg_id), count(c), rep(r), last_position(lp){} +}; + +template +bool perl_matcher::match_all_states() +{ + static matcher_proc_type const s_match_vtable[29] = + { + (&perl_matcher::match_startmark), + &perl_matcher::match_endmark, + &perl_matcher::match_literal, + &perl_matcher::match_start_line, + &perl_matcher::match_end_line, + &perl_matcher::match_wild, + &perl_matcher::match_match, + &perl_matcher::match_word_boundary, + &perl_matcher::match_within_word, + &perl_matcher::match_word_start, + &perl_matcher::match_word_end, + &perl_matcher::match_buffer_start, + &perl_matcher::match_buffer_end, + &perl_matcher::match_backref, + &perl_matcher::match_long_set, + &perl_matcher::match_set, + &perl_matcher::match_jump, + &perl_matcher::match_alt, + &perl_matcher::match_rep, + &perl_matcher::match_combining, + &perl_matcher::match_soft_buffer_end, + &perl_matcher::match_restart_continue, + (::boost::is_random_access_iterator::value ? &perl_matcher::match_dot_repeat_fast : &perl_matcher::match_dot_repeat_slow), + &perl_matcher::match_char_repeat, + &perl_matcher::match_set_repeat, + &perl_matcher::match_long_set_repeat, + &perl_matcher::match_backstep, + &perl_matcher::match_assert_backref, + &perl_matcher::match_toggle_case, + }; + + push_recursion_stopper(); + do{ + while(pstate) + { + matcher_proc_type proc = s_match_vtable[pstate->type]; + ++state_count; + if(!(this->*proc)()) + { + if(state_count > max_state_count) + raise_error(traits_inst, regex_constants::error_space); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + bool successful_unwind = unwind(false); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(false == successful_unwind) + return m_recursive_result; + } + } + }while(unwind(true)); + return m_recursive_result; +} + +template +void perl_matcher::extend_stack() +{ + if(used_block_count) + { + --used_block_count; + saved_state* stack_base; + saved_state* backup_state; + stack_base = static_cast(get_mem_block()); + backup_state = reinterpret_cast(reinterpret_cast(stack_base)+BOOST_REGEX_BLOCKSIZE); + saved_extra_block* block = static_cast(backup_state); + --block; + (void) new (block) saved_extra_block(m_stack_base, m_backup_state); + m_stack_base = stack_base; + m_backup_state = block; + } + else + raise_error(traits_inst, regex_constants::error_size); +} + +template +inline void perl_matcher::push_matched_paren(int index, const sub_match& sub) +{ + BOOST_ASSERT(index); + saved_matched_paren* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_matched_paren(index, sub); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_recursion_stopper() +{ + saved_state* pmp = m_backup_state; + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = m_backup_state; + --pmp; + } + (void) new (pmp)saved_state(saved_type_recurse); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_assertion(const re_syntax_base* ps, bool positive) +{ + saved_assertion* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_assertion(positive, ps, position); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_alt(const re_syntax_base* ps) +{ + saved_position* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_position(ps, position, saved_state_alt); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_non_greedy_repeat(const re_syntax_base* ps) +{ + saved_position* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_position(ps, position, saved_state_non_greedy_long_repeat); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_repeater_count(int i, repeater_count** s) +{ + saved_repeater* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_repeater(i, s, position); + m_backup_state = pmp; +} + +template +inline void perl_matcher::push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int state_id) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + --pmp; + if(pmp < m_stack_base) + { + extend_stack(); + pmp = static_cast*>(m_backup_state); + --pmp; + } + (void) new (pmp)saved_single_repeat(c, r, last_position, state_id); + m_backup_state = pmp; +} + +template +bool perl_matcher::match_startmark() +{ + int index = static_cast(pstate)->index; + switch(index) + { + case 0: + pstate = pstate->next.p; + break; + case -1: + case -2: + { + // forward lookahead assert: + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + push_assertion(next_pstate, index == -1); + break; + } + case -3: + { + // independent sub-expression, currently this is always recursive: + bool old_independent = m_independent; + m_independent = true; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + bool r = match_all_states(); + pstate = next_pstate; + m_independent = old_independent; +#ifdef BOOST_REGEX_MATCH_EXTRA + if(r && (m_match_flags & match_extra)) + { + // + // our captures have been stored in *m_presult + // we need to unpack them, and insert them + // back in the right order when we unwind the stack: + // + match_results temp_match(*m_presult); + unsigned i; + for(i = 0; i < temp_match.size(); ++i) + (*m_presult)[i].get_captures().clear(); + // match everything else: + r = match_all_states(); + // now place the stored captures back: + for(i = 0; i < temp_match.size(); ++i) + { + typedef typename sub_match::capture_sequence_type seq; + seq& s1 = (*m_presult)[i].get_captures(); + const seq& s2 = temp_match[i].captures(); + s1.insert( + s1.end(), + s2.begin(), + s2.end()); + } + } +#endif + return r; + } + case -4: + { + // conditional expression: + const re_alt* alt = static_cast(pstate->next.p); + BOOST_ASSERT(alt->type == syntax_element_alt); + pstate = alt->next.p; + if(pstate->type == syntax_element_assert_backref) + { + if(!match_assert_backref()) + pstate = alt->alt.p; + break; + } + else + { + // zero width assertion, have to match this recursively: + BOOST_ASSERT(pstate->type == syntax_element_startmark); + bool negated = static_cast(pstate)->index == -2; + BidiIterator saved_position = position; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + bool r = match_all_states(); + position = saved_position; + if(negated) + r = !r; + if(r) + pstate = next_pstate; + else + pstate = alt->alt.p; + break; + } + } + default: + { + BOOST_ASSERT(index > 0); + if((m_match_flags & match_nosubs) == 0) + { + push_matched_paren(index, (*m_presult)[index]); + m_presult->set_first(position, index); + } + pstate = pstate->next.p; + break; + } + } + return true; +} + +template +bool perl_matcher::match_alt() +{ + bool take_first, take_second; + const re_alt* jmp = static_cast(pstate); + + // find out which of these two alternatives we need to take: + if(position == last) + { + take_first = jmp->can_be_null & mask_take; + take_second = jmp->can_be_null & mask_skip; + } + else + { + take_first = can_start(*position, jmp->_map, (unsigned char)mask_take); + take_second = can_start(*position, jmp->_map, (unsigned char)mask_skip); + } + + if(take_first) + { + // we can take the first alternative, + // see if we need to push next alternative: + if(take_second) + { + push_alt(jmp->alt.p); + } + pstate = pstate->next.p; + return true; + } + if(take_second) + { + pstate = jmp->alt.p; + return true; + } + return false; // neither option is possible +} + +template +bool perl_matcher::match_rep() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127 4244) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + + // find out which of these two alternatives we need to take: + bool take_first, take_second; + if(position == last) + { + take_first = rep->can_be_null & mask_take; + take_second = rep->can_be_null & mask_skip; + } + else + { + take_first = can_start(*position, rep->_map, (unsigned char)mask_take); + take_second = can_start(*position, rep->_map, (unsigned char)mask_skip); + } + + if((m_backup_state->state_id != saved_state_repeater_count) + || (static_cast*>(m_backup_state)->count.get_id() != rep->state_id) + || (next_count->get_id() != rep->state_id)) + { + // we're moving to a different repeat from the last + // one, so set up a counter object: + push_repeater_count(rep->state_id, &next_count); + } + // + // If we've had at least one repeat already, and the last one + // matched the NULL string then set the repeat count to + // maximum: + // + next_count->check_null_repeat(position, rep->max); + + if(next_count->get_count() < rep->min) + { + // we must take the repeat: + if(take_first) + { + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return true; + } + return false; + } + + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) + { + // try and take the repeat if we can: + if((next_count->get_count() < rep->max) && take_first) + { + if(take_second) + { + // store position in case we fail: + push_alt(rep->alt.p); + } + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return true; + } + else if(take_second) + { + pstate = rep->alt.p; + return true; + } + return false; // can't take anything, fail... + } + else // non-greedy + { + // try and skip the repeat if we can: + if(take_second) + { + if((next_count->get_count() < rep->max) && take_first) + { + // store position in case we fail: + push_non_greedy_repeat(rep->next.p); + } + pstate = rep->alt.p; + return true; + } + if((next_count->get_count() < rep->max) && take_first) + { + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return true; + } + } + return false; +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_dot_repeat_slow() +{ + unsigned count = 0; + const re_repeat* rep = static_cast(pstate); + re_syntax_base* psingle = rep->next.p; + // match compulsary repeats first: + while(count < rep->min) + { + pstate = psingle; + if(!match_wild()) + return false; + ++count; + } + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) + { + // repeat for as long as we can: + while(count < rep->max) + { + pstate = psingle; + if(!match_wild()) + break; + ++count; + } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_slow_dot); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +} + +template +bool perl_matcher::match_dot_repeat_fast() +{ + if(m_match_flags & match_not_dot_null) + return match_dot_repeat_slow(); + if((static_cast(pstate->next.p)->mask & match_any_mask) == 0) + return match_dot_repeat_slow(); + + const re_repeat* rep = static_cast(pstate); + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + unsigned count = static_cast((std::min)(static_cast(::boost::re_detail::distance(position, last)), static_cast(greedy ? rep->max : rep->min))); + if(rep->min > count) + { + position = last; + return false; // not enough text left to match + } + std::advance(position, count); + + if(greedy) + { + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_fast_dot); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +} + +template +bool perl_matcher::match_char_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + BOOST_ASSERT(1 == static_cast(rep->next.p)->length); + const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); + std::size_t count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && (traits_inst.translate(*position, icase) == what)) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && (traits_inst.translate(*position, icase) == what)) + { + ++position; + ++count; + } + } + + if(count < rep->min) + return false; + + if(greedy) + { + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_char); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_set_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + const unsigned char* map = static_cast(rep->next.p)->_map; + std::size_t count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + ++count; + } + } + + if(count < rep->min) + return false; + + if(greedy) + { + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_short_set); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_long_set_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + typedef typename traits::char_class_type mask_type; + const re_repeat* rep = static_cast(pstate); + const re_set_long* set = static_cast*>(pstate->next.p); + std::size_t count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) + { + ++position; + ++count; + } + } + + if(count < rep->min) + return false; + + if(greedy) + { + if((rep->leading) && (count < rep->max)) + restart = position; + // push backtrack info if available: + if(count - rep->min) + push_single_repeat(count, rep, position, saved_state_greedy_single_repeat); + // jump to next state: + pstate = rep->alt.p; + return true; + } + else + { + // non-greedy, push state and return true if we can skip: + if(count < rep->max) + push_single_repeat(count, rep, position, saved_state_rep_long_set); + pstate = rep->alt.p; + return (position == last) ? (rep->can_be_null & mask_skip) : can_start(*position, rep->_map, mask_skip); + } +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +/**************************************************************************** + +Unwind and associated proceedures follow, these perform what normal stack +unwinding does in the recursive implementation. + +****************************************************************************/ + +template +bool perl_matcher::unwind(bool have_match) +{ + static unwind_proc_type const s_unwind_table[14] = + { + &perl_matcher::unwind_end, + &perl_matcher::unwind_paren, + &perl_matcher::unwind_recursion_stopper, + &perl_matcher::unwind_assertion, + &perl_matcher::unwind_alt, + &perl_matcher::unwind_repeater_counter, + &perl_matcher::unwind_extra_block, + &perl_matcher::unwind_greedy_single_repeat, + &perl_matcher::unwind_slow_dot_repeat, + &perl_matcher::unwind_fast_dot_repeat, + &perl_matcher::unwind_char_repeat, + &perl_matcher::unwind_short_set_repeat, + &perl_matcher::unwind_long_set_repeat, + &perl_matcher::unwind_non_greedy_repeat, + }; + + m_recursive_result = have_match; + unwind_proc_type unwinder; + bool cont; + // + // keep unwinding our stack until we have something to do: + // + do + { + unwinder = s_unwind_table[m_backup_state->state_id]; + cont = (this->*unwinder)(m_recursive_result); + }while(cont); + // + // return true if we have more states to try: + // + return pstate ? true : false; +} + +template +bool perl_matcher::unwind_end(bool) +{ + pstate = 0; // nothing left to search + return false; // end of stack nothing more to search +} + +template +bool perl_matcher::unwind_paren(bool have_match) +{ + saved_matched_paren* pmp = static_cast*>(m_backup_state); + // restore previous values if no match was found: + if(have_match == false) + { + m_presult->set_first(pmp->sub.first, pmp->index); + m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched); + } +#ifdef BOOST_REGEX_MATCH_EXTRA + // + // we have a match, push the capture information onto the stack: + // + else if(pmp->sub.matched && (match_extra & m_match_flags)) + ((*m_presult)[pmp->index]).get_captures().push_back(pmp->sub); +#endif + // unwind stack: + m_backup_state = pmp+1; + boost::re_detail::inplace_destroy(pmp); + return true; // keep looking +} + +template +bool perl_matcher::unwind_recursion_stopper(bool) +{ + boost::re_detail::inplace_destroy(m_backup_state++); + pstate = 0; // nothing left to search + return false; // end of stack nothing more to search +} + +template +bool perl_matcher::unwind_assertion(bool r) +{ + saved_assertion* pmp = static_cast*>(m_backup_state); + pstate = pmp->pstate; + position = pmp->position; + bool result = (r == pmp->positive); + m_recursive_result = pmp->positive ? r : !r; + boost::re_detail::inplace_destroy(pmp++); + m_backup_state = pmp; + return !result; // return false if the assertion was matched to stop search. +} + +template +bool perl_matcher::unwind_alt(bool r) +{ + saved_position* pmp = static_cast*>(m_backup_state); + if(!r) + { + pstate = pmp->pstate; + position = pmp->position; + } + boost::re_detail::inplace_destroy(pmp++); + m_backup_state = pmp; + return r; +} + +template +bool perl_matcher::unwind_repeater_counter(bool) +{ + saved_repeater* pmp = static_cast*>(m_backup_state); + boost::re_detail::inplace_destroy(pmp++); + m_backup_state = pmp; + return true; // keep looking +} + +template +bool perl_matcher::unwind_extra_block(bool) +{ + saved_extra_block* pmp = static_cast(m_backup_state); + void* condemmed = m_stack_base; + m_stack_base = pmp->base; + m_backup_state = pmp->end; + boost::re_detail::inplace_destroy(pmp); + put_mem_block(condemmed); + return true; // keep looking +} + +template +inline void perl_matcher::destroy_single_repeat() +{ + saved_single_repeat* p = static_cast*>(m_backup_state); + boost::re_detail::inplace_destroy(p++); + m_backup_state = p; +} + +template +bool perl_matcher::unwind_greedy_single_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + + count -= rep->min; + + if((m_match_flags & match_partial) && (position == last)) + m_has_partial_match = true; + + BOOST_ASSERT(count); + position = pmp->last_position; + + // backtrack till we can skip out: + do + { + --position; + --count; + ++state_count; + }while(count && !can_start(*position, rep->_map, mask_skip)); + + // if we've hit base, destroy this state: + if(count == 0) + { + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count + rep->min; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_slow_dot_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + BOOST_ASSERT(rep->type == syntax_element_dot_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_wild); + + BOOST_ASSERT(count < rep->max); + pstate = rep->next.p; + position = pmp->last_position; + + if(position != last) + { + // wind forward until we can skip out of the repeat: + do + { + if(!match_wild()) + { + // failed repeat match, discard this state and look for another: + destroy_single_repeat(); + return true; + } + ++count; + ++state_count; + pstate = rep->next.p; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_fast_dot_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + + BOOST_ASSERT(count < rep->max); + position = pmp->last_position; + if(position != last) + { + + // wind forward until we can skip out of the repeat: + do + { + ++position; + ++count; + ++state_count; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_char_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + pstate = rep->next.p; + const char_type what = *reinterpret_cast(static_cast(pstate) + 1); + position = pmp->last_position; + + BOOST_ASSERT(rep->type == syntax_element_char_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_literal); + BOOST_ASSERT(count < rep->max); + + if(position != last) + { + // wind forward until we can skip out of the repeat: + do + { + if(traits_inst.translate(*position, icase) != what) + { + // failed repeat match, discard this state and look for another: + destroy_single_repeat(); + return true; + } + ++count; + ++ position; + ++state_count; + pstate = rep->next.p; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_short_set_repeat(bool r) +{ + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + pstate = rep->next.p; + const unsigned char* map = static_cast(rep->next.p)->_map; + position = pmp->last_position; + + BOOST_ASSERT(rep->type == syntax_element_short_set_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_set); + BOOST_ASSERT(count < rep->max); + + if(position != last) + { + // wind forward until we can skip out of the repeat: + do + { + if(!map[static_cast(traits_inst.translate(*position, icase))]) + { + // failed repeat match, discard this state and look for another: + destroy_single_repeat(); + return true; + } + ++count; + ++ position; + ++state_count; + pstate = rep->next.p; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_long_set_repeat(bool r) +{ + typedef typename traits::char_class_type mask_type; + saved_single_repeat* pmp = static_cast*>(m_backup_state); + + // if we have a match, just discard this state: + if(r) + { + destroy_single_repeat(); + return true; + } + + const re_repeat* rep = pmp->rep; + std::size_t count = pmp->count; + pstate = rep->next.p; + const re_set_long* set = static_cast*>(pstate); + position = pmp->last_position; + + BOOST_ASSERT(rep->type == syntax_element_long_set_rep); + BOOST_ASSERT(rep->next.p != 0); + BOOST_ASSERT(rep->alt.p != 0); + BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); + BOOST_ASSERT(count < rep->max); + + if(position != last) + { + // wind forward until we can skip out of the repeat: + do + { + if(position == re_is_set_member(position, last, set, re.get_data(), icase)) + { + // failed repeat match, discard this state and look for another: + destroy_single_repeat(); + return true; + } + ++position; + ++count; + ++state_count; + pstate = rep->next.p; + }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); + } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; + if(position == last) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + if(0 == (rep->can_be_null & mask_skip)) + return true; + } + else if(count == rep->max) + { + // can't repeat any more, remove the pushed state: + destroy_single_repeat(); + if(!can_start(*position, rep->_map, mask_skip)) + return true; + } + else + { + pmp->count = count; + pmp->last_position = position; + } + pstate = rep->alt.p; + return false; +} + +template +bool perl_matcher::unwind_non_greedy_repeat(bool r) +{ + saved_position* pmp = static_cast*>(m_backup_state); + if(!r) + { + position = pmp->position; + pstate = pmp->pstate; + ++(*next_count); + } + boost::re_detail::inplace_destroy(pmp++); + m_backup_state = pmp; + return r; +} + +} // namespace re_detail +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_recursive.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/perl_matcher_recursive.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,854 @@ +/* + * + * Copyright (c) 2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE perl_matcher_common.cpp + * VERSION see + * DESCRIPTION: Definitions of perl_matcher member functions that are + * specific to the recursive implementation. + */ + +#ifndef BOOST_REGEX_V4_PERL_MATCHER_RECURSIVE_HPP +#define BOOST_REGEX_V4_PERL_MATCHER_RECURSIVE_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4800) +#endif + +namespace boost{ +namespace re_detail{ + +template +class backup_subex +{ + int index; + sub_match sub; +public: + template + backup_subex(const match_results& w, int i) + : index(i), sub(w[i], false) {} + template + void restore(match_results& w) + { + w.set_first(sub.first, index); + w.set_second(sub.second, index, sub.matched); + } + const sub_match& get() { return sub; } +}; + +template +bool perl_matcher::match_all_states() +{ + static matcher_proc_type const s_match_vtable[29] = + { + (&perl_matcher::match_startmark), + &perl_matcher::match_endmark, + &perl_matcher::match_literal, + &perl_matcher::match_start_line, + &perl_matcher::match_end_line, + &perl_matcher::match_wild, + &perl_matcher::match_match, + &perl_matcher::match_word_boundary, + &perl_matcher::match_within_word, + &perl_matcher::match_word_start, + &perl_matcher::match_word_end, + &perl_matcher::match_buffer_start, + &perl_matcher::match_buffer_end, + &perl_matcher::match_backref, + &perl_matcher::match_long_set, + &perl_matcher::match_set, + &perl_matcher::match_jump, + &perl_matcher::match_alt, + &perl_matcher::match_rep, + &perl_matcher::match_combining, + &perl_matcher::match_soft_buffer_end, + &perl_matcher::match_restart_continue, + (::boost::is_random_access_iterator::value ? &perl_matcher::match_dot_repeat_fast : &perl_matcher::match_dot_repeat_slow), + &perl_matcher::match_char_repeat, + &perl_matcher::match_set_repeat, + &perl_matcher::match_long_set_repeat, + &perl_matcher::match_backstep, + &perl_matcher::match_assert_backref, + &perl_matcher::match_toggle_case, + }; + + if(state_count > max_state_count) + raise_error(traits_inst, regex_constants::error_space); + while(pstate) + { + matcher_proc_type proc = s_match_vtable[pstate->type]; + ++state_count; + if(!(this->*proc)()) + { + if((m_match_flags & match_partial) && (position == last) && (position != search_base)) + m_has_partial_match = true; + return 0; + } + } + return true; +} + +template +bool perl_matcher::match_startmark() +{ + int index = static_cast(pstate)->index; + bool r = true; + switch(index) + { + case 0: + pstate = pstate->next.p; + break; + case -1: + case -2: + { + // forward lookahead assert: + BidiIterator old_position(position); + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + r = match_all_states(); + pstate = next_pstate; + position = old_position; + if((r && (index != -1)) || (!r && (index != -2))) + r = false; + else + r = true; + break; + } + case -3: + { + // independent sub-expression: + bool old_independent = m_independent; + m_independent = true; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + r = match_all_states(); + pstate = next_pstate; + m_independent = old_independent; +#ifdef BOOST_REGEX_MATCH_EXTRA + if(r && (m_match_flags & match_extra)) + { + // + // our captures have been stored in *m_presult + // we need to unpack them, and insert them + // back in the right order when we unwind the stack: + // + unsigned i; + match_results tm(*m_presult); + for(i = 0; i < tm.size(); ++i) + (*m_presult)[i].get_captures().clear(); + // match everything else: + r = match_all_states(); + // now place the stored captures back: + for(i = 0; i < tm.size(); ++i) + { + typedef typename sub_match::capture_sequence_type seq; + seq& s1 = (*m_presult)[i].get_captures(); + const seq& s2 = tm[i].captures(); + s1.insert( + s1.end(), + s2.begin(), + s2.end()); + } + } +#endif + break; + } + case -4: + { + // conditional expression: + const re_alt* alt = static_cast(pstate->next.p); + BOOST_ASSERT(alt->type == syntax_element_alt); + pstate = alt->next.p; + if(pstate->type == syntax_element_assert_backref) + { + if(!match_assert_backref()) + pstate = alt->alt.p; + break; + } + else + { + // zero width assertion, have to match this recursively: + BOOST_ASSERT(pstate->type == syntax_element_startmark); + bool negated = static_cast(pstate)->index == -2; + BidiIterator saved_position = position; + const re_syntax_base* next_pstate = static_cast(pstate->next.p)->alt.p->next.p; + pstate = pstate->next.p->next.p; + bool r = match_all_states(); + position = saved_position; + if(negated) + r = !r; + if(r) + pstate = next_pstate; + else + pstate = alt->alt.p; + break; + } + } + default: + { + BOOST_ASSERT(index > 0); + if((m_match_flags & match_nosubs) == 0) + { + backup_subex sub(*m_presult, index); + m_presult->set_first(position, index); + pstate = pstate->next.p; + r = match_all_states(); + if(r == false) + sub.restore(*m_presult); +#ifdef BOOST_REGEX_MATCH_EXTRA + // + // we have a match, push the capture information onto the stack: + // + else if(sub.get().matched && (match_extra & m_match_flags)) + ((*m_presult)[index]).get_captures().push_back(sub.get()); +#endif + } + else + { + pstate = pstate->next.p; + } + break; + } + } + return r; +} + +template +bool perl_matcher::match_alt() +{ + bool take_first, take_second; + const re_alt* jmp = static_cast(pstate); + + // find out which of these two alternatives we need to take: + if(position == last) + { + take_first = jmp->can_be_null & mask_take; + take_second = jmp->can_be_null & mask_skip; + } + else + { + take_first = can_start(*position, jmp->_map, (unsigned char)mask_take); + take_second = can_start(*position, jmp->_map, (unsigned char)mask_skip); + } + + if(take_first) + { + // we can take the first alternative, + // see if we need to push next alternative: + if(take_second) + { + BidiIterator oldposition(position); + const re_syntax_base* old_pstate = jmp->alt.p; + pstate = pstate->next.p; + if(!match_all_states()) + { + pstate = old_pstate; + position = oldposition; + } + return true; + } + pstate = pstate->next.p; + return true; + } + if(take_second) + { + pstate = jmp->alt.p; + return true; + } + return false; // neither option is possible +} + +template +bool perl_matcher::match_rep() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127 4244) +#endif + const re_repeat* rep = static_cast(pstate); + // + // Always copy the repeat count, so that the state is restored + // when we exit this scope: + // + repeater_count r(rep->state_id, &next_count, position); + // + // If we've had at least one repeat already, and the last one + // matched the NULL string then set the repeat count to + // maximum: + // + next_count->check_null_repeat(position, rep->max); + + // find out which of these two alternatives we need to take: + bool take_first, take_second; + if(position == last) + { + take_first = rep->can_be_null & mask_take; + take_second = rep->can_be_null & mask_skip; + } + else + { + take_first = can_start(*position, rep->_map, (unsigned char)mask_take); + take_second = can_start(*position, rep->_map, (unsigned char)mask_skip); + } + + if(next_count->get_count() < rep->min) + { + // we must take the repeat: + if(take_first) + { + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return match_all_states(); + } + return false; + } + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) + { + // try and take the repeat if we can: + if((next_count->get_count() < rep->max) && take_first) + { + // store position in case we fail: + BidiIterator pos = position; + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + if(match_all_states()) + return true; + // failed repeat, reset posistion and fall through for alternative: + position = pos; + } + if(take_second) + { + pstate = rep->alt.p; + return true; + } + return false; // can't take anything, fail... + } + else // non-greedy + { + // try and skip the repeat if we can: + if(take_second) + { + // store position in case we fail: + BidiIterator pos = position; + pstate = rep->alt.p; + if(match_all_states()) + return true; + // failed alternative, reset posistion and fall through for repeat: + position = pos; + } + if((next_count->get_count() < rep->max) && take_first) + { + // increase the counter: + ++(*next_count); + pstate = rep->next.p; + return match_all_states(); + } + } + return false; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_dot_repeat_slow() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + unsigned count = 0; + const re_repeat* rep = static_cast(pstate); + re_syntax_base* psingle = rep->next.p; + // match compulsary repeats first: + while(count < rep->min) + { + pstate = psingle; + if(!match_wild()) + return false; + ++count; + } + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + if(greedy) + { + // normal repeat: + while(count < rep->max) + { + pstate = psingle; + if(!match_wild()) + break; + ++count; + } + if((rep->leading) && (count < rep->max)) + restart = position; + pstate = rep; + return backtrack_till_match(count - rep->min); + } + else + { + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + ++count; + pstate = psingle; + position = save_pos; + if(!match_wild()) + return false; + }while(true); + } +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_dot_repeat_fast() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + if(m_match_flags & match_not_dot_null) + return match_dot_repeat_slow(); + if((static_cast(pstate->next.p)->mask & match_any_mask) == 0) + return match_dot_repeat_slow(); + // + // start by working out how much we can skip: + // + const re_repeat* rep = static_cast(pstate); +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4267) +#endif + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t count = (std::min)(static_cast(::boost::re_detail::distance(position, last)), static_cast(greedy ? rep->max : rep->min)); + if(rep->min > count) + { + position = last; + return false; // not enough text left to match + } + std::advance(position, count); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + if((rep->leading) && (count < rep->max) && greedy) + restart = position; + if(greedy) + return backtrack_till_match(count - rep->min); + + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) + { + ++position; + ++count; + } + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + if(save_pos == last) + return false; + position = ++save_pos; + ++count; + }while(true); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_char_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#pragma warning(disable:4267) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + BOOST_ASSERT(1 == static_cast(rep->next.p)->length); + const char_type what = *reinterpret_cast(static_cast(rep->next.p) + 1); + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t count, desired; + if(::boost::is_random_access_iterator::value) + { + desired = + (std::min)( + (std::size_t)(greedy ? rep->max : rep->min), + (std::size_t)::boost::re_detail::distance(position, last)); + count = desired; + ++desired; + if(icase) + { + while(--desired && (traits_inst.translate_nocase(*position) == what)) + { + ++position; + } + } + else + { + while(--desired && (traits_inst.translate(*position) == what)) + { + ++position; + } + } + count = count - desired; + } + else + { + count = 0; + desired = greedy ? rep->max : rep->min; + while((count < desired) && (position != last) && (traits_inst.translate(*position, icase) == what)) + { + ++position; + ++count; + } + } + if((rep->leading) && (count < rep->max) && greedy) + restart = position; + if(count < rep->min) + return false; + + if(greedy) + return backtrack_till_match(count - rep->min); + + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) + { + if((traits_inst.translate(*position, icase) == what)) + { + ++position; + ++count; + } + else + return false; // counldn't repeat even though it was the only option + } + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + position = save_pos; + if(position == last) + return false; + if(traits_inst.translate(*position, icase) == what) + { + ++position; + ++count; + } + else + { + return false; + } + }while(true); +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_set_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + const re_repeat* rep = static_cast(pstate); + const unsigned char* map = static_cast(rep->next.p)->_map; + unsigned count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + ++count; + } + } + if((rep->leading) && (count < rep->max) && greedy) + restart = position; + if(count < rep->min) + return false; + + if(greedy) + return backtrack_till_match(count - rep->min); + + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) + { + if(map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + ++count; + } + else + return false; // counldn't repeat even though it was the only option + } + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + position = save_pos; + if(position == last) + return false; + if(map[static_cast(traits_inst.translate(*position, icase))]) + { + ++position; + ++count; + } + else + { + return false; + } + }while(true); +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::match_long_set_repeat() +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif +#ifdef __BORLANDC__ +#pragma option push -w-8008 -w-8066 -w-8004 +#endif + typedef typename traits::char_class_type char_class_type; + const re_repeat* rep = static_cast(pstate); + const re_set_long* set = static_cast*>(pstate->next.p); + unsigned count = 0; + // + // start by working out how much we can skip: + // + bool greedy = (rep->greedy) && (!(m_match_flags & regex_constants::match_any) || m_independent); + std::size_t desired = greedy ? rep->max : rep->min; + if(::boost::is_random_access_iterator::value) + { + BidiIterator end = position; + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + BidiIterator origin(position); + while((position != end) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) + { + ++position; + } + count = (unsigned)::boost::re_detail::distance(origin, position); + } + else + { + while((count < desired) && (position != last) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) + { + ++position; + ++count; + } + } + if((rep->leading) && (count < rep->max) && greedy) + restart = position; + if(count < rep->min) + return false; + + if(greedy) + return backtrack_till_match(count - rep->min); + + // non-greedy, keep trying till we get a match: + BidiIterator save_pos; + do + { + while((position != last) && (count < rep->max) && !can_start(*position, rep->_map, mask_skip)) + { + if(position != re_is_set_member(position, last, set, re.get_data(), icase)) + { + ++position; + ++count; + } + else + return false; // counldn't repeat even though it was the only option + } + if((rep->leading) && (rep->max == UINT_MAX)) + restart = position; + pstate = rep->alt.p; + save_pos = position; + ++state_count; + if(match_all_states()) + return true; + if(count >= rep->max) + return false; + position = save_pos; + if(position == last) + return false; + if(position != re_is_set_member(position, last, set, re.get_data(), icase)) + { + ++position; + ++count; + } + else + { + return false; + } + }while(true); +#ifdef __BORLANDC__ +#pragma option pop +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +template +bool perl_matcher::backtrack_till_match(std::size_t count) +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4127) +#endif + if((m_match_flags & match_partial) && (position == last)) + m_has_partial_match = true; + + const re_repeat* rep = static_cast(pstate); + BidiIterator backtrack = position; + if(position == last) + { + if(rep->can_be_null & mask_skip) + { + pstate = rep->alt.p; + if(match_all_states()) + return true; + } + if(count) + { + position = --backtrack; + --count; + } + else + return false; + } + do + { + while(count && !can_start(*position, rep->_map, mask_skip)) + { + --position; + --count; + ++state_count; + } + pstate = rep->alt.p; + backtrack = position; + if(match_all_states()) + return true; + if(count == 0) + return false; + position = --backtrack; + ++state_count; + --count; + }while(true); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +} // namespace re_detail +} // namespace boost +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/primary_transform.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/primary_transform.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,146 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: primary_transform.hpp + * VERSION: see + * DESCRIPTION: Heuristically determines the sort string format in use + * by the current locale. + */ + +#ifndef BOOST_REGEX_PRIMARY_TRANSFORM +#define BOOST_REGEX_PRIMARY_TRANSFORM + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + namespace re_detail{ + + +enum{ + sort_C, + sort_fixed, + sort_delim, + sort_unknown +}; + +template +unsigned count_chars(const S& s, charT c) +{ + // + // Count how many occurances of character c occur + // in string s: if c is a delimeter between collation + // fields, then this should be the same value for all + // sort keys: + // + unsigned int count = 0; + for(unsigned pos = 0; pos < s.size(); ++pos) + { + if(s[pos] == c) ++count; + } + return count; +} + + +template +unsigned find_sort_syntax(const traits* pt, charT* delim) +{ + // + // compare 'a' with 'A' to see how similar they are, + // should really use a-accute but we can't portably do that, + // + typedef typename traits::string_type string_type; + typedef typename traits::char_type char_type; + + // Suppress incorrect warning for MSVC + (void)pt; + + char_type a[2] = {'a', '\0', }; + string_type sa(pt->transform(a, a+1)); + if(sa == a) + { + *delim = 0; + return sort_C; + } + char_type A[2] = { 'A', '\0', }; + string_type sA(pt->transform(A, A+1)); + char_type c[2] = { ';', '\0', }; + string_type sc(pt->transform(c, c+1)); + + int pos = 0; + while((pos <= static_cast(sa.size())) && (pos <= static_cast(sA.size())) && (sa[pos] == sA[pos])) ++pos; + --pos; + if(pos < 0) + { + *delim = 0; + return sort_unknown; + } + // + // at this point sa[pos] is either the end of a fixed width field + // or the character that acts as a delimiter: + // + charT maybe_delim = sa[pos]; + if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim))) + { + *delim = maybe_delim; + return sort_delim; + } + // + // OK doen't look like a delimiter, try for fixed width field: + // + if((sa.size() == sA.size()) && (sa.size() == sc.size())) + { + // note assumes that the fixed width field is less than + // (numeric_limits::max)(), should be true for all types + // I can't imagine 127 character fields... + *delim = static_cast(++pos); + return sort_fixed; + } + // + // don't know what it is: + // + *delim = 0; + return sort_unknown; +} + + + } // namespace re_detail +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/protected_call.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/protected_call.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,81 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE basic_regex_creator.cpp + * VERSION see + * DESCRIPTION: Declares template class basic_regex_creator which fills in + * the data members of a regex_data object. + */ + +#ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP +#define BOOST_REGEX_V4_PROTECTED_CALL_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +namespace re_detail{ + +class BOOST_REGEX_DECL abstract_protected_call +{ +public: + bool BOOST_REGEX_CALL execute()const; + // this stops gcc-4 from complaining: + virtual ~abstract_protected_call(){} +private: + virtual bool call()const = 0; +}; + +template +class concrete_protected_call + : public abstract_protected_call +{ +public: + typedef bool (T::*proc_type)(); + concrete_protected_call(T* o, proc_type p) + : obj(o), proc(p) {} +private: + virtual bool call()const; + T* obj; + proc_type proc; +}; + +template +bool concrete_protected_call::call()const +{ + return (obj->*proc)(); +} + +} +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regbase.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regbase.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,180 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regbase.cpp + * VERSION see + * DESCRIPTION: Declares class regbase. + */ + +#ifndef BOOST_REGEX_V4_REGBASE_HPP +#define BOOST_REGEX_V4_REGBASE_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +// +// class regbase +// handles error codes and flags +// +class BOOST_REGEX_DECL regbase +{ +public: + enum flag_type_ + { + // + // Divide the flags up into logical groups: + // bits 0-7 indicate main synatx type. + // bits 8-15 indicate syntax subtype. + // bits 16-31 indicate options that are common to all + // regex syntaxes. + // In all cases the default is 0. + // + // Main synatx group: + // + perl_syntax_group = 0, // default + basic_syntax_group = 1, // POSIX basic + literal = 2, // all characters are literals + main_option_type = literal | basic_syntax_group | perl_syntax_group, // everything! + // + // options specific to perl group: + // + no_bk_refs = 1 << 8, // \d not allowed + no_perl_ex = 1 << 9, // disable perl extensions + no_mod_m = 1 << 10, // disable Perl m modifier + mod_x = 1 << 11, // Perl x modifier + mod_s = 1 << 12, // force s modifier on (overrides match_not_dot_newline) + no_mod_s = 1 << 13, // force s modifier off (overrides match_not_dot_newline) + + // + // options specific to basic group: + // + no_char_classes = 1 << 8, // [[:CLASS:]] not allowed + no_intervals = 1 << 9, // {x,y} not allowed + bk_plus_qm = 1 << 10, // uses \+ and \? + bk_vbar = 1 << 11, // use \| for alternatives + emacs_ex = 1 << 12, // enables emacs extensions + + // + // options common to all groups: + // + no_escape_in_lists = 1 << 16, // '\' not special inside [...] + newline_alt = 1 << 17, // \n is the same as | + no_except = 1 << 18, // no exception on error + failbit = 1 << 19, // error flag + icase = 1 << 20, // characters are matched regardless of case + nocollate = 0, // don't use locale specific collation (deprecated) + collate = 1 << 21, // use locale specific collation + nosubs = 1 << 22, // don't mark sub-expressions + save_subexpression_location = 1 << 23, // save subexpression locations + no_empty_expressions = 1 << 24, // no empty expressions allowed + optimize = 0, // not really supported + + + + basic = basic_syntax_group | collate | no_escape_in_lists, + extended = no_bk_refs | collate | no_perl_ex | no_escape_in_lists, + normal = 0, + emacs = basic_syntax_group | collate | emacs_ex | bk_vbar, + awk = no_bk_refs | collate | no_perl_ex, + grep = basic | newline_alt, + egrep = extended | newline_alt, + sed = basic, + perl = normal, + ECMAScript = normal, + JavaScript = normal, + JScript = normal + }; + typedef unsigned int flag_type; + + enum restart_info + { + restart_any = 0, + restart_word = 1, + restart_line = 2, + restart_buf = 3, + restart_continue = 4, + restart_lit = 5, + restart_fixed_lit = 6, + restart_count = 7 + }; +}; + +// +// provide std lib proposal compatible constants: +// +namespace regex_constants{ + + enum flag_type_ + { + + no_except = ::boost::regbase::no_except, + failbit = ::boost::regbase::failbit, + literal = ::boost::regbase::literal, + icase = ::boost::regbase::icase, + nocollate = ::boost::regbase::nocollate, + collate = ::boost::regbase::collate, + nosubs = ::boost::regbase::nosubs, + optimize = ::boost::regbase::optimize, + bk_plus_qm = ::boost::regbase::bk_plus_qm, + bk_vbar = ::boost::regbase::bk_vbar, + no_intervals = ::boost::regbase::no_intervals, + no_char_classes = ::boost::regbase::no_char_classes, + no_escape_in_lists = ::boost::regbase::no_escape_in_lists, + no_mod_m = ::boost::regbase::no_mod_m, + mod_x = ::boost::regbase::mod_x, + mod_s = ::boost::regbase::mod_s, + no_mod_s = ::boost::regbase::no_mod_s, + save_subexpression_location = ::boost::regbase::save_subexpression_location, + no_empty_expressions = ::boost::regbase::no_empty_expressions, + + basic = ::boost::regbase::basic, + extended = ::boost::regbase::extended, + normal = ::boost::regbase::normal, + emacs = ::boost::regbase::emacs, + awk = ::boost::regbase::awk, + grep = ::boost::regbase::grep, + egrep = ::boost::regbase::egrep, + sed = basic, + perl = normal, + ECMAScript = normal, + JavaScript = normal, + JScript = normal + }; + typedef ::boost::regbase::flag_type syntax_option_type; + +} // namespace regex_constants + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,202 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex.cpp + * VERSION see + * DESCRIPTION: Declares boost::basic_regex<> and associated + * functions and classes. This header is the main + * entry point for the template regex code. + */ + +#ifndef BOOST_RE_REGEX_HPP_INCLUDED +#define BOOST_RE_REGEX_HPP_INCLUDED + +#ifdef __cplusplus + +// what follows is all C++ don't include in C builds!! + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif + +#ifndef BOOST_REGEX_FWD_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_HPP +#include +#endif +#ifndef BOOST_REGEX_RAW_BUFFER_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_MATCH_FLAGS +#include +#endif +#ifndef BOOST_REGEX_RAW_BUFFER_HPP +#include +#endif +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#include +#endif + +#ifndef BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_STATES_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGBASE_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_SUB_MATCH_HPP +#include +#endif +#ifndef BOOST_REGEX_FORMAT_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_MATCH_RESULTS_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP +#include +#endif +#ifndef BOOST_REGEX_MATCHER_HPP +#include +#endif +// +// template instances: +// +#define BOOST_REGEX_CHAR_T char +#ifdef BOOST_REGEX_NARROW_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif + +#ifndef BOOST_NO_WREGEX +#define BOOST_REGEX_CHAR_T wchar_t +#ifdef BOOST_REGEX_WIDE_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif +#endif + +#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T) +#define BOOST_REGEX_CHAR_T unsigned short +#ifdef BOOST_REGEX_US_INSTANTIATE +# define BOOST_REGEX_INSTANTIATE +#endif +#include +#undef BOOST_REGEX_CHAR_T +#ifdef BOOST_REGEX_INSTANTIATE +# undef BOOST_REGEX_INSTANTIATE +#endif +#endif + + +namespace boost{ +#ifdef BOOST_REGEX_NO_FWD +typedef basic_regex > regex; +#ifndef BOOST_NO_WREGEX +typedef basic_regex > wregex; +#endif +#endif + +typedef match_results cmatch; +typedef match_results smatch; +#ifndef BOOST_NO_WREGEX +typedef match_results wcmatch; +typedef match_results wsmatch; +#endif + +} // namespace boost +#ifndef BOOST_REGEX_MATCH_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGEX_SEARCH_HPP +#include +#endif +#ifndef BOOST_REGEX_ITERATOR_HPP +#include +#endif +#ifndef BOOST_REGEX_TOKEN_ITERATOR_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGEX_GREP_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP +#include +#endif +#ifndef BOOST_REGEX_V4_REGEX_MERGE_HPP +#include +#endif +#ifndef BOOST_REGEX_SPLIT_HPP +#include +#endif + +#endif // __cplusplus + +#endif // include + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_format.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_format.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,662 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_format.hpp + * VERSION see + * DESCRIPTION: Provides formatting output routines for search and replace + * operations. Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_FORMAT_HPP +#define BOOST_REGEX_FORMAT_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// +// Forward declaration: +// + template >::allocator_type > +class match_results; + +namespace re_detail{ + +// +// struct trivial_format_traits: +// defines minimum localisation support for formatting +// in the case that the actual regex traits is unavailable. +// +template +struct trivial_format_traits +{ + typedef charT char_type; + + static std::ptrdiff_t length(const charT* p) + { + return global_length(p); + } + static charT tolower(charT c) + { + return ::boost::re_detail::global_lower(c); + } + static charT toupper(charT c) + { + return ::boost::re_detail::global_upper(c); + } + static int value(const charT c, int radix) + { + int result = global_value(c); + return result >= radix ? -1 : result; + } + int toi(const charT*& p1, const charT* p2, int radix)const + { + return global_toi(p1, p2, radix, *this); + } +}; + +template +class basic_regex_formatter +{ +public: + typedef typename traits::char_type char_type; + basic_regex_formatter(OutputIterator o, const Results& r, const traits& t) + : m_traits(t), m_results(r), m_out(o), m_state(output_copy), m_restore_state(output_copy), m_have_conditional(false) {} + OutputIterator format(const char_type* p1, const char_type* p2, match_flag_type f); + OutputIterator format(const char_type* p1, match_flag_type f) + { + return format(p1, p1 + m_traits.length(p1), f); + } +private: + typedef typename Results::value_type sub_match_type; + enum output_state + { + output_copy, + output_next_lower, + output_next_upper, + output_lower, + output_upper, + output_none + }; + + void put(char_type c); + void put(const sub_match_type& sub); + void format_all(); + void format_perl(); + void format_escape(); + void format_conditional(); + void format_until_scope_end(); + + const traits& m_traits; // the traits class for localised formatting operations + const Results& m_results; // the match_results being used. + OutputIterator m_out; // where to send output. + const char_type* m_position; // format string, current position + const char_type* m_end; // format string end + match_flag_type m_flags; // format flags to use + output_state m_state; // what to do with the next character + output_state m_restore_state; // what state to restore to. + bool m_have_conditional; // we are parsing a conditional +private: + basic_regex_formatter(const basic_regex_formatter&); + basic_regex_formatter& operator=(const basic_regex_formatter&); +}; + +template +OutputIterator basic_regex_formatter::format(const char_type* p1, const char_type* p2, match_flag_type f) +{ + m_position = p1; + m_end = p2; + m_flags = f; + format_all(); + return m_out; +} + +template +void basic_regex_formatter::format_all() +{ + // over and over: + while(m_position != m_end) + { + switch(*m_position) + { + case '&': + if(m_flags & ::boost::regex_constants::format_sed) + { + ++m_position; + put(m_results[0]); + break; + } + put(*m_position++); + break; + case '\\': + format_escape(); + break; + case '(': + if(m_flags & boost::regex_constants::format_all) + { + ++m_position; + bool have_conditional = m_have_conditional; + m_have_conditional = false; + format_until_scope_end(); + m_have_conditional = have_conditional; + if(m_position == m_end) + return; + BOOST_ASSERT(*m_position == static_cast(')')); + ++m_position; // skip the closing ')' + break; + } + put(*m_position); + ++m_position; + break; + case ')': + if(m_flags & boost::regex_constants::format_all) + { + return; + } + put(*m_position); + ++m_position; + break; + case ':': + if((m_flags & boost::regex_constants::format_all) && m_have_conditional) + { + return; + } + put(*m_position); + ++m_position; + break; + case '?': + if(m_flags & boost::regex_constants::format_all) + { + ++m_position; + format_conditional(); + break; + } + put(*m_position); + ++m_position; + break; + case '$': + if((m_flags & format_sed) == 0) + { + format_perl(); + break; + } + // fall through, not a special character: + default: + put(*m_position); + ++m_position; + break; + } + } +} + +template +void basic_regex_formatter::format_perl() +{ + // + // On entry *m_position points to a '$' character + // output the information that goes with it: + // + BOOST_ASSERT(*m_position == '$'); + // + // see if this is a trailing '$': + // + if(++m_position == m_end) + { + --m_position; + put(*m_position); + ++m_position; + return; + } + // + // OK find out what kind it is: + // + bool have_brace = false; + const char_type* save_position = m_position; + switch(*m_position) + { + case '&': + ++m_position; + put(this->m_results[0]); + break; + case '`': + ++m_position; + put(this->m_results.prefix()); + break; + case '\'': + ++m_position; + put(this->m_results.suffix()); + break; + case '$': + put(*m_position++); + break; + case '{': + have_brace = true; + ++m_position; + // fall through.... + default: + // see if we have a number: + { + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(2), len); + int v = m_traits.toi(m_position, m_position + len, 10); + if((v < 0) || (have_brace && ((m_position == m_end) || (*m_position != '}')))) + { + // leave the $ as is, and carry on: + m_position = --save_position; + put(*m_position); + ++m_position; + break; + } + // otherwise output sub v: + put(this->m_results[v]); + if(have_brace) + ++m_position; + } + } +} + +template +void basic_regex_formatter::format_escape() +{ + // skip the escape and check for trailing escape: + if(++m_position == m_end) + { + put(static_cast('\\')); + return; + } + // now switch on the escape type: + switch(*m_position) + { + case 'a': + put(static_cast('\a')); + ++m_position; + break; + case 'f': + put(static_cast('\f')); + ++m_position; + break; + case 'n': + put(static_cast('\n')); + ++m_position; + break; + case 'r': + put(static_cast('\r')); + ++m_position; + break; + case 't': + put(static_cast('\t')); + ++m_position; + break; + case 'v': + put(static_cast('\v')); + ++m_position; + break; + case 'x': + if(++m_position == m_end) + { + put(static_cast('x')); + return; + } + // maybe have \x{ddd} + if(*m_position == static_cast('{')) + { + ++m_position; + int val = m_traits.toi(m_position, m_end, 16); + if(val < 0) + { + // invalid value treat everything as literals: + put(static_cast('x')); + put(static_cast('{')); + return; + } + if(*m_position != static_cast('}')) + { + while(*m_position != static_cast('\\')) + --m_position; + ++m_position; + put(*m_position++); + return; + } + ++m_position; + put(static_cast(val)); + return; + } + else + { + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(2), len); + int val = m_traits.toi(m_position, m_position + len, 16); + if(val < 0) + { + --m_position; + put(*m_position++); + return; + } + put(static_cast(val)); + } + break; + case 'c': + if(++m_position == m_end) + { + --m_position; + put(*m_position++); + return; + } + put(static_cast(*m_position++ % 32)); + break; + case 'e': + put(static_cast(27)); + ++m_position; + break; + default: + // see if we have a perl specific escape: + if((m_flags & boost::regex_constants::format_sed) == 0) + { + bool breakout = false; + switch(*m_position) + { + case 'l': + ++m_position; + m_restore_state = m_state; + m_state = output_next_lower; + breakout = true; + break; + case 'L': + ++m_position; + m_state = output_lower; + breakout = true; + break; + case 'u': + ++m_position; + m_restore_state = m_state; + m_state = output_next_upper; + breakout = true; + break; + case 'U': + ++m_position; + m_state = output_upper; + breakout = true; + break; + case 'E': + ++m_position; + m_state = output_copy; + breakout = true; + break; + } + if(breakout) + break; + } + // see if we have a \n sed style backreference: + int v = m_traits.toi(m_position, m_position+1, 10); + if((v > 0) || ((v == 0) && (m_flags & ::boost::regex_constants::format_sed))) + { + put(m_results[v]); + break; + } + else if(v == 0) + { + // octal ecape sequence: + --m_position; + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(4), len); + v = m_traits.toi(m_position, m_position + len, 8); + BOOST_ASSERT(v >= 0); + put(static_cast(v)); + break; + } + // Otherwise output the character "as is": + put(*m_position++); + break; + } +} + +template +void basic_regex_formatter::format_conditional() +{ + if(m_position == m_end) + { + // oops trailing '?': + put(static_cast('?')); + return; + } + std::ptrdiff_t len = ::boost::re_detail::distance(m_position, m_end); + len = (std::min)(static_cast(2), len); + int v = m_traits.toi(m_position, m_position + len, 10); + if(v < 0) + { + // oops not a number: + put(static_cast('?')); + return; + } + + // output varies depending upon whether sub-expression v matched or not: + if(m_results[v].matched) + { + m_have_conditional = true; + format_all(); + m_have_conditional = false; + if((m_position != m_end) && (*m_position == static_cast(':'))) + { + // skip the ':': + ++m_position; + // save output state, then turn it off: + output_state saved_state = m_state; + m_state = output_none; + // format the rest of this scope: + format_until_scope_end(); + // restore output state: + m_state = saved_state; + } + } + else + { + // save output state, then turn it off: + output_state saved_state = m_state; + m_state = output_none; + // format until ':' or ')': + m_have_conditional = true; + format_all(); + m_have_conditional = false; + // restore state: + m_state = saved_state; + if((m_position != m_end) && (*m_position == static_cast(':'))) + { + // skip the ':': + ++m_position; + // format the rest of this scope: + format_until_scope_end(); + } + } +} + +template +void basic_regex_formatter::format_until_scope_end() +{ + do + { + format_all(); + if((m_position == m_end) || (*m_position == static_cast(')'))) + return; + put(*m_position++); + }while(m_position != m_end); +} + +template +void basic_regex_formatter::put(char_type c) +{ + // write a single character to output + // according to which case translation mode we are in: + switch(this->m_state) + { + case output_none: + return; + case output_next_lower: + c = m_traits.tolower(c); + this->m_state = m_restore_state; + break; + case output_next_upper: + c = m_traits.toupper(c); + this->m_state = m_restore_state; + break; + case output_lower: + c = m_traits.tolower(c); + break; + case output_upper: + c = m_traits.toupper(c); + break; + default: + break; + } + *m_out = c; + ++m_out; +} + +template +void basic_regex_formatter::put(const sub_match_type& sub) +{ + typedef typename sub_match_type::iterator iterator_type; + iterator_type i = sub.first; + while(i != sub.second) + { + put(*i); + ++i; + } +} + +template +class string_out_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator +#endif +{ + S* out; +public: + string_out_iterator(S& s) : out(&s) {} + string_out_iterator& operator++() { return *this; } + string_out_iterator& operator++(int) { return *this; } + string_out_iterator& operator*() { return *this; } + string_out_iterator& operator=(typename S::value_type v) + { + out->append(1, v); + return *this; + } + +#ifdef BOOST_NO_STD_ITERATOR + typedef std::ptrdiff_t difference_type; + typedef typename S::value_type value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::output_iterator_tag iterator_category; +#endif +}; + +template +OutputIterator regex_format_imp(OutputIterator out, + const match_results& m, + const charT* p1, const charT* p2, + match_flag_type flags, + const traits& t + ) +{ + if(flags & regex_constants::format_literal) + { + return re_detail::copy(p1, p2, out); + } + + re_detail::basic_regex_formatter< + OutputIterator, + match_results, + traits > f(out, m, t); + return f.format(p1, p2, flags); +} + + +} // namespace re_detail + +template +OutputIterator regex_format(OutputIterator out, + const match_results& m, + const charT* fmt, + match_flag_type flags = format_all + ) +{ + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, m, fmt, fmt + traits.length(fmt), flags, traits); +} + +template +OutputIterator regex_format(OutputIterator out, + const match_results& m, + const std::basic_string& fmt, + match_flag_type flags = format_all + ) +{ + re_detail::trivial_format_traits traits; + return re_detail::regex_format_imp(out, m, fmt.data(), fmt.data() + fmt.size(), flags, traits); +} + +template +std::basic_string regex_format(const match_results& m, + const charT* fmt, + match_flag_type flags = format_all) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, m, fmt, fmt + traits.length(fmt), flags, traits); + return result; +} + +template +std::basic_string regex_format(const match_results& m, + const std::basic_string& fmt, + match_flag_type flags = format_all) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + re_detail::trivial_format_traits traits; + re_detail::regex_format_imp(i, m, fmt.data(), fmt.data() + fmt.size(), flags, traits); + return result; +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_FORMAT_HPP + + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_fwd.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_fwd.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,73 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_fwd.cpp + * VERSION see + * DESCRIPTION: Forward declares boost::basic_regex<> and + * associated typedefs. + */ + +#ifndef BOOST_REGEX_FWD_HPP_INCLUDED +#define BOOST_REGEX_FWD_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +// +// define BOOST_REGEX_NO_FWD if this +// header doesn't work! +// +#ifdef BOOST_REGEX_NO_FWD +# ifndef BOOST_RE_REGEX_HPP +# include +# endif +#else + +namespace boost{ + +template +class cpp_regex_traits; +template +struct c_regex_traits; +template +class w32_regex_traits; + +#ifdef BOOST_REGEX_USE_WIN32_LOCALE +template > +struct regex_traits; +#elif defined(BOOST_REGEX_USE_CPP_LOCALE) +template > +struct regex_traits; +#else +template > +struct regex_traits; +#endif + +template > +class basic_regex; + +typedef basic_regex > regex; +#ifndef BOOST_NO_WREGEX +typedef basic_regex > wregex; +#endif + +} // namespace boost + +#endif // BOOST_REGEX_NO_FWD + +#endif + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_grep.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_grep.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,155 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_grep.hpp + * VERSION see + * DESCRIPTION: Provides regex_grep implementation. + */ + +#ifndef BOOST_REGEX_V4_REGEX_GREP_HPP +#define BOOST_REGEX_V4_REGEX_GREP_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// +// regex_grep: +// find all non-overlapping matches within the sequence first last: +// +template +inline unsigned int regex_grep(Predicate foo, + BidiIterator first, + BidiIterator last, + const basic_regex& e, + match_flag_type flags = match_default) +{ + if(e.flags() & regex_constants::failbit) + return false; + + typedef typename match_results::allocator_type match_allocator_type; + + match_results m; + re_detail::perl_matcher matcher(first, last, m, e, flags, first); + unsigned int count = 0; + while(matcher.find()) + { + ++count; + if(0 == foo(m)) + return count; // caller doesn't want to go on + if(m[0].second == last) + return count; // we've reached the end, don't try and find an extra null match. + if(m.length() == 0) + { + if(m[0].second == last) + return count; + // we found a NULL-match, now try to find + // a non-NULL one at the same position: + match_results m2(m); + matcher.setf(match_not_null | match_continuous); + if(matcher.find()) + { + ++count; + if(0 == foo(m)) + return count; + } + else + { + // reset match back to where it was: + m = m2; + } + matcher.unsetf((match_not_null | match_continuous) & ~flags); + } + } + return count; +} + +// +// regex_grep convenience interfaces: +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +// +// this isn't really a partial specialisation, but template function +// overloading - if the compiler doesn't support partial specialisation +// then it really won't support this either: +template +inline unsigned int regex_grep(Predicate foo, const charT* str, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, str, str + traits::length(str), e, flags); +} + +template +inline unsigned int regex_grep(Predicate foo, const std::basic_string& s, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, s.begin(), s.end(), e, flags); +} +#else // partial specialisation +inline unsigned int regex_grep(bool (*foo)(const cmatch&), const char* str, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, str, str + regex::traits_type::length(str), e, flags); +} +#ifndef BOOST_NO_WREGEX +inline unsigned int regex_grep(bool (*foo)(const wcmatch&), const wchar_t* str, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, str, str + wregex::traits_type::length(str), e, flags); +} +#endif +inline unsigned int regex_grep(bool (*foo)(const match_results&), const std::string& s, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, s.begin(), s.end(), e, flags); +} +#if !defined(BOOST_NO_WREGEX) +inline unsigned int regex_grep(bool (*foo)(const match_results::const_iterator>&), + const std::basic_string& s, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_grep(foo, s.begin(), s.end(), e, flags); +} +#endif +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_GREP_HPP + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_iterator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,201 @@ +/* + * + * Copyright (c) 2003 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_iterator.hpp + * VERSION see + * DESCRIPTION: Provides regex_iterator implementation. + */ + +#ifndef BOOST_REGEX_V4_REGEX_ITERATOR_HPP +#define BOOST_REGEX_V4_REGEX_ITERATOR_HPP + +#include + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +class regex_iterator_implementation +{ + typedef basic_regex regex_type; + + match_results what; // current match + BidirectionalIterator base; // start of sequence + BidirectionalIterator end; // end of sequence + const regex_type re; // the expression + match_flag_type flags; // flags for matching + +public: + regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f) + : base(), end(last), re(*p), flags(f){} + bool init(BidirectionalIterator first) + { + base = first; + return regex_search(first, end, what, re, flags); + } + bool compare(const regex_iterator_implementation& that) + { + if(this == &that) return true; + return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second); + } + const match_results& get() + { return what; } + bool next() + { + //if(what.prefix().first != what[0].second) + // flags |= match_prev_avail; + BidirectionalIterator next_start = what[0].second; + match_flag_type f(flags); + if(!what.length()) + f |= regex_constants::match_not_initial_null; + //if(base != next_start) + // f |= regex_constants::match_not_bob; + bool result = regex_search(next_start, end, what, re, f, base); + if(result) + what.set_base(base); + return result; + } +private: + regex_iterator_implementation& operator=(const regex_iterator_implementation&); +}; + +template ::value_type, + class traits = regex_traits > +class regex_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator< + std::forward_iterator_tag, + match_results, + typename re_detail::regex_iterator_traits::difference_type, + const match_results*, + const match_results& > +#endif +{ +private: + typedef regex_iterator_implementation impl; + typedef shared_ptr pimpl; +public: + typedef basic_regex regex_type; + typedef match_results value_type; + typedef typename re_detail::regex_iterator_traits::difference_type + difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + regex_iterator(){} + regex_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + match_flag_type m = match_default) + : pdata(new impl(&re, b, m)) + { + if(!pdata->init(a)) + { + pdata.reset(); + } + } + regex_iterator(const regex_iterator& that) + : pdata(that.pdata) {} + regex_iterator& operator=(const regex_iterator& that) + { + pdata = that.pdata; + return *this; + } + bool operator==(const regex_iterator& that)const + { + if((pdata.get() == 0) || (that.pdata.get() == 0)) + return pdata.get() == that.pdata.get(); + return pdata->compare(*(that.pdata.get())); + } + bool operator!=(const regex_iterator& that)const + { return !(*this == that); } + const value_type& operator*()const + { return pdata->get(); } + const value_type* operator->()const + { return &(pdata->get()); } + regex_iterator& operator++() + { + cow(); + if(0 == pdata->next()) + { + pdata.reset(); + } + return *this; + } + regex_iterator operator++(int) + { + regex_iterator result(*this); + ++(*this); + return result; + } +private: + + pimpl pdata; + + void cow() + { + // copy-on-write + if(pdata.get() && !pdata.unique()) + { + pdata.reset(new impl(*(pdata.get()))); + } + } +}; + +typedef regex_iterator cregex_iterator; +typedef regex_iterator sregex_iterator; +#ifndef BOOST_NO_WREGEX +typedef regex_iterator wcregex_iterator; +typedef regex_iterator wsregex_iterator; +#endif + +// make_regex_iterator: +template +inline regex_iterator make_regex_iterator(const charT* p, const basic_regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_iterator(p, p+traits::length(p), e, m); +} +template +inline regex_iterator::const_iterator, charT, traits> make_regex_iterator(const std::basic_string& p, const basic_regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, m); +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_ITERATOR_HPP + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_match.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_match.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,382 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_match.hpp + * VERSION see + * DESCRIPTION: Regular expression matching algorithms. + * Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + + +#ifndef BOOST_REGEX_MATCH_HPP +#define BOOST_REGEX_MATCH_HPP + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// +// proc regex_match +// returns true if the specified regular expression matches +// the whole of the input. Fills in what matched in m. +// +template +bool regex_match(BidiIterator first, BidiIterator last, + match_results& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + re_detail::perl_matcher matcher(first, last, m, e, flags, first); + return matcher.match(); +} +template +bool regex_match(iterator first, iterator last, + const basic_regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(first, last, m, e, flags | regex_constants::match_any); +} +// +// query_match convenience interfaces: +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +// +// this isn't really a partial specialisation, but template function +// overloading - if the compiler doesn't support partial specialisation +// then it really won't support this either: +template +inline bool regex_match(const charT* str, + match_results& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + traits::length(str), m, e, flags); +} + +template +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator, Allocator>& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +template +inline bool regex_match(const charT* str, + const basic_regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any); +} + +template +inline bool regex_match(const std::basic_string& s, + const basic_regex& e, + match_flag_type flags = match_default) +{ + typedef typename std::basic_string::const_iterator iterator; + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#else // partial ordering +inline bool regex_match(const char* str, + cmatch& m, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const char* str, + cmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const char* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +#ifndef BOOST_NO_WREGEX +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const wregex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const wchar_t* str, + wcmatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_match(const wchar_t* str, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +#endif +inline bool regex_match(const std::string& s, + smatch& m, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const regex& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const std::string& s, + smatch& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +#if !defined(BOOST_NO_WREGEX) +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const wregex& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_STD_LOCALE +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +inline bool regex_match(const std::basic_string& s, + match_results::const_iterator>& m, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + return regex_match(s.begin(), s.end(), m, e, flags); +} +inline bool regex_match(const std::basic_string& s, + const basic_regex >& e, + match_flag_type flags = match_default) +{ + match_results::const_iterator> m; + return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#endif +#endif + +#endif + + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_MATCH_HPP + + + + + + + + + + + + + + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_merge.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_merge.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,93 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_format.hpp + * VERSION see + * DESCRIPTION: Provides formatting output routines for search and replace + * operations. Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_V4_REGEX_MERGE_HPP +#define BOOST_REGEX_V4_REGEX_MERGE_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +inline OutputIterator regex_merge(OutputIterator out, + Iterator first, + Iterator last, + const basic_regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + return regex_replace(out, first, last, e, fmt, flags); +} + +template +inline OutputIterator regex_merge(OutputIterator out, + Iterator first, + Iterator last, + const basic_regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + return regex_merge(out, first, last, e, fmt.c_str(), flags); +} + +template +inline std::basic_string regex_merge(const std::basic_string& s, + const basic_regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + return regex_replace(s, e, fmt, flags); +} + +template +inline std::basic_string regex_merge(const std::basic_string& s, + const basic_regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + return regex_replace(s, e, fmt, flags); +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_MERGE_HPP + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_raw_buffer.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_raw_buffer.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,210 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_raw_buffer.hpp + * VERSION see + * DESCRIPTION: Raw character buffer for regex code. + * Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_RAW_BUFFER_HPP +#define BOOST_REGEX_RAW_BUFFER_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +#include +#include + +namespace boost{ + namespace re_detail{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +struct empty_padding{}; + +union padding +{ + void* p; + unsigned int i; +}; + +template +struct padding3 +{ + enum{ + padding_size = 8, + padding_mask = 7 + }; +}; + +template<> +struct padding3<2> +{ + enum{ + padding_size = 2, + padding_mask = 1 + }; +}; + +template<> +struct padding3<4> +{ + enum{ + padding_size = 4, + padding_mask = 3 + }; +}; + +template<> +struct padding3<8> +{ + enum{ + padding_size = 8, + padding_mask = 7 + }; +}; + +template<> +struct padding3<16> +{ + enum{ + padding_size = 16, + padding_mask = 15 + }; +}; + +enum{ + padding_size = padding3::padding_size, + padding_mask = padding3::padding_mask +}; + +// +// class raw_storage +// basically this is a simplified vector +// this is used by basic_regex for expression storage +// + +class BOOST_REGEX_DECL raw_storage +{ +public: + typedef std::size_t size_type; + typedef unsigned char* pointer; +private: + pointer last, start, end; +public: + + raw_storage(); + raw_storage(size_type n); + + ~raw_storage() + { + ::operator delete(start); + } + + void BOOST_REGEX_CALL resize(size_type n); + + void* BOOST_REGEX_CALL extend(size_type n) + { + if(size_type(last - end) < n) + resize(n + (end - start)); + register pointer result = end; + end += n; + return result; + } + + void* BOOST_REGEX_CALL insert(size_type pos, size_type n); + + size_type BOOST_REGEX_CALL size() + { + return end - start; + } + + size_type BOOST_REGEX_CALL capacity() + { + return last - start; + } + + void* BOOST_REGEX_CALL data()const + { + return start; + } + + size_type BOOST_REGEX_CALL index(void* ptr) + { + return static_cast(ptr) - static_cast(data()); + } + + void BOOST_REGEX_CALL clear() + { + end = start; + } + + void BOOST_REGEX_CALL align() + { + // move end up to a boundary: + end = start + (((end - start) + padding_mask) & ~padding_mask); + } + void swap(raw_storage& that) + { + std::swap(start, that.start); + std::swap(end, that.end); + std::swap(last, that.last); + } +}; + +inline raw_storage::raw_storage() +{ + last = start = end = 0; +} + +inline raw_storage::raw_storage(size_type n) +{ + start = end = static_cast(::operator new(n)); + BOOST_REGEX_NOEH_ASSERT(start) + last = start + n; +} + + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace re_detail +} // namespace boost + +#endif + + + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_replace.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_replace.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,122 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_format.hpp + * VERSION see + * DESCRIPTION: Provides formatting output routines for search and replace + * operations. Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP +#define BOOST_REGEX_V4_REGEX_REPLACE_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +OutputIterator regex_replace(OutputIterator out, + BidirectionalIterator first, + BidirectionalIterator last, + const basic_regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + regex_iterator i(first, last, e, flags); + regex_iterator j; + if(i == j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(first, last, out); + } + else + { + BidirectionalIterator last_m(first); + while(i != j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(i->prefix().first, i->prefix().second, out); + out = i->format(out, fmt, flags, e); + last_m = (*i)[0].second; + if(flags & regex_constants::format_first_only) + break; + ++i; + } + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(last_m, last, out); + } + return out; +} + +template +inline OutputIterator regex_replace(OutputIterator out, + Iterator first, + Iterator last, + const basic_regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + return regex_replace(out, first, last, e, fmt.c_str(), flags); +} + +template +std::basic_string regex_replace(const std::basic_string& s, + const basic_regex& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + regex_replace(i, s.begin(), s.end(), e, fmt, flags); + return result; +} + +template +std::basic_string regex_replace(const std::basic_string& s, + const basic_regex& e, + const std::basic_string& fmt, + match_flag_type flags = match_default) +{ + std::basic_string result; + re_detail::string_out_iterator > i(result); + regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); + return result; +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_REPLACE_HPP + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_search.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_search.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,217 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_search.hpp + * VERSION see + * DESCRIPTION: Provides regex_search implementation. + */ + +#ifndef BOOST_REGEX_V4_REGEX_SEARCH_HPP +#define BOOST_REGEX_V4_REGEX_SEARCH_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template +bool regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(first, last, m, e, flags, first); +} + +template +bool regex_search(BidiIterator first, BidiIterator last, + match_results& m, + const basic_regex& e, + match_flag_type flags, + BidiIterator base) +{ + if(e.flags() & regex_constants::failbit) + return false; + + re_detail::perl_matcher matcher(first, last, m, e, flags, base); + return matcher.find(); +} + +// +// regex_search convenience interfaces: +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +// +// this isn't really a partial specialisation, but template function +// overloading - if the compiler doesn't support partial specialisation +// then it really won't support this either: +template +inline bool regex_search(const charT* str, + match_results& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(str, str + traits::length(str), m, e, flags); +} + +template +inline bool regex_search(const std::basic_string& s, + match_results::const_iterator, Allocator>& m, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(s.begin(), s.end(), m, e, flags); +} +#else // partial overloads: +inline bool regex_search(const char* str, + cmatch& m, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_search(str, str + regex::traits_type::length(str), m, e, flags); +} +inline bool regex_search(const char* first, const char* last, + const regex& e, + match_flag_type flags = match_default) +{ + cmatch m; + return regex_search(first, last, m, e, flags | regex_constants::match_any); +} + +#ifndef BOOST_NO_WREGEX +inline bool regex_search(const wchar_t* str, + wcmatch& m, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_search(str, str + wregex::traits_type::length(str), m, e, flags); +} +inline bool regex_search(const wchar_t* first, const wchar_t* last, + const wregex& e, + match_flag_type flags = match_default) +{ + wcmatch m; + return regex_search(first, last, m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_search(const std::string& s, + smatch& m, + const regex& e, + match_flag_type flags = match_default) +{ + return regex_search(s.begin(), s.end(), m, e, flags); +} +#if !defined(BOOST_NO_WREGEX) +inline bool regex_search(const std::basic_string& s, + wsmatch& m, + const wregex& e, + match_flag_type flags = match_default) +{ + return regex_search(s.begin(), s.end(), m, e, flags); +} +#endif + +#endif + +template +bool regex_search(BidiIterator first, BidiIterator last, + const basic_regex& e, + match_flag_type flags = match_default) +{ + if(e.flags() & regex_constants::failbit) + return false; + + match_results m; + typedef typename match_results::allocator_type match_alloc_type; + re_detail::perl_matcher matcher(first, last, m, e, flags | regex_constants::match_any, first); + return matcher.find(); +} + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +template +inline bool regex_search(const charT* str, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(str, str + traits::length(str), e, flags); +} + +template +inline bool regex_search(const std::basic_string& s, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_search(s.begin(), s.end(), e, flags); +} +#else // non-template function overloads +inline bool regex_search(const char* str, + const regex& e, + match_flag_type flags = match_default) +{ + cmatch m; + return regex_search(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#ifndef BOOST_NO_WREGEX +inline bool regex_search(const wchar_t* str, + const wregex& e, + match_flag_type flags = match_default) +{ + wcmatch m; + return regex_search(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); +} +#endif +inline bool regex_search(const std::string& s, + const regex& e, + match_flag_type flags = match_default) +{ + smatch m; + return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} +#if !defined(BOOST_NO_WREGEX) +inline bool regex_search(const std::basic_string& s, + const wregex& e, + match_flag_type flags = match_default) +{ + wsmatch m; + return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any); +} + +#endif // BOOST_NO_WREGEX + +#endif // partial overload + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_SEARCH_HPP + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_split.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_split.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,172 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_split.hpp + * VERSION see + * DESCRIPTION: Implements regex_split and associated functions. + * Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_SPLIT_HPP +#define BOOST_REGEX_SPLIT_HPP + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable: 4800) +#endif + +namespace re_detail{ + +template +const basic_regex& get_default_expression(charT) +{ + static const charT expression_text[4] = { '\\', 's', '+', '\00', }; + static const basic_regex e(expression_text); + return e; +} + +template +class split_pred +{ + typedef std::basic_string string_type; + typedef typename string_type::const_iterator iterator_type; + iterator_type* p_last; + OutputIterator* p_out; + std::size_t* p_max; + std::size_t initial_max; +public: + split_pred(iterator_type* a, OutputIterator* b, std::size_t* c) + : p_last(a), p_out(b), p_max(c), initial_max(*c) {} + + bool operator()(const match_results& what); +}; + +template +bool split_pred::operator() + (const match_results& what) +{ + *p_last = what[0].second; + if(what.size() > 1) + { + // output sub-expressions only: + for(unsigned i = 1; i < what.size(); ++i) + { + *(*p_out) = what.str(i); + ++(*p_out); + if(0 == --*p_max) return false; + } + return *p_max != 0; + } + else + { + // output $` only if it's not-null or not at the start of the input: + const sub_match& sub = what[-1]; + if((sub.first != sub.second) || (*p_max != initial_max)) + { + *(*p_out) = sub.str(); + ++(*p_out); + return --*p_max; + } + } + // + // initial null, do nothing: + return true; +} + +} // namespace re_detail + +template +std::size_t regex_split(OutputIterator out, + std::basic_string& s, + const basic_regex& e, + match_flag_type flags, + std::size_t max_split) +{ + typedef typename std::basic_string::const_iterator ci_t; + typedef typename match_results::allocator_type match_allocator; + ci_t last = s.begin(); + std::size_t init_size = max_split; + re_detail::split_pred pred(&last, &out, &max_split); + ci_t i, j; + i = s.begin(); + j = s.end(); + regex_grep(pred, i, j, e, flags); + // + // if there is still input left, do a final push as long as max_split + // is not exhausted, and we're not splitting sub-expressions rather + // than whitespace: + if(max_split && (last != s.end()) && (e.mark_count() == 1)) + { + *out = std::basic_string((ci_t)last, (ci_t)s.end()); + ++out; + last = s.end(); + --max_split; + } + // + // delete from the string everything that has been processed so far: + s.erase(0, last - s.begin()); + // + // return the number of new records pushed: + return init_size - max_split; +} + +template +inline std::size_t regex_split(OutputIterator out, + std::basic_string& s, + const basic_regex& e, + match_flag_type flags = match_default) +{ + return regex_split(out, s, e, flags, UINT_MAX); +} + +template +inline std::size_t regex_split(OutputIterator out, + std::basic_string& s) +{ + return regex_split(out, s, re_detail::get_default_expression(charT(0)), match_default, UINT_MAX); +} + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_token_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_token_iterator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,342 @@ +/* + * + * Copyright (c) 2003 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_token_iterator.hpp + * VERSION see + * DESCRIPTION: Provides regex_token_iterator implementation. + */ + +#ifndef BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP +#define BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP + +#include +#include +#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +// +// Borland C++ Builder 6, and Visual C++ 6, +// can't cope with the array template constructor +// so we have a template member that will accept any type as +// argument, and then assert that is really is an array: +// +#include +#include +#endif + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) +# pragma warning(push) +# pragma warning(disable:4700) +#endif + +template +class regex_token_iterator_implementation +{ + typedef basic_regex regex_type; + typedef sub_match value_type; + + match_results what; // current match + BidirectionalIterator base; // start of search area + BidirectionalIterator end; // end of search area + const regex_type re; // the expression + match_flag_type flags; // match flags + value_type result; // the current string result + int N; // the current sub-expression being enumerated + std::vector subs; // the sub-expressions to enumerate + +public: + regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f) + : end(last), re(*p), flags(f){ subs.push_back(sub); } + regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector& v, match_flag_type f) + : end(last), re(*p), flags(f), subs(v){} +#if !BOOST_WORKAROUND(__HP_aCC, < 60700) +#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) + template + regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const T& submatches, match_flag_type f) + : end(last), re(*p), flags(f) + { + // assert that T really is an array: + BOOST_STATIC_ASSERT(::boost::is_array::value); + const std::size_t array_size = sizeof(T) / sizeof(submatches[0]); + for(std::size_t i = 0; i < array_size; ++i) + { + subs.push_back(submatches[i]); + } + } +#else + template + regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f) + : end(last), re(*p), flags(f) + { + for(std::size_t i = 0; i < CN; ++i) + { + subs.push_back(submatches[i]); + } + } +#endif +#endif + bool init(BidirectionalIterator first) + { + N = 0; + base = first; + if(regex_search(first, end, what, re, flags, base) == true) + { + N = 0; + result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]); + return true; + } + else if((subs[N] == -1) && (first != end)) + { + result.first = first; + result.second = end; + result.matched = (first != end); + N = -1; + return true; + } + return false; + } + bool compare(const regex_token_iterator_implementation& that) + { + if(this == &that) return true; + return (&re.get_data() == &that.re.get_data()) + && (end == that.end) + && (flags == that.flags) + && (N == that.N) + && (what[0].first == that.what[0].first) + && (what[0].second == that.what[0].second); + } + const value_type& get() + { return result; } + bool next() + { + if(N == -1) + return false; + if(N+1 < (int)subs.size()) + { + ++N; + result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); + return true; + } + //if(what.prefix().first != what[0].second) + // flags |= /*match_prev_avail |*/ regex_constants::match_not_bob; + BidirectionalIterator last_end(what[0].second); + if(regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base)) + { + N =0; + result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); + return true; + } + else if((last_end != end) && (subs[0] == -1)) + { + N =-1; + result.first = last_end; + result.second = end; + result.matched = (last_end != end); + return true; + } + return false; + } +private: + regex_token_iterator_implementation& operator=(const regex_token_iterator_implementation&); +}; + +template ::value_type, + class traits = regex_traits > +class regex_token_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator< + std::forward_iterator_tag, + sub_match, + typename re_detail::regex_iterator_traits::difference_type, + const sub_match*, + const sub_match& > +#endif +{ +private: + typedef regex_token_iterator_implementation impl; + typedef shared_ptr pimpl; +public: + typedef basic_regex regex_type; + typedef sub_match value_type; + typedef typename re_detail::regex_iterator_traits::difference_type + difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + regex_token_iterator(){} + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + int submatch = 0, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatch, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const std::vector& submatches, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#if !BOOST_WORKAROUND(__HP_aCC, < 60700) +#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) + template + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const T& submatches, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#else + template + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const int (&submatches)[N], match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#endif +#endif + regex_token_iterator(const regex_token_iterator& that) + : pdata(that.pdata) {} + regex_token_iterator& operator=(const regex_token_iterator& that) + { + pdata = that.pdata; + return *this; + } + bool operator==(const regex_token_iterator& that)const + { + if((pdata.get() == 0) || (that.pdata.get() == 0)) + return pdata.get() == that.pdata.get(); + return pdata->compare(*(that.pdata.get())); + } + bool operator!=(const regex_token_iterator& that)const + { return !(*this == that); } + const value_type& operator*()const + { return pdata->get(); } + const value_type* operator->()const + { return &(pdata->get()); } + regex_token_iterator& operator++() + { + cow(); + if(0 == pdata->next()) + { + pdata.reset(); + } + return *this; + } + regex_token_iterator operator++(int) + { + regex_token_iterator result(*this); + ++(*this); + return result; + } +private: + + pimpl pdata; + + void cow() + { + // copy-on-write + if(pdata.get() && !pdata.unique()) + { + pdata.reset(new impl(*(pdata.get()))); + } + } +}; + +typedef regex_token_iterator cregex_token_iterator; +typedef regex_token_iterator sregex_token_iterator; +#ifndef BOOST_NO_WREGEX +typedef regex_token_iterator wcregex_token_iterator; +typedef regex_token_iterator wsregex_token_iterator; +#endif + +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} +#endif +template +inline regex_token_iterator make_regex_token_iterator(const charT* p, const basic_regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator(p, p+traits::length(p), e, submatch, m); +} +template +inline regex_token_iterator::const_iterator, charT, traits> make_regex_token_iterator(const std::basic_string& p, const basic_regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return regex_token_iterator::const_iterator, charT, traits>(p.begin(), p.end(), e, submatch, m); +} + +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) +# pragma warning(pop) +#endif +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_traits.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,189 @@ +/* + * + * Copyright (c) 2003 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_traits.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits classes. + */ + +#ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_REGEX_TRAITS_HPP_INCLUDED + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif +#ifndef BOOST_REGEX_WORKAROUND_HPP +#include +#endif +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#include +#endif +#ifndef BOOST_NO_STD_LOCALE +# ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) +# ifndef BOOST_C_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +# ifndef BOOST_W32_REGEX_TRAITS_HPP_INCLUDED +# include +# endif +#endif +#ifndef BOOST_REGEX_FWD_HPP_INCLUDED +#include +#endif + +#include "boost/mpl/has_xxx.hpp" +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + +template +struct regex_traits : public implementationT +{ + regex_traits() : implementationT() {} +}; + +// +// class regex_traits_wrapper. +// this is what our implementation will actually store; +// it provides default implementations of the "optional" +// interfaces that we support, in addition to the +// required "standard" ones: +// +namespace re_detail{ +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__HP_aCC, < 60000) +BOOST_MPL_HAS_XXX_TRAIT_DEF(boost_extensions_tag) +#else +template +struct has_boost_extensions_tag +{ + BOOST_STATIC_CONSTANT(bool, value = false); +}; +#endif + +template +struct default_wrapper : public BaseT +{ + typedef typename BaseT::char_type char_type; + std::string error_string(::boost::regex_constants::error_type e)const + { + return ::boost::re_detail::get_default_error_string(e); + } + ::boost::regex_constants::syntax_type syntax_type(char_type c)const + { + return ((c & 0x7f) == c) ? get_default_syntax_type(static_cast(c)) : ::boost::regex_constants::syntax_char; + } + ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const + { + return ((c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast(c)) : ::boost::regex_constants::escape_type_identity; + } + int toi(const char_type*& p1, const char_type* p2, int radix)const + { + return ::boost::re_detail::global_toi(p1, p2, radix, *this); + } + char_type translate(char_type c, bool icase)const + { + return (icase ? this->translate_nocase(c) : this->translate(c)); + } + char_type translate(char_type c)const + { + return BaseT::translate(c); + } + char_type tolower(char_type c)const + { + return ::boost::re_detail::global_lower(c); + } + char_type toupper(char_type c)const + { + return ::boost::re_detail::global_upper(c); + } +}; + +template +struct compute_wrapper_base +{ + typedef BaseT type; +}; +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__HP_aCC, < 60000) +template +struct compute_wrapper_base +{ + typedef default_wrapper type; +}; +#else +template <> +struct compute_wrapper_base, false> +{ + typedef default_wrapper > type; +}; +#ifndef BOOST_NO_WREGEX +template <> +struct compute_wrapper_base, false> +{ + typedef default_wrapper > type; +}; +#endif +#endif + +} // namespace re_detail + +template +struct regex_traits_wrapper + : public ::boost::re_detail::compute_wrapper_base< + BaseT, + ::boost::re_detail::has_boost_extensions_tag::value + >::type +{ + regex_traits_wrapper(){} +private: + regex_traits_wrapper(const regex_traits_wrapper&); + regex_traits_wrapper& operator=(const regex_traits_wrapper&); +}; + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // include + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_traits_defaults.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_traits_defaults.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,331 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_traits_defaults.hpp + * VERSION see + * DESCRIPTION: Declares API's for access to regex_traits default properties. + */ + +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#define BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#include +#endif +#ifndef BOOST_REGEX_ERROR_TYPE_HPP +#include +#endif + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::strlen; +} +#endif + +namespace boost{ namespace re_detail{ + + +// +// helpers to suppress warnings: +// +template +inline bool is_extended(charT c) +{ return c > 256; } +inline bool is_extended(char) +{ return false; } + + +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n); +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n); +BOOST_REGEX_DECL regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c); +BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c); + +// is charT c a combining character? +BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(uint_least16_t s); + +template +inline bool is_combining(charT c) +{ + return (c <= static_cast(0)) ? false : ((c >= static_cast((std::numeric_limits::max)())) ? false : is_combining_implementation(static_cast(c))); +} +template <> +inline bool is_combining(char) +{ + return false; +} +template <> +inline bool is_combining(signed char) +{ + return false; +} +template <> +inline bool is_combining(unsigned char) +{ + return false; +} +#ifndef __hpux // can't use WCHAR_MAX/MIN in pp-directives +#ifdef _MSC_VER +template<> +inline bool is_combining(wchar_t c) +{ + return is_combining_implementation(static_cast(c)); +} +#elif !defined(__DECCXX) && !defined(__osf__) && !defined(__OSF__) && defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if defined(WCHAR_MAX) && (WCHAR_MAX <= USHRT_MAX) +template<> +inline bool is_combining(wchar_t c) +{ + return is_combining_implementation(static_cast(c)); +} +#else +template<> +inline bool is_combining(wchar_t c) +{ + return (c >= (std::numeric_limits::max)()) ? false : is_combining_implementation(static_cast(c)); +} +#endif +#endif +#endif + +// +// is a charT c a line separator? +// +template +inline bool is_separator(charT c) +{ + return BOOST_REGEX_MAKE_BOOL( + (c == static_cast('\n')) + || (c == static_cast('\r')) + || (c == static_cast('\f')) + || (static_cast(c) == 0x2028u) + || (static_cast(c) == 0x2029u) + || (static_cast(c) == 0x85u)); +} +template <> +inline bool is_separator(char c) +{ + return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r') || (c == '\f')); +} + +// +// get a default collating element: +// +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name); + +// +// get the state_id of a character clasification, the individual +// traits classes then transform that state_id into a bitmask: +// +template +struct character_pointer_range +{ + const charT* p1; + const charT* p2; + + bool operator < (const character_pointer_range& r)const + { + return std::lexicographical_compare(p1, p2, r.p1, r.p2); + } + bool operator == (const character_pointer_range& r)const + { + // Not only do we check that the ranges are of equal size before + // calling std::equal, but there is no other algorithm available: + // not even a non-standard MS one. So forward to unchecked_equal + // in the MS case. + return ((p2 - p1) == (r.p2 - r.p1)) && re_detail::equal(p1, p2, r.p1); + } +}; +template +int get_default_class_id(const charT* p1, const charT* p2) +{ + static const charT data[72] = { + 'a', 'l', 'n', 'u', 'm', + 'a', 'l', 'p', 'h', 'a', + 'b', 'l', 'a', 'n', 'k', + 'c', 'n', 't', 'r', 'l', + 'd', 'i', 'g', 'i', 't', + 'g', 'r', 'a', 'p', 'h', + 'l', 'o', 'w', 'e', 'r', + 'p', 'r', 'i', 'n', 't', + 'p', 'u', 'n', 'c', 't', + 's', 'p', 'a', 'c', 'e', + 'u', 'n', 'i', 'c', 'o', 'd', 'e', + 'u', 'p', 'p', 'e', 'r', + 'w', 'o', 'r', 'd', + 'x', 'd', 'i', 'g', 'i', 't', + }; + + static const character_pointer_range ranges[19] = + { + {data+0, data+5,}, // alnum + {data+5, data+10,}, // alpha + {data+10, data+15,}, // blank + {data+15, data+20,}, // cntrl + {data+20, data+21,}, // d + {data+20, data+25,}, // digit + {data+25, data+30,}, // graph + {data+30, data+31,}, // l + {data+30, data+35,}, // lower + {data+35, data+40,}, // print + {data+40, data+45,}, // punct + {data+45, data+46,}, // s + {data+45, data+50,}, // space + {data+57, data+58,}, // u + {data+50, data+57,}, // unicode + {data+57, data+62,}, // upper + {data+62, data+63,}, // w + {data+62, data+66,}, // word + {data+66, data+72,}, // xdigit + }; + static const character_pointer_range* ranges_begin = ranges; + static const character_pointer_range* ranges_end = ranges + (sizeof(ranges)/sizeof(ranges[0])); + + character_pointer_range t = { p1, p2, }; + const character_pointer_range* p = std::lower_bound(ranges_begin, ranges_end, t); + if((p != ranges_end) && (t == *p)) + return static_cast(p - ranges); + return -1; +} + +// +// helper functions: +// +template +std::ptrdiff_t global_length(const charT* p) +{ + std::ptrdiff_t n = 0; + while(*p) + { + ++p; + ++n; + } + return n; +} +template<> +inline std::ptrdiff_t global_length(const char* p) +{ + return (std::strlen)(p); +} +#ifndef BOOST_NO_WREGEX +template<> +inline std::ptrdiff_t global_length(const wchar_t* p) +{ + return (std::wcslen)(p); +} +#endif +template +inline charT BOOST_REGEX_CALL global_lower(charT c) +{ + return c; +} +template +inline charT BOOST_REGEX_CALL global_upper(charT c) +{ + return c; +} + +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_lower(char c); +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_upper(char c); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c); +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c); +#endif +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_lower(unsigned short c); +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_upper(unsigned short c); +#endif +// +// This sucks: declare template specialisations of global_lower/global_upper +// that just forward to the non-template implementation functions. We do +// this because there is one compiler (Compaq Tru64 C++) that doesn't seem +// to differentiate between templates and non-template overloads.... +// what's more, the primary template, plus all overloads have to be +// defined in the same translation unit (if one is inline they all must be) +// otherwise the "local template instantiation" compiler option can pick +// the wrong instantiation when linking: +// +template<> inline char BOOST_REGEX_CALL global_lower(char c){ return do_global_lower(c); } +template<> inline char BOOST_REGEX_CALL global_upper(char c){ return do_global_upper(c); } +#ifndef BOOST_NO_WREGEX +template<> inline wchar_t BOOST_REGEX_CALL global_lower(wchar_t c){ return do_global_lower(c); } +template<> inline wchar_t BOOST_REGEX_CALL global_upper(wchar_t c){ return do_global_upper(c); } +#endif +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +template<> inline unsigned short BOOST_REGEX_CALL global_lower(unsigned short c){ return do_global_lower(c); } +template<> inline unsigned short BOOST_REGEX_CALL global_upper(unsigned short c){ return do_global_upper(c); } +#endif + +template +int global_value(charT c) +{ + static const charT zero = '0'; + static const charT nine = '9'; + static const charT a = 'a'; + static const charT f = 'f'; + static const charT A = 'A'; + static const charT F = 'F'; + + if(c > f) return -1; + if(c >= a) return 10 + (c - a); + if(c > F) return -1; + if(c >= A) return 10 + (c - A); + if(c > nine) return -1; + if(c >= zero) return c - zero; + return -1; +} +template +int global_toi(const charT*& p1, const charT* p2, int radix, const traits& t) +{ + (void)t; // warning suppression + int next_value = t.value(*p1, radix); + if((p1 == p2) || (next_value < 0) || (next_value >= radix)) + return -1; + int result = 0; + while(p1 != p2) + { + next_value = t.value(*p1, radix); + if((next_value < 0) || (next_value >= radix)) + break; + result *= radix; + result += next_value; + ++p1; + } + return result; +} + +} // re_detail +} // boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/regex_workaround.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/regex_workaround.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,202 @@ +/* + * + * Copyright (c) 1998-2005 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_workarounds.cpp + * VERSION see + * DESCRIPTION: Declares Misc workarounds. + */ + +#ifndef BOOST_REGEX_WORKAROUND_HPP +#define BOOST_REGEX_WORKAROUND_HPP + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef BOOST_NO_STD_LOCALE +# include +#endif + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::sprintf; using ::strcpy; using ::strcat; using ::strlen; +} +#endif + +namespace boost{ namespace re_detail{ +#ifdef BOOST_NO_STD_DISTANCE +template +std::ptrdiff_t distance(const T& x, const T& y) +{ return y - x; } +#else +using std::distance; +#endif +}} + + +#ifdef BOOST_REGEX_NO_BOOL +# define BOOST_REGEX_MAKE_BOOL(x) static_cast((x) ? true : false) +#else +# define BOOST_REGEX_MAKE_BOOL(x) static_cast(x) +#endif + +/***************************************************************************** + * + * Fix broken broken namespace support: + * + ****************************************************************************/ + +#if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus) + +namespace std{ + using ::ptrdiff_t; + using ::size_t; + using ::abs; + using ::memset; + using ::memcpy; +} + +#endif + +/***************************************************************************** + * + * helper functions pointer_construct/pointer_destroy: + * + ****************************************************************************/ + +#ifdef __cplusplus +namespace boost{ namespace re_detail{ + +#ifdef BOOST_MSVC +#pragma warning (push) +#pragma warning (disable : 4100) +#endif + +template +inline void pointer_destroy(T* p) +{ p->~T(); (void)p; } + +#ifdef BOOST_MSVC +#pragma warning (pop) +#endif + +template +inline void pointer_construct(T* p, const T& t) +{ new (p) T(t); } + +}} // namespaces +#endif + +/***************************************************************************** + * + * helper function copy: + * + ****************************************************************************/ + +#ifdef __cplusplus +namespace boost{ namespace re_detail{ +#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(_CPPLIB_VER) && defined(BOOST_DINKUMWARE_STDLIB) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) + // + // MSVC 8 will either emit warnings or else refuse to compile + // code that makes perfectly legitimate use of std::copy, when + // the OutputIterator type is a user-defined class (apparently all user + // defined iterators are "unsafe"). This code works around that: + // + template + inline OutputIterator copy( + InputIterator first, + InputIterator last, + OutputIterator dest + ) + { + return stdext::unchecked_copy(first, last, dest); + } + template + inline bool equal( + InputIterator1 first, + InputIterator1 last, + InputIterator2 with + ) + { + return stdext::unchecked_equal(first, last, with); + } + +#else + using std::copy; + using std::equal; +#endif +#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__ + + // use safe versions of strcpy etc: + using ::strcpy_s; + using ::strcat_s; +#else + inline std::size_t strcpy_s( + char *strDestination, + std::size_t sizeInBytes, + const char *strSource + ) + { + if(std::strlen(strSource)+1 > sizeInBytes) + return 1; + std::strcpy(strDestination, strSource); + return 0; + } + inline std::size_t strcat_s( + char *strDestination, + std::size_t sizeInBytes, + const char *strSource + ) + { + if(std::strlen(strSource) + std::strlen(strDestination) + 1 > sizeInBytes) + return 1; + std::strcat(strDestination, strSource); + return 0; + } + +#endif + + inline void overflow_error_if_not_zero(std::size_t i) + { + if(i) + { + std::overflow_error e("String buffer too small"); + boost::throw_exception(e); + } + } + +}} // namespaces + +#endif // __cplusplus + +#endif // include guard + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/states.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/states.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,290 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE states.cpp + * VERSION see + * DESCRIPTION: Declares internal state machine structures. + */ + +#ifndef BOOST_REGEX_V4_STATES_HPP +#define BOOST_REGEX_V4_STATES_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ +namespace re_detail{ + +/*** mask_type ******************************************************* +Whenever we have a choice of two alternatives, we use an array of bytes +to indicate which of the two alternatives it is possible to take for any +given input character. If mask_take is set, then we can take the next +state, and if mask_skip is set then we can take the alternative. +***********************************************************************/ +enum mask_type +{ + mask_take = 1, + mask_skip = 2, + mask_init = 4, + mask_any = mask_skip | mask_take, + mask_all = mask_any +}; + +/*** helpers ********************************************************** +These helpers let us use function overload resolution to detect whether +we have narrow or wide character strings: +***********************************************************************/ +struct _narrow_type{}; +struct _wide_type{}; +template struct is_byte; +template<> struct is_byte { typedef _narrow_type width_type; }; +template<> struct is_byte{ typedef _narrow_type width_type; }; +template<> struct is_byte { typedef _narrow_type width_type; }; +template struct is_byte { typedef _wide_type width_type; }; + +/*** enum syntax_element_type ****************************************** +Every record in the state machine falls into one of the following types: +***********************************************************************/ +enum syntax_element_type +{ + // start of a marked sub-expression, or perl-style (?...) extension + syntax_element_startmark = 0, + // end of a marked sub-expression, or perl-style (?...) extension + syntax_element_endmark = syntax_element_startmark + 1, + // any sequence of literal characters + syntax_element_literal = syntax_element_endmark + 1, + // start of line assertion: ^ + syntax_element_start_line = syntax_element_literal + 1, + // end of line assertion $ + syntax_element_end_line = syntax_element_start_line + 1, + // match any character: . + syntax_element_wild = syntax_element_end_line + 1, + // end of expression: we have a match when we get here + syntax_element_match = syntax_element_wild + 1, + // perl style word boundary: \b + syntax_element_word_boundary = syntax_element_match + 1, + // perl style within word boundary: \B + syntax_element_within_word = syntax_element_word_boundary + 1, + // start of word assertion: \< + syntax_element_word_start = syntax_element_within_word + 1, + // end of word assertion: \> + syntax_element_word_end = syntax_element_word_start + 1, + // start of buffer assertion: \` + syntax_element_buffer_start = syntax_element_word_end + 1, + // end of buffer assertion: \' + syntax_element_buffer_end = syntax_element_buffer_start + 1, + // backreference to previously matched sub-expression + syntax_element_backref = syntax_element_buffer_end + 1, + // either a wide character set [..] or one with multicharacter collating elements: + syntax_element_long_set = syntax_element_backref + 1, + // narrow character set: [...] + syntax_element_set = syntax_element_long_set + 1, + // jump to a new state in the machine: + syntax_element_jump = syntax_element_set + 1, + // choose between two production states: + syntax_element_alt = syntax_element_jump + 1, + // a repeat + syntax_element_rep = syntax_element_alt + 1, + // match a combining character sequence + syntax_element_combining = syntax_element_rep + 1, + // perl style soft buffer end: \z + syntax_element_soft_buffer_end = syntax_element_combining + 1, + // perl style continuation: \G + syntax_element_restart_continue = syntax_element_soft_buffer_end + 1, + // single character repeats: + syntax_element_dot_rep = syntax_element_restart_continue + 1, + syntax_element_char_rep = syntax_element_dot_rep + 1, + syntax_element_short_set_rep = syntax_element_char_rep + 1, + syntax_element_long_set_rep = syntax_element_short_set_rep + 1, + // a backstep for lookbehind repeats: + syntax_element_backstep = syntax_element_long_set_rep + 1, + // an assertion that a mark was matched: + syntax_element_assert_backref = syntax_element_backstep + 1, + syntax_element_toggle_case = syntax_element_assert_backref + 1 +}; + +#ifdef BOOST_REGEX_DEBUG +// dwa 09/26/00 - This is needed to suppress warnings about an ambiguous conversion +std::ostream& operator<<(std::ostream&, syntax_element_type); +#endif + +struct re_syntax_base; + +/*** union offset_type ************************************************ +Points to another state in the machine. During machine construction +we use integral offsets, but these are converted to pointers before +execution of the machine. +***********************************************************************/ +union offset_type +{ + re_syntax_base* p; + std::ptrdiff_t i; +}; + +/*** struct re_syntax_base ******************************************** +Base class for all states in the machine. +***********************************************************************/ +struct re_syntax_base +{ + syntax_element_type type; // what kind of state this is + offset_type next; // next state in the machine +}; + +/*** struct re_brace ************************************************** +A marked parenthesis. +***********************************************************************/ +struct re_brace : public re_syntax_base +{ + // The index to match, can be zero (don't mark the sub-expression) + // or negative (for perl style (?...) extentions): + int index; +}; + +/*** struct re_dot ************************************************** +Match anything. +***********************************************************************/ +enum +{ + dont_care = 1, + force_not_newline = 0, + force_newline = 2, + + test_not_newline = 2, + test_newline = 3 +}; +struct re_dot : public re_syntax_base +{ + unsigned char mask; +}; + +/*** struct re_literal ************************************************ +A string of literals, following this structure will be an +array of characters: charT[length] +***********************************************************************/ +struct re_literal : public re_syntax_base +{ + unsigned int length; +}; + +/*** struct re_case ************************************************ +Indicates whether we are moving to a case insensive block or not +***********************************************************************/ +struct re_case : public re_syntax_base +{ + bool icase; +}; + +/*** struct re_set_long *********************************************** +A wide character set of characters, following this structure will be +an array of type charT: +First csingles null-terminated strings +Then 2 * cranges NULL terminated strings +Then cequivalents NULL terminated strings +***********************************************************************/ +template +struct re_set_long : public re_syntax_base +{ + unsigned int csingles, cranges, cequivalents; + mask_type cclasses; + mask_type cnclasses; + bool isnot; + bool singleton; +}; + +/*** struct re_set **************************************************** +A set of narrow-characters, matches any of _map which is none-zero +***********************************************************************/ +struct re_set : public re_syntax_base +{ + unsigned char _map[1 << CHAR_BIT]; +}; + +/*** struct re_jump *************************************************** +Jump to a new location in the machine (not next). +***********************************************************************/ +struct re_jump : public re_syntax_base +{ + offset_type alt; // location to jump to +}; + +/*** struct re_alt *************************************************** +Jump to a new location in the machine (possibly next). +***********************************************************************/ +struct re_alt : public re_jump +{ + unsigned char _map[1 << CHAR_BIT]; // which characters can take the jump + unsigned int can_be_null; // true if we match a NULL string +}; + +/*** struct re_repeat ************************************************* +Repeat a section of the machine +***********************************************************************/ +struct re_repeat : public re_alt +{ + std::size_t min, max; // min and max allowable repeats + int state_id; // Unique identifier for this repeat + bool leading; // True if this repeat is at the start of the machine (lets us optimize some searches) + bool greedy; // True if this is a greedy repeat +}; + +/*** enum re_jump_size_type ******************************************* +Provides compiled size of re_jump structure (allowing for trailing alignment). +We provide this so we know how manybytes to insert when constructing the machine +(The value of padding_mask is defined in regex_raw_buffer.hpp). +***********************************************************************/ +enum re_jump_size_type +{ + re_jump_size = (sizeof(re_jump) + padding_mask) & ~(padding_mask), + re_repeater_size = (sizeof(re_repeat) + padding_mask) & ~(padding_mask), + re_alt_size = (sizeof(re_alt) + padding_mask) & ~(padding_mask) +}; + +/*** proc re_is_set_member ********************************************* +Forward declaration: we'll need this one later... +***********************************************************************/ + +template +struct regex_data; + +template +iterator BOOST_REGEX_CALL re_is_set_member(iterator next, + iterator last, + const re_set_long* set_, + const regex_data& e, bool icase); + +} // namespace re_detail + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/sub_match.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/sub_match.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,509 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE sub_match.cpp + * VERSION see + * DESCRIPTION: Declares template class sub_match. + */ + +#ifndef BOOST_REGEX_V4_SUB_MATCH_HPP +#define BOOST_REGEX_V4_SUB_MATCH_HPP + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +namespace boost{ + +template +struct sub_match : public std::pair +{ + typedef typename re_detail::regex_iterator_traits::value_type value_type; +#if defined(BOOST_NO_STD_ITERATOR_TRAITS) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + typedef std::ptrdiff_t difference_type; +#else + typedef typename re_detail::regex_iterator_traits::difference_type difference_type; +#endif + typedef BidiIterator iterator_type; + typedef BidiIterator iterator; + typedef BidiIterator const_iterator; + + bool matched; + + sub_match() : std::pair(), matched(false) {} + sub_match(BidiIterator i) : std::pair(i, i), matched(false) {} +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1310)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)\ + && !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) + template + operator std::basic_string ()const + { + return std::basic_string(this->first, this->second); + } +#else + operator std::basic_string ()const + { + return str(); + } +#endif + difference_type BOOST_REGEX_CALL length()const + { + difference_type n = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); + return n; + } + std::basic_string str()const + { + std::basic_string result; + std::size_t len = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second); + result.reserve(len); + BidiIterator i = this->first; + while(i != this->second) + { + result.append(1, *i); + ++i; + } + return result; + } + int compare(const sub_match& s)const + { + if(matched != s.matched) + return static_cast(matched) - static_cast(s.matched); + return str().compare(s.str()); + } + int compare(const std::basic_string& s)const + { + return str().compare(s); + } + int compare(const value_type* p)const + { + return str().compare(p); + } + + bool operator==(const sub_match& that)const + { return compare(that) == 0; } + bool BOOST_REGEX_CALL operator !=(const sub_match& that)const + { return compare(that) != 0; } + bool operator<(const sub_match& that)const + { return compare(that) < 0; } + bool operator>(const sub_match& that)const + { return compare(that) > 0; } + bool operator<=(const sub_match& that)const + { return compare(that) <= 0; } + bool operator>=(const sub_match& that)const + { return compare(that) >= 0; } + +#ifdef BOOST_REGEX_MATCH_EXTRA + typedef std::vector > capture_sequence_type; + + const capture_sequence_type& captures()const + { + if(!m_captures) + m_captures.reset(new capture_sequence_type()); + return *m_captures; + } + // + // Private implementation API: DO NOT USE! + // + capture_sequence_type& get_captures()const + { + if(!m_captures) + m_captures.reset(new capture_sequence_type()); + return *m_captures; + } + +private: + mutable boost::scoped_ptr m_captures; +public: + +#endif + sub_match(const sub_match& that, bool +#ifdef BOOST_REGEX_MATCH_EXTRA + deep_copy +#endif + = true + ) + : std::pair(that), + matched(that.matched) + { +#ifdef BOOST_REGEX_MATCH_EXTRA + if(that.m_captures) + if(deep_copy) + m_captures.reset(new capture_sequence_type(*(that.m_captures))); +#endif + } + sub_match& operator=(const sub_match& that) + { + this->first = that.first; + this->second = that.second; + matched = that.matched; +#ifdef BOOST_REGEX_MATCH_EXTRA + if(that.m_captures) + get_captures() = *(that.m_captures); +#endif + return *this; + } + + +#ifdef BOOST_OLD_REGEX_H + // + // the following are deprecated, do not use!! + // + operator int()const; + operator unsigned int()const; + operator short()const + { + return (short)(int)(*this); + } + operator unsigned short()const + { + return (unsigned short)(unsigned int)(*this); + } +#endif +}; + +typedef sub_match csub_match; +typedef sub_match ssub_match; +#ifndef BOOST_NO_WREGEX +typedef sub_match wcsub_match; +typedef sub_match wssub_match; +#endif + +// comparison to std::basic_string<> part 1: +template +inline bool operator == (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) == 0; } +template +inline bool operator != (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) != 0; } +template +inline bool operator < (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) < 0; } +template +inline bool operator <= (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) <= 0; } +template +inline bool operator >= (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) >= 0; } +template +inline bool operator > (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ return s.compare(m.str()) > 0; } +// comparison to std::basic_string<> part 2: +template +inline bool operator == (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) == 0; } +template +inline bool operator != (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) != 0; } +template +inline bool operator < (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) < 0; } +template +inline bool operator > (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) > 0; } +template +inline bool operator <= (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) <= 0; } +template +inline bool operator >= (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ return m.str().compare(s) >= 0; } +// comparison to const charT* part 1: +template +inline bool operator == (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) == 0; } +template +inline bool operator != (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) != 0; } +template +inline bool operator > (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) > 0; } +template +inline bool operator < (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) < 0; } +template +inline bool operator >= (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) >= 0; } +template +inline bool operator <= (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const* s) +{ return m.str().compare(s) <= 0; } +// comparison to const charT* part 2: +template +inline bool operator == (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) == 0; } +template +inline bool operator != (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) != 0; } +template +inline bool operator < (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) > 0; } +template +inline bool operator > (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) < 0; } +template +inline bool operator <= (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) >= 0; } +template +inline bool operator >= (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ return m.str().compare(s) <= 0; } + +// comparison to const charT& part 1: +template +inline bool operator == (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) == 0; } +template +inline bool operator != (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) != 0; } +template +inline bool operator > (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) > 0; } +template +inline bool operator < (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) < 0; } +template +inline bool operator >= (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) >= 0; } +template +inline bool operator <= (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ return m.str().compare(0, m.length(), &s, 1) <= 0; } +// comparison to const charT* part 2: +template +inline bool operator == (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) == 0; } +template +inline bool operator != (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) != 0; } +template +inline bool operator < (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) > 0; } +template +inline bool operator > (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) < 0; } +template +inline bool operator <= (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) >= 0; } +template +inline bool operator >= (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ return m.str().compare(0, m.length(), &s, 1) <= 0; } + +// addition operators: +template +inline std::basic_string::value_type, traits, Allocator> +operator + (const std::basic_string::value_type, traits, Allocator>& s, + const sub_match& m) +{ + std::basic_string::value_type, traits, Allocator> result; + result.reserve(s.size() + m.length() + 1); + return result.append(s).append(m.first, m.second); +} +template +inline std::basic_string::value_type, traits, Allocator> +operator + (const sub_match& m, + const std::basic_string::value_type, traits, Allocator>& s) +{ + std::basic_string::value_type, traits, Allocator> result; + result.reserve(s.size() + m.length() + 1); + return result.append(m.first, m.second).append(s); +} +#if !(defined(__GNUC__) && defined(BOOST_NO_STD_LOCALE)) +template +inline std::basic_string::value_type> +operator + (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ + std::basic_string::value_type> result; + result.reserve(std::char_traits::value_type>::length(s) + m.length() + 1); + return result.append(s).append(m.first, m.second); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const * s) +{ + std::basic_string::value_type> result; + result.reserve(std::char_traits::value_type>::length(s) + m.length() + 1); + return result.append(m.first, m.second).append(s); +} +#else +// worwaround versions: +template +inline std::basic_string::value_type> +operator + (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ + return s + m.str(); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const * s) +{ + return m.str() + s; +} +#endif +template +inline std::basic_string::value_type> +operator + (typename re_detail::regex_iterator_traits::value_type const& s, + const sub_match& m) +{ + std::basic_string::value_type> result; + result.reserve(m.length() + 2); + return result.append(1, s).append(m.first, m.second); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const& s) +{ + std::basic_string::value_type> result; + result.reserve(m.length() + 2); + return result.append(m.first, m.second).append(1, s); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m1, + const sub_match& m2) +{ + std::basic_string::value_type> result; + result.reserve(m1.length() + m2.length() + 1); + return result.append(m1.first, m1.second).append(m2.first, m2.second); +} +#ifndef BOOST_NO_STD_LOCALE +template +std::basic_ostream& + operator << (std::basic_ostream& os, + const sub_match& s) +{ + return (os << s.str()); +} +#else +template +std::ostream& operator << (std::ostream& os, + const sub_match& s) +{ + return (os << s.str()); +} +#endif + +#ifdef BOOST_OLD_REGEX_H +namespace re_detail{ +template +int do_toi(BidiIterator i, BidiIterator j, char c, int radix) +{ + std::string s(i, j); + char* p; + int result = std::strtol(s.c_str(), &p, radix); + if(*p)raise_regex_exception("Bad sub-expression"); + return result; +} + +// +// helper: +template +int do_toi(I& i, I j, charT c) +{ + int result = 0; + while((i != j) && (isdigit(*i))) + { + result = result*10 + (*i - '0'); + ++i; + } + return result; +} +} + + +template +sub_match::operator int()const +{ + BidiIterator i = first; + BidiIterator j = second; + if(i == j)raise_regex_exception("Bad sub-expression"); + int neg = 1; + if((i != j) && (*i == '-')) + { + neg = -1; + ++i; + } + neg *= re_detail::do_toi(i, j, *i); + if(i != j)raise_regex_exception("Bad sub-expression"); + return neg; +} +template +sub_match::operator unsigned int()const +{ + BidiIterator i = first; + BidiIterator j = second; + if(i == j) + raise_regex_exception("Bad sub-expression"); + return re_detail::do_toi(i, j, *first); +} +#endif + +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/syntax_type.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/syntax_type.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2003 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE syntax_type.hpp + * VERSION see + * DESCRIPTION: Declares regular expression synatx type enumerator. + */ + +#ifndef BOOST_REGEX_SYNTAX_TYPE_HPP +#define BOOST_REGEX_SYNTAX_TYPE_HPP + +namespace boost{ +namespace regex_constants{ + +typedef unsigned char syntax_type; + +// +// values chosen are binary compatible with previous version: +// +static const syntax_type syntax_char = 0; +static const syntax_type syntax_open_mark = 1; +static const syntax_type syntax_close_mark = 2; +static const syntax_type syntax_dollar = 3; +static const syntax_type syntax_caret = 4; +static const syntax_type syntax_dot = 5; +static const syntax_type syntax_star = 6; +static const syntax_type syntax_plus = 7; +static const syntax_type syntax_question = 8; +static const syntax_type syntax_open_set = 9; +static const syntax_type syntax_close_set = 10; +static const syntax_type syntax_or = 11; +static const syntax_type syntax_escape = 12; +static const syntax_type syntax_dash = 14; +static const syntax_type syntax_open_brace = 15; +static const syntax_type syntax_close_brace = 16; +static const syntax_type syntax_digit = 17; +static const syntax_type syntax_comma = 27; +static const syntax_type syntax_equal = 37; +static const syntax_type syntax_colon = 36; +static const syntax_type syntax_not = 53; + +// extensions: + +static const syntax_type syntax_hash = 13; +static const syntax_type syntax_newline = 26; + +// escapes: + +typedef syntax_type escape_syntax_type; + +static const escape_syntax_type escape_type_word_assert = 18; +static const escape_syntax_type escape_type_not_word_assert = 19; +static const escape_syntax_type escape_type_control_f = 29; +static const escape_syntax_type escape_type_control_n = 30; +static const escape_syntax_type escape_type_control_r = 31; +static const escape_syntax_type escape_type_control_t = 32; +static const escape_syntax_type escape_type_control_v = 33; +static const escape_syntax_type escape_type_ascii_control = 35; +static const escape_syntax_type escape_type_hex = 34; +static const escape_syntax_type escape_type_unicode = 0; // not used +static const escape_syntax_type escape_type_identity = 0; // not used +static const escape_syntax_type escape_type_backref = syntax_digit; +static const escape_syntax_type escape_type_decimal = syntax_digit; // not used +static const escape_syntax_type escape_type_class = 22; +static const escape_syntax_type escape_type_not_class = 23; + +// extensions: + +static const escape_syntax_type escape_type_left_word = 20; +static const escape_syntax_type escape_type_right_word = 21; +static const escape_syntax_type escape_type_start_buffer = 24; // for \` +static const escape_syntax_type escape_type_end_buffer = 25; // for \' +static const escape_syntax_type escape_type_control_a = 28; // for \a +static const escape_syntax_type escape_type_e = 38; // for \e +static const escape_syntax_type escape_type_E = 47; // for \Q\E +static const escape_syntax_type escape_type_Q = 48; // for \Q\E +static const escape_syntax_type escape_type_X = 49; // for \X +static const escape_syntax_type escape_type_C = 50; // for \C +static const escape_syntax_type escape_type_Z = 51; // for \Z +static const escape_syntax_type escape_type_G = 52; // for \G + +static const escape_syntax_type escape_type_property = 54; // for \p +static const escape_syntax_type escape_type_not_property = 55; // for \P +static const escape_syntax_type escape_type_named_char = 56; // for \N + +static const escape_syntax_type syntax_max = 57; + +} +} + + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/u32regex_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/u32regex_iterator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,193 @@ +/* + * + * Copyright (c) 2003 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE u32regex_iterator.hpp + * VERSION see + * DESCRIPTION: Provides u32regex_iterator implementation. + */ + +#ifndef BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP +#define BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP + +namespace boost{ + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +template +class u32regex_iterator_implementation +{ + typedef u32regex regex_type; + + match_results what; // current match + BidirectionalIterator base; // start of sequence + BidirectionalIterator end; // end of sequence + const regex_type re; // the expression + match_flag_type flags; // flags for matching + +public: + u32regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f) + : base(), end(last), re(*p), flags(f){} + bool init(BidirectionalIterator first) + { + base = first; + return u32regex_search(first, end, what, re, flags, base); + } + bool compare(const u32regex_iterator_implementation& that) + { + if(this == &that) return true; + return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second); + } + const match_results& get() + { return what; } + bool next() + { + //if(what.prefix().first != what[0].second) + // flags |= match_prev_avail; + BidirectionalIterator next_start = what[0].second; + match_flag_type f(flags); + if(!what.length()) + f |= regex_constants::match_not_initial_null; + //if(base != next_start) + // f |= regex_constants::match_not_bob; + bool result = u32regex_search(next_start, end, what, re, f, base); + if(result) + what.set_base(base); + return result; + } +private: + u32regex_iterator_implementation& operator=(const u32regex_iterator_implementation&); +}; + +template +class u32regex_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator< + std::forward_iterator_tag, + match_results, + typename re_detail::regex_iterator_traits::difference_type, + const match_results*, + const match_results& > +#endif +{ +private: + typedef u32regex_iterator_implementation impl; + typedef shared_ptr pimpl; +public: + typedef u32regex regex_type; + typedef match_results value_type; + typedef typename re_detail::regex_iterator_traits::difference_type + difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + u32regex_iterator(){} + u32regex_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + match_flag_type m = match_default) + : pdata(new impl(&re, b, m)) + { + if(!pdata->init(a)) + { + pdata.reset(); + } + } + u32regex_iterator(const u32regex_iterator& that) + : pdata(that.pdata) {} + u32regex_iterator& operator=(const u32regex_iterator& that) + { + pdata = that.pdata; + return *this; + } + bool operator==(const u32regex_iterator& that)const + { + if((pdata.get() == 0) || (that.pdata.get() == 0)) + return pdata.get() == that.pdata.get(); + return pdata->compare(*(that.pdata.get())); + } + bool operator!=(const u32regex_iterator& that)const + { return !(*this == that); } + const value_type& operator*()const + { return pdata->get(); } + const value_type* operator->()const + { return &(pdata->get()); } + u32regex_iterator& operator++() + { + cow(); + if(0 == pdata->next()) + { + pdata.reset(); + } + return *this; + } + u32regex_iterator operator++(int) + { + u32regex_iterator result(*this); + ++(*this); + return result; + } +private: + + pimpl pdata; + + void cow() + { + // copy-on-write + if(pdata.get() && !pdata.unique()) + { + pdata.reset(new impl(*(pdata.get()))); + } + } +}; + +typedef u32regex_iterator utf8regex_iterator; +typedef u32regex_iterator utf16regex_iterator; +typedef u32regex_iterator utf32regex_iterator; + +inline u32regex_iterator make_u32regex_iterator(const char* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_iterator(p, p+std::strlen(p), e, m); +} +#ifndef BOOST_NO_WREGEX +inline u32regex_iterator make_u32regex_iterator(const wchar_t* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_iterator(p, p+std::wcslen(p), e, m); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +inline u32regex_iterator make_u32regex_iterator(const UChar* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_iterator(p, p+u_strlen(p), e, m); +} +#endif +template +inline u32regex_iterator::const_iterator> make_u32regex_iterator(const std::basic_string& p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + typedef typename std::basic_string::const_iterator iter_type; + return u32regex_iterator(p.begin(), p.end(), e, m); +} +inline u32regex_iterator make_u32regex_iterator(const UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, m); +} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_ITERATOR_HPP + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/u32regex_token_iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/u32regex_token_iterator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,377 @@ +/* + * + * Copyright (c) 2003 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE u32regex_token_iterator.hpp + * VERSION see + * DESCRIPTION: Provides u32regex_token_iterator implementation. + */ + +#ifndef BOOST_REGEX_V4_U32REGEX_TOKEN_ITERATOR_HPP +#define BOOST_REGEX_V4_U32REGEX_TOKEN_ITERATOR_HPP + +#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +// +// Borland C++ Builder 6, and Visual C++ 6, +// can't cope with the array template constructor +// so we have a template member that will accept any type as +// argument, and then assert that is really is an array: +// +#include +#include +#endif + +namespace boost{ + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) +# pragma warning(push) +# pragma warning(disable:4700) +#endif + +template +class u32regex_token_iterator_implementation +{ + typedef u32regex regex_type; + typedef sub_match value_type; + + match_results what; // current match + BidirectionalIterator end; // end of search area + BidirectionalIterator base; // start of search area + const regex_type re; // the expression + match_flag_type flags; // match flags + value_type result; // the current string result + int N; // the current sub-expression being enumerated + std::vector subs; // the sub-expressions to enumerate + +public: + u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f) + : end(last), re(*p), flags(f){ subs.push_back(sub); } + u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector& v, match_flag_type f) + : end(last), re(*p), flags(f), subs(v){} +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + // can't reliably get this to work.... +#elif (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) + template + u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const T& submatches, match_flag_type f) + : end(last), re(*p), flags(f) + { + // assert that T really is an array: + BOOST_STATIC_ASSERT(::boost::is_array::value); + const std::size_t array_size = sizeof(T) / sizeof(submatches[0]); + for(std::size_t i = 0; i < array_size; ++i) + { + subs.push_back(submatches[i]); + } + } +#else + template + u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const int (&submatches)[CN], match_flag_type f) + : end(last), re(*p), flags(f) + { + for(std::size_t i = 0; i < CN; ++i) + { + subs.push_back(submatches[i]); + } + } +#endif + + bool init(BidirectionalIterator first) + { + base = first; + N = 0; + if(u32regex_search(first, end, what, re, flags, base) == true) + { + N = 0; + result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]); + return true; + } + else if((subs[N] == -1) && (first != end)) + { + result.first = first; + result.second = end; + result.matched = (first != end); + N = -1; + return true; + } + return false; + } + bool compare(const u32regex_token_iterator_implementation& that) + { + if(this == &that) return true; + return (&re.get_data() == &that.re.get_data()) + && (end == that.end) + && (flags == that.flags) + && (N == that.N) + && (what[0].first == that.what[0].first) + && (what[0].second == that.what[0].second); + } + const value_type& get() + { return result; } + bool next() + { + if(N == -1) + return false; + if(N+1 < (int)subs.size()) + { + ++N; + result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); + return true; + } + //if(what.prefix().first != what[0].second) + // flags |= match_prev_avail | regex_constants::match_not_bob; + BidirectionalIterator last_end(what[0].second); + if(u32regex_search(last_end, end, what, re, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags), base)) + { + N =0; + result =((subs[N] == -1) ? what.prefix() : what[subs[N]]); + return true; + } + else if((last_end != end) && (subs[0] == -1)) + { + N =-1; + result.first = last_end; + result.second = end; + result.matched = (last_end != end); + return true; + } + return false; + } +private: + u32regex_token_iterator_implementation& operator=(const u32regex_token_iterator_implementation&); +}; + +template +class u32regex_token_iterator +#ifndef BOOST_NO_STD_ITERATOR + : public std::iterator< + std::forward_iterator_tag, + sub_match, + typename re_detail::regex_iterator_traits::difference_type, + const sub_match*, + const sub_match& > +#endif +{ +private: + typedef u32regex_token_iterator_implementation impl; + typedef shared_ptr pimpl; +public: + typedef u32regex regex_type; + typedef sub_match value_type; + typedef typename re_detail::regex_iterator_traits::difference_type + difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + u32regex_token_iterator(){} + u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + int submatch = 0, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatch, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } + u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const std::vector& submatches, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + // can't reliably get this to work.... +#elif (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\ + || BOOST_WORKAROUND(BOOST_MSVC, < 1300) \ + || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) + template + u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const T& submatches, match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#else + template + u32regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re, + const int (&submatches)[N], match_flag_type m = match_default) + : pdata(new impl(&re, b, submatches, m)) + { + if(!pdata->init(a)) + pdata.reset(); + } +#endif + u32regex_token_iterator(const u32regex_token_iterator& that) + : pdata(that.pdata) {} + u32regex_token_iterator& operator=(const u32regex_token_iterator& that) + { + pdata = that.pdata; + return *this; + } + bool operator==(const u32regex_token_iterator& that)const + { + if((pdata.get() == 0) || (that.pdata.get() == 0)) + return pdata.get() == that.pdata.get(); + return pdata->compare(*(that.pdata.get())); + } + bool operator!=(const u32regex_token_iterator& that)const + { return !(*this == that); } + const value_type& operator*()const + { return pdata->get(); } + const value_type* operator->()const + { return &(pdata->get()); } + u32regex_token_iterator& operator++() + { + cow(); + if(0 == pdata->next()) + { + pdata.reset(); + } + return *this; + } + u32regex_token_iterator operator++(int) + { + u32regex_token_iterator result(*this); + ++(*this); + return result; + } +private: + + pimpl pdata; + + void cow() + { + // copy-on-write + if(pdata.get() && !pdata.unique()) + { + pdata.reset(new impl(*(pdata.get()))); + } + } +}; + +typedef u32regex_token_iterator utf8regex_token_iterator; +typedef u32regex_token_iterator utf16regex_token_iterator; +typedef u32regex_token_iterator utf32regex_token_iterator; + +// construction from an integral sub_match state_id: +inline u32regex_token_iterator make_u32regex_token_iterator(const char* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::strlen(p), e, submatch, m); +} +#ifndef BOOST_NO_WREGEX +inline u32regex_token_iterator make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+u_strlen(p), e, submatch, m); +} +#endif +template +inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + typedef typename std::basic_string::const_iterator iter_type; + return u32regex_token_iterator(p.begin(), p.end(), e, m); +} +inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); +} + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) +// construction from a reference to an array: +template +inline u32regex_token_iterator make_u32regex_token_iterator(const char* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::strlen(p), e, submatch, m); +} +#ifndef BOOST_NO_WREGEX +template +inline u32regex_token_iterator make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +template +inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+u_strlen(p), e, m); +} +#endif +template +inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + typedef typename std::basic_string::const_iterator iter_type; + return u32regex_token_iterator(p.begin(), p.end(), e, m); +} +template +inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); +} +#endif // BOOST_MSVC < 1300 + +// construction from a vector of sub_match state_id's: +inline u32regex_token_iterator make_u32regex_token_iterator(const char* p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::strlen(p), e, submatch, m); +} +#ifndef BOOST_NO_WREGEX +inline u32regex_token_iterator make_u32regex_token_iterator(const wchar_t* p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+std::wcslen(p), e, submatch, m); +} +#endif +#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2) +inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(p, p+u_strlen(p), e, submatch, m); +} +#endif +template +inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + typedef typename std::basic_string::const_iterator iter_type; + return u32regex_token_iterator(p.begin(), p.end(), e, m); +} +inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) +{ + return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m); +} + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) +# pragma warning(pop) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_TOKEN_ITERATOR_HPP + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex/v4/w32_regex_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex/v4/w32_regex_traits.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,731 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE w32_regex_traits.hpp + * VERSION see + * DESCRIPTION: Declares regular expression traits class w32_regex_traits. + */ + +#ifndef BOOST_W32_REGEX_TRAITS_HPP_INCLUDED +#define BOOST_W32_REGEX_TRAITS_HPP_INCLUDED + +#ifndef BOOST_RE_PAT_EXCEPT_HPP +#include +#endif +#ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED +#include +#endif +#ifdef BOOST_HAS_THREADS +#include +#endif +#ifndef BOOST_REGEX_PRIMARY_TRANSFORM +#include +#endif +#ifndef BOOST_REGEX_OBJECT_CACHE_HPP +#include +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4786) +#pragma warning(disable:4800) +#endif + +namespace boost{ + +// +// forward declaration is needed by some compilers: +// +template +class w32_regex_traits; + +namespace re_detail{ + +// +// start by typedeffing the types we'll need: +// +typedef ::boost::uint32_t lcid_type; // placeholder for LCID. +typedef ::boost::shared_ptr cat_type; // placeholder for dll HANDLE. + +// +// then add wrappers around the actual Win32 API's (ie implementation hiding): +// +BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale(); +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char, lcid_type); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t, lcid_type); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type state_id); +#endif +#endif +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char, lcid_type); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t, lcid_type); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type state_id); +#endif +#endif +BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name); +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type state_id, int i, const std::string& def); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type state_id, int i, const std::wstring& def); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string& def); +#endif +#endif +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type state_id, const char* p1, const char* p2); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type state_id, const wchar_t* p1, const wchar_t* p2); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL std::basic_string BOOST_REGEX_CALL w32_transform(lcid_type state_id, const unsigned short* p1, const unsigned short* p2); +#endif +#endif +BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type state_id); +#endif +#endif +BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type); +#endif +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, char c); +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type, boost::uint32_t mask, wchar_t c); +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type state_id, boost::uint32_t m, unsigned short c); +#endif +#endif +// +// class w32_regex_traits_base: +// acts as a container for locale and the facets we are using. +// +template +struct w32_regex_traits_base +{ + w32_regex_traits_base(lcid_type l) + { imbue(l); } + lcid_type imbue(lcid_type l); + + lcid_type m_locale; +}; + +template +inline lcid_type w32_regex_traits_base::imbue(lcid_type l) +{ + lcid_type result(m_locale); + m_locale = l; + return result; +} + +// +// class w32_regex_traits_char_layer: +// implements methods that require specialisation for narrow characters: +// +template +class w32_regex_traits_char_layer : public w32_regex_traits_base +{ + typedef std::basic_string string_type; + typedef std::map map_type; + typedef typename map_type::const_iterator map_iterator_type; +public: + w32_regex_traits_char_layer(const lcid_type l); + + regex_constants::syntax_type syntax_type(charT c)const + { + map_iterator_type i = m_char_map.find(c); + return ((i == m_char_map.end()) ? 0 : i->second); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + map_iterator_type i = m_char_map.find(c); + if(i == m_char_map.end()) + { + if(::boost::re_detail::w32_is_lower(c, this->m_locale)) return regex_constants::escape_type_class; + if(::boost::re_detail::w32_is_upper(c, this->m_locale)) return regex_constants::escape_type_not_class; + return 0; + } + return i->second; + } + charT tolower(charT c)const + { + return ::boost::re_detail::w32_tolower(c, this->m_locale); + } + bool isctype(boost::uint32_t mask, charT c)const + { + return ::boost::re_detail::w32_is(this->m_locale, mask, c); + } + +private: + string_type get_default_message(regex_constants::syntax_type); + // TODO: use a hash table when available! + map_type m_char_map; +}; + +template +w32_regex_traits_char_layer::w32_regex_traits_char_layer(::boost::re_detail::lcid_type l) + : w32_regex_traits_base(l) +{ + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: + cat_type cat; + std::string cat_name(w32_regex_traits::get_catalog_name()); + if(cat_name.size()) + { + cat = ::boost::re_detail::w32_cat_open(cat_name); + if(!cat) + { + std::string m("Unable to open message catalog: "); + std::runtime_error err(m + cat_name); + boost::re_detail::raise_runtime_error(err); + } + } + // + // if we have a valid catalog then load our messages: + // + if(cat) + { + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + string_type mss = ::boost::re_detail::w32_cat_get(cat, this->m_locale, i, get_default_message(i)); + for(typename string_type::size_type j = 0; j < mss.size(); ++j) + { + this->m_char_map[mss[j]] = i; + } + } + } + else + { + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + const char* ptr = get_default_syntax(i); + while(ptr && *ptr) + { + this->m_char_map[static_cast(*ptr)] = i; + ++ptr; + } + } + } +} + +template +typename w32_regex_traits_char_layer::string_type + w32_regex_traits_char_layer::get_default_message(regex_constants::syntax_type i) +{ + const char* ptr = get_default_syntax(i); + string_type result; + while(ptr && *ptr) + { + result.append(1, static_cast(*ptr)); + ++ptr; + } + return result; +} + +// +// specialised version for narrow characters: +// +template <> +class BOOST_REGEX_DECL w32_regex_traits_char_layer : public w32_regex_traits_base +{ + typedef std::string string_type; +public: + w32_regex_traits_char_layer(::boost::re_detail::lcid_type l) + : w32_regex_traits_base(l) + { + init(); + } + + regex_constants::syntax_type syntax_type(char c)const + { + return m_char_map[static_cast(c)]; + } + regex_constants::escape_syntax_type escape_syntax_type(char c) const + { + return m_char_map[static_cast(c)]; + } + char tolower(char c)const + { + return m_lower_map[static_cast(c)]; + } + bool isctype(boost::uint32_t mask, char c)const + { + return m_type_map[static_cast(c)] & mask; + } + +private: + regex_constants::syntax_type m_char_map[1u << CHAR_BIT]; + char m_lower_map[1u << CHAR_BIT]; + boost::uint16_t m_type_map[1u << CHAR_BIT]; + void init(); +}; + +// +// class w32_regex_traits_implementation: +// provides pimpl implementation for w32_regex_traits. +// +template +class w32_regex_traits_implementation : public w32_regex_traits_char_layer +{ +public: + typedef typename w32_regex_traits::char_class_type char_class_type; + BOOST_STATIC_CONSTANT(char_class_type, mask_word = 0x0400); // must be C1_DEFINED << 1 + BOOST_STATIC_CONSTANT(char_class_type, mask_unicode = 0x0800); // must be C1_DEFINED << 2 + BOOST_STATIC_CONSTANT(char_class_type, mask_base = 0x3ff); // all the masks used by the CT_CTYPE1 group + + typedef std::basic_string string_type; + typedef charT char_type; + w32_regex_traits_implementation(::boost::re_detail::lcid_type l); + std::string error_string(regex_constants::error_type n) const + { + if(!m_error_strings.empty()) + { + std::map::const_iterator p = m_error_strings.find(n); + return (p == m_error_strings.end()) ? std::string(get_default_error_string(n)) : p->second; + } + return get_default_error_string(n); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + char_class_type result = lookup_classname_imp(p1, p2); + if(result == 0) + { + typedef typename string_type::size_type size_type; + string_type temp(p1, p2); + for(size_type i = 0; i < temp.size(); ++i) + temp[i] = this->tolower(temp[i]); + result = lookup_classname_imp(&*temp.begin(), &*temp.begin() + temp.size()); + } + return result; + } + string_type lookup_collatename(const charT* p1, const charT* p2) const; + string_type transform_primary(const charT* p1, const charT* p2) const; + string_type transform(const charT* p1, const charT* p2) const + { + return ::boost::re_detail::w32_transform(this->m_locale, p1, p2); + } +private: + std::map m_error_strings; // error messages indexed by numberic ID + std::map m_custom_class_names; // character class names + std::map m_custom_collate_names; // collating element names + unsigned m_collate_type; // the form of the collation string + charT m_collate_delim; // the collation group delimiter + // + // helpers: + // + char_class_type lookup_classname_imp(const charT* p1, const charT* p2) const; +}; + +template +typename w32_regex_traits_implementation::string_type + w32_regex_traits_implementation::transform_primary(const charT* p1, const charT* p2) const +{ + string_type result; + // + // What we do here depends upon the format of the sort key returned by + // sort key returned by this->transform: + // + switch(m_collate_type) + { + case sort_C: + case sort_unknown: + // the best we can do is translate to lower case, then get a regular sort key: + { + result.assign(p1, p2); + typedef typename string_type::size_type size_type; + for(size_type i = 0; i < result.size(); ++i) + result[i] = this->tolower(result[i]); + result = this->transform(&*result.begin(), &*result.begin() + result.size()); + break; + } + case sort_fixed: + { + // get a regular sort key, and then truncate it: + result.assign(this->transform(p1, p2)); + result.erase(this->m_collate_delim); + break; + } + case sort_delim: + // get a regular sort key, and then truncate everything after the delim: + result.assign(this->transform(p1, p2)); + std::size_t i; + for(i = 0; i < result.size(); ++i) + { + if(result[i] == m_collate_delim) + break; + } + result.erase(i); + break; + } + if(result.empty()) + result = string_type(1, charT(0)); + return result; +} + +template +typename w32_regex_traits_implementation::string_type + w32_regex_traits_implementation::lookup_collatename(const charT* p1, const charT* p2) const +{ + typedef typename std::map::const_iterator iter_type; + if(m_custom_collate_names.size()) + { + iter_type pos = m_custom_collate_names.find(string_type(p1, p2)); + if(pos != m_custom_collate_names.end()) + return pos->second; + } +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) + std::string name(p1, p2); +#else + std::string name; + const charT* p0 = p1; + while(p0 != p2) + name.append(1, char(*p0++)); +#endif + name = lookup_default_collate_name(name); +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) + if(name.size()) + return string_type(name.begin(), name.end()); +#else + if(name.size()) + { + string_type result; + typedef std::string::const_iterator iter; + iter b = name.begin(); + iter e = name.end(); + while(b != e) + result.append(1, charT(*b++)); + return result; + } +#endif + if(p2 - p1 == 1) + return string_type(1, *p1); + return string_type(); +} + +template +w32_regex_traits_implementation::w32_regex_traits_implementation(::boost::re_detail::lcid_type l) +: w32_regex_traits_char_layer(l) +{ + cat_type cat; + std::string cat_name(w32_regex_traits::get_catalog_name()); + if(cat_name.size()) + { + cat = ::boost::re_detail::w32_cat_open(cat_name); + if(!cat) + { + std::string m("Unable to open message catalog: "); + std::runtime_error err(m + cat_name); + boost::re_detail::raise_runtime_error(err); + } + } + // + // if we have a valid catalog then load our messages: + // + if(cat) + { + // + // Error messages: + // + for(boost::regex_constants::error_type i = static_cast(0); + i <= boost::regex_constants::error_unknown; + i = static_cast(i + 1)) + { + const char* p = get_default_error_string(i); + string_type default_message; + while(*p) + { + default_message.append(1, static_cast(*p)); + ++p; + } + string_type s = ::boost::re_detail::w32_cat_get(cat, this->m_locale, i+200, default_message); + std::string result; + for(std::string::size_type j = 0; j < s.size(); ++j) + { + result.append(1, static_cast(s[j])); + } + m_error_strings[i] = result; + } + // + // Custom class names: + // + static const char_class_type masks[14] = + { + 0x0104u, // C1_ALPHA | C1_DIGIT + 0x0100u, // C1_ALPHA + 0x0020u, // C1_CNTRL + 0x0004u, // C1_DIGIT + (~(0x0020u|0x0008u) & 0x01ffu) | 0x0400u, // not C1_CNTRL or C1_SPACE + 0x0002u, // C1_LOWER + (~0x0020u & 0x01ffu) | 0x0400, // not C1_CNTRL + 0x0010u, // C1_PUNCT + 0x0008u, // C1_SPACE + 0x0001u, // C1_UPPER + 0x0080u, // C1_XDIGIT + 0x0040u, // C1_BLANK + w32_regex_traits_implementation::mask_word, + w32_regex_traits_implementation::mask_unicode, + }; + static const string_type null_string; + for(unsigned int j = 0; j <= 13; ++j) + { + string_type s(::boost::re_detail::w32_cat_get(cat, this->m_locale, j+300, null_string)); + if(s.size()) + this->m_custom_class_names[s] = masks[j]; + } + } + // + // get the collation format used by m_pcollate: + // + m_collate_type = re_detail::find_sort_syntax(this, &m_collate_delim); +} + +template +typename w32_regex_traits_implementation::char_class_type + w32_regex_traits_implementation::lookup_classname_imp(const charT* p1, const charT* p2) const +{ + static const char_class_type masks[20] = + { + 0, + 0x0104u, // C1_ALPHA | C1_DIGIT + 0x0100u, // C1_ALPHA + 0x0040u, // C1_BLANK + 0x0020u, // C1_CNTRL + 0x0004u, // C1_DIGIT + 0x0004u, // C1_DIGIT + (~(0x0020u|0x0008u|0x0040) & 0x01ffu) | 0x0400u, // not C1_CNTRL or C1_SPACE or C1_BLANK + 0x0002u, // C1_LOWER + 0x0002u, // C1_LOWER + (~0x0020u & 0x01ffu) | 0x0400, // not C1_CNTRL + 0x0010u, // C1_PUNCT + 0x0008u, // C1_SPACE + 0x0008u, // C1_SPACE + 0x0001u, // C1_UPPER + w32_regex_traits_implementation::mask_unicode, + 0x0001u, // C1_UPPER + 0x0104u | w32_regex_traits_implementation::mask_word, + 0x0104u | w32_regex_traits_implementation::mask_word, + 0x0080u, // C1_XDIGIT + }; + if(m_custom_class_names.size()) + { + typedef typename std::map, char_class_type>::const_iterator map_iter; + map_iter pos = m_custom_class_names.find(string_type(p1, p2)); + if(pos != m_custom_class_names.end()) + return pos->second; + } + std::size_t state_id = 1 + re_detail::get_default_class_id(p1, p2); + if(state_id < sizeof(masks) / sizeof(masks[0])) + return masks[state_id]; + return masks[0]; +} + + +template +boost::shared_ptr > create_w32_regex_traits(::boost::re_detail::lcid_type l BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(charT)) +{ + // TODO: create a cache for previously constructed objects. + return boost::object_cache< ::boost::re_detail::lcid_type, w32_regex_traits_implementation >::get(l, 5); +} + +} // re_detail + +template +class w32_regex_traits +{ +public: + typedef charT char_type; + typedef std::size_t size_type; + typedef std::basic_string string_type; + typedef ::boost::re_detail::lcid_type locale_type; + typedef boost::uint_least32_t char_class_type; + + struct boost_extensions_tag{}; + + w32_regex_traits() + : m_pimpl(re_detail::create_w32_regex_traits(::boost::re_detail::w32_get_default_locale())) + { } + static size_type length(const char_type* p) + { + return std::char_traits::length(p); + } + regex_constants::syntax_type syntax_type(charT c)const + { + return m_pimpl->syntax_type(c); + } + regex_constants::escape_syntax_type escape_syntax_type(charT c) const + { + return m_pimpl->escape_syntax_type(c); + } + charT translate(charT c) const + { + return c; + } + charT translate_nocase(charT c) const + { + return this->m_pimpl->tolower(c); + } + charT translate(charT c, bool icase) const + { + return icase ? this->m_pimpl->tolower(c) : c; + } + charT tolower(charT c) const + { + return this->m_pimpl->tolower(c); + } + charT toupper(charT c) const + { + return ::boost::re_detail::w32_toupper(c, this->m_pimpl->m_locale); + } + string_type transform(const charT* p1, const charT* p2) const + { + return ::boost::re_detail::w32_transform(this->m_pimpl->m_locale, p1, p2); + } + string_type transform_primary(const charT* p1, const charT* p2) const + { + return m_pimpl->transform_primary(p1, p2); + } + char_class_type lookup_classname(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_classname(p1, p2); + } + string_type lookup_collatename(const charT* p1, const charT* p2) const + { + return m_pimpl->lookup_collatename(p1, p2); + } + bool isctype(charT c, char_class_type f) const + { + if((f & re_detail::w32_regex_traits_implementation::mask_base) + && (this->m_pimpl->isctype(f & re_detail::w32_regex_traits_implementation::mask_base, c))) + return true; + else if((f & re_detail::w32_regex_traits_implementation::mask_unicode) && re_detail::is_extended(c)) + return true; + else if((f & re_detail::w32_regex_traits_implementation::mask_word) && (c == '_')) + return true; + return false; + } + int toi(const charT*& p1, const charT* p2, int radix)const + { + return ::boost::re_detail::global_toi(p1, p2, radix, *this); + } + int value(charT c, int radix)const + { + int result = ::boost::re_detail::global_value(c); + return result < radix ? result : -1; + } + locale_type imbue(locale_type l) + { + ::boost::re_detail::lcid_type result(getloc()); + m_pimpl = re_detail::create_w32_regex_traits(l); + return result; + } + locale_type getloc()const + { + return m_pimpl->m_locale; + } + std::string error_string(regex_constants::error_type n) const + { + return m_pimpl->error_string(n); + } + + // + // extension: + // set the name of the message catalog in use (defaults to "boost_regex"). + // + static std::string catalog_name(const std::string& name); + static std::string get_catalog_name(); + +private: + boost::shared_ptr > m_pimpl; + // + // catalog name handler: + // + static std::string& get_catalog_name_inst(); + +#ifdef BOOST_HAS_THREADS + static static_mutex& get_mutex_inst(); +#endif +}; + +template +std::string w32_regex_traits::catalog_name(const std::string& name) +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + get_catalog_name_inst() = name; + return result; +} + +template +std::string& w32_regex_traits::get_catalog_name_inst() +{ + static std::string s_name; + return s_name; +} + +template +std::string w32_regex_traits::get_catalog_name() +{ +#ifdef BOOST_HAS_THREADS + static_mutex::scoped_lock lk(get_mutex_inst()); +#endif + std::string result(get_catalog_name_inst()); + return result; +} + +#ifdef BOOST_HAS_THREADS +template +static_mutex& w32_regex_traits::get_mutex_inst() +{ + static static_mutex s_mutex = BOOST_STATIC_MUTEX_INIT; + return s_mutex; +} +#endif + + +} // boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/regex_fwd.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/regex_fwd.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,33 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org/libs/regex for documentation. + * FILE regex_fwd.cpp + * VERSION see + * DESCRIPTION: Forward declares boost::basic_regex<> and + * associated typedefs. + */ + +#ifndef BOOST_REGEX_FWD_HPP +#define BOOST_REGEX_FWD_HPP + +#ifndef BOOST_REGEX_CONFIG_HPP +#include +#endif + +#include + +#endif + + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/scoped_array.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/scoped_array.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,16 @@ +#ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED +#define BOOST_SCOPED_ARRAY_HPP_INCLUDED + +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// http://www.boost.org/libs/smart_ptr/scoped_array.htm +// + +#include + +#endif // #ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/scoped_ptr.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/scoped_ptr.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,16 @@ +#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED +#define BOOST_SCOPED_PTR_HPP_INCLUDED + +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// http://www.boost.org/libs/smart_ptr/scoped_ptr.htm +// + +#include + +#endif // #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/system/config.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/config.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,75 @@ +// boost/system/config.hpp -------------------------------------------------// + +// Copyright Beman Dawes 2003, 2006 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/system for documentation. + +#ifndef BOOST_SYSTEM_CONFIG_HPP +#define BOOST_SYSTEM_CONFIG_HPP + +#include + +// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use. +// If not specified, a sensible default will be applied. + +# if defined( BOOST_WINDOWS_API ) && defined( BOOST_POSIX_API ) +# error both BOOST_WINDOWS_API and BOOST_POSIX_API are defined +# elif !defined( BOOST_WINDOWS_API ) && !defined( BOOST_POSIX_API ) +# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) +# define BOOST_WINDOWS_API +# else +# define BOOST_POSIX_API +# endif +# endif + +// enable dynamic linking on Windows ---------------------------------------// + +//# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK)) && defined(__BORLANDC__) && defined(__WIN32__) +//# error Dynamic linking Boost.System does not work for Borland; use static linking instead +//# endif + +#ifdef BOOST_HAS_DECLSPEC // defined in config system +// we need to import/export our code only if the user has specifically +// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost +// libraries to be dynamically linked, or BOOST_SYSTEM_DYN_LINK +// if they want just this one to be dynamically liked: +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) +// export if this is our own source, otherwise import: +#ifdef BOOST_SYSTEM_SOURCE +# define BOOST_SYSTEM_DECL __declspec(dllexport) +#else +# define BOOST_SYSTEM_DECL __declspec(dllimport) +#endif // BOOST_SYSTEM_SOURCE +#endif // DYN_LINK +#endif // BOOST_HAS_DECLSPEC +// +// if BOOST_SYSTEM_DECL isn't defined yet define it now: +#ifndef BOOST_SYSTEM_DECL +#define BOOST_SYSTEM_DECL +#endif + +// enable automatic library variant selection ------------------------------// + +#if !defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SYSTEM_NO_LIB) +// +// Set the name of our library, this will get undef'ed by auto_link.hpp +// once it's done with it: +// +#define BOOST_LIB_NAME boost_system +// +// If we're importing code from a dll, then tell auto_link.hpp about it: +// +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) +# define BOOST_DYN_LINK +#endif +// +// And include the header that does the work: +// +#include +#endif // auto-linking disabled + +#endif // BOOST_SYSTEM_CONFIG_HPP + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/system/cygwin_error.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/cygwin_error.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,56 @@ +// boost/system/cygwin_error.hpp -------------------------------------------// + +// Copyright Beman Dawes 2007 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_CYGWIN_ERROR_HPP +#define BOOST_CYGWIN_ERROR_HPP + +// This header is effectively empty for compiles on operating systems where +// it is not applicable. + +# ifdef __CYGWIN__ + +#include + +namespace boost +{ + namespace system + { + // To construct an error_code after a API error: + // + // error_code( errno, system_category ) + + // User code should use the portable "posix" enums for POSIX errors; this + // allows such code to be portable to non-POSIX systems. For the non-POSIX + // errno values that POSIX-based systems typically provide in addition to + // POSIX values, use the system specific enums below. + + namespace cygwin_error + { + enum cygwin_errno + { + no_net = ENONET, + no_package = ENOPKG, + no_share = ENOSHARE + }; + } // namespace cygwin_error + + template<> struct is_error_code_enum + { static const bool value = true; }; + + namespace cygwin_error + { + inline error_code make_error_code( cygwin_errno e ) + { return error_code( e, get_system_category() ); } + } + } +} + +#endif // __CYGWIN__ + +#endif // BOOST_CYGWIN_ERROR_HPP diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/system/error_code.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/error_code.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,501 @@ +// boost/system/error_code.hpp ---------------------------------------------// + +// Copyright Beman Dawes 2006, 2007 +// Copyright Christoper Kohlhoff 2007 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_ERROR_CODE_HPP +#define BOOST_ERROR_CODE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: undef these macros if not already defined +#include + +#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) +# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined +#endif + +#include // must be the last #include + +namespace boost +{ + namespace system + { + + class error_code; + class error_condition; + + // "Concept" helpers ---------------------------------------------------// + + template< class T > + struct is_error_code_enum { static const bool value = false; }; + + template< class T > + struct is_error_condition_enum { static const bool value = false; }; + + // generic error_conditions --------------------------------------------// + + namespace errc + { + enum errc_t + { + success = 0, + address_family_not_supported = EAFNOSUPPORT, + address_in_use = EADDRINUSE, + address_not_available = EADDRNOTAVAIL, + already_connected = EISCONN, + argument_list_too_long = E2BIG, + argument_out_of_domain = EDOM, + bad_address = EFAULT, + bad_file_descriptor = EBADF, + bad_message = EBADMSG, + broken_pipe = EPIPE, + connection_aborted = ECONNABORTED, + connection_already_in_progress = EALREADY, + connection_refused = ECONNREFUSED, + connection_reset = ECONNRESET, + cross_device_link = EXDEV, + destination_address_required = EDESTADDRREQ, + device_or_resource_busy = EBUSY, + directory_not_empty = ENOTEMPTY, + executable_format_error = ENOEXEC, + file_exists = EEXIST, + file_too_large = EFBIG, + filename_too_long = ENAMETOOLONG, + function_not_supported = ENOSYS, + host_unreachable = EHOSTUNREACH, + identifier_removed = EIDRM, + illegal_byte_sequence = EILSEQ, + inappropriate_io_control_operation = ENOTTY, + interrupted = EINTR, + invalid_argument = EINVAL, + invalid_seek = ESPIPE, + io_error = EIO, + is_a_directory = EISDIR, + message_size = EMSGSIZE, + network_down = ENETDOWN, + network_reset = ENETRESET, + network_unreachable = ENETUNREACH, + no_buffer_space = ENOBUFS, + no_child_process = ECHILD, + no_link = ENOLINK, + no_lock_available = ENOLCK, + no_message_available = ENODATA, + no_message = ENOMSG, + no_protocol_option = ENOPROTOOPT, + no_space_on_device = ENOSPC, + no_stream_resources = ENOSR, + no_such_device_or_address = ENXIO, + no_such_device = ENODEV, + no_such_file_or_directory = ENOENT, + no_such_process = ESRCH, + not_a_directory = ENOTDIR, + not_a_socket = ENOTSOCK, + not_a_stream = ENOSTR, + not_connected = ENOTCONN, + not_enough_memory = ENOMEM, + not_supported = ENOTSUP, + operation_canceled = ECANCELED, + operation_in_progress = EINPROGRESS, + operation_not_permitted = EPERM, + operation_not_supported = EOPNOTSUPP, + operation_would_block = EWOULDBLOCK, + owner_dead = EOWNERDEAD, + permission_denied = EACCES, + protocol_error = EPROTO, + protocol_not_supported = EPROTONOSUPPORT, + read_only_file_system = EROFS, + resource_deadlock_would_occur = EDEADLK, + resource_unavailable_try_again = EAGAIN, + result_out_of_range = ERANGE, + state_not_recoverable = ENOTRECOVERABLE, + stream_timeout = ETIME, + text_file_busy = ETXTBSY, + timed_out = ETIMEDOUT, + too_many_files_open_in_system = ENFILE, + too_many_files_open = EMFILE, + too_many_links = EMLINK, + too_many_synbolic_link_levels = ELOOP, + value_too_large = EOVERFLOW, + wrong_protocol_type = EPROTOTYPE + }; + + } // namespace errc + +# ifndef BOOST_SYSTEM_NO_DEPRECATED + namespace posix = errc; + namespace posix_error = errc; +# endif + + template<> struct is_error_condition_enum + { static const bool value = true; }; + + + // ----------------------------------------------------------------------// + + // Operating system specific interfaces --------------------------------// + + + // The interface is divided into general and system-specific portions to + // meet these requirements: + // + // * Code calling an operating system API can create an error_code with + // a single category (system_category), even for POSIX-like operating + // systems that return some POSIX errno values and some native errno + // values. This code should not have to pay the cost of distinguishing + // between categories, since it is not yet known if that is needed. + // + // * Users wishing to write system-specific code should be given enums for + // at least the common error cases. + // + // * System specific code should fail at compile time if moved to another + // operating system. + + // The system specific portions of the interface are located in headers + // with names reflecting the operating system. For example, + // + // + // + // + // + // These headers are effectively empty for compiles on operating systems + // where they are not applicable. + + // ----------------------------------------------------------------------// + + // class error_category ------------------------------------------------// + + class error_category : public noncopyable + { + public: + virtual ~error_category(){} + virtual inline const char * name() const; // see implementation note below + virtual inline std::string message( int ev ) const; // see implementation note below + virtual inline error_condition default_error_condition( int ev ) const; + virtual inline bool equivalent( int code, const error_condition & condition ) const; + virtual inline bool equivalent( const error_code & code, int condition ) const; + + bool operator==(const error_category & rhs) const { return this == &rhs; } + bool operator!=(const error_category & rhs) const { return this != &rhs; } + bool operator<( const error_category & rhs ) const + { + return std::less()( this, &rhs ); + } + }; + + // predefined error categories -----------------------------------------// + + BOOST_SYSTEM_DECL const error_category & get_system_category(); + BOOST_SYSTEM_DECL const error_category & get_generic_category(); + + static const error_category & system_category = get_system_category(); + static const error_category & generic_category = get_generic_category(); + +# ifndef BOOST_SYSTEM_NO_DEPRECATED + // deprecated synonyms + inline const error_category & get_posix_category() { return get_generic_category(); } + static const error_category & posix_category = get_generic_category(); + static const error_category & errno_ecat = get_generic_category(); + static const error_category & native_ecat = get_system_category(); +# endif + + // class error_condition -----------------------------------------------// + + // error_conditions are portable, error_codes are system or library specific + + class error_condition + { + public: + + // constructors: + error_condition() : m_val(0), m_cat(&get_generic_category()) {} + error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} + + template + error_condition(ErrorConditionEnum e, + typename boost::enable_if >::type* = 0) + { + *this = make_error_condition(e); + } + + // modifiers: + + void assign( int val, const error_category & cat ) + { + m_val = val; + m_cat = &cat; + } + + template + typename boost::enable_if, error_condition>::type & + operator=( ErrorConditionEnum val ) + { + *this = make_error_condition(val); + return *this; + } + + void clear() + { + m_val = 0; + m_cat = &get_generic_category(); + } + + // observers: + int value() const { return m_val; } + const error_category & category() const { return *m_cat; } + std::string message() const { return m_cat->message(value()); } + + typedef void (*unspecified_bool_type)(); + static void unspecified_bool_true() {} + + operator unspecified_bool_type() const // true if error + { + return m_val == 0 ? 0 : unspecified_bool_true; + } + + bool operator!() const // true if no error + { + return m_val == 0; + } + + // relationals: + // the more symmetrical non-member syntax allows enum + // conversions work for both rhs and lhs. + inline friend bool operator==( const error_condition & lhs, + const error_condition & rhs ) + { + return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; + } + + inline friend bool operator<( const error_condition & lhs, + const error_condition & rhs ) + // the more symmetrical non-member syntax allows enum + // conversions work for both rhs and lhs. + { + return lhs.m_cat < rhs.m_cat + || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); + } + + private: + int m_val; + const error_category * m_cat; + + }; + + // class error_code ----------------------------------------------------// + + // We want error_code to be a value type that can be copied without slicing + // and without requiring heap allocation, but we also want it to have + // polymorphic behavior based on the error category. This is achieved by + // abstract base class error_category supplying the polymorphic behavior, + // and error_code containing a pointer to an object of a type derived + // from error_category. + class error_code + { + public: + + // constructors: + error_code() : m_val(0), m_cat(&get_system_category()) {} + error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} + + template + error_code(ErrorCodeEnum e, + typename boost::enable_if >::type* = 0) + { + *this = make_error_code(e); + } + + // modifiers: + void assign( int val, const error_category & cat ) + { + m_val = val; + m_cat = &cat; + } + + template + typename boost::enable_if, error_code>::type & + operator=( ErrorCodeEnum val ) + { + *this = make_error_code(val); + return *this; + } + + void clear() + { + m_val = 0; + m_cat = &get_system_category(); + } + + // observers: + int value() const { return m_val; } + const error_category & category() const { return *m_cat; } + error_condition default_error_condition() const { return m_cat->default_error_condition(value()); } + std::string message() const { return m_cat->message(value()); } + + typedef void (*unspecified_bool_type)(); + static void unspecified_bool_true() {} + + operator unspecified_bool_type() const // true if error + { + return m_val == 0 ? 0 : unspecified_bool_true; + } + + bool operator!() const // true if no error + { + return m_val == 0; + } + + // relationals: + inline friend bool operator==( const error_code & lhs, + const error_code & rhs ) + // the more symmetrical non-member syntax allows enum + // conversions work for both rhs and lhs. + { + return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; + } + + inline friend bool operator<( const error_code & lhs, + const error_code & rhs ) + // the more symmetrical non-member syntax allows enum + // conversions work for both rhs and lhs. + { + return lhs.m_cat < rhs.m_cat + || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); + } + + private: + int m_val; + const error_category * m_cat; + + }; + + // predefined error_code object used as "throw on error" tag + BOOST_SYSTEM_DECL extern error_code throws; + + // non-member functions ------------------------------------------------// + + inline bool operator!=( const error_code & lhs, + const error_code & rhs ) + { + return !(lhs == rhs); + } + + inline bool operator!=( const error_condition & lhs, + const error_condition & rhs ) + { + return !(lhs == rhs); + } + + inline bool operator==( const error_code & code, + const error_condition & condition ) + { + return code.category().equivalent( code.value(), condition ) + || condition.category().equivalent( code, condition.value() ); + } + + inline bool operator!=( const error_code & lhs, + const error_condition & rhs ) + { + return !(lhs == rhs); + } + + inline bool operator==( const error_condition & condition, + const error_code & code ) + { + return condition.category().equivalent( code, condition.value() ) + || code.category().equivalent( code.value(), condition ); + } + + inline bool operator!=( const error_condition & lhs, + const error_code & rhs ) + { + return !(lhs == rhs); + } + + // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet. + + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, error_code ec) + { + os << ec.category().name() << ':' << ec.value(); + return os; + } + + inline std::size_t hash_value( const error_code & ec ) + { + return static_cast(ec.value()) + + reinterpret_cast(&ec.category()); + } + + // make_* functions for errc::errc_t -----------------------------// + + namespace errc + { + // explicit conversion: + inline error_code make_error_code( errc_t e ) + { return error_code( e, get_generic_category() ); } + + // implicit conversion: + inline error_condition make_error_condition( errc_t e ) + { return error_condition( e, get_generic_category() ); } + } + + // error_category default implementation -------------------------------// + + inline error_condition error_category::default_error_condition( int ev ) const + { + return error_condition( ev, *this ); + } + + inline bool error_category::equivalent( int code, + const error_condition & condition ) const + { + return default_error_condition( code ) == condition; + } + + inline bool error_category::equivalent( const error_code & code, + int condition ) const + { + return *this == code.category() && code.value() == condition; + } + + // error_category implementation note: VC++ 8.0 objects to name() and + // message() being pure virtual functions. Thus these implementations. + inline const char * error_category::name() const + { + return "error: should never be called"; + } + + inline std::string error_category::message( int ) const + { + static std::string s("error: should never be called"); + return s; + } + + } // namespace system +} // namespace boost + +#include // pops abi_prefix.hpp pragmas + +# ifdef BOOST_ERROR_CODE_HEADER_ONLY +# include +# endif + +#endif // BOOST_ERROR_CODE_HPP + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/system/linux_error.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/linux_error.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,110 @@ +// boost/system/linux_error.hpp -------------------------------------------// + +// Copyright Beman Dawes 2007 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_LINUX_ERROR_HPP +#define BOOST_LINUX_ERROR_HPP + +// This header is effectively empty for compiles on operating systems where +// it is not applicable. + +#if defined(linux) || defined(__linux) || defined(__linux__) + +#include + +namespace boost +{ + namespace system + { + // To construct an error_code after a API error: + // + // error_code( errno, system_category ) + + // User code should use the portable "posix" enums for POSIX errors; this + // allows such code to be portable to non-POSIX systems. For the non-POSIX + // errno values that POSIX-based systems typically provide in addition to + // POSIX values, use the system specific enums below. + + namespace linux_error + { + enum linux_errno + { + advertise_error = EADV, + bad_exchange = EBADE, + bad_file_number = EBADFD, + bad_font_format = EBFONT, + bad_request_code = EBADRQC, + bad_request_descriptor = EBADR, + bad_slot = EBADSLT, + channel_range = ECHRNG, + communication_error = ECOMM, + dot_dot_error = EDOTDOT, + exchange_full = EXFULL, + host_down = EHOSTDOWN, + is_named_file_type= EISNAM, + key_expired = EKEYEXPIRED, + key_rejected = EKEYREJECTED, + key_revoked = EKEYREVOKED, + level2_halt= EL2HLT, + level2_no_syncronized= EL2NSYNC, + level3_halt = EL3HLT, + level3_reset = EL3RST, + link_range = ELNRNG, + medium_type = EMEDIUMTYPE, + no_anode= ENOANO, + no_block_device = ENOTBLK, + no_csi = ENOCSI, + no_key = ENOKEY, + no_medium = ENOMEDIUM, + no_network = ENONET, + no_package = ENOPKG, + not_avail = ENAVAIL, + not_named_file_type= ENOTNAM, + not_recoverable = ENOTRECOVERABLE, + not_unique = ENOTUNIQ, + owner_dead = EOWNERDEAD, + protocol_no_supported = EPFNOSUPPORT, + remote_address_changed = EREMCHG, + remote_io_error = EREMOTEIO, + remote_object = EREMOTE, + restart_needed = ERESTART, + shared_library_access = ELIBACC, + shared_library_bad = ELIBBAD, + shared_library_execute = ELIBEXEC, + shared_library_max_ = ELIBMAX, + shared_library_section= ELIBSCN, + shutdown = ESHUTDOWN, + socket_type_not_supported = ESOCKTNOSUPPORT, + srmount_error = ESRMNT, + stream_pipe_error = ESTRPIPE, + too_many_references = ETOOMANYREFS, + too_many_users = EUSERS, + unattached = EUNATCH, + unclean = EUCLEAN + }; + } // namespace linux_error + +# ifndef BOOST_SYSTEM_NO_DEPRECATED + namespace Linux = linux_error; +# endif + + template<> struct is_error_code_enum + { static const bool value = true; }; + + namespace linux_error + { + inline error_code make_error_code( linux_errno e ) + { return error_code( e, get_system_category() ); } + } + + } // namespace system +} // namespace boost + +#endif // Linux + +#endif // BOOST_LINUX_ERROR_HPP diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/system/system_error.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/system_error.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,81 @@ +// Boost system_error.hpp --------------------------------------------------// + +// Copyright Beman Dawes 2006 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_SYSTEM_ERROR_HPP +#define BOOST_SYSTEM_ERROR_HPP + +#include +#include +#include +#include + +namespace boost +{ + namespace system + { + // class system_error --------------------------------------------------// + + class system_error : public std::runtime_error + { + public: + system_error( error_code ec ) + : std::runtime_error(""), m_error_code(ec) {} + + system_error( error_code ec, const std::string & what_arg ) + : std::runtime_error(what_arg), m_error_code(ec) {} + + system_error( error_code ec, const char* what_arg ) + : std::runtime_error(what_arg), m_error_code(ec) {} + + system_error( int ev, const error_category & ecat ) + : std::runtime_error(""), m_error_code(ev,ecat) {} + + system_error( int ev, const error_category & ecat, + const std::string & what_arg ) + : std::runtime_error(what_arg), m_error_code(ev,ecat) {} + + system_error( int ev, const error_category & ecat, + const char * what_arg ) + : std::runtime_error(what_arg), m_error_code(ev,ecat) {} + + virtual ~system_error() throw() {} + + const error_code & code() const throw() { return m_error_code; } + const char * what() const throw(); + + private: + error_code m_error_code; + mutable std::string m_what; + }; + + // implementation ------------------------------------------------------// + + inline const char * system_error::what() const throw() + // see http://www.boost.org/more/error_handling.html for lazy build rationale + { + if ( m_what.empty() ) + { + try + { + m_what = this->std::runtime_error::what(); + if ( m_error_code ) + { + if ( !m_what.empty() ) m_what += ": "; + m_what += m_error_code.message(); + } + } + catch (...) { return std::runtime_error::what(); } + } + return m_what.c_str(); + } + + } // namespace system +} // namespace boost + +#endif // BOOST_SYSTEM_ERROR_HPP + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/system/windows_error.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/system/windows_error.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,118 @@ +// boost/system/windows_error.hpp ------------------------------------------// + +// Copyright Beman Dawes 2007 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +#ifndef BOOST_WINDOWS_ERROR_HPP +#define BOOST_WINDOWS_ERROR_HPP + +// This header is effectively empty for compiles on operating systems where +// it is not applicable. + +#include + +#ifdef BOOST_WINDOWS_API + +#include +#include + +namespace boost +{ + namespace system + { + + // Microsoft Windows ---------------------------------------------------// + + // To construct an error_code after a API error: + // + // error_code( ::GetLastError(), system_category ) + + namespace windows_error + { + enum windows_error_code + { + success = 0, + // These names and values are based on Windows winerror.h + invalid_function = ERROR_INVALID_FUNCTION, + file_not_found = ERROR_FILE_NOT_FOUND, + path_not_found = ERROR_PATH_NOT_FOUND, + too_many_open_files = ERROR_TOO_MANY_OPEN_FILES, + access_denied = ERROR_ACCESS_DENIED, + invalid_handle = ERROR_INVALID_HANDLE, + arena_trashed = ERROR_ARENA_TRASHED, + not_enough_memory = ERROR_NOT_ENOUGH_MEMORY, + invalid_block = ERROR_INVALID_BLOCK, + bad_environment = ERROR_BAD_ENVIRONMENT, + bad_format = ERROR_BAD_FORMAT, + invalid_access = ERROR_INVALID_ACCESS, + outofmemory = ERROR_OUTOFMEMORY, + invalid_drive = ERROR_INVALID_DRIVE, + current_directory = ERROR_CURRENT_DIRECTORY, + not_same_device = ERROR_NOT_SAME_DEVICE, + no_more_files = ERROR_NO_MORE_FILES, + write_protect = ERROR_WRITE_PROTECT, + bad_unit = ERROR_BAD_UNIT, + not_ready = ERROR_NOT_READY, + bad_command = ERROR_BAD_COMMAND, + crc = ERROR_CRC, + bad_length = ERROR_BAD_LENGTH, + seek = ERROR_SEEK, + not_dos_disk = ERROR_NOT_DOS_DISK, + sector_not_found = ERROR_SECTOR_NOT_FOUND, + out_of_paper = ERROR_OUT_OF_PAPER, + write_fault = ERROR_WRITE_FAULT, + read_fault = ERROR_READ_FAULT, + gen_failure = ERROR_GEN_FAILURE, + sharing_violation = ERROR_SHARING_VIOLATION, + lock_violation = ERROR_LOCK_VIOLATION, + wrong_disk = ERROR_WRONG_DISK, + sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED, + handle_eof = ERROR_HANDLE_EOF, + handle_disk_full= ERROR_HANDLE_DISK_FULL, + rem_not_list = ERROR_REM_NOT_LIST, + dup_name = ERROR_DUP_NAME, + bad_net_path = ERROR_BAD_NETPATH, + network_busy = ERROR_NETWORK_BUSY, + // ... + file_exists = ERROR_FILE_EXISTS, + cannot_make = ERROR_CANNOT_MAKE, + // ... + broken_pipe = ERROR_BROKEN_PIPE, + open_failed = ERROR_OPEN_FAILED, + buffer_overflow = ERROR_BUFFER_OVERFLOW, + disk_full= ERROR_DISK_FULL, + // ... + lock_failed = ERROR_LOCK_FAILED, + busy = ERROR_BUSY, + cancel_violation = ERROR_CANCEL_VIOLATION, + already_exists = ERROR_ALREADY_EXISTS + // ... + + // TODO: add more Windows errors + }; + + } // namespace windows + +# ifndef BOOST_SYSTEM_NO_DEPRECATED + namespace windows = windows_error; +# endif + + template<> struct is_error_code_enum + { static const bool value = true; }; + + namespace windows_error + { + inline error_code make_error_code( windows_error_code e ) + { return error_code( e, get_system_category() ); } + } + + } // namespace system +} // namespace boost + +#endif // BOOST_WINDOWS_API + +#endif // BOOST_WINDOWS_ERROR_HPP diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/array.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/array.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,88 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_ARRAY_HPP_INCLUDED +# define BOOST_TR1_ARRAY_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_ARRAY + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(array) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(array)) +# endif + +#else + +#include +#include +#include +#include + +namespace std{ namespace tr1{ + +using ::boost::array; + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) +// [6.1.3.2] Tuple creation functions +using ::boost::swap; +#endif + +#if !defined(BOOST_TR1_USE_OLD_TUPLE) +}} namespace boost{ namespace fusion{ +#endif + +// [6.2.2.5] Tuple interface to class template array +template struct tuple_size; // forward declaration +template struct tuple_element; // forward declaration +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template +struct tuple_size< ::boost::array > + : public ::boost::integral_constant< ::std::size_t, N>{}; + + +template +struct tuple_element > +{ +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) + BOOST_STATIC_ASSERT(I < (int)N); + BOOST_STATIC_ASSERT(I >= 0); +#endif + typedef T type; +}; +#endif +template +T& get( ::boost::array& a) +{ + BOOST_STATIC_ASSERT(I < N); + BOOST_STATIC_ASSERT(I >= 0); + return a[I]; +} + +template +const T& get(const array& a) +{ + BOOST_STATIC_ASSERT(I < N); + BOOST_STATIC_ASSERT(I >= 0); + return a[I]; +} + +#if !defined(BOOST_TR1_USE_OLD_TUPLE) +}} namespace std{ namespace tr1{ + + using ::boost::fusion::tuple_size; + using ::boost::fusion::tuple_element; + using ::boost::fusion::get; + +#endif + + +} } // namespaces + +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/cmath.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/cmath.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,267 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_CMATH_HPP_INCLUDED +# define BOOST_TR1_CMATH_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_CMATH + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(cmath) +# else +# include +# include BOOST_TR1_HEADER(cmath) +# endif + +#else + +#include + +namespace std{ namespace tr1{ + +using boost::math::tr1::assoc_laguerre; +using boost::math::tr1::assoc_laguerref; +using boost::math::tr1::assoc_laguerrel; +// [5.2.1.2] associated Legendre functions: +using boost::math::tr1::assoc_legendre; +using boost::math::tr1::assoc_legendref; +using boost::math::tr1::assoc_legendrel; +// [5.2.1.3] beta function: +using boost::math::tr1::beta; +using boost::math::tr1::betaf; +using boost::math::tr1::betal; +// [5.2.1.4] (complete) elliptic integral of the first kind: +using boost::math::tr1::comp_ellint_1; +using boost::math::tr1::comp_ellint_1f; +using boost::math::tr1::comp_ellint_1l; +// [5.2.1.5] (complete) elliptic integral of the second kind: +using boost::math::tr1::comp_ellint_2; +using boost::math::tr1::comp_ellint_2f; +using boost::math::tr1::comp_ellint_2l; +// [5.2.1.6] (complete) elliptic integral of the third kind: +using boost::math::tr1::comp_ellint_3; +using boost::math::tr1::comp_ellint_3f; +using boost::math::tr1::comp_ellint_3l; +#if 0 +// [5.2.1.7] confluent hypergeometric functions: +using boost::math::tr1::conf_hyperg; +using boost::math::tr1::conf_hypergf; +using boost::math::tr1::conf_hypergl; +#endif +// [5.2.1.8] regular modified cylindrical Bessel functions: +using boost::math::tr1::cyl_bessel_i; +using boost::math::tr1::cyl_bessel_if; +using boost::math::tr1::cyl_bessel_il; +// [5.2.1.9] cylindrical Bessel functions (of the first kind): +using boost::math::tr1::cyl_bessel_j; +using boost::math::tr1::cyl_bessel_jf; +using boost::math::tr1::cyl_bessel_jl; +// [5.2.1.10] irregular modified cylindrical Bessel functions: +using boost::math::tr1::cyl_bessel_k; +using boost::math::tr1::cyl_bessel_kf; +using boost::math::tr1::cyl_bessel_kl; +// [5.2.1.11] cylindrical Neumann functions; +// cylindrical Bessel functions (of the second kind): +using boost::math::tr1::cyl_neumann; +using boost::math::tr1::cyl_neumannf; +using boost::math::tr1::cyl_neumannl; +// [5.2.1.12] (incomplete) elliptic integral of the first kind: +using boost::math::tr1::ellint_1; +using boost::math::tr1::ellint_1f; +using boost::math::tr1::ellint_1l; +// [5.2.1.13] (incomplete) elliptic integral of the second kind: +using boost::math::tr1::ellint_2; +using boost::math::tr1::ellint_2f; +using boost::math::tr1::ellint_2l; +// [5.2.1.14] (incomplete) elliptic integral of the third kind: +using boost::math::tr1::ellint_3; +using boost::math::tr1::ellint_3f; +using boost::math::tr1::ellint_3l; +// [5.2.1.15] exponential integral: +using boost::math::tr1::expint; +using boost::math::tr1::expintf; +using boost::math::tr1::expintl; +// [5.2.1.16] Hermite polynomials: +using boost::math::tr1::hermite; +using boost::math::tr1::hermitef; +using boost::math::tr1::hermitel; +#if 0 +// [5.2.1.17] hypergeometric functions: +using boost::math::tr1::hyperg; +using boost::math::tr1::hypergf; +using boost::math::tr1::hypergl; +#endif +// [5.2.1.18] Laguerre polynomials: +using boost::math::tr1::laguerre; +using boost::math::tr1::laguerref; +using boost::math::tr1::laguerrel; +// [5.2.1.19] Legendre polynomials: +using boost::math::tr1::legendre; +using boost::math::tr1::legendref; +using boost::math::tr1::legendrel; +// [5.2.1.20] Riemann zeta function: +using boost::math::tr1::riemann_zeta; +using boost::math::tr1::riemann_zetaf; +using boost::math::tr1::riemann_zetal; +// [5.2.1.21] spherical Bessel functions (of the first kind): +using boost::math::tr1::sph_bessel; +using boost::math::tr1::sph_besself; +using boost::math::tr1::sph_bessell; +// [5.2.1.22] spherical associated Legendre functions: +using boost::math::tr1::sph_legendre; +using boost::math::tr1::sph_legendref; +using boost::math::tr1::sph_legendrel; +// [5.2.1.23] spherical Neumann functions; +// spherical Bessel functions (of the second kind): +using boost::math::tr1::sph_neumann; +using boost::math::tr1::sph_neumannf; +using boost::math::tr1::sph_neumannl; + +// types +using boost::math::tr1::double_t; +using boost::math::tr1::float_t; +// functions +using boost::math::tr1::acosh; +using boost::math::tr1::acoshf; +using boost::math::tr1::acoshl; +using boost::math::tr1::asinh; +using boost::math::tr1::asinhf; +using boost::math::tr1::asinhl; +using boost::math::tr1::atanh; +using boost::math::tr1::atanhf; +using boost::math::tr1::atanhl; +using boost::math::tr1::cbrt; +using boost::math::tr1::cbrtf; +using boost::math::tr1::cbrtl; +using boost::math::tr1::copysign; +using boost::math::tr1::copysignf; +using boost::math::tr1::copysignl; +using boost::math::tr1::erf; +using boost::math::tr1::erff; +using boost::math::tr1::erfl; +using boost::math::tr1::erfc; +using boost::math::tr1::erfcf; +using boost::math::tr1::erfcl; +#if 0 +using boost::math::tr1::exp2; +using boost::math::tr1::exp2f; +using boost::math::tr1::exp2l; +#endif +using boost::math::tr1::expm1; +using boost::math::tr1::expm1f; +using boost::math::tr1::expm1l; +#if 0 +using boost::math::tr1::fdim; +using boost::math::tr1::fdimf; +using boost::math::tr1::fdiml; +using boost::math::tr1::fma; +using boost::math::tr1::fmaf; +using boost::math::tr1::fmal; +#endif +using boost::math::tr1::fmax; +using boost::math::tr1::fmaxf; +using boost::math::tr1::fmaxl; +using boost::math::tr1::fmin; +using boost::math::tr1::fminf; +using boost::math::tr1::fminl; +using boost::math::tr1::hypot; +using boost::math::tr1::hypotf; +using boost::math::tr1::hypotl; +#if 0 +using boost::math::tr1::ilogb; +using boost::math::tr1::ilogbf; +using boost::math::tr1::ilogbl; +#endif +using boost::math::tr1::lgamma; +using boost::math::tr1::lgammaf; +using boost::math::tr1::lgammal; +#if 0 +using boost::math::tr1::llrint; +using boost::math::tr1::llrintf; +using boost::math::tr1::llrintl; +#endif +using boost::math::tr1::llround; +using boost::math::tr1::llroundf; +using boost::math::tr1::llroundl; +using boost::math::tr1::log1p; +using boost::math::tr1::log1pf; +using boost::math::tr1::log1pl; +#if 0 +using boost::math::tr1::log2; +using boost::math::tr1::log2f; +using boost::math::tr1::log2l; +using boost::math::tr1::logb; +using boost::math::tr1::logbf; +using boost::math::tr1::logbl; +using boost::math::tr1::lrint; +using boost::math::tr1::lrintf; +using boost::math::tr1::lrintl; +#endif +using boost::math::tr1::lround; +using boost::math::tr1::lroundf; +using boost::math::tr1::lroundl; +#if 0 +using boost::math::tr1::nan; +using boost::math::tr1::nanf; +using boost::math::tr1::nanl; +using boost::math::tr1::nearbyint; +using boost::math::tr1::nearbyintf; +using boost::math::tr1::nearbyintl; +#endif +using boost::math::tr1::nextafter; +using boost::math::tr1::nextafterf; +using boost::math::tr1::nextafterl; +using boost::math::tr1::nexttoward; +using boost::math::tr1::nexttowardf; +using boost::math::tr1::nexttowardl; +#if 0 +using boost::math::tr1::remainder; +using boost::math::tr1::remainderf; +using boost::math::tr1::remainderl; +using boost::math::tr1::remquo; +using boost::math::tr1::remquof; +using boost::math::tr1::remquol; +using boost::math::tr1::rint; +using boost::math::tr1::rintf; +using boost::math::tr1::rintl; +#endif +using boost::math::tr1::round; +using boost::math::tr1::roundf; +using boost::math::tr1::roundl; +#if 0 +using boost::math::tr1::scalbln; +using boost::math::tr1::scalblnf; +using boost::math::tr1::scalblnl; +using boost::math::tr1::scalbn; +using boost::math::tr1::scalbnf; +using boost::math::tr1::scalbnl; +#endif +using boost::math::tr1::tgamma; +using boost::math::tr1::tgammaf; +using boost::math::tr1::tgammal; +using boost::math::tr1::trunc; +using boost::math::tr1::truncf; +using boost::math::tr1::truncl; +// C99 macros defined as C++ templates +using boost::math::tr1::signbit; +using boost::math::tr1::fpclassify; +using boost::math::tr1::isfinite; +using boost::math::tr1::isinf; +using boost::math::tr1::isnan; +using boost::math::tr1::isnormal; +#if 0 +using boost::math::tr1::isgreater; +using boost::math::tr1::isgreaterequal; +using boost::math::tr1::isless; +using boost::math::tr1::islessequal; +using boost::math::tr1::islessgreater; +using boost::math::tr1::isunordered; +#endif +} } // namespaces + +#endif // BOOST_HAS_TR1_CMATH + +#endif // BOOST_TR1_CMATH_HPP_INCLUDED diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/complex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/complex.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,244 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_COMPLEX_HPP_INCLUDED +# define BOOST_TR1_COMPLEX_HPP_INCLUDED +# include +# include + +#ifndef BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG + +#include + +namespace std { +namespace tr1 { + +using boost::math::acos; +using boost::math::asin; +using boost::math::atan; +using boost::math::acosh; +using boost::math::asinh; +using boost::math::atanh; +using boost::math::fabs; + +} } + +#else + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(complex) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(complex)) +# endif + +#endif + +#ifndef BOOST_HAS_TR1_COMPLEX_OVERLOADS + +#include +#include +#include +#include + +namespace std{ + +#ifdef BOOST_NO_STDC_NAMESPACE + using :: atan2; +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(double) arg(const T& t) +{ + return ::std::atan2(0.0, static_cast(t)); +} +#else +inline double arg(const double& t) +{ + return ::std::atan2(0.0, t); +} +#endif +inline long double arg(const long double& t) +{ + return ::std::atan2(0.0L, static_cast(t)); +} +inline float arg(const float& t) +{ + return ::std::atan2(0.0F, static_cast(t)); +} + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(double) norm(const T& t) +{ + double r = static_cast(t); + return r*r; +} +#else +inline double norm(const double& t) +{ + return t*t; +} +#endif +inline long double norm(const long double& t) +{ + long double l = t; + return l*l; +} +inline float norm(const float& t) +{ + float f = t; + return f*f; +} + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(std::complex) conj(const T& t) +{ + return ::std::conj(std::complex(static_cast(t))); +} +#else +inline std::complex conj(const double& t) +{ + return ::std::conj(std::complex(t)); +} +#endif +inline std::complex conj(const long double& t) +{ + return ::std::conj(std::complex(t)); +} +inline std::complex conj(const float& t) +{ + std::complex ct(t); + ct = ::std::conj(ct); + return ct; +} + +#if !BOOST_WORKAROUND(__BORLANDC__, <=0x570) && !BOOST_WORKAROUND(BOOST_MSVC, < 1310) +inline complex polar(const char& rho, const char& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned char& rho, const unsigned char& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const signed char& rho, const signed char& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const short& rho, const short& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned short& rho, const unsigned short& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const int& rho, const int& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned int& rho, const unsigned int& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const long& rho, const long& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned long& rho, const unsigned long& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +#ifdef BOOST_HAS_LONG_LONG +inline complex polar(const long long& rho, const long long& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned long long& rho, const unsigned long long& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +#elif defined(BOOST_HAS_MS_INT64) +inline complex polar(const __int64& rho, const __int64& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +inline complex polar(const unsigned __int64& rho, const unsigned __int64& theta = 0) +{ return ::std::polar(static_cast(rho), static_cast(theta)); } +#endif + +template +inline complex::type> + polar(const T& rho, const U& theta) +{ + typedef typename boost::tr1_detail::promote_to_real::type real_type; + return std::polar(static_cast(rho), static_cast(theta)); +} +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(double) imag(const T& ) +{ + return 0; +} +#else +inline double imag(const double& ) +{ + return 0; +} +#endif +inline long double imag(const long double& ) +{ + return 0; +} +inline float imag(const float& ) +{ + return 0; +} + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template +inline BOOST_TR1_MATH_RETURN(double) real(const T& t) +{ + return static_cast(t); +} +#else +inline double real(const double& t) +{ + return t; +} +#endif +inline long double real(const long double& t) +{ + return t; +} +inline float real(const float& t) +{ + return t; +} + +template +inline complex::type> + pow(const complex& x, const complex& y) +{ + typedef complex::type> result_type; + typedef typename boost::mpl::if_ >, result_type const&, result_type>::type cast1_type; + typedef typename boost::mpl::if_ >, result_type const&, result_type>::type cast2_type; + cast1_type x1(x); + cast2_type y1(y); + return std::pow(x1, y1); +} +template +inline complex::type> + pow (const complex& x, const U& y) +{ + typedef typename boost::tr1_detail::promote_to_real::type real_type; + typedef complex::type> result_type; + typedef typename boost::mpl::if_ >, result_type const&, result_type>::type cast1_type; + real_type r = y; + cast1_type x1(x); + std::complex y1(r); + return std::pow(x1, y1); +} + +template +inline complex::type> + pow (const T& x, const complex& y) +{ + typedef typename boost::tr1_detail::promote_to_real::type real_type; + typedef complex::type> result_type; + typedef typename boost::mpl::if_ >, result_type const&, result_type>::type cast_type; + real_type r = x; + std::complex x1(r); + cast_type y1(y); + return std::pow(x1, y1); +} + +} + +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/detail/config.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/detail/config.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,163 @@ +// (C) Copyright John Maddock 2005-7. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED +# define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED + +#include + +#if defined(__GNUC__) || (!defined(_AIX) && defined(__IBMCPP__) && (__IBMCPP__ >= 800)) +#if !defined(BOOST_HAS_INCLUDE_NEXT) +# define BOOST_HAS_INCLUDE_NEXT +#endif +// Need to find out if we're using GLIBC: +#ifdef BOOST_TR1_UTILITY_INCLUDED +// Oops we're in a recursive include path!! +// Need to include utility, or some std lib header, +// but *not* via or +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_CONFIG_RECURSION +# endif +# if defined(BOOST_HAS_INCLUDE_NEXT) && !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT) +# include_next +# else +# include BOOST_TR1_STD_HEADER(utility) +# endif +# ifdef BOOST_TR1_NO_CONFIG_RECURSION +# undef BOOST_TR1_NO_CONFIG_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#else +#include +#endif +#endif + +#if defined(__GLIBCXX__) && !defined(BOOST_TR1_PATH) +# define BOOST_TR1_PATH(name) tr1/name +#endif +#if !defined(BOOST_TR1_PATH) +# define BOOST_TR1_PATH(name) name +#endif + +#define BOOST_TR1_HEADER(name) + +// Can't use BOOST_WORKAROUND here, it leads to recursive includes: +#if (defined(__BORLANDC__) && (__BORLANDC__ <= 0x600)) || (defined(_MSC_VER) && (_MSC_VER < 1310)) +# define BOOST_TR1_USE_OLD_TUPLE +#endif + +#ifdef __IBMCPP_TR1__ + // turn on support for everything: +# define BOOST_HAS_TR1 +#endif + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# define BOOST_HAS_TR1_COMPLEX_OVERLOADS +# define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG +#endif + +#ifdef BOOST_HAS_TR1 + // turn on support for everything: +# define BOOST_HAS_TR1_ARRAY +# define BOOST_HAS_TR1_COMPLEX_OVERLOADS +# define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG +# define BOOST_HAS_TR1_REFERENCE_WRAPPER +# define BOOST_HAS_TR1_RESULT_OF +# define BOOST_HAS_TR1_MEM_FN +# define BOOST_HAS_TR1_BIND +# define BOOST_HAS_TR1_FUNCTION +# define BOOST_HAS_TR1_HASH +# define BOOST_HAS_TR1_SHARED_PTR +# define BOOST_HAS_TR1_RANDOM +# define BOOST_HAS_TR1_REGEX +# define BOOST_HAS_TR1_TUPLE +# define BOOST_HAS_TR1_TYPE_TRAITS +# define BOOST_HAS_TR1_UTILITY +# define BOOST_HAS_TR1_UNORDERED_MAP +# define BOOST_HAS_TR1_UNORDERED_SET +# define BOOST_HAS_TR1_CMATH + +#endif + +#if defined(__MWERKS__) && (__MWERKS__ >= 0x3205) +// +// Very preliminary MWCW support, may not be right: +// +# define BOOST_HAS_TR1_SHARED_PTR +# define BOOST_HAS_TR1_REFERENCE_WRAPPER +# define BOOST_HAS_TR1_FUNCTION +# define BOOST_HAS_TR1_TUPLE +# define BOOST_HAS_TR1_RESULT_OF +#endif + +#ifdef BOOST_HAS_GCC_TR1 + // turn on support for everything in gcc 4.0.x: +# define BOOST_HAS_TR1_ARRAY +#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 +//# define BOOST_HAS_TR1_COMPLEX_OVERLOADS +# define BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG +#endif +# define BOOST_HAS_TR1_REFERENCE_WRAPPER +# define BOOST_HAS_TR1_RESULT_OF +# define BOOST_HAS_TR1_MEM_FN +# define BOOST_HAS_TR1_BIND +# define BOOST_HAS_TR1_FUNCTION +# define BOOST_HAS_TR1_HASH +# define BOOST_HAS_TR1_SHARED_PTR +#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 +# define BOOST_HAS_TR1_RANDOM +//# define BOOST_HAS_TR1_REGEX +#ifdef _GLIBCXX_USE_C99_MATH_TR1 +# define BOOST_HAS_TR1_CMATH +#endif +#endif +# define BOOST_HAS_TR1_TUPLE +# define BOOST_HAS_TR1_TYPE_TRAITS +# define BOOST_HAS_TR1_UTILITY +# define BOOST_HAS_TR1_UNORDERED_MAP +# define BOOST_HAS_TR1_UNORDERED_SET + +#endif + +#if defined(_MSC_VER) && (_MSC_VER >= 1500) \ + && defined(_MSC_FULL_VER) && \ + !defined(__SGI_STL_PORT) && \ + !defined(_STLPORT_VERSION) && \ + !defined(_RWSTD_VER_STR) && \ + !defined(_RWSTD_VER) +// +// MSVC-9.0 defines a not-quite TR1 conforming hash +// function object in , so we must define +// this here, in addition the feature pack for VC9 +// provides a more or less full TR1 implementation: +// +#if defined(_HAS_TR1) && (_HAS_TR1 + 0) +# define BOOST_HAS_TR1_ARRAY +# define BOOST_HAS_TR1_REFERENCE_WRAPPER +# define BOOST_HAS_TR1_RESULT_OF +# define BOOST_HAS_TR1_MEM_FN +# define BOOST_HAS_TR1_BIND +# define BOOST_HAS_TR1_FUNCTION +# define BOOST_HAS_TR1_HASH +# define BOOST_HAS_TR1_SHARED_PTR +# define BOOST_HAS_TR1_RANDOM +# define BOOST_HAS_TR1_REGEX +# define BOOST_HAS_TR1_TUPLE +# define BOOST_HAS_TR1_TYPE_TRAITS +# define BOOST_HAS_TR1_UTILITY +# define BOOST_HAS_TR1_UNORDERED_MAP +# define BOOST_HAS_TR1_UNORDERED_SET +#else +# define BOOST_HAS_TR1_HASH +#endif +#endif + +#include + +#endif + + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/detail/config_all.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/detail/config_all.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,158 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + * The gcc include path logic is derived from STLport: + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999-2003 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef BOOST_TR1_DETAIL_CONFIG_ALL_HPP_INCLUDED +# define BOOST_TR1_DETAIL_CONFIG_ALL_HPP_INCLUDED + +// +// IMPORTANT: we must figure out the basics, such as how to +// forward to the real std lib headers *without* including +// boost/config.hpp or any of the std lib headers. A classic +// chicken and the egg problem.... +// +// Including at least lets us detect STLport: +// +#include + +// Including allows us to use __GLIBCXX__ to +// determine the version of the stdc++ library in use +// under Darwin. +#include + +# if defined(_RWSTD_VER) && _RWSTD_VER >= 0x04010200 +# if !defined (__SUNPRO_CC) && !defined (__DECCXX) +# define BOOST_TR1_STD_CHEADER(name) <../include/ansi/name> +# endif +# endif + + +# if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && !defined(__BORLANDC__) +# ifdef __SUNPRO_CC + // can't use <../stlport/name> since some compilers put stlport in a different directory: +# define BOOST_TR1_STD_HEADER(name) <../stlport4/name> +# elif defined(__PGI) +# define BOOST_TR1_STD_HEADER(name) <../CC/name> +# else +# define BOOST_TR1_STD_HEADER(name) <../stlport/name> +# endif + +# elif defined(__HP_aCC) + // HP aCC include path: +# define BOOST_TR1_STD_HEADER(name) <../include_std/name> + +# elif defined(__DECCXX) +# define BOOST_TR1_STD_HEADER(name) <../cxx/name> + +# elif defined(__BORLANDC__) && __BORLANDC__ >= 0x570 +# define BOOST_TR1_STD_HEADER(name) <../include/dinkumware/name> + +# elif defined(__GNUC__) && __GNUC__ >= 3 +# if defined(BOOST_TR1_GCC_INCLUDE_PATH) +# define BOOST_TR1_STD_HEADER(name) <../BOOST_TR1_GCC_INCLUDE_PATH/name> +# elif ( (__GNUC__ == 3 ) && ((__GNUC_MINOR__ == 0) || ((__GNUC_MINOR__ < 3) && defined(__APPLE_CC__)))) +# define BOOST_TR1_STD_HEADER(name) <../g++-v3/name> +# else +# if ( ((__GNUC__ == 3 ) && (__GNUC_MINOR__ >= 3)) && (defined(__APPLE_CC__) || defined(__CYGWIN__))) +# define BOOST_TR1_STD_HEADER(name) <../c++/name> +# elif ((__GLIBCXX__ == 20050421) && defined(__APPLE_CC__)) + // Some Darwin tools fix libstdc++ at 4.0.0 irrespective of the actual + // compiler version: +# define BOOST_TR1_STD_HEADER(name) <../4.0.0/name> + /* + * Before version 3.4.0 the 0 patch level was not part of the include path: + */ +# elif defined (__GNUC_PATCHLEVEL__) && ((__GNUC_PATCHLEVEL__ > 0) || \ + (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ + (__GNUC__ > 3)) +# define BOOST_TR1_STD_HEADER(name) <../__GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__/name> +# else +# define BOOST_TR1_STD_HEADER(name) <../__GNUC__.__GNUC_MINOR__/name> +# endif +# endif + +# if !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT) && !defined(__ICC) \ + && (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) + // Disable use of #include_next on Linux as typically we are installed in a directory that is searched + // *after* the std lib include path: +# define BOOST_TR1_DISABLE_INCLUDE_NEXT +# endif + +# else +# define BOOST_TR1_STD_HEADER(name) <../include/name> +# endif + +#if !defined(BOOST_TR1_STD_CHEADER) +# define BOOST_TR1_STD_CHEADER(name) BOOST_TR1_STD_HEADER(name) +#endif + +#if defined(__GNUC__) && !defined(BOOST_HAS_INCLUDE_NEXT) +# define BOOST_HAS_INCLUDE_NEXT +#endif +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# define BOOST_HAS_CPP_0X +#endif + +// +// We may be in the middle of parsing boost/config.hpp +// when this header is included, so don't rely on config +// stuff in the rest of this header... +// +// Find our actual std lib: +// +#if defined(BOOST_HAS_INCLUDE_NEXT) && !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT) +// +// We don't take this branch if BOOST_TR1_DISABLE_INCLUDE_NEXT +// is defined as we may be installed in +// /usr/include, in which case #include_next won't work as our +// include path will occur AFTER the regular std lib one :-( +// +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_CONFIG_ALL_RECURSION +# endif +# include_next +# if (__GNUC__ < 3) +# include_next +# include_next +# endif +# ifdef BOOST_TR1_NO_CONFIG_ALL_RECURSION +# undef BOOST_TR1_NO_CONFIG_ALL_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#else +# include BOOST_TR1_STD_HEADER(utility) +#endif + +#include + +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/detail/functor2iterator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/detail/functor2iterator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_FUNCTOR_IT_HPP_INCLUDED +# define BOOST_TR1_FUNCTOR_IT_HPP_INCLUDED + +# include + +namespace boost{ namespace tr1_details{ + +template +struct functor2iterator : boost::iterator_facade, const R, std::input_iterator_tag> +{ + functor2iterator() : m_func(0){} + functor2iterator(Func& f) + : m_func(&f) + { + m_val = (*m_func)(); + } + const R& dereference()const + { return m_val; } + void increment(){ m_val = (*m_func)(); } + bool equal(const functor2iterator&)const + { return false; } +private: + Func* m_func; + R m_val; +}; + +} } + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/detail/math_overloads.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/detail/math_overloads.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,58 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_MATH_OVERLOADS_HPP_INCLUDED +# define BOOST_TR1_MATH_OVERLOADS_HPP_INCLUDED +# include + +# ifndef BOOST_NO_SFINAE +# include +# include +# define BOOST_TR1_MATH_RETURN(RET) typename ::boost::enable_if< ::boost::is_convertible, RET >::type +# else +# define BOOST_TR1_MATH_RETURN(RET) RET +# endif + +# include +# include +# include + +namespace boost{ namespace tr1_detail{ + +template +struct largest_real +{ + typedef typename boost::mpl::if_< + boost::is_same, + long double, + typename boost::mpl::if_< + boost::is_same, + long double, + typename boost::mpl::if_< + boost::is_same, + double, + typename boost::mpl::if_< + boost::is_same, + double, + float + >::type + >::type + >::type + >::type type; +}; + +template +struct promote_to_real +{ + typedef typename largest_real< + typename boost::mpl::if_< boost::is_floating_point, T, double>::type, + typename boost::mpl::if_< boost::is_floating_point, U, double>::type + >::type type; +}; + +} } + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/functional.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/functional.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,137 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_FUNCTIONAL_HPP_INCLUDED +# define BOOST_TR1_FUNCTIONAL_HPP_INCLUDED +# include +# include + +#if defined(BOOST_HAS_TR1_REFERENCE_WRAPPER) \ + || defined(BOOST_HAS_TR1_RESULT_OF)\ + || defined(BOOST_HAS_TR1_MEM_FN)\ + || defined(BOOST_HAS_TR1_BIND)\ + || defined(BOOST_HAS_TR1_FUNCTION)\ + || defined(BOOST_HAS_TR1_HASH) +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(functional) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(functional)) +# endif +#endif + +#ifndef BOOST_HAS_TR1_REFERENCE_WRAPPER + +#include + +namespace std{ namespace tr1{ + + using ::boost::reference_wrapper; + using ::boost::ref; + using ::boost::cref; + +} } + +#endif // BOOST_HAS_TR1_REFERENCE_WRAPPER + +#if !defined(BOOST_HAS_TR1_RESULT_OF)\ + && !defined(BOOST_NO_SFINAE) && \ + !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + +// +// we can only actually include result_of.hpp if the compiler +// really does support it, otherwise we just get endless errors... +// +#include + +namespace std{ namespace tr1{ + + using ::boost::result_of; + +} } + +#endif // BOOST_HAS_TR1_RESULT_OF + +#ifndef BOOST_HAS_TR1_MEM_FN +// mem_fn: +#include + +namespace std{ namespace tr1{ + +using boost::mem_fn; + +} } + +#endif // BOOST_HAS_TR1_MEM_FN + + +#ifndef BOOST_HAS_TR1_BIND +// Bind: +#include + +namespace std{ namespace tr1{ + + using ::boost::is_bind_expression; + using ::boost::is_placeholder; + using ::boost::bind; + namespace placeholders { +#ifndef BOOST_BIND_NO_PLACEHOLDERS + using ::_1; + using ::_2; + using ::_3; + using ::_4; + using ::_5; + using ::_6; + using ::_7; + using ::_8; + using ::_9; +#endif + } // placeholders + +} } + +#endif + +#ifndef BOOST_HAS_TR1_FUNCTION +// polymorphic function object wrappers: +#include +#include + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x582) \ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1310) \ + && !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX) +namespace std{ namespace tr1{ + + using ::boost::bad_function_call; + using ::boost::function; + using ::boost::swap; + +}} +#endif + +#endif // BOOST_HAS_TR1_FUNCTION + +#ifndef BOOST_HAS_TR1_HASH +// +// This header can get included by boost/hash.hpp +// leading to cyclic dependencies. As a workaround +// we forward declare boost::hash and include +// the actual header later. +// +namespace boost{ +template struct hash; +} + +namespace std{ namespace tr1{ + using ::boost::hash; + +}} + +#include + +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/memory.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/memory.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,72 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_MEMORY_HPP_INCLUDED +# define BOOST_TR1_MEMORY_HPP_INCLUDED +# include +# include +# include + +#ifndef BOOST_HAS_TR1_SHARED_PTR + +// +// This header can get included by boost/shared_ptr.hpp which leads +// to cyclic dependencies, the workaround is to forward declare all +// the boost components, and then include the actual headers afterwards. +// This is fragile, but seems to work, and doesn't require modification +// of boost/shared_ptr.hpp. +// +namespace boost{ + +class bad_weak_ptr; +template class weak_ptr; +template class shared_ptr; +template void swap(weak_ptr & a, weak_ptr & b); +template void swap(shared_ptr & a, shared_ptr & b); +template shared_ptr static_pointer_cast(shared_ptr const & r); +template shared_ptr dynamic_pointer_cast(shared_ptr const & r); +template shared_ptr const_pointer_cast(shared_ptr const & r); +template D * get_deleter(shared_ptr const & p); +template class enable_shared_from_this; + +namespace detail{ +class shared_count; +class weak_count; +} + +} + +namespace std{ namespace tr1{ + + using ::boost::bad_weak_ptr; + using ::boost::shared_ptr; +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) + using ::boost::swap; +#endif + using ::boost::static_pointer_cast; + using ::boost::dynamic_pointer_cast; + using ::boost::const_pointer_cast; + using ::boost::get_deleter; + using ::boost::weak_ptr; + using ::boost::enable_shared_from_this; + +} } +#include +#include +#include + +#else + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(memory) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(memory)) +# endif + +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/random.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/random.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,586 @@ +// (C) Copyright John Maddock 2005. +// (C) Copyright Henry S. Warren 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_RANDOM_HPP_INCLUDED +# define BOOST_TR1_RANDOM_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_RANDOM +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(random) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(random)) +# endif +#else +// Boost.Random: +#include +#ifndef __SUNPRO_CC + // Sunpros linker complains if we so much as include this... +# include +#endif +#include +#include +#include + +namespace std { namespace tr1{ + +using ::boost::variate_generator; + +template +class linear_congruential +{ +private: + typedef ::boost::random::linear_congruential impl_type; +public: + // types + typedef UIntType result_type; + // parameter values + BOOST_STATIC_CONSTANT(UIntType, multiplier = a); + BOOST_STATIC_CONSTANT(UIntType, increment = c); + BOOST_STATIC_CONSTANT(UIntType, modulus = m); + // constructors and member function + explicit linear_congruential(unsigned long x0 = 1) + : m_gen(x0){} + linear_congruential(const linear_congruential& that) + : m_gen(that.m_gen){} + template linear_congruential(Gen& g) + { + init1(g, ::boost::is_same()); + } + void seed(unsigned long x0 = 1) + { m_gen.seed(x0); } + template void seed(Gen& g) + { + init2(g, ::boost::is_fundamental()); + } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.min)(); } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.max)(); } + result_type operator()() + { + return m_gen(); + } + bool operator==(const linear_congruential& that)const + { return m_gen == that.m_gen; } + bool operator!=(const linear_congruential& that)const + { return m_gen != that.m_gen; } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const linear_congruential& lcg) + { + return os << lcg.m_gen; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + linear_congruential& lcg) + { + return is >> lcg.m_gen; + } +#endif + +private: + template + void init1(Gen& g, const ::boost::true_type&) + { + m_gen = g.m_gen; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_gen.seed(static_cast(g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + //typedef typename Gen::result_type gen_rt; + boost::tr1_details::functor2iterator f1(g), f2; + m_gen.seed(f1, f2); + } + impl_type m_gen; +}; + +template +class mersenne_twister +{ + typedef ::boost::random::mersenne_twister + imp_type; +public: + // types + typedef UIntType result_type; + // parameter values + BOOST_STATIC_CONSTANT(int, word_size = w); + BOOST_STATIC_CONSTANT(int, state_size = n); + BOOST_STATIC_CONSTANT(int, shift_size = m); + BOOST_STATIC_CONSTANT(int, mask_bits = r); + BOOST_STATIC_CONSTANT(UIntType, parameter_a = a); + BOOST_STATIC_CONSTANT(int, output_u = u); + BOOST_STATIC_CONSTANT(int, output_s = s); + BOOST_STATIC_CONSTANT(UIntType, output_b = b); + BOOST_STATIC_CONSTANT(int, output_t = t); + BOOST_STATIC_CONSTANT(UIntType, output_c = c); + BOOST_STATIC_CONSTANT(int, output_l = l); + // constructors and member function + mersenne_twister(){} + explicit mersenne_twister(unsigned long value) + : m_gen(value == 0 ? 5489UL : value){} + template mersenne_twister(Gen& g) + { + init1(g, ::boost::is_same()); + } + void seed() + { m_gen.seed(); } + void seed(unsigned long value) + { m_gen.seed(value == 0 ? 5489UL : value); } + template void seed(Gen& g) + { init2(g, ::boost::is_fundamental()); } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.min)(); } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.max)(); } + result_type operator()() + { return m_gen(); } + bool operator==(const mersenne_twister& that)const + { return m_gen == that.m_gen; } + bool operator!=(const mersenne_twister& that)const + { return m_gen != that.m_gen; } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const mersenne_twister& lcg) + { + return os << lcg.m_gen; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + mersenne_twister& lcg) + { + return is >> lcg.m_gen; + } +#endif +private: + template + void init1(Gen& g, const ::boost::true_type&) + { + m_gen = g.m_gen; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_gen.seed(static_cast(g == 0 ? 4357UL : g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + m_gen.seed(g); + } + imp_type m_gen; +}; + +template +class subtract_with_carry +{ +public: + // types + typedef IntType result_type; + // parameter values + BOOST_STATIC_CONSTANT(IntType, modulus = m); + BOOST_STATIC_CONSTANT(int, long_lag = r); + BOOST_STATIC_CONSTANT(int, short_lag = s); + + // constructors and member function + subtract_with_carry(){} + explicit subtract_with_carry(unsigned long value) + : m_gen(value == 0 ? 19780503UL : value){} + template subtract_with_carry(Gen& g) + { init1(g, ::boost::is_same >()); } + void seed(unsigned long value = 19780503ul) + { m_gen.seed(value == 0 ? 19780503UL : value); } + template void seed(Gen& g) + { init2(g, ::boost::is_fundamental()); } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.min)(); } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.max)(); } + result_type operator()() + { return m_gen(); } + bool operator==(const subtract_with_carry& that)const + { return m_gen == that.m_gen; } + bool operator!=(const subtract_with_carry& that)const + { return m_gen != that.m_gen; } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const subtract_with_carry& lcg) + { + return os << lcg.m_gen; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + subtract_with_carry& lcg) + { + return is >> lcg.m_gen; + } +#endif +private: + template + void init1(Gen& g, const ::boost::true_type&) + { + m_gen = g.m_gen; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_gen.seed(static_cast(g == 0 ? 19780503UL : g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + m_gen.seed(g); + } + ::boost::random::subtract_with_carry m_gen; +}; + +template +class subtract_with_carry_01 +{ +public: + // types + typedef RealType result_type; + // parameter values + BOOST_STATIC_CONSTANT(int, word_size = w); + BOOST_STATIC_CONSTANT(int, long_lag = r); + BOOST_STATIC_CONSTANT(int, short_lag = s); + + // constructors and member function + subtract_with_carry_01(){} + explicit subtract_with_carry_01(unsigned long value) + : m_gen(value == 0 ? 19780503UL : value){} + template subtract_with_carry_01(Gen& g) + { init1(g, ::boost::is_same >()); } + void seed(unsigned long value = 19780503UL) + { m_gen.seed(value == 0 ? 19780503UL : value); } + template void seed(Gen& g) + { init2(g, ::boost::is_fundamental()); } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.min)(); } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return (m_gen.max)(); } + result_type operator()() + { return m_gen(); } + bool operator==(const subtract_with_carry_01& that)const + { return m_gen == that.m_gen; } + bool operator!=(const subtract_with_carry_01& that)const + { return m_gen != that.m_gen; } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const subtract_with_carry_01& lcg) + { + return os << lcg.m_gen; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + subtract_with_carry_01& lcg) + { + return is >> lcg.m_gen; + } +#endif +private: + template + void init1(Gen& g, const ::boost::true_type&) + { + m_gen = g.m_gen; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_gen.seed(static_cast(g == 0 ? 19780503UL : g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + //typedef typename Gen::result_type gen_rt; + boost::tr1_details::functor2iterator f1(g), f2; + m_gen.seed(f1, f2); + } + ::boost::random::subtract_with_carry_01 m_gen; +}; + +using ::boost::random::discard_block; + +template +class xor_combine +{ +public: + // types + typedef UniformRandomNumberGenerator1 base1_type; + typedef UniformRandomNumberGenerator2 base2_type; + typedef unsigned long result_type; + // parameter values + BOOST_STATIC_CONSTANT(int, shift1 = s1); + BOOST_STATIC_CONSTANT(int, shift2 = s2); + // constructors and member function + xor_combine(){ init_minmax(); } + xor_combine(const base1_type & rng1, const base2_type & rng2) + : m_b1(rng1), m_b2(rng2) { init_minmax(); } + xor_combine(unsigned long s) + : m_b1(s), m_b2(s+1) { init_minmax(); } + template xor_combine(Gen& g) + { + init_minmax(); + init1(g, ::boost::is_same >()); + } + void seed() + { + m_b1.seed(); + m_b2.seed(); + } + void seed(unsigned long s) + { + m_b1.seed(s); + m_b2.seed(s+1); + } + template void seed(Gen& g) + { + init2(g, ::boost::is_fundamental()); + } + + const base1_type& base1() const + { return m_b1; } + const base2_type& base2() const + { return m_b2; } + result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return m_min; } + result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const + { return m_max; } + result_type operator()() + { return (m_b1() << s1) ^ (m_b2() << s2); } + + bool operator == (const xor_combine& that)const + { return (m_b1 == that.m_b1) && (m_b2 == that.m_b2); } + bool operator != (const xor_combine& that)const + { return !(*this == that); } + +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const xor_combine& lcg) + { + return os << lcg.m_b1 << " " << lcg.m_b2; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + xor_combine& lcg) + { + return is >> lcg.m_b1 >> lcg.m_b2; + } +#endif + +private: + void init_minmax(); + base1_type m_b1; + base2_type m_b2; + result_type m_min; + result_type m_max; + + template + void init1(Gen& g, const ::boost::true_type&) + { + m_b1 = g.m_b1; + m_b2 = g.m_b2; + } + template + void init1(Gen& g, const ::boost::false_type&) + { + init2(g, ::boost::is_fundamental()); + } + template + void init2(Gen& g, const ::boost::true_type&) + { + m_b1.seed(static_cast(g)); + m_b2.seed(static_cast(g)); + } + template + void init2(Gen& g, const ::boost::false_type&) + { + m_b1.seed(g); + m_b2.seed(g); + } +}; + +template +void xor_combine::init_minmax() +{ + // + // The following code is based on that given in "Hacker's Delight" + // by Henry S. Warren, (Addison-Wesley, 2003), and at + // http://www.hackersdelight.org/index.htm. + // Used here by permission. + // + // calculation of minimum value: + // + result_type a = (m_b1.min)() << s1; + result_type b = (m_b1.max)() << s1; + result_type c = (m_b2.min)() << s2; + result_type d = (m_b2.max)() << s2; + result_type m, temp; + + m = 0x1uL << ((sizeof(result_type) * CHAR_BIT) - 1); + while (m != 0) { + if (~a & c & m) { + temp = (a | m) & (static_cast(0u) - m); + if (temp <= b) a = temp; + } + else if (a & ~c & m) { + temp = (c | m) & (static_cast(0u) - m); + if (temp <= d) c = temp; + } + m >>= 1; + } + m_min = a ^ c; + + // + // calculation of maximum value: + // + if((((std::numeric_limits::max)() >> s1) < (m_b1.max)()) + || ((((std::numeric_limits::max)()) >> s2) < (m_b2.max)())) + { + m_max = (std::numeric_limits::max)(); + return; + } + a = (m_b1.min)() << s1; + b = (m_b1.max)() << s1; + c = (m_b2.min)() << s2; + d = (m_b2.max)() << s2; + + m = 0x1uL << ((sizeof(result_type) * CHAR_BIT) - 1); + + while (m != 0) { + if (b & d & m) { + temp = (b - m) | (m - 1); + if (temp >= a) b = temp; + else { + temp = (d - m) | (m - 1); + if (temp >= c) d = temp; + } + } + m = m >> 1; + } + m_max = b ^ d; +} + +typedef linear_congruential< ::boost::int32_t, 16807, 0, 2147483647> minstd_rand0; +typedef linear_congruential< ::boost::int32_t, 48271, 0, 2147483647> minstd_rand; +typedef mersenne_twister< ::boost::uint32_t, 32,624,397,31,0x9908b0df,11,7,0x9d2c5680,15,0xefc60000,18> mt19937; +typedef subtract_with_carry_01 ranlux_base_01; +typedef subtract_with_carry_01 ranlux64_base_01; +typedef discard_block, 223, 24> ranlux3; +typedef discard_block, 389, 24> ranlux4; +typedef discard_block, 223, 24> ranlux3_01; +typedef discard_block, 389, 24> ranlux4_01; + +#ifndef __SUNPRO_CC +using ::boost::random_device; +#endif +using ::boost::uniform_int; + +class bernoulli_distribution +{ +public: + // types + typedef int input_type; + typedef bool result_type; + // constructors and member function + explicit bernoulli_distribution(double p = 0.5) + : m_dist(p){} + double p() const + { return m_dist.p(); } + void reset() + { m_dist.reset(); } + template + result_type operator()(UniformRandomNumberGenerator& urng) + { + return m_dist(urng); + } +#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, + const bernoulli_distribution& lcg) + { + return os << lcg.m_dist; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, + bernoulli_distribution& lcg) + { + return is >> lcg.m_dist; + } +#endif + +private: + ::boost::bernoulli_distribution m_dist; +}; +//using ::boost::bernoulli_distribution; +using ::boost::geometric_distribution; +using ::boost::poisson_distribution; +using ::boost::binomial_distribution; +using ::boost::uniform_real; +using ::boost::exponential_distribution; +using ::boost::normal_distribution; +using ::boost::gamma_distribution; + +} } + +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/regex.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/regex.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,147 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_REGEX_HPP_INCLUDED +# define BOOST_TR1_REGEX_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_REGEX + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(regex) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(regex)) +# endif + +#else + +#include + +namespace std{ namespace tr1{ + +// [7.5] Regex constants +namespace regex_constants { + +using ::boost::regex_constants::syntax_option_type; +using ::boost::regex_constants::icase; +using ::boost::regex_constants::nosubs; +using ::boost::regex_constants::optimize; +using ::boost::regex_constants::collate; +using ::boost::regex_constants::ECMAScript; +using ::boost::regex_constants::basic; +using ::boost::regex_constants::extended; +using ::boost::regex_constants::awk; +using ::boost::regex_constants::grep; +using ::boost::regex_constants::egrep; + +using ::boost::regex_constants::match_flag_type; +using ::boost::regex_constants::match_default; +using ::boost::regex_constants::match_not_bol; +using ::boost::regex_constants::match_not_eol; +using ::boost::regex_constants::match_not_bow; +using ::boost::regex_constants::match_not_eow; +using ::boost::regex_constants::match_any; +using ::boost::regex_constants::match_not_null; +using ::boost::regex_constants::match_continuous; +using ::boost::regex_constants::match_prev_avail; +using ::boost::regex_constants::format_default; +using ::boost::regex_constants::format_sed; +using ::boost::regex_constants::format_no_copy; +using ::boost::regex_constants::format_first_only; + +using ::boost::regex_constants::error_type; +using ::boost::regex_constants::error_collate; +using ::boost::regex_constants::error_ctype; +using ::boost::regex_constants::error_escape; +using ::boost::regex_constants::error_backref; +using ::boost::regex_constants::error_brack; +using ::boost::regex_constants::error_paren; +using ::boost::regex_constants::error_brace; +using ::boost::regex_constants::error_badbrace; +using ::boost::regex_constants::error_range; +using ::boost::regex_constants::error_space; +using ::boost::regex_constants::error_badrepeat; +using ::boost::regex_constants::error_complexity; +using ::boost::regex_constants::error_stack; + +} // namespace regex_constants + +// [7.6] Class regex_error +using ::boost::regex_error; + +// [7.7] Class template regex_traits +using ::boost::regex_traits; + +// [7.8] Class template basic_regex +using ::boost::basic_regex; +using ::boost::regex; +#ifndef BOOST_NO_WREGEX +using ::boost::wregex; +#endif + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) +// [7.8.6] basic_regex swap +using ::boost::swap; +#endif + +// [7.9] Class template sub_match +using ::boost::sub_match; + +using ::boost::csub_match; +#ifndef BOOST_NO_WREGEX +using ::boost::wcsub_match; +#endif +using ::boost::ssub_match; +#ifndef BOOST_NO_WREGEX +using ::boost::wssub_match; +#endif + +// [7.10] Class template match_results +using ::boost::match_results; +using ::boost::cmatch; +#ifndef BOOST_NO_WREGEX +using ::boost::wcmatch; +#endif +using ::boost::smatch; +#ifndef BOOST_NO_WREGEX +using ::boost::wsmatch; +#endif + +using ::boost::regex_match; + +// [7.11.3] Function template regex_search +using ::boost::regex_search; + +// [7.11.4] Function template regex_replace +using ::boost::regex_replace; + +// [7.12.1] Class template regex_iterator +using ::boost::regex_iterator; +using ::boost::cregex_iterator; +#ifndef BOOST_NO_WREGEX +using ::boost::wcregex_iterator; +#endif +using ::boost::sregex_iterator; +#ifndef BOOST_NO_WREGEX +using ::boost::wsregex_iterator; +#endif + +// [7.12.2] Class template regex_token_iterator +using ::boost::regex_token_iterator; +using ::boost::cregex_token_iterator; +#ifndef BOOST_NO_WREGEX +using ::boost::wcregex_token_iterator; +#endif +using ::boost::sregex_token_iterator; +#ifndef BOOST_NO_WREGEX +using ::boost::wsregex_token_iterator; +#endif + +} } // namespaces + +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/algorithm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/algorithm Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_algorithm_INCLUDED +# define BOOST_TR1_algorithm_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_algorithm_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(algorithm) +# endif +# ifdef BOOST_TR1_NO_algorithm_RECURSION +# undef BOOST_TR1_NO_algorithm_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/array --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/array Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#if !defined(BOOST_TR1_ARRAY_INCLUDED) +# define BOOST_TR1_ARRAY_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(array) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_ARRAY +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(array) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(array)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +#endif +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/array.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/array.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_ARRAY_H_INCLUDED) +# define BOOST_TR1_ARRAY_H_INCLUDED +# include +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/random.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/random.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_RANDOM_H_INCLUDED) +# define BOOST_TR1_RANDOM_H_INCLUDED +# include +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/regex.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/regex.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_REGEX_H_INCLUDED) +# define BOOST_TR1_REGEX_H_INCLUDED +# include +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/tuple.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/tuple.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_TUPLE_H_INCLUDED) +# define BOOST_TR1_TUPLE_H_INCLUDED +# include +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/type_tra.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/type_tra.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,13 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_TYPE_TRAITS_H_INCLUDED) +# define BOOST_TR1_TYPE_TRAITS_H_INCLUDED +# include +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/unordere.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bcc32/unordere.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,15 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// Forwarding header for Borland C++: +// +#if !defined(BOOST_TR1_UNORDERED_H_INCLUDED) +# define BOOST_TR1_UNORDERED_H_INCLUDED +# include +# include +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/bitset --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/bitset Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_bitset_INCLUDED +# define BOOST_TR1_bitset_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_bitset_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(bitset) +# endif +# ifdef BOOST_TR1_NO_bitset_RECURSION +# undef BOOST_TR1_NO_bitset_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/cmath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/cmath Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,41 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#if !defined(BOOST_TR1_CMATH_INCLUDED) || defined(BOOST_TR1_NO_RECURSION) +#ifndef BOOST_TR1_CMATH_INCLUDED +# define BOOST_TR1_CMATH_INCLUDED +#endif +# ifdef BOOST_TR1_NO_CMATH_RECURSION2 +# define BOOST_TR1_NO_CMATH_RECURSION3 +# elif defined(BOOST_TR1_NO_CMATH_RECURSION) +# define BOOST_TR1_NO_CMATH_RECURSION2 +# elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_CMATH_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_CHEADER(cmath) +# endif +#ifdef BOOST_TR1_NO_CMATH_RECURSION3 +# undef BOOST_TR1_NO_CMATH_RECURSION3 +#elif defined(BOOST_TR1_NO_CMATH_RECURSION2) +# undef BOOST_TR1_NO_CMATH_RECURSION2 +#elif defined(BOOST_TR1_NO_CMATH_RECURSION) +# undef BOOST_TR1_NO_RECURSION +# undef BOOST_TR1_NO_CMATH_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_CMATH_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_CMATH_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/complex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/complex Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,31 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_TR1_COMPLEX_INCLUDED +# define BOOST_TR1_COMPLEX_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_COMPLEX_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(complex) +# endif +# ifdef BOOST_TR1_NO_COMPLEX_RECURSION +# undef BOOST_TR1_NO_COMPLEX_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_COMPLEX_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_COMPLEX_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/deque --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/deque Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_deque_INCLUDED +# define BOOST_TR1_deque_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_deque_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(deque) +# endif +# ifdef BOOST_TR1_NO_deque_RECURSION +# undef BOOST_TR1_NO_deque_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/exception --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/exception Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,39 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +// Important: there are no include guards on this header for Borland C++ +// The Borland version of has some peculiar circular dependencies +// that requires multiple inclusion. Likewise for gcc (gcc-2.95.3 fix). +// +#ifdef BOOST_TR1_NO_exception_RECURSION2 +# define BOOST_TR1_NO_exception_RECURSION3 +#elif defined(BOOST_TR1_NO_exception_RECURSION) +# define BOOST_TR1_NO_exception_RECURSION2 +#elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_exception_RECURSION +#endif + +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(exception) +# endif + +#ifdef BOOST_TR1_NO_exception_RECURSION3 +# undef BOOST_TR1_NO_exception_RECURSION3 +#elif defined(BOOST_TR1_NO_exception_RECURSION2) +# undef BOOST_TR1_NO_exception_RECURSION2 +#elif defined(BOOST_TR1_NO_exception_RECURSION) +# undef BOOST_TR1_NO_exception_RECURSION +# undef BOOST_TR1_NO_RECURSION +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/fstream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/fstream Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_fstream_INCLUDED +# define BOOST_TR1_fstream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_fstream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(fstream) +# endif +# ifdef BOOST_TR1_NO_fstream_RECURSION +# undef BOOST_TR1_NO_fstream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/functional --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/functional Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,30 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(BOOST_TR1_FUNCTIONAL_INCLUDED) +# define BOOST_TR1_FUNCTIONAL_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_FUNCTIONAL_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(functional) +# endif +# ifdef BOOST_TR1_NO_FUNCTIONAL_RECURSION +# undef BOOST_TR1_NO_FUNCTIONAL_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_FUNCTIONAL_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_FUNCTIONAL_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/iomanip --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/iomanip Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_iomanip_INCLUDED +# define BOOST_TR1_iomanip_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_iomanip_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(iomanip) +# endif +# ifdef BOOST_TR1_NO_iomanip_RECURSION +# undef BOOST_TR1_NO_iomanip_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/ios --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/ios Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_ios_INCLUDED +# define BOOST_TR1_ios_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_ios_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(ios) +# endif +# ifdef BOOST_TR1_NO_ios_RECURSION +# undef BOOST_TR1_NO_ios_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/iostream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/iostream Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_iostream_INCLUDED +# define BOOST_TR1_iostream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_iostream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(iostream) +# endif +# ifdef BOOST_TR1_NO_iostream_RECURSION +# undef BOOST_TR1_NO_iostream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/istream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/istream Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_istream_INCLUDED +# define BOOST_TR1_istream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_istream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(istream) +# endif +# ifdef BOOST_TR1_NO_istream_RECURSION +# undef BOOST_TR1_NO_istream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/iterator --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/iterator Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_iterator_INCLUDED +# define BOOST_TR1_iterator_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_iterator_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(iterator) +# endif +# ifdef BOOST_TR1_NO_iterator_RECURSION +# undef BOOST_TR1_NO_iterator_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/limits --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/limits Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_limits_INCLUDED +# define BOOST_TR1_limits_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_limits_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(limits) +# endif +# ifdef BOOST_TR1_NO_limits_RECURSION +# undef BOOST_TR1_NO_limits_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/list Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_list_INCLUDED +# define BOOST_TR1_list_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_list_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(list) +# endif +# ifdef BOOST_TR1_NO_list_RECURSION +# undef BOOST_TR1_NO_list_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/locale --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/locale Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_locale_INCLUDED +# define BOOST_TR1_locale_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_locale_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(locale) +# endif +# ifdef BOOST_TR1_NO_locale_RECURSION +# undef BOOST_TR1_NO_locale_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/map --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/map Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_map_INCLUDED +# define BOOST_TR1_map_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_map_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(map) +# endif +# ifdef BOOST_TR1_NO_map_RECURSION +# undef BOOST_TR1_NO_map_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/memory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/memory Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,31 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_TR1_MEMORY_INCLUDED +# define BOOST_TR1_MEMORY_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_MEMORY_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(memory) +# endif +# ifdef BOOST_TR1_NO_MEMORY_RECURSION +# undef BOOST_TR1_NO_MEMORY_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_MEMORY_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_MEMORY_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/new --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/new Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,35 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifdef BOOST_TR1_NO_new_RECURSION2 +# define BOOST_TR1_NO_new_RECURSION3 +#elif defined(BOOST_TR1_NO_new_RECURSION) +# define BOOST_TR1_NO_new_RECURSION2 +#elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_new_RECURSION +#endif + +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(new) +# endif + +#ifdef BOOST_TR1_NO_new_RECURSION3 +# undef BOOST_TR1_NO_new_RECURSION3 +#elif defined(BOOST_TR1_NO_new_RECURSION2) +# undef BOOST_TR1_NO_new_RECURSION2 +#elif defined(BOOST_TR1_NO_new_RECURSION) +# undef BOOST_TR1_NO_new_RECURSION +# undef BOOST_TR1_NO_RECURSION +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/numeric --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/numeric Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_numeric_INCLUDED +# define BOOST_TR1_numeric_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_numeric_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(numeric) +# endif +# ifdef BOOST_TR1_NO_numeric_RECURSION +# undef BOOST_TR1_NO_numeric_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/ostream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/ostream Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_ostream_INCLUDED +# define BOOST_TR1_ostream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_ostream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(ostream) +# endif +# ifdef BOOST_TR1_NO_ostream_RECURSION +# undef BOOST_TR1_NO_ostream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/queue --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/queue Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_queue_INCLUDED +# define BOOST_TR1_queue_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_queue_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(queue) +# endif +# ifdef BOOST_TR1_NO_queue_RECURSION +# undef BOOST_TR1_NO_queue_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/random --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/random Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_TR1_RANDOM_INCLUDED +# define BOOST_TR1_RANDOM_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(random) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_RANDOM +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(random) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(random)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/regex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/regex Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,22 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_TR1_REGEX_INCLUDED +# define BOOST_TR1_REGEX_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# ifdef BOOST_HAS_TR1_REGEX +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(regex) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(regex)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/set --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/set Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_set_INCLUDED +# define BOOST_TR1_set_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_set_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(set) +# endif +# ifdef BOOST_TR1_NO_set_RECURSION +# undef BOOST_TR1_NO_set_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sstream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sstream Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_sstream_INCLUDED +# define BOOST_TR1_sstream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_sstream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(sstream) +# endif +# ifdef BOOST_TR1_NO_sstream_RECURSION +# undef BOOST_TR1_NO_sstream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/stack --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/stack Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_stack_INCLUDED +# define BOOST_TR1_stack_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_stack_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(stack) +# endif +# ifdef BOOST_TR1_NO_stack_RECURSION +# undef BOOST_TR1_NO_stack_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/stdexcept --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/stdexcept Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifdef BOOST_TR1_NO_stdexcept_RECURSION2 +# define BOOST_TR1_NO_stdexcept_RECURSION3 +#elif defined(BOOST_TR1_NO_stdexcept_RECURSION) +# define BOOST_TR1_NO_stdexcept_RECURSION2 +#elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_stdexcept_RECURSION +#endif + +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(stdexcept) +# endif + +#ifdef BOOST_TR1_NO_stdexcept_RECURSION3 +# undef BOOST_TR1_NO_stdexcept_RECURSION3 +#elif defined(BOOST_TR1_NO_stdexcept_RECURSION2) +# undef BOOST_TR1_NO_stdexcept_RECURSION2 +#elif defined(BOOST_TR1_NO_stdexcept_RECURSION) +# undef BOOST_TR1_NO_stdexcept_RECURSION +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/streambuf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/streambuf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_streambuf_INCLUDED +# define BOOST_TR1_streambuf_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_streambuf_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(streambuf) +# endif +# ifdef BOOST_TR1_NO_streambuf_RECURSION +# undef BOOST_TR1_NO_streambuf_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/string --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/string Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_string_INCLUDED +# define BOOST_TR1_string_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_string_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(string) +# endif +# ifdef BOOST_TR1_NO_string_RECURSION +# undef BOOST_TR1_NO_string_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/strstream --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/strstream Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_strstream_INCLUDED +# define BOOST_TR1_strstream_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_strstream_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(strstream) +# endif +# ifdef BOOST_TR1_NO_strstream_RECURSION +# undef BOOST_TR1_NO_strstream_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/algorithm.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/algorithm.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../algorithm" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/array.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/array.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../array" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/bcc32.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/bcc32.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../bcc32" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/bitset.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/bitset.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../bitset" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/cmath.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/cmath.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,7 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../cmath" + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/complex.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/complex.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../complex" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/deque.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/deque.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../deque" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/exception.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/exception.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../exception" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/fstream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/fstream.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../fstream" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/functional.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/functional.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../functional" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iomanip.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iomanip.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../iomanip" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/ios.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/ios.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../ios" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iostream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iostream.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../iostream" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/istream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/istream.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../istream" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iterator.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/iterator.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../iterator" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/limits.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/limits.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../limits" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/list.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/list.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../list" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/locale.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/locale.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../locale" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/map.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/map.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../map" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/memory.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/memory.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../memory" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/new.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/new.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../new" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/numeric.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/numeric.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../numeric" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/ostream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/ostream.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../ostream" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/queue.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/queue.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../queue" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/random.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/random.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../random" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/regex.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/regex.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../regex" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/set.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/set.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../set" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/sstream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/sstream.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../sstream" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/stack.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/stack.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../stack" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/stdexcept.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/stdexcept.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../stdexcept" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/streambuf.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/streambuf.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../streambuf" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/string.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/string.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../string" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/strstream.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/strstream.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../strstream" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/sun.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/sun.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../sun" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/tuple.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/tuple.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../tuple" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/type_traits.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/type_traits.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../type_traits" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/typeinfo.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/typeinfo.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../typeinfo" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/unordered_map.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/unordered_map.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,7 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../unordered_map" + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/unordered_set.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/unordered_set.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,7 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../unordered_set" + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/utility.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/utility.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../utility" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/valarray.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/valarray.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../valarray" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/vector.SUNWCCh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/sun/vector.SUNWCCh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,6 @@ +// (C) Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include "../vector" + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/tuple --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/tuple Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_TR1_TUPLE_INCLUDED +# define BOOST_TR1_TUPLE_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(tuple) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_TUPLE +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(tuple) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(tuple)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/type_traits --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/type_traits Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,43 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#include + +#if (!defined(BOOST_TR1_TYPE_TRAITS_INCLUDED) || defined(BOOST_TR1_NO_RECURSION)) && defined(BOOST_HAS_CPP_0X) +#ifndef BOOST_TR1_TYPE_TRAITS_INCLUDED +# define BOOST_TR1_TYPE_TRAITS_INCLUDED +#endif +# ifdef BOOST_TR1_NO_TYPE_TRAITS_RECURSION2 +# define BOOST_TR1_NO_TYPE_TRAITS_RECURSION3 +# elif defined(BOOST_TR1_NO_TYPE_TRAITS_RECURSION) +# define BOOST_TR1_NO_TYPE_TRAITS_RECURSION2 +# elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_TYPE_TRAITS_RECURSION +# endif +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(type_traits) +# endif +#ifdef BOOST_TR1_NO_TYPE_TRAITS_RECURSION3 +# undef BOOST_TR1_NO_TYPE_TRAITS_RECURSION3 +#elif defined(BOOST_TR1_NO_TYPE_TRAITS_RECURSION2) +# undef BOOST_TR1_NO_TYPE_TRAITS_RECURSION2 +#elif defined(BOOST_TR1_NO_TYPE_TRAITS_RECURSION) +# undef BOOST_TR1_NO_RECURSION +# undef BOOST_TR1_NO_TYPE_TRAITS_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_TYPE_TRAITS_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_TYPE_TRAITS_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/typeinfo --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/typeinfo Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_typeinfo_INCLUDED +# define BOOST_TR1_typeinfo_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_typeinfo_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(typeinfo) +# endif +# ifdef BOOST_TR1_NO_typeinfo_RECURSION +# undef BOOST_TR1_NO_typeinfo_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/unordered_map --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/unordered_map Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_TR1_UNORDERED_MAP_INCLUDED +# define BOOST_TR1_UNORDERED_MAP_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(unordered_map) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_UNORDERED_MAP +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(unordered_map) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_map)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/unordered_set --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/unordered_set Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,34 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_TR1_UNORDERED_SET_INCLUDED +# define BOOST_TR1_UNORDERED_SET_INCLUDED +# include + +# ifdef BOOST_HAS_CPP_0X +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(unordered_map) +# endif +# endif + +# if !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# ifdef BOOST_HAS_TR1_UNORDERED_SET +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(unordered_set) +# else +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_set)) +# endif +# else +# include +# endif +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/utility --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/utility Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,41 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +#if !defined(BOOST_TR1_UTILITY_INCLUDED) || defined(BOOST_TR1_NO_RECURSION) +#ifndef BOOST_TR1_UTILITY_INCLUDED +# define BOOST_TR1_UTILITY_INCLUDED +#endif +# ifdef BOOST_TR1_NO_UTILITY_RECURSION2 +# define BOOST_TR1_NO_UTILITY_RECURSION3 +# elif defined(BOOST_TR1_NO_UTILITY_RECURSION) +# define BOOST_TR1_NO_UTILITY_RECURSION2 +# elif !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_UTILITY_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(utility) +# endif +#ifdef BOOST_TR1_NO_UTILITY_RECURSION3 +# undef BOOST_TR1_NO_UTILITY_RECURSION3 +#elif defined(BOOST_TR1_NO_UTILITY_RECURSION2) +# undef BOOST_TR1_NO_UTILITY_RECURSION2 +#elif defined(BOOST_TR1_NO_UTILITY_RECURSION) +# undef BOOST_TR1_NO_RECURSION +# undef BOOST_TR1_NO_UTILITY_RECURSION +# endif +#endif + +#if !defined(BOOST_TR1_FULL_UTILITY_INCLUDED) && !defined(BOOST_TR1_NO_RECURSION) +# define BOOST_TR1_FULL_UTILITY_INCLUDED +# define BOOST_TR1_NO_RECURSION +# include +# undef BOOST_TR1_NO_RECURSION +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/valarray --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/valarray Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_valarray_INCLUDED +# define BOOST_TR1_valarray_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_valarray_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(valarray) +# endif +# ifdef BOOST_TR1_NO_valarray_RECURSION +# undef BOOST_TR1_NO_valarray_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tr1/vector --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tr1/vector Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,27 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This file exists to prevent std lib headers from accidentally +// including a TR1 extention header; we must suppress this otherwise +// we can end up with cyclic dependencies with some std lib implementations. +// +#ifndef BOOST_TR1_vector_INCLUDED +# define BOOST_TR1_vector_INCLUDED +# ifndef BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_RECURSION +# define BOOST_TR1_NO_vector_RECURSION +# endif +# include +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next +# else +# include BOOST_TR1_STD_HEADER(vector) +# endif +# ifdef BOOST_TR1_NO_vector_RECURSION +# undef BOOST_TR1_NO_vector_RECURSION +# undef BOOST_TR1_NO_RECURSION +# endif +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/tuple.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/tuple.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,82 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_TUPLE_HPP_INCLUDED +# define BOOST_TR1_TUPLE_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_TUPLE + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(tuple) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(tuple)) +# endif + +#else + +#if defined(BOOST_TR1_USE_OLD_TUPLE) + +#include +#include +#include + +namespace std{ namespace tr1{ + +using ::boost::tuple; + +// [6.1.3.2] Tuple creation functions +using ::boost::tuples::ignore; +using ::boost::make_tuple; +using ::boost::tie; + +// [6.1.3.3] Tuple helper classes +template +struct tuple_size + : public ::boost::integral_constant + < ::std::size_t, ::boost::tuples::length::value> +{}; + +template < int I, class T> +struct tuple_element +{ + typedef typename boost::tuples::element::type type; +}; + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) +// [6.1.3.4] Element access +using ::boost::get; +#endif + +} } // namespaces + +#else + +#include +#include + +namespace std{ namespace tr1{ + +using ::boost::fusion::tuple; + +// [6.1.3.2] Tuple creation functions +using ::boost::fusion::ignore; +using ::boost::fusion::make_tuple; +using ::boost::fusion::tie; +using ::boost::fusion::get; + +// [6.1.3.3] Tuple helper classes +using ::boost::fusion::tuple_size; +using ::boost::fusion::tuple_element; + +}} + +#endif + +#endif + +#endif + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/type_traits.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/type_traits.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,86 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_TYPE_TRAITS_HPP_INCLUDED +# define BOOST_TR1_TYPE_TRAITS_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_TYPE_TRAITS + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(type_traits) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(type_traits)) +# endif + +#else +// Boost Type Traits: +#include + +namespace std { namespace tr1{ + + using ::boost::integral_constant; + using ::boost::true_type; + using ::boost::false_type; + using ::boost::is_void; + using ::boost::is_integral; + using ::boost::is_floating_point; + using ::boost::is_array; + using ::boost::is_pointer; + using ::boost::is_reference; + using ::boost::is_member_object_pointer; + using ::boost::is_member_function_pointer; + using ::boost::is_enum; + using ::boost::is_union; + using ::boost::is_class; + using ::boost::is_function; + using ::boost::is_arithmetic; + using ::boost::is_fundamental; + using ::boost::is_object; + using ::boost::is_scalar; + using ::boost::is_compound; + using ::boost::is_member_pointer; + using ::boost::is_const; + using ::boost::is_volatile; + using ::boost::is_pod; + using ::boost::is_empty; + using ::boost::is_polymorphic; + using ::boost::is_abstract; + using ::boost::has_trivial_constructor; + using ::boost::has_trivial_copy; + using ::boost::has_trivial_assign; + using ::boost::has_trivial_destructor; + using ::boost::has_nothrow_constructor; + using ::boost::has_nothrow_copy; + using ::boost::has_nothrow_assign; + using ::boost::has_virtual_destructor; + using ::boost::is_signed; + using ::boost::is_unsigned; + using ::boost::alignment_of; + using ::boost::rank; + using ::boost::extent; + using ::boost::is_same; + using ::boost::is_base_of; + using ::boost::is_convertible; + using ::boost::remove_const; + using ::boost::remove_volatile; + using ::boost::remove_cv; + using ::boost::add_const; + using ::boost::add_volatile; + using ::boost::add_cv; + using ::boost::remove_reference; + using ::boost::add_reference; + using ::boost::remove_extent; + using ::boost::remove_all_extents; + using ::boost::remove_pointer; + using ::boost::add_pointer; + using ::boost::aligned_storage; + +} } + +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/unordered_map.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/unordered_map.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,33 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_UNORDERED_MAP_HPP_INCLUDED +# define BOOST_TR1_UNORDERED_MAP_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_UNORDERED_MAP + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(unordered_map) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_map)) +# endif + +#else + +#include + +namespace std{ namespace tr1{ + + using ::boost::unordered_map; + using ::boost::unordered_multimap; + using ::boost::swap; + +} } // namespaces + +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/unordered_set.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/unordered_set.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,33 @@ +// (C) Copyright John Maddock 2008. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_UNORDERED_SET_HPP_INCLUDED +# define BOOST_TR1_UNORDERED_SET_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_UNORDERED_SET + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(unordered_set) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(unordered_set)) +# endif + +#else + +#include + +namespace std{ namespace tr1{ + + using ::boost::unordered_set; + using ::boost::unordered_multiset; + using ::boost::swap; + +} } // namespaces + +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/boostlibrary/boost/tr1/utility.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/boostlibrary/boost/tr1/utility.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,123 @@ +// (C) Copyright John Maddock 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TR1_UTILITY_HPP_INCLUDED +# define BOOST_TR1_UTILITY_HPP_INCLUDED +# include + +#ifdef BOOST_HAS_TR1_UTILITY + +# ifdef BOOST_HAS_INCLUDE_NEXT +# include_next BOOST_TR1_HEADER(utility) +# else +# include +# include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(utility)) +# endif + +#else + +#if defined(BOOST_TR1_USE_OLD_TUPLE) + +#include +#include +#include +#include + + +namespace std{ namespace tr1{ + +template struct tuple_size; // forward declaration +template < int I, class T> struct tuple_element; // forward declaration + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template +struct tuple_size< ::std::pair > + : public ::boost::integral_constant< ::std::size_t, 2> +{ +}; + +template +struct tuple_element<0, ::std::pair > +{ + typedef typename std::pair::first_type type; +}; + +template +struct tuple_element<1, std::pair > +{ + typedef typename std::pair::second_type type; +}; +#endif + +namespace tuple_detail{ + template + struct tuple_get_result + { + typedef typename boost::mpl::if_c::type t1; + typedef typename boost::add_reference::type type; + }; + template + struct const_tuple_get_result + { + typedef typename boost::mpl::if_c::type t1; +# if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x582)) + // I have absolutely no idea why add_const is not working here for Borland! + // It passes all other free-standing tests, some strange interaction going on + typedef typename boost::add_reference< const t1 >::type type; +# else + typedef typename boost::add_const::type t2; + typedef typename boost::add_reference::type type; +# endif + }; + +template +inline typename tuple_detail::tuple_get_result::type get(std::pair& p, const ::boost::true_type&) +{ + return p.first; +} + +template +inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p, const ::boost::true_type&) +{ + return p.first; +} + +template +inline typename tuple_detail::tuple_get_result::type get(std::pair& p, const ::boost::false_type&) +{ + return p.second; +} + +template +inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p, const ::boost::false_type&) +{ + return p.second; +} + +} + +template +inline typename tuple_detail::tuple_get_result::type get(std::pair& p) +{ + return tuple_detail::get(p, boost::integral_constant()); +} + +template +inline typename tuple_detail::const_tuple_get_result::type get(const std::pair& p) +{ + return tuple_detail::get(p, boost::integral_constant()); +} + +} } // namespaces + +#else + +#include + +#endif + +#endif + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/group/bld.inf --- a/imgtools/imglib/group/bld.inf Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/imglib/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -64,5 +64,4 @@ patchdataprocessor parameterfileprocessor memmap -filesystem uidcrc diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/group/testutf16str.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/group/testutf16str.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +TARGET testutf16str.exe +TARGETTYPE exe +SOURCEPATH ../host +SOURCE utf16string.cpp testutf16str.cpp +USERINCLUDE ../inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +VENDORID 0x70000001 + +option GCC -O2 -Wno-uninitialized diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/host/testutf16str.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/host/testutf16str.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "UTF16String.h" +#include +#include +#include +using namespace std ; + +#ifdef __LINUX__ +#define stricmp strcasecmp +#endif + +void PrintHelp(){ + cout << "Syntax: TestUTF16Str <-[mbtou|utomb] > -i inputfilename -o outputfilename "< 3){ + if(memcmp(buffer,utf8FileHdr,sizeof(utf8FileHdr)) == 0){ + mbstr += 3; + length -= 3 ; + } + } + UTF16String theStr(mbstr , length); + if(length > 0 && theStr.IsEmpty()){ + cerr << "Convert Error[From UTF8 To UTF16]."<(utf16FileHdr),sizeof(utf16FileHdr)); + ofs.write(reinterpret_cast(theStr.c_str()),length); + cout << "Done."<(buffer); + length >>= 1; + if(*unistr == 0xFEFF){ + unistr ++ ; + length -- ; + } + UTF16String theStr(unistr , length); + string mbstr ; + if(!theStr.ToUTF8(mbstr)){ + cerr << "Convert Error[From UTF16 To UTF8]."<(utf8FileHdr),sizeof(utf8FileHdr)); + ofs.write(mbstr.c_str(),mbstr.length()); + cout << "Done."< +#elif defined(WIN32) +#ifdef _STLP_INTERNAL_WINDOWS_H +#define __INTERLOCKED_DECLARED +#endif +#include +#endif +UTF16String::UTF16String() :iData(0), iLength(0){ +} +UTF16String::UTF16String(const UTF16String& aRight){ + iLength = aRight.iLength ; + iData = new TUint16[iLength + 1]; + memcpy(iData,aRight.iData, iLength << 1); + iData[iLength] = 0; +} +UTF16String::UTF16String(const string& aUtf8Str){ + iData = 0 ; + iLength = 0 ; + Assign(aUtf8Str.c_str(),aUtf8Str.length()); +} +UTF16String::UTF16String(const TUint16* aUtf16Str,TInt aLength /* = -1*/){ + + if(aLength < 0){ + aLength = 0 ; + const TUint16* p = aUtf16Str ; + while(*p){ + p++ ; + aLength ++ ; + } + } + if(aLength > 0){ + iLength = aLength ; + aLength <<= 1 ; + iData = new TUint16[iLength + 1] ; + memcpy(iData,aUtf16Str,aLength); + iData[iLength] = 0; + }else{ + iData = 0 ; + iLength = 0 ; + } + +} +UTF16String::UTF16String(const char* aUtf8Str,TInt aLength /*= -1 */){ + iData = 0 ; + iLength = 0 ; + Assign(aUtf8Str,aLength); +} +UTF16String::~UTF16String(){ + if(iData) + delete []iData ; +} + +UTF16String& UTF16String::operator = (const UTF16String& aRight){ + if(&aRight != this){ + if(iData) + delete []iData ; + iLength = aRight.iLength ; + iData = new TUint16[iLength + 1]; + memcpy(iData,aRight.iData, iLength << 1); + iData[iLength] = 0; + } + return *this; +} +bool UTF16String::FromFile(const char* aFileName){ + if(!aFileName || !(*aFileName)) + return false ; + ifstream ifs(aFileName,ios_base::in + ios_base::binary); + if(!ifs.is_open()) + return false ; + + ifs.seekg(0,ios_base::end); + size_t length = ifs.tellg(); + if((length % 2) == 1 ){ + ifs.close() ; + return false ; + } + ifs.seekg(0,ios_base::beg); + TUint16 hdr ; + size_t readLen = length - sizeof(hdr) ; + length >>= 1 ; + TUint16 *newData = new TUint16[length + 1]; + ifs.read(reinterpret_cast(&hdr),sizeof(hdr)); + if(hdr == 0xFEFF){ + ifs.read(reinterpret_cast(newData),readLen); + length -- ; + } + else{ + *newData = hdr ; + ifs.read(reinterpret_cast(&newData[1]),readLen); + } + ifs.close(); + iLength = length ; + if(iData) + delete []iData ; + iData = newData ; + iData[iLength] = 0; + return true ; +} +/** +* aResult will not changed on error +*/ +bool UTF16String::ToUTF8(string& aResult) const { + if(IsEmpty()){ + aResult = ""; + return true; + } + size_t bufLen = (iLength + 1) << 2 ; + char* buffer = new char[bufLen] ; +#ifdef WIN32 + int r = WideCharToMultiByte(CP_UTF8,0,reinterpret_cast(iData),iLength,buffer,bufLen,NULL,NULL); + if(r < 0){ + delete []buffer ; + return false ; + } + buffer[r] = 0; + aResult.assign(buffer,r); +#else + iconv_t it = iconv_open("UTF-8","UTF-16"); + if((iconv_t)(-1) == it){ + return false; + } + char* bufferEnd = buffer ; + char* in_ptr = reinterpret_cast(iData); + size_t in_len = iLength << 1 ; + iconv(it,&in_ptr,&in_len ,&bufferEnd,&bufLen); + iconv_close(it); + *bufferEnd = 0 ; + size_t length = bufferEnd - buffer ; + aResult.assign(buffer,length); +#endif + delete []buffer ; + return true ; +} +bool UTF16String::Assign(const char* aUtf8Str,TInt aLength /* = -1*/) { + if(0 == aUtf8Str) return false ; + if(aLength < 0) aLength = strlen(aUtf8Str); + +#ifdef WIN32 + size_t newLength = aLength + 1; + TUint16* newData = new TUint16[newLength]; + int r = MultiByteToWideChar(CP_UTF8,0,aUtf8Str,aLength,reinterpret_cast(newData),newLength); + if(r < 0){ + delete []newData ; + return false ; + } + iLength = r ; +#else + char* forFree = 0 ; + if(aUtf8Str[aLength - 1] != 0){ + forFree = new char[aLength + 1]; + memcpy(forFree,aUtf8Str,aLength ); + forFree[aLength] = 0; + aUtf8Str = forFree ; + } + iconv_t it = iconv_open("UTF-16","UTF-8"); + if((iconv_t)(-1) == it){ + + return false; + } + size_t newLength = aLength + 2; + TUint16* newData = new TUint16[newLength]; + newLength <<= 1; + char* out_ptr = reinterpret_cast(newData); + size_t in_len = aLength ; + char* in_ptr = const_cast(aUtf8Str); + iconv(it,&in_ptr,&in_len ,&out_ptr ,&newLength); + newLength = out_ptr - reinterpret_cast(newData); + iconv_close(it); + if(newLength % 2 == 1){ //should not be possible + delete []newData; + return false ; + } + iLength = (newLength >> 1) ; + if(forFree) + delete []forFree; +#endif + newData[iLength] = 0 ; + if(iData){ + delete []iData ; + } + iData = newData ; + if(*iData == 0xFEFF) + iLength -- ; + + return true ; +} +static const TUint16 NullUInt16Str[1] = {0}; +const TUint16* UTF16String::c_str() const { + if(0 == iData) + return NullUInt16Str; + else if(0xFEFF != *iData) + return iData ; + else + return iData + 1; +} +/// +/// aUtf16Str must end with '\0' +/// +int UTF16String::Compare(const TUint16* aUtf16Str) const { + if(!aUtf16Str || !(*aUtf16Str)) + return (iLength > 0) ? 1 : 0; + size_t i ; + for(i = 0 ; aUtf16Str[i] != 0 ; i++) { + if( iData[i] > aUtf16Str[i]) + return 1; + else if(iData[i] < aUtf16Str[i]) + return -1 ; + } + return (i < iLength) ? 1 : 0 ; +} +/// +/// aUtf16Str must end with '\0' +/// +int UTF16String::CompareNoCase(const TUint16* aUtf16Str) const { + if(!aUtf16Str || !(*aUtf16Str)) + return (iLength > 0) ? 1 : 0; + size_t i ; + TUint16 a, b; + for(i = 0 ; aUtf16Str[i] != 0 ; i++) { + a = iData[i]; + b = aUtf16Str[i] ; + if( a >= 'A' && a <= 'Z') a |= 0x20 ; + if( b >= 'A' && b <= 'Z') b |= 0x20 ; + + if( a > b ) + return 1; + else if( a < b ) + return -1 ; + } + return (i < iLength) ? 1 : 0 ; +} +TUint16* UTF16String::Alloc(size_t aNewLen) { + TUint16* newData = new TUint16[aNewLen + 1] ; + if(!newData) return 0; + if(iData) delete []iData ; + + iLength = aNewLen ; + iData = newData ; + *iData = 0 ; + iData[aNewLen] = 0; + return iData; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/inc/fatdefines.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/inc/fatdefines.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef __FAT_DEFINES_HEADER__ +#define __FAT_DEFINES_HEADER__ +#include +struct TFATBootSector { + TUint8 BS_jmpBoot[3]; + TUint8 BS_OEMName[8]; + TUint8 BPB_BytsPerSec[2]; + TUint8 BPB_SecPerClus; + TUint8 BPB_RsvdSecCnt[2]; + TUint8 BPB_NumFATs; + TUint8 BPB_RootEntCnt[2]; + TUint8 BPB_TotSec16[2]; + TUint8 BPB_Media; + TUint8 BPB_FATSz16[2]; + TUint8 BPB_SecPerTrk[2]; + TUint8 BPB_NumHeads[2]; + TUint8 BPB_HiddSec[4]; + TUint8 BPB_TotSec32[4]; +}; +struct TFAT32BSExt { + TUint8 BPB_FATSz32[4]; + TUint8 BPB_ExtFlags[2]; + TUint8 BPB_FSVer[2]; + TUint8 BPB_RootClus[4]; + TUint8 BPB_FSInfo[2]; + TUint8 BPB_BkBootSec[2]; + TUint8 BPB_Reserved[12]; +}; + +struct TFATHeader { + TUint8 BS_DrvNum ; + TUint8 BS_Reserved1; + TUint8 BS_BootSig; + TUint8 BS_VolID[4]; + TUint8 BS_VolLab[11]; + TUint8 BS_FilSysType[8]; +}; + +struct TFAT32FSInfoSector { + TUint8 FSI_LeadSig[4]; + TUint8 FSI_Reserved1[480]; + TUint8 FSI_StrucSig[4]; + TUint8 FSI_Free_Count[4]; + TUint8 FSI_Nxt_Free[4]; + TUint8 FSI_Reserved2[12]; + TUint8 FSI_TrailSig[4]; +}; +struct TShortDirEntry { + TUint8 DIR_Name[11]; + TUint8 DIR_Attr ; + TUint8 DIR_NTRes ; + TUint8 DIR_CrtTimeTenth ; + TUint8 DIR_CrtTime[2] ; + TUint8 DIR_CrtDate[2] ; + TUint8 DIR_LstAccDate[2] ; + TUint8 DIR_FstClusHI[2] ; + TUint8 DIR_WrtTime[2] ; + TUint8 DIR_WrtDate[2]; + TUint8 DIR_FstClusLO[2]; + TUint8 DIR_FileSize[4] ; +}; + +struct TLongDirEntry { + TUint8 LDIR_Ord ; + TUint8 LDIR_Name1[10] ; + TUint8 LDIR_Attr ; + TUint8 LDIR_Type ; + TUint8 LDIR_Chksum ; + TUint8 LDIR_Name2[12] ; + TUint8 LDIR_FstClusLO[2] ; + TUint8 LDIR_Name3[4] ; +}; +const TUint8 ATTR_READ_ONLY = 0x01 ; +const TUint8 ATTR_HIDDEN = 0x02; +const TUint8 ATTR_SYSTEM = 0x04; +const TUint8 ATTR_VOLUME_ID = 0x08; +const TUint8 ATTR_DIRECTORY = 0x10; +const TUint8 ATTR_ARCHIVE = 0x20; +const TUint8 ATTR_LONG_NAME = ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID; + +//Time format, should be written as a integer in FAT image +struct FatTime +{ + TUint16 Seconds:5; + TUint16 Minute:6; + TUint16 Hour:5; +}; + +//Date format, should be written as a integer in FAT image +struct FatDate +{ + TUint16 Day:5; + TUint16 Month:4; + TUint16 Year:7; +}; + +//This union convention used to convert bit fields into integer +union TDateInteger +{ + FatDate iCurrentDate; + TUint16 iImageDate; +}; + +//This union convention used to convert bit fields into integer +union TTimeInteger +{ + FatTime iCurrentTime; + TUint16 iImageTime; +}; +struct ConfigurableFatAttributes +{ + char iDriveVolumeLabel[12]; + TInt64 iImageSize ; + TUint16 iDriveSectorSize; + TUint8 iSectorPerCluster ; + TUint8 iDriveNoOfFATs; + ConfigurableFatAttributes():iImageSize(0),iDriveSectorSize(512),iSectorPerCluster(0),iDriveNoOfFATs(2){ + memcpy(iDriveVolumeLabel,"NO NAME \0",12); + } +}; +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/imglib/inc/utf16string.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/imglib/inc/utf16string.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* @internalComponent * @released +* +*/ + +#ifndef __UTF16_STRING_H__ +#define __UTF16_STRING_H__ +#include +#include +#include +using namespace std ; + +class UTF16String { +public : + + UTF16String(); + UTF16String(const UTF16String& aRight); + UTF16String(const string& aUtf8Str); + UTF16String(const TUint16* aUtf16Str,TInt aLength = -1); + UTF16String(const char* aUtf8Str,TInt aLength = -1); + ~UTF16String(); + + bool FromFile(const char* aFileName); + bool ToUTF8(string& aResult) const ; + bool Assign(const char* aUtf8Str,TInt aLength = -1); + inline TUint length() const { return iLength ;} + inline TUint bytes() const { return (iLength << 1) ;} + const TUint16* c_str() const ; + inline bool IsEmpty() const { return (0 == iLength) ;} + UTF16String& operator = (const UTF16String& aRight); + int Compare(const TUint16* aUtf16Str) const ; + int CompareNoCase(const TUint16* aUtf16Str) const ; + TUint16* Alloc(size_t aNewLen); + +protected: + TUint16* iData ; + TUint iLength ; +}; +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/group/release.txt --- a/imgtools/romtools/group/release.txt Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/romtools/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -1,3 +1,18 @@ +Version 2.12.0 (ROFSBUILD) +=============== +Released by Jason Cui, 13/06/2010 + 1)Large FAT image support in Rofsbuild + +Version 2.11.5 (ROFSBUILD) +=============== +Released by Jason Cui, 10/06/2010 + 1)Empty Directory Support in FAT Image + +Version 2.10.5 (rofsbuild) +=============== +Released by Lorence Wang, 01/06/2010 + 1) DPDEF145488 ROFSBUILD crash on extension image creation + Version 1.1.1 (fixupsym.pl) =============== Released by Lorence Wang, 12/05/2010 diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/maksym/fixupsym --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/maksym/fixupsym Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,3 @@ +#!/bin/sh +perl -S fixupsym.pl $@ + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/maksym/hpsym --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/maksym/hpsym Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,3 @@ +#!/bin/sh +perl -S hpsym.pl $@ + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/maksym/maksym --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/maksym/maksym Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,3 @@ +#!/bin/sh +perl -S maksym.pl $@ + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/maksym/maksymrofs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/maksym/maksymrofs Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,3 @@ +#!/bin/sh +perl -S maksymrofs.pl $@ + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/fatcluster.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/fatcluster.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "fatcluster.h" +#include +#include +#include + +TFatCluster::TFatCluster(int aIndex,int aActClustCnt/* = 1*/) :iIndex(aIndex), iActualClusterCount(aActClustCnt), +iSize(0) ,iData(0),iFileName(0),iLazy(true){ +} + +TFatCluster::~TFatCluster() { + if(iData) + delete []iData ; + if(iFileName) + delete []iFileName; +} + + +bool TFatCluster::Init(TUint aSize) { + if(iData == 0){ + iData = reinterpret_cast(new(std::nothrow) char[aSize]); + if(iData == 0) + return false ; + memset(iData,0,aSize); + iSize = aSize ; + iLazy = false ; + return true ; + } + return false ; +} +bool TFatCluster::LazyInit(const char* aFileName,TUint aFileSize){ + if(iFileName == 0){ + int len = strlen(aFileName) + 1; + iFileName = new(std::nothrow) char[len] ; + if(iFileName == 0) + return false ; + iLazy = true ; + memcpy(iFileName,aFileName,len); + iSize = aFileSize ; + } + return false; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/fatcluster.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/fatcluster.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef __FAT_CLUSTER_HEADER__ +#define __FAT_CLUSTER_HEADER__ +#include +class TFatCluster { +public: + TFatCluster(int aIndex,int aActClustCnt = 1); + ~TFatCluster(); + bool Init(TUint aSize); + bool LazyInit(const char* aFileName,TUint aFileSize); + inline TUint8* GetData() const {return iData ; } + inline TUint GetSize() const { return iSize ;} + inline const char* GetFileName() const { return iFileName ;} + inline bool IsLazy() const { return iLazy;} + inline int ActualClusterCount() const { return iActualClusterCount;} + inline int GetIndex() const { return iIndex ;} +protected: + int iIndex ; + int iActualClusterCount ; + TUint iSize ; // length of file or size of data + TUint8* iData ; + char* iFileName ; + bool iLazy ; +}; + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/fatimagegenerator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/fatimagegenerator.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,541 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "fatimagegenerator.h" +#include "fatcluster.h" +#include "fsnode.h" +#include "h_utl.h" + +#include +#include +#include +#include +#include +using namespace std; + +const TInt KCharsOfCmdWndLine = 80 ; +const TInt KRootEntryCount = 0x200; +const TInt KRootClusterIndex = 0; + +TFatImgGenerator::TFatImgGenerator(TSupportedFatType aType ,ConfigurableFatAttributes& aAttr ) : +iType(aType), +iFatTable(0), +iFatTableBytes(0), +iTotalClusters(0), +iBytsPerClus(0) +{ + memset(&iBootSector,0,sizeof(iBootSector)); + memset(&iFat32Ext,0,sizeof(iFat32Ext)); + memset(&iFatHeader,0,sizeof(iFatHeader)); + if(aAttr.iDriveSectorSize != 512 && aAttr.iDriveSectorSize != 1024 && aAttr.iDriveSectorSize != 2048 && aAttr.iDriveSectorSize != 4096) { + iType = EFatUnknown ; + return ; + } + *((TUint32*)iBootSector.BS_jmpBoot) = 0x00905AEB ; + memcpy(iBootSector.BS_OEMName,"SYMBIAN ",8); + *((TUint16 *)iBootSector.BPB_BytsPerSec) = aAttr.iDriveSectorSize; + + iBootSector.BPB_NumFATs = aAttr.iDriveNoOfFATs; + iBootSector.BPB_Media = 0xF8 ; + iFatHeader.BS_DrvNum = 0x80 ; + iFatHeader.BS_BootSig = 0x29 ; + + time_t rawtime; + time(&rawtime); + *((TUint32*)iFatHeader.BS_VolID) = (TUint32)rawtime; + memcpy(iFatHeader.BS_VolLab,aAttr.iDriveVolumeLabel,sizeof(iFatHeader.BS_VolLab)); + if(aAttr.iImageSize == 0){ + if(aType == EFat32) + aAttr.iImageSize = 0x100000000LL ;// 4G + else + aAttr.iImageSize = 0x40000000LL ; // 1G + } + + TUint32 totalSectors = (TUint32)((aAttr.iImageSize + aAttr.iDriveSectorSize - 1) / aAttr.iDriveSectorSize); + if(aType == EFat32) { + InitAsFat32(totalSectors,aAttr.iSectorPerCluster ,aAttr.iDriveSectorSize); + } + else if(aType == EFat16) { + InitAsFat16(totalSectors,aAttr.iSectorPerCluster,aAttr.iDriveSectorSize); + } + if(iType == EFatUnknown) return ; + iBytsPerClus = iBootSector.BPB_SecPerClus * aAttr.iDriveSectorSize; +// if(iBytsPerClus > KMaxClusterBytes){ +// Print(EError,"Cluster too large!\n"); +// iType = EFatUnknown; +// return ; +// } + + +} +TFatImgGenerator::~TFatImgGenerator() { + if(iFatTable) + delete []iFatTable; + Interator it = iDataClusters.begin(); + while(it != iDataClusters.end()){ + TFatCluster* cluster = *it ; + delete cluster; + it++; + } +} + +void TFatImgGenerator::InitAsFat16(TUint32 aTotalSectors,TUint8 aSecPerClus,TUint16 aBytsPerSec){ + + TUint32 numOfClusters ; + if(aSecPerClus == 0) { + //Auto-calc the SecPerClus + // FAT32 ,Count of clusters must >= 4085 and < 65525 , however , to avoid the "off by xx" warning, + // proprositional value >= (4085 + 16) && < (65525 - 16) + if(aTotalSectors < (4085 + 16)) { //when SecPerClus is 1, numOfClusters eq to aTotalSectors + iType = EFatUnknown ; + Print(EError,"Size is too small for FAT16, please set a bigger size !\n"); + return ; + } + TUint8 secPerClusMax = KMaxClusterBytes / aBytsPerSec; + numOfClusters = (aTotalSectors + secPerClusMax - 1) / secPerClusMax ; + if(numOfClusters >= (65525 - 16)) { // too big + iType = EFatUnknown ; + Print(EError,"Size is too big for FAT16, please use the FAT32 format!\n"); + return ; + } + + aSecPerClus = 1; + while(aSecPerClus < secPerClusMax){ + numOfClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus ; + if (numOfClusters >= (4085 + 16) && numOfClusters < (65525 - 16)) { + break; + } + aSecPerClus <<= 1 ; + } + } + else { + if( (aSecPerClus * aBytsPerSec) > KMaxClusterBytes){ + Print(EError,"Cluster too large!\n"); + iType = EFatUnknown; + return ; + } + numOfClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus; + if(numOfClusters >= (65525 - 16)){ + Print(EError,"Cluster count is too big for FAT16, please use the FAT32 format or set a new bigger sector count of cluster!\n"); + iType = EFatUnknown ; + return ; + } + else if(numOfClusters < (4085 + 16)){ + Print(EError,"Cluster count is too small for FAT16, please set a new small sector count of cluster or set the size bigger!\n"); + iType = EFatUnknown ; + return ; + } + + } + iTotalClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus ; + iFatTableBytes = ((iTotalClusters << 1) + aBytsPerSec - 1) & (~(aBytsPerSec - 1)); + iFatTable = new(std::nothrow) char[iFatTableBytes]; + if(!iFatTable) { + Print(EError,"Memory allocation failed for FAT16 Table!\n"); + iType = EFatUnknown ; + return ; + } + memset(iFatTable,0,iFatTableBytes); + *((TUint32*)iFatTable) = 0xFFFFFFF8 ; + iBootSector.BPB_SecPerClus = aSecPerClus; + *((TUint16*)iBootSector.BPB_RsvdSecCnt) = 0x0001 ; + *((TUint16*)iBootSector.BPB_RootEntCnt) = KRootEntryCount ; + if(aTotalSectors > 0xFFFF) + *((TUint32*)iBootSector.BPB_TotSec32) = aTotalSectors; + else + *((TUint16*)iBootSector.BPB_TotSec16) = (TUint16)aTotalSectors; + TUint16 sectorsForFAT = (TUint16)((iFatTableBytes + aBytsPerSec - 1) / aBytsPerSec); + *((TUint16*)iBootSector.BPB_FATSz16) = sectorsForFAT ; + memcpy(iFatHeader.BS_FilSysType,"FAT16 ",sizeof(iFatHeader.BS_FilSysType)); +} +void TFatImgGenerator::InitAsFat32(TUint32 aTotalSectors,TUint8 aSecPerClus,TUint16 aBytsPerSec) { + + TUint32 numOfClusters; + if(aSecPerClus == 0) { + //Auto-calc the SecPerClus + // FAT32 ,Count of clusters must >= 65525, however , to avoid the "off by xx" warning, + // proprositional value >= (65525 + 16) + if(aTotalSectors < (65525 + 16)) { //when SecPerClus is 1, numOfClusters eq to aTotalSectors + iType = EFatUnknown ; + Print(EError,"Size is too small for FAT32, please use the FAT16 format, or set the data size bigger!\n"); + return ; + } + + TUint8 secPerClusMax = KMaxClusterBytes / aBytsPerSec; + aSecPerClus = secPerClusMax; + while(aSecPerClus > 1){ + numOfClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus ; + if (numOfClusters >= (65525 + 16)) { + break; + } + aSecPerClus >>= 1 ; + } + } + else { + if( (aSecPerClus * aBytsPerSec) > KMaxClusterBytes){ + Print(EError,"Cluster too large!\n"); + iType = EFatUnknown; + return ; + } + numOfClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus; + if(numOfClusters < (65525 + 16)) { + Print(EError,"Cluster count is too small for FAT32, please set a new small sector count of cluster or set the size bigger or use the FAT16 format!\n"); + iType = EFatUnknown ; + return ; + } + + } + iTotalClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus ; + iFatTableBytes = ((iTotalClusters << 2) + aBytsPerSec - 1) & (~(aBytsPerSec - 1)); + iFatTable = new(std::nothrow) char[iFatTableBytes]; + if(!iFatTable) { + Print(EError,"Memory allocation failed for FAT32 Table!\n"); + iType = EFatUnknown ; + return ; + } + memset(iFatTable,0,iFatTableBytes); + TUint32* fat32table = reinterpret_cast(iFatTable); + fat32table[0] = 0x0FFFFFF8 ; + fat32table[1] = 0x0FFFFFFF ; + iBootSector.BPB_SecPerClus = aSecPerClus; + iBootSector.BPB_RsvdSecCnt[0] = 0x20 ; + *((TUint32*)iBootSector.BPB_TotSec32) = aTotalSectors; + *((TUint32*)iFat32Ext.BPB_FATSz32) = (iFatTableBytes + aBytsPerSec - 1) / aBytsPerSec; + *((TUint32*)iFat32Ext.BPB_RootClus) = 2 ; + *((TUint16*)iFat32Ext.BPB_FSInfo) = 1 ; + *((TUint16*)iFat32Ext.BPB_BkBootSec) = 6 ; + memcpy(iFatHeader.BS_FilSysType,"FAT32 ",sizeof(iFatHeader.BS_FilSysType)); +} + +bool TFatImgGenerator::Execute(TFSNode* aRootDir , const char* aOutputFile){ + if(EFatUnknown == iType) + return false ; + ofstream o(aOutputFile,ios_base::binary + ios_base::out + ios_base::trunc); + TUint32 writtenBytes = 0 ; + if(!o.is_open()) { + Print(EError,"Can not open \"%s\" for writing !\n",aOutputFile) ; + return false; + } + TUint16 bytsPerSector = *((TUint16*)iBootSector.BPB_BytsPerSec); + Interator it = iDataClusters.begin(); + while(it != iDataClusters.end()){ + TFatCluster* cluster = *it ; + delete cluster; + it++; + } + iDataClusters.clear(); + Print(EAlways,"Filesystem ready.\nWriting Header..."); + + if(EFat16 == iType){ + char* header = new(std::nothrow) char[bytsPerSector]; + if(!header){ + Print(EError,"Can not allocate memory for FAT16 header!\n"); + o.close(); + return false ; + } + int offset = 0; + memcpy(header,&iBootSector,sizeof(iBootSector)); + offset = sizeof(iBootSector); + memcpy(&header[offset],&iFatHeader,sizeof(iFatHeader)); + offset += sizeof(iFatHeader); + memset(&header[offset],0,bytsPerSector - offset); + *((TUint16*)(&header[510])) = 0xAA55 ; + + o.write(header,bytsPerSector); + writtenBytes += bytsPerSector; + delete []header ; + TUint16 rootDirSectors = (KRootEntryCount * 32) / bytsPerSector ; + TUint16 rootDirClusters = (rootDirSectors + iBootSector.BPB_SecPerClus - 1) /iBootSector.BPB_SecPerClus; + TUint32 rootDirBytes = KRootEntryCount * 32; + TFatCluster* rootDir = new(std::nothrow) TFatCluster(0,rootDirClusters); + rootDir->Init(rootDirBytes); + iDataClusters.push_back(rootDir); + aRootDir->WriteDirEntries(KRootClusterIndex,rootDir->GetData()); + + TUint index = 2 ; + Print(EAlways," OK.\nPreparing cluster list..."); + TFSNode* child = aRootDir->GetFirstChild() ; + while(child){ + if(!PrepareClusters(index,child)){ + Print(EAlways," Failed.\nError:Image size is expected to be big enough for all the files.\n"); + return false ; + } + child = child->GetSibling() ; + } + } + else if(EFat32 == iType){ + + TUint headerSize = ( bytsPerSector << 5 ); // 32 reserved sectors for fat32 + char* header = new(std::nothrow) char[headerSize]; + if(!header){ + Print(EError,"Can not allocate memory for FAT32 header!\n"); + o.close(); + return false ; + } + memset(header,0,headerSize); + + int offset = 0; + memcpy(header,&iBootSector,sizeof(iBootSector)); + offset = sizeof(iBootSector); + memcpy(&header[offset],&iFat32Ext,sizeof(iFat32Ext)); + offset += sizeof(iFat32Ext); + memcpy(&header[offset],&iFatHeader,sizeof(iFatHeader)); + offset += sizeof(iFatHeader); + + TFAT32FSInfoSector* fsinfo = reinterpret_cast(&header[bytsPerSector]); + *((TUint32*)fsinfo->FSI_LeadSig) = 0x41615252 ; + *((TUint32*)fsinfo->FSI_StrucSig) = 0x61417272 ; + memset(fsinfo->FSI_Free_Count,0xFF,8); + char* tailed = header + 510 ; + for(int i = 0 ; i < 32 ; i++ , tailed += bytsPerSector ) + *((TUint16*)tailed) = 0xAA55 ; + + TUint index = 2 ; + Print(EAlways," OK.\nPreparing cluster list..."); + if(!PrepareClusters(index,aRootDir)) { + Print(EAlways," Failed.\nERROR: Image size is expected to be big enough for all the files.\n"); + delete []header ; + return false; + } + + + *(TUint32*)(fsinfo->FSI_Free_Count) = iTotalClusters - index + 3; + *(TUint32*)(fsinfo->FSI_Nxt_Free) = index ; + + // write bakup boot sectors + memcpy(&header[bytsPerSector * 6],header,(bytsPerSector << 1)); + o.write(header,headerSize); + writtenBytes += headerSize; + delete []header ; + } + //iDataClusters.sort(); + it = iDataClusters.end() ; + it -- ; + int clusters = (*it)->GetIndex() + (*it)->ActualClusterCount() - 1; + + Print(EAlways," OK.\n%d clusters of data need to be written.\nWriting Fat table...",clusters); + for(TUint8 w = 0 ; w < iBootSector.BPB_NumFATs ; w++){ + o.write(iFatTable,iFatTableBytes); + if(o.bad() || o.fail()){ + Print(EAlways,"\nERROR:Writting failed. Please check the filesystem\n"); + delete []iFatTable, + o.close(); + return false ; + } + writtenBytes += iFatTableBytes; + } + char* buffer = new(std::nothrow) char[KBufferedIOBytes]; + if(!buffer){ + Print(EError,"Can not allocate memory for I/O buffer !\n"); + o.close(); + return false ; + } + o.flush(); + Print(EAlways," OK.\nWriting clusters data..."); + + int bytesInBuffer = 0; + int writeTimes = 24; + + TFatCluster* lastClust = 0 ; + for(it = iDataClusters.begin(); it != iDataClusters.end() ; it++ ){ + TFatCluster* cluster = *it ; + TUint fileSize = cluster->GetSize(); + TUint toProcess = cluster->ActualClusterCount() * iBytsPerClus ; + if(toProcess > KBufferedIOBytes){ // big file + if(bytesInBuffer > 0){ + o.write(buffer,bytesInBuffer); + if(o.bad() || o.fail()){ + Print(EError,"Writting failed.\n"); + delete []buffer, + o.close(); + return false ; + } + writtenBytes += bytesInBuffer; + bytesInBuffer = 0; + Print(EAlways,"."); + writeTimes ++ ; + if((writeTimes % KCharsOfCmdWndLine) == 0){ + o.flush(); + cout << endl ; + } + } + if(cluster->IsLazy()){ + ifstream ifs(cluster->GetFileName(), ios_base::binary + ios_base::in); + if(!ifs.is_open()){ + Print(EError,"Can not open file \"%s\"\n",cluster->GetFileName()) ; + o.close(); + delete []buffer; + return false ; + } + if(!ifs.good()) ifs.clear(); + TUint processedBytes = 0 ; + + while(processedBytes < fileSize){ + TUint ioBytes = fileSize - processedBytes ; + if(ioBytes > KBufferedIOBytes) + ioBytes = KBufferedIOBytes; + ifs.read(buffer,ioBytes); + processedBytes += ioBytes; + o.write(buffer,ioBytes); + if(o.bad() || o.fail()){ + Print(EError,"Writting failed.\n"); + delete []iFatTable, + o.close(); + return false ; + } + writtenBytes += ioBytes; + Print(EAlways,"."); + writeTimes ++ ; + if((writeTimes % KCharsOfCmdWndLine) == 0){ + o.flush(); + Print(EAlways,"\n") ; + } + + } + TUint paddingBytes = toProcess - processedBytes; + if( paddingBytes > 0 ){ + memset(buffer,0,paddingBytes); + o.write(buffer,paddingBytes); + if(o.bad() || o.fail()){ + Print(EError,"Writting failed.\n"); + delete []buffer, + o.close(); + return false ; + } + writtenBytes += paddingBytes; + } + ifs.close(); + + } + else { + // impossible + Print(EError,"Unexpected result!\n"); + o.close(); + delete []buffer; + return false ; + } + } + else { + if(toProcess > (KBufferedIOBytes - bytesInBuffer)){ + o.write(buffer,bytesInBuffer); + if(o.bad() || o.fail()){ + Print(EError,"Writting failed.\n"); + delete []buffer, + o.close(); + return false ; + } + writtenBytes += bytesInBuffer; + Print(EAlways,"."); + writeTimes ++ ; + if((writeTimes % KCharsOfCmdWndLine) == 0){ + o.flush(); + cout << endl ; + } + bytesInBuffer = 0; + } + if(cluster->IsLazy()){ + ifstream ifs(cluster->GetFileName(), ios_base::binary + ios_base::in); + if(!ifs.is_open()){ + Print(EError,"Can not open file \"%s\"\n",cluster->GetFileName()) ; + o.close(); + delete []buffer; + return false ; + } + if(!ifs.good()) ifs.clear(); + ifs.read(&buffer[bytesInBuffer],fileSize); + bytesInBuffer += fileSize; + if(toProcess > fileSize) { // fill padding bytes + memset(&buffer[bytesInBuffer],0,toProcess - fileSize); + bytesInBuffer += (toProcess - fileSize); + } + ifs.close(); + + } + else{ + if(toProcess != cluster->GetSize() && cluster->GetIndex() != KRootClusterIndex){ + Print(EError,"Unexpected size!\n"); + o.close(); + delete []buffer; + return false ; + } + memcpy(&buffer[bytesInBuffer],cluster->GetData(),cluster->GetSize()); + bytesInBuffer += cluster->GetSize(); + } + + } + lastClust = cluster ; + + } + if(bytesInBuffer > 0){ + o.write(buffer,bytesInBuffer); + if(o.bad() || o.fail()){ + Print(EError,"Writting failed.\n"); + delete []buffer, + o.close(); + return false ; + } + writtenBytes += bytesInBuffer; + o.flush(); + } + Print(EAlways,"\nDone.\n\n"); + o.close(); + + return true ; +} +bool TFatImgGenerator::PrepareClusters(TUint& aNextClusIndex,TFSNode* aNode) { + TUint sizeOfItem = aNode->GetSize(); + TUint clusters = (sizeOfItem + iBytsPerClus - 1) / iBytsPerClus; + + if(iTotalClusters < aNextClusIndex + clusters) + return false ; + + TUint16* fat16Table = reinterpret_cast(iFatTable); + TUint32* fat32Table = reinterpret_cast(iFatTable); + + for(TUint i = aNextClusIndex + clusters - 1 ; i > aNextClusIndex ; i--){ + if(iType == EFat16) + fat16Table[i - 1] = i ; + else + fat32Table[i - 1] = i ; + } + if(iType == EFat16) + fat16Table[aNextClusIndex + clusters - 1] = 0xffff ; + else + fat32Table[aNextClusIndex + clusters - 1] = 0x0fffffff ; + + TFatCluster* cluster = new TFatCluster(aNextClusIndex,clusters); + if(aNode->IsDirectory()) { + TUint bytes = clusters * iBytsPerClus ; + cluster->Init(bytes); + aNode->WriteDirEntries(aNextClusIndex,cluster->GetData()); + } + else { + cluster->LazyInit(aNode->GetPCSideName(),sizeOfItem); + aNode->WriteDirEntries(aNextClusIndex,NULL); + } + iDataClusters.push_back(cluster); + + aNextClusIndex += clusters; + if(aNode->GetFirstChild()){ + if(!PrepareClusters(aNextClusIndex,aNode->GetFirstChild())) + return false ; + } + if(aNode->GetSibling()){ + if(!PrepareClusters(aNextClusIndex,aNode->GetSibling())) + return false; + } + return true ; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/fatimagegenerator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/fatimagegenerator.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef __FAT_IMAGE_GENERATER_HEADER__ +#define __FAT_IMAGE_GENERATER_HEADER__ + +#include "fatdefines.h" + +#include +#include +#include +using namespace std ; +const unsigned int KBufferedIOBytes = 0x800000 ; // 8M +const unsigned int KMaxClusterBytes = 0x8000; // 32K +enum TSupportedFatType { + EFatUnknown = 0, + EFat16 = 1, + EFat32 = 2 +}; + +class TFSNode; +class TFatCluster; +typedef list PFatClusterList ; +typedef list::iterator Interator ; + +class TFatImgGenerator +{ +public : + //The constructor , + //a TFatImgGenerator is created and initialized, + //if the parameters breaks the FAT specification, + // then iType is set to EFatUnknown and thus + // IsValid return false + TFatImgGenerator(TSupportedFatType aType , ConfigurableFatAttributes& aAttr ); + ~TFatImgGenerator(); + inline bool IsValid() const { return (EFatUnknown != iType);} + + //Create the FAT image, + //If FAT image is not valid, or error accurs, return false + bool Execute(TFSNode* aRootDir , const char* aOutputFile); +protected : + void InitAsFat16(TUint32 aTotalSectors,TUint8 aSecPerClus,TUint16 aBytsPerSec); + void InitAsFat32(TUint32 aTotalSectors,TUint8 aSecPerClus,TUint16 aBytsPerSec); + bool PrepareClusters(TUint& aNextClusIndex,TFSNode* aNode); + TSupportedFatType iType ; + char* iFatTable ; + TUint iFatTableBytes ; + TUint iTotalClusters ; + TUint iBytsPerClus ; + TFATBootSector iBootSector ; + TFAT32BSExt iFat32Ext ; + TFATHeader iFatHeader ; + PFatClusterList iDataClusters ; +}; + + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/fsnode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/fsnode.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,518 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "fsnode.h" +#include "fatdefines.h" +#include "utf16string.h" +#include +#include +#include +#include +#include + +#include + + +#ifdef __LINUX__ +#include +#include +#include +#define SPLIT_CHAR '/' +#else +#include +#include //TODO: check under MinGW4 + stlport 5.2 +#include +#define SPLIT_CHAR '\\' +#endif + +using namespace std; + +const TUint KBytesPerEntry = 13 ; +// +TFSNode::TFSNode(TFSNode* aParent, const char* aFileName, TUint8 aAttrs, const char* aPCSideName) : +iParent(aParent),iFirstChild(0),iSibling(0),iAttrs(aAttrs), iPCSideName(0), iWideName(0){ + + // According to the FAT specification, short name should be inited with empty string (' ' string) + memset(iShortName,0x20,11); + iShortName[11] = 0 ; + if(aFileName) { + iFileName = strdup(aFileName); + GenerateBasicName() ; + } + if(aPCSideName) { + iPCSideName = strdup(aPCSideName); + } + iFATEntry = 0; + iCrtTimeTenth = 0; + iCrtTime.iImageTime = 0 ; + iCrtDate.iImageDate = 0 ; + iLstAccDate.iImageDate = 0 ; + iWrtTime.iImageTime = 0 ; + iWrtDate.iImageDate = 0 ; + iFileSize = 0; + if(!iParent) return ; + + if(!iParent->iFirstChild) + iParent->iFirstChild = this ; + else { + TFSNode* sibling = iParent->iFirstChild; + while(sibling->iSibling) + sibling = sibling->iSibling ; + sibling->iSibling = this ; + } + +} +TFSNode::~TFSNode(){ + if(iFirstChild) + delete iFirstChild ; + if(iSibling) + delete iSibling ; + if(iFileName) + free(iFileName) ; + if(iWideName) + delete iWideName; +} +TFSNode* TFSNode::CreateFromFolder(const char* aPath,TFSNode* aParent) { + static char fileName[2048]; + int len = strlen(aPath); +#ifdef __LINUX__ + DIR* dir = opendir(aPath); + if(dir == NULL) { + cout << aPath << " does not contain any subfolder/file.\n"; + return aParent; + } + if(!aParent) + aParent = new TFSNode(NULL,"/",ATTR_VOLUME_ID); + dirent* entry; + struct stat statbuf ; + while ((entry = readdir(dir)) != NULL) { + if(entry->d_name[0] == '.') continue ; + memcpy(fileName,aPath,len); + fileName[len] = SPLIT_CHAR; + strcpy(&fileName[len+1],entry->d_name); + stat(fileName , &statbuf); + TFSNode* pNewItem = new TFSNode(aParent,fileName,S_ISDIR(statbuf.st_mode) ? ATTR_DIRECTORY : 0); + pNewItem->Init(statbuf.st_ctime,statbuf.st_atime,statbuf.st_mtime,statbuf.st_size); + if(S_ISDIR(statbuf.st_mode)){ + CreateFromFolder(fileName,pNewItem); + } + } + closedir(dir); +#else + struct _finddata_t data ; + memset(&data, 0, sizeof(data)); + char* pattern = new char[len + 4] ; + memcpy(pattern,aPath,len); + pattern[len] = SPLIT_CHAR; + pattern[len+1] = '*'; + pattern[len+2] = 0; + + intptr_t hFind = _findfirst(pattern,&data); + delete []pattern ; + + if(hFind == (intptr_t)-1 ) { + cout << aPath << " does not contain any subfolder/file.\n"; + return aParent; + } + if(!aParent) + aParent = new TFSNode(NULL,"/",ATTR_VOLUME_ID); + do { + if(data.name[0] == '.') + continue ; + memcpy(fileName,aPath,len); + fileName[len] = SPLIT_CHAR; + strcpy(&fileName[len+1],data.name); + TUint8 attr = 0; + if(data.attrib & _A_SUBDIR) + attr |= ATTR_DIRECTORY; + if(data.attrib & _A_RDONLY) + attr |= ATTR_READ_ONLY ; + if(data.attrib & _A_HIDDEN) + attr |= ATTR_HIDDEN ; + if(data.attrib & _A_SYSTEM) + attr |= ATTR_SYSTEM ; + if(data.attrib & _A_ARCH) + attr |= ATTR_ARCHIVE; + TFSNode* pNewItem = new TFSNode(aParent,fileName,attr); + pNewItem->Init(data.time_create,data.time_access,data.time_write,data.size); + if(data.attrib & _A_SUBDIR){ + CreateFromFolder(fileName,pNewItem); + } + + } while(-1 != _findnext(hFind, &data)); + _findclose(hFind); +#endif + + return aParent; +} + + + +static const char* lbasename(const char* aFullName) { + const char* retval = aFullName ; + while(*aFullName) { + if('\\' == *aFullName || '/' == *aFullName ) + retval = ++aFullName ; + else + aFullName ++ ; + } + return retval ; +} +/** GenerateBasicName : Generate the short name according to long name + * + * algorithm : + * + * 1. The UNICODE name passed to the file system is converted to upper case. + * 2. The upper cased UNICODE name is converted to OEM. + * if (the uppercased UNICODE glyph does not exist as an OEM glyph in the OEM code page) + * or (the OEM glyph is invalid in an 8.3 name) + * { + * Replace the glyph to an OEM '_' (underscore) character. + * Set a "lossy conversion" flag. + * } + * 3. Strip all leading and embedded spaces from the long name. + * 4. Strip all leading periods from the long name. + * 5. While (not at end of the long name) + * and (char is not a period) + * and (total chars copied < 8) + * { + * Copy characters into primary portion of the basis name + * } + * 6. Insert a dot at the end of the primary components of the basis-name + * if the basis name has an extension after the last period in the name. + * + * 7. Scan for the last embedded period in the long name. + * If (the last embedded period was found) + * { + * While (not at end of the long name) and (total chars copied < 3) + * { + * Copy characters into extension portion of the basis name + * } + * } + * + */ +void TFSNode::GenerateBasicName() { + const char* filename = lbasename(iFileName); + TUint length = strlen(filename); + if(0 == length) + return ; + if(0 == strcmp(filename,".")){ + iShortName[0] = '.' ; + return ; + } + if(0 == strcmp(filename,"..")){ + iShortName[0] = '.' ; + iShortName[1] = '.' ; + return ; + } +#ifdef _DEBUG + cout << "GenericBasicName: \"" << filename ; +#endif + iWideName = new UTF16String(filename,length); // The unicode string + char base[10]; + const char* ext = filename + length; + + //Strip all leading periods and spaces from the long name. + while(*filename == '.' || *filename == ' ' || *filename == '\t') { + filename ++ ; + length -- ; + } + //find the extension + while(ext > filename && *ext != '.') + ext -- ; + if(ext == filename){ + ext = "" ; + } + else { + length = ext - filename; + ext ++ ; + } + bool lossyConv = false ; + TUint bl = 0; + for(TUint i = 0 ; i < length ; i++) { + if(filename[i] >= 'a' && filename[i] <= 'z') + base[bl++] = filename[i] + 'A' - 'a'; + else if(filename[i] >= 'A' && filename[i] <= 'Z') + base[bl++] = filename[i]; + else if(filename[i] == '$' || filename[i] == '%' || + filename[i] == '-' || filename[i] == '_' || filename[i] == '@' || + filename[i] == '~' || filename[i] == '`' || filename[i] == '!' || + filename[i] == '(' || filename[i] == ')' || filename[i] == '{' || + filename[i] == '}' || filename[i] == '^' || filename[i] == '#' || + filename[i] == '&' ||filename[i] == '\'') + base[bl++] = filename[i]; + else if(filename[i] != ' ' && filename[i] != '.'){ + base[bl++] = '_'; + lossyConv = true ; + } + if(bl > 8){ + bl -- ; + lossyConv = true ; + break ; + } + } + if(lossyConv){ + if(bl > 6) bl = 6 ; + iShortName[bl] = '~'; + iShortName[bl+1] = '1'; + } + memcpy(iShortName,base,bl); + + //Copy the extension part. + TUint ei = 8; + for(TUint e = 0; ei < 11 && ext[e] != 0 ; e++){ + if(ext[e] >= 'a' && ext[e] <= 'z') + iShortName[ei++] = ext[e] + 'A' - 'a'; + else if(ext[e] >= 'A' && ext[e] <= 'Z') + iShortName[ei++] = ext[e] ; + else if(ext[e] == '$' || ext[e] == '%' || ext[e] == '-' || ext[e] == '_' || + ext[e] == '@' || ext[e] == '~' || ext[e] == '`' || ext[e] == '!' || + ext[e] == '(' || ext[e] == ')' || ext[e] == '{' || ext[e] == '}' || + ext[e] == '^' || ext[e] == '#' || ext[e] == '&' ||ext[e] == '\'') + iShortName[ei++] = ext[e] ; + } + + if(iParent) + iParent->MakeUniqueShortName(iShortName,bl); +#ifdef _DEBUG + cout << "\" => \"" << iShortName << "\"\n"; +#endif +} + +#ifdef _DEBUG +void TFSNode::PrintTree(int nTab) { + for( int i = 0 ; i < nTab ; i++ ) + cout << " " ; + cout << (iFileName ? iFileName : "") << " [" << hex << setw(2) << setfill('0') << (unsigned short)iAttrs << "] \n" ; + if(iFirstChild) + iFirstChild->PrintTree(nTab + 2); + if(iSibling) + iSibling->PrintTree(nTab); +} +#endif +bool TFSNode::IsDirectory() const { + return 0 != (iAttrs & ATTR_DIRECTORY); +} +int TFSNode::GetWideNameLength() const { + if(!iWideName) + return 0 ; + return iWideName->length() ; +} +TUint TFSNode::GetSize() const { + + if( 0 == (iAttrs & ATTR_DIRECTORY)) + return iFileSize ; + TUint retVal = sizeof(TShortDirEntry) ; // the tailed entry + if(iParent) + retVal += sizeof(TShortDirEntry) * 2 ; + TFSNode* child = iFirstChild ; + while(child) { + TUint longNameEntries = (child->GetWideNameLength() + KBytesPerEntry) / KBytesPerEntry ; + retVal += longNameEntries * sizeof(TLongDirEntry) ; + retVal += sizeof(TShortDirEntry); + child = child->iSibling ; + } + return retVal ; +} + +void TFSNode::Init(time_t aCreateTime, time_t aAccessTime, time_t aWriteTime, TUint aSize ) { + + struct tm* temp = localtime(&aCreateTime); + iCrtDate.iCurrentDate.Day = temp->tm_mday; + iCrtDate.iCurrentDate.Month = temp->tm_mon+1; //As per FAT spec + iCrtDate.iCurrentDate.Year = temp->tm_year - 80;//As per FAT spec + iCrtTime.iCurrentTime.Hour = temp->tm_hour; + iCrtTime.iCurrentTime.Minute = temp->tm_min; + iCrtTime.iCurrentTime.Seconds = temp->tm_sec / 2;//As per FAT spec + iCrtTimeTenth = 0; + + temp = localtime(&aAccessTime); + iLstAccDate.iCurrentDate.Day = temp->tm_mday; + iLstAccDate.iCurrentDate.Month = temp->tm_mon+1; //As per FAT spec + iLstAccDate.iCurrentDate.Year = temp->tm_year - 80;//As per FAT spec + + temp = localtime(&aWriteTime); + iWrtDate.iCurrentDate.Day = temp->tm_mday; + iWrtDate.iCurrentDate.Month = temp->tm_mon+1; //As per FAT spec + iWrtDate.iCurrentDate.Year = temp->tm_year - 80;//As per FAT spec + iWrtTime.iCurrentTime.Hour = temp->tm_hour; + iWrtTime.iCurrentTime.Minute = temp->tm_min; + iWrtTime.iCurrentTime.Seconds = temp->tm_sec / 2;//As per FAT spec + + iFileSize = aSize ; +} +/** WriteDirEntries : Write FAT information for this node to a cluster buffer + * aStartIndex : [in],the beginning index of the outputed cluster + * aClusterData : [in,out] the cluster buffer + * + * notice, aClusterData is only required if node is a directory node. + * for a file node, no data will be written out. + * in this case, only corresponding cluster index information is updated. + */ +void TFSNode::WriteDirEntries(TUint aStartIndex,TUint8* aClusterData){ + if(iFATEntry){ + *((TUint16*)iFATEntry->DIR_FstClusHI) = (aStartIndex >> 16) ; + *((TUint16*)iFATEntry->DIR_FstClusLO) = (aStartIndex & 0xFFFF) ; + } + + if(iAttrs & ATTR_DIRECTORY) { // Directory , write dir entries ; + TShortDirEntry* entry = reinterpret_cast(aClusterData); + if(iParent != NULL) { + //Make + GetShortEntry(entry); + //TODO: Add comments to avoid mistaken deleting. + memcpy(entry->DIR_Name,". ",sizeof(entry->DIR_Name)); + entry ++ ; + iParent->GetShortEntry(entry); + memcpy(entry->DIR_Name,".. ",sizeof(entry->DIR_Name)); + entry ++ ; + } + TFSNode* child = iFirstChild ; + while(child){ + int items = child->GetLongEntries(reinterpret_cast(entry)); + entry += items ; + child->GetShortEntry(entry); + child->iFATEntry = entry ; + entry ++ ; + child = child->iSibling ; + + } + + } +} +/** GetShortEntry : Make a short directory entry (FAT16/32 conception) + * aEntry : the entry buffer + */ +void TFSNode::GetShortEntry(TShortDirEntry* aEntry) { + if(!aEntry) return ; + if(iFATEntry){ + if(iFATEntry != aEntry) + memcpy(aEntry,iFATEntry,sizeof(TShortDirEntry)); + return ; + } + memcpy(aEntry->DIR_Name,iShortName,sizeof(aEntry->DIR_Name)); + aEntry->DIR_Attr = iAttrs; + aEntry->DIR_NTRes = 0 ; + aEntry->DIR_CrtTimeTenth = 0 ; + memcpy(aEntry->DIR_CrtTime,&iCrtTime,sizeof(aEntry->DIR_CrtTime)); + memcpy(aEntry->DIR_CrtDate,&iCrtDate,sizeof(aEntry->DIR_CrtDate)); + memcpy(aEntry->DIR_LstAccDate,&iLstAccDate,sizeof(aEntry->DIR_LstAccDate)); + memset(aEntry->DIR_FstClusHI,0,sizeof(aEntry->DIR_FstClusHI)); + memcpy(aEntry->DIR_WrtTime,&iWrtTime,sizeof(aEntry->DIR_WrtTime)); + memcpy(aEntry->DIR_WrtDate,&iWrtDate,sizeof(aEntry->DIR_WrtDate)); + memset(aEntry->DIR_FstClusLO,0,sizeof(aEntry->DIR_FstClusLO)); + memcpy(aEntry->DIR_FileSize,&iFileSize,sizeof(aEntry->DIR_FileSize)); +} +TUint8 FATChkSum(const char* pFcbName) { + short fcbNameLen ; + TUint8 sum = 0 ; + for(fcbNameLen = 11 ; fcbNameLen != 0 ; fcbNameLen --) { + sum = ((sum & 1) ? 0x80 : 0 ) + (sum >> 1 ) + *pFcbName++ ; + } + return sum ; +} +/** GetLongEntries : Make a series of long directory entries (FAT16/32 conception) + * aEntries : the start addr of the long directory entries buffer + * + * return value : actual entris count. + */ +int TFSNode::GetLongEntries(TLongDirEntry* aEntries) { + + if(!aEntries) return 0; + int packs = (GetWideNameLength() + KBytesPerEntry) / KBytesPerEntry ; + + TUint buflen = packs * KBytesPerEntry; + TUint16* buffer = new(std::nothrow) TUint16[buflen]; + if(!buffer) + return 0 ; + memset(buffer,0xff,(buflen << 1)); + if(iWideName) { + memcpy(buffer,iWideName->c_str(),iWideName->bytes()); + buffer[iWideName->length()] = 0; + } + TUint8 chkSum = FATChkSum(iShortName);; + + TUint16* ptr = buffer ; + TLongDirEntry* entry = aEntries +(packs - 1); + for(int i = 1 ; i <= packs ; i++, entry--) { + entry->LDIR_Ord = i ; + entry->LDIR_Chksum = chkSum ; + entry->LDIR_Attr = (TUint8)ATTR_LONG_NAME; + *((TUint16*)(entry->LDIR_FstClusLO)) = 0; + entry->LDIR_Type = 0; + memcpy(entry->LDIR_Name1,ptr,10); + memcpy(entry->LDIR_Name2,&ptr[5],12); + memcpy(entry->LDIR_Name3,&ptr[11],4); + ptr += 13; + } + aEntries->LDIR_Ord |= 0x40 ; + + delete []buffer ; + return packs ; +} +/** Make a unique name for a new child which has not been added. + * to avoid same short names under a directory + * rShortName : [in,out] , The new short name to be checked and changed. + * baseNameLength: [in], the length of the base part of the short name + * not including the "~n" + * for example, + * "ABC.LOG" => baseNameLength == 3 ("ABC") + * "AB~1.TXT" => baseNameLength == 2 ("AB") + * + * + *The Numeric-Tail Generation Algorithm + + * If (a "lossy conversion" was not flagged) + * and (the long name fits within the 8.3 naming conventions) + * and (the basis-name does not collide with any existing short name) + * { + * The short name is only the basis-name without the numeric tail. + * } + * else { + * Insert a numeric-tail "~n" to the end of the primary name such that the value of + * the "~n" is chosen so that the name thus formed does not collide with + * any existing short name and that the primary name does not exceed eight + * characters in length. + * } + * The "~n" string can range from "~1" to "~999999". + * + */ + +void TFSNode::MakeUniqueShortName(char rShortName[12],TUint baseNameLength) const { + bool dup ; + char nstring[10]; + int n = 0 ; + do { + TFSNode* child = iFirstChild ; + dup = false ; + while(child){ + if(0 == memcmp(rShortName,child->iShortName,11)) { + dup = true ; + break ; + } + child = child->iSibling ; + } + if(dup){ //duplex , increase the index , make a new name + int nlen = sprintf(nstring,"~%u",++n); + while((baseNameLength + nlen > 8) && baseNameLength > 1) + baseNameLength -- ; + memcpy(&rShortName[baseNameLength],nstring,nlen); + + } + }while(dup) ; + +} + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/fsnode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/fsnode.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef __FILE_SYSTEM_ITEM_HEADER__ +#define __FILE_SYSTEM_ITEM_HEADER__ +#include "fatdefines.h" +#include +class UTF16String; +class TFSNode { +public : + TFSNode(TFSNode* aParent = 0 ,const char* aFileName = 0, TUint8 aAttrs = 0, const char* aPCSideName = 0); + ~TFSNode() ; +#ifdef _DEBUG + void PrintTree(int nTab = 0); +#endif + inline TUint8 GetAttrs() const { return iAttrs ;} + inline const char* GetFileName() const { return (iFileName != 0) ? iFileName : "" ;} + inline const char* GetPCSideName() const { return (iPCSideName != 0) ? iPCSideName : "" ;} + inline TFSNode* GetParent() const { return iParent;} + inline TFSNode* GetFirstChild() const {return iFirstChild;} + inline TFSNode* GetSibling() const { return iSibling ;} + + // return the size of memory needed to store this entry in a FAT system + // for a file entry, it's size of file + // for a directory entry, it's sumup of memory for subdir and files entry storage + TUint GetSize() const ; + + bool IsDirectory() const ; + + //Except for "." and "..", every direcoty/file entry in FAT filesystem are treated as with + //"long name", for the purpose of reserving case sensitive file name. + // This function is for GetLongEntries() to know length of long name . + int GetWideNameLength() const ; + + // To init the entry, + // For a file entry, aSize is the known file size, + // For a directory entry, aSize is not cared. + void Init(time_t aCreateTime, time_t aAccessTime, time_t aWriteTime, TUint aSize ); + + //This function is used by TFatImgGenerator::PrepareClusters, to prepare the clusters + // aClusterData should points to a buffer which is at least the size returns by + // GetSize() + void WriteDirEntries(TUint aStartIndex, TUint8* aClusterData ); + + static TFSNode* CreateFromFolder(const char* aPath,TFSNode* aParent = NULL); + + + +protected: + void GenerateBasicName(); + void MakeUniqueShortName(char rShortName[12],TUint baseNameLength) const; + void GetShortEntry(TShortDirEntry* aEntry); + int GetLongEntries(TLongDirEntry* aEntries) ; + TFSNode* iParent ; + TFSNode* iFirstChild ; + TFSNode* iSibling ; + TUint8 iAttrs ; + char* iPCSideName; + char* iFileName; + char iShortName[12]; + UTF16String* iWideName ; + TTimeInteger iCrtTime ; + TDateInteger iCrtDate ; + TUint8 iCrtTimeTenth ; + TDateInteger iLstAccDate ; + TTimeInteger iWrtTime ; + TDateInteger iWrtDate ; + TUint iFileSize ; + TShortDirEntry* iFATEntry ; +}; + +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/inc/cache/cache.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cache.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,74 @@ +/** + * @file cache.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_ + + +#define BOOST_FILESYSTEM_NO_DEPRECATED + + +/** + * @class Cache + * @brief Cache + */ +class Cache +{ +public: + /** + * @fn static Cache* Cache::GetInstance(void) + * @brief Retrieve singleton instance of class Cache. + * @return The singleton instance. + */ + static Cache* GetInstance(void) throw (CacheException); + + /** + * @fn void Cache::Initialize(path* CacheRoot) + * @brief Load Cache meta data file and initialize inner structures. + * @exception CacheException I/O operation failures or resource allocation failures. + */ + void Initialize(void) throw (CacheException); + + /** + * @fn CacheEntry Cache::GetEntryList(const char* OriginalFilename) + * @param OriginalFilename The filename of original executable which is being cached. + * @return A list of cached items for the original executables or NULL if there's no entries match the original filename. + */ + CacheEntry* GetEntryList(const char* OriginalFilaname); + + /** + * @fn void Cache::SetEntry(const char* OriginalFilename, CacheEntry* EntryRef) + * @brief Add a new cache entry into cache or update an existing cache entry. + * @param OriginalFilename The filename of the original executable file. + * @param EntryRef The address pointing to an instance of class CacheEntry, must be valid, verified by the caller. + */ + void AddEntry(const char* OriginalFilename, CacheEntry* EntryRef); + + /** + * @fn void Cache::CloseCache(void) + * @brief Update cache with all cache entries. + * @exception CacheException Catch errors occurring when the Cache gets updated. + */ + void CloseCache(void) throw (CacheException); +protected: + bool ValidateEntry(std::string& EntryRawText); + + static Cache* Only; + + std::string metafile; + + boost::mutex cachemutex; + + std::map entrymap; +private: + Cache(void); + + Cache(const Cache&); + + Cache& operator = (const Cache&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHE_H_ */ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/inc/cache/cacheablelist.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cacheablelist.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,56 @@ +/** + * @file cacheablelist.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEABLELIST_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEABLELIST_H_ + + +/** + * @class CacheableList + * @brief CacheableList is used to hold buffers for executable files to be written into the cache. + */ +class CacheableList +{ +public: + /** + * @fn CacheableList* CacheableList::GetInstance(void) + * @return The singleton instance of class CacheableList. + * @exception CacheException Not enough system resource to create an instance at the first this method gets called. + */ + static CacheableList* GetInstance(void) throw (CacheException); + + /** + * @fn void CacheableList::AddCacheable(CacheEntry* EntryRef) + * @brief Add a file which needs to be cached into the list, cache generator will process this list. + * @param EntryRef The instance of CacheEntry, it represents the file which is going to be cached. + */ + void AddCacheable(CacheEntry* EntryRef); + + /** + * @fn CacheEntry* CacheableList::GetCacheable(void) + * @brief Retrieve a file from this list and write it into cache, the write operation is performed by cache generator. + * @return The instance of CacheEntry, used by cache generator. + */ + CacheEntry* GetCacheable(void); + + virtual ~CacheableList(void); +protected: + static CacheableList* Only; + + std::queue filelist; + + boost::condition_variable queuecond; + + boost::mutex queuemutex; +private: + CacheableList(void); + + CacheableList(const CacheableList&); + + CacheableList& operator = (const CacheableList&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEABLELIST_H_ */ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/inc/cache/cacheentry.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cacheentry.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,96 @@ +/** + * @file cacheentry.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEENTRY_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEENTRY_H_ + + +/** + * @class CacheEntry + * @brief CacheEntry holds both original executable data and cached executable data. + */ +class CacheEntry +{ +public: + CacheEntry(void); + + /** + * @fn void CacheEntry::SetOriginalFilename(const char* OriginalFilename) + * @brief Assign the original filename of the executable to be cached. + * @param OriginalFilename The original filename. + */ + void SetOriginalFilename(const char* OriginalFilename); + + /** + * @fn const char* CacheEntry::GetOriginalFilename(void) + * @return The original filename. + */ + const char* GetOriginalFilename(void) const; + + void SetCachedFilename(const char* CachedFilename); + + const char* GetCachedFilename(void) const; + + void SetOriginalFileCreateTime(time_t* CreateRawTime); + + void SetOriginalFileCreateTime(const char* CreateRawTime); + + const char* GetOriginalFileCreateTime(void) const; + + void SetOriginalFileCompression(const char* CompressionMethodID); + + void SetOriginalFileCompression(unsigned int CompressionMethodID); + + const char* GetOriginalFileCompressionID(void) const; + + void SetCachedFileCompression(const char* CompressionMethodID); + + void SetCachedFileCompression(unsigned int CompressionMethodID); + + const char* GetCachedFileCompressionID(void) const; + + void SetCachedFileBuffer(char* FileBuffer, int FileBufferLen); + + const char* GetCachedFileBuffer(void) const; + + int GetCachedFileBufferLen(void) const; + + void AppendEntry(CacheEntry* EntryRef); + + CacheEntry* GetNextEntry(void) const; + + void SetNextEntry(CacheEntry* EntryRef); + + bool Equals(CacheEntry* EntryRef); + + virtual ~CacheEntry(void); +protected: + std::string originalfile; + + std::string cachedfile; + + std::string originalfilecreatetime; + + std::string originalfilecompression; + + std::string cachedfilecompression; + + std::string compressionenabled; + + std::string compressionindicator; + + CacheEntry* next; + + char* cachedfilebuffer; + + int cachedfilebuffersize; +private: + CacheEntry(const CacheEntry&); + + CacheEntry& operator = (const CacheEntry&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEENTRY_H_ */ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/inc/cache/cacheexception.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cacheexception.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,55 @@ +/** + * @file cacheexception.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEEXCEPTION_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEEXCEPTION_H_ + + +/** + * @class CacheException + * @brief Encapsulates all possible failures happening inside cache. + */ +class CacheException +{ +public: + /** + * @fn CacheException::CacheException(int ErrorCode) + * @brief Constructor + * @param ErrorCode The error code, must be one of the static constants. + */ + CacheException(int ErrorCode); + + /** + * @fn int CacheException::GetErrorCode(void) + * @brief Retrieve integer error number. + * @reurn The error code. + */ + int GetErrorCode(void); + + /** + * @fn const char* CacheException::GetErrorMessage(void) + * @brief Retrieve text error message. + * @return The error message. + */ + const char* GetErrorMessage(void); + + virtual ~CacheException(void); + + static int EPOCROOT_NOT_FOUND ; + static int RESOURCE_ALLOCATION_FAILURE; + static int CACHE_NOT_FOUND ; + static int CACHE_INVALID ; + static int CACHE_IS_EMPTY ; + static int HARDDRIVE_FAILURE ; +protected: + int errcode; +private: + CacheException(void); + + CacheException& operator = (const CacheException&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEEXCEPTION_H_ */ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/inc/cache/cachegenerator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cachegenerator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,41 @@ +/** + * @file cachegenerator.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEGENERATOR_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEGENERATOR_H_ + + +/** + * @class CacheGenerator + * @brief Cache Generator will be running in a separated thread, its job is to pick up an invalidated entry from the CacheableList and then write the content into the cache. + */ +class CacheGenerator : public boost::thread +{ +public: + /** + * @fn static CacheGenerator* CacheGenerator::GetInstance(void) + * @brief Get singleton instance. + * @return The singleton instance. + * @exception CacheException Catch resource allocation failures. + */ + static CacheGenerator* GetInstance(void) throw (CacheException); + + /** + * @fn void CacheGenerator::ProcessFiles(void) + * @brief Pick up an invalidated entry from the cacheable list and write the content into the cache (i.e. under cache root directory). + */ + static void ProcessFiles(void) throw (CacheException); +protected: + static CacheGenerator* Only; +private: + CacheGenerator(void); + + CacheGenerator(const CacheGenerator&); + + CacheGenerator& operator = (const CacheGenerator&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEGENERATOR_H_ */ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/inc/cache/cachemanager.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cachemanager.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,99 @@ +/** + * @file cachemanager.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_ + + +#define BOOST_FILESYSTEM_NO_DEPRECATED + + +/** + * @class CacheManager + * @brief Managing cache content and the processing of generating/updating cache. + * @note CacheManager will accept forward slashes as file separators and all input filenames will be normalized. + */ +class CacheManager +{ +public: + /** + * @fn static CacheManager* CacheManager::GetInstance(void) + * @brief This method is thread-safe as it's using double-check pattern for singleton creation. + * @exception CacheException Catch initialization failures. + * @return Retrieve the singleton instance of class CacheManager. + */ + static CacheManager* GetInstance(void) throw (CacheException); + + /** + * @fn E32ImageFile* CacheManager::GetE32ImageFile(char* Filename, int CurrentCompressionID) + * @brief Retrieve an instance of class E32ImageFile. + * @param OriginalFilename The filename of the original file. + * @param CurrentCompressionID The ID of compression method used over current image build. + * @return Instance of class E32ImageFile or NULL if the original file has not been cached yet. + */ + E32ImageFile* GetE32ImageFile(char* OriginalFilename, int CurrentCompressionID); + + /** + * @fn CacheEntry* CacheManager::GetE32ImageFileRepresentation(char* OriginalFilename, int CurrentCompressionID, int FileFlags) + * @param OriginalFilename The filename of the original executable file. + * @param CurrentCompressionID + * @return A valid cached entry or NULL if the original file has not been cached yet. + */ + CacheEntry* GetE32ImageFileRepresentation(char* OriginalFilename, int CurrentCompressionID); + + /** + * @fn void CacheManager::Invalidate(const char* Filename) + * @brief Add an invalidated cache entry into the cacheable list. + * @param Filename The filename of the original file. + * @param EntryRef The reference of newly created CacheEntry instance. + * @exception CacheException Catch resource allocation failures. + */ + void Invalidate(char* Filename, CacheEntry* EntryRef) throw (CacheException); + + /** + * @fn void CacheManager::CleanCache(void) + * @brief Remove all cache content from hard drive. + * @exception CacheException Catch I/O failures on deletion. + */ + void CleanCache(void) throw (CacheException); + + /** + * @fn const char* CacheManager::GetCacheRoot(void) + * @brief Retrieve the root directory of cache. + * @return The absolute path of root directory. + */ + const char* GetCacheRoot(void); + + /** + * @fn CacheManager::~CacheManager(void) + * @brief Clean up allocated resources and writes Cache class back in the cache. + * @note It's important to delete CacheManager instance if you created it with new operation. + */ + virtual ~CacheManager(void); + + /** + * @fn void CacheManager::NormalizeFilename(char* Filename) + * @brief Convert back slashes into forward slashes and remove redundant slashes. + * @param Filename The filename which will be normalized when this function gets returned. + */ + void NormalizeFilename(char* Filename); +protected: + void InitializeCache(void) throw (CacheException); + + char* cacheroot; + + static boost::mutex creationlock; + + static CacheManager* Only; +private: + CacheManager(void); + + CacheManager(const CacheManager&); + + CacheManager& operator = (const CacheManager&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEMANAGER_H_ */ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/inc/cache/cachevalidator.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/inc/cache/cachevalidator.hpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,44 @@ +/** + * @file cachevalidator.hpp + */ + + +#ifndef ROM_TOOLS_ROFSBUILD_CACHE_CACHEVALIDATOR_H_ +#define ROM_TOOLS_ROFSBUILD_CACHE_CACHEVALIDATOR_H_ + + +/** + * @class CacheValidator + * @brief Validate an existing cache entry. + */ +class CacheValidator +{ +public: + /** + * @fn CacheValidator* CacheValidator::GetInstance(void) + * @brief Get singleton instance of class CacheValidator. + * @return The singleton instance. + * @exception CacheException Catch allocation failures. + */ + static CacheValidator* GetInstance(void) throw (CacheException); + + /** + * @fn CacheEntry* CacheValidator::Validate(const char* OriginalFilename, int CurrentCompressionID) + * @brief Validate cached executable with original version. + * @param OriginalFilename The filename of original executable. + * @param CurrentCompressionID The ID of compression method used over current image build. + * @return The entry for cached file or zero if the given executable file is invalidated. + */ + CacheEntry* Validate(const char* OriginalFilename, int CurrentCompressionID); +protected: + static CacheValidator* Only; +private: + CacheValidator(void); + + CacheValidator(const CacheValidator&); + + CacheValidator& operator = (const CacheValidator&); +}; + + +#endif /* defined ROM_TOOLS_ROFSBUILD_CACHE_CACHEVALIDATOR_H_ */ diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/r_driveimage.cpp --- a/imgtools/romtools/rofsbuild/r_driveimage.cpp Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/romtools/rofsbuild/r_driveimage.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -20,7 +20,13 @@ #include #include - +#include "fsnode.h" +#include "fatimagegenerator.h" +#include +#include +#include +#include +using namespace boost ; #ifdef __LINUX__ #include @@ -48,125 +54,96 @@ #include "r_romnode.h" #include "r_rofs.h" #include "r_driveimage.h" - - -// File format supported by Rofsbuild -DriveFileFormatSupported CDriveImage::iFormatType[] = - { - {"FAT16",EFAT16}, - {"FAT32",EFAT32}, - {0,EFATINVALID} - }; - - -/** -File format conversion from char* to coresponding enum value. - -@param aUserFileFormat - pointer to user entered file format. -@param aDriveFileFormat - Reference to actual variable. -*/ -TBool CDriveImage::FormatTranslation(const char* aUserFileFormat,enum TFileSystem& aDriveFileFormat) - { - struct DriveFileFormatSupported* strPointer = iFormatType; - for( ; (strPointer->iDriveFileFormat) != '\0' ; ++strPointer ) - { - if(!strcmp(aUserFileFormat,strPointer->iDriveFileFormat)) - { - aDriveFileFormat = strPointer->iFileSystem; - return ETrue; - } - } - return EFalse; - } - - + /** Constructor: CDriveImage class @param aObey - pointer to Drive obey file. */ CDriveImage::CDriveImage(CObeyFile *aObey) - : iObey( aObey ),iParentDirEntry(0),iListReference(0),iTempDirName(NULL), iData(0) - { - } - - -/** -Destructor: CDriveImage class - -Release the resources allocated in heap. -*/ -CDriveImage::~CDriveImage() - { - iNodeAddStore.clear(); - iNodeList.clear(); - if(iData) - delete[] iData; - if(iTempDirName) - delete[] iTempDirName; - } + : iObey( aObey ) +{ +} +CDriveImage::~CDriveImage() +{ + +} /** -Creates the STL list to interface with file system module. -Creates the Temp folder for placing the executables - (those changed,due to user option like compression,un-compression & fileattribute) -Updates the excutable options (file attributes, compression etc) - -@return Status - 'KErrNone' - successfully done above operations. - 'KErrNoMemory' - Not able to allocate the memory. - 'KErrGeneral' - Unable to done the above operations. -*/ -TInt CDriveImage::CreateList() - { - - TRomNode* pRootDir = iObey->iRootDirectory; - TInt16 dirCheck = 1; - TInt retStatus = 0; - - // For Creating the temp folder. - iTempDirName = new char[KMaxGenBuffer]; - if(!iTempDirName) - return KErrNoMemory; - - // Create the temp folder. - // Check for folder exist, if exist it loops until dir created or loop exit. - while(dirCheck) - { - sprintf(iTempDirName,"%s%05d","temp",dirCheck); - retStatus = MKDIR(iTempDirName); - if(!retStatus) - break; - - ++dirCheck; + * + */ +TFSNode* CDriveImage::PrepareFileSystem(TRomNode* aRomNode){ + TUint8 attrib ; + TFSNode* root = 0; + TRomNode* romNode = aRomNode; + stack > nodesStack ; + TFSNode* parentFS = 0 ; + TFSNode* curFS = 0; + bool err = false ; + while(1) { + attrib = 0 ; + if(romNode->iAtt & KEntryAttReadOnly) + attrib |= ATTR_READ_ONLY ; + if(romNode->iAtt & KEntryAttHidden) + attrib |= ATTR_HIDDEN ; + if(romNode->iAtt & KEntryAttSystem) + attrib |= ATTR_SYSTEM ; + if(romNode->IsDirectory()) { + curFS = new(std::nothrow) TFSNode(parentFS,romNode->iName,attrib | ATTR_DIRECTORY); + if(!curFS){ + err = true ; + break ; + } + if(!root) root = curFS ; + time_t now = time(NULL); + curFS->Init(now,now,now,0); + TRomNode* child = romNode->Currentchild(); + if(child){ + TRomNode* sibling = romNode->Currentsibling(); + if(sibling) + nodesStack.push(make_pair(sibling,parentFS)); + romNode = child ; + parentFS = curFS ; + continue ; + } } - - if(!dirCheck) - { - Print(EError,"Unable to Create the temp folder,Check directory settings.\n"); - if(iTempDirName) - { - delete[] iTempDirName; - iTempDirName = 0; - } - return KErrCancel; + else { // file + curFS = new(std::nothrow) TFSNode(parentFS,romNode->iEntry->iName,attrib,romNode->iEntry->iFileName); + if(!curFS){ + err = true ; + break ; + } + + if(!root) root = curFS ; + struct stat statbuf ; + stat(romNode->iEntry->iFileName, &statbuf); + curFS->Init(statbuf.st_ctime,statbuf.st_atime,statbuf.st_mtime,statbuf.st_size); + + } + + TRomNode* sibling = romNode->Currentsibling(); + if(sibling) { + romNode = sibling ; } - - // Construct the file options. - if(ConstructOptions() != KErrNone) - { - return KErrGeneral; - } - - // Construct the List. - if((GenTreeTraverse(pRootDir,KNodeTypeRoot)) != KErrNone ) - { - return KErrGeneral; - } - - return KErrNone; + else { + if(nodesStack.empty()) { + break ; + } + else { + romNode = nodesStack.top().first; + parentFS = nodesStack.top().second ; + nodesStack.pop() ; + + } + } + } + if(err) { + if(root) delete root ; + return NULL ; } - + return root ; +} /** Creates the Image/Call to file system module. @@ -179,396 +156,31 @@ @return Status(r) - returns the status of file system module. 'KErrGeneral' - Unable to done the above operations properly. */ -TInt CDriveImage::CreateImage(const char* alogfile) - { - - TInt retStatus = 0; - retStatus = CreateList(); - - if((retStatus == KErrCancel) || (retStatus == KErrNoMemory)) - return KErrGeneral; - - if(retStatus != KErrNone) - { - Print(EError,"Insufficent Memory/Not able to generate the Structure\n"); - if(DeleteTempFolder(iTempDirName) != KErrNone ) - { - Print(EWarning,"Not able to delete the temp folder : %s",iTempDirName); - } - return KErrGeneral; - } - - // Close log file. - H.CloseLogFile(); +TInt CDriveImage::CreateImage(const char* alogfile) { - // Convert fileformat to corresponding enum value. - enum TFileSystem fileFormat = (TFileSystem)0; - FormatTranslation(iObey->iDriveFileFormat,fileFormat); - - // Call to file system module. create the image. - if(iObey->iDataSize) - retStatus = CFileSystemInterFace::CreateFilesystem(&iNodeList,fileFormat, - (char*)iObey->iDriveFileName, - (char*)alogfile, - iObey->iConfigurableFatAttributes, - iObey->iDataSize); - else - retStatus = CFileSystemInterFace::CreateFilesystem(&iNodeList,fileFormat, - (char*)iObey->iDriveFileName, - (char*)alogfile, - iObey->iConfigurableFatAttributes); ; - - //delete the temp folder. - if(DeleteTempFolder(iTempDirName) != KErrNone ) - { - cout << "Warning: Not able to delete the temp folder : " << iTempDirName << "\n" ; - } - - return retStatus; + TSupportedFatType fst = EFatUnknown ; + if(stricmp(iObey->iDriveFileFormat,"FAT16") == 0) + fst = EFat16 ; + else if(stricmp(iObey->iDriveFileFormat,"FAT32") == 0) + fst = EFat32 ; + if(EFatUnknown == fst){ + Print(EError,"Unsupported FAT type : %s",iObey->iDriveFileFormat); + return KErrGeneral ; } - - - -/** -Delete the temp directory. - -@param aTempDirName - Temporory folder name to be deleted. -@return Status(r) - returns the status. - 'KErrGeneral' - Unable to done the above operations properly. - 'KErrNone' - successfully deleted the folder. -*/ -TInt CDriveImage::DeleteTempFolder(const char* aTempDirName) - { - - TInt fileDeleted = 1; - string dirPath(aTempDirName); - string fileName(aTempDirName); - -#ifdef __LINUX__ - - // Open directory - DIR *dirHandler = opendir(aTempDirName); - struct dirent *dirEntry; - - if(!dirHandler) - return KErrGeneral; - - dirPath.append("/"); - fileName.append("/"); - - // Go through each entry - while((dirEntry = readdir(dirHandler))) - { - if(dirEntry->d_type != DT_DIR) - { - fileName.append((char*)dirEntry->d_name); - remove(fileName.c_str()); - fileName.assign(dirPath); - } - } - //Close dir - if(!closedir(dirHandler)) - { - fileDeleted = rmdir(aTempDirName); - } -#else - - WIN32_FIND_DATA FindFileData; - HANDLE hFind = INVALID_HANDLE_VALUE; - - dirPath.append("\\*"); - fileName.append("\\"); - - // find the first file - hFind = FindFirstFile(dirPath.c_str(),&FindFileData); - - if(hFind == INVALID_HANDLE_VALUE) - return KErrGeneral; + + TFatImgGenerator generator(fst,iObey->iConfigurableFatAttributes); - dirPath.assign(fileName); - - do - { - // Check for directory or file. - if(!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - // Delete the file. - fileName.append((char*)FindFileData.cFileName); - remove(fileName.c_str()); - fileName.assign(dirPath); - } - } while(FindNextFile(hFind,&FindFileData)); - - FindClose(hFind); - - if(ERROR_NO_MORE_FILES != GetLastError()) - { - cout << "Warning: FindNextFile error. Error is " << GetLastError() << "\n" ; - } - - fileDeleted = _rmdir(aTempDirName); - -#endif - - if(!fileDeleted) - return KErrNone; - else - return KErrGeneral; + if(!generator.IsValid()){ + return KErrGeneral; } - - -/** -General Tree Traverse to create the List. -Recursive call to update the list. - -@param anode - Current Node in the tree. -@param anodeType - Node type(root,child,sibling) - -@return r - returns 'KErrNoMemory' if fails to generate the list or memory not allocated. - or 'KErrNone' -*/ -TInt CDriveImage::GenTreeTraverse(TRomNode* anode,enum KNodeType anodeType) - { - - TInt r =0; - if((r = CreateDirOrFileEntry(anode,anodeType)) != KErrNone) - return KErrNoMemory; - - if(anode->Currentchild()) - { - if((r = GenTreeTraverse(anode->Currentchild(),KNodeTypeChild)) != KErrNone) - return KErrNoMemory; - - if(iNodeAddStore.size()) - iNodeAddStore.pop_back(); - - --iListReference; - } - - if(anode->Currentsibling()) - { - if((r = GenTreeTraverse(anode->Currentsibling(),KNodeTypeSibling)) != KErrNone) - return KErrNoMemory; - } - return r; - } - - -/** -Generate the List. required for drive image creation. -Hidden file node is not placed in list. - -@param atempnode - Current Node in the tree. -@param aType - Node type(root,child,sibling) - -@return r - returns 'KErrNoMemory' if memory is not allocated or 'KErrNone' -*/ -TInt CDriveImage::CreateDirOrFileEntry(TRomNode* atempnode,enum KNodeType aType) - { - - CDirectory* parentDirectory = NULL ; - if(KNodeTypeChild == aType) - parentDirectory = iParentDirEntry; - else if(KNodeTypeSibling == aType) - parentDirectory = (CDirectory*)(iNodeAddStore[iListReference-1]); + TFSNode* root = PrepareFileSystem(iObey->iRootDirectory); + if(!root) + return KErrGeneral; - CDirectory* iDirectory = new CDirectory(atempnode->iName,parentDirectory); - if(!iDirectory) - return KErrNoMemory; + + TInt retVal = generator.Execute(root,iObey->iDriveFileName) ? KErrNone : KErrGeneral; + + delete root ; - char attrib = 0 ; - if(atempnode->iAtt & KEntryAttReadOnly) - attrib |= EAttrReadOnly ; - if(atempnode->iAtt & KEntryAttHidden) - attrib |= EAttrHidden ; - if(atempnode->iAtt & KEntryAttSystem) - attrib |= EAttrSystem ; - - - // for files only. - if(atempnode->iEntry) - { - iDirectory->SetEntryAttribute(attrib); - - // don't place the hidden files to list. - if(!atempnode->iHidden) - { - iDirectory->SetFilePath(atempnode->iEntry->iFileName); - iDirectory->SetFileSize(atempnode->iSize); - } - else - { - iNodeAddStore.push_back((void*)iParentDirEntry); - ++iListReference; - return KErrNone; - } - } - else - iDirectory->SetEntryAttribute(attrib | EAttrDirectory); - - - switch(aType) - { - case KNodeTypeRoot: - iDirectory->SetEntryAttribute(EAttrVolumeId); - iNodeList.push_back(iDirectory); - iParentDirEntry = iDirectory; - break; - - case KNodeTypeChild: - iNodeAddStore.push_back((void*)iParentDirEntry); - ++iListReference; - parentDirectory->InsertIntoEntryList(iDirectory); - iParentDirEntry = iDirectory ; - break; - - case KNodeTypeSibling: - parentDirectory->InsertIntoEntryList(iDirectory); - iParentDirEntry = iDirectory ; - break; - - default: - break; - } - return KErrNone; - } - - -/** -Traverses all entries and update compress/uncompress and file attribute options. - -Place executables in temp folder.(if changed) -Hidden file node is not placed in temp folder. - -@return r - returns 'KErrNoMemory/KErrGeneral' if fails to update the options or memory - not allocated or else 'KErrNone' for Succesfully operation. -*/ -TInt CDriveImage::ConstructOptions() { - - TInt32 len = 0; - TRomNode* node = TRomNode::FirstNode(); - CBytePair bpe; - - while(node) - { - // Don't do anything for hidden files. - if(node->IsFile() && (!node->iHidden)) - { - - TInt32 size=HFile::GetLength(node->iEntry->iFileName); - if(size <= 0) - { - Print(EWarning,"File %s does not exist or is 0 bytes in length.\n",node->iEntry->iFileName); - } - node->iSize = size; - if(node->iEntry->iExecutable && (size > 0)) - { - - if((node->iFileUpdate) || (node->iOverride)) - { - size_t allocSize = size << 1 ; - iData = new char[allocSize]; - if(!iData) - return KErrNoMemory; - - HMem::Set(iData, 0xff, allocSize); - TUint8* aData = (TUint8*)iData; - len = node->PlaceFile(aData,0,allocSize,&bpe); - if(len < KErrNone) - { - delete[] iData; - iData = 0; - return KErrGeneral; - } - - // Place the file in Newly created Folder. - TInt r = PlaceFileTemporary(len,node); - delete[] iData; - iData = 0; - - if(r != KErrNone) - { - return r; - } - } // file update end. - } - } // is file end - node = node->NextNode(); - } - return KErrNone; - } - - -/** -Place the modified exe's(e32 format) in Temp Folder. -Place executables in temp folder.(if changed) - -@param afileSize - No. of bytes to be palced in the file. -@param acurrentNode - file node, to modify its source path. - -@return r - returns 'KErrNoMemory' if fails to allocate the memory. - or 'KErrNone' -*/ -TInt CDriveImage::PlaceFileTemporary(const TInt afileSize,TRomNode* acurrentNode) - { - - TInt randomValue = 0; - char randomString[KMaxGenBuffer] = "\0"; - char* fileSourcePath = acurrentNode->iEntry->iName; - string newFileName; - - do - { - newFileName.append(iTempDirName); - newFileName.append("/"); - - if(!randomValue) - { - newFileName.append(fileSourcePath); - } - else - { - newFileName.append(randomString); - newFileName.append(fileSourcePath); - } - - - ifstream test(newFileName.c_str()); - if (!test) - { - test.close(); - ofstream driveFile(newFileName.c_str(),ios_base::binary); - if (!driveFile) - { - Print(EError,"Cannot open file %s for output\n",newFileName.c_str()); - return KErrGeneral; - } - - driveFile.write(iData,afileSize); - driveFile.close(); - - // Update the new source path. - delete[] acurrentNode->iEntry->iFileName; - acurrentNode->iEntry->iFileName = new char[ newFileName.length() + 1 ]; - if(!acurrentNode->iEntry->iFileName) - return KErrNoMemory; - - memcpy(acurrentNode->iEntry->iFileName,newFileName.c_str(),newFileName.length()); - acurrentNode->iEntry->iFileName[newFileName.length()] = 0; - break; - } - - test.close(); - newFileName.erase(); - ++randomValue; - sprintf(randomString,"%d",randomValue); - - } - while(randomValue); - - return KErrNone; - } - - - - + return retVal; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/r_driveimage.h --- a/imgtools/romtools/rofsbuild/r_driveimage.h Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/romtools/rofsbuild/r_driveimage.h Wed Jun 30 11:35:58 2010 +0800 @@ -21,13 +21,9 @@ #ifndef __R_DRIVEIMAGE_H__ #define __R_DRIVEIMAGE_H__ -#include -#include "filesysteminterface.h" +#include #include -typedef vector EntryReferenceVector; -typedef list EntryList; - const TInt KMaxGenBuffer=0x14; // Node Type. @@ -40,12 +36,8 @@ }; // File Format Supported. -struct DriveFileFormatSupported - { - const char* iDriveFileFormat; - enum TFileSystem iFileSystem; - }; +class TFSNode ; // Image creation class. class CDriveImage { @@ -53,37 +45,14 @@ CDriveImage(CObeyFile *aObey); ~CDriveImage(); TInt CreateImage(const char* alogfile); - static TBool FormatTranslation(const char* aUserFileFormat,enum TFileSystem& aDriveFileFormat); - + private: - - TInt CreateList(); - TInt GenTreeTraverse(TRomNode* anode,enum KNodeType anodeType); - TInt CreateDirOrFileEntry(TRomNode* atempnode,enum KNodeType aType); - TInt ConstructOptions(); - TInt PlaceFileTemporary(const TInt afileSize,TRomNode* acurrentNode); - TInt DeleteTempFolder(const char* aTempDirName); - -private: - + + TFSNode* PrepareFileSystem(TRomNode* aRomNode); // Holds the address of CObeyFile object. used to get the object information. - CObeyFile *iObey; - // Container required for file sysem module. - EntryList iNodeList; - // Pointer for nested Container. - CDirectory* iParentDirEntry ; - - // For temp storge of Container address. - EntryReferenceVector iNodeAddStore; - - // For file format support. - static DriveFileFormatSupported iFormatType[]; - // Reference variable used for converting tree to list. - TInt iListReference; - // Holds temp folder name. - char *iTempDirName; - // Pointer to buffer, which will be used for compression/un-compression purpose. - char *iData; + CObeyFile *iObey; + + }; #endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/r_obey.cpp --- a/imgtools/romtools/rofsbuild/r_obey.cpp Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/romtools/rofsbuild/r_obey.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -37,7 +37,7 @@ #include "r_obey.h" #include "r_coreimage.h" #include "patchdataprocessor.h" -#include "filesysteminterface.h" +#include "fatimagegenerator.h" #include "r_driveimage.h" extern TInt gCodePagingOverride; @@ -54,6 +54,7 @@ { {_K("file"), 2,-2, EKeywordFile, "File to be copied into ROFS"}, {_K("data"), 2,-2, EKeywordData, "same as file"}, + {_K("dir"), 2,1, EKeywordDir, "Directory to be created into FAT image"}, {_K("rofsname"), 1, 1, EKeywordRofsName, "output file for ROFS image"}, {_K("romsize"), 1, 1, EKeywordRomSize, "size of ROM image"}, @@ -412,8 +413,7 @@ const FileAttributeKeyword ObeyFileReader::iAttributeKeywords[] = { {"attrib",3 ,0,1,EAttributeAtt, "File attributes in ROM file system"}, - {"exattrib",3 ,0,1,EAttributeAttExtra, "File extra attributes in ROM file system"}, - // {_K("compress") ,1,1,EAttributeCompress, "Compress file"}, + {"exattrib",3 ,0,1,EAttributeAttExtra, "File extra attributes in ROM file system"}, {"stack",3 ,1,1,EAttributeStack, "?"}, {"fixed",3 ,1,0,EAttributeFixed, "Relocate to a fixed address space"}, {"priority",3 ,1,1,EAttributePriority, "Override process priority"}, @@ -497,10 +497,8 @@ iTime(0), iRootDirectory(0), iNumberOfDataFiles(0), -iDriveFileName(0), -iDataSize(0), -iDriveFileFormat(0), -iConfigurableFatAttributes(new ConfigurableFatAttributes), +iDriveFileName(0), +iDriveFileFormat(0), iReader(aReader), iMissingFiles(0), iLastExecutable(0), @@ -539,9 +537,7 @@ iRomFileName = 0 ; } if (iRootDirectory) - iRootDirectory->Destroy(); - if(iConfigurableFatAttributes) - delete iConfigurableFatAttributes; + iRootDirectory->Destroy(); if(iPatchData) delete iPatchData; } @@ -739,6 +735,7 @@ case EKeywordHide: case EKeywordFile: + case EKeywordDir: case EKeywordData: case EKeywordFileCompress: case EKeywordFileUncompress: @@ -789,16 +786,8 @@ Print(EWarning,"Not a valid Image Size. Default size is considered\n"); break; } -#ifdef __LINUX__ - errno = 0; - iDataSize = strtoll(bigString,NULL,10); - if((iDataSize == LONG_MAX) || (iDataSize == LONG_MIN) ||(errno == ERANGE)) - { - Print(EWarning,"Invalid Range. Default size is considered\n"); - } -#else - iDataSize = _atoi64(bigString); -#endif + + Val(iConfigurableFatAttributes.iImageSize,bigString); } break; case EKeywordDataImageVolume: @@ -823,8 +812,13 @@ position = volumeLabel.find_first_of("\r\n"); if (position != string::npos) volumeLabel = volumeLabel.substr(0,position); - - iConfigurableFatAttributes->iDriveVolumeLabel = volumeLabel.data() ; + size_t length = volumeLabel.length() ; + if(length > 11) + length = 11 ; + memcpy(iConfigurableFatAttributes.iDriveVolumeLabel,volumeLabel.c_str(),length) ; + while(length != 11) + iConfigurableFatAttributes.iDriveVolumeLabel[length++] = ' '; + iConfigurableFatAttributes.iDriveVolumeLabel[length] = 0; } else { Print(EWarning,"Value for Volume Label is not provided. Default value is considered.\n"); @@ -839,7 +833,7 @@ Print(EWarning,"Invalid Sector Size value. Default value is considered.\n"); } else { - iConfigurableFatAttributes->iDriveSectorSize = atoi(bigString); + iConfigurableFatAttributes.iDriveSectorSize = atoi(bigString); } } break; @@ -850,7 +844,7 @@ if (noOfFats <=0) Print(EWarning,"Invalid No of FATs specified. Default value is considered.\n"); else - iConfigurableFatAttributes->iDriveNoOfFATs = atoi(bigString); + iConfigurableFatAttributes.iDriveNoOfFATs = atoi(bigString); } break; default: @@ -879,7 +873,7 @@ retVal = EFalse; } // Check for '-'ve entered value. - if(iDataSize <= 0){ + if(iConfigurableFatAttributes.iImageSize <= 0){ Print(EWarning,"Image Size should be positive. Default size is Considered.\n"); } @@ -891,10 +885,8 @@ } // Checking the validity of file system format. - if(iDriveFileFormat){ - strupr((char *)iDriveFileFormat); - enum TFileSystem check = (TFileSystem)0; - if(!(CDriveImage::FormatTranslation(iDriveFileFormat,check))) { + if(iDriveFileFormat){ + if(stricmp(iDriveFileFormat,"FAT16") && stricmp(iDriveFileFormat,"FAT32")) { Print(EError,"The name of the file system not supported : %s\n",iDriveFileFormat); retVal = EFalse; } @@ -931,6 +923,7 @@ switch (aKeyword) { case EKeywordData: + case EKeywordDir: case EKeywordHide: isPeFile = EFalse; break; @@ -950,7 +943,7 @@ return EFalse; } - if (aKeyword!=EKeywordHide) { + if (aKeyword!=EKeywordHide && aKeyword!=EKeywordDir) { // check the PC file exists char* nname = NormaliseFileName(iReader.Word(1)); ifstream test(nname); @@ -965,10 +958,15 @@ else epocPathStart=1; - iNumberOfFiles++; + if(aKeyword != EKeywordDir) + iNumberOfFiles++; TBool endOfName=EFalse; - const char *epocStartPtr= IsValidFilePath(iReader.Word(epocPathStart)); + const char *epocStartPtr; + if(aKeyword != EKeywordDir) + epocStartPtr = IsValidFilePath(iReader.Word(epocPathStart)); + else + epocStartPtr = IsValidDirPath(iReader.Word(epocPathStart)); char *epocEndPtr = const_cast(epocStartPtr); if (epocStartPtr == NULL) { @@ -982,7 +980,7 @@ while (!endOfName) { endOfName = GetNextBitOfFileName(epocEndPtr); - if (endOfName) { // file + if (endOfName && (aKeyword!=EKeywordDir)) { // file TRomNode* alreadyExists=dir->FindInDirectory(epocStartPtr); if ((aKeyword != EKeywordHide) && alreadyExists) { // duplicate file if (gKeepGoing) { @@ -1034,6 +1032,10 @@ } else { // directory + //for directory creation, given /sys/bin/, it's possible to reach 0 at the end, just ignore that... + if(!*epocStartPtr) + break; + subDir = dir->FindInDirectory(epocStartPtr); if (!subDir){ // sub directory does not exist if(aKeyword==EKeywordHide) { @@ -1683,6 +1685,9 @@ if (len == 0) return NULL; len=0; + p++; + continue; + } len++; p++; @@ -1690,6 +1695,24 @@ return (len ? aPath : NULL); } +const char* CObeyFile::IsValidDirPath(const char* aPath) +{ + const char* walker = aPath; + + //validate path... + while(*walker) + { + if(((*walker=='/') || (*walker=='\\')) && ((*(walker+1)=='/') || (*(walker+1)=='\\'))) + return (const char*)0; + walker++; + } + + if((*aPath=='/') || (*aPath=='\\')) + aPath++; + + return aPath; +} + // // Move the end pointer past the next directory separator, replacing it with 0 // diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/r_obey.h --- a/imgtools/romtools/rofsbuild/r_obey.h Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/romtools/rofsbuild/r_obey.h Wed Jun 30 11:35:58 2010 +0800 @@ -26,6 +26,7 @@ #include #include #include +#include "fatdefines.h" #include #include @@ -46,6 +47,7 @@ EKeywordNone=0, // backwards compatibility, but now ignored EKeywordFile, EKeywordData, + EKeywordDir, EKeywordRofsName, EKeywordExtensionRofs, EKeywordCoreRofsName, @@ -178,7 +180,8 @@ }; class CPatchDataProcessor; -struct ConfigurableFatAttributes; +// Configurable FAT attributes + class CObeyFile { @@ -194,10 +197,9 @@ TRomNode* iRootDirectory; TInt iNumberOfDataFiles; // Added to support Data Drive Images. - char* iDriveFileName; - TInt64 iDataSize; + char* iDriveFileName; char* iDriveFileFormat; - ConfigurableFatAttributes* iConfigurableFatAttributes; + ConfigurableFatAttributes iConfigurableFatAttributes; private: ObeyFileReader& iReader; @@ -252,6 +254,7 @@ static TBool GetNextBitOfFileName(char*& epocEndPtr); static const char *IsValidFilePath(const char *aPath); + static const char* IsValidDirPath(const char* aPath); TBool iAutoSize; TUint32 iAutoPageSize; diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/rofsbuild.cpp --- a/imgtools/romtools/rofsbuild/rofsbuild.cpp Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/romtools/rofsbuild/rofsbuild.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -46,8 +46,8 @@ #endif static const TInt RofsbuildMajorVersion=2; -static const TInt RofsbuildMinorVersion=10; -static const TInt RofsbuildPatchVersion=4; +static const TInt RofsbuildMinorVersion=12; +static const TInt RofsbuildPatchVersion=0; static TBool SizeSummary=EFalse; static TPrintType SizeWhere=EAlways; @@ -313,13 +313,13 @@ gLowMem = ETrue; else { #ifdef WIN32 - cout << "Unrecognised option " << argv[i] << "\n"; + Print (EWarning, "Unrecognised option %s\n",argv[i]); #else if(0 == access(argv[i],R_OK)){ filename.assign(argv[i]); } else { - cout << "Unrecognised option " << argv[i] << "\n"; + Print (EWarning, "Unrecognised option %s\n",argv[i]); } #endif @@ -335,14 +335,13 @@ if((gDriveImage == EFalse) && (gSmrImage == EFalse) && (filename.empty() || (gUseCoreImage && gImageFilename.length() == 0))){ - PrintVersion(); - cout << HelpText; + Print (EAlways, HelpText); if (reallyHelp) { ObeyFileReader::KeywordHelp(); - cout << ReallyHelpText; + Print (EAlways, ReallyHelpText); } else if (filename.empty()){ - Print(EError, "Obey filename is missing\n"); + Print(EAlways, "Obey filename is missing\n"); } } } @@ -399,10 +398,10 @@ // Drive image creation. retstatus = userImage->CreateImage(alogfile); if(retstatus == KErrNone) { - cout << "\nSuccessfully generated the Drive image : " << mainObeyFile->iDriveFileName << "\n"; + Print (EAlways, "\nSuccessfully generated the Drive image : %s \n",mainObeyFile->iDriveFileName); } else { - cout << "\nFailed to generate the Image : " << mainObeyFile->iDriveFileName << "\n"; + Print (EError, "Failed to generate the Image : %s\n",mainObeyFile->iDriveFileName); } delete userImage; } @@ -437,10 +436,10 @@ retstatus = smrImage->CreateImage(); } if(retstatus == KErrNone) { - cout << "\nSuccessfully generated the SMR image : " << smrImage->GetImageName().c_str() << "\n"; + Print (EAlways, "\nSuccessfully generated the SMR image : %s\n" ,smrImage->GetImageName().c_str()); } else { - cout << "\nFailed to generate the Image : " << smrImage->GetImageName().c_str() << "\n"; + Print (EError, "\nFailed to generate the Image : %s\n" ,smrImage->GetImageName().c_str()); } delete smrImage; } @@ -472,15 +471,16 @@ #endif if(gCPUNum > MAXIMUM_THREADS) gCPUNum = MAXIMUM_THREADS; + PrintVersion(); processCommandLine(argc, argv); //if the user wants to clean up the cache, do it only. if(gCleanCache){ try { CacheManager::GetInstance()->CleanCache(); - printf("Cache has been deleted successfully.\r\n"); + Print (EAlways, "Cache has been deleted successfully.\n"); } catch(CacheException& ce){ - printf("%s\r\n", ce.GetErrorMessage()); + Print (EError, "%s\n", ce.GetErrorMessage()); return (TInt)1; } return r; @@ -491,7 +491,7 @@ CacheManager::GetInstance(); } catch(CacheException ce){ - printf("%s\r\n", ce.GetErrorMessage()); + Print (EError, "%s\n", ce.GetErrorMessage()); return (TInt)1; } } @@ -503,11 +503,11 @@ } if(gThreadNum == 0) { if(gCPUNum > 0) { - printf("The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum); + Print (EWarning, "The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum); gThreadNum = gCPUNum; } else { - printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS); + Print (EWarning, "Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS); gThreadNum = DEFAULT_THREADS; } } @@ -525,7 +525,6 @@ char* logfile = 0; if(Getlogfile(driveobeyFileName,logfile) == KErrNone) { H.SetLogFile(logfile); - PrintVersion(); GetLocalTime(); r = ProcessDataDriveMain(driveobeyFileName,logfile); H.CloseLogFile(); @@ -534,7 +533,7 @@ return KErrNoMemory; } else { - cout << "Error : Invalid obey file name : " << driveobeyFileName << "\n" ; + Print(EError,"Invalid obey file name : %s\n", driveobeyFileName); } } driveobeyFileName = ptr; @@ -554,7 +553,6 @@ char * logfile = 0; if(Getlogfile(smrImageObeyFileName,logfile) == KErrNone){ H.SetLogFile(logfile); - PrintVersion(); GetLocalTime(); r = ProcessSmrImageMain(smrImageObeyFileName, logfile); H.CloseLogFile(); @@ -563,7 +561,7 @@ return KErrNoMemory; } else { - cout << "Error: Invalid obey file name: " << smrImageObeyFileName << "\n"; + Print(EError,"Invalid obey file name: %s", smrImageObeyFileName); } } smrImageObeyFileName = ptr; @@ -572,8 +570,7 @@ } // Process Rofs Obey files. if(obeyFileName) { - H.SetLogFile("ROFSBUILD.LOG"); - PrintVersion(); + H.SetLogFile("ROFSBUILD.LOG"); ObeyFileReader *reader = new ObeyFileReader(obeyFileName); if (!reader->Open()) return KErrGeneral; @@ -661,9 +658,7 @@ r = extensionRofs->WriteImage(0); delete extensionRofs; - delete extensionObeyFile; extensionRofs = 0; - extensionObeyFile = 0; } while (r == KErrNone); if(RofsImage) { delete RofsImage; diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/rofsbuild.mmp --- a/imgtools/romtools/rofsbuild/rofsbuild.mmp Wed Jun 23 17:27:59 2010 +0800 +++ b/imgtools/romtools/rofsbuild/rofsbuild.mmp Wed Jun 30 11:35:58 2010 +0800 @@ -24,6 +24,7 @@ SOURCEPATH ../rofsbuild SOURCE r_obey.cpp r_build.cpp r_rofs.cpp r_driveimage.cpp r_driveutl.cpp SOURCE rofsbuild.cpp r_coreimage.cpp r_smrimage.cpp symbolgenerator.cpp +SOURCE fatcluster.cpp fsnode.cpp fatimagegenerator.cpp SOURCEPATH ../../imglib/host SOURCE h_utl.cpp h_file.cpp h_mem.cpp utf16string.cpp SOURCEPATH ../rofsbuild/src/cache @@ -42,14 +43,14 @@ OS_LAYER_SYSTEMINCLUDE_SYMBIAN -USERINCLUDE ../../imglib/inc ../../imglib/compress ../../imglib/filesystem/include +USERINCLUDE ../../imglib/inc ../../imglib/compress USERINCLUDE ../../imglib/patchdataprocessor/include ../../imglib/parameterfileprocessor/include USERINCLUDE ../../imglib/memmap/include USERINCLUDE ../rofsbuild/inc USERINCLUDE ../../imglib/boostlibrary/ USERINCLUDE ../../imglib/boostlibrary/boost -STATICLIBRARY filesystem patchdataprocessor parameterfileprocessor memmap +STATICLIBRARY patchdataprocessor parameterfileprocessor memmap STATICLIBRARY boost_thread-1.39 boost_filesystem-1.39 boost_regex-1.39 boost_system-1.39 #ifdef TOOLS2_LINUX OPTION GCC -pthread -O2 -Wno-uninitialized diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/src/cache/cache.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cache.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,242 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "e32image.h" + +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cacheablelist.hpp" +#include "cache/cache.hpp" +#include "cache/cachegenerator.hpp" +#include "cache/cachevalidator.hpp" +#include "cache/cachemanager.hpp" +#include +#ifdef __LINUX__ +#define _alloca alloca +#endif + +Cache* Cache::Only = (Cache*)0; + + +Cache* Cache::GetInstance(void) throw (CacheException) +{ + if(! Cache::Only) + { + Cache::Only = new (std::nothrow) Cache(); + if(! Cache::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + } + + return Cache::Only; +} + + +void Cache::Initialize(void) throw (CacheException) +{ + //create and open cache meta data file. + + + metafile = CacheManager::GetInstance()->GetCacheRoot(); + metafile += "/.rofsmeta"; + boost::filesystem::path metafilepath(metafile.c_str()); + if(!exists(metafilepath)) + { + //create cache root directory if it's not present. + boost::filesystem::path createcacheroot(CacheManager::GetInstance()->GetCacheRoot()); + create_directory(createcacheroot); + + //create cache index file. + ofstream openmetafile(metafilepath.file_string().c_str(), ios_base::app | ios_base::out); + if(! openmetafile.is_open()) + throw CacheException(CacheException::CACHE_INVALID); + openmetafile.close(); + } + printf("Loading cache meta file : %s\r\n", metafilepath.file_string().c_str()); + ifstream metafileref(metafilepath.file_string().c_str(), ios_base::in); + if(! metafileref.is_open()) + throw CacheException(CacheException::HARDDRIVE_FAILURE); + + //read ROFS meta file and construct entry map. + string inboundbuffer; + while(getline(metafileref, inboundbuffer)) + { + //validate cache index record. + if(! ValidateEntry(inboundbuffer)) + throw CacheException(CacheException::CACHE_INVALID); + + //instantiate a new instance of class CacheEntry. + CacheEntry* entryref = new (nothrow) CacheEntry(); + if(!entryref) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + + //set entry's attributes. + + char* attrwalker = (char*)_alloca(inboundbuffer.length() + 1); + memcpy(attrwalker,inboundbuffer.c_str(),inboundbuffer.length() + 1); + + char* start = attrwalker ; + while(*start != ';') + start++; + *start++ = 0; + entryref->SetOriginalFilename(attrwalker); + attrwalker = start; + while(*start != ';') + start++; + *start++ = 0; + entryref->SetOriginalFileCreateTime(attrwalker); + attrwalker = start; + while(*start != ';') + start++; + *start++ = 0; + entryref->SetOriginalFileCompression(attrwalker); + attrwalker = start; + while(*start != ';') + start++; + *start++ = 0; + entryref->SetCachedFilename(attrwalker); + attrwalker = start; + entryref->SetCachedFileCompression(attrwalker); + + //add newly created entry into entry-map. + string newentrystring(entryref->GetOriginalFilename()); + CacheEntry* existentryref = entrymap[newentrystring]; + if(existentryref) { + while(existentryref->GetNextEntry()) + existentryref = existentryref->GetNextEntry(); + existentryref->AppendEntry(entryref); + } + else { + entrymap[newentrystring] = entryref; + } + + //reinitialize inbound buffer. + inboundbuffer.clear(); + } + + return; +} + + +CacheEntry* Cache::GetEntryList(const char* OriginalFilename) +{ + //retrieval could be performed concurrently. + boost::lock_guard lock(cachemutex); + string originalfile(OriginalFilename); + CacheEntry* resultentries = entrymap[originalfile]; + + return resultentries; +} + + +void Cache::AddEntry(const char* OriginalFilename, CacheEntry* EntryRef) +{ + string originalfile(OriginalFilename); + + //addtions could be performed concurrently. + boost::lock_guard lock(cachemutex); + + entrymap[originalfile] = EntryRef; + + return; +} + + +void Cache::CloseCache(void) throw (CacheException) +{ + //open up the cache meta file. + boost::filesystem::path metafilepath(metafile); + ofstream metafileref; + if(! exists(metafilepath)) + metafileref.open(metafilepath.file_string().c_str(), ios_base::out | ios_base::app); + else + metafileref.open(metafilepath.file_string().c_str(), ios_base::out | ios_base::trunc); + if(! metafileref.is_open()) + throw CacheException(CacheException::HARDDRIVE_FAILURE); + + //save cache meta onto hard drive along with changed cache files. + char* delimiter = ";"; + map::iterator mapitem; + for(mapitem=entrymap.begin(); mapitem != entrymap.end(); mapitem++) + { + CacheEntry* concreteentryref = (*mapitem).second; + while(concreteentryref) + { + metafileref.write(concreteentryref->GetOriginalFilename(), strlen(concreteentryref->GetOriginalFilename())); + metafileref.write(delimiter, strlen(delimiter)); + metafileref.write(concreteentryref->GetOriginalFileCreateTime(), strlen(concreteentryref->GetOriginalFileCreateTime())); + metafileref.write(delimiter, strlen(delimiter)); + metafileref.write(concreteentryref->GetOriginalFileCompressionID(), strlen(concreteentryref->GetOriginalFileCompressionID())); + metafileref.write(delimiter, strlen(delimiter)); + metafileref.write(concreteentryref->GetCachedFilename(), strlen(concreteentryref->GetCachedFilename())); + metafileref.write(delimiter, strlen(delimiter)); + metafileref.write(concreteentryref->GetCachedFileCompressionID(), strlen(concreteentryref->GetCachedFileCompressionID())); + metafileref.write("\n", strlen("\n")); + +// CacheEntry* tobedeletedentryref = concreteentryref; + concreteentryref = concreteentryref->GetNextEntry(); +// delete tobedeletedentryref; + } + } + + //close cache meta file. + metafileref.close(); + + return; +} + + +bool Cache::ValidateEntry(string& EntryRawText) +{ + //an entry is formed as original_filename;original_file_create_time;original_file_compression_id;cached_filename;cached_file_compression_id(end of line - '\n') + + //format validation. + int semicolon = 0; + size_t semicolonposition = 0; + while(1) { + semicolonposition = EntryRawText.find(';', semicolonposition); + if(semicolonposition != string::npos) { + semicolonposition++; + semicolon++; + } + else + break; + } + if(semicolon != 4) + return false; + + return true; +} + + +Cache::Cache(void) +{ + return; +} + diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/src/cache/cacheablelist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cacheablelist.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include + +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cacheablelist.hpp" + + +CacheableList* CacheableList::Only = (CacheableList*)0; + + +CacheableList* CacheableList::GetInstance(void) throw (CacheException) +{ + if(! CacheableList::Only) + { + CacheableList::Only = new (std::nothrow) CacheableList(); + if(! CacheableList::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + } + + return CacheableList::Only; +} + + +void CacheableList::AddCacheable(CacheEntry* EntryRef) +{ + if(1) + { + boost::mutex::scoped_lock lock(this->queuemutex); + this->filelist.push(EntryRef); + } + + this->queuecond.notify_all(); + + return; +} + + +CacheEntry* CacheableList::GetCacheable(void) +{ + boost::mutex::scoped_lock lock(this->queuemutex); + while(this->filelist.empty()) + this->queuecond.wait(lock); + + CacheEntry* resref = this->filelist.front(); + this->filelist.pop(); + + return resref; +} + + +CacheableList::~CacheableList(void) +{ + return; +} + + +CacheableList::CacheableList(void) +{ + return; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/src/cache/cacheentry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cacheentry.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,225 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" + + +CacheEntry::CacheEntry(void) +{ + this->next = (CacheEntry*)0; + this->cachedfilebuffer = (char*)0 ; + this->cachedfilebuffersize = 0 ; + + return; +} + + +void CacheEntry::SetOriginalFilename(const char* OriginalFilename) +{ + this->originalfile.clear(); + this->originalfile.assign(OriginalFilename); + + return; +} + + +const char* CacheEntry::GetOriginalFilename(void) const +{ + return this->originalfile.c_str(); +} + + +void CacheEntry::SetCachedFilename(const char* CachedFilename) +{ + this->cachedfile.clear(); + this->cachedfile.assign(CachedFilename); + + return; +} + + +const char* CacheEntry::GetCachedFilename(void) const +{ + return this->cachedfile.c_str(); +} + + +void CacheEntry::SetOriginalFileCreateTime(time_t* CreateRawTime) +{ + this->originalfilecreatetime.clear(); + this->originalfilecreatetime.assign(ctime(CreateRawTime)); + + size_t newlinepos = this->originalfilecreatetime.find("\n"); + while(newlinepos != std::string::npos) + { + this->originalfilecreatetime.erase(newlinepos, 1); + newlinepos = this->originalfilecreatetime.find(("\n")); + } + + return; +} + + +void CacheEntry::SetOriginalFileCreateTime(const char* CreateRawTime) +{ + this->originalfilecreatetime.clear(); + this->originalfilecreatetime.assign(CreateRawTime); + + return; +} + + +const char* CacheEntry::GetOriginalFileCreateTime(void) const +{ + return this->originalfilecreatetime.c_str(); +} + + +void CacheEntry::SetOriginalFileCompression(const char* CompressionMethodID) +{ + this->originalfilecompression.clear(); + this->originalfilecompression.assign(CompressionMethodID); + + return; +} + + +void CacheEntry::SetOriginalFileCompression(unsigned int CompressionMethodID) +{ + char methodid[30]; + memset(methodid, 0, sizeof(methodid)); + sprintf(methodid, "%d", CompressionMethodID); + + this->originalfilecompression.clear(); + this->originalfilecompression.assign(methodid); + + return; +} + + +const char* CacheEntry::GetOriginalFileCompressionID(void) const +{ + return this->originalfilecompression.c_str(); +} + + +void CacheEntry::SetCachedFileCompression(const char* CompressionMethodID) +{ + this->cachedfilecompression.clear(); + this->cachedfilecompression.assign(CompressionMethodID); + + return; +} + + +void CacheEntry::SetCachedFileCompression(unsigned int CompressionMethodID) +{ + char methodid[128]; + memset(methodid, 0, sizeof(methodid)); + sprintf(methodid, "%d", CompressionMethodID); + + this->cachedfilecompression.clear(); + this->cachedfilecompression.assign(methodid); + + return; +} + + +const char* CacheEntry::GetCachedFileCompressionID(void) const +{ + return this->cachedfilecompression.c_str(); +} + + +void CacheEntry::SetCachedFileBuffer(char* FileBuffer, int FileBufferLen) +{ + this->cachedfilebuffer = (char*)malloc(sizeof(char)*FileBufferLen); + memcpy(this->cachedfilebuffer, FileBuffer, FileBufferLen); + this->cachedfilebuffersize = FileBufferLen; + + return; +} + + +const char* CacheEntry::GetCachedFileBuffer(void) const +{ + return this->cachedfilebuffer; +} + + +int CacheEntry::GetCachedFileBufferLen(void) const +{ + return this->cachedfilebuffersize; +} + + +void CacheEntry::AppendEntry(CacheEntry* EntryRef) +{ + //the parameter EntryRef must be valid, should be verified by the caller. + this->next = EntryRef; + + return; +} + + +CacheEntry* CacheEntry::GetNextEntry(void) const +{ + return this->next; +} + + +void CacheEntry::SetNextEntry(CacheEntry* EntryRef) +{ + this->next = EntryRef; + + return; +} + + +bool CacheEntry::Equals(CacheEntry* EntryRef) +{ + if( (this->originalfile.compare(EntryRef->GetOriginalFilename())==0) && + (this->originalfilecreatetime.compare(EntryRef->GetOriginalFileCreateTime())==0) && + (this->originalfilecompression.compare(EntryRef->GetOriginalFileCompressionID())==0) && + (this->cachedfile.compare(EntryRef->GetCachedFilename())==0) && + (this->cachedfilecompression.compare(EntryRef->GetCachedFileCompressionID())==0) + ) + return true; + + return false; +} + + +CacheEntry::~CacheEntry(void) +{ + if(this->cachedfilebuffer) + { + free(this->cachedfilebuffer); + this->cachedfilebuffer = NULL; + } + + return; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/src/cache/cacheexception.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cacheexception.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "cache/cacheexception.hpp" + + +int CacheException::EPOCROOT_NOT_FOUND = 1; +int CacheException::RESOURCE_ALLOCATION_FAILURE = 2; +int CacheException::CACHE_NOT_FOUND = 3; +int CacheException::CACHE_INVALID = 4; +int CacheException::CACHE_IS_EMPTY = 5; +int CacheException::HARDDRIVE_FAILURE = 6; + + +CacheException::CacheException(int ErrorCode) +{ + this->errcode = ErrorCode; + + return; +} + + +int CacheException::GetErrorCode(void) +{ + return this->errcode; +} + + +const char* CacheException::GetErrorMessage(void) +{ + if(this->errcode == CacheException::EPOCROOT_NOT_FOUND) + return "EPOCROOT environment variable is not set."; + else if(this->errcode == CacheException::RESOURCE_ALLOCATION_FAILURE) + return "Not enough system resources to initialize cache module."; + else if(this->errcode == CacheException::CACHE_NOT_FOUND) + return "Cache is not present in the current system."; + else if(this->errcode == CacheException::CACHE_INVALID) + return "Cache is invalid."; + else if(this->errcode == CacheException::CACHE_IS_EMPTY) + return "Cache is empty."; + else if(this->errcode == CacheException::HARDDRIVE_FAILURE) + return "A hard drive failure occurred in Cache operations."; + + return "Undefined error type."; +} + + +CacheException::~CacheException(void) +{ + return; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/src/cache/cachegenerator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cachegenerator.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cacheablelist.hpp" +#include "cache/cachegenerator.hpp" + +using namespace std ; +CacheGenerator* CacheGenerator::Only = (CacheGenerator*)0; + + +CacheGenerator* CacheGenerator::GetInstance(void) throw (CacheException) +{ + if(! CacheGenerator::Only) + { + CacheGenerator::Only = new (nothrow) CacheGenerator(); + if(! CacheGenerator::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + } + + return CacheGenerator::Only; +} + + +void CacheGenerator::ProcessFiles(void) throw (CacheException) +{ + while(1) + { + //pick one entry from the CacheableList. + CacheEntry* entryref = CacheableList::GetInstance()->GetCacheable(); + if(! entryref->GetCachedFileBuffer()) + break; + + //write cacheable content into the cache. + boost::filesystem::path filepath(entryref->GetCachedFilename()); + string filename = filepath.file_string(); + ofstream fileref(filename.c_str(), ios_base::binary | ios_base::out | ios_base::trunc); + if(! fileref.is_open()) + { + printf("Cannot write/update cached %s\r\n", filepath.file_string().c_str()); + continue; + } + + fileref.write(entryref->GetCachedFileBuffer(), entryref->GetCachedFileBufferLen()); + fileref.close(); + } + + return; +} + + +CacheGenerator::CacheGenerator(void) : boost::thread(ProcessFiles) +{ + return; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/src/cache/cachemanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cachemanager.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,231 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include + +#include "e32image.h" + +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cache.hpp" +#include "cache/cachegenerator.hpp" +#include "cache/cachevalidator.hpp" +#include "cache/cacheablelist.hpp" +#include "cache/cachemanager.hpp" + +using namespace std; + + +CacheManager* CacheManager::Only = (CacheManager*)0; +boost::mutex CacheManager::creationlock; + + +CacheManager* CacheManager::GetInstance(void) throw (CacheException) +{ + if(! CacheManager::Only) + { + boost::mutex::scoped_lock lock(CacheManager::creationlock); + if(! CacheManager::Only) + { + CacheManager::Only = new (nothrow) CacheManager(); + if(!CacheManager::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + CacheManager::Only->InitializeCache(); + } + } + + return CacheManager::Only; +} + + +E32ImageFile* CacheManager::GetE32ImageFile(char* OriginalFilename, int CurrentCompressionID) +{ + this->NormalizeFilename(OriginalFilename); + CacheEntry* validatedfile =CacheValidator::GetInstance()->Validate(OriginalFilename, CurrentCompressionID); + if(! validatedfile) + return (E32ImageFile*)0; + + printf("%s is validated in cache.\r\n", OriginalFilename); + E32ImageFile* cachedimagefile = new (nothrow) E32ImageFile(); + if(! cachedimagefile) + return (E32ImageFile*)0; + boost::filesystem::path cachedfile(validatedfile->GetCachedFilename()); + ifstream filecontentreader(cachedfile.file_string().c_str(), ios_base::in | ios_base::binary); + if(! filecontentreader.is_open()) + return (E32ImageFile*)0; + filecontentreader.seekg(0, ios_base::end); + int contentlength = filecontentreader.tellg(); + cachedimagefile->iData = (char*)malloc(sizeof(char)*contentlength); + filecontentreader.seekg(0, ios_base::beg); + filecontentreader.read(cachedimagefile->iData, contentlength); + cachedimagefile->iHdr->iUncompressedSize = contentlength - cachedimagefile->iHdr->TotalSize(); + + return cachedimagefile; +} + + +CacheEntry* CacheManager::GetE32ImageFileRepresentation(char* OriginalFilename, int CurrentCompressionID) +{ + this->NormalizeFilename(OriginalFilename); + + return CacheValidator::GetInstance()->Validate(OriginalFilename, CurrentCompressionID); +} + + +void CacheManager::Invalidate(char* Filename, CacheEntry* EntryRef) throw (CacheException) +{ + //update cache meta file. + this->NormalizeFilename(Filename); + Cache::GetInstance()->AddEntry(Filename, EntryRef); + + //update cache content. + CacheableList::GetInstance()->AddCacheable(EntryRef); + + printf("Caching %s\r\n", Filename); + + return; +} + + +void CacheManager::CleanCache(void) throw (CacheException) +{ + //check if the cache is present in the current system. + boost::filesystem::path cacherootdir(this->cacheroot); + if(! exists(cacherootdir)) + throw CacheException(CacheException::CACHE_NOT_FOUND); + + //remove files iteratively from cache root directory. + if(remove_all(cacherootdir) <= 0) + throw CacheException(CacheException::CACHE_IS_EMPTY); + + return; +} + + +const char* CacheManager::GetCacheRoot(void) +{ + return this->cacheroot; +} + + +CacheManager::~CacheManager(void) +{ + CacheEntry* newentryref = new (nothrow) CacheEntry(); + CacheableList::GetInstance()->AddCacheable(newentryref); + Cache::GetInstance()->CloseCache(); + CacheGenerator::GetInstance()->join(); + + delete CacheValidator::GetInstance(); + delete Cache::GetInstance(); + delete CacheGenerator::GetInstance(); + delete CacheableList::GetInstance(); + + return; +} + + +void CacheManager::InitializeCache(void) throw (CacheException) +{ + //assume the root directory is EPOCROOT/epoc32/build/.cache + char* epocroot = getenv("EPOCROOT"); + if(! epocroot) + throw CacheException(CacheException::EPOCROOT_NOT_FOUND); + + //initialize cacheroot member variable. + int cacherootstrlen = sizeof(char)*(strlen(epocroot)+strlen("/epoc32/build/.cache")+1); + this->cacheroot = (char*)malloc(cacherootstrlen); + if(! this->cacheroot) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + memset(this->cacheroot, 0, cacherootstrlen); + sprintf(this->cacheroot, "%s%s", epocroot, "/epoc32/build/.cache"); + + //normalize cache root path. + this->NormalizeFilename(this->cacheroot); + + //create cache root directory if it is not present. + boost::filesystem::path cacherootdir(this->cacheroot); + if(! exists(cacherootdir)) + create_directories(cacherootdir); + printf("Using %s as cache root directory.\r\n", cacherootdir.file_string().c_str()); + + //create cache instance. + Cache* cacheref = Cache::GetInstance(); + if(! cacheref) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + + //create cache validator instance. + if(! CacheValidator::GetInstance()) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + + //create cacheable list instance + if(! CacheableList::GetInstance()) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + + //initialize cache container. + cacheref->Initialize(); + + //start cache generator. + CacheGenerator::GetInstance(); + + return; +} + + +void CacheManager::NormalizeFilename(char* Filename) +{ + if(!Filename) + return; + + //convert back slashes into forward slashes. + char* normalizedfilename = Filename; + while(*normalizedfilename) + { + if(*normalizedfilename == '\\') + *normalizedfilename = '/'; + + normalizedfilename++; + } + + //remove redundant slashes. + char* redundantfilename = Filename; + while(*redundantfilename) + { + if((*redundantfilename=='/') && (*(redundantfilename+1)=='/')) + { + redundantfilename++; + continue; + } + *Filename++ = *redundantfilename++; + } + *Filename = 0; + + return; +} + + +CacheManager::CacheManager(void) +{ + return; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/src/cache/cachevalidator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/src/cache/cachevalidator.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cache/cacheexception.hpp" +#include "cache/cacheentry.hpp" +#include "cache/cache.hpp" +#include "cache/cachevalidator.hpp" + +using namespace std ; +CacheValidator* CacheValidator::Only = (CacheValidator*)0; + + +CacheValidator* CacheValidator::GetInstance(void) throw (CacheException) +{ + if(! CacheValidator::Only) + { + CacheValidator::Only = new (nothrow) CacheValidator(); + if(! CacheValidator::Only) + throw CacheException(CacheException::RESOURCE_ALLOCATION_FAILURE); + } + + return CacheValidator::Only; +} + + +CacheEntry* CacheValidator::Validate(const char* OriginalFilename, int CurrentCompressionID) +{ + if(! OriginalFilename) + return (CacheEntry*)0; + + //an executable will be validated if its creation time does not altered and the compression method is not different against previous image build used. + CacheEntry* entryref = Cache::GetInstance()->GetEntryList(OriginalFilename); + if(! entryref) + { + return (CacheEntry*)0; + } + while(entryref) + { + boost::filesystem::path originalfile(OriginalFilename); + time_t originalcreationtime = last_write_time(originalfile); + string creationtime(ctime(&originalcreationtime)); + size_t newlinepos = creationtime.find("\n"); + while(newlinepos != string::npos) + { + creationtime.erase(newlinepos, 1); + newlinepos = creationtime.find(("\n")); + } + if((creationtime.compare(entryref->GetOriginalFileCreateTime())== 0) || (atoi(entryref->GetCachedFileCompressionID())==CurrentCompressionID)) + { + boost::filesystem::path cachedfile(entryref->GetCachedFilename()); + string filename = cachedfile.file_string(); + ifstream filecontentreader(filename.c_str(), ios_base::in | ios_base::binary); + if(! filecontentreader.is_open()){ + cerr << "Cannot open cached file " << filename << endl ; + return NULL; + } + filecontentreader.seekg(0, ios_base::end); + int contentlength = filecontentreader.tellg(); + char* bufferref = new char[contentlength + 1]; + filecontentreader.seekg(0, ios_base::beg); + filecontentreader.read(bufferref, contentlength); + bufferref[contentlength] = 0 ; + entryref->SetCachedFileBuffer(bufferref, contentlength); + delete []bufferref; + + cout << "Using cached" << OriginalFilename << endl ; + + return entryref; + } + + entryref = entryref->GetNextEntry(); + } + + return (CacheEntry*)0; +} + + +CacheValidator::CacheValidator(void) +{ + return; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/symbolgenerator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/symbolgenerator.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,279 @@ +#include +#define MAX_LINE 65535 +#include "symbolgenerator.h" +#include "e32image.h" + +#if defined(__LINUX__) +#define PATH_SEPARATOR '/' +#else +#define PATH_SEPARATOR '\\' +#endif + +boost::mutex SymbolGenerator::iMutexSingleton; +SymbolGenerator* SymbolGenerator::iInst = NULL; +SymbolGenerator* SymbolGenerator::GetInstance(){ + iMutexSingleton.lock(); + if(iInst == NULL) { + iInst = new SymbolGenerator(); + } + iMutexSingleton.unlock(); + return iInst; +} +void SymbolGenerator::Release() { + iMutexSingleton.lock(); + if(iInst != NULL) { + delete iInst; + iInst = NULL; + } + iMutexSingleton.unlock(); +} +void SymbolGenerator::SetSymbolFileName( const string& fileName ){ + if(iSymFile.is_open()) + iSymFile.close(); + string s = fileName.substr(0,fileName.rfind('.'))+".symbol"; + printf("* Writing %s - ROFS symbol file\n", s.c_str()); + iSymFile.open(s.c_str()); +} +void SymbolGenerator::AddFile( const string& fileName, bool isExecutable ){ + iMutex.lock(); + iQueueFiles.push(TPlacedEntry(fileName,isExecutable)); + iMutex.unlock(); + iCond.notify_all(); +} +void SymbolGenerator::ProcessExecutable( const string& fileName ){ + char str[MAX_LINE]; + string outString; + outString = "\nFrom "; + outString += fileName + "\n\n"; + iSymFile.write(outString.c_str(),outString.length()); + string mapFile2 = fileName+".map"; + size_t dot = fileName.rfind('.'); + string mapFile = fileName.substr(0,dot)+".map"; + ifstream fMap; + fMap.open(mapFile2.c_str()); + if(!fMap.is_open()) { + fMap.open(mapFile.c_str()); + } + + if(!fMap.is_open()) { + printf("%s\nWarning: Can't open \"%s\" or \"%s\"\n",fileName.c_str(),mapFile2.c_str(),mapFile.c_str()); + int binSize = GetSizeFromBinFile(fileName); + memset(str,0,sizeof(str)); + sprintf(str,"%04x", binSize); + outString = "00000000 "; + outString += str; + outString += " "; + outString += fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } + else { + if(!fMap.good()) fMap.clear(); + boost::regex regARMV5("ARMV5", boost::regex::icase); + boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase); + boost::cmatch what; + if(regex_search(fileName, what, regARMV5)) { + ProcessArmv5File(fileName, fMap); + } + else if(regex_search(fileName, what, regGCCEoARMV4)) { + ProcessGcceOrArm4File(fileName, fMap); + } + else { + printf("\nWarning: cannot determine linker type used to create %s\n",fileName.c_str()); + outString = "00000000 0000 "; + outString += fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } + } +} +void SymbolGenerator::ProcessDatafile( const string& fileName ){ + string line = "\nFrom "+fileName+"\n\n00000000 0000 "+fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n"; + iSymFile.write(line.c_str(),line.length()); +} +void SymbolGenerator::ProcessArmv5File( const string& fileName, ifstream& aMap ){ + aMap.seekg (0, ios::beg); + char str[MAX_LINE]; + string outString; + aMap.getline(str,MAX_LINE); + boost::cmatch what; + boost::regex reg("^ARM Linker"); + if(!regex_search(str, what, reg)) { + printf("\nWarning: expecting %s to be generated by ARM linker\n", fileName.c_str()); + outString = "00000000 0000 "+fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } + reg.assign("Global Symbols"); + while(aMap.getline(str,MAX_LINE)) { + if(regex_search(str, what, reg)) { + break; + } + } + + reg.assign("^\\s*(.+)\\s*0x(\\S+)\\s+[^\\d]*(\\d+)\\s+(.*)$"); + string sSym,sTmp,sSection; + unsigned int addr,size,baseOffset = 0; + map syms; + char symString[MAX_LINE]; + while(aMap.getline(str,MAX_LINE)) { + if(regex_search(str, what, reg)) { + sSym.assign(what[1].first,what[1].second-what[1].first); + sTmp.assign(what[2].first,what[2].second-what[2].first); + addr = strtol(sTmp.c_str(), NULL, 16); + sTmp.assign(what[3].first,what[3].second-what[3].first); + size = strtol(sTmp.c_str(), NULL, 10); + sSection.assign(what[4].first,what[4].second-what[4].first); + if(sSection.find("(StubCode)") != string::npos) + size = 8; + if(addr > 0) { + memset(symString,0,sizeof(symString)); + sprintf(symString,"%04x ",size); + outString = symString; + outString += sSym+" "; + outString += sSection; + if(baseOffset == 0) + baseOffset = addr; + unsigned int k = addr - baseOffset; + if( (syms.find(k) == syms.end()) || size != 0) + syms[k] = outString; + } + // end of addr>0 + } + // end of regex_search + } + + map::iterator it; + for(it = syms.begin(); it != syms.end(); it++) { + memset(str,0,sizeof(str)); + sprintf(str,"%08x",it->first); + outString = str; + outString += " "; + outString += it->second+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } +} +void SymbolGenerator::ProcessGcceOrArm4File( const string& fileName, ifstream& aMap ){ + aMap.seekg (0, ios_base::beg); + char str[MAX_LINE]; + aMap.getline(str,MAX_LINE); + boost::cmatch what; + boost::regex reg("^\\.text\\s+"); + while(aMap.getline(str,MAX_LINE)) { + if(regex_search(str, what, reg)) { + break; + } + } + + reg.assign("^\\.text\\s+(\\w+)\\s+\\w+"); + if(!regex_search(str, what, reg)) { + printf("ERROR: Can't get .text section info for \"%s\"\n",fileName.c_str()); + } + else { + string sTmp, sLibFile; + sTmp.assign(what[1].first,what[1].second-what[1].first); + unsigned int imgText = strtol(sTmp.c_str(), NULL, 16); + + reg.assign("^LONG 0x.*", boost::regex::icase); + boost::cmatch what1; + boost::regex reg1("^\\s(\\.text)?\\s+(0x\\w+)\\s+(0x\\w+)\\s+(.*)$", boost::regex::icase); + boost::regex reg2("^\\s+(\\w+)\\s\\s+([a-zA-Z_].+)", boost::regex::icase); + boost::regex reg3(".*lib\\(.*d\\d*s_?\\d{5}.o\\)$", boost::regex::icase); + + map syms; + unsigned int addr, len, stubhex; + + while(aMap.getline(str,MAX_LINE)) { + if(strlen(str) == 0) + break; + else if(regex_search(str, what, reg1)) { + sLibFile.assign(what[4].first,what[4].second-what[4].first); + if(!regex_search(sLibFile, what1, reg)) { + sTmp.assign(what[2].first,what[2].second-what[2].first); + addr = strtol(sTmp.c_str(), NULL, 16); + sTmp.assign(what[3].first,what[3].second-what[3].first); + len = strtol(sTmp.c_str(), NULL, 16); + syms[addr+len] = ""; + if(regex_search(sLibFile, what, reg3)) { + stubhex = addr; + } + } + } + else if(regex_search(str, what, reg2)) { + sTmp.assign(what[1].first,what[1].second-what[1].first); + addr = strtol(sTmp.c_str(), NULL, 16); + sTmp.assign(what[2].first,what[2].second-what[2].first); + syms[addr] = (addr == stubhex)? ("stub "+sTmp) : sTmp; + } + } + + map::iterator it = syms.begin(); + map::iterator itp = it++; + string outString; + for(; it != syms.end(); itp = it++) { + if(itp->second != "") { + memset(str,0,sizeof(str)); + sprintf(str,"%08x %04x ",(itp->first-imgText), (it->first-itp->first)); + outString = str; + outString += it->second+"\n"; + iSymFile.write(outString.c_str(),outString.length()); + } + } + } +} +int SymbolGenerator::GetSizeFromBinFile( const string& fileName ){ + TInt ret = 0; + ifstream aIf(fileName.c_str(), ios_base::binary); + if( !aIf.is_open() ) { + printf("Warning: Cannot open file \n"); + } + else { + E32ImageFile e32Image; + TUint32 aSz; + + aIf.seekg(0,ios_base::end); + aSz = aIf.tellg(); + + e32Image.Adjust(aSz); + e32Image.iFileSize = aSz; + + aIf.seekg(0,ios_base::beg); + aIf >> e32Image; + ret = e32Image.iOrigHdr->iCodeSize; + } + return ret; +} +void SymbolGenerator::thrd_func(){ + SymbolGenerator* me = GetInstance(); + + TPlacedEntry pe("",false); + while(1) { + if(1) { + //scope the code block with if(1) for lock + boost::mutex::scoped_lock lock(me->iMutex); + while(me->iQueueFiles.empty()) + me->iCond.wait(lock); + /* + if(me->iQueueFiles.empty()) { + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + continue; + } + */ + + pe = me->iQueueFiles.front(); + me->iQueueFiles.pop(); + } + + if(pe.iFileName == "") + break; + else if(pe.iExecutable) + me->ProcessExecutable(pe.iFileName); + else + me->ProcessDatafile(pe.iFileName); + } +} +SymbolGenerator::SymbolGenerator() : boost::thread(thrd_func) { +} +SymbolGenerator::~SymbolGenerator(){ + if(joinable()) + join(); + iSymFile.flush(); + iSymFile.close(); +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rofsbuild/symbolgenerator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rofsbuild/symbolgenerator.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,43 @@ +#ifndef __SYMBOLGENERATOR_H__ +#define __SYMBOLGENERATOR_H__ +#include +#include +#include +using namespace std; +#include +#include + + +struct TPlacedEntry{ + string iFileName; + bool iExecutable; + TPlacedEntry(const string& aName, bool aExecutable) { + iFileName = aName; + iExecutable = aExecutable; + } +}; +class SymbolGenerator : public boost::thread { + public: + static SymbolGenerator* GetInstance(); + static void Release(); + void SetSymbolFileName( const string& fileName ); + void AddFile( const string& fileName, bool isExecutable ); + private: + SymbolGenerator(); + ~SymbolGenerator(); + void ProcessExecutable( const string& fileName ); + void ProcessDatafile( const string& fileName ); + void ProcessArmv5File( const string& fileName, ifstream& aMap ); + void ProcessGcceOrArm4File( const string& fileName, ifstream& aMap ); + int GetSizeFromBinFile( const string& fileName ); + static void thrd_func(); + + queue iQueueFiles; + boost::mutex iMutex; + static boost::mutex iMutexSingleton; + static SymbolGenerator* iInst; + boost::condition_variable iCond; + + ofstream iSymFile; +}; +#endif diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rombuild/symbolgenerator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rombuild/symbolgenerator.cpp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,536 @@ +#include +#include +#include "symbolgenerator.h" +#include "r_rom.h" +#include +#include "h_utl.h" +typedef boost::unique_lock scoped_lock ; +typedef boost::lock_guard guarded_lock ; + +SymbolGenerator::SymbolGenerator(const char* aSymbolFileName, int aMultiThreadsCount/* = 1*/) : +iOutput(aSymbolFileName,ios_base::out |ios_base::binary | ios_base::trunc) { + if(iOutput.is_open()){ + if(aMultiThreadsCount < 1) + aMultiThreadsCount = 1; + + for(int i = 0 ; i < aMultiThreadsCount ; i++){ + iThreads.add_thread(new boost::thread(ThreadFunc,this)); + } + } + else { + cerr << "\nWarning: Can't write data to \""<::iterator i = iErrMsgs.begin() ; i != iErrMsgs.end() ; i++){ + char* msg = *i ; + cerr << msg ; + delete []msg ; + } + iErrMsgs.clear(); +} + +void SymbolGenerator::AddEntry(const SymGenContext& aEntry){ + if(iOutput.is_open()){ + guarded_lock lock(iQueueMutex); + iEntries.push(aEntry); + iCond.notify_all(); + } +} +void SymbolGenerator::ThreadFunc(SymbolGenerator* aInst) { + SymGenContext entry ; + while(1){ + entry.iFileName = 0; + if(1) { + scoped_lock lock(aInst->iQueueMutex); + while(aInst->iEntries.empty()){ + aInst->iCond.wait(lock); + } + entry = aInst->iEntries.front(); + if(0 == entry.iFileName) // end , exit + return ; + + aInst->iEntries.pop(); + } + aInst->ProcessEntry(entry); + } + +} +#define MAX_LINE_LENGTH 65535 +#define SKIP_WS(p) while((*p) == ' ' || (*p) == '\t') (p)++ +#define FIND_WS(p) while((*p) != ' ' && (*p) != '\t' && (*p) != 0) (p)++ +static void split(char* str, vector& result) { + result.clear(); + while(*str) { + SKIP_WS(str); + char* saved = str ; + FIND_WS(str); + bool end = (0 == *str); + *str = 0 ; + if(saved != str) + result.push_back(saved); + if(!end) str ++ ; + } +} +static void make_lower(char* str){ + while(*str){ + if(*str >= 'A' && *str >= 'Z') { + *str += ('a' - 'A'); + } + str++; + } +} +bool SymbolGenerator::ProcessEntry(const SymGenContext& aContext) { + size_t allocBytes ; + if(aContext.iExecutable ) { + string mapFileName(aContext.iFileName); + mapFileName += ".map"; + ifstream ifs(mapFileName.c_str()); + if(!ifs.is_open()){ + int index = mapFileName.length() - 5 ; + int count = 1 ; + while(index > 0 && mapFileName.at(index) != '.'){ + index -- ; + count ++ ; + } + mapFileName.erase(index,count); + ifs.open(mapFileName.c_str()); + } + if(!ifs.is_open()){ + guarded_lock lock(iFileMutex); + allocBytes = mapFileName.length() + 60 ; + char* msg = new char[ allocBytes] ; + snprintf(msg,allocBytes,"\nWarning: Can't open \"%s.map\"\n",aContext.iFileName ); + iErrMsgs.push_back(msg); + msg = new char[allocBytes] ; + int n = snprintf(msg,allocBytes,"%08x %04x %s\r\n",(unsigned int)aContext.iCodeAddress,(unsigned int)aContext.iTotalSize,aContext.iFileName); + iOutput.write(msg,n); + iOutput.flush(); + return false ; + } + if(!ifs.good()) ifs.clear(); + char buffer[100]; + *buffer = 0; + //See if we're dealing with the RVCT output + ifs.getline(buffer,100); + if(!ifs.good()) { + ifs.close(); + guarded_lock lock(iFileMutex); + allocBytes = mapFileName.length() + 60; + char* msg = new char[allocBytes] ; + snprintf(msg,allocBytes,"\nWarning: File \"%s\" is opened yet can not be read!",mapFileName.c_str()); + iErrMsgs.push_back(msg); + return false ; + } + if(strncmp(buffer,"ARM Linker",10) == 0){ + return ProcessARMV5Map(ifs,aContext); + } + // See if we're dealing with the GCC output + else if ( 0 == strncmp(buffer,"Archive member included",23)){ + return ProcessGCCMap(ifs,aContext); + } + else { // Must be x86 output + ifs.seekg(0,ios_base::beg); + return ProcessX86Map(ifs,aContext); + } + } + else { + const char* fileName = aContext.iFileName; + size_t len = strlen(fileName); + size_t index = len - 1; + while(index > 0 && (fileName[index] != '\\' && fileName[index] != '/')) + index -- ; + const char* basename = fileName + index + 1 ; + allocBytes = (len << 1) + 40 ; + char* msg = new char[allocBytes] ; + int n = snprintf(msg,allocBytes,"\r\nFrom %s\r\n\r\n%08x 0000 %s\r\n", fileName ,(unsigned int)aContext.iDataAddress,basename); + guarded_lock lock(iFileMutex); + iOutput.write(msg,n); + iOutput.flush(); + delete []msg ; + return true ; + } + return true ; +} +struct ArmSymbolInfo { + string name ; + TUint size ; + string section ; +}; +typedef multimap ArmSymMap ; + +bool SymbolGenerator::ProcessARMV5Map(ifstream& aStream, const SymGenContext& aContext) { + string symName ; + ArmSymMap symbols ; + vector words ; + ArmSymbolInfo info; + char* lineStart ; + char buffer[MAX_LINE_LENGTH]; + while(aStream.good() && (!aStream.eof())){ + *buffer = 0; + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if(strstr(lineStart,"Global Symbols")) + break ; + char* armstamp = strstr(lineStart,"ARM Code"); + if(0 == armstamp) + armstamp = strstr(lineStart,"Thumb Code") ; + if(0 == armstamp) continue ; + *(armstamp - 1) = 0 ; + + char* hexStr = lineStart ; + char* nameEnd; + while(1) { + hexStr = strstr(hexStr,"0x"); + if(0 == hexStr) break ; + nameEnd = hexStr - 1; + if(*nameEnd == ' ' || *nameEnd == '\t') break ; + hexStr += 2 ; + } + if(0 == hexStr) continue ; + while(nameEnd > lineStart && (*nameEnd == ' ' || *nameEnd == '\t')) + nameEnd -- ; + + nameEnd[1] = 0; + info.name = lineStart; + char* temp ; + TUint32 addr = strtoul(hexStr + 2,&temp,16); + char* decStr ; + if(*armstamp == 'A') + decStr = armstamp + 9 ; + else + decStr = armstamp + 11 ; + SKIP_WS(decStr); + info.size = strtoul(decStr,&temp,10); + SKIP_WS(temp); + info.section = temp; + if(info.section.find("(StubCode)") != string::npos ) + info.size = 8 ; + if(addr > 0){ + symbols.insert(pair(addr,info)); + } + } + size_t lenOfFileName = strlen(aContext.iFileName); + while(aStream.good() && (!aStream.eof())){ + *buffer = 0; + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + char* hexStr = lineStart ; + char* nameEnd; + while(1) { + hexStr = strstr(hexStr,"0x"); + if(0 == hexStr) break ; + nameEnd = hexStr - 1; + if(*nameEnd == ' ' || *nameEnd == '\t') + break ; + hexStr += 2 ; + } + if(0 == hexStr) continue ; + while(nameEnd > lineStart && (*nameEnd == ' ' || *nameEnd == '\t')){ + nameEnd -- ; + } + nameEnd[1] = 0; + info.name = lineStart; + char *temp ; + TUint32 addr = strtoul(hexStr + 2,&temp,16); + while(*temp < '0' || *temp > '9' )//[^\d]* + temp++ ; + char* decStr = temp ; + info.size = strtoul(decStr,&temp,10); + SKIP_WS(temp); + info.section = temp; + if(info.section.find("(StubCode)") != string::npos ) + info.size = 8 ; + if(addr > 0){ + symbols.insert(pair(addr,info)); + } + } + + TUint32 textSectAddr = 0x00008000; // .text gets linked at 0x00008000 + TUint32 dataSectAddr = 0x00400000 ; // .data gets linked at 0x00400000 + vector > lines ; + size_t allocBytes; + for( ArmSymMap::iterator it = symbols.begin(); it != symbols.end() ; it++){ + TUint32 thisAddr = it->first ; + TUint32 romAddr ; + ArmSymbolInfo& info = it->second; + if (thisAddr >= textSectAddr && thisAddr <= (textSectAddr + aContext.iTextSize)) { + romAddr = thisAddr - textSectAddr + aContext.iCodeAddress ; + } + else if ( aContext.iDataAddress && + ( thisAddr >= dataSectAddr && thisAddr <= (dataSectAddr + aContext.iTextSize))) { + romAddr = thisAddr-dataSectAddr + aContext.iDataBssLinearBase; + } + else if ( aContext.iDataBssLinearBase && + ( thisAddr >= dataSectAddr && thisAddr <= (dataSectAddr+ aContext.iTotalDataSize))) { + romAddr = thisAddr - dataSectAddr + aContext.iDataBssLinearBase; + } + else { + guarded_lock lock(iFileMutex); + allocBytes = info.name.length() + 60; + char* msg = new char[allocBytes] ; + snprintf(msg,allocBytes,"\r\nWarning: Symbol %s @ 0x%08x not in text or data segments\r\n", \ + info.name.c_str() ,(unsigned int)thisAddr) ; + iErrMsgs.push_back(msg); + allocBytes = lenOfFileName + 80; + msg = new char[allocBytes]; + snprintf(msg,allocBytes,"Warning: The map file for binary %s is out-of-sync with the binary itself\r\n\r\n",aContext.iFileName); + iErrMsgs.push_back(msg); + continue ; + } + allocBytes = info.section.length() + info.name.length() + 140; + char* outputLine = new char[allocBytes]; + int len = snprintf(outputLine,allocBytes,"%08x %04x %-40s %s\r\n",(unsigned int)romAddr,info.size, + info.name.c_str(),info.section.c_str()); + if((size_t)len > allocBytes) { + allocBytes = len + 4 ; + delete []outputLine; + outputLine = new char[allocBytes]; + len = snprintf(outputLine,allocBytes,"%08x %04x %-40s %s\r\n",(unsigned int)romAddr,info.size, + info.name.c_str(),info.section.c_str()); + } + lines.push_back(pair(len,outputLine)); + + } + guarded_lock lock(iFileMutex); + allocBytes = lenOfFileName + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"\r\nFrom %s\r\n\r\n",aContext.iFileName); + iOutput.write(outputLine,n); + delete []outputLine ; + for (vector >::iterator i = lines.begin() ; i < lines.end(); i ++ ) { + int len = i->first ; + char* line = i->second; + iOutput.write(line,len); + delete []line ; + } + iOutput.flush(); + return true ; + +} +template +static void put_to_map(M& m,const K& k, const V& v) { + typedef typename M::iterator iterator; + iterator it = m.find(k); + if(m.end() == it){ + m.insert(pair(k,v)); + } + else { + it->second = v ; + } +} +bool SymbolGenerator::ProcessGCCMap(ifstream& aStream, const SymGenContext& aContext){ + char* lineStart; + vector words ; + char buffer[MAX_LINE_LENGTH]; + while(aStream.good() && (!aStream.eof())){ + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if( 0 == strncmp(lineStart,".text",5)) { + lineStart += 5; + break ; + } + } + split(lineStart,words); + TUint32 codeAddr , codeSize; + size_t allocBytes ; + if(words.size() != 2 || + KErrNone != Val(codeAddr,words.at(0)) || + KErrNone != Val(codeSize,words.at(1))) { + allocBytes = strlen(aContext.iFileName) + 60; + char* msg = new char[allocBytes]; + snprintf(msg,allocBytes,"\nError: Can't get .text section info for \"%s\"\r\n",aContext.iFileName); + guarded_lock lock(iFileMutex); + iErrMsgs.push_back(msg); + return false ; + } + map symbols ; + TUint32 stubHex = 0; + //Slurp symbols 'til the end of the text section + while(aStream.good() && (!aStream.eof())){ + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if(0 == *lineStart) break ; //blank line marks the end of the text section + + // .text + // .text$something + // + // LONG 0x0 + // (/^\s(\.text)?\s+(0x\w+)\s+(0x\w+)\s+(.*)$/io) + if(strncmp(lineStart,".text",5) == 0){ + lineStart += 5 ; + SKIP_WS(lineStart); + } + char* hex1 = NULL ; + char* hex2 = NULL ; + char* strAfterhex1 = NULL ; + TUint32 addr,size ; + if(strncmp(lineStart,"0x",2) == 0){ + hex1 = lineStart + 2; + char* temp ; + addr = strtoul(hex1,&temp,16); + SKIP_WS(temp); + strAfterhex1 = temp ; + if(strncmp(temp,"0x",2) == 0){ + hex2 = temp + 2 ; + } + } + if(NULL != hex2){ + char* libraryfile ; + size = strtoul(hex2,&libraryfile,16); + SKIP_WS(libraryfile); + TUint32 key = addr + size ; + put_to_map(symbols,key,string(""));//impossible symbol as end marker + make_lower(libraryfile); + // EUSER.LIB(ds01423.o) + // EUSER.LIB(C:/TEMP/d1000s_01423.o) + size_t len = strlen(libraryfile); + char* p1 = strstr(libraryfile,".lib("); + if(NULL == p1) + continue ; + p1 += 5; + if(strcmp(libraryfile + len - 3,".o)")!= 0) + continue ; + len -= 3 ; + libraryfile[len] = 0; + if(EFalse == IsValidNumber(libraryfile + len - 5)) + continue ; + len -= 7 ; + if('_' == libraryfile[len]) + len -- ; + if('s' != libraryfile[len]) + continue ; + char* p2 = libraryfile + len - 1; + while(p2 > p1 ) { + if(*p2 < '0' || *p2 > '9') + break ; + p2 -- ; + } + if(*p2 != 'd') + continue ; + stubHex = addr ; + } + else if(NULL != hex1 && NULL != strAfterhex1){ + //# + //(/^\s+(\w+)\s\s+([a-zA-Z_].+)/o) + char* symName = strAfterhex1; + if((*symName >= 'A' && *symName <= 'Z') || + (*symName >= 'a' && *symName <= 'z') || *symName == '_') { + string symbol(symName); + if(addr == stubHex) + symbol.insert(0,"stub "); + + put_to_map(symbols,addr,symbol); + + } + } + } + map::iterator it = symbols.begin(); + TUint32 lastAddr = it->first; + string lastSymName = it->second; + vector >lines ; + it ++ ; + while(it != symbols.end()) { + TUint32 addr = it->first ; + unsigned int fixedupAddr = lastAddr - codeAddr + aContext.iCodeAddress; + TUint size = addr - lastAddr ; + if(!lastSymName.empty()) { + allocBytes = lastSymName.length() + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"%08x %04x %s\r\n", fixedupAddr,size,lastSymName.c_str()); + lines.push_back(pair(n,outputLine)); + } + lastAddr = addr ; + lastSymName = it->second; + it ++ ; + } + + guarded_lock lock(iFileMutex); + allocBytes = strlen(aContext.iFileName) + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"\r\nFrom %s\r\n\r\n",aContext.iFileName); + iOutput.write(outputLine,n); + delete []outputLine ; + vector >::iterator i; + for ( i = lines.begin() ; i < lines.end(); i ++ ) { + int len = i->first ; + char* line = i->second ; + iOutput.write(line,len); + delete []line ; + } + iOutput.flush(); + return true ; +} +bool SymbolGenerator::ProcessX86Map(ifstream& aStream, const SymGenContext& aContext) { + char buffer[MAX_LINE_LENGTH]; + char* lineStart; + while(aStream.good() && (!aStream.eof())){ + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if( 0 == strncmp(lineStart,"Address",7)) { + break ; + } + } + aStream.getline(buffer,MAX_LINE_LENGTH); + string lastName ; + TUint32 lastAddr = 0; + size_t allocBytes ; + vector >lines ; + while(aStream.good() && (!aStream.eof())){ + aStream.getline(buffer,MAX_LINE_LENGTH); + lineStart = buffer ; + SKIP_WS(lineStart); + if(0 != strncmp(lineStart,"0001:",5)) + break ; + char* end ; + TUint32 addr = strtoul(lineStart + 5,&end,16); + char* name = end + 1; + SKIP_WS(name); + end = name + 1; + FIND_WS(end); + *end = 0 ; + if(!lastName.empty()){ + unsigned int size = addr - lastAddr ; + unsigned int romAddr = lastAddr + aContext.iCodeAddress; + allocBytes = lastName.length() + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"%08x %04x %s\r\n",romAddr,size,lastName.c_str()); + lines.push_back(pair(n,outputLine)); + } + } + guarded_lock lock(iFileMutex); + allocBytes = strlen(aContext.iFileName) + 40; + char* outputLine = new char[allocBytes]; + int n = snprintf(outputLine,allocBytes,"\r\nFrom %s\r\n\r\n",aContext.iFileName); + iOutput.write(outputLine,n); + delete []outputLine ; + vector >::iterator it; + for ( it = lines.begin() ; it < lines.end(); it ++ ) { + int len = it->first ; + char* line = it->second ; + iOutput.write(line,len); + delete []line ; + } + if(!lastName.empty()){ + allocBytes = lastName.length() + 40 ; + outputLine = new char[allocBytes]; + unsigned int romAddr = lastAddr + aContext.iCodeAddress; + n = snprintf(outputLine,allocBytes,"%08x 0000 %s\r\n",romAddr,lastName.c_str()); + iOutput.write(outputLine,n); + delete []outputLine ; + } + iOutput.flush(); + return false ; +} diff -r 22486c9c7b15 -r 378360dbbdba imgtools/romtools/rombuild/symbolgenerator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/imgtools/romtools/rombuild/symbolgenerator.h Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,51 @@ +#ifndef __SYMBOLSCREATER_H__ +#define __SYMBOLSCREATER_H__ +#include +#include +#include +#include +#include + +using namespace std; + +#include +#include + +struct SymGenContext { + const char* iFileName ; + TUint32 iTotalSize ; + TUint32 iCodeAddress; + TUint32 iDataAddress; + TUint32 iDataBssLinearBase; + TInt iTextSize; + TInt iDataSize; + TInt iBssSize; + TInt iTotalDataSize; + TBool iExecutable ; +}; + +class SymbolGenerator { +public : + SymbolGenerator(const char* aSymbolFileName, int aMultiThreadsCount = 1); + ~SymbolGenerator(); + void AddEntry(const SymGenContext& aEntry); + void WaitThreads(); +private : + SymbolGenerator(); + SymbolGenerator& operator = (const SymbolGenerator& aRight); + static void ThreadFunc(SymbolGenerator* aInst); + bool ProcessEntry(const SymGenContext& aContext); + bool ProcessARMV5Map(ifstream& aStream, const SymGenContext& aContext); + bool ProcessGCCMap(ifstream& aStream, const SymGenContext& aContext); + bool ProcessX86Map(ifstream& aStream, const SymGenContext& aContext); + ofstream iOutput ; + boost::thread_group iThreads ; + boost::condition_variable iCond; + boost::mutex iQueueMutex; + boost::mutex iFileMutex ; + queue iEntries ; + vector iErrMsgs ; + +}; + +#endif //__ROMSYMBOLGENERATOR_H__ diff -r 22486c9c7b15 -r 378360dbbdba javatoolsplat/j2re-1.3.1/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatoolsplat/j2re-1.3.1/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,22 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS + +PRJ_EXPORTS + +../j2re-1_3_1_01-win-i.exe /epoc32/tools/distrib/j2re-1_3_1_01-win-i.exe + +PRJ_MMPFILES diff -r 22486c9c7b15 -r 378360dbbdba javatoolsplat/j2re-1.3.1/group/j2re-1.3.1.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatoolsplat/j2re-1.3.1/group/j2re-1.3.1.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,23 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +component dev_build_javatoolsplat_j2re-1.3.1 + +source \src\tools\build\javatoolsplat\j2re-1.3.1 +exports \src\tools\build\javatoolsplat\j2re-1.3.1\group + +notes_source \src\tools\build\javatoolsplat\j2re-1.3.1\group\release.txt + +ipr T \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba javatoolsplat/j2re-1.3.1/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatoolsplat/j2re-1.3.1/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,5 @@ +NOTESRC_RELEASER +Symbian Software Ltd. + +NOTESRC_RELEASE_REASON +j2re 1.3.1. diff -r 22486c9c7b15 -r 378360dbbdba javatoolsplat/j2re-1.3.1/j2re-1_3_1_01-win-i.exe Binary file javatoolsplat/j2re-1.3.1/j2re-1_3_1_01-win-i.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba javatoolsplat/j2re-1.3.1/java.ipr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatoolsplat/j2re-1.3.1/java.ipr Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,248 @@ +[purpose] + +Java run time envonment + +[categories] +generic + +[files] +tools\distrib\j2re-1_3_1_01-win-i.exe + +[owner] +Developer Kits + +[IPR] +Sun Microsystems, Inc. + +Binary Code License Agreement + + + + +READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSE TERMS +(COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE OPENING THE SOFTWARE MEDIA +PACKAGE. BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE TERMS OF THIS +AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY, INDICATE YOUR +ACCEPTANCE OF THESE TERMS BY SELECTING THE "ACCEPT" BUTTON AT THE END OF THIS +AGREEMENT. IF YOU DO NOT AGREE TO ALL OF THESE TERMS, PROMPTLY RETURN THE +UNUSED SOFTWARE TO YOUR PLACE OF PURCHASE FOR A REFUND OR, IF THE SOFTWARE IS +ACCESSED ELECTRONICALLY, SELECT THE "DECLINE" BUTTON AT THE END OF THIS +AGREEMENT AND THE INSTALLATION PROCESS WILL NOT CONTINUE. + + + + +1. License to Use. Sun Microsystems, Inc. ("Sun") grants you a non-exclusive +and non-transferable license for the internal use only of the accompanying +software, documentation and any error corrections provided by Sun +(collectively "Software"), by the number of users and the class of computer +hardware for which the corresponding fee has been paid. + + + + +2. Restrictions. Software is confidential and copyrighted. Title to Software +and all associated intellectual property rights is retained by Sun and/or its +licensors. Except as specifically authorized in any Supplemental License +Terms, you may not make copies of Software, other than a single copy of +Software for archival purposes. Unless enforcement is prohibited by applicable +law, you may not modify, decompile, or reverse engineer Software. You +acknowledge that Software is not designed, licensed or intended for use in the +design, construction, operation or maintenance of any nuclear facility. Sun +disclaims any express or implied warranty of fitness for such uses. No right, +title or interest in or to any trademark, service mark, logo or trade name of +Sun or its licensors is granted under this Agreement. + + + + +3. Limited Warranty. Sun warrants to you that for a period of ninety (90) days +from the date of purchase, as evidenced by a copy of the receipt, the media on +which Software is furnished (if any) will be free of defects in materials and +workmanship under normal use. Except for the foregoing, Software is provided +"AS IS". Your exclusive remedy and Sun's entire liability under this limited +warranty will be at Sun's option to replace Software media or refund the fee +paid for Software. + + + + +4. DISCLAIMER OF WARRANTY. UNLESS SPECIFIED IN THIS AGREEMENT, ALL EXPRESS OR +IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED +WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +NON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS +ARE HELD TO BE LEGALLY INVALID. + + + + +5. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT +WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR +FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER +CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO THE +USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. In no event will Sun's liability to you, whether +in contract, tort (including negligence), or otherwise, exceed the amount paid +by you for Software under this Agreement. The foregoing limitations will apply +even if the above stated warranty fails of its essential purpose. + + + + +6. Termination. This Agreement is effective until terminated. You may +terminate this Agreement at any time by destroying all copies of Software. +This Agreement will terminate immediately without notice from Sun if you fail +to comply with any provision of this Agreement. Upon Termination, you must +destroy all copies of Software. + + + + +7. Export Regulations. All Software and any technical data delivered under +this Agreement are subject to US export control laws and may be subject to +export or import regulations in other countries. You agree to comply strictly +with all such laws and regulations and acknowledge that you have the +responsibility to obtain such licenses to export, re-export, or import as may +be required after delivery to you. + + + + +8. U.S. Government Restricted Rights. If Software is being acquired by or on +behalf of the U.S. Government or by a U.S. Government prime contractor or +subcontractor (at any tier), then the Government's rights in Software and +accompanying documentation will be only as set forth in this Agreement; this +is in accordance with 48 C.F.R. 227.7202-4 (for Department of Defense (DOD) +acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DOD acquisitions). + + + + +9. Governing Law. Any action related to this Agreement will be governed by +California law and controlling U.S. federal law. No choice of law rules of any +jurisdiction will apply. + + + + +10. Severability. If any provision of this Agreement is held to be +unenforceable, this Agreement will remain in effect with the provision +omitted, unless omission would frustrate the intent of the parties, in which +case this Agreement will immediately terminate. + + + + +11. Integration. This Agreement is the entire agreement between you and Sun +relating to its subject matter. It supersedes all prior or contemporaneous +oral or written communications, proposals, representations and warranties and +prevails over any conflicting or additional terms of any quote, order, +acknowledgment, or other communication between the parties relating to its +subject matter during the term of this Agreement. No modification of this +Agreement will be binding, unless in writing and signed by an authorized +representative of each party. + + + + +For inquiries please contact: Sun Microsystems, Inc. 901 San Antonio Road, +Palo Alto, California 94303 + + + + +JAVA 2 RUNTIME ENVIRONMENT (J2RE), VERSION 1.3.x + +SUPPLEMENTAL LICENSE TERMS + + + + +These supplemental license terms ("Supplemental Terms") add to or modify the +terms of the Binary Code License Agreement (collectively, the "Agreement"). +Capitalized terms not defined in these Supplemental Terms shall have the same +meanings ascribed to them in the Agreement. These Supplemental Terms shall +supersede any inconsistent or conflicting terms in the Agreement, or in any +license contained within the Software. + +1. Software Internal Use and Development License Grant. Subject to the terms +and conditions of this Agreement, including, but not limited to Section 4 +(Java(TM) Technology Restrictions) of these Supplemental Terms, Sun grants you +a non-exclusive, non-transferable, limited license to reproduce internally and +use internally the binary form of the Software complete and unmodified for the +sole purpose of designing, developing and testing your Java applets and +applications intended to run on the Java platform ("Programs"). + +2. License to Distribute Software. Subject to the terms and conditions of this +Agreement, including, but not limited to Section 4 (Java (TM) Technology +Restrictions) of these Supplemental Terms, Sun grants you a non-exclusive, +non-transferable, limited license to reproduce and distribute the Software in +binary code form only, provided that (i) you distribute the Software complete +and unmodified and only bundled as part of, and for the sole purpose of +running, your Programs, (ii) the Programs add significant and primary +functionality to the Software, (iii) you do not distribute additional software +intended to replace any component(s) of the Software, (iv) you do not remove +or alter any proprietary legends or notices contained in the Software, (v) you +only distribute the Software subject to a license agreement that protects +Sun's interests consistent with the terms contained in this Agreement, and +(vi) you agree to defend and indemnify Sun and its licensors from and against +any damages, costs, liabilities, settlement amounts and/or expenses (including +attorneys' fees) incurred in connection with any claim, lawsuit or action by +any third party that arises or results from the use or distribution of any and +all Programs and/or Software. + +3. License to Distribute Redistributables. Subject to the terms and conditions +of this Agreement, including but not limited to Section 4 (Java Technology +Restrictions) of these Supplemental Terms, Sun grants you a non-exclusive, +non-transferable, limited license to reproduce and distribute the binary form +of those files specifically identified as redistributable in the Software +"README" file ("Redistributables") provided that: (i) you distribute the +Redistributables complete and unmodified (unless otherwise specified in the +applicable README file), and only bundled as part of Programs, (ii) you do not +distribute additional software intended to supersede any component(s) of the +Redistributables, (iii) you do not remove or alter any proprietary legends or +notices contained in or on the Redistributables, (iv) you only distribute the +Redistributables pursuant to a license agreement that protects Sun's interests +consistent with the terms contained in the Agreement, and (v) you agree to +defend and indemnify Sun and its licensors from and against any damages, +costs, liabilities, settlement amounts and/or expenses (including attorneys' +fees) incurred in connection with any claim, lawsuit or action by any third +party that arises or results from the use or distribution of any and all +Programs and/or Software. + +4. Java Technology Restrictions. You may not modify the Java Platform +Interface ("JPI", identified as classes contained within the "java" package or +any subpackages of the "java" package), by creating additional classes within +the JPI or otherwise causing the addition to or modification of the classes in +the JPI. In the event that you create an additional class and associated +API(s) which (i) extends the functionality of the Java platform, and (ii) is +exposed to third party software developers for the purpose of developing +additional software which invokes such additional API, you must promptly +publish broadly an accurate specification for such API for free use by all +developers. You may not create, or authorize your licensees to create, +additional classes, interfaces, or subpackages that are in any way identified +as "java", "javax", "sun" or similar convention as specified by Sun in any +naming convention designation. + +5. Trademarks and Logos. You acknowledge and agree as between you and Sun that +Sun owns the SUN, SOLARIS, JAVA, JINI, FORTE, and iPLANET trademarks and all +SUN, SOLARIS, JAVA, JINI, FORTE, and iPLANET-related trademarks, service +marks, logos and other brand designations ("Sun Marks"), and you agree to +comply with the Sun Trademark and Logo Usage Requirements currently located at +http://www.sun.com/policies/trademarks. Any use you make of the Sun Marks +inures to Sun's benefit. + +6. Source Code. Software may contain source code that is provided solely for +reference purposes pursuant to the terms of this Agreement. Source code may +not be redistributed unless expressly provided for in this Agreement. + +7. +Termination for Infringement. Either party may terminate this Agreement +immediately should any Software become, or in either party's opinion be likely +to become, the subject of a claim of infringement of any intellectual property +right. + +For inquiries please contact: Sun Microsystems, Inc. 901 San Antonio Road, +Palo Alto, California 94303 +(LFI#90956/Form ID#011801) + diff -r 22486c9c7b15 -r 378360dbbdba perltoolsplat/activestate-perl-5.6.1/APi518e.exe Binary file perltoolsplat/activestate-perl-5.6.1/APi518e.exe has changed diff -r 22486c9c7b15 -r 378360dbbdba perltoolsplat/activestate-perl-5.6.1/ActivePerl-5.6.1.635-MSWin32-x86.msi Binary file perltoolsplat/activestate-perl-5.6.1/ActivePerl-5.6.1.635-MSWin32-x86.msi has changed diff -r 22486c9c7b15 -r 378360dbbdba perltoolsplat/activestate-perl-5.6.1/group/activestate-perl-5.6.1.mrp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perltoolsplat/activestate-perl-5.6.1/group/activestate-perl-5.6.1.mrp Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,23 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +component dev_build_perltoolsplat_activestate-perl-5.6.1 + +source \src\tools\build\perltoolsplat\activestate-perl-5.6.1 +exports \src\tools\build\perltoolsplat\activestate-perl-5.6.1\group + +notes_source \src\tools\build\perltoolsplat\activestate-perl-5.6.1\group\release.txt + +ipr T \ No newline at end of file diff -r 22486c9c7b15 -r 378360dbbdba perltoolsplat/activestate-perl-5.6.1/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perltoolsplat/activestate-perl-5.6.1/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,23 @@ +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_PLATFORMS + +PRJ_EXPORTS + +../APi518e.exe /epoc32/tools/distrib/api518e.exe +../ActivePerl-5.6.1.635-MSWin32-x86.msi /epoc32/tools/distrib/activeperl-5.6.1.635-mswin32-x86.msi + +PRJ_MMPFILES diff -r 22486c9c7b15 -r 378360dbbdba perltoolsplat/activestate-perl-5.6.1/group/release.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perltoolsplat/activestate-perl-5.6.1/group/release.txt Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,5 @@ +NOTESRC_RELEASER +Symbian Software Ltd. + +NOTESRC_RELEASE_REASON +activestate perl tools. diff -r 22486c9c7b15 -r 378360dbbdba perltoolsplat/activestate-perl-5.6.1/perl.ipr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perltoolsplat/activestate-perl-5.6.1/perl.ipr Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,15 @@ +[purpose] + +ActivePerl + +[categories] +generic + +[files] +tools\distrib\APi518e.exe # full distribution of ActivePerl 518 + +[owner] +Runtime & Tools + +[IPR] +Copyright (c) 1999 ActiveState Tool Corp. All rights reserved. diff -r 22486c9c7b15 -r 378360dbbdba releasing/cbrtools/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/releasing/cbrtools/group/bld.inf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,216 @@ +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +// + +PRJ_PLATFORMS + +PRJ_EXPORTS + +../perl/archive_path.txt.ex /tools/cbr/archive_path.txt.ex +../perl/BinInfo /tools/cbr/BinInfo +../perl/BinInfo.bat /tools/cbr/BinInfo.bat +../perl/BldDocs /tools/cbr/BldDocs +../perl/BldDocs.bat /tools/cbr/BldDocs.bat +../perl/BuildRel /tools/cbr/BuildRel +../perl/BuildRel.bat /tools/cbr/BuildRel.bat +../perl/CatData.pm /tools/cbr/CatData.pm +../perl/CheckBc /tools/cbr/CheckBc +../perl/CheckBc.bat /tools/cbr/CheckBc.bat +../perl/CheckBc.pm /tools/cbr/CheckBc.pm +../perl/CheckRls /tools/cbr/CheckRls +../perl/CheckRls.bat /tools/cbr/CheckRls.bat +../perl/CleanEnv /tools/cbr/CleanEnv +../perl/CleanEnv.bat /tools/cbr/CleanEnv.bat +../perl/CleanEnv.pm /tools/cbr/CleanEnv.pm +../perl/CleanEnv.pod /tools/cbr/CleanEnv.pod +../perl/Cleaner.pm /tools/cbr/Cleaner.pm +../perl/CleanLocalArch /tools/cbr/CleanLocalArch +../perl/CleanLocalArch.bat /tools/cbr/CleanLocalArch.bat +../perl/cleanremote /tools/cbr/cleanremote +../perl/cleanremote.bat /tools/cbr/cleanremote.bat +../perl/CommandController.pm /tools/cbr/CommandController.pm +../perl/CopyRel /tools/cbr/CopyRel +../perl/CopyRel.bat /tools/cbr/CopyRel.bat +../perl/CopyRel.pm /tools/cbr/CopyRel.pm +../perl/Crypt.pm /tools/cbr/Crypt.pm +../perl/DeltaEnv /tools/cbr/DeltaEnv +../perl/DeltaEnv.bat /tools/cbr/DeltaEnv.bat +../perl/DiffEnv /tools/cbr/DiffEnv +../perl/DiffEnv.bat /tools/cbr/DiffEnv.bat +../perl/DiffRel /tools/cbr/DiffRel +../perl/DiffRel.bat /tools/cbr/DiffRel.bat +../perl/EnvData /tools/cbr/EnvData +../perl/EnvData.bat /tools/cbr/EnvData.bat +../perl/EnvDb.pm /tools/cbr/EnvDb.pm +../perl/EnvDifferencer.pm /tools/cbr/EnvDifferencer.pm +../perl/EnvInfo /tools/cbr/EnvInfo +../perl/EnvInfo.bat /tools/cbr/EnvInfo.bat +../perl/EnvInfoTk /tools/cbr/EnvInfoTk +../perl/EnvInfoTk.bat /tools/cbr/EnvInfoTk.bat +../perl/Environment /tools/cbr/Environment +../perl/envmembership /tools/cbr/envmembership +../perl/envmembership.bat /tools/cbr/envmembership.bat +../perl/envsize /tools/cbr/envsize +../perl/envsize.bat /tools/cbr/envsize.bat +../perl/ExportData.pm /tools/cbr/ExportData.pm +../perl/ExportEnv /tools/cbr/ExportEnv +../perl/ExportEnv.bat /tools/cbr/ExportEnv.bat +../perl/ExportingReleases /tools/cbr/ExportingReleases +../perl/ExportRel /tools/cbr/ExportRel +../perl/ExportRel.bat /tools/cbr/ExportRel.bat +../perl/FAQ /tools/cbr/FAQ +../perl/FundamentalConcepts /tools/cbr/FundamentalConcepts +../perl/FurtherInformation /tools/cbr/FurtherInformation +../perl/GetEnv /tools/cbr/GetEnv +../perl/GetEnv.bat /tools/cbr/GetEnv.bat +../perl/GetEnv.pm /tools/cbr/GetEnv.pm +../perl/getrel /tools/cbr/getrel +../perl/getrel.bat /tools/cbr/getrel.bat +../perl/GetSource /tools/cbr/GetSource +../perl/GetSource.bat /tools/cbr/GetSource.bat +../perl/HistoricPerspective /tools/cbr/HistoricPerspective +../perl/ImportEnv /tools/cbr/ImportEnv +../perl/ImportEnv.bat /tools/cbr/ImportEnv.bat +../perl/ImportRel /tools/cbr/ImportRel +../perl/ImportRel.bat /tools/cbr/ImportRel.bat +../perl/IniData.pm /tools/cbr/IniData.pm +../perl/Installation /tools/cbr/Installation +../perl/InstallSnapShot /tools/cbr/InstallSnapShot +../perl/InstallSnapShot.bat /tools/cbr/InstallSnapShot.bat +../perl/InstCol2 /tools/cbr/InstCol2 +../perl/InstCol2.bat /tools/cbr/InstCol2.bat +../perl/LatestVer /tools/cbr/LatestVer +../perl/LatestVer.bat /tools/cbr/LatestVer.bat +../perl/listcomponents /tools/cbr/listcomponents +../perl/listcomponents.bat /tools/cbr/listcomponents.bat +../perl/MakeEnv /tools/cbr/MakeEnv +../perl/MakeEnv.bat /tools/cbr/MakeEnv.bat +../perl/MakeRel /tools/cbr/MakeRel +../perl/MakeRel.bat /tools/cbr/MakeRel.bat +../perl/MakeRel.pm /tools/cbr/MakeRel.pm +../perl/MakeSnapShot /tools/cbr/MakeSnapShot +../perl/MakeSnapShot.bat /tools/cbr/MakeSnapShot.bat +../perl/MakingReleases /tools/cbr/MakingReleases +../perl/ManagingEnvironments /tools/cbr/ManagingEnvironments +../perl/mbld /tools/cbr/mbld +../perl/mbld.bat /tools/cbr/mbld.bat +../perl/MergeEnvironments /tools/cbr/MergeEnvironments +../perl/MergeEnvironments.bat /tools/cbr/MergeEnvironments.bat +../perl/MLDBM.pm /tools/cbr/MLDBM.pm +../perl/ModNotes /tools/cbr/ModNotes +../perl/ModNotes.bat /tools/cbr/ModNotes.bat +../perl/MrpComplexity /tools/cbr/MrpComplexity +../perl/MrpComplexity.bat /tools/cbr/MrpComplexity.bat +../perl/MrpData.pm /tools/cbr/MrpData.pm +../perl/NotesCompiler.pm /tools/cbr/NotesCompiler.pm +../perl/Optimisation /tools/cbr/Optimisation +../perl/PathData.pm /tools/cbr/PathData.pm +../perl/PrepEnv /tools/cbr/PrepEnv +../perl/PrepEnv.bat /tools/cbr/PrepEnv.bat +../perl/PrepRel /tools/cbr/PrepRel +../perl/PrepRel.bat /tools/cbr/PrepRel.bat +../perl/PrepRel.pm /tools/cbr/PrepRel.pm +../perl/PullEnv /tools/cbr/PullEnv +../perl/PullEnv.bat /tools/cbr/PullEnv.bat +../perl/pullrel /tools/cbr/pullrel +../perl/pullrel.bat /tools/cbr/pullrel.bat +../perl/PushEnv /tools/cbr/PushEnv +../perl/PushEnv.bat /tools/cbr/PushEnv.bat +../perl/PushPullRel.pm /tools/cbr/PushPullRel.pm +../perl/pushrel /tools/cbr/pushrel +../perl/pushrel.bat /tools/cbr/pushrel.bat +../perl/QuickStart /tools/cbr/QuickStart +../perl/RelData.pm /tools/cbr/RelData.pm +../perl/relnotes.txt /tools/cbr/relnotes.txt +../perl/reltools.ini.ex /tools/cbr/reltools.ini.ex +../perl/RelTransfer.pm /tools/cbr/RelTransfer.pm +../perl/RemoteSite.pm /tools/cbr/RemoteSite.pm +../perl/RemoveRel /tools/cbr/RemoveRel +../perl/RemoveRel.bat /tools/cbr/RemoveRel.bat +../perl/removesource /tools/cbr/removesource +../perl/removesource.bat /tools/cbr/removesource.bat +../perl/SourceInfo /tools/cbr/SourceInfo +../perl/SourceInfo.bat /tools/cbr/SourceInfo.bat +../perl/TableFormatter.pm /tools/cbr/TableFormatter.pm +../perl/Utils.pm /tools/cbr/Utils.pm +../perl/ValidateEnv /tools/cbr/ValidateEnv +../perl/ValidateEnv.bat /tools/cbr/ValidateEnv.bat +../perl/ValidateRel /tools/cbr/ValidateRel +../perl/ValidateRel.bat /tools/cbr/ValidateRel.bat +../perl/version.txt /tools/cbr/version.txt +../perl/ViewNotes /tools/cbr/ViewNotes +../perl/ViewNotes.bat /tools/cbr/ViewNotes.bat +../perl/Archive/Tar.pm /tools/cbr/Archive/Tar.pm +../perl/Archive/Zip.pm /tools/cbr/Archive/Zip.pm +../perl/Archive/Zip/BufferedFileHandle.pm /tools/cbr/Archive/Zip/BufferedFileHandle.pm +../perl/Archive/Zip/MockFileHandle.pm /tools/cbr/Archive/Zip/MockFileHandle.pm +../perl/Archive/Zip/Tree.pm /tools/cbr/Archive/Zip/Tree.pm +../perl/Class/Singleton.pm /tools/cbr/Class/Singleton.pm +../perl/Crypt/GPG.pm /tools/cbr/Crypt/GPG.pm +../perl/Crypt/PGP.pm /tools/cbr/Crypt/PGP.pm +../perl/Digest/Perl/MD5.pm /tools/cbr/Digest/Perl/MD5.pm +../perl/Digest/Perl/readme.txt /tools/cbr/Digest/Perl/readme.txt +../perl/MLDBM/Sync.pm /tools/cbr/MLDBM/Sync.pm +../perl/MLDBM/Sync/SDBM_File.pm /tools/cbr/MLDBM/Sync/SDBM_File.pm +../perl/MLDBM/Serializer/FreezeThaw.pm /tools/cbr/MLDBM/Serializer/FreezeThaw.pm +../perl/MLDBM/Serializer/Storable.pm /tools/cbr/MLDBM/Serializer/Storable.pm +../perl/MLDBM/Serializer/Data/Dumper.pm /tools/cbr/MLDBM/Serializer/Data/Dumper.pm +../perl/Net/Cmd.pm /tools/cbr/Net/Cmd.pm +../perl/Net/Config.pm /tools/cbr/Net/Config.pm +../perl/Net/Domain.pm /tools/cbr/Net/Domain.pm +../perl/Net/DummyInetd.pm /tools/cbr/Net/DummyInetd.pm +../perl/Net/FTP.pm /tools/cbr/Net/FTP.pm +../perl/Net/libnetFAQ.pod /tools/cbr/Net/libnetFAQ.pod +../perl/Net/Netrc.pm /tools/cbr/Net/Netrc.pm +../perl/Net/NNTP.pm /tools/cbr/Net/NNTP.pm +../perl/Net/PH.pm /tools/cbr/Net/PH.pm +../perl/Net/POP3.pm /tools/cbr/Net/POP3.pm +../perl/Net/SMTP.pm /tools/cbr/Net/SMTP.pm +../perl/Net/SNPP.pm /tools/cbr/Net/SNPP.pm +../perl/Net/Time.pm /tools/cbr/Net/Time.pm +../perl/Net/FTP/A.pm /tools/cbr/Net/FTP/A.pm +../perl/Net/FTP/dataconn.pm /tools/cbr/Net/FTP/dataconn.pm +../perl/Net/FTP/E.pm /tools/cbr/Net/FTP/E.pm +../perl/Net/FTP/I.pm /tools/cbr/Net/FTP/I.pm +../perl/Net/FTP/L.pm /tools/cbr/Net/FTP/L.pm +../perl/PathData/ComponentBased.pm /tools/cbr/PathData/ComponentBased.pm +../perl/PathData/ProjectBased.pm /tools/cbr/PathData/ProjectBased.pm +../perl/RelTransfer/Export.pm /tools/cbr/RelTransfer/Export.pm +../perl/RelTransfer/Import.pm /tools/cbr/RelTransfer/Import.pm +../perl/RemoteSite/FTP.pm /tools/cbr/RemoteSite/FTP.pm +../perl/RemoteSite/NetDrive.pm /tools/cbr/RemoteSite/NetDrive.pm +../perl/RemoteSite/FTP/Experimental.pm /tools/cbr/RemoteSite/FTP/Experimental.pm +../perl/RemoteSite/FTP/Proxy.pm /tools/cbr/RemoteSite/FTP/Proxy.pm +../perl/RemoteSite/FTP/Proxy/Experimental.pm /tools/cbr/RemoteSite/FTP/Proxy/Experimental.pm +../perl/RemoteSite/NetDrive/MultiVolumeExport.pm /tools/cbr/RemoteSite/NetDrive/MultiVolumeExport.pm +../perl/RemoteSite/NetDrive/MultiVolumeImport.pm /tools/cbr/RemoteSite/NetDrive/MultiVolumeImport.pm +../perl/Symbian/DistributionPolicy.pm /tools/cbr/Symbian/DistributionPolicy.pm +../perl/Symbian/IPR.pm /tools/cbr/Symbian/IPR.pm +../perl/Symbian/CBR/ApplyDelta.pm /tools/cbr/Symbian/CBR/ApplyDelta.pm +../perl/Symbian/CBR/CreateDelta.pm /tools/cbr/Symbian/CBR/CreateDelta.pm +../perl/Symbian/CBR/MRP.pm /tools/cbr/Symbian/CBR/MRP.pm +../perl/Symbian/CBR/MRPInterface.pm /tools/cbr/Symbian/CBR/MRPInterface.pm +../perl/Symbian/CBR/Component/Manifest.pm /tools/cbr/Symbian/CBR/Component/Manifest.pm +../perl/Symbian/CBR/DeltaRelease/Manifest.pm /tools/cbr/Symbian/CBR/DeltaRelease/Manifest.pm +../perl/Symbian/CBR/IPR/MRP.pm /tools/cbr/Symbian/CBR/IPR/MRP.pm +../perl/Symbian/CBR/MRP/Reader.pm /tools/cbr/Symbian/CBR/MRP/Reader.pm +../perl/Symbian/CBR/release/Manifest.pm /tools/cbr/Symbian/CBR/release/Manifest.pm +../perl/Symbian/DistributionPolicy/Reader.pm /tools/cbr/Symbian/DistributionPolicy/Reader.pm +../perl/TableFormatter/Auto.pm /tools/cbr/TableFormatter/Auto.pm +../perl/TableFormatter/Csv.pm /tools/cbr/TableFormatter/Csv.pm +../perl/TableFormatter/Excel.pm /tools/cbr/TableFormatter/Excel.pm +../perl/TableFormatter/Html.pm /tools/cbr/TableFormatter/Html.pm +../perl/TableFormatter/Text.pm /tools/cbr/TableFormatter/Text.pm +../perl/Text/Glob.pm /tools/cbr/Text/Glob.pm diff -r 22486c9c7b15 -r 378360dbbdba releasing/cbrtools/group/build.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/releasing/cbrtools/group/build.mk Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,74 @@ +# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +# Description: +# Extension Makefile for creating the CBR tools installable package +# + +# Constants +TOOLS_DIR = $(EPOCROOT)tools +WORK_DIR = $(EPOCROOT)temp\cbr +SRC_DIR = ..\perl +CUR_DIR = $(shell chdir) +include version.mk + +# Targets + +do_nothing: + rem do_nothing + +MAKMAKE : do_nothing + +RESOURCE : do_nothing + +FREEZE : do_nothing + +SAVESPACE : BLD + +LIB: do_nothing + +RELEASABLES : +ifeq ("$(PLATFORM) $(CFG)", "TOOLS REL") + @echo $(TOOLS_DIR)\cbr\cbrtools$(VERSION).zip +endif + + +# remove jar file and class files +CLEAN : +ifeq ("$(PLATFORM) $(CFG)", "TOOLS REL") + -del $(TOOLS_DIR)\cbr\cbrtools$(VERSION).zip + -rmdir /s/q $(WORK_DIR) +endif + +# Called with +# +# $(PLATFORM) = TOOLS +# $(CFG) = DEB, REL + +# Note: DISTRIBUTION.POLICY files are only shipped with the example + +BLD : + @echo BLD called with $(PLATFORM) $(CFG) +ifeq ("$(PLATFORM) $(CFG)", "TOOLS REL") + -rmdir /S/Q $(WORK_DIR) + -mkdir $(TOOLS_DIR)\cbr + -del $(TOOLS_DIR)\cbr\cbrtools$(VERSION).zip + -mkdir $(WORK_DIR) + xcopy /EI $(SRC_DIR) $(WORK_DIR) + cd $(WORK_DIR); zip -9r $(TOOLS_DIR)\cbr\cbrtools$(VERSION).zip * + -rmdir /S/Q $(WORK_DIR) +endif + +FINAL : do_nothing diff -r 22486c9c7b15 -r 378360dbbdba releasing/cbrtools/group/cbr.preconfigure.nsh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/releasing/cbrtools/group/cbr.preconfigure.nsh Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,288 @@ +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +########################################################################################### +# CBR Tools handling +# +!define RELTOOLSKEY "SOFTWARE\Symbian\Release Tools" +!define CBRTOOLSKEY "SOFTWARE\Symbian\Symbian CBR Tools" +!define PRODUCT_UNINST_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" + +VAR CBRUNINSTALL + +!macro CBRToolsNSISManualUninstall inVersion inPath + SetShellVarContext current + RMDir /r "$SMPROGRAMS\Symbian CBR Tools\${inVersion}" + RMDir "$SMPROGRAMS\Symbian CBR Tools" ; delete if empty + RMDir /r "${inPath}" + DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}\Symbian CBR Tools ${inVersion}" + DeleteRegKey HKLM "${CBRTOOLSKEY}\${inVersion}" + DeleteRegKey /ifempty HKLM "${CBRTOOLSKEY}" + Push "${inPath}" + !insertmacro PathTypeRmvFromEnvVar "path" "${inPath}" "" + !insertmacro SetShellVarCtxt +!macroend + + +!macro CBRToolsISManualUninstall inVersion inPath inUninstallKey + RMDir /r "$SMPROGRAMS\Symbian OS Release Tools\" + RMDir /r "${inPath}" + ${If} "${inUninstallKey}" != "" + DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}\${inUninstallKey}" + ${EndIf} + DeleteRegKey HKLM "${RELTOOLSKEY}\${inVersion}" + DeleteRegKey /ifempty HKLM "${RELTOOLSKEY}" + DeleteRegKey /ifempty HKLM "SOFTWARE\Symbian" + Push "${inPath}" + !insertmacro PathTypeRmvFromEnvVar "path" "${inPath}" "" +!macroend + + +Function CBRToolsPreConfigureFunction +exch $0 +push $1 # counter +push $2 # version +push $3 # uninstall string +push $4 +push $5 + +push $6 + +push $R0 # $ReplaceVer +push $R1 # $ReplaceKey + +push $R2 # nsis installations found +push $R3 # install shield installations found + StrCpy $CBRUNINSTALL "no" +StrCpy $5 1 +SectionGetFlags $0 $R0 +IntOp $R0 $R0 & ${SF_SELECTED} +${If} $R0 == ${SF_SELECTED} + + StrCpy $R0 "Following CBR Tools version(s) are already installed: " + StrCpy $R1 "" + StrCpy $R2 "" + StrCpy $R3 "" + StrCpy $6 "" + StrCpy $1 0 + loop: #check if there is install shield installation + EnumRegKey $2 HKLM "${RELTOOLSKEY}" $1 + StrCmp $2 "" checkNsis + IntOp $1 $1 + 1 + readregstr $3 HKLM "${RELTOOLSKEY}\$2" "Path" + StrCpy $R3 "1" + StrCpy $R0 "$R0$\r$\nVersion $2 is already installed in $3." + GoTo loop + + checkNsis: # check if there is NSIS installation + StrCpy $4 $1 + StrCpy $1 0 + loop1: + EnumRegKey $2 HKLM "${CBRTOOLSKEY}" $1 + StrCmp $2 "" done + IntOp $1 $1 + 1 + readregstr $3 HKLM "${CBRTOOLSKEY}\$2" "Path" + StrCpy $R2 "$R2-$2-" + StrCpy $R0 "$R0$\r$\nVersion $2 is already installed in $3." + GoTo loop1 + + done: + IntOp $1 $1 + $4 + ${If} $1 > 0 + + ${If} $SILENT == "true" + ${AndIf} $DIALOGS == "false" + !insertmacro LogStopMessage "CBRTools (Release Tools) already installed. Stopping installation.\ + $\r$\nPlease uninstall CBRTools (Rlease Tools) before continuing " "${OTHER_ERROR}" + ${Else} + MessageBox MB_YESNOCANCEL "$R0$\r$\n\ + Do you want to uninstall previous installation(s) before continuing?" IDYES continue IDNO finish + ${EndIf} + + cancel: + StrCpy $5 0 + GoTo finish + + + continue: + StrCpy $CBRUNINSTALL "yes" + + ${EndIf} + finish: +${EndIf} + StrCpy $0 "$5" + pop $R3 + pop $R2 + pop $R1 + pop $R0 + pop $6 + pop $5 + pop $4 + pop $3 + pop $2 + pop $1 + exch $0 +FunctionEnd + +Function CBRToolsPreviousUninstall +exch $0 +push $1 # counter +push $2 # version +push $3 # uninstall string +push $4 +push $5 + +push $6 + +push $R0 # $ReplaceVer +push $R1 # $ReplaceKey + +push $R2 # nsis installations found +push $R3 # install shield installations found + +${If} $CBRUNINSTALL == "yes" + #uninstall + #Uninstall first all NSIS installations + StrCpy $1 0 + EnumRegKey $2 HKLM "${CBRTOOLSKEY}" $1 + ${While} $2 != "" + ReadRegStr $3 HKLM "${PRODUCT_UNINST_KEY}\Symbian CBR Tools $2" "UninstallString" + ReadRegStr $4 HKLM "${CBRTOOLSKEY}\$2" "Path" + ${If} $3 == "" #no uninstaller found + StrCpy $6 "error" + ${Else} + IfFileExists $3 +2 0 + StrCpy $6 "error" + ${EndIf} + + ${If} $SILENT == "false" + ${OrIf} $DIALOGS == "true" + Banner::show /NOUNLOAD /set 76 "Removing previous installation $2..." "Please wait." + ${EndIf} + IfFileExists "$4\reltools.ini" 0 +3 + CreateDirectory "$TEMP\sitk\$2\" + CopyFiles /SILENT "$4\reltools.ini" "$TEMP\sitk\$2\" + ${If} $6 == "error" + !insertmacro CBRToolsNSISManualUninstall "$2" "$4" + ${Else} + ClearErrors + ExecWait '"$3" /S _?=$4\' ;$3: Uninstaller $4:installation path + IfErrors +2 0 + RMDir /r $4 ; delete installation folder + ${EndIf} + IfFileExists "$TEMP\sitk\$2\reltools.ini" 0 +4 + CreateDirectory "$4" + CopyFiles /SILENT "$TEMP\sitk\$2\reltools.ini" "$4" + RMDir /r "$TEMP\sitk\$2\" + ${If} $SILENT == "false" + ${OrIf} $DIALOGS == "true" + Banner::destroy + ${EndIf} + + #IntOp $1 $1 + 1 + EnumRegKey $2 HKLM "${CBRTOOLSKEY}" $1 + ${EndWhile} + + loop: #check if there is install shield installation + + + StrCpy $1 0 + StrCpy $R3 0 + EnumRegKey $2 HKLM "${RELTOOLSKEY}" $1 + ${While} $2 != "" + ReadRegStr $3 HKLM "${RELTOOLSKEY}\$2" "Path" + + CreateDirectory "$TEMP\sitk\InstallShield\$2\" + IfFileExists "$3\reltools.ini" 0 +2 + CopyFiles /SILENT "$3\reltools.ini" "$TEMP\sitk\InstallShield\$2\" + FileOpen $4 "$TEMP\sitk\InstallShield\$2\dir.txt" "w" + FileWrite $4 "$3" + FileClose $4 + StrCpy $R3 "1" + IntOp $1 $1 + 1 + EnumRegKey $2 HKLM "${RELTOOLSKEY}" $1 + ${EndWhile} + + + ${If} $R3 == "1" #Look for install shield installations to uninstall + StrCpy $1 0 + StrCpy $6 "" + EnumRegKey $2 HKLM "${PRODUCT_UNINST_KEY}" $1 + ${While} $2 != "" + ReadRegStr $3 HKLM "${PRODUCT_UNINST_KEY}\$2" "DisplayName" + ${If} $3 == "Release Tools" + ${ExitWhile} + ${EndIf} + IntOp $1 $1 + 1 + EnumRegKey $2 HKLM "${PRODUCT_UNINST_KEY}" $1 + ${EndWhile} + + ${If} $2 == "" + StrCpy $6 "error" + ${ElseIf} $3 == "Release Tools" + ReadRegStr $3 HKLM "${PRODUCT_UNINST_KEY}\$2" "UninstallString" + ${If} $3 == "" + StrCpy $6 "error" + ${Else} + MessageBox MB_OK "InstallShield will be launched, please select and follow the wizard" /SD IDOK + ExecWait $3 + ${EndIf} + ${EndIf} + + FindFirst $0 $4 "$TEMP\sitk\InstallShield\*" + ${While} $4 != "" + ${If} $4 != "." + ${AndIf} $4 != ".." + IfFileExists "$TEMP\sitk\InstallShield\$4\dir.txt" 0 notfound + + FileOpen $3 "$TEMP\sitk\InstallShield\$4\dir.txt" "r" + FileRead $3 $1 + FileClose $3 + + ${If} $6 == "error" + !insertmacro CBRToolsISManualUninstall "$4" "$1" "$2" + ${EndIf} + + IfFileExists "$TEMP\sitk\InstallShield\$4\reltools.ini" 0 notfound + CreateDirectory "$1" + CopyFiles /SILENT "$TEMP\sitk\InstallShield\$4\reltools.ini" "$1" + notfound: + + ${EndIf} + FindNext $0 $4 + ${EndWhile} + FindClose $0 + + ${EndIf} + #uninstal +${EndIF} + + pop $R3 + pop $R2 + pop $R1 + pop $R0 + pop $6 + pop $5 + pop $4 + pop $3 + pop $2 + pop $1 + pop $0 +FunctionEnd + +!macro CBRToolsPreconfigure inSectionName + push "${inSectionName}" + call CBRToolsPreConfigureFunction +!macroend diff -r 22486c9c7b15 -r 378360dbbdba releasing/cbrtools/group/cbr_tools.tdf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/releasing/cbrtools/group/cbr_tools.tdf Wed Jun 30 11:35:58 2010 +0800 @@ -0,0 +1,15 @@ + + + + + +