|
|
BSD 4.3reno
/* d_main.c - make the decode routine into a stand alone program */
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/photo/d_main.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif
/*
* $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/photo/d_main.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*
*
* $Log: d_main.c,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.1 90/03/15 11:18:08 mrose
* quipu-sync
*
* Revision 7.0 89/11/23 22:01:36 mrose
* Release 6.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
#include <sys/file.h>
#include <stdio.h>
#include "quipu/photo.h"
int two_passes = 0;
char *getenv ();
main (argc,argv)
int argc;
char ** argv;
{
char *inbuf;
char *cp;
char * name;
int n, count, len;
char * malloc();
if (argc > 1)
name = *++argv;
else
if ((name = getenv ("RDN")) == 0)
name = "unknown";
if ((len = find_size()) < 0) {
fprintf(stderr, "\n");
exit(-1);
}
if ((inbuf = malloc(len)) < 0) {
fprintf(stderr, "PHOTO: Couldn't malloc() %d bytes\n", n);
exit(-1);
}
for (cp = inbuf, n = len; n > 0; ) {
if ((count = read (0, cp, n)) <= 0)
break;
cp += count;
n -= count;
}
if (decode_t4 (inbuf, name, len) == -1) {
(void) fprintf (stderr,"\n");
exit (-1);
}
if (two_passes && decode_t4 (inbuf, name, len) == -1) {
(void) fprintf (stderr,"\n");
exit (-1);
}
}
static find_size()
{
char c, i;
long size = 0;
/* read the ASN.1 "magic number" for bitstring */
read(0, &c, 1);
/* how many of the next N bytes store the size? */
read(0, &c, 1);
for (c &= 0x7f; c > 0; c--) {
read(0, &i, 1);
size = (size << 8) | (i & 0xff);
}
return(size);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.