| verzia 1.10, 2002/10/08 19:46:49 |
verzia 1.11, 2002/10/09 22:06:35 |
| Riadok 165 void read_obj(long offset) |
|
| Riadok 165 void read_obj(long offset) |
|
| fget(&buffer[0], BUFLEN, fp); |
fget(&buffer[0], BUFLEN, fp); |
| }*/ |
}*/ |
| |
|
| |
/* add object to object structure */ |
| void add_obj(char *s) |
void add_obj(char *s) |
| { |
{ |
| long offset, old_off; |
long offset, old_off; |
| Riadok 174 void add_obj(char *s) |
|
| Riadok 175 void add_obj(char *s) |
|
| fseek(fp, old_off, SEEK_SET); |
fseek(fp, old_off, SEEK_SET); |
| } |
} |
| |
|
| |
/* get offset of start xref table */ |
| long get_startxref(void) |
long get_startxref(void) |
| { |
{ |
| char startxref[XREFLINE]; |
char startxref[XREFLINE]; |
| Riadok 194 long get_startxref(void) |
|
| Riadok 196 long get_startxref(void) |
|
| return strtoul(&startxref[i + 1], NULL, 10); |
return strtoul(&startxref[i + 1], NULL, 10); |
| } |
} |
| |
|
| /* find objects */ |
void probe_ptree(int num) |
| |
{ |
| |
char *p, **kids; |
| |
p = strstr(object[num]->unparsed, "/Type "); |
| |
if (!p) { |
| |
/* error */ |
| |
return; |
| |
} |
| |
if (!strcmp(p, "/Pages")) |
| |
object[num]->type = PAGES; |
| |
else { |
| |
object[num]->type = PAGE; |
| |
/* parse_page(num); */ |
| |
return; |
| |
} |
| |
p = strstr(object[num]->unparsed, "/Kids "); |
| |
if (!p) { |
| |
/* error */ |
| |
return; |
| |
} |
| |
kids = array(p); |
| |
while (**kids != ']') { |
| |
/* some code */ |
| |
kids += 2; |
| |
} |
| |
} |
| |
|
| |
/* find objects and add it to object structure */ |
| void xref(void) |
void xref(void) |
| { |
{ |
| char xref[XREFLINE]; |
char xref[XREFLINE]; |
| Riadok 214 void xref(void) |
|
| Riadok 243 void xref(void) |
|
| fget(xref, XREFLINE, fp); |
fget(xref, XREFLINE, fp); |
| sscanf(xref, "%d %d", &entry[0], &entry[1]); |
sscanf(xref, "%d %d", &entry[0], &entry[1]); |
| if (entry[0] + entry[1] > obj_count) { |
if (entry[0] + entry[1] > obj_count) { |
| object = |
object = (struct object **) |
| (struct object **) realloc(object, |
realloc(object, |
| entry[0] + |
entry[0] + entry[1] + 1); |
| entry[1] + 1); |
|
| obj_count = entry[0] + entry[1]; |
obj_count = entry[0] + entry[1]; |
| } |
} |
| if (!entry[0]) |
if (!entry[0]) |
| Riadok 232 void xref(void) |
|
| Riadok 260 void xref(void) |
|
| trailer.prev = 0; |
trailer.prev = 0; |
| while (xref[0] != '>' && xref[1] != '>') { |
while (xref[0] != '>' && xref[1] != '>') { |
| if (!strncmp(xref, "/Root", 5)) |
if (!strncmp(xref, "/Root", 5)) |
| sscanf(xref, "/Root %d 0 R\n", |
sscanf(xref, |
| |
"/Root %d 0 R \n", |
| &trailer.root); |
&trailer.root); |
| if (!strncmp(xref, "/Info", 5)) |
if (!strncmp(xref, "/Info", 5)) |
| sscanf(xref, "/Info %d 0 R\n", |
sscanf(xref, |
| |
"/Info %d 0 R \n", |
| &trailer.info); |
&trailer.info); |
| if (!strncmp(xref, "/Prev", 5)) |
if (!strncmp(xref, "/Prev", 5)) |
| sscanf(xref, "/Prev %ld", |
sscanf(xref, "/Prev %ld", |
| Riadok 250 void xref(void) |
|
| Riadok 280 void xref(void) |
|
| return; |
return; |
| } |
} |
| |
|
| |
int parse_catalog(void) |
| |
{ |
| |
char *p; |
| |
struct catalog *c; |
| |
object[trailer.root]->type = CATALOG; |
| |
p = strstr(object[trailer.root]->unparsed, "/Pages"); |
| |
if (!p) { |
| |
/* error */ |
| |
return; |
| |
} |
| |
object[trailer.root]->parsed = c = |
| |
(struct catalog *) xmalloc(sizeof(struct catalog)); |
| |
sscanf(p, "/Pages %d 0 R \n", &c->pages); |
| |
free(object[trailer.root]->unparsed); |
| |
object[trailer.root]->unparsed = NULL; |
| |
return c->pages; |
| |
} |
| |
|
| int parse_pdf(void) |
int parse_pdf(void) |
| { |
{ |
| |
int ret; |
| xref(); |
xref(); |
| |
ret = parse_catalog(); |
| |
/* probe_ptree(ret); */ |
| return 0; |
return 0; |
| } |
} |