home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / uccs / root.14 / udk / usr / include / ldfcn.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-19  |  4.2 KB  |  176 lines

  1. /*
  2.  * Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  3.  *                                                                         
  4.  *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  5.  *                   SANTA CRUZ OPERATION INC.                             
  6.  *                                                                         
  7.  *   The copyright notice above does not evidence any actual or intended   
  8.  *   publication of such source code.                                      
  9.  */
  10.  
  11. #ident    "@(#)sgs-head:common/head/ldfcn.h    2.5.4.5"
  12.  
  13. #ifndef LDFILE
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19. #ifndef _SYS_TYPES_H
  20. #include <sys/types.h>
  21. #endif
  22.  
  23. #ifndef _STDIO_H
  24. #include <stdio.h>
  25. #endif
  26.  
  27. #ifndef _FILEHDR_H
  28. #include <filehdr.h>
  29. #endif
  30.  
  31. struct    ldfile {
  32.     int    _fnum_;        /* so each instance of an LDFILE is unique */
  33.     FILE    *ioptr;        /* system I/O pointer value */
  34.     long    offset;        /* absolute offset to the start of the file */
  35.     FILHDR    header;        /* the file header of the opened file */
  36.     unsigned short    type;        /* indicator of the type of the file */
  37. };
  38.  
  39.  
  40. /*
  41.     provide a structure "type" definition, and the associated
  42.     "attributes"
  43. */
  44.  
  45. #define    LDFILE        struct ldfile
  46. #define IOPTR(x)    (x)->ioptr
  47. #define OFFSET(x)    (x)->offset
  48. #define TYPE(x)        (x)->type
  49. #define    HEADER(x)    (x)->header
  50. #define LDFSZ        sizeof(LDFILE)
  51.  
  52. /*
  53.     define various values of TYPE(ldptr)
  54. */
  55.  
  56. #define USH_ARTYPE      (unsigned short) ARTYPE
  57. #define ARTYPE     0177545
  58.  
  59. /*
  60.     define symbolic positioning information for FSEEK (and fseek)
  61. */
  62.  
  63. #define BEGINNING    0
  64. #define CURRENT        1
  65. #define END        2
  66.  
  67. /*
  68.     define a structure "type" for an archive header
  69. */
  70.  
  71. typedef struct
  72. {
  73.     char ar_name[16];
  74.     time_t ar_date;
  75.     uid_t ar_uid;
  76.     gid_t ar_gid;
  77.     mode_t ar_mode;
  78.     off_t ar_size;
  79. } archdr;
  80.  
  81. #define    ARCHDR    archdr
  82. #define ARCHSZ    sizeof(ARCHDR)
  83.  
  84.  
  85. /*
  86.     define some useful symbolic constants
  87. */
  88.  
  89. #define SYMTBL    0    /* section nnumber and/or section name of the Symbol Table */
  90.  
  91. #define    SUCCESS     1
  92. #define    CLOSED     1
  93. #define    FAILURE     0
  94. #define    NOCLOSE     0
  95. #define    BADINDEX    -1L
  96.  
  97. #define    OKFSEEK    0
  98.  
  99. #ifndef _SYMS_H
  100. #include <syms.h>
  101. #endif
  102.  
  103. #ifndef _LINENUM_H
  104. #include <linenum.h>
  105. #endif
  106.  
  107. #ifndef _SCNHDR_H
  108. #include <scnhdr.h>
  109. #endif
  110.  
  111. #if defined(__STDC__)
  112.  
  113. extern int ldaclose(LDFILE *);
  114. extern int ldahread(LDFILE *, ARCHDR *);
  115. extern LDFILE *ldaopen(const char *, LDFILE *);
  116. extern int ldclose(LDFILE *);
  117. extern int ldfhread(LDFILE *, FILHDR *);
  118. extern char *ldgetname(LDFILE *, const SYMENT *);
  119. extern int ldlinit(LDFILE *, long);
  120. extern int ldlitem(LDFILE *, unsigned short, LINENO *);
  121. extern int ldlread(LDFILE *, long, unsigned short, LINENO *);
  122. extern int ldlseek(LDFILE *, unsigned short);
  123. extern int ldnlseek(LDFILE *, const char *);
  124. extern int ldnrseek(LDFILE *, const char *);
  125. extern int ldnsseek(LDFILE *, const char *);
  126. extern int ldohseek(LDFILE *);
  127. extern LDFILE *ldopen(const char *, LDFILE *);
  128. extern int ldrseek(LDFILE *, unsigned short);
  129. extern int ldshread(LDFILE *, unsigned short, SCNHDR *);
  130. extern int ldnshread(LDFILE *, const char *, SCNHDR *);
  131. extern int ldsseek(LDFILE *, unsigned short);
  132. extern long ldtbindex(LDFILE *);
  133. extern int ldtbread(LDFILE *, long, SYMENT *);
  134. extern int ldtbseek(LDFILE *);
  135. extern long sgetl(const char *);
  136. extern void sputl(long, char *);
  137.  
  138. #else
  139.  
  140. extern LDFILE *ldopen();
  141. extern LDFILE *ldaopen();
  142. extern char *ldgetname();
  143. extern long ldtbindex();
  144. extern long sgetl();
  145. extern void sputl();
  146.  
  147. #endif    /* __STDC__ */
  148.  
  149.  
  150. /*
  151.     define macros to permit the direct use of LDFILE pointers with the
  152.     standard I/O library procedures
  153. */
  154.  
  155. #define GETC(ldptr)    getc(IOPTR(ldptr))
  156. #define GETW(ldptr)    getw(IOPTR(ldptr))
  157. #define FEOF(ldptr)    feof(IOPTR(ldptr))
  158. #define FERROR(ldptr)    ferror(IOPTR(ldptr))
  159. #define FGETC(ldptr)    fgetc(IOPTR(ldptr))
  160. #define FGETS(s,n,ldptr)    fgets(s,n,IOPTR(ldptr))
  161. #define FILENO(ldptr)    fileno(IOPTR(ldptr))
  162. #define FREAD(p,s,n,ldptr)    fread(p,s,n,IOPTR(ldptr))
  163. #define FSEEK(ldptr,o,p)    fseek(IOPTR(ldptr),(p==BEGINNING)?(OFFSET(ldptr)+o):o,p)
  164. #define FTELL(ldptr)    ftell(IOPTR(ldptr))
  165. #define FWRITE(p,s,n,ldptr)       fwrite(p,s,n,IOPTR(ldptr))
  166. #define REWIND(ldptr)    rewind(IOPTR(ldptr))
  167. #define SETBUF(ldptr,b)    setbuf(IOPTR(ldptr),b)
  168. #define UNGETC(c,ldptr)        ungetc(c,IOPTR(ldptr))
  169. #define STROFFSET(ldptr)    (HEADER(ldptr).f_symptr + HEADER(ldptr).f_nsyms * SYMESZ)
  170.  
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174.  
  175. #endif
  176.