idf.3 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. .TH IDF 3 "$Revision$"
  2. .ad
  3. .SH NAME
  4. init_idf, str2idf, findidf\ \-\ a namelist module
  5. .SH SYNOPSIS
  6. .PP
  7. .B void init_idf()
  8. .PP
  9. .B struct idf *str2idf(tag, cpy)
  10. .br
  11. .B char *tag;
  12. .PP
  13. .B struct idf *findidf(tag)
  14. .br
  15. .B char *tag;
  16. .SH DESCRIPTION
  17. This is a generic namelist module. It provides a fast mechanism for
  18. associating information with identifiers. To get an instantiation, the
  19. user must provide two files \fIidf.h\fR and \fIidf.c\fR.
  20. \fIidf.h\fR could contain the following:
  21. .br
  22. .PP
  23. .RS
  24. .nf
  25. #define IDF_TYPE struct id_info
  26. #define IDF_HSIZE 8
  27. #include <idf_pkg.spec>
  28. .fi
  29. .RE
  30. .PP
  31. and \fIidf.c\fR could contain:
  32. .br
  33. .PP
  34. .RS
  35. .nf
  36. #include "id_info.h" /* contains definition for struct id_info */
  37. #include "idf.h"
  38. #include <idf_pkg.body>
  39. .fi
  40. .RE
  41. .PP
  42. IDF_TYPE denotes a type containing all information associated with
  43. an identifier. If it is not defined, the instantiation will not contain
  44. any user-defined information.
  45. .PP
  46. IDF_HSIZE denotes the number of significant characters for the hashing
  47. function. It's default value is 64. Notice that this value does \fBnot\fP
  48. denote the number of significant characters, but only the number of characters
  49. that are used for hashing.
  50. .PP
  51. The user can also define IDF_NAME, to give a name to the selector in the
  52. idf-structure. It's default value is \fIid_user\fP.
  53. .PP
  54. The routine \fIinit_idf\fR initializes the namelist.
  55. .PP
  56. The function
  57. \fIstr2idf\fR searches for the string \fItag\fR in the namelist, and
  58. creates an entry for it if necessary. A pointer to this entry is
  59. returned. If \fIcpy\fR is non-zero, a copy of the \fItag\fR is made,
  60. otherwise the \fItag\fR itself is used.
  61. The entry has the following structure, defined in \fIidf_pkg.spec\fR:
  62. .PP
  63. .nf
  64. struct idf {
  65. struct idf *next; \kx/* links idf-structures together */
  66. char *id_text;\h'|\nxu'/* string representing the name */
  67. #ifdef IDF_TYPE
  68. IDF_TYPE IDF_NAME;\h'|\nxu'/* user defined type */
  69. #endif
  70. };
  71. .fi
  72. .PP
  73. The field \fIid_text\fR will point to a copy of \fItag\fR, or
  74. to the \fItag\fR itself, depending on \fIcpy\fR.
  75. The field \fInext\fR is used for internal information and must not
  76. be changed by the user of this module.
  77. The user-defined part of the structure is initialized with zeros.
  78. .PP
  79. The function \fIfindidf\fP searches for the string \fItag\fP in the
  80. namelist, but returns 0 when it is not present.
  81. .SH "MODULES USED"
  82. alloc(3)
  83. .SH FILES
  84. ~em/modules/pkg/idf_pkg.spec
  85. .br
  86. ~em/modules/pkg/idf_pkg.body