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

C++ FOPEN函数代码示例

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

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



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

示例1: FOPEN

void CWE36_Absolute_Path_Traversal__char_file_fopen_82_bad::action(char * data)
{
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, "wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:12,代码来源:CWE36_Absolute_Path_Traversal__char_file_fopen_82_bad.cpp


示例2: FOPEN

CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84_bad::~CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84_bad()
{
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, L"wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:12,代码来源:CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84_bad.cpp


示例3: cu_difftext

void cu_difftext(char *testFile, char *referenceFile, char *exceptFile)
{
  char line[1024], tLine[1024], rLine[1024];
  int ii, nExcept = 0;

  // Read exceptions
  FILE *fp = FOPEN(exceptFile, "r");
  while(fgets(line, 1024, fp)) {
    chomp(line);
    nExcept++;
  }
  FCLOSE(fp);
  char **exception = (char **) MALLOC(sizeof(char *)*nExcept);
  fp = FOPEN(exceptFile, "r");
  for (ii=0; ii<nExcept; ii++) {
    exception[ii] = (char *) MALLOC(sizeof(char)*1024);
    fgets(exception[ii], 1024, fp);
  }
  FCLOSE(fp);

  // Go through both text files simultaneously
  FILE *fpTest = FOPEN(testFile, "r");
  FILE *fpRef = FOPEN(referenceFile, "r");
  while (fgets(tLine, 1024, fpTest)) {
    fgets(rLine, 1024, fpRef);
    for (ii=0; ii<nExcept; ii++) {
      if (strcmp_case(rLine, exception[ii]) != 0) {
	if (strcmp_case(tLine, rLine) != 0) {
	  asfForcePrintStatus("\ntest: %sreference: %s", tLine, rLine);
	  CU_ASSERT_TRUE(strcmp_case(tLine, rLine) == 0);
	}
      }
    }
  }

  // Clean up
  for (ii=0; ii<nExcept; ii++)
    FREE(exception[ii]);
  FREE(exception);
}
开发者ID:glshort,项目名称:MapReady,代码行数:40,代码来源:asf_test.c


示例4: plot_save

latan_errno plot_save(const strbuf dirname, plot *p)
{
    strbuf path,buf,*datfname_bak,term_bak,output_bak;
    FILE *outf;
    size_t i,j,lc;
    mode_t mode_755;
    strbuf name,ver,err_msg;
    
    MALLOC_ERRVAL(datfname_bak,strbuf *,p->nplot,LATAN_ENOMEM);
    
    mode_755 = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
    
    /* backup I/O parameters */
    strbufcpy(term_bak,p->term);
    strbufcpy(output_bak,p->output);
    for (i=0;i<p->nplot;i++)
    {
        strbufcpy(datfname_bak[i],p->datfname[i]);
    }
    /* generate directory */
    if (access(dirname,R_OK|W_OK|X_OK))
    {
        if (mkdir(dirname,mode_755))
        {
            sprintf(err_msg,"impossible to create directory %s",dirname);
            LATAN_ERROR(err_msg,LATAN_ESYSTEM);
        }
    }
    /* save pdf */
    sprintf(path,"%s/plot.pdf",dirname);
    plot_set_term(p,"pdf");
    plot_set_output(p,path);
    plot_disp(p);
    plot_set_term(p,term_bak);
    plot_set_output(p,output_bak);
    /* save script and datafiles */
    j = 0;
    for (i=0;i<p->nplot;i++)
    {
        if (strlen(p->datfname[i]))
        {
            sprintf(p->datfname[i],"points_%lu.dat",(long unsigned)(j));
            j++;
            sprintf(path,"%s/%s",dirname,p->datfname[i]);
            FOPEN(outf,path,"w");
            BEGIN_FOR_LINE(buf,datfname_bak[i],lc)
            {
                fprintf(outf,"%s\n",buf);
            }
            END_FOR_LINE
            fclose(outf);
        }
开发者ID:aportelli,项目名称:LatAnalyze-legacy,代码行数:52,代码来源:latan_plot.c


示例5: badSink

void badSink(char * * dataPtr)
{
    char * data = *dataPtr;
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, "wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:13,代码来源:CWE23_Relative_Path_Traversal__char_environment_fopen_63b.cpp


示例6: goodG2BSink

/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(list<wchar_t *> dataList)
{
    wchar_t * data = dataList.back();
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, L"wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:14,代码来源:CWE36_Absolute_Path_Traversal__wchar_t_environment_fopen_73b.cpp


示例7: addDebugLine

static void addDebugLine(_In_z_ _Printf_format_string_ TCHAR const * const format, ...) {
  static Semaphore gate;
  static TCHAR *mode = _T("w");
  gate.wait();
  FILE *f = FOPEN(_T("c:\\temp\\semaphore.log"),mode);
  mode = _T("a");
  va_list argptr;
  va_start(argptr,format);
  _vftprintf(f, format, argptr);
  va_end(argptr);
  fclose(f);
  gate.signal();
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:13,代码来源:Semaphore.cpp


示例8: badSink

static void badSink()
{
    wchar_t * data = badData;
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, L"wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:13,代码来源:CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_45.cpp


示例9: goodG2BSink

/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(vector<char *> dataVector)
{
    char * data = dataVector[2];
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, "wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:14,代码来源:CWE23_Relative_Path_Traversal__char_listen_socket_fopen_72b.cpp


示例10: badSink

void badSink()
{
    char * data = CWE36_Absolute_Path_Traversal__char_console_fopen_68_badData;
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, "wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:13,代码来源:CWE36_Absolute_Path_Traversal__char_console_fopen_68b.cpp


示例11: goodG2BSink

/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(map<int, wchar_t *> dataMap)
{
    wchar_t * data = dataMap[2];
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, L"wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:14,代码来源:CWE23_Relative_Path_Traversal__wchar_t_connect_socket_fopen_74b.cpp


示例12: goodG2BSink

/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2BSink()
{
    char * data = goodG2BData;
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, "wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:14,代码来源:CWE23_Relative_Path_Traversal__char_console_fopen_45.cpp


示例13: goodG2BSink

/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink()
{
    wchar_t * data = CWE36_Absolute_Path_Traversal__wchar_t_connect_socket_fopen_68_goodG2BData;
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, L"wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:14,代码来源:CWE36_Absolute_Path_Traversal__wchar_t_connect_socket_fopen_68b.cpp


示例14: goodG2BSink

/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(structType myStruct)
{
    wchar_t * data = myStruct.structFirst;
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, L"wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:14,代码来源:CWE23_Relative_Path_Traversal__wchar_t_connect_socket_fopen_67b.cpp


示例15: getSignalFormat

void getSignalFormat(char *baseName,long long bytesInFile,getRec *r)
{
    char name[1024];
    char buf[80];
    FILE *fp;
    create_name(name,baseName,".fmt");
    fp=FOPEN(name,"r");
    FILL(buf,80,fp) sscanf(buf,"%i%i", &r->lineSize, &r->header);
    FILL(buf,80,fp) sscanf(buf,"%f%f", &r->dcOffsetI, &r->dcOffsetQ);
    FILL(buf,80,fp) sscanf(buf,"%c", &r->flipIQ);

    r->nLines=bytesInFile/r->lineSize;/*Automatically figure out number of lines in file.*/
    r->nSamples=(r->lineSize-r->header)/r->sampleSize;/*Ditto for samples*/

    fgets(buf,80,fp);/*Skip comment line*/
    if (NULL==fgets(buf,80,fp))
        return; /*If no extra data, bail!*/
    else /*File has information about window shifts and AGC compensation*/
    {/*Read infomation about each line of the file*/
        float firstWindow;/*First Window Position shift*/
        int lastLine;float lastAGC,lastWindow;
        int keepGoing=1;

        r->lines=(signalLineRec *)MALLOC(r->nLines*sizeof(signalLineRec));

        /*Read first line's info.*/
        sscanf(buf,"%d%g%g",&lastLine,&lastWindow,&lastAGC);
        firstWindow=lastWindow;

        while (keepGoing)
        {
            int line,thisLine;
            if (NULL==fgets(buf,80,fp))
            {/*Hit EOF*/
                keepGoing=0;/*Don't keep going*/
                thisLine=r->nLines;/*Write to last line*/
            } else
                sscanf(buf,"%d",&thisLine);

            /*Write old values until this line*/
            for (line=lastLine;line<thisLine;line++)
            {
                r->lines[line].shiftBy=(int)(lastWindow-firstWindow);
                r->lines[line].scaleBy=lastAGC;
            }
            /*Read new values*/
            sscanf(buf,"%d%g%g",&lastLine,&lastWindow,&lastAGC);
        }
    }
    fclose(fp);
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:51,代码来源:read_signal.c


示例16: write_pid_file

/**
 * Write PID file.
 *
 * @param sctx service context
 * @param pid PID to write (should be equal to 'getpid()'
 * @return  #GNUNET_OK on success (including no work to be done)
 */
static int
write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid)
{
  FILE *pidfd;
  char *pif;
  char *user;
  char *rdir;
  int len;

  if (NULL == (pif = get_pid_file_name (sctx)))
    return GNUNET_OK;           /* no file desired */
  user = get_user_name (sctx);
  rdir = GNUNET_strdup (pif);
  len = strlen (rdir);
  while ((len > 0) && (rdir[len] != DIR_SEPARATOR))
    len--;
  rdir[len] = '\0';
  if (0 != ACCESS (rdir, F_OK))
  {
    /* we get to create a directory -- and claim it
     * as ours! */
    (void) GNUNET_DISK_directory_create (rdir);
    if ((NULL != user) && (0 < strlen (user)))
      GNUNET_DISK_file_change_owner (rdir, user);
  }
  if (0 != ACCESS (rdir, W_OK | X_OK))
  {
    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", rdir);
    GNUNET_free (rdir);
    GNUNET_free_non_null (user);
    GNUNET_free (pif);
    return GNUNET_SYSERR;
  }
  GNUNET_free (rdir);
  pidfd = FOPEN (pif, "w");
  if (NULL == pidfd)
  {
    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "fopen", pif);
    GNUNET_free (pif);
    GNUNET_free_non_null (user);
    return GNUNET_SYSERR;
  }
  if (0 > FPRINTF (pidfd, "%u", pid))
    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fprintf", pif);
  GNUNET_break (0 == FCLOSE (pidfd));
  if ((NULL != user) && (0 < strlen (user)))
    GNUNET_DISK_file_change_owner (pif, user);
  GNUNET_free_non_null (user);
  GNUNET_free (pif);
  return GNUNET_OK;
}
开发者ID:tg-x,项目名称:gnunet,代码行数:58,代码来源:service.c


示例17: PRINT_NFO

const CHR *AudioIO::detectSourceType(const CHR *const fileName, const bool verbose)
{
	if (verbose)
	{
		PRINT_NFO(TXT("------- Audio I/O -------"));
	}
	
	uint8_t type = AUDIO_LIB_NULL;
	const bool bStdIn = (STRCASECMP(fileName, TXT("-")) == 0);

	if (bStdIn || PATH_ISREG(fileName))
	{
		if (FILE *const file = bStdIn ? stdin : FOPEN(fileName, TXT("rb")))
		{
			if (FD_ISREG(FILENO(file)))
			{
				for (size_t i = 0; g_audioIO_mapping[i].id; ++i)
				{
					if (verbose)
					{
						PRINT2_NFO(TXT("Trying input module ") FMT_CHR TXT("..."), g_audioIO_mapping[i].name);
					}
					if (checkFileType(g_audioIO_mapping[i].checkFileType, file))
					{
						type = g_audioIO_mapping[i].id;
						if (verbose)
						{
							PRINT_NFO(TXT("succeeded."));
						}
						break;
					}
				}
			}
			if (!bStdIn)
			{
				fclose(file);
			}
		}
	}

	if (verbose)
	{
		if(type == AUDIO_LIB_NULL)
		{
			PRINT_NFO(TXT("No suitable input module found -> falling back to default!"));
		}
		PRINT_NFO(TXT("------- Audio I/O -------\n"));
	}

	return getLibName(type);
}
开发者ID:lordmulder,项目名称:DynamicAudioNormalizer,代码行数:51,代码来源:AudioIO.cpp


示例18: asf_logscale

int asf_logscale(const char *inFile, const char *outFile)
{
  int ii, jj, kk;
  meta_parameters *meta = meta_read(inFile);
  int band_count = meta->general->band_count;
  int sample_count = meta->general->sample_count;
  int line_count = meta->general->line_count;
  float *bufIn = (float *) MALLOC(sizeof(float)*sample_count);
  float *bufOut = (float *) MALLOC(sizeof(float)*sample_count);
  
  char *input = appendExt(inFile, ".img");
  char *output = appendExt(outFile, ".img");
  FILE *fpIn = FOPEN(input, "rb");
  FILE *fpOut = FOPEN(output, "wb");
  for (kk=0; kk<band_count; kk++) {
    for (ii=0; ii<line_count; ii++) {
      get_band_float_line(fpIn, meta, kk, ii, bufIn);
      for (jj=0; jj<sample_count; jj++) {
	if (FLOAT_EQUIVALENT(bufIn[jj], 0.0))
	  bufOut[jj] = 0.0;
	else
	  bufOut[jj] = 10.0 * log10(bufIn[jj]);
      }
      put_band_float_line(fpOut, meta, kk, ii, bufOut);
      asfLineMeter(ii, line_count);
    }
  }
  meta_write(meta, outFile);
  meta_free(meta);
  FCLOSE(fpIn);
  FCLOSE(fpOut);
  FREE(bufIn);
  FREE(bufOut);
  FREE(input);
  FREE(output);

  return FALSE;
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:38,代码来源:calibrate.c


示例19: badSink

void badSink(map<int, char *> dataMap)
{
    /* copy data out of dataMap */
    char * data = dataMap[2];
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, "wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:14,代码来源:CWE36_Absolute_Path_Traversal__char_listen_socket_fopen_74b.cpp


示例20: badSink

void badSink(vector<wchar_t *> dataVector)
{
    /* copy data out of dataVector */
    wchar_t * data = dataVector[2];
    {
        FILE *pFile = NULL;
        /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
        pFile = FOPEN(data, L"wb+");
        if (pFile != NULL)
        {
            fclose(pFile);
        }
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:14,代码来源:CWE23_Relative_Path_Traversal__wchar_t_environment_fopen_72b.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FOREACH_MOD函数代码示例发布时间:2022-05-30
下一篇:
C++ FOFS函数代码示例发布时间: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