Example #1
0
int main()
{
    FILE* fp = 0;
    fpos_t fpos = {0};
    size_t s = 0;
    char* cp = 0;
    va_list va;
    static_assert((std::is_same<decltype(remove("")), int>::value), "");
    static_assert((std::is_same<decltype(rename("","")), int>::value), "");
    static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), "");
    static_assert((std::is_same<decltype(tmpnam(cp)), char*>::value), "");
    static_assert((std::is_same<decltype(fclose(fp)), int>::value), "");
    static_assert((std::is_same<decltype(fflush(fp)), int>::value), "");
    static_assert((std::is_same<decltype(fopen("", "")), FILE*>::value), "");
    static_assert((std::is_same<decltype(freopen("", "", fp)), FILE*>::value), "");
    static_assert((std::is_same<decltype(setbuf(fp,cp)), void>::value), "");
    static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
    static_assert((std::is_same<decltype(fprintf(fp," ")), int>::value), "");
    static_assert((std::is_same<decltype(fscanf(fp,"")), int>::value), "");
    static_assert((std::is_same<decltype(printf("\n")), int>::value), "");
    static_assert((std::is_same<decltype(scanf("\n")), int>::value), "");
    static_assert((std::is_same<decltype(snprintf(cp,0,"p")), int>::value), "");
    static_assert((std::is_same<decltype(sprintf(cp," ")), int>::value), "");
    static_assert((std::is_same<decltype(sscanf("","")), int>::value), "");
    static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
    static_assert((std::is_same<decltype(vfscanf(fp,"",va)), int>::value), "");
    static_assert((std::is_same<decltype(vprintf(" ",va)), int>::value), "");
    static_assert((std::is_same<decltype(vscanf("",va)), int>::value), "");
    static_assert((std::is_same<decltype(vsnprintf(cp,0," ",va)), int>::value), "");
    static_assert((std::is_same<decltype(vsprintf(cp," ",va)), int>::value), "");
    static_assert((std::is_same<decltype(vsscanf("","",va)), int>::value), "");
    static_assert((std::is_same<decltype(fgetc(fp)), int>::value), "");
    static_assert((std::is_same<decltype(fgets(cp,0,fp)), char*>::value), "");
    static_assert((std::is_same<decltype(fputc(0,fp)), int>::value), "");
    static_assert((std::is_same<decltype(fputs("",fp)), int>::value), "");
    static_assert((std::is_same<decltype(getc(fp)), int>::value), "");
    static_assert((std::is_same<decltype(getchar()), int>::value), "");
    static_assert((std::is_same<decltype(gets(cp)), char*>::value), "");
    static_assert((std::is_same<decltype(putc(0,fp)), int>::value), "");
    static_assert((std::is_same<decltype(putchar(0)), int>::value), "");
    static_assert((std::is_same<decltype(puts("")), int>::value), "");
    static_assert((std::is_same<decltype(ungetc(0,fp)), int>::value), "");
    static_assert((std::is_same<decltype(fread((void*)0,0,0,fp)), size_t>::value), "");
    static_assert((std::is_same<decltype(fwrite((const void*)0,0,0,fp)), size_t>::value), "");
    static_assert((std::is_same<decltype(fgetpos(fp, &fpos)), int>::value), "");
    static_assert((std::is_same<decltype(fseek(fp, 0,0)), int>::value), "");
    static_assert((std::is_same<decltype(fsetpos(fp, &fpos)), int>::value), "");
    static_assert((std::is_same<decltype(ftell(fp)), long>::value), "");
    static_assert((std::is_same<decltype(rewind(fp)), void>::value), "");
    static_assert((std::is_same<decltype(clearerr(fp)), void>::value), "");
#if !defined(feof)
    //check return type of feof only if it's not an macro which may be a compound expression
    static_assert((std::is_same<decltype(feof(fp)), int>::value), "");
#endif
#if !defined(ferror)
    //check return type of ferror only if it's not an macro which may be a compound expression
    static_assert((std::is_same<decltype(ferror(fp)), int>::value), "");
