⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uerfdbc.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 4 页
字号:
	/* output the 2 include files */output_h() {	char **cp;	struct std_index *si;	std_h = fopen(STD_H_NAME, "w");	if( std_h == NULL )  {		errval = 1;		fprintf(stderr, "Error, Unable to open %s\n", STD_H_NAME);		exit(4);	}	os_h = fopen(OS_H_NAME, "w");	if( os_h == NULL )  {		errval = 1;		fprintf(stderr, "Error, Unable to open %s\n", OS_H_NAME);		exit(4);	}	fprintf(std_h, "#define UERF_VERSION %d\n", uerf_version);	fprintf(os_h, "#define UERF_VERSION %d\n", uerf_version);	print_block(std_h, std_h_fixed1);	fprintf(std_h, "/* sitem id codes */\n");	for(sitem = first_sitem; sitem; sitem = sitem->next) {		fprintf(std_h, "#define DD$%-*s %d	/* %s */\n",			pr_width(sitem->name),			sitem->name, sitem->id, sitem->doc);	}	fprintf(std_h, "\n/* Standard coded field definitions */\n");	for(sitem = first_sitem; sitem; sitem = sitem->next) {		switch(sitem->type) {			case DT_SHORT_INDEX:			case DT_TINY_INDEX:			case DT_INDEXED:				fprintf(std_h, "/* Coded values for %s */\n", sitem->name);				for(si=sitem->map_index; si; si=si->next) {					fprintf(std_h, "#define %-*s %lu	/* %s */\n",						pr_width2(si->name),						si->name, si->value, si->label_plain);			}		}	}	print_block(std_h, std_h_fixed2);	fprintf(std_h, "/* sseg id codes */\n");	for(sseg = first_sseg; sseg; sseg = sseg->next) {		fprintf(std_h, "#define DD$%-*s %d	/* %s */\n",			pr_width(sseg->name),			sseg->name, sseg->type_id, sseg->doc);	}	print_block(std_h, std_h_fixed3);	print_block(os_h, os_h_fixed1);	fprintf(os_h, "/* oitem id codes */\n");	for(oitem = first_oitem; oitem; oitem = oitem->next) {		fprintf(os_h, "#define OS$%-*s %d	/* %s */\n",			pr_width(oitem->name),			oitem->name, oitem->id, oitem->doc);	}	print_block(os_h, os_h_fixed2);}	/* upper case to lower case */convert_tolower(cp)char *cp;{	if(!cp)		return;	for(; *cp; cp++) {		if( *cp >= 'A' && *cp <= 'Z' )			*cp = *cp - ('A' - 'a');	}}	/* lower case to upper case */convert_toupper(cp)char *cp;{	if(!cp)		return;	for(; *cp; cp++) {		if( *cp >= 'a' && *cp <= 'z' )			*cp = *cp + ('A' - 'a');	}}/* return id number of std item with given name *//* return 0 if not found */find_id_of_sitem(name)char *name;{	if(!name || !*name || (name[0]==' ' && name[1]=='\0') )		return(0);	for(sitem = first_sitem; sitem; sitem = sitem->next) {		if(!strcmp(name, sitem->name))			return(sitem->id);	}	return(0);}	/* go through the std items, looking for name in        the index values.  return the value of name */		/* return 0 if failure */unsigned longfind_id_of_index(name)char *name;{	struct std_index *si;	if(!name || !*name || (name[0]==' ' && name[1]=='\0') )		return((unsigned long)0);	for(sitem = first_sitem; sitem; sitem = sitem->next) {		if( sitem->type != DT_SHORT_INDEX &&			sitem->type != DT_INDEXED &&			sitem->type != DT_TINY_INDEX )				continue;		for(si=sitem->map_index; si; si=si->next) {			if(!strcmp(name, si->name))				return(si->value);		}	}	return((unsigned long)0);}/* return the print width for this string *//*  I had to try to figure out the rule used by the vaxlisp system */pr_width(name)char *name;{	int len = strlen(name);	if( len < 12 )		return(12);	else if( len < 16 )		return(16);	else if( len < 20 )		return(20);	else		return(24);}pr_width2(name)char *name;{	int len = strlen(name);	if( len < 15 )		return(15);	else if( len < 19 )		return(19);	else if( len < 23 )		return(23);	else		return(27);}print_block(fp, block)FILE *fp;char *block[];{char **cp;for( cp=block; **cp; cp++ )	fprintf(fp, *cp);}char *std_h_fixed1[] = { "/*\n", "**	.title Standard DSD definitions\n", "**	.ident / 1.14 /\n", "**\n", "**\n", "**	  File:	std_dsd.h\n", "** Description:	Standard DSD definitions\n", "**	Author:	Luis Arce\n", "**	  Date:	8-Oct-1986\n", "**\n", "**\n", "**	Copyright 1986, Digital Equipment Corporation\n", "**\n", "**\n", "**++\n", "**	These definitions were generated by the DSD Editor / Compiler\n", "**--\n", "*/\n", "\n", "\n", "\n", "#define STD_DSD_FILE_FORMAT 2\n", "\n", "/* Miscellaneous definitions needed for the DSD access functions */\n", "\n", "#define DD$HEADER_BYTES 8		/* Size of standard header */\n", "#define DD$MAX_SEGMENT_ELEMENTS 512	/* Max elements excluding the header */\n", "#define DD$VALID_CODE_SIZE 2		/* Size in bits of a validity code */\n", "\n", "#define DD$ELEMENT_COUNT        ctx->segment_DSD_ptr->COUNT\n", "#define DD$VALID_BITS(COUNT)    ( (COUNT + 1) * DD$VALID_CODE_SIZE)\n", "#define DD$VALID_BYTES(COUNT)   ( (DD$VALID_BITS(COUNT) +7) / 8)\n", "\n", "\0"};char *std_h_fixed2[] = { "#ifndef ES$EIS\n", "\n", "/* Standard segment type:  codes */\n", "#define ES$EIS          1	/* Event Identification Segment */\n", "#define ES$DIS          2	/* Device Information Segment */\n", "#define ES$SDS          3	/* Supporting Data Segment */\n", "#define ES$CDS          4	/* Correlating Data Segment */\n", "#define ES$ADS          5	/* Additional Data Segment */\n", "#define ES$SIS          6	/* Summary Information Segment */\n", "#define ES$CIS          7	/* Configuration Information Segment */\n", "#endif  ES$EIS\n", "\n", "\0"};char *std_h_fixed3[] = { "\n", "/* STD-RECORD id codes */\n", "\n", "/********** STRUCTURE DEFINITIONS FOR THE STANDARD DSD TABLES **********/\n", "\n", "\n", "	/**** Structure definition for the standard segment header ****/\n", "\n", "typedef struct\n", "  {\n", "  short			type;\n", "  short			subtype;\n", "  short			version;\n", "  short			length;\n", "  DD$BYTE VALID_byte[DD$MAX_SEGMENT_ELEMENTS * DD$VALID_CODE_SIZE / 8];\n", "  }\n", " DD$STD_HEADER, *DD$STD_HEADER_PTR;\n", "\n", "\n", "	/**** Structure definition for std item codes array ****/\n", "\n", "typedef struct \n", "  {\n", "  long			CODE;\n", "  long			LABEL_IX;	/* index to DD$DSP_LABELS */\n", "  }\n", " DD$STD_CODES_DSD, *DD$STD_CODES_DSD_PTR;\n", "\n", "\n", "	/**** Structure definition for std item register array ****/\n", "\n", "typedef struct\n", "  {\n", "  DD$BYTE		SIZE;		/* bits in field		*/\n", "  DD$BYTE		TYPE;		/* field type (int, coded etc)	*/\n", "  short			COUNT;		/* for coded fields only	*/\n", "  long			CODE_IX;	/* index to DD$STD_CODES	*/\n", "  long			LABEL_IX;	/* index to DD$DSP_LABELS	*/\n", "  }\n", " DD$STD_REGS_DSD, *DD$STD_REGS_DSD_PTR;\n", "\n", "\n", "	/**** Structure definition for std item array ****/\n", "\n", "typedef struct\n", "  {\n", "  short			ID;\n", "  DD$BYTE		TYPE;		/* field type (int, coded etc)	*/\n", "  DD$BYTE		FILLER1;        /* filler                       */\n", "  short			COUNT;		/* for coded or vectors only	*/\n", "  short 		FILLER2;        /* filler                       */\n", "  long			INDEX;		/* index to DD$STD_CODES/REGS	*/\n", "  long			LABEL_IX;	/* index to DD$DSP_LABELS	*/\n", "  }\n", " DD$STD_ITEMS_DSD, *DD$STD_ITEMS_DSD_PTR;\n", "\n", "\n", "	/**** Structure definition for std segment items array ****/\n", "\n", "typedef struct\n", "  {\n", "  long			ITEM_IX;	/* index to DD$STD_ITEMS	*/\n", "  long			ITEM_OFFSET;	/* item offset in seg		*/\n", "  }\n", " DD$STD_SEG_ITEMS_DSD, *DD$STD_SEG_ITEMS_DSD_PTR;\n", "\n", "\n", "	/**** Structure definition for std segment array ****/\n", "\n", "typedef struct\n", "  {\n", "  short			TYPE;\n", "  short			SUBTYPE;\n", "  short			COUNT;		/* count of items in seg	*/\n", "  short			STR_OFFSET;	/* offset to string area in seg	*/\n", "  long			LABEL_IX;	/* index to DD$DSP_LABELS	*/\n", "  long			SEG_ITEM_IX;	/* index to DD$STD_SEG_ITEMS	*/\n", "  }\n", " DD$STD_SEGS_DSD, *DD$STD_SEGS_DSD_PTR;\n", "\n", "\n", "\n", "	/**** Structure definition for std record array ****/\n", "\n", "typedef struct\n", "  {\n", "  short			TYPE;\n", "  short			SUBTYPE;\n", "  short			VERSION;\n", "  short			TAILOR_ID;\n", "  short			COUNT;		/* count of segs in rec		*/\n", "  short                 FILLER1;        /* filler                       */\n", "  long			SEG_IX;		/* index to DD$STD_SEGS		*/\n", "  }\n", " DD$STD_RECORD_DSD, *DD$STD_RECORD_DSD_PTR;\n", "\n", "\n", "	/**** Standard Data Structure Definition Context Structure ****/\n", "\n", "typedef struct\n", "  {					/* Table access function info	*/\n", "  int			CTX_type;	/* Not for use by application	*/\n", "  int			curr_item;	/* Not for use by application	*/\n", "  int			curr_field;	/* Not for use by application	*/\n", "						/* Data_record info	*/\n", "  DD$STD_RECORD_DSD_PTR	rec_DSD_ptr;	/* pointer to curr record DSD	*/\n", "						/* Data-segment info	*/\n", "  DD$STD_HEADER_PTR	segment_ptr;	/* Pointer to curr data-segment */\n", "  DD$STD_SEGS_DSD_PTR	segment_DSD_ptr;/* Pointer to curr segment DSD	*/\n", "  int			segment_VALID_code;\n", "						/* Data-item info	*/\n", "  DD$BYTE		*item_ptr;	/* Pointer to curr data-item	*/\n", "  DD$STD_ITEMS_DSD_PTR	item_DSD_ptr;	/* Pointer to curr item DSD	*/\n", "  int			item_VALID_code;\n", "\n", "						/* Register field info	*/\n", "  DD$BYTE		field_position;	/* Bits to right of field	*/\n", "  DD$STD_REGS_DSD_PTR	field_DSD_ptr;	/* Pointer to curr field DSD	*/\n", "						/* Coded item info	*/\n", "  DD$STD_CODES_DSD_PTR	code_DSD_ptr;	/* pointer to curr codes DSD	*/\n", "						/* Application infor	*/\n", "  long			user_1;		/* Reserved for application	*/\n", "  long			user_2;		/* Reserved for application	*/\n", "  long			user_3;		/* Reserved for application	*/\n", "}\n", " DD$STD_DSD_CTX, *DD$STD_DSD_CTX_PTR;\n", "\n", "\n", "\n", "/********** STRUCTURE DEFINITIONS FOR DISPLAY DSD TABLES **********/\n", "\n", "\n", "	/**** Structure definition for the label DSD array ****/\n", "\n", "typedef struct\n", "  {\n", "  DD$BYTE		TYPE;		/* display type (hex, dec etc)	*/\n", "  DD$BYTE		COUNT;		/* length of label		*/\n", "  short                 FILLER1;        /* filler                       */\n", "  long			STRINGS_IX;	/* index to strings array	*/\n", "  }\n", " DD$DSP_LABELS, *DD$DSP_LABELS_PTR;\n", "\n", "\n", "/* End of std_dsd.h */\n", "\0"};char *os_h_fixed1[] = { "/*\n", "**	.title Operating system DSD definitions\n", "**	.ident / 1.14 /\n", "**\n", "**\n", "**	  File:	ultrix_dsd.h\n", "** Description:	Operating system DSD definitions\n", "**	Author:	Luis Arce\n", "**	  Date:	8-Oct-1986\n", "**\n", "**\n", "**	Copyright 1986, Digital Equipment Corporation\n", "**\n", "**\n", "**++\n", "**	These definitions were generated by the DSD Editor / Compiler\n", "**--\n", "*/\n", "\n", "\n", "\n", "#define OS_DSD_FILE_FORMAT 2\n", "\n", "\0"};char *os_h_fixed2[] = { "\n", "/********** STRUCTURE DEFINITIONS FOR THE OS DSD TABLES **********/\n", "\n", "	/**** Structure definition for an os data-item codes DSD ****/\n", "\n", "typedef struct\n", "  {\n", "  long			OS_CODE;\n", "  long		        STD_CODE;\n", "  }\n", " DD$OS_CODES_DSD, *DD$OS_CODES_DSD_PTR;\n", "\n", "	/**** Structure definition for an os data-item DSD ****/\n", "\n", "typedef struct\n", "  {\n", "  short			ID;		/* not same as index or std	*/\n", "  DD$BYTE		TYPE;		/* item type (long, coded etc)	*/\n", "  DD$BYTE               FILLER1;        /* filler                       */\n", "  short			COUNT;		/* for coded or vectors		*/\n", "  short                 FILLER2;        /* filler                       */\n", "  long			CODE_IX;	/* index to DD$OS_CODSE_DSD	*/\n", "  }\n", " DD$OS_ITEMS_DSD, *DD$OS_ITEMS_DSD_PTR;\n", "\n", "\n", "\n", "/* End of ultrix_dsd.h */\n", "\0"};process_args(argc, argv, arge)int argc;char **argv, **arge;{	char *cp, c;	cmd_name = *argv++;	for(;*argv;argv++){		cp = *argv;		if(*cp++ != '-')			break;		while(c= *cp++){			switch(c) {				case 'a':					opt_auto_assign = 1;					break;				case 'd':					opt_d = 1;					break;				case 'i':					opt_i = 1;					break;				case 'j':					opt_j = 1;					break;				default:					errval = 1;					fprintf(stderr, "Error, Unknown option: '%c'\n", c);				case 'h':printf("Usage: %s options filenames\n", cmd_name);printf("  Option a = assign id numbers automatically\n");printf("  Option i = use old method of index value assignment (by position)\n");printf("  Option j = issue warning if given index values differs from position\n");					break;			}		}	}	db_files = argv;}print_where(){	fprintf(stderr, "File %s, line %d: %s\n", in_name, lineno, linebuf);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -