• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FCLOSE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: MountableDevice

/*
 * See if device can be mounted by looking in /etc/fstab.
 * If so, set device name and mount point name, and return 1,
 * otherwise return 0.
 */
static int MountableDevice(const char *name, char **mountName, char **deviceName)
{
	FILE *fp;
	char line[1024];
	char s1[1024];
	char s2[1024];
	int rc;

	fp = fopen("/etc/fstab", "r");
	if (fp == NULL) {
/*
 * /etc/fstab may be unreadable in some situations due to passwords in the
 * file.
 */
		return -1;
	}

	while (fgets(line, sizeof(line), fp) != 0) {
		rc = sscanf(line, "%1023s %1023s", s1, s2);
		if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) {
			FCLOSE(fp);
			*deviceName = estrdup(s1);
			*mountName = estrdup(s2);
			return 1;
		}
	}
	FCLOSE(fp);
	return 0;
}
开发者ID:oasynnoum,项目名称:php-eject,代码行数:34,代码来源:eject.c


示例2: DEHT_freeResources

static void DEHT_freeResources(DEHT * ht, bool_t removeFiles)
{
	TRACE_FUNC_ENTRY();

	CHECK (NULL != ht);

	(void) fflush(ht->keyFP);
	FCLOSE(ht->keyFP);
	(void) fflush(ht->dataFP);
	FCLOSE(ht->dataFP);

	/* free ht cache if present */
	FREE(ht->hashTableOfPointersImageInMemory);
	FREE(ht->hashPointersForLastBlockImageInMemory);
	FREE(ht->userBuf);

	if (removeFiles) {
		/* attempt to remove bad files. Errors are silenced */
		CHECK(DEHT_removeFilesInternal(ht));
	}

	/* finally, free the ht itself */
	FREE(ht);

	goto LBL_CLEANUP;

LBL_ERROR:
	/* do nothing special - just quit */
	TRACE_FUNC_ERROR();

LBL_CLEANUP:
	/* bye */
	TRACE_FUNC_EXIT();
	return;
}
开发者ID:itn0x2e,项目名称:TestProj21218,代码行数:35,代码来源:DEHT.c


示例3: fileCopy

/******************************************************************************
 * fileCopy:
 * Copy the file specified by "src" to the file specified by "dst". Error
 * checking is taken care of by the caplib functions (ie FOPEN, FWRITE, etc) */
void fileCopy(const char *src, const char *dst)
{
   char buffer[BUFFER_SIZE];
   FILE *srcFp;
   FILE *dstFp;
   unsigned int amount;

   srcFp = FOPEN( src, "rb" );
   dstFp = FOPEN( dst, "wb" );

   do {
      amount = fread( buffer, sizeof(char), BUFFER_SIZE, srcFp );
      if (amount) {
         int a = fwrite( buffer, sizeof(char), amount, dstFp );
	 if (a<amount) {
	   asfPrintError("Error copying file %s -> %s\n"
			 "Only %d of %d bytes written.\n%s\n",
			 src, dst, a, amount, strerror(errno));
	 }
      }
   /* when amount read is < BUFSZ, copy is done */
   } while (amount == BUFFER_SIZE);

   FCLOSE(srcFp);
   FCLOSE(dstFp);
}
开发者ID:glshort,项目名称:MapReady,代码行数:30,代码来源:fileUtil.c


示例4: floats_to_bytes_from_file_ext

void floats_to_bytes_from_file_ext(const char *inFile, const char *outFile,
  char *band, float mask, scale_t scaling, float scale_factor)
{
  FILE *fp;
  meta_parameters *meta;
  float *float_data;
  unsigned char *byte_data;
  int ii, band_number;
  long long pixel_count;
  long offset;

  meta = meta_read(inFile);
  band_number = (!band || strlen(band) == 0 || strcmp(band, "???")==0) ? 0 :
    get_band_number(meta->general->bands, meta->general->band_count, band);
  pixel_count = meta->general->line_count * meta->general->sample_count;
  offset = meta->general->line_count * band_number;
  float_data = (float *) MALLOC(sizeof(float) * pixel_count);
  fp = FOPEN(inFile, "rb");
  get_float_lines(fp, meta, offset, meta->general->line_count, float_data);
  FCLOSE(fp);
  byte_data = floats_to_bytes_ext(float_data, pixel_count, mask, scaling,
    scale_factor);
  for (ii=0; ii<pixel_count; ii++)
    float_data[ii] = (float) byte_data[ii];
  meta->general->data_type = ASF_BYTE;
  meta_write(meta, outFile);
  fp = FOPEN(outFile, "wb");
  put_float_lines(fp, meta, offset, meta->general->line_count, float_data);
  FCLOSE(fp);
  FREE(float_data);
  FREE(byte_data);
  meta_free(meta);
}
开发者ID:rudigens,项目名称:ASF_MapReady,代码行数:33,代码来源:scaling.c


示例5: isArcList

static int isArcList(const char *sensor, const char *file)
{
    if (!file)
        return FALSE;
    if (!strstr(file, "arclist"))
        return FALSE;
    if (!fileExists(file))
        return FALSE;

    FILE *fp = FOPEN(file, "r");
    if (!fp)
        return FALSE;

    char line[1024];
    if (fgets(line, 1024, fp) == NULL) {
        FCLOSE(fp);
        return FALSE;
    }

    FCLOSE(fp);
    if (!strstr(line, sensor))
        return FALSE;

    return TRUE;
}
开发者ID:talogan,项目名称:ASF_MapReady,代码行数:25,代码来源:fetch_prc_stvec.c


示例6: write_qm_name

/*********************************************************************
 Write the actual qmaster into the master_file
 -> master_file and master_host
 <- return -1   error in err_str
            0   means OK
  
   NOTES
      MT-NOTE: write_qm_name() is MT safe
 *********************************************************************/
int write_qm_name(
const char *master_host,
const char *master_file,
char *err_str 
) {
   FILE *fp;

   if (!(fp = fopen(master_file, "w"))) {
      if (err_str)
         sprintf(err_str, MSG_GDI_OPENWRITEMASTERHOSTNAMEFAILED_SS, 
                 master_file, strerror(errno));
      return -1;
   }

   if (fprintf(fp, "%s\n", master_host) == EOF) {
      if (err_str)
         sprintf(err_str, MSG_GDI_WRITEMASTERHOSTNAMEFAILED_S , 
                 master_file);
      FCLOSE(fp);
      return -1;
   } 

   FCLOSE(fp);
   return 0;
FCLOSE_ERROR:
   return -1;
}
开发者ID:HPCKP,项目名称:gridengine,代码行数:36,代码来源:qm_name.c


示例7: FOPEN

//テキストファイルの読み込み
bool TextAnalyseW::load( const char *path )
{
	FILEPOINTER fp;
	unsigned char temp[2];

	if( enable ) release();

	fp = FOPEN( path );
	if( fp == 0 ) return false;

	FREAD( temp, 2, fp );
	if( temp[0] != 0xff || temp[1] != 0xfe )
	{
		FCLOSE( fp );
		return false;
	}

	FSIZE( path, fp, strsize );
	strsize = ( strsize - 2 ) / sizeof( wchar_t );
	buffer = new wchar_t[strsize + 1];
	FREAD( buffer, strsize * sizeof( wchar_t ), fp );
	FSEEK( fp, 2, SEEK_SET );
	FCLOSE( fp );
	buffer[strsize] = L'\0';

	enable = true;
	mem    = false;
	pos    = buffer;
	last   = buffer + strsize;

	return true;
}
开发者ID:monokura,项目名称:csharp,代码行数:33,代码来源:TextAnalyse.cpp


示例8: host_in_file

