示例#1
0
main()
{
	/*
	char	buf[512], bbuf[512];
	int	i;
	long	srchndl, dsthndl, ret;
	/**/

/*
	for (i = 0; i < 512*3;) {
		buf[i++] = 'M';
		buf[i++] = 'I';
		buf[i++] = 'N';
		buf[i++] = 'O';
	}
/**/	

	/* physical operation on unit 0 */
/*
	Lrwabs(9, buf, 1, 0x10000, 2);
	Lrwabs(8, bbuf, 1, 0x10000, 3);
/**/	
	/* logical operation on D: */
/*
	i = 1;
	while (i == 1) {
		Mediach(3);
		Getbpb(3);
		Rwabs(1, buf, 1, 0x700, 3);
	}
/**/	
/*
	Lrwabs(0, bbuf, 1, 0x10000, 3);
	Rwabs(1, buf+1, 3, 102, 3);
	Rwabs(0, buf, 3, 102, 3);
	Rwabs(9, bbuf, 1, 0, 11);
	Rwabs(8, bbuf, 1, 0, 11);
	Rwabs(9, bbuf, 1, 0, 11);
	char	*buf256;
	
	buf256 = (char *)Malloc(131072L);
	Rwabs(8, buf256+1, 2, 0, 18);
	Rwabs(9, buf256+1, 2, 0xa35a, 18);
/**/
/*
	Rwabs(8, buf256+1, 255, 0, 10);
	Rwabs(9, buf256+1, 255, 0, 10);
/**/
	Fsfirst("h:\\*.*", 0);
	
	while (!(Cconis()))
		;

	Fsfirst("g:\\*.*", 0);
	Fsfirst("h:\\*.*", 0);
	Pterm(0);
}
示例#2
0
/*
 * raw_read_file:
 *	read the CKB file completely
 */
BOOL raw_read_file(char *name)
{
	DTA		mydta;
	int		handle;

	if (CKBfileblock) {
		Mfree(CKBfileblock);
		CKBfileblock = NULL;
	}

	Readlnidx = 0; cline=0;

	/* locate file */
	Fsetdta(&mydta);
	if (Fsfirst(name, FA_READONLY|FA_ARCHIVE|FA_SYSTEM)!=0) return FALSE;		/* file not found */

	/* alloc space for the file */
	CKBfileblock = Malloc((mydta.d_length+16L)&(-16L));
	if (CKBfileblock==0) return FALSE;				/* out of memory */

	/* open the file */
	handle = (int)Fopen(name, FO_READ);
	if (handle<=0) return FALSE;					/* file open error */

	/* read all of it */
	CKBfilesize = Fread(handle, mydta.d_length, CKBfileblock);

	/* close it */
	Fclose(handle);

	if (CKBfilesize<=0) return FALSE;
	return TRUE;
}
示例#3
0
/*******************************************************************************
	Test if a folder exists
*******************************************************************************/
int _dexist(char *name)
{
	char	old_path[FILENAME_MAX];
	char	myname[FILENAME_MAX];
	int	old_drv;
	int	i,ok=FALSE;
	DTA	*old,dta;

	old=Fgetdta();
	old_drv=Dgetdrv();
	Dgetpath(old_path,1+old_drv);
	if (name[1]==':')
		Dsetdrv((int)name[1]-65);
	Fsetdta(&dta);

	strcpy(myname,name);
	i=(int)strlen(myname);
	if (myname[i-1]=='\\')
		strcat(myname,"*.*");
	else
		strcat(myname,"\\*.*");
	if (!Fsfirst(myname,FA_READONLY+FA_HIDDEN+FA_SYSTEM+FA_ARCHIVE+FA_SUBDIR))
		ok=TRUE;
	Dsetdrv(old_drv);
	Dsetpath(old_path);
	Fsetdta(old);
	return ok;
}
示例#4
0
文件: appl.c 项目: e8johan/oaesis
/*
** Description
** Get program name and command line
*/
static
void
get_loadinfo (WORD   pid,
	      WORD   fnamelen,
	      BYTE * cmdlin,
	      BYTE * fname)
{
  BYTE pname[30];
  _DTA *olddta,newdta;
	
  olddta = Fgetdta();
  Fsetdta(&newdta);
	
  sprintf(pname,"u:\\proc\\*.%03d",pid);
  if(Fsfirst(pname,0) == 0) {
    LONG fd;
		
    sprintf(pname,"u:\\proc\\%s",newdta.dta_name);
		
    if((fd = Fopen(pname,0)) >= 0) {
      struct ploadinfo li;
			
      li.fnamelen = fnamelen;
      li.cmdlin = cmdlin;
      li.fname = fname;
			
      Fcntl((WORD)fd,&li,PLOADINFO);
      Fclose((WORD)fd);
    }
  }
	
  Fsetdta(olddta);
}
示例#5
0
WORD file_exists(BYTE *dir, BYTE *name)
{
	BYTE f_name[80];

	strcpy( dir, f_name );
	strcat( f_name, name );
#if GEMDOS
	return( Fsfirst( ADDR(f_name), 0 ) );
#else
	return( dos_sfirst( ADDR(f_name), 0 ) );
#endif
}
示例#6
0
char *load_avr( char *name )
{
	char fname[80] = "D:\\SOUNDS\\";
	char *avr, *p;
	int handle;
	DTA	file_info;

	strcat( fname, name );
	p = name;

	if ( Fsfirst( name, 0 ) != 0 ) {
		Fsfirst( fname, 0 );
		p = fname;
	}
	file_info = *Fgetdta();
	
	avr = Malloc( file_info.d_length );
	
	handle = (int)Fopen( p, FO_READ );
	Fread( handle, 1000000L, avr );
	Fclose( handle );
	
	return( avr );
}
示例#7
0
/****************************************************************
*																*
*			test la chaŒne renvoy‚e par scrp_read()				*
*																*
****************************************************************/
boolean test_scrap_path(char *scrap_path)
{
	int len = (int)strlen(scrap_path);

	if (len == 0)
	{
		int device, err;

		/* C:\ existe ? */
		if (Drvmap() & (1<<2))
			device = 'C';
		else
			device = 'A';

		sprintf(scrap_path, "%c:\\CLIPBRD", device);

		/* cr‚e le r‚pertoire */
		if ((err = Dcreate(scrap_path)) < 0 && err != -36)
		{
			error_msg(err);
			return TRUE;
		}

		strcat(scrap_path, "\\");

		/* on pr‚vient l'AES */
		if (!scrp_write(scrap_path))
		{
			error_msg(Z_CLIPBOARD_NOT_INSTALLABLE);
			return TRUE;
		}
	}
	else
		if (scrap_path[len-1] != '\\')
		{
			if (Fsfirst(scrap_path, FA_SUBDIR))
			{
				/* c'est un r‚pertoire sans \ … la fin (C:\CLIPBRD) */
				scrap_path[len] = '\\';
				scrap_path[len+1] = '\0';
			}
			else
				/* c'est pas un r‚pertoire (C:\CLIPBRD\SCRAP.TXT) */
				*(strrchr(scrap_path, '\\')+1) = '\0';
		}

	return FALSE;
} /* test_scrap_path */
示例#8
0
文件: dir.c 项目: 8l/vlink
char *open_dir(const char *dirname)
/* open a directory for examination */
{
  struct Dir *d;

  if (d = malloc(sizeof(struct Dir))) {
    strncpy(d->name,dirname,MAX_PATH_LEN);
    d->olddta = Fgetdta();
    Fsetdta(&d->dta);
    d->err = Fsfirst(d->name,FA_READONLY|FA_ARCHIVE);
    if (d->err != E_OK) {
      Fsetdta(d->olddta);
      free(d);
      d = NULL;
    }
  }
  return (char *)d;
}
示例#9
0
void test0301(void)
{
    char dta[44];
    int cnt, res;
    BYTE ok;
    
    cnt = countFoundItems(dta, "*.*", 0x3f, TRUE,  -1);
    (cnt == 77) ? (ok = 1) : (ok = 0);
    out_tr_bw(0x0301, "Fsfirst & Fsnext - match everything", ok, cnt);

    cnt = countFoundItems(dta, "*.*", 0x10, TRUE,  -1);
    (cnt == 27 || cnt == 77) ? (ok = 1) : (ok = 0);                     // TOS bug? It shoud find only 27 directories, but instead it finds everything?
    out_tr_bw(0x0302, "Fsfirst & Fsnext - match all dirs", ok, cnt);

    cnt = countFoundItems(dta, "*.*", 0x00, TRUE,  -1);
    (cnt == 50) ? (ok = 1) : (ok = 0);
    out_tr_bw(0x0303, "Fsfirst & Fsnext - match all files", ok, cnt);

    cnt = countFoundItems(dta, "FILE_1*.*", 0x3f, TRUE,  -1);
    (cnt == 10) ? (ok = 1) : (ok = 0);
    out_tr_bw(0x0304, "Fsfirst & Fsnext - wildcard * in fname", ok, cnt);

    cnt = countFoundItems(dta, "FILE_?5.*", 0x3f, TRUE,  -1);
    (cnt == 2) ? (ok = 1) : (ok = 0);
    out_tr_bw(0x0305, "Fsfirst & Fsnext - wildcard ? in fname", ok, cnt);

    cnt = countFoundItems(dta, "FILENAME.*2", 0x3f, TRUE,  -1);
    (cnt == 2 || cnt == 25) ? (ok = 1) : (ok = 0);                      // TOS bug? Steam drive finds only 2 files (which is correct), TOS finds all 25 files like there would be no '2' after '*'
    out_tr_bw(0x0306, "Fsfirst & Fsnext - wildcard * in ext", ok, cnt);

    cnt = countFoundItems(dta, "FILENAME.X0?", 0x3f, TRUE,  -1);
    (cnt == 15) ? (ok = 1) : (ok = 0);
    out_tr_bw(0x0307, "Fsfirst & Fsnext - wildcard ? in ext", ok, cnt);
    
    cnt = countFoundItems(dta, "FILE_05", 0x00, TRUE,  -1);
    (cnt == 1) ? (ok = 1) : (ok = 0);
    out_tr_bw(0x0308, "Fsfirst & Fsnext - exact file", ok, cnt);
    
    Fsetdta(dta);                       // set DTA 
    res = Fsfirst("DOESNT.EXS", 0x00);
    (res == -33) ? (ok = 1) : (ok = 0);
    out_tr_bw(0x0309, "Fsfirst & Fsnext - non-existing file", ok, res);
}
示例#10
0
int initiatedcc(char *usr,char *ftg){
short temp;
struct FILEINFO finf;
uint32 length;
uint32 cip;
char temps2[2048];

if(!strlen(ftg)){form_alert(1,"[1][DCC Error:|Please specify a file][Okay]");return 0;}
if(!strlen(usr)){form_alert(1,"[1][DCC Error:|Please specify recipient][Okay]");return 0;}
temp=findfreedc();
if(temp==-1){form_alert(1,"[1][DCC Error:|No free channels!][Okay]");return 0;}
dcc[temp].dcfh=Fopen(ftg,0);
if(dcc[temp].dcfh<0){form_alert(1,"[DCC Error:|Unable to open file][Okay]");return 0;}
dcc[temp].cn=TCP_open(0L,0,0,4096);
if(dcc[temp].cn<0){form_alert(1,"[1][DCC Error:|Unable to open socket][Okay]");return 0;}
dcc[temp].stat=SAWAIT;
dcc[temp].dir=DCOUT;
Fsetdta(&finf);
Fsfirst(ftg,0);
length=finf.size;
strcpy(dname,ftg);
basename(dname);
cb=CNgetinfo(cn[wn[cwin].cnn].cn);
cip=stik_cfg->client_ip;
if(cip==0||cip==0x7F000001)
cip=cb->lhost;
cb=CNgetinfo(dcc[temp].cn);
sprintf(temps2,":%s PRIVMSG %s :\001DCC SEND %s %lu %u %lu\001\n",cn[wn[cwin].cnn].nick,usr,dname,cip,cb->lport,length);
TCP_send(cn[wn[cwin].cnn].cn,(char *)&temps2,(int16)strlen(temps2));
dcc[temp].rport=cb->lport;
dcc[temp].rip=cip;
strcpy(dcc[temp].fname,dname);
dcc[temp].len=length;
strcpy(dcc[temp].avec,usr);
if(!conf.boldnicks)
sprintf(temps2,"--Initiating DCC send to %s: %s",usr,dname);
else
sprintf(temps2,"--Initiating DCC send to %s: %s",usr,dname);

sendout(temps2,cwin,col[CDCCINFO]);
if(conf.autodcd)opendccsenddialog(temp,dname);
return 0;
}
示例#11
0
void GetLDVLanguages(LDV_MODULE *ldv, char *buf)
{
  DTA  dta, *old_dta ;
  char name[PATH_MAX] ;
  char ini_name[PATH_MAX] ;
  char ldv_nameextini[50] ;
  char *dot ;
  int  ret ;

  if ( ldv->FileName ) strcpy( ldv_nameextini, ldv->FileName ) ;
  else                 return ;
  dot = strrchr( ldv_nameextini, '.' ) ;
  if ( dot )
  {
    *dot = 0 ;
    strcat( ldv_nameextini, ".INI" ) ;
  }

  sprintf( ini_name, "%s\\%s", config.path_ldv, ldv_nameextini ) ;
  if ( FileExist( ini_name ) ) sprintf( buf, "English " ) ;
  else                         buf[0] = 0 ;

  sprintf( name, "%s\\*.*", config.path_ldv ) ;
  old_dta = Fgetdta() ;
  Fsetdta( &dta ) ;
  ret = Fsfirst( name, FA_SUBDIR ) ;
  while ( ret == 0 )
  {
    if ( ( dta.d_fname[0] != '.' ) && ( dta.d_attrib & FA_SUBDIR ) )
    {
      sprintf( ini_name, "%s\\%s\\%s", config.path_ldv, dta.d_fname, ldv_nameextini ) ;
      if ( FileExist( ini_name ) )
      {
        strlwr( &dta.d_fname[1] ) ;
        strcat( buf, dta.d_fname ) ;
        strcat( buf, " " ) ;
      }
    }
    ret = Fsnext() ;
  }

  Fsetdta( old_dta ) ;
}
示例#12
0
/**
 * Process all files in the directory.
 *
 * @param dirpath path to directory to traverse.
 * @param callback function called back for each file found.
 * @return True if and only if everything was ok.
 */
bool ReadDir_ProcessAllFiles(const char * dirpath, bool (*callback)(const char *name, const char *path, uint32 size))
{
	_DTA dta;
	char searchpath[256];
	char path[256];
	long r;

	snprintf(searchpath, sizeof(searchpath), "%s*.*", dirpath);
	Fsetdta(&dta);
	if(Fsfirst(searchpath, FA_RDONLY | FA_HIDDEN) != 0) {
		return false;
	} else do {
		/* Skip directories */
		if (dta.dta_attribute & FA_DIR) continue;
		snprintf(path, sizeof(path), "%s%s", dirpath, dta.dta_name);
		Debug("Found file %-17s %7ld bytes\n", path, dta.dta_size);
		if (!callback(dta.dta_name, path, (uint32)dta.dta_size)) {
			return false;
		}
	} while((r = Fsnext()) == 0);
	return (r == -ENMFILES);
}
示例#13
0
/*******************************************************************************
	Test if a file exists
*******************************************************************************/
int _fexist(char *name,DTA *res)
{
	char	old_path[FILENAME_MAX];
	int	old_drv;
	int	ok=FALSE;
	DTA	*old,dta;

	old=Fgetdta();
	old_drv=Dgetdrv();
	Dgetpath(old_path,1+old_drv);
	if (name[1]==':')
		Dsetdrv((int)name[1]-65);
	Fsetdta(&dta);

	if (!Fsfirst(name,FA_READONLY+FA_HIDDEN+FA_SYSTEM+FA_ARCHIVE+FA_SUBDIR))
		ok=TRUE;
	if (ok && res)
		memcpy((void *)res,(void *)&dta,sizeof(DTA));
	Dsetdrv(old_drv);
	Dsetpath(old_path);
	Fsetdta(old);
	return ok;
}
示例#14
0
int x_getlabel(int drive, char *label)
{
	DTA *olddta, dta;
	int error;
	char path[10];

#if USE_gemdos
	olddta = (DTA *) gemdos(47);
	gemdos(26, &dta);
#else
	olddta = Fgetdta();
	Fsetdta(&dta);
#endif

	strcpy(path, "A:\\*.*");
	path[0] += (char) drive;

#if USE_gemdos
	error = (int) gemdos(78, path, 0x3F);
#else
	error = Fsfirst(path, 0x3F);
#endif

	/* if ((error == 0) && (dta.d_attrib & 8)) DjV 004 300103 */
	if ((error == 0) && (dta.d_attrib & FA_VOLUME)) /* DjV 004 300103 same but more readable */
		strcpy(label, dta.d_fname);
	else
		*label = 0;

#if USE_gemdos
	gemdos(26, olddta);
#else
	Fsetdta(olddta);
#endif

	return ((error == -49) || (error == -33)) ? 0 : error;
}
示例#15
0
int countFoundItems(char *dta, char *fspec, WORD attribs, BYTE startNotCont, int stopAfter)
{
    int res, found = 0;
    
    if(startNotCont) {                  // on start clean DTA
        memset(dta, 0, 44);
    }
    
    Fsetdta(dta);                       // set DTA 

    if(startNotCont) {                  // if should start search, not continue
        res = Fsfirst(fspec, attribs);
        
        if(res) {                       // file not found?
            return 0;
        }
        
        found++;
    }
    
    while(1) {
        if(found == stopAfter) {        // if we found all we needed, stop
            return found;
        }
        
        res = Fsnext();
        
        if(res) {                       // if file not found, quit
            return found;
        }
        
        found++;
    }
    
    return found;                       // this should never happen
}
示例#16
0
/*******************************************************************************
	BALAYAGE D'UN DOSSIER
*******************************************************************************/
static int Balaie_Path(char *directory,int wx,int wy,int ww,int wh)
{
	char		old_path[FILENAME_MAX];
	int		old_drv;
	char		pfn[FILENAME_MAX];
	DTA		*mydta;
	int		i,Fin=0;
	int		cnt,pos;
/*	long		count;*/

	t2=0;
	old_drv=Dgetdrv();
	Dgetpath(old_path,1+old_drv);
	mydta=Fgetdta();
	if (directory[1]==':')
		Dsetdrv((int)directory[1]-65);

	strcpy(pfn,directory);
	strcat(pfn,"\\*.*");
	if (glb.opt.sl_rec)
		i=Fsfirst(pfn,FA_READONLY|FA_SUBDIR|FA_ARCHIVE);
	else
		i=Fsfirst(pfn,FA_READONLY|FA_ARCHIVE);
	pos=0;
loop1:
	cnt=0;
	while (!i)
	{
		cnt+=1;
		if (mydta->d_fname[0]!='.' && cnt>pos)
		{
			strcpy(pfn,directory);
			strcat(pfn,"\\");
			strcat(pfn,mydta->d_fname);
			if (mydta->d_attrib&FA_SUBDIR)
			{
				pos=cnt;
				if (Balaie_Path(pfn,wx,wy,ww,wh))
					return TRUE;
				strcpy(pfn,directory);
				strcat(pfn,"\\*.*");
				if (glb.opt.sl_rec)
					i=Fsfirst(pfn,FA_READONLY|FA_SUBDIR|FA_ARCHIVE);
				else
					i=Fsfirst(pfn,FA_READONLY|FA_ARCHIVE);
				goto loop1;
			}
		}
		if (Kbshift(-1)!=shift)
			return TRUE;
		i=Fsnext();
/*
		if (i!=0)
			{
				time(&t1);
				if(glb.opt.sl_pause)
				{
					count=1000L*max( 0 , (long)glb.opt.sl_ptime - (t1-t2) );
					evnt_timer( (int)(count&0xFFFFUL),(int)(count>>16) );
				}
				else
					count=0;
			}
*/
	}


	strcpy(pfn,directory);
	strcat(pfn,"\\");
	strcat(pfn,glb.opt.sl_name);

	if (glb.opt.sl_rec)
		i=Fsfirst(pfn,FA_READONLY|FA_SUBDIR|FA_ARCHIVE);
	else
		i=Fsfirst(pfn,FA_READONLY|FA_ARCHIVE);
	pos=0;
	cnt=0;
	while (!i)
	{
		cnt+=1;
		if (mydta->d_fname[0]!='.' && cnt>pos)
		{
			strcpy(pfn,directory);
			strcat(pfn,"\\");
			strcat(pfn,mydta->d_fname);
			if (!(mydta->d_attrib&FA_SUBDIR))
				affiche(pfn,wx,wy,ww,wh);
		}
		if (Kbshift(-1)!=shift)
			return TRUE;
		i=Fsnext();
/*
		if (i!=0)
			{
				time(&t1);
				if(glb.opt.sl_pause)
					count=1000L*max( 0 , (long)glb.opt.sl_ptime - (t1-t2) );
				else
					count=0;
				evnt_timer( (int)(count&0xFFFFUL),(int)(count>>16) );
			}
*/
	}


	Dsetdrv(old_drv);
	Dsetpath(old_path);
	return Fin;
}
示例#17
0
WORD
wrfile( char *fstr )
{
	REG int 	ret, retmsg;
	int 		inhand,outhand;
	int		time[2];
	DMABUFFER 	*mydta, *saved;
	char 		*buffer;
	long 		copysiz, bufsiz, wrsiz, tmpsiz; 
	int 		crted,sttime;
	char		buf[2];

	crted = 0;
	sttime = 1;
	retmsg = TRUE;
	rename = 0;
open:					/* open the source file	*/
	if ( ( inhand = (WORD)Fopen(fixsrc, 0) ) < 0 )		
	{				/* seek error or drive not ready */	
/*	  if ( (inhand == E_SEEK) || (inhand == EDRVNR) )
	    return( FALSE );
*/					/* skip	*/
	  if ( ( ret = fill_string( fixsrc, CNTOPEN ) ) == 1 )
	  {
	    updatnum(NUMFILE, --numfiles);
	    return SKIP;
	  }
	  else if (ret == 2)			/* retry */
		  goto open;
		else 				/* abort */
		  goto ww_3;
	}

	if ( !ch_undo() || f_cancel )		/* user want to stop */
	{
	  Fclose( inhand );
ww_3:	  f_abort = 1;
	  return( FALSE );
	}		  

	saved = (DMABUFFER *)Fgetdta();
	Fsetdta(mydta=(DMABUFFER *)malloc( (long)sizeof(DMABUFFER)));

	if ( Fsfirst( fixsrc, 0x37 ) )	
	{
	   retmsg = SKIP;
	   if ( do1_alert( RDERROR ) == 2 )	/* abort */
	   {
	     f_abort = 1;
	     retmsg = FALSE;
	   }
	   goto y2;
	}

	copysiz = mydta->d_fsize;
	buffer = (char *)malloc( copysiz );
	if ( buffer )
	{
	  bufsiz = copysiz;
	}
	else
	{
	  for (bufsiz = 128*1024L; bufsiz >= 1024L; bufsiz /= 2)
	  {
	    if ((buffer = (char *)malloc( bufsiz )) != 0)
	      break;
	  }
	  if (!buffer)
	    goto y2;
	}
  
	Fdatime( &time, inhand, 0 );	/* read the time and date */

rechkd:
	switch(chkdf(fstr, CPFILE))
	{
	    case CHECK:	
	      goto rechkd;

	    case SKIP:	
	      retmsg = SKIP;	
	      goto y1;

	    case QUIT:	
	      f_abort = 1;
	      retmsg = FALSE;
	      goto y1;

	    case FALSE:	
              retmsg = FALSE;
	      goto y1;
	}


	/* if it is move operation, then try rename first	*/

	if ( opcode == OP_MOVE )
	{			/* if same name and path, don't do it */
	  if ( strcmp( fixsrc, fixdst ) )
	    goto y22;
	
	  Fclose( inhand );

	  if ( Frename(0, fixsrc, fixdst) >= 0 )
   	  {	
	    inhand = (WORD)Fopen( fixdst, 0 );
	    if ( !p_timedate )		/* get the new time and date */
	    {
	      time[0] = Tgettime();
	      time[1] = Tgetdate();
	      Fdatime( &time, inhand, 1 ); 	
	    }
y22:	    
	    rename = 1;
	    goto y1;
	  }
	  else
	    inhand = (WORD)Fopen( fixsrc, 0 );		
	}


	while ( copysiz >= 0 ) 	/* let it passes through for zero file */
	{
	  tmpsiz = (copysiz > bufsiz) ? bufsiz : copysiz;
	  if (Fread(inhand, tmpsiz, buffer) < 0)	
	  {
	    retmsg = SKIP;
	    if ( crted )	
	      Fdelete( fixdst );

	    if (do1_alert( RDERROR ) == 2)	
	    {					/* abort */
	      f_abort = 1;
	      retmsg = FALSE;
	    }
	    goto y1;			/* skip */
	  }




create:
	  if ( sttime )
	  {
	    sttime = 0;

	    if ((outhand = (WORD)Fcreate(fixdst, mydta->d_fattr&7)) < 0)	
	    {
	      if ( ( ret = fill_string( fixdst, CNTCRTFL ) ) == 2 )
		goto create;

	      else if (ret == 3)				/* abort */
	      {
		 f_abort = 1;
		 retmsg = FALSE;
	      }
	      else	
		retmsg = SKIP;

	      goto y1;
	    }

	    crted = 1;
	  }

	  if ((wrsiz = Fwrite(outhand, tmpsiz, buffer)) < 0)	
	  {
	     retmsg = SKIP;
	     Fclose(outhand);
	     Fdelete(fixdst);

	    if (do1_alert( WRERROR ) == 2)	
	    {					/* abort */
	      f_abort = 1;
	      retmsg = FALSE;
	    }

	    goto y1;
	   }
				/* check if there are sufficent memory */
	   if (wrsiz != tmpsiz)		
	   { 			/* not sufficent memory ??*/
	      f_abort = 1;
	      retmsg = FALSE;
	      Fclose(outhand);	
	      Fdelete(fixdst);
	      buf[0] = *fixdst;
	      buf[1] = 0;
	      fill_string( buf, STDISKFU );
	      goto y1;
	   }

	   copysiz -= tmpsiz;
	   if ( !copysiz )
	     break;
	}

	if ( p_timedate )
	  Fdatime( &time, outhand, 1 );	

y0:
	Fclose(outhand);
y1:
	free(buffer);
y2:
	updatnum(NUMFILE, --numfiles);
	Fsetdta(saved);
y3:
	Fclose(inhand);
	free(mydta);

	if ( ( opcode == OP_MOVE ) && ( retmsg == TRUE ) )
	  upfdesk( fixsrc, fixdst );
	
	return(retmsg);
}
示例#18
0
WORD
countrec( VOID )
{
/*	char 		*saved; */
	DMABUFFER 	*dumb, *saved;
	REG int 	retmsg;
	
	dumb = (DMABUFFER *)malloc( (LONG)sizeof(DMABUFFER) );
	if ( !dumb )
	{
	  do1_alert( STFO8DEE );
	  return( FALSE );
	}
	  	
	retmsg = TRUE;
	saved = (DMABUFFER *)Fgetdta();	/* save the current dta	*/
	Fsetdta( dumb );

	if (!Fsfirst(curall, 0x37))	
	{
	  do 	
	  {
	    if (dumb->d_fname[0] != HOME)	
	    {
	      if (SUBDIR & dumb->d_fattr)	
	      {	       				/* setpath to one more down */
		if (Dsetpath(dumb->d_fname))	
		{
		  retmsg = FALSE;
		  goto endrec;
		}

	    	numdirs++;

		if ( ++f_level > COPYMAXDEPTH ) 	
		{
		  do1_alert( STFO8DEE );
		  retmsg = FALSE;
		  goto endrec;
		}

		if (!countrec())	/* to the recursion setpath to one back */
		{
		  retmsg = FALSE;
		  goto endrec;
		}
		f_level--;
		if (Dsetpath(baklvl))	
		{
		  retmsg = FALSE;
		  goto endrec;
		}
	      }
	      else 
	      {
		numfiles++;	/* add up the file count and size	*/
		tolsize += dumb->d_fsize;
	      }
	    } 
          } while (!Fsnext());
	}

endrec:
	Fsetdta( saved );	/* reset the dta	*/
	free( dumb );
	return(retmsg);
}
示例#19
0
int
doact( VOID )
{
/*	char 		*saved; */
	DMABUFFER 	*dumb, * saved;
	REG int 	ret, retmsg;
	int		error;

	if ( f_level >= ( COPYMAXDEPTH + 1 ) )
	{
act_1:	  do1_alert( STFO8DEE );
	  return( FALSE );
	}
	/* changed CHAR * to DMABUFFER * in expression below - JTT */
	if ( !( dumb = (DMABUFFER *)malloc( (LONG)sizeof( DMABUFFER ) ) ) )
	  goto act_1; 
	
	f_level++;
	retmsg = TRUE;
	saved = (DMABUFFER *)Fgetdta();
	Fsetdta( dumb );
	strcat(getall, fixsrc);

	if ( !( error = Fsfirst(fixsrc, 0x37) ) )	
	{
	  do
	  {
	    if ( !ch_undo( ) || f_cancel )	/* user want to abort	*/
	    {
	      f_abort = 1;
	      retmsg = FALSE;
	      goto mvend;
	    } 

	    if (dumb->d_fname[0] != HOME)	
	    {
	      if (SUBDIR & dumb->d_fattr)	
	      {
		chkbuf(srclen, srcbuf, &fixsrc);	/* check buf size */
		addfile(fixsrc, dumb->d_fname); /* add a dir into the path */
		strcat(bckslsh, fixsrc);
		if (opcode != OP_DELETE)
		{
		  chkbuf(dstlen, dstbuf, &fixdst);	/* check buf size */
		  strcat(dumb->d_fname, fixdst);
		}
		else
		  goto dorec;

		updatbox(dumb->d_fname);
rechkd1: 						/* update check the dir existing or not */
		switch( chkdf( dumb->d_fname, CPDIR ) ) 
		{
		  case	QUIT:
		  	f_abort = 1;
		  	retmsg = FALSE;
		  	goto mvend;

		  case	SKIP:
		  	backdir(fixsrc);
		  	backdir(fixdst);
		  	updatnum(NUMDIR, --numdirs);
		  	srclen -= FILE_LEN;		/* subtract the add lenth */
		  	dstlen -= FILE_LEN;		/* subtract the add lenth */
		  	retmsg = TRUE;
		  	continue;

		  case 	FALSE:
		  	goto mvend;

		  case 	CHECK:
		 	goto rechkd1;

		  case 	OK:
recrtd:		  	
			if (Dcreate(fixdst))	
		  	{
		  	  if ( write_save )
	      	            goto kk_1;

			  switch( fill_string( fixdst, CNTCRTDR ) )
		  	  {	
			    case 1:			/* skip */
		  	      backdir(fixsrc);
		  	      backdir(fixdst);
		  	      updatnum(NUMDIR, --numdirs);
		  	      srclen -= FILE_LEN;	/* subtract the add lenth */
		  	      dstlen -= FILE_LEN;	/* subtract the add lenth */
		  	      continue;

			    case 2:		/* retry */
		  	      goto recrtd;
		
			    default: 		/* quit */
		  	      f_abort = 1;
		  	      retmsg = FALSE;
		  	      goto mvend;

		  	  }/* switch */
		  	}/* if recrtd */

			break;
		}
kk_1:
		updatnum(NUMDIR, --numdirs);
		strcat(bckslsh, fixdst);
dorec:
		if (!doact())	 /* do the recursion */
		{
		  retmsg = FALSE;
		  goto mvend;
		}

		if (opcode == OP_COPY)
		  goto clndir;

		rmstarb(fixsrc);		/* after call, -> c:\d1\ */

		if (opcode == OP_DELETE)
		{
		  getlastpath(filestr, fixsrc);
		  updatbox(filestr);
		}
remvd:
		if (Ddelete(fixsrc))	
		{ 				/* delete a dir */
		  if ( ( ret = fill_string( fixsrc, CNTDELD ) ) == 2 )
		    goto remvd; 		/* retry */

		  else if (ret == 3)
		  { 				/* abort */
		    f_abort = 1;
		    retmsg = FALSE;
		    goto mvend;
		  }
	 	}
		else				/* No error	*/
		  upfdesk( fixsrc, (BYTE*)0 );

clndir:
		backdir(fixsrc);		/* back one dir */
		srclen -= FILE_LEN;		/* subtract the add lenth */
		if (opcode == OP_DELETE)
		  updatnum(NUMDIR, --numdirs);
		else
		{
		  backdir(fixdst);		/* back one dir */
		  dstlen -= FILE_LEN;		/* subtract the add lenth */
		}
	    } 
	    else 
	    {
		getlastpath(filestr, fixdst);
		updatname(CPDIR, filestr);		/* update the dir */
		updatname( CPFILE, dumb->d_fname ); 	/* update the file */
		chkbuf(srclen, srcbuf, &fixsrc);	/* check buf size */
		addfile(fixsrc, dumb->d_fname);
		if (opcode != OP_DELETE)
		{
		  chkbuf(dstlen, dstbuf, &fixdst);	/* check buf size */
		  addfile(fixdst, dumb->d_fname);
		  rename = 0;
		  if (!(retmsg = wrfile(dumb->d_fname)))
		    goto mvend;

		  if ((rename) || (retmsg == SKIP))
		    goto clnfile;
		}

		if (opcode == OP_COPY)
		  goto clnfile;
remvf:
		if (ret = (WORD)(Fdelete(fixsrc))) 	/* rm the file from source */
		{			/* seek error or drive not ready */
/*		  if ((ret == E_SEEK) || (ret == EDRVNR))
		  {
		    retmsg = FALSE;
		    goto mvend;
		  }
*/					/* retry */
	          if ( ( ret = fill_string( fixsrc, CNTDELF ) ) == 2 )
		    goto remvf;
		  else 
		  if ( ret == 3 )	
		  {			/* abort */
		    f_abort = 1;
		    retmsg = FALSE;
		    goto mvend;
		  }
		}
		else
		  upfdesk( fixsrc, (BYTE*)0 );
clnfile:
		backdir(fixsrc);		/* back one dir */
		srclen -= FILE_LEN;		/* subtract the add lenth */
		if (opcode == OP_DELETE)
		  updatnum(NUMFILE, --numfiles);
		else
		{
		  backdir(fixdst);		/* back one dir */
		  dstlen -= FILE_LEN;		/* subtract the add lenth */
		}
	      }
	    } 
	  } while (!Fsnext());
	}
	else 
	{
	  if ( error != EFILNF )	/* if not file not found */
	    retmsg = FALSE;		/* then return error	 */
	}
	
mvend:
	Fsetdta( saved );
	f_level--;
	free( dumb );	
	return( retmsg );
}
示例#20
0
int
__quickstat (const char *_path, struct stat *st, int lflag)
{
	char tmpbuf[PATH_MAX];
	char *path = (char *) _path;
	int nval;
	long r;

	if (!_path) {
		__set_errno (EFAULT);
		return -1;
	}

	if (*_path == '\0') {
		__set_errno (ENOENT);
		return -1;
	}

	if (__libc_unix_names) 
		nval = 0;
	else {
	    	/* _unx2dos returns 1 for device names (like /dev/con) */
	     	path = tmpbuf;
  	    	nval = _unx2dos(_path, path, sizeof (tmpbuf));
	}

	r = __sys_stat (path, st, lflag, 0);
	if (r != -ENOSYS) {
		if (r) {
			if ((r == -ENOTDIR) && _enoent (path)) {
				r = -ENOENT;
			}
			__set_errno (-r);
			return -1;
		}
		return 0;
	}

	{
	char	*ext, drv;
	_DTA	d;
	_DTA	*olddta;
	int	isdot = 0;
	int	isdir = 0;
	
	__bzero (st, sizeof (*st));
	
	/* Otherwise, check to see if we have a name like CON: or AUX: */
	if (nval == 1) {
		st->st_mode = S_IFCHR | 0600;
		st->st_flags = 0;
		st->st_ino = __inode++;
		st->st_rdev = 0;
		st->st_mtime = st->st_ctime = st->st_atime = 0;
		st->st_dev = 0;
		st->st_nlink = 1;
		st->st_uid = geteuid();
		st->st_gid = getegid();
		st->st_size = st->st_blocks = 0;
		st->st_blksize = 1024;
		return 0;
	}

	/* A file name: check for root directory of a drive */
	if (path[0] == '\\' && path[1] == 0) {
		drv = Dgetdrv() + 'A';
		isdir = 1;
		goto rootdir;
	}

	if (((drv = path[0]) != 0) && path[1] == ':' &&
	     (path[2] == 0 || (path[2] == '\\' && path[3] == 0)) ) {
rootdir:
		isdir = 1;
		st->st_mode = S_IFDIR | 0755;
		st->st_flags = 0;
		st->st_dev = isupper(drv) ? drv - 'A' : drv - 'a';
		st->st_ino = 2;
		st->st_mtime = st->st_ctime = st->st_atime = 0;
		goto fill_dir;
	}


	/* Forbid wildcards in path names */
	if (index(path, '*') || index (path, '?')) {
		__set_errno (ENOENT);
		return -1;
	}

	/* NOTE: Fsfirst(".",-1) or Fsfirst("..",-1) both fail under TOS,
	 * so we kludge around this by using the fact that Fsfirst(".\*.*"
	 * or "..\*.*" will return the correct file first (except, of course,
	 * in root directories :-( ).
	 * NOTE2: Some versions of TOS don't like Fsfirst("RCS\\", -1) either,
	 * so we do the same thing if the path ends in '\\'.
	 */

	/* Find the end of the string.  */
	for (ext = path; ext[0] && ext[1]; ext++) ;

	/* Add appropriate kludge if necessary. */
	if (*ext == '.' && (ext == path || ext[-1] == '\\' || ext[-1] == '.')) {
		isdot = 1;
		strcat (path, "\\*.*");
	} else if (*ext == '\\') {
		isdot = 1;
		strcat (path, "*.*");
	}
	olddta = Fgetdta();
	Fsetdta(&d);
	r = Fsfirst (path, 0xff);
	Fsetdta (olddta);
	if (r < 0) {
		if (isdot && r == -ENOENT) goto rootdir;
		__set_errno (-r);
		return -1;
	}	

	if (isdot && ((d.dta_name[0] != '.') || (d.dta_name[1]))) {
		goto rootdir;
	}

	if (((drv = *path) != 0) && path[1] == ':')
		st->st_dev = _toupper (drv) - 'A';
	else
		st->st_dev = Dgetdrv ();

	st->st_ino = __inode++;
	st->st_flags = 0;
	st->st_mode = 0644 | (isdir ? S_IFDIR | 0111 : S_IFREG);

	if (st->st_flags & FA_RDONLY)
		st->st_mode &= ~0222;	/* no write permission */
	if (st->st_flags & FA_HIDDEN)
		st->st_mode &= ~0444;	/* no read permission */

	/* Check for a file with an executable extension */
	ext = strrchr(_path, '.');
	if (ext) {
		if (!strcmp (ext, ".app") || !strcmp (ext, ".gtp") ||
		    !strcmp (ext, ".ttp") || !strcmp (ext, ".prg") ||
		    !strcmp (ext, ".tos")) {
			st->st_mode |= 0111;
		}
	}
	if ((st->st_mode & S_IFMT) == S_IFREG) {
		st->st_size = d.dta_size;
		/* In Unix, blocks are measured in 512 bytes */
		st->st_blocks = (st->st_size + 511) / 512;
		st->st_nlink = 1; /* we dont have hard links */
	} else {
fill_dir:
		st->st_size = 1024;
		st->st_blocks = 2;
		st->st_nlink = 2;	/* "foo" && "foo/.." */
	}

	st->st_uid = geteuid();	/* the current user owns every file */
	st->st_gid = getegid();
	st->st_blksize = 1024;
	
	}
	
	return 0;
}
示例#21
0
/* Read_Data()
 * ================================================================
 */
