Exemplo n.º 1
0
mlx_extract()
{
	char filename[13],pathname[80];
	char *ext;
	int nblocks,block;
	register int i;
	long blockptr[MAXNBLOCKS+1];
	long addr[32],leng[32];	/* oversized */
	long end_record= idEND;
	GLOBRECORD *ptr;

	/* load multi-block file containing block to be extracted */
	Dsetdrv(mlt_drive); dsetpath(mlt_path);
	if (!readdatafile(MLXEXTTITL,mlxfile,mlxpath,MLX_EXT,0)) return;
	mlt_drive= Dgetdrv(); Dgetpath(mlt_path,mlt_drive+1);
	mlx_mem= tempmem;

	/* choose block from it */
	nblocks= scan_blocks(heap[mlx_mem].start,blockptr);
	if (!nblocks) return;	/* can't happen? */
	block= select_block(BLOCK2EXT,nblocks,blockptr);
	if ( (block<0) || (block>=nblocks) ) return;

	/* name of data file defaults to block comment */
	Dsetdrv(data_drive); dsetpath(data_path);
	ptr= (GLOBRECORD*)(blockptr[block]);
	copy_bytes(ptr->comment,filename,12L);
	filename[12]=0;
	ext=filename;
	for (i=0; i<9; i++) if (ext[i]=='.') break;
	if (i<9)
		ext+=(i+1);
	else
		ext= ALL_EXT;
	if (getfile(pathname,filename,ext,MLXXDATTITL)<=0) return;
	data_drive= Dgetdrv(); Dgetpath(data_path,data_drive+1);

	/* build file -- */
	i=0;

	/* -- header */
	addr[i]= (long)(&dataheader);
	leng[i++]= sizeof(dataheader);

	/* -- the selected block */
	addr[i]= blockptr[block];
	leng[i++]= blockptr[block+1] - blockptr[block] ;

	/* -- end record */
	addr[i]= (long)(&end_record);
	leng[i++]= 4;

	save_file(filename,pathname,i,addr,leng);

}	/* end mlx_extract() */
Exemplo n.º 2
0
void test010203(void)
{
    WORD res;
    BYTE ok;
    
    WORD drives = Drvmap();
    WORD dr2    = drives & (~drive);        // remove tested drive
    
    int drvExisting = -1;
    int drvNonexisting = -1;
    int i;
    
    for(i=15; i>= 0; i--) {
        if((dr2 & (1 << i)) != 0) {         // drive exists?
            drvExisting = i;
        }
        
        if((dr2 & (1 << i)) == 0) {         // drive doesn't exist?
            if(i == drive) {                // if it's not in dr2, but it's our drive, skip it
                continue;
            }
        
            drvNonexisting = i;         
        }
    }
    
    res = Dsetdrv(drvExisting);             // switch to existing drive
    ok  = drives == res;                    // OK when returns existing drives
    
    if(ok) {
        WORD drv = Dgetdrv();
        ok = drvExisting == drv;            // OK if drive changed
        if(!ok) {
            out_swsw("Was switching to ", drvExisting, ", Dgetdrv returned ", drv);
        }
    }

    out_tr_b(0x0102, "Dsetdrv to existing drive", ok);

    res = Dsetdrv(drvNonexisting);          // switch to non-existing drive
    ok  = drives == res;                    // OK when returns existing drives
    
    if(ok) {
        WORD drv = Dgetdrv();
        ok = drvNonexisting == drv;         // TOS 1.02: OK if drive change to non-existing anyway
        if(!ok) {
            out_swsw("Was switching to ", drvNonexisting, ", Dgetdrv returned ", drv);
        }
    }

    out_tr_b(0x0103, "Dsetdrv to non-existing drive", ok);
}
Exemplo n.º 3
0
mlx_name()
{
	int nblocks,block;
	GLOBRECORD *blockptr[MAXNBLOCKS+1];
	long addr[32],leng[32];	/* oversized */

	/* load multi-block file containing block to be renamed */
	Dsetdrv(mlt_drive); dsetpath(mlt_path);
	if (!readdatafile(MLXNAMTITL,mlxfile,mlxpath,MLX_EXT,0)) return;
	mlt_drive= Dgetdrv(); Dgetpath(mlt_path,mlt_drive+1);
	mlx_mem= tempmem;

	/* choose block from it */
	nblocks= scan_blocks(heap[mlx_mem].start,blockptr);
	if (!nblocks) return;	/* can't happen? */
	block= select_block(BLOCK2NAM,nblocks,blockptr);
	if ( (block<0) || (block>=nblocks) ) return;

	/* edit the comment field in the selected block, and replace file
		without warning */
	if (_mlx_name(blockptr[block]->comment))
	{
		addr[0]= heap[mlx_mem].start;
		leng[0]= heap[mlx_mem].nbytes;
		save_file(mlxfile,mlxpath,-1,addr,leng);
	}

}	/* end mlx_name() */
Exemplo n.º 4
0
ex_loadtem()
{
#if TEMFLAG
	char filename[13],pathname[80];
	long load_file();

	/* overwrite changed template? */
	if (change_flag[temCHANGE])
		if (form_alert(1,CHNGETEM)==2) return;

	filename[0]=0;
	Dsetdrv(tem_drive); dsetpath(tem_path);
	tempmem= -1;
	if (getfile(pathname,filename,TE_EXT,TLDETITL)>0)
	{
		tem_drive=Dgetdrv(); Dgetpath(tem_path,tem_drive+1);
		if (load_file(pathname,filename))
		{
			if (load_tem(filename))
			{
				strcpy(temfile,filename);
			}
		}	/* end if file loaded successfully */
	}	/* end if ok from file selector */

	dealloc_mem(tempmem);

#endif
}	/* end ex_loadtem() */
Exemplo n.º 5
0
/* ---------------- */
main()
{
    char path2[80];
    long code_len;

    appl_init();

    path1[0] = Dgetdrv();
    path1[1] = ':';
    Dgetpath(path1 + 2, path1[0] + 1);
    path1[0] += 'A';
    strcat(path1, "\\*.PRT");

    code_len = (long)Malloc(-1L) - 75000;
    code_mem = (unsigned char *)Malloc(code_len);

    graf_mouse(ARROW, 0L);

    do
    {
        if (!fsel(path1, "PRT", "Druckersource w�hlen!"))
            break;

        strcpy(path2, path1);
        if (rindex(path2, '.') > rindex(path2, '\\'))
            strcpy(rindex(path2, '.'), ".PRC");

        if (fsel(path2, "PRC", "Treiberdatei w�hlen!"))
            comp_source(path1, path2);

    } while(TRUE);

    appl_exit();
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
0
void sauve_palette(void)
{
  int  pal[256*3] ;
  char name[200] ;
  char *pt ;

  if (*path_palette == 0)
  {
    Dgetpath( path_palette+2, 0 ) ;
    path_palette[1] = ':' ;
    path_palette[0] = 'A'+Dgetdrv() ;
    strcat(path_palette, "\\*.PAL") ;
  }

  if (file_name(path_palette, "", name))
  {
    FILE *stream ;

    stream = fopen(name, "wb") ;
    if (stream == NULL)
    {
      form_stop(1, msg[MSG_WRITEERROR]) ;
      return ;
    }
    get_vdipalette(pal) ;
    if (fwrite(pal, 6, nb_colors, stream) != nb_colors)
      form_stop(1, msg[MSG_WRITEERROR]) ;
    fclose(stream) ;
    strcpy(path_palette, name) ;
    pt = strrchr(path_palette, '\\') ;
    if (pt != NULL) *(1+pt) = 0 ;
    else            *path_palette = 0 ;
  }
}
Exemplo n.º 8
0
int x_getdrv(void)
{
#if USE_gemdos
	return (int) gemdos(25);
#else
	return Dgetdrv();
#endif
}
Exemplo n.º 9
0
get_path()
{
	syspath[0] = (char)Dgetdrv() + 'A';
	syspath[1] = ':';
	Dgetpath(&syspath[2],0);
	strcat(syspath,"\\");
	strcpy(pathbuf,syspath);
}
Exemplo n.º 10
0
/* --------------------------------- */
void init_mtext(void)
{
register int i, j;
int a, b;

scrtchp = (long)Malloc(2048L);

mtext_mlen = (long)Malloc(-1L) - 75000;
mtext_mem = (unsigned char *)Malloc(mtext_mlen);

/*printf("\033H%lx\n", mtext_mem);*/

memset(mtext_mem, 0, mtext_mlen);

pathes[0][0] = Dgetdrv();
pathes[0][1] = ':';
Dgetpath(pathes[0] + 2, 0);
strcat(pathes[0] + 2, "\\");
pathes[0][0] += 'A';

strcpy(pathes[1], pathes[0]);
strcpy(pathes[2], pathes[0]);
strcpy(pathes[3], pathes[0]);

pic_fpath[0] = pathes[0][0];
del_file[0] = font_path[0] = pathes[0][0];

for (i = 0; i < 68; txt_lineal[0][i++] = '.');
txt_lineal[0][68] = 0;

strcpy(txt_lineal[1], txt_lineal[0]);
strcpy(txt_lineal[2], txt_lineal[0]);
strcpy(txt_lineal[3], txt_lineal[0]);

strncpy(txt_linpar[0], "NPS110", 6);
strncpy(txt_linpar[1], txt_linpar[0], 6);
strncpy(txt_linpar[2], txt_linpar[0], 6);
strncpy(txt_linpar[3], txt_linpar[0], 6);

strcpy(txt_infol[0], "  Seite: 999, Zeile: 99999, Spalte: 999          Einf�gen ");
strcpy(txt_infol[1], txt_infol[0]);
strcpy(txt_infol[2], txt_infol[0]);
strcpy(txt_infol[3], txt_infol[0]);

vst_alignment(vdi_handle, 0, 3, &a, &b);
vsf_perimeter(vdi_handle, FALSE);

load_cfg();

get_work(0);
for (i = 0; i < 4; i++)
	{
	w_koor[i][0] = wx;
	w_koor[i][1] = wy;
	w_koor[i][2] = ww - (3 - i) * 10;
	w_koor[i][3] = wh - i * 10;
	}
}
Exemplo n.º 11
0
init_fname()
{
current_drive = Dgetdrv();
Dgetpath(current_dir, 0);
fold_buf[0] = current_drive + 'A';
fold_buf[1] = ':';
strcat(fold_buf, current_dir);
strcat(fold_buf, "\\");
}
Exemplo n.º 12
0
mlx_delete()
{
	int nblocks,block;
	register int i;
	long blockptr[MAXNBLOCKS+1];
	long addr[32],leng[32];	/* oversized */
	long end_record= idEND;

	/* load multi-block file containing block to be deleted */
	Dsetdrv(mlt_drive); dsetpath(mlt_path);
	if (!readdatafile(MLXDELTITL,mlxfile,mlxpath,MLX_EXT,0)) return;
	mlt_drive= Dgetdrv(); Dgetpath(mlt_path,mlt_drive+1);
	mlx_mem= tempmem;

	/* choose block from it */
	nblocks= scan_blocks(heap[mlx_mem].start,blockptr);
	if (!nblocks) return;	/* can't happen? */
	if (nblocks==1)
	{
		form_alert(1,BADMLXDEL);
		return;
	}
	block= select_block(BLOCK2DEL,nblocks,blockptr);
	if ( (block<0) || (block>=nblocks) ) return;

	/* build file -- */
	i=0;

	/* -- header */
	addr[i]= (long)(&dataheader);
	leng[i++]= sizeof(dataheader);

	/* -- blocks before the selected block */
	if (block>0)
	{
		addr[i]= blockptr[0];
		leng[i++]= blockptr[block] - blockptr[0] ;
	}

	/* -- blocks after the selected block */
	if (block<(nblocks-1))
	{
		addr[i]= blockptr[block+1];
		leng[i++]= blockptr[nblocks] - blockptr[block+1] ;
	}

	/* -- end record */
	addr[i]= (long)(&end_record);
	leng[i++]= 4;

	save_file(mlxfile,mlxpath,-i,addr,leng);	/* replace without warning */

}	/* end mlx_delete() */
Exemplo n.º 13
0
// Determine which directory contains the executable.
// IN: Main's argv[0], some platforms need it, some don't.
// OUT: Write into program_dir. Trailing / or \ is kept.
// Note : in fact this is only used to check for the datafiles and fonts in 
// this same directory.
void Set_program_directory(const char * argv0,char * program_dir)
{
  (void)argv0; // unused sometimes
  
  // MacOSX
  #if defined(__macosx__)
    CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
    CFURLGetFileSystemRepresentation(url,true,(UInt8*)program_dir,MAXPATHLEN);
    CFRelease(url);
    // Append trailing slash
    strcat(program_dir    ,"/");
  
  // AmigaOS and alike: hard-coded volume name.
  #elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
    strcpy(program_dir,"PROGDIR:");
  #elif defined(__MINT__)
  static char path[1024]={0};
  char currentDrive='A';
  currentDrive=currentDrive+Dgetdrv();
  
  Dgetpath(path,0);
  sprintf(program_dir,"%c:\%s",currentDrive,path);
  // Append trailing slash
  strcat(program_dir,PATH_SEPARATOR);
  // Linux: argv[0] unreliable
  #elif defined(__ANDROID__)
  getcwd(program_dir, MAX_PATH_CHARACTERS);
  strcat(program_dir, "/");
  #elif defined(__linux__)
  if (argv0[0]!='/')
  {
    char path[PATH_MAX];
    readlink("/proc/self/exe", path, sizeof(path));
    Extract_path(program_dir, path);
    return;
  }  
  Extract_path(program_dir, argv0);
  
  // Others: The part of argv[0] before the executable name.    
  // Keep the last \ or /.
  // On Windows, Mingw32 already provides the full path in all cases.
  #else
    Extract_path(program_dir, argv0);
  #endif
  printf("Set_program_directory: %s\n", program_dir);
}
Exemplo n.º 14
0
void test0101(void)
{
    WORD res;
    BYTE ok;
    
    WORD drives = Drvmap();

    res = Dsetdrv(drive);
    ok  = drives == res;        // OK if returning bitmap of drives
    
    if(ok) {
        WORD drv = Dgetdrv();
        ok = drive == drv;      // OK if drive changed
    }
    
    out_tr_b(0x0101, "Dsetdrv to selected drive", ok);
}
Exemplo n.º 15
0
int load_reg_file(void)
{
  char filename[MAXSTRING],filepath[MAXSTRING];
  FILE *file;
  short dummy;

  strcpy(filepath,"A:");
  filepath[0]=Dgetdrv()+'A';
  Dgetpath(filepath+2,0);
  strcat(filepath,"\\*.DAT");
  strcpy(filename,"REGISTER.DAT");
  fsel_exinput(filepath, filename, &dummy,alerts[A_LOAD_KEY]);
  if(!dummy)
    return(FALSE);

  strcpy(strrchr(filepath,'\\')+1,filename);

  file=fopen(filepath,"rb");
  if(file==NULL)
  {
    alertbox(1,alerts[ER_FILE_OPEN]);
    return(FALSE);
  }

  dummy=FALSE;
  fgets(filename,MAXSTRING,file);
  while((filename[strlen(filename)-1]=='\n')||(filename[strlen(filename)-1]=='\r')) filename[strlen(filename)-1]=NOLL;
  str2ted(register_win.dialog,REG_NAME,filename);
  fgets(filename,MAXSTRING,file);
  while((filename[strlen(filename)-1]=='\n')||(filename[strlen(filename)-1]=='\r')) filename[strlen(filename)-1]=NOLL;
  str2ted(register_win.dialog,REG_ADR1,filename);
  fgets(filename,MAXSTRING,file);
  while((filename[strlen(filename)-1]=='\n')||(filename[strlen(filename)-1]=='\r')) filename[strlen(filename)-1]=NOLL;
  str2ted(register_win.dialog,REG_ADR2,filename);
  fgets(filename,MAXSTRING,file);
  while((filename[strlen(filename)-1]=='\n')||(filename[strlen(filename)-1]=='\r')) filename[strlen(filename)-1]=NOLL;
  str2ted(register_win.dialog,REG_ADR3,filename);
  fgets(filename,MAXSTRING,file);
  while((filename[strlen(filename)-1]=='\n')||(filename[strlen(filename)-1]=='\r')) filename[strlen(filename)-1]=NOLL;
  str2ted(register_win.dialog,REG_KEY,filename);

  fclose(file);
  return(TRUE);
}
Exemplo n.º 16
0
void test0104(void)
{
    WORD res;
    BYTE ok;

    #define DRIVE_OUT_OF_RANGE  30
    
    WORD drives = Drvmap();
    
    res = Dsetdrv(DRIVE_OUT_OF_RANGE);      // switch to out of range drive 
    ok  = drives == res;                    // OK when returns existing drives
    
    if(ok) {
        WORD drv = Dgetdrv();
        ok = DRIVE_OUT_OF_RANGE == drv;     // OK if drive changed
        if(!ok) {
            out_swsw("Was switching to ", DRIVE_OUT_OF_RANGE, ", Dgetdrv returned ", drv);
        }
    }

    out_tr_b(0x0104, "Dsetdrv to out of range", ok);
}
Exemplo n.º 17
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;
}
Exemplo n.º 18
0
VOID get_path(BYTE *tmp_path, BYTE *spec)
{
	WORD	cur_drv;

#if GEMDOS
	cur_drv = Dgetdrv();
#else
	cur_drv = dos_gdrv();
#endif
	tmp_path[0] = cur_drv + 'A';
	tmp_path[1] = ':';
	tmp_path[2] = '\\';
#if GEMDOS
	Dgetpath((char *)ADDR(&tmp_path[3]), cur_drv+1);
#else
	dos_gdir(cur_drv+1, ADDR(&tmp_path[3]));
#endif
	if (strlen(tmp_path) > 3)
		strcat(tmp_path, "\\");
	else
		tmp_path[2] = '\0';
	strcat(tmp_path, spec);
}
Exemplo n.º 19
0
void  get_path()