/*----------------------------------------------------------------------
 * host_in_file
 * look if resolved host is in "file"
 * return  
 *         0 if present 
 *         1 if not
 *        -1 error occured
 *----------------------------------------------------------------------*/
static int host_in_file(
const char *host,
const char *file 
) {
   FILE *fp;
   char buf[512], *cp;

   DENTER(TOP_LAYER, "host_in_file");

   fp = fopen(file, "r");
   if (!fp) {
      DRETURN(-1);
   }

   while (fgets(buf, sizeof(buf), fp)) {
      for (cp = strtok(buf, " \t\n,"); cp; cp = strtok(NULL, " \t\n,")) {
         char* resolved_host = NULL;
         cl_com_cached_gethostbyname(cp,&resolved_host,NULL,NULL,NULL);
         if (resolved_host) {
            if (!sge_hostcmp(host, resolved_host )) {
               FCLOSE(fp);
               sge_free(&resolved_host);
               DRETURN(0);
            }
            sge_free(&resolved_host);
         }
      }      
   }

   FCLOSE(fp);
   DRETURN(1);

FCLOSE_ERROR:
   DRETURN(0);
}
开发者ID:StephenDennis,项目名称:gridengine,代码行数:43,代码来源:shadowd.c


示例9: extract_fastfile

int extract_fastfile(char * infilename, char * outfilename) {
    FILE *fd,
         *fdo  = NULL;

    uint32_t inlen,
             outlen;
    int i,
        files;

    char *file_input,
         *file_output,
         *file_offset;

    setbuf(stdout, NULL);
    setbuf(stderr, NULL);
    file_input  = infilename;
    file_output = outfilename;
    file_offset = "0x15";

    printf("Extracting fastfile: %s\n", file_input);
    fd = fopen(file_input, "rb");
    if(!fd) std_err();

    if(minzip > INSZ) minzip = INSZ;
    if(minzip < 1)    minzip = 1;

    in       = malloc(INSZ);
    out      = malloc(OUTSZ);
    filebuff = malloc(FBUFFSZ);
    if(!in || !out || !filebuff) std_err();

    offset = get_num(file_offset);  // do not skip, needed for buffseek
    buffseek(fd, offset, SEEK_SET);

    z.zalloc = (alloc_func)0;
    z.zfree  = (free_func)0;
    z.opaque = (voidpf)0;
    if(inflateInit2(&z, zipwbits) != Z_OK) zlib_err(Z_INIT_ERROR);

    fdo = save_file(file_output);
    unzip(fd, &fdo, &inlen, &outlen);
    FCLOSE(fdo)

    printf("\n"
        "%u bytes compressed\n"
        "%u bytes extracted\n",
        inlen, outlen);

    FCLOSE(fdo)
    FCLOSE(fd)
    inflateEnd(&z);
    free(in);
    free(out);
    free(filebuff);
    return(0);
}
开发者ID:JordanShinigami,项目名称:mw2ffex,代码行数:56,代码来源:extract.c


示例10: ingest_polarimetry_data