BOOLEAN
Read_Data( void )
{
    DTA  thedta, *saved;
    int  fd;
    int  *DataPtr;
    long EndIndex;
    BOOLEAN flag;

    flag = FALSE;
    saved = Fgetdta();
    Fsetdta( &thedta );
    if( Fsfirst( FPath, 0 ) <= -1 ) /* Can't find the file... */
    {
        Objc_draw( tree, ROOT, MAX_DEPTH, NULL );
        form_alert( 1, alert2 );
    }
    else
    {
        DataBuf = calloc( 1, thedta.d_length * 2L );

        if( DataBuf )
        {
            fd = Fopen( FPath, 0 );
            if( fd <= 0 )
            {
                form_alert( 1, alert1 );
            }
            else
            {
                Buffer = ( long )DataBuf;
                Buffer = ( Buffer + 15L ) & 0xFFFFFFF0L;
                DataHdr = ( int *)Buffer;

                Fread( fd, thedta.d_length, DataHdr );
                Fclose( fd );

                EndIndex = thedta.d_length;
                DataPtr  = FindString( DataHdr, DataHdr + EndIndex - 8 );
                if( DataPtr )
                {
                    hdr = ( HEADER *)DataPtr;
                    hdr_buffer = ( HEADER )*hdr;
                    hdr = &hdr_buffer;
                    strcpy( title, hdr->fname );
                    flag = TRUE;
                }
                else
                {
                    Objc_draw( tree, ROOT, MAX_DEPTH, NULL );
                    form_alert( 1, alert3 );
                }
                free( DataBuf );
            }
        }
        else
            form_alert( 1, alert4 );
    }
    Fsetdta( saved );
    return( flag );
}
示例#22
0
LOCAL WORD rs_read (WORD *global, CONST BYTE *fname)
{
    WORD i, fh;
    BYTE tmpnam[128];
    DTA  dta, *old_dta;
    LONG size;
    WORD ret = TRUE;

    strcpy (tmpnam, fname);

    if (!shel_find (tmpnam))
    {
        form_error (-33);
        return (FALSE);
    }

    rs_global = global;

    old_dta = Fgetdta ();
    Fsetdta (&dta);
    if (Fsfirst (tmpnam, 0x10) == 0)
        size = dta.d_length;
    else
        size = 0;
    Fsetdta (old_dta);

    if (size > sizeof (RSHDR) && (fh = Fopen (tmpnam, 0)) > 0)
    {
        if ((hdr_buf = (RSXHDR *)malloc (size + sizeof (RSXHDR))) != NULL)
        {
            (LONG)rs_hdr = (LONG)hdr_buf + sizeof (RSXHDR);

            if (Fread (fh, size, rs_hdr) == size)
            {
                if (((RSHDR *)rs_hdr)->rsh_vrsn == 3)
                    memcpy (hdr_buf, rs_hdr, sizeof (RSXHDR));
                else
                    for (i = 0; i < sizeof (RSXHDR) / sizeof (LONG); i++)
                        ((ULONG *)hdr_buf)[i] = ((UWORD *)rs_hdr)[i];

                do_rsfix (hdr_buf->rsh_rssize);

                if (size > hdr_buf->rsh_rssize + 72L)	/* Farbicons in der Resource? */
                    do_ciconfix ((ULONG)rs_hdr, hdr_buf, size);
            }
            else
                ret = FALSE;
        }
        else
        {
            form_error (-39);
            ret = FALSE;
        }

        Fclose (fh);
    }
    else
        ret = FALSE;

    return (ret);
}
示例#23
0
copy_dir ()       /* source und dest sind global; bei Fehler: return (1) */
{
int source_len, dest_len, fd_source, fd_dest, error;
char dta[44];
long old_dta, fail, size, count;
   error=0;
   source_len=strlen(source);
   dest_len=strlen(dest);
   old_dta=Fgetdta();
   Fsetdta(dta);
   strcat(source,"\\*.*");
   fail=Fsfirst(source,16);
   source[source_len]=0;
   while (!fail)
   {  strcat(source,"\\");
      strcat(source,dta+30);
      strcat(dest,"\\");
      strcat(dest,dta+30);
      if (dta[21]==16)         /* Directory */
      {  if (strcmp(dta+30,".")&&strcmp(dta+30,".."))
            if (Dcreate(dest))
            {  printf("Ordner %s l„žt sich nicht anlegen.\n",dest);
               error=1;
            }
            else
               error|=copy_dir(source,dest);
      }
      else                     /* File */
      {  printf("%s  nach  %s\n",source,dest);
         if ((fd_source=Fopen(source,0))<0)
         {  printf("Datei %s l„žt sich nicht ”ffnen.\n",source);
            error=1;
         }
         else
            if ((fd_dest=Fcreate(dest,dta[21]&~1))<0)
            {  printf("Datei %s l„žt sich nicht einrichten.\n",dest);
               error=1;
            }
            else
            {  size=*(long*)(dta+26);
               while (size)
               {  count=(size<buf_size)?size:buf_size;
                  size-=count;
                  if (Fread(fd_source,count,buffer)!=count)
                  {  printf("Fehler beim Lesen von %s .\n",source);
                     error=1;
                     break;
                  }
                  if (Fwrite(fd_dest,count,buffer)!=count)
                  {  printf("Fehler beim Schreiben von %s .\n",dest);
                     error=1;
                     break;
                  }
               }
               Fclose(fd_source);
               Fclose(fd_dest);
               fd_dest=Fopen(dest,1);
               Fdatime(fd_dest,dta+22,1);
               Fclose(fd_dest);
            }
      }
      source[source_len]=0;
      dest[dest_len]=0;
      fail=Fsnext();
   }
   if (fail!=-49l)
   {  printf("Ordner %s nicht gefunden.\n",source);
      error=1;
   }
   Fsetdta(old_dta);
   return (error);
}
示例#24
0
int
main(int argc, char **argv)
{
    long size[NUMFILES];
    long totsize;
    char buf[20], name[40];
    byte *inbuf, *ptr;
    byte *outbuf;
    long outsize;
    int i, fd;
    DTA *dt;
    int compress, noheader;
    int interactive = 1;

    dt = (DTA *)Fgetdta();

    compress = 0;
    noheader = 0;

    printf("\nSuperglue v1.0\n");
    while (argc > 1) {
        ptr = (byte *)argv[1];
        argv++;
        --argc;
        if (*ptr == '-') {
            ptr++;
            switch (*ptr) {
            case 'c':
                compress = 1;
                i = atoi(ptr+1);
                if (i) gl_matchsize = i;
                break;
            case 'n':
                noheader = 1;
                break;
            default:
                printf("usage: superglu [-n][-c#] [extension]\n");
                break;
            }
        } else {
            interactive = 0;
            break;
        }
    }

    puts(compress ? "COMPRESSING resources" : "storing resources" );
    if (interactive) {
        printf("\nPlease enter the 3 letter country abbreviation, or\n");
        printf("type 'exit' to quit\n");
    }

    do {
        totsize = HEADERSIZE;
        if (interactive) {
            printf("> ");
            fflush(stdout);
            gets(buf);
            if (strlen(buf) > 3) break;
        } else {
            strcpy(buf, *argv);
        }

        /* first, find the sizes of the pieces */
        for (i = 0; i < NUMFILES; i++) {
            sprintf(name, fname[i], buf);
            if (Fsfirst(name, 0) != 0) {
                printf("%s: not found\n", name);
                goto top;
            }
            size[i] = dt->dta_size;
            /* we round all file sizes up to the next even number when we
             * read them into memory, so everything will be on a word boundary
             */
            totsize += ROUND(size[i]);
        }


        ptr = inbuf = (byte *)Malloc( totsize );
        if (!inbuf) {
            printf("not enough memory: couldn't allocate %ld bytes\n",
                   totsize);
            goto top;
        }

        ptr += HEADERSIZE;

        /* now, go read the files */
        for (i = 0; i < NUMFILES; i++) {
            sprintf(name, fname[i], buf);
            fd = Fopen(name, 0);
            if (fd < 0) {
                printf("couldn't open %s\n", name);
                Mfree(inbuf);
                goto top;
            }
            puts(name);
            if (Fread(fd, size[i], ptr) != size[i]) {
                printf("Error during read\n");
                Mfree(inbuf);
                Fclose(fd);
                goto top;
            }
            Fclose(fd);
            ptr += ROUND(size[i]);
            /* fill in the size in the header */
            ((long *)inbuf)[i] = ROUND(size[i]);
        }

        /* OK, now write the result */
        sprintf(name, "glue.%s", buf);
        fd = Fcreate(name, 0);
        if (fd < 0) {
            printf("couldn't create %s\n", name);
            Mfree(inbuf);
            goto top;
        }

        if (compress) {
            outbuf = (byte *)Malloc( totsize * 2 );
            if (!outbuf) {
                printf("NO MEMORY FOR COMPRESSION!!\n");
                printf("storing resource instead\n");
                compress = 0;
            }
        }
        if (compress) {
            magic[0] = 0xab;
            magic[1] = 0x08;
            outsize = crunch(inbuf, totsize, outbuf);
        } else {
            outbuf = inbuf;
            outsize = totsize;
            magic[0] = magic[1] = 0;
        }
        printf("Writing %s...\n", name);

        /* first, the file header */
        if (!noheader) {
            Fwrite(fd, 2L, magic);
            Fwrite(fd, 4L, &totsize);
            Fwrite(fd, 4L, &outsize);
        }

        /* now write the data */
        if (Fwrite(fd, outsize, outbuf) != outsize) {
            printf("write error!\n");
        }

        Fclose(fd);
        Mfree(inbuf);
        if (compress) Mfree(outbuf);
top:
        ;
    } while (interactive);

    return 0;
}
示例#25
0
/* Save_Data()
 * ======================================================================
 */
