int main (int argc, char *argv[]) { uulist *item; int i, res; UUInitialize (); for (i=1; i<argc; i++) if ((res = UULoadFile (argv[i], NULL, 0)) != UURET_OK) fprintf (stderr, "could not load %s: %s\n", argv[i], (res==UURET_IOERR) ? strerror (UUGetOption (UUOPT_ERRNO, NULL, NULL, 0)) : UUstrerror(res)); for (i=0; (item=UUGetFileListItem(i)) != NULL; i++) { if ((item->state & UUFILE_OK) == 0) continue; if ((res = UUDecodeFile (item, NULL)) != UURET_OK) { fprintf (stderr, "error decoding %s: %s\n", (item->filename==NULL)?"oops":item->filename, (res==UURET_IOERR) ? strerror (UUGetOption (UUOPT_ERRNO, NULL, NULL, 0)) : UUstrerror(res)); } else { printf ("successfully decoded '%s'\n", item->filename); } } UUCleanUp (); return 0; }
int main (int argc, char *argv[]) { UUInitialize (); UULoadFile (argv[1], NULL, 0); UUDecodeFile (UUGetFileListItem (0), NULL); UUCleanUp (); return 0; }
static int UUTCLFUNC uutcl_DecodeFile (ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { char tmpstring[256]; uulist *iter; int res; uutcl_UpdateParameter (interp); if (argc < 2 || argc > 3) { sprintf (tmpstring, "wrong # args: should be \"%s number ?targetname?\"", argv[0]); Tcl_SetResult (interp, tmpstring, TCL_VOLATILE); return TCL_ERROR; } if ((iter = UUGetFileListItem (atoi (argv[1]))) == NULL) { Tcl_SetResult (interp, "invalid file number", TCL_STATIC); return TCL_ERROR; } if ((res = UUDecodeFile (iter, (argc==3)?argv[2]:NULL)) != UURET_OK) { sprintf (tmpstring, "Error while decoding %s (%s): %s (%s)", (iter->filename) ? iter->filename : "", (iter->subfname) ? iter->subfname : "", UUstrerror (res), (res==UURET_IOERR)? strerror(UUGetOption(UUOPT_ERRNO,NULL,NULL,0)):""); Tcl_SetResult (interp, tmpstring, TCL_VOLATILE); return TCL_ERROR; } return TCL_OK; }