home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / NAME.H < prev    next >
C/C++ Source or Header  |  1992-05-18  |  3KB  |  70 lines

  1. /* Copyright (C) 1989, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* name.h */
  21. /* Name table entry structure for Ghostscript */
  22.  
  23. /* Name structure.  The name table is a simple chained hash table. */
  24. /* There is an optimization to avoid lookup for operator and other */
  25. /* global names. */
  26. struct name_s {
  27.     ushort next_index;    /* next name in chain or 0 */
  28.     ushort string_size;
  29.     const byte *string_bytes;
  30. /* pvalue specifies the definition status of the name: */
  31. /*    pvalue == pv_no_defn: no definitions */
  32. #define pv_no_defn ((ref *)0)
  33. /*    pvalue == pv_other: other status */
  34. #define pv_other ((ref *)1)
  35. #define pv_valid(pvalue) ((unsigned long)(pvalue) > 1)
  36. /*    pvalue != pv_no_defn, pvalue != pv_other: pvalue is valid */
  37.     ref *pvalue;        /* if only defined in systemdict */
  38.                 /* or userdict, this points to */
  39.                 /* the value */
  40. };
  41. /*typedef struct name_s name;*/        /* in ghost.h */
  42.  
  43. /* Procedures for the name table. */
  44.  
  45. /* The size argument for name_ref should be a ushort, */
  46. /* but this gets the Apollo compiler confused. */
  47. /* enterflag=-1 means don't enter (return an error if missing); */
  48. /* enterflag=0 means enter if missing, don't copy the string; */
  49. /* enterflag=1 means enter if missing, copy the string. */
  50. extern    int    name_ref(P4(const byte *ptr, uint size, ref *pnref, int enterflag));
  51. extern    void    name_string_ref(P2(const ref *pnref, ref *psref));
  52. extern    void    name_enter(P2(const char *str, ref *pnref));
  53. /* name_from_string essentially implements cvn. */
  54. /* It always enters the name, and copies the executable attribute. */
  55. extern    int    name_from_string(P2(const ref *psref, ref *pnref));
  56.  
  57. /* Compare two names for equality. */
  58. #define name_eq(pnref1, pnref2)\
  59.   (name_index(pnref1) == name_index(pnref2))
  60.  
  61. /* Conversion between names and indices. */
  62. #define name_index(pnref) r_size(pnref)
  63. extern    void    name_index_ref(P2(uint index /* should be ushort */,
  64.                       ref *pnref));
  65. extern    uint    name_count(P0());
  66. extern    int    name_is_since_count(P2(const ref *, uint));
  67.  
  68. /* Clean up the name table before a restore. */
  69. extern    void    name_restore(P1(uint old_count));
  70.