2007-03-08 04:03:40 +08:00
|
|
|
// Copyright 2006 Google Inc.
|
|
|
|
// All Rights Reserved.
|
|
|
|
// Author: renn
|
|
|
|
//
|
|
|
|
// Contains file io functions (mainly for file parsing), that might not be
|
|
|
|
// available, on embedded devices, or that have an incomplete implementation
|
|
|
|
// there.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#ifndef SCANUTILS_H
|
|
|
|
#define SCANUTILS_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
2009-07-11 10:50:24 +08:00
|
|
|
#include <sys/stat.h>
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2010-09-30 07:43:31 +08:00
|
|
|
// Parse a file stream according to the given format. See the fscanf manpage
|
|
|
|
// for more information, as this function attempts to mimic its behavior.
|
|
|
|
// Note that scientific floating-point notation is not supported.
|
|
|
|
// This variant is used to ensure correct reading regardless of locale.
|
|
|
|
int tess_fscanf(FILE* stream, const char *format, ...);
|
|
|
|
|
|
|
|
#ifdef EMBEDDED
|
|
|
|
|
|
|
|
#include <klibc/extern.h>
|
|
|
|
|
2007-03-08 04:03:40 +08:00
|
|
|
// Attempts to parse the given file stream s as an integer of the base
|
|
|
|
// 'base'. Returns the first successfully parsed integer as a uintmax_t, or
|
|
|
|
// 0, if none was found.
|
|
|
|
uintmax_t streamtoumax(FILE* s, int base);
|
|
|
|
|
|
|
|
// Parse a file stream according to the given format. See the fscanf manpage
|
|
|
|
// for more information, as this function attempts to mimic its behavior.
|
2010-09-30 07:43:31 +08:00
|
|
|
// Note that scientific floating-point notation is not supported.
|
2007-03-08 04:03:40 +08:00
|
|
|
int fscanf(FILE* stream, const char *format, ...);
|
|
|
|
|
|
|
|
// Parse a file stream according to the given format. See the fscanf manpage
|
|
|
|
// for more information, as this function attempts to mimic its behavior.
|
2010-09-30 07:43:31 +08:00
|
|
|
// Note that scientific floating-point notation is not supported.
|
2007-03-08 04:03:40 +08:00
|
|
|
int vfscanf(FILE* stream, const char *format, va_list ap);
|
|
|
|
|
|
|
|
// Create a file at the specified path. See the creat manpage for more
|
|
|
|
// information, as this function attempts to mimic its behavior.
|
|
|
|
int creat(const char *pathname, mode_t mode);
|
|
|
|
|
|
|
|
// Convert the specified C-String to a float. Returns the first parsed float,
|
|
|
|
// or 0.0 if no floating point value could be found. Note that scientific
|
|
|
|
// floating-point notation is not supported.
|
|
|
|
double strtofloat(const char* s);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|