This commit is contained in:
2026-06-18 18:13:12 +08:00
parent 2f42b036a9
commit 25f7ef1967
34 changed files with 2107 additions and 2 deletions

BIN
server-exp3/cgi-bin/add Normal file

Binary file not shown.

27
server-exp3/cgi-bin/add.c Normal file
View File

@@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINE 8192
int main(void) {
char *buf, *p;
char content[MAXLINE];
int n1=0, n2=0;
/* Extract the two arguments from standard input */
scanf("%d&%d", &n1, &n2);
/* Make the response body */
sprintf(content, "Welcome to add.com: ");
sprintf(content, "%sTHE Internet addition portal.\r\n<p>", content);
sprintf(content, "%sThe answer is: %d + %d = %d\r\n<p>",
content, n1, n2, n1 + n2);
sprintf(content, "%sThanks for visiting!\r\n", content);
/* Generate the HTTP response */
printf("Content-length: %d\r\n", (int) strlen(content));
printf("Content-type: text/html\r\n\r\n");
printf("%s", content);
fflush(stdout);
exit(0);
}