dbmi0.1/0040755000175200017560000000000007306140342012453 5ustar stephensstephengdbmi0.1/src/0040755000175200017560000000000007306140336013245 5ustar stephensstephengdbmi0.1/src/dbmi/0040755000175200017560000000000007306140336014160 5ustar stephensstephengdbmi0.1/src/dbmi/CVS/0040755000175200017560000000000007236675451014630 5ustar stephensstephengdbmi0.1/src/dbmi/CVS/Root0100644000175200017560000000003407236675451015470 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/dbmi/CVS/Repository0100644000175200017560000000002207236675451016721 0ustar stephensstephenghome/ion/src/dbmi dbmi0.1/src/dbmi/CVS/Entries0100644000175200017560000000043107236675451016157 0ustar stephensstepheng/Makefile/1.3/Sun Feb 6 20:31:46 2000// /Makefile.use/1.1/Thu Jan 13 03:24:25 2000// /PKG/1.1/Tue Mar 21 07:59:23 2000// /dbmi.c/1.4/Thu Feb 1 05:52:42 2001// /dbmi.h/1.4/Thu Feb 1 05:52:42 2001// /main.c/1.2/Sun Feb 6 20:35:10 2000// /test.ts/1.1/Thu Jan 13 03:25:40 2000// D dbmi0.1/src/dbmi/Makefile0100644000175200017560000000165007047355062015625 0ustar stephensstepheng# $Id: Makefile,v 1.3 2000/02/06 20:31:46 stephensk Exp $ INCLS += .. ../gdbm-1.8.0 H_FILES = dbmi.h C_FILES = dbmi.c ################################################################# # Pre include $(MAKS)/pre.mak ################################################################# # Create LIB_NAME:=dbmi include $(MAKS)/lib.mak TOOL_NAME:=dbmi TOOL_MAIN:=main.c TOOL_LIBS:=dbmi gdbm include $(MAKS)/tool.mak APP=$(TOOL) ################################################################# # Basic include $(MAKS)/basic.mak ################################################################# $(O_FILES) : $(H_FILES) ################################################################# GARBAGE += testfile testfile.i testfile.i.cfg testfile : dbmi.c cp dbmi.c testfile debug : ${APP} testfile test.ts ts run -t gdb APP=${APP} test.ts rm testfile test : ${APP} testfile test.ts ts run -t time APP=${APP} test.ts rm testfile dbmi0.1/src/dbmi/Makefile.use0100644000175200017560000000017107037242551016412 0ustar stephensstepheng# $Id: Makefile.use,v 1.1 2000/01/13 03:24:25 stephensk Exp $ USE:=../util include $(MAKS)/use.mak LIBS:= dbmi $(LIBS) dbmi0.1/src/dbmi/PKG0100644000175200017560000000036007065625733014533 0ustar stephensstephengNAME=dbmi VERSION=0.1 RCS_ID="$Id: PKG,v 1.1 2000/03/21 07:59:23 stephensk Exp $" DESC="A keyword-indexed data output stream C library." CHANGES_RELEASES="0.1" CATEGORY="Development Tools" REQUIRES_PKGS="../maks ../util" REQUIRES_OTHERS="" dbmi0.1/src/dbmi/dbmi.c0100644000175200017560000012273707236174652015262 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_dbmi_dbmi_c__ #define __rcs_id_dbmi_dbmi_c__ static const char __rcs_id_dbmi_dbmi_c[] = "$Id: dbmi.c,v 1.4 2001/02/01 05:52:42 stephens Exp $"; #endif #endif /* __rcs_id__ */ #include "dbmi.h" #include "util/file.h" #include #include #include #include #include #include #include #include #include "gdbm.h" #define DB(X) ((GDBM_FILE)((X)->db)) #define KDB(X) ((GDBM_FILE)((X)->kdb)) /* Default options. */ int dbmi_index_enabled = 1; FILE *dbmi_err = 0; /* stderr */ int dbmi_verbose = 0; int dbmi_debug = 0; int dbmi_token_foldcase = 1; int dbmi_token_plural = 1; int dbmi_token_min_length = 3; int dbmi_token_mask = dbmi_token_WORD; int dbmi_mtime_check = 0; int dbmi_index_lock = 0; int dbmi_centfree = 1; int dbmi_coalesceblks = 0; int dbmi_retry_index_open = 0; static int _dbmi_mtime_check(dbmi *dbi); static dbmi_token dbmi_token_exclude_default[] = { #define TOKEN(X) { X, sizeof(X) - 1, dbmi_token_WORD }, TOKEN("a") TOKEN("i") TOKEN("or") TOKEN("to") TOKEN("is") TOKEN("it") TOKEN("if") TOKEN("of") TOKEN("do") TOKEN("us") TOKEN("he") TOKEN("she") TOKEN("you") TOKEN("not") TOKEN("the") TOKEN("and") TOKEN("his") TOKEN("him") TOKEN("her") TOKEN("its") TOKEN("who") TOKEN("etc") TOKEN("for") TOKEN("but") TOKEN("are") TOKEN("can") TOKEN("your") TOKEN("from") TOKEN("hers") TOKEN("whom") TOKEN("then") TOKEN("this") TOKEN("that") TOKEN("what") TOKEN("them") TOKEN("have") TOKEN("they") TOKEN("there") TOKEN("their") TOKEN("") /* Guard to test sortedness. (l == 0) */ { 0, 0 } /* Guard for end of list. (b == 0) */ #undef TOKEN }; dbmi_token *dbmi_token_exclude = dbmi_token_exclude_default; static int dbmi_token_cmp(const void *a, const void *b) { #define A ((const dbmi_token*) a) #define B ((const dbmi_token*) b) int diff; if ( (diff = A->l - B->l) ) return diff; return strncmp(A->b, B->b, B->l); #undef A #undef B } int dbmi_set_token_exclude(dbmi *dbi, dbmi_token *tokens, int ntokens) { /* Compute list length. */ int i; if ( ntokens < 0 ) { for ( i = 0; tokens[i].b; ++ i ) ; ntokens = i; } dbi->token_exclude = tokens; if ( dbi->token_exclude_len == 0 || dbi->token_exclude[0].l != 0 ) { dbi->token_exclude_len = ntokens; /* Sort it. */ qsort( dbi->token_exclude, dbi->token_exclude_len, sizeof(dbi->token_exclude[0]), dbmi_token_cmp); if ( dbi->debug ) { fprintf(dbmi_err, "dbmi: exclude sorted {\n"); for ( i = 0; dbi->token_exclude[i].b; ++ i ) { fprintf(dbmi_err, "%s\n", dbi->token_exclude[i].b); } fprintf(dbmi_err, "}\n"); } } return 0; } static void dbmi_token_depluralize(dbmi *dbi, dbmi_token *token) { /* Handle depluralizing */ if ( (! dbi->token_plural) ) { if ( token->l > 3 && token->b[token->l - 1] == 's' && token->b[token->l - 2] != 's') { -- token->l; if ( token->l > 3 && token->b[token->l - 1] == 'e' ) { -- token->l; } } } } static int dbmi_token_check(dbmi *dbi, dbmi_token *token) { /* Check type and length */ if ( (token->t & dbi->token_mask) && token->l >= dbi->token_min_length ) { #if 0 { int i; assert(dbi->token_exclude); assert(dbi->token_exclude_len); for ( i = 1; i < dbi->token_exclude_len; ++ i ) { assert(dbmi_token_cmp(&dbi->token_exclude[i - 1], &dbi->token_exclude[i]) < 0); } } #endif /* Search exclusion list. */ if ( dbi->token_exclude ) { if ( bsearch(token, dbi->token_exclude, dbi->token_exclude_len, sizeof(dbi->token_exclude[0]), dbmi_token_cmp) ) { if ( dbi->debug ) { fprintf(dbmi_err, "E"); fflush(dbmi_err); } #if 0 fprintf(dbmi_err, "token '%*s' excluded\n", (int) token->l, token->b); #endif return 0; } } /* Okay */ return 1; } /* Not right type or length */ return 0; } static void dbmi_foldcase(char *b, char *e) { while ( b != e ) { if ( isupper(*b) ) *b = tolower(*b); ++ b; } } #if 1 #define ISALNUM(X) (isalnum(X)) #define ISALPHA(X) (isalpha(X)) #define ISDIGIT(X) (isdigit(X)) #else #define ISALNUM(X) (isanum(X) || (X) == '_') #define ISALPHA(X) (isalpha(X) || (X) == '_') #define ISDIGIT(X) (isdigit(X)) #endif dbmi_token_parse_DECL(dbmi_token_parse_default) { const char *mb, *me; token->t = dbmi_token_NONE; mb = b; /* Scan till first alphanumberic char. */ while ( mb != e && ! ISALNUM(*mb) ) { ++ mb; } me = mb; #define return goto _rtn if ( me == e ) return; /* [0-9] */ if ( ISDIGIT(*me) ) { token->t = dbmi_token_NUMBER; /* [0-9]+ */ while ( me != e && ISDIGIT(*me) ) { ++ me; } if ( me == e ) return; /* [0-9]+.[0-9]* */ if ( *me == '.' ) { ++ me; while ( me != e && ISDIGIT(*me) ) { ++ me; } if ( me == e ) return; } /* [0-9]+(.[0-9]*)?[eE] */ if ( *me == 'e' || *me == 'E' ) { ++ me; if ( me == e ) return; /* [0-9]+(.[0-9]*)?[eE][+-]? */ if ( *me == '+' || *me == '-' ) { ++ me; } if ( me == e ) return; /* [0-9]+(.[0-9]*)?[eE][+-]?[0-9]+ */ if ( isdigit(*me) ) { while ( me != e && ISDIGIT(*me) ) { ++ me; } } } } else { /* [A-Za-z_]+ */ token->t = dbmi_token_WORD; while ( me != e && ISALNUM(*me) ) { ++ me; } } #if 0 if ( me != mb ) { fwrite(mb, me - mb, 1, dbmi_err); fwrite("\n", 1, 1, dbmi_err); } #endif _rtn: token->l = me - mb; token->b = (char*) mb; #undef return return token->t; } dbmi_token_parse_t dbmi_token_parse = dbmi_token_parse_default; /*************************************************************************/ #ifndef DBMI_USE_NETWORK_ENCODING #define DBMI_USE_NETWORK_ENCODING 0 #endif #if DBMI_USE_NETWORK_ENCODING #define HTONL(X) htonl(X) #define NTOHL(X) ntohl(X) #else #define HTONL(X) (X) #define NTOHL(X) (X) #endif static int dbmi_token_get(dbmi_token *token, dbmi *dbi, int keep_pos) { int result = 0; datum content; int i, j; assert(token); assert(dbi); assert(DB(dbi)); assert(token->pos == 0); /* Get positions content for token key. */ content = gdbm_fetch(DB(dbi), *(datum*) token); token->pos = (pos_t*) content.dptr; token->spos = content.dsize / sizeof(token->pos[0]); /* Translate from network to host endianess */ /* Remove empty slots and compute npos. */ for ( i = j = 0; i < token->spos; ++ i ) { token->pos[j] = NTOHL(token->pos[i]); if ( token->pos[j] != -1L ) { ++ j; } } token->npos = j; if ( ! keep_pos ) { free(token->pos); token->pos = 0; } return result; } static int dbmi_token_put(dbmi_token *token, dbmi *dbi) { int result = 0; datum content; int i; assert(token); assert(token->pos); #if DBMI_USE_NETWORK_ENCODING /* Translate from host to network endianess */ for ( i = 0; i < token->spos; ++ i ) { token->pos[i] = HTONL(token->pos[i]); } #endif /* Store content. */ content.dptr = (char*) token->pos; content.dsize = token->spos * sizeof(token->pos[0]); result = gdbm_store(DB(dbi), * (datum*) token, content, GDBM_REPLACE); #if DBMI_USE_NETWORK_ENCODING /* Translate from network to host endianess. */ for ( i = 0; i < token->spos; ++ i ) { token->pos[i] = NTOHL(token->pos[i]); } #endif return result; } #define pos_t_EMPTY -1L static int dbmi_token_append_pos(dbmi_token *token, pos_t off) { int result = 0; int i; /* No pos */ if ( ! token->pos ) { token->spos = 1; token->npos = 0; token->pos = malloc(sizeof(token->pos[0]) * token->spos); if ( 0 ) fprintf(dbmi_err, "C"); } else { /* Find empty slot. */ if ( token->npos < token->spos ) { for ( i = token->npos; i >= 0; -- i ) { if ( token->pos[i] == pos_t_EMPTY ) { reuse: /* Reused. */ token->pos[i] = off; ++ i; if ( token->npos < i ) token->npos = i; if ( 0 ) fprintf(dbmi_err, "R"); return result; } } } for ( i = token->npos; i < token->spos; ++ i ) { if ( token->pos[i] == pos_t_EMPTY ) { goto reuse; } } /* Grow pos array. */ { size_t nspos = ((token->spos * 3) / 2) + 1;; token->pos = realloc(token->pos, sizeof(token->pos[0]) * nspos); /* Fill empties. */ for ( i = token->spos; i < nspos; ++ i ) { token->pos[i] = pos_t_EMPTY; } token->spos = nspos; } if ( 0 ) fprintf(dbmi_err, "A"); } /* Store position. */ token->pos[token->npos ++] = off; return result; } static int dbmi_append_token_pos(dbmi *dbi, dbmi_token *token, pos_t off) { int result = 0; /* Get current key positions. */ token->pos = 0; dbmi_token_get(token, dbi, 1); /* Add position. */ dbmi_token_append_pos(token, off); /* Put new positions. */ dbmi_token_put(token, dbi); /* Free positions. */ free(token->pos); token->pos = 0; token->npos = 0; return result; } int dbmi_token_pos(dbmi *dbi, dbmi_token *token, pos_t **posp) { if ( ! DB(dbi) ) return -1; token->pos = 0; dbmi_token_get(token, dbi, posp != 0); if ( posp ) { *posp = token->pos; } return token->npos; } static int dbmi_index_buf(dbmi *dbi, char *buf, size_t buflen, pos_t off) { int result = 0; dbmi_token token; char *b = buf, *e = b + buflen; /* Scan for tokens and append positions from off. */ while ( dbi->token_parse(dbi, b, e, &token) ) { char *n = token.b + token.l; /* Stem token */ dbmi_token_depluralize(dbi, &token); /* Validate token. */ if ( dbmi_token_check(dbi, &token) ) { /* Compute position of token in file. */ pos_t p = (token.b - buf) + off; if ( dbmi_append_token_pos(dbi, &token, p) < 0 ) return -1; result ++; } b = n; } /* Return total of tokens indexed. */ return result; } /* DBMI_INDEX support */ #define dbmi_max_line_len 2048 static int dbmi_key_incr(dbmi *dbi, dbmi_token *token) { int result = 0; datum content; pos_t count; /* Get key count. */ content = gdbm_fetch(KDB(dbi), * (datum *) token); count = content.dptr ? * (pos_t *) content.dptr : 0; free(content.dptr); /* Increment count */ count ++; /* Store new count. */ content.dptr = (void*) &count; content.dsize = sizeof(&count); result = gdbm_store(KDB(dbi), * (datum *) token, content, GDBM_REPLACE); /* Return 1 if new key. */ return count == 1; } static int dbmi_key_count(dbmi *dbi, char *buf, size_t buflen) { int result = 0; dbmi_token token; char *b = buf, *e = b + buflen; /* Scan for tokens and append positions from off. */ while ( dbi->token_parse(dbi, b, e, &token) ) { char *n = token.b + token.l; /* Stem token */ dbmi_token_depluralize(dbi, &token); /* Validate token. */ if ( dbmi_token_check(dbi, &token) ) { /* Total up new keys. */ result += dbmi_key_incr(dbi, &token); } b = n; } return result; } static int dbmi_key_allocate(dbmi *dbi, datum *key) { int result = 0; int npos; pos_t *pos; datum content; int i; /* Get key count. */ content = gdbm_fetch(KDB(dbi), *key); npos = * (pos_t*) content.dptr; free(content.dptr); if ( 0 ) fprintf(dbmi_err, "%lu ", (unsigned long) npos); /* Allow room to grow. */ npos = (npos * 3) / 2; /* Allocate array with empty pos slots. */ pos = malloc(sizeof(pos[0]) * npos); for ( i = 0; i < npos; i ++ ) { pos[i] = HTONL(pos_t_EMPTY); } /* Write back. */ content.dptr = (void*) pos; content.dsize = sizeof(pos[0]) * npos; result = gdbm_store(DB(dbi), *key, content, GDBM_REPLACE); /* Free array. */ free(pos); return 0; } static int dbmi_index(dbmi *dbi) /* Read lines and create index */ { int result = 0; char buf[dbmi_max_line_len]; pos_t old_pos, pos; size_t fsize; int nkeys = 0; /* Full file indexing works as follows: 1) Scan file for keys, keeping track of number cites for each key in a separate keyword count database. 2) Allcate space for each key (and 50% growing room) in the index database. 3) Destroy the old keyword count database. 4) Scan file again for keys adding cites to this index. This method reduces index file fragmentation when adding cites from scratch since space is never put on free list. */ if ( 0 ) fprintf(dbmi_err, "dbmi_index()\n"); if ( ! dbi->fp ) return -1; old_pos = ftell(dbi->fp); /* Create key database */ dbi->kfile = strcpy(malloc(strlen(dbi->ifile) + 4), dbi->ifile); strcat(dbi->kfile, ".k"); dbi->kdb = (void*) gdbm_open( (char *) dbi->kfile, 0, GDBM_NEWDB, 0600, 0); if ( ! dbi->kdb ) { if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: cannot open '%s': %s\n", dbi->kfile, gdbm_strerror(gdbm_errno)); } return -2; } { /* Really big key count cache for speed. */ int cachesize = 500; gdbm_setopt(KDB(dbi), GDBM_CACHESIZE, &cachesize, sizeof(cachesize)); } fsize = file_size(dbi->file); if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: Indexing %s (%lu bytes)...\n", dbi->file, (unsigned long) fsize); } /* Scan for key count. */ if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: Counting keys...\n"); } /* Read lines. */ fseek(dbi->fp, 0, SEEK_SET); nkeys = 0; while ( pos = ftell(dbi->fp), fgets(buf, dbmi_max_line_len, dbi->fp) ) { if ( dbi->verbose > 1 ) { fprintf(dbmi_err, "dbmi: %5g%% \t%d keys \r", (double) pos / (double) fsize * 100, nkeys); fflush(dbmi_err); } /* Fold case */ if ( dbi->token_foldcase ) { dbmi_foldcase(buf, strchr(buf, '\0')); } /* Index tokens in each line. */ nkeys += dbmi_key_count(dbi, buf, strlen(buf)); } if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: %d keys \n", nkeys); } /* Allocate slots for each key. */ if ( dbi->verbose ) { gdbm_sync(KDB(dbi)); fprintf(dbmi_err, "dbmi: Keyword count db %s (%lu bytes)\n", dbi->kfile, (unsigned long) file_size(dbi->kfile)); fprintf(dbmi_err, "dbmi: Allocating keys...\n"); } { datum key, next_key; int i = 0; /* Scan key count db. */ for ( key = gdbm_firstkey(KDB(dbi)); key.dptr; next_key = gdbm_nextkey(KDB(dbi), key), free(key.dptr), key = next_key ) { if ( dbi->verbose > 1 ) { fprintf(dbmi_err, "dbmi: %5g%% \r", (double) i / (double) nkeys * 100); fflush(dbmi_err); } dbmi_key_allocate(dbi, &key); ++ i; } if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: %d unique keys \n", nkeys); } /* Close and delete key count db. */ gdbm_close(KDB(dbi)); dbi->kdb = 0; unlink(dbi->kfile); free(dbi->kfile); dbi->kfile = 0; } /* Scan adding references. */ if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: Adding cites...\n"); } fseek(dbi->fp, 0, SEEK_SET); nkeys = 0; while ( pos = ftell(dbi->fp), fgets(buf, dbmi_max_line_len, dbi->fp) ) { int count; if ( dbi->verbose > 1 ) { fprintf(dbmi_err, "dbmi: %5g%% \t %lu cites \r", (double) pos / (double) fsize * 100, (unsigned long) nkeys); fflush(dbmi_err); } /* Fold case */ if ( dbi->token_foldcase ) { dbmi_foldcase(buf, strchr(buf, '\0')); } /* Index tokens in each line. */ if ( (count = dbmi_index_buf(dbi, buf, strlen(buf), pos)) < 0 ) { result = -1; break; } /* Total up number of keys. */ nkeys += count; } if ( dbi->verbose ) fprintf(dbmi_err, "dbmi: %lu cites \n", (unsigned long) nkeys); #if 0 /* Reorganize token database. */ if ( dbi->verbose ) fprintf(dbmi_err, "dbmi: Reorganizing...\r"); gdbm_reorganize(DB(dbi)); #endif /* Flush pending writes. */ dbmi_flush(dbi); if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: Index %s (%lu bytes)q\n", dbi->ifile, (unsigned long) file_size(dbi->ifile)); } if ( dbi->verbose ) fprintf(dbmi_err, "dbmi: done. \n"); /* Restore old fp pos */ fseek(dbi->fp, old_pos, SEEK_SET); if ( 0 ) fprintf(dbmi_err, "dbmi_index(): returning to %lu\n", (unsigned long) old_pos); return result; } int dbmi_dump_key(dbmi *dbi, dbmi_token *token, FILE *out) { int npos; pos_t *pos; token->pos = 0; npos = dbmi_token_pos(dbi, token, &pos); if ( npos < 0 ) return npos; fwrite(token->b, token->l, 1, out); fprintf(out, "\t"); { int i; for ( i = 0; i < npos; i ++ ) { fprintf(out, "%lu ", (unsigned long) pos[i]); } } fprintf(out, "\n"); if ( pos ) free(pos); return npos; } int dbmi_dump(dbmi *dbi, const char *tok, FILE *out) { int result = 0; dbmi_token token; int nkeys = 0, ncites = 0; if ( ! DB(dbi) ) return -1; token.t = ~0; if ( tok && *tok ) { char *tok_copy = 0; token.b = (char*) tok; token.l = strlen(tok); #if 0 if ( ! dbi->token_plural ) { tok_copy = malloc(sizeof(tok_copy[0]) * token.l); token.b = strcpy(tok_copy, token.b); dbmi_token_depluralize(dbi, &token); } #endif if ( dbmi_token_check(dbi, &token) ) { result = dbmi_dump_key(dbi, &token, out) >= 0; } if ( tok_copy ) { free(tok_copy); } } else { datum key, next_key; for ( key = gdbm_firstkey(DB(dbi)); key.dptr; next_key = gdbm_nextkey(DB(dbi), key), free(key.dptr), key = next_key ) { int npos; token.b = key.dptr; token.l = key.dsize; npos = dbmi_dump_key(dbi, &token, out); if ( npos >= 0 ) { ncites += npos; nkeys ++; } } fprintf(out, "\tnkeys %d ncites %d\n", nkeys, ncites); } return result; } static int token_npos_cmp(const void *a, const void *b) { int diff; /* Compare count in reverse order. */ if ( (diff = ((const dbmi_token*) b)->npos - ((const dbmi_token*) a)->npos) ) return diff; /* Compare token lexically. */ diff = ((const dbmi_token*) a)->l < ((const dbmi_token*) b)->l ? ((const dbmi_token*) a)->l : ((const dbmi_token*) b)->l; if ( (diff = strncmp(((const dbmi_token*) a)->b, ((const dbmi_token*) b)->b, diff)) ) return diff; return ((const dbmi_token*) a)->l - ((const dbmi_token*) b)->l; } static int token_npos_sort(dbmi_token *tok, int ntok) { qsort(tok, ntok, sizeof(tok[0]), token_npos_cmp); return 0; } static const char *bstrstr( const char *ab, const char *ae, const char *bb, const char *be) { while ( ab != ae ) { const char *am = ab; const char *bm = bb; const char *cm = ab + 1; /* Location of next first bb char in b search. */ int cm_okay = 1; while ( 1 ) { if ( bm == be ) return ab; /* At end of b, must have matched at ab! */ if ( am == ae ) break; /* At end of a, and no match break. */ /* Keep track of next first b char. */ if ( *am == *bb && am > cm && cm_okay ) { cm = am; cm_okay = 0; } if ( *am != *bm ) goto next; /* No match */ ++ bm; ++ am; } next: /* Did we find the first bb in a while matching b? */ ab = cm; /* Try next char in a. */ } /* Got to end of a, no match. */ return ab; } int dbmi_histogram(dbmi *dbi, char *query, FILE *out) { int result = 0; dbmi_token qt; /* Make sure the index is up to date. */ _dbmi_mtime_check(dbi); if ( ! DB(dbi) ) { if ( dbi->verbose ) fprintf(dbmi_err, "dbmi_histogram(): no db\n"); return -1; } if ( ! dbi->fp ) { if ( dbi->verbose ) fprintf(dbmi_err, "dbmi_histogram(): no fp\n"); return -2; } if ( ! query ) query = ""; qt.b = query; qt.l = strlen(query); /* Fold case. */ if ( dbi->token_foldcase ) { dbmi_foldcase(qt.b, qt.b + qt.l); } /* Stem token. */ dbmi_token_depluralize(dbi, &qt); if ( dbi->debug ) fprintf(dbmi_err, "dbmi_histogram(): query '%s'\n", qt.b); { int i; int nkeys = 0, ncites = 0; datum key, next_key; int ntokens = 0; dbmi_token *tokens = malloc(0); int free_key = 0; for ( key = gdbm_firstkey(DB(dbi)); key.dptr; next_key = gdbm_nextkey(DB(dbi), key), (free_key ? (free(key.dptr), 0) : 0), key = next_key ) { char *ke = key.dptr + key.dsize; free_key = 0; if ( (! *query) || bstrstr(key.dptr, ke, qt.b, qt.b + qt.l) != ke ) { tokens = realloc(tokens, sizeof(tokens[0]) * (ntokens + 1)); tokens[ntokens].b = key.dptr; tokens[ntokens].l = key.dsize; tokens[ntokens].pos = 0; dbmi_token_get(&tokens[ntokens], dbi, 0); ++ ntokens; ncites += tokens->npos; ++ nkeys; } else { free_key = 1; } } /* Sort tokens by npos */ token_npos_sort(tokens, ntokens); for ( i = 0; i < ntokens; ++ i ) { dbmi_token *token = tokens + i; fwrite(token->b, token->l, 1, out); fprintf(out, "\t%lu\n", (unsigned long) token->npos); } fprintf(out, "\tnkeys %d ncites %d\n", nkeys, ncites); /* Free tokens */ for ( i = 0; i < ntokens; ++ i ) { dbmi_token *token = tokens + i; free(token->b); free(token->pos); } free(tokens); } return result; } /*********************************************************************/ const char *dbmi_suffix = ".i"; const char *dbmi_csuffix = ".cfg"; char *dbmi_file(const char *file, char *ifile) { strcpy(ifile, file); strcat(ifile, dbmi_suffix); return ifile; } char *dbmi_cfile(const char *file, char *cfile) { strcpy(cfile, file); strcat(cfile, dbmi_csuffix); return cfile; } /* High-level interface */ int _dbmi_open(dbmi *dbi); int dbmi_open(dbmi **dbip, const char *file, const char *ifile, int flags, int mode) { dbmi *dbi = 0; const char *cfile = 0; char _ifile[1024]; char _cfile[1024]; assert(dbip); assert(file && file[0]); /* Verbose/debug stream. */ if ( ! dbmi_err ) { dbmi_err = stderr; } /* Initialization invariants */ #define OFFSETOF(T,E) ((size_t)(&(((T*)0)->E))) /* Make sure dbmi_token is superclass of datum. */ assert(OFFSETOF(datum, dptr) == OFFSETOF(dbmi_token, b)); assert(OFFSETOF(datum, dsize) == OFFSETOF(dbmi_token, l)); #undef OFFSETOF /* Compute ifile name if needed. */ if ( ! (ifile && *ifile) ) { dbmi_file(file, _ifile); ifile = _ifile; } /* Compute cfile name if needed. */ if ( ! (cfile && *cfile) ) { dbmi_cfile(ifile, _cfile); cfile = _cfile; } /* Create dbi object. */ /* Default open as QUERY. */ if ( flags <= 0 ) flags = dbmi_QUERY; /* Default file creation mode. */ if ( mode <= 0 ) mode = 0644; dbi = malloc(sizeof(*dbi)); memset(dbi, 0, sizeof(*dbi)); dbi->file = strcpy(malloc(strlen(file) + 1), file); dbi->ifile = strcpy(malloc(strlen(ifile) + 1), ifile); dbi->cfile = strcpy(malloc(strlen(cfile) + 1), cfile); dbi->flags = flags; dbi->mode = mode; /* Defaults */ dbi->index_enabled = dbmi_index_enabled; dbi->verbose = dbmi_verbose; dbi->debug = dbmi_debug; dbi->token_parse = dbmi_token_parse; dbi->token_foldcase = dbmi_token_foldcase; dbi->token_plural = dbmi_token_plural; dbi->token_min_length = dbmi_token_min_length; dbi->token_mask = dbmi_token_mask; dbmi_set_token_exclude(dbi, dbmi_token_exclude, -1); dbi->token_parse = dbmi_token_parse; dbi->mtime_check = dbmi_mtime_check; dbi->index_lock = dbmi_index_lock; dbi->retry_index_open = dbmi_retry_index_open; /* Open file and ifile. */ if ( _dbmi_open(dbi) < 0 ) { /* Cannot open. */ /* Free handle. */ dbmi_close(dbi); /* Return error. */ *dbip = 0; return -1; } /* Create index? */ if ( dbi->flags & dbmi_INDEX ) { dbmi_index(dbi); } /* Return handle. */ *dbip = dbi; /* Okay. */ return 0; } int dbmi_set_option(dbmi *dbi, int option, int value) { switch ( option ) { case dbmi_NOINDEX: dbi->index_enabled = ! option; break; default: if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: file '%s': cannot set option '%d' to '%d'\n", dbi->file, option, value); } return -1; break; } /* Okay. */ return 0; } int _dbmi_config_write(dbmi *dbi, int force) { if ( force || (dbi->flags & (dbmi_CREATE | dbmi_INDEX)) ) { FILE *fp; int i; if ( ! (fp = fopen(dbi->cfile, "w")) ) { if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: cannot write '%s'\n", dbi->cfile); } return -1; } fprintf(fp, "version 1.0\n"); #if 0 fprintf(fp, "index_enabled %d\n", dbi->index_enabled); #endif fprintf(fp, "foldcase %d\n", dbi->token_foldcase); fprintf(fp, "plural %d\n", dbi->token_plural); fprintf(fp, "minlength %d\n", dbi->token_min_length); fprintf(fp, "tokenmask %d\n", dbi->token_mask); fprintf(fp, "exclude\n"); for ( i = 0; dbi->token_exclude[i].b; ++ i ) { if ( dbi->token_exclude[i].l ) { fprintf(fp, "%s\n", dbi->token_exclude[i].b); } } fprintf(fp, "\n"); fclose(fp); } return 0; } int _dbmi_config_read(dbmi *dbi) { size_t bufsize; char *buf; FILE *fp; if ( ! (fp = fopen(dbi->cfile, "r")) ) { if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: cannot read '%s'\n", dbi->cfile); } return -1; } /* Predetermine configuration buffer size. */ bufsize = file_size(dbi->cfile); buf = malloc(bufsize + 1); /* Read config file. */ bufsize = fread(buf, 1, bufsize, fp); buf[bufsize] = 0; fclose(fp); /* Keep reference of configuration buffer for free in dbmi_close() */ dbi->c_buf = buf; { char *b = buf, *e = buf + bufsize; int i, l; dbmi_token *token; while ( b != e ) { char *tb, *te; /* key */ char *vb, *ve; /* value */ /* Get key. */ tb = b; while ( tb != e && isspace(*tb) ) ++ tb; te = tb; while ( te != e ) { if ( isspace(*te) ) { *(te ++) = '\0'; break; } ++ te; } /* Get value. */ vb = te; while ( vb != e && isspace(*vb) ) ++ vb; ve = vb; while ( ve != e && ! isspace(*ve) ) ++ ve; switch ( isupper(*tb) ? tolower(*tb) : *tb ) { default: fprintf(dbmi_err, "dbmi: WARNING: unknown config token '%s' in '%s'\n", tb, dbi->cfile); break; case '\0': /* BUG?? */ break; #if 0 case 'i': /* index_enabled */ *(ve ++) = '\0'; if ( 0 ) fprintf(dbmi_err, "dbmi: config: '%s' '%s'\n", tb, vb); dbi->index_enabled = atoi(vb); break; #endif case 'v': /* version */ break; case 'f': /* foldcase */ *(ve ++) = '\0'; if ( 0 ) fprintf(dbmi_err, "dbmi: config: '%s' '%s'\n", tb, vb); dbi->token_foldcase = atoi(vb); break; case 'p': /* plural */ *(ve ++) = '\0'; if ( 0 ) fprintf(dbmi_err, "dbmi: config: '%s' '%s'\n", tb, vb); dbi->token_plural = atoi(vb); break; case 'm': /* minlength */ *(ve ++) = '\0'; if ( dbi->debug ) fprintf(dbmi_err, "dbmi: config: '%s' '%s'\n", tb, vb); dbi->token_min_length = atoi(vb); break; case 't': /* tokenmask */ *(ve ++) = '\0'; if ( dbi->debug ) fprintf(dbmi_err, "dbmi: config: '%s' '%s'\n", tb, vb); dbi->token_mask = atoi(vb); break; case 'e': /* exclude */ dbi->token_exclude = malloc(0); dbi->token_exclude_len = 0; /* Skip to next line. */ vb = te; while ( vb != e ) { if ( *vb == '\n' ) { ++ vb; break; } ++ vb; } i = l = 0; while ( vb != e && *vb != '\n' ) { /* Get each word on a line. */ while ( vb != e && isspace(*vb) ) { ++ vb; } ve = vb; /* Find end of word. */ while ( ve != e ) { if ( isspace(*ve) ) { l ++; dbi->token_exclude = realloc(dbi->token_exclude, sizeof(dbi->token_exclude[0]) * (l + 2)); token = dbi->token_exclude + (i ++); *ve = '\0'; if ( dbi->token_foldcase ) { dbmi_foldcase(vb, ve); } if ( dbi->debug ) fprintf(dbmi_err, "dbmi: config: 'exclude' '%s'\n", vb); token->b = vb; token->l = ve - vb; token->t = dbmi_token_WORD; ve ++; /* skip null-term. */ break; } ++ ve; } vb = ve; } /* Terminate array for auto-sorting. */ if ( l ) { token[1].b = ""; token[1].l = 0; token[1].t = dbmi_token_WORD; token[2].b = 0; token[2].l = 0; token[3].t = 0; /* Sort exclude list. */ dbmi_set_token_exclude(dbi, dbi->token_exclude, -1); } else { free(dbi->token_exclude); dbi->token_exclude = dbmi_token_exclude; } } /* Next token value pair. */ b = ve; } } /* Okay. */ return 0; } int _dbmi_open_index(dbmi *dbi) { int result = 0; /* Open the index database, if not opened. */ if ( ! DB(dbi) ) { /* Don't bother if the index is not enabled. */ if ( ! dbi->index_enabled ) { return 0; } /* Attempt to open the database. */ dbi->db = (void*) gdbm_open((char *) dbi->ifile, 0, dbi->db_flags, dbi->mode, 0); /* The index open failed. */ if ( ! DB(dbi) ) { /* Is this index not to be retried later? */ if ( ! dbi->retry_index_open ) { /* Print an error message. */ if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: cannot open '%s': %s\n", dbi->ifile, gdbm_strerror(gdbm_errno)); } dbi->errors ++; result = -1; return result; } } else { /* Get index's modification time. */ dbi->db_mtime = file_mtime(dbi->ifile); /* Big cache */ if ( dbi->flags & (dbmi_CREATE|dbmi_INDEX) ) { int cachesize = 100; gdbm_setopt(DB(dbi), GDBM_CACHESIZE, &cachesize, sizeof(cachesize)); } /* Other options. */ { int opt; #ifdef GDBM_CENTFREE opt = dbmi_centfree; gdbm_setopt(DB(dbi), GDBM_CENTFREE, &opt, sizeof(opt)); #endif #ifdef GDBM_COALESCEBLKS opt = dbmi_coalesceblks; gdbm_setopt(DB(dbi), GDBM_COALESCEBLKS, &opt, sizeof(opt)); #endif } } } return result; } int _dbmi_open(dbmi *dbi) { int result = 0; /* Okay. */ int do_chmod = 0; dbi->errors = 0; /* Determine open flags. */ switch ( dbi->flags & dbmi_FLAGS ) { case dbmi_CREATE: dbi->fp_flags = "w"; /* Truncate file. */ dbi->db_flags = GDBM_NEWDB; /* New index. */ do_chmod = 1; break; case dbmi_INDEX: dbi->fp_flags = "r"; /* Read file. */ dbi->db_flags = GDBM_NEWDB; /* New index. */ break; case dbmi_APPEND: dbi->fp_flags = "a"; /* Append/create file. */ dbi->db_flags = GDBM_WRCREAT; /* Append/create index. */ break; case dbmi_QUERY: dbi->fp_flags = "r"; /* Read file. */ dbi->db_flags = GDBM_READER; /* Read index. */ break; default: fprintf(dbmi_err, "dbmi: invalid open flag: %d", dbi->flags); return -1; break; } /* Read any existing configuration. */ if ( _dbmi_config_read(dbi) < 0 ) { /* Couldn't read config, write one now. */ if ( _dbmi_config_write(dbi, 1) >= 0 ) { if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: created '%s'\n", dbi->cfile); } } } #ifdef GDBM_FAST dbi->db_flags |= GDBM_FAST; #endif /* Index database lock? */ if ( (dbi->flags & dbmi_NOLOCK) || ! dbi->index_lock ) { #ifdef GDBM_NOLOCK dbi->db_flags |= GDBM_NOLOCK; #endif } /* Disabled index? */ if ( (dbi->flags & dbmi_NOINDEX) ) { dbi->index_enabled = 0; } /* Open the indexed file. */ /* if file doesn't exist, attempt to chmod it after creation. */ if ( ! dbi->file ) { if ( file_mtime(dbi->file) != 0 ) { do_chmod = 0; } dbi->fp = fopen(dbi->file, dbi->fp_flags /*, dbi->mode */); if ( ! dbi->fp ) { if ( dbi->verbose ) { fprintf(dbmi_err, "dbmi: cannot open '%s': errno %d\n", dbi->file, errno); } dbi->errors ++; result = -2; } else { if ( do_chmod ) { chmod(dbi->file, dbi->mode); } } } if ( ! dbi->fp ) return result; /* Error! */ dbi->fp_mtime = file_mtime(dbi->file); /* Open the index file. */ if ( _dbmi_open_index(dbi) ) { result = -3; } /* Big cache */ if ( DB(dbi) ) { if ( dbi->flags & (dbmi_CREATE|dbmi_INDEX) ) { int cachesize = 10000; gdbm_setopt(DB(dbi), GDBM_CACHESIZE, &cachesize, sizeof(cachesize)); } /* Other options. */ { int opt; #ifdef GDBM_CENTFREE opt = 1; gdbm_setopt(DB(dbi), GDBM_CENTFREE, &opt, sizeof(opt)); #endif #ifdef GDBM_COALESCEBLKS opt = 1; gdbm_setopt(DB(dbi), GDBM_COALESCEBLKS, &opt, sizeof(opt)); #endif } } } /* OK if file and index could be opened. */ if ( 0 ) fprintf(dbmi_err, "_dbmi_open(): return(%d)\n", result); return result; } int _dbmi_close(dbmi *dbi) { /* Flush pending writes. */ dbmi_flush(dbi); /* Close file. */ if ( dbi->fp ) { if ( fclose(dbi->fp) ) dbi->errors ++; dbi->fp = 0; } /* Close index after file so index->mtime >= file->mtime. */ if ( DB(dbi) ) { gdbm_close(DB(dbi)); dbi->db = 0; } /* Close k index after file so index->mtime >= file->mtime. */ if ( KDB(dbi) ) { gdbm_close(KDB(dbi)); dbi->kdb = 0; } return dbi->errors; } int dbmi_reopen(dbmi *dbi) { _dbmi_close(dbi); return _dbmi_open(dbi); } int dbmi_close(dbmi *dbi) { int result = 0; if ( ! dbi ) return -1; result = _dbmi_close(dbi); if ( dbi->c_buf ) { if ( dbi->token_exclude != dbmi_token_exclude_default ) { free(dbi->token_exclude); } free(dbi->c_buf); dbi->c_buf = 0; } free(dbi->cfile); dbi->cfile = 0; free(dbi->ifile); dbi->ifile = 0; free(dbi->file); dbi->file = 0; if ( dbi->kfile ) { free(dbi->kfile); dbi->kfile = 0; } free(dbi); return result; } int dbmi_flush(dbmi *dbi) { if ( ! dbi ) return -1; /* Write config file if necessary. */ _dbmi_config_write(dbi, 0); /* Flush file. */ if ( dbi->fp ) { if ( fflush(dbi->fp) ) dbi->errors = errno; } /* Flush index. */ if ( DB(dbi) ) { gdbm_sync(DB(dbi)); /* Force the file's mtime to be updated. */ if ( dbi->mtime_check ) { if ( file_touch(dbi->ifile) < 0 ) { fprintf(dbmi_err, "dbmi: cannot touch '%s'\n", dbi->ifile); } } } return 0; } static int _dbmi_mtime_check(dbmi *dbi) { int result = 0; /* ** Check index mtime against data file mtime. ** Reindex data file if index is older than data file. */ if ( dbi->mtime_check && dbi->index_enabled && ! (dbi->flags & (dbmi_INDEX)) && (! DB(dbi) || dbi->fp_mtime > dbi->db_mtime) ) { int old_flags = dbi->flags; int old_mtime_check = dbi->mtime_check; /* Temporarily reopen for indexing. */ dbi->flags &= ~dbmi_FLAGS; dbi->flags |= dbmi_INDEX; dbi->mtime_check = 0; /* If reopen under new mode fails, reopen as old mode. */ if ( ! dbmi_reopen(dbi) ) { result = dbmi_index(dbi); } else { if ( dbi->verbose ) fprintf(dbmi_err, "dbmi: reopen '%s' for INDEX failed\n", dbi->file); dbi->errors ++; } /* Reopen in old mode. */ dbi->flags = old_flags; dbi->mtime_check = old_mtime_check; dbmi_reopen(dbi); } return result; } int dbmi_append(dbmi *dbi, const char *buf, size_t buflen, int addnewline) { int result = 0; char *buf_copy = 0; pos_t pos; if ( ! buflen ) return 0; if ( ! buf ) return -1; /* Make sure the index is up to date. */ _dbmi_mtime_check(dbi); /* Where are we in the file? */ pos = ftell(dbi->fp); if ( 0 ) fprintf(dbmi_err, "append pos = %lu\n", (unsigned long) pos); /* Write to file. */ buflen = fwrite(buf, 1, buflen, dbi->fp); /* Give up if fwrite failed. */ if ( buflen <= 0 ) { dbi->errors ++; return -2; } /* Append a newline if requested. */ if ( addnewline ) { putc('\n', dbi->fp); } /* Don't bother if the index not enabled. */ if ( ! dbi->index_enabled ) return 0; /* If the index is not open, */ if ( ! DB(dbi) ) { /* Attempt to retry opening the index. */ if ( ! dbi->retry_index_open ) { return -3; } else { /* Try reopening */ _dbmi_open_index(dbi); if ( ! DB(dbi) ) { /* Give up. */ return 0; } } } /* Don't bother if we don't have a index open. */ if ( ! dbi->index_enabled ) return 0; if ( ! DB(dbi) ) return -3; /* Fold case if needed. */ if ( dbi->token_foldcase ) { buf_copy = malloc(buflen); memcpy(buf_copy, buf, buflen); dbmi_foldcase(buf_copy, buf_copy + buflen + 1); buf = buf_copy; } /* Index all tokens in buf. */ result = dbmi_index_buf(dbi, (char *) buf, buflen, pos); /* Free case-folded buf. */ if ( buf_copy ) free(buf_copy); /* Don't attempt to auto reindex again. */ dbi->db_mtime = dbi->fp_mtime; return result; } static int pos_t_cmp(const void *a, const void *b) { return * (const pos_t*) a - * (const pos_t *) b; } static int pos_t_sort(pos_t *pos, int npos) { qsort(pos, npos, sizeof(pos[0]), pos_t_cmp); return 0; } static const char *match_str( const char *sb, const char *se, /* String to search. */ const char *mb, const char *me /* String to match in [sb,se). */ ) { /* Loop through src string. */ while ( sb != se ) { const char *nm = 0; const char *ss = sb; const char *mm = mb; /* Try to match each [mb,me) against each [ss,se). */ while ( mm != me ) { /* Reached end of s, try next sb. */ if ( ss == se ) { goto no_match; } /* Element doesn't match, try next sb. */ if ( *ss != *mm ) { goto no_match; } /* Try next m and s. */ ++ ss; ++ mm; /* Keep track of next location where ss == mb[0] */ /* Example: ** s = "abcdabcqs" ** m = "abcde" ** nm = s + 4 ("abcqs") */ if ( *ss == *mb && ! nm ) { nm = ss; } } /* MATCHED! */ return sb; no_match: /* Not matched: try next s where it might match. */ if ( nm ) { sb = nm; } else { ++ sb; } } return sb; } int dbmi_query_proc(dbmi *dbi, char **query, int nquery, int (*proc) (char *b, char *e, pos_t pos, void *data), void *data) { int result = 0; int npos = 0; pos_t *pos = malloc(0); int i; pos_t save_pos; /* Make sure the index is up to date. */ _dbmi_mtime_check(dbi); if ( ! DB(dbi) ) { if ( dbi->verbose ) fprintf(dbmi_err, "dbmi_query(): no db\n"); return -1; } if ( ! dbi->fp ) { if ( dbi->verbose ) fprintf(dbmi_err, "dbmi_query(): no fp\n"); return -2; } /* Remember current pos. */ save_pos = ftell(dbi->fp); /* Get all positions for all querys. */ for ( i = 0; i < nquery; ++ i ) { dbmi_token token; char *b = query[i], *e = strchr(b, '\0'); /* Scan for tokens to search for */ while ( dbi->token_parse(dbi, b, e, &token) ) { char *n = token.b + token.l; /* Parse possible query strings from each query. */ dbmi_token_depluralize(dbi, &token); /* Fold case? */ if ( dbi->token_foldcase ) { dbmi_foldcase(token.b, token.b + token.l); } /* Valid token? */ if ( dbmi_token_check(dbi, &token) ) { int t_npos; pos_t *t_pos; if ( 0 ) { fprintf(stderr, "dbmi_query: token '"); fwrite(token.b, 1, token.l, stderr); fprintf(stderr, "'\n"); } /* Get list of file positions for token. */ t_npos = dbmi_token_pos(dbi, &token, &t_pos); /* Append token positions to pos list. */ if ( t_npos > 0 ) { pos = realloc(pos, sizeof(pos[0]) * (npos + t_npos)); memcpy(pos + npos, t_pos, sizeof(pos[0]) * t_npos); npos += t_npos; free(t_pos); } } /* Find next token in query[i] */ b = n; } } /* Sort the position list. */ if ( 0 ) { fprintf(stderr, "dbmi_query: npos = %ld\n", (long) npos); } pos_t_sort(pos, npos); /* Apply proc to each line once for all positions within the line. */ { int i; pos_t line_pos = -1; pos_t pos_last = -1; for ( i = 0; i < npos; ++ i ) { char *lb, *le; size_t len; pos_t new_line_pos; /* Avoid duplicate keywords. */ if ( pos_last != pos[i] ) { pos_last = pos[i]; /* Get the line at the pos. */ lb = FILE_get_line_at_pos(dbi->fp, 1024, pos[i], &len, &new_line_pos); if ( lb ) { le = lb + len; /* Is it a new line? */ if ( line_pos != new_line_pos ) { int j; char *lb_folded = 0; char *lmb, *lme; /* Line to match against. */ /* Fold case for match? */ if ( dbi->token_foldcase ) { /* Make a copy of the line buffer and fold case it. */ lb_folded = malloc(sizeof(lb_folded[0]) * (len + 1)); memcpy(lb_folded, lb, sizeof(lb_folded[0]) * len); dbmi_foldcase(lb_folded, lb_folded + len); lmb = lb_folded; } else { lb_folded = 0; lmb = lb; } lme = lmb + len; line_pos = new_line_pos; /* If any of the query strings match, apply proc to the line. */ for ( j = 0; j < nquery; ++ j ) { if ( match_str(lmb, lme, query[j], strchr(query[j], '\0')) != lme ) { int proc_result; proc_result = proc(lb, le, line_pos, data); if ( proc_result ) { result = proc_result; } /* Got a match, so don't bother with other query strings. */ break; } } /* Free the casefolded line buffer. */ if ( lb_folded ) free(lb_folded); } /* Free the line buffer. */ free(lb); } else { /* Couldn't find the line at pos[i]. */ result = -1; } } /* Next token position. */ } } /* Free sorted position list. */ free(pos); /* Restore current pos. */ fseek(dbi->fp, save_pos, SEEK_SET); return result; } static int dbmi_query_print(char *b, char *e, pos_t pos, void *data) { fprintf((FILE*) data, "%lu\t", (unsigned long) pos); fwrite(b, sizeof(*b), e - b, (FILE*) data); return 0; } int dbmi_query(dbmi *dbi, char **query, int nquery, FILE *out) { return dbmi_query_proc(dbi, query, nquery, dbmi_query_print, (void*) out); } dbmi0.1/src/dbmi/dbmi.h0100644000175200017560000001153007236174652015253 0ustar stephensstepheng#ifndef _dbmi_dbmi_h #define _dbmi_dbmi_h /* $Id: dbmi.h,v 1.4 2001/02/01 05:52:42 stephens Exp $ */ #ifdef __cplusplus extern "C" { #endif #include "util/file.h" /* pos_t */ #include /* Token types. */ typedef enum dbmi_token_t { dbmi_token_NONE = 0, dbmi_token_WORD = 1, dbmi_token_NUMBER = 2 } dbmi_token_t; /* Token type. */ typedef struct dbmi_token { /* WARNING!!!! First two fields must match struct datum layout! */ char *b; size_t l; dbmi_token_t t; /* Token type. */ pos_t *pos; /* Positions it occurs in. */ size_t npos; /* Times it occurs. */ size_t spos; /* Size of pos array. */ } dbmi_token; /* Indexed file handle. */ struct dbmi; typedef struct dbmi dbmi; /* Token parsing function declaration. */ #define dbmi_token_parse_DECL(X) \ dbmi_token_t X (dbmi *dbi, const char *b, const char *e, dbmi_token *token) /* Default options. */ extern int dbmi_index_enabled; /* 1 */ extern dbmi_token *dbmi_token_exclude; /* Default token exclusion list. */ extern int dbmi_verbose; /* 0 */ extern int dbmi_debug; /* 0 */ extern const char *dbmi_suffix; /* ".i" */ extern int dbmi_token_foldcase; /* 1 */ extern int dbmi_token_plural; /* 1 */ extern int dbmi_token_min_length; /* 3 */ extern int dbmi_token_mask; /* token_WORD */ extern int dbmi_mtime_check; /* 0 */ extern int dbmi_index_lock; /* 0 */ extern int dbmi_centfree; /* 1 */ extern int dbmi_coalesceblks; /* 0 */ extern int dbmi_retry_index_open; /* 0 */ typedef dbmi_token_parse_DECL((*dbmi_token_parse_t)); extern dbmi_token_parse_t dbmi_token_parse; /* Handle flags. */ enum dbmi_flags { /* dbmi_open() flags. */ dbmi_CREATE = 1, /* Create a new data and index file. */ dbmi_INDEX = 2, /* Create a new index from an existing data file. */ dbmi_APPEND = 4, /* Append lines to existing data/index file. */ dbmi_QUERY = 8, /* Query an existing data/index file. */ dbmi_FLAGS = (dbmi_QUERY * 2) - 1, /* Optional flags. */ dbmi_NOLOCK = 16, /* Do not lock the index database. */ dbmi_NOINDEX = 32 /* Do not use the index. */ }; /* Handle declaration. */ struct dbmi { char *file; /* Indexed file name. */ char *ifile; /* Index database file name. (defaults to file + dbmi_suffix) */ char *cfile; /* Config file name. (defaults to file + dbmi_suffix + ".cfg")*/ int flags; /* See enum dbmi_flags. */ int mode; /* chmod() */ int verbose; /* Verbose messages to dbmi_err? */ int debug; /* Debug messages to dbmi_err? */ int errors; /* Any errors occurred? */ void *user; /* Opaque user hook. */ /* Options. */ int index_enabled; /* Indexing enabled. */ dbmi_token_parse_t token_parse; /* Token parsing routine. */ int token_foldcase; /* Fold tokens to lower case? */ int token_plural; /* Allow plural tokens? */ int token_min_length; /* Mininum token length? */ dbmi_token_t token_mask; /* Mask of tokens to index? */ dbmi_token *token_exclude; /* Tokens to exclude from index. */ int token_exclude_len; /* Length of token_exclude. */ int mtime_check; /* Check to make sure index is up to date on dbmi_append(), dbmi_query(), etc. */ int index_lock; /* Lock the index. */ int retry_index_open; /* Indexed file */ FILE *fp; const char *fp_flags; long fp_mtime; /* Modification time of fp. */ /* Index database */ void *db; /* opaque database handle (GDBM_FILE) */ void *kdb; /* keyword count database (used only during DBMI_INDEX) */ char *kfile; int db_flags; long db_mtime; /* Modification time of db. */ /* Config file. */ const char *c_flags; char *c_buf; }; /* Open an indexed file handle. */ int dbmi_open(dbmi **dbip, const char *file, const char *ifile, int flags, int mode); /* Reopen an indexed file handle. */ int dbmi_reopen(dbmi *dbi); /* Append an indexed line to the file. */ int dbmi_append(dbmi *dbi, const char *buf, size_t buflen, int appendnewline); /* Get a list of file position for a token. */ int dbmi_token_pos(dbmi *dbi, dbmi_token *t, pos_t **posp); /* Dump the index database. */ int dbmi_dump(dbmi *dbi, const char *token, FILE *out); /* Create a histogram of tokens from most frequent to least frequent. */ int dbmi_histogram(dbmi *dbi, char *query, FILE *out); /* Call proc for each line than matches querys. */ int dbmi_query_proc(dbmi *dbi, char **query, int nquery, int (*proc) (char *b, char *e, pos_t pos, void *data), void *data); /* Print all lines that match querys. */ int dbmi_query(dbmi *dbi, char **querys, int nquerys, FILE *out); /* Flush all cached data. */ int dbmi_flush(dbmi *dbi); /* Close the indexed file handle. */ int dbmi_close(dbmi *dbi); /* Set the excluded token. */ int dbmi_set_token_exclude(dbmi *dbi, dbmi_token *tokens, int ntoken); /* Set any options. */ int dbmi_set_option(dbmi *dbi, int option, int value); #ifdef __cplusplus } #endif #endif dbmi0.1/src/dbmi/main.c0100644000175200017560000000510107047355376015260 0ustar stephensstepheng#include #include "dbmi.h" int main(int argc, char **argv) { int argi; char mode = 0; int errors = 0; char *arg; dbmi *dbi = 0; const char *file = 0; const char *ifile = 0; if ( argc < 2 ) goto usage; dbmi_mtime_check = 1; file = argv[1]; for ( argi = 2; argi < argc; argi ++ ) { char *arg = argv[argi]; if ( *arg == '-' ) { arg ++; if ( *arg == '-' ) arg ++; mode = *arg; if ( dbi ) { dbmi_close(dbi); dbi = 0; ifile = 0; } switch ( mode ) { case 'V': dbmi_verbose ++; break; case 'D': dbmi_debug ++; break; case 'i': ifile = arg; break; case 'c': if ( dbmi_open(&dbi, file, ifile, dbmi_INDEX, 0) ) { errors ++; } break; case 'a': case 'A': if ( dbmi_open(&dbi, file, ifile, dbmi_APPEND, 0) ) { errors ++; } break; case 'd': case 'q': case 'h': if ( dbmi_open(&dbi, file, ifile, dbmi_QUERY, 0) ) { errors ++; } break; default: usage: errors ++; /* FALL THROUGH */ case '?': fprintf(stderr, "%s: USAGE\n", argv[0]); fprintf(stderr, "%s \n", argv[0]); fprintf(stderr, "OPTIONS\n" " -V\n" " Enables verbose output.\n" " -D\n" " Enables debug output.\n" " -i \n" " Specifies an index file for .\n" " -c\n" " Create an index file from .\n" " -a \n" " -A \n" " Append to file with indexing.\n" " -A appends with no newline.\n" " -d \n" " Dump an index file.\n" " If is "", dump entire index.\n" " -h \n" " Dump a histogram of all keys containing .\n" " If is "", dump entire histogram.\n" " -q +\n" " Print lines in that contain .\n" ); break; } if ( dbi && dbi->errors ) { errors ++; } } else { switch ( mode ) { case 'a': case 'A': if ( ! dbi || dbmi_append(dbi, arg, strlen(arg), mode == 'a') < 0 ) { errors ++; } break; case 'd': if ( ! dbi || dbmi_dump(dbi, arg, stdout) < 0 ) { errors ++; } break; case 'h': if ( ! dbi || dbmi_histogram(dbi, arg, stdout) < 0 ) { errors ++; } break; case 'q': { char **query; int nquery; query = argv + argi; nquery = argc - argi; if ( ! dbi || dbmi_query(dbi, query, nquery, stdout) < 0 ) { errors ++; } argi = argc; } break; default: goto usage; break; } } } if ( dbi ) dbmi_close(dbi); return errors; } dbmi0.1/src/dbmi/test.ts0100644000175200017560000000105207037242664015512 0ustar stephensstephengrun testfile -c run testfile -d "" run testfile -d "pos_t" grep -ni "pos_t" testfile run testfile -q "pos_t" "dbmi_dump" run testfile -q "pos_t pos" grep -ni "pos_t pos" testfile run testfile -a "foobar foobaz " run testfile -q "foobar" sleep 5 echo "foo bar append" >> testfile ls -lag testfile* run testfile -q "foo" run testfile -q "bar" chmod -w testfile.i; ls -lag testfile* sleep 5 echo "another foo bar append" >> testfile ls -lag testfile* run testfile -q "foo" run testfile -q "bar" chmod +w testfile.i; ls -lag testfile* run testfile -q "bar" dbmi0.1/src/maks/0040755000175200017560000000000007306140336014200 5ustar stephensstephengdbmi0.1/src/maks/CVS/0040755000175200017560000000000007262562005014635 5ustar stephensstephengdbmi0.1/src/maks/CVS/Root0100644000175200017560000000003407236675452015511 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/maks/CVS/Repository0100644000175200017560000000002207236675452016742 0ustar stephensstephenghome/ion/src/maks dbmi0.1/src/maks/CVS/Entries0100644000175200017560000000056207262562005016171 0ustar stephensstepheng/fixpound.pl/1.2/Fri Feb 19 09:26:01 1999// /tool.mak/1.7/Tue Mar 21 08:21:48 2000// /tools.mak/1.5/Thu Sep 9 04:59:21 1999// D/bin//// D/opengl//// D/os//// D/win32//// /PKG/1.2/Tue Apr 3 18:51:56 2001// /lib.mak/1.6/Tue Apr 3 18:51:56 2001// /pre.mak/1.10/Tue Apr 3 18:51:56 2001// /use.mak/1.4/Tue Apr 3 18:51:56 2001// /basic.mak/1.9/Wed Apr 4 09:09:10 2001// dbmi0.1/src/maks/PKG0100744000175200017560000000031607262415714014550 0ustar stephensstephengNAME=maks VERSION=0.2 DESC="A Makefile library. Handles automatic header file dependencies and interpackage dependencies." CATEGORY="Development Tools" REQUIRES_PKGS="../bin" REQUIRES_OTHERS="gnumake sh" dbmi0.1/src/maks/basic.mak0100744000175200017560000001046707262562266015774 0ustar stephensstepheng# $Id: basic.mak,v 1.9 2001/04/04 09:09:10 stephens Exp $ Makefile=Makefile Makefile.use=Makefile.use ########################################################################## # Suffix translation rules # SWIG SWIG.swig=swig $(SWIG_C_FILES_GEN) : $(GEN_FILE_DIR)/$(notdir %)_swig$(c) : %$(swig) $(foreach w,$(SWIG_WRAPPER),$(SWIG.swig) -$w $(SWIG_WRAPPER_$w) -o $(GEN_FILE_DIR)/$(notdir $*)_swig_$(w)$(c) $<;) touch $(GEN_FILE_DIR)/$(notdir $*)_swig$(c) # C %$(c):%$(o) $(C_O_FILES_GEN) : $(O_FILE_DIR)/$(notdir %)$(o) : %$(c) $(COMPILE.c) $< -o $(O_FILE_DIR)/$(notdir $*)$(o) $(C_GEN_O_FILES_GEN) : $(O_FILE_DIR)/%$(o) : $(GEN_FILE_DIR)/%$(c) $(COMPILE.c) $< -o $(O_FILE_DIR)/$*$(o) # C++ %$(cc):%$(o) $(CC_O_FILES_GEN) : $(O_FILE_DIR)/$(notdir %)$(o) : %$(cc) $(COMPILE.cc) $< -o $(O_FILE_DIR)/$(notdir $*)$(o) # yacc %$(y):%$(o) %$(y):%$(c) ifeq "$(strip $(MACHTYPE))" "i586-pc-cygwin32" YACC+= -S '$(CYGFS)/share/bison.simple' else YACC=bison --yacc endif $(Y_C_FILES_GEN) : $(GEN_FILE_DIR)/$(notdir %)$(c) : %.y $(CP) $*$(y) $(GEN_FILE_DIR)/$(notdir $*)$(y) cd $(GEN_FILE_DIR) && $(YACC) -d $(notdir $*)$(y) $(MV) $(GEN_FILE_DIR)/y.tab.c $(GEN_FILE_DIR)/$(notdir $*)$(c) $(MV) $(GEN_FILE_DIR)/y.tab.h $(GEN_FILE_DIR)/$(notdir $*).yh # Java ifneq "$(strip $(JAVA_FILES_ALL))" "" ifeq "$(strip $(JAVA_TIMESTAMP))" "" JAVA_TIMESTAMP=$(JAVA_CLASS_FILE_DIR)/../.jc endif $(JAVA_TIMESTAMP) : $(JAVA_FILES_ALL) '$(JAVAC)' $(JAVACFLAGS) -d $(JAVA_CLASS_FILE_DIR) $(JAVA_FILES_ALL) $(TOUCH) $@ PRODUCTS+=$(JAVA_TIMESTAMP) GARBAGE_DIRS+=$(JAVA_CLASS_FILE_DIR) endif #DIRS += $(GEN_FILE_DIR) ########################################################################## EARLY_TARGETS+= USE_ALL DIRS $(Y_C_FILES_GEN) DEPS ########################################################################## all : $(EARLY_TARGETS) $(PRODUCTS) $(TARGETS) @$(MSG) Made $@ ########################################################################## # Autodependencies # Header deps #$(O_FILES_GEN) : $(H_FILES) DEP_FILE_DIR:=$(O_FILE_DIR) make_dep = $(ECHO) "Making include deps for $<"; $(SHELL) -ec 'o="$(notdir $*)$(o)"; od="$(O_FILE_DIR)/$$o"; d="$(DEP_FILE_DIR)/$(notdir $*).d"; $(CC) -MM $(CPPFLAGS) $< | sed -e "s@$$o[ ]*:@$$od : $(Makefile) $(Makefile.use) @g" > $$d; [ -s $$d ] || rm -f $$d' C_D_FILES += $(_C_FILES_ALL:%.c=$(DEP_FILE_DIR)/$(notdir %).d) $(C_D_FILES) : $(DEP_FILE_DIR)/$(notdir %).d : %.c $(make_dep) CC_D_FILES += $(_CC_FILES_ALL:%.cc=$(DEP_FILE_DIR)/$(notdir %).d) $(CC_D_FILES) : $(DEP_FILE_DIR)/$(notdir %).d : %.cc @$(make_dep) DEPS+= $(C_D_FILES) $(CC_D_FILES) # Disable deps DEPS:= DEPS : DIRS $(DEPS) .PHONY : DEPS GARBAGE+= $(DEPS) GENERATED_DIRS+= $(DEP_FILE_DIR) GARBAGE_DIRS+= $(DEP_FILE_DIR) ifeq "$(strip $(__DISABLE_DEPS__))" "" EARLY_TARGETS+= DEPS ifneq "$(strip $(DEPS))" "" $(DEPS) : $(DEP_FILE_DIR) -include $(DEPS) endif endif ########################################################################## # Use USE_ALL : @for f in $(USE_ALL) . ; \ do \ [ "$$f" = . ] && break; \ $(ECHO) "Using '$$f'" ;\ $(MAKE) -C "$$f" > /dev/null ; \ done .PHONY : USE_ALL ########################################################################## # Directories DIRS+= $(GENERATED_DIRS) $(OUTPUT_DIRS) DIRS:=$(sort $(DIRS)) $(DIRS) : $(MKDIRS) $@ DIRS : $(DIRS) .PHONY : DIRS ########################################################################## # Clean GARBAGE += $(O_FILES_GEN) GARBAGE += $(C_FILES_GEN) GARBAGE += $(PRODUCTS) GARBAGE += core *.core #GARBAGE += *.o clean : rm -f $(filter-out .,$(sort $(GARBAGE))) rm -rf $(filer-out .,$(sort $(GARBAGE_DIRS))) @$(MSG) Made $@ cleanproducts : rm -f $(PRODUCTS) veryclean : clean rm -rf $(filter-out .,$(sort $(GENERATED_DIRS) $(GARBAGE_VERY_DIRS))) @$(MSG) Made $@ archiveclean : veryclean @$(MSG) Made $@ .PHONY : clean veryclean archiveclean cleanproducts ########################################################################## # Archive archive : tgz tgz : archiveclean pwd=`pwd`;dname=`basename $$pwd`;cd ..; $(TAR) -cvf - "$$dname" | $(GZIP) > "$$dname.tgz" .PHONY : archive tgz ######################################################################### # Variable make ifdef vm _vm : $(foreach f,$(vm), $($(f))) @$(MSG) Made $(vm): $< .PHONY : _vm endif ########################################################################## # EOF dbmi0.1/src/maks/fixpound.pl0100644000175200017560000000025406663227051016374 0ustar stephensstepheng# $Id: fixpound.pl,v 1.2 1999/02/19 09:26:01 stephensk Exp $ while ( <> ) { chop; if ( /^#/ ) { print "/* ", $_, "*/\n"; } else { print $_, "\n"; } } dbmi0.1/src/maks/lib.mak0100744000175200017560000000430607262415714015447 0ustar stephensstepheng# $Id: lib.mak,v 1.6 2001/04/03 18:42:08 stephens Exp $ # # Usage: # # LIB_NAME:= # include $(MAKS)/lib.mak # # Adds targets to create a library named LIB_NAME from LIB_O_FILES. # LIB_O_FILES defaults to O_FILES. # ############################################################## # Defaults LIB_PREFIX:=lib# LIB_SUFFIX:=.a# LIB:=$(LIB_DIR)/$(LIB_PREFIX)$(LIB_NAME)$(LIB_SUFFIX)# ifeq "$(strip $(LIB_O_FILES))" "" LIB_O_FILES:=$(O_FILES)# endif ifeq "$(strip $(LIB_LIB_FLAGS))" "" LIB_LIB_FLAGS:=$(LIB_FLAGS) endif ifeq "$(strip $(LIB_LIBS))" "" LIB_LIBS:=$(LIBS) endif ############################################################## # Target ifneq "$(strip $(LIB_DYNAMIC))" "" LIB_DLL_SUFFIX=.dll# LIB_DLL:=$(LIB_DIR)/$(LIB_NAME)$(LIB_DLL_SUFFIX)# LIB_DLL_DEF:=$(LIB_DIR)/$(LIB_NAME).def# ifneq "$(strip $(SWIG2DEF))" "" LIB_SWIG2DEF:=perl $(MAKS)/../bin/swig2def.pl $(SWIG2DEF) > $(LIB_DLL_DEF)# LIB_DEF:=--def $(LIB_DLL_DEF)# else LIB_SWIG2DEF:=true# LIB_DEF:=--output-def $(LIB_DLL_DEF)# endif $(LIB_DLL) $(LIB) : $(LIB_O_FILES) $(LIB_SWIG2DEF) dllwrap --verbose --output-lib $(LIB) $(LIB_DEF) --dllname $(LIB_DLL) $(LIB_O_FILES) $(LIB_LIB_FLAGS) $(foreach l,$(LIB_LIBS),-l'$(l)') else LIB_DLL:=# $(LIB) : $(LIB_O_FILES) -$(RM) $@ $(AR) cr $@ $(LIB_O_FILES) endif $(LIB_DLL) $(LIB) : LIB:=$(LIB) $(LIB_DLL) $(LIB) : LIB_O_FILES:=$(LIB_O_FILES) $(LIB_DLL) $(LIB) : LIB_DLL:=$(LIB_DLL) $(LIB_DLL) $(LIB) : LIB_DLL_DEF:=$(LIB_DLL_DEF) $(LIB_DLL) $(LIB) : LIB_SWIG2DEF:=$(LIB_SWIG2DEF) $(LIB_DLL) $(LIB) : LIB_DEF:=$(LIB_DEF) $(LIB_DLL) $(LIB) : LIB_LIB_FLAGS:=$(LIB_LIB_FLAGS) $(LIB_DLL) $(LIB) : LIB_LIBS:=$(LIB_LIBS) ############################################################## # Alias .PHONY : $(LIB_NAME) $(LIB_NAME) : $(LIB) ############################################################## # Exports LOCAL_LIBS:=$(LOCAL_LIBS) $(LIB)# LIB_PRODUCTS:=$(LIB_PRODUCTS) $(LIB) $(LIB_DLL)# PRODUCTS:=$(PRODUCTS) $(LIB) $(LIB_DLL)# libs :: $(LIB_PRODUCTS) @$(MSG) Made $@: $(LIB_PRODUCTS) .PHONY : libs ############################################################## # Reset vars LIB:=# LIB_NAME:=# LIB_O_FILES:=# LIB_DLL:=# SWIG2DEF:=# ############################################################## # EOF dbmi0.1/src/maks/pre.mak0100744000175200017560000001501307262415714015464 0ustar stephensstepheng# $Id: pre.mak,v 1.10 2001/03/17 20:20:04 stephens Exp $ include $(MAKS)/tools.mak ######################################################################### # Variable query ifdef v _v : @$(foreach f,$(v),$(ECHO) "$(f)='$($(f))'"; ) .PHONY : _v endif ######################################################################### # Variable make ifdef vm _vm : endif ######################################################################### # Default targets all : .PHONY : all clean ######################################################################### # Build Options ifndef DEBUG DEBUG=YES endif export DEBUG ifndef OPTIMIZE OPTIMIZE=NO endif export OPTIMIZE ######################################################################### # Disable RCS and SCCS get % : %,v % : RCS/%,v % : s.% % : SCCS/s.% %.mak : %.use : Makefile : ######################################################################### # Config CWD=$(shell pwd) export CWD ifeq "$(strip $(MAKE_ARCH))" "" MAKE_ARCH:=$(shell uname) export MAKE_ARCH endif ifeq "$(strip $(DEV_ROOT))" "" DEV_ROOT:=$(HOME) export DEV_ROOT endif #DEV_ROOT:=$(strip $(shell cd "$(DEV_ROOT)" && pwd)) ######################################################################### # Directories # libraries go in LIB_DIR ifeq "$(strip $(LIB_DIR))" "" LIB_DIR:=$(DEV_ROOT)/lib/$(MAKE_ARCH) export LIB_DIR endif OUTPUT_DIRS+= $(LIB_DIR) # executables go in TOOL_DIR ifeq "$(strip $(TOOL_DIR))" "" TOOL_DIR:=$(DEV_ROOT)/bin/$(MAKE_ARCH) export TOOL_DIR endif OUTPUT_DIRS+= $(TOOL_DIR) ifeq "$(strip $(GEN_FILE_ROOT))" "" GEN_FILE_ROOT:=mak_gen GARBAGE_VERY_DIRS:=$(GARBAGE_VERY_DIRS) $(GEN_FILE_ROOT) endif # test executables go in TEST_DIR ifeq "$(strip $(TEST_DIR))" "" TEST_DIR:=$(GEN_FILE_ROOT)/$(MAKE_ARCH)/t export TEST_DIR endif OUTPUT_DIRS+= $(TEST_DIR) # object files go in O_FILE_DIR ifeq "$(strip $(O_FILE_DIR))" "" O_FILE_DIR:=$(GEN_FILE_ROOT)/$(MAKE_ARCH)/o export O_FILE_DIR endif #VPATH:=$(VPATH) $(O_FILE_DIR)# # Java class files go in JAVA_CLASS_FILE_DIR ifeq "$(strip $(JAVA_CLASS_FILE_DIR))" "" JAVA_CLASS_FILE_DIR:=$(GEN_FILE_ROOT)/jvm export JAVA_CLASS_FILE_DIR endif ifeq "$(DEBUG)" "YES" JAVACFLAGS+=-g CFLAGS+= $(DEBUG_FLAGS) CXXFLAGS+= $(DEBUG_FLAGS) O_FILE_DIR:=$(strip $(O_FILE_DIR)d) endif ifeq "$(OPTIMIZE)" "YES" JAVACFLAGS+=-O CFLAGS+= $(OPTIMIZE_FLAGS) CXXFLAGS+= $(OPTIMIZE_FLAGS) O_FILE_DIR:=$(strip $(O_FILE_DIR)o) endif GENERATED_DIRS+= $(O_FILE_DIR) # # yacc, lex and other tools put there output in GEN_FILE_DIR ifeq "$(strip $(GEN_FILE_DIR))" "" GEN_FILE_DIR:=$(MAKE_ARCH)/g GEN_FILE_DIR:=$(O_FILE_DIR) export GEN_FILE_DIR endif GENERATED_DIRS+= $(GEN_FILE_DIR) #EARLY_TARGETS+= $(DIRS) # Expect to be using some libs generated by us LIB_DIRS+= $(LIB_DIR) ######################################################################### # Suffixes exe= o=.o c=.c cc=.cc y=.y yy=.yy h=.h hh=.h java=.java class=.class swig=.swig ######################################################################### # Default CC options OPTIMIZE_FLAGS+= -O3 DEBUG_FLAGS+= -g CFLAGS+= -Wall ######################################################################### # Target-specifics include $(MAKS)/os/$(MAKE_ARCH).mak ######################################################################### # BUILD_VARS ifndef BUILD_TARGET export BUILD_TARGET:=$(MAKE_ARCH) endif BUILD_VARS+= BUILD_TARGET ifndef BUILD_DATE export BUILD_DATE:=$(shell date) endif BUILD_VARS+= BUILD_DATE ifndef BUILD_HOST export BUILD_HOST:=$(shell hostname) endif BUILD_VARS+= BUILD_HOST ifndef BUILD_USER export BUILD_USER:=$(USER) endif BUILD_VARS+= BUILD_USER ifndef BUILD_ROOT export BUILD_ROOT:=$(CWD) endif BUILD_VARS+= BUILD_ROOT _DEFINES:= $(foreach v,$(BUILD_VARS),-D'$v="$(${v})"' ) DEFINE_FLAGS:=$(DEFINE_FLAGS) $(_DEFINES) ######################################################################### # BUILD_VARS build_vars_h = $(GEN_FILE_DIR)/build_vars.h build_vars_h : $(dir $(build_vars_h)) $(ECHO) '/* DO NOT MODIFY Generated by maks/pre.mak. */' > $(build_vars_h) $(foreach v,$(BUILD_VARS),$(ECHO) '#define $(v) "$($(v))"' >> $(build_vars_h); ) @$(MSG) Made $@ EARLY_TARGETS+= build_vars_h GARBAGE+= $(build_vars_h) ######################################################################### # Defines DEFINE_FLAGS+= $(foreach f,$(DEFINES), -D'$(f)') ######################################################################### # Includes INCLS+= $(O_FILE_DIR) INCL_FLAGS+= $(foreach f,$(INCLS), -I'$(f)') CPPFLAGS+= $(DEFINE_FLAGS) $(INCL_FLAGS) ######################################################################### # Libs LIB_FLAGS+= $(foreach f,$(LIB_DIRS), -L'$(f)') LIB_FLAGS+= $(foreach f,$(LIBS), -l'$(f)') ######################################################################### # version ######################################################################### # yacc Y_FILES_ALL+= $(Y_FILES) $(Y_FILES_GEN) _Y_FILES_ALL=$(notdir $(Y_FILES_ALL)) Y_C_FILES_GEN+= $(_Y_FILES_ALL:%$(y)=$(GEN_FILE_DIR)/$(notdir %)$(c)) C_FILES_GEN+= $(Y_C_FILES_GEN) ######################################################################### # swig SWIG_WRAPPER=tcl8# SWIG_WRAPPER_tcl8=-namespace -module $(notdir $*) SWIG_FILES_ALL+= $(SWIG_FILES) $(SWIG_FILES_GEN) _SWIG_FILES_ALL=$(notdir $(SWIG_FILES_ALL)) SWIG_C_FILES_GEN+= \ $(_SWIG_FILES_ALL:%$(swig)=$(GEN_FILE_DIR)/$(notdir %)_swig$(c)) SWIG_WRAPPER_C_FILES_GEN+= \ $(foreach w,$(SWIG_WRAPPER),$(_SWIG_FILES_ALL:%$(swig)=$(GEN_FILE_DIR)/$(notdir %)_swig_$(w)$(c))) C_FILES_GEN+= $(SWIG_C_FILES_GEN) $(SWIG_WRAPPER_C_FILES_GEN) ######################################################################### # C C_FILES_ALL+= $(C_FILES)# $(C_FILES_GEN) _C_FILES_ALL=$(notdir $(C_FILES_ALL)) C_O_FILES_GEN+= $(_C_FILES_ALL:%$(c)=$(O_FILE_DIR)/$(notdir %)$(o)) C_GEN_O_FILES_GEN+= $(C_FILES_GEN:%$(c)=%$(o)) O_FILES_GEN+= $(C_O_FILES_GEN) $(C_GEN_O_FILES_GEN) ######################################################################### # C++ CC_FILES_ALL+= $(CC_FILES) $(CC_FILES_GEN) _CC_FILES_ALL=$(notdir $(CC_FILES_ALL)) CC_O_FILES_GEN+= $(_CC_FILES_ALL:%$(cc)=$(O_FILE_DIR)/$(notdir %)$(o)) O_FILES_GEN+= $(CC_O_FILES_GEN) ######################################################################### # Java JAVA_FILES_ALL+= $(JAVA_FILES) $(JAVA_FILES_GEN) _JAVA_FILES_ALL=$(notdir $(JAVA_FILES_ALL)) JAVA_CLASS_FILES_GEN+= $(_JAVA_FILES_ALL:%$(java)=$(CLASS_FILE_DIR)/$(notdir %)$(class)) ######################################################################### # Object files O_FILES+= $(O_FILES_GEN) ######################################################################### # Use -include Makefile.use dbmi0.1/src/maks/tool.mak0100644000175200017560000000316307065630434015654 0ustar stephensstepheng# $Id: tool.mak,v 1.7 2000/03/21 08:21:48 stephensk Exp $ ###################################################################### # Defaults TOOL_SUFFIX:=$(exe) _TOOL_DIR:=$(TOOL_DIR) ifneq "$(TOOL_TEST)" "" TOOL_DIR:=$(TEST_DIR) endif TOOL:=$(TOOL_DIR)/$(TOOL_NAME)$(TOOL_SUFFIX) TOOL_DIR:=$(_TOOL_DIR) ifeq "$(strip $(TOOL_MAIN))" "" TOOL_MAIN:=$(TOOL_NAME).c endif ifeq "$(strip $(TOOL_O_FILES))" "" TOOL_O_FILES:=$(TOOL_MAIN) endif TOOL_O_FILES_$(TOOL):=$(TOOL_O_FILES) ifeq "$(strip $(TOOL_LIBS))" "" TOOL_LIBS:=$(LIBS) endif TOOL_LIBS_$(TOOL):=$(TOOL_LIBS) ifeq "$(strip $(TOOL_LIB_FLAGS))" "" TOOL_LIB_FLAGS:=$(LIB_FLAGS) endif TOOL_LIB_FLAGS_$(TOOL):=$(TOOL_LIB_FLAGS) ###################################################################### # Target $(TOOL) : $(TOOL_O_FILES_$(TOOL)) $(LOCAL_LIBS) $(CC) $(CFLAGS) $(CPPFLAGS) -o '$@' $(TOOL_O_FILES_$(@)) $(TOOL_LIB_FLAGS_$(@)) $(foreach l,$(TOOL_LIBS_$(@)),-l'$(l)') # $(CP) $@ $(notdir $@) GARBAGE:=$(GARBAGE) $(notdir $(TOOL)) ###################################################################### # Aliases .PHONY : $(TOOL_NAME) $(notdir $(TOOL)) $(TOOL_NAME) $(notdir $(TOOL)) : $(TOOL) ###################################################################### # Export the target TOOL_PRODUCTS:=$(TOOL_PRODUCTS) $(TOOL) PRODUCTS:=$(PRODUCTS) $(TOOL) tools :: $(TOOL_PRODUCTS) @$(MSG) Made $@: $(TOOL_PRODUCTS) .PHONY : tools ###################################################################### # Reset vars TOOL_NAME:= TOOL_MAIN:= TOOL_O_FILES:= TOOL_LIBS:= TOOL_LIB_FLAGS:= TOOL_TEST:= ###################################################################### # EOF dbmi0.1/src/maks/tools.mak0100644000175200017560000000032406765637251016045 0ustar stephensstepheng# $Id: tools.mak,v 1.5 1999/09/09 04:59:21 stephensk Exp $ ECHO=echo MSG_PREFIX=+++ MSG=$(ECHO) $(MSG_PREFIX) MKDIR=mkdir MKDIRS=$(MKDIR) -p CP=cp CP_RECURSIVE=$(CP) -rp MV=mv TAR=tar GZIP=gzip -9 GUNZIP=gzip -d dbmi0.1/src/maks/use.mak0100744000175200017560000000075607262415714015502 0ustar stephensstepheng# $Id: use.mak,v 1.4 2001/03/21 02:04:14 stephens Exp $ # # Use a package. # # USE:= # include $(MAKS)/use.mak # # A package's Makefile.use contains the names of libraries # and header directories needed to 'USE' the package. # #USE:=$(strip $(shell cd $(USE) && /bin/pwd)) # Canonicalize the name error USE=$(USE) ifeq "$(findstring $(USE),$(USE_ALL))" "" # Include it once USE_ALL:=$(USE_ALL) $(USE) # Keep track of directories we USEd -include $(USE)/Makefile.use endif dbmi0.1/src/maks/bin/0040755000175200017560000000000007236675452014766 5ustar stephensstephengdbmi0.1/src/maks/bin/CVS/0040755000175200017560000000000007236675452015421 5ustar stephensstephengdbmi0.1/src/maks/bin/CVS/Root0100644000175200017560000000003407236675452016261 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/maks/bin/CVS/Repository0100644000175200017560000000002607236675452017516 0ustar stephensstephenghome/ion/src/maks/bin dbmi0.1/src/maks/bin/CVS/Entries0100644000175200017560000000011607236675452016750 0ustar stephensstepheng/mak/1.2/Mon Jun 28 14:03:33 1999// /mak.bat/1.3/Mon Jun 28 14:03:33 1999// D dbmi0.1/src/maks/bin/mak0100644000175200017560000000064206735700265015452 0ustar stephensstepheng#!/bin/sh HOME=`cd "$HOME" && pwd` if [ -z "$DEV_ROOT" ] then DEV_ROOT="${HOME}/src" fi DEV_ROOT=`cd "$DEV_ROOT" && pwd` export DEV_ROOT if [ -z "$MAKS" ] then MAKS='/home/stephens/src/maks' fi MAKS=`cd "$MAKS" && pwd` export MAKS if [ -z "$MAKE_ARCH" ] then MAKE_ARCH=`uname` fi export MAKE_ARCH echo "HOME=$HOME" echo "DEV_ROOT=$DEV_ROOT" echo "MAKS=$MAKS" echo "MAKE_ARCH=$MAKE_ARCH" exec make ${1+"$@"} dbmi0.1/src/maks/bin/mak.bat0100644000175200017560000000015206735700265016213 0ustar stephensstepheng@REM $Id: mak.bat,v 1.3 1999/06/28 14:03:33 stephensk Exp $ @sh %MAKS%\bin\mak %1 %2 %3 %4 %5 %6 %7 %8 %9 dbmi0.1/src/maks/opengl/0040755000175200017560000000000007262533466015477 5ustar stephensstephengdbmi0.1/src/maks/opengl/CVS/0040755000175200017560000000000007262562005016121 5ustar stephensstephengdbmi0.1/src/maks/opengl/CVS/Root0100644000175200017560000000003407236675452016775 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/maks/opengl/CVS/Repository0100644000175200017560000000003107236675452020226 0ustar stephensstephenghome/ion/src/maks/opengl dbmi0.1/src/maks/opengl/CVS/Entries0100644000175200017560000000013007262562005017444 0ustar stephensstepheng/Makefile/1.2/Fri Feb 19 09:26:02 1999// /Makefile.use/1.4/Wed Apr 4 09:09:10 2001// D dbmi0.1/src/maks/opengl/Makefile0100644000175200017560000000011306663227052017122 0ustar stephensstepheng# $Id: Makefile,v 1.2 1999/02/19 09:26:02 stephensk Exp $ all : clean : dbmi0.1/src/maks/opengl/Makefile.use0100644000175200017560000000075707262562266017740 0ustar stephensstepheng# $Id: Makefile.use,v 1.4 2001/04/04 09:09:10 stephens Exp $ #OPENGL_ROOT:=$(APPS)/dev# OPENGL_LIBDIR:=$(OPENGL_ROOT)# OPENGL_INCL:=$(OPENGL_ROOT)# # Are we using WIN32? MAKS_ARCH=$(MAKE_ARCH)# ifneq "$(strip $(findstring WIN,$(MAKS_ARCH)))" "" USE:=$(MAKS)/win32 include $(MAKS)/use.mak OPENGL_LIBS := opengl32 glu32 glut32 m # endif ifneq "$(strip $(findstring Linux,$(MAKS_ARCH)))" "" OPENGL_LIBS := GL GLU glut m # endif INCLS:=$(INCLS) $(OPENGL_INCL)# LIBS:=$(OPENGL_LIBS) $(LIBS)# dbmi0.1/src/maks/os/0040755000175200017560000000000007236675452014637 5ustar stephensstephengdbmi0.1/src/maks/os/CVS/0040755000175200017560000000000007236675452015272 5ustar stephensstephengdbmi0.1/src/maks/os/CVS/Root0100644000175200017560000000003407236675452016132 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/maks/os/CVS/Repository0100644000175200017560000000002507236675452017366 0ustar stephensstephenghome/ion/src/maks/os dbmi0.1/src/maks/os/CVS/Entries0100644000175200017560000000021207236675452016616 0ustar stephensstepheng/CYGWIN.mak/1.1/Thu Jan 13 11:24:09 2000// /CYGWIN_98-4.10.mak/1.1/Thu Jan 13 11:24:09 2000// /Linux.mak/1.1/Thu Jan 13 11:24:10 2000// D dbmi0.1/src/maks/os/CYGWIN.mak0100644000175200017560000000013007037332731016305 0ustar stephensstepheng# $Id: CYGWIN.mak,v 1.1 2000/01/13 11:24:09 stephensk Exp $ # CYGWIN (generic) exe=.exe dbmi0.1/src/maks/os/CYGWIN_98-4.10.mak0100644000175200017560000000016407037332731017214 0ustar stephensstepheng# $Id: CYGWIN_98-4.10.mak,v 1.1 2000/01/13 11:24:09 stephensk Exp $ # CYGWIN_98-4.10 include $(MAKS)/os/CYGWIN.mak dbmi0.1/src/maks/os/Linux.mak0100644000175200017560000000011507037332732016410 0ustar stephensstepheng# $Id: Linux.mak,v 1.1 2000/01/13 11:24:10 stephensk Exp $ # Linux-specifics dbmi0.1/src/maks/win32/0040755000175200017560000000000007236675452015160 5ustar stephensstephengdbmi0.1/src/maks/win32/CVS/0040755000175200017560000000000007236675452015613 5ustar stephensstephengdbmi0.1/src/maks/win32/CVS/Root0100644000175200017560000000003407236675452016453 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/maks/win32/CVS/Repository0100644000175200017560000000003007236675452017703 0ustar stephensstephenghome/ion/src/maks/win32 dbmi0.1/src/maks/win32/CVS/Entries0100644000175200017560000000013007236675452017136 0ustar stephensstepheng/Makefile/1.2/Fri Feb 19 09:26:02 1999// /Makefile.use/1.2/Fri Feb 19 09:26:02 1999// D dbmi0.1/src/maks/win32/Makefile0100644000175200017560000000011306663227052016600 0ustar stephensstepheng# $Id: Makefile,v 1.2 1999/02/19 09:26:02 stephensk Exp $ all : clean : dbmi0.1/src/maks/win32/Makefile.use0100644000175200017560000000014506663227052017400 0ustar stephensstepheng# $Id: Makefile.use,v 1.2 1999/02/19 09:26:02 stephensk Exp $ LIBS := kernel32 user32 gdi32 $(LIBS) dbmi0.1/src/bin/0040755000175200017560000000000007306140336014015 5ustar stephensstephengdbmi0.1/src/bin/CVS/0040755000175200017560000000000007306135474014457 5ustar stephensstephengdbmi0.1/src/bin/CVS/Root0100644000175200017560000000003407236675451015325 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/bin/CVS/Repository0100644000175200017560000000002107236675451016555 0ustar stephensstephenghome/ion/src/bin dbmi0.1/src/bin/CVS/Entries0100644000175200017560000000343107306135474016011 0ustar stephensstepheng/PKG/1.1.1.1/Wed Feb 17 06:33:07 1999// /addcr/1.5/Wed Feb 17 23:02:18 1999// /addrcsid.pl/1.3/Mon Jun 28 13:55:59 1999// /ccinfo/1.1.1.1/Wed Feb 17 06:33:07 1999// /ccloclibs/1.1.1.1/Wed Feb 17 06:33:07 1999// /ctocnl.c/1.2/Fri Feb 19 09:25:26 1999// /cvschrep.pl/1.3/Sun Jan 14 15:40:02 2001// /cvschroot.pl/1.3/Wed Feb 17 22:29:09 1999// /cvsclean/1.1/Thu Oct 21 00:01:07 1999// /cvsedited/1.1/Wed Oct 13 21:42:43 1999// /cvsfind.pl/1.4/Thu Oct 21 00:01:07 1999// /cvsretag.pl/1.1/Thu Sep 9 06:11:27 1999// /cvsrevhist.pl/1.6/Tue Mar 21 07:13:26 2000// /cwfixlib.pl/1.2/Fri Feb 19 09:25:26 1999// /d2u.pl/1.8/Sun Jan 14 15:40:36 2001// /ecd/1.1.1.1/Wed Feb 17 06:33:07 1999// /fe/1.1.1.1/Wed Feb 17 06:33:08 1999// /findsource/1.1.1.1/Wed Feb 17 06:33:08 1999// /igrep/1.2/Thu Sep 30 18:41:09 1999// /linkdups/1.1.1.1/Wed Feb 17 06:33:07 1999// /locstatic/1.1.1.1/Wed Feb 17 06:33:08 1999// /lsup/1.2/Thu Sep 30 18:49:41 1999// /mergefiles.pl/1.2/Fri Feb 19 09:25:26 1999// /mkindex/1.2/Thu Sep 30 18:41:09 1999// /mvr.pl/1.1/Wed Oct 13 21:42:44 1999// /nmlibs/1.1.1.1/Wed Feb 17 06:33:07 1999// /nmm/1.1.1.1/Wed Feb 17 06:33:07 1999// /objcsyms/1.1.1.1/Wed Feb 17 06:33:08 1999// /sci/1.1.1.1/Wed Feb 17 06:33:08 1999// /scip/1.1.1.1/Wed Feb 17 06:33:08 1999// /si/1.2/Wed Oct 13 17:09:27 1999// /split.c/1.2/Fri Feb 19 09:25:26 1999// /tgz/1.6/Sun Jan 14 15:41:22 2001// /ts/1.2/Tue Mar 21 07:15:07 2000// /which/1.1.1.1/Wed Feb 17 06:33:08 1999// /whichall/1.1.1.1/Wed Feb 17 06:33:08 1999// /wwwsend/1.1.1.1/Wed Feb 17 06:33:07 1999// D/addcr.t//// D/lib//// /dos2unix.c/1.1/Fri Apr 8 22:48:41 1994// /swig2def.pl/1.1/Tue Apr 3 18:40:06 2001// /cvsfix.pl/1.1/Mon Apr 9 20:43:32 2001// /uud/1.3/Tue Apr 3 18:51:54 2001// /uudindex/1.3/Tue Apr 3 18:51:55 2001// /publish.pl/1.10/Sat Jun 2 10:09:00 2001// dbmi0.1/src/bin/PKG0100644000175200017560000000034606662461243014370 0ustar stephensstephengNAME=bin VERSION=0.1 DESC="A development script library. Tools for: publishing PKG packages, adding COPYRIGHT and RCS version strings to source files, etc." CATEGORY="Development Tools" REQUIRES_PKGS="" REQUIRES_OTHERS="perl sh" dbmi0.1/src/bin/addcr0100644000175200017560000002206706662645172015035 0ustar stephensstepheng#!/usr/local/bin/perl # @COPYRIGHT@ # # Copyright (c) 1997-1999 Kurt A. Stephens and ION, Inc., All Rights Reserved. # # http://www.acm.org/~stephensk # # Kurt A. Stephens and Ion, Inc. MAKE NO REPRESENTATIONS OR WARRANTIES # ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING # BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR # A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. Kurt A. Stephens or Ion, Inc. # SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF # USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. # # $Id: addcr,v 1.5 1999/02/17 23:02:18 stephensk Exp $ # # @COPYRIGHT END@ ($progname = $0) =~ s@^.*[/\\]@@; $progdir = ($0 =~ m@^(.*)[/\\]@) ? $1 : '.'; #print STDERR "progdir = '$progdir', progname = '$progname'\n"; exit(1); @comments = ( [ '/\.(o|obj|lib|a|exe|com|out|bak)$/i || /,v$/i || /~$/ || -B $filename', 0 ], # Ignore object, backup, RCS, emacs backups, and binary files [ '/$backup_suffix$/i', 0 ], # Ignore our backup files [ '/\.([CchHyYlL]+|java)$/i || firstline_() =~ /^\s*(#\s*include|#\s*if|#\s*define|\/\*|\/\/)/', [ '/*', '**', '*/' ] ], [ '/\.(el|scm|ll|lisp)$/i || firstline_() =~ /^\s*;/', [ ';' ] ], [ '/\.(bat)$/i', [ 'REM ' ] ], # DOS BAT files [ '/Makefile.*|(\.(mak|pl|pm|perl|[ck]?sh))$/i || firstline() =~ /^\s*#/', [ '#' ] ] ); foreach $x ( @comments ) { die "$!: Cannot compile $x->[0]" if ( ! ($x->[2] = eval("sub { $x->[0]; }")) ); $x->[1]->[1] = $x->[1]->[0] if ( ! defined($x->[1]->[1]) ); $x->[1]->[2] = '' if ( ! defined($x->[1]->[2]) ); } ################################## sub firstline { local(*F); if ( $_firstline_filename eq $filename ) { return $_firstline; } $_firstline_filename = $filename; open(F, "<$filename") || warn "$!: Cannot open $filename for reading"; $F = ; close(F); chop $F; $_firstline = $F; $F; } sub firstline_ { # Get first non-blank line, skipping first line if it's "#!" local(*F); if ( $_firstline__filename eq $filename ) { return $_firstline_; } $_firstline__filename = $filename; open(F, "<$filename") || warn "$!: Cannot open $filename for reading"; $F = ; #print STDERR "firstline_ = '$F'\n"; $F = if ( $F =~ /^\#\!/ ); #print STDERR "firstline_ = '$F'\n"; chop $F; while ( $F =~ /^\s*$/ ) { $F = ; chop $F; } close(F); $_firstline_ = $F; #print STDERR "firstline_ = '$F'\n"; $F; } ################################## $replacestr = 'COPYRIGHT'; $replacefile = $replacestr; $filename = '.'; $testing = 0; $debug = 0; $backup_suffix = '.acr'; $rm_backup = 0; $dryrun = 0; $usage = 0; $recursive = 0; sub findfile { my($replacedir); $replacedir = ($filename =~ m@^(.*)[/\\]@) ? $1 : '.'; #print STDERR "replacedir = '$replacedir'\n"; while ( ! -r ($FILE = "$replacedir/$replacefile") ) { $replacedir .= "/.."; if ( $replacedir eq './../../../../../../../../../..' ) { die "Cannot locate $replacefile" if ( ! $usage ); return ""; } } $FILE; } sub insertfile { # Begin replace block print OUT $comments->[0], ' @', $replacestr, '@', "\n"; print OUT $comments->[1], "\n"; # Open comment text file open(FILE, "<$FILE") || die "$!: Cannot open $FILE for reading"; # Insert the comment text while ( $line = ) { print OUT $comments->[1], ' ', $line; } close(FILE); # End replace block print OUT $comments->[1], "\n"; print OUT $comments->[1], ' @', $replacestr, ' END@ ', $comments->[2], "\n"; # Copy rest of IN file if ( defined($firstline) ) { print OUT $firstline; $firstline = undef; } while ( $line = ) { print OUT $line; } close(IN); close(OUT); if ( (! $testing) && $rm_backup ) { system('rm', $IN); } print STDERR "$progname: $filename: found and replaced preexisting $replacestr block\n" if ( $debug ); 1; } sub replacestr { local($comments) = @_; local(*IN,*OUT,*FILE); local($line, $firstline); # Find the replacement text file $FILE = findfile(); if ( $dryrun ) { print "$progname: $filename: $FILE: $comment->[0]: $comment->[1]: $comment->[2]\n"; } $_ = $filename; if ( $testing ) { $OUT = $filename . $backup_suffix; $IN = $filename; } else { # We move the file to $IN $OUT = $filename; $IN = $filename . $backup_suffix; if ( -f $IN ) { print STDERR "$progname: backup file $IN already exists\n"; return 0; } if ( ! (-w && -r && -f) ) { print STDERR "$progname: $filename: file not read/write\n"; return 0; } system('mv', $OUT, $IN) && die "$!: Cannot mv $OUT $IN"; } # Open IN and OUT files open(OUT, ">$OUT") || die "$!: Cannot open $OUT for writing"; open(IN, "<$IN") || die "$!: Cannot open $IN for reading"; # Read first line if ( ($line = ) ) { # If first line contains 'DO NOT MODIFY', don't do anything! if ( $line =~ /DO NOT MODIFY/i ) { print STDERR "$progname: $filename: found 'DO NOT MODIFY'\n" if ( $debug ); close(IN); close(OUT); # Restore original file if ( ! $testing ) { system('mv', $IN, $OUT); } return 0; } } while ( $line ) { # Have we found a preexisting replace string if ( $line !~ /@$replacestr@/ ) { # Simply echo to OUT print OUT $line; } else { print STDERR "$progname: $filename: found '\@$replacestr\@'\n" if ( $debug ); # Skip over input comment block while ( ($line = ) ) { if ( $line =~ /@$replacestr END@/ ) { print STDERR "$progname: $filename: found '\@$replacestr END\@' terminator\n" if ( $debug ); return insertfile(); } } # Did not find END terminator! print STDERR "$progname: $filename: did not find '\@$replacestr END\@' terminator\n"; close(IN); close(OUT); open(OUT, ">$OUT") || die "$!: Cannot open $OUT for writing"; open(IN, "<$IN") || die "$!: Cannot open $IN for reading"; while ( ($line = ) ) { if ( $line =~ /@$replacestr@/ ) { return insertfile(); } else { print OUT $line; } } } $line = ; } # We never found a preexisting comment block; # insert $FILE after #! line. print STDERR "$progname: $filename: did not find preexisting $replacestr block\n" if ( $debug ); close(IN); close(OUT); open(OUT, ">$OUT") || die "$!: Cannot open $OUT for writing"; open(IN, "<$IN") || die "$!: Cannot open $IN for reading"; # Skip over first shell script #! line $firstline = ; if ( $firstline =~ /^#!\// ) { print STDERR "$progname: $filename: skipping first line '$firstline'\n" if ( $debug ); print OUT $firstline; $firstline = undef; } insertfile(); } sub getdir { local(*DIR); $DIR = $_[0]; opendir(DIR, $DIR); @DIR = grep(($_ ne '.' && $_ ne '..'), readdir DIR); closedir(DIR); print STDERR "getdir: $DIR: ", join(", ", @DIR), "\n" if ( $debug > 2 ); @DIR; } sub dofile { $filename = $_[0]; $_ = $filename; s@^.*[/\\]@@; # remove directory path print STDERR "$progname: $filename: dofile\n" if ( $debug > 1 ); if ( -r $filename && -w $filename ) { if ( -d $filename ) { my($fuc) = uc($_); if ( $fuc =~ /^CVS/ || $fuc eq 'RCS' || $fuc eq 'SCCS' ) { print STDERR "$progname: $filename: skipping dir\n" if ( 1 || $debug ); } elsif ( $recursive ) { print STDERR "$progname: $filename: recursing\n" if ( $debug ); my($dirname) = $filename; foreach $_ ( getdir($dirname) ) { dofile("$dirname/$_"); } } else { print STDERR "$progname: $filename: skipping\n"; } } else { X: foreach $x ( @comments ) { print STDERR "$progname: $filename: trying $x->[0]\n" if ( $debug > 1); if ( $x->[2] ) { if ( &{$x->[2]}() ) { print STDERR "$progname: $filename: matched $x->[0]\n" if ( $debug > 1); if ( $x->[1] ) { print STDERR "$progname: $filename: not modified\n" if ( ! replacestr($x->[1]) ); } else { print STDERR "$progname: $filename: skipping\n"; } last X; } } else { die "$progname: no proc for $x->[0]\n"; } } } } else { print STDERR "$progname: $filename: cannot read or write\n"; } } sub usage { $usage = 1; print STDERR qq~ $progname: usage: $progname ... $progname replaces \@$replacestr\@ with contents of the $replacefile file. OPTIONS -dryrun Do a dryrun. -debug Enable debugging. -testing Enable testing. -R If directories are specified, they are traversed recursively. -h, -? This usage message. The current $replacefile file is located at ~ . &findfile() . "\n"; exit(0); } #push(@ARGV, '.') if ( ! @ARGV ); foreach ( @ARGV ) { if ( s/^--?// ) { if ( /^[Hh\?]/ ) { &usage; } elsif ( /^dr/ ) { $dryrun ++; } elsif ( /^d/ ) { $debug ++; } elsif ( /^t/ ) { $testing ++; } elsif ( /^(R|rec)/ ) { $recursive ++; } else { print STDERR "$progname: $_: unrecognized option\n"; } } else { dofile($_); } } 1; dbmi0.1/src/bin/addrcsid.pl0100644000175200017560000000647106735677357016163 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: addrcsid.pl,v 1.3 1999/06/28 13:55:59 stephensk Exp $ # # addrcsid.pl ... # # Recursively add $Id: addrcsid.pl,v 1.3 1999/06/28 13:55:59 stephensk Exp $ strings to source files. # Avoids CVS, RCS, and SCCS directories and binary and ',v' files. # # TO DO: # use @comment array from addcr.pl to control comment characters and such # use File::Basename; use File::Find; $progname = basename($0); sub skip_first_lines { $suffix = '.scm' if ( $suffix =~ /^\.(scm|lisp|ll|el)$/i ); # Skip lines until after %{ for yacc files if ( $suffix =~ /^\.[yl]/i ) { LINE: while ( $line = <$in> ) { print $out $line; last LINE if ( $line =~ /^\s*%\{/ ); } } elsif ( $suffix =~ /^\.h/i ) { $line = <$in>; if ( $line =~ /^\s*#\s*if/ ) { print $out $line; $line = <$in>; } } else { $line = <$in>; if ( $line =~ /^\s*\#!/ ) { print $out $line; $line = <$in>; } } $line; } $rcs_id_str = '$Id: addrcsid.pl,v 1.3 1999/06/28 13:55:59 stephensk Exp $'; sub print_rcs_id { if ( $suffix =~ /^\.[ychlm]/i ) { print $out qq~ #ifndef __rcs_id__ #ifndef __rcs_id_${ftoken}__ #define __rcs_id_${ftoken}__ static const char __rcs_id_${ftoken}[] = "$rcs_id_str"; #endif #endif /* __rcs_id__ */ ~; } elsif ( $suffix =~ /^.htm/ ) { print $out qq~ ~; } elsif ( $suffix eq '.java' ) { print $out qq~/* $rcs_id_str */ ~; } else { my($com) = '#'; $com = ';' if ( $suffix =~ /^\.(scm|lisp|ll|el)$/ ); print $out qq~$com $rcs_id_str ~; } } sub do_file { #print STDERR "$progname: do_file($File::Find::dir/$_)\n"; if ( ( -d && /^(CVS|RCS|SCCS)/i ) || /,v$/ ) { $File::Find::prune = 1; } elsif ( -f && -r && ! -B && ( /(\.[a-zA-Z_0-9]+)$/i || /^makefile/i ) ) { local($suffix) = $1; my($found) = 0; local($in, $out); local($line); # In and out files $in = $_; $out = "$_.tmp"; # Generate a C token for the filename local($ftoken) = $File::Find::name; $ftoken = $1 if ( $ftoken =~ m@([^\\/]+[\\/][^\\/]+)$@ ); $ftoken =~ tr/A-Za-z_0-9/_/c; # open files die "$out exists" if ( -e $out ); open($out, ">$out") || die "$out: $!: "; open($in, "<$in") || die "$in: $!: "; skip_first_lines(); while ( $line ) { if ( $line =~ /DO NOT MODIFY/ ) { print STDERR "$progname: DO NOT MODIFY: skipping $File::Find::dir/$_\n"; close($in); close($out); unlink($out); return; } #locate prexisting rcs id block */ if ( $line =~ /^\s*\#\s*ifndef\s+__rcs_id__/ ) { $found = 1; # skip block while ( $line = <$in> && $line !~ m@^\s*\#\s*endif\s*/\*\s*__rcs_id__\s*\*/@ ) { 1; } print_rcs_id(); } print $out $line; $line = <$in>; } close($in); close($out); if ( ! $found ) { open($out, ">$out") || die "$out: $!: "; open($in, "<$in") || die "$in: $!: "; # Skip first lines skip_first_lines(); # Put rcs id print_rcs_id(); # write rest of file while ( $line ) { print $out $line; $line = <$in>; } close($in); close($out); } if ( -w $in ) { unlink($in); rename($out, $in); print STDERR "$progname: $File::Find::dir/$in\n" } else { print STDERR "$progname: $File::Find::dir/$in not writable: result in $File::Find::dir/$out\n"; } } } File::Find::find(\&do_file, @ARGV); 1; dbmi0.1/src/bin/ccinfo0100644000175200017560000001177606662461243015221 0ustar stephensstepheng#!/run/thirdParty/perl5/bin/perl eval 'exec /run/thirdParty/perl5/bin/perl $0 ${1+"$@"}' if 0; $cwd = 0; sub cwd { if ( ! $cwd ) { chop($cwd = `/bin/pwd`); $cwd = simplifyPathname($cwd); #print STDERR "cwd = $cwd\n"; } $cwd; } sub simplifyPathname { my($p) = $_[0]; $p =~ s@^/private/@/@; $p =~ s@//@/@g; $p =~ s@/\./@/@g; while ( $p =~ s@/[^/]+/\.\./@/@ ) { } #print STDERR "simplifyPathname $_[0] -> $p\n"; $p; } #for ( @ARGV ) { # print $_, " => ", simplifyPathname($_), "\n"; #} #exit 0; sub absPathname { my($f) = $_[0]; $f = ($f =~ m@^/@) ? $f : simplifyPathname(cwd() . "/" .$f); #print STDERR "absPathname $_[0] -> $f\n"; $f; } sub filePathname { my($f) = $_[0]; $f = ($f =~ m@([^/]+)$@) ? $1 : $f; #print STDERR "filePathname $_[0] -> $f\n"; $f; } sub suffixPathname { my($f) = $_[0]; $f = ($f =~ m@(\.[^/.]*)$@) ? $1 : ''; #print STDERR "suffixPathname $_[0] -> $f\n"; $f; } sub findFile { my($file,$path) = @_; my($f); if ( $file =~ m@^/@ ) { if ( -r $file ) { return $file; } } else { foreach $d ( @$path ) { $f = $d . '/' . $file; if ( -r $f ) { return $f; } } } 0; } sub expandSoftlink { my($f) = @_; my($l,$linkcount); $linkcount = 40; while ( -l $f && ($l = readlink($f)) ) { # print STDERR "softlink $f -> $l\n"; -- $linkcount || die "$0: $f: Too many levels of symbolic links"; if ( $l =~ m@^/@ ) { $f = $l; } else { $f =~ s@/[^/]+/?$@@; $f .= "/" . $l; } } $f; } sub _objCName { if ( s/^\.objc_class_name_// ) { $_ = '@class ' . $_; } elsif ( m/^\.objc_category_name_([^_]+)_([^_]+)/ ) { $_ = '@category ' . $1 . '(' . $2 . ')'; } $_; } sub _nmInfo { my($x) = @_; my($fp, $f, $suf, $floc, $a); $f = $x->[1]; $fp = $x->[2]; $suf = $x->[0]; $floc = $fp; $a = []; open(NM, "/bin/nm $fp|"); while ( ) { chop; if ( s/^\s+U\s+// ) { _objCName(); push(@$a, [ $suf, $f, $floc, 'refs', 'symb', $_, '' ]); } elsif ( s/^([0-9a-fA-f]+)\s+T\s+// || (s/^([0-9a-fA-f]+)\s+t\s+// && m/^[-+]\[/) ) { _objCName(); push(@$a, [ $suf, $f, $floc, 'defs', 'prog', $_, $1 ]); } elsif ( s/^([0-9a-fA-f]+)\s+D\s+// ) { _objCName(); push(@$a, [ $suf, $f, $floc, 'defs', 'data', $_, $1 ]); } elsif ( s/^([0-9a-fA-f]+)\s+A\s+// ) { _objCName(); push(@$a, [ $suf, $f, $floc, 'defs', 'abs', $_, $1 ]); } elsif ( m@^/([^(]+)[(]([^)]+)[)]@ ) { $module = $2; $suf = suffixPathname($module); $f = $module; $floc = $x->[2] . '@' . $module; push(@$a, [ $x->[0], $x->[1], $x->[2], 'has', $suf, $f, '' ]); } } close(NM); $a; } sub nmInfo { my($fp) = @_; #print STDERR "nmInfo $fp->[2] \n"; _nmInfo($fp); } @ldirs = ('.'); @fdirs = ('/LocalLibrary/Frameworks', '/NextLibrary/Frameworks'); @lfiles = (); @ffiles = (); @archs = (); @infiles = (); $outfile = 0; $doInfo = 1; @argv = @ARGV; shift @argv; while ( $a = shift @argv ) { if ( $a =~ m/^-L(.*)$/ ) { push(@ldirs, $1); } elsif ( $a =~ m/^-l(.*)$/ ) { push(@lfiles, [ 'lib', $1, '' ]); } elsif ( $a eq '-o' ) { $outfile = absPathname(shift @argv); } elsif ( $a eq '-arch' ) { push(@archs, shift @argv); } elsif ( $a eq '-framework' ) { $f = shift @argv; push(@ffiles, [ 'framework', $f, '' ]); } elsif ( $a =~ m/^-[cSE]$/ ) { $doInfo = 0; } elsif ( $a eq '-sectcreate' || $a eq '-segprot' ) { shift @argv; shift @argv; shift @argv; } elsif ( $a !~ m@^-@ && $a =~ m/\.\w+$/ ) { if ( $a =~ m/\.a$/ ) { push(@infiles, [ 'lib', filePathname($a), absPathname($a) ] ); } else { push(@infiles, [ suffixPathname($a), filePathname($a), absPathname($a) ] ); } } } if ( $doInfo ) { foreach $x ( @lfiles ) { my($file) = 'lib' . $x->[1] . '.a'; $x->[2] = absPathname(expandSoftlink(findFile($file, \@ldirs))); if ( $x->[2] ) { push(@infiles, $x); } } push(@ffiles, [ 'framework', 'System' ]); foreach $x ( @ffiles ) { my($file) = $x->[1] . '.framework/' . $x->[1]; $x->[2] = absPathname(expandSoftlink(findFile($file, \@fdirs))); if ( $x->[2] ) { push(@infiles, $x); } } if ( ! $outfile ) { $outfile = 'a.out'; } @info = (); # type name location relation type name location # 0 1 2 3 4 5 6 %defs = (); $datafile="$outfile.ccinfo"; open(FILE,">$datafile") || print STDERR "$0: cannot open $datafile for writing: $!"; for $x ( @infiles ) { print FILE join("\t", 'exe', filePathname($outfile), $outfile, 'links', $x->[0], $x->[1], $x->[2]), "\n"; if ( $x->[2] && ($x->[0] eq 'lib' || $x->[0] eq 'framework' || $x->[0] eq '.o') ) { for $i ( @{nmInfo($x)} ) { push(@info, $i); if ( $i->[3] eq 'defs' ) { $defs{$i->[5]} = $i; } } } } for $i ( @info ) { if ( $i->[3] eq 'refs' ) { if ( $j = $defs{$i->[5]} ) { $i->[4] = $j->[4]; $i->[6] = ''; # $j->[2] . '@' . $j->[6]; } } print FILE join("\t", @{$i}), "\n"; } close(FILE); } exec(@ARGV); dbmi0.1/src/bin/ccloclibs0100644000175200017560000000576306662461243015714 0ustar stephensstepheng#!/run/thirdParty/perl5/bin/perl eval 'exec /run/thirdParty/perl5/bin/perl $0 ${1+"$@"}' if 0; # # This program interprets cc -L and -l linker command lines # a attempts to locate the libraries (lib*.a) in the -L paths specified # for each library file found. a "dir " entry is written # to a "gdbinit" file. # # It also creates a dependency in Makefile.dependencies for the executable # on the libraries. # # Libs files found that are softlinks are resolved. This will # allow you to find source for a library if you install your libraries # in directory a directory by using softlinks instead of copies. # # The last step is to exec the linker command # you can use this in your Makefile by calling 'make "CC=ccloclibs cc"' # sub findFile { my($file,$path) = @_; my($f); if ( $file =~ m@^/@ ) { if ( -r $file ) { return $file; } } else { foreach $d ( @$path ) { $f = $d . '/' . $file; if ( -r $f ) { return $f; } } } 0; } sub expandSoftlink { my($f) = @_; my($l,$linkcount); $linkcount = 40; while ( -l $f && ($l = readlink($f)) ) { # print STDERR "softlink $f -> $l\n"; -- $linkcount || die "$0: $f: Too many levels of symbolic links"; if ( $l =~ m@^/@ ) { $f = $l; } else { $f =~ s@/[^/]+/?$@@; $f .= "/" . $l; } } $f; } sub simplifyPathname { my($p) = $_[0]; $p =~ s@^/private/@/@; $p =~ s@//@/@g; $p =~ s@/\./@/@g; while ( $p =~ s@/[^/]+/\.\./@/@ ) { } #print STDERR "simplifyPathname $_[0] -> $p\n"; $p; } #print @ARGV, "\n"; @ldirs = ('.'); @lfiles = (); $outfile = 'a.out'; $gotLibs = 0; @argv = @ARGV; shift @argv; while ( $a = shift @argv ) { if ( $a =~ m/^-L(.*)$/ ) { push(@ldirs, $1); } elsif ( $a =~ m/^-l(.*)$/ ) { push(@lfiles, $1); $gotLibs ++; } elsif ( $a eq '-o' ) { $outfile = shift @argv; } } if ( $gotLibs ) { %dirs = (); $libs = "LIBS"; $deps = "Makefile.dependencies"; open(LIBS, ">$libs") || print STDERR "$0: cannot open $libs for writing: $!"; open(DEPS, ">$deps") || print STDERR "$0: cannot open $deps for writing: $!"; print DEPS "$outfile : "; foreach $lfile ( @lfiles ) { my($f); $f = simplifyPathname(expandSoftlink(findFile("lib" . $lfile . ".a", \@ldirs))); if ( ! $f ) { $f = simplifyPathname(expandSoftlink(findFile("lib" . $lfile . ".dylib", \@ldirs))); } if ( $f ) { print STDERR "lib $lfile $f\n"; print LIBS "lib $lfile $f\n"; print DEPS "\\\n $f "; $f =~ s@/[^/]*$@@; while ( $f =~ s@/NeXT_[^/]*obj$@@ ) { } $dirs{$f} ++; } else { print STDERR "$0: $lfile: not found\n"; } } print DEPS "\n\n"; close(LIBS); close(DEPS); $gdbinit = "gdbinit"; open(GDBINIT, ">$gdbinit") || print STDERR "$0: cannot open $gdbinit for writing: $!"; foreach $f ( keys(%dirs) ) { print GDBINIT "dir $f\n"; print STDERR "dir $f\n"; } close(GDBINIT); } #print STDERR "$0: ", join(" ", @ARGV), "\n"; exec(@ARGV); dbmi0.1/src/bin/ctocnl.c0100644000175200017560000000056406663227006015452 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_bin_ctocnl_c__ #define __rcs_id_bin_ctocnl_c__ static const char __rcs_id_bin_ctocnl_c[] = "$Id: ctocnl.c,v 1.2 1999/02/19 09:25:26 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include int main() { int c; while ( (c = getchar()) != EOF ) { putchar(c); if ( c == ';' ) putchar('\n'); } return 0; } dbmi0.1/src/bin/cvschrep.pl0100744000175200017560000000234707230344122016166 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: cvschrep.pl,v 1.3 2001/01/14 15:40:02 stephens Exp $ # use File::Find; $debug = 1; $testing = 0; $keep_backup = 0; $filename = 'Repository'; $from = undef; $to = $undef; while ( @ARGV ) { $_ = shift; if ( /^--?r/ ) { $filename = 'Root'; } elsif ( /^--?d/ ) { ++ $debug; } elsif ( /^--?t/ ) { ++ $testing; } elsif ( ! defined $from ) { $from = $_; } elsif ( ! defined $to ) { $to = $_; last; } } sub wanted { my($file) = $File::Find::name; if ( $File::Find::name =~ m@/CVS/$filename$@o && -f ) { my($in, $out) = ( "$_.tmp", $_ ); my($line); print STDERR "wanted: '$File::Find::name'\n" if ( $testing || $debug ); if ( $testing ) { $in = $out; } else { die "$in exists" if ( -e $in ); system('mv', $out, $in); } open($in, "<$in") || die "$in: $!"; if ( ! $testing ) { open($out, ">$out") || die "$out: $!"; } while ( $line = <$in> ) { $line =~ s/\r//sg; if ( $line =~ s@$from@$to@i ) { print STDERR "$File::Find::name: $line"; } if ( ! $testing ) { print $out $line; } } close($in); if ( ! $testing ) { close($out); unlink($in) if ( ! $keep_backup ); } } } find(\&wanted, @ARGV); 1; dbmi0.1/src/bin/cvschroot.pl0100644000175200017560000000204606662641265016376 0ustar stephensstepheng#!/bin/perl # $Id: cvschroot.pl,v 1.3 1999/02/17 22:29:09 stephensk Exp $ # use File::Find; $debug = 1; $keep_backup = 0; $testing = 0; $delete = 1; #$from = shift; #$to = shift; sub wanted { my($file) = $File::Find::name; if ( $File::Find::name =~ m@/CVS/Root$@ && -f ) { my($in, $out) = ( "$_.tmp", $_ ); my($line); print STDERR "$0: '$File::Find::name'\n" if ( $testing || $debug ); if ( $testing ) { $in = $out; } else { die "$in exists" if ( -e $in ); system('mv', $out, $in); } if ( $delete ) { unlink($out) if ( ! $testing ); unlink($in) if ( ! $keep_backup ); } else { open($in, "<$in") || die "$in: $!"; if ( ! $testing ) { open($out, ">$out") || die "$out: $!"; } # while ( $line = <$in> ) { # if ( $line =~ s@^$from@$to@i ) { # print STDERR "$File::Find::name: $line"; # } # if ( ! $testing ) { # print $out $line; # } # } close($in); if ( ! $testing ) { close($out); unlink($in) if ( ! $keep_backup ); } } } } find(\&wanted, @ARGV); 1; dbmi0.1/src/bin/cvsclean0100644000175200017560000000054007003453703015531 0ustar stephensstepheng#!/bin/sh #$Id: cvsclean,v 1.1 1999/10/21 00:01:07 stephensk Exp $ #cvs() { # echo "cvs $@" #} files="" OIFS="$IFS" IFS="/" while read type file version date sticky do if [ -n "$file" ] then case "$type" in *) if [ ! -f "$file" ] then files="$files$file " fi ;; esac fi done < CVS/Entries IFS="$OIFS" cvs rm $files dbmi0.1/src/bin/cvsedited0100644000175200017560000000051307001176323015703 0ustar stephensstepheng#!/bin/sh # $Id: cvsedited,v 1.1 1999/10/13 21:42:43 stephensk Exp $ tmp=/tmp/$$.tmp set -x find \( -name 'CVS' -prune \) -o \( -type f -print \) "$@" | #> "$tmp" while read f do status="$(cvs status $f | egrep -e '^File: .*Status:')" case "$status" in *Locally*) echo "$f $status" ;; esac done rm -f "$tmp" dbmi0.1/src/bin/cvsfind.pl0100644000175200017560000000253507003453703016007 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: cvsfind.pl,v 1.4 1999/10/21 00:01:07 stephensk Exp $ use File::Basename; use Cwd 'fast_abs_path'; $progdir = fast_abs_path(dirname($0)); push(@INC, $progdir, "$progdir/lib/perl"); print STDERR "@INC\n"; eval 'use ion::_cvs::find;'; ################################################################### $debug = 0; $testing = 0; $sep = "\t"; @print_entries = (); OPT: while ( ($_ = $ARGV[0]) && /^-/ ) { shift; s/^--?//; if ( $_ eq '' ) { last OPT; } elsif ( /^sep/ ) { $sep = shift; } else { FLAG: while ( $_ ne '' ) { if ( /^A/ ) { @print_entries = ( 0 .. $#ion::_cvs::entry::map ); last FLAG; } elsif ( s/^([a-zA-Z]+)$// ) { my $i = $ion::_cvs::entry::map{$1}; die "$1: unknown field: must be one of '@ion::_cvs::entry::map'" if ( ! defined $i ); push(@print_entries, $i); } elsif ( s/^([0-9]+)$// ) { push(@print_entries, $1); } else { last FLAG; } } } } @print_entries = ( 0 .. $#ion::_cvs::entry::map ) if ( ! @print_entries ); ########################################################### @entries = (); ion::_cvs::find(sub { push(@{$_[1]}, $_[0]) }, \@entries, @ARGV); @entries = sort { ($a->fullpath) cmp ($b->fullpath); } @entries; foreach $e ( @entries ) { print join($sep, map($e->[$_], @print_entries)), "\n"; } 1; dbmi0.1/src/bin/cvsretag.pl0100644000175200017560000000225106765647617016213 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: cvsretag.pl,v 1.1 1999/09/09 06:11:27 stephensk Exp $ #use Carp; use File::Basename; use Cwd 'fast_abs_path'; $progdir = fast_abs_path(dirname($0)); push(@INC, $progdir, "$progdir/lib/perl"); eval 'use ion::_cvs::find;'; #eval 'use ion::_cvs::rlog;' || die "$!"; $opts = { }; while ( $_ = $ARGV[0], s/^--?// ) { shift; if ( s/^f([^=]*=)?// ) { $opts->{filter} = $1 ? $_ : shift; } elsif ( s/^s([^=]*=)?// ) { $opts->{show_rev_info} = $1 ? $_ : 1; } } my(@entries); ion::_cvs::find(sub {push(@{$_[1]}, $_[0]); }, \@entries, @ARGV); @entries = sort { $a->fullpath() cmp $b->fullpath() } @entries; my($OUTPUT); $OUTPUT = 'STDOUT'; $opts = {filter => '-h'}; $opts = {}; my($e); foreach $e ( @entries ) { if ( $e->isFile ) { print $e->repository, "\n"; my($rlog) = $e->rlog({}); use Data::Dumper; $Data::Dumper::Purity = 1; $Data::Dumper::Quotekeys = 1; print Dumper($rlog), "\n"; my($sym_name); foreach $sym_name ( @{$rlog->{symbolic_names}} ) { my($rev) = $rlog->{sym_name_to_rev}->{$sym_name}; if ( $rev && $sym_name =~ /^PUBLISH:/ ) { echo $e->repository, " $sym_name => $rev\n"; } } } } 1; dbmi0.1/src/bin/cvsrevhist.pl0100644000175200017560000000676307065620426016570 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: cvsrevhist.pl,v 1.6 2000/03/21 07:13:26 stephensk Exp $ #use Carp; BEGIN { use File::Basename; use Cwd 'fast_abs_path'; $progdir = fast_abs_path(dirname($0)); push(@INC, $progdir, "$progdir/lib/perl"); } use ion::_cvs::find; #eval 'use ion::_cvs::rlog;' || die "$!"; $opts = { }; $errors = 0; $opts->{collapse_comments} = 1; while ( $_ = $ARGV[0], s/^([-+])\1?// ) { my($pos) = $1 eq '-'; shift; if ( s/^f([^=]*=)?// ) { $opts->{filter} = $1 ? $_ : shift; } elsif ( s/^e([^=]*=)?// ) { $opts->{show_empty_entries} = $1 ? $_ : $pos; } elsif ( s/^c([^=]*=)?// ) { $opts->{collapse_comments} = $1 ? $_ : $pos; } elsif ( s/^x([^=]*=)?// ) { $opts->{auto_extend_rev_ranges} = $1 ? $_ : $pos; } elsif ( s/^s([^=]*=)?// ) { $opts->{show_rev_info} = $1 ? $_ : $pos; } } my(@entries); ion::_cvs::find(sub {push(@{$_[1]}, $_[0]); }, \@entries, @ARGV); @entries = sort { $a->fullpath() cmp $b->fullpath() } @entries; my($OUTPUT); $OUTPUT = 'STDOUT'; my($e); my($last_comments); ENTRY: foreach $e ( @entries ) { if ( $e->isFile ) { my($path) = $e->fullpath; $path =~ s@^\./@@; my($filter) = $opts->{filter}; if ( ! defined $filter ) { $filter = "-r:+"; } my($e_rev) = $e->revision; $filter =~ s/\+/$e_rev/g; my($rlog); # If a rev in a rev range does not exists, replace it with '' if ( $opts->{auto_extend_rev_ranges} ) { $rlog = $e->rlog(); if ( ! $rlog ) { $errors ++; next ENTRY; } if ( $filter =~ /-r(\S+)/ ) { my($b,$a) = ($`, $'); my($revs) = $1; if ( $revs =~ /^([^:]*):(.*)$/ ) { my($from, $to) = ($1, $2); if ( ! ($rlog->{revision}->{$from} || $rlog->{sym_name_to_rev}->{$from}) ) { #print STDERR "$path: no from rev '$from'\n"; $from = ''; } if ( ! ($rlog->{revision}->{$to} || $rlog->{sym_name_to_rev}->{$to}) ) { #print STDERR "$path: no to rev '$to'\n"; $to = ''; } $revs = $from . ':' . $to; my ($new_filter); $new_filter = $b . '-r' . $revs . $a; if ( $filter ne $new_filter ) { print STDERR "$path: filter = '$filter', new filter = '$new_filter'\n"; $filter = $new_filter; } } } # Redo log $e->clear_rlog(); } $rlog = $e->rlog({filter => $filter}); if ( ! rlog ) { $errors ++; next ENTRY; } if ( @{$rlog->{revisions}} || $opts->{show_empty_entries} ) { my($rev); if ( $opts->{show_rev_info} ) { print $OUTPUT "$path:\n"; foreach $rev ( @{$rlog->{revisions}} ) { my($r) = $rlog->{revision}->{$rev}; my($r_comments) = " " . join("\n ", split(/\n+/, $r->{comment})) . "\n"; print $OUTPUT " ", join(" ", map($r->{$_}, revision, date, author, state, lines), @{$r->{symbolic_names}}); print $OUTPUT ":\n"; print $OUTPUT $r_comments; } } else { my($comments) = ''; foreach $rev ( @{$rlog->{revisions}} ) { my($r) = $rlog->{revision}->{$rev}; my($r_comments) = " " . join("\n ", split(/\n+/, $r->{comment})) . "\n"; $comments .= $r_comments; } if ( $opts->{collapse_comments} ) { if ( $last_comments ne $comments ) { print $OUTPUT $last_comments, "\n" if ( defined $last_comments ); $last_comments = $comments; } print $OUTPUT $path, ":\n"; } else { print $OUTPUT $path, ":\n"; print $OUTPUT $comments, "\n"; } } } } } if ( $opts->{collapse_comments} ) { print $OUTPUT $last_comments, "\n" if ( defined $last_comments ); } exit($errors); 1; dbmi0.1/src/bin/cwfixlib.pl0100644000175200017560000000166106663227006016167 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: cwfixlib.pl,v 1.2 1999/02/19 09:25:26 stephensk Exp $ sub run { print join(" ", @_), "\n"; system(@_) && die "$!: Could not run " . join(" ", @_); } $lib = shift @ARGV; print "lib = '$lib'\n"; $LIB = $ENV{'LIB'}; $LIB = 'f:/apps/dev/msvc20/bin/lib.exe' if ( ! defined($LIB) ); open(NM, "nm $lib|"); @members = (); @exports = (); while ( ) { chop; if ( /^(.*\.obj):$/ ) { push(@members, $1); } elsif ( /^([0-9]+)\s+T\s+_([a-zA-Z0-9_]+)/ ) { push(@exports, $2); } } close(NM); print "members = ", join(" ", @members), "\n"; print "exports = ", join(" ", @exports), "\n"; $def = $lib; $def =~ m@^([^\\/]+)\.lib$@; $def = "$1.def"; print "def = '$def'\n"; open(DEF, ">$def"); print DEF "EXPORTS\n"; foreach ( @exports ) { print DEF "$_\n"; } close(DEF); &run($LIB, '/LIST', $lib); foreach ( @members ) { s@.*[\\/]@@; &run( $LIB, $lib, "/extract:$_"); } exit(0); 1; dbmi0.1/src/bin/d2u.pl0100744000175200017560000000570207230344164015047 0ustar stephensstepheng#!/usr/bin/perl # $Id: d2u.pl,v 1.8 2001/01/14 15:40:36 stephens Exp $ use File::Find; $save_bak = 0; $dos2unix = 1; $force = 0; $recursive = 1; $try_pattern = '(^Makefile)|(\.([chlym][a-zA-Z]?|make?|gdb|[ck]?sh|p[lm]|ll|scm|def|tcl)$)'; $ignore_pattern = '\.(o|a|obj|lib|exe|com)$'; @files = (); ARG: while ( defined ($_ = shift @ARGV) ) { if ( s/^--?// ) { if ( /^[h?]/ ) { print STDERR qq~ Version: ~ . '$Id: d2u.pl,v 1.8 2001/01/14 15:40:36 stephens Exp $' . qq~ Options: -d[os2unix] Convert dos to unix. Default. -u[nix2dos] Convert unix to dos. -p The file matching pattern. Default: '$try_pattern'. -i The file ingore pattern. Default: '$ignore_pattern'. -r Process recursively. Default. -s Save a backup file. -f Force a conversion. -- End processing options. ~; exit(0); } elsif ( /^d(os2unix)?/ ) { $dos2unix = 1; next ARG; } elsif ( /^u(nix2dos)?/ ) { $dos2unix = 0; next ARG; } elsif ( /^p/ ) { $try_pattern = shift @ARGV; next ARG; } elsif ( /^i/ ) { $ignore_pattern = shift @ARGV; next ARG; } elsif ( /^s/ ) { $save_bak ++; next ARG; } elsif ( /^f/ ) { $force ++; next ARG; } elsif ( /^$/ ) { last ARG; } } # must be a file name push(@files, $_); } push(@files, @ARGV); sub translate { my($dir, $in) = @_; my($out, $mode, $t); if ( ! ( -f $in && -r && -w && -T) ) { return 1; } if ( $in =~ /^(RCS|SCCS|CVS)/i ) { return 1; } $out = "$in.bak"; print STDERR "translate $dir/$in\n"; die "$dir/$out already exists: $!" if ( -e $out ); rename($in, $out) || die "Cannot rename $dir/$in to $dir/$out: $!"; $t = $in; $in = $out; $out = $t; # Rename all dotted cap name to all lowercase if ( $out =~ m@^[A-Z0-9_/.]+\.[A-Z0-9_]+$@ ) { $out =~ y/A-Z/a-z/; } $mode = (stat($in))[2]; open(IN, "<$in") || die "Cannot read $dir/$in: $!"; binmode(IN); open(OUT, ">$out") || die "Cannot write $dir/$out: $!"; binmode(OUT); if ( $dos2unix ) { while ( defined ($t = ) ) { chomp $t; $t =~s/\r$//; print OUT $t, "\n"; } } else { while ( defined ($t = ) ) { chomp $t; $t =~s/\r$//; print OUT $t, "\r\n"; } } close(IN); close(OUT); print STDERR " $dir/$in -> $dir/$out\n"; chmod($out, $mode); unlink($in) if ( ! $save_bak ); 0; } sub wanted { #print STDERR "$0 $File::Find::dir/$_\n"; if ( /^(RCS|SCCS|CVS)/i || ! $recursive ) { $File::Find::prune = 1; return 0; } return 0 if ( -d $_ ); if ( $force || (($try_pattern eq '' || /$try_pattern/oi) && ! ($ignore_pattern ne '' && /$ignore_pattern/oi)) ) { translate($File::Find::dir, $_); } else { print STDERR "ignoring $File::Find::dir/$_\n"; } 0; } push(@files, '.') if ( ! @files ); find(\&wanted, @files); 1; dbmi0.1/src/bin/ecd0100644000175200017560000000130506662461243014476 0ustar stephensstepheng#!/bin/sh #set -x exe="$1" if [ -z "$MAKE" ] then MAKE="${DEV_ROOT}/src/maks/bin/mak" fi prompt=" $exe: Command: " help=" 'return' to compile and debug '$exe' 'q' to quit 'c' to 'make clean' 'r' to complie and run 'd' to delete '!' to run a command 'h' for help " echo -n "$prompt" while read x do read y echo "" case "$x" in h*) echo "$help" ;; c*) $MAKE clean ;; q*|x*) exit 0 ;; d*) rm "$exe.exe" ;; r*) $MAKE && "$exe.exe" ;; !*) echo -n "shell cmd: " read x read y eval $x ;; *) $MAKE && gdb "$exe.exe" -x "$exe.gdb" ;; esac echo "" echo -n "$prompt" done dbmi0.1/src/bin/fe0100644000175200017560000000027606662461244014344 0ustar stephensstepheng#!/bin/sh out="$1" shift filter="$1" shift for f in $* do cmd="$out '$f' | $filter | awk '/^[^:]+:/ { pre = "'$1'"; } { print "'"'$f':"'", pre, "'$0'"; }'" #echo "$cmd" eval $cmd done dbmi0.1/src/bin/findsource0100644000175200017560000000014706662461244016110 0ustar stephensstepheng#!/bin/sh find $* \( \( -name '*.rtf*' -o -name '*.nib' \) -prune -print \) -o \( \! -type d -print \) dbmi0.1/src/bin/igrep0100644000175200017560000001464606774727305015075 0ustar stephensstepheng#!/run/pd/prod/bin/perl # stephensk@acm.org sub usage { print STDERR 'igrep [-nlirwvtuh] ', "\n"; print STDERR ' Version 1.1', "\n"; print STDERR ' options:', "\n"; print STDERR ' -n print line numbers', "\n"; print STDERR ' -l print each filename once', "\n"; print STDERR ' -i case insensitive', "\n"; print STDERR ' -r match pattern as a regexpr, not as a word', "\n"; print STDERR ' -w match pattern as a word, not a regexpr (default)', "\n"; print STDERR ' -v verbose output', "\n"; print STDERR ' -t check if index is up to date', "\n"; print STDERR " -u use index file (default '$indexname')", "\n"; print STDERR " -h this help message", "\n"; exit 1; } &usage if ( @ARGV < 1 ); $indexname = ".mkindex"; $verbose = 0; $matchwords = 1; $regexp = 0; $linenumbers = 0; $listonly = 0; $caseinsensitive = ''; $timecheck = 0; $countlines = 0; while ( @ARGV ) { $arg = shift; $verbose ++ if ( $arg =~ /^-.*v/i ); $matchwords = 0 if ( $arg =~ /^-.*r/i ); $regexp = 1 if ( $arg =~ /^-.*w/i ); $linenumbers = 1 if ( $arg =~ /^-.*n/i ); $listonly = 1 if ( $arg =~ /^-.*l/i ); $caseinsensitive = '(?i)' if ( $arg =~ /^-.*i/i ); $timecheck = 1 if ( $arg =~ /^-.*t/i ); $indexfile = shift if ( $arg =~ /^-.*u/i ); $countlines = 1 if ( $arg =~ /^-.*c/i ); if ( $arg =~ m/^-(\?|h)/i ) { &usage; } else { $pattern = $arg; } } ##################################################################### # Create key and line regexps @subpatterns = grep(length($_), split(/[^_a-zA-Z]+/, $pattern)); $patternIsOneWord = $matchwords && (scalar @subpatterns) == 1 && $caseinsensitive eq '' && ! $regexp; if ( $matchwords ) { if ( ! (scalar @subpatterns) == 1 ) { $pattern =~ s@([_a-zA-Z][_a-zA-Z0-9]*)@(\\B$1\\B)@g; } if ( ! $regexp ) { $pattern =~ s@([.*+()|\\\[\]])@\\$1@g; } $keypattern = '(^' . join('$)|(^', @subpatterns) . '$)'; } else { $keypattern = join('|', @subpatterns); } $pattern = $caseinsensitive . $pattern; $keypattern = $caseinsensitive . $keypattern; print STDERR "patternIsOneWord = '$patternIsOneWord'\n" if ( $verbose ); print STDERR "pattern = '$pattern'\n" if ( $verbose ); print STDERR "keypattern = '$keypattern'\n" if ( $verbose ); ##################################################################### # locate and open index file $index = $indexname; while ( ! -r $index ) { $index = "../$index"; if ( length($index) > 64 ) { die "Cannot find $indexname"; } } print STDERR "index = '$index'\n" if ( $verbose ); open(INDEX, "<$index") || die "Cannot open $index for reading: $!"; $indexM = -M $index; # get the modification time ##################################################################### # Read version string $_ = ; chop; die "expected 'mkindex', found '$_'" if ( $_ !~ /^mkindex /); $version = (split(/ /, $_, 2))[1]; ##################################################################### # Read timestamp $_ = ; chop; die "expected 'timestamp', found '$_'" if ( $_ !~ /^timestamp / ); $timestamp = (split(/ /, $_, 2))[1]; ##################################################################### # Read file table $_ = ; chop; die "expected 'files', found '$_'" if ( $_ !~ /^files / ); $n = (split(/ /, $_, 2))[1]; $files[$n] = undef; # preextend @files = (); print STDERR "nfiles: $n " if ( $verbose ); while ( $n -- ) { $_ = ; chop; print STDERR "$0: warning: $_ is newer than $index\n" if ( $timecheck && -r && -M $_ < $indexM ); push(@files,$_); print STDERR "." if ( $verbose > 1 ); } print STDERR "\n" if ( $verbose ); $_ = ; chop; die "expected blank line" if ( $_ ne ''); print STDERR "files: ", join("\n", @files), "\n" if ( $verbose > 2 ); ##################################################################### # Read index and remember any locations for keys that match the pattern $_ = ; chop; die "expected 'keys', found '$_'" if ( $_ !~ /^keys /); $n = (split(/ /, $_, 2))[1]; print STDERR "nkeys: $n " if ( $verbose ); @keys_matched = (); %filesmatched = (); while ( $n -- ) { $_ = ; chop; ($key, $locs) = split(/ /, $_, 2); if ( $key =~ m/$keypattern/o ) { push(@keys_matched, $key); $lastlineno = -1; foreach $loc ( split(/ /, $locs) ) { ($fileno, $lineno, $pos) = split(/:/, $loc); if ( $lastlineno != $lineno ) { $filesmatched{$fileno} .= "$lineno:$pos "; print STDERR $files[$fileno], ":", $lineno, "\n" if ( $verbose > 2 ); } $lastlineno = $lineno; } print STDERR "*" if ( $verbose > 1 ); last if ( $patternIsOneWord ); } else { print STDERR "." if ( $verbose > 1 ); } } print STDERR " ", scalar @keys_matched, " keys matched\n" if ( $verbose ); print STDERR "keys matched: '", join("', '", @keys_matched), "'\n" if ( keys_matched && $verbose > 1); if ( ! $patternIsOneWord ) { $_ = ; chop; die "expected blank line" if ( $_ ne ''); } #print STDERR "keys: ", join("\n", sort(keys(%index))), "\n" if ( $verbose > 2 ); close(INDEX); ##################################################################### # %getline_cannotopen = (); $getline_FILE_file = ''; sub getline { # file, pos my ($file, $pos) = @_; my ($line); if ( $getline_FILE_file ne $file ) { $getline_FILE_file = $file; close(FILE); if ( ! open(FILE, "<$file") ) { print STDERR "$0: cannot open $file: $!\n" if ( ! $getline_cannotopen{$file} ++ ); return; } } while ( 1 ) { seek(FILE, $pos, 0); read(FILE, $line, 1); last if ( $line eq "\n" ); if ( -- $pos < 0 ) { seek(FILE, 0, 0); last; } } $line = ; chop $line; $line; } # Print each line no that matches sub numerically { $a <=> $b } $linematches = 0; FILE: foreach $fileno ( sort(keys(%filesmatched)) ) { $file = $files[$fileno]; $lastlineno = -1; %locs = (); foreach $loc ( split(/ /, $filesmatched{$fileno}) ) { ($lineno, $pos) = split(/:/, $loc); if ( $lastlineno != $lineno ) { $locs{$lineno} = $pos; } $lastlineno = $lineno; } foreach $lineno ( sort numerically (keys(%locs)) ) { if ( defined($line = &getline($file, $locs{$lineno})) ) { if ( $line =~ m/$pattern/o ) { $linematches ++; if ( $countlines ) { next FILE; } if ( $listonly ) { print $file, "\n"; next FILE; } print $file, ":"; print $lineno, ":" if ( $linenumbers ); print $line, "\n"; } } } } print $linematches, "\n" if ( $countlines ); exit(! $linematches); 0; dbmi0.1/src/bin/linkdups0100644000175200017560000000120706662461243015575 0ustar stephensstepheng#!/bin/sh find . -type f -print | sed 's!\./!!g' > /tmp/$$.names #cat /tmp/$$.names EXEC=echo EXEC= while read f1 do while read f2 do # `/bin/expr length "$f1"` -lt `/bin/expr length "$f2"` if [ "$f1" != "$f2" -a ! \( -h "$f1" -o -h "$f2" \) ] then if /bin/cmp -s "$f1" "$f2" then r2=`expr "$f2" : '\(.*/\).*' '|' "$f2"` r2=`echo "$r2" | sed 's@[^/]*/@../@g'` f1r="$r2$f1" #echo "f1=$f1 f2=$f2 f1r=$f1r" if [ "$f1r" != "$f2" ] then echo "$f2 -> $f1r" /bin/rm -f "$f2" /bin/ln -s "$f1r" "$f2" fi fi fi done < /tmp/$$.names done < /tmp/$$.names dbmi0.1/src/bin/locstatic0100644000175200017560000000253106662461244015733 0ustar stephensstepheng#!/bin/sh -- # -*- perl -*- eval 'exec /run/thirdParty/perl5/bin/perl $0 ${1+"$@"}' if 0; # print "$0: ", join(" ", @ARGV), "\n"; $pat = '\W(static\s+(id|\w+\s*\*)\s[^;(){}]*;)'; #$pat = '(static)'; sub scanFileForStatic { my($file) = @_; my($lineno,$s); #select(STDERR); $| = 1; select(STDOUT); #print STDERR "$file \r"; open(FILE,"<$file") || print STDERR "$0: cannot open $file for reading: $!\n"; $lineno = 0; while ( $lineno ++, $_ = ) { $s .= $_; while ( $s =~ s@$pat@@m ) { $s = $'; print "$file: $lineno: $1\n"; } } while ( $s =~ s@$pat@@m ) { $s = $'; print "$file: $lineno: $1\n"; } close(FILE); 0; } sub readDir { my($dirname) = @_; my(@dirlist); opendir(DIR,"$dirname") || print STDERR "$0: cannot open $dirname for reading: $!\n"; @dirlist = readdir(DIR); closedir(DIR); @dirlist = grep(!($_ eq '.' || $_ eq '..' || $_ eq 'SCCS' || $_ eq 'RCS'), @dirlist); # print STDERR "$0: ", join(" ", @dirlist), "\n"; @dirlist; } sub scanFiles { my(@files) = @_; my($f,$ff); foreach $f ( @files ) { if ( -d $f ) { foreach $ff ( readDir($f) ) { scanFiles("$f/$ff"); } } else { scanFileForStatic($f) if $f =~ m/\.[hmc]$/; } } 0; } # print "$0: ", join(" ", @ARGV), "\n"; scanFiles(@ARGV); 0; dbmi0.1/src/bin/lsup0100644000175200017560000000040306774730305014726 0ustar stephensstepheng#!/bin/sh # $Id: lsup,v 1.2 1999/09/30 18:49:41 stephensk Exp $ # stephensk@acm.org # if [ $# -eq 0 ] then set `pwd` fi while [ $# -gt 0 ] do f="$1" while [ -n "$f" ] do /bin/ls -lagd "$f" f=`/bin/expr "$f" : '\(.*\)/.*'` done shift done dbmi0.1/src/bin/mergefiles.pl0100644000175200017560000001452506663227006016505 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: mergefiles.pl,v 1.2 1999/02/19 09:25:26 stephensk Exp $ # Creates a shell script to merge two directories # based on file modification time and size. # Also generates diffs for files that do not have the same mod time and size # sub ignore_files { grep(! (/\.(o|obj|a|lib|dll|exe|core)$/ || /^\.saves/ || /^CYGWIN/ || /^pilot$/ || /~$/ ), @_); } sub cmd { print "@_\n"; } sub mkdir_p_ { my($dstp) = @_; $dstp =~ s@/[^/]+$@@; cmd("mkdir -p $dstp"); } sub rm_rf { cmd("rm -rf $_[0]"); } sub cp_rp { mkdir_p_($_[1]); cmd("cp -rp @_"); } sub _cp_rp { cmd("#cp -rp @_"); } sub date_str { my($s,$m,$h,$D,$M,$Y,$W,$YD,$dst) = gmtime($_[0]); $s = '0' . $s if ( $s < 10 ); $m = '0' . $m if ( $m < 10 ); $h = '0' . $h if ( $h < 10 ); $Y += 1900; $M ++; $M = '0' . $M if ( $M < 10 ); "$Y/$M/$D-$h:$m:$s"; } sub M_str { my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]); date_str($mtime); } sub get_dir { my(@dir); opendir(DIR, $_[0]) || return ( 0, $! ); @dir = grep($_ ne '.' && $_ ne '..', readdir(DIR)); closedir(DIR); (1, @dir); } sub merge_paths { my(@p) = @_; my(@e) = map(-e $_, @p); my(@f) = map(-f $_, @p); my(@d) = map(-d $_, @p); my(@s) = map(-s $_, @p); my(@M) = map(-M $_, @p); my(@pd) = map((s@/[^/]+@@, $_), @_); my(@pM) = map(-M $_, @pd); my(@d0, @d1); my($delete, $choose) = ( 0, -1 ); #print STDERR "p = ", "@p", "\n"; #print STDERR "e = ", "@e", "\n"; #print STDERR "f = ", "@f", "\n"; #print STDERR "d = ", "@d", "\n"; #print STDERR "s = ", "@s", "\n"; #print STDERR "M = ", "@M", "\n"; if ( ! $e[0] && ! $e[1] ) { # Both do not exist return; } elsif ( $e[0] && ! $e[1] ) { # d0/f0 exists and d1/f1 does not exists # if d0 is older than d1 if ( $pM[0] < $pM[1] ) { cmd("# $p[1] does not exist and $pd[0] is newer than $pd[1]"); $choose = 2; $delete = 1; } else { cmd("# $p[1] does not exist"); $choose = 1; } } elsif ( ! $e[0] && $e[1] ) { if ( $pM[1] < $pM[0] ) { cmd("# $p[0] does not exist and $pd[1] is newer than $pd[0]"); $choose = 1; $delete = 1; } else { cmd("# $p[0] does not exist"); $choose = 2; } } elsif ( $f[0] && $f[1] ) { if ( $M[0] < $M[1] ) { cmd("# $p[0] is newer than $p[1]"); $choose = 1; } elsif ( $M[0] > $M[1] ) { cmd("# $p[1] is newer than $p[0]"); $choose = 2; } elsif ( $s[0] == $s[1] ) { cmd("# $p[0] is the same time and size as $p[1]"); return; } } elsif ( $d[0] && $d[1] ) { my(@d0, @d1); my($f, $f_last); @d0 = get_dir($p[0]); shift @d0; #print STDERR "d0 = @d0\n"; @d1 = get_dir($p[1]); shift @d1; #print STDERR "d1 = @d1\n"; push(@d0, @d1); @d0 = ignore_files(sort(@d0)); F: foreach $f ( @d0 ) { next F if ( $f_last eq $f ); $f_last = $f; merge_paths($p[0] . "/" . $f, $p[1] . "/" . $f); } return; } else { cmd("#!!!! $p[0] is a " . $d[0] ? "dir" : "file" . ", $p[1] is a " . $d[1] ? "dir" : "file"); } my $get_cmd = $choose == -1; while ( $get_cmd ) { print STDERR join("\t", "1[", $p[0], $s[0], M_str($p[0]), "]"), "\n"; print STDERR join("\t", "2[", $p[1], $s[1], M_str($p[1]), "] :", $choose), " > "; $_ = ; chop; $choose = $1 if ( /([0-9]+)/ ); $delete = /d/; if ( $choose == 3 ) { system("diff -r $p[0] $p[1]"); } else { $get_cmd = 0 if ( $choose != -1 ); } } if ( $choose == 0 ) { $get_cmd = 0; } else { $choose --; if ( $delete ) { rm_rf($p[$delete - 1]); } else { cp_rp($p[$choose], $p[1 - $choose]); } } } sub merge_paths3 { # p0, p1, mp my(@p) = @_; my(@e) = map(-e $_, @p); my(@f) = map(-f $_, @p); my(@d) = map(-d $_, @p); my(@s) = map(-s $_, @p); my(@M) = map(-M $_, @p); my(@pd) = map((s@/[^/]+@@, $_), @_); my(@pM) = map(-M $_, @pd); my(@d0, @d1); my($delete, $choose) = ( 0, -1 ); #print STDERR "p = ", "@p", "\n"; #print STDERR "e = ", "@e", "\n"; #print STDERR "f = ", "@f", "\n"; #print STDERR "d = ", "@d", "\n"; #print STDERR "s = ", "@s", "\n"; #print STDERR "M = ", "@M", "\n"; if ( ! $e[0] && ! $e[1] ) { # Both do not exist } elsif ( $e[0] && ! $e[1] ) { # d0/f0 exists and d1/f1 does not exists # if d0 is older than d1 cmd(""); if ( $pM[0] < $pM[1] ) { cmd("# $p[1] does not exist and $pd[0] is newer than $pd[1]"); } else { cmd("# $p[1] does not exist"); } cp_rp($p[0], $p[2]); } elsif ( ! $e[0] && $e[1] ) { cmd(""); if ( $pM[1] < $pM[0] ) { cmd("# $p[0] does not exist and $pd[1] is newer than $pd[0]"); } else { cmd("# $p[0] does not exist"); } cp_rp($p[1], $p[2]); } elsif ( $f[0] && $f[1] ) { cmd(""); if ( $M[0] < $M[1] ) { cmd("# $p[0] is newer than $p[1]"); $choose = 0; } elsif ( $M[0] > $M[1] ) { cmd("# $p[1] is newer than $p[0]"); $choose = 1; } elsif ( $s[0] == $s[1] ) { cmd("# $p[0] is the same time and size as $p[1]"); $choose = 0; cp_rp($p[$choose], $p[2]); return; } cp_rp($p[$choose], $p[2]); _cp_rp($p[1 - $choose], $p[2]); # Do a diff $tmp = "$$.diff"; $cmd = "diff -cd \"$p[1 - $choose]\" \"$p[$choose]\""; system("$cmd > \"$tmp\""); $choose = 0; open(F, "<$tmp"); while ( $_ = ) { chop; if ( ! $choose ) { cmd("# $cmd "); $choose = 1; } cmd("# $_"); } close(F); cmd("##############################################") if ( $choose ); unlink($tmp); } elsif ( $d[0] && $d[1] ) { my(@d0, @d1); my($f, $f_last); my($errors) = 0; @d0 = get_dir($p[0]); if ( ! shift @d0 ) { print STDERR "$p[0]: ", @d0; $errors ++; } else { shift @d0; } @d1 = get_dir($p[1]); if ( ! shift @d1 ) { print STDERR "$p[1]: ", @d1; $errors ++; } if ( $errors ) { return; } push(@d0, @d1); @d0 = ignore_files(sort(@d0)); F: foreach $f ( @d0 ) { next F if ( $f_last eq $f ); $f_last = $f; merge_paths3($p[0] . "/" . $f, $p[1] . "/" . $f, $p[2] . "/" . $f); } } else { cmd(""); cmd("#!!!! $p[0] is a " . $d[0] ? "dir" : "file" . ", $p[1] is a " . $d[1] ? "dir" : "file"); } } cmd("#!/bin/sh"); cmd("# $0 " . join(" ", @ARGV)); cmd("set -x"); #if ( $#ARGV == 3 ) { merge_paths3(@ARGV); #} else { # merge_paths(@ARGV); #} 1; dbmi0.1/src/bin/mkindex0100644000175200017560000000365506774727305015424 0ustar stephensstepheng#!/run/pd/prod/bin/perl # stephensk@acm.org $version = 1.1; $indexname = $index = ".mkindex"; $verbose = 0; while ( @ARGV ) { $arg = shift; $verbose ++ if ( $arg =~ /^-.*v/ ); } # open the index file open(INDEX, ">$index") || die "Cannot open $index for writing: $!"; $INDEX = "INDEX"; # get a list of files from stdin @files = (); while ( <> ) { chop; s@^\./@@; push(@files,$_) if ( -r && -T && ! m@(^|/)$indexname$@o ); } %index = (); print STDERR "$0: indexing ", (scalar @files), " files: " if ( $verbose ); $nentries = 0; $fileindex = -1; foreach ( @files ) { $fileindex ++; $lineno = 0; $pos = 0; open(FILE, "<$_") || next; $nkeys = 0; while ( $line = ) { print STDERR "$line\n" if ( $verbose > 1 ); $lineno ++; while ( $line =~ m/([_a-zA-Z][_a-zA-Z0-9]*)/g ) { $linepos = $pos + (pos $line) - length($1); $index{$1} .= "$fileindex:$lineno:$linepos "; print STDERR "$fileindex:$lineno:$linepos " if ( $verbose > 2 ); $nkeys ++; $nentries ++; } $pos += length($line); } close(FILE); print STDERR "$nkeys " if ( $verbose > 1 ); print STDERR "." if ( $verbose ); } print STDERR "\n" if ( $verbose ); ##################################################################### # Create a unique list of keys @keys = sort(keys(%index)); print STDERR "$0: ", scalar @keys, " unique keys, $nentries citations\n" if ( $verbose ); ##################################################################### # Write version string print $INDEX "mkindex $version\n"; # Write timestamp print $INDEX "timestamp ", time, "\n"; # Write file table print $INDEX "files ", scalar @files, "\n"; print $INDEX join("\n", @files); print $INDEX "\n\n"; # Write index print $INDEX "keys ", scalar @keys, "\n"; foreach ( sort(keys(%index)) ) { print $INDEX "$_ $index{$_}\n"; } print $INDEX "\n\n"; close(INDEX); ##################################################################### 0; dbmi0.1/src/bin/mvr.pl0100644000175200017560000000331307001176324015151 0ustar stephensstepheng#!/usr/bin/perl use File::Find; package mvr; sub wanted { my($dir) = $File::Find::dir; my($old, $new); $old = $new = $_; print STDERR "$dir/$old\n" if ( $mvr::verbose > 1 ); if ( &mvr::match($new) ) { if ( $mvr::interactive ) { print STDERR "mv $dir/$old $dir/$new? [y] "; my($line); $line = ; return 0 if ( $line !~ /y/i ); } print STDERR "mv $dir/$old $dir/$new\n" if ( $mvr::verbose || $mvr::debug ); if ( ! $mvr::debug ) { my($tmp) = "$new.$$"; die "$dir/$tmp exists" if ( -e $tmp ); rename($old, $tmp) || die "mv $dir/$old $dir/$tmp failed: $!"; rename($tmp, $new) || print STDERR "mv $dir/$old $dir/$new: $!\n"; } } 0; } sub mvr { $mvr::debug = 0; $mvr::verbose = 1; $mvr::interactive = 0; while ( defined ($_ = shift @_) ) { if ( s/^--?// ) { while ( s/i(nteractive)?// ) { $mvr::interactive ++; } while ( s/d(ebug)?// ) { $mvr::debug ++; } while ( s/v(erbose)?// ){ $mvr::verbose ++; } if ( s/[h?]// ) { print STDERR qq~ $0 [-dvi] FROM TO Rename all files that match regexpr FROM to TO under the current directory. Options: -d[ebug] Enable debugging, does not actually rename. -i[interactive] Interactive; prompts on stderr for confirmation. -v[erbose] Enable verbose messages. -?|-h[elp] This help message. ~; return 1; } } else { $o = $_; $n = shift @_; if ( defined $n ) { print STDERR "mvr $o $n\n" if ( $verbose ); eval 'sub mvr::match { $_[0] =~ s/^' . $o . '$/' . $n . '/; }'; File::Find::find(\&wanted, '.'); } } } 0; } #print STDERR "$0\n"; if ( $0 =~ m@/mvr.pl$@ ) { mvr(@ARGV); } 1; dbmi0.1/src/bin/nmlibs0100644000175200017560000000042706662461243015233 0ustar stephensstepheng#!/bin/sh if [ -z "$LIBDIRS" ] then LIBDIRS="/lib /usr/lib" fi LIBDIRS="$* $LIBDIRS" for d in $LIBDIRS do (cd $d for f in lib*.a *.o do nm -gp "$f" | awk ' BEGIN { name = "'$d/$f'"; } /^.*:/ { name = "'$d'/" $1; } { print name, $0, "\n"; }' done ) done dbmi0.1/src/bin/nmm0100755000175200017560000000010006662461243014525 0ustar stephensstepheng#!/bin/sh for f do nm "$f" | awk '{ print "'$f'", $0; }' done dbmi0.1/src/bin/objcsyms0100644000175200017560000000457306662461244015607 0ustar stephensstepheng#!perl $tmp || ($tmp = $ENV{'TEMP'}); $tmp || ($tmp = $ENV{'TMP'}); $tmp || ($tmp = '/tmp/'); $symbols = (); $nm = '/bin/nm'; $dumpbin = 'dumpbin'; if ( -e $nm ) { # NeXT eval q@ $libprefix = 'lib'; $libsuffix = '.a'; $frameworksuffix = ''; sub refsym { $v && print STDERR "$0: refsym: $_[0]\n"; print C 'asm(".reference ', $_[0], '");', "\n"; } sub do_ObjC_symbols { open(F,"$nm -gp $_ |") || die "$!: cannot read $_"; while ( ) { if ( /\s+[ATDB]\s+(.objc_(class|category)_name_[a-zA-Z0-9_]+)/ ) { &refsym($1); } } close(F); } @; } else { # WinNT eval q@ $libprefix = ''; $libsuffix = '.lib'; $frameworksuffix = '.lib'; sub refsym { $v && print STDERR "$0: refsym: $_[0]\n"; print C 'asm(".global ', $_[0], '");', "\n"; } sub do_ObjC_symbols { open(F,"$dumpbin /symbols /exports $_ |") || die "$!: cannot read $_"; while ( ) { if ( /\s+External\s+(.objc_(class|category)_name_[a-zA-Z0-9_]+)/ ) { &refsym($1); } } close(F); } @; } @libs = (); @libpaths = ("/usr/lib", "/lib"); @frameworkpaths = ("$NEXT_ROOT/LocalLibrary/Frameworks", "$NEXT_ROOT/NextLibrary/Frameworks"); sub findinpath { $f = shift @_; while ( $_ = shift @_ ) { $ft = $_ . '/' . $f; $v && print "$0: try: $ft\n"; if ( -e $ft ) { $v && print "$0: found: $ft\n"; return $ft; } } 0; } $ObjC = 0; $v = 0; $cf = "$tmp$$.c"; while ( $_ = shift @ARGV ) { push(@args, $_); if ( /^-(o|b|V|include|imacros|idirafter|iprefix|iwithprefix)$/ ) { shift @ARGV; } elsif ( /^-ObjC(++)?$/ ) { $ObjC ++; push(@args, $cf); } elsif ( /^-v$/ ) { $v ++; } elsif ( /^-L(.+)$/ ) { push(@libpaths, $1); } elsif ( /^-l(.+)$/ ) { if ( $ft = &findinpath("$libprefix$1$libsuffix", @libpaths) ) { push(@libs, $ft); } } elsif ( /^-F(.+)$/ ) { push(@frameworkpaths, $1); } elsif ( /^-framework$/ ) { push(@args, $_ = shift @ARGV); if ( $ft = &findinpath("$_.framework/$_$frameworksuffix", @frameworkpaths) ) { push(@libs, $ft); } } } if ( $ObjC ) { open(C,">$cf") || die "$!: cannot create $cf"; &refsym('_main'); # force linking foreach ( @libs ) { &do_ObjC_symbols(); } close(C) || die "$!: cannot close $cf"; push(@args, $cf); } else { $cf = 0; } $v && print STDERR join(" ", @args), "\n"; $errors = system(@args) / 256; $cf && unlink($cf); exit $errors; 1; #PERLEND dbmi0.1/src/bin/publish.pl0100644000175200017560000004341507306137336016032 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: publish.pl,v 1.10 2001/06/02 10:09:00 stephens Exp $ # TO DO # * Fix problems with non "../" REQUIRES_PKGS # ############################################################################## use Carp; use File::Basename; use Cwd; # fastgetcwd use Cwd 'fast_abs_path'; $progdir = fast_abs_path(dirname($0)); push(@INC, $progdir, "$progdir/lib/perl"); eval 'use ion::_cvs::revhist;'; ############################################################################## $time = time(); { my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($time); $sec = '0' . $sec if ( $sec < 10 ); $min = '0' . $min if ( $min < 10 ); $hour = '0' . $hour if ( $hour < 10 ); $mon ++; $mon = '0' . $mon if ( $mon < 10 ); $mday = '0' . $mday if ( $mday < 10 ); $year += 1900; $timestr = "$year/$mon/$mday $hour:$min:$sec"; } ############################################################################## $tmp_root = "/usr/tmp"; $tmp_root = fast_abs_path($tmp_root); $tmp = "$tmp_root/t" . abs($$); mkdir($tmp, 0777) || die "$!: $tmp"; sub END { #print STDERR "in END\n"; system("rm", "-rf", $tmp) if ( $tmp ); } ############################################################################## $sep = '=' x 78; sub basename { my($x) = @_; $x =~ s@^.*[/\\]@@; $x; } sub dirname { my($x) = @_; #print STDERR "dirname('$x') = "; if ( $x !~ s@[/\\][^/\\]+$@@ ) { $x = '.'; } #print STDERR "'$x'\n"; $x; } sub absname { my($x) = @_; #print STDERR "absname('$x') = "; if ( $x !~ m@^([a-zA-Z]:)?[/\\]@ ) { $x = fastgetcwd() . '/' . $x; } #print STDERR "'$x'\n"; $x; } sub unix_path { my($x) = @_; #print STDERR "unix_path('$x') = "; $x =~ y@\\@/@; $x !~ s@^([a-zA-Z]):@//$1@; #print STDERR "'$x'\n"; $x; } sub mkdirs { my($p, $m) = @_; if ( ! defined($m) ) { $m = 0777; } if ( -d $p ) { 1; } else { my($pdir) = dirname($p); if ( ! -d $pdir ) { mkdirs($pdir, $m); } mkdir($p, $m); } } sub appendFileToHandle { my($in,$OUT) = @_; open(__F, "<$in"); while ( $in = <__F> ) { print $OUT $in; } close(__F); } sub readFile { my($r, $l); open(__F, "<$_[0]") || return; $r = ''; while ( $l = <__F> ) { $r .= $l; } close(__F); $r; } sub copyFile { my($src, $dst) = @_; my($l); open($src, "<$src") || die "$src: $!:"; open($dst, ">$dst") || die "$dst: $!:"; while ( $l = <$src> ) { print $dst $l; } close($src); close($dst); } sub readVars { my($file, $vars, $stopAtEmptyLine) = @_; $vars = {} if ( ! $vars ); open(F, "<$file") || return; LINE: while ( $_ = ) { chop; s/^\s+//; s/\s+$//; if ( /^\s*#/ ) { next LINE; } if ( $_ eq '' && $stopAtEmptyLine ) { last LINE; } my($key, $value) = (undef, undef); # KEY if ( s/^\s*([A-Za-z_0-9]+)// ) { $key = $1; # ='VALUE' if ( m/^\s*=\s*'([^']*)'\s*$/ ) { #' $value = $1; # ="VALUE" } elsif ( m/^\s*=\s*"([^"]*)"\s*$/ ) { #" $value = $1; # =VALUE } elsif ( m/^\s*=(.*)$/ ) { $value = $1; # [ ]VALUE } elsif ( m/^\s?(.*)$/ ) { $value = $1; } else { print STDERR "$0: unparsed line in $file: $key $_\n"; } } if ( defined($key) && defined($value) ) { $value =~ s/^\s+//; $value =~ s/\s+$//; $vars->{$key} = $value; } } close(F); $vars; } sub readPKG { my($pkg); $pkg = {}; $pkg->{src} = $_[0]; $pkg->{src_abs} = fast_abs_path($pkg->{src}); $pkg->{src_name} = basename($pkg->{src_abs}); $pkg->{src_dir} = dirname($pkg->{src_abs}); # Defaults $pkg->{NAME} = $pkg->{src_name}; $pkg->{README} = "README"; $pkg->{VERSION} = readFile("$pkg->{src}/VERSION"); $pkg->{VERSION} =~ y/\n/ /; $pkg->{VERSION} =~ s/^\s+//; $pkg->{VERSION} =~ s/\s+$//; $pkg->{CVSLOG} = 'CVSLOG'; $pkg->{DESC} = ''; $pkg->{CATEGORY} = ''; $pkg->{REQUIRES_PKGS} = ''; $pkg->{REQUIRES_OTHERS} = ''; $pkg->{MAKE} = 'make'; $pkg->{MAKE_CLEAN} = 'clean veryclean'; $pkg->{subpkgs} = []; $pkg->{parent} = $pkg; $pkg->{root} = $pkg; readVars("$pkg->{src}/PKG", $pkg); die "Package $pkg->{src} has no NAME" if ( $pkg->{NAME} eq '' ); print STDERR " WARNING: $pkg->{src_abs} has no VERSION\n" if ( $pkg->{VERSION} eq '' ); print STDERR " WARNING: $pkg->{src_abs} has no CATEGORY\n" if ( $pkg->{CATEGORY} eq '' ); print STDERR " WARNING: $pkg->{src_abs} has no DESC\n" if ( $pkg->{DESC} eq '' ); $pkg; } sub parsePkg { my($pkg, @more) = @_; my($pcwd); # Determine the copy dst $pkg->{dst} = $pkg->{root}->{dst_root} . "/" . $pkg->{src_name}; # Attempt to cd into package $pcwd = getcwd(); chdir($pkg->{src}) || die "chdir: $!: $pkg->{src}"; # Don't visit a package more than once if ( $pkg->{root}->{parsed}->{$pkg->{src_abs}} ) { return; } $pkg->{root}->{parsed}->{$pkg->{src_abs}} ++; # Add package to parent and root push(@{$pkg->{parent}->{subpkgs}}, $pkg); push(@{$pkg->{root}->{subpkgs_flat}}, $pkg); # Collect the other pkgs #print STDERR "REQUIRES_OTHERS='$pkg->{REQUIRES_OTHERS}'\n"; @others = split(/\s+/, $pkg->{REQUIRES_OTHERS}); $pkg->{others} = [ @others ]; # Add others to root foreach $r ( @others ) { $pkg->{root}->{others_map}->{$r} ++; } @{$pkg->{root}->{others_flat}} = sort(keys(%{$pkg->{root}->{others_map}})); # Collect subpkgs foreach $r ( split(/\s+/, $pkg->{REQUIRES_PKGS}), @more ) { my($subpkg) = readPKG($r); $subpkg->{parent} = $pkg; $subpkg->{root} = $pkg->{root}; parsePkg($subpkg); } # chdir($pcwd) || die "chdir: $!: $pcwd"; } sub copyPkg { my($rpkg) = @_; my($pkg); foreach $pkg ( @{$rpkg->{subpkgs_flat}} ) { # Copy the package into the dst area print STDERR " Copying $pkg->{src_abs} $pkg->{dst}\n"; mkdirs($pkg->{dst}, 0777); $src = unix_path($pkg->{src_abs}); $dst = unix_path($pkg->{dst}); system("sh -c '$tar -C $src -cf - . | $tar -C $dst -x${tar_verbose}f -'") && die "tar: $!"; print STDERR " Copying $pkg->{src_abs} $pkg->{dst}: DONE\n\n"; } } sub cleanPkg { my($rpkg) = @_; my($pkg); foreach $pkg ( @{$rpkg->{subpkgs_flat}} ) { # Clean up the dst area if ( -r "$pkg->{dst}/Makefile" ) { print STDERR " Cleaning $pkg->{dst}\n"; $dst = unix_path($pkg->{dst}); system("sh -c 'cd $dst && eval $pkg->{MAKE} __DISABLE_DEPS__=YES $pkg->{MAKE_CLEAN}'"); print STDERR " Cleaning $pkg->{dst}: DONE\n\n"; } } } sub commitPkg { my($rpkg) = @_; my($pkg); if ( defined($CVSROOT) ) { foreach $pkg ( @{$rpkg->{subpkgs_flat}} ) { # Clean up the dst area if ( -d "$pkg->{dst}/CVS" ) { my($msg, $cmd); # Commit print STDERR " Committing $pkg->{dst}\n"; $msg = "PUBLISH_$rpkg->{NAME}$rpkg->{VERSION}"; $cmd = "$CVS commit -m \"$msg\" $pkg->{dst}"; print STDERR " $cmd\n"; system($cmd) && die "$cmd"; print STDERR " Committing $pkg->{dst}: DONE\n\n"; # Tag $msg = "PUBLISH_$rpkg->{NAME}$rpkg->{VERSION}"; $msg =~ tr/A-Za-z0-9_/_/c; print STDERR " Tagging $pkg->{dst} as $msg\n"; $cmd = "$CVS tag "; $cmd .= "-F " if ( $force ); $cmd .= "-c $msg $pkg->{dst}"; print STDERR " $cmd\n"; system($cmd) && die "$cmd"; print STDERR " Tagging $pkg->{dst} as $msg: DONE\n\n"; # Log #print STDERR " Logging CVS versions $pkg->{dst}\n"; #$cmd = "$CVS log -h -N -r$msg $pkg->{dst} > $pkg->{dst}/$pkg->{CVSLOG}"; #print STDERR " $cmd\n"; #system($cmd) && die "$cmd"; #print STDERR " Logging CVS versions $pkg->{dst}: DONE\n\n"; } } } } sub createPkgFiles { my($rootpkg) = @_; foreach $pkg ( @{$rootpkg->{subpkgs_flat}} ) { # Append README $file = "$pkg->{dst}/$pkg->{README}"; if ( $pkg->{README} ne '' && -r $file ) { print dst_README "$pkg->{NAME} $pkg->{VERSION} README\n"; print dst_README "$sep\n"; appendFileToHandle($file, 'dst_README'); } # Append PUB { my(%x); %x = %$pkg; $x{SRC_DIR} = $x{src_abs}; foreach $k ( NAME, VERSION, CATEGORY, DESC, SRC_DIR ) { print PUB $k, " ", $x{$k}, "\n"; delete $x{$k}; } foreach $k ( sort(grep(/^[A-Z_0-9]+$/, keys(%x))) ) { print PUB $k, " ", $x{$k}, "\n"; } print PUB "\n"; } } foreach $r ( @{$rootpkg->{others_flat}} ) { print PUB "OTHER $r\n\n"; } } sub createPkg { my $pkg; $pkg = readPKG($_[0]); print STDERR "Publishing $_[0]\n"; $dst_name = "$pkg->{src_name}$pkg->{VERSION}"; $dst_dir = "$tmp/$dst_name"; $dst_root = "$dst_dir/src"; mkdirs($dst_root, 0777) || die "$dst_root: $!"; $pkg->{dst_root} = $dst_root; $pkg->{parsed} = {}; $pkg->{others_map} = {}; $pkg->{subpkgs_flat} = []; $pkg->{others_flat} = []; ######################################################################### # Recursively parse packages parsePkg($pkg); ######################################################################### # Copy the entire package copyPkg($pkg); ######################################################################### # Clean the entire package cleanPkg($pkg); ######################################################################### # CVS commit the entire package commitPkg($pkg); ######################################################################### # The files we are going to publish $filev = $pkg->{src_name} . $pkg->{VERSION}; $txt = "$PUBLISH_DIR/$filev.txt"; $archive = "$PUBLISH_DIR/$filev.tgz"; $pub = "$PUBLISH_DIR/$filev.pub"; ######################################################################### # Init PUB file die "$pub already exists, try -force option" if ( -f $pub && ! $force ); open(PUB, ">$pub") || die "$pub: $!"; print PUB "NAME $pkg->{NAME}\n"; print PUB "VERSION $pkg->{VERSION}\n"; print PUB "CATEGORY $pkg->{CATEGORY}\n"; print PUB "DESC $pkg->{DESC}\n"; @subpkg_names = map($_->{NAME}, @{$pkg->{subpkgs_flat}}); print PUB "CONTAINS_PKGS ", join(' ', @subpkg_names), "\n"; print PUB "REQUIRES_OTHERS ", join(' ', @{$pkg->{others_flat}}), "\n"; print PUB "DATE $timestr\n"; #print PUB "MD5 $\n"; print PUB "README $txt\n"; print PUB "ARCHIVE $archive\n"; print PUB "\n"; ################################################################## # Init README, TOC files $dst_README = "$dst_dir/README"; open(dst_README, ">$dst_README") || die "$dst_README: $!"; print dst_README "$pkg->{NAME} $pkg->{VERSION} README\n"; print dst_README "$sep\n\n"; ################################################################## # Add GUM_BUILD_ROOT $GUM_BUILD_ROOT = "$pkg->{src_abs}/../GUM_BUILD_ROOT"; if ( -r $GUM_BUILD_ROOT ) { copyFile($GUM_BUILD_ROOT, "$dst_dir/src/GUM_BUILD_ROOT"); } ################################################################## # Add copyright $COPYRIGHT = "$pkg->{src_abs}/../COPYRIGHT"; if ( -r $COPYRIGHT ) { copyFile($COPYRIGHT, "$dst_dir/COPYRIGHT"); } appendFileToHandle($COPYRIGHT, dst_README); print dst_README "\n$sep\n\n"; ################################################################## # Add license $LICENSE = "$pkg->{src_abs}/../LICENSE"; if ( -r $LICENSE ) { copyFile($LICENSE, "$dst_dir/LICENSE"); appendFileToHandle($LICENSE, dst_README); print dst_README "\n$sep\n\n"; } ################################################################## # Create CHANGES $dst_CHANGES = "$dst_dir/CHANGES"; print STDERR " Creating CHANGES $dst_CHANGES\n"; open(dst_CHANGES, ">$dst_CHANGES") || die "$dst_CHANGES: $!"; print dst_CHANGES "$pkg->{NAME} $pkg->{VERSION} CHANGES\n"; print dst_CHANGES "$sep\n\n"; close(dst_CHANGES); my($save_cwd) = getcwd; chdir($dst_dir) || die "$dst_dir: $!"; if ( $pkg->{CHANGES_RELEASES} ) { my(@rels) = split(/\s+/, $pkg->{CHANGES_RELEASES}); @rels = map( "PUBLISH_" . $pkg->{NAME} . $_, @rels); @rels = grep( (tr/a-zA-Z0-9_/_/c, 1), @rels); push(@rels, ''); #print STDERR "rels = '", join("' '", @rels), "'\n"; #exit -1; my($r1, $r2); $r2 = shift(@rels); while ( $r1 = $r2, defined($r2 = shift(@rels)) ) { open(dst_CHANGES, ">>$dst_CHANGES") || die "$dst_CHANGES: $!"; print dst_CHANGES "\n$sep\nChanges from release '$r2' to '$r1'\n"; print dst_CHANGES "$sep\n\n"; close(dst_CHANGES); print STDERR " Changes from release '$r2' to '$r1'\n"; $cmd = "perl $progdir/cvsrevhist.pl -f=-r$r2:$r1 . >> $dst_CHANGES"; print STDERR "$cmd\n"; system("sh -c '$cmd'") && die "$cmd: $!"; } } else { $cmd = "perl $progdir/cvsrevhist.pl . >> $dst_CHANGES"; system("sh -c '$cmd'") && die "$cmd: $!"; } chdir($save_cwd) || die "$save_cwd: $!"; print STDERR " Created CHANGES $dst_CHANGES: DONE\n\n"; ################################################################## # Create TOC $dst_TOC = "$dst_dir/TOC"; print STDERR " Creating TOC $dst_TOC\n"; open(dst_TOC, ">$dst_TOC") || die "$dst_TOC: $!"; print dst_TOC "$pkg->{NAME} $pkg->{VERSION} Table of Contents\n"; print dst_TOC "$sep\n"; close(dst_TOC); # Use ls -lagR system("sh -c 'cd $tmp && ls -lagR $dst_name >> $dst_TOC'"); # Fill in the pkg files createPkgFiles($pkg); # Close output files close(PUB); close(dst_README); print STDERR " Created TOC $dst_TOC: DONE.\n\n"; ######################################################################## # Create the external readme print STDERR " Creating README $txt\n"; open(TXT, ">$txt"); appendFileToHandle($dst_README, TXT); print TXT "$sep\n\n"; print dst_TOC "$pkg->{NAME} $pkg->{VERSION} Package Info\n"; print TXT "$sep\n\n"; appendFileToHandle($pub, TXT); print TXT "$sep\n\n"; appendFileToHandle($dst_CHANGES, TXT); print TXT "$sep\n\n"; appendFileToHandle($dst_TOC, TXT); print TXT "$sep\n\n"; close(TXT); print STDERR " Created README $txt: DONE.\n\n"; ######################################################################## # Create archive and finish TOC print STDERR " Creating $pkg->{NAME} archive $archive\n"; system("sh -c '$tar -C $tmp -c${tar_verbose}f - $dst_name | $gzip -9 > $archive'"); print STDERR " Created $pkg->{NAME} archive $archive: DONE.\n\n"; ######################################################################## # Remove the temp directory system("rm", "-rf", $dst_dir); print STDERR "Publishing $_[0]: DONE\n\n"; } ############################################################################## # tar, gzip $tar = 'tar'; $tar_verbose = 'v'; $tar_verbose = ''; $gzip = 'gzip'; # cvs $CVSROOT = $ENV{CVSROOT}; $CVS = $ENV{CVS}; $CVS = 'cvs.exe' if ( ! defined($CVS) ); $PUBLISH_DIR = $ENV{PUBLISH_DIR}; $PUBLISH_DIR = 'd:/data/ion/www/research/pub' if ( ! $PUBLISH_DIR ); ############################################################################## # Parse arguments @pkgs = (); $index = 0; $reldir = ""; $force = 0; while ( $_ = shift @ARGV ) { if ( /^-?-i/ ) { $index = shift; } elsif ( /^-?-f/ ) { $force ++; } elsif ( /^-?-p/ ) { $PUBLISH_DIR = shift; } elsif ( /^-?-r/ ) { $reldir = shift; } else { push(@pkgs, $_); } } ############################################################################## # Create each package foreach $pkg ( @pkgs ) { createPkg($pkg); } ############################################################################## # Create package index sub size_str { "(" . (-s $_[0]) . " bytes)"; } if ( $index ) { #Pkgs by CATEGORY %c = (); if ( $reldir ne '' && $reldir !~ m@[/\\]$@ ) { $reldir .= '/'; } # Read each published pkg's data file foreach $pub ( glob("$PUBLISH_DIR/*.pub") ) { my($pkg) = readVars($pub, undef, 1); # Arrange by CATEGORY $pkg->{CATEGORY} = "UNKNOWN-CATEGORY" if ( $pkg->{CATEGORY} eq '' ); $pkg->{DESC} = "No Description Available. See README." if ( ! $pkg->{DESC} ); $pkg->{pub} = $pub; $pkg->{pub_file} = basename($pub); if ( ! defined($c{$pkg->{CATEGORY}}) ) { $c{$pkg->{CATEGORY}} = [ ]; } push(@{$c{$pkg->{CATEGORY}}}, $pkg); } @cats = sort(keys(%c)); # Open the index file open(INDEX, ">$index") || die "$index: $!"; # List the cats print INDEX "

Package Categories

\n"; print INDEX "
    \n"; $ci = 0; foreach $cat ( @cats ) { $ci ++; print INDEX qq@
  • $cat\n@; } print INDEX "
\n"; # Print each cat $ci = 0; foreach $cat ( @cats ) { $ci ++; print INDEX qq@

$cat

\n@; print INDEX "
\n"; foreach $pkg ( sort { $a->{NAME} cmp $b->{NAME} || $b->{VERSION} <=> $a->{VERSION} } @{$c{$cat}} ) { my($NAME) = uc($pkg->{NAME}); my($VERSION) = $pkg->{VERSION}; my($DESC) = $pkg->{DESC}; my($ARCHIVE) = basename($pkg->{ARCHIVE}); my($README) = basename($pkg->{README}); print INDEX qq@
$NAME $VERSION
$DESC\n@; print INDEX qq@
Date: $pkg->{DATE}\n@; print INDEX qq@
Requires: $pkg->{REQUIRES_OTHERS}\n@ if ( $pkg->{REQUIRES_OTHERS} ne '' ); print INDEX qq@
View README @ . &size_str($pkg->{README}) . "\n"; print INDEX qq@
View package info @ . &size_str($pkg->{pub}) . "\n"; print INDEX qq@
Download $ARCHIVE @ . &size_str($pkg->{ARCHIVE}) . "\n"; print INDEX qq@
\n@; } print INDEX "
\n"; } print INDEX "
\n"; # Close the index file close(INDEX); print STDERR "Created index $index\n"; } 1; dbmi0.1/src/bin/sci0100644000175200017560000000561506662461244014532 0ustar stephensstepheng#!/bin/sh #set -x #exec=/bin/echo exec= force= y='Checkpoint' fs= tarfs= cmd="$1" opts="" shift while /bin/test $# -gt 0 do f="$1" shift case "$f" in -TEST) exec=/bin/echo opts="$opts $f" ;; -f) force=1 opts="$opts $f" ;; -y) y="$1" shift ;; SCCS) ;; .) /bin/ls SCCS | /bin/sed -e '/^s\./!d' -e 's@^s\.@@' | /usr/bin/xargs -n1024 $0 "$cmd" $opts -y "$y" ;; */*) (cd `/bin/expr "$f" : '\(.*\)/.*'` && $0 "$cmd" $opts -y "$y" `/bin/expr "$f" : '.*/\(.*\)'`) ;; *) if /bin/test -d "$f" then if /bin/test -f "SCCS/s.$f.tar" then f="$f.tar" fs="$fs $f" else /bin/ls "$f" | (cd "$f" && /usr/bin/xargs -n1024 $0 "$cmd" $opts -y "$y") fi else fs="$fs $f" fi ;; esac done case "$cmd" in get|ci|edit|editopen|update) _fs="$fs"; fs="" for f in $_fs do if /bin/test -f "SCCS/s.$f" then fs="$fs $f" if /bin/test -n "$force" then /bin/chmod -w "$f" fi else echo "$f: no SCCS/s.$f" fi done ;; esac case "$cmd" in create|ci|edit|editopen|update) _fs="$fs"; fs="" for f in $_fs do if /bin/test -f "SCCS/p.$f" then echo "$f: SCCS/p.$f exists:" `cat SCCS/p.$f` else fs="$fs $f" fi done ;; esac for f in $fs do case "$f" in *.tar) tarfs="$tarfs $f" ;; esac done case "$cmd" in ci|delget|delta|create) for f in $tarfs do d=`/usr/bin/basename $f .tar` $exec /bin/rm -f "$f" $exec /bin/chmod -Rf ugo+wr "$d" $exec tar -cvf - "$d" > "$f" done ;; esac case "$cmd" in ci|create) _fs="$fs"; fs="" for f in $_fs do if /bin/test -r "$f" then fs="$fs $f" else echo "$f: not readable" fi done ;; esac if /bin/test -n "$fs" then case "$cmd" in update) set +x for f in $fs do sf="SCCS/s.$f" /usr/bin/find "$sf" -newer "$f" -print done | /bin/sed -e 's@^SCCS/s\.@@' | /usr/bin/xargs -n1024 $0 get $opts ;; ci|cie) for f in $fs do $exec /bin/mv "$f" "$f.sci.$$" done $exec scc edit $fs for f in $fs do $exec /bin/mv "$f.sci.$$" "$f" done $exec /bin/chmod +w $fs if /bin/test "$cmd" = "cie" then $exec scc deledit "-y$y" $fs else $exec scc delget "-y$y" $fs fi $exec /bin/date > 'CheckpointDate' ;; create|delget|deledit) $exec scc $cmd "-y$y" $fs ;; get|unedit|prs|diffs) $exec scc $cmd $fs ;; co|edit|editopen) $exec scc edit $fs ;; *) /bin/echo "$0: $cmd: bad command" ;; esac case "$cmd" in get|co|edit|create) for f in $tarfs do d=`/usr/bin/basename $f .tar` $exec /bin/rm -rf "$d" $exec tar -xvf "$f" $exec /bin/chmod -Rf ugo+wr "$d" done ;; esac case "$cmd" in editopen) $exec open -a Edit $fs ;; esac fi exit 0 dbmi0.1/src/bin/scip0100644000175200017560000000640006662461244014703 0ustar stephensstepheng#!/run/thirdParty/perl5/bin/perl eval 'exec /run/thirdParty/perl5/bin/perl $0 ${1+"$@"}' if 0; $exec = 0; $y = 'Checkpoint'; @fs = (); @tarfs = (); sub _exec { if ( $exec ) { system(@_); } else { print STDERR @_, "\n"; } } sub warning { print STDERR "$0: ", @_, "\n"; } sub getdir { my($dir) = $_[0]; my(@filenames); opendir(DIR,$dir) || (warning "Can't open $dir: $!\n", return); @filenames = readdir(DIR); closedir(DIR); grep(($_ ne '.' && $_ ne '..'), @filenames); } sub sfile { ( $_[0] =~ m/^(.*/)([^/]+)$/ ) ? "$1SCCS/$_[1].$2" : "SCCS/$_[1].$_[0]"; } sub dofile { if ( -d ) { if ( -f &sfile("$_.tar", 's') ) { $_ .= '.tar'; push(@fs, $_); } else { } } else { push(@fs, $_); } } $cmd = shift; while ( shift ) { if ( $_ eq '-TEST' ) { $exec = 0; } elsif ( $_ eq '-y' ) { $y = shift; } elsif ( $_ eq 'SCCS' || $_ eq 'RCS' ) { } elsif ( $_ eq '.' ) { my(@x) = &getdir('SCCS'); grep((s/^s.//, 1), @x); push(@ARGV, @x); } elsif ( m@/@ ) { } else { if ( -d ) { if ( -f &sfile_("$_.tar", 's') ) { $_ .= '.tar'; push(@fs, $_); } else { $d = $_; for ( &getdir($d) ) { &dofile("$d/$_"); } } } else { push(@fs, $_); } } } if ( $cmd =~ m/^(get|ci|edit|editopen|update)$/ ) { @_fs = @fs; @fs = (); for ( @_fs ) { $sf = &sfile($_, 's'); if ( -f $sf ) { push(@fs, $_); } else { &warning("$_: no $sf"); } } } if ( $cmd =~ m/^(create|ci|edit|editopen|update)$/ ) { @_fs = @fs; @fs = (); for ( @_fs ) { if ( -f &sfile($_, 'p') ) { &warning("$_: is under edit"); } else { push(@fs, $_); } } } @tarfs = (); for ( @fs ) { if ( m/\.tar$/ ) { push(@tarfs, $_); } } if ( $cmd =~ m/^(ci|delget|delta|create)$/ ) { for ( @tarfs ) { m@^(.*)\.tar$@; $d = $1; &_exec('/bin/rm', '-f', $_); &_exec('/bin/chmod', '-Rf', 'ugo+wr', $d); &_exec("tar -cvf - $d > $_"); } } if ( $cmd =~ m/^(ci|create)$/ ) { @_fs = @fs; @fs = (); for ( @_fs ) { if ( -r $_ ) { push(@fs, $_); } else { &warning("$_: not readable"); } } } if ( @fs ) { if ( $cmd eq 'update' ) { for ( @fs ) { $sf = &sfile($_, 's'); if ( (-M $sf) > (-M $_) ) { &warning("$_: is out of date with $sf"); } } } elsif ( $cmd =~ m/^(ci|cie)$/ ) { for ( @fs ) { &_exec('/bin/mv', $_, "$f.sci.$$"); } &_exec('scc', 'edit', @fs); for ( @fs ) { &_exec('/bin/mv', "$f.sci.$$", $_); } &_exec('/bin/chmod', '+w', @fs); &_exec('scc', ( $cmd eq 'cie' ? 'deledit' : 'delget' ), "-y$y", @fs); #$exec /bin/date > 'CheckpointDate' } elsif ( $cmd =~ m/^(create|delget|deledit)$/ ) { &_exec('scc', $cmd, "-y$y", @fs); } elsif ( $cmd =~ m/^(get|unedit)$/ ) { &_exec('scc', $cmd, @fs); } elsif ( $cmd =~ m/^(co|edit|editopen)$/ ) { &_exec('scc', 'edit', @fs); } else { &warning("$cmd: bad command"); } if ( $cmd =~ m/^(get|co|edit|create)$/ ) { for ( @tarfs ) { m@^(.*)\.tar$@; $d = $1; &_exec('/bin/rm', '-rf', $d); &_exec("tar", '-xvf', $_); &_exec('/bin/chmod', '-Rf', 'ugo+wr', $d); } } } 1; dbmi0.1/src/bin/si0100644000175200017560000000013407001136307014341 0ustar stephensstepheng#!/bin/sh #set -x echo '#include "'"$1"'"' | gcc -E - | awk 'NF' | egrep -v -e '^#' | less dbmi0.1/src/bin/split.c0100644000175200017560000000450606663227006015323 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_bin_split_c__ #define __rcs_id_bin_split_c__ static const char __rcs_id_bin_split_c[] = "$Id: split.c,v 1.2 1999/02/19 09:25:26 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include /* malloc(), free() */ #include /* strlen(), strcpy(), strcat(), strcmp() */ static char *progname; #ifdef BC #include /* O_BINARY */ #include #endif static int dofile(unsigned long fsize, FILE *in, const char *name) { char *fname; int fn; int rtnval = 0; fname = malloc(sizeof(fname[0]) * (strlen(name) + 5)); fn = 0; do { FILE *out; unsigned long bytes_left; { char buf[5]; sprintf(buf, ".%03d", (int) fn ++); strcpy(fname, name); strcat(fname, buf); if ( (out = fopen(fname, "wb")) == 0 ) { fprintf(stderr, "%s: cannot open \"%s\" for writing\n", progname, fname); rtnval = -1; goto rtn; } } bytes_left = fsize; while ( bytes_left ) { int c; if ( (c = getc(in)) == EOF ) { fclose(out); rtnval = 0; goto rtn; } else { putc(c, out); bytes_left --; } } fclose(out); } while ( 1 ); rtn: free(fname); return rtnval; } int main(int argc, char **argv) { int i; char *outname = 0; unsigned long fsize = 1440000UL; int rtnval = 0; progname = argv[0]; #ifdef BC _fmode = O_BINARY; #endif for ( i = 1; i < argc; i ++ ) { if ( argv[i][0] == '-' ) { switch ( argv[i][1] ) { case 's': fsize = atol(argv[i][2] ? argv[i] + 2 : argv[++ i]); break; case 'o': outname = argv[i][2] ? argv[i] + 2 : argv[++ i]; break; default: fprintf(stderr, "%s: bad option \"%s\"\n", progname, argv[i]); break; } } else { FILE *in; char *inname = argv[i]; if ( strcmp(inname, "-") == 0 ) { in = stdin; } else if ( (in = fopen(inname, "rb")) == 0 ) { fprintf(stderr, "%s: cannot open \"%s\" for reading\n", progname, inname); rtnval ++; } if ( outname == 0 ) { char *p; outname = malloc(sizeof(outname[0]) * (strlen(inname) + 2)); strcpy(outname, inname); if ( (p = strrchr(outname, '.')) ) { *p = '\0'; } else { strcat(outname, "."); } } rtnval += dofile(fsize, in, outname); if ( in != stdin ) fclose(in); } } return rtnval; } dbmi0.1/src/bin/tgz0100744000175200017560000000445607230344242014551 0ustar stephensstepheng#!/bin/sh # $Id: tgz,v 1.6 2001/01/14 15:41:22 stephens Exp $ #set -x if [ -z "$TAR" ] then TAR=tar fi if [ -z "$GZIP" ] then GZIP=gzip fi if [ -z "$BZIP" ] then BZIP=bzip2 fi if [ -z "$BUNZIP" ] then BUNZIP=bunzip2 fi if [ -z "$GUNZIP" ] then GUNZIP="$GZIP -d" fi if [ -z "$COMPRESS" ] then COMPRESS=compress fi c= C=. o= tv= s=.tgz x=x #set -x while [ $# -gt 0 ] do case "$1" in -c) c=1 ;; -o) o="$2" shift ;; -s) s="$2" shift ;; -C) C="$2" shift ;; -*) case "$1" in -*t*) tv="${tv}t" x= ;; esac case "$1" in -*v*) tv="${tv}v" ;; esac ;; *) if [ -d "$1" -o -n "$c" ] then d=`expr "$1" : '\(.*\)/[^/]*' '|' '.'` f=`expr "$1" : '.*/\([^/]*\)' '|' "$1"` if [ -z "$o" ] then o="$f$s" fi case "$o" in *.tb2|*.TB2|*.tar.bz2|*_tar.bz2|*_TAR.BZ2) cmd="(cd $d && $TAR -c${tv}f - '$f' ) | (cd '$C' && $BZIP -9 > '$o')" ;; *.tgz|*.TGZ|*.tar.gz|*_TAR.GZ) cmd="(cd $d && $TAR -c${tv}f - '$f' ) | (cd '$C' && $GZIP -9 > '$o')" ;; *.tar|*.TAR|*.gtar|*.GTAR) cmd="(cd $d && $TAR -c${tv}f - '$f' ) | (cd '$C' && cat - > '$o')" ;; *.gz|*.GZ|*.gzip|*.GZIP) cmd="(cd $d && $GZIP -9 -c '$f' ) | (cd '$C' && cat - > '$o')" ;; *.bz|*.BZ|*.bz2|*.BZ2) cmd="(cd $d && $BZIP -9 -c '$f' ) | (cd '$C' && cat - > '$o')" ;; esac echo $cmd eval $cmd o= elif [ -f "$1" ] then if [ -z "$o" ] then o="." fi if [ ! -d "$o" ] then mkdir "$o" fi case "$1" in *.tgz|*.tar.gz|*.TGZ|*.tz|*.TZ) cmd="$GUNZIP < '$1' | (cd '$o' && $TAR -$x${tv}f -)" ;; *.tbz|*.TBZ|*.tar.b2|*.tb2|*.TB2|*_tar.bz2|*_TAR.BZ2) cmd="$BUNZIP -d -c -k '$1' | (cd '$o' && $TAR -$x${tv}f -)" ;; *.bz|*.BZ) cmd="$BUNZIP -d -k '$1'" ;; *.gz|*.GZ) cmd="$GUNZIP -d -c < '$1'" ;; *.tar|*.TAR|*.gtar|*.GTAR) cmd="(cd '$o' && $TAR -$x${tv}f -) < '$1'" ;; *) echo "$0: $1: unknown suffix" 1>&2 cmd="" ;; esac if [ -n "$cmd" ] then echo $cmd eval $cmd fi o= x=x else : fi ;; esac shift done dbmi0.1/src/bin/ts0100644000175200017560000000316707065620573014402 0ustar stephensstepheng#!/bin/sh set -x action="$1" shift [ -z "$GDB" ] && GDB='gdb' target=gdb files='' while [ $# -gt 0 ] do case "$1" in -t) target="$2" shift; ;; *=*) eval "$1" ;; *) files="$files $1" ;; esac shift done for f in $files do pre='cat -' post='' gdbx='' run_in_db() { _app="$1"; shift gdbx="/tmp/gdbx" echo "#Created by $0: DO NOT MODIFY" > $gdbx echo "break main" >> $gdbx echo "run $*" >> $gdbx $GDB $_app -x $gdbx rm $gdbx } case "$target" in *gdb*) _APP="${APP}" gdbx="/tmp/gdbx" echo "#Created by $0: DO NOT MODIFY" > $gdbx do_line() { case "$line" in \#*) echo "$line" >> $gdbx ;; run*) echo "shell echo '$line'" >> $gdbx echo "$line" >> $gdbx echo 'shell echo Hit return' >> $gdbx echo 'shell read line' >> $gdbx ;; *=*) eval "$line" ;; *) echo "shell echo '$line'" >> $gdbx eval echo "shell '$line'" >> $gdbx ;; esac } post='$target $APP -x $gdbx' ;; *time*) do_line() { echo "$line" case "$line" in \#*) ;; *=*) eval "$line" ;; *) eval "$line" ;; esac } run() { eval time $APP "$@" code=$? echo "=== $APP $@: terminated with $code" if [ $code -ne 0 ] then run_in_db $APP "$@" fi } ;; *) echo "$0: unknown target '$target'" 1>&2 ;; esac eval $pre < "$f" | while read line do do_line done [ -n "$gdbx" -a -r "$gdbx" ] && cat $gdbx eval $post donedbmi0.1/src/bin/uud0100744000175200017560000000417207262415712014543 0ustar stephensstepheng#!/bin/perl # # scans files for a uuencoded items in files and decodes them to $dir # and adds a line to $db based on the Subject: lines found # $count = 0; $subject = ''; $dir = shift || die("Specify an output directory"); $db = "$dir/images.txt"; @files = (); %subjects = (); %files = (); $again = 0; while ( $again || defined($_ = <>) ) { $again = 0; chop; if ( s/^Subject:\s+// ) { $subject = $_; } elsif ( /^begin\s+(\S+)\s+(\S+)/ ) { $mode = $1; $file = $2; print STDERR "File: $file, Subject: $subject\n"; if ( $file ne '' ) { $str = ''; $nlines = 0; while ( defined($_ = <>) ) { $nlines ++; if ( $nlines % 100 ) { print STDERR "$nlines lines...\r"; } last if /^end/; if ( /^Subject:\s+/ || /^begin\s+(\S+)\s+(\S+)/ ) { print STDERR "WARNING: found $_"; $again ++; last; } next if /[a-z]/; next unless int((((ord() - 32) & 077) + 2) / 3) == int(length() / 4); $str .= unpack('u', $_); } # Remove dir from $file name $file =~ s@^.*/@@; # Add .jpg suffix if needed $file .= "_" . ($count ++) . ".jpg" if ( $file !~ /\.jpg$/ ); # Give it an orignal name if ( 0 ) { while ( -f "$dir/$file" ) { $file =~ s/_([0-9]+)(\.[^\.]+)$//; $suffix = $1; $file .= ($count ++) . $suffix; } } # If the file doesn't already exist if ( ! -f "$dir/$file" ) { # Add an entry to the index push(@files, $file); while ( defined($files{$subject}) ) { $subject =~ s/_([0-9]+)$//; $subject .= '_' . ($1 + 1); } $subjects{$file} = $subject; $files{$subject} = $file; # print "file = $file, mode = $mode, subject = $subject\n"; # Write the file open(F, ">$dir/$file"); binmode(F); print F $str; close(F); #exit(0); } } } } #Append to db $exists = -r $db; open(INDEX, ">>$db"); binmode(INDEX); print INDEX "Filename\tSubject\n" if ( ! $exists ); foreach $file ( sort(@files) ) { $subject = $subjects{$file}; print INDEX "$file\t$subject\n"; } close(INDEX); ########################################################################## 1; dbmi0.1/src/bin/uudindex0100744000175200017560000000711507262415713015574 0ustar stephensstepheng#!/bin/perl # Creates a html index for stuff in $dir listed by $db # Run this after uud. # $dir = shift || "images"; $db = "$dir.txt"; $_html = '.html'; ########################################################################## @fieldnames = (); @fields = (); @records = (); @files = (); %subjects = (); %files = (); #Read db open(INDEX, "<$db"); binmode(INDEX); # First record is the field names $_ = ; chop; @fieldnames = split("\t", $_); $fieldindex = 0; foreach $fieldname ( @fieldnames ) { $fieldindex{$fieldname} = $fieldindex ++; } while ( ) { chop; @fields = split("\t", $_); push(@records, [ @fields ]); } close(INDEX); #Create index.html $menu = "menu_" . $fieldnames[0] . $_html; open(INDEX, ">$dir/index$_html"); binmode(INDEX); print INDEX qq@ None <BODY> <CENTER> This frameset document contains: <UL> <LI> <A HREF="$menu">Menu</A></LI> </UL> </BODY> @; close(INDEX); #Create blank.html open(INDEX, ">$dir/blank$_html"); binmode(INDEX); print INDEX q@ None @; close(INDEX); sub add_suffix { my($x,$s) = @_; $x =~ s/\.[^.]+$//; $x .= $s; $x; } #Create menus $fieldindex = -1; foreach $fieldname ( @fieldnames ) { $fieldindex ++; $menu = "menu_$fieldname$_html"; open(INDEX, ">$dir/$menu"); binmode(INDEX); print INDEX qq~ None ~; # Put a record to select a different column sorting print INDEX qq~~; foreach $fname ( @fieldnames ) { print INDEX qq~~; foreach $field ( @$record ) { print INDEX qq~
$fname~; } print INDEX "\n"; # Sort by Filename and create htmls for each file $fieldindex = $fieldindex{'Filename'}; @records = sort { $a->[$fieldindex] cmp $b->[$fieldindex] } @records; foreach $ri ( 0..$#records ) { $record = $records[$ri]; $image = $record->[0]; $HREF = add_suffix($record->[0], $_html); $prev = $ri > 0 ? add_suffix($records[$ri - 1]->[0], $_html) : undef; $next = $ri <= $#records ? add_suffix($records[$ri + 1]->[0], $_html) : undef; print STDERR "HREF='$HREF', image='$image', prev='$prev', next='$next'\n"; exit(1); if ( $HREF ) { open(HREF,">$HREF") || die "Cannot write '$HREF'"; print HREF qq~ None
$record->[1]

~; if ( $prev ) { print HREF qq~PREV $prev\n~; } if ( $next ) { print HREF qq~NEXT $next\n~; } print HREF qq~


$image\n~; print HREF qq~
~; close(HREF); } } # Sort by current field @records = sort { $a->[$fieldindex] cmp $b->[$fieldindex] } @records; foreach $ri ( 0..$#records ) { $record = $records[$ri]; $HREF = add_suffix($record->[0]. $_html); print INDEX qq~
$field~; } print INDEX "\n"; } print INDEX qq~

~; close(INDEX); } 1; dbmi0.1/src/bin/which0100644000175200017560000000113606662461244015050 0ustar stephensstepheng#!/bin/sh #set -x pathchar=':' if expr index "$PATH" ';' > /dev/null then pathchar=';' fi oIFS="$IFS" for f in ${1+"$@"} do IFS="$pathchar" for d in ${PATH} do IFS="$oIFS" b="$d/$f" t="$b" if [ -x "$t" ] then echo "$f: $t" continue 2 fi t="$b.bat" if [ -x "$t" ] then echo "$f: $t" continue 2 fi t="$b.com" if [ -x "$t" ] then echo "$f: $t" continue 2 fi t="$b.exe" if [ -x "$t" ] then echo "$f: $t" continue 2 fi done echo "$f: not found" done IFS="$oIFS" dbmi0.1/src/bin/whichall0100644000175200017560000000014306662461244015536 0ustar stephensstepheng#!/bin/sh for d in `echo $PATH|tr ':' ' '` do if [ -x $d/$1 ] then echo "$d/$1" fi done dbmi0.1/src/bin/wwwsend0100644000175200017560000000336106662461243015445 0ustar stephensstepheng#!/bin/sh # Copyright 1998-1999 Kurt A. Stephens http://www.acm.org/~stephensk # # This script sends an entire directory tree via ftp # It only sends the files that have changed since the last send # by keeping a timestamp file around (wwwsend.ts) # #set -x dat=./wwwsend.dat ldir=www dryrun= override= timestamp= findopts= while [ $# -gt 0 ] do case "$1" in -dryrun) dryrun=1 ;; *=*) override="$override$1;" ;; *) dat="$1" ;; esac shift done echo "$0: Reading $dat" [ -n "$override" ] && eval $override cwd="`pwd`" . $dat || exit 1 [ -n "$override" ] && eval $override cwd="`pwd`" #ldir=$(cd $ldir && pwd) #echo "ldir=$ldir" #exit # Run make if it has a Makefile if [ -f $ldir/Makefile ] then echo "$0: Making $ldir ..." (cd $ldir && make) echo "$0: done."; fi # ftp script: open, login and set binary script=$$.tmp echo "$0: Creating ftp script $script"; cat >$script <>$script # ftp script: copy files [ -z "$timestamp" ] && timestamp="$cwd/wwwsend.ts" [ -f "$timestamp" ] && findopts="-newer '$timestamp' $findopts" (set -x; cd $ldir && eval find . -type f $findopts -print) | while read f do d=`dirname $f` echo "cd $rdir/$d" echo "put $f" done >>$script # ftp script: close and quit cat >>$script <> $timestamp # Cleanup rm $script echo "$0: done." dbmi0.1/src/bin/addcr.t/0040755000175200017560000000000007236675451015351 5ustar stephensstephengdbmi0.1/src/bin/addcr.t/CVS/0040755000175200017560000000000007236675451016004 5ustar stephensstephengdbmi0.1/src/bin/addcr.t/CVS/Root0100644000175200017560000000003407236675451016644 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/bin/addcr.t/CVS/Repository0100644000175200017560000000003107236675451020075 0ustar stephensstephenghome/ion/src/bin/addcr.t dbmi0.1/src/bin/addcr.t/CVS/Entries0100644000175200017560000000006107236675451017332 0ustar stephensstepheng/run/1.1/Wed Feb 17 23:02:18 1999// D/backup//// dbmi0.1/src/bin/addcr.t/run0100644000175200017560000000021706662645172016074 0ustar stephensstepheng#!/bin/sh # Test script for addcr # $Id: run,v 1.1 1999/02/17 23:02:18 stephensk Exp $ # set -x rm t[0-9]* cp backup/* . perl ../addcr t[0-9]* dbmi0.1/src/bin/addcr.t/backup/0040755000175200017560000000000007236675451016616 5ustar stephensstephengdbmi0.1/src/bin/addcr.t/backup/CVS/0040755000175200017560000000000007236675451017251 5ustar stephensstephengdbmi0.1/src/bin/addcr.t/backup/CVS/Root0100644000175200017560000000003407236675451020111 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/bin/addcr.t/backup/CVS/Repository0100644000175200017560000000004007236675451021342 0ustar stephensstephenghome/ion/src/bin/addcr.t/backup dbmi0.1/src/bin/addcr.t/backup/CVS/Entries0100644000175200017560000000023307236675451020600 0ustar stephensstepheng/t1.c/1.2/Fri Feb 19 09:25:27 1999// /t2/1.1.1.1/Wed Feb 17 06:33:08 1999// /t3/1.1.1.1/Wed Feb 17 06:33:08 1999// /t4/1.2/Wed Feb 17 23:02:19 1999/-kb/ D dbmi0.1/src/bin/addcr.t/backup/t1.c0100644000175200017560000000040406663227007017272 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_backup_t1_c__ #define __rcs_id_backup_t1_c__ static const char __rcs_id_backup_t1_c[] = "$Id: t1.c,v 1.2 1999/02/19 09:25:27 stephensk Exp $"; #endif #endif /* __rcs_id__ */ L1 /* @COPYRIGHT@ Blah ** @COPYRIGHT END@ */ L2 dbmi0.1/src/bin/addcr.t/backup/t20100644000175200017560000000002406662461244017052 0ustar stephensstepheng#!/bin/sh #L1 L2 L3 dbmi0.1/src/bin/addcr.t/backup/t30100644000175200017560000000005106662461244017053 0ustar stephensstepheng#!/usr/local/bin/scheme ; L1 L2 L3 dbmi0.1/src/bin/addcr.t/backup/t40100644000175200017560000000057306662645173017072 0ustar stephensstephengLèV.textD+Üâ» `.data ,bý|@À.bss€À.stab,% 1:+R.stabstrÆ‹LVRopportobj_writePortbooleanU‰å¡‹P‰ÐÁøƒø~¡‹P‰ÐÁøƒøëèè‰Â‰ÐëÉÃ#f#t‰öU‰åƒìS¡‰Eü‹Eü‹‹J‰ÊÁúJý‹ˉ]ø‹Eü‹Â‹ dbmi0.1/src/bin/lib/0040755000175200017560000000000007236675451014600 5ustar stephensstephengdbmi0.1/src/bin/lib/CVS/0040755000175200017560000000000007236675451015233 5ustar stephensstephengdbmi0.1/src/bin/lib/CVS/Root0100644000175200017560000000003407236675451016073 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/bin/lib/CVS/Repository0100644000175200017560000000002507236675451017327 0ustar stephensstephenghome/ion/src/bin/lib dbmi0.1/src/bin/lib/CVS/Entries0100644000175200017560000000001307236675451016556 0ustar stephensstephengD/perl//// dbmi0.1/src/bin/lib/perl/0040755000175200017560000000000007236675451015542 5ustar stephensstephengdbmi0.1/src/bin/lib/perl/CVS/0040755000175200017560000000000007236675451016175 5ustar stephensstephengdbmi0.1/src/bin/lib/perl/CVS/Root0100644000175200017560000000003407236675451017035 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/bin/lib/perl/CVS/Repository0100644000175200017560000000003207236675451020267 0ustar stephensstephenghome/ion/src/bin/lib/perl dbmi0.1/src/bin/lib/perl/CVS/Entries0100644000175200017560000000001207236675451017517 0ustar stephensstephengD/ion//// dbmi0.1/src/bin/lib/perl/ion/0040755000175200017560000000000007236675451016327 5ustar stephensstephengdbmi0.1/src/bin/lib/perl/ion/CVS/0040755000175200017560000000000007236675451016762 5ustar stephensstephengdbmi0.1/src/bin/lib/perl/ion/CVS/Root0100644000175200017560000000003407236675451017622 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/bin/lib/perl/ion/CVS/Repository0100644000175200017560000000003607236675451021060 0ustar stephensstephenghome/ion/src/bin/lib/perl/ion dbmi0.1/src/bin/lib/perl/ion/CVS/Entries0100644000175200017560000000001307236675451020305 0ustar stephensstephengD/_cvs//// dbmi0.1/src/bin/lib/perl/ion/_cvs/0040755000175200017560000000000007306123713017244 5ustar stephensstephengdbmi0.1/src/bin/lib/perl/ion/_cvs/CVS/0040755000175200017560000000000007306135474017706 5ustar stephensstephengdbmi0.1/src/bin/lib/perl/ion/_cvs/CVS/Root0100644000175200017560000000003407236675451020554 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/bin/lib/perl/ion/_cvs/CVS/Repository0100644000175200017560000000004307236675451022010 0ustar stephensstephenghome/ion/src/bin/lib/perl/ion/_cvs dbmi0.1/src/bin/lib/perl/ion/_cvs/CVS/Entries0100644000175200017560000000017307306135474021240 0ustar stephensstepheng/entry.pm/1.4/Tue Mar 21 07:17:32 2000// /rlog.pm/1.2/Sun Mar 7 10:45:55 1999// /find.pm/1.9/Sat Jun 2 10:09:00 2001// D dbmi0.1/src/bin/lib/perl/ion/_cvs/entry.pm0100644000175200017560000000210607065621014020736 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: entry.pm,v 1.4 2000/03/21 07:17:32 stephensk Exp $ package ion::_cvs::entry; #print STDERR "ion::_cvs::entry\n"; @map = ( 'type', 'file', 'revision', 'date', 'extra', 'sticky', 'path', 'Repository', 'Filepath' ); %map = (); foreach $_ ( 0 .. $#map ) { my($s) = $map[$_]; my($c) = substr($s, 0, 1); die "Check @map" if ( $map{$c} ); $map{$c} = $_; $map{$s} = $_; } sub type { $_[0]->[0]; } sub isFile { $_[0]->type() ne 'D'; } sub isDirectory { $_[0]->type() eq 'D'; } sub name { $_[0]->[1]; } sub version { $_[0]->[2]; } sub revision { # alias $_[0]->[2]; } sub date { $_[0]->[3]; } sub other { $_[0]->[4]; } sub sticky { $_[0]->[5]; } sub path { $_[0]->[6]; } sub repository { $_[0]->[7]; } sub fullpath { $_[0]->[8]; } sub rlog { if ( ! defined $_[0]->[9] ) { eval 'use ion::_cvs::rlog;'; $_[0]->[9] = ion::_cvs::rlog($_[0]->repository, ($_[1] ? $_[1] : $ion::_cvs::rlog::options)); } } sub clear_rlog { $_[0]->[9] = undef; } sub make { my($x) = @_; bless $x; } 1; dbmi0.1/src/bin/lib/perl/ion/_cvs/find.pm0100644000175200017560000000634007306135474020531 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: find.pm,v 1.9 2001/06/02 10:09:00 stephens Exp $ use ion::_cvs::entry; ######################################################### package ion::_cvs; #print STDERR "ion::_cvs::find\n"; use Cwd; use File::Find; use File::Basename; $debug = 0; $testing = 0; $find::show_funny_entries = 0; $find::all_files = 0; sub read_CVS_Entries { my($dir) = @_; my($in); my($Repository); $in = "$dir/CVS/Repository"; if ( -f $in ) { open($in, "<$in") || die "$in: $!"; $Repository = <$in>; chop $Repository; close($in); } $in = "$dir/CVS/Entries"; if ( -f $in ) { my(@entries); my($line); my($lineno) = 0; open($in, "<$in") || die "$in: $!"; while ( $line = <$in> ) { chomp $line; $lineno ++; my($rec); $rec = [ split('/', $line) ]; if ( $#{$rec} > 0 ) { $rec->[6] = $dir; $rec->[7] = $rec->[0] eq 'D' ? "$Repository/$rec->[1]" : "$Repository/$rec->[1],v"; $rec->[8] = $rec->[6] . '/' . $rec->[1]; #print join('+', $#{$rec}, @{$rec}), "\n"; ion::_cvs::entry::make($rec); #print join('-', $#{$rec}, @{$rec}), "\n"; #die "$in:$lineno:$line" if ( $#{$rec} <= 0 ); push(@entries, $rec); } else { warn "$in:$lineno: funny entry: '$line'\n" if ( $ion::_cvs::find::show_funny_entries ); } } close($in); @entries; } else { 0; } } sub do_entry { my($entry, $proc, $data) = @_; #print join('|', $#{$rec}, @{$rec}), "\n"; &{$proc}($entry, $data); if ( $entry->[0] eq 'D' ) { my($se); foreach $se ( read_CVS_Entries($entry->[8]) ) { &{$proc}($se, $data); do_entry($se, $proc, $data); } } } ######################################################### sub wanted { print STDERR "wanted: $File::Find::name\n" if ( $debug ); if ( $_ eq 'CVS' ) { $File::Find::prune = 1; } else { if ( -d && (-f "$_/CVS/Entries" || -f "../CVS/Entries") ) { #print STDERR "Found dir $File::Find::name\n"; push(@found_files, $File::Find::name); $File::Find::prune = 1; } elsif ( -f ) { #print STDERR "Found file $File::Find::name\n"; push(@found_files, $File::Find::name); } } } sub find { my($proc, $data, @files) = @_; # Collect files under CVS control @found_files = (); my($save_cwd) = getcwd; File::Find::find(\&wanted, @files); chdir($save_cwd) || die "$save_cwd: $!"; ######################################################### #print STDERR "files = (", join("\n\t", @files), ")\n"; my($path); foreach $path ( @found_files ) { my($dir, $file); my($entry); $dir = dirname($path); $file = basename($path); print STDERR "$path:$dir:$file\n" if ( $debug ); if ( -d $path && -f "$path/CVS/Entries" ) { print STDERR "$path is a dir\n" if ( $debug ); foreach $entry ( read_CVS_Entries($path) ) { do_entry($entry, $proc, $data); } } elsif ( $file ne '.' && -f "$dir/CVS/Entries" ) { #print STDERR "Search for $file in $dir/CVS\n"; ENTRY: foreach $entry ( read_CVS_Entries($dir) ) { #print STDERR "Entry name $entry->[1]\n"; if ( $file eq $entry->[1] ) { print STDERR "Found entry for $file in $dir/CVS\n" if ( $debug); do_entry($entry, $proc, $data); last ENTRY; } } } } } 1; dbmi0.1/src/bin/lib/perl/ion/_cvs/rlog.pm0100644000175200017560000001167406670454343020564 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: rlog.pm,v 1.2 1999/03/07 10:45:55 stephensk Exp $ package ion::_cvs; ######################################################## $debug = 0; $testing = 0; ######################################################## $RLOG = $ENV{RLOG} if ( ! defined $RLOG ); $RLOG = 'rlog' if ( ! defined $RLOG ); sub END { unlink($tmp) if ( defined $tmp ); } sub rlog { my($vfile, $opts) = @_; my($obj) = {}; #my($debug) = 3; $opts = {} if ( ! defined $opts ); $opts->{RLOG} = $RLOG if ( ! defined $opts->{RLOG} ); $obj->{vfile} = $vfile; $obj->{revisions} = []; $obj->{revision} = {}; $obj->{symbolic_names} = []; $obj->{sym_name_to_rev} = {}; $obj->{rev_to_sym_names} = {}; $obj->{filter} = $opts->{filter}; ############################################ # Run rlog into temp file my($in) = "rlog" . abs($$) . ".tmp"; $tmp = $in; my($cmd) = qq($opts->{RLOG} $obj->{filter} $obj->{vfile} > $in); print STDERR "$cmd\n" if ( $debug > 0 ); if ( system($cmd) ) { unlink($in); return undef; } ############################################ # Slurp in the whole file open($in, "<$in") || die "$cmd: $!"; my(@lines); my($line); my($lineno) = 0; while ( defined ($line = <$in>) ) { chomp $line; print "$vfile: $line\n" if ( $debug > 2 ); push(@lines, $line); } close($in); unlink($tmp); undef $tmp; exit if ( $debug > 3 ); ############################################ # Begin scan $lineno = 0; if ( defined($line = shift @lines) ) { $lineno ++; } ############################################ # Scan header while ( defined $line && ($line !~ /^(-+|=+)$/) ) { if ( $line =~ /^([^:]+):\s*(.*)$/ ) { my($key, $value) = ($1, $2); if ( $key eq 'symbolic names' ) { ############################################ # Scan symbolic names print STDERR "Found symbolic names: $lineno:$line\n" if ( $debug > 1 ); if ( defined($line = shift @lines) ) { $lineno ++; } while ( defined $line && ($line =~ /^\s/) ) { print STDERR "Try sym_name: $lineno:$line\n" if ( $debug > 2 ); if ( $line =~ /^\s+([^\s:]+)\s*:\s*([\.0-9]+)/ ) { print STDERR "Matched sym_name '$1' '$2': $lineno:$line\n" if ( $debug > 1 ); push(@{$obj->{symbolic_names}}, $1); $obj->{sym_name_to_rev}->{$1} = $2; my($a); $a = $obj->{rev_to_sym_names}->{$2}; $a = $obj->{rev_to_sym_names}->{$2} = [] if ( ! defined $a ); push(@{$a}, $1); } if ( defined($line = shift @lines) ) { $lineno ++; } } } else { $key =~ tr/a-zA-Z0-9_/_/c; $value =~ s/\s+$//; print STDERR "Found key='$key' value='$value': $lineno:$line\n" if ( $debug > 2 ); $value = [ split(/\s+/, $value) ]; $obj->{$key} = $value; if ( defined($line = shift @lines) ) { $lineno ++; } } } else { if ( defined($line = shift @lines) ) { $lineno ++; } } } if ( defined($line = shift @lines) ) { $lineno ++; } while ( defined $line && $line !~ /^=+$/ ) { my($v) = {}; ############################################ # Scan 'revision:' print STDERR "Try revision: $lineno:$line\n" if ( $debug > 2); if ( $line =~ s/^revision[ :]// ) { $line =~ s/\s+;?\s*$//; $v->{revision} = $line; push(@{$obj->{revisions}}, $line); $obj->{revision}->{$line} = $v; $v->{symbolic_names} = $obj->{rev_to_sym_names}->{$line} || []; if ( defined($line = shift @lines) ) { $lineno ++; } print STDERR "Matched revision '$v->{revision}': $lineno:$line\n" if ( $debug > 1 ); } print STDERR "After revision '$v->{revision}': $lineno:$line\n" if ( $debug > 1 ); while ( $line =~ /^\s*$/ ) { print STDERR "Eat blank line: $lineno:$line\n" if ( $debug > 1 ); if ( defined($line = shift @lines) ) { $lineno ++; } } ############################################ # Scan ': ;' KEY1: while ( defined $line && $line ne '' ) { $line =~ s/^\s+//; if ( $line =~ s/^([a-zA-Z_]+)\s*:\s*([^;]+)(;|$)// ) { print STDERR "Matched key '$1' '$2': $lineno:$line\n" if ( $debug > 1 ); $v->{$1} = $2; } else { last KEY1; } } if ( defined($line = shift @lines) ) { $lineno ++; } ############################################ # Scan 'branches: ' if ( $line =~ s/^branches:\s*// ) { $line =~ s/\s+$//; $v->{branches} = [ split(/\s/, $line) ]; print STDERR "Matched branches: '$1': $lineno:$line\n" if ( $debug > 1 ); if ( defined($line = shift @lines) ) { $lineno ++; } } ############################################ # Scan comment $v->{comment} = ''; while ( defined $line && ($line !~ /^(-+|=+)$/) ) { $line =~ s/^\s+//; $line =~ s/\s+$//; if ( $line ne '' && $line !~ m@^\s*\*\*\* empty log message \*\*\*\s*$@ ) { $v->{comment} .= $line . "\n"; print STDERR "Comment: $line\n" if ( $debug > 1 ); } if ( defined($line = shift @lines) ) { $lineno ++; } } if ( defined($line = shift @lines) ) { $lineno ++; } } $obj; } 1; dbmi0.1/src/bin/dos2unix.c0100644000175200017560000000047005551357511015737 0ustar stephensstepheng#include int main() { int c; while ( (c = getchar()) != EOF ) { if ( c == '\r' ) { if ( (c = getchar()) == '\n' ) { putchar('\n'); } else { putchar('\r'); if ( c != EOF ) putchar(c); } } else { putchar(c); } } return 0; } dbmi0.1/src/bin/swig2def.pl0100744000175200017560000000066407262414406016073 0ustar stephensstepheng#!/usr/bin/perl use English; $RS = ';'; my $id = 1; print "EXPORTS\n"; while ( <> ) { if ( s/^\s*[a-z_]*extern[a-z_]*\s+((const\s*)?\w+\s*\**\s*\**)//si ) { my $type = $1; print STDERR "line '$_'\n"; $type =~ s/\s+//sg; while ( s/(\w+)//s ) { my $symbol = $1; my $data = (s/[(][^\]]*[)]//s ? '' : 'DATA '); if ( ! $data ) { print "\t$symbol @ $id $data;\n"; ++ $id; } } } } 1; dbmi0.1/src/bin/.#uud.1.20100744000175200017560000000417207245406670015167 0ustar stephensstepheng#!/bin/perl # # scans files for a uuencoded items in files and decodes them to $dir # and adds a line to $db based on the Subject: lines found # $count = 0; $subject = ''; $dir = shift || die("Specify an output directory"); $db = "$dir/images.txt"; @files = (); %subjects = (); %files = (); $again = 0; while ( $again || defined($_ = <>) ) { $again = 0; chop; if ( s/^Subject:\s+// ) { $subject = $_; } elsif ( /^begin\s+(\S+)\s+(\S+)/ ) { $mode = $1; $file = $2; print STDERR "File: $file, Subject: $subject\n"; if ( $file ne '' ) { $str = ''; $nlines = 0; while ( defined($_ = <>) ) { $nlines ++; if ( $nlines % 100 ) { print STDERR "$nlines lines...\r"; } last if /^end/; if ( /^Subject:\s+/ || /^begin\s+(\S+)\s+(\S+)/ ) { print STDERR "WARNING: found $_"; $again ++; last; } next if /[a-z]/; next unless int((((ord() - 32) & 077) + 2) / 3) == int(length() / 4); $str .= unpack('u', $_); } # Remove dir from $file name $file =~ s@^.*/@@; # Add .jpg suffix if needed $file .= "_" . ($count ++) . ".jpg" if ( $file !~ /\.jpg$/ ); # Give it an orignal name if ( 0 ) { while ( -f "$dir/$file" ) { $file =~ s/_([0-9]+)(\.[^\.]+)$//; $suffix = $1; $file .= ($count ++) . $suffix; } } # If the file doesn't already exist if ( ! -f "$dir/$file" ) { # Add an entry to the index push(@files, $file); while ( defined($files{$subject}) ) { $subject =~ s/_([0-9]+)$//; $subject .= '_' . ($1 + 1); } $subjects{$file} = $subject; $files{$subject} = $file; # print "file = $file, mode = $mode, subject = $subject\n"; # Write the file open(F, ">$dir/$file"); binmode(F); print F $str; close(F); #exit(0); } } } } #Append to db $exists = -r $db; open(INDEX, ">>$db"); binmode(INDEX); print INDEX "Filename\tSubject\n" if ( ! $exists ); foreach $file ( sort(@files) ) { $subject = $subjects{$file}; print INDEX "$file\t$subject\n"; } close(INDEX); ########################################################################## 1; dbmi0.1/src/bin/.#uudindex.1.20100744000175200017560000000711507245406752016220 0ustar stephensstepheng#!/bin/perl # Creates a html index for stuff in $dir listed by $db # Run this after uud. # $dir = shift || "images"; $db = "$dir.txt"; $_html = '.html'; ########################################################################## @fieldnames = (); @fields = (); @records = (); @files = (); %subjects = (); %files = (); #Read db open(INDEX, "<$db"); binmode(INDEX); # First record is the field names $_ = ; chop; @fieldnames = split("\t", $_); $fieldindex = 0; foreach $fieldname ( @fieldnames ) { $fieldindex{$fieldname} = $fieldindex ++; } while ( ) { chop; @fields = split("\t", $_); push(@records, [ @fields ]); } close(INDEX); #Create index.html $menu = "menu_" . $fieldnames[0] . $_html; open(INDEX, ">$dir/index$_html"); binmode(INDEX); print INDEX qq@ None <BODY> <CENTER> This frameset document contains: <UL> <LI> <A HREF="$menu">Menu</A></LI> </UL> </BODY> @; close(INDEX); #Create blank.html open(INDEX, ">$dir/blank$_html"); binmode(INDEX); print INDEX q@ None @; close(INDEX); sub add_suffix { my($x,$s) = @_; $x =~ s/\.[^.]+$//; $x .= $s; $x; } #Create menus $fieldindex = -1; foreach $fieldname ( @fieldnames ) { $fieldindex ++; $menu = "menu_$fieldname$_html"; open(INDEX, ">$dir/$menu"); binmode(INDEX); print INDEX qq~ None ~; # Put a record to select a different column sorting print INDEX qq~~; foreach $fname ( @fieldnames ) { print INDEX qq~~; foreach $field ( @$record ) { print INDEX qq~
$fname~; } print INDEX "\n"; # Sort by Filename and create htmls for each file $fieldindex = $fieldindex{'Filename'}; @records = sort { $a->[$fieldindex] cmp $b->[$fieldindex] } @records; foreach $ri ( 0..$#records ) { $record = $records[$ri]; $image = $record->[0]; $HREF = add_suffix($record->[0], $_html); $prev = $ri > 0 ? add_suffix($records[$ri - 1]->[0], $_html) : undef; $next = $ri <= $#records ? add_suffix($records[$ri + 1]->[0], $_html) : undef; print STDERR "HREF='$HREF', image='$image', prev='$prev', next='$next'\n"; exit(1); if ( $HREF ) { open(HREF,">$HREF") || die "Cannot write '$HREF'"; print HREF qq~ None
$record->[1]

~; if ( $prev ) { print HREF qq~PREV $prev\n~; } if ( $next ) { print HREF qq~NEXT $next\n~; } print HREF qq~


$image\n~; print HREF qq~
~; close(HREF); } } # Sort by current field @records = sort { $a->[$fieldindex] cmp $b->[$fieldindex] } @records; foreach $ri ( 0..$#records ) { $record = $records[$ri]; $HREF = add_suffix($record->[0]. $_html); print INDEX qq~
$field~; } print INDEX "\n"; } print INDEX qq~

~; close(INDEX); } 1; dbmi0.1/src/bin/cvsfix.pl0100644000175200017560000000222007264417364015660 0ustar stephensstepheng#!/usr/local/bin/perl # $Id: cvsfix.pl,v 1.1 2001/04/09 20:43:32 stephens Exp $ # use File::Find; $debug = 9; $testing = 0; $keep_backup = 1; $filename = '(Entries|Root|Repository)'; while ( @ARGV ) { $_ = shift @ARGV; if ( /^--?f/ ) { $filename = shift @ARGV; } elsif ( /^--?d/ ) { ++ $debug; } elsif ( /^--?t/ ) { ++ $testing; } elsif ( /^--?[h?]/ ) { print "Removes CRs from CVS files.\n"; } else { push(@ARGV, $_); last; } } sub wanted { my ($file) = $File::Find::name; #print STDERR "$file\n"; if ( $file =~ m@/CVS/(Entries|Root|Repository)$@s ) { my($in, $out) = ( $_, "$_.tmp" ); my($line); print STDERR "Checking: $file\n" if ( $debug > 1 ); open($in, "<$in") || die "$in: $!"; binmode($in); $line = join('', <$in>); close($in); #print STDERR "$line"; if ( $line =~ s/\r//sg ) { print "Had CR: $file\n"; if ( ! $testing ) { rename($in, $out) || die "rename $in $out: $!"; open($in, ">$in") || die "$in: $!"; binmode($in); print $in $line; close($in); #unlink($out) if ( ! $keep_backup ); } } } } find(\&wanted, @ARGV); 1; dbmi0.1/src/util/0040755000175200017560000000000007306140336014222 5ustar stephensstephengdbmi0.1/src/util/CVS/0040755000175200017560000000000007270653774014674 5ustar stephensstephengdbmi0.1/src/util/CVS/Root0100644000175200017560000000003407236675453015534 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/util/CVS/Repository0100644000175200017560000000002207236675453016765 0ustar stephensstephenghome/ion/src/util dbmi0.1/src/util/CVS/Entries0100644000175200017560000000341607270653774016231 0ustar stephensstepheng/ConfigInfo.c/1.9/Tue Jan 4 06:22:24 2000// /ConfigInfo.h/1.4/Mon Apr 5 19:04:21 1999// /Makefile/1.15/Tue Jan 4 06:22:24 2000// /Makefile.use/1.2/Fri Feb 19 09:26:46 1999// /PKG/1.7/Fri May 7 12:30:05 1999// /bitset.h/1.1/Fri Jan 7 09:39:13 2000// /charset.c/1.2/Thu Sep 30 18:53:44 1999// /charset.h/1.1/Thu Apr 22 05:45:47 1999// /enum.c/1.8/Thu Jan 13 14:03:55 2000// /enum.h/1.7/Thu Jan 13 13:58:11 2000// /errlist.h/1.5/Thu Jan 13 11:22:31 2000// /errlist.pl/1.6/Tue Oct 26 23:41:37 1999// /file.c/1.4/Thu Feb 1 06:22:18 2001// /file.h/1.4/Thu Feb 1 06:22:18 2001// /host.c/1.2/Tue Jan 4 06:22:24 2000// /host.h/1.3/Tue Jan 4 06:34:47 2000// /lockfile.c/1.6/Tue Jan 4 06:22:24 2000// /lockfile.h/1.3/Wed Jun 9 05:43:23 1999// /lockfile_main.c/1.1/Wed Jun 9 05:43:31 1999// /mem.c/1.2/Fri Feb 19 09:26:47 1999// /mem.h/1.5/Mon Jun 28 14:04:14 1999// /midi.h/1.1/Wed Oct 13 17:30:44 1999// /outbuf.c/1.3/Tue Jan 4 06:22:24 2000// /outbuf.h/1.2/Thu Sep 30 18:49:28 1999// /path.c/1.5/Mon Jun 28 14:04:14 1999// /path.h/1.2/Fri Feb 19 09:26:47 1999// /port.c/1.2/Tue Jan 4 06:22:24 2000// /port.h/1.3/Tue Jan 4 06:34:47 2000// /prime.c/1.6/Thu Jan 13 13:29:50 2000// /prime.h/1.3/Thu Jan 13 13:25:04 2000// /rc4.c/1.4/Wed May 10 03:55:22 2000// /rc4.h/1.4/Wed May 10 03:55:22 2000// /setenv.c/1.3/Mon Apr 5 19:04:22 1999// /setenv.h/1.3/Mon Apr 5 19:04:22 1999// /sig.c/1.2/Tue Jan 4 05:53:51 2000// /sig.h/1.2/Tue Jan 4 05:53:51 2000// /sigs.pl/1.4/Tue Jan 4 05:53:51 2000// /ssprintf.c/1.2/Tue Jan 4 06:22:24 2000// /ssprintf.h/1.1/Thu Apr 22 05:07:25 1999// D/test//// /refcntptr.cc/1.1/Thu Apr 5 20:23:33 2001// /memcpy.h/1.1/Fri Apr 6 03:05:28 2001// /refcntptr.hh/1.3/Thu Apr 19 18:54:30 2001// /nurbs.c/1.1/Sun Apr 22 21:53:39 2001// /nurbs.h/1.1/Sun Apr 22 21:53:39 2001// dbmi0.1/src/util/ConfigInfo.c0100644000175200017560000005104607034310640016405 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_util_ConfigInfo_c__ #define __rcs_id_util_ConfigInfo_c__ static const char __rcs_id_util_ConfigInfo_c[] = "$Id: ConfigInfo.c,v 1.9 2000/01/04 06:22:24 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include "ConfigInfo.h" #include #include #include /* isspace() */ #include #include #include #include #ifdef __NeXT__ #include /* open, read, close */ #endif #include #include #include #ifdef MEMDEBUG #include "memdebug/memdebug.h" #endif ConfigInfoError ConfigInfoError_OK = "OK", ConfigInfoError_CannotStat = "Cannot stat file", ConfigInfoError_CannotAlloc = "Cannot allocate memory", ConfigInfoError_CannotOpen = "Cannot open file", ConfigInfoError_CannotRead = "Cannot read file", ConfigInfoError_; ConfigInfoError ConfigInfo_dump(ConfigInfo *c, FILE *fp, ConfigInfo *style, int depth) /* Dumps the config ^c^ to ^fp^, using ^style^'s lexical controls. Recurses to ^depth^, or to bottom of config chain if ^depth^ < 0. */ { if ( ! style ) { static ConfigInfo defaultStyle; defaultStyle.fieldSep = "\t"; defaultStyle.recordSep = "\n"; defaultStyle.commentBegin = "#"; defaultStyle.commentEnd = defaultStyle.recordSep; style = &defaultStyle; } while ( c ) { int i; fprintf(fp, "%sfrom %s%s", style->commentBegin ? style->commentBegin : "", c->from_where ? c->from_where : "", style->commentEnd ? style->commentEnd : ""); for ( i = 0; i < c->nconfigs; i ++ ) { int j; for ( j = 0; j < c->nfields[i]; ) { fwrite(c->configs[i][j], 1, strlen(c->configs[i][j]), fp); if ( ++ j < c->nfields[i] ) { fwrite(style->fieldSep, 1, strlen(style->fieldSep), fp); } } fwrite(style->recordSep, 1, strlen(style->recordSep), fp); } if ( depth > 0 ) { depth --; } if ( depth == 0 ) break; c = c->chain; } return ConfigInfoError_OK; } ConfigInfoError ConfigInfo_destroy(ConfigInfo *c) /* Destroys storage assocated with ^c^. */ { if ( ! c ) return ConfigInfoError_OK; if ( c->from_where ) { free(c->from_where); c->from_where = 0; } if ( c->configs ) { int i; for ( i = 0; i < c->nconfigs; i ++ ) { int j; /* Free externally allocated config data */ for ( j = 0; j < c->nfields[i]; j ++ ) { #if 1 if ( ! (c->buf <= c->configs[i][j] && c->configs[i][j] < c->buf + c->bufsize) ) { fprintf(stderr, "ConfigInfo_destroy(%p): freeing external string at [%d][%d] '%s'\n", c, i, j, c->configs[i][j]); free(c->configs[i][j]); } #endif c->configs[i][j] = 0; } free(c->configs[i]); c->configs[i] = 0; c->nfields[i] = 0; } free(c->configs); c->configs = 0; } c->nconfigs = 0; if ( c->nfields ) { free(c->nfields); c->nfields = 0; } if ( c->buf ) { memset(c->buf, 0, c->bufsize); free(c->buf); c->buf = 0; } c->bufsize = 0; c->instance_id = 0; return ConfigInfoError_OK; } ConfigInfoError ConfigInfo_free(ConfigInfo *c, int free_chain) /* Destroy storage assocated with ^c^ and frees ^c^. Recurses on all chains if ^free_chain^ is non-zero. */ { while ( c ) { ConfigInfo *chain; chain = c->chain; ConfigInfo_destroy(c); memset(c, 0, sizeof(*c)); free(c); if ( ! free_chain ) { break; } c = chain; } return ConfigInfoError_OK; } static int strprefix(const char *str, const char *pre) { if ( ! pre ) return 0; while ( *pre ) { if ( *str != *pre ) return 0; str ++; pre ++; } return 1; } ConfigInfoError ConfigInfo_initFromBuffer(ConfigInfo *c, char *buf, size_t bufsize) { ConfigInfoError result = ConfigInfoError_OK; int commentEndIsRecordSep; int i, j; char *s, *next_line; char *bufend; #define return(X) do { result = (X); goto rtn; } while(0) c->buf = buf; c->bufsize = bufsize != (size_t) -1 ? bufsize : strlen(buf) + 1; c->chain = 0; bufend = c->buf + c->bufsize; if ( ! c->recordSep ) { c->recordSep = "\n"; } if ( ! c->fieldSep ) { c->fieldSep = "\t"; } if ( ! c->commentEnd ) { c->commentEnd = c->recordSep; } commentEndIsRecordSep = ! strcmp(c->commentEnd, c->recordSep); /* Count the number of lines so we can guesstimate the length of c->configs */ for ( s = c->buf, i = 0; *s; ) { if ( strprefix(s, c->recordSep) ) { s += strlen(c->recordSep); i ++; } else { s ++; } } /* Allocate the config buffer */ if ( (c->configs = calloc(sizeof(c->configs[0]), (i + 1))) == 0 ) { return ConfigInfoError_CannotAlloc; } /* Allocate the nfields buffer */ if ( (c->nfields = calloc(sizeof(c->nfields[0]), (i + 1))) == 0 ) { return ConfigInfoError_CannotAlloc; } /* Skip header records */ for ( s = c->buf, i = c->skipHeaderRecords; i && s < bufend; ) { if ( strprefix(s, c->recordSep) ) { s += strlen(c->recordSep); i --; } else { s ++; } } /* Begin parsing each config */ for ( i = 0; *s && s < bufend; s = next_line ) { char *t; /* Skip leading whitespace */ if ( c->skipLeadingWhiteSpace ) { while ( *s && isspace(*s) ) s ++; } /* Find next_line */ next_line = s; while ( *next_line && next_line < bufend ) { if ( strprefix(next_line, c->recordSep) ) { next_line += strlen(c->recordSep); break; } next_line ++; } /* Skip trailing whitespace */ if ( c->skipTrailingWhiteSpace ) { t = next_line; t -= strlen(c->recordSep); while ( t > s ) { if ( isspace(*t) ) { char *dst = t; const char *src = c->recordSep; while ( *src ) *(dst ++) = *(src ++); t --; } else { break; } } } /* Skip comment only lines */ #define SKIP_COMMENTS(s,E) if ( strprefix(s, c->commentBegin) ) { (void) (E); s += strlen(c->commentBegin); while ( *s && ! strprefix(s, c->commentEnd) ) s ++; if ( *s && ! commentEndIsRecordSep ) { s += strlen(c->commentEnd); } } SKIP_COMMENTS(s,0) /* Skip blank lines */ if ( c->skipBlankRecords && strprefix(s, c->recordSep) ) { s += strlen(c->recordSep); continue; } /* Count the number of field separators to g */ for ( t = s, j = 1; *t && ! strprefix(t, c->recordSep); ) { SKIP_COMMENTS(t,0) else if ( strprefix(t, c->fieldSep) ) { t += strlen(c->fieldSep); j ++; } else { t ++; } } if ( c->maxFields && j > c->maxFields ) { j = c->maxFields; } c->nfields[i] = j; /* Allocate an array for the fields */ if ( (c->configs[i] = calloc(sizeof(c->configs[0][0]), (j + 1))) == 0 ) { return(ConfigInfoError_CannotAlloc); } /* Parse out the fields */ for ( t = s, j = 1, c->configs[i][0] = t; *t && ! strprefix(t, c->recordSep) ; ) { if ( j == c->nfields[i] ) { while ( *t && ! strprefix(t, c->recordSep) ) { SKIP_COMMENTS(t,*t = '\0') else t ++; } break; } SKIP_COMMENTS(t,*t = '\0') if ( strprefix(t, c->fieldSep) ) { *t = '\0'; t += strlen(c->fieldSep); c->configs[i][j ++] = t; } else { t ++; } } if ( strprefix(t, c->recordSep) ) { *t = '\0'; t += strlen(c->recordSep); } s = t; c->configs[i][j] = 0; c->nfields[i] = j; i ++; } c->nconfigs = i; if ( c->from_where ) { c->from_where = strcpy(ConfigInfo_MALLOC(strlen(c->from_where) + 1), c->from_where); } { static int instance_id = 0; c->instance_id = ++ instance_id; } /* ConfigInfo_dump(c, stderr, 0, 0); */ rtn: if ( result != ConfigInfoError_OK ) { ConfigInfo_destroy(c); } #undef return return result; } ConfigInfoError ConfigInfo_initFromFile(ConfigInfo *c, const char *file) { ConfigInfoError result = ConfigInfoError_OK; int fd = -1; char *buf; size_t bufsize; #define return(X) do { result = (X); goto rtn; } while(0) /* Determine the size of the parse buffer */ { struct stat s; if ( stat(file, &s) == -1 ) { return(ConfigInfoError_CannotStat); } bufsize = s.st_size; } /* Allocate the parse buffer */ if ( (buf = malloc(sizeof(buf[0]) * (bufsize + 1))) == 0 ) { return(ConfigInfoError_CannotAlloc); } /* Open the file and read into the parse buffer */ if ( (fd = open(file, O_RDONLY)) >= 0 ) { size_t r; size_t bufi = 0; size_t bufs = bufsize; bufsize = 0; while ( (r = read(fd, buf + bufi, bufs)) > 0 ) { bufi += r; bufs -= r; bufsize += r; } if ( bufsize > 0 ) { buf[bufsize] = '\0'; } else { return(ConfigInfoError_CannotRead); } close(fd); fd = -1; } else { return(ConfigInfoError_CannotOpen); } c->from_where = (char*) file; result = ConfigInfo_initFromBuffer(c, buf, bufsize + 1); rtn: if ( result != ConfigInfoError_OK ) { if ( fd != -1 ) close(fd); } #undef return return result; } ConfigInfoError ConfigInfo_initFromValueArray(ConfigInfo *c, const char **values) { char *buf; size_t bufsize; char *s, *t; char **v; bufsize = 0; v = (char **) values; while ( (t = *(v ++)) ) { bufsize += strlen(t) + 3; while ( (t = *(v ++)) ) { bufsize += strlen(t) + 3; } } c->fieldSep = "\02"; c->recordSep = "\01"; c->commentBegin = c->commentEnd = 0; c->maxFields = 0; if ( (buf = malloc(sizeof(buf[0]) * (bufsize + 1))) == 0 ) { return(ConfigInfoError_CannotAlloc); } s = buf; v = (char **) values; while ( (t = *(v ++)) ) { assert(s < buf + bufsize); strcpy(s, t); while ( (t = *(v ++)) ) { assert(s < buf + bufsize); strcat(s, c->fieldSep); strcat(s, t); s = strchr(s, '\0'); } strcat(s, c->recordSep); s = strchr(s, '\0'); } assert(s < buf + bufsize); *s = '\0'; if ( ! c->from_where ) c->from_where = "values"; return ConfigInfo_initFromBuffer(c, buf, -1); } ConfigInfoError ConfigInfo_initFromValues(ConfigInfo *c, ...) { const char *t; va_list vap; int nvalues = 0; const char **values = 0; ConfigInfoError error = ConfigInfoError_OK; va_start(vap, c); while ( (t = va_arg(vap, char*)) ) { nvalues ++; while ( (t = va_arg(vap, char*)) ) { nvalues ++; } nvalues ++; /* null term */ } va_end(vap); nvalues ++; /* null term */ values = malloc(sizeof(values[0]) * nvalues); va_start(vap, c); nvalues = 0; while ( (t = va_arg(vap, char*)) ) { values[nvalues ++] = t; while ( (t = va_arg(vap, char*)) ) { values[nvalues ++] = t; } values[nvalues ++] = t; } va_end(vap); values[nvalues ++] = t; error = ConfigInfo_initFromValueArray(c, values); free(values); return error; } ConfigInfoError ConfigInfo_initFromEnvironment(ConfigInfo *c, const char **env) { ConfigInfoError error = ConfigInfoError_OK; char *buf; size_t bufsize; int i; char *s; bufsize = 1; for ( i = 0; env[i]; i ++ ) { bufsize += strlen(env[i]) + 1; } if ( (buf = malloc(sizeof(buf[0]) * (bufsize + 1))) == 0 ) { return(ConfigInfoError_CannotAlloc); } c->commentBegin = c->commentEnd = 0; c->fieldSep = "="; c->recordSep = "\01"; c->maxFields = 2; for ( s = buf, i = 0; env[i]; i ++ ) { assert(s < buf + bufsize); strcpy(s, env[i]); strcat(s, c->recordSep); s = strchr(s, '\0'); } assert(s < buf + bufsize); assert(s == buf + bufsize - 1); c->from_where = "environment"; error = ConfigInfo_initFromBuffer(c, buf, bufsize); return error; } const char *ConfigInfo_ARGV0 = "*argv0*", *ConfigInfo_ARGV = "*argv*", *ConfigInfo_ARGV0_BASENAME = "*argv0-basename*"; ConfigInfoError ConfigInfo_initFromArgv(ConfigInfo *c, int argc, const char **argv, const char *opts) { char *buf; size_t bufsize; int i; char *s; const char *argv0_basename; if ( ! opts ) opts = ""; argv0_basename = (argv0_basename = strrchr(argv[0], '/')) ? argv0_basename + 1 : argv[0]; bufsize = 0; bufsize += strlen(ConfigInfo_ARGV) + 3; bufsize += strlen(ConfigInfo_ARGV0) + strlen(argv[0]) + 3; bufsize += strlen(ConfigInfo_ARGV0_BASENAME) + strlen(argv0_basename) + 3; for ( i = 0; i < argc && argv[i]; i ++ ) { bufsize += (strlen(argv[i]) + 3) * 2; } if ( (buf = malloc(sizeof(buf[0]) * (bufsize + 1))) == 0 ) { return(ConfigInfoError_CannotAlloc); } c->fieldSep = "\02"; c->recordSep = "\01"; c->commentBegin = c->commentEnd = 0; c->maxFields = 0; s = buf; strcpy(s, ConfigInfo_ARGV0); strcat(s, c->fieldSep); strcat(s, argv[0]); strcat(s, c->recordSep); s = strchr(s, '\0'); strcpy(s, ConfigInfo_ARGV0_BASENAME); strcat(s, c->fieldSep); strcat(s, argv0_basename); strcat(s, c->recordSep); s = strchr(s, '\0'); for ( i = 1; i < argc && argv[i]; i ++ ) { const char *arg = argv[i]; const char *t; assert(s < buf + bufsize); /* Does the arg start with '-'? */ if ( *arg != '-' ) break; /* It might be a switch */ /* Skip extra '-' */ arg ++; if ( *arg == '-' ) arg ++; /* Not a switch */ if ( ! *arg ) break; /* Look for "--[" ... "]" */ if ( arg[0] == '[' && arg[1] == '\0' ) { i ++; while ( i < argc && argv[i] && strcmp(argv[i], "]") != 0 ) { strcat(s, argv[i]); if ( ++ i < argc ) { strcat(s, c->fieldSep); } } } else /* Look for "--?option=value" */ if ( (t = strchr(arg, '=')) ) { strncpy(s, arg, t - arg); s += t - arg; strcpy(s, c->fieldSep); strcat(s, t + 1); } else { strcpy(s, arg); strcat(s, c->fieldSep); /* Is a a single op char? */ if ( arg[1] == '\0' && strchr(opts, arg[0]) ) { strcat(s, "1"); } else { /* Must be "--?option" "value" */ i ++; if ( i < argc && argv[i] ) { strcat(s, argv[i]); } } } strcat(s, c->recordSep); s = strchr(s, '\0'); } /* Store remaining args in *argv* */ strcpy(s, ConfigInfo_ARGV); s = strchr(s, '\0'); for ( ; i < argc && argv[i]; i ++ ) { assert(s < buf + bufsize); strcpy(s, c->fieldSep); strcat(s, argv[i]); s = strchr(s, '\0'); } strcpy(s, c->recordSep); s = strchr(s, '\0'); assert(s < buf + bufsize); c->from_where = "argv"; return ConfigInfo_initFromBuffer(c, buf, -1); } int ConfigInfo_getRowIndexForKey(ConfigInfo *c, int keyfield, const char *key, ConfigInfo **fc) { if ( fc ) { *fc = 0; } if ( key ) while ( c ) { int i; for ( i = 0; i < c->nconfigs; i ++ ) { if ( keyfield < c->nfields[i] && strcmp(c->configs[i][keyfield], key) == 0 ) { if ( fc ) *fc = c; return i; } } c = c->chain; } return -1; } const char **ConfigInfo_getRowForKey(ConfigInfo *c, int keyfield, const char *key) { ConfigInfo *fc = 0; int i = ConfigInfo_getRowIndexForKey(c, keyfield, key, &fc); if ( i >= 0 && fc ) { return (const char **) fc->configs[i]; } return 0; } const char *ConfigInfo_getValue1(ConfigInfo *c, const char *key) { if ( key && c ) { int i; int keyfield = 0; for ( i = 0; i < c->nconfigs; i ++ ) { if ( keyfield < c->nfields[i] && strcmp(c->configs[i][keyfield], key) == 0 ) { return c->configs[i][1]; } } } return 0; } const char *ConfigInfo_getValue(ConfigInfo *c, const char *key) { const char **row; return (const char *) ((row = ConfigInfo_getRowForKey(c, 0, key)) ? row[1] : 0); } const char *ConfigInfo_getValueOr(ConfigInfo *c, const char *key, const char *alt) { const char *value = ConfigInfo_getValue(c, key); return value ? value : alt; } int ConfigInfo_strToIntValue(const char *value) { if ( value ) { int c; while ( *value && isspace(*value) ) value ++; c = tolower(value[0]); if ( c == 'y' || c == 't' ) { return -1; } else if ( c == 'n' || c == 'f' ) { return 0; } else if ( *value ) { return atoi(value); } } return 0; } int ConfigInfo_strToBooleanValue(const char *str) { return ConfigInfo_strToIntValue(str); } int ConfigInfo_getIntValue(ConfigInfo *c, const char *key) { return ConfigInfo_strToIntValue(ConfigInfo_getValue(c, key)); } double ConfigInfo_getDoubleValue(ConfigInfo *c, const char *key) { const char *value; return (value = ConfigInfo_getValue(c, key)) ? atof(value) : 0; } int ConfigInfo_getBooleanValue(ConfigInfo *c, const char *key) { return ConfigInfo_strToBooleanValue(ConfigInfo_getValue(c, key)); } /*********************************************************************/ ConfigInfoError ConfigInfo_initFromDefaults(ConfigInfo *options, ConfigInfo *defaults, int argc, char **argv, char **env, ConfigInfo **configp) { ConfigInfo *config = 0; ConfigInfo *defaultConfig = 0, *envConfig = 0, *argvConfig = 0, *fileConfig = 0; static char error_buf[1024]; ConfigInfoError error = ConfigInfoError_OK; const char *opts = ConfigInfo_getValue(options, "opts"); *configp = 0; /* Config search should be Argv -> Configfile -> Env -> Defaults */ /* Defaults */ defaultConfig = defaults; /* Environment */ envConfig = ConfigInfo_MALLOC(sizeof(*envConfig)); memset(envConfig, 0, sizeof(*envConfig)); error = ConfigInfo_initFromEnvironment(envConfig, (const char **) env); if ( error != ConfigInfoError_OK ) { goto rtn; } envConfig->chain = defaults; config = envConfig; /* Config chain is now: env, defaults */ /* Argv */ argvConfig = ConfigInfo_MALLOC(sizeof(*argvConfig)); memset(argvConfig, 0, sizeof(*argvConfig)); error = ConfigInfo_initFromArgv(argvConfig, argc, (const char **) argv, opts); if ( error != ConfigInfoError_OK ) { goto rtn; } /* Config chain: argv, environment, defaults */ argvConfig->chain = envConfig; config = argvConfig; /* config file */ { const char *configfile; const char *basename; const char *template; char filename[1024]; /* Check for option configfile name override */ configfile = ConfigInfo_getValue(config, "configfile"); /* fprintf(stderr, "configfile = '%s'\n", configfile); */ if ( ! (configfile && *configfile) ) { /* Try to get the name of a config file */ basename = ConfigInfo_getValueOr(options, "configfile/basename", ConfigInfo_ARGV0_BASENAME); basename = ConfigInfo_getValueOr(config, basename, ""); template = ConfigInfo_getValueOr(options, "configfile/template", "configfile"); template = ConfigInfo_getValueOr(config, template, ""); sprintf(filename, template, basename); configfile = filename; } if ( *configfile ) { if ( ConfigInfo_getIntValue(config, "debug") ) { fprintf(stderr, "Loading config... \"%s\" ", configfile); fflush(stderr); } /* Allocate */ fileConfig = ConfigInfo_MALLOC(sizeof(*fileConfig)); memset(fileConfig, 0, sizeof(*fileConfig)); /* Fill in scanning options and defaults */ fileConfig->recordSep = ConfigInfo_getValueOr(options, "configfile/recordSep", "\n"); fileConfig->fieldSep = ConfigInfo_getValueOr(options, "configfile/fieldSep", "\t"); fileConfig->commentBegin = ConfigInfo_getValueOr(options, "configfile/commentBegin", "#"); fileConfig->commentEnd = ConfigInfo_getValueOr(options, "configfile/commentEnd", fileConfig->recordSep); fileConfig->skipLeadingWhiteSpace = ConfigInfo_strToBooleanValue(ConfigInfo_getValueOr(options, "configfile/skipLeadingWhiteSpace", "1")); fileConfig->skipTrailingWhiteSpace = ConfigInfo_strToBooleanValue(ConfigInfo_getValueOr(options, "configfile/skipTrailingWhiteSpace", "1")); fileConfig->skipBlankRecords = ConfigInfo_strToBooleanValue(ConfigInfo_getValueOr(options, "configfile/skipBlankRecords", "1")); fileConfig->maxFields = ConfigInfo_strToIntValue(ConfigInfo_getValueOr(options, "configfile/maxFields", "0")); if ( (error = ConfigInfo_initFromFile(fileConfig, configfile)) != ConfigInfoError_OK ) { sprintf(error_buf, "%s: Cannot read configfile \"%s\"\n", error, configfile); error = error_buf; goto rtn; } fileConfig->chain = envConfig; argvConfig->chain = fileConfig; config = argvConfig; /* Config chain is now: argv, configfile, environment, defaults */ if ( ConfigInfo_getIntValue(config, "debug") ) { fprintf(stderr, "done.\n"); fflush(stderr); } } } rtn: if ( error != ConfigInfoError_OK ) { ConfigInfo_free(argvConfig, 0); ConfigInfo_free(envConfig, 0); ConfigInfo_free(defaultConfig, 0); ConfigInfo_free(fileConfig, 0); config = 0; } *configp = config; return error; } /* EOF */ dbmi0.1/src/util/ConfigInfo.h0100644000175200017560000001133206702204465016414 0ustar stephensstepheng#ifndef _ConfigInfo_h #define _ConfigInfo_h #ifndef __rcs_id__ #ifndef __rcs_id_util_ConfigInfo_h__ #define __rcs_id_util_ConfigInfo_h__ static const char __rcs_id_util_ConfigInfo_h[] = "$Id: ConfigInfo.h,v 1.4 1999/04/05 19:04:21 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include /* size_t */ #include /* FILE */ #define ConfigInfo_MALLOC(X) malloc(X) #define ConfigInfo_REALLOC(X,Y) realloc(X,Y) #define ConfigInfo_FREE(X) free(X) typedef struct ConfigInfo { /* Contains the state for a ConfigInfo node. */ /*

Configuration Data
*/ char ***configs; /* Configurations are records containing any number of fields; generally configs[i][0] is the key for finding a configuration value. */ int *nfields; /* The number of fields for a configs[i]. */ int nconfigs; /* The number of rows in configs */ void **user; /* User-row data */ /*

Memory
*/ char *buf; /* Buffer allocated for initialization; all config values are within this buffer. */ size_t bufsize; /* The size of buf. */ /*

Lexical Controls
*/ const char *commentBegin; /* The string that begins a comment. */ const char *commentEnd; /* The string that ends a comment. */ const char *fieldSep; /* The string that delimits a field. */ const char *recordSep; /* The string that delimits a record. */ int skipLeadingWhiteSpace; /* If !0, skip any leading whitespace chars. */ int skipTrailingWhiteSpace; /* If !0, skip any leading whitespace chars. */ int skipBlankRecords; /* If !0, skip any records with no fields. */ int skipHeaderRecords; /* If !0, skip this number of records at the beginning. */ int maxFields; /* Specifies the max number of fields. */ /*

Search Chain
*/ struct ConfigInfo *chain; /* The next node to search if a search failed. ConfigInfo nodes can be chained to allow different configuration sources, like command line options, environment variables, default configurations and configuration files seem like one configuration. */ /*

Initialization
*/ char *from_where; /* Where is this ConfigInfo from? */ int instance_id; /* Each ConfigInfo struct gets a unique id when initialized. Use this to determine if a configuration has been reinitialized. */ } ConfigInfo; /* */ typedef const char *ConfigInfoError; extern ConfigInfoError ConfigInfoError_OK, ConfigInfoError_CannotStat, ConfigInfoError_CannotAlloc, ConfigInfoError_CannotOpen, ConfigInfoError_CannotRead; #if 0 ConfigInfoError ConfigInfo_setUserData(ConfigInfo *c, int row, void *ptr); void *ConfigInfo_userData(ConfigInfo *c, int row, void *ptr); #endif ConfigInfoError ConfigInfo_dump(ConfigInfo *c, FILE *fp, ConfigInfo *style, int depth); ConfigInfoError ConfigInfo_destroy(ConfigInfo *c); ConfigInfoError ConfigInfo_free(ConfigInfo *c, int free_chain); ConfigInfoError ConfigInfo_initFromBuffer(ConfigInfo *c, char *buf, size_t bufsize); ConfigInfoError ConfigInfo_initFromValueArray(ConfigInfo *c, const char **values); ConfigInfoError ConfigInfo_initFromValues(ConfigInfo *c, ...); ConfigInfoError ConfigInfo_initFromFile(ConfigInfo *c, const char *file); ConfigInfoError ConfigInfo_initFromEnvironment(ConfigInfo *c, const char **env); extern const char *ConfigInfo_ARGV0, *ConfigInfo_ARGV; ConfigInfoError ConfigInfo_initFromArgv(ConfigInfo *c, int argc, const char **argv, const char *opts); int ConfigInfo_getRowIndexForKey(ConfigInfo *c, int keyfield, const char *key, ConfigInfo **cfound); const char **ConfigInfo_getRowForKey(ConfigInfo *c, int keyfield, const char *key); const char *ConfigInfo_getValue1(ConfigInfo *c, const char *key); const char *ConfigInfo_getValue(ConfigInfo *c, const char *key); /* same as ConfigInfo_getRowForKey(c, 0, key)[1] */ const char *ConfigInfo_getValueOr(ConfigInfo *c, const char *key, const char *or); /* same as ConfigInfo_getRowForKey(c, 0, key)[1] */ ConfigInfoError ConfigInfo_initFromDefaults(ConfigInfo *options, ConfigInfo *defaults, int argc, char **argv, char **env, ConfigInfo **configp); int ConfigInfo_strToIntValue(const char *str); #define ConfigInfo_strToInt ConfigInfo_strToIntValue int ConfigInfo_strToBooleanValue(const char *str); #define ConfigInfo_strToBoolean ConfigInfo_strToBooleanValue int ConfigInfo_getIntValue(ConfigInfo *c, const char *key); double ConfigInfo_getDoubleValue(ConfigInfo *c, const char *key); int ConfigInfo_getBooleanValue(ConfigInfo *c, const char *key); #endif dbmi0.1/src/util/Makefile0100644000175200017560000000207107034310640015652 0ustar stephensstepheng# $Id: Makefile,v 1.15 2000/01/04 06:22:24 stephensk Exp $ INCLS += .. H_FILES = \ path.h \ ConfigInfo.h \ enum.h \ setenv.h \ sig.h \ signals.h \ errlist.h \ prime.h \ lockfile.h \ rc4.h \ ssprintf.h \ outbuf.h \ file.h \ host.h \ port.h C_FILES = \ path.c \ ConfigInfo.c \ enum.c \ setenv.c \ sig.c \ errlist.c \ prime.c \ lockfile.c \ rc4.c \ ssprintf.c \ outbuf.c \ file.c \ host.c \ port.c ################################################################# include $(MAKS)/pre.mak ################################################################# # Create LIB_NAME:=ionutil include $(MAKS)/lib.mak ################################################################# # Basic include $(MAKS)/basic.mak ################################################################# signals.h : sigs.pl perl sigs.pl < /usr/include/sys/signal.h > $@ ################################################################# errlist.c : errlist.pl perl errlist.pl < /usr/include/sys/errno.h > $@ ################################################################# dbmi0.1/src/util/Makefile.use0100644000175200017560000000012606663227126016461 0ustar stephensstepheng# $Id: Makefile.use,v 1.2 1999/02/19 09:26:46 stephensk Exp $ LIBS:=ionutil $(LIBS) dbmi0.1/src/util/PKG0100644000175200017560000000037106714556315014576 0ustar stephensstephengNAME=util VERSION=0.4 RCS_ID="$Id: PKG,v 1.7 1999/05/07 12:30:05 stephensk Exp $" DESC="A C library with path, mem, and other functions." CHANGES_RELEASES="0.4 0.3 0.2 0.1" CATEGORY="Development Tools" REQUIRES_PKGS="../maks" REQUIRES_OTHERS="perl" dbmi0.1/src/util/bitset.h0100644000175200017560000000131007035332101015645 0ustar stephensstepheng#ifndef BITSET_H #define BITSET_H /* $Id: bitset.h,v 1.1 2000/01/07 09:39:13 stephensk Exp $ */ /* Bitset ops. */ typedef unsigned int bitset_t; #ifndef bitset_BITS_PER_BYTE #define bitset_BITS_PER_BYTE 8 #endif #define bitset_ELEM_BSIZE (sizeof(bitset_t) * bitset_BITS_PER_BYTE) #define bitset_ELEM_LEN(S) (S / bitset_ELEM_BSIZE) #define bitset_MASK (bitset_ELEM_BSIZE-1) #define bitset_SHIFT (sizeof(bitset_t) == 4 ? 5 : 4) #define bitset_BIT(i) (1<<((i)&bitset_MASK)) #define bitset_OFF(i) ((i)>>bitset_SHIFT) #define bitset_get(bs, i) (bs[bitset_OFF(i)] & bitset_BIT(i)) #define bitset_set(bs, i) (bs[bitset_OFF(i)] |= bitset_BIT(i)) #define bitset_clr(bs, i) (bs[bitset_OFF(i)] &= ~bitset_BIT(i)) #endif dbmi0.1/src/util/charset.c0100644000175200017560000001073306774730670016036 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_misc_charset_c__ #define __rcs_id_misc_charset_c__ static const char __rcs_id_misc_charset_c[] = "$Id: charset.c,v 1.2 1999/09/30 18:53:44 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include /* strchr() */ #include /* isdigit(), isxdigit(), isprint(), iscntrl() */ #include "charset.h" #define PUTC(x) (*(s ++) = (x)) #define GETC() (*s ? *(s ++) : -1) #define PEEKC() (*s ? *s : -1) #define UNGETC(c) (*(-- s)) #define MATCHC(X) ({ if ( PEEKC() != (X) ) goto SYNTAX_ERROR; GETC(); }) #define PEEKCMATCHC(X) (PEEKC() == (X) ? (GETC(), 1) : 0) static const char escape_chars[] = "n\nr\rt\tf\fb\ba\av\ve\033"; int getc_escaped(char **_s) { unsigned char *s = (unsigned char *)*_s; int c; c = GETC(); if ( c == '\\' ) { const char *r; c = GETC(); if ( (r = strchr(escape_chars, c)) && ((r - escape_chars) % 2 == 0) ) { c = r[1]; } else if ( '0' <= c && c <= '7' ) { /* \012 -> \n */ int n = c; int ndigits = 0; c = 0; do { c <<= 3; c += n - '0'; ndigits ++; } while ( ndigits < 3 && (n = PEEKC(), '0' <= n && n <= '7' && GETC()) ); } else if ( tolower(c) == 'x' ) { /* \xff -> 0xff */ int n; int ndigits = 0; c = 0; while ( ndigits < 2 && (n = PEEKC(), isxdigit(n) && GETC()) ) { c <<= 4; c += isdigit(n) ? n - '0' : 'a' <= n && n <= 'f' ? n - 'a' + 10 : n - 'A' + 10; ndigits ++; } if ( ! ndigits ) { goto SYNTAX_ERROR; } } else if ( tolower(c) == 'c' ) { /* \cC -> Control-C */ c = GETC(); c &= 0x1F; /* leave bottom 5 bits */ } if ( c < 0 || c >= (UCHAR_MAX+1) ) { return -2; } } *_s = (char*) s; return c; SYNTAX_ERROR: *_s = (char*) s; return -2; } #define GETC_ESCAPED() ({ int c = getc_escaped((char **)&s); if ( c < 0 ) goto SYNTAX_ERROR; c; }) int putc_escaped(char **_s, int i) { char *s = *_s; char *r; if ( isprint(i) && isascii(i) && ! iscntrl(i) ) { PUTC(i); } else if ( (r = strchr(escape_chars, i)) && ((r - escape_chars) % 2 == 1) ) { PUTC('\\'); PUTC(r[-1]); } else { PUTC('\\'); PUTC(((i >> 6) & 0x7) + '0'); PUTC(((i >> 3) & 0x7) + '0'); PUTC(((i >> 0) & 0x7) + '0'); } *_s = (char*) s; return 0; } int charset_compile(charset *cs, char **_s) { unsigned char *s = (unsigned char*) *_s; short invert = 0; int c; charset_CLEAR(*cs); MATCHC('['); invert = PEEKCMATCHC('^'); while ( (c = PEEKC()) >= 0 && c != ']' ) { c = GETC_ESCAPED(); charset_SET(cs,c); if ( PEEKCMATCHC('-') ) { int oc = GETC_ESCAPED(); if ( c > oc ) { int t; t = c; c = oc; oc = t; } while ( c <= oc ) { charset_SET(cs,c); c ++; } } } MATCHC(']'); if ( invert ) { charset_INVERT(cs); } *_s = (char*) s; return 0; SYNTAX_ERROR: *_s = (char*) s; return -2; } int charset_print(charset *cs, char **_s) { char *s = *_s; int i, j; int invert; PUTC('['); if ( (invert = charset_MATCH(cs,(UCHAR_MAX+1))) ) { PUTC('^'); charset_INVERT(cs); /* Temporarly invert */ } for ( i = 0; i < (UCHAR_MAX+1); i ++ ) { if ( charset_MATCH(cs,i) ) { if ( i == '^' || i == '-' ) { PUTC('\\'); PUTC(i); } else { putc_escaped(&s, i); } for ( j = i + 1; j < (UCHAR_MAX+1); j ++ ) { if ( ! charset_MATCH(cs,j) ) break; } if ( j - i > 3 ) { i = j - 1; PUTC('-'); putc_escaped(&s, i); } } } if ( invert ) { charset_INVERT(cs); /* revert */ } PUTC(']'); *_s = (char*) s; return 0; } #undef GETC #undef PEEKC #undef UNGETC #undef MATCHC #undef PEEKCMATCHC #undef GETC_ESCAPED #ifdef TEST int main(int argc, char **argv) { int i; /* printf("sizeof(charset) = %d\n", (int) sizeof(charset)); */ for ( i = 1; i < argc; i ++ ) { char *t; if ( strcmp(argv[i], "-e") == 0 ) { i ++; for ( t = argv[i]; *t; ) { int c; unsigned char *s = t; c = getc_escaped(&t); printf("%s -> %d\n", s, c); } } else if ( strcmp(argv[i], "-c") == 0 ) { i ++; for ( t = argv[i]; *t; ) { unsigned char *s = t; charset cs; char buf[1024], *b = buf; if ( charset_compile(&cs,&t) < 0 ) { printf("syntax error at %s in %s\n", t, s); } else { charset_print(&cs,&b); } printf("%s -> %s\n", s, buf); } } } return 0; } #endif dbmi0.1/src/util/charset.h0100644000175200017560000000165706707533613016042 0ustar stephensstepheng#ifndef _charset_h #ifndef __rcs_id__ #ifndef __rcs_id_misc_charset_h__ #define __rcs_id_misc_charset_h__ static const char __rcs_id_misc_charset_h[] = "$Id: charset.h,v 1.1 1999/04/22 05:45:47 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define _charset_h #ifndef BITS_PER_CHAR #define BITS_PER_CHAR 8 #endif #ifndef UCHAR_MAX #define UCHAR_MAX 255 #endif typedef unsigned char charset[(UCHAR_MAX+1+1+BITS_PER_CHAR-1)/BITS_PER_CHAR]; #define charset_CLEAR(cs) bzero(cs, sizeof(charset)) #define charset_SET(cs,x) ((*(cs))[(x)/BITS_PER_CHAR]|=(1<<((x)%BITS_PER_CHAR))) #define charset_MATCH(cs,x) ((*(cs))[(x)/BITS_PER_CHAR]&(1<<((x)%BITS_PER_CHAR))) #define charset_INVERT(cs) do { \ int i; \ for ( i = 0; i < sizeof(charset); i ++ ) (*(cs))[i] ^= ~ 0; \ } while(0) int getc_escaped(char **_s); int putc_escaped(char **_s, int i); int charset_compile(charset *cs, char **_s); int charset_print(charset *cs, char **_s); #endif dbmi0.1/src/util/enum.c0100644000175200017560000000655607037355513015351 0ustar stephensstepheng/* Copyright (c) 1998, 1999 Kurt A. Stephens and Ion, Inc. */ #ifndef __rcs_id__ #ifndef __rcs_id_util_enum_c__ #define __rcs_id_util_enum_c__ static const char __rcs_id_util_enum_c[] = "$Id: enum.c,v 1.8 2000/01/13 14:03:55 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include "enum.h" #include #include #include int C_enum_str_to_value(const C_enum *table, const char *name, size_t name_len, long *result) { int i; if ( ! name ) return 0; if ( name_len == (size_t) -1 ) name_len = strlen(name); for ( i = 0; table[i].name; i ++ ) { if ( strncmp(table[i].name, name, name_len) == 0 && table[i].name[name_len] == '\0' ) { *result = table[i].value; return 1; } } return 0; } int C_enum_str_to_or_value(const C_enum *table, const char *name, size_t name_len, long *resultp) { long result = 0; const char *s; const char *e; if ( ! name ) return 0; if ( name_len == (size_t) -1 ) name_len = strlen(name); s = name; e = name + name_len; while ( s < e ) { long eresult = 0; const char *t; /* Scan for '|' or end of s */ for ( t = s; t != e; ++ t ) { if ( *t == '|' ) { break; } } if ( C_enum_str_to_value(table, s, t - s, &eresult) ) { result |= eresult; } else { return 0; } s = t + 1; } *resultp = result; return 1; } const char * C_enum_value_to_str(const C_enum *table, long value) { int i; for ( i = 0; table[i].name; ++ i ) { if ( table[i].value == value ) { return table[i].name; } } return 0; } const char * C_enum_or_value_to_str(const C_enum *table, long value, char *buf, size_t buf_len) { if ( value == 0 ) { /* There might be an enum of 0! */ return C_enum_value_to_str(table, value); } else { int i; /* table[i] */ char *bp; /* Current buf write position. */ int new_buf; /* Was the buf allocated by us? */ /* Calculate buf_len if not specified. */ if ( ! buf_len ) { buf_len = table[i].name ? strlen(table[i].name) + 1 : 16; } /* Allocate buffer if not specified. */ if ( ! buf ) { new_buf = 1; buf = malloc(buf_len); } else { new_buf = 0; } /* Initialize buffer and buffer pointer. */ buf[0] = '\0'; bp = buf; /* While value still has bits: */ while ( value ) { for ( i = 0; table[i].name; ++ i ) { /* If value has enum value's bits? */ if ( (value & table[i].value) == table[i].value ) { size_t len = (bp - buf); size_t name_len = strlen(table[i].name); size_t new_len = len + name_len + 2; /* Resize buffer if possible. */ if ( new_len > buf_len ) { if ( new_buf ) { buf = realloc(buf, new_len); bp = buf + len; } else { /* Buffer to small! */ return 0; } } /* Append trailing '|'. */ if ( buf[0] ) { *(bp ++) = '|'; } /* Append table[i].name. */ { const char *s = table[i].name; while ( *s ) { *(bp ++) = *(s ++); } } /* Remove enum value bits from value. */ value &= ~table[i].value; /* Try more values. */ goto next_value; } /* Try next enum value. */ } /* An enum value for values bits was not found. */ return 0; /* ERROR */ next_value: /* Try more values. */ (void) 0; } *bp = '\0'; return buf; } } dbmi0.1/src/util/enum.h0100644000175200017560000000142607037354763015353 0ustar stephensstepheng/* Copyright (c) 1998, 1999 Kurt A. Stephens and Ion, Inc. */ #ifndef _util_enum_h #define _util_enum_h #ifndef __rcs_id__ #ifndef __rcs_id_util_enum_h__ #define __rcs_id_util_enum_h__ static const char __rcs_id_util_enum_h[] = "$Id: enum.h,v 1.7 2000/01/13 13:58:11 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include /* size_t */ typedef struct C_enum { const char *name; long value; } C_enum; int C_enum_str_to_value(const C_enum *table, const char *name, size_t name_len, long *result); int C_enum_str_to_or_value(const C_enum *table, const char *name, size_t name_len, long *resultp); const char * C_enum_value_to_str(const C_enum *table, long value); const char * C_enum_or_value_to_str(const C_enum *table, long value, char *buf, size_t buf_len); #endif dbmi0.1/src/util/errlist.h0100644000175200017560000000027007037332567016065 0ustar stephensstepheng#ifndef _util_errlist_h #define _util_errlist_h #include #ifndef Linux #ifndef NeXT extern const char * const sys_errlist[]; extern int sys_nerr; #endif #endif #endif dbmi0.1/src/util/errlist.pl0100644000175200017560000000125407005436061016241 0ustar stephensstepheng#!/bin/perl # $Id: errlist.pl,v 1.6 1999/10/26 23:41:37 stephensk Exp $ @errs = (); while ( <> ) { #print; if ( m@^\s*#define\s+E(\w+)\s+([0-9]+)(\s+/\*\s*(.*)\s*(\*/))?@ ) { $name = $1; $err = $2; $comment = $4; $comment =~ s/\s+$//g; $errs[$err] = $comment; } } print "/* DO NOT MODIFY! Generated by $0 ", join(" ", @ARGV), " */\n"; print "#ifndef sun\n"; print "#ifndef NeXT\n"; print "const char *sys_errlist[] = {\n"; foreach $err ( 0 .. $#errs ) { if ( ! $errs[$err] ) { $errs[$err] = "Error $err"; } print '"', $errs[$err], '", ', "\n"; } print " 0\n};\n"; print "int sys_nerr = ", $#errs + 1, ";\n"; print "#endif\n"; print "#endif\n"; 1; dbmi0.1/src/util/file.c0100644000175200017560000002664607236200232015312 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_util_file_c__ #define __rcs_id_util_file_c__ static const char __rcs_id_util_file_c[] = "$Id: file.c,v 1.4 2001/02/01 06:22:18 ion Exp $"; #endif #endif /* __rcs_id__ */ #include "util/file.h" #include #include #include #include #include #include #include #include #include #include #include #include "util/path.h" static void write_error(const char *s) { write(2, s, strlen(s)); } static void *xmalloc(size_t s) { void *ptr = malloc(s); if ( ! ptr ) { write_error("out of memory in "); write_error(__FILE__); write_error("\n"); abort(); } return ptr; } time_t file_mtime(const char *fname) { struct stat s; #if 0 fprintf(stderr, "file_mtime(\"%s\")\n", fname); #endif return stat(fname, &s) == 0 ? (time_t) s.st_mtime : (time_t) 0; } int file_mode_masked(const char *fname, int euid, int egid) { struct stat s; int mask; if ( euid < 0 ) euid = geteuid(); if ( egid < 0 ) egid = getegid(); if ( stat(fname, &s) ) return 0; mask = euid == s.st_uid ? S_IRWXU : 0; mask |= egid == s.st_gid ? S_IRWXG : 0; mask |= (euid != s.st_uid && egid != s.st_gid) ? S_IRWXO : 0; return s.st_mode & mask; } int file_executable(const char *fname) { #if defined(WIN32) { const char *suffix = path_suffix(fname); return suffix && (strcasecmp(suffix, ".exe") == 0 || strcasecmp(suffix, ".con") == 0 || strcasecmp(suffix, ".bat") == 0 || strcasecmp(suffix, ".dll") == 0); } #else return file_mode_masked(fname, -1, -1) & (S_IXUSR|S_IXGRP|S_IXOTH); #endif } static int progname_try(char *buf) { #if 0 fprintf(stderr, "progname_try(\"%s\")\n", buf); #endif #if defined(_WIN32) || defined(WINNT) /* Try .exe */ strcat(buf, ".exe"); if ( file_mtime(buf) ) { return 1; } /* Try .com */ strcpy(strchr(buf, 0) - 4, ".com"); if ( file_mtime(buf) ) { return 1; } /* Try .dll */ strcpy(strchr(buf, 0) - 4, ".dll"); if ( file_mtime(buf) ) { return 1; } /* Try .bat */ strcpy(strchr(buf, 0) - 4, ".bat"); if ( file_mtime(buf) ) { return 1; } *(strchr(buf, 0) - 4) = 0; #else /* Try filename alone */ if ( file_executable(buf) ) { return 1; } #endif return 0; } int file_in_path(const char *argv0, const char *PATH, char *buf) { char dir_sep[] = "/"; if ( ! (argv0[0] == '/' || argv0[0] == '\\') ) { if ( (PATH || (PATH = getenv("PATH"))) && *PATH ) { const char *p, *pe, *pn; int path_sep = ':'; if ( strchr(PATH, ';') ) path_sep = ';'; for ( p = PATH, pe = PATH; *p; p = pn) { if ( (pe = strchr(p, path_sep)) ) { pn = pe + 1; } else { pn = ""; } if ( *p ) { strncpy(buf, p, pe - p); buf[pe - p] = 0; strcat(buf, dir_sep); strcat(buf, argv0); if ( progname_try(buf) ) return 1; } } } } strcpy(buf, argv0); if ( progname_try(buf) ) return 1; strcpy(buf, argv0); return 0; } size_t file_size(const char *file) { struct stat s; return stat(file, &s) ? 0 : s.st_size; } int file_touch(const char *file) { int fd; if ( (fd = open(file, O_RDWR, 0644)) >= 0 ) { char buf[1]; size_t bytes = sizeof(buf); buf[0] = 0; lseek(fd, 0, SEEK_SET); bytes = read(fd, buf, bytes); lseek(fd, 0, SEEK_SET); bytes = write(fd, buf, bytes); lseek(fd, 0, SEEK_END); close(fd); return 0; } return -1; } char *FILE_get_line_at_pos(FILE *fp, int linesize, pos_t pos, size_t *lenp, pos_t *line_pos) { /* ** Read a buffer twice the expected maximum linesize to handle ** hopefully to get a beginning and ending newline bounding the ** file position (pos) wanted. */ size_t bufsize = linesize * 2 + 3; /* The buffer read. */ char *buf = xmalloc(bufsize + 1); /* The size of the buffer read. */ pos_t readpos; /* Where the read began. */ do { /* Where to begin reading lines from. */ if ( pos < linesize ) { /* Dont read before beginning of file! */ readpos = 0; } else { readpos = pos - linesize; } /* Read a buffer and terminate it. */ fseek(fp, readpos, SEEK_SET); bufsize = fread(buf, 1, bufsize, fp); buf[bufsize] = '\0'; /* Guard. */ { /* Buffer begin/end */ const char *bb = buf, *be = buf + bufsize; /* Position wanted within the buffer. */ const char *pp = bb + (pos - readpos); /* Line begin/end */ const char *lb = bb, *le; /* Find beginning of first line. */ if ( readpos > 0 ) { while ( *lb != '\n' ) { if ( lb == be ) { /* Beginning of first line not found. */ goto bigger; } ++ lb; } /* Skip newline. */ ++ lb; } do { /* Find end of current line. */ le = lb; while ( *le != '\n' ) { if ( le == be ) { /* End of line not found. */ goto bigger; } ++ le; } /* Skip newline. */ ++ le; /* ** If found end of line and ** the position wanted is within the line found. */ if ( lb <= pp && pp < le ) { /* Return beginning of line position. */ if ( line_pos ) *line_pos = readpos + (lb - bb); /* ** Got the line. ** Shrink buffer. */ bufsize = le - lb; memmove(buf, lb, bufsize); buf = realloc(buf, bufsize + 1); buf[bufsize] = '\0'; #if 0 fprintf(stderr, "line = '%s'\n", buf); #endif /* Return buffer and length. */ if ( lenp ) { *lenp = bufsize; } return buf; } /* Try next line. */ lb = le; } while ( lb != be ); } /* Try again with a larger buffer. */ bigger: bufsize *= 2; buf = realloc(buf, bufsize); } while ( 1 ); /* Give up. */ free(buf); return 0; } int FILE_print_line_at_pos(FILE *fp, int linesize, pos_t pos, pos_t *line_pos, FILE *out) { int result = 0; size_t len; pos_t new_line_pos = line_pos ? *line_pos : -1; char *line = FILE_get_line_at_pos(fp, linesize, pos, &len, &new_line_pos); if ( ! line ) { result = -1; } else { /* Do not print any lines that we all ready printed. */ if ( ! (line_pos && *line_pos == new_line_pos) ) { fprintf(out, "%lu\t", (unsigned long) new_line_pos); fwrite(line, 1, len, out); } free(line); } if ( line_pos ) *line_pos = new_line_pos; return result; } int file_print_line_at_pos(const char *file, int linesize, pos_t pos, pos_t *line_pos, FILE *out) { int result = 0; FILE *fp; if ( ! (fp = fopen(file, "r")) ) { result = -1; } else { result = FILE_print_line_at_pos(fp, linesize, pos, line_pos, out); fclose(fp); } return result; } static const char *_file = ""; /* for debugging. */ #if 0 #define PDEBUG(X) fprintf X #else #define PDEBUG(X) #endif char *FILE_read_from_end(FILE *fp, size_t *buflenp, pos_t *posp) { static const char _funcname[] = "FILE_read_from_end"; char *buf; size_t buflen = 1024; /* Arbitrary bufsize. */ long savepos; if ( buflenp && *buflenp ) { buflen = *buflenp; } buf = (char*) xmalloc(sizeof(buf[0]) * (buflen + 1)); memset(buf, 0, sizeof(buf[0]) * (buflen + 1)); /* Save current pos. */ savepos = ftell(fp); /* ** If buflen is bigger than the file's size, ** read from beginning as much as possible. */ if ( fseek(fp, - (long) buflen, SEEK_END) ) { #if 0 fprintf(stderr, "%s('%s'): fseek(%ld, SEEK_END) error.\n", _funcname, _file, - (long) buflen); #endif clearerr(fp); fseek(fp, 0, SEEK_SET); } /* Remember where read started from. */ if ( posp ) { *posp = (pos_t) ftell(fp); } /* Read any remember the actual size read. */ buflen = fread(buf, sizeof(buf[0]), buflen, fp); /* Check for read error. */ if ( buflen == 0 && ferror(fp) ) { fprintf(stderr, "%s('%s'): read error.\n", _funcname, _file); clearerr(fp); free(buf); buf = 0; } /* Restore fp pos. */ fseek(fp, savepos, SEEK_SET); if ( buf ) { /* Realloc buf. */ buf = realloc(buf, sizeof(buf[0]) * (buflen + 1)); /* Null terminate. */ buf[buflen] = '\0'; } #if 0 fprintf(stderr, "%s('%s'): return '%s', buflen %ld.\n", _funcname, _file, buf, (long) buflen ); #endif if ( buflenp ) *buflenp = buflen; return buf; } char *file_read_from_end(const char *file, size_t *buflenp, pos_t *posp) { FILE *fp; char *buf; _file = file; if ( ! (fp = fopen(file, "r")) ) return 0; buf = FILE_read_from_end(fp, buflenp, posp); fclose(fp); return buf; } char *FILE_get_line_at_end(FILE *fp, size_t *buflenp, pos_t *posp) { char *buf = 0; size_t buflen = 1024; char *line = 0; /* The line found. */ pos_t pos = 0; /* The position in the file the line was found. */ char *b, *e; /* Search range in buffer. */ static const char _funcname[] = "FILE_get_line_at_end"; if ( buflenp && *buflenp ) { buflen = *buflenp; } do { if ( buf ) free(buf); buf = FILE_read_from_end(fp, &buflen, &pos); if ( ! buf ) break; /* ** If buflen is 0, ** the file is empty. */ if ( buflen == 0 ) { PDEBUG((stderr, "%s('%s'): file is empty\n", _funcname, _file)); line = 0; break; } /* Begin scanning backwards for a newline before last line. */ e = buf + buflen; /* end of buffer (hence, end of possible line). */ b = e - 1; /* beginning of possible line. */ /* Skip trailing newline only if it exists. */ if ( *b == '\n' ) { b --; } else { PDEBUG((stderr, "%s('%s'): no trailing newline found.\n", _funcname, _file)); } /* Find newline before trailing newline. */ while ( b >= buf ) { if ( *b == '\n' ) { line = b + 1; PDEBUG((stderr, "%s('%s'): found previous newline.\n", _funcname, _file)); break; } -- b; } /* ** If no newline was found and ** if buf starts at beginning of file, ** the buf is the first line. */ if ( (! line) && pos == 0 ) { PDEBUG((stderr, "%s('%s'): read entire file.\n", _funcname, _file)); line = buf; break; } /* ** Try growing buflen until a complete line is read. */ } while ( (! line) && (buflen *= 2) ); if ( line ) { assert(buf); /* ** The line's start position is offset from ** the buffer's start position by the offset of the line ** in the buffer. Got it? */ pos += (line - buf); /* ** Resize buf to only contain the line. */ buflen = e - line; memmove(buf, line, sizeof(buf[0]) * buflen); buf = realloc(buf, sizeof(buf[0]) * (buflen + 1)); buf[buflen] = '\0'; line = buf; /* ** Pass back bufsize and line pos. */ if ( buflenp ) *buflenp = buflen; if ( posp ) *posp = pos; } else { /* Done with buf. */ if ( buf ) free(buf); } PDEBUG((stderr, "%s('%s'): return '%s': buflen %ld pos %ld\n", _funcname, _file, line ? line : "", (long) buflen, (long) pos)); return line; } char *file_get_line_at_end(const char *file, size_t *buflenp, pos_t *posp) { FILE *fp; char *buf; _file = file; /* for debugging. */ if ( ! (fp = fopen(file, "r")) ) { fprintf(stderr, "file_get_line_at_end('%s'): cannot open: %s\n", file, strerror(errno)); fflush(stderr); return 0; } buf = FILE_get_line_at_end(fp, buflenp, posp); fclose(fp); _file = ""; /* for debugging. */ return buf; } dbmi0.1/src/util/file.h0100644000175200017560000000237407236200232015307 0ustar stephensstepheng#ifndef _util_file_h #define _util_file_h #ifndef __rcs_id__ #ifndef __rcs_id_util_file_h__ #define __rcs_id_util_file_h__ static const char __rcs_id_util_file_h[] = "$Id: file.h,v 1.4 2001/02/01 06:22:18 ion Exp $"; #endif #endif /* __rcs_id__ */ #ifdef __cplusplus extern "C" { #endif #include /* FILE */ #include /* time_t */ time_t file_mtime(const char *fname); size_t file_size(const char *file); typedef long pos_t; int file_touch(const char *file); int file_mode_masked(const char *fname, int euid, int egid); int file_executable(const char *fname); int file_in_path(const char *argv, const char *PATH, char *buf); char *FILE_get_line_at_pos(FILE *fp, int linesize, pos_t pos, size_t *lenp, pos_t *line_pos); int FILE_print_line_at_pos(FILE *fp, int linesize, pos_t pos, pos_t *line_pos, FILE *out); int file_print_line_at_pos(const char *file, int linesize, pos_t pos, pos_t *line_pos, FILE *out); char *FILE_read_from_end(FILE *file, size_t *buflenp, pos_t *posp); char *file_read_from_end(const char *file, size_t *buflenp, pos_t *bufposp); char *FILE_get_line_at_end(FILE *fp, size_t *bufsize, pos_t *lineposp); char *file_get_line_at_end(const char *file, size_t *bufsize, pos_t *lineposp); #ifdef __cplusplus } #endif #endif dbmi0.1/src/util/host.c0100644000175200017560000000213107034310640015330 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_util_host_c__ #define __rcs_id_util_host_c__ static const char __rcs_id_util_host_c[] = "$Id: host.c,v 1.2 2000/01/04 06:22:24 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include "host.h" #include #include /* MAXHOSTNAMELEN */ int hostname_matches_hostent(const char *h, const struct hostent *he) { int i; if ( strcmp(h, he->h_name) == 0 ) return 1; for ( i = 0; he->h_aliases[i]; i ++ ) { if ( strcmp(h, he->h_aliases[i]) == 0 ) return 1; } return 0; } int hostname_matches_hostname(const char *h1, const char *h2) { struct hostent *he1, *he2; char hostname[MAXHOSTNAMELEN + 1]; if ( ! (h1 && *h1) ) { if ( gethostname(hostname, sizeof(hostname)) ) return 0; h1 = hostname; } if ( ! (h2 && *h2) ) { if ( gethostname(hostname, sizeof(hostname)) ) return 0; h2 = hostname; } if ( strcmp(h1, h2) == 0 ) return 1; if ( ! (he1 = gethostbyname(h1)) ) return 0; if ( ! (he2 = gethostbyname(h2)) ) return 0; return strcmp(he1->h_name, he2->h_name) == 0; } dbmi0.1/src/util/host.h0100644000175200017560000000051707034312207015344 0ustar stephensstepheng/* $Id: host.h,v 1.3 2000/01/04 06:34:47 stephensk Exp $ */ #ifndef _util_host_h #define _util_host_h #include #ifdef __cplusplus extern "C" { #endif int hostname_matches_hostent(const char *h, const struct hostent *he); int hostname_matches_hostname(const char *h1, const char *h2); #ifdef __cplusplus } #endif #endif dbmi0.1/src/util/lockfile.c0100644000175200017560000001322607034310640016152 0ustar stephensstepheng/* $Id: lockfile.c,v 1.6 2000/01/04 06:22:24 stephensk Exp $ */ #include "lockfile.h" #include #include #include #include #include #include #include #include #include #include #include #include "errlist.h" #ifdef MEMDEBUG #include "memdebug/memdebug.h" #endif /* NOT THREAD-SAFE */ const char *lockfile_progname = ""; /* The program name for lockfile contents. */ /* A lockfile list entry. */ typedef struct lockfile_stat { struct lockfile_stat *next; char *file; int locks; } lockfile_stat; /* A list of lockfiles aquired by this process. */ static lockfile_stat *lockfile_stats; /* Has lockfile_atexit been installed into atexit? */ static int lockfile_atexit_installed; void lockfile_release_all() { lockfile_stat *l = lockfile_stats; while ( l ) { lockfile_stat *ln = l->next; unlink(l->file); free(l->file); free(l); l = ln; } } int lockfile_unlock_at_exit = 1; void lockfile_atexit() { if ( lockfile_unlock_at_exit ) { lockfile_release_all(); } } static void lockfile_stat_add(const char *file) { lockfile_stat *l; l = malloc(sizeof(*l)); l->file = strcpy(malloc(strlen(file) + 1), file); l->locks = 1; l->next = lockfile_stats; lockfile_stats = l; /* Install an atexit handler to unaquire all lockfiles this process has created. */ if ( ! lockfile_atexit_installed ) { lockfile_atexit_installed ++; atexit(lockfile_atexit); } } static lockfile_stat **lockfile_stat_find(const char *file) { lockfile_stat **l = &lockfile_stats; while ( *l ) { if ( strcmp(file, (*l)->file) == 0 ) { return l; } l = &((*l)->next); } return 0; } int lockfile_mode = 0666; /* The error handler. */ int lockfile_error_default(const char *file, const char *msg) { fprintf(stderr, "lockfile '%s': %s\n", file, msg); return 0; } int (*lockfile_error)(const char *file, const char *msg) = lockfile_error_default; int lockfile_acquire(const char *file, int retries, int wait) { lockfile_stat **l; int rtnval = 0; int nretries = 0; if ( retries < 0 ) { retries = 10; } if ( wait < 0 ) { wait = 60; } /* Has this process already acquired the lockfile? */ if ( (l = lockfile_stat_find(file)) ) { /* Increment lock count. */ (*l)->locks ++; /* Success. */ return 0; } else { int fd; char buf[1024]; int lockfile_read = 0; char msg[1024]; int broke_lock = 0; buf[0] = '\0'; while ( 1 ) { /* Attempt to create the file atomically. */ fd = open(file, O_RDWR|O_CREAT|O_EXCL, 0666); if ( fd < 0 ) { /* Couldn't create the file atomically. */ /* It already existed and was not created by our process id. */ if ( errno == EEXIST ) { /* Read the contents of the lockfile for the error msg. */ if ( ! lockfile_read ) { size_t rlen; fd = open(file, O_RDONLY); rlen = read(fd, buf, sizeof(buf) - 1); /* Remove newline. */ if ( rlen > 0 && rlen != (size_t) -1 ) buf[rlen - 1] = '\0'; close(fd); lockfile_read = 1; sprintf(msg, "acquired by '%s'", buf); if ( (rtnval = lockfile_error(file, msg)) ) return rtnval; } /* Sleep if retries are left. */ if ( -- retries > 0 ) { nretries ++; if ( nretries == 1 ) { sprintf(msg, "sleeping for %d secs for %d times", wait, retries + 1); if ( (rtnval = lockfile_error(file, msg)) ) return rtnval; } /* Sleep for a while then retry */ sleep(wait); } /* If out of retries, attempt to break the lock. */ if ( retries <= 0 ) { if ( ! broke_lock ) { if ( (rtnval = lockfile_error(file, "attempting to break lock")) ) return rtnval; /* Attempt one retry after breaking the lock. */ broke_lock ++; retries = 1; unlink(file); } else { /* Out of retries. */ if ( (rtnval = lockfile_error(file, "giving up")) ) return rtnval; /* Failure! */ return -1; } } } else { /* Failed to create the lockfile for some other reason. */ sprintf(msg, "cannot create: %s", sys_errlist[errno]); if ( (rtnval = lockfile_error(file, msg)) ) return rtnval; /* Failure! */ return -1; } } else { /* Fill the lockfile with hostname, username, programname, and process id */ char hostname[64]; char username[64]; struct passwd *pw; strcpy(hostname, "localhost"); gethostname(hostname, sizeof(hostname) - 1); strcpy(username, ""); if ( (pw = getpwuid(geteuid())) ) { memset(username, 0, sizeof(username)); strncpy(username, pw->pw_name, sizeof(username) - 1); } sprintf(buf, "%s %s %s %d\n", hostname, username, lockfile_progname, getpid()); write(fd, buf, strlen(buf)); /* Add it to our process's list of lockfiles */ lockfile_stat_add(file); close(fd); /* Chmod to default mode */ chmod(file, lockfile_mode); /* Success! */ return 0; } } } } int lockfile_release(const char *file) { lockfile_stat **lp; /* Has this process acquired the lockfile? */ if ( (lp = lockfile_stat_find(file)) ) { lockfile_stat *l = *lp; /* Decrement lock count. */ if ( -- l->locks == 0 ) { lockfile_stat *ln = l->next; /* Delete the lockfile. */ unlink(l->file); /* Free and remove the lockfile list entry. */ free(l->file); free(l); *lp = ln; } } else { int rtnval; /* This process has not acquired the lockfile, so it cannot release it. */ if ( (rtnval = lockfile_error(file, "not acquired")) ) return rtnval; return -1; } return 0; } dbmi0.1/src/util/lockfile.h0100644000175200017560000000141506727377373016204 0ustar stephensstepheng#ifndef _util_lockfile_h #define _util_lockfile_h /* $Id: lockfile.h,v 1.3 1999/06/09 05:43:23 stephensk Exp $ */ /* Options */ extern const char *lockfile_progname; extern int lockfile_mode; /* Lockfile creation perms */ extern int lockfile_unlock_at_exit; /* Release lockfiles at exit? */ /* Error handling. */ extern int (*lockfile_error)(const char *file, const char *msg); int lockfile_error_default(const char *file, const char *msg); /* Prints "lockfile '': " to stderr; returns 0. */ /* Acquire/Release. */ int lockfile_acquire(const char *file, int retries, int wait); int lockfile_release(const char *file); /* Release all lockfiles. */ void lockfile_release_all(); void lockfile_atexit(); /* lockfile_release_all() if lockfile_unlock_at_exit. */ #endif dbmi0.1/src/util/lockfile_main.c0100644000175200017560000000166506727377403017204 0ustar stephensstepheng/* $Id: lockfile_main.c,v 1.1 1999/06/09 05:43:31 stephensk Exp $ */ #include "lockfile.h" #include #include #include #include int main(int argc, char **argv) { int errors = 0; int i; lockfile_progname = argv[0]; lockfile_unlock_at_exit = 0; switch ( argv[1] && argv[1][0] == '-' ? argv[1][1] : 0 ) { case 'l': case 'a': for ( i = 2; i < argc; i ++ ) { if ( lockfile_acquire(argv[i], 60, 10) ) { errors ++; } } break; case 'u': case 'r': for ( i = 2; i < argc; i ++ ) { if ( unlink(argv[i]) ) { fprintf(stderr, "%s: cannot unlink: '%s'\n", argv[0], argv[i]); errors ++; } } break; default: fprintf(stderr, "%s: bad option: '%s'\n", argv[0], argv[1]); errors ++; /* FALL THROUGH */ case 'h': case '?': fprintf(stderr, "%s: USAGE: %s [-lock|-unlock] files...\n", argv[0], argv[0]); break; } return errors; } dbmi0.1/src/util/mem.c0100644000175200017560000000611206663227127015152 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_util_mem_c__ #define __rcs_id_util_mem_c__ static const char __rcs_id_util_mem_c[] = "$Id: mem.c,v 1.2 1999/02/19 09:26:47 stephensk Exp $"; #endif #endif /* __rcs_id__ */ /* ** Unrolled memcpy */ void memcpy_fast(char *_dst, const char *_src, unsigned int _len) { if ( _len == 0 ) return; #define MEMSET_4() *(long*)_dst = *(long*)_src; _dst += sizeof(long); _src += sizeof(long) #define MEMSET_1() *(_dst ++) = *(_src ++) /* Align to 4 dword */ switch ( ((unsigned int) _dst) & 3 ) { case 1: if ( _len -- <= 0 ) return; MEMSET_1(); case 2: if ( _len -- <= 0 ) return; MEMSET_1(); case 3: if ( _len -- <= 0 ) return; MEMSET_1(); } /* Do blocks of 64 bytes */ while ( _len >= 64 ) { MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); _len -= 64; } /* Do remaining dwords */ switch ( _len / 4 ) { case 16: MEMSET_4(); case 15: MEMSET_4(); case 14: MEMSET_4(); case 13: MEMSET_4(); case 12: MEMSET_4(); case 11: MEMSET_4(); case 10: MEMSET_4(); case 9: MEMSET_4(); case 8: MEMSET_4(); case 7: MEMSET_4(); case 6: MEMSET_4(); case 5: MEMSET_4(); case 4: MEMSET_4(); case 3: MEMSET_4(); case 2: MEMSET_4(); case 1: MEMSET_4(); case 0: break; } /* Do remaining bytes */ switch ( _len & 3 ) { case 3: MEMSET_1(); case 2: MEMSET_1(); case 1: MEMSET_1(); case 0: break; } #undef MEMSET_4 #undef MEMSET_1 } /* ** Unrolled memset */ void memset_fast(unsigned char *_dst, int val, unsigned int _len) { unsigned long _val; if ( _len == 0 ) return; _val = val; _val |= _val << 8 | _val << 16 | _val << 24; #define MEMSET_4() (* ((unsigned long*) _dst)) = _val; _dst += sizeof(unsigned long) #define MEMSET_1() *(_dst ++) = _val; /* Align to 4 dword */ switch ( ((unsigned int) _dst) & 3 ) { case 1: if ( _len -- <= 0 ) return; MEMSET_1(); case 2: if ( _len -- <= 0 ) return; MEMSET_1(); case 3: if ( _len -- <= 0 ) return; MEMSET_1(); } /* Do blocks of 64 bytes */ while ( _len >= 64 ) { MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); MEMSET_4(); _len -= 64; } /* Do remaining dwords */ switch ( _len / 4 ) { case 16: MEMSET_4(); case 15: MEMSET_4(); case 14: MEMSET_4(); case 13: MEMSET_4(); case 12: MEMSET_4(); case 11: MEMSET_4(); case 10: MEMSET_4(); case 9: MEMSET_4(); case 8: MEMSET_4(); case 7: MEMSET_4(); case 6: MEMSET_4(); case 5: MEMSET_4(); case 4: MEMSET_4(); case 3: MEMSET_4(); case 2: MEMSET_4(); case 1: MEMSET_4(); case 0: break; } /* Do remaining bytes */ switch ( _len & 3 ) { case 3: MEMSET_1(); case 2: MEMSET_1(); case 1: MEMSET_1(); case 0: break; } #undef MEMSET_4 #undef MEMSET_1 } dbmi0.1/src/util/mem.h0100644000175200017560000000107706735700336015162 0ustar stephensstepheng/* Copyright (c) 1998, 1999 Kurt A. Stephens and Ion, Inc. */ #ifndef _util_mem_h #define _util_mem_h #ifndef __rcs_id__ #ifndef __rcs_id_util_mem_h__ #define __rcs_id_util_mem_h__ static const char __rcs_id_util_mem_h[] = "$Id: mem.h,v 1.5 1999/06/28 14:04:14 stephensk Exp $"; #endif #endif /* __rcs_id__ */ void memcpy_fast(void *, const void *, unsigned int); void memset_fast(void *, int, unsigned int); #ifdef memcpy #undef memcpy #endif #define memcpy(x,y,z) memcpy_fast(x,y,z) #ifdef memset #undef memset #endif #define memset(x,y,z) memset_fast(x,y,z) #endif dbmi0.1/src/util/midi.h0100644000175200017560000000352307001140704015304 0ustar stephensstepheng /* NAME, CODE, BYTES, PATTERN, COMMENT */ MIDI(NOTE_OFF, "\x80\x00\x00", 3, "1000cccc 0nnnnnnn 0vvvvvvv", "") MIDI(NOTE_ON, "\x90\x00\x00", 3, "1001cccc 0nnnnnnn 0vvvvvvv", "") MIDI(KEY_PRESSURE, "\xA0\x00\x00", 3, "1010cccc 0nnnnnnn 0aaaaaaa", "") MIDI(CONTROL_CNG, "\xB0\x00\x00", 3, "1011cccc 0xxxxxxx 0yyyyyyy", "") MIDI(CC_RESET, "\xB0\x79\x00", 3, "1011cccc", "") MIDI(LOCAL_CNTRL, "\xB0\x7A\x00", 3, "1011cccc @@@@@@@@ 0xxxxxxx", "") MIDI(ALL_NOTES_OFF, "\xB0\x7B\x00", 3, "1011cccc", "") MIDI(OMNI_MODE_OFF, "\xB0\x7C\x00", 3, "1011cccc", "") MIDI(OMNI_MODE_ON, "\xB0\x7D\x00", 3, "1011cccc", "") MIDI(MONO_MODE_ON, "\xB0\x7E\x00", 3, "1011cccc @@@@@@@@ 0vvvvvvv", "") MIDI(POLY_MODE_ON, "\xB0\x7F\x00", 3, "1011cccc", "") MIDI(PROGRAM_CNG, "\xC0", 2, "1100cccc 0ppppppp", "") MIDI(CH_PRESSURE, "\xD0", 2, "1101cccc 0aaaaaaa", "") MIDI(PITCHBEND, "\xE0", 3, "1110cccc 0xxxxxxx 0XXXXXXX", "") MIDI(SYSEX, "\xF0", MIDI_EOX(), "11110000 ...", "") MIDI(MTC_1_4th, "\xF1", "") MIDI(SONG_PTR, "\xF2\x00\x00", 3, "11110010 0xxxxxxx 0XXXXXXX", "") MIDI(SONG_SEL, "\xF3\x00", 2, "11110011 0xxxxxxx", "") MIDI(UNDEF1, "\xF4", "") MIDI(UNDEF2, "\xF5", "") MIDI(TUNE_REQ, "\xF6", "") MIDI(EOX, "\xF7", "") MIDI(TIMING_CLK, "\xF8", 1, "") MIDI(UNDEF3, "\xF9", "") MIDI(START, "\xFA", 1, "") MIDI(CONTINUE, "\xFB", 1, "") MIDI(STOP, "\xFC", 1, "") MIDI(UNDEF4, "\xFD", "") MIDI(ACTIVE_SENSING, "\xFE", 1, "") MIDI(SYS_RESET, "\xFF", 1, "") dbmi0.1/src/util/outbuf.c0100644000175200017560000000345507034310640015671 0ustar stephensstepheng/* $Id: outbuf.c,v 1.3 2000/01/04 06:22:24 stephensk Exp $ */ #include "outbuf.h" #include #ifdef MEMDEBUG #include "memdebug/memdebug.h" #endif #include /* memmove */ int outbuf_write(outbuf *ob, const void *buf, size_t size) { int rtn = 0; if ( ! ob ) return -1; if ( ! size ) return 0; if ( ! buf ) return -1; /* allocate buffer */ if ( ! ob->buf ) { if ( ob->size < size ) ob->size = size; ob->buf = malloc(ob->size + 1); /* resize buffer? */ } else if ( ob->size < ob->len + size ) { ob->size = ob->len + size; ob->buf = realloc(ob->buf, ob->size + 1); } /* Append to buffer */ memcpy(ob->buf + ob->len, buf, size); ob->len += size; ob->buf[ob->len] = '\0'; return rtn; } int outbuf_flush(outbuf *ob) { int rtn = 0; if ( ! ob ) return 0; /* nothing to flush */ if ( ! ob->len ) return 0; /* nothing to flush */ /* Don't call flush recursively */ if ( ! ob->flushing ) { ob->flushing ++; if ( ob->flush ) { /* Make a copy of the buffer to allow re-entry into ob_write(), during ob->flush() */ size_t oblen = ob->len; char *buf_copy = malloc(ob->len + 1); memcpy(buf_copy, ob->buf, ob->len + 1); if ( ! (rtn = (ob->flush)(ob, buf_copy, ob->len)) ) { /* Remove flushed portion from front */ size_t l = ob->len - oblen; memmove(ob->buf, ob->buf + oblen, l); ob->len = l; ob->buf[ob->len] = '\0'; ob->failed_flush = 0; } else { ob->failed_flush ++; } free(buf_copy); } ob->flushing --; } return rtn; } int outbuf_destroy(outbuf *ob) { int rtn = 0; if ( ! ob ) return 0; if ( ob->destroy ) { if ( ! (rtn = ob->destroy(ob)) ) return rtn; } if ( ob->buf ) { free(ob->buf); ob->buf = 0; } return rtn; } dbmi0.1/src/util/outbuf.h0100644000175200017560000000132606774730270015710 0ustar stephensstepheng/* $Id: outbuf.h,v 1.2 1999/09/30 18:49:28 stephensk Exp $ */ #ifndef _util_outbuf_h #define _util_outbuf_h #include /* size_t */ typedef struct outbuf { int (*flush)(struct outbuf *ob, void *buf, size_t size); /* flush method. Can modify buf. */ int (*destroy)(struct outbuf *ob); /* destroy method. */ void *data[4]; /* user data. */ char *buf; /* the buffered data. */ size_t len; /* length of current buf contents. */ size_t size; /* size of buf. */ int failed_flush; /* no. of failed flush ops. */ int flushing; /* currently flushing? */ } outbuf; int outbuf_write(outbuf *ob, const void *buf, size_t size); int outbuf_flush(outbuf *ob); int outbuf_destroy(outbuf *ob); #endif dbmi0.1/src/util/path.c0100644000175200017560000000506106735700336015330 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_util_path_c__ #define __rcs_id_util_path_c__ static const char __rcs_id_util_path_c[] = "$Id: path.c,v 1.5 1999/06/28 14:04:14 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include "util/path.h" #include #include const char *path_sep = "/"; const char *path_cwd = "."; const char *path_file(const char *p) { const char *s; s = strrchr(p, path_sep[0]); if ( s ) { s ++; } else { s = p; } return s; } const char *path_dir(const char *p, char *buf) { const char *s; s = strrchr(p, path_sep[0]); if ( s ) { const char *r = p; char *t = buf; while ( r < s ) { *(t ++) = *(r ++); } *t = '\0'; } else { strcpy(buf, path_cwd); } return buf; } const char *path_absolute(const char *p, char *buf) { if ( p[0] == path_sep[0] ) { return p; } else { strcpy(buf, path_cwd); if ( ! strrchr(buf, path_sep[0]) ) { strcat(buf, path_sep); } strcat(buf, p); return buf; } } const char *path_suffix(const char *p) { const char *s; s = strrchr(path_file(p), '.'); return s; } const char *path_no_suffix(const char *p, char *buf) { const char *s; s = path_suffix(p); if ( s ) { strncpy(buf, p, s - p); buf[s - p] = '\0'; return buf; } else { return p; } } char *path_simplify(const char *p, char *buf) { const char *s; char *t; t = buf; s = p; while ( *s ) { /* replace "//" with "/" */ if ( s[0] == path_sep[0] && s[1] == path_sep[0] ) { s ++; } else /* replace "./" with "" */ if ( (s == p || s[-1] == path_sep[0]) && s[0] == '.' && s[1] == path_sep[0] ) { s += 2; } else { *(t ++) = *(s ++); } } *t = '\0'; /* replace "//../" where != ".." with "" */ t = buf; s = buf; while ( *s ) { if ( s[0] == path_sep[0] && s[1] == '.' && s[2] == '.' && s[3] == path_sep[0] ) { if ( s - buf >= 3 && ! ( s[-3] == path_sep[0] && s[-2] == '.' && s[-1] == '.' ) ) { t = (char*) s - 1; s += 3; while ( t > buf && *t != path_sep[0] ) { t --; } } else { *(t ++) = *(s ++); *(t ++) = *(s ++); } } *(t ++) = *(s ++); } *t = '\0'; return buf; } const char *path_2_dos(const char *s, char *buf) { char *p = buf; if ( s[0] == path_sep[0] && s[1] == path_sep[0] && isalpha(s[2]) && s[3] == path_sep[0] ) { *(p ++) = toupper(s[2]); *(p ++) = ':'; *(p ++) = '\\'; s += 4; } while ( *s ) { *(p ++) = *s == path_sep[0] ? '\\' : toupper(*s); s ++; } *p = '\0'; return buf; } dbmi0.1/src/util/path.h0100644000175200017560000000121306663227127015332 0ustar stephensstepheng#ifndef _util_path_h #ifndef __rcs_id__ #ifndef __rcs_id_util_path_h__ #define __rcs_id_util_path_h__ static const char __rcs_id_util_path_h[] = "$Id: path.h,v 1.2 1999/02/19 09:26:47 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define _util_path_h extern const char *path_sep; /* defaults to "/" */ extern const char *path_cwd; /* defaults to "." */ const char *path_file(const char *s); const char *path_dir(const char *s, char *buf); const char *path_absolute(const char *s, char *buf); const char *path_suffix(const char *s); const char *path_no_suffix(const char *s, char *buf); const char *path_2_dos(const char *s, char *buf); #endif dbmi0.1/src/util/port.c0100644000175200017560000000161007034310640015340 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_util_port_c__ #define __rcs_id_util_port_c__ static const char __rcs_id_util_port_c[] = "$Id: port.c,v 1.2 2000/01/04 06:22:24 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include "port.h" #include #include #include #include int port_by_name(const char *port, const char *proto) { if ( isdigit(*port) ) { return atoi(port); } else { struct servent *se; char service[64]; if ( ! (proto && *proto) ) { const char *r; /* parse "service/protocol"? */ if ( (r = strchr(port, '/')) ) { strncpy(service, port, r - port); service[r - port] = 0; port = service; proto = r + 1; /* Default to "tcp" */ if ( ! *proto ) { proto = "tcp"; } } else { proto = "tcp"; } } if ( ! (se = getservbyname(port, proto)) ) return 0; return se->s_port; } } dbmi0.1/src/util/port.h0100644000175200017560000000035407034312207015352 0ustar stephensstepheng/* $Id: port.h,v 1.3 2000/01/04 06:34:47 stephensk Exp $ */ #ifndef _util_port_h #define _util_port_h #ifdef __cplusplus extern "C" { #endif int port_by_name(const char *port, const char *proto); #ifdef __cplusplus } #endif #endif dbmi0.1/src/util/prime.c0100644000175200017560000001041607037351516015506 0ustar stephensstepheng/* $Id: prime.c,v 1.6 2000/01/13 13:29:50 stephensk Exp $ */ #include "prime.h" #ifdef UNIT_TEST #include #endif #include #include #ifdef MEMDEBUG #include "memdebug/memdebug.h" #endif #ifndef EXTERN #define EXTERN #endif struct prime_list { prime_t x; struct prime_list *next; }; static struct prime_list pl_3 = { 3 }, pl_2 = { 2, &pl_3 }, *pl = &pl_2, *pl_last = &pl_3; static const prime_t *prime_new(prime_t x) { struct prime_list *p; #ifdef UNIT_TEST assert(pl_last->x != x); /* Do a simple verification of the primality of x. */ { prime_t y = x / 2; while ( y >= 2 ) { assert( x % y ); y --; } } fprintf(stderr, "%lu is prime\n", (unsigned long) x); #endif p = malloc(sizeof(*p)); p->x = x; p->next = 0; pl_last->next = p; pl_last = p; return &(p->x); } EXTERN const prime_t *prime_next(const prime_t *x) /* Returns the next prime > ^x^. ^x^ must be a result returned from prime_*(). */ { struct prime_list *p = (struct prime_list *) x; if ( ! p ) return 0; if ( p->next ) { return &(p->next->x); } else { prime_t y; assert(p == pl_last); #ifdef UNIT_TEST fprintf(stderr, "prime_next(%lu)\n", (unsigned long) *x); #endif y = p->x + 2; #ifdef UNIT_TEST /* Make sure y is not even. */ assert(y % 2 != 0); #endif for ( p = &pl_3; p; ) { if ( y % p->x == 0 ) { /* y is not prime, try y + 2. */ y += 2; p = &pl_3; continue; } else { /* y might be prime, see if y is multiple of next prime. */ p = p->next; } } /* y must be prime */ return prime_new(y); } } EXTERN const prime_t *prime_le(prime_t x) /* Returns a prime <= ^x^. */ { #ifdef UNIT_TEST fprintf(stderr, "prime_le(%lu)\n", (unsigned long) x); #endif if ( x < 2 ) return 0; while ( pl_last->x < x ) { prime_next(&(pl_last->x)); } { struct prime_list *p, *pp = pl; for ( p = pp->next; p; pp = p, p = p->next ) { if ( p->x > x ) { return &pp->x; } } abort(); } } EXTERN const prime_t *prime_q(prime_t x) /* Returns a prime if ^x^ is prime, 0 if ^x^ is not prime. */ { if ( x == pl_last->x ) { return &(pl_last->x); } else if ( x > pl_last->x ) { prime_le(x); } { struct prime_list *p; for ( p = pl; p; p = p->next ) { if ( p->x == x ) { /* x is prime. */ return &p->x; } } return 0; } } EXTERN const prime_t *prime_ge(prime_t x) /* Returns a prime number greater than or equal to ^x^. */ { #ifdef UNIT_TEST fprintf(stderr, "prime_ge(%lu)\n", (unsigned long) x); #endif while ( pl_last->x < x ) { prime_next(&(pl_last->x)); } { struct prime_list *p; for ( p = pl; p; p = p->next ) { if ( p->x >= x ) { return &(p->x); } } abort(); } } EXTERN prime_t *prime_factors(prime_t x) { int nfactors = 0; prime_t *factors = malloc(sizeof(factors[0]) * (nfactors + 1)); prime_t *f = pl; #ifdef UNIT_TEST prime_t x_save = x; #endif /* ** For each prime f < x: */ for ( f = pl; *f <= x; f = prime_next(f) ) { /* ** If x is divisible by f, ** append f to factors list. */ while ( x % *f == 0 ) { factors = realloc(factors, sizeof(factors[0]) * (nfactors + 2)); factors[nfactors ++] = *f; x /= *f; } } factors[nfactors] = 0; #ifdef UNIT_TEST { int i; prime_t product = 1; x = x_save; for ( i = 0; factors[i]; ++ i ) { product *= factors[i]; } assert(product == x); } #endif return factors; } #undef EXTERN #ifdef UNIT_TEST int main(int argc, char **argv) { #define Pi(X) {prime_t _X = (X); printf("%s = %lu\n", #X, (unsigned long) _X);} Pi(*prime_le(1024)); Pi(*prime_ge(1024)); Pi(*prime_le(512)); Pi(*prime_ge(512)); { int i, j; prime_t xs[] = { 678, 231, 148, 829, 818, 131, 512, 569, 126, 1025 }; for ( i = 1; i < sizeof(xs)/sizeof(xs[0]); ++ i ) { prime_t x = xs[i]; prime_t *factors = prime_factors(x); printf("factors(%lu) = { ", (unsigned long) x); for ( j = 0; factors[j]; ++ j ) { printf("%lu%s ", (unsigned long) factors[j], factors[j + 1] ? "," : ""); } printf("}\n"); free(factors); } } return 0; } #endif dbmi0.1/src/util/prime.h0100644000175200017560000000060407037351060015503 0ustar stephensstepheng#ifndef _util_prime_h #define _util_prime_h /* $Id: prime.h,v 1.3 2000/01/13 13:25:04 stephensk Exp $ */ #ifndef prime_t typedef unsigned long prime_t; #endif const prime_t * prime_le(prime_t x); const prime_t * prime_ge(prime_t x); const prime_t * prime_q(prime_t x); const prime_t * prime_next(const prime_t *p); prime_t * prime_factors(prime_t x); /* must free() result. */ #endif dbmi0.1/src/util/rc4.c0100644000175200017560000000225007106156652015060 0ustar stephensstepheng#include "rc4.h" /* $Id: rc4.c,v 1.4 2000/05/10 03:55:22 stephensk Exp $ */ RC4_EXPORT int rc4_init(rc4_state *s, const char *_key, size_t keylen) { int i; int temp1, temp2, temp3, temp4; int i1, i2; const unsigned char *key = (const unsigned char *) _key; for ( i = 0; i < 256; i ++ ) s->_state[i] = i; s->_x = s->_y = 0; i1 = i2 = 0; for ( i = 0; i < 256; i ++ ) { int ch = key[i1]; temp4 = (ch + s->_state[i] + i2) & 255; temp1 = s->_state[temp4]; temp2 = s->_state[i]; temp3 = (i1 + 1) % keylen; s->_state[i] = temp1; s->_state[i2] = temp2; i1 = temp3; i2 = temp4; } return 0; } RC4_EXPORT int rc4_crypt(rc4_state *s, char *_data, size_t datalen) { int i; unsigned char *data = (unsigned char *) _data; for ( i = 0; i < datalen; i ++ ) { int temp1, temp2; s->_x ++; /* SAME AS: s->_x = (s->_x + 1) & 255; */ s->_y += s->_state[s->_x]; /* SAME AS: s->_y = (s->_y + s->_state[s->_x]) & 255; */ temp1 = s->_state[s->_x]; s->_state[s->_x] = temp2 = s->_state[s->_y]; s->_state[s->_y] = temp1; data[i] ^= s->_state[(temp1 + temp2) & 255]; } return 0; } dbmi0.1/src/util/rc4.h0100644000175200017560000000061707106156652015072 0ustar stephensstepheng#ifndef _rc4_h #define _rc4_h /* $Id: rc4.h,v 1.4 2000/05/10 03:55:22 stephensk Exp $ */ #include typedef struct rc4_state { unsigned char _state[256]; unsigned char _x, _y; } rc4_state; #ifndef RC4_EXPORT #define RC4_EXPORT #endif RC4_EXPORT int rc4_init(rc4_state *s, const char *key, size_t keylen); RC4_EXPORT int rc4_crypt(rc4_state *s, char *data, size_t datalen); #endif dbmi0.1/src/util/setenv.c0100644000175200017560000000244506702204466015700 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_util_setenv_c__ #define __rcs_id_util_setenv_c__ static const char __rcs_id_util_setenv_c[] = "$Id: setenv.c,v 1.3 1999/04/05 19:04:22 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include #include "setenv.h" extern char **environ; void setenv(const char *name, const char *value) { size_t name_len, value_len; int i; char *e, *v; static int realloc_environ = 0; if ( ! (name && *name && value && *value) ) return; name_len = strlen(name); value_len = strlen(value); for ( i = 0; (e = environ[i]); i ++ ) { if ( strncmp(e, name, name_len) == 0 && e[name_len] == '=' ) { v = e + name_len + 1; if ( strlen(v) <= value_len ) { strcpy(v, value); return; } else { break; } } } if ( ! e ) { if ( realloc_environ ) { environ = realloc(environ, sizeof(environ[0]) * (i + 2)); } else { char **new_environ = malloc(sizeof(environ[0]) * (i + 2)); memcpy(new_environ, environ, sizeof(environ[0]) * i); environ = new_environ; realloc_environ ++; } environ[i + 1] = 0; } /* This might leak mem */ e = malloc(name_len + value_len + 2); strcpy(e, name); strcpy(e + name_len, "="); strcpy(e + name_len + 1, value); environ[i] = e; } dbmi0.1/src/util/setenv.h0100644000175200017560000000057106702204466015703 0ustar stephensstepheng#ifndef _util_setenv_h #define _util_setenv_h #ifndef __rcs_id__ #ifndef __rcs_id_util_setenv_h__ #define __rcs_id_util_setenv_h__ static const char __rcs_id_util_setenv_h[] = "$Id: setenv.h,v 1.3 1999/04/05 19:04:22 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #ifndef setenv #define setenv ion_setenv #endif void setenv (const char *name, const char *value); #endif dbmi0.1/src/util/sig.c0100644000175200017560000000250107034305357015147 0ustar stephensstepheng#include "sig.h" #include #include /* isdigit() */ #include /* atoi */ static sigdef sigdefs[] = { #define signal_def(N,S,D) { #N, S, D }, #include "signals.h" { 0, -1, 0 } }; sigdef *sigdef_begin() { return sigdefs; } sigdef *sigdef_end() { return sigdefs + sizeof(sigdefs)/sizeof(sigdefs[0]) - 1; } sigdef *sigdef_by_name(const char *name) { int i; if ( ! name ) return 0; if ( strncasecmp(name, "SIG", 3) == 0 ) { name += 3; } if ( isdigit(*name) ) { int sig = atoi(name); for ( i = 0; sigdefs[i].name; i ++ ) { if ( sigdefs[i].sig == sig ) return &sigdefs[i]; } } else { for ( i = 0; sigdefs[i].name; i ++ ) { if ( strcasecmp(sigdefs[i].name, name) == 0 ) return &sigdefs[i]; } } return 0; } sigdef *sigdef_by_sig(int sig) { int i; for ( i = 0; sigdefs[i].name; i ++ ) { if ( sigdefs[i].sig == sig ) return &sigdefs[i]; } return 0; } sigdef *sigdef_max_sig(void) { int i; sigdef *m = &sigdefs[0]; for ( i = 1; sigdefs[i].name; i ++ ) { if ( sigdefs[i].sig > m->sig ) m = &sigdefs[i]; } return m; } sigdef *sigdef_min_sig(void) { int i; sigdef *m = &sigdefs[0]; for ( i = 1; sigdefs[i].name; i ++ ) { if ( sigdefs[i].sig < m->sig ) m = &sigdefs[i]; } return m; } dbmi0.1/src/util/sig.h0100644000175200017560000000053407034305357015160 0ustar stephensstepheng#ifndef _util_sig_h #define _util_sig_h #include typedef struct sigdef { const char *name; int sig; const char *desc; void *user[4]; } sigdef; sigdef *sigdef_by_name(const char *signame); sigdef *sigdef_by_sig(int sig); sigdef *sigdef_begin(); sigdef *sigdef_end(); sigdef *sigdef_min_sig(); sigdef *sigdef_max_sig(); #endif dbmi0.1/src/util/sigs.pl0100644000175200017560000000102507034305357015523 0ustar stephensstepheng#!/bin/perl # $Id: sigs.pl,v 1.4 2000/01/04 05:53:51 stephensk Exp $ print "/* DO NOT MODIFY: Created by perl $0 @ARGV */\n"; while ( <> ) { #print; if ( m@^\s*#define\s+SIG([A-Z0-9]+)\s+(\S+)(\s+/\*\s*(.*)\s*(\*/))?@ ) { $name = $1; $sig = $2; $comment = $4; $comment =~ s/^\s+//; $comment =~ s/\s+$//; if ( $sig !~ /[()]/ && $comment ne '' ) { print "#ifdef SIG$name\n"; print "signal_def($name,SIG$name,\"$comment\") /* $sig */\n"; print "#endif\n"; } } } print "#undef signal_def\n"; 1; dbmi0.1/src/util/ssprintf.c0100644000175200017560000000373707034310640016240 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_util_ssprintf_c__ #define __rcs_id_util_ssprintf_c__ static const char __rcs_id_util_path_c[] = "$Id: ssprintf.c,v 1.2 2000/01/04 06:22:24 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include #include #include #include "ssprintf.h" char *ssprintf(char *str, const char *format, ...) { size_t len; size_t flen; len = str ? strlen(str) : 0; /* Calc append length */ flen = strlen(format); { const char *f; va_list vap; va_start(vap, format); f = format; while ( *f ) { if ( *f == '%' ) { int l = 0; int w = 0; int more = 0; f ++; do { int fw = 0; more = 0; switch ( *(f ++) ) { case 's': fw = strlen(va_arg(vap, char*)); break; case '*': fw = va_arg(vap, int); break; case 'l': l ++; more = 1; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': w *= 10; w += f[-1] - '0'; more = 1; break; case '-': case '+': case '.': more = 1; break; case 'f': case 'g': case 'e': (void) va_arg(vap, double); fw = 32; break; case 'd': case 'u': case 'o': case 'x': case 'c': if ( l ) { (void) va_arg(vap, int); } else { (void) va_arg(vap, long); } flen += 32; break; case 'p': (void) va_arg(vap, void*); fw = 32; break; case '\0': break; case '%': break; default: abort(); break; } if ( fw < w ) { fw = w; } flen += fw; } while ( more && *f ); } else { f ++; } } va_end(vap); } /* re/alloc buffer */ if ( str ) { str = realloc(str, len + flen + 1); } else { str = malloc(flen + 1); } /* append to buffer */ { va_list vap; va_start(vap, format); vsprintf(str + len, format, vap); va_end(vap); } return str; } dbmi0.1/src/util/ssprintf.h0100644000175200017560000000052106707527215016247 0ustar stephensstepheng#ifndef _util_ssprintf_h #define _util_ssprintf_h #ifndef __rcs_id__ #ifndef __rcs_id_util_ssprintf_h__ #define __rcs_id_util_ssprintf_h__ static const char __rcs_id_util_ssprintf_h[] = "$Id: ssprintf.h,v 1.1 1999/04/22 05:07:25 stephensk Exp $"; #endif #endif /* __rcs_id__ */ char *ssprintf(char *, const char *format, ...); #endif dbmi0.1/src/util/test/0040755000175200017560000000000007236675453015220 5ustar stephensstephengdbmi0.1/src/util/test/CVS/0040755000175200017560000000000007236675453015653 5ustar stephensstephengdbmi0.1/src/util/test/CVS/Root0100644000175200017560000000003407236675453016513 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot dbmi0.1/src/util/test/CVS/Repository0100644000175200017560000000002707236675453017751 0ustar stephensstephenghome/ion/src/util/test dbmi0.1/src/util/test/CVS/Entries0100644000175200017560000000013607236675453017204 0ustar stephensstepheng/ConfigTest.c/1.1/Fri May 7 13:29:31 1999// /ConfigTest.cfg/1.1/Fri May 7 13:29:31 1999// D dbmi0.1/src/util/test/ConfigTest.c0100644000175200017560000000225006714565273017423 0ustar stephensstephengstatic char *_version_id = "$Id: ConfigTest.c,v 1.1 1999/05/07 13:29:31 stephensk Exp $"; #include "ConfigInfo.h" #include "config.h" #include #include #include /* isspace() */ #include "sqldummy.c" int main(int argc, char **argv, char **env) { ConfigInfo *config; passthru_config_init(argc, argv, env); config = passthru_config(); { char buf[1024]; while ( gets(buf) ) { char *key = buf; char **rec; if ( key[0] == 'p' ) { char *user, *password; while ( ! isspace(*key) ) key ++; while ( isspace(*key) ) key ++; user = key; while ( ! isspace(*key) ) key ++; *(key ++) = '\0'; while ( isspace(*key) ) key ++; password = key; while ( ! isspace(*key) ) key ++; *(key ++) = '\0'; printf("user = '%s', password = '%s'\n", user, password); rec = (char **) passthru_map_login(user, password); } else { rec = ConfigInfo_getRowForKey(config, 0, key); } if ( rec ) { int i; for ( i = 0; rec[i]; i ++ ) { printf("\"%s\"\t", rec[i]); } printf("\n"); } else { fprintf(stderr, "No record for '%s'\n", buf); } } } return 0; } dbmi0.1/src/util/test/ConfigTest.cfg0100644000175200017560000000005406714565273017740 0ustar stephensstepheng#ConfigTest.cfg config1 1 2 3 config2 1 2 3 dbmi0.1/src/util/refcntptr.hh0100644000175200017560000000511407267632146016563 0ustar stephensstepheng#ifndef _util_REFCNTPTR_HH #define _util_REFCNTPTR_HH #ifndef refcntptr_DEBUG #define refcntptr_DEBUG 0 #endif #if refcntptr_DEBUG #define refcntptr_DEBUG_PRINT(X) printf X #else #define refcntptr_DEBUG_PRINT(X)(void)0 #endif #include /* assert(_refcnt) */ /* Class with refcnt support. */ #define refcntptr_STRINGTIZE_(T)#T #define refcntptr_STRINGTIZE(T)refcntptr_STRINGTIZE_(T) #define refcntptr_(T)T #define refcntptr_PASTE_(A,B)A##B #define refcntptr_PASTE(A,B)refcntptr_PASTE_(A,B) /* Declare ref count manipulation glue. */ #define refcntptr_DECL(T) \ void __ref(refcntptr_(T)*); \ void __deref(refcntptr_(T)*); \ extern "C" refcntptr_(T)* refcntptr_PASTE(T,_ref)(refcntptr_(T)* __p); \ extern "C" void refcntptr_PASTE(T,_deref)(refcntptr_(T)* __p); /* Defines support for refcntptr in T. */ #define refcntptr_CLASS(T) \ private: \ unsigned long _refcnt; \ public: \ virtual void __deref_delete(void); \ void __ref(void) { ++ _refcnt; assert(_refcnt); } \ void __deref(void) \ { \ if ( _refcnt <= 1 ) { \ refcntptr_DEBUG_PRINT(("(%s*)%p delete\n", refcntptr_STRINGTIZE(T), this)); \ this->__deref_delete(); \ } else { \ -- _refcnt; \ } \ } /* Defines ref count manipulation glue. */ #define refcntptr_DEF(SCOPE,T) \ SCOPE void __ref(refcntptr_(T)* __p) { if ( __p ) __p->__ref(); } \ SCOPE void __deref(refcntptr_(T)* __p) { if ( __p ) __p->__deref(); } \ refcntptr_(T)* refcntptr_PASTE(T,_ref)(refcntptr_(T)* __p) { __ref(__p); return __p; } \ void refcntptr_PASTE(T,_deref)(refcntptr_(T)* __p) { __deref(__p); } template class refcntptr { private: T *_p; public: refcntptr () : _p(0) { }; refcntptr (T* ptr) { __ref(_p = ptr); } refcntptr (const refcntptr &x) { __ref(_p = x._p); } ~refcntptr () { __deref(_p); } refcntptr& operator = (T* p) { __ref(p); __deref(_p); _p = p; return *this; } refcntptr& operator = (const refcntptr& x) { return (*this) = x._p; } operator void* () const { return (void*) _p; } operator int () const { return (int) _p; } operator T* () const { return _p; } int operator ! () const { return ! (int) _p; } T& operator *() const { return *_p; } T* operator ->() const { return _p; } int operator == (T* ptr) const { return _p == ptr; } int operator == (const refcntptr &x) const { return *this == x._p; } int operator != (T* ptr) const { return _p != ptr; } int operator != (const refcntptr &x) const { return *this != x._p; } int operator < (T* ptr) { return _p < ptr; } int operator < (const refcntptr &x) const { return *this < x._p; } }; #endif dbmi0.1/src/util/refcntptr.cc0100644000175200017560000000242507263152105016537 0ustar stephensstepheng#include "refcntptr.hh" #ifdef UNIT_TEST #include class Cons; inline void __ref(Cons *t); inline void __deref(Cons *t); typedef refcntptr ref; #define Ref const ref & class Cons { private: friend void __ref(Cons *t); friend void __deref(Cons *t); unsigned long _refcnt; void __ref() { #ifdef _refcntptr_DEBUG fprintf(stderr,"(Cons*)%p->__ref()\n", this); #endif ++ _refcnt; } void __deref() { #ifdef _refcntptr_DEBUG fprintf(stderr,"(Cons*)%p->__deref()\n", this); #endif if ( -- _refcnt <= 0 ) { delete this; } } ref _car; ref _cdr; public: Cons() : _refcnt(0) { }; Cons(const ref &car, const ref &cdr) : _refcnt(0), _car(car), _cdr(cdr) { }; ~Cons() { #ifdef _refcntptr_DEBUG fprintf(stderr, "delete (Cons*)%p\n"); #endif } void _print(Ref x) { if ( x ) { x->print(); } else { fprintf(stderr, "nil"); } } void print() { fprintf(stderr, "("); _print(_car); fprintf(stderr, " . "); _print(_cdr); fprintf(stderr, ")"); } }; inline void __ref(Cons *t) { if ( t ) t->__ref(); } inline void __deref(Cons *t) { if ( t ) t->__deref(); } int main(int argc, char **argv) { ref x; ref y = new Cons(); ref z = new Cons(x, y); z->print(); return 0; } #endif dbmi0.1/src/util/memcpy.h0100644000175200017560000000071107263231170015660 0ustar stephensstepheng#ifndef _util_MEMCPY_H #define _util_MEMCPY_H #ifdef __cplusplus #include /* Typesafe memcpy handles assignment properly. */ template inline void _typesafe_memcpy(T1 *_dst, const T2 *_src, size_t _size) { assert(_size % sizeof(*_dst) == 0); _size /= sizeof(*_dst); while ( _size -- >= 0 ) { *(_dst ++) = *(_src ++); } } #define memcpy(A,B,C) _typesafe_memcpy(A,B,C) #else #include #endif #endif dbmi0.1/src/util/nurbs.c0100644000175200017560000000544607270651343015532 0ustar stephensstepheng #ifndef _util_NURBS_H #include "nurbs.h" #endif #include #include NURBS(EXPORT) int NURBS(_check_pi)(const NURBS(NURBS_T) *n, int i) { assert(i >= 0); assert(i < n->nv); return i; } NURBS(EXPORT) int NURBS(_check_ui)(const NURBS(NURBS_T) *n, int i) { assert(i >= 0); assert(i < n->nu); return i; } #define deg_ (n->degree) #define nv n->nv #define vdim n->vdim #define P(i) (n->v + n->voff + n->vskip * NURBS(_check_pi)(n, (i))) #define W(i) (n->w + n->woff + n->wskip * NURBS(_check_pi)(n, (i)))[0] #define U(i) (n->u[NURBS(_check_ui)(n, (i))]) #ifndef NURBS_EXPORT #define NURBS_EXPORT #endif NURBS(EXPORT) NURBS(T) NURBS(_min_knot)(NURBS(NURBS_T) *n) { return n->u[0]; } NURBS(EXPORT) NURBS(T) NURBS(_max_knot)(NURBS(NURBS_T) *n) { return n->u[n->nu - n->degree]; } NURBS(EXPORT) int NURBS(_find_span) (NURBS(NURBS_T) *n, NURBS(T) u) { if ( u >= U(nv) ) return nv - 1 ; if ( u <= U(deg_) ) return deg_ ; { int low = 0 ; int high = nv + 1 ; int mid; while ( mid = (low + high) / 2, u < U(mid) || u >= U(mid + 1) ) { if ( u < U(mid) ) high = mid ; else low = mid ; } return mid ; } } NURBS(EXPORT) void NURBS(_basis_funs) (NURBS(NURBS_T) *n, NURBS(T) u, int i, NURBS(T) *N) { NURBS(T)* left = (NURBS(T)*) alloca(2 * (deg_+1) * sizeof(NURBS(T))) ; NURBS(T)* right = &left[deg_ + 1] ; int j; N[0] = 1.0 ; for ( j = 1; j <= deg_ ; ++ j ) { int r; NURBS(T) saved = 0.0; left[j] = u - U(i + 1 - j) ; right[j] = U(i + j) - u ; for ( r = 0 ; r < j; ++ r ) { NURBS(T) temp = N[r] / (right[r + 1] + left[j - r]) ; N[r] = saved + right[r + 1] * temp ; saved = left[j - r] * temp ; } N[j] = saved ; } } NURBS(EXPORT) void NURBS(_basis_funs_der)(NURBS(NURBS_T) *n, NURBS(T) u, int i, int d, NURBS(T) *funs) { } NURBS(EXPORT) NURBS(T) * NURBS(_eval) (NURBS(NURBS_T) *n, NURBS(T) u, NURBS(T) *p) { int span = NURBS(_find_span)(n, u); NURBS(T) *Nb = (NURBS(T) *) alloca(sizeof(Nb[0]) * (deg_ + 1)); int i, j; NURBS(T) w; NURBS(_basis_funs)(n, u, span, Nb); i = deg_; for ( j = 0; j < vdim; ++ j ) { p[j] = Nb[i] * P(span - deg_ + i)[j] * (n->w ? W(span - deg_ + i) : 1); } if ( n->w ) { w = Nb[i] * W(span - deg_ + i); } for ( -- i; i >= 0; -- i ) { for ( j = 0; j < vdim; ++ j ) { p[j] += Nb[i] * P(span - deg_ + i)[j] * (n->w ? W(span - deg_ + i) : 1); } if ( n->w ) { w += Nb[i] * W(span - deg_ + i); } } /* Homogenous division. */ if ( n->w ) { for ( j = 0; j < vdim; ++ j ) { p[j] /= w; } } return p; } NURBS(EXPORT) NURBS(T) * NURBS(_eval_der)(NURBS(NURBS_T) *n, NURBS(T) u, int d, NURBS(T) *p) { return p; } #undef deg_ #undef nv #undef vdim #undef P #undef W #undef U dbmi0.1/src/util/nurbs.h0100644000175200017560000000206707270651343015533 0ustar stephensstepheng#ifndef _util_NURBS_H #define _util_NURBS_H #ifndef NURBS_T #define NURBS_T double #endif #define __NURBS(X)NURBS_##X #define _NURBS(X)__NURBS(X) #define NURBS(X)_NURBS(X) typedef struct NURBS(NURBS_T) { short degree; int nv; NURBS(T) *v; short vdim; short vskip; short voff; NURBS(T) *w; short wskip; short woff; int nu; NURBS(T) *u; /* Length must be nv + (degree * 2) - 2. */ } NURBS(NURBS_T); #ifndef NURBS_IMPORT #define NURBS_IMPORT /* extern */ #endif NURBS(IMPORT) NURBS(T) NURBS(_min_knot)(NURBS(NURBS_T) *n); NURBS(IMPORT) NURBS(T) NURBS(_max_knot)(NURBS(NURBS_T) *n); NURBS(IMPORT) int NURBS(_find_span) (NURBS(NURBS_T) *n, NURBS(T) u); NURBS(IMPORT) void NURBS(_basis_funs) (NURBS(NURBS_T) *n, NURBS(T) u, int span, NURBS(T) *funs); NURBS(IMPORT) void NURBS(_basis_funs_der)(NURBS(NURBS_T) *n, NURBS(T) u, int span, int d, NURBS(T) *funs); NURBS(IMPORT) NURBS(T) *NURBS(_eval) (NURBS(NURBS_T) *n, NURBS(T) u, NURBS(T) *r); NURBS(IMPORT) NURBS(T) *NURBS(_eval_der)(NURBS(NURBS_T) *n, NURBS(T) u, int d, NURBS(T) *r); #endif dbmi0.1/src/GUM_BUILD_ROOT0100644000175200017560000000060607306140336015401 0ustar stephensstepheng# $Id: GUM_BUILD_ROOT,v 1.3 2001/04/07 10:26:24 stephens Exp $ # Build options DEBUG=YES #OPTIMIZE=NO # output root is ../gumo GUM_GENERATED_ROOT:=$(shell cd $(GUM_BUILD_ROOT)/../gumo && /bin/pwd)# # Quick install. GUM_GENERATED_LIB_DIR=$(INSTALL_DIR_LIB)# # Pick up /iimp stuff PATH:=/iimp/bin:$(PATH) INCLUDE_DIRS_GLOBAL:=$(GUM_BUILD_ROOT) /iimp/include# LIB_DIRS_GLOBAL:=/iimp/lib# dbmi0.1/README0100644000175200017560000000141207306140336013331 0ustar stephensstephengdbmi 0.1 README ============================================================================== Copyright (c) 1997-2001 Kurt A. Stephens and Ion, Inc., All Rights Reserved. http://www.acm.org/~stephensk Kurt A. Stephens and Ion, Inc. MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. Kurt A. Stephens and Ion, Inc. SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. $Id: COPYRIGHT,v 1.3 2001/04/03 18:37:16 stephens Exp $ ============================================================================== dbmi0.1/COPYRIGHT0100644000175200017560000000113107306140336013742 0ustar stephensstephengCopyright (c) 1997-2001 Kurt A. Stephens and Ion, Inc., All Rights Reserved. http://www.acm.org/~stephensk Kurt A. Stephens and Ion, Inc. MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. Kurt A. Stephens and Ion, Inc. SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. $Id: COPYRIGHT,v 1.3 2001/04/03 18:37:16 stephens Exp $ dbmi0.1/CHANGES0100644000175200017560000000045607306140336013453 0ustar stephensstephengdbmi 0.1 CHANGES ============================================================================== ============================================================================== Changes from release '' to 'PUBLISH_dbmi0_1' ============================================================================== dbmi0.1/TOC0100644000175200017560000004304707306140342013030 0ustar stephensstephengdbmi 0.1 Table of Contents ============================================================================== dbmi0.1: total 7 drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:33 . drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:33 .. -rw-r--r-- 1 stephens stepheng 302 Jun 2 05:33 CHANGES -rw-r--r-- 1 stephens stepheng 601 Jun 2 05:33 COPYRIGHT -rw-r--r-- 1 stephens stepheng 778 Jun 2 05:33 README -rw-r--r-- 1 stephens stepheng 106 Jun 2 05:33 TOC drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:33 src dbmi0.1/src: total 7 drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:33 . drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:33 .. -rw-r--r-- 1 stephens stepheng 390 Jun 2 05:33 GUM_BUILD_ROOT drwxr-xr-x 5 stephens stepheng 1024 Jun 2 05:33 bin drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:33 dbmi drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:33 maks drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:33 util dbmi0.1/src/bin: total 134 drwxr-xr-x 5 stephens stepheng 1024 Jun 2 05:33 . -rwxr--r-- 1 stephens stepheng 2170 Feb 23 01:14 .#uud.1.2 -rwxr--r-- 1 stephens stepheng 3661 Feb 23 01:14 .#uudindex.1.2 drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Jun 2 05:09 CVS -rw-r--r-- 1 stephens stepheng 230 Feb 17 1999 PKG -rw-r--r-- 1 stephens stepheng 9271 Feb 17 1999 addcr drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 addcr.t -rw-r--r-- 1 stephens stepheng 3385 Jun 28 1999 addrcsid.pl -rw-r--r-- 1 stephens stepheng 5118 Feb 17 1999 ccinfo -rw-r--r-- 1 stephens stepheng 3059 Feb 17 1999 ccloclibs -rw-r--r-- 1 stephens stepheng 372 Feb 19 1999 ctocnl.c -rwxr--r-- 1 stephens stepheng 1255 Jan 14 09:40 cvschrep.pl -rw-r--r-- 1 stephens stepheng 1062 Feb 17 1999 cvschroot.pl -rw-r--r-- 1 stephens stepheng 352 Oct 20 1999 cvsclean -rw-r--r-- 1 stephens stepheng 331 Oct 13 1999 cvsedited -rw-r--r-- 1 stephens stepheng 1373 Oct 20 1999 cvsfind.pl -rw-r--r-- 1 stephens stepheng 1168 Apr 9 15:43 cvsfix.pl -rw-r--r-- 1 stephens stepheng 1193 Sep 9 1999 cvsretag.pl -rw-r--r-- 1 stephens stepheng 3571 Mar 21 2000 cvsrevhist.pl -rw-r--r-- 1 stephens stepheng 945 Feb 19 1999 cwfixlib.pl -rwxr--r-- 1 stephens stepheng 3010 Jan 14 09:40 d2u.pl -rw-r--r-- 1 stephens stepheng 312 Apr 8 1994 dos2unix.c -rw-r--r-- 1 stephens stepheng 709 Feb 17 1999 ecd -rw-r--r-- 1 stephens stepheng 190 Feb 17 1999 fe -rw-r--r-- 1 stephens stepheng 103 Feb 17 1999 findsource -rw-r--r-- 1 stephens stepheng 6566 Sep 30 1999 igrep drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 lib -rw-r--r-- 1 stephens stepheng 647 Feb 17 1999 linkdups -rw-r--r-- 1 stephens stepheng 1369 Feb 17 1999 locstatic -rw-r--r-- 1 stephens stepheng 259 Sep 30 1999 lsup -rw-r--r-- 1 stephens stepheng 6485 Feb 19 1999 mergefiles.pl -rw-r--r-- 1 stephens stepheng 1965 Sep 30 1999 mkindex -rw-r--r-- 1 stephens stepheng 1739 Oct 13 1999 mvr.pl -rw-r--r-- 1 stephens stepheng 279 Feb 17 1999 nmlibs -rwxr-xr-x 1 stephens stepheng 64 Feb 17 1999 nmm -rw-r--r-- 1 stephens stepheng 2427 Feb 17 1999 objcsyms -rw-r--r-- 1 stephens stepheng 18189 Jun 2 05:24 publish.pl -rw-r--r-- 1 stephens stepheng 2957 Feb 17 1999 sci -rw-r--r-- 1 stephens stepheng 3328 Feb 17 1999 scip -rw-r--r-- 1 stephens stepheng 92 Oct 13 1999 si -rw-r--r-- 1 stephens stepheng 2374 Feb 19 1999 split.c -rwxr--r-- 1 stephens stepheng 436 Apr 3 13:40 swig2def.pl -rwxr--r-- 1 stephens stepheng 2350 Jan 14 09:41 tgz -rw-r--r-- 1 stephens stepheng 1655 Mar 21 2000 ts -rwxr--r-- 1 stephens stepheng 2170 Apr 3 13:51 uud -rwxr--r-- 1 stephens stepheng 3661 Apr 3 13:51 uudindex -rw-r--r-- 1 stephens stepheng 606 Feb 17 1999 which -rw-r--r-- 1 stephens stepheng 99 Feb 17 1999 whichall -rw-r--r-- 1 stephens stepheng 1777 Feb 17 1999 wwwsend dbmi0.1/src/bin/CVS: total 6 drwxr-xr-x 2 stephens stepheng 1024 Jun 2 05:09 . drwxr-xr-x 5 stephens stepheng 1024 Jun 2 05:33 .. -rw-r--r-- 1 stephens stepheng 1817 Jun 2 05:09 Entries -rw-r--r-- 1 stephens stepheng 17 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/bin/addcr.t: total 5 drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 5 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 backup -rw-r--r-- 1 stephens stepheng 143 Feb 17 1999 run dbmi0.1/src/bin/addcr.t/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 49 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 25 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/bin/addcr.t/backup: total 7 drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS -rw-r--r-- 1 stephens stepheng 260 Feb 19 1999 t1.c -rw-r--r-- 1 stephens stepheng 20 Feb 17 1999 t2 -rw-r--r-- 1 stephens stepheng 41 Feb 17 1999 t3 -rw-r--r-- 1 stephens stepheng 379 Feb 17 1999 t4 dbmi0.1/src/bin/addcr.t/backup/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 155 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 32 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/bin/lib: total 4 drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 5 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 perl dbmi0.1/src/bin/lib/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 11 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 21 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/bin/lib/perl: total 4 drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 ion dbmi0.1/src/bin/lib/perl/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 10 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 26 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/bin/lib/perl/ion: total 4 drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS drwxr-xr-x 3 stephens stepheng 1024 Jun 2 03:46 _cvs dbmi0.1/src/bin/lib/perl/ion/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 11 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 30 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/bin/lib/perl/ion/_cvs: total 14 drwxr-xr-x 3 stephens stepheng 1024 Jun 2 03:46 . drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 .. drwxr-xr-x 2 stephens stepheng 1024 Jun 2 05:09 CVS -rw-r--r-- 1 stephens stepheng 1094 Mar 21 2000 entry.pm -rw-r--r-- 1 stephens stepheng 3296 Jun 2 05:09 find.pm -rw-r--r-- 1 stephens stepheng 5052 Mar 7 1999 rlog.pm dbmi0.1/src/bin/lib/perl/ion/_cvs/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Jun 2 05:09 . drwxr-xr-x 3 stephens stepheng 1024 Jun 2 03:46 .. -rw-r--r-- 1 stephens stepheng 123 Jun 2 05:09 Entries -rw-r--r-- 1 stephens stepheng 35 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/dbmi: total 58 drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:33 . drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS -rw-r--r-- 1 stephens stepheng 936 Feb 6 2000 Makefile -rw-r--r-- 1 stephens stepheng 121 Jan 12 2000 Makefile.use -rw-r--r-- 1 stephens stepheng 240 Mar 21 2000 PKG -rw-r--r-- 1 stephens stepheng 42463 Jan 31 23:52 dbmi.c -rw-r--r-- 1 stephens stepheng 4952 Jan 31 23:52 dbmi.h -rw-r--r-- 1 stephens stepheng 2625 Feb 6 2000 main.c -rw-r--r-- 1 stephens stepheng 554 Jan 12 2000 test.ts dbmi0.1/src/dbmi/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:33 .. -rw-r--r-- 1 stephens stepheng 281 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 18 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/maks: total 28 drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:33 . drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Apr 4 04:06 CVS -rwxr--r-- 1 stephens stepheng 206 Apr 3 13:51 PKG -rwxr--r-- 1 stephens stepheng 4407 Apr 4 04:09 basic.mak drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 bin -rw-r--r-- 1 stephens stepheng 172 Feb 19 1999 fixpound.pl -rwxr--r-- 1 stephens stepheng 2246 Apr 3 13:51 lib.mak drwxr-xr-x 3 stephens stepheng 1024 Apr 4 00:55 opengl drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 os -rwxr--r-- 1 stephens stepheng 6667 Apr 3 13:51 pre.mak -rw-r--r-- 1 stephens stepheng 1651 Mar 21 2000 tool.mak -rw-r--r-- 1 stephens stepheng 212 Sep 8 1999 tools.mak -rwxr--r-- 1 stephens stepheng 494 Apr 3 13:51 use.mak drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 win32 dbmi0.1/src/maks/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Apr 4 04:06 . drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:33 .. -rw-r--r-- 1 stephens stepheng 370 Apr 4 04:06 Entries -rw-r--r-- 1 stephens stepheng 18 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/maks/bin: total 5 drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS -rw-r--r-- 1 stephens stepheng 418 Jun 28 1999 mak -rw-r--r-- 1 stephens stepheng 106 Jun 28 1999 mak.bat dbmi0.1/src/maks/bin/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 78 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 22 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/maks/opengl: total 5 drwxr-xr-x 3 stephens stepheng 1024 Apr 4 00:55 . drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Apr 4 04:06 CVS -rw-r--r-- 1 stephens stepheng 75 Feb 19 1999 Makefile -rw-r--r-- 1 stephens stepheng 495 Apr 4 04:09 Makefile.use dbmi0.1/src/maks/opengl/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Apr 4 04:06 . drwxr-xr-x 3 stephens stepheng 1024 Apr 4 00:55 .. -rw-r--r-- 1 stephens stepheng 88 Apr 4 04:06 Entries -rw-r--r-- 1 stephens stepheng 25 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/maks/os: total 6 drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS -rw-r--r-- 1 stephens stepheng 88 Jan 13 2000 CYGWIN.mak -rw-r--r-- 1 stephens stepheng 116 Jan 13 2000 CYGWIN_98-4.10.mak -rw-r--r-- 1 stephens stepheng 77 Jan 13 2000 Linux.mak dbmi0.1/src/maks/os/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 138 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 21 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/maks/win32: total 5 drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS -rw-r--r-- 1 stephens stepheng 75 Feb 19 1999 Makefile -rw-r--r-- 1 stephens stepheng 101 Feb 19 1999 Makefile.use dbmi0.1/src/maks/win32/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 88 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 24 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/util: total 120 drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:33 . drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Apr 22 17:15 CVS -rw-r--r-- 1 stephens stepheng 21030 Jan 4 2000 ConfigInfo.c -rw-r--r-- 1 stephens stepheng 4826 Apr 5 1999 ConfigInfo.h -rw-r--r-- 1 stephens stepheng 1081 Jan 4 2000 Makefile -rw-r--r-- 1 stephens stepheng 86 Feb 19 1999 Makefile.use -rw-r--r-- 1 stephens stepheng 249 May 7 1999 PKG -rw-r--r-- 1 stephens stepheng 712 Jan 7 2000 bitset.h -rw-r--r-- 1 stephens stepheng 4571 Sep 30 1999 charset.c -rw-r--r-- 1 stephens stepheng 943 Apr 22 1999 charset.h -rw-r--r-- 1 stephens stepheng 3438 Jan 13 2000 enum.c -rw-r--r-- 1 stephens stepheng 790 Jan 13 2000 enum.h -rw-r--r-- 1 stephens stepheng 184 Jan 13 2000 errlist.h -rw-r--r-- 1 stephens stepheng 684 Oct 26 1999 errlist.pl -rw-r--r-- 1 stephens stepheng 11686 Feb 1 00:22 file.c -rw-r--r-- 1 stephens stepheng 1276 Feb 1 00:22 file.h -rw-r--r-- 1 stephens stepheng 1113 Jan 4 2000 host.c -rw-r--r-- 1 stephens stepheng 335 Jan 4 2000 host.h -rw-r--r-- 1 stephens stepheng 5782 Jan 4 2000 lockfile.c -rw-r--r-- 1 stephens stepheng 781 Jun 9 1999 lockfile.h -rw-r--r-- 1 stephens stepheng 949 Jun 9 1999 lockfile_main.c -rw-r--r-- 1 stephens stepheng 3146 Feb 19 1999 mem.c -rw-r--r-- 1 stephens stepheng 575 Jun 28 1999 mem.h -rw-r--r-- 1 stephens stepheng 457 Apr 5 22:05 memcpy.h -rw-r--r-- 1 stephens stepheng 1875 Oct 13 1999 midi.h -rw-r--r-- 1 stephens stepheng 2854 Apr 22 16:53 nurbs.c -rw-r--r-- 1 stephens stepheng 1079 Apr 22 16:53 nurbs.h -rw-r--r-- 1 stephens stepheng 1837 Jan 4 2000 outbuf.c -rw-r--r-- 1 stephens stepheng 726 Sep 30 1999 outbuf.h -rw-r--r-- 1 stephens stepheng 2609 Jun 28 1999 path.c -rw-r--r-- 1 stephens stepheng 651 Feb 19 1999 path.h -rw-r--r-- 1 stephens stepheng 904 Jan 4 2000 port.c -rw-r--r-- 1 stephens stepheng 236 Jan 4 2000 port.h -rw-r--r-- 1 stephens stepheng 4366 Jan 13 2000 prime.c -rw-r--r-- 1 stephens stepheng 388 Jan 13 2000 prime.h -rw-r--r-- 1 stephens stepheng 1192 May 9 2000 rc4.c -rw-r--r-- 1 stephens stepheng 399 May 9 2000 rc4.h -rw-r--r-- 1 stephens stepheng 1301 Apr 5 15:23 refcntptr.cc -rw-r--r-- 1 stephens stepheng 2636 Apr 19 13:54 refcntptr.hh -rw-r--r-- 1 stephens stepheng 1317 Apr 5 1999 setenv.c -rw-r--r-- 1 stephens stepheng 377 Apr 5 1999 setenv.h -rw-r--r-- 1 stephens stepheng 1345 Jan 3 2000 sig.c -rw-r--r-- 1 stephens stepheng 348 Jan 3 2000 sig.h -rw-r--r-- 1 stephens stepheng 533 Jan 3 2000 sigs.pl -rw-r--r-- 1 stephens stepheng 2015 Jan 4 2000 ssprintf.c -rw-r--r-- 1 stephens stepheng 337 Apr 22 1999 ssprintf.h drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 test dbmi0.1/src/util/CVS: total 6 drwxr-xr-x 2 stephens stepheng 1024 Apr 22 17:15 . drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:33 .. -rw-r--r-- 1 stephens stepheng 1806 Apr 22 17:15 Entries -rw-r--r-- 1 stephens stepheng 18 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root dbmi0.1/src/util/test: total 6 drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:33 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS -rw-r--r-- 1 stephens stepheng 1192 May 7 1999 ConfigTest.c -rw-r--r-- 1 stephens stepheng 44 May 7 1999 ConfigTest.cfg dbmi0.1/src/util/test/CVS: total 5 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 .. -rw-r--r-- 1 stephens stepheng 94 Feb 2 21:29 Entries -rw-r--r-- 1 stephens stepheng 23 Feb 2 21:29 Repository -rw-r--r-- 1 stephens stepheng 28 Feb 2 21:29 Root