BOOLEAN
Save_Data( void )
{
    DTA  thedta, *saved;
    int  fd;
    int  *DataPtr;
    long EndIndex;
    BOOLEAN flag;

    flag = FALSE;
    saved = Fgetdta();
    Fsetdta( &thedta );
    if( Fsfirst( FPath, 0 ) <= -1 ) /* Can't find the file... */
    {
        Objc_draw( tree, ROOT, MAX_DEPTH, NULL );
        form_alert( 1, alert2 );
    }
    else
    {
        DataBuf = calloc( 1, thedta.d_length * 2L );

        if( DataBuf )
        {
            fd = Fopen( FPath, 0 );
            if( fd <= 0 )
            {
                form_alert( 1, alert1 );
            }
            else
            {
                Buffer = ( long )DataBuf;
                Buffer = ( Buffer + 15L ) & 0xFFFFFFF0L;
                DataHdr = ( int *)Buffer;

                Fread( fd, thedta.d_length, DataHdr );
                Fclose( fd );

                EndIndex = thedta.d_length;
                DataPtr  = FindString( DataHdr, DataHdr + EndIndex - 8 );
                if( DataPtr )
                {
                    hdr = ( HEADER *)DataPtr;

                    hdr_buffer.quality    = Menu[ MQUALITY ].curvalue;
                    hdr_buffer.nplanes    = Menu[ MCOLOR ].curvalue + 1;
                    hdr_buffer.PageSize   = Menu[ MPAGESIZE ].curvalue;
                    hdr_buffer.xres       = xres_value;
                    hdr_buffer.yres       = yres_value;
                    hdr_buffer.port       = Menu[ MPORT ].curvalue;
                    hdr_buffer.paper_feed = Menu[ MTRAY ].curvalue;

                    *hdr = hdr_buffer;

                    flag = TRUE;
                    fd = Fcreate( FPath, 0 );
                    Fwrite( fd, thedta.d_length, DataHdr );
                    Fclose( fd );
                }
                else
                {
                    Objc_draw( tree, ROOT, MAX_DEPTH, NULL );
                    form_alert( 1, alert3 );
                }
                free( DataBuf );
            }
        }
        else
            form_alert( 1, alert4 );
    }
    Fsetdta( saved );
    return( flag );
}
示例#26
0
/* GetCDrivers()
 * ====================================================================
 * Go thru the list of .sys files and try to load them.
 * Those that we can load, get the header and see if they are of the
 * new driver type. Get the filenames of those that are printer drivers
 * and store them in cdriver. Store their index into the driver array
 * into our cdriver array position.
 */
