gwenhywfar 5.12.0
syncio.c File Reference
#include "syncio_p.h"
#include "syncio_file.h"
#include "syncio_buffered.h"
#include <gwenhywfar/misc.h>
#include <gwenhywfar/debug.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for syncio.c:

Go to the source code of this file.

Macros

#define DISABLE_DEBUGLOG

Functions

void GWEN_SyncIo_AddFlags (GWEN_SYNCIO *sio, uint32_t fl)
void GWEN_SyncIo_Attach (GWEN_SYNCIO *sio)
int GWEN_SyncIo_Connect (GWEN_SYNCIO *sio)
int GWEN_SyncIo_Disconnect (GWEN_SYNCIO *sio)
int GWEN_SyncIo_Flush (GWEN_SYNCIO *sio)
void GWEN_SyncIo_free (GWEN_SYNCIO *sio)
GWEN_SYNCIOGWEN_SyncIo_GetBaseIo (const GWEN_SYNCIO *sio)
GWEN_SYNCIOGWEN_SyncIo_GetBaseIoByTypeName (const GWEN_SYNCIO *sio, const char *typeName)
uint32_t GWEN_SyncIo_GetFlags (const GWEN_SYNCIO *sio)
GWEN_SYNCIO_STATUS GWEN_SyncIo_GetStatus (const GWEN_SYNCIO *sio)
const char * GWEN_SyncIo_GetTypeName (const GWEN_SYNCIO *sio)
int GWEN_SyncIo_Helper_CopyFile (const char *srcPath, const char *destPath)
int GWEN_SyncIo_Helper_PartiallyReadFile (const char *fName, uint8_t *buffer, uint32_t size)
int GWEN_SyncIo_Helper_ReadFile (const char *fName, GWEN_BUFFER *dbuf)
int GWEN_SyncIo_Helper_ReadFileToStringList (const char *fname, int maxLines, GWEN_STRINGLIST *sl)
int GWEN_SyncIo_Helper_WriteFile (const char *fName, const uint8_t *ptrSource, uint64_t lenSource)
GWEN_SYNCIOGWEN_SyncIo_new (const char *typeName, GWEN_SYNCIO *baseIo)
int GWEN_SyncIo_Read (GWEN_SYNCIO *sio, uint8_t *buffer, uint32_t size)
int GWEN_SyncIo_ReadForced (GWEN_SYNCIO *sio, uint8_t *buffer, uint32_t size)
GWEN_SYNCIO_CONNECT_FN GWEN_SyncIo_SetConnectFn (GWEN_SYNCIO *sio, GWEN_SYNCIO_CONNECT_FN fn)
GWEN_SYNCIO_DISCONNECT_FN GWEN_SyncIo_SetDisconnectFn (GWEN_SYNCIO *sio, GWEN_SYNCIO_DISCONNECT_FN fn)
void GWEN_SyncIo_SetFlags (GWEN_SYNCIO *sio, uint32_t fl)
GWEN_SYNCIO_FLUSH_FN GWEN_SyncIo_SetFlushFn (GWEN_SYNCIO *sio, GWEN_SYNCIO_FLUSH_FN fn)
GWEN_SYNCIO_READ_FN GWEN_SyncIo_SetReadFn (GWEN_SYNCIO *sio, GWEN_SYNCIO_READ_FN fn)
void GWEN_SyncIo_SetStatus (GWEN_SYNCIO *sio, GWEN_SYNCIO_STATUS st)
GWEN_SYNCIO_WRITE_FN GWEN_SyncIo_SetWriteFn (GWEN_SYNCIO *sio, GWEN_SYNCIO_WRITE_FN fn)
void GWEN_SyncIo_SubFlags (GWEN_SYNCIO *sio, uint32_t fl)
int GWEN_SyncIo_Write (GWEN_SYNCIO *sio, const uint8_t *buffer, uint32_t size)
int GWEN_SyncIo_WriteChar (GWEN_SYNCIO *sio, char s)
int GWEN_SyncIo_WriteForced (GWEN_SYNCIO *sio, const uint8_t *buffer, uint32_t size)
int GWEN_SyncIo_WriteLine (GWEN_SYNCIO *sio, const char *s)
int GWEN_SyncIo_WriteString (GWEN_SYNCIO *sio, const char *s)

Macro Definition Documentation

◆ DISABLE_DEBUGLOG

#define DISABLE_DEBUGLOG

Definition at line 29 of file syncio.c.

Function Documentation

◆ GWEN_SyncIo_AddFlags()

◆ GWEN_SyncIo_Attach()

void GWEN_SyncIo_Attach ( GWEN_SYNCIO * sio)

Definition at line 69 of file syncio.c.

◆ GWEN_SyncIo_Connect()

◆ GWEN_SyncIo_Disconnect()

◆ GWEN_SyncIo_Flush()

int GWEN_SyncIo_Flush ( GWEN_SYNCIO * sio)

