|
|
1.1 ! root 1: /* d_main.c - make the decode routine into a stand alone program */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/others/quipu/photo/RCS/d_main.c,v 7.1 90/03/15 11:18:08 mrose Exp $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/others/quipu/photo/RCS/d_main.c,v 7.1 90/03/15 11:18:08 mrose Exp $ ! 9: * ! 10: * ! 11: * $Log: d_main.c,v $ ! 12: * Revision 7.1 90/03/15 11:18:08 mrose ! 13: * quipu-sync ! 14: * ! 15: * Revision 7.0 89/11/23 22:01:36 mrose ! 16: * Release 6.0 ! 17: * ! 18: */ ! 19: ! 20: /* ! 21: * NOTICE ! 22: * ! 23: * Acquisition, use, and distribution of this module and related ! 24: * materials are subject to the restrictions of a license agreement. ! 25: * Consult the Preface in the User's Manual for the full terms of ! 26: * this agreement. ! 27: * ! 28: */ ! 29: ! 30: ! 31: ! 32: #include <sys/file.h> ! 33: #include <stdio.h> ! 34: #include "quipu/photo.h" ! 35: ! 36: ! 37: int two_passes = 0; ! 38: ! 39: char *getenv (); ! 40: ! 41: main (argc,argv) ! 42: int argc; ! 43: char ** argv; ! 44: { ! 45: char *inbuf; ! 46: char *cp; ! 47: char * name; ! 48: int n, count, len; ! 49: char * malloc(); ! 50: ! 51: if (argc > 1) ! 52: name = *++argv; ! 53: else ! 54: if ((name = getenv ("RDN")) == 0) ! 55: name = "unknown"; ! 56: ! 57: if ((len = find_size()) < 0) { ! 58: fprintf(stderr, "\n"); ! 59: exit(-1); ! 60: } ! 61: if ((inbuf = malloc(len)) < 0) { ! 62: fprintf(stderr, "PHOTO: Couldn't malloc() %d bytes\n", n); ! 63: exit(-1); ! 64: } ! 65: for (cp = inbuf, n = len; n > 0; ) { ! 66: if ((count = read (0, cp, n)) <= 0) ! 67: break; ! 68: cp += count; ! 69: n -= count; ! 70: } ! 71: ! 72: if (decode_t4 (inbuf, name, len) == -1) { ! 73: (void) fprintf (stderr,"\n"); ! 74: exit (-1); ! 75: } ! 76: if (two_passes && decode_t4 (inbuf, name, len) == -1) { ! 77: (void) fprintf (stderr,"\n"); ! 78: exit (-1); ! 79: } ! 80: } ! 81: ! 82: static find_size() ! 83: { ! 84: char c, i; ! 85: long size = 0; ! 86: ! 87: /* read the ASN.1 "magic number" for bitstring */ ! 88: read(0, &c, 1); ! 89: ! 90: /* how many of the next N bytes store the size? */ ! 91: read(0, &c, 1); ! 92: for (c &= 0x7f; c > 0; c--) { ! 93: read(0, &i, 1); ! 94: size = (size << 8) | (i & 0xff); ! 95: } ! 96: ! 97: return(size); ! 98: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.