void
GetCDrivers( void )
{
    DTA  thedta, *saved;
    int  fd;
    int  *DataPtr;
    long EndIndex;
    int  error;

    saved = Fgetdta();
    Fsetdta( &thedta );

    cdriver_count =  0;

    get_bitpath();
    strcpy( FPath, epath );
    strcat( FPath, "\\*.SYS");

    error = Fsfirst( FPath, 0 );	/* Normal file search for 1st file */
    if( error != E_OK )  	/* No such files! */
    {
        return;
    }

    do
    {
        sprintf( line_buf, "%s\\%s", epath, thedta.d_fname );
        DataBuf = calloc( 1, thedta.d_length * 2L );

        if( DataBuf )
        {
            fd = Fopen( line_buf, 0 );
            if( fd > 0 )
            {
                Buffer = ( long )DataBuf;
                Buffer = ( Buffer + 15L ) & 0xFFFFFFF0L;
                DataHdr = ( int *)Buffer;

                Fread( fd, thedta.d_length, DataHdr );
                Fclose( fd );
                EndIndex = thedta.d_length;
                DataPtr  = FindString( DataHdr, DataHdr + EndIndex - 8 );
                if( DataPtr )	/* Look only for new drivers with headers*/
                {
                    hdr = ( HEADER *)DataPtr;
                    hdr_buffer = ( HEADER )*hdr;
                    hdr = &hdr_buffer;

                    /* want only those drivers with real page sizes */
                    if( hdr->config_map & 0x3E )
                    {
                        /* then get the name...*/
                        strcpy( cdrivers[ cdriver_count ], hdr->fname );
                        strcpy( drivers[ cdriver_count ], thedta.d_fname );
                        cdriver_count++;
                    }
                }
            }
            free( DataBuf );
        }
        else
        {
            /* memory error - break out of loop and exit routine */
            form_alert( 1, alert4 );
            break;
        }
    } while ( ( Fsnext() == E_OK ) && ( cdriver_count < MAX_DRIVERS ) );
    SortCDriverNames();
    Fsetdta( saved );
}
示例#27
0
void main(void)
{
	long		adr,max,length;
	int		dummy,handle,freq_div=1;
	char		tch;
	DTA		*buf;

	Cconws(CLEAR_HOME);
	Cconws("Amiga 4/6/8 voices & xxCH DSP Replay Routine by Simplet / FATAL DESIGN\r\n");
	Cconws("----------------------------------------------------------------------\r\n\n");

	dummy=Fsfirst(MODNAME,0);
	buf=Fgetdta();
	length=buf->d_length;
	
	if (dummy!=0)
		{
		Cconws("Disk Error!\r\nPress any key...");
		Crawcin();exit();
		}

	Cconws("Allocating Memory...");

	adr=Malloc(length+20832);		/* Workspace takes up to 20832 bytes */
	if (adr<=0)
		{
		Cconws("Error!\r\nNot enough Memory to load!\r\nPress any key...");
		Crawcin();exit();
		}
	
	Cconws("Ok!\r\nLoading Module...");

	handle=Fopen(MODNAME,FO_READ);
	Fread(handle,length,adr);
	Fclose(handle);

	Cconws("\r\nInitialising Module and Samples...");

	dummy=MGTK_Init_Module_Samples(adr,adr+length+20832);
	if (dummy==-3)
		{
		Cconws("Error!\r\n");
		Cconws("Not enough workspace to prepare samples!\r\n");
		Cconws("Press any key...");
		Crawcin();exit();
		}

	Cconws("Ok!\r\nInitialising DSP Program...");

	dummy=MGTK_Init_DSP();
	if (dummy!=0)
		{
		Cconws("Error!\r\n");
		Cconws("DSP Program couldn't be loaded!\r\n");
		Cconws("Press any key...");
		Crawcin();exit();
		}

	Cconws("Ok!\r\n\n");

	MGTK_Save_Sound();
	MGTK_Init_Sound();
	MGTK_Set_Replay_Frequency(freq_div);
	MGTK_Restart_Loop=-1;
	MGTK_Play_Music();

	Cconws("You can use the following keys :\r\n");
	Cconws("  - or + for previous or next music position\r\n");
	Cconws("  / or * for previous or next replay frequency\r\n");
	Cconws("  L for play, P for pause, S for stop\r\n");
	Cconws("  Space to quit\r\n");

	do
		{
		tch=Crawcin();
		switch ( tch-32*((97<=tch) && (tch<=122)) )
			{
			case	'-':	MGTK_Previous_Position();break;
			case '+':	MGTK_Next_Position();break;
			case '/':	if (freq_div>1)
					MGTK_Set_Replay_Frequency(--freq_div);break;
			case '*':	if (freq_div<5)
					MGTK_Set_Replay_Frequency(++freq_div);break;
			case	'L':	MGTK_Play_Music();break;
			case	'P':	MGTK_Pause_Music();break;
			case	'S':	MGTK_Stop_Music();break;
			}
		}
	while (tch!=*" ");
		
	MGTK_Stop_Music();
	MGTK_Restore_Sound();
}
示例#28
0
long x_xreaddir(XDIR *dir, char *buffer, int len, XATTR *attrib)
{
#if _MINT_
	if (mint)			/* HR 151102 */
	{
		if (dir->type)
		{
			/*
			 * DOS file system.
			 */
	
			int error;
		
			if (dir->data.gdata.first != 0)
			{
				char *fspec;
		
				if ((fspec = x_makepath(dir->path, "*.*", &error)) != NULL)
				{
#if USE_gemdos
					error = xerror((int) gemdos(78, fspec, 0x37));
#else
					error = xerror(Fsfirst(fspec, 0x37));
#endif
					free(fspec);
					dir->data.gdata.first = 0;
				}
			}
			else
#if USE_gemdos
				error = xerror((int) gemdos(79));
#else
				error = xerror(Fsnext());
#endif

			if (error == 0)
			{
				if (strlen(dir->data.gdata.dta.d_fname) + 1 > len)
					error = EFNTL;
				else
				{
					strupr(dir->data.gdata.dta.d_fname);		/* HR 151102: arrogant MiNT tampering with filenames. */
					strncpy(buffer, dir->data.gdata.dta.d_fname, len);
					dta_to_xattr(&dir->data.gdata.dta, attrib);
				}
			}
			return (long) error;
		}
		else
		{
			/*
			 * File system with long filenames.
			 * HR 130203: Use Dxreaddir in stead of Dreaddir,
			 *            handle links correctly.
			 */
	
			int h;
			char str[260];
			long error, rep;
	
			if ((error = Dxreaddir(len, dir->data.handle, str, (long)attrib, &rep)) == 0)
				strcpy(buffer, &str[4]);

			if (error == 0)
				return error;
		
			return (long) xerror((int) error);
		}
	}
	else
#endif
	{
		int error;
	
		if (dir->data.gdata.first != 0)
		{
			char *fspec;
	
			if ((fspec = x_makepath(dir->path, "*.*", &error)) != NULL)
			{
#if USE_gemdos
				error = xerror((int) gemdos(78, fspec, 0x37));
#else
				error = xerror(Fsfirst(fspec, 0x37));
#endif
				free(fspec);
				dir->data.gdata.first = 0;
			}
		}
		else
#if USE_gemdos
			error = xerror((int) gemdos(79));
#else
			error = xerror(Fsnext());
#endif
	
		if (error == 0)
		{
			if (strlen(dir->data.gdata.dta.d_fname) + 1 > len)
				error = EFNTL;
			else
			{
				strncpy(buffer, dir->data.gdata.dta.d_fname, len);
				dta_to_xattr(&dir->data.gdata.dta, attrib);
			}
		}
		return (long) error;
	
	}
}
示例#29
0
/* HandleCache()
 * ===================================================================
 */
