diff options
Diffstat (limited to 'include/apps_std.h')
-rw-r--r-- | include/apps_std.h | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/include/apps_std.h b/include/apps_std.h new file mode 100644 index 0000000..72a68f6 --- /dev/null +++ b/include/apps_std.h @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2017, The Linux Foundation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* 3. Neither the name of the copyright holder nor the names of its contributors +* may be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef _APPS_STD_H +#define _APPS_STD_H +#include "AEEStdDef.h" +#ifndef __QAIC_HEADER +#define __QAIC_HEADER(ff) ff +#endif //__QAIC_HEADER + +#ifndef __QAIC_HEADER_EXPORT +#define __QAIC_HEADER_EXPORT +#endif // __QAIC_HEADER_EXPORT + +#ifndef __QAIC_HEADER_ATTRIBUTE +#define __QAIC_HEADER_ATTRIBUTE +#endif // __QAIC_HEADER_ATTRIBUTE + +#ifndef __QAIC_IMPL +#define __QAIC_IMPL(ff) ff +#endif //__QAIC_IMPL + +#ifndef __QAIC_IMPL_EXPORT +#define __QAIC_IMPL_EXPORT +#endif // __QAIC_IMPL_EXPORT + +#ifndef __QAIC_IMPL_ATTRIBUTE +#define __QAIC_IMPL_ATTRIBUTE +#endif // __QAIC_IMPL_ATTRIBUTE +#ifdef __cplusplus +extern "C" { +#endif +#if !defined(__QAIC_STRING1_OBJECT_DEFINED__) && !defined(__STRING1_OBJECT__) +#define __QAIC_STRING1_OBJECT_DEFINED__ +#define __STRING1_OBJECT__ +typedef struct _cstring1_s +{ + char *data; + int dataLen; +} _cstring1_t; + +#endif /* __QAIC_STRING1_OBJECT_DEFINED__ */ +/** + * standard library functions remoted from the apps to the dsp + */ +typedef int apps_std_FILE; +enum apps_std_SEEK +{ + APPS_STD_SEEK_SET, + APPS_STD_SEEK_CUR, + APPS_STD_SEEK_END, + _32BIT_PLACEHOLDER_apps_std_SEEK = 0x7fffffff +}; +typedef enum apps_std_SEEK apps_std_SEEK; +/** + * @retval, if operation fails errno is returned + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fopen)(const char *name, const char *mode, apps_std_FILE *psout) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_freopen)(apps_std_FILE sin, const char *name, const char *mode, apps_std_FILE *psout) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fflush)(apps_std_FILE sin) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fclose)(apps_std_FILE sin) __QAIC_HEADER_ATTRIBUTE; +/** + * @param, bEOF, if read or write bytes <= bufLen bytes then feof() is called + * and the result is returned in bEOF, otherwise bEOF is set to 0. + * @retval, if read or write return 0 for non zero length buffers, ferror is checked + * and a non zero value is returned in case of error with no rout parameters + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fread)(apps_std_FILE sin, byte *buf, int bufLen, int *bytesRead, int *bEOF) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fwrite)(apps_std_FILE sin, const byte *buf, int bufLen, int *bytesWritten, int *bEOF) __QAIC_HEADER_ATTRIBUTE; +/** + * @param, pos, this buffer is filled up to MIN(posLen, sizeof(fpos_t)) + * @param, posLenReq, returns sizeof(fpos_t) + * @retval, if operation fails errno is returned + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fgetpos)(apps_std_FILE sin, byte *pos, int posLen, int *posLenReq) __QAIC_HEADER_ATTRIBUTE; +/** + * @param, if size of pos doesn't match the system size an error is returned. + * fgetpos can be used to query the size of fpos_t + * @retval, if operation fails errno is returned + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fsetpos)(apps_std_FILE sin, const byte *pos, int posLen) __QAIC_HEADER_ATTRIBUTE; +/** + * @retval, if operation fails errno is returned + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_ftell)(apps_std_FILE sin, int *pos) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fseek)(apps_std_FILE sin, int offset, apps_std_SEEK whence) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_flen)(apps_std_FILE sin, uint64 *len) __QAIC_HEADER_ATTRIBUTE; +/** + * @retval, only fails if transport fails + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_rewind)(apps_std_FILE sin) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_feof)(apps_std_FILE sin, int *bEOF) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_ferror)(apps_std_FILE sin, int *err) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_clearerr)(apps_std_FILE sin) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_print_string)(const char *str) __QAIC_HEADER_ATTRIBUTE; +/** + * @param val, must contain space for NULL + * @param valLenReq, length required with NULL + * @retval, if fails errno is returned + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_getenv)(const char *name, char *val, int valLen, int *valLenReq) __QAIC_HEADER_ATTRIBUTE; +/** + * @retval, if fails errno is returned + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_setenv)(const char *name, const char *val, int override) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_unsetenv)(const char *name) __QAIC_HEADER_ATTRIBUTE; +/** + * This function will try to open a file given directories in envvarname separated by + * delim. + * so given environment variable FOO_PATH=/foo;/bar + * fopen_wth_env("FOO_PATH", ";", "path/to/file", "rw", &out); + * will try to open /foo/path/to/file, /bar/path/to/file + * if the variable is unset, it will open the file directly + * + * @param envvarname, name of the environment variable containing the path + * @param delim, delimiator string, such as ";" + * @param name, name of the file + * @param mode, mode + * @param psout, output handle + * @retval, 0 on success errno or -1 on failure + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fopen_with_env)(const char *envvarname, const char *delim, const char *name, const char *mode, apps_std_FILE *psout) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fgets)(apps_std_FILE sin, byte *buf, int bufLen, int *bEOF) __QAIC_HEADER_ATTRIBUTE; +/** + * This method will return the paths that are searched when looking for a file. + * The paths are defined by the environment variable (separated by delimiters) + * that is passed to the method. + * + * @param envvarname, name of the environment variable containing the path + * @param delim, delimiator string, such as ";" + * @param name, name of the file + * @param paths, Search paths + * @param numPaths, Actual number of paths found + * @param maxPathLen, The max path length + * @retval, 0 on success errno or -1 on failure + * + */ +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_get_search_paths_with_env)(const char *envvarname, const char *delim, _cstring1_t *paths, int pathsLen, uint32 *numPaths, uint16 *maxPathLen) __QAIC_HEADER_ATTRIBUTE; +__QAIC_HEADER_EXPORT int __QAIC_HEADER(apps_std_fileExists)(const char *path, boolean *exists) __QAIC_HEADER_ATTRIBUTE; +#ifdef __cplusplus +} +#endif +#endif //_APPS_STD_H |