Example #1
0
void static
names( const char *data, char *lookaside , char *quotesUsed )
{

   char drive[FILENAME_MAX],
        dir[FILENAME_MAX],
        file[FILENAME_MAX],
        ext[FILENAME_MAX];

/*--------------------------------------------------------------------*/
/*       Build the lookaside file name from the data file name        */
/*--------------------------------------------------------------------*/

#ifdef __TURBOC__

   fnsplit( data, drive, dir, file, ext);
   fnmerge( lookaside, drive, dir, file, ".las");
   fnmerge( quotesUsed, drive, dir, file, ".qus");

#else

   _splitpath( (char *) data, drive, dir, file, ext);
   _makepath( lookaside, drive, dir, file, ".las");
   _makepath( quotesUsed, drive, dir, file, ".qus");

#endif /* __TURBOC__ */

} /* names */
Example #2
0
FILE * trypath(const char *flags, const char *path, const char *name, const char *ext)
{
  char buffer[MAXPATH];			/* full path to try */

  fnmerge (buffer, NULL, path, name, ext);
  return fopen(buffer, flags);
}
static int Mk_NewName(char *NameF)                           //Автоматическое формирование нового имени
{
   char Driv[MAXDRIVE+3], Dir[MAXPATH], Name[MAXFILE], Ext[MAXEXT];
   fnsplit(NameF, Driv, Dir, Name, Ext);
   int l = lstrlen(Name);
   for(DWORD i=1; i<0xFFFFFFFF; i++)
   {  sprintf(Name+l, ".%03d", i);
      fnmerge(NameF, Driv, Dir, Name, Ext);
      if(CtrlFileYesNo(NameF) == 0) return 0;                //Файла нет - Проверка наличия файла
  }
  return 0;
}
void main (void)
{
    char nomecaminho [MAXPATH];

    char *unidade = "F:";
    char *subdir = "\\desenvolvidos";
    char *nomearq = "relatorio4";
    char *extensao = ".txt";

    fnmerge (nomecaminho, unidade, subdir, nomearq, extensao);

    printf ("O nome do caminho completo e %s\n", nomecaminho);
}
Example #5
0
char* fullmerge( char* path )
{
#ifdef _WIN32
// FIXME: 2008 Upgrades needed here?
#if defined( _MSC_VER ) && ( _MSC_VER <= 1310 )  // up to VS2003
  _makepath( path, temp_drive, temp_dir, temp_fname, temp_ext );
#else  // VS2005 using MS STL, booooo
  _makepath_s( path, MAXPATH, temp_drive, temp_dir, temp_fname, temp_ext );
#endif
#else
  fnmerge( path, temp_drive, temp_dir, temp_fname, temp_ext );
#endif
  return path;
}
Example #6
0
int filebkup( const char *input )
{
   char fdrive[FILENAME_MAX];
   char fpath[FILENAME_MAX];
   char fname[FILENAME_MAX];
   char ftype[FILENAME_MAX];
   char backup[FILENAME_MAX];

   if ( !bflag[F_BACKUP] )    /* Are we to not back it up?            */
      return 1;               /* Yes --> Report we did not            */

#ifdef __TURBOC__
   fnsplit( input, fdrive, fpath, fname, ftype );

   if ( E_backup == NULL )
      strcpy(ftype, ".bak" );
   else if ( *E_backup == '.' )
      strcpy( ftype, E_backup );
   else {
      *ftype = '.';
      strcpy(  ftype + 1 , E_backup );
   } /* else */

   fnmerge( backup, fdrive, fpath, fname, ftype );
#else

   if ( E_backup == NULL )
      E_backup = ".bak";

   _splitpath( (char *) input , fdrive, fpath, fname, ftype );
   _makepath( backup , fdrive, fpath, fname, E_backup );
#endif /* __TURBOC__ */

   REMOVE( backup );

   if (rename( input, backup ))
   {
      printerr( backup );
      printmsg(1,"Unable to rename %s to %s", input, backup );
      return 1;

   } /* if (rename( input, backup )) */
   else
      return 0;

} /* filebkup */
int TFileOpen::canClose()
{
	WORD pathLen;

  GetDlgItemText(hWindow, id_FName, fileSpec, fsPathName + 1);
  fnmerge(pathName,"","",fileSpec,"");
  pathLen = strlen(pathName);
  if (hasWildCards(pathName) ||
      (GetFocus() == GetDlgItem( hWindow, id_DList) ||
      ( pathLen && (pathName[pathLen - 1] == '\\') )

        ))
  {
        if (pathName[pathLen - 1] == '\\')
          strncat(pathName, fileSpec, fsPathName);
	if (!updateListBoxes())
        {
          MessageBeep(0);
          selectFileName();
        }
        return 0;
  }
  strncat(strncat(pathName, "\\", fsPathName), fileSpec, fsPathName);
  if (updateListBoxes())
        return 0;
  pathName[pathLen] = '\0';
  if (getExtension(pathName)[0] == '\0')
        strncat(pathName, extension, fsPathName);
  AnsiLower((LPSTR) strcpy(filePath, pathName));
  updateButtons();
  if (IsDlgButtonChecked(hWindow, id_Text) == 1)
        *fileType = FileWindow;
  else
  if (IsDlgButtonChecked(hWindow, id_Scribble) == 1)
        *fileType = ScribbleWindow;
  else
  if (IsDlgButtonChecked(hWindow, id_Graph) == 1)
        *fileType = GraphWindow;
  else
	return 0;
  return 1;
}
Example #8
0
int getname(char textst[],unsigned x,unsigned y,unsigned maxlen,char attr)
{
    int i;
    char drv[MAXDRIVE],dir[MAXDIR],name[MAXFILE],ext[MAXEXT];
    char textst2[80];
    do {
      i = getstring(textst,x,y,maxlen,attr,ENGUPCASE);
    } while ((i != YES) && (i != ESCKEY) && (i != NO));
    if (i == YES) {
      fnsplit(textst,drv,dir,name,ext);
      fnmerge(textst2,drv,dir,name,ext);
      if (strcmp(textst,textst2) != 0) {
	blockmsg(10);
	dispstrhgc("������������żԴ��Ҵ ! �� <ESC> ���ͷӧҹ���",27,10,REVERSEATTR);
        while (bioskey(0) != ESCKEY);
        return(ESCKEY);
      }
    }
    return(i);
}
Example #9
0
Boolean TFileEditor::saveFile()
{
    char drive[MAXDRIVE];
    char dir[MAXDIR];
    char file[MAXFILE];
    char ext[MAXEXT];

    if( (editorFlags & efBackupFiles) != 0 )
        {
        fnsplit( fileName, drive, dir, file, ext );
        char backupName[MAXPATH];
        fnmerge( backupName, drive, dir, file, backupExt );
        unlink( backupName );
        rename( fileName, backupName );
        }

    ofstream f( fileName, ios::out | ios::binary );

    if( !f )
        {
        editorDialog( edCreateError, fileName );
        return False;
        }
    else
        {
        writeBlock( f, buffer, curPtr );
        writeBlock( f, buffer+curPtr+gapLen, bufLen-curPtr );

        if( !f )
            {
            editorDialog( edWriteError, fileName );
            return False;
            }
        else
            {
            modified = False;
            update(ufUpdate);
            }
        }
    return True;
}
//------------------------------------------------------------------------------

