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

📄 gen.c

📁 bind 9.3结合mysql数据库
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003  Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. *//* $Id: gen.c,v 1.65.2.5.2.6 2004/03/15 01:02:54 marka Exp $ */#include <config.h>#include <sys/types.h>#include <ctype.h>#include <stdlib.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#ifdef WIN32#include "gen-win32.h"#else#include "gen-unix.h"#endif#define FROMTEXTARGS "rdclass, type, lexer, origin, options, target, callbacks"#define FROMTEXTCLASS "rdclass"#define FROMTEXTTYPE "type"#define FROMTEXTDEF "result = DNS_R_UNKNOWN"#define TOTEXTARGS "rdata, tctx, target"#define TOTEXTCLASS "rdata->rdclass"#define TOTEXTTYPE "rdata->type"#define TOTEXTDEF "use_default = ISC_TRUE"#define FROMWIREARGS "rdclass, type, source, dctx, options, target"#define FROMWIRECLASS "rdclass"#define FROMWIRETYPE "type"#define FROMWIREDEF "use_default = ISC_TRUE"#define TOWIREARGS "rdata, cctx, target"#define TOWIRECLASS "rdata->rdclass"#define TOWIRETYPE "rdata->type"#define TOWIREDEF "use_default = ISC_TRUE"#define FROMSTRUCTARGS "rdclass, type, source, target"#define FROMSTRUCTCLASS "rdclass"#define FROMSTRUCTTYPE "type"#define FROMSTRUCTDEF "use_default = ISC_TRUE"#define TOSTRUCTARGS "rdata, target, mctx"#define TOSTRUCTCLASS "rdata->rdclass"#define TOSTRUCTTYPE "rdata->type"#define TOSTRUCTDEF "use_default = ISC_TRUE"#define FREESTRUCTARGS "source"#define FREESTRUCTCLASS "common->rdclass"#define FREESTRUCTTYPE "common->rdtype"#define FREESTRUCTDEF NULL#define COMPAREARGS "rdata1, rdata2"#define COMPARECLASS "rdata1->rdclass"#define COMPARETYPE "rdata1->type"#define COMPAREDEF "use_default = ISC_TRUE"#define ADDITIONALDATAARGS "rdata, add, arg"#define ADDITIONALDATACLASS "rdata->rdclass"#define ADDITIONALDATATYPE "rdata->type"#define ADDITIONALDATADEF "use_default = ISC_TRUE"#define DIGESTARGS "rdata, digest, arg"#define DIGESTCLASS "rdata->rdclass"#define DIGESTTYPE "rdata->type"#define DIGESTDEF "use_default = ISC_TRUE"#define CHECKOWNERARGS "name, rdclass, type, wildcard"#define CHECKOWNERCLASS "rdclass"#define CHECKOWNERTYPE "type"#define CHECKOWNERDEF "result = ISC_TRUE"#define CHECKNAMESARGS "rdata, owner, bad"#define CHECKNAMESCLASS "rdata->rdclass"#define CHECKNAMESTYPE "rdata->type"#define CHECKNAMESDEF "result = ISC_TRUE"const char copyright[] ="/*\n"" * Copyright (C) 2004%s Internet Systems Consortium, Inc. (\"ISC\")\n"" * Copyright (C) 1998-2003 Internet Software Consortium.\n"" *\n"" * Permission to use, copy, modify, and distribute this software for any\n"" * purpose with or without fee is hereby granted, provided that the above\n"" * copyright notice and this permission notice appear in all copies.\n"" *\n"" * THE SOFTWARE IS PROVIDED \"AS IS\" AND ISC DISCLAIMS ALL WARRANTIES WITH\n"" * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n"" * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,\n"" * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n"" * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\n"" * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n"" * PERFORMANCE OF THIS SOFTWARE.\n"" */\n""\n""/***************\n"" ***************\n"" ***************   THIS FILE IS AUTOMATICALLY GENERATED BY gen.c.\n"" ***************   DO NOT EDIT!\n"" ***************\n"" ***************/\n""\n";#define TYPENAMES 256struct cc {	struct cc *next;	int rdclass;	char classname[11];} *classes;struct tt {	struct tt *next;	int rdclass;	int type;	char classname[11];	char typename[11];	char dirname[256];		/* XXX Should be max path length */} *types;struct ttnam {	char typename[11];	char macroname[11];	char attr[256];	unsigned int sorted;	int type;} typenames[TYPENAMES];int maxtype = -1;char *upper(char *);char *funname(const char *, char *);voiddoswitch(const char *, const char *, const char *, const char *,	 const char *, const char *);voiddodecl(char *, char *, char *);voidadd(int, const char *, int, const char *, const char *);voidsd(int, const char *, const char *, char);voidinsert_into_typenames(int, const char *, const char *);/* * If you use more than 10 of these in, say, a printf(), you'll have problems. */char *upper(char *s) {	static int buf_to_use = 0;	static char buf[10][256];	char *b;	int c;	buf_to_use++;	if (buf_to_use > 9)		buf_to_use = 0;	b = buf[buf_to_use];	memset(b, 0, 256);	while ((c = (*s++) & 0xff))		*b++ = islower(c) ? toupper(c) : c;	*b = '\0';	return (buf[buf_to_use]);}char *funname(const char *s, char *buf) {	char *b = buf;	char c;	while ((c = *s++)) {		*b++ = (c == '-') ? '_' : c;	}	*b = '\0';	return (buf);}voiddoswitch(const char *name, const char *function, const char *args,	 const char *tsw, const char *csw, const char *res){	struct tt *tt;	int first = 1;	int lasttype = 0;	int subswitch = 0;	char buf1[11], buf2[11];	const char *result = " result =";	if (res == NULL)		result = "";	for (tt = types; tt != NULL; tt = tt->next) {		if (first) {			fprintf(stdout, "\n#define %s \\\n", name);			fprintf(stdout, "\tswitch (%s) { \\\n" /*}*/, tsw);			first = 0;		}		if (tt->type != lasttype && subswitch) {			if (res == NULL)				fprintf(stdout, "\t\tdefault: break; \\\n");			else				fprintf(stdout,					"\t\tdefault: %s; break; \\\n", res);			fputs(/*{*/ "\t\t} \\\n", stdout);			fputs("\t\tbreak; \\\n", stdout);			subswitch = 0;		}		if (tt->rdclass && tt->type != lasttype) {			fprintf(stdout, "\tcase %d: switch (%s) { \\\n" /*}*/,				tt->type, csw);			subswitch = 1;		}		if (tt->rdclass == 0)			fprintf(stdout,				"\tcase %d:%s %s_%s(%s); break;",				tt->type, result, function,				funname(tt->typename, buf1), args);		else			fprintf(stdout,				"\t\tcase %d:%s %s_%s_%s(%s); break;",				tt->rdclass, result, function,				funname(tt->classname, buf1),				funname(tt->typename, buf2), args);		fputs(" \\\n", stdout);		lasttype = tt->type;	}	if (subswitch) {		if (res == NULL)			fprintf(stdout, "\t\tdefault: break; \\\n");		else			fprintf(stdout, "\t\tdefault: %s; break; \\\n", res);		fputs(/*{*/ "\t\t} \\\n", stdout);		fputs("\t\tbreak; \\\n", stdout);	}	if (first) {		if (res == NULL)			fprintf(stdout, "\n#define %s\n", name);		else			fprintf(stdout, "\n#define %s %s;\n", name, res);	} else {		if (res == NULL)			fprintf(stdout, "\tdefault: break; \\\n");		else			fprintf(stdout, "\tdefault: %s; break; \\\n", res);		fputs(/*{*/ "\t}\n", stdout);	}}voiddodecl(char *type, char *function, char *args) {	struct tt *tt;	char buf1[11], buf2[11];	fputs("\n", stdout);	for (tt = types; tt; tt = tt->next)		if (tt->rdclass)			fprintf(stdout,				"static inline %s %s_%s_%s(%s);\n",				type, function,				funname(tt->classname, buf1),				funname(tt->typename, buf2), args);		else			fprintf(stdout,				"static inline %s %s_%s(%s);\n",				type, function,				funname(tt->typename, buf1), args);}static struct ttnam *find_typename(int type) {	int i;	for (i = 0; i < TYPENAMES; i++) {		if (typenames[i].typename[0] != 0 &&		    typenames[i].type == type)			return (&typenames[i]);	}	return (NULL);}voidinsert_into_typenames(int type, const char *typename, const char *attr) {	struct ttnam *ttn = NULL;	int c, i;	char tmp[256];	for (i = 0; i < TYPENAMES; i++) {		if (typenames[i].typename[0] != 0 &&		    typenames[i].type == type &&		    strcmp(typename, typenames[i].typename) != 0) {			fprintf(stderr,				"Error:  type %d has two names: %s, %s\n",				type, typenames[i].typename, typename);			exit(1);		}		if (typenames[i].typename[0] == 0 && ttn == NULL)			ttn = &typenames[i];	}	if (ttn == NULL) {		fprintf(stderr, "Error: typenames array too small\n");		exit(1);	}		if (strlen(typename) > sizeof(ttn->typename) - 1) {		fprintf(stderr, "Error:  type name %s is too long\n",			typename);		exit(1);	}	strcpy(ttn->typename, typename);	ttn->type = type;	strcpy(ttn->macroname, ttn->typename);	c = strlen(ttn->macroname);	while (c > 0) {		if (ttn->macroname[c - 1] == '-')			ttn->macroname[c - 1] = '_';		c--;	}	if (attr == NULL) {		sprintf(tmp, "RRTYPE_%s_ATTRIBUTES", upper(ttn->macroname));		attr = tmp;	}	if (ttn->attr[0] != 0 && strcmp(attr, ttn->attr) != 0) {		fprintf(stderr, "Error:  type %d has different attributes: "			"%s, %s\n", type, ttn->attr, attr);		exit(1);	}	if (strlen(attr) > sizeof(ttn->attr) - 1) {		fprintf(stderr, "Error:  attr (%s) [name %s] is too long\n",			attr, typename);		exit(1);	}	strcpy(ttn->attr, attr);	ttn->sorted = 0;	if (maxtype < type)		maxtype = type;}voidadd(int rdclass, const char *classname, int type, const char *typename,    const char *dirname){	struct tt *newtt = (struct tt *)malloc(sizeof(*newtt));	struct tt *tt, *oldtt;	struct cc *newcc;	struct cc *cc, *oldcc;	insert_into_typenames(type, typename, NULL);	if (newtt == NULL) {		fprintf(stderr, "malloc() failed\n");		exit(1);	}	newtt->next = NULL;	newtt->rdclass = rdclass;	newtt->type = type;	strcpy(newtt->classname, classname);	strcpy(newtt->typename, typename);	strcpy(newtt->dirname, dirname);	tt = types;	oldtt = NULL;	while ((tt != NULL) && (tt->type < type)) {		oldtt = tt;		tt = tt->next;	}	while ((tt != NULL) && (tt->type == type) && (tt->rdclass < rdclass)) {		if (strcmp(tt->typename, typename) != 0)			exit(1);		oldtt = tt;		tt = tt->next;	}	if ((tt != NULL) && (tt->type == type) && (tt->rdclass == rdclass))		exit(1);	newtt->next = tt;	if (oldtt != NULL)		oldtt->next = newtt;	else		types = newtt;	/*	 * Do a class switch for this type.	 */	if (rdclass == 0)		return;	newcc = (struct cc *)malloc(sizeof(*newcc));	newcc->rdclass = rdclass;	strcpy(newcc->classname, classname);	cc = classes;	oldcc = NULL;	while ((cc != NULL) && (cc->rdclass < rdclass)) {		oldcc = cc;		cc = cc->next;	}	if ((cc != NULL) && cc->rdclass == rdclass) {		free((char *)newcc);		return;	}	newcc->next = cc;	if (oldcc != NULL)		oldcc->next = newcc;	else		classes = newcc;}

⌨️ 快捷键说明

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