diff --git a/ChangeLog b/ChangeLog index b7626b7..5534600 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,159 +1,69 @@ -2004-11-24 12:42 davi +2005-01-18 10:18 davi - * src/czech.c: Fixed some leaks. + * COPYING, INSTALL, src/Makefile.am, src/bmz.c, src/bmz.h, + src/cmph.c, src/cmph.h, src/cmph_structs.c, src/cmph_structs.h, + src/czech.c, src/czech.h, src/debug.h, src/djb2_hash.c, + src/graph.c, src/graph.h, src/hash.c, src/jenkins_hash.c, + src/main.c, src/sdbm_hash.c, src/vqueue.c: Fixed a lot of warnings. + Added visual studio project. Make needed changes to work with + windows. -2004-11-24 11:34 davi +2005-01-17 16:01 fc_botelho - * src/: Makefile.am, cmph.h, cmph_types.h, czech.h, graph.h, - hash.h, jenkins_hash.h, types.h, vstack.h: Better header layout. + * src/main.c: stable version -2004-11-23 15:15 davi +2005-01-17 15:58 fc_botelho - * src/jenkins_hash.c: Fixed trivial bug. + * src/: bmz.c, cmph.c, cmph.h, graph.c: stable version -2004-11-04 00:56 davi +2005-01-13 21:56 davi - * src/: czech.c, graph.c: Forgot. + * src/czech.c: Better error handling in czech.c. -2004-11-04 00:09 davi +2005-01-05 18:45 fc_botelho - * src/: cmph.c, cmph.h, czech.c, czech.h, graph.c, main.c: Fixed - small bug due to fgets trick. + * src/cmph_structs.c: included option -k to specify the number of + keys to use -2004-11-03 23:15 davi +2005-01-05 17:48 fc_botelho - * src/: cmph.c, cmph.h, cmph_structs.c, cmph_structs.h, czech.c, - main.c: Added verbosity option + * src/: cmph.c, main.c: included option -k to specify the number of + keys to use -2004-11-03 22:42 davi +2005-01-03 19:38 fc_botelho - * src/czech.c: [no log message] + * src/bmz.c: using less memory -2004-11-03 20:57 davi +2005-01-03 18:47 fc_botelho - * src/: Makefile.am, fnv_hash.c, fnv_hash.h, hash.c, hash_state.h: - Added fnv hash function. + * src/: bmz.c, graph.c: using less space to store the used_edges + and critical_nodes arrays -2004-11-03 18:10 davi +2004-12-23 11:16 davi - * src/: Makefile.am, cmph.c, cmph.h, czech.c, czech.h, djb2_hash.c, - hash.c, hash_state.h, jenkins_hash.c, main.c, sdbm_hash.c, - sdbm_hash.h: Added sdbm hash function. + * INSTALL, COPYING, AUTHORS, ChangeLog, Makefile.am, NEWS, README, + cmph.spec, configure.ac, src/graph.c, tests/Makefile.am, + tests/graph_tests.c, src/bmz.c, src/cmph_types.h, + src/czech_structs.h, src/hash_state.h, src/jenkins_hash.c, + src/bmz_structs.h, src/cmph.c, src/cmph.h, src/cmph_structs.h, + src/czech.c, src/debug.h, src/djb2_hash.c, src/djb2_hash.h, + src/fnv_hash.c, src/fnv_hash.h, src/graph.h, src/hash.c, + src/hash.h, src/jenkins_hash.h, src/sdbm_hash.c, src/vstack.h, + src/Makefile.am, src/bmz.h, src/cmph_structs.c, src/czech.h, + src/main.c, src/sdbm_hash.h, src/vqueue.c, src/vqueue.h, + src/vstack.c: Initial release. -2004-11-03 15:53 davi +2004-12-23 11:16 davi - * src/cmph.c, src/cmph.h, src/cmph_structs.c, src/cmph_structs.h, - src/czech.c, src/czech.h, src/czech_structs.h, src/main.c, - tests/Makefile.am, tests/czech_tests.c: Added callback structure to - retrieve keys in disk. - -2004-10-31 22:57 davi - - * src/: Makefile.am, djb2_hash.c, djb2_hash.h, hash.c, hash.h, - hash_funcs.h, jenkins_hash.h: Added new hash function. - -2004-10-31 20:53 davi - - * src/main.c: Added random seed. - -2004-10-31 20:48 davi - - * src/main.c, tests/czech_tests.c: Better getopt code. - -2004-10-31 19:27 davi - - * src/: cmph.c, cmph.h, cmph_structs.c, cmph_structs.h, czech.c, - czech.h, czech_structs.h, hash.c, hash.h, jenkins_hash.c, - jenkins_hash.h, main.c: Everything working flawlessly. - -2004-10-30 20:12 davi - - * src/cmph_structs.c: Added missing file. - -2004-10-30 20:09 davi - - * src/main.c: forgot. - -2004-10-29 19:02 davi - - * src/: Makefile.am, cmph.c, cmph.h, cmph_structs.h, czech.c, - czech.h, czech_structs.h, graph.c, hash.c, hash.h, jenkins_hash.c, - jenkins_hash.h, main.c: Cleaned some warnings. - -2004-10-29 16:14 davi - - * src/: hash.c, hash_state.h: Missing file. - -2004-10-29 14:18 davi - - * src/: Makefile.am, cmph.c, cmph.h, czech.c, graph.c, hash.h, - jenkins_hash.c, jenkins_hash.h, jenkinshash.c, jenkinshash.h: - Working nice. Serialization almost there. - -2004-10-28 11:21 davi - - * Makefile.am, src/cmph.c, src/cmph_structs.h, src/czech.c, - src/czech_structs.h, src/jenkinshash.c: Hash generation seems to be - working fine. - -2004-10-27 15:19 davi - - * src/hash.h: Added hash header. - -2004-10-27 15:06 davi - - * COPYING, INSTALL, Makefile.am, src/czech.c, src/czech_structs.h, - src/graph.c, src/graph.h, src/vstack.c, tests/Makefile.am, - tests/czech_tests.c, tests/graph_tests.c: Cool. Now it is - serialization time. - -2004-10-27 13:06 davi - - * tests/: czech_tests.c, keys: Added missing files. - -2004-10-26 21:23 davi - - * src/graph.c, tests/Makefile.am: Still working on f*cking graph - implementation. - -2004-10-25 20:05 davi - - * src/: cmph.c, cmph.h, cmph_structs.h, czech.c, czech.h, - czech_structs.h, graph.c, graph.h, jenkinshash.c, jenkinshash.h, - vstack.c: Added some new files. - -2004-10-25 00:27 davi - - * src/: czech.c, czech.h, graph.c, graph.h, jenkinshash.c: Some - random code. - -2004-10-24 23:07 davi - - * src/: Makefile.am, debug.h, graph.c, main.c, vstack.c, vstack.h: - Added stack implementation. - -2004-10-24 21:57 davi - - * src/list.h: Added missing file. - -2004-10-24 21:50 davi - - * src/types.h: Added missing file. - -2004-10-22 20:30 davi - - * src/: Makefile.am, cmph.h, czech.c, czech.h, graph.c, graph.h, - jenkinshash.c, jenkinshash.h: Added a lot of files. - -2004-10-19 17:08 davi - - * AUTHORS, COPYING, ChangeLog, INSTALL, Makefile.am, NEWS, README, - cmph.spec, configure.ac, src/Makefile.am, src/cmph.c, src/cmph.h, - src/main.c, tests/Makefile.am: Initial revision - -2004-10-19 17:08 davi - - * AUTHORS, COPYING, ChangeLog, INSTALL, Makefile.am, NEWS, README, - cmph.spec, configure.ac, src/Makefile.am, src/cmph.c, src/cmph.h, - src/main.c, tests/Makefile.am: Minimum perfect hashing library + * INSTALL, COPYING, AUTHORS, ChangeLog, Makefile.am, NEWS, README, + cmph.spec, configure.ac, src/graph.c, tests/Makefile.am, + tests/graph_tests.c, src/bmz.c, src/cmph_types.h, + src/czech_structs.h, src/hash_state.h, src/jenkins_hash.c, + src/bmz_structs.h, src/cmph.c, src/cmph.h, src/cmph_structs.h, + src/czech.c, src/debug.h, src/djb2_hash.c, src/djb2_hash.h, + src/fnv_hash.c, src/fnv_hash.h, src/graph.h, src/hash.c, + src/hash.h, src/jenkins_hash.h, src/sdbm_hash.c, src/vstack.h, + src/Makefile.am, src/bmz.h, src/cmph_structs.c, src/czech.h, + src/main.c, src/sdbm_hash.h, src/vqueue.c, src/vqueue.h, + src/vstack.c: Initial revision diff --git a/cmph.vcproj b/cmph.vcproj new file mode 100644 index 0000000..d7e925b --- /dev/null +++ b/cmph.vcproj @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cmphapp.vcproj b/cmphapp.vcproj new file mode 100644 index 0000000..bf92899 --- /dev/null +++ b/cmphapp.vcproj @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wingetopt.c b/wingetopt.c new file mode 100644 index 0000000..09fd6d9 --- /dev/null +++ b/wingetopt.c @@ -0,0 +1,177 @@ +/***************************************************************************** + * + * MODULE NAME : GETOPT.C + * + * COPYRIGHTS: + * This module contains code made available by IBM + * Corporation on an AS IS basis. Any one receiving the + * module is considered to be licensed under IBM copyrights + * to use the IBM-provided source code in any way he or she + * deems fit, including copying it, compiling it, modifying + * it, and redistributing it, with or without + * modifications. No license under any IBM patents or + * patent applications is to be implied from this copyright + * license. + * + * A user of the module should understand that IBM cannot + * provide technical support for the module and will not be + * responsible for any consequences of use of the program. + * + * Any notices, including this one, are not to be removed + * from the module without the prior written consent of + * IBM. + * + * AUTHOR: Original author: + * G. R. Blair (BOBBLAIR at AUSVM1) + * Internet: bobblair@bobblair.austin.ibm.com + * + * Extensively revised by: + * John Q. Walker II, Ph.D. (JOHHQ at RALVM6) + * Internet: johnq@ralvm6.vnet.ibm.com + * + *****************************************************************************/ + +/****************************************************************************** + * getopt() + * + * The getopt() function is a command line parser. It returns the next + * option character in argv that matches an option character in opstring. + * + * The argv argument points to an array of argc+1 elements containing argc + * pointers to character strings followed by a null pointer. + * + * The opstring argument points to a string of option characters; if an + * option character is followed by a colon, the option is expected to have + * an argument that may or may not be separated from it by white space. + * The external variable optarg is set to point to the start of the option + * argument on return from getopt(). + * + * The getopt() function places in optind the argv index of the next argument + * to be processed. The system initializes the external variable optind to + * 1 before the first call to getopt(). + * + * When all options have been processed (that is, up to the first nonoption + * argument), getopt() returns EOF. The special option "--" may be used to + * delimit the end of the options; EOF will be returned, and "--" will be + * skipped. + * + * The getopt() function returns a question mark (?) when it encounters an + * option character not included in opstring. This error message can be + * disabled by setting opterr to zero. Otherwise, it returns the option + * character that was detected. + * + * If the special option "--" is detected, or all options have been + * processed, EOF is returned. + * + * Options are marked by either a minus sign (-) or a slash (/). + * + * No errors are defined. + *****************************************************************************/ + +#include /* for EOF */ +#include /* for strchr() */ + +/* static (global) variables that are specified as exported by getopt() */ +extern char *optarg; /* pointer to the start of the option argument */ +extern int optind; /* number of the next argv[] to be evaluated */ +extern int opterr; /* non-zero if a question mark should be returned + when a non-valid option character is detected */ + +/* handle possible future character set concerns by putting this in a macro */ +#define _next_char(string) (char)(*(string+1)) + +int getopt(int argc, char *argv[], char *opstring) +{ + static char *pIndexPosition = NULL; /* place inside current argv string */ + char *pArgString = NULL; /* where to start from next */ + char *pOptString; /* the string in our program */ + + + if (pIndexPosition != NULL) { + /* we last left off inside an argv string */ + if (*(++pIndexPosition)) { + /* there is more to come in the most recent argv */ + pArgString = pIndexPosition; + } + } + + if (pArgString == NULL) { + /* we didn't leave off in the middle of an argv string */ + if (optind >= argc) { + /* more command-line arguments than the argument count */ + pIndexPosition = NULL; /* not in the middle of anything */ + return EOF; /* used up all command-line arguments */ + } + + /*--------------------------------------------------------------------- + * If the next argv[] is not an option, there can be no more options. + *-------------------------------------------------------------------*/ + pArgString = argv[optind++]; /* set this to the next argument ptr */ + + if (('/' != *pArgString) && /* doesn't start with a slash or a dash? */ + ('-' != *pArgString)) { + --optind; /* point to current arg once we're done */ + optarg = NULL; /* no argument follows the option */ + pIndexPosition = NULL; /* not in the middle of anything */ + return EOF; /* used up all the command-line flags */ + } + + /* check for special end-of-flags markers */ + if ((strcmp(pArgString, "-") == 0) || + (strcmp(pArgString, "--") == 0)) { + optarg = NULL; /* no argument follows the option */ + pIndexPosition = NULL; /* not in the middle of anything */ + return EOF; /* encountered the special flag */ + } + + pArgString++; /* look past the / or - */ + } + + if (':' == *pArgString) { /* is it a colon? */ + /*--------------------------------------------------------------------- + * Rare case: if opterr is non-zero, return a question mark; + * otherwise, just return the colon we're on. + *-------------------------------------------------------------------*/ + return (opterr ? (int)'?' : (int)':'); + } + else if ((pOptString = strchr(opstring, *pArgString)) == 0) { + /*--------------------------------------------------------------------- + * The letter on the command-line wasn't any good. + *-------------------------------------------------------------------*/ + optarg = NULL; /* no argument follows the option */ + pIndexPosition = NULL; /* not in the middle of anything */ + return (opterr ? (int)'?' : (int)*pArgString); + } + else { + /*--------------------------------------------------------------------- + * The letter on the command-line matches one we expect to see + *-------------------------------------------------------------------*/ + if (':' == _next_char(pOptString)) { /* is the next letter a colon? */ + /* It is a colon. Look for an argument string. */ + if ('\0' != _next_char(pArgString)) { /* argument in this argv? */ + optarg = &pArgString[1]; /* Yes, it is */ + } + else { + /*------------------------------------------------------------- + * The argument string must be in the next argv. + * But, what if there is none (bad input from the user)? + * In that case, return the letter, and optarg as NULL. + *-----------------------------------------------------------*/ + if (optind < argc) + optarg = argv[optind++]; + else { + optarg = NULL; + return (opterr ? (int)'?' : (int)*pArgString); + } + } + pIndexPosition = NULL; /* not in the middle of anything */ + } + else { + /* it's not a colon, so just return the letter */ + optarg = NULL; /* no argument follows the option */ + pIndexPosition = pArgString; /* point to the letter we're on */ + } + return (int)*pArgString; /* return the letter that matched */ + } +} + diff --git a/wingetopt.h b/wingetopt.h new file mode 100644 index 0000000..4df5d78 --- /dev/null +++ b/wingetopt.h @@ -0,0 +1,25 @@ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef WIN32 + #include +#else + #ifndef _GETOPT_ + #define _GETOPT_ + + #include /* for EOF */ + #include /* for strchr() */ + + char *optarg = NULL; /* pointer to the start of the option argument */ + int optind = 1; /* number of the next argv[] to be evaluated */ + int opterr = 1; /* non-zero if a question mark should be returned */ + + int getopt(int argc, char *argv[], char *opstring); + #endif +#endif + +#ifdef __cplusplus +} +#endif +