static int Copy_File1(DWORD ind)                             //Копирование выбранного файла на диск ПК
{
   char Driv[MAXDRIVE], Dir[MAXPATH], Name[MAXFILE], Ext[MAXEXT];
   char outNameF1[260], NameFF[260];

   fnsplit(outNameF1, Driv, Dir, Name, Ext);
   lstrcpy(NameFF, (aTree+ind)->NameF);
   Ctrl_Name_Ch(NameFF);                                     //Проверка имени на недопустимые символы
   fnmerge(outNameF1, Driv, Dir, NameFF, "");
   indF = ind;                                               //Индекс копируемого файла
   if(OpenOutFileName_New(outNameF1, (aTree+ind)->pf.SizeF, &outFile) < 0) return -1; //Открытие выходного файла
   UpdateWindow(MainWin);                                    //Восстановили окно после диалога выбора файла
   InitProgressBar = InitProgressBar1;
   ProgressBar = ProgressBar1;
   Close_ProgressBar = Close_ProgressBar1;
//11   int ret = Copy_One_File(&((aTree+ind)->pf), (Lan+24)->msg, outNameF1);//int ret = Copy_One_File((Tree+ind)->pf.SizeF, (Tree+ind)->pf.ClSt,  "Копирование файла");
   int ret = Copy_One_File(&((aTree+ind)->pf), (Lan+24)->msg);               //int ret = Copy_One_File((Tree+ind)->pf.SizeF, (Tree+ind)->pf.ClSt,  "Копирование файла");
   Close_ProgressBar();
   CloseFile(&outFile);                                      //Закрыли входной файл
   if(ret < 0) DeleteFile(outNameF1);
   return ret;
Example #11
0
// Main PaperBack program.
int PASCAL WinMain(HINSTANCE hi,HINSTANCE hprev,LPSTR cmdline,int show) {
  int dx,dy,isbitmap;
  char path[MAXPATH],drv[MAXDRIVE],dir[MAXDIR],fil[MAXFILE];
  char s[TEXTLEN],inifile[MAXPATH];
  WNDCLASS wc;
  MSG msg;
  TW_UINT16 result;
  // Save the instance.
  hinst=hi;
  // Very Advanced Controls like Magnificious Supertabs are used here.
  InitCommonControls();
  // Create custom GDI objects.
  graybrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
  // Create name of initialization file.
  GetModuleFileName(NULL,path,MAXPATH);
  fnsplit(path,drv,dir,fil,NULL);
  fnmerge(inifile,drv,dir,fil,".ini");
  // Get settings from the initialization file.
  GetPrivateProfileString("Settings","Infile","",infile,MAXPATH,inifile);
  GetPrivateProfileString("Settings","Inbmp","",inbmp,MAXPATH,inifile);
  GetPrivateProfileString("Settings","Outfile","",outfile,MAXPATH,inifile);
  GetPrivateProfileString("Settings","Outbmp","",outbmp,MAXPATH,inifile);
  dpi=GetPrivateProfileInt("Settings","Raster",200,inifile);
  dotpercent=GetPrivateProfileInt("Settings","Dot size",70,inifile);
  compression=GetPrivateProfileInt("Settings","Compression",2,inifile);
  redundancy=GetPrivateProfileInt("Settings","Redundancy",5,inifile);
  printheader=GetPrivateProfileInt("Settings","Header and footer",1,inifile);
  printborder=GetPrivateProfileInt("Settings","Border",0,inifile);
  autosave=GetPrivateProfileInt("Settings","Autosave",1,inifile);
  bestquality=GetPrivateProfileInt("Settings","Best quality",1,inifile);
  encryption=GetPrivateProfileInt("Settings","Encryption",0,inifile);
  opentext=GetPrivateProfileInt("Settings","Open password",0,inifile);
  // Get printer's page size.
  marginunits=GetPrivateProfileInt("Settings","Margin units",0,inifile);
  marginleft=GetPrivateProfileInt("Settings","Margin left",1000,inifile);
  marginright=GetPrivateProfileInt("Settings","Margin right",400,inifile);
  margintop=GetPrivateProfileInt("Settings","Margin top",400,inifile);
  marginbottom=GetPrivateProfileInt("Settings","Margin bottom",500,inifile);
  // Register class of main window.
  wc.style=CS_OWNDC;
  wc.lpfnWndProc=Mainwp;
  wc.cbClsExtra=wc.cbWndExtra=0;
  wc.hInstance=hinst;
  wc.hIcon=LoadIcon(hinst,"ICON_MAIN");
  wc.hCursor=LoadCursor(NULL,IDC_ARROW);
  wc.hbrBackground=graybrush;
  wc.lpszMenuName=NULL;
  wc.lpszClassName=MAINCLASS;
  if (!RegisterClass(&wc))
    return 1;
  // Create main window. It will accept drag-and-drop files.
  dx=min(GetSystemMetrics(SM_CXSCREEN),MAINDX);
  dy=min(GetSystemMetrics(SM_CYSCREEN),MAINDY);
  hmenu=LoadMenu(hinst,"MENU_MAIN");
  hwmain=CreateWindowEx(
    WS_EX_ACCEPTFILES,
    MAINCLASS,"PaperBack",
    WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|
      WS_CLIPCHILDREN|WS_VISIBLE,
    CW_USEDEFAULT,CW_USEDEFAULT,dx,dy,
    NULL,hmenu,hinst,NULL);
  if (hwmain==NULL)
    return 1;
  // Create controls in the window.
  if (Createcontrols()!=0)
    return 1;
  // Load TWAIN interface. Failure is not critical - we still can print data!
  twainstate=1;
  if (LoadTWAINlibrary()==0) {
    EnableMenuItem(hmenu,M_FILE_SELECT,MF_BYCOMMAND|MF_GRAYED);
    EnableMenuItem(hmenu,M_FILE_ACQUIRE,MF_BYCOMMAND|MF_GRAYED); };
  Updatebuttons();
  // Initialize printer settings.
  Initializeprintsettings();
  // And now, the main Windows loop.
  while (1) {
    // Check if there are some unprocessed Windows messages and process them at
    // once.
    while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
      // Pass all messages to the TWAIN interface.
      result=TWRC_NOTDSEVENT;
      if (twainstate>=5)
        result=(TW_UINT16)PassmessagetoTWAIN(&msg);
      // If message was not processed by TWAIN, it must be processed by
      // the application.
      if (result==TWRC_NOTDSEVENT) {
        // Pass keyboard messages first to block display.
        if (msg.message!=WM_KEYDOWN || Changeblockselection(msg.wParam)==1) {
          TranslateMessage(&msg);
          DispatchMessage(&msg);
        };
      };
    };
    if (msg.message==WM_QUIT) break;
    // Execute next steps of data decoding and file printing.
    if (procdata.step!=0)
      Nextdataprocessingstep(&procdata);
    else if (printdata.step!=0)
      Nextdataprintingstep(&printdata);
    // Some TWAIN drivers require very frequent calls when scanning, don't
    // sleep.
    if (twainstate>=5)
      continue;
    // Check whether new printing or decoding task can be executed.
    if (procdata.step==0 && printdata.step==0) {
      isbitmap=Getfilefromqueue(path);
      if (isbitmap==0) Printfile(path,NULL);
      else if (isbitmap==1) Decodebitmap(path); };
    // If we have nothing to do, be kind to other applications.
    if (twainstate<5 && procdata.step==0 && printdata.step==0 &&
      GetQueueStatus(QS_ALLINPUT)==0
    ) {
      Sleep(1);                        // Reduces CPU time practically to zero
    };
  };
  // Save settings to the initialization file.
  WritePrivateProfileString("Settings","Infile",infile,inifile);
  WritePrivateProfileString("Settings","Inbmp",inbmp,inifile);
  WritePrivateProfileString("Settings","Outfile",outfile,inifile);
  WritePrivateProfileString("Settings","Outbmp",outbmp,inifile);
  sprintf(s,"%i",dpi);
    WritePrivateProfileString("Settings","Raster",s,inifile);
  sprintf(s,"%i",dotpercent);
    WritePrivateProfileString("Settings","Dot size",s,inifile);
  sprintf(s,"%i",compression);
    WritePrivateProfileString("Settings","Compression",s,inifile);
  sprintf(s,"%i",redundancy);
    WritePrivateProfileString("Settings","Redundancy",s,inifile);
  sprintf(s,"%i",printheader);
    WritePrivateProfileString("Settings","Header and footer",s,inifile);
  sprintf(s,"%i",printborder);
    WritePrivateProfileString("Settings","Border",s,inifile);
  sprintf(s,"%i",autosave);
    WritePrivateProfileString("Settings","Autosave",s,inifile);
  sprintf(s,"%i",bestquality);
    WritePrivateProfileString("Settings","Best quality",s,inifile);
  sprintf(s,"%i",encryption);
    WritePrivateProfileString("Settings","Encryption",s,inifile);
  sprintf(s,"%i",opentext);
    WritePrivateProfileString("Settings","Open password",s,inifile);
  // Save printer's page size.
  if (pagesetup.Flags & PSD_INTHOUSANDTHSOFINCHES) marginunits=1;
  else if (pagesetup.Flags & PSD_INHUNDREDTHSOFMILLIMETERS) marginunits=2;
  else marginunits=0;
  if (marginunits) {
    sprintf(s,"%i",marginunits);
      WritePrivateProfileString("Settings","Margin units",s,inifile);
    sprintf(s,"%i",pagesetup.rtMargin.left);
      WritePrivateProfileString("Settings","Margin left",s,inifile);
    sprintf(s,"%i",pagesetup.rtMargin.right);
      WritePrivateProfileString("Settings","Margin right",s,inifile);
    sprintf(s,"%i",pagesetup.rtMargin.top);
      WritePrivateProfileString("Settings","Margin top",s,inifile);
    sprintf(s,"%i",pagesetup.rtMargin.bottom);
      WritePrivateProfileString("Settings","Margin bottom",s,inifile);
    ;
  };
  // Clear password. It's a bad idea to keep password in the swap file after
  // shutdown.
  memset(password,0,sizeof(password));
  // Clean up.
  Freeprocdata(&procdata);
  Stopprinting(&printdata);
  CloseTWAINmanager();
  CloseTWAINlibrary();
  Closeprintsettings();
  // Destroy objects.
  DeleteObject(graybrush);
  return 0;
};
Example #12
0
inst_t
set_install (const char *diskset, char *fromdir, char *destdir)
{
  /* Variables */

  char endfile[MAXPATH];		/* marks end of series */
  char datfile[MAXPATH];		/* current DAT file */
  char ext[MAXPATH];			/* file extension */
  char *s;
  int disknum = 0;			/* current disk number */
  int ch;
  inst_t ret;				/* return: no. of errors,warnings */
  inst_t this;				/* no. of errors,warnings */

  /* Create the filenames */

  fnmerge (endfile, "", fromdir, diskset, "END");

  /* Print the name of the series we are working on */

  repaint_empty();
  s = catgets (cat, SET_PKG_GENERAL, MSG_INSTSERIES, MSG_INSTSERIES_STR);
  gotoxy (2, 3);
  cputs (s);
  cputs (diskset);
  log("<diskset name=\"%s\" >\n", diskset);


  /* Install while we have disks to work from.  Since we will reach an
     exit condition within the loop, we use an infinite loop here. */

  ret.errors = 0;
  ret.warnings = 0;

  while (1) {
    repaint_empty();

    /* First check that the datfile exists.  If it doesn't, check if
       the endfile was found. */

    sprintf (ext, "%d", ++disknum);
    fnmerge (datfile, "", fromdir, diskset, ext);

    if (!isfile (datfile)) {
      /* Does the endfile exist? */

      if (isfile (endfile)) {
	s = catgets (cat, SET_PKG_GENERAL, MSG_INSTSERIESDONE, MSG_INSTSERIESDONE_STR);
	gotoxy (2, 10);
	cputs (s);

	s = catgets (cat, SET_PKG_GENERAL, MSG_NEXTSERIESDISK, MSG_NEXTSERIESDISK_STR);
	gotoxy (2, 15);
	cputs (s);

	s = catgets (cat, SET_PKG_GENERAL, MSG_NEXTSERIESDISK2, MSG_NEXTSERIESDISK2_STR);
	gotoxy (2, 16);
	cputs (s);

      log("</diskset>\n\n");
	pause();
	return (ret);
      }

      /* The endfile was not found, so we know there is at least one
         more disk left to do.  Keep asking the user to insert the
         next disk. */

      do {

      /* If this is the 1st disk in the series, then instead of assuming wrong disk
         prompt for them to insert the disk. */
      if (disknum == 1)
      {
        s = catgets (cat, SET_PKG_GENERAL, MSG_INSERT1STDISK, MSG_INSERT1STDISK_STR);
	  gotoxy (2, 10);
        cprintf(s, diskset);
      }
      else 
      {
	  s = catgets (cat, SET_PKG_GENERAL, MSG_MISSINGDATAFILE, MSG_MISSINGDATAFILE_STR);
	  gotoxy (2, 10);
	  cputs (s);

	  gotoxy (2, 11);
	  cputs (datfile);

	  s = catgets (cat, SET_PKG_GENERAL, MSG_WRONGFLOPPY, MSG_WRONGFLOPPY_STR);
	  gotoxy (2, 15);
	  cputs (s);

	  s = catgets (cat, SET_PKG_GENERAL, MSG_STILLWRONGFLOPPY, MSG_STILLWRONGFLOPPY_STR);
	  gotoxy (2, 16);
	  cputs (s);
      }

	s = catgets (cat, SET_PROMPT_YN, MSG_CONTINSTDISK, MSG_CONTINSTDISK_STR);
	ch = select_yn (s, yes, no, NULL, NULL);

	if (ch)
	  {
	    /* user has decided to quit this series */
          log("</diskset>\n\n");
	    return (ret);
	  }

      } while (!isfile (datfile));
    } /* if no datfile */

    /* Install files from this disk */

    log("<disk name=\"%s\" number=\"%i\" >\n", diskset, disknum);
    this = disk_install (datfile, fromdir, destdir);
    log("</disk>\n");
    ret.errors += this.errors;
    ret.warnings += this.warnings;
  } /* while (1) */
}
Example #13
0
inst_t
disk_install(const char *datfile, char *fromdir, char *destdir)
{
  char lsmfile[MAXPATH];		/* Linux software map file */
  char *s;

  int dat_count;				/* size of the dat array */
  int ret;
  int ch;
  int i;

  int pkg_yesToAll = 0;			/* Assume default yes to all = not specified */

  dat_t *dat_ary;				/* the DAT array */
  inst_t this;				/* return: no. of errors,warnings */

  /* Initialize variables */

  this.errors = 0;
  this.warnings = 0;

  /* Read dat file */
  dat_ary = dat_read (datfile, &dat_count);
  if (dat_ary == NULL)
    {
      s = catgets (cat, SET_ERRORS, MSG_ERROR, MSG_ERROR_STR);
      fprintf (stderr, s);
      log("<error msg=\"%s\" />\n", s);
      s = catgets (cat, SET_ERRORS, MSG_ERRALLOCMEMFDF, MSG_ERRALLOCMEMFDF_STR);
      fprintf (stderr, s);
      log("<error msg=\"%s\" />\n", s);

	pause();
      return (this);
    }
  if (dat_count < 1)
    {
      s = catgets (cat, SET_ERRORS, MSG_ERROR, MSG_ERROR_STR);
      fprintf (stderr, s);
      log("<error msg=\"%s\" />\n", s);
      s = catgets (cat, SET_ERRORS, MSG_ERREMPTYFLOPPYDATAFILE, MSG_ERREMPTYFLOPPYDATAFILE_STR);
      fprintf (stderr, s);
      log("<error msg=\"%s\" />\n", s);


	pause();
      free (dat_ary);
      return (this);
    }

  /* Run the install */

  for (i = 0; i < dat_count; i++) {
    /* Print the screen and progress bargraph */

    repaint_empty();

    box (14, 16, 66, 18);
    gotoxy (15, 17);
    bargraph (i, dat_count, 50 /* width */);

    /* Print the package name */

    gotoxy (2, 5);
    s = catgets (cat, SET_PKG_GENERAL, MSG_PACKAGE, MSG_PACKAGE_STR);
    cputs (s);

    cputs (dat_ary[i].name);

    /* Show the package description */

    /* Generate the lsmfile name */

    fnmerge (lsmfile, "", fromdir, dat_ary[i].name, "LSM");

    if (isfile (lsmfile))
      {
	lsm_description (8, 2, 10, lsmfile);
      }
    else
      {
	/* no lsm file. try it again with a plain txt file (or localized version) */

	fnmerge (lsmfile, "", fromdir, dat_ary[i].name, "");

	    gotoxy (2, 8);
	    cat_file (lsmfile, 10 /* no. lines */);
	  }

    /* Find out which ones the user wants to install */

    gotoxy (2, 25);
    switch (dat_ary[i].rank) {
    case 'n':
    case 'N':
      /* Do not install */

      log("<package name=\"%s\" choice=\"n\" />\n", dat_ary[i].name);
      s = catgets (cat, SET_PKG_NEED, MSG_SKIPPED, MSG_SKIPPED_STR);
      cputs (s);
      break;

    case 'y':
    case 'Y':
      /* Always install */

      log("<package name=\"%s\" choice=\"y\" ", dat_ary[i].name);
      s = catgets (cat, SET_PKG_NEED, MSG_REQUIRED, MSG_REQUIRED_STR);
      cputs (s);

      ret = unzip_file (dat_ary[i].name, fromdir, destdir);

      reregisterSIGINTHandler(); /* unzip installs its own SIGINT handler */

      if (ret != 0) {
	/* Print an error message */

	s = catgets (cat, SET_PKG_GENERAL, MSG_ERRREQPKG, MSG_ERRREQPKG_STR);
	cputs (s);
      log(">\n");
      log("<error msg=\"%s\" />\n", s);
      log("</package>\n");

	/* Return an error */

	this.errors++;

	/* Does the user want to continue anyway? */

	s = catgets (cat, SET_PROMPT_YN, MSG_CONTINSTDISK, MSG_CONTINSTDISK_STR);
	ch = select_yn(s, yes, no, NULL, NULL);

        if (ch)
        {
          log("<abort msg=\"User choose not to continue after error.\" />\n");
          return (this);
	  }
      }
      else /* ret == 0, ie no errors */
        log("/>\n");
      break;

    default:
      /* Optional */

      s = catgets (cat, SET_PKG_NEED, MSG_OPTIONAL, MSG_OPTIONAL_STR);
      cputs (s);

      /* Ask the user if you want to install it */

      s = catgets (cat, SET_PROMPT_YN, MSG_INSTALLPKG, MSG_INSTALLPKG_STR);
      if (!pkg_yesToAll)
	{
	      ch = select_yn (s, yes, no, 
                            catgets (cat, SET_PROMPT_YN, MSG_YESTOALL, MSG_YESTOALL_STR),
                            NULL);
		if (ch == 2) pkg_yesToAll = 1;
	}

      if (pkg_yesToAll || ch==0) /* Yes or YesToAll */
	{
        log("<package name=\"%s\" choice=\"y\" ", dat_ary[i].name);
	  ret = unzip_file (dat_ary[i].name, fromdir, destdir);

        reregisterSIGINTHandler(); /* unzip installs its own SIGINT handler */

	  if (ret != 0)
	    {
	      /* Print a warning message */

	      gotoxy (2, 13);
	      s = catgets (cat, SET_PKG_GENERAL, MSG_WARNOPTPKG, MSG_WARNOPTPKG_STR);
	      cputs (s);
            log(">\n");
            log("<warning msg=\"%s\" />\n", s);
            log("</package>\n");

		pause();
	      this.warnings++;
	    }
          else
            log("/>\n");
	}
      else /* user selected no */
          log("<package name=\"%s\" choice=\"n\" />\n", dat_ary[i].name);
      break;

    } /* switch */
  } /* for */

  /* Print the screen and 100% complete progress bargraph */
  repaint_empty();
  box (14, 16, 66, 18);
  gotoxy (15, 17);
  bargraph (1, 1, 50 /* width */);

  /* Free memory for this disk */

  free (dat_ary);
  return (this);
}
/*
 * Open input file with given define for C-preprocessor 
 */
