当前位置: 首页>>代码示例>>C++>>正文


C++ efopen函数代码示例

本文整理汇总了C++中efopen函数的典型用法代码示例。如果您正苦于以下问题:C++ efopen函数的具体用法?C++ efopen怎么用?C++ efopen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了efopen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load

static Proto* load(const char* filename)
{
 Proto* tf;
 ZIO z;
 char source[512];
 FILE* f;
 int c,undump;
 if (filename==NULL) 
 {
  f=stdin;
  filename="(stdin)";
 }
 else
  f=efopen(filename,"r");
 c=ungetc(fgetc(f),f);
 if (ferror(f))
 {
  fprintf(stderr,"luac: cannot read from ");
  perror(filename);
  exit(1);
 }
 undump=(c==ID_CHUNK);
 if (undump && f!=stdin)
 {
  fclose(f);
  f=efopen(filename,"rb");
 }
 sprintf(source,"@%.*s",Sizeof(source)-2,filename);
 luaZ_Fopen(&z,f,source);
 tf = undump ? luaU_undump(L,&z) : luaY_parser(L,&z);
 if (f!=stdin) fclose(f);
 return tf;
}
开发者ID:Akagi201,项目名称:learning-lua,代码行数:33,代码来源:luac.c

示例2: ttyin

char ttyin(void) {
	char buf[BUFSIZ];
	FILE *efopen();
	static FILE *tty = NULL;

	if (tty == NULL) {
		tty = efopen("/dev/tty", "r");
}
	else if (fgets(buf, BUFSIZ, tty) == NULL || buf[0] =='q') {
		exit(0);
}
	else {
		return buf[0];
}
}
开发者ID:cheetah0216,项目名称:hnreader,代码行数:15,代码来源:p.c

示例3: main

int 
main(int argc, char **argv)
{
	/* Segy data constans */
	int ntr=0;		/* number of traces			*/
	char *outpar=NULL;	/* name of file holding output		*/
	FILE *outparfp=stdout;	/* ... its file pointer			*/

	initargs(argc, argv);
   	requestdoc(1);
	
	/* Get information from the first header */
	if (!gettr(&tr)) err("can't get first trace");
	if (!getparstring("outpar", &outpar))	outpar = "/dev/stdout" ;
	
	outparfp = efopen(outpar, "w");

        checkpars();
	/* Loop over traces getting a count */
	do {
		++ntr;
	} while(gettr(&tr));

	fprintf(outparfp, "%d", ntr);

	return(CWP_Exit());

}
开发者ID:JohnWStockwellJr,项目名称:SeisUnix,代码行数:28,代码来源:sutrcount.c

示例4: afa_out

int afa_out (Options * options, Alignment * alignment) {

    int i, pos;
    char * seq;
    FILE * fptr;
    char filename[BUFFLEN];
 
    sprintf (filename, "%s.patched.afa", options->outname);

    fptr = efopen (filename, "w");
    if (!fptr) return 1;
    
    for (i=0; i<alignment->number_of_seqs; i++) {
	
	fprintf ( fptr,  ">%s\n", alignment->name[i]);
	seq = alignment->sequence[i];
	
	for (pos=0; pos<alignment->length; pos++) {
	    if ( seq [pos] == '.' ) {
		/* seaview doesn't like dots */
		fprintf ( fptr,  "-");
	    } else {
		fprintf ( fptr,  "%c",  seq [pos]);
	    }
	    if ( pos%50 == 49 ) fprintf (fptr, "\n");
	}
	if ( pos%50 ) fprintf (fptr, "\n");
  
    }
    fclose (fptr);
    
    return 0;
}
开发者ID:ivanamihalek,项目名称:hypercube,代码行数:33,代码来源:hc_afa_out.c

示例5: ecalloc

/* Lê o ficheiro de configuração dos jogadores
 * Numero de baralhos e jogadores
 */
