|
拡張子 | Content-type |
txt | text/plain |
htm html | text/html |
jpg jpeg | image/jpeg |
gif | image/gif |
bmp | image/bmp |
zip | application/x-zip-compressed |
doc | application/msword |
xls | application/vnd.ms-excel |
ppt | application/vnd.ms-powerpoint |
exe dll | application/vnd.ms-download |
eml mht mhtml nws | message/rfc822 |
fdf | application/vnd.fdf |
pdf | application/pdf |
rmi | audio/mid |
qt mov | video/quicktime |
avi | video/x-msvideo |
tiff | image/tiff |
wav mp1 mp2 mp3 | audio/wav |
als | Audio/X-Alpha5 |
以外 | application/octet-stream |
|
|
|
#include <stdio.h>
void
main( int argc, char *argv[] )
{
int i;
printf( "Content-Type: text/html; Charset=shift_jis\n\n" );
printf( "<HTML>\n" );
printf( "<HEAD><TITLE>\n" );
printf( "%s\n", argv[0] );
printf( "</TITLE></HEAD>\n" );
printf( "<BODY>\n" );
printf( "<TABLE border=1>\n" );
for( i = 1; i < argc; i++ ) {
printf( "<TR>\n" );
printf( "<td>%s</td>\n", argv[i] );
printf( "</TR>\n" );
}
printf( "</TABLE>\n" );
printf( "</BODY>\n" );
printf( "</HTML>\n" );
}
| |
|
|
引き数の表示(2) printf --> fprintf |
|
|
#include <stdio.h>
void
main( int argc, char *argv[] )
{
int i;
fprintf( stdout, "Content-Type: text/html; Charset=shift_jis\n\n" );
fprintf( stdout, "<HTML>\n" );
fprintf( stdout, "<HEAD><TITLE>\n" );
fprintf( stdout, "%s\n", argv[0] );
fprintf( stdout, "</TITLE></HEAD>\n" );
fprintf( stdout, "<BODY>\n" );
fprintf( stdout, "<TABLE border=1>\n" );
for( i = 1; i < argc; i++ ) {
fprintf( stdout, "<TR>\n" );
fprintf( stdout, "<td>%s</td>\n", argv[i] );
fprintf( stdout, "</TR>\n" );
}
fprintf( stdout, "</TABLE>\n" );
fprintf( stdout, "</BODY>\n" );
fprintf( stdout, "</HTML>\n" );
}
| |
|
|
|
|
#include <stdio.h>
#include <fcntl.h>
void
main( int argc, char *argv[] )
{
int gif;
int size = 6837;
int i;
char buff[1024];
fprintf( stdout, "Content-type: image/gif\n" );
fprintf( stdout, "Content-length: 6837\n\n" );
gif = open( "d:\\kadai\\doumi\\yahoo.gif", O_RDONLY | O_BINARY );
setmode( fileno(stdout), O_BINARY );
while( 1 ) {
i = read( gif, buff, 1000 );
if ( i <= 0 ) {
break;
}
size = size - i;
fwrite( buff, i, 1, stdout );
if ( size <= 0 ) {
break;
}
}
close( gif );
}
| |
|
|
|