home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / stex2-18.zip / SeeTeX / libtex / search.h < prev    next >
C/C++ Source or Header  |  1990-07-10  |  1KB  |  38 lines

  1. /*
  2.  * Copyright (c) 1987, 1989 University of Maryland
  3.  * Department of Computer Science.  All rights reserved.
  4.  * Permission to copy for any purpose is hereby granted
  5.  * so long as this copyright notice remains intact.
  6.  */
  7.  
  8. /* search structures and routines for 32-bit key, arbitrary data */
  9.  
  10. struct search {
  11.     unsigned s_dsize;    /* data object size (includes key size) */
  12.     unsigned s_space;    /* space left (in terms of objects) */
  13.     unsigned s_n;        /* number of objects in the table */
  14.     char    *s_data;    /* data area */
  15. };
  16.  
  17. /* returns a pointer to the search table (for future search/installs) */
  18. struct    search *SCreate();    /* create a search table */
  19.  
  20. /* returns a pointer to the data object found or created */
  21. char    *SSearch();        /* search for a data object */
  22.  
  23. /* clears a search table (wipes out all entries) */
  24. #define    SClear(s)    ((s)->s_space += (s)->s_n, (s)->s_n = 0)
  25.  
  26. /* the third argument to SSearch controls operation as follows: */
  27. #define    S_LOOKUP    0x00    /* pseudo flag */
  28. #define    S_CREATE    0x01    /* create object if not found */
  29. #define    S_EXCL        0x02    /* complain if already exists */
  30.  
  31. /* in addition, it is modified before return to hold status: */
  32. #define    S_COLL        0x04    /* collision (occurs iff S_EXCL set) */
  33. #define    S_FOUND        0x08    /* found (occurs iff existed already) */
  34. #define    S_NEW        0x10    /* created (occurs iff S_CREATE && !S_EXCL) */
  35. #define    S_ERROR        0x20    /* problem creating (out of memory) */
  36.  
  37. void SEnumerate();
  38.