int
HandleCache( int button, WORD *msg )
{
    int   quit;
    int	 out;
    int   error;

    quit   = FALSE;


    /* Handle Double-clicking of the objects */
    if( ( button != -1 ) && ( button & 0x8000 ) )
        button &= 0x7FFF;

    switch( button )
    {
    case CCANCEL:
        Current.SpeedoCacheSize = OldSpeedoCache;
        Current.speedo_percent  = OldPercent;
        Current.BitMapCacheSize = OldBitMapSize;

    case C*K:
        Deselect( button );
        if( button == C*K )
        {
            DoValuesCheck();
            CacheCheck();
        }

        Reset_Tree( ad_options );
        Objc_draw( tree, ROOT, MAX_DEPTH, NULL );
        break;

    case LCACHE:
    case MCACHE:
    case SCACHE:
        if( SpeedoFlag )
        {
            sprintf( cache_path, "%s\\", OutlinePath );

            out = fsel_name( FALSE, cache_path, "*.SPC", cache_text[ button - LCACHE ] );

            if( ( ( out == A_OK ) || ( out == A_CANCEL )) && ( cache_path[0] != '\0' ) )
            {
                if( out == A_OK )
                {
                    /* Check if the file exists first */
                    if(( button == LCACHE ) || ( button == MCACHE ))
                    {
                        olddma = Fgetdta();
                        Fsetdta( &newdma );		/* Point to OUR buffer */

                        error = Fsfirst( cache_path, 0 );/* Normal file search for 1st file */
                        if( error != E_OK )	/* No such files! */
                        {
                            Fsetdta( olddma );	/* Point to OLD buffer */
                            form_alert( 1, nofile );
                            XDeselect( tree, button );
                            return( quit );
                        }
                    }

                    if( open_vwork() )
                    {
                        switch( button )
                        {
                        case LCACHE:
                            out = v_loadcache( vhandle, cache_path, TRUE );
                            break;

                        case MCACHE:
                            out = v_loadcache( vhandle, cache_path, FALSE ); /* append, merge */
                            break;

                        case SCACHE:
                            out = v_savecache( vhandle, cache_path );
                            break;
                        default:
                            break;
                        }
                        if( out == -1 )
                            form_alert( 1, alert19 );
                        close_vwork();

                    }
                    else
                        form_alert( 1, alert18 );
                }
            }
            Calc_Cache( TRUE );
        }
        XDeselect( tree, button );
        break;

    case CCACHE:
        if( SpeedoFlag )
        {
            if( form_alert( 1, alert17 ) == 1 )
            {
                if( open_vwork())
                {
                    if( v_flushcache( vhandle ) == -1 )
                        form_alert( 1, alert19 );
                    close_vwork();
                }
                else
                    form_alert( 1, alert18 );
                Calc_Cache( TRUE );
            }
        }
        XDeselect( tree, button );
        break;


    case MUP:
    case MDOWN:
        Up_Down_Arrow( button, MUP, &MiscSizeText[0], &mcache, MSIZE );
        break;

    case BUP:
    case BDOWN:
        Up_Down_Arrow( button, BUP, &BitSizeText[0], &Current.BitMapCacheSize, BSIZE );
        break;

    case CUP:
    case CDOWN:
        Up_Down_Arrow( button, CUP, &CharSizeText[0], &ccache, CSIZE );
        break;

    default:
        if( button == -1 )
        {
            switch( msg[0] )
            {
            case WM_REDRAW:
                break;

            case AC_CLOSE:
                quit = TRUE;
                break;

            case WM_CLOSED:
                quit = TRUE;
                DoValuesCheck();
                CloseWindow();
                break;

            case CT_KEY:
                break;
            default:
                break;
            }
        }
        break;
    }
    return( quit );


}
示例#30
0
/* get_bitpath()
 * ====================================================================
 * Get the font path from the ASSIGN.SYS
 * If there is NO ASSIGN.SYS, we substitute C: or A: instead.
 *
 */
