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

📄 test.cpp

📁 tftp client sorser code,Please download it and compolie it ,byebye
💻 CPP
字号:
#include <stdio.h>#include <ctype.h>#include <sys/types.h>#include <signal.h>#include <fcntl.h>#include <sys/stat.h>#include <errno.h>#include <string.h>#include "gzip.h"int main(int argc, char *argv[]){	char compress_buf[MAX_INBUF];	int compress_len = 0;	int len;	int ret;	int length;	long  n = 0;	long *uncompress_len;	int od;	int flags = O_WRONLY | O_CREAT | O_EXCL | O_BINARY;			memset(compress_buf, 0x00, MAX_INBUF);	ungzipbuf = (char *)malloc(MAX_OUTBUF);		if (argc < 3)	{		printf("argc error\n");		return;	}	ifd = open(argv[1], O_RDONLY | O_BINARY, S_IRWXU);	if (ifd <= 0)	{		perror(ifname);		printf("open file error\n");		return;	}	do 	{		len = read(ifd, compress_buf + compress_len, 1024);		if (len == 0 || len == EOF) 			break;		compress_len += len;	} while (compress_len < INBUFSIZ);	if (compress_len <= 0)	{		printf("read error\n");		return;	}	uncompress_len = &n;	ret = ungzip(compress_buf, compress_len, ungzipbuf, uncompress_len);	if (ret != OK)		return;	n = *uncompress_len;	if (ret != 0)		return;	od = open(argv[2], flags, S_IRUSR);	if (od <= 0)	{		printf("open out file error\n");		return;	}	while ((length = write(od, ungzipbuf, n)) != n)	{		n -= length;		ungzipbuf = ungzipbuf + length;		}	free(ungzipbuf);		close(od);	close(ifd);		return 0;}

⌨️ 快捷键说明

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