static void
open_input (char *infile, char *define)
{
  int pd[2];

  infilename = (infile == NULL) ? "<stdin>" : infile;
#ifdef __MSDOS__
#define	DOSCPP	"\\prog\\bc31\\bin\\cpp.exe"
  {
    int retval;
    char drive[MAXDRIVE], dir[MAXDIR], name[MAXFILE], ext[MAXEXT];
    char cppfile[MAXPATH];
    char *cpp;

    if ((cpp = searchpath ("cpp.exe")) == NULL
	&& (cpp = getenv ("RPCGENCPP")) == NULL)
      cpp = DOSCPP;

    putarg (0, cpp);
    putarg (1, "-P-");
    putarg (2, CPPFLAGS);
    addarg (define);
    addarg (infile);
    addarg (NULL);

    retval = spawnvp (P_WAIT, arglist[0], arglist);
    if (retval != 0) {
      fprintf (stderr, "%s: C PreProcessor failed\n", cmdname);
      crash ();
    }

    fnsplit (infile, drive, dir, name, ext);
    fnmerge (cppfile, drive, dir, name, ".i");

    fin = fopen (cppfile, "r");
    if (fin == NULL) {
      f_print (stderr, "%s: ", cmdname);
      perror (cppfile);
      crash ();
    }
    dos_cppfile = strdup (cppfile);
    if (dos_cppfile == NULL) {
      fprintf (stderr, "%s: out of memory\n", cmdname);
      crash ();
    }
  }
#else
  (void) pipe (pd);
  switch (fork ()) {
  case 0:
    putarg (0, CPP);
    putarg (1, CPPFLAGS);
    addarg (define);
    addarg (infile);
    addarg ((char *) NULL);
    (void) close (1);
    (void) dup2 (pd[1], 1);
    (void) close (pd[0]);
    execv (arglist[0], arglist);
    perror ("execv");
    exit (1);
  case -1:
    perror ("fork");
    exit (1);
  }
  (void) close (pd[1]);
  fin = fdopen (pd[0], "r");
#endif
  if (fin == NULL) {
    f_print (stderr, "%s: ", cmdname);
    perror (infilename);
    crash ();
  }
}
Example #15
0
dat_t *listbox(dat_t *dat_ary, int dat_count, char *fromdir)
{
    int boxlength = dat_count / 5, centre = 12 - boxlength, i, j;
    key_t ch;
    char *thecwd = getcwd(NULL, 0);

    centre += 4;

    textbackground(BLUE);
    textcolor(WHITE);

    /* OK, lets draw all of the selections using some simple calculations */
    for(i = 0, j = 0; i < dat_count; i++, j++) {
        gotoxy(8 + (j * 13), centre + (i / 5));
        if(toupper(dat_ary[i].rank) == 'N') cputs("[ ] ");
        else {
            cputs("[X] ");
            dat_ary[i].rank = 'Y';
        }
        /* Don't bother printing the pathname (if it exists) */
        cputs(strrchr(dat_ary[i].name, '\\') != NULL ?
              &strrchr(dat_ary[i].name, '\\')[1] : dat_ary[i].name);
        if(j == 4) j = -1;
    }
    /* Draw the DONE button */
    gotoxy(37, centre + (dat_count / 5) + 2);
    cputs("[DONE]");
    gotoxy(8, centre);
    cputs(toupper(dat_ary[i].rank) == 'N' ? "< >" : "<X>");
    gotoxy(9, centre);
    i = j = 0;

    /* Begin the selection loop; runs forever until ENTER is pressed */
    for(;;) {
        unsigned x = wherex(), y = wherey(), k, l;
        for(k = 19; k < 22; k++) for(l = 2; l < 80; l++) {
            gotoxy(l, k);
            putch(' ');
        }
        gotoxy(2, 20);
        if(i != dat_count) {
            char lsmfile[MAXPATH];
            unsigned total;

            chdir(fromdir);
            _dos_setdrive(toupper(fromdir[0]) - 'A' + 1, &total);
            fnmerge(lsmfile, "", fromdir, dat_ary[i].name, ".LSM");
            if(isfile(lsmfile)) lsm_description(20, 2, 3, lsmfile);
            else cat_file(dat_ary[i].name, 3);
            chdir(thecwd);
            _dos_setdrive(toupper(thecwd[0]) - 'A' + 1, &total);
        }
        gotoxy(x, y);
        ch = getkey();
        switch(ch.extended) {
            /* Moves the current selection to the next row */
            case KEY_DOWN:
                if(i < (dat_count - 4)) i += 5;
                else {
                    j = (dat_count - ((dat_count / 5) * 5) + 5) - 5;
                    i = dat_count;
                }
                break;
            /* 
             * Moves the current selection to the next column (or the first
             * column of the next row)
             */
            case KEY_RIGHT:
                if(i < dat_count) {
                    i++;
                    j++;
                }
                break;
            /* 
             * Moves the current selection to the previous row or to the
             * first column of the current row
             */
            case KEY_UP:
                if(i > 4) i -= 5;
                else j = i = 0;
                break;
            /*
             * Moves the current selection to the previous column (or the
             * last column of the previous row
             */
            case KEY_LEFT:
                if(i != 0) {
                    i--;
                    j--;
                }
                break;
        }
        switch(ch.key) {
            /* Complete the selection, return the results */
            case KEY_ENTER:
                free(thecwd);
                return(dat_ary);
            /* 
             * If pressed on the DONE button, return the results, else
             * toggle the current selection yes or no
             */
            case ' ':
                if(i == dat_count) {
                    free(thecwd);
                    return(dat_ary);
                }
                dat_ary[i].rank = (toupper(dat_ary[i].rank) == 'Y') ? 'N' : 'Y';
                break;
        }
        if(j > 4) j = 0;
        if(j < 0) j = 4;
        /* 
         * Change the previous selection borders to [], move the current to
         * <>
         */
        if (wherex() != 38) {
            gotoxy(wherex() - 1, wherey());
            putch('[');
            gotoxy(wherex() + 1, wherey());
            putch(']');
        }
        if(i == dat_count) gotoxy(38, centre + (dat_count / 5) + 2);
        else {
            gotoxy(8 + (j * 13), centre + (i / 5));
            cputs(toupper(dat_ary[i].rank) == 'Y' ? "<X>" : "< >");
            gotoxy(9 + (j * 13), centre + (i / 5));
        }
    }
}