#endif
    static_assert((std::is_same<decltype(perror("")), void>::value), "");
}
Example #2
0
void safe_file_scanf(const char *file, const int lineno,
		     void (*cleanup_fn) (void),
		     const char *path, const char *fmt, ...)
{
	va_list va;
	FILE *f;
	int exp_convs, ret;

	f = fopen(path, "r");

	if (f == NULL) {
		tst_brkm(TBROK | TERRNO, cleanup_fn,
			 "Failed to open FILE '%s' for reading at %s:%d",
			 path, file, lineno);
	}

	exp_convs = count_scanf_conversions(fmt);

	va_start(va, fmt);
	ret = vfscanf(f, fmt, va);
	va_end(va);

	if (ret == EOF) {
		tst_brkm(TBROK, cleanup_fn,
			 "The FILE '%s' ended prematurely at %s:%d",
			 path, file, lineno);
	}

	if (ret != exp_convs) {
		tst_brkm(TBROK, cleanup_fn,
			 "Expected %i conversions got %i FILE '%s' at %s:%d",
			 exp_convs, ret, path, file, lineno);
	}

}
Example #3
0
	void File::Read(const char *format, ...)
	{
		va_list args;
		va_start(args, format);
		vfscanf(fp, format, args);
		va_end(args);
	}
Example #4
0
	int vscanf (

/*  SYNOPSIS */
	const char * format,
	va_list      args)

/*  FUNCTION
	Scan the standard input and convert it into the arguments as
	specified by format.

    INPUTS
	format - A scanf() format string.
	args - A list of arguments for the results

    RESULT
	The number of converted parameters.

    NOTES

    EXAMPLE

    BUGS

    SEE ALSO

    INTERNALS

******************************************************************************/
{
    struct PosixCBase *PosixCBase = __aros_getbase_PosixCBase();

    return vfscanf (PosixCBase->_stdin, format, args);
} /* vscanf */
int FileWrapper::scanf(const char *format, ...)
{
 va_list ap;
 int ret;

 clearerr(fp);

 va_start(ap, format);

 ret = vfscanf(fp, format, ap);

 va_end(ap);

 if(ferror(fp))
 {
  ErrnoHolder ene(errno);

  throw(MDFN_Error(ene.Errno(), _("Error reading from opened file \"%s\": %s"), path_save.c_str(), ene.StrError()));
 }

 //if(ret < 0 || ret == EOF)
 // throw(MDFN_Error(0, _("%s error on format string \"%s\""), "trio_vfscanf()", format));

 return(ret);
}
Example #6
0
int vsscanf(char *s, char *fmt, va_list ap)
{
	FILE f = {-1, EOF};
	f.ibuf = s;
	f.ilen = strlen(s);
	return vfscanf(&f, fmt, ap);
}
Example #7
0
static int
sysctl_vscanf(const char *name, const char *fmt, va_list ap)
{
    char *path = NULL;
    FILE *s = NULL;
    int rv;

    path = mprintf("/proc/sys/%s", name);
    if (!path) {
        rv = -errno;
        goto fail;
    }

    s = fopen(path, "r");
    if (!s) {
        rv = -errno;
        goto fail;
    }

    rv = vfscanf(s, fmt, ap);
fail:
    if (s)
        fclose(s);

    if (path)
        free(path);

    return rv;
}
Example #8
0
int uart_vscanf(const char *fmt, va_list ap){
    int count;
    acquire(&uart_lock);
    count = vfscanf(&uartio, fmt, ap);
    release(&uart_lock);

    return count;
}
Example #9
0
int scanf(const char *format, ...) {
  int n;
  va_list arg_ptr;
  va_start(arg_ptr, format);
  n=vfscanf(stdin,format,arg_ptr);
  va_end (arg_ptr);
  return n;
}
Example #10
0
int fscanf(FILE* fp, const char* format, ...)
{
	va_list ap;
	va_start(ap, format);
	int ret = vfscanf(fp, format, ap);
	va_end(ap);
	return ret;
}
Example #11
0
int scanf(const char *fmt, ...){
	int n;
	va_list args;
	va_start(args, fmt);
	n=vfscanf(stdin, fmt, args);
	va_end(args);
	return n;
}
Example #12
0
int __darwin_fscanf(__darwin_FILE* fp, const char* fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	int r = vfscanf(fp->linux_fp, fmt, ap);
	va_end(ap);
	return r;
}
Example #13
0
int fscanf(FILE *stream,const char *format,...)
{ int retval;
  va_list args;
  va_start(args,format);
  retval=vfscanf(stream,format,args);
  va_end(args);
  return retval;
}
Example #14
0
int fscanf(FILE *f, const char *fmt, ...){
	int n;
	va_list args;
	va_start(args, fmt);
	n=vfscanf(f, fmt, args);
	va_end(args);
	return n;
}
Example #15
0
void ffind( FILE *fp, char *format, ... )
  {
    va_list arglist;

    va_start( arglist, format );
    vfscanf( fp, format, arglist );
    va_end( arglist );
  }
