Пример #1
0
int cmd_verify(char *param)
{
  if (!param || !*param)
    displayString(TEXT_MSG_VERIFY_STATE, getverify()? D_ON : D_OFF);
  else if (stricmp(param, D_OFF) == 0)
    setverify(0);
  else if (stricmp(param, D_ON) == 0)
    setverify(1);
  else
    displayString(TEXT_ERROR_ON_OR_OFF);

  return 0;
}
Пример #2
0
int cmd_verify(char *param)
{
  switch(onoffStr(param)) {
  	default:
		displayString(TEXT_ERROR_ON_OR_OFF);
		return 1;
	case OO_Null:	case OO_Empty:
		displayString(TEXT_MSG_VERIFY_STATE, getverify() ? D_ON : D_OFF);
		break;
  	case OO_Off:	setverify(0);	break;
  	case OO_On:		setverify(1);	break;
	}
  return 0;
}
Пример #3
0
Файл: MOVE.C Проект: FDOS/move
static void exit_fn(void)
{
    if (opt_verify)
    {
        setverify(old_verify); /* Restore value of the verify flag. */
    } /* end if. */

} /* end exit_fn. */
Пример #4
0
Файл: xcopy.c Проект: FDOS/xcopy
/*-------------------------------------------------------------------------*/
void exit_fn(void) {
  if (switch_verify) {
    /* restore value of verify flag */
    setverify(bak_verify);
  }

  printf("%d %s\n", file_counter, catgets(cat, 1, 19, "file(s) copied"));
  catclose(cat);
}
Пример #5
0
/*------------------------------------------------------------------------------

 FUNCTION NAME: Main_Init

 DESCRIPTION: Main init function

 PARAMETERS:
   - INPUT:
   - OUTPUT:

 RETURN:

 NOTES: Don't try to change the order of the function calls!

------------------------------------------------------------------------------*/
void Main_Init (void)
{
t_uchar    Lines[2] = {9,END_OF_LINES};
char    Msg[40];
#ifdef PC_TERMINAL
int     RetVal;
t_uchar    PrinterIndex, NumPrinters, Type, Port, Model;
t_boolean InvertScreen;
int     LCDContrastOffset;
#endif

  /* MAEL Version */
  #if defined (FEDORA_VERSION)
    srand48((long) time(NULL));
  #else

    #if !defined (NT_VERSION)
      /* Standart Random generation init */
      randomize ();
    #else
      /* Seed the random-number generator with current time so that
      * the numbers will be different every time we run.
      */
      srand( (unsigned)time( NULL ) );  
    #endif

  #endif /* MAEL Version */

  /*---------------------------------------------------*/
  /* Set dos verify option to on and other DOS options */
  /*---------------------------------------------------*/
  #if !defined (NT_VERSION)
    #if !defined (FEDORA_VERSION)
    /* In Linux Verify is always on */
    /* And cbreak does nothing */
    setverify (1);
    setcbrk (0);
    #endif /* FEDORA_VERSION */
    /* Set new Ctrl-Break handler */
    #if defined (DOSX286)
      DosSetPassToProtVec (0x1B, (PIHANDLER) Main_HandlerCtrlBreak,
                           &OldCtrlBrkProt, &OldCtrlBrkReal);
      DosSetPassToProtVec (0x23, (PIHANDLER) Main_HandlerCtrlBreak,
                           &OldCtrlCProt, &OldCtrlCReal);
    #else
      #if defined (FEDORA_VERSION)
        signal(SIGINT,SIG_IGN); 
      #else
        ctrlbrk (Main_HandlerCtrlBreak);
      #endif /* MAEL VERSION */
    #endif
  #endif


  /*-------------*/
  /* Nosdos Init */
  /*-------------*/

  /*----------*/
  /* Init. Kb */
  /*----------*/

  #if defined (FEDORA_VERSION)
      Kb_Init (KEYBOARD_STANDART);
  #else
  #if defined (TERMINAL_WT9602)
    Kb_Init (KEYBOARD_WT9602);
  #else
    #if defined (TERMINAL_WT9603)
      Kb_Init (KEYBOARD_WT9603);
    #else
      Kb_Init (KEYBOARD_STANDART);
    #endif
  #endif

  #endif /* MAEL Version */

  /*-----------------------*/
  /* Init. display modules */
  /*-----------------------*/

  #if defined(FEDORA_VERSION)
    #if defined(SVGALIB_MODE) || defined(XLIB_MODE)
      GrphDisp_Init (240, 128, 8);
    #else
      GrphDisp_Init (40, 14, 8);
    #endif
  #else

  #if defined(NT_VERSION)
    GrphDisp_Init (40, 14, 8);
  #else
    GrphDisp_Init (240, 128, 8);
  #endif

  #endif /* MAEL Version */

  GrphText_Init (240, 128, 8);

  #if defined (TERMINAL_WT9602) || defined (TERMINAL_WT9603)
    #if defined (LNSE)
      GrphDisp_SetInvertScreen (FALSE);
    #else
      GrphDisp_SetInvertScreen (TRUE);
    #endif
    Util_SetLCDContrast (INITIAL_LCD_CONTRAST);
  #endif

  /* Init message */
  GrphText_PopUp (54, 0, 240, Lines, TRUE);
  strcpy (Msg, S0252);
  GrphText_Cls (TRUE);
  GrphText_Write (1, (t_uchar) ((40-strlen (Msg))/2*6), Msg, FONT_7X5, (t_uchar) strlen (Msg),
                  TRUE, FALSE);


  /*-------------------------------------------------------*/
  /* Ramdisk init (includes error handler for disk access) */
  /*-------------------------------------------------------*/
  
  RamDisk_Init ();

  /* Init. Error logger */
  Errlog_Init ();

  /*------------*/
  /* Init. UART */
  /*------------*/
  
  Uart_Init ();

  /*----------------------*/
  /* Init. Parallel ports */
  /*----------------------*/

  Parallel_Init ();

  /*-----------------*/
  /* End nosdos Init */
  /*-----------------*/

  /*-----------*/
  /* App. Init */
  /*-----------*/

  /* Database Init */
  DB_InitStaticData ();

  RetVal = DB_LoadDBGlobal ();
  if (RetVal != DB_OK)
  { /* ??? Disk error: ends application ??? */
  } /* endif */
  DB_InitDynamicData ();

  /* Communication Init */
  Comm_Init ();

#if defined (FEDORA_VERSION)
  /* Ping IP address to initialize vpn */
  TCPIP_Init_Tunnel();
  /* Get and Apply last contrast value configured */
  Display_GetAndApplyContrast();
#endif

  /* Comm_Init for backup line if it is configured */
  {
    t_uchar CurrentLineType, OperationMode;

    DB_OperationMode (&OperationMode);
    if (OperationMode == OPERATIONMODE_REALONLINEBACKUP)
    {
      DB_CurrentLineType (&CurrentLineType);
      /* Change current line type to backup line */
      DB_GLOBAL_DYNAMIC.DB_CURRENT_LINETYPE = LINETYPE_BACKUP;
      /* Init backup line */
      Comm_PhysInitComm ();
      /* Restore main line type */
      DB_GLOBAL_DYNAMIC.DB_CURRENT_LINETYPE = CurrentLineType;
    } /* endif */
  }

  /* Comm_Init for main line */
  Comm_PhysInitComm ();

  Comm_CommDeviceInit ();

  /* App. protocol */
  Prot_Init ();

#if defined(ENABLE_HOTLINE)
  /* Init. Answer logger of hotline */
  Hotline_Init ();
#endif

  /* Devices init */
  Devices_Init ();
  /* Enable OMR device */
  Devices_SetState (DEVCODE_OMR, DEVSTATE_ENABLED);

  /*----------------------*/
  /* Init. printer module */
  /*----------------------*/

  DB_NumPrinters (&NumPrinters);

  for (PrinterIndex = 0; PrinterIndex < NumPrinters; PrinterIndex++)
  {
    DB_PrinterInfo (PrinterIndex, &Type, &Port, &Model);
    Printer_Init (PrinterIndex, Type, Port, Model, TRUE);
  } /* endfor */

  /* Invert screen option */
  DB_GetInvertScreen (&InvertScreen);
  GrphDisp_SetInvertScreen (InvertScreen);

  /* LCD Contrast */
  DB_GetLCDContrastOffset (&LCDContrastOffset);
  Util_SetLCDContrast (LCDContrastOffset);

  /*----------------------*/
  /* App. crc error check */
  /*----------------------*/

  DB_ChkAppCrcError ();

  /*---------------*/
  /* End App. Init */
  /*---------------*/

  /* Clear message from virtual display */
  GrphText_Cls (FALSE);
  GrphText_PopDown (FALSE);

} /* Main_Init */
Пример #6
0
Файл: xcopy.c Проект: FDOS/xcopy
/*-------------------------------------------------------------------------*/
int main(int argc, const char **argv) {
  int fileargc, 
	  switchargc;
  char *fileargv[255],
       *switchargv[255],
       env_prompt[MAXSWITCH],
       tmp_switch[MAXSWITCH] = "",
       src_pathname[MYMAXPATH] = "",
       src_filename[MAXFILE + MAXEXT] = "",
       dest_pathname[MYMAXPATH] = "",
       dest_filename[MAXFILE + MAXEXT] = "",
       *ptr,
       ch;
  int i, length;
  THEDATE dt;
#ifdef __WATCOMC__
  struct dostime_t tm;
#else
  struct time tm;
#endif

  cat = catopen ("xcopy", 0);	/* initialize kitten */

  classify_args(argc, argv, &fileargc, fileargv, &switchargc, switchargv);

  if (fileargc < 1 || switchargv[0] == "?") {
    print_help();
    catclose(cat);
    exit(4);
  }

  if (fileargc > 2) {
    printf("%s\n",catgets(cat, 1, 1, "Invalid number of parameters"));
    catclose(cat);
    exit(4);
  }

  /* activate termination function */
  /* (writes no. of copied files at exit) */
  atexit(exit_fn);

  /* read environment variable COPYCMD to set confirmation switch */
  strmcpy(env_prompt, getenv("COPYCMD"), sizeof(env_prompt));
  if (env_prompt[0] != '\0') {
    strupr(env_prompt);
    if (strcmp(env_prompt, "/Y") == 0)
      /* overwrite existing file(s) */
      switch_confirm = 0;
    else if (strcmp(env_prompt, "/N") == 0)
      /* skip existing file(s) */
      switch_confirm = 1;
    else
      /* ask for confirmation */
      switch_confirm = 2;
  }

  /* get switches */
  for (i = 0; i < switchargc; i++) {
    strmcpy(tmp_switch, switchargv[i], sizeof(tmp_switch));
    strupr(tmp_switch);
    if (strcmp(tmp_switch, "A") == 0)
      switch_archive = -1;
    else if (strcmp(tmp_switch, "C") == 0)
      switch_continue = -1;
    else if (strcmp(tmp_switch, "D") == 0)
      switch_date = -1;
    else if (strncmp(tmp_switch, "D:", 2) == 0) {
      if (strtodate(tmp_switch+2, &dt) != 0 ||
          !datevalid(&dt)) {
        printf("%s\n",catgets(cat, 1, 2, "Invalid date"));
        catclose(cat);
        exit(4);
      }
#ifdef __WATCOMC__
      memset((void *)&tm, 0, sizeof(struct dostime_t));
      /* tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_hund = 0; */
#else
      memset((void *)&tm, 0, sizeof(struct time));
      /* tm.ti_hour = 0; tm.ti_min = 0; tm.ti_sec = 0; tm.ti_hund = 0; */
#endif
      switch_date = dostounix(&dt, &tm);
    }
    else if (strcmp(tmp_switch, "E") == 0)
      switch_emptydir = -1;
    else if (strcmp(tmp_switch, "F") == 0)
      switch_fullnames = -1;
    else if (strcmp(tmp_switch, "H") == 0)
      switch_hidden = -1;
    else if (strcmp(tmp_switch, "I") == 0)
      switch_intodir = -1;
    else if (strcmp(tmp_switch, "L") == 0)
      switch_listmode = -1;
    else if (strcmp(tmp_switch, "M") == 0)
      switch_archive_reset = -1;
    else if (strcmp(tmp_switch, "N") == 0)
      switch_confirm = 1;
    else if (strcmp(tmp_switch, "P") == 0)
      switch_prompt = -1;
    else if (strcmp(tmp_switch, "Q") == 0)
      switch_quiet = -1;
    else if (strcmp(tmp_switch, "R") == 0)
      switch_readonly = -1;
    else if (strcmp(tmp_switch, "S") == 0)
      switch_subdir = -1;
    else if (strcmp(tmp_switch, "T") == 0)
      switch_tree = -1;
    else if (strcmp(tmp_switch, "V") == 0) {
      switch_verify = -1;
      bak_verify = getverify();
      setverify(1);
    }
    else if (strcmp(tmp_switch, "W") == 0)
      switch_wait = -1;
    else if (strcmp(tmp_switch, "Y") == 0)
      switch_confirm = 0;
    else if (strcmp(tmp_switch, "-Y") == 0)
      switch_confirm = 2;
    else {
      printf("%s - %s\n", catgets(cat, 1, 3, "Invalid switch"), switchargv[i]);
      catclose(cat);
      exit(4);
    }
  }

  /* get source pathname (with trailing backspace) and filename/-pattern */
  length = strlen(fileargv[0]);
  if (length > (MAXPATH - 1)) {
    printf("%s\n", catgets(cat, 1, 4, "Source path too long"));
    catclose(cat);
    exit(4);
  }
  _fullpath(src_pathname, fileargv[0], MYMAXPATH);
  if (src_pathname[0] == '\0') {
    printf("%s\n", catgets(cat, 1, 5, "Invalid source drive specification"));
    catclose(cat);
    exit(4);
  }
  /* check source path */
  if (!dir_exists(src_pathname)) {
    /* source path contains a filename/-pattern -> separate it */
    ptr = strrchr(src_pathname, *DIR_SEPARATOR);
    ptr++;
    strmcpy(src_filename, ptr, sizeof(src_filename));
    *ptr = '\0';
    if (!dir_exists(src_pathname)) {
      printf("%s - %s\n", catgets(cat, 1, 6, "Source path not found"), src_pathname);
      catclose(cat);
      exit(4);
    }
  }
  else {
    /* source is a directory -> filepattern = "*.*" */
    strmcpy(src_filename, "*.*", sizeof(src_filename));
  }
  cat_separator(src_pathname);
  length = strlen(src_pathname);
  if (length > (MAXDRIVE - 1 + MAXDIR - 1)) {
    printf("%s\n", catgets(cat, 1, 7, "Source path too long"));
    catclose(cat);
    exit(4);
  }

  /* get destination pathname (with trailing backspace) and */
  /* filename/-pattern */
  if (fileargc < 2) {
    /* no destination path specified -> use current */
    getcwd(dest_pathname, MAXPATH);
    strmcpy(dest_filename, "*.*", sizeof(dest_filename));
  }
  else {
    /* destination path specified */
    length = strlen(fileargv[1]);
    if (length > (MAXPATH - 1)) {
      printf("%s\n", catgets(cat, 1, 8, "Destination path too long"));
      catclose(cat);
      exit(4);
    }
    _fullpath(dest_pathname, fileargv[1], MYMAXPATH);
    if (dest_pathname[0] == '\0') {
      printf("%s\n", catgets(cat, 1, 9, "Invalid destination drive specification"));
      catclose(cat);
      exit(4);
    }
    /* check destination path */
    if (fileargv[1][length - 1] != *DIR_SEPARATOR &&
        !dir_exists(dest_pathname)) {
      ptr = strrchr(dest_pathname, *DIR_SEPARATOR);
      ptr++;
      strmcpy(dest_filename, ptr, sizeof(dest_filename));
      *ptr = '\0';
      if ((ptr = strchr(dest_filename, '*')) == NULL &&
          (ptr = strchr(dest_filename, '?')) == NULL) {
        /* last destination entry is not a filepattern -> does it specify */
        /* a file or directory? */
        if (((ptr = strchr(src_filename, '*')) == NULL &&
             (ptr = strchr(src_filename, '?')) == NULL) ||
            !switch_intodir) {
          /* source is a single file or switch /I was not specified -> ask */
          /* user if destination should be a file or a directory */
          printf("%s %s %s\n",
            catgets(cat, 1, 10, "Does"),
            dest_filename,
            catgets(cat, 1, 11, "specify a file name"));
          ch = confirm(
            catgets(cat, 1, 12, "or directory name on the target"),
            catgets(cat, 1, 13, "File"),
            catgets(cat, 1, 14, "Directory"), NULL, NULL);
          switch (ch) {
            case 1: /* 'F' */
              /* file */
              switch_file = -1;
              break;
            case 2: /* 'D' */
              /* directory */
              switch_intodir = -1;
              break;
          }
        }
        if (switch_intodir) {
          /* destination is a directory -> filepattern = "*.*" */
          strmcat(dest_pathname, dest_filename, sizeof(dest_pathname));
          strmcpy(dest_filename, "*.*", sizeof(dest_filename));
        }
      }
    }
    else {
      /* destination is a directory -> filepattern = "*.*" */
      strmcpy(dest_filename, "*.*", sizeof(dest_filename));
    }
  }
  cat_separator(dest_pathname);
  length = strlen(dest_pathname);
  if (length > (MAXDRIVE - 1 + MAXDIR - 1)) {
    printf("%s\n",catgets(cat, 1, 15, "Destination path too long"));
    catclose(cat);
    exit(4);
  }

  /* check for cyclic path */
  if ((switch_emptydir || switch_subdir) &&
      cyclic_path(src_pathname, dest_pathname)) {
    printf("%s\n",catgets(cat, 1, 16, "Cannot perform a cyclic copy"));
    catclose(cat);
    exit(4);
  }

  /* get destination drive (1 = A, 2 = B, 3 = C, ...) */
  dest_drive = toupper(dest_pathname[0]) - 64;

  if (switch_wait) {
    printf("%s\n",catgets(cat, 1, 17, "Press enter to continue..."));
    (void)getchar(); /* getch(); would need conio.h */
    fflush(stdin);
  }

  xcopy_files(src_pathname, src_filename, dest_pathname, dest_filename);
  if (!file_found) {
    printf("%s - %s\n",catgets(cat, 1, 18, "File not found"), src_filename);
    catclose(cat);
    exit(1);
  }

  catclose(cat);
  return 0;
}