hash0.5/0040755000175200017560000000000007306140044012466 5ustar stephensstephenghash0.5/src/0040755000175200017560000000000007306140040013251 5ustar stephensstephenghash0.5/src/hash/0040755000175200017560000000000007306140040014174 5ustar stephensstephenghash0.5/src/hash/CVS/0040755000175200017560000000000007236675452014655 5ustar stephensstephenghash0.5/src/hash/CVS/Root0100644000175200017560000000003407236675452015515 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/hash/CVS/Repository0100644000175200017560000000002207236675452016746 0ustar stephensstephenghome/ion/src/hash hash0.5/src/hash/CVS/Entries0100644000175200017560000000204707236675452016211 0ustar stephensstepheng/Makefile/1.5/Thu Apr 22 05:15:07 1999// /PKG/1.6/Wed Oct 13 17:34:58 1999// /charP_hash.c/1.1/Thu Nov 4 10:38:29 1999// /charP_int_Table.c/1.3/Thu Nov 4 10:38:29 1999// /charP_int_Table.def/1.3/Thu Apr 22 05:16:38 1999// /charP_int_Table.h/1.2/Fri Feb 19 09:25:41 1999// /charP_voidP_Table.c/1.3/Thu Nov 4 10:38:29 1999// /charP_voidP_Table.def/1.3/Thu Apr 22 05:16:38 1999// /charP_voidP_Table.h/1.2/Fri Feb 19 09:25:41 1999// /generic_Table.c/1.2/Fri Feb 19 09:25:41 1999// /generic_Table.def/1.2/Fri Feb 19 09:25:42 1999// /generic_Table.h/1.2/Fri Feb 19 09:25:42 1999// /hash.c/1.9/Thu Nov 4 10:38:29 1999// /hash.def/1.6/Thu Nov 4 10:38:29 1999// /hash.h/1.4/Tue Oct 12 07:27:08 1999// /hash_end.def/1.5/Thu Nov 4 10:38:29 1999// /int_voidP_Table.c/1.3/Thu Nov 4 10:38:29 1999// /int_voidP_Table.def/1.2/Fri Feb 19 09:25:42 1999// /int_voidP_Table.h/1.2/Fri Feb 19 09:25:43 1999// /voidP_voidP_Table.c/1.2/Thu Nov 4 10:38:30 1999// /voidP_voidP_Table.def/1.1/Thu Apr 22 05:15:08 1999// /voidP_voidP_Table.h/1.1/Thu Apr 22 05:15:07 1999// D/test//// hash0.5/src/hash/Makefile0100644000175200017560000000056306707530133015647 0ustar stephensstepheng# $Id: Makefile,v 1.5 1999/04/22 05:15:07 stephensk Exp $ C_FILES = \ charP_int_Table.c \ charP_voidP_Table.c \ int_voidP_Table.c \ voidP_voidP_Table.c \ generic_Table.c CFLAGS = -I.. -g O_FILES = $(C_FILES:.c=.o) LIB = libhash.a $(LIB) : $(O_FILES) -rm -f $@ ar r $@ $(O_FILES) $(O_FILES) : hash.def hash.c hash.h clean : rm -f $(LIB) $(O_FILES) hash0.5/src/hash/PKG0100644000175200017560000000033707001141302014532 0ustar stephensstephengNAME=hash VERSION=0.5 RCS_ID="$Id: PKG,v 1.6 1999/10/13 17:34:58 stephensk Exp $" DESC="A C template library for efficient, configurable hash tables." CATEGORY="Development Tools" REQUIRES_PKGS="../util" REQUIRES_OTHERS="" hash0.5/src/hash/charP_hash.c0100644000175200017560000000073207010261045016400 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_hash_charP_hash_c__ #define __rcs_id_hash_charP_hash_c__ static const char __rcs_id_hash_charP_hash_c[] = "$Id: charP_hash.c,v 1.1 1999/11/04 10:38:29 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #ifndef HASH_EXTERN #define HASH_EXTERN #endif HASH_EXTERN unsigned int strhash (const char *str) { unsigned int hash = 0; while ( *str ) { hash ^= (hash << 15) | (hash >> 1) ^ * (unsigned char*) (str ++); } return hash; } hash0.5/src/hash/charP_int_Table.c0100644000175200017560000000061107010261045017352 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_hash_charP_int_Table_c__ #define __rcs_id_hash_charP_int_Table_c__ static const char __rcs_id_hash_charP_int_Table_c[] = "$Id: charP_int_Table.c,v 1.3 1999/11/04 10:38:29 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include #include #include "charP_hash.c" #include "charP_int_Table.def" #include "hash.c" hash0.5/src/hash/charP_int_Table.def0100644000175200017560000000112206707530266017704 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_hash_charP_int_Table_def__ #define __rcs_id_hash_charP_int_Table_def__ static const char __rcs_id_hash_charP_int_Table_def[] = "$Id: charP_int_Table.def,v 1.3 1999/04/22 05:16:38 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define HASH(X)charP_int_##X #define HASH_KEY const char* #define HASH_KEY_HASH(X) strhash(X) #define HASH_KEY_EQUAL(X,Y) ((X)[0] == (Y)[0] && strcmp((X),(Y))==0) #define HASH_KEY_SET(X,Y) do { (X) = strcpy(HASH_MALLOC(strlen(Y) + 1), (Y)); } while(0) #define HASH_KEY_FREE(X) do { HASH_FREE(X); } while(0) #define HASH_DATA int hash0.5/src/hash/charP_int_Table.h0100644000175200017560000000056706663227025017406 0ustar stephensstepheng#ifndef _charP_int_Table_h #ifndef __rcs_id__ #ifndef __rcs_id_hash_charP_int_Table_h__ #define __rcs_id_hash_charP_int_Table_h__ static const char __rcs_id_hash_charP_int_Table_h[] = "$Id: charP_int_Table.h,v 1.2 1999/02/19 09:25:41 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define _charP_int_Table_h #include "charP_int_Table.def" #include "hash/hash.h" #endif hash0.5/src/hash/charP_voidP_Table.c0100644000175200017560000000062407010261045017645 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_hash_charP_voidP_Table_c__ #define __rcs_id_hash_charP_voidP_Table_c__ static const char __rcs_id_hash_charP_voidP_Table_c[] = "$Id: charP_voidP_Table.c,v 1.3 1999/11/04 10:38:29 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include #include #include "charP_hash.c" #include "charP_voidP_Table.def" #include "hash.c" hash0.5/src/hash/charP_voidP_Table.def0100644000175200017560000000115006707530266020174 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_hash_charP_voidP_Table_def__ #define __rcs_id_hash_charP_voidP_Table_def__ static const char __rcs_id_hash_charP_voidP_Table_def[] = "$Id: charP_voidP_Table.def,v 1.3 1999/04/22 05:16:38 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define HASH(X)charP_voidP_##X #define HASH_KEY const char* #define HASH_KEY_HASH(X) strhash(X) #define HASH_KEY_EQUAL(X,Y) ((X)[0] == (Y)[0] && strcmp((X),(Y))==0) #define HASH_KEY_SET(X,Y) do { (X) = strcpy(HASH_MALLOC(strlen(Y) + 1), (Y)); } while(0) #define HASH_KEY_FREE(X) do { HASH_FREE((char*) (X)); } while(0) #define HASH_DATA void* hash0.5/src/hash/charP_voidP_Table.h0100644000175200017560000000060506663227025017666 0ustar stephensstepheng#ifndef _charP_voidP_Table_h #ifndef __rcs_id__ #ifndef __rcs_id_hash_charP_voidP_Table_h__ #define __rcs_id_hash_charP_voidP_Table_h__ static const char __rcs_id_hash_charP_voidP_Table_h[] = "$Id: charP_voidP_Table.h,v 1.2 1999/02/19 09:25:41 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define _charP_voidP_Table_h #include "charP_voidP_Table.def" #include "hash/hash.h" #endif hash0.5/src/hash/generic_Table.c0100644000175200017560000000045306663227025017100 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_hash_generic_Table_c__ #define __rcs_id_hash_generic_Table_c__ static const char __rcs_id_hash_generic_Table_c[] = "$Id: generic_Table.c,v 1.2 1999/02/19 09:25:41 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include "generic_Table.def" #include "hash.c" hash0.5/src/hash/generic_Table.def0100644000175200017560000000144406663227026017416 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_hash_generic_Table_def__ #define __rcs_id_hash_generic_Table_def__ static const char __rcs_id_hash_generic_Table_def[] = "$Id: generic_Table.def,v 1.2 1999/02/19 09:25:42 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define HASH(X)generic_##X struct generic_TableMethods; #define HASH_TABLE_DATA struct generic_TableMethods _methods; #define HASH_KEY void* #define HASH_KEY_HASH(X) (ht->_methods._hash)(X) #define HASH_KEY_EQUAL(X,Y) (ht->_methods._equal)(X, Y) #define HASH_KEY_SET(X,Y) ((X) = (ht->_methods._copy(Y))) #define HASH_KEY_FREE(X) (ht->_methods._free)(X) typedef struct generic_TableMethods { unsigned int (*_hash)(HASH_KEY); int (*_equal)(HASH_KEY a, HASH_KEY b); void* (*_copy)(HASH_KEY); void (*_free)(HASH_KEY); } generic_TableMethods; hash0.5/src/hash/generic_Table.h0100644000175200017560000000055106663227026017105 0ustar stephensstepheng#ifndef _generic_Table_h #ifndef __rcs_id__ #ifndef __rcs_id_hash_generic_Table_h__ #define __rcs_id_hash_generic_Table_h__ static const char __rcs_id_hash_generic_Table_h[] = "$Id: generic_Table.h,v 1.2 1999/02/19 09:25:42 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define _generic_Table_h #include "generic_Table.def" #include "hash/hash.h" #endif hash0.5/src/hash/hash.c0100644000175200017560000002633707010261045015274 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_hash_hash_c__ #define __rcs_id_hash_hash_c__ static const char __rcs_id_hash_hash_c[] = "$Id: hash.c,v 1.9 1999/11/04 10:38:29 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include /* size_t */ #include /* malloc(), realloc(), free() */ #include #include #include "hash.def" #if HASH_TABLE_SIZE_TO_PRIME #define EXTERN static #include "util/prime.c" #undef EXTERN #endif #ifndef HASH_MALLOC #define HASH_MALLOC(X) malloc(X) #endif #ifndef HASH_FREE #define HASH_FREE(X) free(X) #endif #ifndef HASH_WRITE_BARRIER #define HASH_WRITE_BARRIER(X) #endif #if HASH_KEEP_HASH #define HASH_ENTRY_HASH(e) (e)->_hash #else #define HASH_ENTRY_HASH(e) HASH_KEY_HASH((e)->_key) #endif HASH_EXTERN void HASH(TableStats) (HASH(Table) *ht, FILE *fp) { int i; int ne = 0; int tne = 0; /* total no. of entries */ int tnhc = 0; /* total no. of hash collisions */ int tbc = 0; /* total no. of bucket collisions */ int mbc = 0; /* max no of bucket collisions */ int biu = 0; /* buckets in use */ #define _HASH_STRINGTIZE(X)#X #define HASH_STRINGTIZE(X)_HASH_STRINGTIZE(X) fprintf(fp, "HASH_STATS %s %p {\n", HASH_STRINGTIZE(HASH(Table)), ht); for ( i = 0; i < HASH_TABLE_SIZE(ht); i ++ ) { HASH(TableEntry) *e; ne = 0; for ( e = ht->_entries[i]; e; e = e->_next ) { ne ++; tne ++; } if ( ne > 0 ) { biu ++; } if ( ne > 1 ) { if ( mbc < ne ) { mbc = ne; } tbc += ne - 1; } if ( ne > 1 ) { HASH_VAL *hashes = malloc(sizeof(hashes[0]) * ne); unsigned int *counts = malloc(sizeof(counts[0]) * ne); int nhashes = 0; int hi; memset(hashes, 0, sizeof(hashes[0]) * ne); memset(counts, 0, sizeof(counts[0]) * ne); fprintf(fp, " %5d: %4d: ", i, ne); for ( e = ht->_entries[i]; e; e = e->_next ) { HASH_VAL h = HASH_ENTRY_HASH(e); for ( hi = 0; hi < nhashes; hi ++ ) { if ( hashes[hi] == h ) { counts[hi] ++; goto found_hash; } } nhashes ++; assert(nhashes <= ne); hashes[hi] = h; found_hash: counts[hi] ++; } fprintf(fp, " %3d: { ", nhashes); for ( hi = 0; hi < nhashes; hi ++ ) { fprintf(stderr, "0x%08lx %4d ", (unsigned long) hashes[hi], (int) counts[hi]); tnhc += counts[hi] - 1; } fprintf(fp, "}\n"); free(hashes); free(counts); } } fprintf(fp, "}\n"); fprintf(fp, "total buckets: %d\n", HASH_TABLE_SIZE(ht)); fprintf(fp, "total buckets in use: %d\n", biu); fprintf(fp, "total nentries: %d\n", tne); fprintf(fp, "total hash collisions: %d\n", tnhc); fprintf(fp, "total bucket collisions: %d\n", tbc); #if HASH_TABLE_COLLISIONS fprintf(fp, "_collisions: %d\n", ht->_collisions); #endif fprintf(fp, "max bucket collisions: %d\n", mbc); } #ifndef HASH_COLLISION_STATS #define HASH_COLLISION_STATS 0 #endif #if HASH_COLLISION_STATS static int hcs = 0; #define HASH_CHECK_COLLISION_STATS(ht) if ( hcs ++ > HASH_COLLISION_STATS ) { hcs = 0; HASH(TableStats) (ht, stderr); } #else #define HASH_CHECK_COLLISION_STATS(ht) #endif HASH_EXTERN HASH(TableEntry) ** HASH(TableSearch) ( HASH(Table) *ht, HASH_KEY _key, HASH_VAL _hash ) { #if HASH_CACHE if ( ht->_cache && (*ht->_cache) && #if HASH_KEEP_HASH _hash == (*ht->_cache)->_hash && #endif (HASH_KEY_EQUAL(_key, (*ht->_cache)->_key)) ) { return ht->_cache; } #endif { unsigned int i = ((unsigned int) _hash) % HASH_TABLE_SIZE(ht); HASH(TableEntry) **e = &(ht->_entries[i]); while ( *e ) { if ( #if HASH_KEEP_HASH _hash == (*e)->_hash && #endif (HASH_KEY_EQUAL(_key, (*e)->_key)) ) { #if HASH_SEARCH_MOVE_TO_FRONT != 0 if ( HASH_SEARCH_MOVE_TO_FRONT ) { HASH(TableEntry) *ee = *e; *e = ee->_next; HASH_WRITE_BARRIER(e); ee->_next = ht->_entries[i]; HASH_WRITE_BARRIER(ee); ht->_entries[i] = ee; HASH_WRITE_BARRIER(ht->entries); e = &(ht->_entries[i]); HASH_WRITE_BARRIER(e); } #endif return e; } e = &((*e)->_next); } return 0; } } HASH_EXTERN void HASH(TableAddEntry) ( HASH(Table) *ht, HASH(TableEntry) *e ) { unsigned int i = ((unsigned int) HASH_ENTRY_HASH(e)) % HASH_TABLE_SIZE(ht); #if HASH_TABLE_COLLISIONS != 0 if ( ht->_entries[i] ) ht->_collisions ++; #endif e->_next = ht->_entries[i]; HASH_WRITE_BARRIER(e); ht->_entries[i] = e; HASH_WRITE_BARRIER(ht->_entries); #if HASH_TABLE_NENTRIES != 0 ht->_nentries ++; #endif HASH_CHECK_COLLISION_STATS(ht); } HASH_EXTERN void HASH(TableInit) ( HASH(Table) *ht, int capacity ) { #ifdef HASH_TABLE_INIT HASH_TABLE_INIT(ht); #undef HASH_TABLE_INIT #endif HASH_TABLE_CAPACITY_ADJUST(capacity); if ( capacity < 1 ) capacity = 1; #if HASH_CACHE ht->_cache = 0; #endif #if HASH_TABLE_FIXED_SIZE == 0 ht->_entriesLen = capacity; ht->_entries = HASH_MALLOC(sizeof(ht->_entries[0]) * HASH_TABLE_SIZE(ht)); #endif memset(ht->_entries, 0, sizeof(ht->_entries[0]) * HASH_TABLE_SIZE(ht)); HASH_WRITE_BARRIER(ht->_entries); #if HASH_TABLE_NENTRIES != 0 ht->_nentries = 0; #endif #if HASH_TABLE_COLLISIONS != 0 ht->_collisions = 0; #endif } HASH_EXTERN size_t HASH(TableSize) ( HASH(Table) *ht ) { return HASH_TABLE_SIZE(ht); } HASH_EXTERN size_t HASH(TableNEntries) ( HASH(Table) *ht ) { #if HASH_TABLE_NENTRIES != 0 return ht->_nentries; #else int i; size_t tne = 0; for ( i = 0; i < HASH_TABLE_SIZE(ht); i ++ ) { HASH(TableEntry) *e; for ( e = ht->_entries[i]; e; e = e->_next ) { tne ++; } } return tne; #endif } HASH_EXTERN size_t HASH(TableCollisions) ( HASH(Table) *ht ) { #if HASH_TABLE_COLLISIONS != 0 return ht->_collisions; #else return (size_t) -1L; #endif } HASH_EXTERN void HASH(TableResize) ( HASH(Table) *ht, int capacity ) { #if HASH_TABLE_FIXED_SIZE == 0 unsigned int i; /* Remember the old entries */ HASH(TableEntry) **_entries = ht->_entries; unsigned int _entriesLen = HASH_TABLE_SIZE(ht); HASH_TABLE_CAPACITY_ADJUST(capacity); if ( capacity < 1 ) capacity = 1; if ( capacity == ht->_entriesLen ) return; /* Create a new entries table. */ HASH(TableInit) ( ht, capacity ); /* Scan through old entries. */ for ( i = 0; i < _entriesLen; i ++ ) { HASH(TableEntry) *e, *e_next; /* Reverse the list because Add puts them at the front of the list */ e = _entries[i]; _entries[i] = 0; HASH_WRITE_BARRIER(_entries); for ( ; e; e = e_next ) { e_next = e->_next; e->_next = _entries[i]; HASH_WRITE_BARRIER(e); _entries[i] = e; HASH_WRITE_BARRIER(_entries); } /* Add them to the new table. */ for ( e = _entries[i]; e; e = e_next ) { e_next = e->_next; HASH(TableAddEntry) (ht, e); } } /* Free old table. */ HASH_FREE((void*) _entries); #if 0 /* Show some stats. */ HASH(TableStats) (ht, stderr); #endif #endif } HASH_EXTERN void HASH(TableDestroy) ( HASH(Table) *ht ) { unsigned int i; #if HASH_CACHE ht->_cache = 0; #endif for ( i = 0; i < HASH_TABLE_SIZE(ht); i ++ ) { HASH(TableEntry) *e, *e_next; for ( e = ht->_entries[i]; e; e = e_next ) { e_next = e->_next; /* free the key */ HASH_KEY_FREE((void*) e->_key); /* free the data */ #ifdef HASH_DATA_DECL HASH_DATA_FREE((void*) e->_data); #endif /* free the entry */ HASH_FREE((void*) e); } } /* Delete the table */ #if HASH_TABLE_FIXED_SIZE HASH_FREE((void*) ht->_entries); ht->_entries = 0; HASH_WRITE_BARRIER(ht); ht->_entriesLen = 0; #endif #if HASH_TABLE_NENTRIES != 0 ht->_nentries = 0; #endif #if HASH_TABLE_COLLISIONS != 0 ht->_collisions = 0; #endif #ifdef HASH_TABLE_DESTROY HASH_TABLE_DESTROY(ht); #undef HASH_TABLE_DESTROY #endif } HASH_EXTERN void HASH(TablePush_) ( HASH(Table) *ht, HASH_KEY _key HASH_DATA_ARG , HASH_VAL _hash) { HASH(TableEntry) *e; e = HASH_MALLOC(sizeof(*e)); #if HASH_KEEP_HASH e->_hash = _hash; #endif HASH_KEY_SET(e->_key, _key); HASH_WRITE_BARRIER(e); #ifdef HASH_DATA_DECL HASH_DATA_SET(e->_data, _data); HASH_WRITE_BARRIER(e); #endif HASH(TableAddEntry) (ht, e); HASH_TABLE_AUTO_RESIZE(ht, 1); } HASH_EXTERN void HASH(TablePush) ( HASH(Table) *ht, HASH_KEY _key HASH_DATA_ARG) { HASH(TablePush_) (ht, _key HASH_DATA_ARG_VAR ,(HASH_KEY_HASH(_key))); } HASH_EXTERN int HASH(TableAdd_) (HASH(Table) *ht, HASH_KEY _key HASH_DATA_ARG ,HASH_VAL _hash) { HASH(TableEntry) **en = HASH(TableSearch) (ht, _key, _hash); if ( en ) { #ifdef HASH_DATA_DECL HASH_DATA_SET((*en)->_data, _data); HASH_WRITE_BARRIER(*en); #else HASH_KEY_SET((*en)->_key, _key); HASH_WRITE_BARRIER(*en); #endif return 0; } else { HASH(TablePush_)(ht, _key HASH_DATA_ARG_VAR , _hash); return 1; } } HASH_EXTERN int HASH(TableAdd) (HASH(Table) *ht, HASH_KEY _key HASH_DATA_ARG) { return HASH(TableAdd_) (ht, _key HASH_DATA_ARG_VAR , (HASH_KEY_HASH(_key))); } HASH_EXTERN int HASH(TableIsSet_) (HASH(Table) *ht, HASH_KEY _key, HASH_VAL _hash) { return HASH(TableSearch) (ht, _key, _hash) != 0; } HASH_EXTERN int HASH(TableIsSet) (HASH(Table) *ht, HASH_KEY _key) { return HASH(TableIsSet_) (ht, _key, (HASH_KEY_HASH(_key))); } HASH_EXTERN HASH_DATA *HASH(TableGet_) (HASH(Table) *ht, HASH_KEY _key, HASH_VAL _hash) { HASH(TableEntry) **en = HASH(TableSearch) (ht, _key, _hash); if ( en ) { #if HASH_CACHE /* Look up was successful, remember it in the cache. */ ht->_cache = en; #endif #ifdef HASH_DATA_DECL return &(*en)->_data; #else return &(*en)->_key; #endif } else { return 0; } } HASH_EXTERN HASH_DATA *HASH(TableGet) (HASH(Table) *ht, HASH_KEY _key) { return HASH(TableGet_) (ht, _key, (HASH_KEY_HASH(_key))); } HASH_EXTERN int HASH(TableRemove_) (HASH(Table) *ht, HASH_KEY _key, HASH_VAL _hash) { HASH(TableEntry) **en = HASH(TableSearch) (ht, _key, _hash); if ( en ) { HASH(TableEntry) *e = *en; *en = e->_next; HASH_WRITE_BARRIER(en); #if HASH_CACHE if ( ht->_cache == en ) ht->_cache = 0; #endif #if HASH_TABLE_NENTRIES != 0 ht->_nentries --; #endif #if HASH_TABLE_COLLISIONS if ( e->_next ) ht->_collisions --; #endif HASH_KEY_FREE((void*) e->_key); #ifdef HASH_DATA_DECL HASH_DATA_FREE((void*) e->_data); #endif HASH_FREE((void*) e); HASH_TABLE_AUTO_RESIZE(ht, -1); return ! 0; } else { return 0; } } HASH_EXTERN int HASH(TableRemove) (HASH(Table) *ht, HASH_KEY _key) { return HASH(TableRemove_) (ht, _key, (HASH_KEY_HASH(_key))); } HASH_EXTERN void HASH(TableIteratorInit)(HASH(Table) *ht, HASH(TableIterator) *i) { i->_i = -1; i->_e = 0; } HASH_EXTERN int HASH(TableIteratorNext)(HASH(Table) *ht, HASH(TableIterator) *i) { if ( i->_i >= HASH_TABLE_SIZE(ht) ) return 0; if ( i->_e ) i->_e = i->_e->_next; while ( ! i->_e ) { if ( ++ i->_i >= HASH_TABLE_SIZE(ht) ) return 0; i->_e = ht->_entries[i->_i]; } return 1; } HASH_EXTERN HASH_KEY *HASH(TableIteratorKey)(HASH(Table) *ht, HASH(TableIterator) *i) { return i->_e ? (HASH_KEY*) &(i->_e->_key) : (HASH_KEY*) 0; } HASH_EXTERN HASH_DATA *HASH(TableIteratorData)(HASH(Table) *ht, HASH(TableIterator) *i) { #ifdef HASH_DATA_DECL return i->_e ? (HASH_DATA *) &(i->_e->_data) : (HASH_DATA *) 0; #else return i->_e ? (HASH_DATA *) &(i->_e->_key) : (HASH_DATA *) 0; #endif } hash0.5/src/hash/hash.def0100644000175200017560000001747507010261045015613 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_hash_hash_def__ #define __rcs_id_hash_hash_def__ static const char __rcs_id_hash_hash_def[] = "$Id: hash.def,v 1.6 1999/11/04 10:38:29 stephensk Exp $"; #endif #endif /* __rcs_id__ */ /* ** Hash table template ** Copyright 1998, 1999 Kurt A. Stephens, http://www.acm.org/~stephensk ** $Id: hash.def,v 1.6 1999/11/04 10:38:29 stephensk Exp $ */ #ifndef HASH #define HASH(X) Hash##X #endif #ifndef HASH_EXTERN #define HASH_EXTERN #endif #ifndef HASH_VAL #define HASH_VAL unsigned int #endif #ifndef HASH_KEY #error "you must define HASH_KEY to a type" #endif #ifndef HASH_KEY_SET #define HASH_KEY_SET(X,Y) X = Y #endif #ifndef HASH_KEY_FREE #define HASH_KEY_FREE(X) #endif #ifndef HASH_KEY_EQUAL #define HASH_KEY_EQUAL(X,Y) (X)=(Y) #endif #ifndef HASH_KEY_HASH #error "you must define HASH_KEY_HASH(X) to a function that returns a HASH_VAL such that if HASH_KEY_EQUAL(X,Y) then HASH_KEY_HASH(X) == HASH_KEY_HASH(Y)" #endif #ifdef HASH_DATA #define HASH_DATA_DECL HASH_DATA _data; #define HASH_DATA_ARG ,HASH_DATA _data #define HASH_DATA_ARG_VAR ,_data #ifndef HASH_DATA_SET #define HASH_DATA_SET(X,Y) X = Y #endif #ifndef HASH_DATA_FREE #define HASH_DATA_FREE(X) #endif #else #define HASH_DATA_ARG #define HASH_DATA_ARG_VAR #define HASH_DATA HASH_KEY #endif #ifndef HASH_TABLE_DATA /* Define this to be struct elements that you want at the beginning of HASH(Table) */ #define HASH_TABLE_DATA #endif #ifndef HASH_TABLE_FIXED_SIZE #define HASH_TABLE_FIXED_SIZE 0 /* Define this to non-zero for a fixed size table */ #endif /* Choose a 2 ^ n - 1 >= X */ #define HASH_TO_POW_2_MINUS_1(X) { unsigned _x = 1; while ( _x - 1 < (X) ) _x *= 2; (X) = _x - 1; } #ifndef HASH_TABLE_SIZE_TO_PRIME /* Define this to non-zero to force table size to be a prime number. */ #define HASH_TABLE_SIZE_TO_PRIME 0 #endif #if HASH_TABLE_SIZE_TO_PRIME /* Choose a prime >= X, where X == 2 ^ n - 1 */ #define _HASH_TABLE_SIZE_TO_PRIME(X) (X) = *prime_ge(X) #else #define _HASH_TABLE_SIZE_TO_PRIME(X) #endif #ifndef HASH_TABLE_SIZE_ADJUST /* Define this to adjust X before finding power of two bigger. */ #define HASH_TABLE_SIZE_ADJUST(X) \ if ( ((X) & 1) == 0 ) (X) ++ \ /* { (X) = ((X) * 3) / 2; } */ \ /* HASH_TO_POW_2_MINUS_1(X) */ #endif #ifndef HASH_TABLE_CAPACITY_ADJUST /* Define this to adjust capacity X before allocating a new bucket table. */ #define HASH_TABLE_CAPACITY_ADJUST(X) HASH_TABLE_SIZE_ADJUST(X); _HASH_TABLE_SIZE_TO_PRIME(X) #endif #ifndef HASH_TABLE_COLLISIONS_THRESHOLD /* Define this to the limit in percent of allowable hash table collisions. */ #define HASH_TABLE_COLLISIONS_THRESHOLD 25 #endif #ifndef HASH_TABLE_COLLISIONS /* Define to non-zero if you want to keep track of hash collisions (useful for determining if you need an auto resize) */ #define HASH_TABLE_COLLISIONS HASH_TABLE_COLLISIONS_THRESHOLD #endif #ifdef HASH_TABLE_COLLISIONS_THRESHOLD #define HASH_TABLE_COLLISIONS_THRESHOLD_CHECK(HT) \ (((HT)->_collisions * 100 / (HT)->_entriesLen) > HASH_TABLE_COLLISIONS_THRESHOLD) #define HASH_TABLE_NEW_CAPACITY(HT) \ (HASH_TABLE_COLLISIONS_THRESHOLD_CHECK(HT) ? \ (HT)->_entriesLen * (100 + HASH_TABLE_COLLISIONS_THRESHOLD) / 100 : \ (HT)->_nentries) #else #define HASH_TABLE_COLLISIONS_THRESHOLD_CHECK(HT) 0 #endif #ifndef HASH_TABLE_NEW_CAPACITY #define HASH_TABLE_NEW_CAPACITY(HT) (HT)->_nentries #endif #ifndef HASH_TABLE_AUTO_RESIZE /* Define this to automatically resize the bucket array after add or delete. */ #if HASH_TABLE_FIXED_SIZE == 0 #define HASH_TABLE_AUTO_RESIZE(HT,GROWTH)if ( (GROWTH) > 0 && (HT)->_nentries > (HT)->_entriesLen || HASH_TABLE_COLLISIONS_THRESHOLD_CHECK(HT) ) HASH(TableResize)(HT, HASH_TABLE_NEW_CAPACITY(HT)); #define HASH_TABLE_NENTRIES 1 #endif #endif /* HASH_TABLE_AUTO_RESIZE */ #ifndef HASH_SEARCH_MOVE_TO_FRONT /* Define to non-zero if you want to move the entry to the front of the list when found during the bucket search */ #define HASH_SEARCH_MOVE_TO_FRONT 1 #endif #ifndef HASH_TABLE_NENTRIES /* Define to non-zero if you want to keep track of the number of entries in the hash table */ #define HASH_TABLE_NENTRIES 1 #endif #ifndef HASH_KEEP_HASH /* Define to non-zero if you want to use a cached hash value to short-circuit bucket collision key comparasions. */ #define HASH_KEEP_HASH 1 #endif #ifndef HASH_CACHE /* Define to non-zero if you want to cache last lookup. */ #define HASH_CACHE 1 #endif typedef struct HASH(TableEntry) { struct HASH(TableEntry) *_next; /* Points to the next entry with the same hash modulo */ #if HASH_KEEP_HASH HASH_VAL _hash; /* The hash value of the key */ #endif HASH_KEY _key; /* The hash key */ #ifdef HASH_DATA_DECL HASH_DATA_DECL /* The hash data */ #endif } HASH(TableEntry); typedef struct HASH(Table) { HASH_TABLE_DATA #if HASH_CACHE struct HASH(TableEntry) **_cache; /* Maybe this will be slot 0, which might be faster to access on some computers. */ #endif #if HASH_TABLE_NENTRIES != 0 unsigned int _nentries; /* The number of entries in the table */ #endif #if HASH_TABLE_COLLISIONS != 0 unsigned int _collisions; /* The number of entries that share buckets in the table */ #endif #if HASH_TABLE_FIXED_SIZE #define HASH_TABLE_SIZE(ht) HASH_TABLE_FIXED_SIZE struct HASH(TableEntry) *_entries[HASH_TABLE_FIXED_SIZE]; #else #define HASH_TABLE_SIZE(ht) (ht)->_entriesLen struct HASH(TableEntry) **_entries; unsigned int _entriesLen; #endif } HASH(Table); typedef struct HASH(TableIterator) { unsigned int _i; const struct HASH(TableEntry) *_e; } HASH(TableIterator); HASH_EXTERN void HASH(TableInit) ( HASH(Table) *ht, int capacity ); /* Initialize the table for a given size */ HASH_EXTERN size_t HASH(TableSize) ( HASH(Table) *ht ); /* Get the size of the table */ HASH_EXTERN size_t HASH(TableNEntries) ( HASH(Table) *ht ); /* Get the number of entries in the table */ HASH_EXTERN size_t HASH(TableCollisions) ( HASH(Table) *ht ); /* Get the number of collisions in the table */ HASH_EXTERN void HASH(TableResize) ( HASH(Table) *ht, int capacity ); /* Resize the table */ HASH_EXTERN void HASH(TableDestroy) ( HASH(Table) *ht ); /* Destroy the table */ HASH_EXTERN HASH_VAL HASH(TableHash) ( HASH(Table) *ht, HASH_KEY _key ); /* Get the hash value for a key */ HASH_EXTERN void HASH(TablePush_) ( HASH(Table) *ht, HASH_KEY _key HASH_DATA_ARG ,HASH_VAL _hash); HASH_EXTERN void HASH(TablePush) ( HASH(Table) *ht, HASH_KEY _key HASH_DATA_ARG); /* Push a value on to the table */ /* Return 1 if a new value was added */ HASH_EXTERN int HASH(TableAdd_) (HASH(Table) *ht, HASH_KEY _key HASH_DATA_ARG ,HASH_VAL _hash); HASH_EXTERN int HASH(TableAdd) (HASH(Table) *ht, HASH_KEY _key HASH_DATA_ARG); /* Return 1 if a value exists */ HASH_EXTERN int HASH(TableIsSet_) (HASH(Table) *ht, HASH_KEY _key, HASH_VAL _hash); HASH_EXTERN int HASH(TableIsSet) (HASH(Table) *ht, HASH_KEY _key); /* Return a pointer to the data for _key, or 0 if not set */ HASH_EXTERN HASH_DATA * HASH(TableGet_) (HASH(Table) *ht, HASH_KEY _key, HASH_VAL _hash); HASH_EXTERN HASH_DATA * HASH(TableGet) (HASH(Table) *ht, HASH_KEY _key); /* Return 1 if a value was removed */ HASH_EXTERN int HASH(TableRemove_) (HASH(Table) *ht, HASH_KEY _key, HASH_VAL _hash); HASH_EXTERN int HASH(TableRemove) (HASH(Table) *ht, HASH_KEY _key); /* Dump hash table stats to fp. */ HASH_EXTERN void HASH(TableStats) (HASH(Table) *ht, FILE *fp); /* ** Iterators: ** ** HASH(TableIterator) i; ** HASH(TableIteratorInit)(ht, &i) ** while ( HASH(TableInteratorNext)(ht, &i) ) { ** HASH_KEY key = *HASH(TableIteratorKey)(ht, &i); ** HASH_DATA data = *HASH(TableIteratorData)(ht, &i); ** } */ HASH_EXTERN void HASH(TableIteratorInit)(HASH(Table) *ht, HASH(TableIterator) *i); HASH_EXTERN int HASH(TableIteratorNext)(HASH(Table) *ht, HASH(TableIterator) *i); HASH_EXTERN HASH_KEY *HASH(TableIteratorKey)(HASH(Table) *ht, HASH(TableIterator) *i); HASH_EXTERN HASH_DATA *HASH(TableIteratorData)(HASH(Table) *ht, HASH(TableIterator) *i); hash0.5/src/hash/hash.h0100644000175200017560000000055007000561314015267 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_hash_hash_h__ #define __rcs_id_hash_hash_h__ static const char __rcs_id_hash_hash_h[] = "$Id: hash.h,v 1.4 1999/10/12 07:27:08 stephensk Exp $"; #endif #endif /* __rcs_id__ */ /* ** Template Hash Table ** Copyright 1998, 1999, Kurt A. Stephens, http://www.acm.org/~stephensk */ #include "hash.def" #include "hash_end.def" hash0.5/src/hash/hash_end.def0100644000175200017560000000176407010261045016433 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_hash_hash_end_def__ #define __rcs_id_hash_hash_end_def__ static const char __rcs_id_hash_hash_end_def[] = "$Id: hash_end.def,v 1.5 1999/11/04 10:38:29 stephensk Exp $"; #endif #endif /* __rcs_id__ */ /* ** Template Hash Table ** Copyright 1998, 1999, Kurt A. Stephens, http://www.acm.org/~stephensk */ #undef HASH #undef HASH_EXTERN #undef HASH_VAL #undef HASH_KEY #undef HASH_KEY_SET #undef HASH_KEY_FREE #undef HASH_KEY_EQUAL #undef HASH_KEY_HASH #ifdef HASH_DATA #undef HASH_DATA #undef HASH_DATA_SET #undef HASH_DATA_FREE #endif #undef HASH_TABLE_DATA #undef HASH_TABLE_COLLISIONS #undef HASH_TABLE_COLLISIONS_THRESHOLD #ifdef HASH_TABLE_COLLISIONS_THRESHOLD_CHECK #undef HASH_TABLE_COLLISIONS_THRESHOLD_CHECK #endif #ifdef HASH_TABLE_NEW_CAPACITY #undef HASH_TABLE_NEW_CAPACITY #endif #undef HASH_SEARCH_MOVE_TO_FRONT #undef HASH_TABLE_AUTO_RESIZE #undef HASH_TABLE_NENTRIES #undef HASH_TABLE_SIZE #undef HASH_TABLE_SIZE_TO_PRIME #undef HASH_KEEP_HASH #undef HASH_CACHE hash0.5/src/hash/int_voidP_Table.c0100644000175200017560000000127007010261045017400 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_hash_int_voidP_Table_c__ #define __rcs_id_hash_int_voidP_Table_c__ static const char __rcs_id_hash_int_voidP_Table_c[] = "$Id: int_voidP_Table.c,v 1.3 1999/11/04 10:38:29 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include #include static unsigned int inthash(int _x) { const unsigned char *x = (const char*) &_x; unsigned int hash = x[0]; #define DO_HASH(i) hash ^= (hash << 15) | (hash >> 1) ^ x[i] switch ( sizeof(_x) ) { default: case 4: DO_HASH(3); case 3: DO_HASH(2); case 2: DO_HASH(1); } #undef DO_HASH return hash; } #include "int_voidP_Table.def" #include "hash.c" hash0.5/src/hash/int_voidP_Table.def0100644000175200017560000000057006663227026017734 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_hash_int_voidP_Table_def__ #define __rcs_id_hash_int_voidP_Table_def__ static const char __rcs_id_hash_int_voidP_Table_def[] = "$Id: int_voidP_Table.def,v 1.2 1999/02/19 09:25:42 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define HASH(X)int_voidP_##X #define HASH_KEY int #define HASH_KEY_HASH(X) inthash(X) #define HASH_DATA void* hash0.5/src/hash/int_voidP_Table.h0100644000175200017560000000056706663227027017434 0ustar stephensstepheng#ifndef _int_voidP_Table_h #ifndef __rcs_id__ #ifndef __rcs_id_hash_int_voidP_Table_h__ #define __rcs_id_hash_int_voidP_Table_h__ static const char __rcs_id_hash_int_voidP_Table_h[] = "$Id: int_voidP_Table.h,v 1.2 1999/02/19 09:25:43 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define _int_voidP_Table_h #include "int_voidP_Table.def" #include "hash/hash.h" #endif hash0.5/src/hash/voidP_voidP_Table.c0100644000175200017560000000130707010261046017671 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_hash_voidP_voidP_Table_c__ #define __rcs_id_hash_voidP_voidP_Table_c__ static const char __rcs_id_hash_voidP_voidP_Table_c[] = "$Id: voidP_voidP_Table.c,v 1.2 1999/11/04 10:38:30 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include #include static unsigned int voidP_hash(void *_x) { const unsigned char *x = (const char*) &_x; unsigned int hash = x[0]; #define DO_HASH(i) hash ^= (hash << 15) | (hash >> 1) ^ x[i] switch ( sizeof(_x) ) { default: case 4: DO_HASH(3); case 3: DO_HASH(2); case 2: DO_HASH(1); } #undef DO_HASH return hash; } #include "voidP_voidP_Table.def" #include "hash.c" hash0.5/src/hash/voidP_voidP_Table.def0100644000175200017560000000060706707530134020220 0ustar stephensstepheng #ifndef __rcs_id__ #ifndef __rcs_id_hash_voidP_voidP_Table_def__ #define __rcs_id_hash_voidP_voidP_Table_def__ static const char __rcs_id_hash_voidP_voidP_Table_def[] = "$Id: voidP_voidP_Table.def,v 1.1 1999/04/22 05:15:08 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #define HASH(X)voidP_voidP_##X #define HASH_KEY void* #define HASH_KEY_HASH(X) voidP_hash(X) #define HASH_DATA void* hash0.5/src/hash/voidP_voidP_Table.h0100644000175200017560000000060406707530133017705 0ustar stephensstepheng#ifndef _voidP_voidP_Table_h #define _voidP_voidP_Table_h #ifndef __rcs_id__ #ifndef __rcs_id_hash_voidP_voidP_Table_h__ #define __rcs_id_hash_voidP_voidP_Table_h__ static const char __rcs_id_hash_voidP_voidP_Table_h[] = "$Id: voidP_voidP_Table.h,v 1.1 1999/04/22 05:15:07 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include "voidP_voidP_Table.def" #include "hash/hash.h" #endif hash0.5/src/hash/test/0040755000175200017560000000000007236675452015201 5ustar stephensstephenghash0.5/src/hash/test/CVS/0040755000175200017560000000000007236675452015634 5ustar stephensstephenghash0.5/src/hash/test/CVS/Root0100644000175200017560000000003407236675452016474 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/hash/test/CVS/Repository0100644000175200017560000000002707236675452017732 0ustar stephensstephenghome/ion/src/hash/test hash0.5/src/hash/test/CVS/Entries0100644000175200017560000000012207236675452017160 0ustar stephensstepheng/Makefile/1.3/Tue Oct 12 07:27:08 1999// /test.c/1.3/Tue Oct 12 07:27:08 1999// D hash0.5/src/hash/test/Makefile0100644000175200017560000000051507000561314016613 0ustar stephensstepheng# $Id: Makefile,v 1.3 1999/10/12 07:27:08 stephensk Exp $ C_FILES = ../charP_int_Table.c CFLAGS = -I.. -I../.. -g O_FILES = $(C_FILES:.c=.o) EXE=.exe test$(EXE) : test.c $(O_FILES) $(CC) $(CFLAGS) -o $@ test.c $(O_FILES) $(O_FILES) : $(MAKE) -C .. run_test : test$(EXE) test$(EXE) debug_test : test$(EXE) gdb test$(EXE) hash0.5/src/hash/test/test.c0100644000175200017560000000110107000561314016266 0ustar stephensstepheng#ifndef __rcs_id__ #ifndef __rcs_id_test_test_c__ #define __rcs_id_test_test_c__ static const char __rcs_id_test_test_c[] = "$Id: test.c,v 1.3 1999/10/12 07:27:08 stephensk Exp $"; #endif #endif /* __rcs_id__ */ #include #include #include #include "charP_int_Table.h" int main(int argc, char **argv) { charP_int_Table _t, *t = &_t; charP_int_TableInit(t, 5); charP_int_TableAdd(t, "foo", 4); assert(*charP_int_TableGet(t, "foo") == 4); charP_int_TableRemove(t, "foo"); assert(charP_int_TableGet(t, "foo") == 0); return 0; } hash0.5/src/util/0040755000175200017560000000000007306140040014226 5ustar stephensstephenghash0.5/src/util/CVS/0040755000175200017560000000000007270653774014710 5ustar stephensstephenghash0.5/src/util/CVS/Root0100644000175200017560000000003407236675453015550 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/util/CVS/Repository0100644000175200017560000000002207236675453017001 0ustar stephensstephenghome/ion/src/util hash0.5/src/util/CVS/Entries0100644000175200017560000000341607270653774016245 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// hash0.5/src/util/ConfigInfo.c0100644000175200017560000005104607034310640016421 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 */ hash0.5/src/util/ConfigInfo.h0100644000175200017560000001133206702204465016430 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 hash0.5/src/util/Makefile0100644000175200017560000000207107034310640015666 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 > $@ ################################################################# hash0.5/src/util/Makefile.use0100644000175200017560000000012606663227126016475 0ustar stephensstepheng# $Id: Makefile.use,v 1.2 1999/02/19 09:26:46 stephensk Exp $ LIBS:=ionutil $(LIBS) hash0.5/src/util/PKG0100644000175200017560000000037106714556315014612 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" hash0.5/src/util/bitset.h0100644000175200017560000000131007035332101015661 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 hash0.5/src/util/charset.c0100644000175200017560000001073306774730670016052 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 hash0.5/src/util/charset.h0100644000175200017560000000165706707533613016056 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 hash0.5/src/util/enum.c0100644000175200017560000000655607037355513015365 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; } } hash0.5/src/util/enum.h0100644000175200017560000000142607037354763015367 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 hash0.5/src/util/errlist.h0100644000175200017560000000027007037332567016101 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 hash0.5/src/util/errlist.pl0100644000175200017560000000125407005436061016255 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; hash0.5/src/util/file.c0100644000175200017560000002664607236200232015326 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; } hash0.5/src/util/file.h0100644000175200017560000000237407236200232015323 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 hash0.5/src/util/host.c0100644000175200017560000000213107034310640015344 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; } hash0.5/src/util/host.h0100644000175200017560000000051707034312207015360 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 hash0.5/src/util/lockfile.c0100644000175200017560000001322607034310640016166 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; } hash0.5/src/util/lockfile.h0100644000175200017560000000141506727377373016220 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 hash0.5/src/util/lockfile_main.c0100644000175200017560000000166506727377403017220 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; } hash0.5/src/util/mem.c0100644000175200017560000000611206663227127015166 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 } hash0.5/src/util/mem.h0100644000175200017560000000107706735700336015176 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 hash0.5/src/util/midi.h0100644000175200017560000000352307001140704015320 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, "") hash0.5/src/util/outbuf.c0100644000175200017560000000345507034310640015705 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; } hash0.5/src/util/outbuf.h0100644000175200017560000000132606774730270015724 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 hash0.5/src/util/path.c0100644000175200017560000000506106735700336015344 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; } hash0.5/src/util/path.h0100644000175200017560000000121306663227127015346 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 hash0.5/src/util/port.c0100644000175200017560000000161007034310640015354 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; } } hash0.5/src/util/port.h0100644000175200017560000000035407034312207015366 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 hash0.5/src/util/prime.c0100644000175200017560000001041607037351516015522 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 hash0.5/src/util/prime.h0100644000175200017560000000060407037351060015517 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 hash0.5/src/util/rc4.c0100644000175200017560000000225007106156652015074 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; } hash0.5/src/util/rc4.h0100644000175200017560000000061707106156652015106 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 hash0.5/src/util/setenv.c0100644000175200017560000000244506702204466015714 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; } hash0.5/src/util/setenv.h0100644000175200017560000000057106702204466015717 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 hash0.5/src/util/sig.c0100644000175200017560000000250107034305357015163 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; } hash0.5/src/util/sig.h0100644000175200017560000000053407034305357015174 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 hash0.5/src/util/sigs.pl0100644000175200017560000000102507034305357015537 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; hash0.5/src/util/ssprintf.c0100644000175200017560000000373707034310640016254 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; } hash0.5/src/util/ssprintf.h0100644000175200017560000000052106707527215016263 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 hash0.5/src/util/test/0040755000175200017560000000000007236675453015234 5ustar stephensstephenghash0.5/src/util/test/CVS/0040755000175200017560000000000007236675453015667 5ustar stephensstephenghash0.5/src/util/test/CVS/Root0100644000175200017560000000003407236675453016527 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/util/test/CVS/Repository0100644000175200017560000000002707236675453017765 0ustar stephensstephenghome/ion/src/util/test hash0.5/src/util/test/CVS/Entries0100644000175200017560000000013607236675453017220 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 hash0.5/src/util/test/ConfigTest.c0100644000175200017560000000225006714565273017437 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; } hash0.5/src/util/test/ConfigTest.cfg0100644000175200017560000000005406714565273017754 0ustar stephensstepheng#ConfigTest.cfg config1 1 2 3 config2 1 2 3 hash0.5/src/util/refcntptr.hh0100644000175200017560000000511407267632146016577 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 hash0.5/src/util/refcntptr.cc0100644000175200017560000000242507263152105016553 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 hash0.5/src/util/memcpy.h0100644000175200017560000000071107263231170015674 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 hash0.5/src/util/nurbs.c0100644000175200017560000000544607270651343015546 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 hash0.5/src/util/nurbs.h0100644000175200017560000000206707270651343015547 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 hash0.5/src/maks/0040755000175200017560000000000007306140040014204 5ustar stephensstephenghash0.5/src/maks/CVS/0040755000175200017560000000000007262562005014651 5ustar stephensstephenghash0.5/src/maks/CVS/Root0100644000175200017560000000003407236675452015525 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/maks/CVS/Repository0100644000175200017560000000002207236675452016756 0ustar stephensstephenghome/ion/src/maks hash0.5/src/maks/CVS/Entries0100644000175200017560000000056207262562005016205 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// hash0.5/src/maks/PKG0100744000175200017560000000031607262415714014564 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" hash0.5/src/maks/basic.mak0100744000175200017560000001046707262562266016010 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 hash0.5/src/maks/fixpound.pl0100644000175200017560000000025406663227051016410 0ustar stephensstepheng# $Id: fixpound.pl,v 1.2 1999/02/19 09:26:01 stephensk Exp $ while ( <> ) { chop; if ( /^#/ ) { print "/* ", $_, "*/\n"; } else { print $_, "\n"; } } hash0.5/src/maks/lib.mak0100744000175200017560000000430607262415714015463 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 hash0.5/src/maks/pre.mak0100744000175200017560000001501307262415714015500 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 hash0.5/src/maks/tool.mak0100644000175200017560000000316307065630434015670 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 hash0.5/src/maks/tools.mak0100644000175200017560000000032406765637251016061 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 hash0.5/src/maks/use.mak0100744000175200017560000000075607262415714015516 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 hash0.5/src/maks/bin/0040755000175200017560000000000007236675452015002 5ustar stephensstephenghash0.5/src/maks/bin/CVS/0040755000175200017560000000000007236675452015435 5ustar stephensstephenghash0.5/src/maks/bin/CVS/Root0100644000175200017560000000003407236675452016275 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/maks/bin/CVS/Repository0100644000175200017560000000002607236675452017532 0ustar stephensstephenghome/ion/src/maks/bin hash0.5/src/maks/bin/CVS/Entries0100644000175200017560000000011607236675452016764 0ustar stephensstepheng/mak/1.2/Mon Jun 28 14:03:33 1999// /mak.bat/1.3/Mon Jun 28 14:03:33 1999// D hash0.5/src/maks/bin/mak0100644000175200017560000000064206735700265015466 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+"$@"} hash0.5/src/maks/bin/mak.bat0100644000175200017560000000015206735700265016227 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 hash0.5/src/maks/opengl/0040755000175200017560000000000007262533466015513 5ustar stephensstephenghash0.5/src/maks/opengl/CVS/0040755000175200017560000000000007262562005016135 5ustar stephensstephenghash0.5/src/maks/opengl/CVS/Root0100644000175200017560000000003407236675452017011 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/maks/opengl/CVS/Repository0100644000175200017560000000003107236675452020242 0ustar stephensstephenghome/ion/src/maks/opengl hash0.5/src/maks/opengl/CVS/Entries0100644000175200017560000000013007262562005017460 0ustar stephensstepheng/Makefile/1.2/Fri Feb 19 09:26:02 1999// /Makefile.use/1.4/Wed Apr 4 09:09:10 2001// D hash0.5/src/maks/opengl/Makefile0100644000175200017560000000011306663227052017136 0ustar stephensstepheng# $Id: Makefile,v 1.2 1999/02/19 09:26:02 stephensk Exp $ all : clean : hash0.5/src/maks/opengl/Makefile.use0100644000175200017560000000075707262562266017754 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)# hash0.5/src/maks/os/0040755000175200017560000000000007236675452014653 5ustar stephensstephenghash0.5/src/maks/os/CVS/0040755000175200017560000000000007236675452015306 5ustar stephensstephenghash0.5/src/maks/os/CVS/Root0100644000175200017560000000003407236675452016146 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/maks/os/CVS/Repository0100644000175200017560000000002507236675452017402 0ustar stephensstephenghome/ion/src/maks/os hash0.5/src/maks/os/CVS/Entries0100644000175200017560000000021207236675452016632 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 hash0.5/src/maks/os/CYGWIN.mak0100644000175200017560000000013007037332731016321 0ustar stephensstepheng# $Id: CYGWIN.mak,v 1.1 2000/01/13 11:24:09 stephensk Exp $ # CYGWIN (generic) exe=.exe hash0.5/src/maks/os/CYGWIN_98-4.10.mak0100644000175200017560000000016407037332731017230 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 hash0.5/src/maks/os/Linux.mak0100644000175200017560000000011507037332732016424 0ustar stephensstepheng# $Id: Linux.mak,v 1.1 2000/01/13 11:24:10 stephensk Exp $ # Linux-specifics hash0.5/src/maks/win32/0040755000175200017560000000000007236675452015174 5ustar stephensstephenghash0.5/src/maks/win32/CVS/0040755000175200017560000000000007236675452015627 5ustar stephensstephenghash0.5/src/maks/win32/CVS/Root0100644000175200017560000000003407236675452016467 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/maks/win32/CVS/Repository0100644000175200017560000000003007236675452017717 0ustar stephensstephenghome/ion/src/maks/win32 hash0.5/src/maks/win32/CVS/Entries0100644000175200017560000000013007236675452017152 0ustar stephensstepheng/Makefile/1.2/Fri Feb 19 09:26:02 1999// /Makefile.use/1.2/Fri Feb 19 09:26:02 1999// D hash0.5/src/maks/win32/Makefile0100644000175200017560000000011306663227052016614 0ustar stephensstepheng# $Id: Makefile,v 1.2 1999/02/19 09:26:02 stephensk Exp $ all : clean : hash0.5/src/maks/win32/Makefile.use0100644000175200017560000000014506663227052017414 0ustar stephensstepheng# $Id: Makefile.use,v 1.2 1999/02/19 09:26:02 stephensk Exp $ LIBS := kernel32 user32 gdi32 $(LIBS) hash0.5/src/bin/0040755000175200017560000000000007306140040014021 5ustar stephensstephenghash0.5/src/bin/CVS/0040755000175200017560000000000007306135474014473 5ustar stephensstephenghash0.5/src/bin/CVS/Root0100644000175200017560000000003407236675451015341 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/bin/CVS/Repository0100644000175200017560000000002107236675451016571 0ustar stephensstephenghome/ion/src/bin hash0.5/src/bin/CVS/Entries0100644000175200017560000000343107306135474016025 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// hash0.5/src/bin/PKG0100644000175200017560000000034606662461243014404 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" hash0.5/src/bin/addcr0100644000175200017560000002206706662645172015051 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; hash0.5/src/bin/addrcsid.pl0100644000175200017560000000647106735677357016177 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; hash0.5/src/bin/ccinfo0100644000175200017560000001177606662461243015235 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); hash0.5/src/bin/ccloclibs0100644000175200017560000000576306662461243015730 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); hash0.5/src/bin/ctocnl.c0100644000175200017560000000056406663227006015466 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; } hash0.5/src/bin/cvschrep.pl0100744000175200017560000000234707230344122016202 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; hash0.5/src/bin/cvschroot.pl0100644000175200017560000000204606662641265016412 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; hash0.5/src/bin/cvsclean0100644000175200017560000000054007003453703015545 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 hash0.5/src/bin/cvsedited0100644000175200017560000000051307001176323015717 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" hash0.5/src/bin/cvsfind.pl0100644000175200017560000000253507003453703016023 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; hash0.5/src/bin/cvsretag.pl0100644000175200017560000000225106765647617016227 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; hash0.5/src/bin/cvsrevhist.pl0100644000175200017560000000676307065620426016604 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; hash0.5/src/bin/cwfixlib.pl0100644000175200017560000000166106663227006016203 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; hash0.5/src/bin/d2u.pl0100744000175200017560000000570207230344164015063 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; hash0.5/src/bin/ecd0100644000175200017560000000130506662461243014512 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 hash0.5/src/bin/fe0100644000175200017560000000027606662461244014360 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 hash0.5/src/bin/findsource0100644000175200017560000000014706662461244016124 0ustar stephensstepheng#!/bin/sh find $* \( \( -name '*.rtf*' -o -name '*.nib' \) -prune -print \) -o \( \! -type d -print \) hash0.5/src/bin/igrep0100644000175200017560000001464606774727305015111 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; hash0.5/src/bin/linkdups0100644000175200017560000000120706662461243015611 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 hash0.5/src/bin/locstatic0100644000175200017560000000253106662461244015747 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; hash0.5/src/bin/lsup0100644000175200017560000000040306774730305014742 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 hash0.5/src/bin/mergefiles.pl0100644000175200017560000001452506663227006016521 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; hash0.5/src/bin/mkindex0100644000175200017560000000365506774727305015440 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; hash0.5/src/bin/mvr.pl0100644000175200017560000000331307001176324015165 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; hash0.5/src/bin/nmlibs0100644000175200017560000000042706662461243015247 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 hash0.5/src/bin/nmm0100755000175200017560000000010006662461243014541 0ustar stephensstepheng#!/bin/sh for f do nm "$f" | awk '{ print "'$f'", $0; }' done hash0.5/src/bin/objcsyms0100644000175200017560000000457306662461244015623 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 hash0.5/src/bin/publish.pl0100644000175200017560000004341507306137336016046 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; hash0.5/src/bin/sci0100644000175200017560000000561506662461244014546 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 hash0.5/src/bin/scip0100644000175200017560000000640006662461244014717 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; hash0.5/src/bin/si0100644000175200017560000000013407001136307014355 0ustar stephensstepheng#!/bin/sh #set -x echo '#include "'"$1"'"' | gcc -E - | awk 'NF' | egrep -v -e '^#' | less hash0.5/src/bin/split.c0100644000175200017560000000450606663227006015337 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; } hash0.5/src/bin/tgz0100744000175200017560000000445607230344242014565 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 hash0.5/src/bin/ts0100644000175200017560000000316707065620573014416 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 donehash0.5/src/bin/uud0100744000175200017560000000417207262415712014557 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; hash0.5/src/bin/uudindex0100744000175200017560000000711507262415713015610 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; hash0.5/src/bin/which0100644000175200017560000000113606662461244015064 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" hash0.5/src/bin/whichall0100644000175200017560000000014306662461244015552 0ustar stephensstepheng#!/bin/sh for d in `echo $PATH|tr ':' ' '` do if [ -x $d/$1 ] then echo "$d/$1" fi done hash0.5/src/bin/wwwsend0100644000175200017560000000336106662461243015461 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." hash0.5/src/bin/addcr.t/0040755000175200017560000000000007236675451015365 5ustar stephensstephenghash0.5/src/bin/addcr.t/CVS/0040755000175200017560000000000007236675451016020 5ustar stephensstephenghash0.5/src/bin/addcr.t/CVS/Root0100644000175200017560000000003407236675451016660 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/bin/addcr.t/CVS/Repository0100644000175200017560000000003107236675451020111 0ustar stephensstephenghome/ion/src/bin/addcr.t hash0.5/src/bin/addcr.t/CVS/Entries0100644000175200017560000000006107236675451017346 0ustar stephensstepheng/run/1.1/Wed Feb 17 23:02:18 1999// D/backup//// hash0.5/src/bin/addcr.t/run0100644000175200017560000000021706662645172016110 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]* hash0.5/src/bin/addcr.t/backup/0040755000175200017560000000000007236675451016632 5ustar stephensstephenghash0.5/src/bin/addcr.t/backup/CVS/0040755000175200017560000000000007236675451017265 5ustar stephensstephenghash0.5/src/bin/addcr.t/backup/CVS/Root0100644000175200017560000000003407236675451020125 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/bin/addcr.t/backup/CVS/Repository0100644000175200017560000000004007236675451021356 0ustar stephensstephenghome/ion/src/bin/addcr.t/backup hash0.5/src/bin/addcr.t/backup/CVS/Entries0100644000175200017560000000023307236675451020614 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 hash0.5/src/bin/addcr.t/backup/t1.c0100644000175200017560000000040406663227007017306 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 hash0.5/src/bin/addcr.t/backup/t20100644000175200017560000000002406662461244017066 0ustar stephensstepheng#!/bin/sh #L1 L2 L3 hash0.5/src/bin/addcr.t/backup/t30100644000175200017560000000005106662461244017067 0ustar stephensstepheng#!/usr/local/bin/scheme ; L1 L2 L3 hash0.5/src/bin/addcr.t/backup/t40100644000175200017560000000057306662645173017106 0ustar stephensstephengLèV.textD+Üâ» `.data ,bý|@À.bss€À.stab,% 1:+R.stabstrÆ‹LVRopportobj_writePortbooleanU‰å¡‹P‰ÐÁøƒø~¡‹P‰ÐÁøƒøëèè‰Â‰ÐëÉÃ#f#t‰öU‰åƒìS¡‰Eü‹Eü‹‹J‰ÊÁúJý‹ˉ]ø‹Eü‹Â‹ hash0.5/src/bin/lib/0040755000175200017560000000000007236675451014614 5ustar stephensstephenghash0.5/src/bin/lib/CVS/0040755000175200017560000000000007236675451015247 5ustar stephensstephenghash0.5/src/bin/lib/CVS/Root0100644000175200017560000000003407236675451016107 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/bin/lib/CVS/Repository0100644000175200017560000000002507236675451017343 0ustar stephensstephenghome/ion/src/bin/lib hash0.5/src/bin/lib/CVS/Entries0100644000175200017560000000001307236675451016572 0ustar stephensstephengD/perl//// hash0.5/src/bin/lib/perl/0040755000175200017560000000000007236675451015556 5ustar stephensstephenghash0.5/src/bin/lib/perl/CVS/0040755000175200017560000000000007236675451016211 5ustar stephensstephenghash0.5/src/bin/lib/perl/CVS/Root0100644000175200017560000000003407236675451017051 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/bin/lib/perl/CVS/Repository0100644000175200017560000000003207236675451020303 0ustar stephensstephenghome/ion/src/bin/lib/perl hash0.5/src/bin/lib/perl/CVS/Entries0100644000175200017560000000001207236675451017533 0ustar stephensstephengD/ion//// hash0.5/src/bin/lib/perl/ion/0040755000175200017560000000000007236675451016343 5ustar stephensstephenghash0.5/src/bin/lib/perl/ion/CVS/0040755000175200017560000000000007236675451016776 5ustar stephensstephenghash0.5/src/bin/lib/perl/ion/CVS/Root0100644000175200017560000000003407236675451017636 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/bin/lib/perl/ion/CVS/Repository0100644000175200017560000000003607236675451021074 0ustar stephensstephenghome/ion/src/bin/lib/perl/ion hash0.5/src/bin/lib/perl/ion/CVS/Entries0100644000175200017560000000001307236675451020321 0ustar stephensstephengD/_cvs//// hash0.5/src/bin/lib/perl/ion/_cvs/0040755000175200017560000000000007306123713017260 5ustar stephensstephenghash0.5/src/bin/lib/perl/ion/_cvs/CVS/0040755000175200017560000000000007306135474017722 5ustar stephensstephenghash0.5/src/bin/lib/perl/ion/_cvs/CVS/Root0100644000175200017560000000003407236675451020570 0ustar stephensstepheng:local://cvs/ioncvs/cvsroot hash0.5/src/bin/lib/perl/ion/_cvs/CVS/Repository0100644000175200017560000000004307236675451022024 0ustar stephensstephenghome/ion/src/bin/lib/perl/ion/_cvs hash0.5/src/bin/lib/perl/ion/_cvs/CVS/Entries0100644000175200017560000000017307306135474021254 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 hash0.5/src/bin/lib/perl/ion/_cvs/entry.pm0100644000175200017560000000210607065621014020752 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; hash0.5/src/bin/lib/perl/ion/_cvs/find.pm0100644000175200017560000000634007306135474020545 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; hash0.5/src/bin/lib/perl/ion/_cvs/rlog.pm0100644000175200017560000001167406670454343020600 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; hash0.5/src/bin/dos2unix.c0100644000175200017560000000047005551357511015753 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; } hash0.5/src/bin/swig2def.pl0100744000175200017560000000066407262414406016107 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; hash0.5/src/bin/.#uud.1.20100744000175200017560000000417207245406670015203 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; hash0.5/src/bin/.#uudindex.1.20100744000175200017560000000711507245406752016234 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; hash0.5/src/bin/cvsfix.pl0100644000175200017560000000222007264417364015674 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; hash0.5/src/GUM_BUILD_ROOT0100644000175200017560000000060607306140040015405 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# hash0.5/README0100644000175200017560000000141207306140040013335 0ustar stephensstephenghash 0.5 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 $ ============================================================================== hash0.5/COPYRIGHT0100644000175200017560000000113107306140040013746 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 $ hash0.5/CHANGES0100644000175200017560000000014107306140040013446 0ustar stephensstephenghash 0.5 CHANGES ============================================================================== hash0.5/TOC0100644000175200017560000004657307306140044013052 0ustar stephensstephenghash 0.5 Table of Contents ============================================================================== hash0.5: total 7 drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:29 . drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:29 .. -rw-r--r-- 1 stephens stepheng 97 Jun 2 05:29 CHANGES -rw-r--r-- 1 stephens stepheng 601 Jun 2 05:29 COPYRIGHT -rw-r--r-- 1 stephens stepheng 778 Jun 2 05:29 README -rw-r--r-- 1 stephens stepheng 106 Jun 2 05:29 TOC drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:29 src hash0.5/src: total 7 drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:29 . drwxr-xr-x 3 stephens stepheng 1024 Jun 2 05:29 .. -rw-r--r-- 1 stephens stepheng 390 Jun 2 05:29 GUM_BUILD_ROOT drwxr-xr-x 5 stephens stepheng 1024 Jun 2 05:29 bin drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:29 hash drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:29 maks drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:29 util hash0.5/src/bin: total 134 drwxr-xr-x 5 stephens stepheng 1024 Jun 2 05:29 . -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:29 .. 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 hash0.5/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:29 .. -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 hash0.5/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:29 .. 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 hash0.5/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 hash0.5/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 hash0.5/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 hash0.5/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:29 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS drwxr-xr-x 4 stephens stepheng 1024 Feb 2 21:29 perl hash0.5/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 hash0.5/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 hash0.5/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 hash0.5/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 hash0.5/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 hash0.5/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 hash0.5/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 hash0.5/src/hash: total 44 drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:29 . drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:29 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS -rw-r--r-- 1 stephens stepheng 371 Apr 22 1999 Makefile -rw-r--r-- 1 stephens stepheng 223 Oct 13 1999 PKG -rw-r--r-- 1 stephens stepheng 474 Nov 4 1999 charP_hash.c -rw-r--r-- 1 stephens stepheng 393 Nov 4 1999 charP_int_Table.c -rw-r--r-- 1 stephens stepheng 594 Apr 22 1999 charP_int_Table.def -rw-r--r-- 1 stephens stepheng 375 Feb 19 1999 charP_int_Table.h -rw-r--r-- 1 stephens stepheng 404 Nov 4 1999 charP_voidP_Table.c -rw-r--r-- 1 stephens stepheng 616 Apr 22 1999 charP_voidP_Table.def -rw-r--r-- 1 stephens stepheng 389 Feb 19 1999 charP_voidP_Table.h -rw-r--r-- 1 stephens stepheng 299 Feb 19 1999 generic_Table.c -rw-r--r-- 1 stephens stepheng 804 Feb 19 1999 generic_Table.def -rw-r--r-- 1 stephens stepheng 361 Feb 19 1999 generic_Table.h -rw-r--r-- 1 stephens stepheng 11487 Nov 4 1999 hash.c -rw-r--r-- 1 stephens stepheng 7997 Nov 4 1999 hash.def -rw-r--r-- 1 stephens stepheng 360 Oct 12 1999 hash.h -rw-r--r-- 1 stephens stepheng 1012 Nov 4 1999 hash_end.def -rw-r--r-- 1 stephens stepheng 696 Nov 4 1999 int_voidP_Table.c -rw-r--r-- 1 stephens stepheng 376 Feb 19 1999 int_voidP_Table.def -rw-r--r-- 1 stephens stepheng 375 Feb 19 1999 int_voidP_Table.h drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 test -rw-r--r-- 1 stephens stepheng 711 Nov 4 1999 voidP_voidP_Table.c -rw-r--r-- 1 stephens stepheng 391 Apr 22 1999 voidP_voidP_Table.def -rw-r--r-- 1 stephens stepheng 388 Apr 22 1999 voidP_voidP_Table.h hash0.5/src/hash/CVS: total 6 drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:29 .. -rw-r--r-- 1 stephens stepheng 1063 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 hash0.5/src/hash/test: total 5 drwxr-xr-x 3 stephens stepheng 1024 Feb 2 21:29 . drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:29 .. drwxr-xr-x 2 stephens stepheng 1024 Feb 2 21:29 CVS -rw-r--r-- 1 stephens stepheng 333 Oct 12 1999 Makefile -rw-r--r-- 1 stephens stepheng 577 Oct 12 1999 test.c hash0.5/src/hash/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 82 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 hash0.5/src/maks: total 28 drwxr-xr-x 7 stephens stepheng 1024 Jun 2 05:29 . drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:29 .. 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 hash0.5/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:29 .. -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 hash0.5/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:29 .. 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 hash0.5/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 hash0.5/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:29 .. 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 hash0.5/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 hash0.5/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:29 .. 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 hash0.5/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 hash0.5/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:29 .. 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 hash0.5/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 hash0.5/src/util: total 120 drwxr-xr-x 4 stephens stepheng 1024 Jun 2 05:29 . drwxr-xr-x 6 stephens stepheng 1024 Jun 2 05:29 .. 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 hash0.5/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:29 .. -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 hash0.5/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:29 .. 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 hash0.5/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