Definition at line 121 of file syncio.c.

Referenced by GWEN_HttpSession_RecvPacketToFile(), and GWEN_Sar_CloseArchive().

Here is the caller graph for this function:

◆ GWEN_SyncIo_free()

◆ GWEN_SyncIo_GetBaseIo()

◆ GWEN_SyncIo_GetBaseIoByTypeName()

GWEN_SYNCIO * GWEN_SyncIo_GetBaseIoByTypeName ( const GWEN_SYNCIO * sio,
const char * typeName )

Definition at line 233 of file syncio.c.

References NULL.

Referenced by GWEN_HttpSession_Init().

Here is the caller graph for this function:

◆ GWEN_SyncIo_GetFlags()

◆ GWEN_SyncIo_GetStatus()

◆ GWEN_SyncIo_GetTypeName()

const char * GWEN_SyncIo_GetTypeName ( const GWEN_SYNCIO * sio)

Definition at line 215 of file syncio.c.

Referenced by GWEN_DBIO_Import(), and GWEN_HttpSession_Init().

Here is the caller graph for this function:

◆ GWEN_SyncIo_Helper_CopyFile()

int GWEN_SyncIo_Helper_CopyFile ( const char * srcPath,
const char * destPath )

Copy source file to destination file. Destination file is overwritten if it exists.

Returns
number of bytes actually copied (or error code if negative value)
Parameters
srcPathpath and name of the file to read
destPathpath and name of the file to write

Definition at line 640 of file syncio.c.

References DBG_INFO, GWEN_ERROR_INTERRUPTED, GWEN_LOGDOMAIN, GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_File_CreationMode_OpenExisting, GWEN_SyncIo_File_CreationMode_TruncateExisting, GWEN_SYNCIO_FILE_FLAGS_READ, GWEN_SYNCIO_FILE_FLAGS_WRITE, GWEN_SyncIo_File_new(), GWEN_SyncIo_free(), GWEN_SyncIo_Read(), GWEN_SyncIo_SetFlags(), and GWEN_SyncIo_WriteForced().

Referenced by _copyRegFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_SyncIo_Helper_PartiallyReadFile()

int GWEN_SyncIo_Helper_PartiallyReadFile ( const char * fName,
uint8_t * buffer,
uint32_t size )

Read SIZE bytes from the given file. Returns the number of bytes actually read or an error code (negative value).

Returns
number of bytes actually read (or error code if negative value)
Parameters
fNamename of the file to load
bufferpointer to a fixed buffer to receive the bytes read
sizenumber of bytes to read

Definition at line 476 of file syncio.c.

References DBG_INFO, GWEN_ERROR_INTERRUPTED, GWEN_LOGDOMAIN, GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_File_CreationMode_OpenExisting, GWEN_SYNCIO_FILE_FLAGS_READ, GWEN_SyncIo_File_new(), GWEN_SyncIo_free(), GWEN_SyncIo_Read(), and GWEN_SyncIo_SetFlags().

Here is the call graph for this function:

◆ GWEN_SyncIo_Helper_ReadFile()

int GWEN_SyncIo_Helper_ReadFile ( const char * fName,
GWEN_BUFFER * dbuf )

Read a whole file into the given buffer

Returns
number of bytes actually read (or error code if negative value)
Parameters
fNamename of the file to load
dbufGWEN_BUFFER to receive the bytes read

Definition at line 524 of file syncio.c.

References DBG_INFO, GWEN_Buffer_AdjustUsedBytes(), GWEN_Buffer_AllocRoom(), GWEN_Buffer_GetMaxUnsegmentedWrite(), GWEN_Buffer_GetPosPointer(), GWEN_Buffer_IncrementPos(), GWEN_ERROR_INTERRUPTED, GWEN_LOGDOMAIN, GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_File_CreationMode_OpenExisting, GWEN_SYNCIO_FILE_FLAGS_READ, GWEN_SyncIo_File_new(), GWEN_SyncIo_File_Seek(), GWEN_SyncIo_File_Whence_End, GWEN_SyncIo_File_Whence_Set, GWEN_SyncIo_free(), GWEN_SyncIo_Read(), and GWEN_SyncIo_SetFlags().

Referenced by _printCmdOutputIfNotEmptyAndDeleteFile(), _readDepFile(), _readModifyWriteFile(), and test_json().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_SyncIo_Helper_ReadFileToStringList()

int GWEN_SyncIo_Helper_ReadFileToStringList ( const char * fname,
int maxLines,
GWEN_STRINGLIST * sl )

◆ GWEN_SyncIo_Helper_WriteFile()

int GWEN_SyncIo_Helper_WriteFile ( const char * fName,
const uint8_t * ptrSource,
uint64_t lenSource )

Writes a whole file from the given buffer

Returns
number of bytes actually written (or error code if negative value)
Parameters
fNamename of the file to load
ptrSourcepointer to the data to write
lenSourcesize of the data to write

