本文整理汇总了C++中FOPEN函数的典型用法代码示例。如果您正苦于以下问题:C++ FOPEN函数的具体用法?C++ FOPEN怎么用?C++ FOPEN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FOPEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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();
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}