コード例 #1
0
ファイル: gp_msdos.c プロジェクト: LambdaCalculus379/SLS-1.02
/* Enumerate the next file. */
uint
gp_enumerate_files_next(file_enum *pfen, char *ptr, uint maxlen)
{	int code;
	char *p, *q;
	if ( pfen->first_time )
	   {	code = dos_findfirst(pfen->pattern, &pfen->ffblk);
		pfen->first_time = 0;
	   }
	else
		code = dos_findnext(&pfen->ffblk);
	if ( code != 0 )
	   {	/* All done, clean up. */
		gp_enumerate_files_close(pfen);
		return ~(uint)0;
	   }
	if ( maxlen < 13 + pfen->head_size ) return maxlen + 1;	/* cop out! */
	memcpy(ptr, pfen->pattern, pfen->head_size);
	for ( p = &pfen->ffblk.ff_name[0], q = ptr + pfen->head_size; *p; p++ )
	  if ( *p != ' ' ) *q++ = *p;
	return q - ptr;
}
コード例 #2
0
ファイル: fcbfns.c プロジェクト: TijmenW/FreeDOS
BOOL FcbDelete(xfcb FAR * lpXfcb)
{
  COUNT FcbDrive;

  /* Build a traditional DOS file name                            */
  CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);

  /* check for a device                                           */
  /* if we have an extension, can't be a device                   */
  if (IsDevice(PriPathName))
  {
    return FALSE;
  }
  else
  {
    BYTE FAR *lpOldDta = dta;
    dmatch Dmatch;

    dta = (BYTE FAR *) & Dmatch;
    if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS)
    {
      dta = lpOldDta;
      return FALSE;
    }
    do
    {
      if (dos_delete(Dmatch.dm_name) != SUCCESS)
      {
        dta = lpOldDta;
        return FALSE;
      }
    }
    while (dos_findnext() == SUCCESS);
    dta = lpOldDta;
    return TRUE;
  }
}
コード例 #3
0
ファイル: fcbfns.c プロジェクト: TijmenW/FreeDOS
BOOL FcbFindFirst(xfcb FAR * lpXfcb)
{
  BYTE FAR *lpOldDta;
  BYTE FAR *lpDir;
  COUNT nIdx,
    FcbDrive;
  psp FAR *lpPsp = MK_FP(cu_psp, 0);

  /* First, move the dta to a local and change it around to match */
  /* our functions.                                               */
  lpDir = (BYTE FAR *) dta;
  dta = (BYTE FAR *) & Dmatch;

  /* Next initialze local variables by moving them from the fcb   */
  lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);
  if (lpXfcb->xfcb_flag == 0xff)
  {
    wAttr = lpXfcb->xfcb_attrib;
    fbcopy(lpXfcb, lpDir, 7);
    lpDir += 7;
  }
  else
    wAttr = D_ALL;

  *lpDir++ = PriPathName[0] - 'A';
  if (dos_findfirst(wAttr, PriPathName) != SUCCESS)
  {
    dta = lpPsp->ps_dta;
    return FALSE;
  }

  MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir);
  lpFcb->fcb_dirclst = Dmatch.dm_cluster;
  lpFcb->fcb_diroff = Dmatch.dm_entry;
  dta = lpPsp->ps_dta;
  return TRUE;
}
コード例 #4
0
ファイル: if.c プロジェクト: FDOS/freecom
int cmd_if(char *param)
{

#define X_EXEC 1

	char *pp;

	int x_flag = 0;       /* when set cause 'then' clause to be exec'ed */
	int negate = 0;       /* NOT keyword present */
	int ignore_case = 0;  /* /I option, case insensitive compare */


	/* First check if param exists */
	assert(param);

	/* check for options, note non-options must be treated as part of comparision */
      if (matchtok(param, "/I")||matchtok(param, "/i"))
        ignore_case++;

	/* next check if param string begins with word 'not' */
	if(matchtok(param, "not"))
		negate = X_EXEC;            /* Remember 'NOT' */

	/* Check for 'exist' form */

	if(matchtok(param, "exist")) {
		struct dos_ffblk f;
		isr olderrhandler;

		if(!*param) {
			/* syntax error */
			error_if_exist();
			return 0;
		}

		pp = skip_word(param);
		*pp++ = '\0';

		/* don't show abort/retry/fail if no disk in drive */
		get_isr(0x24, olderrhandler);
#ifdef XMS_SWAP
		set_isrfct(0x24, autofail_err_handler);  /* always fails */
#else
		set_isrfct(0x24, dummy_criter_handler);  /* always fails */
#endif

		if(dos_findfirst(param, &f, FA_NORMAL|FA_ARCH|FA_SYSTEM|FA_RDONLY|FA_HIDDEN) == 0)
			x_flag = X_EXEC;
		dos_findclose(&f);
        
		/* restore critical error handler */
		set_isrfct(0x24, olderrhandler);
	}

	/* Check for 'errorlevel' form */

	else if(matchtok(param, "errorlevel")) {
		int n = 0;

#if 0
		if(!isdigit(*param)) {
			error_if_errorlevel();
			return 0;
		}

		pp = param;
		do  n = n * 10 + (*pp - '0');
		while (isdigit(*++pp));

		if(*pp && !isargdelim(*pp)) {
			error_if_errorlevel_number();
			return 0;
		}
#else
		/* Add this COMMAND bug as someone tries to use:
			IF ERRORLEVEL H<upper-case_letter>
			-or-
			IF ERRORLEVEL x<lower-case_letter>

			to match the errorlevel against drive letters.
			NOT supported by 4dos or WinNT.

			HA --> maps to errorlevel 1
			xa --> same

			HB & xb --> to 2
			a.s.o.
		*/

		if(!*param) {
			error_if_errorlevel();
			return 0;
		}
		pp = param;
		do  n = n * 10 + (*pp - '0');
		while(*++pp && !isargdelim(*pp));
		n &= 255;
		dprintf( ("IF: checking for ERRORLEVEL >= %u\n", n) );
#endif

		if(errorlevel >= n)
			x_flag = X_EXEC;
	}

	/* Check that '==' is present, syntax error if not */
	else {
		size_t len;
		char *r;      /* right operand */

		pp = skipqword(param, "==");

		if(*pp != '=' || pp[1] != '=') {
			error_syntax(0);
			return 0;
		}

		*pp = '\0';     /* param[] points to the left operand */

		/* skip over the '==' and subsquent spaces and
			assign the end of the right operator to pp */
		pp = skipqword(r = ltrimcl(pp + 2), 0);

		/*	now: param := beginning of the left operand
			r := beginning of the right operand
			pp := end of right operand
		*/

		rtrimcl(param);      /* ensure that spurious whitespaces are ignored */
		len = strlen(param);

		/* check if strings differ */
		if ( ((pp - r) == len) &&
		     ((ignore_case && strnicmp(param, r, len) == 0) ||
		      (memcmp(param, r, len) == 0)) )
			x_flag = X_EXEC;
	}

	if(x_flag ^ negate)		/* perform the command */
		if(!*(pp = ltrimcl(pp)))
			error_if_command();
		else
			parsecommandline(pp, FALSE);

	return 0;
}
コード例 #5
0
ファイル: dosfns.c プロジェクト: krinkleneck/ForthDOS
COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name)
{
  SAttr = (BYTE) attr;
  return dos_findfirst(attr, name);
}
コード例 #6
0
ファイル: fcbfns.c プロジェクト: TijmenW/FreeDOS
BOOL FcbRename(xfcb FAR * lpXfcb)
{
  rfcb FAR *lpRenameFcb;
  COUNT FcbDrive;

  /* Build a traditional DOS file name                            */
  lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);

  /* check for a device                                           */
  /* if we have an extension, can't be a device                   */
  if (IsDevice(PriPathName))
  {
    return FALSE;
  }
  else
  {
    BYTE FAR *lpOldDta = dta;
    dmatch Dmatch;

    dta = (BYTE FAR *) & Dmatch;
    if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS)
    {
      dta = lpOldDta;
      return FALSE;
    }

    do
    {
      fcb LocalFcb;
      BYTE *pToName,
       *pszFrom;
      BYTE FAR *pFromPattern;
      COUNT nIndex;

      /* First, expand the find match into fcb style  */
      /* file name entry                              */
      /* Fill with blanks first                       */
      for (pToName = LocalFcb.fcb_fname, nIndex = 0;
           nIndex < FNAME_SIZE; nIndex++)
      {
        *pToName++ = ' ';
      }
      for (pToName = LocalFcb.fcb_fext, nIndex = 0;
           nIndex < FEXT_SIZE; nIndex++)
      {
        *pToName++ = ' ';
      }

      /* next move in the file name while overwriting */
      /* the filler blanks                            */
      pszFrom = Dmatch.dm_name;
      pToName = LocalFcb.fcb_fname;
      for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++)
      {
        if (*pszFrom != 0 && *pszFrom != '.')
          *pToName++ = *pszFrom++;
        else if (*pszFrom == '.')
        {
          ++pszFrom;
          break;
        }
        else
          break;
      }

      if (*pszFrom != '\0')
      {
        pToName = LocalFcb.fcb_fext;
        for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++)
        {
          if (*pszFrom != '\0')
            *pToName++ = *pszFrom++;
          else
            break;
        }
      }

      /* Overlay the pattern, skipping '?'            */
      /* I'm cheating because this assumes that the   */
      /* struct alignments are on byte boundaries     */
      pToName = LocalFcb.fcb_fname;
      for (pFromPattern = lpRenameFcb->renNewName,
           nIndex = 0; nIndex < FNAME_SIZE + FEXT_SIZE; nIndex++)
      {
        if (*pFromPattern != '?')
          *pToName++ = *pFromPattern++;
        else
          ++pFromPattern;
      }

      /* now to build a dos name again                */
      LocalFcb.fcb_drive = 0;
      FcbNameInit((fcb FAR *) & LocalFcb, PriPathName, &FcbDrive);

      if (dos_rename(Dmatch.dm_name,
       PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS)
      {
        dta = lpOldDta;
        return FALSE;
      }
    }
    while (dos_findnext() == SUCCESS);
    dta = lpOldDta;
    return TRUE;
  }
}