home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
-
- #include <netinet/in.h>
-
- int main(int argc, char *argv[])
- {
- char bbuf[5000];
- unsigned long xlong;
- unsigned short xshort;
- long bbuflen;
- int i;
- FILE *outfd, *infd;
- int argp;
-
- if (argc < 2) {
- fprintf(stderr, "Usage: %s prcfile\n", argv[0]);
- exit(1);
- }
-
- for (argp = 1; argp < argc; argp++) {
- strcpy(bbuf, argv[argp]);
-
- infd = fopen(bbuf, "r");
-
- if (!strcmp(&bbuf[strlen(bbuf) - 4], ".pdb"))
- bbuf[strlen(bbuf) - 4] = 0;
- else
- strcat(bbuf, ".out");
-
- outfd = fopen(bbuf, "w");
-
- fseek(infd, 76, SEEK_SET);
- fread(&xshort, 1, 2, infd);
- fread(&xlong, 1, 4, infd);
-
- xshort = htons(xshort);
- xlong = htonl(xlong);
- fseek(infd, xlong, SEEK_SET);
-
- for (i = 0; i < xshort; i++) {
- bbuflen = fread(bbuf, 1, 4104, infd);
- if (bbuflen < 8 || strncmp(bbuf, "DBLK", 4))
- exit(-2);
- fwrite(&bbuf[8], 1, bbuflen - 8, outfd);
- }
- fclose(outfd);
- fclose(infd);
- }
- return 0;
- }
-