static void ingest_polarimetry_data(char *inFile, char *inBaseName, 
				    char *outFile, char band, int create)
{
  FILE *fpIn, *fpOut;
  meta_parameters *meta = NULL;
  char tmp[10];
  int ii, kk;
  float *power = NULL;
  char *byteBuf = NULL;
  
  fpIn = FOPEN(inFile, "rb");
  append_ext_if_needed(outFile, ".img", NULL);
  if (create)
    fpOut = FOPEN(outFile, "wb");
  else
    fpOut = FOPEN(outFile, "ab");
  
  if (create) {
    meta = import_airsar_meta(inFile, inBaseName, TRUE);
    meta->general->data_type = REAL32;
    meta->general->band_count = 1;
    sprintf(meta->general->bands, "AMP-%c", band);
    meta->general->image_data_type = IMAGE_LAYER_STACK;
  }
  else {
    meta = meta_read(outFile);
    meta->general->band_count += 1;
    sprintf(tmp, ",AMP-%c", band);
    strcat(meta->general->bands, tmp);
  }      

  power = (float *) MALLOC(sizeof(float)*meta->general->sample_count);
  byteBuf = (char *) MALLOC(sizeof(char)*10);
  airsar_header *header = read_airsar_header(inFile);
  long offset = header->first_data_offset;
  FSEEK(fpIn, offset, SEEK_SET);
  for (ii=0; ii<meta->general->line_count; ii++) {
    for (kk=0; kk<meta->general->sample_count; kk++) {
      FREAD(byteBuf, sizeof(char), 10, fpIn);
      power[kk] = sqrt(((float)byteBuf[1]/254.0 + 1.5) * pow(2, byteBuf[0]));
    }
    put_float_line(fpOut, meta, ii, power);
    asfLineMeter(ii, meta->general->line_count);
  }
  FCLOSE(fpIn);
  FCLOSE(fpOut);
  meta_write(meta, outFile);
  if (power)
    FREE(power);
  if (byteBuf)
    FREE(byteBuf);
  if (meta)
    meta_free(meta);
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:54,代码来源:asf_airsar_import.c


示例11: generate

void generate(char* source, char* destination){
    FILE *ip,*op;
	printf("File to work on : %s\n",source);
    ip = FOPEN(source,"rb");
    op = FOPEN(destination,"ab");
    unsigned long len;
    
    unsigned long offset=0;
    char *buf = NULL, *buf_orig = NULL, *buf_read=NULL;
    
    // Opening input and output file
    char header[MAX_FILE_NAME];
    if(verbose){
        strcpy(header,"String, File Name, md5, offset, size \n");
        FWRITE(header, "header", op);
    }
    
    if((buf = (char*)malloc(4*1024)) == NULL){
        printf("Error in allocating memory");
    }
    buf_orig=buf;
    buf_read = buf;
    while((len=fread(buf,1,RDLEN,ip))!=0){
        // Generate MD5 here
        char out[MD5_DIGEST_LENGTH*2+1];
        getMD5(buf,out,len);
        if(verbose){
            FWRITE(buf_read, "buf",op);
            FWRITE(",",",",op);
        }
        if(fileNameRequired){
            FWRITE(source, "fileName",op);
            FWRITE(",",",",op);
        }
        FWRITE(out,"md5value",op);
        FWRITE(",",",",op);
        
        char offset_str[MAX_BUF_LEN];
        sprintf(offset_str, "%lu",offset);
        FWRITE(offset_str,"offset",op);
        FWRITE(",",",",op);
        
        char size_str[MAX_BUF_LEN];
        sprintf(size_str, "%lu",len);
        FWRITE(size_str,"size",op);
        FWRITE("\n","New Line",op);
        
        offset += len;
    }
    free(buf);
    FCLOSE(op);
    FCLOSE(ip);
    
}
开发者ID:AdityaKotwal,项目名称:Dedup_Project,代码行数:54,代码来源:main.c


示例12: DENTER

char *qmonReadText(const char *filename, lList **alpp)
{
   char *text = NULL;
   SGE_STRUCT_STAT statb;
   FILE *fp = NULL;

   DENTER(GUI_LAYER, "qmonReadText");

   if (filename == NULL) {
      answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
                              "No filename specified");
      DRETURN(NULL);
   }

   /* 
   ** make sure the file is a regular text file and open it 
   */
   if (SGE_STAT(filename, &statb) == -1 
       || (statb.st_mode & S_IFMT) != S_IFREG 
       || !(fp = fopen(filename, "r"))) {
      answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
                      MSG_FILE_OPENFAILED_S, filename);
      DRETURN(NULL);
   }

   /* 
   ** put the contents of the file in the Text widget by allocating
   ** enough space for the entire file, reading the file into the
   ** allocated space, and using XmTextFieldSetString() to show the file.
   */
   if ((text = XtMalloc((unsigned)(statb.st_size + 1))) == NULL) {
      answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
                              "%s", MSG_MEMORY_MALLOCFAILED);
      FCLOSE(fp);
      DRETURN(NULL);
   }

   if (!fread(text, sizeof (char), statb.st_size + 1, fp)) {
      answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
                              MSG_FILE_FREADFAILED_SS, filename, strerror(errno));
   }

   text[statb.st_size] = 0; /* be sure to NULL-terminate */

   FCLOSE(fp);
   DRETURN(text);

