コード例 #1
0
ファイル: elf.cpp プロジェクト: geomsaek/CSCI212_Ass2
// checks initial path
bool check_paths(char* custname){

	//first we check a curLib against all the paths
	int start = 0, end = 0, counter = 0;
	bool check = false;
	char path[5000];
	
	while(custname[counter] != '\0'){
		end = search_until(custname,start);

		if(custname[end] != '0'){
			cpy_string(path,custname,start,end);
			start = end + 1;
			strcat(path,"/");
			strcat(path,curLib);
			
			// exit loop when library is resolved
			if(checkfile(path) == 0){
				strcat(complete_list,curLib);
				strcat(complete_list," =>  ");
				strcat(path,"\n");
				strcat(complete_list,path);
				check = true;
				break;
			}
			strcpy(path,"");
		}
		counter = end;
	}
	
	return check;

}
コード例 #2
0
ファイル: main.c プロジェクト: JamesMarino/CSCI131
static void checkDirectory(DIR *dir, char *name)
{
	struct dirent *dp;
	
	rewinddir(dir);
	
	while ((dp = readdir(dir)) != NULL) {
		char *aname = dp->d_name;
		
		if (0 == strcmp("..", aname)) {
			continue;
		}
		
		if (0 == strcmp(".", aname)) {
			continue;
		}
		
		unsigned char entrytype = dp->d_type;
		
		if ((entrytype == DT_BLK) || (entrytype == DT_CHR) || (entrytype == DT_FIFO) || (entrytype == DT_SOCK)) {
			continue;
		}
		
		char path[1025];
		strcpy(path, name);
		strcat(path, "/");
		strcat(path, aname);
		
		struct stat finfo;
		int statresult;
		statresult = lstat(path, &finfo);
		
		if (statresult != 0) {
			perror("Stat failed for the file: ");
			exit(1);
		}
		
		if (entrytype == DT_DIR) {
			DIR *subdir;
			subdir = opendir(path);
			
			if (subdir == NULL) {
				if (errno == EACCES) {
					fprintf(stdout, "Cannot access %s\n", path);
					continue;
				} else {
					perror("Opendir failed");
					exit(1);
				}
			}
			
			checkDirectory(subdir, path);
			closedir(subdir);
		} else {
			if (entrytype == DT_REG) {
				checkfile(path);
			}
		}
	}
}
コード例 #3
0
ファイル: romident.c プロジェクト: Judder/Romident
int main(int argc, char **argv)
{
   int i, nf;

   printf("ROMIDENT v2.1\nThierry Lescot, 1998/99.\n\n");

   load_datafile(argv[0]);

   printf("DAT file revision %d.\n", g_entry);

   if (argc<2) {
      printf("Error, specify at least one file name !\n");
      return 1;
   };

   for (nf=1;nf<argc;nf++) {
      if (argv[nf][0] == '-') {
         switch(argv[nf][1]) {
            case '&':
               ident_crc(hex2int(&argv[nf][2]));
               break;
         };
      } else {
         if ((i = checkfile(argv[nf])) == -1) {
            printf("Error, '%s' doesn't exist !\n", argv[1]);
            return 1;
         };
         ident(argv[nf]);
      };
   };

   return unk;
}
コード例 #4
0
ファイル: jspell.c プロジェクト: gitpan/Lingua-Jspell
/**
 * @brief ...
 * @param filename
 */
void dofile(char *filename)
{
    struct stat statbuf;

    currentfile = filename;

    /* Checks if this is a tex file */
    det_tflag(filename);
    det_defdupchar(filename);

    if ((infile = fopen(filename, "r")) == NULL) {
		fprintf(stderr, CANT_OPEN, filename);
		sleep((unsigned) 2);
		return;
    }

    det_readonly_access(filename);
    open_outfile(&statbuf);

    quit = 0;
    changes = 0;

    checkfile();

    fclose(infile);
    fclose(outfile);

    if (!cflag)
        treeoutput();

    if (changes && !readonly)
        update_file(filename, &statbuf);
    unlink(tempfile);
}
コード例 #5
0
ファイル: upload.c プロジェクト: jungsagacity/ftp
void hourtask(int wwww,int d,int hr)
{
	char bd_std_filename[STD_FILENAME_SIZE]={0};
	char pre_filename[PRE_FILENAME_SIZE]="ACI";
	char post_filename[POST_FILENAME_SIZE]=".irt.Z";
    sprintf(bd_std_filename,"%s%04d%d_%02d%s",pre_filename,wwww,d,hr,post_filename);
    //standard file name:ACIwwwwd_HR.irt.Z
    checkfile(bd_std_filename,BD);

    int gps_week = wwww + GPS_WEEK;
	char gps_std_filename[STD_FILENAME_SIZE]={0};
    sprintf(gps_std_filename,"%s%04d%d_%02d%s",pre_filename,gps_week,d,hr,post_filename);
    //standard file name:ACIwwwwd_HR.irt.Z
    checkfile(gps_std_filename,GPS);


}
コード例 #6
0
ファイル: minipoint.cpp プロジェクト: mahdi12167/libmini
// get file
char *minipoint::getfile(const char *filename,const char *altpath)
   {
   if (checkfile(filename)!=0) return(strdup(filename));

   if (CACHE!=NULL) return(CACHE->getfile(filename,altpath));

   return(NULL);
   }
コード例 #7
0
ファイル: ft_ls.c プロジェクト: Wouterbeets/ft_ls
void	readdirectory(ls_type *lst, char *str)
{
	DIR	*dir;
	struct dirent	*sd;

	if((dir = opendir(str)) == NULL)
		ft_putstr("error");
	while ((sd = readdir(dir)) != 0)
	{
		if (lst->a != 1) 
		{
			if (sd->d_name[0] != '.')
				checkfile(sd->d_name, lst);
		}
		else
			checkfile(sd->d_name, lst);
	}
}
コード例 #8
0
ファイル: elf.cpp プロジェクト: geomsaek/CSCI212_Ass2
//connects libraries with address
bool get_replace(char complete_list[], char curLib[],char* custname) {
	
	char path[5000];
	bool check;
	
	check = check_paths(custname);
	
	// if end of array has been reached and no library has been found
	if(check == false){
		//we look into "LD_curLib_PATH"
		if(getenv("LD_curLib_PATH") != NULL)  {
			strcpy(path,getenv("LD_curLib_PATH"));
			strcat(path,"/");
			strcat(path,curLib);
			
			if(checkfile(path) == 0){
				strcat(complete_list,curLib);
				strcat(complete_list," =>  ");
				strcat(path,"\n");
				strcat(complete_list,path);
				check = true;
			}
		}
	}
	// if previous test still doesnt link
	if(check == false) {
		strcpy(path,"");
		strcat(path,"/");
		
		// look here
		strcat(path,"usr/lib/");
		strcat(path,curLib);
		if(checkfile(path) == 0){
			strcat(complete_list,curLib);
			strcat(complete_list," =>  ");
			strcat(path,"\n");
			strcat(complete_list,path);
			check = true;
		}
	}

	// return status
	return check;
}
コード例 #9
0
ファイル: language.c プロジェクト: Rambonuaa/BoundCheck4
main(int argc, char **argv)
{
	int opt, cmd = 0, rc = 0;
	char *langIDs[16];
	char *outfile = NULL;

	init_crc();
	if ((strbuf = (char *) malloc(STRBUFSIZE)) == NULL) {
		perror(argv[0]);
		exit(1);
	}
	while ((opt = getopt(argc, argv, "cxmo:")) != EOF) {
		switch (opt) {
		  case 'c': cmd = CMD_CHECK; break;
		  case 'x': cmd = CMD_EXTRACT; break;
		  case 'm': cmd = CMD_MERGE; break;
		  case 'o': outfile = optarg; break;
		  default: usage();
		}
	}
	argc -= optind; argv += optind;
	switch (cmd) {
		case CMD_EXTRACT:
			if (argc < 2)
				usage();
			rc = extract(argv[0], outfile, &argv[1]);
			break;
		case CMD_MERGE:
			if (argc < 2)
				usage();
			rc = merge(argv[0], argv[1], outfile, argv[2]);
			break;
		case CMD_CHECK:
			verbose = 1;
			if (argc == 0)
				checkfile("language.txt");
			else
				while (--argc >= 0)
					checkfile(*argv++);
			break;
		default: usage();
	}
	exit(rc);
}
コード例 #10
0
ファイル: fdf_read.c プロジェクト: Sbbrav/archives
t_point		*read_fdf(t_env *basic)
{
	char	*buffer;
	t_point	*points;

	buffer = ft_buffing(basic->fd);
	checkfile(buffer);
	points = get_point(buffer);
	return (points);
}
コード例 #11
0
ファイル: upload.c プロジェクト: jungsagacity/ftp
void daytask(int wwww,int d)
{
	char bd_std_filename[3][STD_FILENAME_SIZE]={0};
	char pre_filename[PRE_FILENAME_SIZE]="ACR";
	char post_filename[3][POST_FILENAME_SIZE]={".sp3.Z",".clk.Z",".erp.Z"};
	int i=0;
	for(i=0;i<3;i++)
	{
        sprintf(bd_std_filename[i],"%s%04d%d%s",pre_filename,wwww,d,post_filename[i]);
        //standard file name:ACUwwwwd.sp3.Z,ACUwwwwd.clk.Z,ACUwwwwd.erp.Z
        checkfile(bd_std_filename[i],BD);
	}

    int gps_week = wwww + GPS_WEEK;
	char gps_std_filename[3][STD_FILENAME_SIZE]={0};
	for(i=0;i<3;i++)
	{
        sprintf(gps_std_filename[i],"%s%04d%d%s",pre_filename,gps_week,d,post_filename[i]);
        //standard file name:ACIwwwwd_HR.irt.Z
        checkfile(gps_std_filename[i],GPS);
    }
}
コード例 #12
0
ファイル: eolcheck.c プロジェクト: bobrippling/cbin
int main(int argc, char **argv)
{
	if(argc > 1){
		int i = 1, processargs = 1;

		/*
		 * order matters - ./$0 -- -n will segfault,
		 * since argv[i][0] is accessed after inc'ing i for --
		 * , if processargs is checked second
		 */
		while(processargs && argv[i][0] == '-'){
			switch(argv[i][1]){
				case 'f':
					if(!prompt)
						usage(argv[0]);
					prompt = 0;
					append = 0; /* minor hack for fall through */

				case 'n':
					if(append)
						usage(argv[0]);
					append = 1;
					break;

				case '-':
					if(strcmp(argv[i], "--"))
						/* argv[i] isn't "--", so decrease i and exit, so that this arg is checked */
						i--;
					/* either way, process this 'file' */

				default:
					processargs = 0;
					break;
			}
			i++;
		}

		if(i >= argc)
			fputs("No input files\n", stderr);
		else
			while(i < argc)
				checkfile(argv[i++]);

	}else{
		usage(argv[0]);
	}

	return 0;
}
コード例 #13
0
ファイル: IconList.cpp プロジェクト: Mattia98/MultiMC5
void IconList::fileChanged(const QString &path)
{
	QLOG_INFO() << "Checking " << path;
	QFileInfo checkfile(path);
	if (!checkfile.exists())
		return;
	QString key = checkfile.baseName();
	int idx = getIconIndex(key);
	if (idx == -1)
		return;
	QIcon icon(path);
	if (!icon.availableSizes().size())
		return;

	icons[idx].m_images[MMCIcon::FileBased].icon = icon;
	dataChanged(index(idx), index(idx));
	emit iconUpdated(key);
}
コード例 #14
0
ファイル: terrain_init.cpp プロジェクト: bloodead/Bomberman
void	terrain_map::generate_all()
{
	int	id;
	char	buff;
	int	fd;

	fd = open("./src.txt",0);
	id = 0;

	while (id != size_map)
	{
		checkfile(fd,&buff);
		if(buff == '+')
			id_case[id].type = 0;
		else
			id_case[id].type = 1;
		id_case[id].id = id;
		id = id + 1;
	}
	printf("tout les donne entrer dans id\n");
}
コード例 #15
0
ファイル: liolib.cpp プロジェクト: Supermanu/xoreos
static int g_iofile (lua_State *L, const char *name, const char *mode) {
  if (!lua_isnoneornil(L, 1)) {
    const char *filename = lua_tostring(L, 1);
    lua_pushstring(L, name);
    if (filename) {
      FILE **pf = newfile(L);
      *pf = fopen(filename, mode);
      if (*pf == NULL) {
        lua_pushfstring(L, "%s: %s", filename, strerror(errno));
        luaL_argerror(L, 1, lua_tostring(L, -1));
      }
    }
    else {
      checkfile(L, 1);  /* check that it's a valid file handle */
      lua_pushvalue(L, 1);
    }
    lua_rawset(L, lua_upvalueindex(1));
  }
  /* return current value */
  lua_pushstring(L, name);
  lua_rawget(L, lua_upvalueindex(1));
  return 1;
}
コード例 #16
0
ファイル: sep_augxyz.c プロジェクト: nartasan/seplib
int main(int argc, char **argv){
  double lbox_1[3], lbox_2[3];
  int npart_1, npart_2;
 
  if ( argc < 3 || argc > 4 ){
    fprintf(stderr, 
	    "Usage is:  sep_augxyz <xyz-file 1> <xyz-file 2> <dist (optional)> \n");
    exit(EXIT_FAILURE);
  }

  if ( strcmp(argv[2], "start.xyz") == 0 ){
    fprintf(stderr, "Warning: ");
    fprintf(stderr, "Input argument is start.xyz wierd things will happen!\n");
  }

  FILE *fout = fopen("start.xyz", "r");
  if ( fout != NULL ){
    fprintf(stderr, "Warning: ");
    fprintf(stderr, "start.xyz exists - it will be overwritten\n");
    fclose(fout);
  }

  printpre();
  checkfile();

  double dz = 1.0;
  if ( argc==4 ) dz = atof(argv[3]);

  readxyzfile(lbox_1, &npart_1, argv[1]);
  readxyzfile(lbox_2, &npart_2, argv[2]);

  writexyzfile(lbox_1, lbox_2, npart_1, npart_2, argv[1], argv[2], dz);

  
  return 0;

}
コード例 #17
0
/*!

*/
void Reptation_method::runWithVariables(Properties_manager & prop, 
                                  System * sys, 
                                  Wavefunction_data * wfdata,
                                  Pseudopotential * psp,
                                  ostream & output)
{


  
  allocateIntermediateVariables(sys, wfdata);
  

  
  prop.setSize(wf->nfunc(), nblock, nstep, 1, 
               sys, wfdata);
  prop.initializeLog(average_var);

  Properties_manager prop_center;
  string logfile, label_temp;
  prop.getLog(logfile, label_temp);
  label_temp+="_cen";
  prop_center.setLog(logfile, label_temp);
  
  prop_center.setSize(wf->nfunc(), nblock, nstep, 1, sys, 
                      wfdata);
  prop_center.initializeLog(average_var);


  cout.precision(10);
  output.precision(10);

  Sample_point * center_samp(NULL);
  sys->generateSample(center_samp);
  
    Reptile_point pt;
  
  Array1 <Reptile> reptiles;
  int nreptile=1;
  if(!readcheck(readconfig,reptiles)) { 
    Array1 <Config_save_point> configs;
    generate_sample(sample,wf,wfdata,guidewf,nreptile,configs);
    reptiles.Resize(nreptile);
    for(int r=0; r< nreptile; r++) { 
      reptiles[r].direction=1;
      configs(r).restorePos(sample);
      wf->notify(all_electrons_move,0);
      wf->updateLap(wfdata,sample);
      for(int i=0; i< reptile_length; i++) {
        doublevar main_diffusion;
        slither(1,reptiles[r].reptile, mygather,pt,main_diffusion);
        reptiles[r].reptile.push_back(pt);
      }
    }
  }
  nreptile=reptiles.GetDim(0);

  //assert(reptile.size()==reptile_length);
  //Branch limiting variables
  //we start off with no limiting, and establish the parameters after the
  //first block.  This seems to be reasonably stable, since it's mostly
  //to keep the reptile from getting stuck.
  eref=0;
  energy_cutoff=1e16;

  //--------begin averaging..
  
  Array3 <doublevar> derivatives_block(nblock, sys->nIons(), 3);
  for(int block=0; block< nblock; block++) {

    //clock_t block_start_time=clock();
    doublevar avg_age=0;
    doublevar max_age=0;

    doublevar main_diff=0;
    double ntry=0, naccept=0;
    double nbounce=0;


    for(int r=0; r< nreptile; r++) { 
      Reptile & curr_reptile=reptiles[r];
      //Control variable that will be set to one when 
      //we change direction, which signals to recalculate
      //the wave function
      int recalc=1;
      
    for(int step=0; step< nstep; step++) {
      psp->randomize();
      if(recalc) { 
        if(curr_reptile.direction==1) 
          curr_reptile.reptile[reptile_length-1].restorePos(sample);
        else
          curr_reptile.reptile[0].restorePos(sample);          
      }
      doublevar main_diffusion;
      doublevar accept=slither(curr_reptile.direction, curr_reptile.reptile,mygather, pt,
                               main_diffusion);
      ntry++;
      if(accept+rng.ulec() > 1.0) {
        recalc=0;
        naccept++;
        main_diff+=main_diffusion;
        if(curr_reptile.direction==1) {
          curr_reptile.reptile.pop_front();
          curr_reptile.reptile.push_back(pt);
        }
        else {
          curr_reptile.reptile.pop_back();
          curr_reptile.reptile[0].branching=pt.branching;
          curr_reptile.reptile.push_front(pt);
        }
      }
      else {
        recalc=1;
        curr_reptile.direction*=-1;
        nbounce++;
      }

      for(deque<Reptile_point>::iterator i=curr_reptile.reptile.begin();
          i!=curr_reptile.reptile.end(); i++) {
        i->age++;
        avg_age+=i->age/reptile_length;
        if(i->age > max_age) max_age=i->age;
      }
      
      Properties_point avgpt;
      get_avg(curr_reptile.reptile, avgpt);
      avgpt.parent=0; avgpt.nchildren=1; //just one walker
      avgpt.children(0)=0;
      prop.insertPoint(step, 0, avgpt);
      
      int cpt=reptile_length/2+1;      
      Properties_point centpt;
      get_center_avg(curr_reptile.reptile, centpt);
      centpt.parent=0; centpt.nchildren=1;
      centpt.children(0)=0;
      
      prop_center.insertPoint(step, 0, centpt);
      
      curr_reptile.reptile[cpt].restorePos(center_samp);

      for(int i=0; i< densplt.GetDim(0); i++) 
        densplt(i)->accumulate(center_samp,1.0);
      
      
      if(center_trace != "" 
         && (block*nstep+step)%trace_wait==0) {
        ofstream checkfile(center_trace.c_str(), ios::app);
        if(!checkfile)error("Couldn't open ", center_trace);
        checkfile << "SAMPLE_POINT { \n";
        write_config(checkfile, sample);
        checkfile << "}\n\n";
      }
      
      
    }   //step
    } //reptile

    prop.endBlock();
    prop_center.endBlock();
    double ntot=parallel_sum(nstep);

    Properties_block lastblock;
    prop.getLastBlock(lastblock);
    eref=lastblock.avg(Properties_types::total_energy,0);
    energy_cutoff=10*sqrt(lastblock.var(Properties_types::total_energy,0));
    
    
    nbounce=parallel_sum(nbounce);
    naccept=parallel_sum(naccept);
    ntry=parallel_sum(ntry);
    avg_age=parallel_sum(avg_age);

    for(int i=0; i< densplt.GetDim(0); i++) 
      densplt(i)->write();

    storecheck(reptiles, storeconfig);
    main_diff=parallel_sum(main_diff);
    if(output) {
      output << "****Block " << block 
             << " acceptance " << naccept/ntry 
             << "  average steps before bounce " << ntot/nbounce
             << endl;
      output << "average age " << avg_age/ntot 
             << "   max age " << max_age <<  endl;
      output << "eref " << eref << " cutoff " << energy_cutoff << endl;
      output << "Green's function sampler:" << endl;
      sampler->showStats(output);
      prop.printBlockSummary(output);
      output << "Center averaging: " << endl;
      prop_center.printBlockSummary(output);
    }
    sampler->resetStats();

    //clock_t block_end_time=clock();
    
    //cout << mpi_info.node << ":CPU block time " 
    //// << double(block_end_time-block_start_time)/double(CLOCKS_PER_SEC)
    // << endl;

  }   //block


  if(output) {
    output << "############## Reptation Done ################\n";
    output << "End averages " << endl;
    prop.printSummary(output,average_var);
    output << "Center averages " << endl;
    prop_center.printSummary(output,average_var);


    //Print out a PDB file with one of the reptiles, for visualization purposes
    if(print_pdb) { 
      ofstream pdbout("rmc.pdb");
      pdbout.precision(3);
      pdbout << "REMARK    4 Mode COMPLIES WITH FORMAT V. 2.0\n";
      int nelectrons=sample->electronSize();

      int counter=1;
      string name="H";
      for(int e=0; e<nelectrons; e++) {
        for(deque<Reptile_point>::iterator i=reptiles[0].reptile.begin();
            i!=reptiles[0].reptile.end(); i++) {
          pdbout<<"ATOM"<<setw(7)<< counter <<" " <<name<<"   UNK     1"
            <<setw(12)<< i->electronpos[e][0]
            <<setw(8)<< i->electronpos[e][1]
            <<setw(8)<< i->electronpos[e][2]
            << "  1.00  0.00\n";
          counter++;
        }
      }
      int nions=sys->nIons();
      Array1 <doublevar> ionpos(3);
      vector <string> atomnames;
      sys->getAtomicLabels(atomnames);
      for(int i=0; i< nions; i++) {
        sys->getIonPos(i,ionpos);
        pdbout<<"ATOM"<<setw(7)<< counter <<" " <<atomnames[i]<<"   UNK     1"
          <<setw(12)<< ionpos[0]
          <<setw(8)<< ionpos[1]
          <<setw(8)<< ionpos[2]
          << "  1.00  0.00\n";
      }



      counter=1;
      for(int e=0; e<nelectrons; e++) {
        for(deque<Reptile_point>::iterator i=reptiles[0].reptile.begin();
            i!=reptiles[0].reptile.end(); i++) {
          if(i != reptiles[0].reptile.begin()) { 
            pdbout << "CONECT" << setw(5) << counter << setw(5) << counter-1 << endl;
          }
          counter++;
        }
      }
    
    }
    //------------Done PDB file

  }


  delete center_samp;
  wfdata->clearObserver();
  deallocateIntermediateVariables();
}
コード例 #18
0
ファイル: fileio1.c プロジェクト: janfj/dd-wrt
int main( int argc, char **argv )
{
    int err;

    CYG_TEST_INIT();

    // --------------------------------------------------------------

    createfile( "/foo", 202 );
    checkfile( "foo" );
    copyfile( "foo", "fee");
    checkfile( "fee" );
    comparefiles( "foo", "/fee" );

    err = mkdir( "/bar", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    listdir( "/" , false);

    copyfile( "fee", "/bar/fum" );
    checkfile( "bar/fum" );
    comparefiles( "/fee", "bar/fum" );


    err = chdir( "bar" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    err = rename( "/foo", "bundy" );
    if( err < 0 ) SHOW_RESULT( rename, err );

    listdir( "/", true );
    listdir( "" , true );

    checkfile( "/bar/bundy" );
    comparefiles("/fee", "bundy" );

    testfs_dump();

    // --------------------------------------------------------------

    err = unlink( "/fee" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    err = unlink( "fum" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    err = unlink( "/bar/bundy" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    err = chdir( "/" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    err = rmdir( "/bar" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    listdir( "/", false );

    // --------------------------------------------------------------

    err = mount( "", "/ram", "testfs" );
    if( err < 0 ) SHOW_RESULT( mount, err );

    createfile( "/ram/tinky", 456 );
    copyfile( "/ram/tinky", "/ram/laalaa" );
    checkfile( "/ram/tinky");
    checkfile( "/ram/laalaa");
    comparefiles( "/ram/tinky", "/ram/laalaa" );

    err = chdir( "/ram" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    createfile( "tinky", 678 );
    checkfile( "tinky" );

    maxfile( "dipsy" );
    checkfile( "dipsy" );
    copyfile( "dipsy", "po" );
    checkfile( "po" );
    comparefiles( "dipsy", "po" );

    testfs_dump();

    // --------------------------------------------------------------

    err = unlink( "tinky" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    err = unlink( "dipsy" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    err = unlink( "po" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    err = unlink( "laalaa" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    err = chdir( "/" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    err = umount( "/ram" );
    if( err < 0 ) SHOW_RESULT( umount, err );

    CYG_TEST_PASS_FINISH("fileio1");
}
コード例 #19
0
ファイル: sep_bcc.c プロジェクト: nartasan/seplib
int main( int argc, char **argv ){
  int numb[3];
  float gab[3], lbox[3];

  if ( argc != 8 ){
    fprintf(stderr, 
	    "Usage: sep_bcc <nx> <ny> <nz> <gabx> <gaby> <gabz> <type>\n");
    exit(EXIT_FAILURE);
  }

  printpre();
  checkfile();

  for ( int k=0; k<3; k++ ){
    numb[k] = atoi(argv[k+1]);
    gab[k]  = atof(argv[k +4]);
    lbox[k] = numb[k]*gab[k];
  }

  char type = argv[7][0];

  FILE *fout = fopen("start.xyz", "w");
  if ( fout == NULL ) {
    fprintf(stderr, "Coulnd't open file start.xyz");
    exit(EXIT_FAILURE);
  }
  
  fprintf(fout, "%d\n", numb[0]*numb[1]*numb[2]);
  fprintf(fout, "%f %f %f\n", lbox[0], lbox[1], lbox[2]);

  float c[3];
  int ngab, ngab0 = 0; 
  for (int nZ = 0; nZ < numb[2]; nZ++ ){
    c[2] = nZ*gab[2];
    ngab = ngab0;
    for ( int nY = 0; nY < numb[1]; nY++ ){
      c[1] = nY*gab[1];
      for ( int nX = 0; nX < numb[0]; nX++ ){
	c[0] = nX*gab[0];
	if (ngab == 1) c[0] += 0.5*gab[0];
	
	fprintf(fout,"%c %f %f %f 0.0 0.0 0.0 1.0 0.0\n", 
		type, c[0], c[1], c[2]); 
      }
      if (ngab == 0)
	ngab = 1;
      else 
	ngab = 0;
    }
    if (ngab0 == 0)
      ngab0 = 1;
    else 
      ngab0 = 0;
  }

  fclose(fout);
 
  printf("Wrote xyz configurational file: start.xyz\n");
 
  return 0;
}
コード例 #20
0
ファイル: auth.c プロジェクト: juanfra684/DragonFlyBSD
static int
plogin(char *user, char *passwd, char **msg, int *msglen)
{

#ifdef USE_PAM

    struct pam_conv pam_conversation;
    pam_handle_t *pamh;
    int pam_error;
/*
 * Fill the pam_conversion structure
 */
    memset (&pam_conversation, '\0', sizeof (struct pam_conv));
    pam_conversation.conv = &pam_conv;

    pam_error = pam_start ("ppp", user, &pam_conversation, &pamh);

    if (pam_error != PAM_SUCCESS) {
        *msg = MY_PAM_STRERROR (pam_error);
	return UPAP_AUTHNAK;
    }
/*
 * Define the fields for the credintial validation
 */
    pam_set_item (pamh, PAM_TTY, devnam);
    PAM_username = user;
    PAM_password = passwd;
/*
 * Validate the user
 */
    pam_error = pam_authenticate (pamh, PAM_SILENT);
    if (pam_error == PAM_SUCCESS) {
        pam_error = pam_acct_mgmt (pamh, PAM_SILENT);

	/* start a session for this user. Session closed when link ends. */
	if (pam_error == PAM_SUCCESS)
	   pam_open_session (pamh, PAM_SILENT);
    }

    *msg = MY_PAM_STRERROR (pam_error);

    PAM_username =
    PAM_password = "";
/*
 * Clean up the mess
 */
    pam_end (pamh, pam_error);

    if (pam_error != PAM_SUCCESS)
        return UPAP_AUTHNAK;
/*
 * Use the non-PAM methods directly
 */
#else /* #ifdef USE_PAM */

    struct passwd *pw;
    struct utmp utmp;
    struct timeval tp;
    char *tty;

#ifdef HAS_SHADOW
    struct spwd *spwd;
    struct spwd *getspnam();
#endif

    pw = getpwnam(user);
    endpwent();
    if (pw == NULL) {
	return (UPAP_AUTHNAK);
    }
/*
 * Check that the user is not listed in /etc/ppp/ppp.deny
 * and that the user's shell is listed in /etc/ppp/ppp.shells
 * if /etc/ppp/ppp.shells exists.
 */

    if (checkfile(_PATH_PPPDENY, user) == 1) {
	    	syslog(LOG_WARNING, "upap user %s: login denied in %s",
			user, _PATH_PPPDENY);
		return (UPAP_AUTHNAK);
    }

    if (checkfile(_PATH_PPPSHELLS, pw->pw_shell) == 0) {
	    	syslog(LOG_WARNING, "upap user %s: shell %s not in %s",
			user, pw->pw_shell, _PATH_PPPSHELLS);
		return (UPAP_AUTHNAK);
    }

#ifdef HAS_SHADOW
    spwd = getspnam(user);
    endspent();
    if (spwd) {
	/* check the age of the password entry */
	long now = time(NULL) / 86400L;

	if ((spwd->sp_expire > 0 && now >= spwd->sp_expire)
	    || ((spwd->sp_max >= 0 && spwd->sp_max < 10000)
		&& spwd->sp_lstchg >= 0
		&& now >= spwd->sp_lstchg + spwd->sp_max)) {
	    syslog(LOG_WARNING, "Password for %s has expired", user);
	    return (UPAP_AUTHNAK);
	}
	pw->pw_passwd = spwd->sp_pwdp;
    }
#endif

    /*
     * If no passwd, don't let them login.
     */
    if (pw->pw_passwd == NULL || *pw->pw_passwd == '\0'
	|| strcmp(crypt(passwd, pw->pw_passwd), pw->pw_passwd) != 0)
	return (UPAP_AUTHNAK);

    if (pw->pw_expire) {
	gettimeofday(&tp, NULL);
	if (tp.tv_sec >= pw->pw_expire) {
	    syslog(LOG_INFO, "pap user %s account expired", user);
	    return (UPAP_AUTHNAK);
	}
    }

    /* These functions are not enabled for PAM. The reason for this is that */
    /* there is not necessarily a "passwd" entry for this user. That is     */
    /* real purpose of 'PAM' -- to virtualize the account data from the     */
    /* application. If you want to do the same thing, write the entry in    */
    /* the 'session' hook.                                                  */

    /* Log in wtmp and utmp using login() */

    tty = devnam;
    if (strncmp(tty, _PATH_DEV, sizeof _PATH_DEV - 1) == 0)
	tty += 5;

    if (logout(tty))		/* Already entered (by login?) */
        logwtmp(tty, "", "");

#if defined(_PATH_LASTLOG)
    {
	    struct lastlog ll;
	    int fd;

	    if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
		lseek(fd, (off_t)(pw->pw_uid * sizeof(ll)), SEEK_SET);
		memset((void *)&ll, 0, sizeof(ll));
		time(&ll.ll_time);
		strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
		write(fd, (char *)&ll, sizeof(ll));
		close(fd);
	    }
    }
#endif

    memset((void *)&utmp, 0, sizeof(utmp));
    time(&utmp.ut_time);
    strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
    strncpy(utmp.ut_host, ":PPP", sizeof(utmp.ut_host));
    strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
    login(&utmp);		/* This logs us in wtmp too */

#endif /* #ifdef USE_PAM */

    syslog(LOG_INFO, "user %s logged in", user);
    logged_in = TRUE;

    return (UPAP_AUTHACK);
}
コード例 #21
0
ファイル: fatfs1.c プロジェクト: DavionKnight/GT873M_4F
int main( int argc, char **argv )
{
    int err;
    int existingdirents=-1;
#if defined(CYGSEM_FILEIO_BLOCK_USAGE)
    struct cyg_fs_block_usage usage;
#endif

    CYG_TEST_INIT();

    // --------------------------------------------------------------

    err = mount( "/dev/disk0/1", "/", "fatfs" );    
    if( err < 0 ) SHOW_RESULT( mount, err );    

    err = chdir( "/" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/" );
    
    listdir( "/", true, -1, &existingdirents );

    // --------------------------------------------------------------
#if defined(CYGSEM_FILEIO_BLOCK_USAGE)
    err = cyg_fs_getinfo("/", FS_INFO_BLOCK_USAGE, &usage, sizeof(usage));
    if( err < 0 ) SHOW_RESULT( cyg_fs_getinfo, err );
    diag_printf("<INFO>: total size: %6lld blocks, %10lld bytes\n",
		usage.total_blocks, usage.total_blocks * usage.block_size); 
    diag_printf("<INFO>: free size:  %6lld blocks, %10lld bytes\n",
		usage.free_blocks, usage.free_blocks * usage.block_size); 
    diag_printf("<INFO>: block size: %6u bytes\n", usage.block_size);
#endif
    // --------------------------------------------------------------

    createfile( "/foo", 20257 );
    checkfile( "foo" );
    copyfile( "foo", "fee");
    checkfile( "fee" );
    comparefiles( "foo", "/fee" );
    diag_printf("<INFO>: mkdir bar\n");
    err = mkdir( "/bar", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    listdir( "/" , true, existingdirents+3, NULL );

    copyfile( "fee", "/bar/fum" );
    checkfile( "bar/fum" );
    comparefiles( "/fee", "bar/fum" );

    diag_printf("<INFO>: cd bar\n");
    err = chdir( "bar" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/bar" );
    
    diag_printf("<INFO>: rename /foo bundy\n");    
    err = rename( "/foo", "bundy" );
    if( err < 0 ) SHOW_RESULT( rename, err );
    
    listdir( "/", true, existingdirents+2, NULL );
    listdir( "" , true, 4, NULL );

    checkfile( "/bar/bundy" );
    comparefiles("/fee", "bundy" );

#if defined(CYGSEM_FILEIO_BLOCK_USAGE)
    err = cyg_fs_getinfo("/", FS_INFO_BLOCK_USAGE, &usage, sizeof(usage));
    if( err < 0 ) SHOW_RESULT( cyg_fs_getinfo, err );
    diag_printf("<INFO>: total size: %6lld blocks, %10lld bytes\n",
		usage.total_blocks, usage.total_blocks * usage.block_size); 
    diag_printf("<INFO>: free size:  %6lld blocks, %10lld bytes\n",
		usage.free_blocks, usage.free_blocks * usage.block_size); 
    diag_printf("<INFO>: block size: %6u bytes\n", usage.block_size);
#endif
    // --------------------------------------------------------------

    diag_printf("<INFO>: unlink fee\n");    
    err = unlink( "/fee" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink fum\n");        
    err = unlink( "fum" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink /bar/bundy\n");        
    err = unlink( "/bar/bundy" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: cd /\n");        
    err = chdir( "/" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/" );
    
    diag_printf("<INFO>: rmdir /bar\n");        
    err = rmdir( "/bar" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );
    
    listdir( "/", false, existingdirents, NULL );

    // --------------------------------------------------------------

#if 0
    diag_printf("<INFO>: mkdir disk2\n");
    err = mkdir( "/disk2", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );
#else
    diag_printf("<INFO>: mount /disk2\n");    
    err = mount( "/dev/disk0/2", "/disk2", "fatfs" );    
    if( err < 0 ) SHOW_RESULT( mount, err );    
#endif
    
    listdir( "/disk2" , true, -1, &existingdirents);
        
    createfile( "/disk2/tinky", 4567 );
    copyfile( "/disk2/tinky", "/disk2/laalaa" );
    checkfile( "/disk2/tinky");
    checkfile( "/disk2/laalaa");
    comparefiles( "/disk2/tinky", "/disk2/laalaa" );

    diag_printf("<INFO>: cd /disk2\n");    
    err = chdir( "/disk2" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/disk2" );
        
    diag_printf("<INFO>: mkdir noonoo\n");    
    err = mkdir( "noonoo", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    listdir( "/disk2" , true, existingdirents+3, NULL);

    diag_printf("<INFO>: cd noonoo\n");
    err = chdir( "noonoo" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/disk2/noonoo" );
    
    createfile( "tinky", 6789 );
    checkfile( "tinky" );

    createfile( "dipsy", 34567 );
    checkfile( "dipsy" );
    copyfile( "dipsy", "po" );
    checkfile( "po" );
    comparefiles( "dipsy", "po" );

    listdir( ".", true, 5, NULL );
    listdir( "", true, 5, NULL );
    listdir( "..", true, existingdirents+3, NULL );

    // --------------------------------------------------------------

    diag_printf("<INFO>: unlink tinky\n");    
    err = unlink( "tinky" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink dipsy\n");    
    err = unlink( "dipsy" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink po\n");    
    err = unlink( "po" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: cd ..\n"); 
    err = chdir( ".." );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/disk2" );
    
    diag_printf("<INFO>: rmdir noonoo\n"); 
    err = rmdir( "noonoo" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    // --------------------------------------------------------------

    err = mkdir( "x", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );
    
    err = mkdir( "x/y", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );
    
    err = mkdir( "x/y/z", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    err = mkdir( "x/y/z/w", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );
    
    diag_printf("<INFO>: cd /disk2/x/y/z/w\n");
    err = chdir( "/disk2/x/y/z/w" );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/disk2/x/y/z/w" );

    diag_printf("<INFO>: cd ..\n");
    err = chdir( ".." );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/disk2/x/y/z" );
    
    diag_printf("<INFO>: cd .\n");
    err = chdir( "." );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/disk2/x/y/z" );

    diag_printf("<INFO>: cd ../../y\n");
    err = chdir( "../../y" );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/disk2/x/y" );

    diag_printf("<INFO>: cd ../..\n");
    err = chdir( "../.." );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/disk2" );

    diag_printf("<INFO>: rmdir x/y/z/w\n"); 
    err = rmdir( "x/y/z/w" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    diag_printf("<INFO>: rmdir x/y/z\n"); 
    err = rmdir( "x/y/z" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    diag_printf("<INFO>: rmdir x/y\n"); 
    err = rmdir( "x/y" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    diag_printf("<INFO>: rmdir x\n"); 
    err = rmdir( "x" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );
    
    // --------------------------------------------------------------

    checkcwd( "/disk2" );
    
    diag_printf("<INFO>: unlink tinky\n");    
    err = unlink( "tinky" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink laalaa\n");    
    err = unlink( "laalaa" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: cd /\n");    
    err = chdir( "/" );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/" );

    listdir( "/disk2", true, -1, NULL );
    
#if 0
    diag_printf("<INFO>: rmdir dir\n"); 
    err = rmdir( "disk2" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );
#else
    diag_printf("<INFO>: umount /disk2\n");    
    err = umount( "/disk2" );
    if( err < 0 ) SHOW_RESULT( umount, err );    
#endif
    
#ifdef CYGCFG_FS_FAT_USE_ATTRIBUTES
    // Create file
    diag_printf("<INFO>: create /foo\n");
    createfile( "/foo", 20257 );

    // Verify it is created with archive bit set
    checkattrib( "/foo", S_FATFS_ARCHIVE );

    // Make it System
    diag_printf("<INFO>: attrib -A+S /foo\n");
    err = cyg_fs_set_attrib( "/foo", S_FATFS_SYSTEM );
    if( err < 0 ) SHOW_RESULT( chmod system , err );

    // Verify it is now System
    checkattrib( "/foo", S_FATFS_SYSTEM );

    // Make it Hidden
    diag_printf("<INFO>: attrib -S+H /foo\n");
    err = cyg_fs_set_attrib( "/foo", S_FATFS_HIDDEN );
    if( err < 0 ) SHOW_RESULT( chmod system , err );

    // Verify it is now Hidden
    checkattrib( "/foo", S_FATFS_HIDDEN );

    // Make it Read-only
    diag_printf("<INFO>: attrib -H+R /foo\n");
    err = cyg_fs_set_attrib( "/foo", S_FATFS_RDONLY );
    if( err < 0 ) SHOW_RESULT( chmod system , err );

    // Verify it is now Read-only
    checkattrib( "/foo", S_FATFS_RDONLY );

    // Verify we cannot unlink a read-only file
    diag_printf("<INFO>: unlink /foo\n");
    err = unlink( "/foo" );
    if( (err != -1) || (errno != EPERM) ) SHOW_RESULT( unlink, err );

    // Verify we cannot rename a read-only file
    diag_printf("<INFO>: rename /foo bundy\n");
    err = rename( "/foo", "bundy" );
    if( (err != -1) || (errno != EPERM) ) SHOW_RESULT( rename, err );

    // Verify we cannot open read-only file for writing
    int fd;
    diag_printf("<INFO>: create file /foo\n");
    fd = open( "/foo", O_WRONLY );
    if( (err != -1) || (errno != EACCES) ) SHOW_RESULT( open, err );
    if( err > 0 ) close(fd);

    // Make it Normal
    diag_printf("<INFO>: attrib -H /foo\n");
    err = cyg_fs_set_attrib( "/foo", 0 );
    if( err < 0 ) SHOW_RESULT( chmod none , err );

    // Verify it is now nothing
    checkattrib( "/foo", 0 );

    // Now delete our test file
    diag_printf("<INFO>: unlink /foo\n");
    err = unlink( "/foo" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

#endif // CYGCFG_FS_FAT_USE_ATTRIBUTES

    maxfile("file.max");

    listdir( "/", true, -1, NULL );    
        
    diag_printf("<INFO>: unlink file.max\n");    
    err = unlink( "file.max" );
    if( err < 0 ) SHOW_RESULT( unlink, err );    
    diag_printf("<INFO>: umount /\n");    
    err = umount( "/" );
    if( err < 0 ) SHOW_RESULT( umount, err );    
    
    CYG_TEST_PASS_FINISH("fatfs1");
}
コード例 #22
0
ファイル: home.c プロジェクト: Alibaba-boonya/mile
/* Parse a VM configuration file */
static bool parse(home_data *data)
{
    FILE *cfgf = fopen(data->cfgf, "r");
    char *ret = NULL, *sp;
    char buf[1024];

    if (cfgf == NULL) {
        log_debug("Can't open %s\n", data->cfgf);
        return (false);
    }

    data->jvms = (home_jvm **)malloc(256 * sizeof(home_jvm *));

    while ((ret = fgets(buf, 1024, cfgf)) != NULL) {
        char *tmp = strchr(ret, '#');
        int pos;

        /* Clear the string at the first occurrence of '#' */
        if (tmp != NULL)
            tmp[0] = '\0';

        /* Trim the string (including leading '-' chars */
        while ((ret[0] == ' ') || (ret[0] == '\t') || (ret[0] == '-'))
            ret++;
        pos = strlen(ret);
        while (pos >= 0) {
            if ((ret[pos] == '\r') || (ret[pos] == '\n') || (ret[pos] == '\t')
                || (ret[pos] == '\0') || (ret[pos] == ' ')) {
                ret[pos--] = '\0';
            }
            else
                break;
        }
        /* Format changed for 1.4 JVMs */
        sp = strchr(ret, ' ');
        if (sp != NULL)
            *sp = '\0';

        /* Did we find something significant? */
        if (strlen(ret) > 0) {
            char *libf = NULL;
            int x = 0;

            log_debug("Found VM %s definition in configuration", ret);
            while (location_jvm_configured[x] != NULL) {
                char *orig = location_jvm_configured[x];
                char temp[1024];
                char repl[1024];
                int k;

                k = replace(temp, 1024, orig, "$JAVA_HOME", data->path);
                if (k != 0) {
                    log_error("Can't replace home in VM library (%d)", k);
                    return (false);
                }
                k = replace(repl, 1024, temp, "$VM_NAME", ret);
                if (k != 0) {
                    log_error("Can't replace name in VM library (%d)", k);
                    return (false);
                }

                log_debug("Checking library %s", repl);
                if (checkfile(repl)) {
                    libf = strdup(repl);
                    break;
                }
                x++;
            }

            if (libf == NULL) {
                log_debug("Cannot locate library for VM %s (skipping)", ret);
            }
            else {
                data->jvms[data->jnum] = (home_jvm *)malloc(sizeof(home_jvm));
                data->jvms[data->jnum]->name = strdup(ret);
                data->jvms[data->jnum]->libr = libf;
                data->jnum++;
                data->jvms[data->jnum] = NULL;
            }
        }
    }
    return (true);
}
コード例 #23
0
ファイル: home.c プロジェクト: Alibaba-boonya/mile
/* Build a Java Home structure for a path */
static home_data *build(char *path)
{
    home_data *data = NULL;
    char *cfgf = NULL;
    char buf[1024];
    int x = 0;
    int k = 0;

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

    log_debug("Attempting to locate Java Home in %s", path);
    if (checkdir(path) == false) {
        log_debug("Path %s is not a directory", path);
        return (NULL);
    }

    while (location_jvm_cfg[x] != NULL) {
        if ((k =
             replace(buf, 1024, location_jvm_cfg[x], "$JAVA_HOME",
                     path)) != 0) {
            log_error("Error replacing values for jvm.cfg (%d)", k);
            return (NULL);
        }
        log_debug("Attempting to locate VM configuration file %s", buf);
        if (checkfile(buf) == true) {
            log_debug("Found VM configuration file at %s", buf);
            cfgf = strdup(buf);
            break;
        }
        x++;
    }

    data = (home_data *)malloc(sizeof(home_data));
    data->path = strdup(path);
    data->cfgf = cfgf;
    data->jvms = NULL;
    data->jnum = 0;

    /* We don't have a jvm.cfg configuration file, so all we have to do is
       trying to locate the "default" Java Virtual Machine library */
    if (cfgf == NULL) {
        log_debug("VM configuration file not found");
        x = 0;
        while (location_jvm_default[x] != NULL) {
            char *libr = location_jvm_default[x];

            if ((k = replace(buf, 1024, libr, "$JAVA_HOME", path)) != 0) {
                log_error("Error replacing values for JVM library (%d)", k);
                return (NULL);
            }
            log_debug("Attempting to locate VM library %s", buf);
            if (checkfile(buf) == true) {
                data->jvms = (home_jvm **)malloc(2 * sizeof(home_jvm *));
                data->jvms[0] = (home_jvm *)malloc(sizeof(home_jvm));
                data->jvms[0]->name = NULL;
                data->jvms[0]->libr = strdup(buf);
                data->jvms[1] = NULL;
                data->jnum = 1;
                return (data);
            }
            x++;
        }

        return (data);
    }

    /* If we got here, we most definitely found a jvm.cfg file */
    if (parse(data) == false) {
        log_error("Cannot parse VM configuration file %s", data->cfgf);
    }

    return (data);
}
コード例 #24
0
ファイル: t_vnops.c プロジェクト: anuragpeshne/minix
static void
rename_dir(const atf_tc_t *tc, const char *mp)
{
	char pb1[MAXPATHLEN], pb2[MAXPATHLEN], pb3[MAXPATHLEN];
	struct stat ref, sb;

	if (FSTYPE_RUMPFS(tc))
		atf_tc_skip("rename not supported by file system");

	USES_DIRS;

	md(pb1, mp, "dir1");
	if (rump_sys_mkdir(pb1, 0777) == -1)
		atf_tc_fail_errno("mkdir 1");

	md(pb2, mp, "dir2");
	if (rump_sys_mkdir(pb2, 0777) == -1)
		atf_tc_fail_errno("mkdir 2");
	md(pb2, mp, "dir2/subdir");
	if (rump_sys_mkdir(pb2, 0777) == -1)
		atf_tc_fail_errno("mkdir 3");

	md(pb3, mp, "dir1/file");
	if (rump_sys_mknod(pb3, S_IFREG | 0777, -1) == -1)
		atf_tc_fail_errno("create file");
	if (rump_sys_stat(pb3, &ref) == -1)
		atf_tc_fail_errno("stat of file");

	/*
	 * First try ops which should succeed.
	 */

	/* rename within directory */
	md(pb3, mp, "dir3");
	if (rump_sys_rename(pb1, pb3) == -1)
		atf_tc_fail_errno("rename 1");
	checkfile(pb3, &ref);

	/* rename directory onto itself (two ways, should fail) */
	md(pb1, mp, "dir3/.");
	if (rump_sys_rename(pb1, pb3) != -1 || errno != EINVAL)
		atf_tc_fail_errno("rename 2");
	if (FSTYPE_ZFS(tc))
		atf_tc_expect_fail("PR kern/47656: Test known to be broken");
	if (rump_sys_rename(pb3, pb1) != -1 || errno != EISDIR)
		atf_tc_fail_errno("rename 3");

	checkfile(pb3, &ref);

	/* rename father of directory into directory */
	md(pb1, mp, "dir2/dir");
	md(pb2, mp, "dir2");
	if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL)
		atf_tc_fail_errno("rename 4");

	/* same for grandfather */
	md(pb1, mp, "dir2/subdir/dir2");
	if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL)
		atf_tc_fail("rename 5");

	checkfile(pb3, &ref);

	/* rename directory over a non-empty directory */
	if (rump_sys_rename(pb2, pb3) != -1 || errno != ENOTEMPTY)
		atf_tc_fail("rename 6");

	/* cross-directory rename */
	md(pb1, mp, "dir3");
	md(pb2, mp, "dir2/somedir");
	if (rump_sys_rename(pb1, pb2) == -1)
		atf_tc_fail_errno("rename 7");
	checkfile(pb2, &ref);

	/* move to parent directory */
	md(pb1, mp, "dir2/somedir/../../dir3");
	if (rump_sys_rename(pb2, pb1) == -1)
		atf_tc_fail_errno("rename 8");
	md(pb1, mp, "dir2/../dir3");
	checkfile(pb1, &ref);

	/* atomic cross-directory rename */
	md(pb3, mp, "dir2/subdir");
	if (rump_sys_rename(pb1, pb3) == -1)
		atf_tc_fail_errno("rename 9");
	checkfile(pb3, &ref);

	/* rename directory over an empty directory */
	md(pb1, mp, "parent");
	md(pb2, mp, "parent/dir1");
	md(pb3, mp, "parent/dir2");
	RL(rump_sys_mkdir(pb1, 0777));
	RL(rump_sys_mkdir(pb2, 0777));
	RL(rump_sys_mkdir(pb3, 0777));
	RL(rump_sys_rename(pb2, pb3));

	RL(rump_sys_stat(pb1, &sb));
	if (! FSTYPE_MSDOS(tc))
		ATF_CHECK_EQ(sb.st_nlink, 3);
	RL(rump_sys_rmdir(pb3));
	RL(rump_sys_rmdir(pb1));
}
コード例 #25
0
static void readdirectories(const char *path, struct node_s *entry)
{
  DIR *dirp;
  struct node_s *node;
  struct dirent *direntry;
  char *fullpath;

  printf("Traversing directory: %s\n", path);
  dirp = opendir(path);
  if (!dirp)
    {
      printf("  ERROR opendir(\"%s\") failed: %d\n", path, errno);
      g_nerrors++;
      return;
    }

  for (direntry = readdir(dirp); direntry; direntry = readdir(dirp))
    {
      if (strcmp(direntry->d_name, ".") == 0 || strcmp(direntry->d_name, "..") == 0)
        {
           printf("  Skipping %s\n", direntry->d_name);
           continue;
        }

      node = findindirectory(entry, direntry->d_name);
      if (!node)
        {
          printf("  ERROR: No node found for %s\n", direntry->d_name);
          g_nerrors++;
          continue;
        }

      /* Get the full path to the entry */

      sprintf(g_scratchbuffer, "%s/%s", path, direntry->d_name);
      fullpath = strdup(g_scratchbuffer);

      if (DIRENT_ISDIRECTORY(direntry->d_type))
        {
          printf("  DIRECTORY: %s/\n", fullpath);
          if (!node->directory)
            {
              printf("  -- ERROR: Expected type directory\n");
              g_nerrors++;
            }
          else
            {
              checkattributes(fullpath, node->mode, 0);
              readdirectories(fullpath, node->u.child);
              printf("Continuing directory: %s\n", path);
            }
        }
      else
        {
          printf("  FILE: %s/\n", fullpath);
          if (node->directory)
            {
              printf("  -- ERROR: Expected type file\n");
              g_nerrors++;
            }
          else
            {
              checkattributes(fullpath, node->mode, node->size);
              checkfile(fullpath, node);
            }
        }
      free(fullpath);
    }

  closedir(dirp);
}
コード例 #26
0
ファイル: ScriptEdit.cpp プロジェクト: TeoTwawki/dltcep
void CScriptEdit::OnLoadex() 
{
  char BASED_CODE *szFilter;
  CString m_text;
  CString fpath;
  int fhandle;
  int res;
  char *pos;
  
  res=OFN_FILEMUSTEXIST|OFN_ENABLESIZING|OFN_EXPLORER;
  if(readonly) res|=OFN_READONLY;
  szFilter=szFilterb;
  CMyFileDialog m_getfiledlg(TRUE, m_bcs?"bcs":"baf", m_bcs ? makeitemname(".bcs",0): makeitemname(".baf",1), res, szFilter);
  m_getfiledlg.m_ofn.nFilterIndex = m_bcs+1;

  if( m_getfiledlg.DoModal() == IDOK )
  {
    filepath = fpath = m_getfiledlg.GetPathName();
    if(checkfile(fpath,"SC") )
    {
      m_bcs=1;
      res=decompile(filepath, m_getfiledlg.GetFileTitle()); //decompile first
      if(res)
      {
        MessageBox("Cannot decompile file: "+fpath+"!","Error",MB_OK);
        return;
      }
      lastopenedoverride=fpath.Left(filepath.ReverseFind('\\'));
    }
    else
    { //remember the path when opening a script source 
      m_bcs=0;
      lastopenedscript=fpath.Left(filepath.ReverseFind('\\'));
    }
    fhandle=open(filepath, O_RDONLY|O_BINARY);
    if(fhandle<1)
    {
      MessageBox("Cannot open file!","Error",MB_OK);
      return;
    }
    readonly=m_getfiledlg.GetReadOnlyPref();
    res=filelength(fhandle);
    if(res>=0)
    {
      pos=m_text.GetBufferSetLength(res);
      if(pos)
      {
        if(read(fhandle,pos,res)!=res) res=-9;
        else res=0;
      }
      else res=-9;
    }
    m_text.ReleaseBuffer();
    close(fhandle);
    m_text_control.SetWindowText(m_text);
    switch(res)
    {
    case 0:
      if((m_bcs==1) && (editflg&REMBAF) )
      {//removing decompiled baf
        unlink(filepath);
      }
      itemname=m_getfiledlg.GetFileTitle();
      itemname.MakeUpper();
      break;
    case -9: //special error: cannot read decompiled script
      MessageBox("Cannot read script!","Error",MB_OK);
    default: //that error was already handled elsewhere
      OnNew();
      return;
    }
  }
  UpdateData(UD_DISPLAY);
  the_script.m_changed=false;
  CheckScript(WHOLE_CHECK|FORCED_CHECK);
  RefreshDialog();
}
コード例 #27
0
ファイル: pager.c プロジェクト: DanielT/NitroHack
/* quick: use cursor && don't search for "more info" */
static int do_look(boolean quick)
{
    char out_str[BUFSZ];
    char firstmatch[BUFSZ];
    int i, ans = 0, objplur = 0;
    int found;		/* count of matching syms found */
    coord cc;		/* screen pos of unknown glyph */
    boolean save_verbose;	/* saved value of flags.verbose */
    boolean from_screen;	/* question from the screen */
    struct nh_desc_buf descbuf;
    struct obj *otmp;

    if (quick) {
	from_screen = TRUE;	/* yes, we want to use the cursor */
    } else {
	i = ynq("Specify unknown object by cursor?");
	if (i == 'q') return 0;
	from_screen = (i == 'y');
    }

    if (from_screen) {
	cc.x = u.ux;
	cc.y = u.uy;
    } else {
	getlin("Specify what? (type the word)", out_str);
	if (out_str[0] == '\0' || out_str[0] == '\033')
	    return 0;

	/* the ability to specify symbols is gone: it is simply impossible to
	 * know how the window port is displaying things (tiles?) and even if
	 * charaters are used it may not be possible to type them (utf8)
	 */
	
	checkfile(out_str, NULL, TRUE, TRUE);
	return 0;
    }
    /* Save the verbose flag, we change it later. */
    save_verbose = flags.verbose;
    flags.verbose = flags.verbose && !quick;
    
    /*
     * we're identifying from the screen.
     */
    do {
	/* Reset some variables. */
	found = 0;
	out_str[0] = '\0';
	objplur = 0;

	if (flags.verbose)
	    pline("Please move the cursor to %s.",
		    what_is_an_unknown_object);
	else
	    pline("Pick an object.");

	ans = getpos(&cc, FALSE, what_is_an_unknown_object);
	if (ans < 0 || cc.x < 0) {
	    flags.verbose = save_verbose;
	    return 0;	/* done */
	}
	flags.verbose = FALSE;	/* only print long question once */

	nh_describe_pos(cc.x, cc.y, &descbuf);
	
	otmp = vobj_at(cc.x, cc.y);
	if (otmp && is_plural(otmp))
	    objplur = 1;
	
	out_str[0] = '\0';
	if (append_str(out_str, descbuf.effectdesc, 0))
	    if (++found == 1)
		strcpy (firstmatch, descbuf.effectdesc);
	
	if (append_str(out_str, descbuf.invisdesc, 0))
	    if (++found == 1)
		strcpy (firstmatch, descbuf.invisdesc);
	
	if (append_str(out_str, descbuf.mondesc, 0))
	    if (++found == 1)
		strcpy (firstmatch, descbuf.mondesc);
	
	if (append_str(out_str, descbuf.objdesc, objplur))
	    if (++found == 1)
		strcpy (firstmatch, descbuf.objdesc);
	
	if (append_str(out_str, descbuf.trapdesc, 0))
	    if (++found == 1)
		strcpy (firstmatch, descbuf.trapdesc);
	
	if (append_str(out_str, descbuf.bgdesc, 0))
	    if (!found) {
		found++; /* only increment found if nothing else was seen,
		so that checkfile can be called below */
		strcpy (firstmatch, descbuf.bgdesc);
	    }
	

	/* Finally, print out our explanation. */
	if (found) {
	    out_str[0] = highc(out_str[0]);
	    pline("%s.", out_str);
	    /* check the data file for information about this thing */
	    if (found == 1 && ans != LOOK_QUICK && ans != LOOK_ONCE &&
			(ans == LOOK_VERBOSE || !quick)) {
		checkfile(firstmatch, NULL, FALSE, ans == LOOK_VERBOSE);
	    }
	} else {
	    pline("I've never heard of such things.");
	}
    } while (!quick && ans != LOOK_ONCE);

    flags.verbose = save_verbose;

    return 0;
}
コード例 #28
0
ファイル: pager.c プロジェクト: FredrIQ/nethack4
/* quick: use cursor && don't search for "more info" */
static int
do_look(boolean quick, const struct nh_cmd_arg *arg)
{
    const char *out_str;
    const char *firstmatch;
    int i, ans = 0, objplur = 0, is_in;
    coord cc;   /* screen pos of unknown glyph */
    boolean save_verbose;       /* saved value of flags.verbose */
    boolean from_screen;        /* question from the screen */
    struct nh_desc_buf descbuf;
    struct obj *otmp;

    if (arg->argtype & CMD_ARG_OBJ) {
        from_screen = FALSE;
    } else if (quick || (arg->argtype & CMD_ARG_POS)) {
        from_screen = TRUE;     /* yes, we want to use the cursor */
    } else {
        i = ynq("Specify unknown object by cursor?");
        if (i == 'q')
            return 0;
        from_screen = (i == 'y');
    }

    if (from_screen) {
        cc.x = u.ux;
        cc.y = u.uy;
    } else {
        if (arg->argtype & CMD_ARG_OBJ) {
            static const char allowall[] = { ALL_CLASSES, 0 };
            out_str = simple_typename(getargobj(arg, allowall, "explain")->otyp);
        } else {
            out_str = getarglin(arg, "Specify what? (type the word)");
            if (out_str[0] == '\0' || out_str[0] == '\033')
                return 0;
        }

        /* the ability to specify symbols is gone: it is simply impossible to
           know how the window port is displaying things (tiles?) and even if
           charaters are used it may not be possible to type them (utf8) */

        checkfile(out_str, NULL, !(arg->argtype & CMD_ARG_OBJ), TRUE);
        return 0;
    }
    /* Save the verbose flag, we change it later. */
    save_verbose = flags.verbose;
    flags.verbose = flags.verbose && !quick;

    /* 
     * we're identifying from the screen.
     */
    do {
        /* Reset some variables. */
        firstmatch = NULL;
        objplur = 0;

        if (flags.verbose)
            pline("Please move the cursor to %s.", what_is_an_unknown_object);
        else
            pline("Pick an object.");

        ans = getargpos(arg, &cc, FALSE, what_is_an_unknown_object);
        if (ans == NHCR_CLIENT_CANCEL || cc.x < 0) {
            flags.verbose = save_verbose;
            if (flags.verbose)
                pline(quick ? "Never mind." : "Done.");
            return 0;   /* done */
        }
        flags.verbose = FALSE;  /* only print long question once */

        nh_describe_pos(cc.x, cc.y, &descbuf, &is_in);

        otmp = vobj_at(cc.x, cc.y);
        if (otmp && is_plural(otmp))
            objplur = 1;

        out_str = "";
        if (append_str(&out_str, descbuf.effectdesc, 0, 0))
            if (!firstmatch)
                firstmatch = descbuf.effectdesc;

        if (append_str(&out_str, descbuf.invisdesc, 0, 0))
            if (!firstmatch)
                firstmatch = descbuf.invisdesc;

        /* We already have a/an added by describe_mon; don't add it again,
           because that'll fail in cases like "Dudley's ghost" */
        if (append_str(&out_str, descbuf.mondesc, 1, 0))
            if (!firstmatch)
                firstmatch = descbuf.mondesc;

        if (append_str(&out_str, descbuf.objdesc, objplur, 0))
            if (!firstmatch)
                firstmatch = descbuf.objdesc;

        if (append_str(&out_str, descbuf.trapdesc, 0, 0))
            if (!firstmatch)
                firstmatch = descbuf.trapdesc;

        if (!descbuf.feature_described &&
            append_str(&out_str, descbuf.bgdesc, 0, is_in))
            if (!firstmatch)
                firstmatch = descbuf.bgdesc;

        /* Finally, print out our explanation. */
        if (firstmatch) {
            pline("%s.", msgupcasefirst(out_str));
            /* check the data file for information about this thing */
            if (firstmatch && ans != NHCR_CONTINUE &&
                (ans == NHCR_MOREINFO ||
                 ans == NHCR_MOREINFO_CONTINUE || !quick)) {
                checkfile(firstmatch, NULL, FALSE,
                          ans == NHCR_MOREINFO ||
                          ans == NHCR_MOREINFO_CONTINUE);
            }
        } else {
            pline("I've never heard of such things.");
        }
    } while (ans == NHCR_CONTINUE || ans == NHCR_MOREINFO_CONTINUE);

    flags.verbose = save_verbose;
    if (!quick && flags.verbose)
        pline("Done.");

    return 0;
}
コード例 #29
0
int main( int argc, char **argv )
{
    int err;
    //int i;
    int existingdirents=-1;

    CYG_TEST_INIT();

    // --------------------------------------------------------------

    err = mount( CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, "/", "jffs2" );
    if( err < 0 ) SHOW_RESULT( mount, err );

    err = chdir( "/" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/" );

    listdir( "/", true, -1, &existingdirents );
    if ( existingdirents < 2 )
        CYG_TEST_FAIL("Not enough dir entries\n");

    // --------------------------------------------------------------

    createfile( "/foo", 202 );
    checkfile( "foo" );
    copyfile( "foo", "fee");
    checkfile( "fee" );
    comparefiles( "foo", "/fee" );
    diag_printf("<INFO>: mkdir bar\n");
    err = mkdir( "/bar", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    listdir( "/" , true, existingdirents+3, NULL );

    copyfile( "fee", "/bar/fum" );
    checkfile( "bar/fum" );
    comparefiles( "/fee", "bar/fum" );

    diag_printf("<INFO>: cd bar\n");
    err = chdir( "bar" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/bar" );

    diag_printf("<INFO>: rename /foo bundy\n");
    err = rename( "/foo", "bundy" );
    if( err < 0 ) SHOW_RESULT( rename, err );

    listdir( "/", true, existingdirents+2, NULL );
    listdir( "" , true, 4, NULL );

    checkfile( "/bar/bundy" );
    comparefiles("/fee", "bundy" );

    // --------------------------------------------------------------

    createfile( LONGNAME1, 123 );
    checkfile( LONGNAME1 );
    copyfile( LONGNAME1, LONGNAME2 );

    listdir( "", false, 6, NULL );

    diag_printf("<INFO>: unlink " LONGNAME1 "\n");
    err = unlink( LONGNAME1 );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink " LONGNAME2 "\n");
    err = unlink( LONGNAME2 );
    if( err < 0 ) SHOW_RESULT( unlink, err );


    // --------------------------------------------------------------

    diag_printf("<INFO>: unlink fee\n");
    err = unlink( "/fee" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink fum\n");
    err = unlink( "fum" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink /bar/bundy\n");
    err = unlink( "/bar/bundy" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: cd /\n");
    err = chdir( "/" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/" );

    diag_printf("<INFO>: rmdir /bar\n");
    err = rmdir( "/bar" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    listdir( "/", false, existingdirents, NULL );

    // --------------------------------------------------------------

    diag_printf("<INFO>: mount /jffs2 \n");
    err = mount( CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, "/jffs2", "jffs2" );
    if( err < 0 ) SHOW_RESULT( mount, err );

    createfile( "/jffs2/tinky", 456 );
    copyfile( "/jffs2/tinky", "/jffs2/laalaa" );
    checkfile( "/jffs2/tinky");
    checkfile( "/jffs2/laalaa");
    comparefiles( "/jffs2/tinky", "/jffs2/laalaa" );

    diag_printf("<INFO>: cd /jffs2\n");
    err = chdir( "/jffs2" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/jffs2" );

    diag_printf("<INFO>: mkdir noonoo\n");
    err = mkdir( "noonoo", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    listdir( "." , true, existingdirents+3, NULL);

    diag_printf("<INFO>: cd noonoo\n");
    err = chdir( "noonoo" );
    if( err < 0 ) SHOW_RESULT( chdir, err );

    checkcwd( "/jffs2/noonoo" );

    createfile( "tinky", 678 );
    checkfile( "tinky" );

    createfile( "dipsy", 3456 );
    checkfile( "dipsy" );
    copyfile( "dipsy", "po" );
    checkfile( "po" );
    comparefiles( "dipsy", "po" );


    /*for(i=0;i<2048;i++) {
        diag_printf("<INFO>: churningchurningchurning................................ITERATION = %d\n", i);
        createfile( "churningchurningchurning", 4096 );
        diag_printf("<INFO>: unlink churningchurningchurning\n");
        err = unlink( "churningchurningchurning" );
        if( err < 0 ) SHOW_RESULT( unlink, err );
    }*/


    listdir( ".", true, 5, NULL );
    listdir( "", true, 5, NULL );
    listdir( "..", true, existingdirents+3, NULL );

    // --------------------------------------------------------------

    diag_printf("<INFO>: unlink tinky\n");
    err = unlink( "tinky" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink dipsy\n");
    err = unlink( "dipsy" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink po\n");
    err = unlink( "po" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: cd ..\n");
    err = chdir( ".." );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/jffs2" );

    diag_printf("<INFO>: rmdir noonoo\n");
    err = rmdir( "noonoo" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    // --------------------------------------------------------------

    err = mkdir( "x", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    err = mkdir( "x/y", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    err = mkdir( "x/y/z", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    err = mkdir( "x/y/z/w", 0 );
    if( err < 0 ) SHOW_RESULT( mkdir, err );

    diag_printf("<INFO>: cd /jffs2/x/y/z/w\n");
    err = chdir( "/jffs2/x/y/z/w" );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/jffs2/x/y/z/w" );

    diag_printf("<INFO>: cd ..\n");
    err = chdir( ".." );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/jffs2/x/y/z" );

    diag_printf("<INFO>: cd .\n");
    err = chdir( "." );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/jffs2/x/y/z" );

    diag_printf("<INFO>: cd ../../y\n");
    err = chdir( "../../y" );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/jffs2/x/y" );

    diag_printf("<INFO>: cd ../..\n");
    err = chdir( "../.." );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/jffs2" );

    diag_printf("<INFO>: rmdir x/y/z/w\n");
    err = rmdir( "x/y/z/w" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    diag_printf("<INFO>: rmdir x/y/z\n");
    err = rmdir( "x/y/z" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    diag_printf("<INFO>: rmdir x/y\n");
    err = rmdir( "x/y" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    diag_printf("<INFO>: rmdir x\n");
    err = rmdir( "x" );
    if( err < 0 ) SHOW_RESULT( rmdir, err );

    // --------------------------------------------------------------

    diag_printf("<INFO>: unlink tinky\n");
    err = unlink( "tinky" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: unlink laalaa\n");
    err = unlink( "laalaa" );
    if( err < 0 ) SHOW_RESULT( unlink, err );

    diag_printf("<INFO>: cd /\n");
    err = chdir( "/" );
    if( err < 0 ) SHOW_RESULT( chdir, err );
    checkcwd( "/" );

    diag_printf("<INFO>: umount /jffs2\n");
    err = umount( "/jffs2" );
    if( err < 0 ) SHOW_RESULT( umount, err );

    diag_printf("<INFO>: umount /\n");
    err = umount( "/" );
    if( err < 0 ) SHOW_RESULT( umount, err );

    CYG_TEST_PASS_FINISH("jffs2_1");
}
コード例 #30
0
ファイル: test.c プロジェクト: overwhelm07/systemprogramming
int main()
{

	int Val;


	mysql_init(&conn);//연결 지시자 초기화
	connection = mysql_real_connect(&conn, DB_HOST, DB_USER, DB_PASS, DB_NAME, 3306, (char *)NULL, 0);//mysql서버에 직접 접근

	if (connection == NULL){
		fprintf(stderr, "MySQL Connection Error :%s", mysql_error(&conn));
		return 1;
	}




	while (1)
	{
		icnt = checkfile();

		menulist();
		fprintf(stdout, "Menu Select = ");
		fscanf(stdin, "%d", &Val);
		getchar();

		switch (Val)
		{

		case 1:
		{
			while (1)
			{
				Datainput();
    			icnt++;
				break;
			}
			break;
		}
		case 2:{
			while (1){
				deleteData();
				icnt--;
				break;
			}
		}

		case 3:
		{
			datalist();
			break;
		}

		case 4:{
			run_server();
			break;
		}

		case 5:
		{
			printf("Program Exit!!\n");
			return 0;
		}
		default:
			return 0;
		}
	}

	return 0;
}