Example #16
0
int fscanf(FILE *stream, const char *format, ...)
{
	va_list arg;
	va_start(arg, format);
	int ret = vfscanf(stream, format, arg);
	va_end(arg);
	return ret;
}
Example #17
0
int Stream::scanf(const char* format, ...) {
    std::va_list arg;
    va_start(arg, format);
    fflush(_file);
    int r = vfscanf(_file, format, arg);
    va_end(arg);
    return r;
}
Example #18
0
int fscanf(FILE *stream, const char *format, ...)
{
	va_list ap;
	va_start(ap, format);
	int out = vfscanf(stream, format, ap);
	va_end(ap);
	return out;
};
Example #19
0
int scanf(char *fmt, ...)
{
	va_list ap;
	int ret;
	va_start(ap, fmt);
	ret = vfscanf(stdin, fmt, ap);
	va_end(ap);
	return ret;
}
Example #20
0
REALIGN int32_t fscanf_wrap(FILE *f, const char *fmt, ...)
{
	int ret;
	va_list arg;
	va_start(arg, fmt);
	ret = vfscanf(f, fmt, arg);
	va_end(arg);
	return ret;
}
Example #21
0
int fscanf(FILE *stream, const char *format, ...)
{
	va_list	args;
	 int	rv;
	va_start(args, format);
	rv = vfscanf(stream, format, args);
	va_end(args);
	return rv;
}
Example #22
0
int scanf(const char *format, ...)
{
	va_list	args;
	 int	rv;
	va_start(args, format);
	rv = vfscanf(stdin, format, args);
	va_end(args);
	return rv;
}
Example #23
0
int fscanf(FILE *fp, char *fmt, ...)
{
	va_list ap;
	int ret;
	va_start(ap, fmt);
	ret = vfscanf(fp, fmt, ap);
	va_end(ap);
	return ret;
}
Example #24
0
static int
xfscanf (FILE *f, const char *fmt, ...)
{
  va_list ap;
  va_start (ap, fmt);
  int ret = vfscanf (f, fmt, ap);
  va_end (ap);
  return ret;
}
Example #25
0
int fscanf(FILE *file,const char *format,...)
{ /*Call the vfscanf.*/
   va_list list;
   int retval;
   va_start(list,format);
   retval = vfscanf(file,format,list);
   va_end(list);
   return retval;
}
Example #26
0
int fscanf(FILE *f, const char *fmt, ...)
{
    va_list arg;

    va_start(arg, fmt);
    int n = vfscanf(f, fmt, arg);
    va_end(arg);
    return n;
}
Example #27
0
File: scanf.c Project: phoboz/vmx
int fscanf(FILE * fp, const char *fmt, ...)
{
        va_list ptr;
        int rv;

        va_start(ptr, fmt);
        rv = vfscanf(fp, fmt, ptr);
        va_end(ptr);
        return rv;
}
Example #28
0
File: scanf.c Project: phoboz/vmx
int scanf(const char *fmt, ...)
{
        va_list ptr;
        int rv;

        va_start(ptr, fmt);
        rv = vfscanf(stdin, fmt, ptr);
        va_end(ptr);
        return rv;
}
Example #29
0
File: scanf.c Project: phoboz/vmx
int vsscanf(const char *sp, const char *fmt, va_list ap)
{
        FILE string[1] = {
                {0, (unsigned char *) ((unsigned) -1), 0, 0, (char *) ((unsigned) -1),
                 0, -1, _IOFBF}
        };

        string->bufpos = (unsigned char *) sp;
        return vfscanf(string, fmt, ap);
}
Example #30
0
int scanf(const char *format, ...) {
	int result;
	va_list ap;

	va_start(ap, format);
	result = vfscanf(stdin, format, ap);
	va_end(ap);

	return result;
}