FCLOSE_ERROR:
   XtFree(text);
   answer_list_add_sprintf(alpp, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
                           MSG_FILE_NOCLOSE_SS, filename, strerror(errno));
   DRETURN(NULL);
}
开发者ID:valhallasw,项目名称:son-of-gridengine,代码行数:53,代码来源:qmon_file.c


示例13: get_qmaster_heartbeat

/*--------------------------------------------------------------
 * Name:   get_qmaster_heartbeat
 * Descr:  get number found in qmaster heartbeat file
 * Return: > 0 number found in given heartbeat file 
 *         -1   can't open file 
 *         -2   can't read entry
 *         -3   read timeout
 *         -4   fclose error
 *-------------------------------------------------------------*/
int get_qmaster_heartbeat( char *file, int read_timeout ) {
   FILE *fp   = NULL;
   int hb     = 0; 
   struct timeval start_time;
   struct timeval end_time;
   unsigned long read_time;

   DENTER(TOP_LAYER, "get_qmaster_heartbeat");

   if (file == NULL) {
      ERROR((SGE_EVENT, SFNMAX, MSG_HEART_NO_FILENAME));
      DEXIT;
      return -1;
   }

   gettimeofday(&start_time,NULL);

   fp = fopen(file, "r");
   if (!fp) {
      ERROR((SGE_EVENT, MSG_HEART_CANNOTOPEN_SS, file, strerror(errno))); 
      DEXIT;
      return -1;
   }

   if (fscanf(fp, "%d", &hb) != 1) {
      FCLOSE(fp);
      ERROR((SGE_EVENT, MSG_HEART_CANNOT_READ_FILE_S, strerror(errno)));
      DEXIT;
      return -2;
   }

   FCLOSE(fp);

   /* This is only for testsuite testing */
   if (sge_testmode_timeout_value > 0 && hb == sge_testmode_timeout_at_heartbeat ) {
      sleep(sge_testmode_timeout_value);
   }

   gettimeofday(&end_time,NULL);
   read_time = end_time.tv_sec - start_time.tv_sec;
   if (read_time > read_timeout) {
      ERROR((SGE_EVENT, MSG_HEART_READ_TIMEOUT_S, file));
      DEXIT;
      return -3;
   }

   DEXIT;
   return hb;
FCLOSE_ERROR:
   ERROR((SGE_EVENT, MSG_HEART_CLOSE_ERROR_SS, file, strerror(errno)));
   DEXIT;
   return -4;
}
开发者ID:HPCKP,项目名称:gridengine,代码行数:62,代码来源:qmaster_heartbeat.c


示例14: uninitRepair

