|
|
1.1 root 1: static char ID[] = "@(#) generate.c: 1.2 12/8/82";
2: #include <stdio.h>
3: #include "sdp.h"
4:
5: #define YYMMDD 811221
6:
7: #include "define3.h"
8:
9: #ifdef SHORT
10: #define GE01 "GE01 "
11: #define GE02 "GE02 "
12: #define GE03 "GE03 "
13: #define GE04 "GE04 "
14: #define GE05 "GE05 "
15: #define GE06 "GE06 "
16: #define GEAU "GEAU "
17: #else
18: #define GE01 "GE01 -- fail to allocate header\n%s\n",name
19: #define GE02 "GE02 -- fail to allocate for file structure\n%s\n",name
20: #define GE03 "GE03 -- fail to allocate stacks structure\n%s\n",name
21: #define GE04 "GE04 -- fail to build name\n%s\n",name
22: #define GE05 "GE05 -- fail to create header file\n%s\n",sp->head_name
23: #define GE06 "GE06 -- error return from wtSPACE\n%s\n",name
24: #define GEAU "%s","GEAU -- audit failed in sdp_generate\n"
25: #endif
26:
27: #ifdef SWEET
28: #define PROLOG
29: #define EPILOG
30: #else
31: #define PROLOG if( (aud_flag == AUDITON) && (aud_check() == ERROR) )\
32: ERR_RET(GEAU,ERROR)
33: #define EPILOG if(aud_flag == AUDITON)\
34: aud_set() ;\
35: if(hist_fp != NULL)\
36: fprintf(hist_fp,"GE\t%s\t%u\t%o\n",name,page_size,library) ;
37: #endif
38:
39:
40: extern int aud_flag ;
41: extern struct LIBFILE *Glib_file ;
42: extern long Gln_file[] ;
43: extern int Gnumbfile ;
44: extern int Gnumbstax ;
45: extern int Gsz_stax[] ;
46: extern FILE *hist_fp ;
47: extern struct LIBFILE lib_file ;
48:
49: extern int *ALLOC() ;
50: extern char *BUILDNAME() ;
51: extern aud_set() ;
52: extern int aud_check() ;
53: extern struct LIBFILE lib_file ;
54: extern struct LIBFILE *Glib_file ;
55: extern FATAL() ;
56: extern int wtSPACE() ;
57: extern freeSPACE() ;
58:
59: int /* SUCCESS or ERROR */
60: sdp_generate(name,page_size,library,mode)
61: char *name ;
62: unsigned page_size ;
63: struct LIBFILE *library ;
64: int mode ;
65: {
66: register struct SPACE *sp ;
67: register int i ;
68:
69: PROLOG
70:
71: Glib_file = (library == NULL) ? &lib_file : library ;
72:
73: if( (sp = (struct SPACE *)ALLOC(sizeof(struct SPACE))) == NULL )
74: ERR_RET(GE01,ERROR)
75:
76: sp->version = YYMMDD ;
77: sp->page_size = page_size ;
78: sp->maxpage = 0l ;
79: sp->curpage = IDNULL ;
80: sp->curleft = 0 ;
81: sp->perms = WRTN ;
82: sp->mode = mode ;
83: sp->numbfile = Gnumbfile ;
84: sp->numbstax = Gnumbstax+1 ;
85: sp->known_id = IDNULL ;
86: sp->environ = NULL ;
87: sp->lib_file = NULL ;
88: sp->next_space = NULL ;
89: sp->sp1_hash = HASHNULL ;
90: sp->sp2_hash = HASHNULL ;
91:
92: if( (sp->fileinfo = (struct FILEINFO *)ALLOC(sp->numbfile*sizeof(struct FILEINFO))) == NULL )
93: ERR_RET(GE02,ERROR)
94:
95: for(i=0; i<sp->numbfile; i++)
96: {
97: sp->fileinfo[i].leng = Gln_file[i] ;
98: sp->fileinfo[i].desc = NOTMADE ;
99: }
100:
101: if( (sp->staxinfo = (struct STAXINFO *)ALLOC((sp->numbstax+1)*sizeof(struct STAXINFO))) == NULL )
102: ERR_RET(GE03,ERROR)
103:
104: sp->staxinfo[0].top = IDNULL ;
105: sp->staxinfo[0].size = 0 ;
106: sp->staxinfo[0].depth = 0 ;
107: for(i=1; i<sp->numbstax; i++)
108: {
109: sp->staxinfo[i].top = IDNULL ;
110: sp->staxinfo[i].size = Gsz_stax[i-1] ;
111: sp->staxinfo[i].depth = 0 ;
112: }
113:
114: if( (sp->head_name = MBUILDNAME(name,-1)) == NULL )
115: ERR_RET(GE04,ERROR)
116: if(MCREATE(sp->head_name,mode) == ERROR)
117: ERR_RET(GE05,ERROR)
118:
119: if(wtSPACE(sp) == ERROR)
120: ERR_RET(GE06,ERROR)
121:
122: freeSPACE(sp) ;
123:
124:
125: EPILOG
126: return(SUCCESS) ;
127: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.