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

📄 t_api.c

📁 bind 9.3结合mysql数据库
💻 C
📖 第 1 页 / 共 2 页
字号:
		default:			p = "UNKNOWN";			break;	}	printf("R:%s\n", p);}char *t_getenv(const char *name) {	char	*n;	char	**p;	size_t	len;	n = NULL;	if (name && *name) {		p = &T_env[0];		len = strlen(name);		while (*p != NULL) {			if (strncmp(*p, name, len) == 0) {				if ( *(*p + len) == '=') {					n = *p + len + 1;					break;				}			}			++p;		}	}	return(n);}/* * * Read in the config file at path, initializing T_env. * * note: no format checking for now ... * */static intt_initconf(const char *path) {	int	n;	int	rval;	char	**p;	FILE	*fp;	rval = -1;	fp = fopen(path, "r");	if (fp != NULL) {		n = 0;		p = &T_env[0];		while (n < T_MAXENV) {			*p = t_fgetbs(fp);			if (*p == NULL)				break;			if ((**p == '#') || (strchr(*p, '=') == NULL)) {				/*				 * Skip comments and other junk.				 */				(void)free(*p);				continue;			}			++p; ++n;		}		(void)fclose(fp);		rval = 0;	}	return (rval);}/* * * Dump T_env to stdout. * */static intt_dumpconf(const char *path) {	int	rval;	char	**p;	FILE	*fp;	rval = -1;	fp = fopen(path, "r");	if (fp != NULL) {		p = &T_env[0];		while (*p != NULL) {			printf("C:%s\n", *p);			++p;		}		(void) fclose(fp);		rval = 0;	}	return(rval);}/* * * Read a newline or EOF terminated string from fp. * On success: *	return a malloc'd buf containing the string with *	the newline converted to a '\0'. * On error: *	return NULL. * * Caller is responsible for freeing buf. * */char *t_fgetbs(FILE *fp) {	int	c;	size_t	n;	size_t	size;	char	*buf;	char	*p;	n	= 0;	size	= T_BUFSIZ;	buf	= (char *) malloc(T_BUFSIZ * sizeof(char));	if (buf != NULL) {		p = buf;		while ((c = fgetc(fp)) != EOF) {			if (c == '\n')				break;			*p++ = c;			++n;			if ( n >= size ) {				size += T_BUFSIZ;				buf = (char *)realloc(buf,						      size * sizeof(char));				if (buf == NULL)					break;				p = buf + n;			}		}		*p = '\0';		return(((c == EOF) && (n == 0U)) ? NULL : buf);	} else {		fprintf(stderr, "malloc failed %d", errno);		return(NULL);	}}/* * * Put info to log, using key. * For now, just dump it out. * Later format into pretty lines. * */static intt_putinfo(const char *key, const char *info) {	int	rval;	/*	 * For now.	 */	rval = printf("%s:%s", key, info);	return(rval);}static char *t_getdate(char *buf, size_t buflen) {	size_t		n;	time_t		t;	struct tm	*p;	t = time(NULL);	p = localtime(&t);	n = strftime(buf, buflen - 1, "%A %d %B %H:%M:%S %Y\n", p);	return(n != 0U ? buf : NULL);}/* * Some generally used utilities. */struct dns_errormap {	isc_result_t	result;	const char *text;} dns_errormap[] = {	{ ISC_R_SUCCESS,		"ISC_R_SUCCESS"		},	{ ISC_R_EXISTS,			"ISC_R_EXISTS"		},	{ ISC_R_NOTFOUND,		"ISC_R_NOTFOUND"	},	{ ISC_R_NOSPACE,		"ISC_R_NOSPACE"		},	{ ISC_R_UNEXPECTED,		"ISC_R_UNEXPECTED"	},	{ ISC_R_UNEXPECTEDEND,		"ISC_R_UNEXPECTEDEND"	},	{ ISC_R_RANGE,			"ISC_R_RANGE"		},	{ DNS_R_LABELTOOLONG,		"DNS_R_LABELTOOLONG"	},	{ DNS_R_BADESCAPE,		"DNS_R_BADESCAPE"	},	/* { DNS_R_BADBITSTRING,	"DNS_R_BADBITSTRING"	}, */	/* { DNS_R_BITSTRINGTOOLONG,	"DNS_R_BITSTRINGTOOLONG"}, */	{ DNS_R_EMPTYLABEL,		"DNS_R_EMPTYLABEL"	},	{ DNS_R_BADDOTTEDQUAD,		"DNS_R_BADDOTTEDQUAD"	},	{ DNS_R_UNKNOWN,		"DNS_R_UNKNOWN"		},	{ DNS_R_BADLABELTYPE,		"DNS_R_BADLABELTYPE"	},	{ DNS_R_BADPOINTER,		"DNS_R_BADPOINTER"	},	{ DNS_R_TOOMANYHOPS,		"DNS_R_TOOMANYHOPS"	},	{ DNS_R_DISALLOWED,		"DNS_R_DISALLOWED"	},	{ DNS_R_EXTRATOKEN,		"DNS_R_EXTRATOKEN"	},	{ DNS_R_EXTRADATA,		"DNS_R_EXTRADATA"	},	{ DNS_R_TEXTTOOLONG,		"DNS_R_TEXTTOOLONG"	},	{ DNS_R_SYNTAX,			"DNS_R_SYNTAX"		},	{ DNS_R_BADCKSUM,		"DNS_R_BADCKSUM"	},	{ DNS_R_BADAAAA,		"DNS_R_BADAAAA"		},	{ DNS_R_NOOWNER,		"DNS_R_NOOWNER"		},	{ DNS_R_NOTTL,			"DNS_R_NOTTL"		},	{ DNS_R_BADCLASS,		"DNS_R_BADCLASS"	},	{ DNS_R_PARTIALMATCH,		"DNS_R_PARTIALMATCH"	},	{ DNS_R_NEWORIGIN,		"DNS_R_NEWORIGIN"	},	{ DNS_R_UNCHANGED,		"DNS_R_UNCHANGED"	},	{ DNS_R_BADTTL,			"DNS_R_BADTTL"		},	{ DNS_R_NOREDATA,		"DNS_R_NOREDATA"	},	{ DNS_R_CONTINUE,		"DNS_R_CONTINUE"	},	{ DNS_R_DELEGATION,		"DNS_R_DELEGATION"	},	{ DNS_R_GLUE,			"DNS_R_GLUE"		},	{ DNS_R_DNAME,			"DNS_R_DNAME"		},	{ DNS_R_CNAME,			"DNS_R_CNAME"		},	{ DNS_R_NXDOMAIN,		"DNS_R_NXDOMAIN"	},	{ DNS_R_NXRRSET,		"DNS_R_NXRRSET"		},	{ DNS_R_BADDB,			"DNS_R_BADDB"		},	{ DNS_R_ZONECUT,		"DNS_R_ZONECUT"		},	{ DNS_R_NOTZONETOP,		"DNS_R_NOTZONETOP"	},	{ DNS_R_SEENINCLUDE,		"DNS_R_SEENINCLUDE"	},	{ DNS_R_SINGLETON,		"DNS_R_SINGLETON"	},	{ (isc_result_t)0, NULL }};isc_result_tt_dns_result_fromtext(char *name) {	isc_result_t		result;	struct dns_errormap	*pmap;	result = ISC_R_UNEXPECTED;	pmap = dns_errormap;	while (pmap->text != NULL) {		if (strcmp(name, pmap->text) == 0)			break;		++pmap;	}	if (pmap->text != NULL)		result = pmap->result;	return (result);}struct dc_method_map {	unsigned int	dc_method;	const char 	*text;} dc_method_map[] = {	{	DNS_COMPRESS_NONE,	"DNS_COMPRESS_NONE"	},	{	DNS_COMPRESS_GLOBAL14,	"DNS_COMPRESS_GLOBAL14"	},	{	DNS_COMPRESS_ALL,	"DNS_COMPRESS_ALL"	},	{	0,			NULL			}};unsigned intt_dc_method_fromtext(char *name) {	unsigned int		dc_method;	struct dc_method_map	*pmap;	dc_method = DNS_COMPRESS_NONE;	pmap = dc_method_map;	while (pmap->text != NULL) {		if (strcmp(name, pmap->text) == 0)			break;		++pmap;	}	if (pmap->text != NULL)		dc_method = pmap->dc_method;	return(dc_method);}intt_bustline(char *line, char **toks) {	int	cnt;	char	*p;	cnt = 0;	if (line && *line) {		while ((p = strtok(line, "\t")) && (cnt < T_MAXTOKS)) {			*toks++ = p;			line = NULL;			++cnt;		}	}	return(cnt);}static voidprinthelp(void) {	int		cnt;	testspec_t	*pts;	cnt = 1;	pts = &T_testlist[0];	printf("Available tests:\n");	while (pts->func_name) {		printf("\t%d\t%s\n", cnt, pts->func_name);		++pts;		++cnt;	}}static voidprintusage(void) {	printf("Usage:\n%s\n", Usage);}intt_eval(const char *filename, int (*func)(char **), int nargs) {	FILE		*fp;	char		*p;	int		line;	int		cnt;	int		result;	int		nfails;	int		nprobs;	int		npass;	char		*tokens[T_MAXTOKS + 1];	npass = 0;	nfails = 0;	nprobs = 0;	fp = fopen(filename, "r");	if (fp != NULL) {		line = 0;		while ((p = t_fgetbs(fp)) != NULL) {			++line;			/*			 * Skip comment lines.			 */			if ((isspace((unsigned char)*p)) || (*p == '#'))				continue;			cnt = t_bustline(p, tokens);			if (cnt == nargs) {				result = func(tokens);				switch (result) {				case T_PASS:					++npass;					break;				case T_FAIL:					++nfails;					break;				case T_UNTESTED:					break;				default:					++nprobs;					break;				}			} else {				t_info("bad format in %s at line %d\n",						filename, line);				++nprobs;			}			(void)free(p);		}		(void)fclose(fp);	} else {		t_info("Missing datafile %s\n", filename);		++nprobs;	}	result = T_UNRESOLVED;	if (nfails == 0 && nprobs == 0 && npass > 0)		result = T_PASS;	else if (nfails > 0)		result = T_FAIL;	else if (npass == 0)		result = T_UNTESTED;	return (result);}

⌨️ 快捷键说明

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