Ejemplo n.º 1
0
static void openwithtags() {
	int32 iotag = lua_newtag();
	int32 closedtag = lua_newtag();
	uint32 i;
	for (i = 0; i < sizeof(iolibtag) / sizeof(iolibtag[0]); i++) {
		// put both tags as upvalues for these functions
		lua_pushnumber(iotag);
		lua_pushnumber(closedtag);
		lua_pushCclosure(iolibtag[i].func, 2);
		lua_setglobal(iolibtag[i].name);
	}

	g_fin = new LuaFile();
	g_fin->_stdin = true;
	setfile(addfile(g_fin), FINPUT, iotag);

	g_fout = new LuaFile();
	g_fout->_stdout = true;
	setfile(addfile(g_fout), FOUTPUT, iotag);

	g_stdin = new LuaFile();
	g_stdin->_stdin = true;
	setfile(addfile(g_stdin), "_STDIN", iotag);

	g_stdout = new LuaFile();
	g_stdout->_stdout = true;
	setfile(addfile(g_stdout), "_STDOUT", iotag);

	g_stderr = new LuaFile();
	g_stderr->_stderr = true;
	setfile(addfile(g_stderr), "_STDERR", iotag);
}
Ejemplo n.º 2
0
MPlex::MPlex(int n1, int n2, char *f, int uc)
{
	num_tags = n1;
	ntail = n2;
	addfile(f);
	use_codes = uc;
}
Ejemplo n.º 3
0
static void
doinclude(State *s, char *p)
{
	File *f;
	int sysinc;
	char term, *q, *path;

	if(peek(s) & (Tdisable|Tinherit))
		return;

	switch(*p){
	case '"': p++; term = '"'; break;
	case '<': p++; term = '>'; break;
	default:
		cpperr(s, "%c - bad filename quote character\n", *p);
		return;
	}
	if((q = strchr(p, term)) == nil){
		cpperr(s, "%s - unterminated filename\n", p);
		return;
	}
	*q = 0;

	if((path = findinc(p, term, s->langincdirs, &sysinc)) == nil){
		if(Autoconf && strcmp(p, "config.h") != 0)
			cpperr(s, "%q - include file not found\n", p);
	}

	if(path == nil)
		path = estrdup(p);
	f = addfile(path, sysinc);
	f->ref++;
	free(path);
	scanfile(s->dep, f, s->file, s->line);
}
Ejemplo n.º 4
0
Archivo: ls.c Proyecto: cmgnn/42
t_file	*ft_open(char *name, int deep)
{
	t_dir	*entry;
	t_file	*file;
	t_file	*ret;
	DIR		*d;
	char	*tmp = NULL;

	d = opendir(name);
	ret = NULL;
	if (d)
	{
		while ((entry = readdir(d)))
		{
			if (ft_strcmp(entry->d_name, "..") && ft_strcmp(entry->d_name, "."))
			{
				file = init_file(entry->d_name);
				printf("%s\n", entry->d_name);
				if (entry->d_type & DT_DIR && deep != 0)
				{
					tmp = set_name_path(name, entry->d_name);
					file->dir = ft_open(tmp, deep - 1);
					ft_memdel((void**)&tmp);
				}
				addfile(&ret, file);
			}
		}
		closedir(d);
	}
	else
		printf("cannot acces to %s\n", name);
	return (ret);
}
Ejemplo n.º 5
0
static void io_readfrom() {
	lua_Object f = lua_getparam(FIRSTARG);
	if (f == LUA_NOOBJECT) {
		closefile(FINPUT);
		setreturn(1, FINPUT);
	} else if (lua_tag(f) == gettag(IOTAG)) {
		int32 id = lua_getuserdata(f);
		LuaFile *current = getfile(id);
		if (!current) {
			pushresult(0);
			return;
		}
		setreturn(id, FINPUT);
	} else {
		const char *s = luaL_check_string(FIRSTARG);
		LuaFile *current;
		Common::SeekableReadStream *inFile = NULL;
		Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
		inFile = saveFileMan->openForLoading(s);
		if (!inFile)
			current = g_resourceloader->openNewStreamLuaFile(s);
		else {
			current = new LuaFile();
			current->_in = inFile;
			current->_filename = s;
		}
		if (!current) {
			delete current;
			pushresult(0);
		} else {
			setreturn(addfile(current), FINPUT);
		}
	}
}
Ejemplo n.º 6
0
static void io_writeto() {
	lua_Object f = lua_getparam(FIRSTARG);
	if (f == LUA_NOOBJECT) {
		closefile(FOUTPUT);
		setreturn(2, FOUTPUT);
	} else if (lua_tag(f) == gettag(IOTAG)) {
		int32 id = lua_getuserdata(f);
		LuaFile *current = getfile(id);
		if (!current->isOpen()) {
			pushresult(0);
			return;
		}
		setreturn(id, FOUTPUT);
	} else {
		Common::String s = Common::lastPathComponent(luaL_check_string(FIRSTARG), '\\');
		LuaFile *current;
		Common::WriteStream *outFile = NULL;
		Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
		outFile = saveFileMan->openForSaving(s);
		if (!outFile) {
			pushresult(0);
			return;
		}
		current = new LuaFile();
		current->_out = outFile;
		current->_filename = s;
		setreturn(addfile(current), FOUTPUT);
	}
}
Ejemplo n.º 7
0
static void io_appendto() {
	Common::String s = Common::lastPathComponent(luaL_check_string(FIRSTARG), '\\');
	Common::SeekableReadStream *inFile = NULL;
	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	inFile = saveFileMan->openForLoading(s);
	if (!inFile) {
		pushresult(0);
		return;
	}
	int size = inFile->size();
	byte *buf = new byte[size];
	inFile->read(buf, size);
	delete inFile;

	Common::WriteStream *outFile = NULL;
	outFile = saveFileMan->openForSaving(s);
	if (!outFile)
		pushresult(0);
	else {
		outFile->write(buf, size);
		LuaFile *current = new LuaFile();
		current->_out = outFile;
		current->_filename = s;
		setreturn(addfile(current), FOUTPUT);
	}
	delete[] buf;
}
Ejemplo n.º 8
0
/* private */ void 
mainwindow::_create_actions()
{
  _action_exit                            = new QAction(tr("Exit"), this);
  _action_loadfile                        = new QAction(tr("Open"), this);
  _action_addfile                         = new QAction(tr("Add"),  this);

  // menu
  connect(_action_exit,                     SIGNAL( triggered()), this,         SLOT( close_window() ));
  connect(_action_loadfile,                 SIGNAL( triggered()), this,         SLOT( openfile() ));
  connect(_action_addfile,                  SIGNAL( triggered()), this,         SLOT( addfile() ));

  connect(_button_recompile,                SIGNAL( released() ), _glwindow,    SLOT( recompile() ));
  connect(_button_set_spheremap,            SIGNAL( released() ), _glwindow,    SLOT( load_spheremap() ));

  connect(_addfile_button, SIGNAL(released()), this, SLOT(addfile()));
  connect(_deletefile_button, SIGNAL(released()), this, SLOT(deletefiles()));

  connect(_checkbox_spheremap,              SIGNAL( stateChanged(int) ), _glwindow,    SLOT( spheremapping(int) ));
  connect(_checkbox_fxaa,                   SIGNAL( stateChanged(int) ), _glwindow,    SLOT( fxaa(int) ));
  
  
  connect(_checkbox_pretessellation,        SIGNAL(stateChanged(int)), _glwindow, SLOT(enable_pretessellation(int)));
  connect(_checkbox_vsync,                  SIGNAL( stateChanged(int) ), _glwindow,    SLOT( vsync(int) ));
  connect(_checkbox_culling,                SIGNAL(stateChanged(int)),   _glwindow,    SLOT( backface_culling(int)));
  connect(_checkbox_counting,               SIGNAL(stateChanged(int)),   _glwindow,    SLOT( enable_counter(int)));
  connect(_checkbox_tritesselation,         SIGNAL(stateChanged(int)), _glwindow, SLOT(enable_triangular_tesselation(int)));
  connect(_checkbox_holefilling,            SIGNAL(stateChanged(int)), _glwindow, SLOT(holefilling(int)));
  connect(_checkbox_conservative_rasterization, SIGNAL(stateChanged(int)), _glwindow, SLOT(conservative_rasterization(int)));
  
  connect(_combobox_antialiasing,           SIGNAL(currentIndexChanged(int)), this, SLOT(antialiasing()));
  connect(_combobox_trimming,               SIGNAL(currentIndexChanged(int)), this, SLOT(trimming()));
  connect(_combobox_rendering,              SIGNAL(currentIndexChanged(int)), this, SLOT(rendering()));
  connect(_combobox_fillmode,               SIGNAL(currentIndexChanged(int)), this, SLOT(fillmode()));
  connect(_combobox_preclassification,      SIGNAL(currentIndexChanged(int)), this, SLOT(preclassification()));
  
  connect(_slider_trim_max_bisections,          SIGNAL(valueChanged(int)),    _glwindow, SLOT(trim_max_bisections(int)));
  connect(_slider_trim_error_tolerance,         SIGNAL(valueChanged(float)),  _glwindow, SLOT(trim_error_tolerance(float)));
  connect(_slider_tesselation_max_pixel_error,  SIGNAL(valueChanged(float)),  _glwindow, SLOT(tesselation_max_pixel_error(float)));
  connect(_slider_tesselation_max_object_error, SIGNAL(valueChanged(float)),  _glwindow, SLOT(tesselation_max_geometric_error(float)));
  connect(_slider_raycasting_max_iterations,    SIGNAL(valueChanged(int)),    _glwindow, SLOT(raycasting_max_iterations(int)));
  connect(_slider_raycasting_error_tolerance,   SIGNAL(valueChanged(float)),  _glwindow, SLOT(raycasting_error_tolerance(float)));

  connect(_current_specular, SIGNAL(released()), this, SLOT(set_specular()));
  connect(_current_diffuse, SIGNAL(released()), this, SLOT(set_diffuse()));
  connect(_current_ambient, SIGNAL(released()), this, SLOT(set_ambient()));
  connect(_current_shininess, SIGNAL(valueChanged(float)), this, SLOT(set_shininess(float)));
  connect(_current_opacity, SIGNAL(valueChanged(float)), this, SLOT(set_opacity(float)));

  connect(_material_apply, SIGNAL(released()), this, SLOT(apply_material()));

  _file_menu->addSeparator();
  _file_menu->addAction   (_action_loadfile);
  _file_menu->addAction   (_action_addfile);
  _file_menu->addAction   (_action_exit);
}
Ejemplo n.º 9
0
int
getinfo(char *s, char *d)
{
	int 	sdir, ddir;
	int	ret;

	srclen = strlen(s) + 5; 	/* 1 byte for null and 4 byte for \*.* */
	dstlen = strlen(d) + 17; 	/* 1 for null, 4 for \*.* and 13 for folder */
	srcbuf = 500;				/* initialize the buffer */
	dstbuf = 500;

	while (srclen > srcbuf)
	  srcbuf *= 2;

	while (dstlen > dstbuf)
	  dstbuf *= 2;

	fixsrc = (char *)malloc( (long)srcbuf );
	fixdst = (char *)malloc( (long)dstbuf );
	sdir = mystrcp(s, fixsrc);

	if ( opcode == OP_DELETE )	/* do directories or files rm */
	  return( (sdir)? DTOD:OK );
	else			/* do directories or files cp or mv */
	{		
	   getlastpath(filestr,fixsrc);
	   if (((ddir = mystrcp(d, fixdst))) && (sdir))	
	   { 					/* dir to dir */
	     if (*filestr)	
	     {					/* folder cp */
	       chkbuf(dstlen, dstbuf, &fixdst);		/* check buf size */
	       addfile(fixdst, filestr);	/* add the folder to dst */
	       
	       ret = created( filestr );	/* create the 1st folder */
	       if ( ( !ret ) || ( ret == SKIP ) )
	       {
		 free( fixsrc );
		 free( fixdst );
		 return( ret );
	       }
	       strcat(bckslsh, fixdst);
	     }
	     return (DTOD);
	   }
	   if (ddir)
	   {						/* one file to dir */
	     chkbuf(dstlen, dstbuf, &fixdst);		/* check buf size */
	     strcat(filestr, fixdst);
	   }
	   return OK;			
	} 
}
Ejemplo n.º 10
0
int main(int argc, char *argv[])
{
  int i;

  InitList(&filelist);
  if (argc == 1)
    copyfile(stdin);
  else
  {
    for (i = 1; i < argc; i++)
      addfile(argv[i]);
    WalkList(&filelist, (WordFnPtr)putfile, 0);
  }
  return 0;
}
Ejemplo n.º 11
0
Archivo: msi.c Proyecto: ovsm-dev/sdp
/***************************************************************************
 * addlistfile:
 *
 * Add files listed in the specified file to the global input file list.
 *
 * Returns count of files added on success and -1 on error.
 ***************************************************************************/
