cgi-send.c
来自「ace开发环境 用来开发网络程序 其运用了设计模式、多平台、C++等多种知识」· C语言 代码 · 共 47 行
C
47 行
/* $Id: cgi-send.c 32986 2000-06-04 22:02:08Z brunsch $ *//* * Send 10K file; send random bits. * */#include <stdio.h>#include <stdlib.h>#define FILE_SIZE 10240#define MALLOC_FAILURE "Out of memory"intmain(){ int filesize; char *str_filesize; char *buffer; int index; printf("Content-type: text/plain\r\n\r\n"); if ( !(str_filesize = getenv("QUERY_STRING")) ) filesize = FILE_SIZE; else { if ( !strncmp(str_filesize, "size=", 5) ) filesize = atoi(&(str_filesize[5])); else filesize = FILE_SIZE; } if ( !(buffer = (char *)malloc(filesize)) ) { fwrite(MALLOC_FAILURE, strlen(MALLOC_FAILURE), 1, stdout); return -1; } for (index=0; index< filesize; index++) /* generate random characters from A-Z */ buffer[index] = rand() %26 + 63; fwrite(buffer, filesize, 1, stdout); free(buffer); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?