MS Visual C build

This commit is contained in:
Stas Degteff 2005-09-15 20:42:29 +00:00
parent 7f416bdb4f
commit 85f1f53d51

View File

@ -134,6 +134,8 @@ struct nl_stat {
nl_stat statistic; nl_stat statistic;
#endif #endif
char* _MapPath(char* map, bool reverse = false);
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Display a "twirly" // Display a "twirly"
@ -368,7 +370,7 @@ static char* make_addr_str(char* str, Addr* addr, char* domain) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Compare two nodes by name/address/file/pos // Compare two nodes by name/address/file/pos
static bool cmp_nnlsts(const _GEIdx A, const _GEIdx B) { static bool cmp_nnlsts(const _GEIdx &A, const _GEIdx &B) {
int cmp; int cmp;
@ -391,7 +393,7 @@ static bool cmp_nnlsts(const _GEIdx A, const _GEIdx B) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Compare two nodes by address/name/file/pos // Compare two nodes by address/name/file/pos
static bool cmp_anlsts(const _GEIdx A, const _GEIdx B) { static bool cmp_anlsts(const _GEIdx &A, const _GEIdx &B) {
int cmp; int cmp;
@ -411,6 +413,17 @@ static bool cmp_anlsts(const _GEIdx A, const _GEIdx B) {
} }
// ------------------------------------------------------------------
#if defined(_MSC_VER)
enum{ sort_by_address=0, sort_by_name } static sort_type;
bool operator<(const _GEIdx &A, const _GEIdx &B)
{
if (sort_type==sort_by_address)
return cmp_anlsts(A, B);
else
return cmp_nnlsts(A, B);
}
#endif
// ------------------------------------------------------------------ // ------------------------------------------------------------------
static char* CvtName(char* inp) { static char* CvtName(char* inp) {
@ -882,7 +895,12 @@ static void read_nodelists() {
// Sort by name // Sort by name
if(not quiet) std::cout << std::endl << "* Sorting by name " << std::flush; if(not quiet) std::cout << std::endl << "* Sorting by name " << std::flush;
#if defined(_MSC_VER)
sort_type = sort_by_name;
nodeidx.sort();
#else
nodeidx.sort(cmp_nnlsts); nodeidx.sort(cmp_nnlsts);
#endif
// Write the name-sorted .GXN // Write the name-sorted .GXN
fp = fsopen(nodeindex.c_str(), "wb", sh_mod); fp = fsopen(nodeindex.c_str(), "wb", sh_mod);
@ -935,7 +953,12 @@ static void read_nodelists() {
// Sort by address // Sort by address
if(not quiet) std::cout << ' ' << std::endl << "* Sorting by node " << std::flush; if(not quiet) std::cout << ' ' << std::endl << "* Sorting by node " << std::flush;
#if defined(_MSC_VER)
sort_type = sort_by_address;
nodeidx.sort();
#else
nodeidx.sort(cmp_anlsts); nodeidx.sort(cmp_anlsts);
#endif
// Write the address-sorted .GXA // Write the address-sorted .GXA
fp = fsopen(addrindex.c_str(), "wb", sh_mod); fp = fsopen(addrindex.c_str(), "wb", sh_mod);
@ -1020,7 +1043,7 @@ static void check_nodelists(bool force) {
char* val=buf; char* val=buf;
getkeyval(&key, &val); getkeyval(&key, &val);
key = strxcpy(newpath, strbtrim(key), sizeof(Path)); key = strxcpy(newpath, strbtrim(key), sizeof(Path));
MapPath(key); _MapPath(key);
strchg(key, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); strchg(key, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR);
for(n=0; n<nodelist.size(); n++) { for(n=0; n<nodelist.size(); n++) {
if(strieql(nodelist[n].fn, key)) { if(strieql(nodelist[n].fn, key)) {
@ -1131,7 +1154,7 @@ static int do_if(char* val) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
char* MapPath(char* fmap, bool reverse) { char* _MapPath(char* fmap, bool reverse) {
Path buf, cmap; Path buf, cmap;
@ -1229,7 +1252,7 @@ static int parse_config(const char *__configfile, Addr& zoneaddr) {
if((not _gotcond) and cond_status) { if((not _gotcond) and cond_status) {
switch(crc) { switch(crc) {
case CRC_NODEPATH: case CRC_NODEPATH:
MapPath(value); _MapPath(value);
PathCopy(nodepath, value); PathCopy(nodepath, value);
break; break;
case CRC_ADDRESS: case CRC_ADDRESS:
@ -1258,7 +1281,7 @@ static int parse_config(const char *__configfile, Addr& zoneaddr) {
ndl.ft = (dword)-1; ndl.ft = (dword)-1;
ndl.fc = NO; ndl.fc = NO;
strschg_environ(value); strschg_environ(value);
MapPath(value); _MapPath(value);
strcpy(ndl.fn, value); strcpy(ndl.fn, value);
nodelist.push_back(ndl); nodelist.push_back(ndl);
nodezone.push_back(ndz); nodezone.push_back(ndz);
@ -1283,7 +1306,7 @@ static int parse_config(const char *__configfile, Addr& zoneaddr) {
ndl.ft = (dword)-1; ndl.ft = (dword)-1;
ndl.fc = NO; ndl.fc = NO;
strschg_environ(value); strschg_environ(value);
MapPath(value); _MapPath(value);
strcpy(ndl.fn, value); strcpy(ndl.fn, value);
userlist.push_back(ndl); userlist.push_back(ndl);
userzone.push_back(ndz); userzone.push_back(ndz);
@ -1311,7 +1334,7 @@ static int parse_config(const char *__configfile, Addr& zoneaddr) {
break; break;
case CRC_INCLUDE: case CRC_INCLUDE:
strschg_environ(value); strschg_environ(value);
MapPath(value); _MapPath(value);
if(not parse_config(value,zoneaddr)) // NOTE! This is a recursive call! if(not parse_config(value,zoneaddr)) // NOTE! This is a recursive call!
if(not quiet) std::cout << "* Could not read configuration file " << value << '!' << std::endl; if(not quiet) std::cout << "* Could not read configuration file " << value << '!' << std::endl;
break; break;
@ -1508,43 +1531,39 @@ static void run_gn(int argc, char* argv[]) {
} }
if(not quiet) { if(not quiet) {
std::cout << __GPID__ " " __GVER__ " Nodelist Compiler." << std::endl std::cout << __GPID__ " " __GVER__ " Nodelist Compiler.\n"
<< "Copyright (C) 1990-1999 Odinn Sorensen" << std::endl << "Copyright (C) 1990-1999 Odinn Sorensen\n"
<< "Copyright (C) 1999-2001 Alexander S. Aganichev" << std::endl << "Copyright (C) 1999-2001 Alexander S. Aganichev\n"
<< "-------------------------------------------------------------------------------" << std::endl << "-------------------------------------------------------------------------------\n\n";
<< std::endl;
} }
if(not(force or conditional)) { if(not(force or conditional)) {
if(not quiet) { if(not quiet) {
std::cout << "Commandline syntax: " << CleanFilename(argv[0]) << " [-options] [configfile]" << std::endl std::cout << "Commandline syntax: " << CleanFilename(argv[0]) << " [-options] [configfile]\n"
<< std::endl << "\n[-options] =\t-C\t Conditional compile.\n"
<< "[-options] =\t-C\t Conditional compile." << std::endl << "\t\t-F\t Forced compile.\n"
<< "\t\t-F\t Forced compile." << std::endl << "\t\t-D\t Remove duplicate nodes from index while compiling.\n"
<< "\t\t-D\t Remove duplicate nodes from index while compiling." << std::endl << "\t\t-Q\t Quiet compile. No screen output improves speed.\n"
<< "\t\t-Q\t Quiet compile. No screen output improves speed." << std::endl << "\t\t-S<size> Set max size of a name in the index.\n"
<< "\t\t-S<size> Set max size of a name in the index." << std::endl << "\t\t-U<file> Create sorted FIDOUSER.LST userlist file.\n"
<< "\t\t-U<file> Create sorted FIDOUSER.LST userlist file." << std::endl
#ifdef GOLDNODE_STATS #ifdef GOLDNODE_STATS
<< "\t\t-T\t Make statistics." << std::endl << "\t\t-T\t Make statistics.\n"
#endif #endif
<< std::endl << "\n[configfile] =\t\t The path AND filename of GOLDED.CFG\n"
<< "[configfile] =\t\t The path AND filename of GOLDED.CFG" << std::endl << "\t\t\t configuration file to read.\n\n";
<< "\t\t\t configuration file to read." << std::endl
<< std::endl;
} }
} }
else { else {
if(force) if(force)
if(not quiet) std::cout << "* Forced compile." << std::endl; if(not quiet) std::cout << "* Forced compile.\n";
if(read_config(cfg, argv[0])) { if(read_config(cfg, argv[0])) {
if(force or conditional) if(force or conditional)
check_nodelists(force); check_nodelists(force);
} }
else { else {
if(not quiet) std::cout << std::endl << "Could not find the configuration file!" << std::endl; if(not quiet) std::cout << "\nCould not find the configuration file!\n";
} }
} }
} }