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

📄 test.c

📁 this is very good for teacher
💻 C
字号:
#include <stack.h>#include <errno.h>#include <stdio.h>#include <list.h>#include <hlink.h>#include <uri.h>#define BUFSIZE		4096int filter(const struct uri *uri, void *context){	return 1;}int main(int argc, char *argv[]){	char a; int b; long c; float d; double e;	LIST_HEAD(head);	struct list_head *pos;	FILE *file;	struct hlink *node;	struct uri page_uri;	int len, nhlinks;	char uristr[BUFSIZE];	STACK *stack;	if (argc < 2 || argc > 3)	{		fprintf(stderr, "USAGE: test <page file> [page uri]\n");		exit(1);	}	if (!(file = fopen(argv[1], "r")))	{		fprintf(stderr, "opening %s: %s\n", argv[1], strerror(errno));		exit (1);	}	if (argc == 3)		len = uri_parse_string(&page_uri, argv[2]);	else		len = uri_parse_bytes(&page_uri, NULL, 0);	if (len < 0)	{		perror("parse page uri");		exit(1);	}	fseek(file, SEEK_SET, 0);	if ((nhlinks = hlink_detect(&head, file, &page_uri, filter, NULL)) < 0)	{		fprintf(stderr, "detecting hyper links from %s: %s\n", argv[1],				strerror(errno));		uri_destroy(&page_uri);		exit(1);	}	list_for_each(pos, &head)	{		node = list_entry(pos, struct hlink, list);		if ((len = uri_recombine(&node->uri, uristr, BUFSIZE)) >= 0)			printf("%s\n", uristr);		else			printf("URI too long, we has insufficent space\n");		if (node->uri.scheme)			printf("scheme = %s\n", node->uri.scheme);		if (node->uri.authority)		{			if (node->uri.authority->type == AT_SERVER)			{				if (node->uri.authority->userinfo)					printf("userinfo = %s\n", node->uri.authority->userinfo);				if (node->uri.authority->host)					printf("host = %s\n", node->uri.authority->host);				if (node->uri.authority->port)					printf("port = %s\n", node->uri.authority->port);			}			else if (node->uri.authority->reg_name)				printf("reg_name = %s\n", node->uri.authority->reg_name);		}		if (node->uri.path)			printf("path = %s\n", node->uri.path);		if (node->uri.query)			printf("query = %s\n", node->uri.query);		if (node->uri.fragment)			printf("fragment = %s\n", node->uri.fragment);		printf("\n");	}	printf("%d hyper links detected in file %s\n", nhlinks, argv[1]);	hlink_destroy(&head);	uri_destroy(&page_uri);/*	stack = stack_new(1);	stack_push(stack, 1, int);	stack_push(stack, 'a', char);	stack_push(stack, 1.5, double);	stack_push(stack, 2.5, float);	stack_push(stack, 5000, long);	stack_push(stack, "hoho", const char *);	stack_push(stack, 123, long long);	printf("%lld\n", stack_top(stack, long long));	printf("%lld\n", stack_pop(stack, long long));	printf("%s\n", stack_top(stack, const char *));	printf("%s\n", stack_pop(stack, const char *));	printf("%ld\n", stack_pop(stack, long));	printf("%f\n", stack_pop(stack, float));	printf("%lf\n", stack_pop(stack, double));	printf("%c\n", stack_pop(stack, char));	printf("%d\n", stack_pop(stack, int));	stack_destroy(stack);*/	exit(0);}

⌨️ 快捷键说明

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