Definition at line 586 of file syncio.c.

References DBG_INFO, GWEN_ERROR_INTERRUPTED, GWEN_ERROR_IO, GWEN_LOGDOMAIN, GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_File_CreationMode_CreateNew, GWEN_SYNCIO_FILE_FLAGS_READ, GWEN_SYNCIO_FILE_FLAGS_UREAD, GWEN_SYNCIO_FILE_FLAGS_UWRITE, GWEN_SYNCIO_FILE_FLAGS_WRITE, GWEN_SyncIo_File_new(), GWEN_SyncIo_free(), GWEN_SyncIo_SetFlags(), and GWEN_SyncIo_Write().

Referenced by _readModifyWriteFile(), _writeConfigH(), _writeStaticLibHelper(), GWB_Tools_CheckCompilerArgs(), GWB_Tools_TryCompile(), and GWB_Tools_TryLink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_SyncIo_new()

GWEN_SYNCIO * GWEN_SyncIo_new ( const char * typeName,
GWEN_SYNCIO * baseIo )

◆ GWEN_SyncIo_Read()

◆ GWEN_SyncIo_ReadForced()

int GWEN_SyncIo_ReadForced ( GWEN_SYNCIO * sio,
uint8_t * buffer,
uint32_t size )

Definition at line 360 of file syncio.c.

References DBG_ERROR, DBG_INFO, GWEN_ERROR_EOF, GWEN_ERROR_INTERRUPTED, GWEN_LOGDOMAIN, and GWEN_SyncIo_Read().

Referenced by GWEN_Sar_ExtractAndDigestFileDir(), GWEN_Sar_ExtractAndDigestFileLink(), GWEN_Sar_ExtractAndDigestFileReg(), GWEN_Sar_ScanFile(), GWEN_Sar_Sign(), and GWEN_Sar_Verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_SyncIo_SetConnectFn()

GWEN_SYNCIO_CONNECT_FN GWEN_SyncIo_SetConnectFn ( GWEN_SYNCIO * sio,
GWEN_SYNCIO_CONNECT_FN fn )

Definition at line 252 of file syncio.c.

Referenced by GWEN_SyncIo_Buffered_new(), GWEN_SyncIo_Http_new(), GWEN_SyncIo_Socket_new(), GWEN_SyncIo_Socket_TakeOver(), and GWEN_SyncIo_Tls_new().

Here is the caller graph for this function:

◆ GWEN_SyncIo_SetDisconnectFn()

GWEN_SYNCIO_DISCONNECT_FN GWEN_SyncIo_SetDisconnectFn ( GWEN_SYNCIO * sio,
GWEN_SYNCIO_DISCONNECT_FN fn )

Definition at line 265 of file syncio.c.

Referenced by GWEN_SyncIo_Buffered_new(), GWEN_SyncIo_Http_new(), GWEN_SyncIo_Socket_new(), GWEN_SyncIo_Socket_TakeOver(), and GWEN_SyncIo_Tls_new().

Here is the caller graph for this function:

◆ GWEN_SyncIo_SetFlags()

void GWEN_SyncIo_SetFlags ( GWEN_SYNCIO * sio,
uint32_t fl )

◆ GWEN_SyncIo_SetFlushFn()

GWEN_SYNCIO_FLUSH_FN GWEN_SyncIo_SetFlushFn ( GWEN_SYNCIO * sio,
GWEN_SYNCIO_FLUSH_FN fn )

Definition at line 278 of file syncio.c.

◆ GWEN_SyncIo_SetReadFn()

◆ GWEN_SyncIo_SetStatus()

◆ GWEN_SyncIo_SetWriteFn()

◆ GWEN_SyncIo_SubFlags()

void GWEN_SyncIo_SubFlags ( GWEN_SYNCIO * sio,
uint32_t fl )

Definition at line 188 of file syncio.c.

Referenced by GWEN_SyncIo_Buffered_Read(), GWEN_SyncIo_Http_ReadHeader(), GWEN_SyncIo_Http_ReadLine(), and GWEN_SyncIo_Tls_Connect().

Here is the caller graph for this function:

◆ GWEN_SyncIo_Write()

int GWEN_SyncIo_Write ( GWEN_SYNCIO * sio,
const uint8_t * buffer,
uint32_t size )

Definition at line 147 of file syncio.c.

References GWEN_ERROR_BROKEN_PIPE.

Referenced by GWEN_SyncIo_Buffered_Write(), GWEN_SyncIo_Helper_WriteFile(), GWEN_SyncIo_Tls_Push(), and GWEN_SyncIo_WriteForced().

Here is the caller graph for this function:

◆ GWEN_SyncIo_WriteChar()

int GWEN_SyncIo_WriteChar ( GWEN_SYNCIO * sio,
char s )

◆ GWEN_SyncIo_WriteForced()

◆ GWEN_SyncIo_WriteLine()

◆ GWEN_SyncIo_WriteString()