static int
addlistfile (char *filename) 
{
  FILE *fp;
  char filelistent[1024];
  int filecount = 0;
  
  if ( verbose >= 1 )
    ms_log (1, "Reading list file '%s'\n", filename);
  
  if ( ! (fp = fopen(filename, "rb")) )
    {
      ms_log (2, "Cannot open list file %s: %s\n", filename, strerror(errno));
      return -1;
    }
  
  while ( fgets (filelistent, sizeof(filelistent), fp) )
    {
      char *cp;
      
      /* End string at first newline character */
      if ( (cp = strchr(filelistent, '\n')) )
        *cp = '\0';
      
      /* Skip empty lines */
      if ( ! strlen (filelistent) )
        continue;
      
      /* Skip comment lines */
      if ( *filelistent == '#' )
        continue;
      
      if ( verbose > 1 )
        ms_log (1, "Adding '%s' from list file\n", filelistent);
      
      if ( addfile (filelistent) )
        return -1;
      
      filecount++;
    }
  
  fclose (fp);
  
  return filecount;
}  /* End of addlistfile() */
Ejemplo n.º 12
0
/*
 * Open a file, add it to the linked list of open files.
 * This is called only from openfile() above.
 */
int openfile(char* filename)
{
    FILE* fp;

    if ((fp = fopen(filename, "r")) == NULL)
    {
#if OSL_DEBUG_LEVEL > 1
        if ( debug || !bDumpDefs )
            perror(filename);
#endif
        return (FALSE);
    }
#if OSL_DEBUG_LEVEL > 1
    if (debug)
        fprintf(stderr, "Reading from \"%s\"\n", filename);
#endif
    addfile(fp, filename);
    return (TRUE);
}
Ejemplo n.º 13
0
fileEntry *listFiles(short *fileCount, char **namebuffer) {
	struct filelist *list = newFilelist();

	// windows: FindFirstFile/FindNextFile 
	DIR *dp= opendir ("./");

	if (dp != NULL) {
		struct dirent *ep;
		struct stat statbuf;
		struct tm *timeinfo;

		while ((ep = readdir(dp))) {
			// get statistics about the file (0 on success)
			if (!stat(ep->d_name, &statbuf)) {
				fileEntry *file = addfile(list, ep->d_name);
				if (file != NULL) {
					// add the modification date to the file entry, the same way we do it for scores
					timeinfo = localtime(&statbuf.st_mtime);
					strftime(file->date, sizeof(file->date), "%m/%d/%y", timeinfo);
				}
			}
		}

		closedir (dp);
	}
	else {
		*fileCount = 0;
		return NULL;
	}
	
	fileEntry *files = commitFilelist(list, namebuffer);
	
	if (files != NULL) {
		*fileCount = (short) list->nfiles;
	} else {
		*fileCount = 0;
	}

	freeFilelist(list);

	return files;
}
Ejemplo n.º 14
0
int main(int ARGC, char **ARGV, char **ENV) {
	Res_dos *res;
	Byte* data;

	if(ARGC < 4) {
		fprintf(stderr, "%s: %s", ARGV[0], usage);
		exit(1);
	}

	char wad_file[256];
	sprintf(wad_file, "%s%s", ARGV[1], ARGV[2]);

	wad = new Resfile(wad_file, false);

	wad->clear();

	char res_file[256];
	sprintf(res_file, "%s%s", ARGV[1], ARGV[3]);

	res = new Res_dos(res_file, RES_READ);
	data = new Byte[res->size()+1];

	memcpy(data, res->buf(), res->size());

	Stringtable st(data, res->size());

	for(int i=0; i<st.size(); i++)
	{
		char temp[256];
		sprintf(temp, "%s%s", ARGV[1], st.get(i));
		addfile(temp);
	}

	delete data;
	delete res;

	wad->freeze();

	delete wad;

	return 0;
}
Ejemplo n.º 15
0
static void io_readfrom() {
	lua_Object f = lua_getparam(FIRSTARG);
	if (f == LUA_NOOBJECT) {
		if (getfile(FOUTPUT) != getfile(1)) {
			closefile(FINPUT);
			setreturn(1, FINPUT);
		}
	} else if (lua_tag(f) == gettag(IOTAG)) {
		int32 id = lua_getuserdata(f);
		LuaFile *current = getfile(id);
		if (!current) {
			pushresult(0);
			return;
		}
		setreturn(id, FINPUT);
	} else {
		const char *s = luaL_check_string(FIRSTARG);
		Common::String fileName = Common::lastPathComponent(s, '\\');
		LuaFile *current = NULL;
		Common::SeekableReadStream *inFile = NULL;
		Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
		inFile = saveFileMan->openForLoading(fileName);
		if (!inFile) {
			inFile = g_resourceloader->openNewStreamFile(s);
		}
		if (inFile) {
			current = new LuaFile();
			current->_in = inFile;
			current->_filename = s;
		} else {
			warning("liolib.cpp, io_readfrom(): Could not open file %s", s);
		}
		if (!current) {
			delete current;
			pushresult(0);
		} else {
			setreturn(addfile(current), FINPUT);
		}
	}
}
Ejemplo n.º 16
0
fileEntry *listFiles(short *fileCount, char **namebuffer) {
	struct filelist *list = newFilelist();

	WIN32_FIND_DATAA ep;
	HANDLE dp = FindFirstFileA("*", &ep);
	fileEntry *files;

	if (dp != INVALID_HANDLE_VALUE)
	{
		boolean hasFiles = true;
		do {
			fileEntry *file = addfile(list, ep.cFileName);
			if (file != NULL) {
				// add the modification date to the file entry, the same way we do it for scores
				SYSTEMTIME timeinfo;
				FileTimeToSystemTime(&(ep.ftLastWriteTime), &timeinfo);
				sprintf_s(file->date, sizeof(file->date), "%02d/%02d/%02d", timeinfo.wMonth, timeinfo.wDay, timeinfo.wYear % 100);
			}

			if ((0 == FindNextFileA(dp, &ep)) && (GetLastError() == ERROR_NO_MORE_FILES)) {
				hasFiles = false;
			}
		} while (hasFiles);
		FindClose(dp);
	}
	else {
		*fileCount = 0;
		return 0;
	}

	files = commitFilelist(list, namebuffer);
	if (files != NULL) {
		*fileCount = (short) list->nfiles;
	} else {
		*fileCount = 0;
	}

	freeFilelist(list);
	return files;
}
Ejemplo n.º 17
0
int combine(int argc, char **argv, const char *o, const char *m)
{
    scm **V = NULL;
    int   C = 0;
    int   O = 0;

    const char *out = o ? o : "out.tif";

    if (m)
    {
        if      (strcmp(m, "sum")   == 0) O = 0;
        else if (strcmp(m, "max")   == 0) O = 1;
        else if (strcmp(m, "avg")   == 0) O = 2;
        else if (strcmp(m, "blend") == 0) O = 3;
    }

    if ((V = (scm **) calloc((size_t) argc, sizeof (scm *))))
    {
        for (int i = 0; i < argc; ++i)
            C = addfile(V, C, argv[i]);

        if (C)
        {
            int n = scm_get_n(V[0]);
            int c = scm_get_c(V[0]);
            int b = scm_get_b(V[0]);
            int g = scm_get_g(V[0]);

            scm *s;

            if ((s = scm_ofile(out, n, c, b, g)))
            {
                process(s, V, C, O);
                scm_close(s);
            }
        }
    }
    return 0;
}
Ejemplo n.º 18
0
// destroys snbuf - use after loading all files
void C_Fdd::addboot()
{
	t.seek(this, 0, 0, LOAD_SECTORS);

	for (unsigned s = 0; s < 8; s++)
	{
		s_SecHdr *sc = t.get_sector(s+1);
		if (!sc) return;

		for (unsigned p = 0; p < 0x100; p += 0x10) {
			if (!memcmp(sc->data+p, "boot    B", 9)) return;
		}
	}

	FILE *f = fopen(get_appendboot(), "rb");
	if (!f) return;

	if (fread(snbuf, 1, sizeof(snbuf), f) < 0x10) DEBUG_MESSAGE("fread failed");
	fclose(f);

	snbuf[13] = snbuf[14]; // copy length
	addfile(snbuf, snbuf+0x11);
}
Ejemplo n.º 19
0
Archivo: cpp3.c Proyecto: cjapes/core
int
openfile(char* filename)
/*
 * Open a file, add it to the linked list of open files.
 * This is called only from openfile() above.
 */
{
        register FILE           *fp;

        if ((fp = fopen(filename, "r")) == NULL) {
#if OSL_DEBUG_LEVEL > 1
            if ( debug || !bDumpDefs )
                perror(filename);
#endif
            return (FALSE);
        }
#if OSL_DEBUG_LEVEL > 1
        if (debug)
            fprintf(stderr, "Reading from \"%s\"\n", filename);
#endif
        addfile(fp, filename);
        return (TRUE);
}
Ejemplo n.º 20
0
Archivo: cpp3.c Proyecto: vidarh/FPL
ReturnCode openfile(struct Global *global, char *filename)
{
  /*
   * Open a file, add it to the linked list of open files.
   * This is called only from openfile() in cpp2.c.
   */

  FILE *fp;
  ReturnCode ret;
  
  if ((fp = fopen(filename, "r")) == NULL)
    ret=FPP_OPEN_ERROR;
  else
    ret=addfile(global, fp, filename);

  if(!ret && global->showincluded) {
	  /* no error occured! */
	  Error(global, "cpp: included \"");
	  Error(global, filename);
	  Error(global, "\"\n");
  }
  return(ret);
}
Ejemplo n.º 21
0
Archivo: addfile.c Proyecto: kik/fca
int
main(int argc, char **argv)
{
  char *name, *ext;

  if (argc != 3) {
    printf("usage: addfile filename name\n");
    return 1;
  }

  name = argv[2];
  ext = strchr(argv[2], '.');
  if (ext)
    *ext++ = '\0';
  else
    ext = "???";

  if (addfile(stdout, argv[1], name, ext)) {
    perror(argv[1]);
    exit(1);
  }

  return 0;
}
Ejemplo n.º 22
0
/*
 * mainline for grep
 */
int
main(int argc, char **argv)
{
	char	*ap, *test;
	int	c;
	int	fflag = 0;
	int	i, n_pattern = 0, n_file = 0;
	char	**pattern_list = NULL;
	char	**file_list = NULL;

	(void) setlocale(LC_ALL, "");
#if !defined(TEXT_DOMAIN)	/* Should be defined by cc -D */
#define	TEXT_DOMAIN	"SYS_TEST"	/* Use this only if it weren't */
#endif
	(void) textdomain(TEXT_DOMAIN);

	/*
	 * true if this is running on the multibyte locale
	 */
	mblocale = (MB_CUR_MAX > 1);
	/*
	 * Skip leading slashes
	 */
	cmdname = argv[0];
	if (ap = strrchr(cmdname, '/'))
		cmdname = ap + 1;

	ap = cmdname;
	/*
	 * Detect egrep/fgrep via command name, map to -E and -F options.
	 */
	if (*ap == 'e' || *ap == 'E') {
		regflags |= REG_EXTENDED;
		egrep++;
	} else {
		if (*ap == 'f' || *ap == 'F') {
			fgrep++;
		}
	}

	/* check for non-standard "-line-count" option */
	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "--") == 0)
			break;

		if ((argv[i][0] == '-') && isdigit(argv[i][1])) {
			if (strlen(&argv[i][1]) !=
			    strspn(&argv[i][1], "0123456789")) {
				(void) fprintf(stderr, gettext(
				    "%s: Bad number flag\n"), argv[0]);
				usage();
			}

			conalen = conblen = strtoul(&argv[i][1], (char **)NULL,
			    10);

			/* isdigit() check prevents negative arguments */
			if (conalen >= ULONG_MAX) {
				(void) fprintf(stderr, gettext(
				    "%s: Bad context argument\n"), argv[0]);
			}

			if (conalen)
				conflag = CONTEXT;

			while (i < argc) {
				argv[i] = argv[i + 1];
				i++;
			}
			argc--;
		}
	}

	while ((c = getopt(argc, argv, "vwchHilnrbse:f:qxEFIRA:B:C:")) != EOF) {
		unsigned long tval;
		switch (c) {
		case 'v':	/* POSIX: negate matches */
			nvflag = 0;
			break;

		case 'c':	/* POSIX: write count */
			cflag++;
			break;

		case 'i':	/* POSIX: ignore case */
			iflag++;
			regflags |= REG_ICASE;
			break;

		case 'l':	/* POSIX: Write filenames only */
			lflag++;
			break;

		case 'n':	/* POSIX: Write line numbers */
			nflag++;
			break;

		case 'r':	/* Solaris: search recursively */
			rflag++;
			break;

		case 'b':	/* Solaris: Write file block numbers */
			bflag++;
			break;

		case 's':	/* POSIX: No error msgs for files */
			sflag++;
			break;

		case 'e':	/* POSIX: pattern list */
			n_pattern++;
			pattern_list = realloc(pattern_list,
			    sizeof (char *) * n_pattern);
			if (pattern_list == NULL) {
				(void) fprintf(stderr,
				    gettext("%s: out of memory\n"),
				    cmdname);
				exit(2);
			}
			*(pattern_list + n_pattern - 1) = optarg;
			break;

		case 'f':	/* POSIX: pattern file */
			fflag = 1;
			n_file++;
			file_list = realloc(file_list,
			    sizeof (char *) * n_file);
			if (file_list == NULL) {
				(void) fprintf(stderr,
				    gettext("%s: out of memory\n"),
				    cmdname);
				exit(2);
			}
			*(file_list + n_file - 1) = optarg;
			break;

		/* based on options order h or H is set as in GNU grep */
		case 'h':	/* Solaris: supress printing of file name */
			hflag = 1;
			Hflag = 0;
			break;
		/* Solaris: precede every matching with file name */
		case 'H':
			Hflag = 1;
			hflag = 0;
			break;

		case 'q':	/* POSIX: quiet: status only */
			qflag++;
			break;

		case 'w':	/* Solaris: treat pattern as word */
			wflag++;
			break;

		case 'x':	/* POSIX: full line matches */
			xflag++;
			regflags |= REG_ANCHOR;
			break;

		case 'E':	/* POSIX: Extended RE's */
			regflags |= REG_EXTENDED;
			Eflag++;
			break;

		case 'F':	/* POSIX: strings, not RE's */
			Fflag++;
			break;

		case 'R':	/* Solaris: like rflag, but follow symlinks */
			Rflag++;
			rflag++;
			break;

		case 'A':	/* print N lines after each match */
			conalen = strtoul(optarg, &test, 10);
			/* *test will be non-null if optarg is negative */
			if (*test != '\0' || conalen >= ULONG_MAX) {
				(void) fprintf(stderr, gettext(
				    "%s: Bad context argument\n"), argv[0]);
				exit(2);
			}
			if (conalen)
				conflag |= AFTER;
			else
				conflag &= ~AFTER;
			break;
		case 'B':	/* print N lines before each match */
			conblen = strtoul(optarg, &test, 10);
			/* *test will be non-null if optarg is negative */
			if (*test != '\0' || conblen >= ULONG_MAX) {
				(void) fprintf(stderr, gettext(
				    "%s: Bad context argument\n"), argv[0]);
				exit(2);
			}
			if (conblen)
				conflag |= BEFORE;
			else
				conflag &= ~BEFORE;
			break;
		case 'C':	/* print N lines around each match */
			tval = strtoul(optarg, &test, 10);
			/* *test will be non-null if optarg is negative */
			if (*test != '\0' || tval >= ULONG_MAX) {
				(void) fprintf(stderr, gettext(
				    "%s: Bad context argument\n"), argv[0]);
				exit(2);
			}
			if (tval) {
				conflag = CONTEXT;
				conalen = conblen = tval;
			}
			break;

		default:
			usage();
		}
	}
	/*
	 * If we're invoked as egrep or fgrep we need to do some checks
	 */

	if (egrep || fgrep) {
		/*
		 * Use of -E or -F with egrep or fgrep is illegal
		 */
		if (Eflag || Fflag)
			usage();
		/*
		 * Don't allow use of wflag with egrep / fgrep
		 */
		if (wflag)
			usage();
		/*
		 * For Solaris the -s flag is equivalent to XCU -q
		 */
		if (sflag)
			qflag++;
		/*
		 * done with above checks - set the appropriate flags
		 */
		if (egrep)
			Eflag++;
		else			/* Else fgrep */
			Fflag++;
	}

	if (wflag && (Eflag || Fflag)) {
		/*
		 * -w cannot be specified with grep -F
		 */
		usage();
	}

	/*
	 * -E and -F flags are mutually exclusive - check for this
	 */
	if (Eflag && Fflag)
		usage();

	/*
	 * -l overrides -H like in GNU grep
	 */
	if (lflag)
		Hflag = 0;

	/*
	 * -c, -l and -q flags are mutually exclusive
	 * We have -c override -l like in Solaris.
	 * -q overrides -l & -c programmatically in grep() function.
	 */
	if (cflag && lflag)
		lflag = 0;

	argv += optind - 1;
	argc -= optind - 1;

	/*
	 * Now handling -e and -f option
	 */
	if (pattern_list) {
		for (i = 0; i < n_pattern; i++) {
			addpattern(pattern_list[i]);
		}
		free(pattern_list);
	}
	if (file_list) {
		for (i = 0; i < n_file; i++) {
			addfile(file_list[i]);
		}
		free(file_list);
	}

	/*
	 * No -e or -f?  Make sure there is one more arg, use it as the pattern.
	 */
	if (patterns == NULL && !fflag) {
		if (argc < 2)
			usage();
		addpattern(argv[1]);
		argc--;
		argv++;
	}

	/*
	 * If -x flag is not specified or -i flag is specified
	 * with fgrep in a multibyte locale, need to use
	 * the wide character APIs.  Otherwise, byte-oriented
	 * process will be done.
	 */
	use_wchar = Fflag && mblocale && (!xflag || iflag);

	/*
	 * Compile Patterns and also decide if BMG can be used
	 */
	fixpatterns();

	/* Process all files: stdin, or rest of arg list */
	if (argc < 2) {
		matched = grep(0, STDIN_FILENAME);
	} else {
		if (Hflag || (argc > 2 && hflag == 0))
			outfn = 1;	/* Print filename on match line */
		for (argv++; *argv != NULL; argv++) {
			process_path(*argv);
		}
	}
	/*
	 * Return() here is used instead of exit
	 */

	(void) fflush(stdout);

	if (errors)
		return (2);
	return (matched ? 0 : 1);
}
void
newsyntax(rtems_shell_hexdump_globals* globals, int argc, char ***argvp)
{
	int ch;
	char *p, **argv;

  struct getopt_data getopt_reent;
  memset(&getopt_reent, 0, sizeof(getopt_data));

	argv = *argvp;
	if ((p = rindex(argv[0], 'h')) != NULL &&
	    strcmp(p, "hd") == 0) {
		/* "Canonical" format, implies -C. */
		add(globals, "\"%08.8_Ax\n\"");
		add(globals, "\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
		add(globals, "\"  |\" 16/1 \"%_p\" \"|\\n\"");
	}
	while ((ch = getopt_r(argc, argv, "bcCde:f:n:os:vx", &getopt_reent)) != -1)
		switch (ch) {
		case 'b':
			add(globals, "\"%07.7_Ax\n\"");
			add(globals, "\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"");
			break;
		case 'c':
			add(globals, "\"%07.7_Ax\n\"");
			add(globals, "\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"");
			break;
		case 'C':
			add(globals, "\"%08.8_Ax\n\"");
			add(globals, "\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
			add(globals, "\"  |\" 16/1 \"%_p\" \"|\\n\"");
			break;
		case 'd':
			add(globals, "\"%07.7_Ax\n\"");
			add(globals, "\"%07.7_ax \" 8/2 \"  %05u \" \"\\n\"");
			break;
		case 'e':
			add(globals, getopt_reent.optarg);
			break;
		case 'f':
			addfile(globals, getopt_reent.optarg);
			break;
		case 'n':
			if ((length = atoi(getopt_reent.optarg)) < 0)
				errx(exit_jump, 1, "%s: bad length value", getopt_reent.optarg);
			break;
		case 'o':
			add(globals, "\"%07.7_Ax\n\"");
			add(globals, "\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"");
			break;
		case 's':
			if ((skip = strtoll(getopt_reent.optarg, &p, 0)) < 0)
				errx(exit_jump, 1, "%s: bad skip value", getopt_reent.optarg);
			switch(*p) {
			case 'b':
				skip *= 512;
				break;
			case 'k':
				skip *= 1024;
				break;
			case 'm':
				skip *= 1048576;
				break;
			}
			break;
		case 'v':
			vflag = ALL;
			break;
		case 'x':
			add(globals, "\"%07.7_Ax\n\"");
			add(globals, "\"%07.7_ax \" 8/2 \"   %04x \" \"\\n\"");
			break;
		case '?':
			usage(globals);
		}

	if (!fshead) {
		add(globals, "\"%07.7_Ax\n\"");
		add(globals, "\"%07.7_ax \" 8/2 \"%04x \" \"\\n\"");
	}

	*argvp += getopt_reent.optind;
}
Ejemplo n.º 24
0
static int
open_f(
	int		argc,
	char		**argv)
{
	int		c, fd, flags = 0;
	char		*sp;
	mode_t		mode = 0600;
	xfs_fsop_geom_t	geometry = { 0 };

	if (argc == 1) {
		if (file)
			return stat_f(argc, argv);
		fprintf(stderr, _("no files are open, try 'help open'\n"));
		return 0;
	}

	while ((c = getopt(argc, argv, "FRTacdfm:nrstx")) != EOF) {
		switch (c) {
		case 'F':
			/* Ignored / deprecated now, handled automatically */
			break;
		case 'a':
			flags |= IO_APPEND;
			break;
		case 'c':
		case 'f':
			flags |= IO_CREAT;
			break;
		case 'd':
			flags |= IO_DIRECT;
			break;
		case 'm':
			mode = strtoul(optarg, &sp, 0);
			if (!sp || sp == optarg) {
				printf(_("non-numeric mode -- %s\n"), optarg);
				return 0;
			}
			break;
		case 'n':
			flags |= IO_NONBLOCK;
			break;
		case 'r':
			flags |= IO_READONLY;
			break;
		case 's':
			flags |= IO_OSYNC;
			break;
		case 't':
			flags |= IO_TRUNC;
			break;
		case 'R':
		case 'x':	/* backwards compatibility */
			flags |= IO_REALTIME;
			break;
		case 'T':
			flags |= IO_TMPFILE;
			break;
		default:
			return command_usage(&open_cmd);
		}
	}

	if (optind != argc - 1)
		return command_usage(&open_cmd);

	if ((flags & (IO_READONLY|IO_TMPFILE)) == (IO_READONLY|IO_TMPFILE)) {
		fprintf(stderr, _("-T and -r options are incompatible\n"));
		return -1;
	}

	fd = openfile(argv[optind], &geometry, flags, mode);
	if (fd < 0)
		return 0;

	if (!platform_test_xfs_fd(fd))
		flags |= IO_FOREIGN;

	addfile(argv[optind], fd, &geometry, flags);
	return 0;
}
Ejemplo n.º 25
0
void
newsyntax(int argc, char ***argvp)
{
	int ch;
	char *p, **argv;

	argv = *argvp;
	if ((p = strrchr(argv[0], 'h')) != NULL &&
	    strcmp(p, "hd") == 0) {
		/* "Canonical" format, implies -C. */
		add("\"%08.8_Ax\n\"");
		add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
		add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
	}
	while ((ch = getopt(argc, argv, "bcCde:f:n:os:vx")) != -1)
		switch (ch) {
		case 'b':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"");
			break;
		case 'c':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"");
			break;
		case 'C':
			add("\"%08.8_Ax\n\"");
			add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
			add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
			break;
		case 'd':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 8/2 \"  %05u \" \"\\n\"");
			break;
		case 'e':
			add(optarg);
			break;
		case 'f':
			addfile(optarg);
			break;
		case 'n':
			if ((length = atoi(optarg)) < 0)
				errx(1, "%s: bad length value", optarg);
			break;
		case 'o':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"");
			break;
		case 's':
			if ((skip = strtoll(optarg, &p, 0)) < 0)
				errx(1, "%s: bad skip value", optarg);
			switch(*p) {
			case 'b':
				skip *= 512;
				break;
			case 'k':
				skip *= 1024;
				break;
			case 'm':
				skip *= 1048576;
				break;
			}
			break;
		case 'v':
			vflag = ALL;
			break;
		case 'x':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 8/2 \"   %04x \" \"\\n\"");
			break;
		case '?':
			usage();
		}

	if (!fshead) {
		add("\"%07.7_Ax\n\"");
		add("\"%07.7_ax \" 8/2 \"%04x \" \"\\n\"");
	}

	*argvp += optind;
}
Ejemplo n.º 26
0
void
init(
	int		argc,
	char		**argv)
{
	int		c, flags = 0;
	char		*sp;
	mode_t		mode = 0600;
	xfs_fsop_geom_t	geometry = { 0 };

	progname = basename(argv[0]);
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	pagesize = getpagesize();
	gettimeofday(&stopwatch, NULL);

	while ((c = getopt(argc, argv, "ac:dFfmp:nrRstVx")) != EOF) {
		switch (c) {
		case 'a':
			flags |= IO_APPEND;
			break;
		case 'c':
			add_user_command(optarg);
			break;
		case 'd':
			flags |= IO_DIRECT;
			break;
		case 'F':
			/* Ignored / deprecated now, handled automatically */
			break;
		case 'f':
			flags |= IO_CREAT;
			break;
		case 'm':
			mode = strtoul(optarg, &sp, 0);
			if (!sp || sp == optarg) {
				fprintf(stderr, _("non-numeric mode -- %s\n"),
					optarg);
				exit(1);
			}
			break;
		case 'n':
			flags |= IO_NONBLOCK;
			break;
		case 'p':
			progname = optarg;
			break;
		case 'r':
			flags |= IO_READONLY;
			break;
		case 's':
			flags |= IO_OSYNC;
			break;
		case 't':
			flags |= IO_TRUNC;
			break;
		case 'R':
			flags |= IO_REALTIME;
			break;
		case 'x':
			expert = 1;
			break;
		case 'V':
			printf(_("%s version %s\n"), progname, VERSION);
			exit(0);
		default:
			usage();
		}
	}

	while (optind < argc) {
		if ((c = openfile(argv[optind], &geometry, flags, mode)) < 0)
			exit(1);
		if (!platform_test_xfs_fd(c))
			flags |= IO_FOREIGN;
		if (addfile(argv[optind], c, &geometry, flags) < 0)
			exit(1);
		optind++;
	}

	init_commands();
	add_args_command(init_args_command);
	add_check_command(init_check_command);
}
Ejemplo n.º 27
0
void
newsyntax(int argc, char ***argvp)
{
	int ch;
	char *p, **argv;

	argv = *argvp;
	while ((ch = getopt(argc, argv, "bcCde:f:n:os:vx")) != -1)
		switch (ch) {
		case 'b':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"");
			break;
		case 'c':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"");
			break;
		case 'C':
			add("\"%08.8_Ax\n\"");
			add("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ");
			add("\"  |\" 16/1 \"%_p\" \"|\\n\"");
			break;
		case 'd':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 8/2 \"  %05u \" \"\\n\"");
			break;
		case 'e':
			add(optarg);
			break;
		case 'f':
			addfile(optarg);
			break;
		case 'n':
			if ((length = atoi(optarg)) < 0) {
				fprintf(stderr,
				    _("hexdump: bad length value.\n"));
				exit(1);
			}
			break;
		case 'o':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"");
			break;
		case 's':
			if ((skip = strtol(optarg, &p, 0)) < 0) {
				fprintf(stderr,
				    _("hexdump: bad skip value.\n"));
				exit(1);
			}
			switch(*p) {
			case 'b':
				skip *= 512;
				break;
			case 'k':
				skip *= 1024;
				break;
			case 'm':
				skip *= 1048576;
				break;
			}
			break;
		case 'v':
			vflag = ALL;
			break;
		case 'x':
			add("\"%07.7_Ax\n\"");
			add("\"%07.7_ax \" 8/2 \"   %04x \" \"\\n\"");
			break;
		case '?':
			usage();
		}

	if (!fshead) {
		add("\"%07.7_Ax\n\"");
		add("\"%07.7_ax \" 8/2 \"%04x \" \"\\n\"");
	}

	*argvp += optind;
}
Ejemplo n.º 28
0
static void
blobcache_prune(void)
{
  DIR *d1, *d2;
  struct dirent *de1, *de2;
  char path[PATH_MAX];
  char path2[PATH_MAX];
  char path3[PATH_MAX];
  struct stat st;
  
  uint64_t tsize = 0, msize;
  int files = 0;
  struct cachfile_list list;

  snprintf(path, sizeof(path), "%s/blobcache", showtime_cache_path);

  if((d1 = opendir(path)) == NULL)
    return;

  LIST_INIT(&list);

  while((de1 = readdir(d1)) != NULL) {
    if(de1->d_name[0] != '.') {
      snprintf(path2, sizeof(path2), "%s/blobcache/%s",
	       showtime_cache_path, de1->d_name);

      if((d2 = opendir(path2)) != NULL) {
	while((de2 = readdir(d2)) != NULL) {
          if(de2->d_name[0] != '.') {

	    snprintf(path3, sizeof(path3), "%s/blobcache/%s/%s",
		     showtime_cache_path, de1->d_name,
		     de2->d_name);
	    
	    if(!stat(path3, &st)) {
	      addfile(&list, de1->d_name, de2->d_name, &st);
	      files++;
	      tsize += st.st_size;
	    }
	  }
	}
	closedir(d2);
      }
    }
  }
  closedir(d1);
  
  msize = blobcache_compute_size(tsize);
  
  if(files > 0) {
    struct cachefile **v, *c, *next;
    int i;

    time_t now;
    time(&now);

    for(c = LIST_FIRST(&list); c != NULL; c = next) {
      next = LIST_NEXT(c, link);

      digest_to_path(c->d, path, sizeof(path));
      int fd = open(path, O_RDONLY, 0);
      if(fd != -1) {
	uint8_t buf[4];
	
	if(read(fd, buf, 4) == 4) {
	  time_t exp = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];

	  if(exp < now) {
	    tsize -= c->size;
	    files--;
	    unlink(path);
	    LIST_REMOVE(c, link);
	    free(c);
	  }
	}
	close(fd);
      }
    }

    v = malloc(sizeof(struct cachfile_list *) * files);
    i = 0;
    LIST_FOREACH(c, &list, link)
      v[i++] = c;

    assert(i == files);

    qsort(v, files, sizeof(struct cachfile_list *), cfcmp);

    for(i = 0; i < files; i++) {
      c = v[i];
    
      if(tsize > msize) {
	digest_to_path(c->d, path, sizeof(path));
	if(!unlink(path))
	  tsize -= c->size;
      }
      free(c);
    }
    free(v);
  }


  hts_mutex_lock(&blobcache_mutex);

  blobcache_size_max = msize;
  blobcache_size_current = tsize;

  TRACE(TRACE_DEBUG, "blobcache", "Using %lld MB out of %lld MB",
	blobcache_size_current / 1000000LL, 
	blobcache_size_max     / 1000000LL);

  hts_mutex_unlock(&blobcache_mutex);
}
Ejemplo n.º 29
0
void processcommand( char *command, char *P1, char *P2, char *P3 ) {

    if( strcmp(command, "createvfs") == 0 ) {
        int size = atoi(P2);
        if( (0 == strcmp(P1,"")) || 0 == P2 ) {
            printf("createvfs_FAILURE %s \n",ERR_VFS_CREATE_00);
        } else {
            createvfs (P1,size);
        }
    }
    else if( strcmp(command, "mountvfs") == 0 ) {
        if( (0 == strcmp(P1,"")) ) {
            printf("mountvfs_FAILURE %s \n",ERR_VFS_MOUNT_05);
        } else {
            if( 1 == ui_mountFlag ) {
                printf("mountvfs_FAILURE %s \n",ERR_VFS_MOUNT_04);
            } else {
                mountvfs (P1);
            }
        }
    }
    else if( strcmp(command, "unmountvfs") == 0 ) {
        if( (0 == strcmp(P1,"")) ) {
            printf("unmountvfs_FAILURE %s \n",ERR_VFS_UNMOUNT_00);
        } else {
            if( 0 == ui_mountFlag ) {
                printf("unmountvfs_FAILURE %s \n",ERR_VFS_UNMOUNT_04);
            } else {
                unmountvfs (P1);
            }
        }
    }
    else if( strcmp(command, "makedir") == 0 ) {
        if( (0 == strcmp(P1,"")) || (0 == strcmp(P2,"")) ) {
            printf("makedir_FAILURE %s \n",ERR_VFS_MAKEDIR_00);
        } else {
            if( 0 == ui_mountFlag ) {
                printf("makedir_FAILURE %s \n",ERR_VFS_MAKEDIR_05);
            } else {
                makedir (P1,P2);
            }
        }
    }
    else if( strcmp(command, "deletedir") == 0 )
        deletedir (P1);
    else if( strcmp(command, "movedir") == 0 )
        movedir (P1,P2);
    else if( strcmp(command, "listdir") == 0 ) {
        int flag = atoi(P2);
        listdir (P1,flag,P3);
    }
    else if( strcmp(command, "addfile") == 0 )
        addfile (P1,P2,P3);
    else if( strcmp(command, "listfile") == 0 )
        listfile (P1,P2);
    else if( strcmp(command, "updatefile") == 0 )
        updatefile (P1,P2);
    else if( strcmp(command, "removefile") == 0 )
        removefile (P1);
    else if( strcmp(command, "movefile") == 0 )
        movefile (P1,P2);
    else if( strcmp(command, "copyfile") == 0 )
        copyfile (P1,P2);
    else if( strcmp(command, "exportfile") == 0 )
        exportfile (P1,P2);
    else if( strcmp(command, "searchfile") == 0 )
        searchfile (P1,P2);
    else
        printf("Ignoring invalid command %s\n", command);
}
Ejemplo n.º 30
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 );
}