2 Unix SMB/Netbios implementation.
4 SMB parameters and setup
5 Copyright (C) Andrew Tridgell 1992-1995
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef MAX_CONNECTIONS
25 #define MAX_CONNECTIONS 127
28 #ifndef MAX_OPEN_FILES
29 #define MAX_OPEN_FILES 50
33 #define GUEST_ACCOUNT "nobody"
36 #define BUFFER_SIZE (0xFFFF)
37 #define SAFETY_MARGIN 1024
40 # define EXTERN extern
44 #define DGRAM_PORT 138
49 #define BOOLSTR(b) ((b) ? "Yes" : "No")
50 #define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
51 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
52 #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
57 Samba needs type definitions for int16, int32, uint16 and uint32.
59 Normally these are signed and unsigned 16 and 32 bit integers, but
60 they actually only need to be at least 16 and 32 bits
61 respectively. Thus if your word size is 8 bytes just defining them
62 as signed and unsigned int will work.
65 /* afs/stds.h defines int16 and int32 */
72 typedef unsigned short uint16;
76 typedef unsigned int uint32;
80 #define uchar unsigned char
86 #define uint16 unsigned short
89 #define uint32 unsigned int
94 #ifndef DEF_CREATE_MASK
95 #define DEF_CREATE_MASK (0755)
98 #ifndef DEFAULT_PIPE_TIMEOUT
99 #define DEFAULT_PIPE_TIMEOUT 10000000 /* Ten seconds */
104 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
106 EXTERN int syslog_level;
108 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))? \
109 (syslog_level = (level), Debug1 body):0)
112 #define DIR_STRUCT_SIZE 43
114 /* these define all the command types recognised by the server - there
115 are lots of gaps so probably there are some rare commands that are not
118 #define pSETDIR '\377'
120 /* these define the attribute byte as seen by DOS */
121 #define aRONLY (1L<<0)
122 #define aHIDDEN (1L<<1)
123 #define aSYSTEM (1L<<2)
124 #define aVOLID (1L<<3)
126 #define aARCH (1L<<5)
137 #define STYPE_DISKTREE 0 /* Disk drive */
138 #define STYPE_PRINTQ 1 /* Spooler queue */
139 #define STYPE_DEVICE 2 /* Serial device */
140 #define STYPE_IPC 3 /* Interprocess communication (IPC) */
142 /* SMB X/Open error codes for the ERRdos error class */
143 #define ERRbadfunc 1 /* Invalid function (or system call) */
144 #define ERRbadfile 2 /* File not found (pathname error) */
145 #define ERRbadpath 3 /* Directory not found */
146 #define ERRnofids 4 /* Too many open files */
147 #define ERRnoaccess 5 /* Access denied */
148 #define ERRbadfid 6 /* Invalid fid */
149 #define ERRnomem 8 /* Out of memory */
150 #define ERRbadmem 9 /* Invalid memory block address */
151 #define ERRbadenv 10 /* Invalid environment */
152 #define ERRbadaccess 12 /* Invalid open mode */
153 #define ERRbaddata 13 /* Invalid data (only from ioctl call) */
154 #define ERRres 14 /* reserved */
155 #define ERRbaddrive 15 /* Invalid drive */
156 #define ERRremcd 16 /* Attempt to delete current directory */
157 #define ERRdiffdevice 17 /* rename/move across different filesystems */
158 #define ERRnofiles 18 /* no more files found in file search */
159 #define ERRbadshare 32 /* Share mode on file conflict with open mode */
160 #define ERRlock 33 /* Lock request conflicts with existing lock */
161 #define ERRfilexists 80 /* File in operation already exists */
162 #define ERRbadpipe 230 /* Named pipe invalid */
163 #define ERRpipebusy 231 /* All instances of pipe are busy */
164 #define ERRpipeclosing 232 /* named pipe close in progress */
165 #define ERRnotconnected 233 /* No process on other end of named pipe */
166 #define ERRmoredata 234 /* More data to be returned */
167 #define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
168 #define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not suppored */
169 #define ERRunknownlevel 124
170 #define ERRunknownipc 2142
173 /* here's a special one from observing NT */
174 #define ERRnoipc 66 /* don't support ipc */
176 /* Error codes for the ERRSRV class */
178 #define ERRerror 1 /* Non specific error code */
179 #define ERRbadpw 2 /* Bad password */
180 #define ERRbadtype 3 /* reserved */
181 #define ERRaccess 4 /* No permissions to do the requested operation */
182 #define ERRinvnid 5 /* tid invalid */
183 #define ERRinvnetname 6 /* Invalid servername */
184 #define ERRinvdevice 7 /* Invalid device */
185 #define ERRqfull 49 /* Print queue full */
186 #define ERRqtoobig 50 /* Queued item too big */
187 #define ERRinvpfid 52 /* Invalid print file in smb_fid */
188 #define ERRsmbcmd 64 /* Unrecognised command */
189 #define ERRsrverror 65 /* smb server internal error */
190 #define ERRfilespecs 67 /* fid and pathname invalid combination */
191 #define ERRbadlink 68 /* reserved */
192 #define ERRbadpermits 69 /* Access specified for a file is not valid */
193 #define ERRbadpid 70 /* reserved */
194 #define ERRsetattrmode 71 /* attribute mode invalid */
195 #define ERRpaused 81 /* Message server paused */
196 #define ERRmsgoff 82 /* Not receiving messages */
197 #define ERRnoroom 83 /* No room for message */
198 #define ERRrmuns 87 /* too many remote usernames */
199 #define ERRtimeout 88 /* operation timed out */
200 #define ERRnoresource 89 /* No resources currently available for request. */
201 #define ERRtoomanyuids 90 /* too many userids */
202 #define ERRbaduid 91 /* bad userid */
203 #define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
204 #define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */
205 #define ERRcontMPX 252 /* resume MPX mode */
206 #define ERRbadPW /* reserved */
207 #define ERRnosupport 0xFFFF
208 #define ERRunknownsmb 22 /* from NT 3.5 response */
211 /* Error codes for the ERRHRD class */
213 #define ERRnowrite 19 /* read only media */
214 #define ERRbadunit 20 /* Unknown device */
215 #define ERRnotready 21 /* Drive not ready */
216 #define ERRbadcmd 22 /* Unknown command */
217 #define ERRdata 23 /* Data (CRC) error */
218 #define ERRbadreq 24 /* Bad request structure length */
220 #define ERRbadmedia 26
221 #define ERRbadsector 27
222 #define ERRnopaper 28
223 #define ERRwrite 29 /* write fault */
224 #define ERRread 30 /* read fault */
225 #define ERRgeneral 31 /* General hardware failure */
226 #define ERRwrongdisk 34
227 #define ERRFCBunavail 35
228 #define ERRsharebufexc 36 /* share buffer exceeded */
229 #define ERRdiskfull 39
232 typedef char pstring[1024];
233 typedef char fstring[128];
234 typedef fstring string;
237 struct current_user {
251 /* these times are normally kept in GMT */
259 /* Structure used when SMBwritebmpx is active */
262 int wr_total_written; /* So we know when to discard this */
265 int32 wr_error; /* Cached errors */
266 BOOL wr_mode; /* write through mode) */
267 BOOL wr_discard; /* discard all further data */
279 write_bmpx_struct *wbmpx_ptr;
295 int list[UID_CACHE_SIZE];
302 int uid; /* uid of user who *opened* this connection */
303 int gid; /* gid of user who *opened* this connection */
304 struct uid_cache uid_cache;
314 char *user; /* name of user who *opened* this connection */
315 /* following groups stuff added by ih */
316 /* This groups info is valid for the user that *opened* the connection */
319 int *igroups; /* an integer version - some OSes are broken :-( */
328 int uid; /* uid of a validated user */
329 int gid; /* gid of a validated user */
330 fstring name; /* name of a validated user */
332 /* following groups stuff added by ih */
333 /* This groups info is needed for when we become_user() for this uid */
336 int *user_igroups; /* an integer version - some OSes are broken :-( */
340 enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
351 } print_queue_struct;
353 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
359 } print_status_struct;
361 /* used for server information: client, nameserv and ipc */
362 struct server_info_struct
367 fstring domain; /* used ONLY in ipc.c NOT namework.c */
368 BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
372 /* this is used for smbstatus */
373 struct connect_record
387 #define LOCKING_VERSION 2
389 /* these are useful macros for checking validity of handles */
390 #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
391 #define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open)
392 #define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
393 #define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
394 #define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
395 #define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
397 #define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
398 return(ERROR(ERRDOS,ERRbadfid))
399 #define CHECK_READ(fnum) if (!Files[fnum].can_read) \
400 return(ERROR(ERRDOS,ERRbadaccess))
401 #define CHECK_WRITE(fnum) if (!Files[fnum].can_write) \
402 return(ERROR(ERRDOS,ERRbadaccess))
403 #define CHECK_ERROR(fnum) if (HAS_CACHED_ERROR(fnum)) \
404 return(CACHED_ERROR(fnum))
406 /* translates a connection number into a service number */
407 #define SNUM(cnum) (Connections[cnum].service)
409 /* access various service details */
410 #define SERVICE(snum) (lp_servicename(snum))
411 #define PRINTCAP (lp_printcapname())
412 #define PRINTCOMMAND(snum) (lp_printcommand(snum))
413 #define PRINTERNAME(snum) (lp_printername(snum))
414 #define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
415 #define VALID_SNUM(snum) (lp_snum_ok(snum))
416 #define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
417 #define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
418 #define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
419 #define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
420 #define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
421 #define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
422 #define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
423 #define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
424 #define CREATE_MODE(cnum) (lp_create_mode(SNUM(cnum)) | 0700)
426 #define SMBENCRYPT() (lp_encrypted_passwords())
428 #define SMBENCRYPT() (False)
431 /* the basic packet size, assuming no words or bytes */
434 /* offsets into message for common items */
469 #define SMBmkdir 0x00 /* create directory */
470 #define SMBrmdir 0x01 /* delete directory */
471 #define SMBopen 0x02 /* open file */
472 #define SMBcreate 0x03 /* create file */
473 #define SMBclose 0x04 /* close file */
474 #define SMBflush 0x05 /* flush file */
475 #define SMBunlink 0x06 /* delete file */
476 #define SMBmv 0x07 /* rename file */
477 #define SMBgetatr 0x08 /* get file attributes */
478 #define SMBsetatr 0x09 /* set file attributes */
479 #define SMBread 0x0A /* read from file */
480 #define SMBwrite 0x0B /* write to file */
481 #define SMBlock 0x0C /* lock byte range */
482 #define SMBunlock 0x0D /* unlock byte range */
483 #define SMBctemp 0x0E /* create temporary file */
484 #define SMBmknew 0x0F /* make new file */
485 #define SMBchkpth 0x10 /* check directory path */
486 #define SMBexit 0x11 /* process exit */
487 #define SMBlseek 0x12 /* seek */
488 #define SMBtcon 0x70 /* tree connect */
489 #define SMBtconX 0x75 /* tree connect and X*/
490 #define SMBtdis 0x71 /* tree disconnect */
491 #define SMBnegprot 0x72 /* negotiate protocol */
492 #define SMBdskattr 0x80 /* get disk attributes */
493 #define SMBsearch 0x81 /* search directory */
494 #define SMBsplopen 0xC0 /* open print spool file */
495 #define SMBsplwr 0xC1 /* write to print spool file */
496 #define SMBsplclose 0xC2 /* close print spool file */
497 #define SMBsplretq 0xC3 /* return print queue */
498 #define SMBsends 0xD0 /* send single block message */
499 #define SMBsendb 0xD1 /* send broadcast message */
500 #define SMBfwdname 0xD2 /* forward user name */
501 #define SMBcancelf 0xD3 /* cancel forward */
502 #define SMBgetmac 0xD4 /* get machine name */
503 #define SMBsendstrt 0xD5 /* send start of multi-block message */
504 #define SMBsendend 0xD6 /* send end of multi-block message */
505 #define SMBsendtxt 0xD7 /* send text of multi-block message */
508 #define SMBlockread 0x13 /* Lock a range and read */
509 #define SMBwriteunlock 0x14 /* Unlock a range then write */
510 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
511 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
512 #define SMBwritec 0x20 /* secondary write request */
513 #define SMBwriteclose 0x2c /* write a file then close it */
515 /* dos extended protocol */
516 #define SMBreadBraw 0x1A /* read block raw */
517 #define SMBreadBmpx 0x1B /* read block multiplexed */
518 #define SMBreadBs 0x1C /* read block (secondary response) */
519 #define SMBwriteBraw 0x1D /* write block raw */
520 #define SMBwriteBmpx 0x1E /* write block multiplexed */
521 #define SMBwriteBs 0x1F /* write block (secondary request) */
522 #define SMBwriteC 0x20 /* write complete response */
523 #define SMBsetattrE 0x22 /* set file attributes expanded */
524 #define SMBgetattrE 0x23 /* get file attributes expanded */
525 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
526 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
527 #define SMBtranss 0x26 /* transaction (secondary request/response) */
528 #define SMBioctl 0x27 /* IOCTL */
529 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
530 #define SMBcopy 0x29 /* copy */
531 #define SMBmove 0x2A /* move */
532 #define SMBecho 0x2B /* echo */
533 #define SMBopenX 0x2D /* open and X */
534 #define SMBreadX 0x2E /* read and X */
535 #define SMBwriteX 0x2F /* write and X */
536 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
537 #define SMBffirst 0x82 /* find first */
538 #define SMBfunique 0x83 /* find unique */
539 #define SMBfclose 0x84 /* find close */
540 #define SMBinvalid 0xFE /* invalid command */
542 /* Extended 2.0 protocol */
543 #define SMBtrans2 0x32 /* TRANS2 protocol set */
544 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
545 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
546 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
547 #define SMBulogoffX 0x74 /* user logoff */
550 /* these are the TRANS2 sub commands */
551 #define TRANSACT2_OPEN 0
552 #define TRANSACT2_FINDFIRST 1
553 #define TRANSACT2_FINDNEXT 2
554 #define TRANSACT2_QFSINFO 3
555 #define TRANSACT2_SETFSINFO 4
556 #define TRANSACT2_QPATHINFO 5
557 #define TRANSACT2_SETPATHINFO 6
558 #define TRANSACT2_QFILEINFO 7
559 #define TRANSACT2_SETFILEINFO 8
560 #define TRANSACT2_FSCTL 9
561 #define TRANSACT2_IOCTL 10
562 #define TRANSACT2_FINDNOTIFYFIRST 11
563 #define TRANSACT2_FINDNOTIFYNEXT 12
564 #define TRANSACT2_MKDIR 13
567 /* these are the trans2 sub fields for primary requests */
568 #define smb_tpscnt smb_vwv0
569 #define smb_tdscnt smb_vwv1
570 #define smb_mprcnt smb_vwv2
571 #define smb_mdrcnt smb_vwv3
572 #define smb_msrcnt smb_vwv4
573 #define smb_flags smb_vwv5
574 #define smb_timeout smb_vwv6
575 #define smb_pscnt smb_vwv9
576 #define smb_psoff smb_vwv10
577 #define smb_dscnt smb_vwv11
578 #define smb_dsoff smb_vwv12
579 #define smb_suwcnt smb_vwv13
580 #define smb_setup smb_vwv14
581 #define smb_setup0 smb_setup
582 #define smb_setup1 (smb_setup+2)
583 #define smb_setup2 (smb_setup+4)
585 /* these are for the secondary requests */
586 #define smb_spscnt smb_vwv2
587 #define smb_spsoff smb_vwv3
588 #define smb_spsdisp smb_vwv4
589 #define smb_sdscnt smb_vwv5
590 #define smb_sdsoff smb_vwv6
591 #define smb_sdsdisp smb_vwv7
592 #define smb_sfid smb_vwv8
594 /* and these for responses */
595 #define smb_tprcnt smb_vwv0
596 #define smb_tdrcnt smb_vwv1
597 #define smb_prcnt smb_vwv3
598 #define smb_proff smb_vwv4
599 #define smb_prdisp smb_vwv5
600 #define smb_drcnt smb_vwv6
601 #define smb_droff smb_vwv7
602 #define smb_drdisp smb_vwv8
604 /* where to find the base of the SMB packet proper */
605 #define smb_base(buf) (((char *)(buf))+4)
608 #define SUCCESS 0 /* The request was successful. */
609 #define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
610 #define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
611 #define ERRHRD 0x03 /* Error is an hardware error. */
612 #define ERRCMD 0xFF /* Command was not in the "SMB" format. */
614 /* structure used to hold the incoming hosts info */
616 char *name; /* host name */
617 char *addr; /* host address */
618 struct sockaddr_in *sin; /* their side of the link */
622 int Debug1(char *, ...);
628 void dfs_unlogin(void);
629 extern int dcelogin_atmost_once;
633 void ajt_panic(void);
637 char *strdup(char *s);
640 #ifdef REPLACE_STRLEN
644 #ifdef REPLACE_STRSTR
645 char *Strstr(char *s, char *p);
649 #define MIN(a,b) ((a)<(b)?(a):(b))
652 #define MAX(a,b) ((a)>(b)?(a):(b))
656 #define ABS(a) ((a)>0?(a):(-(a)))
668 /* Some POSIX definitions for those without */
671 #define S_IFDIR 0x4000
674 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
677 #define S_IRWXU 00700 /* read, write, execute: owner */
680 #define S_IRUSR 00400 /* read permission: owner */
683 #define S_IWUSR 00200 /* write permission: owner */
686 #define S_IXUSR 00100 /* execute permission: owner */
689 #define S_IRWXG 00070 /* read, write, execute: group */
692 #define S_IRGRP 00040 /* read permission: group */
695 #define S_IWGRP 00020 /* write permission: group */
698 #define S_IXGRP 00010 /* execute permission: group */
701 #define S_IRWXO 00007 /* read, write, execute: other */
704 #define S_IROTH 00004 /* read permission: other */
707 #define S_IWOTH 00002 /* write permission: other */
710 #define S_IXOTH 00001 /* execute permission: other */
714 /* these are used in NetServerEnum to choose what to receive */
715 #define SV_TYPE_WORKSTATION 0x00000001
716 #define SV_TYPE_SERVER 0x00000002
717 #define SV_TYPE_SQLSERVER 0x00000004
718 #define SV_TYPE_DOMAIN_CTRL 0x00000008
719 #define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
720 #define SV_TYPE_TIME_SOURCE 0x00000020
721 #define SV_TYPE_AFP 0x00000040
722 #define SV_TYPE_NOVELL 0x00000080
723 #define SV_TYPE_DOMAIN_MEMBER 0x00000100
724 #define SV_TYPE_PRINTQ_SERVER 0x00000200
725 #define SV_TYPE_DIALIN_SERVER 0x00000400
726 #define SV_TYPE_SERVER_UNIX 0x00000800
727 #define SV_TYPE_NT 0x00001000
728 #define SV_TYPE_WFW 0x00002000
729 #define SV_TYPE_SERVER_MFPN 0x00004000
730 #define SV_TYPE_SERVER_NT 0x00008000
731 #define SV_TYPE_POTENTIAL_BROWSER 0x00010000
732 #define SV_TYPE_BACKUP_BROWSER 0x00020000
733 #define SV_TYPE_MASTER_BROWSER 0x00040000
734 #define SV_TYPE_DOMAIN_MASTER 0x00080000
735 #define SV_TYPE_SERVER_OSF 0x00100000
736 #define SV_TYPE_SERVER_VMS 0x00200000
737 #define SV_TYPE_ALTERNATE_XPORT 0x20000000
738 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
739 #define SV_TYPE_DOMAIN_ENUM 0x80000000
740 #define SV_TYPE_ALL 0xFFFFFFFF
744 /* protocol types. It assumes that higher protocols include lower protocols
746 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
748 /* security levels */
749 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
752 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
753 PRINT_QNX,PRINT_PLP};
757 enum case_handling {CASE_LOWER,CASE_UPPER};
760 /* Macros to get at offsets within smb_lkrng and smb_unlkrng
761 structures. We cannot define these as actual structures
762 due to possible differences in structure packing
763 on different machines/compilers. */
765 #define SMB_LPID_OFFSET(indx) (10 * (indx))
766 #define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
767 #define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
769 /* Macro to cache an error in a write_bmpx_struct */
770 #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
771 w->wr_discard = True, -1)
772 /* Macro to test if an error has been cached for this fnum */
773 #define HAS_CACHED_ERROR(fnum) (Files[(fnum)].open && \
774 Files[(fnum)].wbmpx_ptr && \
775 Files[(fnum)].wbmpx_ptr->wr_discard)
776 /* Macro to turn the cached error into an error packet */
777 #define CACHED_ERROR(fnum) cached_error_packet(inbuf,outbuf,fnum,__LINE__)
779 /* these are the datagram types */
780 #define DGRAM_DIRECT_UNIQUE 0x10
782 #define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)
784 /* this is how errors are generated */
785 #define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)
787 #define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))