1 /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
2 /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
3 /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
4 /*%% (c) Copyright 1993, 1994 Novell, Inc. */
5 /*%% $XConsortium: isam.h /main/3 1995/10/23 11:33:51 rswiston $ */
12 * Copyright (c) 1988 by Sun Microsystems, Inc.
19 * isam.h is to be included in NetISAM C application programs.
21 * Make sure all changes in this file are reflected in lib/db/tt_client_isam.h
35 extern float ldfloat();
36 extern double lddbl();
37 extern short ldshort();
38 extern ldchar(), stchar(), stlong(), stint(), stdbl(), stfloat();
39 extern stbin(), ldbin();
41 extern int iserrno; /* isam error number code */
42 extern long isrecnum; /* record number of last call */
43 extern int isreclen; /* used for variable length recs */
44 extern char isstat1; /* cobol status characters */
54 #define LONGSIZE LONG_BIT/8
68 #define ISDESC 0x80 /* add to make descending type */
69 #define TYPEMASK 0x7f /* type mask */
71 #define BYTEMASK 0xff /* mask for one byte */
72 #define BYTESHFT 8 /* shift for one byte */
74 /* mode parameter in isread() and isstart() */
76 #define ISFIRST 0 /* first record */
77 #define ISLAST 1 /* last record */
78 #define ISNEXT 2 /* next record */
79 #define ISPREV 3 /* previous record */
80 #define ISCURR 4 /* current record */
82 #define ISEQUAL 5 /* equal value */
83 #define ISGREAT 6 /* greater value */
84 #define ISGTEQ 7 /* >= value */
85 #define ISLESS 8 /* < */
86 #define ISLTEQ 9 /* <= */
88 /* isopen, isbuild lock modes */
89 #define ISAUTOLOCK 0x200 /* automatic record lock */
90 #define ISMANULOCK 0x400 /* manual record lock */
91 #define ISEXCLLOCK 0x800 /* exclusive isam file lock */
92 #define ISFASTLOCK 0x4000 /* no locking when EXCLLOCK! */
94 /* isread lock modes */
95 #define ISLOCK 0x100 /* lock record before reading */
96 #define ISSKIPLOCK 0x1000 /* advance record pointer to */
98 /* isstart lock mode for automatic record locking */
99 #define ISKEEPLOCK 0x2000 /* keep record locked */
101 /* Fix/Variable length records mode */
103 #define ISVARLEN 0x10000
105 /* Access remote file via NFS */
106 #define ISNFS 0x20000
109 #define ISINPUT 0 /* open for input only */
110 #define ISOUTPUT 1 /* open for output only */
111 #define ISINOUT 2 /* open for input and output */
113 #define MAXKEYSIZE 150 /* max number of bytes in key */
114 #define NPARTS 8 /* max number of key parts */
116 /*#define ISMAXRECLEN 8192 */ /* Maximum number of bytes in record */
117 #define ISMAXRECLEN 32767 /* 32K - 1 */
118 #define ISMINRECLEN 4 /* Minimum number of bytes in record */
121 unsigned short kp_start; /* starting byte of key part */
122 short kp_leng; /* length in bytes */
123 short kp_type; /* type of key part */
127 short k_flags; /* flags */
128 short k_nparts; /* number of parts in key */
129 struct keypart k_part[NPARTS]; /* each part */
132 /* The next three defines are for compatibility with X/OPEN */
133 #define k_start k_part[0].kp_start
134 #define k_leng k_part[0].kp_leng
135 #define k_type k_part[0].kp_type
137 #define ISNODUPS 000 /* no duplicates and */
139 #define ISDUPS 001 /* duplicates allowed */
140 #define COMPRESS 020 /* full compression */
143 short di_nkeys; /* number of keys defined */
144 unsigned short di_recsize; /* data record size */
145 short di_idxsize; /* index record size */
146 long di_nrecords; /* number of records in file */
149 /* msb in di_nkeys indicates that ISAM file supports variable length records */
150 #define DICTVARLENBIT 0x8000
152 /* mask to access the true number of keys */
153 #define DICTNKEYSMASK (DICTVARLENBIT - 1)
156 #define ENOERROR 0 /* No error */
157 #define EDUPL 100 /* duplicate record */
158 #define ENOTOPEN 101 /* file not open */
159 #define EBADARG 102 /* illegal argument */
160 #define EBADKEY 103 /* illegal key desc */
161 #define ETOOMANY 104 /* too many files open */
162 #define EBADFILE 105 /* bad ISAM file format */
163 #define ENOTEXCL 106 /* non-exclusive access */
164 #define ELOCKED 107 /* record locked */
165 #define EKEXISTS 108 /* key already exists */
166 #define EPRIMKEY 109 /* is primary key */
167 #define EENDFILE 110 /* end/begin of file */
168 #define ENOREC 111 /* no record found */
169 #define ENOCURR 112 /* no current record */
170 #define EFLOCKED 113 /* file locked */
171 #define EFNAME 114 /* file name too long */
172 #define EBADMEM 116 /* cannot allocate memory */
174 /* NetISAM specific error codes non XOPEN compliant*/
175 #define ETIMEOUT 1117 /* RPC timeout */
176 #define ERPC 1118 /* Broken TCP/IP */
177 #define ETCP 1119 /* Cannot connect to server */
178 #define EIMPORT 1120 /* Cannot import */
179 #define ENODAEMON 1121 /* no local daemon */
180 #define EFATAL 1122 /* internal fatal error */
181 #define ELANG 1123 /* Locale/LANG mismatch */
184 #define ISOK 0 /* no error return code */
185 #define ISERROR -1 /* error return code */
188 extern struct keydesc *nokey; /* May be used as parameter
190 * primary key is to be built
193 /* ischeckindex() diagmode values */
194 #define CHK_NODIAG 0 /* do not print any messages */
195 #define CHK_DIAG 1 /* Access Level module will print to stderr */
197 /* values of corrupt parameter of ischeckindex() */
198 #define CHK_OK 0 /* ISAM file is not corrupted */
199 #define CHK_DAT 1 /* .dat file is corrupted */
200 #define CHK_VAR 2 /* .var file is corrupted */
201 #define CHK_IND 3 /* .ind file is corrupted */
204 /* iscntl() definitions */
205 /* For one isfd - use iscntl(isfd, func, ...) */
206 #define ISCNTL_RPCS_TO_SET 1 /* short oper. timeout (in sec) */
207 #define ISCNTL_RPCS_TO_GET 2 /* short oper. timeout (in sec) */
208 #define ISCNTL_RPCL_TO_SET 3 /* long oper. timeout (in sec) */
209 #define ISCNTL_RPCL_TO_GET 4 /* long oper. timeout (in sec) */
210 #define ISCNTL_TCP_TO_SET 5 /* timeout to reconnect TCP?IP */
211 #define ISCNTL_TCP_TO_GET 6 /* timeout to reconnect TCP?IP */
212 #define ISCNTL_APPLMAGIC_WRITE 7 /* Write Appl. Magic */
213 #define ISCNTL_APPLMAGIC_READ 8 /* Read Appl. Magic */
214 #define ISCNTL_FSYNC 9 /* Flush pages to disk */
215 #define ISCNTL_FDLIMIT_SET 10 /* Set UNIX fd usage limit */
216 #define ISCNTL_FDLIMIT_GET 11 /* Get UNIX fd usage limit */
217 #define ISCNTL_FATAL 12 /* Specify NetISAM fatal error hadler */
218 #define ISCNTL_MASKSIGNALS 13 /* Enable or Disable masking signals during NetISAM operations */
220 #define ISAPPLMAGICLEN 32
223 * ALLISFD in iscntl() calls means that the operation should be done
224 * on all open file descriptors, or the operation is not related to
225 * any file descriptor (e.g: maskintg signals)
229 /* isshowlocks() and isshowhostlocks() return an array of struct showlock */
230 #define IPADDRLEN 4 /* IP address length */
232 short dev; /* Major/Minor device number,
233 * actually type dev_t */
234 long inode; /* inode number */
235 long recnum; /* record number */
236 char hostid[IPADDRLEN]; /* IP address of host */
237 short pid; /* UNIX process ID */
238 long uid; /* User ID */
239 short type; /* See below */
243 /* NetISAM Programmer Toolkit related definitions */
257 struct isfldmap *tbi_fields;
259 struct keydesc *tbi_keys;
263 /* record descriptor isreadm/iswritem record descriptor */
272 * The following defines and variable definitions are not used by NetISAM 1.0.
273 * They are defined for compatibility with VSX 2.5.
275 #define EBADCOLL (-1)
277 #define IO_OPEN 0x10 /* open() */
278 #define IO_CREA 0x20 /* creat() */
279 #define IO_SEEK 0x30 /* lseek() */
280 #define IO_READ 0x40 /* read() */
281 #define IO_WRIT 0x50 /* write() */
282 #define IO_LOCK 0x60 /* lockf() */
283 #define IO_IOCTL 0x70 /* ioctl() */
284 #define IO_RENAME 0x80 /* rename() */
285 #define IO_UNLINK 0x90 /* unlink() */
290 #endif /* !_ISAM_H */