Exemplo n.º 1
0
int main (int argc, char *argv[])
{
  uulist *item;
  int i, res;

  UUInitialize     ();
  UUSetMsgCallback (NULL, MsgCallBack);
  UUSetFNameFilter (NULL, FNameFilter);

  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' as '%s'\n",
	      item->filename,
	      UUFNameFilter (item->filename));
    }
  }
  UUCleanUp ();
  return 0;
}
Exemplo n.º 2
0
int UUTCLEXPORT UUTCLFUNC
Uu_Init (Tcl_Interp *interp)
{
  char tmp[32];

  /*
   * Check whether we are already initialized
   */

  if (uu_AlreadyInitialized++)
    return TCL_OK;

  /*
   * Initialize decoding engine
   */

  if (UUInitialize () != UURET_OK) {
    Tcl_SetResult (interp, "Error initializing decoding engine", TCL_STATIC);
    return TCL_ERROR;
  }

  /*
   * register commands
   */

  Tcl_CreateCommand (interp, "uu_Info",          uutcl_Info, NULL, NULL);
  Tcl_CreateCommand (interp, "uu_SetMessageProc",uutcl_SetMessageProc,
		     NULL, NULL);
  Tcl_CreateCommand (interp, "uu_SetBusyProc",   uutcl_SetBusyProc,NULL,NULL);
  Tcl_CreateCommand (interp, "uu_GetProgressInfo",uutcl_GetProgressInfo,
		     NULL, NULL);
  Tcl_CreateCommand (interp, "uu_GetListOfFiles",uutcl_GetListOfFiles,
		     NULL, NULL);
  Tcl_CreateCommand (interp, "uu_LoadFile",      uutcl_LoadFile, NULL, NULL);
  Tcl_CreateCommand (interp, "uu_DecodeFile",    uutcl_DecodeFile, NULL, NULL);
  Tcl_CreateCommand (interp, "uu_GetTempFile",   uutcl_GetTempFile,NULL,NULL);
  Tcl_CreateCommand (interp, "uu_InfoFile",      uutcl_InfoFile, NULL, NULL);
  Tcl_CreateCommand (interp, "uu_ListFile",      uutcl_ListFile, NULL, NULL);
  Tcl_CreateCommand (interp, "uu_Rename",        uutcl_Rename, NULL, NULL);
  Tcl_CreateCommand (interp, "uu_CleanUp",       uutcl_CleanUp, NULL, NULL);
  Tcl_CreateCommand (interp, "uu_EncodeToFile",  uutcl_EncodeToFile,NULL,NULL);
  Tcl_CreateCommand (interp, "uu_EncodeToMail",  uutcl_EncodeToMail,NULL,NULL);
  Tcl_CreateCommand (interp, "uu_EncodeToNews",  uutcl_EncodeToNews,NULL,NULL);

  /*
   * our message-handling function and busy callback
   */

  theDMcbdata.interp       = NULL;
  theDMcbdata.tclproc[0]   = '\0';
  UUSetMsgCallback (&theDMcbdata, uutcl_DisplayMessage);

  theBusycbdata.interp     = NULL;
  theBusycbdata.tclproc[0] = '\0';
  UUSetBusyCallback (&theBusycbdata, uutcl_BusyCallback, 1000);

  /*
   * only set variables if they aren't set already
   */

  sprintf (tmp, "%d", UUGetOption (UUOPT_FAST, NULL, NULL, 0));
  if (Tcl_GetVar (interp, "OptionFast", TCL_GLOBAL_ONLY) == NULL)
    Tcl_SetVar (interp, "OptionFast", tmp, TCL_GLOBAL_ONLY);

  sprintf (tmp, "%d", UUGetOption (UUOPT_BRACKPOL, NULL, NULL, 0));
  if (Tcl_GetVar (interp, "OptionBracket", TCL_GLOBAL_ONLY) == NULL)
    Tcl_SetVar (interp, "OptionBracket", tmp, TCL_GLOBAL_ONLY);

  sprintf (tmp, "%d", UUGetOption (UUOPT_DESPERATE, NULL, NULL, 0));
  if (Tcl_GetVar (interp, "OptionDesperate", TCL_GLOBAL_ONLY) == NULL)
    Tcl_SetVar (interp, "OptionDesperate", tmp, TCL_GLOBAL_ONLY);

  sprintf (tmp, "%d", UUGetOption (UUOPT_DEBUG, NULL, NULL, 0));
  if (Tcl_GetVar (interp, "OptionDebug", TCL_GLOBAL_ONLY) == NULL)
    Tcl_SetVar (interp, "OptionDebug", tmp, TCL_GLOBAL_ONLY);

  sprintf (tmp, "%d", UUGetOption (UUOPT_USETEXT, NULL, NULL, 0));
  if (Tcl_GetVar (interp, "OptionUsetext", TCL_GLOBAL_ONLY) == NULL)
    Tcl_SetVar (interp, "OptionUsetext", tmp, TCL_GLOBAL_ONLY);

  return TCL_OK;
}