1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#define S_BUF 1000
int desc;
void open_pipe()
{
if (( desc = open ("tube",O_RDWR,0666)) == -1)
{
perror ("open");
exit (1);
}
}
void wr_pipe(char* buffer)
{
int n;
n= write(desc,buffer, strlen(buffer));
if (n == -1)
{
perror (buffer);
exit (1);
}
}
void rd_pipe(char* buffer)
{
int n;
memset(buffer,'\0',S_BUF);
n= read (desc, buffer, S_BUF);
if (n == -1)
{
perror ("read");
exit (1);
}
}
int main()
{
int n;
char buffer[S_BUF] = {0};
char tmp[S_BUF] = {0};
FILE *cgiOut;
n=51000;
cgiOut = stdout;
fprintf(cgiOut,"<meta content=\"text/html; charset=ISO-8859-1\"http-equiv=\"content-type\"> \n\n");
fprintf(cgiOut,"<meta Content-type: multipart/x-mixed-replace;boundary=ThisRandomString>\n");
fprintf(cgiOut,"<meta Connection : Keep-Alive>\n");
fprintf(cgiOut,"<meta Keep-Alive : timeout=15, max=100>\n");
fprintf(cgiOut,"<html><header><title>Test</title></header><body>\n\n");
strcpy(tmp,"<table style=\"text-align: left; width: 989px; height: 30px;\" border=\"1\"");
strcat(tmp,"cellpadding=\"2\" cellspacing=\"2\"><tbody><tr><td style=\"vertical-align: top;\"><a href=\"index.html\"");
strcat(tmp,">accueil</a></td><td style=\"vertical-align: top;\"><a href=\"description.html\">Description");
strcat(tmp,"de la carte</a></td>");
strcat(tmp,"<td style=\"vertical-align: top;\"><a href=\"config.html\">config</a><br>");
strcat(tmp,"<td style=\"vertical-align: top;\"><a href=\"type.html\">type</a><br></td></tr></tbody></table>\n");
fprintf(cgiOut,"%s\n",tmp);
open_pipe();
wr_pipe("banniere : ");
rd_pipe(buffer);
fprintf(stdout,"%s\n",buffer);
close(desc);
return 0;
} |
Partager