void
get_bitpath( void )
{
    int  i, sys_file;
    long j;
    int  error;
    char *fname;
    int  alen;

    olddma = Fgetdta();
    Fsetdta( &newdma );		/* Point to OUR buffer */

    strcpy( epath, "C:\\ASSIGN.SYS" );
    epath[0] = GetBaseDrive();

    bufptr     = 0L;
    BufferSize = 0L;

    error = Fsfirst( epath, 0 );	/* Normal file search for 1st file */
    if( error == 0 )
    {   /* found it! */
        bufptr = calloc( 1, newdma.d_length * 2L );
        if( bufptr )
        {
            BufferSize = newdma.d_length;

            if( (sys_file = Fopen( epath, 0 )) < 0)
            {
                Fsetdta( olddma );		/* Point to OLD buffer */
                if( bufptr )
                {
                    free( bufptr );
                    bufptr = 0L;
                }
                form_alert( 1, alert1 );
                return;
            }

            path_found = FALSE;
            do
            {
                i = 0;
                alen = (int)Fread( sys_file, BufferSize, bufptr );
                do
                {
                    if( !strncmp( &bufptr[i], "path", 4) ||
                            !strncmp( &bufptr[i], "PATH", 4) )
                    {
                        strcpy( epath, extract_path( &i, alen ) );
                        path_found = TRUE;
                        goto done;
                    }
                    else
                    {
                        while(( bufptr[i] != '\n' ) && ( i < alen )) {
                            ++i;    /* Skip to newline */
                        }
                        ++i;
                    }
                } while( i < alen );
            } while( alen == BufferSize );
done:
            Fclose( sys_file );

            if( bufptr )
            {
                free( bufptr );
                bufptr = 0L;
            }
            j = strlen( epath );
            if( epath[ j - 1 ] == '\\' )
                epath[ j - 1 ] = '\0';
        }
        else
            form_alert( 1, alert1 );
    }
    Fsetdta( olddma );		/* Point to OLD buffer */

    fname = &epath[0];
    fname = strupr( fname );
}