void uninitRepair (PROG_INFO *prog_struct, BLOCK_INFO *block_struct) {
  /*
  **  If output was sent to a file, then put an end of file marker
  **  on the prelude file and close both the seq and prel files.
  */
  if (prog_struct -> prel_file != NULL) {
    writeBits (prog_struct -> prel_file, 1, 1, R_FALSE);
    writeBits (prog_struct -> prel_file, 0, 0, R_FALSE);
    writeBits (prog_struct -> prel_file, 0, 0, R_FALSE);
    writeBits (prog_struct -> prel_file, 0, 0, R_TRUE);

    FCLOSE (prog_struct -> seq_file);
    FCLOSE (prog_struct -> prel_file);
    if (prog_struct -> prel_text_file != NULL) {
      FCLOSE (prog_struct -> prel_text_file);
    }

  }
  
#ifdef DEBUG
    fprintf (stderr, "\nOverall Statistics:\n\n");
    fprintf (stderr, "Input filename:  %s\n", prog_struct -> base_filename != NULL ? prog_struct -> base_filename : "N/A");
    fprintf (stderr, "Input file size:  %d\n", prog_struct -> base_filename != NULL ? prog_struct -> in_file_size : 0);
    fprintf (stderr, "Total number of phrases:  %d\n", prog_struct -> total_num_phrases);
    fprintf (stderr, "Total number of blocks:  %d\n", prog_struct -> total_blocks);
    fprintf (stderr, "Total sequence length:  %d\n", prog_struct -> total_num_symbols);
    if (prog_struct -> prel_text_file != NULL) {
      fprintf (stderr, "Average length of phrases:  %f per phrase\n", (R_DOUBLE) prog_struct -> total_sum_phrase_length / (R_DOUBLE) prog_struct -> total_num_phrases);
      fprintf (stderr, "The longest phrases was:\n");
      fprintf (stderr, "\tphrase number:  %d\n", prog_struct -> max_longest_phrase_num);
      fprintf (stderr, "\tblock number:  %d\n", prog_struct -> max_longest_phrase_block);
      fprintf (stderr, "\tphrase length:  %d\n", prog_struct -> max_longest_phrase_length);
    }

    fprintf (stderr, "\nMaximum for one phrase hierarchy:\n");
    fprintf (stderr, "\tNumber of primitives and phrases:  %d\n", prog_struct -> maximum_total_num_phrases);
    fprintf (stderr, "\tGeneration:  %d\n", prog_struct -> maximum_generations + 1);
                                   /*  Add 1 since generation is 0-based  */
    fprintf (stderr, "\tNumber of primitives:  %d\n", prog_struct -> maximum_primitives);
#endif

  /*  Must add 1 to maximum_generations since it is 0-based  */
  if (prog_struct -> verbose_level == R_TRUE) {
    fprintf (stderr, "-------------------------------------------------------------------------\n");
    fprintf (stderr, "%5u\t%5u\t%7u\t  %15u\t%11u\t%7u\n", prog_struct -> total_blocks, prog_struct -> total_num_prims, prog_struct -> total_num_phrases, prog_struct -> total_num_prims + prog_struct -> total_num_phrases, prog_struct -> maximum_generations + 1, prog_struct -> total_num_symbols);
  }

  wfree (prog_struct -> seq_nodelist);
  wfree (prog_struct -> progname);
  wfree (prog_struct -> base_filename);

  return;
}
开发者ID:rwanwork,项目名称:Re-Pair,代码行数:53,代码来源:repair.c


示例15: sge_peclose

/****** uti/stdio/sge_peclose() ***********************************************
*  NAME
*     sge_peclose() -- pclose() call which is suitable for sge_peopen()
*
*  SYNOPSIS
*     int sge_peclose(pid_t pid, FILE *fp_in, FILE *fp_out, 
*                     FILE *fp_err, struct timeval *timeout)
*
*  FUNCTION
*     ???
*
*  INPUTS
*     pid_t pid               - pid returned by peopen()
*     FILE *fp_in
*     FILE *fp_out
*     FILE *fp_err
*     struct timeval *timeout
*
*  RESULT
*     int - exit code of command or -1 in case of errors
*
*  SEE ALSO
*     uti/stdio/peopen()
*
*  NOTES
*     MT-NOTE: sge_peclose() is MT safe
******************************************************************************/
int sge_peclose(pid_t pid, FILE *fp_in, FILE *fp_out, FILE *fp_err,
                struct timeval *timeout)
{
   int i, status;
 
   DENTER(TOP_LAYER, "sge_peclose");
 
   if (fp_in != NULL) {
      FCLOSE(fp_in);
   }
   if (fp_out != NULL) {
      FCLOSE(fp_out);
   }
   if (fp_err != NULL) {
      FCLOSE(fp_err);
   }  