Config *read_config(char *filename)
{
	char buffer[MAX_LINE_LEN];

	Config *config = NULL;
	config = (Config *) ecalloc((size_t) 1, sizeof(Config));

	FILE *config_file = efopen(filename, "r");

    // Parametros gerais de configuração:
    // Número de jogadores e numero de baralhos
	fgets(buffer, MAX_LINE_LEN, config_file);
	sscanf(buffer, "%d-%d", &(config->num_decks), &(config->num_players));

	if (config->num_decks > 8 || config->num_decks < 4){
		fprintf(stderr, "Erro: número de baralhos invalido.\n");
		exit(EXIT_FAILURE);
	}

	if (config->num_players > 4 || config->num_players < 1) {
		fprintf(stderr, "Erro: número de jogadores invalido.\n");
		exit(EXIT_FAILURE);
	}
    // Leitura dos parâmetros de configuracão de cada jogador
	for (int i=0; fgets(buffer, MAX_LINE_LEN, config_file) != NULL && i < config->num_players; i++)
		config = read_player(buffer, config, i);

	fclose(config_file);

	return config;
}
开发者ID:joajfreitas,项目名称:blackjack,代码行数:34,代码来源:file.c

示例6: main

int
main(
	int  argc,
	char  **argv
)
{
	FILE  *fp;

	progname = *argv++;
	argc--;

	init(progname);
	if (argc)
		while (argc)  {
			fp = efopen(*argv, "r");
			plot(fp);
			fclose(fp);
			argv++;
			argc--;
		}
	else
		plot(stdin);

	if (!newpage)
		endpage();

	done();
	return(0);
}
开发者ID:Pizookies,项目名称:Radiance,代码行数:29,代码来源:psmeta.c

示例7: main

int main(int argc, char *argv[]){
  int i;
  char *version;
  Args *args;
  FILE *fp;

  version = "0.3";
  setprogname2("inspectPro");
  args = getArgs(argc, argv);
  if(args->v)
    printSplash(version);
  if(args->h || args->e)
    printUsage(version);
  if(args->numInputFiles == 0){
    fp = stdin;
    scanFile(fp, args);
  }else{
    for(i=0;i<args->numInputFiles;i++){
      fp = efopen(args->inputFiles[i],"rb");
      scanFile(fp, args);
      fclose(fp);
    }
  }
  free(args);
  free(progname());
  return 0;
}
开发者ID:CIPaGES,项目名称:InspectPro,代码行数:27,代码来源:inspectPro.c

示例8: main

int
main(
	int  argc,
	char  *argv[]
)
{
	FILE  *fp;
	int  i;

	progname = argv[0];

	pout = popen(OUTFILT, "w");

	if (argc > 1)
		for (i = 1; i < argc; i++) {
			fp = efopen(argv[i], "r");
			plot4(fp);
			fclose(fp);
		}
	else
		plot4(stdin);
	
	pglob(PEOF, 0200, NULL);

	return(pclose(pout));
}
开发者ID:MITSustainableDesignLab,项目名称:Daysim,代码行数:26,代码来源:plot4.c

示例9: efopen

char *string_file(const char *fname) {
/*
 * read file in dynamically allocated character string
 */
	FILE *in = NULL;
	char *buf = NULL, cr;
	int c;
	int buf_size = 1000, i = 0;

	/* read as ascii file */
	in = (fname == NULL) ? (FILE *) stdin : efopen(fname, "r");
	buf = (char *) emalloc(buf_size * sizeof(char));
	while ((c = fgetc(in)) != EOF) {
		cr = c;
		convert_null_to_space(&cr, fname ? fname : "stdin", NULL);
		if (i == buf_size) {
			buf_size += 1000;
			buf = (char *) erealloc(buf, buf_size * sizeof(char));
		}
		buf[i] = c;
		i++;
	}
	buf[i] = '\0'; /* close string */
	if (fname != NULL)
		efclose(in); /* close file */
	/* free unnecesary memory: */
	return (char *) erealloc(buf, (i + 1) * sizeof(char));
}
开发者ID:Andlon,项目名称:cs267FinalProject,代码行数:28,代码来源:utils.c

示例10: main

int main(int argc, char*argv[]) {

    // the graph is just a list og from to identifier pairs, one per line
    if (argc != 4) {
	fprintf (stderr, "Usage: %s  <path to graph>  <from id>  <to id>\n", argv[0]);
	exit(1);
    }
    
    // 57572 DOCK6
    // 7049 TGFBR3
    // 2263 FGFBP3
    igraph_vs_t  vertex_to; 
    igraph_integer_t vertex_from;
    vertex_from = atol(argv[2]);
    // in principle, unumber of "to" vertices is arbitrary,
    // but that is a piece of code I will write some other time
    //igraph_vs_vector_small(&vertex_to, 2263, 7049,  -1);
    igraph_vs_vector_small(&vertex_to, atol(argv[3]),  -1);
   
    igraph_t graph;
    /*The number of vertices in the graph. If smaller than the largest integer in
      the file it will be ignored. It is thus safe to supply zero here. */
    igraph_integer_t zero = 0;

    FILE * infile  =  efopen(argv[1], "r") ;
    
    igraph_bool_t directed  = IGRAPH_UNDIRECTED;
    igraph_read_graph_edgelist (&graph, infile,  zero, directed);

    /* shortest path calculation: */
    /* http://igraph.org/c/doc/igraph-Structural.html#igraph_get_all_shortest_paths
       int igraph_get_all_shortest_paths(const igraph_t *graph,
				  igraph_vector_ptr_t *res, 
				  igraph_vector_t *nrgeo,
				  igraph_integer_t from, const igraph_vs_t to,
				  igraph_neimode_t mode);
    */
    igraph_vector_ptr_t result;
    igraph_vector_t nrgeo;
    igraph_integer_t i;
    // the second argument here is the number of "to"  vertices
    igraph_vector_ptr_init (&result, 1);
    igraph_vector_init(&nrgeo, 0);
    igraph_get_all_shortest_paths (&graph, &result, &nrgeo,
			    vertex_from,  vertex_to,
			   IGRAPH_ALL);
    for (i=0; i<igraph_vector_ptr_size(&result); i++) {
	print_vector(VECTOR(result)[i]);
    }

    igraph_vector_ptr_destroy(&result);
    igraph_vs_destroy(&vertex_to);
    igraph_destroy(&graph);

    if (!IGRAPH_FINALLY_STACK_EMPTY) return 1;
  
    return 0;
}
开发者ID:ivanamihalek,项目名称:c-utils,代码行数:58,代码来源:shortest_path.c

示例11: main

