Rozdiely pre cpdf/cpdf.c medzi verziami 1.1 a 1.2
| verzia 1.1, 2002/08/11 19:25:52 |
verzia 1.2, 2002/08/11 19:36:35 |
|
|
| |
#include <stdio.h> |
| |
#include <stdlib.h> |
| |
#include <string.h> |
| |
#include <sys/stat.h> |
| |
#include <unistd.h> |
| |
#include <fcntl.h> |
| |
#include <vga.h> |
| |
#include <vgagl.h> |
| |
#include "pdf.h" |
| |
void usage(char *prg) |
| |
{ |
| |
printf("Use %s pdffile\n", prg); |
| |
exit(-1); |
| |
} |
| |
|
| |
int main(int argc, char *argv[]) |
| |
{ |
| |
FILE *fp; |
| |
char *buffer; |
| |
struct stat sbuf; |
| |
if (argc == 1) |
| |
usage(argv[0]); |
| |
if (stat(argv[1], &sbuf) == -1) |
| |
usage(argv[0]); |
| |
buffer = (char *) malloc(sbuf.st_size); |
| |
if (buffer == NULL) { |
| |
perror("malloc"); |
| |
exit(-1); |
| |
} |
| |
fp = fopen(argv[1], "r"); |
| |
if(fread(buffer, sbuf.st_size, 1, fp) < 1) { |
| |
fprintf(stderr,"Can't read %s\n",argv[1]); |
| |
free(buffer); |
| |
exit(-1); |
| |
} |
| |
if(strncmp(buffer,"%PDF-",5) != 0) { |
| |
fprintf(stderr,"%s is not PDF document!\n",argv[1]); |
| |
free(buffer); |
| |
exit(-1); |
| |
} |
| |
fclose(fp); |
| |
vga_init(); |
| |
vga_setmode(10); |
| |
gl_setcontextvga(10); |
| |
gl_clearscreen(15); |
| |
/* parse_pdf(buffer); */ |
| |
getchar(); |
| |
vga_setmode(TEXT); |
| |
free(buffer); |
| |
exit(0); |
| |
} |
Platon Group <platon@platon.sk> http://platon.sk/
|
|