isam.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
  24. /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
  25. /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
  26. /*%% (c) Copyright 1993, 1994 Novell, Inc. */
  27. /*%% $XConsortium: isam.h /main/3 1995/10/23 11:33:51 rswiston $ */
  28. /*
  29. @(#)isam.h
  30. 1.17 90/01/20
  31. SMI */
  32. /*
  33. * Copyright (c) 1988 by Sun Microsystems, Inc.
  34. */
  35. /*
  36. * isam.h
  37. *
  38. * Description:
  39. * isam.h is to be included in NetISAM C application programs.
  40. *
  41. * Make sure all changes in this file are reflected in lib/db/tt_client_isam.h
  42. */
  43. #ifndef _ISAM_H
  44. #define _ISAM_H
  45. #include <limits.h>
  46. #ifndef LONG_BIT
  47. #define LONG_BIT 32
  48. #endif
  49. extern short ldint();
  50. extern long ldlong();
  51. extern float ldfloat();
  52. extern double lddbl();
  53. extern short ldshort();
  54. extern int ldchar(), stchar(), stlong(), stdbl();
  55. extern int stint(short val, char *p);
  56. extern int stfloat(float f, char *p);
  57. extern int iserrno; /* isam error number code */
  58. extern long isrecnum; /* record number of last call */
  59. extern int isreclen; /* used for variable length recs */
  60. extern char isstat1; /* cobol status characters */
  61. extern char isstat2;
  62. #define CHARTYPE 0
  63. #define CHARSIZE 1
  64. #define INTTYPE 1
  65. #define INTSIZE 2
  66. #define LONGTYPE 2
  67. #define LONGSIZE LONG_BIT/8
  68. #define DOUBLETYPE 3
  69. #define DOUBLESIZE 8
  70. #define FLOATTYPE 4
  71. #define FLOATSIZE 4
  72. #define BINTYPE 5
  73. #define BINSIZE 1
  74. #define MINTYPE 0
  75. #define MAXTYPE 6
  76. #define ISDESC 0x80 /* add to make descending type */
  77. #define TYPEMASK 0x7f /* type mask */
  78. #define BYTEMASK 0xff /* mask for one byte */
  79. #define BYTESHFT 8 /* shift for one byte */
  80. /* mode parameter in isread() and isstart() */
  81. #define ISFIRST 0 /* first record */
  82. #define ISLAST 1 /* last record */
  83. #define ISNEXT 2 /* next record */
  84. #define ISPREV 3 /* previous record */
  85. #define ISCURR 4 /* current record */
  86. #define ISEQUAL 5 /* equal value */
  87. #define ISGREAT 6 /* greater value */
  88. #define ISGTEQ 7 /* >= value */
  89. #define ISLESS 8 /* < */
  90. #define ISLTEQ 9 /* <= */
  91. /* isopen, isbuild lock modes */
  92. #define ISAUTOLOCK 0x200 /* automatic record lock */
  93. #define ISMANULOCK 0x400 /* manual record lock */
  94. #define ISEXCLLOCK 0x800 /* exclusive isam file lock */
  95. #define ISFASTLOCK 0x4000 /* no locking when EXCLLOCK! */
  96. /* isread lock modes */
  97. #define ISLOCK 0x100 /* lock record before reading */
  98. #define ISSKIPLOCK 0x1000 /* advance record pointer to */
  99. /* locked record */
  100. /* isstart lock mode for automatic record locking */
  101. #define ISKEEPLOCK 0x2000 /* keep record locked */
  102. /* Fix/Variable length records mode */
  103. #define ISFIXLEN 0
  104. #define ISVARLEN 0x10000
  105. /* Access remote file via NFS */
  106. #define ISNFS 0x20000
  107. #define ISINPUT 0 /* open for input only */
  108. #define ISOUTPUT 1 /* open for output only */
  109. #define ISINOUT 2 /* open for input and output */
  110. #define MAXKEYSIZE 150 /* max number of bytes in key */
  111. #define NPARTS 8 /* max number of key parts */
  112. /*#define ISMAXRECLEN 8192 */ /* Maximum number of bytes in record */
  113. #define ISMAXRECLEN 32767 /* 32K - 1 */
  114. #define ISMINRECLEN 4 /* Minimum number of bytes in record */
  115. struct keypart {
  116. unsigned short kp_start; /* starting byte of key part */
  117. short kp_leng; /* length in bytes */
  118. short kp_type; /* type of key part */
  119. };
  120. struct keydesc {
  121. short k_flags; /* flags */
  122. short k_nparts; /* number of parts in key */
  123. struct keypart k_part[NPARTS]; /* each part */
  124. };
  125. /* The next three defines are for compatibility with X/OPEN */
  126. #define k_start k_part[0].kp_start
  127. #define k_leng k_part[0].kp_leng
  128. #define k_type k_part[0].kp_type
  129. #define ISNODUPS 000 /* no duplicates and */
  130. /* no compression */
  131. #define ISDUPS 001 /* duplicates allowed */
  132. #define COMPRESS 020 /* full compression */
  133. struct dictinfo {
  134. short di_nkeys; /* number of keys defined */
  135. unsigned short di_recsize; /* data record size */
  136. short di_idxsize; /* index record size */
  137. long di_nrecords; /* number of records in file */
  138. };
  139. /* msb in di_nkeys indicates that ISAM file supports variable length records */
  140. #define DICTVARLENBIT 0x8000
  141. /* mask to access the true number of keys */
  142. #define DICTNKEYSMASK (DICTVARLENBIT - 1)
  143. #define ENOERROR 0 /* No error */
  144. #define EDUPL 100 /* duplicate record */
  145. #define ENOTOPEN 101 /* file not open */
  146. #define EBADARG 102 /* illegal argument */
  147. #define EBADKEY 103 /* illegal key desc */
  148. #define ETOOMANY 104 /* too many files open */
  149. #define EBADFILE 105 /* bad ISAM file format */
  150. #define ENOTEXCL 106 /* non-exclusive access */
  151. #define ELOCKED 107 /* record locked */
  152. #define EKEXISTS 108 /* key already exists */
  153. #define EPRIMKEY 109 /* is primary key */
  154. #define EENDFILE 110 /* end/begin of file */
  155. #define ENOREC 111 /* no record found */
  156. #define ENOCURR 112 /* no current record */
  157. #define EFLOCKED 113 /* file locked */
  158. #define EFNAME 114 /* file name too long */
  159. #define EBADMEM 116 /* cannot allocate memory */
  160. /* NetISAM specific error codes non XOPEN compliant*/
  161. #define ETIMEOUT 1117 /* RPC timeout */
  162. #define ERPC 1118 /* Broken TCP/IP */
  163. #define ETCP 1119 /* Cannot connect to server */
  164. #define EIMPORT 1120 /* Cannot import */
  165. #define ENODAEMON 1121 /* no local daemon */
  166. #define EFATAL 1122 /* internal fatal error */
  167. #define ELANG 1123 /* Locale/LANG mismatch */
  168. #define ISOK 0 /* no error return code */
  169. #define ISERROR -1 /* error return code */
  170. extern struct keydesc *nokey; /* May be used as parameter
  171. * to isbuild() if no
  172. * primary key is to be built
  173. */
  174. /* ischeckindex() diagmode values */
  175. #define CHK_NODIAG 0 /* do not print any messages */
  176. #define CHK_DIAG 1 /* Access Level module will print to stderr */
  177. /* values of corrupt parameter of ischeckindex() */
  178. #define CHK_OK 0 /* ISAM file is not corrupted */
  179. #define CHK_DAT 1 /* .dat file is corrupted */
  180. #define CHK_VAR 2 /* .var file is corrupted */
  181. #define CHK_IND 3 /* .ind file is corrupted */
  182. /* iscntl() definitions */
  183. /* For one isfd - use iscntl(isfd, func, ...) */
  184. #define ISCNTL_RPCS_TO_SET 1 /* short oper. timeout (in sec) */
  185. #define ISCNTL_RPCS_TO_GET 2 /* short oper. timeout (in sec) */
  186. #define ISCNTL_RPCL_TO_SET 3 /* long oper. timeout (in sec) */
  187. #define ISCNTL_RPCL_TO_GET 4 /* long oper. timeout (in sec) */
  188. #define ISCNTL_TCP_TO_SET 5 /* timeout to reconnect TCP?IP */
  189. #define ISCNTL_TCP_TO_GET 6 /* timeout to reconnect TCP?IP */
  190. #define ISCNTL_APPLMAGIC_WRITE 7 /* Write Appl. Magic */
  191. #define ISCNTL_APPLMAGIC_READ 8 /* Read Appl. Magic */
  192. #define ISCNTL_FSYNC 9 /* Flush pages to disk */
  193. #define ISCNTL_FDLIMIT_SET 10 /* Set UNIX fd usage limit */
  194. #define ISCNTL_FDLIMIT_GET 11 /* Get UNIX fd usage limit */
  195. #define ISCNTL_FATAL 12 /* Specify NetISAM fatal error hadler */
  196. #define ISCNTL_MASKSIGNALS 13 /* Enable or Disable masking signals during NetISAM operations */
  197. #define ISAPPLMAGICLEN 32
  198. /*
  199. * ALLISFD in iscntl() calls means that the operation should be done
  200. * on all open file descriptors, or the operation is not related to
  201. * any file descriptor (e.g: maskintg signals)
  202. */
  203. #define ALLISFD (-2)
  204. /* isshowlocks() and isshowhostlocks() return an array of struct showlock */
  205. #define IPADDRLEN 4 /* IP address length */
  206. struct showlock {
  207. short dev; /* Major/Minor device number,
  208. * actually type dev_t */
  209. long inode; /* inode number */
  210. long recnum; /* record number */
  211. char hostid[IPADDRLEN]; /* IP address of host */
  212. short pid; /* UNIX process ID */
  213. long uid; /* User ID */
  214. short type; /* See below */
  215. };
  216. /* NetISAM Programmer Toolkit related definitions */
  217. struct isfldmap {
  218. char *flm_fldname;
  219. short flm_recoff;
  220. short flm_bufoff;
  221. short flm_type;
  222. short flm_length;
  223. };
  224. struct istableinfo {
  225. char *tbi_tablename;
  226. int tbi_reclength;
  227. int tbi_nfields;
  228. struct isfldmap *tbi_fields;
  229. int tbi_nkeys;
  230. struct keydesc *tbi_keys;
  231. char **tbi_keynames;
  232. };
  233. /* record descriptor isreadm/iswritem record descriptor */
  234. struct recorddesc {
  235. char *rec_buffer;
  236. long rec_number;
  237. short rec_length;
  238. short rec_locked;
  239. };
  240. /*
  241. * The following defines and variable definitions are not used by NetISAM 1.0.
  242. * They are defined for compatibility with VSX 2.5.
  243. */
  244. #define EBADCOLL (-1)
  245. #define IO_OPEN 0x10 /* open() */
  246. #define IO_CREA 0x20 /* creat() */
  247. #define IO_SEEK 0x30 /* lseek() */
  248. #define IO_READ 0x40 /* read() */
  249. #define IO_WRIT 0x50 /* write() */
  250. #define IO_LOCK 0x60 /* lockf() */
  251. #define IO_IOCTL 0x70 /* ioctl() */
  252. #define IO_RENAME 0x80 /* rename() */
  253. #define IO_UNLINK 0x90 /* unlink() */
  254. extern int iserrio;
  255. #endif /* !_ISAM_H */