{
   int   handle;
   long  len;
   char  *ptr, file[] = "\\IND.INF", path[] = "\\ISM";

   inetd_path[0] = 'A' + Dgetdrv();
   inetd_path[1] = ':';
   Dgetpath (&inetd_path[2], 0);

   strcpy (ism_path, inetd_path);

   strcat (ism_path, file);
   handle = (int) Fopen (ism_path, 0);

   if (handle < 0) {
        strcpy (&ism_path[2], file);
        handle = (int) Fopen (ism_path, 0);

        if (handle < 0) {
             strcpy (ism_path, path);
             return;
           }
      }

   len = Fread (handle, 250L, ism_path);
   Fclose (handle);

   if (len > 0) {
        if ((ptr = strchr (ism_path, '\r')) != NULL)   *ptr = '\0';
        if ((ptr = strchr (ism_path, '\n')) != NULL)   *ptr = '\0';
        ism_path[len] = '\0';
      }
     else
        strcpy (&ism_path[2], path);
 }
Exemplo n.º 20
0
void charge_palette(void)
{
  int  pal[256*3] ;
  int  ncol ;
  char name[200] ;
  char *pt ;

  if (*path_palette == 0)
  {
    Dgetpath( path_palette+2, 0 ) ;
    path_palette[1] = ':' ;
    path_palette[0] = 'A'+Dgetdrv() ;
    strcat(path_palette, "\\*.PAL") ;
  }

  if (file_name(path_palette, "", name))
  {
    FILE *stream ;

    ncol   = (int) file_size(name)/6 ;
    stream = fopen(name, "rb") ;
    if ( ( ncol < 0 ) || ( stream == NULL ) )
    {
      form_stop(1, msg[MSG_FILENOTEXIST]) ;
      return ;
    }
    if (ncol > nb_colors) ncol = nb_colors ;
    fread(pal, 6, ncol, stream) ;
    fclose(stream) ;
    set_vdipalette(pal, ncol) ;
    strcpy(path_palette, name) ;
    pt = strrchr(path_palette, '\\') ;
    if (pt != NULL) *(1+pt) = 0 ;
    else            *path_palette = 0 ;
  }
}
Exemplo n.º 21
0
/*
*	Initializes the spooler. Assigns the ted infos to the proper objects
*	and the strings to the proper ted infos.
*/
LONG ini_spol(VOID)
{
	LONG		tree;
	WORD		i, j;

	tree = (LONG)ADDR(&the_spol[0]);

	j = 0;
	for (i=0; i < SPOL_OBS; i++)
	{
		rsrc_obfix((OBJECT FAR *)tree, i);
		if (the_spol[i].ob_type == G_STRING)
		{
#ifdef TURBO_C
			the_spol[i].ob_spec.free_string = ADDR(spol_str[j]);
#else
			the_spol[i].ob_spec = ADDR(spol_str[j]);
#endif
			*spol_str[j] = NULL;
			j++;
		}
		if (the_spol[i].ob_type == G_BUTTON) 
		{
#ifdef TURBO_C
			the_spol[i].ob_spec.free_string = ADDR(spol_str[j]);
#else
			the_spol[i].ob_spec = ADDR(spol_str[j]);
#endif
			j++;
		}
	}

	if (color == 2)
	{
#if TURBO_C
		the_spol[0].ob_spec.index = 0x173L;
#else
		the_spol[0].ob_spec = 0x0173L;
#endif
	}  
	else if (color >= 3)
	{
#ifdef TURBO_C
		the_spol[0].ob_spec.index = 0x0175L;
#else
		the_spol[0].ob_spec = 0x0175L;
#endif
	}  

	for (i=0; i<NUM_SPOL; i++)
	{
		gl_sppfn[i] = NULL;
		*gl_splst[i] = NULL;
		gl_spdel[i] = FALSE;
		gl_sptab[i] = FALSE;
	}
	gl_spnxt = 0;

	the_spol[ADDNAME].ob_state = NORMAL;
	the_spol[REMNAME].ob_state = DISABLED;

 	strcpy("A:\*.*", &gl_fspec[0]);
#if GEMDOS
	gl_fspec[0] += Dgetdrv();
#else
	gl_fspec[0] += dos_gdrv();
#endif

	spol_setup();
	return(tree);
}
Exemplo n.º 22
0
int analyse_parameter(int argc,char *argv[],void **search_pfade)
{
	int zahl_der_pfade;
	int i,ARGV;
	char *arg;
	struct pfadkette *help;

	ARGV=0;
	if(getenv("ARGV"))
		ARGV=1;

	for(i=0;i<argc-1-ARGV;i++)
	{
		if(argv[i+1-ARGV][0]=='\'')
		{
			int von,nach;

			von=1;
			nach=0;
			do {
				if(argv[i+1-ARGV][von]=='\'')
					von++;

				argv[i+1-ARGV][nach]=argv[i+1-ARGV][von];
				nach++;
			} while(argv[i+1-ARGV][von++]);
		}
	}

	zahl_der_pfade=0;
	for(i=0;i<argc-1-ARGV;i++)
	{
		arg=argv[i+1-ARGV];

		if(arg[0]=='-')
		{
			if(arg[1]=='D')
			{
				int i;

				i=2;
				while(arg[i]!='\0')
				{
					zahl_der_pfade++;
					i++;
				}
			}
			else if(arg[1]=='P')
			{
				zahl_der_pfade++;
			}
		}
		else
		{
			zahl_der_pfade++;
		}
	}

	if(zahl_der_pfade==0)
	{
		int j;
		char *dm;
		char lwks[]="_______________________";

		dm=getenv("DRIVEMAP");
		if(!dm || !strlen(dm))
		{
			long lwk;

			dm=lwks;

			lwk=Dsetdrv(Dgetdrv());

			if(lwk & 0x03effffcl)	/* Gibt es ein Laufwerk au�er a,b und u? */
				lwk&=0x03effffcl;	/* ... dann a,b und u ausblenden */

			j=0;
			i=0;
			do {
				if(lwk & 1)
				{
					lwks[j++]=i+'A';
				}
				i++;
				lwk/=2;
			} while(lwk);
			lwks[j]='\0';
		}

		zahl_der_pfade=(int) strlen(dm);

		help=(struct pfadkette *)search_pfade;
		help->next=NULL;

		for(i=0;i<zahl_der_pfade;i++)
		{
			help->next=malloc(sizeof(struct pfadkette)+3);
			if(help->next)
			{
				help=help->next;

				help->next=NULL;
				help->selected=0;
				help->pfad[0]=dm[i];
				help->pfad[1]=':';
				help->pfad[2]='\\';
				help->pfad[3]='\0';
			}
			else
			{
				free_pfade(*search_pfade);
				return -1;
			}
		}

		return zahl_der_pfade;
	}

	help=(struct pfadkette *)search_pfade;
	help->next=NULL;

	zahl_der_pfade=0;
	for(i=0;i<argc-1-ARGV;i++)
	{
		arg=argv[i+1-ARGV];

		if(arg[0]=='-')
		{
			if(arg[1]=='D')
			{
				int j;

				j=2;
				while(arg[j]!='\0')
				{
					help->next=malloc(sizeof(struct pfadkette)+3);
					if(help->next)
					{
						help=help->next;

						help->next=NULL;
						help->selected=0;
						help->pfad[0]=arg[j];
						help->pfad[1]=':';
						help->pfad[2]='\\';
						help->pfad[3]='\0';
						j++;
						zahl_der_pfade++;
					}
					else
					{
						free_pfade(*search_pfade);
						return -1;
					}
				}
			}
			else if(arg[1]=='P')
			{
					/* Struct + String + ggf. '\\' */
				help->next=malloc(sizeof(struct pfadkette)+
							strlen(&arg[2])+
							(arg[strlen(arg)-1]!='\\'));
				if(help->next)
				{
					help=help->next;

					help->next=NULL;
					help->selected=0;

					strcpy(help->pfad,&arg[2]);
					if(help->pfad[strlen(help->pfad)-1]!='\\')
						strcat(help->pfad,"\\");

					zahl_der_pfade++;
				}
				else
				{
					free_pfade(*search_pfade);
					return -1;
				}
			}
		}
		else
		{
				/* Struct + String + ggf. '\\' */
			help->next=malloc(sizeof(struct pfadkette)+
						strlen(arg)+
						(arg[strlen(arg)-1]!='\\'));
			if(help->next)
			{
				help=help->next;

				help->next=NULL;
				help->selected=0;

				strcpy(help->pfad,arg);
				if(help->pfad[strlen(help->pfad)-1]!='\\')
				{ /* Unter Umst�nden wurde eine Datei �bergeben */
					long j;

						/* Hinten ein '\\' anh�ngen */
					strcat(help->pfad,"\\");

					for(j=strlen(help->pfad)-2;j>=0;j--)
					{
						if(help->pfad[j]=='\\')
						{
							help->pfad[j+1]='\0';
							j=-1;
						}
					}
				}

				zahl_der_pfade++;
			}
			else
			{
				free_pfade(*search_pfade);
				return -1;
			}
		}
	}

	/* doppelte Pfade entfernen */
	zahl_der_pfade-=remove_double_paths(&suji.search_pfade);

	return zahl_der_pfade;
}
Exemplo n.º 23
0
mlx_replace()
{
	char filename[13],pathname[80];
	int mlxnblocks,mlxblock;
	int datnblocks,datblock;
	long mlxblockptr[MAXNBLOCKS+1];
	long datblockptr[MAXNBLOCKS+1];
	register int i;
	long addr[32],leng[32];	/* oversized */
	long end_record= idEND;

	/* load data file containing block to be added */
	Dsetdrv(data_drive); dsetpath(data_path);
	filename[0]=0;
	if (!readdatafile(MLXRDATTITL,filename,pathname,ALL_EXT,0)) return;
	data_drive= Dgetdrv(); Dgetpath(data_path,data_drive+1);
	data_mem= tempmem;

	/* choose block from it */
	datnblocks= scan_blocks(heap[data_mem].start,datblockptr);
	if (!datnblocks) return;	/* can't happen? */
	datblock= select_block(BLOCK2REP,datnblocks,datblockptr);
	if ( (datblock<0) || (datblock>=datnblocks) ) return;

	/* load multi-block file to receive block */
	Dsetdrv(mlt_drive); dsetpath(mlt_path);
	if (!readdatafile(MLXREPTITL,mlxfile,mlxpath,MLX_EXT,0)) return;
	mlt_drive= Dgetdrv(); Dgetpath(mlt_path,mlt_drive+1);
	mlx_mem= tempmem;

	/* choose block from it */
	mlxnblocks= scan_blocks(heap[mlx_mem].start,mlxblockptr);
	if (!mlxnblocks) return;	/* can't happen? */
	mlxblock= select_block(BLOCK2BRP,mlxnblocks,mlxblockptr);
	if ( (mlxblock<0) || (mlxblock>=mlxnblocks) ) return;

	/* because data_mem may have moved */
	scan_blocks(heap[data_mem].start,datblockptr);

	/* build file -- */
	i=0;

	/* -- header */
	addr[i]= (long)(&dataheader);
	leng[i++]= sizeof(dataheader);

	/* -- blocks before the selected block */
	if (mlxblock>0)
	{
		addr[i]= mlxblockptr[0];
		leng[i++]= mlxblockptr[mlxblock] - mlxblockptr[0] ;
	}

	/* -- new block */
	addr[i]= datblockptr[datblock];
	leng[i++]= datblockptr[datblock+1] - datblockptr[datblock] ;

	/* -- blocks after the selected block */
	if (mlxblock<(mlxnblocks-1))
	{
		addr[i]= mlxblockptr[mlxblock+1];
		leng[i++]= mlxblockptr[mlxnblocks] - mlxblockptr[mlxblock+1] ;
	}

	/* -- end record */
	addr[i]= (long)(&end_record);
	leng[i++]= 4;

	save_file(mlxfile,mlxpath,-i,addr,leng);	/* replace without warning */

}	/* end mlx_replace() */
Exemplo n.º 24
0
/*******************************************************************************
	Multi FileSelect

	FileSelect �volu� permettant de traiter un ensemble de fichiers en une
	seule passe.
	S�lection des fichiers avec Selectric; ou � l'aide de joker.
	On appelle ensuite en boucle la fonction (*call) avec comme unique
	param�tre le nom complet du fichier.
	De plus; le joker # permet de remplacer un num�ro de fichier. Par exemple
	le masque TOTO####.TXT cherchera le fichier TOTO0001.TXT puis les suivants.
*******************************************************************************/
int _multifsel(char *pfname,char *pname,char *fname,char *ext,char *title,int cdecl (*call)(char *name))
{
	DTA	*dta;
	long	k,n,m;
	char	path[FILENAME_MAX];
	char	mask[20];
	char	*p;
	int	drvold=-1;
	int	is_slct_da,num=0;
	int	i,j=1,Break;

	p=glb.div.buf;
	is_slct_da=_slctMoreNames(1,512,glb.div.buf);
	i=_fselect(pfname,pname,fname,ext,title);
	if (i)
	{
		Break=FALSE;
		if (is_slct_da)
		{
			while (*p && j && !Break)
			{
				num+=1;
				strcpy(path,pname);
				fname[0]=0;
				while (*p && *p!=' ')
					strncat(fname,p++,1L);
				strcat(path,"\\");
				strcat(path,fname);
				p++;
				if (call)
					j=(*call)(path);
			}
		}
		if (num==0)
		{
			if (pname[1]==':')
			{
				drvold=Dgetdrv();
				Dsetdrv((int)pfname[0]-65);
			}

			p=strchr(pfname,'#');
			if (p)		/*	Gestion du masque #	*/
			{
				n=0L;
				while (*p++=='#')
					n+=1L;

				p=strchr(pfname,'#');					/*	pfname=C:\TOTO\TITI.EXT\TATA##O.JPG"	n=2	*/
				*p='\0';
				strcpy(path,pfname);						/*	path=C:\TOTO\TITI.EXT\TATA							*/
				sprintf(mask,"%%s%%0%lili%%s",n);	/*	mask='%s%02li%s'										*/
				m=1L;
				for (k=0;k<n;k++)
					m*=10L;
				for (k=0;k<m;k++)
				{
					sprintf(path,mask,pfname,k,&p[n]);
					if (!_fexist(path,NULL))
						k=m;
					else if (call)
						j=(*call)(path);
					if (!j)
						k=m;
				}
			}
			else
			if (!Fsfirst(pfname,FA_READONLY+FA_HIDDEN+FA_SYSTEM+FA_ARCHIVE))
			{
				dta=Fgetdta();
				do
				{
					strcpy(path,pname);
					strcat(path,"\\");
					strcat(path,dta->d_fname);
					if (call)
						j=(*call)(path);
				}	while (!Fsnext() && j && !Break);
			}
			if (drvold!=-1)
				Dsetdrv(drvold);
		}
		Break=FALSE;
	}
	return num;
}
Exemplo n.º 25
0
int
open_file( WX **pwx, int *pvw, int *pvh )
{
	WX		*wx;
	char	file[14], *ppath;
	int		i, ret;
	DTA		mydta, *savedta;
	long	readamt;
	char	*readbuf;

	if( (wx = calloc( 1L, sizeof(WX) )) == NULL ) {
		return (int)ENSMEM;
	}

	wx->name[0] = (char)Dgetdrv() + 'A';
	wx->name[1] = ':';
	Dgetpath( &(wx->name[2]), 0 );
	strcat( wx->name, "\\*.*" );
	file[0] = 0;

	ret = fsel_input( wx->name, file, &i );
	if( ret != 1 )  {
		goto err1;
	} else if( !i ) {
		ret = (int)ERROR;
		goto err1;
	}
	if( (ppath = strrchr( wx->name, '\\' )) == NULL ) ppath = wx->name;
	else ++ppath;
	strcpy( ppath, file );

	savedta = Fgetdta();
	Fsetdta( &mydta );
	Fsfirst( wx->name, 1 );
	Fsetdta( savedta );

	if( (readbuf = (char *)Malloc(mydta.d_length)) <= NULL ) {
		ret = (int)ENSMEM;
		goto err1;
	}

	if( (ret = (int)Fopen(wx->name, 0)) < 0 ) goto err;

	graf_mouse( BUSYBEE, NULL );
	readamt = Fread( ret, mydta.d_length, readbuf );
	graf_mouse( ARROW, NULL );
	Fclose( ret );
	if( readamt != mydta.d_length ) {
		ret = (int)readamt;
err:	Mfree( readbuf );
err1:	free( wx );
		return ret;
	}
	wx->tabs = 4 * form_alert( 1, "[2][ What size tabs? ][ 4 | 8 ]" );

	graf_mouse( BUSYBEE, NULL );
	ret = parse_buf( readbuf, readamt, wx->tabs, &wx->line0, pvw, pvh );
	graf_mouse( ARROW, NULL );
	Mfree( readbuf );
	if( ret != E_OK ) {
		free_tlines( wx->curline );
		goto err1;
	}
	*pwx = wx;
	return ret;
}
Exemplo n.º 26
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;
}
Exemplo n.º 27
0
//********************************************************************
// 1998-09-16 - Created
//********************************************************************
// Initiates the Application so that it can make AES calls
//********************************************************************
int init_appl(void)
{
	char	args[ MAXSTRING ];
	char	progname[ SIZE_ID + 1 ];  
	int		flag;
	char	*temp_s;
	char	*addr;
	
	ap_id = appl_init();
	if( ap_id == FAIL )
	{
		sprintf( tempvar.errorstring , APPL_ERROR );
		alertbox( 1 , tempvar.errorstring );
		
		#ifdef LOGGING 
		Log( LOG_INIT , "Could register Application!!!!\n" ); 
		#endif

		Return FALSE;
	}

	Pdomain( 1 );

	flag = shel_read( system_dir , args);
	if( !flag )
	{
		#ifdef LOGGING
			Log( LOG_INIT , "shell_read, did not work :( %d\n" , flag );
		#endif
		Return FALSE;
	}

	#ifdef LOGGING
	Log(LOG_INIT,"system-path returned by shell_read: %s\n",system_dir);
	#endif

	temp_s = ( char * )strrchr( system_dir , '\\' );
	if( temp_s == NULL )
	{
		#ifdef LOGGING
		Log( LOG_INIT , "there was no end '\\' in the pathname: %s\n " , system_dir);
		#endif
		Return FALSE;
	}
	*temp_s++ = 0;
	strncpy( progname , temp_s , 8 );
	strcat( system_dir , "\\fireconf\\" );
	progname[ 8 ] = 0;
	temp_s = ( char * )strchr( progname , '.' );
	if( temp_s )
		*temp_s = 0;
	while ( strlen( progname ) < 8 )
		strcat( progname, " " );

	if( ( !strcmp( progname , "LC5     " ) ) || ( system_dir[ 0 ] == 0 ) )
	{
		#ifdef LOGGING
		Log( LOG_INIT , "could not use path provided from shell-read , resorting to a different method \n " );
		#endif
		strcpy( system_dir , "A:" );
		system_dir[ 0 ] = Dgetdrv() + 'A';
		Dgetpath( system_dir + 2 , 0 );
		strcat( system_dir , "\\fireconf\\" );
	}
  
	#ifdef LOGGING
	Log( LOG_INIT , "Getting the name of the AV-Server\n" );
	#endif

	flag = shel_envrn( &addr , "AVSERVER=" );
	if( !addr )
	{
		#ifdef LOGGING
		Log( LOG_INIT , "NO AVSERVER enviroment string found \n" );
		#endif
    	if( appl_find( "AVSERVER" ) >= 0 )
    	{
			#ifdef LOGGING
			Log( LOG_INIT , "AVSERVER Application found\n" );
			#endif

			strcpy( avserver , "AVSERVER" );
		}
		else if( appl_find( "THING   " ) >=0 )
		{
			#ifdef LOGGING
			Log( LOG_INIT , "THING Application found\n" );
			#endif

			strcpy(avserver,"THING   ");
		}
		else if( appl_find( "GEMINI  " ) >=0 )
		{
			#ifdef LOGGING
			Log( LOG_INIT , "GEMINI Application found\n" );
			#endif
			
			strcpy( avserver , "GEMINI  " );
		}

		if( avserver[ 0 ] == 0 )
		{
			#ifdef LOGGING
			Log( LOG_INIT , "No AVSERVER application found\n" );
			#endif
		}
	}
	else
	{
		#ifdef LOGGING
		Log( LOG_INIT , "AVSERVER: %s\n" , addr );
		#endif

		strcpy( avserver , addr );
		while ( strlen( avserver ) < 8 )
			strcat( avserver, " ");
	}  
	flag = appl_find( avserver );
	if ( flag == ap_id )
		strcpy( avserver , "" );

	Return TRUE;
}
Exemplo n.º 28
0
ex_paths()
{
#if DISKFLAG
	int done,mstate,edit_obj,exit_obj;
	register int i,temp;
#define NPATHS 7
	char *ptr[NPATHS];
	static int obj[NPATHS]= {
		PATHCNX,PATHMAC,PATHTEM,PATHLDAT,PATHRDAT,PATHMIDI,PATHMULT
	};
	static int *drive[NPATHS]= {
		&cnx_drive,&mac_drive,&tem_drive,
		&ldat_drive,&rdat_drive,&midi_drive,&mlt_drive
	};
	static char *path[NPATHS]= {
		cnx_path,mac_path,tem_path,
		ldat_path,rdat_path,midi_path,mlt_path
	};
	static int findobj[NPATHS]= {
		FINDCNX,FINDMAC,FINDTEM,FINDLDAT,FINDRDAT,FINDMIDI,FINDMULT
	};
	static char *title[NPATHS]= {
		FINDCNXMSG,FINDMACMSG,FINDTEMMSG,FINDLDATMSG,
		FINDRDATMSG,FINDMIDIMSG,FINDMULTMSG
	};
	static char *ext[NPATHS]= {
		CNXF_EXT, MAXC_EXT, TE_EXT, ALL_EXT, ALL_EXT, ALL_EXT, MLX_EXT
	};
	char filename[13],pathname[80];

	for (i=0; i<NPATHS; i++)
	{
		ptr[i]= pathaddr[obj[i]].ob_spec;
		ptr[i][0]= 'A' + *drive[i];
		ptr[i][1]= ':';
		strcpy(ptr[i]+2,path[i]);
	}
	/* draw dialog box, centered */
	putdial(pathaddr,-1,0);
	
	edit_obj= -1;
	done=0;
	do
	{
		waitmouse();	/* no mouse repeat */
		exit_obj= my_form_do(pathaddr,&edit_obj,&mstate,0,&dummy);
		switch (exit_obj)
		{
			case OKPATH:
			for (i=0; i<NPATHS; i++)
			{
				if (ptr[i][1]==':')
				{
					temp= ptr[i][0]-'A';
					if ((temp>=0)&&(temp<16)) *drive[i]=temp;
					strcpy(path[i],ptr[i]+2);
				}
				else
					strcpy(path[i],ptr[i]);
			}
			case CANPATH:		done=1; break;

			default:
			for (i=0; i<NPATHS; i++) if (exit_obj==findobj[i]) break;
			putdial(0L,0,exit_obj);
			Dsetdrv(ptr[i][0]-'A');
			if (ptr[i][1]==':')
				dsetpath(ptr[i]+2);
			else
				dsetpath(ptr[i]);
			filename[0]=0;
			if (getfile(pathname,filename,ext[i],title[i]))
			{
				ptr[i][0]= (temp=Dgetdrv()) + 'A';
				ptr[i][1]= ':';
				Dgetpath(ptr[i]+2,temp+1);
				if (!ptr[i][2])
				{
					ptr[i][2]='\\';
					ptr[i][3]=0;
				}
			}
			putdial(pathaddr,-1,0);

		}	/* end switch */
	}
	while (!done);
	putdial(0L,0,exit_obj);

#endif
}  /* end ex_paths() */
Exemplo n.º 29
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;
}
Exemplo n.º 30
0
/* ------------ */
main()
{
register int which; 										/* Ausgel�ste Aktion */
register int i; 												/* Schleifenindex */
int msg[8]; 														/* Message-Buffer */
int dummy;															/* f�r unwichtige Werte */

appl_init();
open_vwork();

fnt_path[0] = Dgetdrv() + 'A';					/* Aktuellen Pfad ermitteln*/
fnt_path[1] = ':';
Dgetpath(fnt_path + 2, 0);
strcat(fnt_path, "\\*.FNT");

rsrc_load("VDI_FONT.RSC");							/* RSC laden */

graf_mouse(ARROW, 0L);									/* Mauspfeil */

set_workarea(); 												/* Hintergrund anlegen */
count_defined();
set_marker(); 													/* Marker positionieren */
restore_char(); 												/* Erstes Zeichen holen */
show_ccharacter();

do
	{
	which = evnt_multi(MU_BUTTON|MU_KEYBD|MU_MESAG,
										 2, 1, 1,
										 0, 0, 0, 0, 0,
										 0, 0, 0, 0, 0,
										 msg,
										 0, 0,
										 &mousex, &mousey, &dummy,
										 &dummy, &key, &clicks);


	switch(which)
		{
		case MU_KEYBD:											/* Tastendruck ? */
			if ((char)key >= 'a' && (char)key <= 'z')
				key &= 0xDF;
				
			if (!(char)key) 									/* Kontrolltaste ?*/
				{
				key >>= 8;
				key |= 0x80;
				}

			for (i = 0; i < KEY_NUM; i++)					/* Passenden Men�eintrag suchen */
				if (m_keys[i] == (char)key)
					{
					which = MU_MESAG;
					msg[0] = MN_SELECTED;
					msg[4] = m_entry[i];
					menu_action(msg); 						/* Men�eintrag ausf�hren */
					break;
					}
			break;

		case MU_MESAG:
			if (msg[0] == MN_SELECTED)				/* Men�eintrag ? */
				{
				menu_action(msg);
				menu_tnormal(menu_adr, msg[3], TRUE);
				}
			break;

		case MU_BUTTON:
			button_click(); 									/* Mausklick */
			break;
		}

	}while(which != MU_MESAG || msg[0] != MN_SELECTED || msg[4] != F_OK);

cls_vwork();
appl_exit();
}