   do {
      i = waitpid(pid, &status, timeout?WNOHANG:0);
      if (i==-1) {
         DEXIT;
         return -1;
      }
      if (i==0) { /* not yet exited */
         if (timeout->tv_sec == 0) {
#ifdef WIN32 /* kill not called */
            /* CygWin has no kill command */
            DPRINTF(("killing not yet implemented\n"));
            timeout = NULL;
            /* kill(pid, SIGKILL); */
#else
            DPRINTF(("killing\n"));
            timeout = NULL;
            kill(pid, SIGKILL);
#endif /* WIN32 */
         } else {
            DPRINTF(("%d seconds waiting for exit\n", timeout->tv_sec));
            sleep(1);
            timeout->tv_sec -= 1;
         }
      }
   } while (i != pid);
 
   if (status & 0xff) {    /* terminated by signal */
      DEXIT;
      return -1;
   }
 
   DEXIT;
   return (status&0xff00) >> 8;  /* return exitcode */
FCLOSE_ERROR:
   return -1;
}
开发者ID:ricrogz,项目名称:gridscheduler,代码行数:80,代码来源:sge_stdio.c


示例16: reset_colors

void reset_colors( char_data * ch )
{
   if( !ch->isnpc(  ) )
   {
      char filename[256];

      snprintf( filename, 256, "%s%s", COLOR_DIR, "default" );
      if( exists_file( filename ) )
      {
         FILE *fp;
         int max_colors = 0;

         if( !( fp = fopen( filename, "r" ) ) )
         {
            memcpy( &ch->pcdata->colors, &default_set, sizeof( default_set ) );
            return;
         }

         while( !feof( fp ) )
         {
            char *word = fread_word( fp );

            if( !str_cmp( word, "MaxColors" ) )
            {
               max_colors = fread_number( fp );
               continue;
            }

            if( !str_cmp( word, "Colors" ) )
            {
               for( int x = 0; x < max_colors; ++x )
                  ch->pcdata->colors[x] = fread_number( fp );
               continue;
            }

            if( !str_cmp( word, "End" ) )
            {
               FCLOSE( fp );
               return;
            }
         }
         FCLOSE( fp );
         return;
      }
      else
         memcpy( &ch->pcdata->colors, &default_set, sizeof( default_set ) );
   }
   else
      log_printf( "%s: Attempting to reset NPC colors: %s", __func__, ch->short_descr );
}
开发者ID:carriercomm,项目名称:AFKMud,代码行数:50,代码来源:color.cpp


示例17: main

int main(int argc, char** argv)
{
  int result = -1;
  Cookie cookie;

  memset(&cookie, 0, sizeof(Cookie));

  next_file(&cookie);

  for (;;)
  {
    uint8_t name_size;
    char* name = NULL;

#if 0
    printf("Volume %i, offset 0x%08lx\n", cookie.index, ftell(cookie.input_file));
#endif
    
    if (sizeof(name_size) != reader(&name_size, sizeof(name_size), &cookie))
      break;

    name = malloc(MAX_FILENAME_SIZE);

    if (MAX_FILENAME_SIZE != reader(name, MAX_FILENAME_SIZE, &cookie))
    {
      fprintf(stderr, "read name failed\n");
      break;
    }

    name[name_size] = '\0';
    printf("extracting: %s\n", name);

    cookie.output_file = fopen(name, "w");

    result = dynamite_explode(reader, writer, &cookie);

    FCLOSE(cookie.output_file);

    if (DYNAMITE_SUCCESS != result)
    {
      fprintf(stderr, "Error %i\n", result);
      break;
    }
  }

  FCLOSE(cookie.input_file);
  FCLOSE(cookie.output_file);
  return result;
}
开发者ID:twogood,项目名称:dynamite,代码行数:49,代码来源:queen_extract.c


示例18: dem_to_mask