int
main(int argc, char **argv)
{
	cwp_String key1,  key2;	/* x and y key header words	*/
	Value  val1,  val2;	/* ... their values		*/
	cwp_String type1, type2;/* ... their types		*/
	int index1, index2;	/* ... their indices in hdr.h	*/
	float x, y;		/* temps to hold current x & y 	*/
	cwp_String outpar;	/* name of par file		*/
	register int npairs;	/* number of pairs found	*/


	/* Hook up getpars */
	initargs(argc, argv);
	requestdoc(1);


	/* Prevent byte codes from spilling to screen */
	if (isatty(STDOUT)) err("must redirect or pipe binary output");


	/* Get parameters */
	if (!getparstring("key1", &key1))	key1 = "sx";
	if (!getparstring("key2", &key2))	key2 = "gx";

	type1 = hdtype(key1);
	type2 = hdtype(key2);

	index1 = getindex(key1);
	index2 = getindex(key2);


	/* Loop over traces */
	npairs = 0;
	while(gettr(&tr)) {

		gethval(&tr, index1, &val1);
		gethval(&tr, index2, &val2);

		x = vtof(type1, val1);
		y = vtof(type2, val2);

		efwrite(&x, FSIZE, 1, stdout);
		efwrite(&y, FSIZE, 1, stdout);

		++npairs;
	}


	/* Make parfile if needed */
	if (getparstring("outpar", &outpar))
		fprintf(efopen(outpar, "w"),
			"n=%d label1=%s label2=%s\n",
			npairs, key1, key2);

	return(CWP_Exit());
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:57,代码来源:suchart.c

示例12: treemerge

static void
treemerge(	/* merge into one file */

int  height, int nt, int nf,
PLIST  *pl,
int  (*pcmp)(),
FILE  *ofp
)
{
    FILE  *fi[NFILES], *fp;
    int  i;
    
    if (nf <= NFILES) {

	for (i = 0; i < nf; i++)
	    fi[i] = efopen(tfname(height, i + nt*NFILES), "r");
	
	if ((fp = ofp) == NULL)
	    fp = efopen(tfname(height + 1, nt), "w");
	
	pmergesort(fi, nf, pl, pcmp, fp);
	
	for (i = 0; i < nf; i++) {
	    fclose(fi[i]);
	    unlink(tfname(height, i + nt*NFILES));
	}
	if (ofp == NULL) {
	    writeof(fp);
	    fclose(fp);
	}
	
    } else {
    
        for (i = 0; i < (nf-1)/NFILES; i++)
            treemerge(height, i, NFILES, NULL, pcmp, NULL);
            
	treemerge(height, (nf-1)/NFILES, (nf-1)%NFILES + 1, pl, pcmp, NULL);

	treemerge(height + 1, 0, (nf-1)/NFILES + 1, NULL, pcmp, ofp);
            
    }

}
开发者ID:Pizookies,项目名称:Radiance,代码行数:43,代码来源:sort.c

示例13: ttyin

ttyin()	/* process response from /dev/tty (version 2) */
{
	char buf[BUFSIZ];
	FILE *efopen();
	static FILE *tty = NULL;

	if (tty == NULL)
		tty = efopen("/dev/tty", "r");
	for (;;) {
		if (fgets(buf,BUFSIZ,tty) == NULL || buf[0] == 'q')
			exit(0);
		else if (buf[0] == '!') {
			system(buf+1);	/* BUG here */
			printf("!\n");
		}
		else	/* ordinary line */
			return buf[0];
	}
}
开发者ID:harvintoledo,项目名称:hamat,代码行数:19,代码来源:ttyin2.c

示例14: main

int
main(int argc, char **argv)
{
	float fz[BUFSIZ];
	int iz=0,jz,nz=0;
	unsigned int z[BUFSIZ];
	char line[BUFSIZ],*lp, *outpar;
	FILE *infp=stdin,*outfp=stdout, *outparfp;

	unsigned int *uz = &(z[0]);

	/* Hook up getpar */
	initargs(argc, argv);
	requestdoc(1);

	/* Prevent floats from dumping on screen */
	switch(filestat(STDOUT)) {
	case BADFILETYPE:
		warn("stdout is illegal filetype");
		pagedoc();
	break;
	case TTY:
		warn("stdout can't be tty");
		pagedoc();
	break;
	default: /* rest are OK */
	break;
	}


	/* Get parameters and do set up */
	if (!getparstring("outpar", &outpar))  outpar = "/dev/tty" ;
	outparfp = efopen(outpar, "w");

	while (fgets(line,BUFSIZ,infp)!=NULL) {

		/* set pointer to beginning of line */
		lp = line;

		/* read hex digits from input line */
		for(iz=0;sscanf(lp,"%2x",&uz[iz])==1;iz++,nz++,lp+=2);

		/* convert to floats */
		for(jz=0;jz<iz;jz++)
			fz[jz] = 255-z[jz];

		/* write floats */
		fwrite(fz,sizeof(float),iz,outfp);
	}

	/* Make par file */
	fprintf(outparfp, "total number of values=%d\n",nz);

	return(CWP_Exit());
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:55,代码来源:h2b.c

示例15: doit

static void doit(int undump, char* filename)
{
 FILE* f= (filename==NULL) ? stdin : efopen(filename, undump ? "rb" : "r");
 ZIO z;
 char source[255+2];			/* +2 for '@' and '\0' */
 luaL_filesource(source,filename,sizeof(source));
 zFopen(&z,f,source);
 if (verbose) fprintf(stderr,"%s\n",source+1);
 if (undump) do_undump(&z); else do_compile(&z);
 if (f!=stdin) fclose(f);
}
开发者ID:Akagi201,项目名称:learning-lua,代码行数:11,代码来源:luac.c


注:本文中的efopen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。