int
dem_to_mask(char *inDemFile, char *outMaskFile, float cutoff)
{
    meta_parameters *inDemMeta = meta_read(inDemFile);
    meta_parameters *outDemMeta = meta_read(inDemFile);

    // out metadata will differ from in only in the data type
    outDemMeta->general->data_type = ASF_BYTE;

    int x_size = inDemMeta->general->sample_count;
    int y_size = inDemMeta->general->line_count;

    float *maskbuffer = MALLOC(sizeof(float) * x_size);
    float *floatbuffer = MALLOC(sizeof(float) * x_size);

    FILE *in = fopenImage(inDemFile, "rb");
    FILE *out = fopenImage(outMaskFile, "wb");

    float mv = masked_value();
    float umv = unmasked_value();

    int y,x;
    for (y=0; y<y_size; y++) 
    {
        get_float_line(in, inDemMeta, y, floatbuffer);

        for (x=0; x < x_size; x++)            
            maskbuffer[x] = floatbuffer[x] <= cutoff ? mv : umv;

        put_float_line(out, outDemMeta, y, maskbuffer);
        asfLineMeter(y, y_size);
    }

    FCLOSE(in);
    FCLOSE(out);

    FREE(floatbuffer);
    FREE(maskbuffer);

    meta_write(outDemMeta, outMaskFile);

    meta_free(inDemMeta);
    meta_free(outDemMeta);

    asfPrintStatus("Created Mask file '%s' from DEM '%s'.\n",
                   outMaskFile, inDemFile);

    return 0;
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:49,代码来源:mfd.c


示例19: FGETS

STATICFNDEF char *read_table(char *b, int l, FILE *f)
{
	char	*t;
	int	fclose_res;

	ext_source_column = 0;
	FGETS(b, l, f, t);
	if (NULL == t)
	{
		if (0 != ferror(f))
		{
			FCLOSE(f, fclose_res);
			/* Expand error message */
			rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) errno);
		} else
			assert(feof(f) != 0);
	} else
	{
		/* Unfortunately, fgets does not strip the NL, we will do it for it */
		for (ext_source_line_len = 0; *t ; t++)
		{
			ext_source_line[ext_source_line_len++] = *t;
			if (CR == *t)
			{
				*t = 0;
				ext_source_line_num += 1;
				break;
			}
		}
	}
	return t;
}
开发者ID:ChristopherEdwards,项目名称:fis-gtm,代码行数:32,代码来源:exttab_parse.c


示例20: meta_read

meta_parameters *read_asf_meta(const char *meta_name)
{
  meta_parameters *meta = meta_read(meta_name);

  // If the ASF internal format file is a single-band image with RGB color map
  // in the metadata, then store the color map as an ASF style look-up table
  if (meta->colormap) {
    int i;
    meta_colormap *mc = meta->colormap;
    char lut_file[256];
    char *lut_loc = (char *)MALLOC(sizeof(char)*(strlen(get_asf_share_dir())+128));
    sprintf(lut_loc, "%s%clook_up_tables", get_asf_share_dir(), DIR_SEPARATOR);
    sprintf(lut_file,"%s%c%s", lut_loc, DIR_SEPARATOR, EMBEDDED_ASF_COLORMAP_LUT_FILE);
    FILE *lutFP = (FILE *)FOPEN(lut_file, "wt");
    fprintf(lutFP, "# Look up table type: %s\n", mc->look_up_table);
    fprintf(lutFP, "# Originating source: %s\n", meta_name);
    fprintf(lutFP, "# Index   Red   Green   Blue\n");
    for (i=0; i<mc->num_elements; i++) {
      fprintf(lutFP, "%03d    %03d    %03d    %03d\n",
              i, mc->rgb[i].red, mc->rgb[i].green, mc->rgb[i].blue);
    }
    fprintf(lutFP, "\n");
    FCLOSE(lutFP);
  }

  return meta;
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:27,代码来源:read_asf.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FCPPT_TEXT函数代码示例发布时间:2022-05-30
下一篇:
C++ FCGI_Accept函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap