1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Move extern function comments to headers.

This has been the policy for some time but due to migration pressure only new functions and refactors have been following this rule. Now it seems sensible to make a clean sweep and move all the comments that have not been moved already (i.e. most of them).

Only obvious typos and gross inaccuracies in the comments have been fixed. For this most part this was a copy and paste operation.

Useless comments, e.g. "New object", were not copied. Even so, there are surely many deficient comments left.

Some rearranging was done where needed and functions were placed in the proper sections, e.g. "Constructors", "Functions", etc.

A few function prototypes were found that not longer had an implementation. These were removed, but there may be more.

The coding document has been updated to reflect this policy, which is not new but has never been documented.
This commit is contained in:
David Steele
2020-04-03 18:01:28 -04:00
parent 3fbde30c6f
commit 1aca2cc902
220 changed files with 1652 additions and 2131 deletions

View File

@ -30,6 +30,10 @@ if (archiveInfoPgHistory.id != backupInfoPgHistory.id || archiveInfoPgHistory.sy
backupInfoPgHistory.systemId || archiveInfoPgHistory.version != backupInfoPgHistory.version) backupInfoPgHistory.systemId || archiveInfoPgHistory.version != backupInfoPgHistory.version)
``` ```
### Function Comments
Comments for `extern` functions should be included in the `.h` file. Comments for `static` functions and implementation-specific notes for `extern` functions (i.e., not of interest to the general user) should be included in the `.c` file.
### Inline Comment ### Inline Comment
Inline comments shall start at character 69 and must not exceed the line length of 132. For example: Inline comments shall start at character 69 and must not exceed the line length of 132. For example:

View File

@ -41,6 +41,12 @@ if (archiveInfoPgHistory.id != backupInfoPgHistory.id || archiveInfoPgHistory.sy
</code-block> </code-block>
</section> </section>
<section id="function-comment">
<title>Function Comments</title>
<p>Comments for <code>extern</code> functions should be included in the <file>.h</file> file. Comments for <code>static</code> functions and implementation-specific notes for <code>extern</code> functions (i.e., not of interest to the general user) should be included in the <file>.c</file> file.</p>
</section>
<section id="inline-comment"> <section id="inline-comment">
<title>Inline Comment</title> <title>Inline Comment</title>

View File

@ -67,9 +67,7 @@ archiveAsyncErrorClear(ArchiveMode archiveMode, const String *archiveFile)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Check for ok/error status files in the spool in/out directory
***********************************************************************************************************************************/
bool bool
archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throwOnError) archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throwOnError)
{ {
@ -172,9 +170,7 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throw
FUNCTION_LOG_RETURN(BOOL, result); FUNCTION_LOG_RETURN(BOOL, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Write an error status file
***********************************************************************************************************************************/
void void
archiveAsyncStatusErrorWrite(ArchiveMode archiveMode, const String *walSegment, int code, const String *message) archiveAsyncStatusErrorWrite(ArchiveMode archiveMode, const String *walSegment, int code, const String *message)
{ {
@ -203,9 +199,7 @@ archiveAsyncStatusErrorWrite(ArchiveMode archiveMode, const String *walSegment,
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Write an ok status file
***********************************************************************************************************************************/
void void
archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment, const String *warning) archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment, const String *warning)
{ {
@ -282,9 +276,7 @@ archiveAsyncExec(ArchiveMode archiveMode, const StringList *commandExec)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Is the segment partial?
***********************************************************************************************************************************/
bool bool
walIsPartial(const String *walSegment) walIsPartial(const String *walSegment)
{ {
@ -298,9 +290,7 @@ walIsPartial(const String *walSegment)
FUNCTION_LOG_RETURN(BOOL, strEndsWithZ(walSegment, WAL_SEGMENT_PARTIAL_EXT)); FUNCTION_LOG_RETURN(BOOL, strEndsWithZ(walSegment, WAL_SEGMENT_PARTIAL_EXT));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Generates the location of the wal directory using a relative wal path and the supplied pg path
***********************************************************************************************************************************/
String * String *
walPath(const String *walFile, const String *pgPath, const String *command) walPath(const String *walFile, const String *pgPath, const String *command)
{ {
@ -356,9 +346,7 @@ walPath(const String *walFile, const String *pgPath, const String *command)
FUNCTION_LOG_RETURN(STRING, result); FUNCTION_LOG_RETURN(STRING, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Is the file a segment or some other file (e.g. .history, .backup, etc)
***********************************************************************************************************************************/
bool bool
walIsSegment(const String *walSegment) walIsSegment(const String *walSegment)
{ {
@ -383,12 +371,7 @@ walIsSegment(const String *walSegment)
FUNCTION_LOG_RETURN(BOOL, regExpMatch(regExpSegment, walSegment)); FUNCTION_LOG_RETURN(BOOL, regExpMatch(regExpSegment, walSegment));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Find a WAL segment in the repository
The file name can have several things appended such as a hash, compression extension, and partial extension so it is possible to
have multiple files that match the segment, though more than one match is not a good thing.
***********************************************************************************************************************************/
String * String *
walSegmentFind(const Storage *storage, const String *archiveId, const String *walSegment, TimeMSec timeout) walSegmentFind(const Storage *storage, const String *archiveId, const String *walSegment, TimeMSec timeout)
{ {
@ -456,9 +439,7 @@ walSegmentFind(const Storage *storage, const String *archiveId, const String *wa
FUNCTION_LOG_RETURN(STRING, result); FUNCTION_LOG_RETURN(STRING, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get the next WAL segment given a WAL segment and WAL segment size
***********************************************************************************************************************************/
String * String *
walSegmentNext(const String *walSegment, size_t walSegmentSize, unsigned int pgVersion) walSegmentNext(const String *walSegment, size_t walSegmentSize, unsigned int pgVersion)
{ {
@ -505,9 +486,7 @@ walSegmentNext(const String *walSegment, size_t walSegmentSize, unsigned int pgV
FUNCTION_LOG_RETURN(STRING, strNewFmt("%08X%08X%08X", timeline, major, minor)); FUNCTION_LOG_RETURN(STRING, strNewFmt("%08X%08X%08X", timeline, major, minor));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Build a list of WAL segments based on a beginning WAL and number of WAL in the range (inclusive)
***********************************************************************************************************************************/
StringList * StringList *
walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, unsigned int pgVersion, unsigned int range) walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, unsigned int pgVersion, unsigned int range)
{ {

View File

@ -63,18 +63,36 @@ Functions
// old error may be reported rather than waiting for the async process to succeed or fail. // old error may be reported rather than waiting for the async process to succeed or fail.
void archiveAsyncErrorClear(ArchiveMode archiveMode, const String *archiveFile); void archiveAsyncErrorClear(ArchiveMode archiveMode, const String *archiveFile);
// Check for ok/error status files in the spool in/out directory
bool archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throwOnError); bool archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool throwOnError);
// Write an ok status file
void archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment, const String *warning); void archiveAsyncStatusOkWrite(ArchiveMode archiveMode, const String *walSegment, const String *warning);
// Write an error status file
void archiveAsyncStatusErrorWrite(ArchiveMode archiveMode, const String *walSegment, int code, const String *message); void archiveAsyncStatusErrorWrite(ArchiveMode archiveMode, const String *walSegment, int code, const String *message);
// Execute the async process. This function will only return in the calling process and the implementation is platform depedent. // Execute the async process. This function will only return in the calling process and the implementation is platform depedent.
void archiveAsyncExec(ArchiveMode archiveMode, const StringList *commandExec); void archiveAsyncExec(ArchiveMode archiveMode, const StringList *commandExec);
// Is the segment partial?
bool walIsPartial(const String *walSegment); bool walIsPartial(const String *walSegment);
// Is the file a segment or some other file (e.g. .history, .backup, etc)
bool walIsSegment(const String *walSegment); bool walIsSegment(const String *walSegment);
// Generates the location of the wal directory using a relative wal path and the supplied pg path
String *walPath(const String *walFile, const String *pgPath, const String *command); String *walPath(const String *walFile, const String *pgPath, const String *command);
// Find a WAL segment in the repository. The file name can have several things appended such as a hash, compression extension, and
// partial extension so it is possible to have multiple files that match the segment, though more than one match is not a good
// thing.
String *walSegmentFind(const Storage *storage, const String *archiveId, const String *walSegment, TimeMSec timeout); String *walSegmentFind(const Storage *storage, const String *archiveId, const String *walSegment, TimeMSec timeout);
// Get the next WAL segment given a WAL segment and WAL segment size
String *walSegmentNext(const String *walSegment, size_t walSegmentSize, unsigned int pgVersion); String *walSegmentNext(const String *walSegment, size_t walSegmentSize, unsigned int pgVersion);
// Build a list of WAL segments based on a beginning WAL and number of WAL in the range (inclusive)
StringList *walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, unsigned int pgVersion, unsigned int range); StringList *walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, unsigned int pgVersion, unsigned int range);
#endif #endif

View File

@ -109,9 +109,7 @@ archiveGetCheck(const String *archiveFile, CipherType cipherType, const String *
FUNCTION_LOG_RETURN(ARCHIVE_GET_CHECK_RESULT, result); FUNCTION_LOG_RETURN(ARCHIVE_GET_CHECK_RESULT, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Copy a file from the archive to the specified destination
***********************************************************************************************************************************/
int int
archiveGetFile( archiveGetFile(
const Storage *storage, const String *archiveFile, const String *walDestination, bool durable, CipherType cipherType, const Storage *storage, const String *archiveFile, const String *walDestination, bool durable, CipherType cipherType,

View File

@ -11,6 +11,7 @@ Archive Get File
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Copy a file from the archive to the specified destination
int archiveGetFile( int archiveGetFile(
const Storage *storage, const String *archiveFile, const String *walDestination, bool durable, CipherType cipherType, const Storage *storage, const String *archiveFile, const String *walDestination, bool durable, CipherType cipherType,
const String *cipherPass); const String *cipherPass);

View File

@ -99,9 +99,7 @@ queueNeed(const String *walSegment, bool found, uint64_t queueSize, size_t walSe
FUNCTION_LOG_RETURN(STRING_LIST, result); FUNCTION_LOG_RETURN(STRING_LIST, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get an archive file from the repository (WAL segment, history file, etc.)
***********************************************************************************************************************************/
int int
cmdArchiveGet(void) cmdArchiveGet(void)
{ {
@ -277,9 +275,7 @@ cmdArchiveGet(void)
FUNCTION_LOG_RETURN(INT, result); FUNCTION_LOG_RETURN(INT, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Async version of archive get that runs in parallel for performance
***********************************************************************************************************************************/
typedef struct ArchiveGetAsyncData typedef struct ArchiveGetAsyncData
{ {
const StringList *walSegmentList; // List of wal segments to process const StringList *walSegmentList; // List of wal segments to process

View File

@ -7,7 +7,10 @@ Archive Get Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Get an archive file from the repository (WAL segment, history file, etc.)
int cmdArchiveGet(void); int cmdArchiveGet(void);
// Async version of archive get that runs in parallel for performance
void cmdArchiveGetAsync(void); void cmdArchiveGetAsync(void);
#endif #endif

View File

@ -17,9 +17,7 @@ Constants
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
STRING_EXTERN(PROTOCOL_COMMAND_ARCHIVE_GET_STR, PROTOCOL_COMMAND_ARCHIVE_GET); STRING_EXTERN(PROTOCOL_COMMAND_ARCHIVE_GET_STR, PROTOCOL_COMMAND_ARCHIVE_GET);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process protocol requests
***********************************************************************************************************************************/
bool bool
archiveGetProtocol(const String *command, const VariantList *paramList, ProtocolServer *server) archiveGetProtocol(const String *command, const VariantList *paramList, ProtocolServer *server)
{ {

View File

@ -17,6 +17,7 @@ Constants
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process protocol requests
bool archiveGetProtocol(const String *command, const VariantList *paramList, ProtocolServer *server); bool archiveGetProtocol(const String *command, const VariantList *paramList, ProtocolServer *server);
#endif #endif

View File

@ -16,9 +16,7 @@ Archive Push File
#include "postgres/interface.h" #include "postgres/interface.h"
#include "storage/helper.h" #include "storage/helper.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Copy a file from the source to the archive
***********************************************************************************************************************************/
String * String *
archivePushFile( archivePushFile(
const String *walSource, const String *archiveId, unsigned int pgVersion, uint64_t pgSystemId, const String *archiveFile, const String *walSource, const String *archiveId, unsigned int pgVersion, uint64_t pgSystemId, const String *archiveFile,

View File

@ -12,6 +12,7 @@ Archive Push File
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Copy a file from the source to the archive
String *archivePushFile( String *archivePushFile(
const String *walSource, const String *archiveId, unsigned int pgVersion, uint64_t pgSystemId, const String *archiveFile, const String *walSource, const String *archiveId, unsigned int pgVersion, uint64_t pgSystemId, const String *archiveFile,
CipherType cipherType, const String *cipherPass, CompressType compressType, int compressLevel); CipherType cipherType, const String *cipherPass, CompressType compressType, int compressLevel);

View File

@ -17,9 +17,7 @@ Constants
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
STRING_EXTERN(PROTOCOL_COMMAND_ARCHIVE_PUSH_STR, PROTOCOL_COMMAND_ARCHIVE_PUSH); STRING_EXTERN(PROTOCOL_COMMAND_ARCHIVE_PUSH_STR, PROTOCOL_COMMAND_ARCHIVE_PUSH);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process protocol requests
***********************************************************************************************************************************/
bool bool
archivePushProtocol(const String *command, const VariantList *paramList, ProtocolServer *server) archivePushProtocol(const String *command, const VariantList *paramList, ProtocolServer *server)
{ {

View File

@ -17,6 +17,7 @@ Constants
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process protocol requests
bool archivePushProtocol(const String *command, const VariantList *paramList, ProtocolServer *server); bool archivePushProtocol(const String *command, const VariantList *paramList, ProtocolServer *server);
#endif #endif

View File

@ -248,9 +248,7 @@ archivePushCheck(CipherType cipherType, const String *cipherPass)
FUNCTION_LOG_RETURN(ARCHIVE_PUSH_CHECK_RESULT, result); FUNCTION_LOG_RETURN(ARCHIVE_PUSH_CHECK_RESULT, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Push a WAL segment to the repository
***********************************************************************************************************************************/
void void
cmdArchivePush(void) cmdArchivePush(void)
{ {
@ -376,9 +374,7 @@ cmdArchivePush(void)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Async version of archive push that runs in parallel for performance
***********************************************************************************************************************************/
typedef struct ArchivePushAsyncData typedef struct ArchivePushAsyncData
{ {
const String *walPath; // Path to pg_wal/pg_xlog const String *walPath; // Path to pg_wal/pg_xlog

View File

@ -7,7 +7,10 @@ Archive Push Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Push a WAL segment to the repository
void cmdArchivePush(void); void cmdArchivePush(void);
// Async version of archive push that runs in parallel for performance
void cmdArchivePushAsync(void); void cmdArchivePushAsync(void);
#endif #endif

View File

@ -1929,9 +1929,7 @@ backupComplete(InfoBackup *const infoBackup, Manifest *const manifest)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Make a backup
***********************************************************************************************************************************/
void void
cmdBackup(void) cmdBackup(void)
{ {

View File

@ -7,6 +7,7 @@ Backup Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Make a backup
void cmdBackup(void); void cmdBackup(void);
#endif #endif

View File

@ -16,9 +16,7 @@ STRING_EXTERN(BACKUP_TYPE_FULL_STR, BACKUP_TYPE_
STRING_EXTERN(BACKUP_TYPE_DIFF_STR, BACKUP_TYPE_DIFF); STRING_EXTERN(BACKUP_TYPE_DIFF_STR, BACKUP_TYPE_DIFF);
STRING_EXTERN(BACKUP_TYPE_INCR_STR, BACKUP_TYPE_INCR); STRING_EXTERN(BACKUP_TYPE_INCR_STR, BACKUP_TYPE_INCR);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Returns an anchored regex string for filtering backups based on the type (at least one type is required to be true)
***********************************************************************************************************************************/
String * String *
backupRegExp(BackupRegExpParam param) backupRegExp(BackupRegExpParam param)
{ {
@ -83,9 +81,7 @@ backupRegExp(BackupRegExpParam param)
FUNCTION_LOG_RETURN(STRING, result); FUNCTION_LOG_RETURN(STRING, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Convert text backup type to an enum and back
***********************************************************************************************************************************/
BackupType BackupType
backupType(const String *type) backupType(const String *type)
{ {

View File

@ -26,8 +26,9 @@ typedef enum
STRING_DECLARE(BACKUP_TYPE_INCR_STR); STRING_DECLARE(BACKUP_TYPE_INCR_STR);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Returns an anchored regex string for filtering backups based on the type (at least one type is required to be true) Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Returns an anchored regex string for filtering backups based on the type (at least one type is required to be true)
typedef struct BackupRegExpParam typedef struct BackupRegExpParam
{ {
bool full; bool full;
@ -41,9 +42,7 @@ typedef struct BackupRegExpParam
String *backupRegExp(BackupRegExpParam param); String *backupRegExp(BackupRegExpParam param);
/*********************************************************************************************************************************** // Convert text backup type to an enum and back
Convert text backup type to an enum and back
***********************************************************************************************************************************/
BackupType backupType(const String *type); BackupType backupType(const String *type);
const String *backupTypeStr(BackupType type); const String *backupTypeStr(BackupType type);

View File

@ -33,9 +33,7 @@ segmentNumber(const String *pgFile)
FUNCTION_TEST_RETURN(regExpMatchOne(STRDEF("\\.[0-9]+$"), pgFile) ? cvtZToUInt(strrchr(strPtr(pgFile), '.') + 1) : 0); FUNCTION_TEST_RETURN(regExpMatchOne(STRDEF("\\.[0-9]+$"), pgFile) ? cvtZToUInt(strrchr(strPtr(pgFile), '.') + 1) : 0);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Copy a file from the PostgreSQL data directory to the repository
***********************************************************************************************************************************/
BackupFileResult BackupFileResult
backupFile( backupFile(
const String *pgFile, bool pgFileIgnoreMissing, uint64_t pgFileSize, const String *pgFileChecksum, bool pgFileChecksumPage, const String *pgFile, bool pgFileIgnoreMissing, uint64_t pgFileSize, const String *pgFileChecksum, bool pgFileChecksumPage,

View File

@ -23,6 +23,7 @@ typedef enum
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Copy a file from the PostgreSQL data directory to the repository
typedef struct BackupFileResult typedef struct BackupFileResult
{ {
BackupCopyResult backupCopyResult; BackupCopyResult backupCopyResult;

View File

@ -216,9 +216,7 @@ pageChecksumResult(THIS_VOID)
FUNCTION_LOG_RETURN(VARIANT, varNewKv(result)); FUNCTION_LOG_RETURN(VARIANT, varNewKv(result));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
pageChecksumNew(unsigned int segmentNo, unsigned int segmentPageTotal, uint64_t lsnLimit) pageChecksumNew(unsigned int segmentNo, unsigned int segmentPageTotal, uint64_t lsnLimit)
{ {

View File

@ -15,7 +15,7 @@ Filter type constant
STRING_DECLARE(PAGE_CHECKSUM_FILTER_TYPE_STR); STRING_DECLARE(PAGE_CHECKSUM_FILTER_TYPE_STR);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Constructor Constructors
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
IoFilter *pageChecksumNew(unsigned int segmentNo, unsigned int segmentPageTotal, uint64_t lsnLimit); IoFilter *pageChecksumNew(unsigned int segmentNo, unsigned int segmentPageTotal, uint64_t lsnLimit);
IoFilter *pageChecksumNewVar(const VariantList *paramList); IoFilter *pageChecksumNewVar(const VariantList *paramList);

View File

@ -17,9 +17,7 @@ Constants
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
STRING_EXTERN(PROTOCOL_COMMAND_BACKUP_FILE_STR, PROTOCOL_COMMAND_BACKUP_FILE); STRING_EXTERN(PROTOCOL_COMMAND_BACKUP_FILE_STR, PROTOCOL_COMMAND_BACKUP_FILE);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process protocol requests
***********************************************************************************************************************************/
bool bool
backupProtocol(const String *command, const VariantList *paramList, ProtocolServer *server) backupProtocol(const String *command, const VariantList *paramList, ProtocolServer *server)
{ {

View File

@ -17,6 +17,7 @@ Constants
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process protocol requests
bool backupProtocol(const String *command, const VariantList *paramList, ProtocolServer *server); bool backupProtocol(const String *command, const VariantList *paramList, ProtocolServer *server);
#endif #endif

View File

@ -144,9 +144,7 @@ checkPrimary(const DbGetResult dbGroup)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Perform standard checks
***********************************************************************************************************************************/
void void
cmdCheck(void) cmdCheck(void)
{ {

View File

@ -7,6 +7,7 @@ Check Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Perform standard checks
void cmdCheck(void); void cmdCheck(void);
#endif #endif

View File

@ -40,9 +40,7 @@ checkArchiveCommand(const String *archiveCommand)
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Check the database path and version are configured correctly
***********************************************************************************************************************************/
void void
checkDbConfig(const unsigned int pgVersion, const unsigned int dbIdx, const Db *dbObject, bool isStandby) checkDbConfig(const unsigned int pgVersion, const unsigned int dbIdx, const Db *dbObject, bool isStandby)
{ {
@ -96,9 +94,7 @@ checkDbConfig(const unsigned int pgVersion, const unsigned int dbIdx, const Db *
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Validate the archive and backup info files
***********************************************************************************************************************************/
void void
checkStanzaInfo(const InfoPgData *archiveInfo, const InfoPgData *backupInfo) checkStanzaInfo(const InfoPgData *archiveInfo, const InfoPgData *backupInfo)
{ {
@ -126,9 +122,7 @@ checkStanzaInfo(const InfoPgData *archiveInfo, const InfoPgData *backupInfo)
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Load and validate the database data of the info files against each other and the current database
***********************************************************************************************************************************/
void void
checkStanzaInfoPg( checkStanzaInfoPg(
const Storage *storage, const unsigned int pgVersion, const uint64_t pgSystemId, CipherType cipherType, const Storage *storage, const unsigned int pgVersion, const uint64_t pgSystemId, CipherType cipherType,

View File

@ -11,8 +11,13 @@ Check Command Common
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Check the database path and version are configured correctly
void checkDbConfig(const unsigned int pgVersion, const unsigned int dbIdx, const Db *dbObject, bool isStandby); void checkDbConfig(const unsigned int pgVersion, const unsigned int dbIdx, const Db *dbObject, bool isStandby);
// Validate the archive and backup info files
void checkStanzaInfo(const InfoPgData *archiveInfo, const InfoPgData *backupInfo); void checkStanzaInfo(const InfoPgData *archiveInfo, const InfoPgData *backupInfo);
// Load and validate the database data of the info files against each other and the current database
void checkStanzaInfoPg( void checkStanzaInfoPg(
const Storage *storage, const unsigned int pgVersion, const uint64_t pgSystemId, CipherType cipherType, const Storage *storage, const unsigned int pgVersion, const uint64_t pgSystemId, CipherType cipherType,
const String *cipherPass); const String *cipherPass);

View File

@ -20,9 +20,7 @@ Track time command started
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
static TimeMSec timeBegin; static TimeMSec timeBegin;
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Capture time at the very start of main so total time is more accurate
***********************************************************************************************************************************/
void void
cmdInit(void) cmdInit(void)
{ {
@ -33,9 +31,7 @@ cmdInit(void)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Begin the command
***********************************************************************************************************************************/
void void
cmdBegin(bool logOption) cmdBegin(bool logOption)
{ {
@ -168,9 +164,7 @@ cmdBegin(bool logOption)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
End the command
***********************************************************************************************************************************/
void void
cmdEnd(int code, const String *errorMessage) cmdEnd(int code, const String *errorMessage)
{ {

View File

@ -9,9 +9,13 @@ Common Command Routines
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Capture time at the very start of main so total time is more accurate
void cmdInit(void); void cmdInit(void);
// Begin the command
void cmdBegin(bool logOption); void cmdBegin(bool logOption);
// End the command
void cmdEnd(int code, const String *errorMessage); void cmdEnd(int code, const String *errorMessage);
#endif #endif

View File

@ -8,9 +8,7 @@ Common Handler for Control Commands
#include "config/config.h" #include "config/config.h"
#include "storage/helper.h" #include "storage/helper.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Create the stop filename
***********************************************************************************************************************************/
String * String *
lockStopFileName(const String *stanza) lockStopFileName(const String *stanza)
{ {
@ -24,9 +22,7 @@ lockStopFileName(const String *stanza)
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Test for the existence of a stop file
***********************************************************************************************************************************/
void void
lockStopTest(void) lockStopTest(void)
{ {

View File

@ -14,7 +14,10 @@ Constants
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Create the stop filename
String *lockStopFileName(const String *stanza); String *lockStopFileName(const String *stanza);
// Test for the existence of a stop file
void lockStopTest(void); void lockStopTest(void);
#endif #endif

View File

@ -9,6 +9,7 @@ Start Command
#include "storage/helper.h" #include "storage/helper.h"
#include "storage/storage.h" #include "storage/storage.h"
/**********************************************************************************************************************************/
void void
cmdStart(void) cmdStart(void)
{ {

View File

@ -18,6 +18,7 @@ Stop Command
#include "storage/storage.h" #include "storage/storage.h"
#include "storage/storage.intern.h" #include "storage/storage.intern.h"
/**********************************************************************************************************************************/
void void
cmdStop(void) cmdStop(void)
{ {

View File

@ -634,9 +634,7 @@ removeExpiredBackup(InfoBackup *infoBackup)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Expire backups and archives
***********************************************************************************************************************************/
void void
cmdExpire(void) cmdExpire(void)
{ {

View File

@ -7,6 +7,7 @@ Expire Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Expire backups and archives
void cmdExpire(void); void cmdExpire(void);
#endif #endif

View File

@ -365,9 +365,7 @@ helpRender(void)
FUNCTION_LOG_RETURN(STRING, result); FUNCTION_LOG_RETURN(STRING, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Render help and output to stdout
***********************************************************************************************************************************/
void void
cmdHelp(void) cmdHelp(void)
{ {

View File

@ -7,6 +7,7 @@ Help Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Render help and output to stdout
void cmdHelp(void); void cmdHelp(void);
#endif #endif

View File

@ -813,9 +813,7 @@ infoRender(void)
FUNCTION_LOG_RETURN(STRING, result); FUNCTION_LOG_RETURN(STRING, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Render info and output to stdout
***********************************************************************************************************************************/
void void
cmdInfo(void) cmdInfo(void)
{ {

View File

@ -7,6 +7,7 @@ Info Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Render info and output to stdout
void cmdInfo(void); void cmdInfo(void);
#endif #endif

View File

@ -16,9 +16,7 @@ Local Command
#include "protocol/helper.h" #include "protocol/helper.h"
#include "protocol/server.h" #include "protocol/server.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Remote command
***********************************************************************************************************************************/
void void
cmdLocal(int handleRead, int handleWrite) cmdLocal(int handleRead, int handleWrite)
{ {

View File

@ -7,6 +7,7 @@ Local Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Local command
void cmdLocal(int handleRead, int handleWrite); void cmdLocal(int handleRead, int handleWrite);
#endif #endif

View File

@ -17,9 +17,7 @@ Remote Command
#include "protocol/server.h" #include "protocol/server.h"
#include "storage/remote/protocol.h" #include "storage/remote/protocol.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Remote command
***********************************************************************************************************************************/
void void
cmdRemote(int handleRead, int handleWrite) cmdRemote(int handleRead, int handleWrite)
{ {

View File

@ -7,6 +7,7 @@ Remote Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Remote command
void cmdRemote(int handleRead, int handleWrite); void cmdRemote(int handleRead, int handleWrite);
#endif #endif

View File

@ -18,9 +18,7 @@ Restore File
#include "config/config.h" #include "config/config.h"
#include "storage/helper.h" #include "storage/helper.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Copy a file from the backup to the specified destination
***********************************************************************************************************************************/
bool bool
restoreFile( restoreFile(
const String *repoFile, const String *repoFileReference, CompressType repoFileCompressType, const String *pgFile, const String *repoFile, const String *repoFileReference, CompressType repoFileCompressType, const String *pgFile,

View File

@ -12,6 +12,7 @@ Restore File
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Copy a file from the backup to the specified destination
bool restoreFile( bool restoreFile(
const String *repoFile, const String *repoFileReference, CompressType repoFileCompressType, const String *pgFile, const String *repoFile, const String *repoFileReference, CompressType repoFileCompressType, const String *pgFile,
const String *pgFileChecksum, bool pgFileZero, uint64_t pgFileSize, time_t pgFileModified, mode_t pgFileMode, const String *pgFileChecksum, bool pgFileZero, uint64_t pgFileSize, time_t pgFileModified, mode_t pgFileMode,

View File

@ -17,9 +17,7 @@ Constants
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
STRING_EXTERN(PROTOCOL_COMMAND_RESTORE_FILE_STR, PROTOCOL_COMMAND_RESTORE_FILE); STRING_EXTERN(PROTOCOL_COMMAND_RESTORE_FILE_STR, PROTOCOL_COMMAND_RESTORE_FILE);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process protocol requests
***********************************************************************************************************************************/
bool bool
restoreProtocol(const String *command, const VariantList *paramList, ProtocolServer *server) restoreProtocol(const String *command, const VariantList *paramList, ProtocolServer *server)
{ {

View File

@ -17,6 +17,7 @@ Constants
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process protocol requests
bool restoreProtocol(const String *command, const VariantList *paramList, ProtocolServer *server); bool restoreProtocol(const String *command, const VariantList *paramList, ProtocolServer *server);
#endif #endif

View File

@ -1995,9 +1995,7 @@ static ProtocolParallelJob *restoreJobCallback(void *data, unsigned int clientId
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Restore a backup
***********************************************************************************************************************************/
void void
cmdRestore(void) cmdRestore(void)
{ {

View File

@ -7,6 +7,7 @@ Restore Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Restore a backup
void cmdRestore(void); void cmdRestore(void);
#endif #endif

View File

@ -14,9 +14,7 @@ Stanza Commands Handler
#include "postgres/version.h" #include "postgres/version.h"
#include "storage/helper.h" #include "storage/helper.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Generate a cipher
***********************************************************************************************************************************/
String * String *
cipherPassGen(CipherType cipherType) cipherPassGen(CipherType cipherType)
{ {
@ -38,9 +36,7 @@ cipherPassGen(CipherType cipherType)
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Validate and return database information
***********************************************************************************************************************************/
PgControl PgControl
pgValidate(void) pgValidate(void)
{ {

View File

@ -10,7 +10,10 @@ Stanza Commands Handler
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Generate a cipher
String *cipherPassGen(CipherType cipherType); String *cipherPassGen(CipherType cipherType);
// Validate and return database information
PgControl pgValidate(void); PgControl pgValidate(void);
#endif #endif

View File

@ -23,9 +23,7 @@ Stanza Create Command
#include "protocol/helper.h" #include "protocol/helper.h"
#include "storage/helper.h" #include "storage/helper.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process stanza-create
***********************************************************************************************************************************/
void void
cmdStanzaCreate(void) cmdStanzaCreate(void)
{ {

View File

@ -7,6 +7,7 @@ Stanza Create Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process stanza-create
void cmdStanzaCreate(void); void cmdStanzaCreate(void);
#endif #endif

View File

@ -127,9 +127,7 @@ stanzaDelete(const Storage *storageRepoWriteStanza, const StringList *archiveLis
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process stanza-delete
***********************************************************************************************************************************/
void void
cmdStanzaDelete(void) cmdStanzaDelete(void)
{ {

View File

@ -7,6 +7,7 @@ Stanza Delete Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process stanza-delete
void cmdStanzaDelete(void); void cmdStanzaDelete(void);
#endif #endif

View File

@ -23,9 +23,7 @@ Stanza Update Command
#include "protocol/helper.h" #include "protocol/helper.h"
#include "storage/helper.h" #include "storage/helper.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process stanza-upgrade
***********************************************************************************************************************************/
void void
cmdStanzaUpgrade(void) cmdStanzaUpgrade(void)
{ {

View File

@ -7,6 +7,7 @@ Stanza Upgrade Command
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process stanza-upgrade
void cmdStanzaUpgrade(void); void cmdStanzaUpgrade(void);
#endif #endif

View File

@ -9,9 +9,7 @@ Gz Common
#include "common/debug.h" #include "common/debug.h"
#include "common/memContext.h" #include "common/memContext.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process gz errors
***********************************************************************************************************************************/
int int
gzError(int error) gzError(int error)
{ {

View File

@ -18,6 +18,7 @@ Constants
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process gz errors
int gzError(int error); int gzError(int error);
#endif #endif

View File

@ -158,9 +158,7 @@ gzCompressInputSame(const THIS_VOID)
FUNCTION_TEST_RETURN(this->inputSame); FUNCTION_TEST_RETURN(this->inputSame);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
gzCompressNew(int level) gzCompressNew(int level)
{ {

View File

@ -141,9 +141,7 @@ gzDecompressInputSame(const THIS_VOID)
FUNCTION_TEST_RETURN(this->inputSame); FUNCTION_TEST_RETURN(this->inputSame);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
gzDecompressNew(void) gzDecompressNew(void)
{ {

View File

@ -10,9 +10,7 @@ LZ4 Common
#include "common/compress/lz4/common.h" #include "common/compress/lz4/common.h"
#include "common/debug.h" #include "common/debug.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process lz4 errors
***********************************************************************************************************************************/
LZ4F_errorCode_t LZ4F_errorCode_t
lz4Error(LZ4F_errorCode_t error) lz4Error(LZ4F_errorCode_t error)
{ {

View File

@ -14,6 +14,7 @@ LZ4 extension
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Process lz4 errors
size_t lz4Error(size_t error); size_t lz4Error(size_t error);
#endif // HAVE_LIBLZ4 #endif // HAVE_LIBLZ4

View File

@ -237,9 +237,7 @@ lz4CompressInputSame(const THIS_VOID)
FUNCTION_TEST_RETURN(this->inputSame); FUNCTION_TEST_RETURN(this->inputSame);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
lz4CompressNew(int level) lz4CompressNew(int level)
{ {

View File

@ -155,9 +155,7 @@ lz4DecompressInputSame(const THIS_VOID)
FUNCTION_TEST_RETURN(this->inputSame); FUNCTION_TEST_RETURN(this->inputSame);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
lz4DecompressNew(void) lz4DecompressNew(void)
{ {

View File

@ -380,9 +380,7 @@ cipherBlockInputSame(const THIS_VOID)
FUNCTION_TEST_RETURN(this->inputSame); FUNCTION_TEST_RETURN(this->inputSame);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New block encrypt/decrypt object
***********************************************************************************************************************************/
IoFilter * IoFilter *
cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const String *digestName) cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const String *digestName)
{ {
@ -464,9 +462,7 @@ cipherBlockNewVar(const VariantList *paramList)
BUFSTR(varStr(varLstGet(paramList, 2))), varLstGet(paramList, 3) == NULL ? NULL : varStr(varLstGet(paramList, 3))); BUFSTR(varStr(varLstGet(paramList, 2))), varLstGet(paramList, 3) == NULL ? NULL : varStr(varLstGet(paramList, 3)));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Helper function to add a block cipher to an io object
***********************************************************************************************************************************/
IoFilterGroup * IoFilterGroup *
cipherBlockFilterGroupAdd(IoFilterGroup *filterGroup, CipherType type, CipherMode mode, const String *pass) cipherBlockFilterGroupAdd(IoFilterGroup *filterGroup, CipherType type, CipherMode mode, const String *pass)
{ {

View File

@ -14,7 +14,7 @@ Filter type constant
STRING_DECLARE(CIPHER_BLOCK_FILTER_TYPE_STR); STRING_DECLARE(CIPHER_BLOCK_FILTER_TYPE_STR);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Constructor Constructors
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
IoFilter *cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const String *digestName); IoFilter *cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const String *digestName);
IoFilter *cipherBlockNewVar(const VariantList *paramList); IoFilter *cipherBlockNewVar(const VariantList *paramList);
@ -22,6 +22,7 @@ IoFilter *cipherBlockNewVar(const VariantList *paramList);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Helper functions Helper functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Add a block cipher to an io object
IoFilterGroup *cipherBlockFilterGroupAdd(IoFilterGroup *filterGroup, CipherType type, CipherMode mode, const String *pass); IoFilterGroup *cipherBlockFilterGroupAdd(IoFilterGroup *filterGroup, CipherType type, CipherMode mode, const String *pass);
#endif #endif

View File

@ -25,9 +25,7 @@ Flag to indicate if OpenSSL has already been initialized
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
static bool cryptoInitDone = false; static bool cryptoInitDone = false;
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Throw crypto errors
***********************************************************************************************************************************/
void void
cryptoError(bool error, const char *description) cryptoError(bool error, const char *description)
{ {
@ -56,9 +54,7 @@ cryptoErrorCode(unsigned long code, const char *description)
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get cipher type or name
***********************************************************************************************************************************/
CipherType CipherType
cipherType(const String *name) cipherType(const String *name)
{ {
@ -95,9 +91,7 @@ cipherTypeName(CipherType type)
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Initialize crypto
***********************************************************************************************************************************/
void void
cryptoInit(void) cryptoInit(void)
{ {
@ -125,9 +119,7 @@ cryptoInit(void)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Has crypto been initialized?
***********************************************************************************************************************************/
bool bool
cryptoIsInit(void) cryptoIsInit(void)
{ {
@ -135,9 +127,7 @@ cryptoIsInit(void)
FUNCTION_TEST_RETURN(cryptoInitDone); FUNCTION_TEST_RETURN(cryptoInitDone);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Generate random bytes
***********************************************************************************************************************************/
void void
cryptoRandomBytes(unsigned char *buffer, size_t size) cryptoRandomBytes(unsigned char *buffer, size_t size)
{ {

View File

@ -32,15 +32,21 @@ typedef enum
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Initialize crypto
void cryptoInit(void); void cryptoInit(void);
// Has crypto been initialized?
bool cryptoIsInit(void); bool cryptoIsInit(void);
// Throw crypto errors
void cryptoError(bool error, const char *description); void cryptoError(bool error, const char *description);
void cryptoErrorCode(unsigned long code, const char *description) __attribute__((__noreturn__)); void cryptoErrorCode(unsigned long code, const char *description) __attribute__((__noreturn__));
// Get cipher type or name
CipherType cipherType(const String *name); CipherType cipherType(const String *name);
const String *cipherTypeName(CipherType type); const String *cipherTypeName(CipherType type);
// Generate random bytes
void cryptoRandomBytes(unsigned char *buffer, size_t size); void cryptoRandomBytes(unsigned char *buffer, size_t size);
#endif #endif

View File

@ -133,9 +133,7 @@ cryptoHashResult(THIS_VOID)
FUNCTION_LOG_RETURN(VARIANT, varNewStr(bufHex(cryptoHash(this)))); FUNCTION_LOG_RETURN(VARIANT, varNewStr(bufHex(cryptoHash(this))));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
cryptoHashNew(const String *type) cryptoHashNew(const String *type)
{ {
@ -191,9 +189,7 @@ cryptoHashNewVar(const VariantList *paramList)
return cryptoHashNew(varStr(varLstGet(paramList, 0))); return cryptoHashNew(varStr(varLstGet(paramList, 0)));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get hash for one C buffer
***********************************************************************************************************************************/
Buffer * Buffer *
cryptoHashOne(const String *type, const Buffer *message) cryptoHashOne(const String *type, const Buffer *message)
{ {
@ -227,9 +223,7 @@ cryptoHashOne(const String *type, const Buffer *message)
FUNCTION_LOG_RETURN(BUFFER, result); FUNCTION_LOG_RETURN(BUFFER, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get hmac for one message/key
***********************************************************************************************************************************/
Buffer * Buffer *
cryptoHmacOne(const String *type, const Buffer *key, const Buffer *message) cryptoHmacOne(const String *type, const Buffer *key, const Buffer *message)
{ {

View File

@ -48,7 +48,7 @@ Hash type sizes
#define HASH_TYPE_SHA256_SIZE_HEX (HASH_TYPE_SHA256_SIZE * 2) #define HASH_TYPE_SHA256_SIZE_HEX (HASH_TYPE_SHA256_SIZE * 2)
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Constructor Constructors
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
IoFilter *cryptoHashNew(const String *type); IoFilter *cryptoHashNew(const String *type);
IoFilter *cryptoHashNewVar(const VariantList *paramList); IoFilter *cryptoHashNewVar(const VariantList *paramList);
@ -56,7 +56,10 @@ IoFilter *cryptoHashNewVar(const VariantList *paramList);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Helper functions Helper functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Get hash for one buffer
Buffer *cryptoHashOne(const String *type, const Buffer *message); Buffer *cryptoHashOne(const String *type, const Buffer *message);
// Get hmac for one message/key
Buffer *cryptoHmacOne(const String *type, const Buffer *key, const Buffer *message); Buffer *cryptoHmacOne(const String *type, const Buffer *key, const Buffer *message);
#endif #endif

View File

@ -7,9 +7,7 @@ Debug Routines
#include "common/debug.h" #include "common/debug.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Convert object to a zero-terminated string for logging
***********************************************************************************************************************************/
size_t size_t
objToLog(const void *object, const char *objectName, char *buffer, size_t bufferSize) objToLog(const void *object, const char *objectName, char *buffer, size_t bufferSize)
{ {
@ -23,9 +21,7 @@ objToLog(const void *object, const char *objectName, char *buffer, size_t buffer
return result; return result;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Convert pointer to a zero-terminated string for logging
***********************************************************************************************************************************/
size_t size_t
ptrToLog(const void *pointer, const char *pointerName, char *buffer, size_t bufferSize) ptrToLog(const void *pointer, const char *pointerName, char *buffer, size_t bufferSize)
{ {
@ -39,18 +35,14 @@ ptrToLog(const void *pointer, const char *pointerName, char *buffer, size_t buff
return result; return result;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Convert zero-terminated string for logging
***********************************************************************************************************************************/
size_t size_t
strzToLog(const char *string, char *buffer, size_t bufferSize) strzToLog(const char *string, char *buffer, size_t bufferSize)
{ {
return (size_t)snprintf(buffer, bufferSize, string == NULL ? "%s" : "\"%s\"", string == NULL ? NULL_Z : string); return (size_t)snprintf(buffer, bufferSize, string == NULL ? "%s" : "\"%s\"", string == NULL ? NULL_Z : string);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Convert a type name to a zero-terminated string for logging
***********************************************************************************************************************************/
size_t size_t
typeToLog(const char *typeName, char *buffer, size_t bufferSize) typeToLog(const char *typeName, char *buffer, size_t bufferSize)
{ {

View File

@ -114,9 +114,16 @@ FUNCTION_LOG_VOID() is provided as a shortcut for functions that have no paramet
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions and macros to render various data types Functions and macros to render various data types
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Convert object to a zero-terminated string for logging
size_t objToLog(const void *object, const char *objectName, char *buffer, size_t bufferSize); size_t objToLog(const void *object, const char *objectName, char *buffer, size_t bufferSize);
// Convert pointer to a zero-terminated string for logging
size_t ptrToLog(const void *pointer, const char *pointerName, char *buffer, size_t bufferSize); size_t ptrToLog(const void *pointer, const char *pointerName, char *buffer, size_t bufferSize);
// Convert zero-terminated string for logging
size_t strzToLog(const char *string, char *buffer, size_t bufferSize); size_t strzToLog(const char *string, char *buffer, size_t bufferSize);
// Convert a type name to a zero-terminated string for logging
size_t typeToLog(const char *typeName, char *buffer, size_t bufferSize); size_t typeToLog(const char *typeName, char *buffer, size_t bufferSize);
#define FUNCTION_LOG_BOOL_TYPE \ #define FUNCTION_LOG_BOOL_TYPE \

View File

@ -17,9 +17,7 @@ Macro to handle invalid encode type errors
#define ENCODE_TYPE_INVALID_ERROR(encodeType) \ #define ENCODE_TYPE_INVALID_ERROR(encodeType) \
THROW_FMT(AssertError, "invalid encode type %u", encodeType); THROW_FMT(AssertError, "invalid encode type %u", encodeType);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Encode binary data to a printable string
***********************************************************************************************************************************/
void void
encodeToStr(EncodeType encodeType, const unsigned char *source, size_t sourceSize, char *destination) encodeToStr(EncodeType encodeType, const unsigned char *source, size_t sourceSize, char *destination)
{ {
@ -38,9 +36,7 @@ encodeToStr(EncodeType encodeType, const unsigned char *source, size_t sourceSiz
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Size of the string returned by encodeToStr()
***********************************************************************************************************************************/
size_t size_t
encodeToStrSize(EncodeType encodeType, size_t sourceSize) encodeToStrSize(EncodeType encodeType, size_t sourceSize)
{ {
@ -59,9 +55,7 @@ encodeToStrSize(EncodeType encodeType, size_t sourceSize)
FUNCTION_TEST_RETURN(destinationSize); FUNCTION_TEST_RETURN(destinationSize);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Decode a string to binary data
***********************************************************************************************************************************/
void void
decodeToBin(EncodeType encodeType, const char *source, unsigned char *destination) decodeToBin(EncodeType encodeType, const char *source, unsigned char *destination)
{ {
@ -79,9 +73,7 @@ decodeToBin(EncodeType encodeType, const char *source, unsigned char *destinatio
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Size of the binary data returned by decodeToBin()
***********************************************************************************************************************************/
size_t size_t
decodeToBinSize(EncodeType encodeType, const char *source) decodeToBinSize(EncodeType encodeType, const char *source)
{ {
@ -100,9 +92,7 @@ decodeToBinSize(EncodeType encodeType, const char *source)
FUNCTION_TEST_RETURN(destinationSize); FUNCTION_TEST_RETURN(destinationSize);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Check that the encoded string is valid
***********************************************************************************************************************************/
bool bool
decodeToBinValid(EncodeType encodeType, const char *source) decodeToBinValid(EncodeType encodeType, const char *source)
{ {
@ -126,9 +116,7 @@ decodeToBinValid(EncodeType encodeType, const char *source)
FUNCTION_TEST_RETURN(valid); FUNCTION_TEST_RETURN(valid);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Validate the encoded string
***********************************************************************************************************************************/
void void
decodeToBinValidate(EncodeType encodeType, const char *source) decodeToBinValidate(EncodeType encodeType, const char *source)
{ {

View File

@ -9,16 +9,30 @@ These high-level functions are preferred to the low-level functions for each enc
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Encoding types Encoding types
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef enum {encodeBase64} EncodeType; typedef enum
{
encodeBase64
} EncodeType;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Encode binary data to a printable string
void encodeToStr(EncodeType encodeType, const unsigned char *source, size_t sourceSize, char *destination); void encodeToStr(EncodeType encodeType, const unsigned char *source, size_t sourceSize, char *destination);
// Size of the string returned by encodeToStr()
size_t encodeToStrSize(EncodeType encodeType, size_t sourceSize); size_t encodeToStrSize(EncodeType encodeType, size_t sourceSize);
// Decode a string to binary data
void decodeToBin(EncodeType encodeType, const char *source, unsigned char *destination); void decodeToBin(EncodeType encodeType, const char *source, unsigned char *destination);
// Size of the binary data returned by decodeToBin()
size_t decodeToBinSize(EncodeType encodeType, const char *source); size_t decodeToBinSize(EncodeType encodeType, const char *source);
// Check that the encoded string is valid
bool decodeToBinValid(EncodeType encodeType, const char *source); bool decodeToBinValid(EncodeType encodeType, const char *source);
// Validate the encoded string
void decodeToBinValidate(EncodeType encodeType, const char *source); void decodeToBinValidate(EncodeType encodeType, const char *source);
#endif #endif

View File

@ -9,9 +9,7 @@ Base64 Binary to String Encode/Decode
#include "common/debug.h" #include "common/debug.h"
#include "common/error.h" #include "common/error.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Encode binary data to a printable string
***********************************************************************************************************************************/
static const char encodeBase64Lookup[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char encodeBase64Lookup[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
void void
@ -72,9 +70,7 @@ encodeToStrBase64(const unsigned char *source, size_t sourceSize, char *destinat
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Size of the destination param required by encodeToStrBase64() minus space for the null terminator
***********************************************************************************************************************************/
size_t size_t
encodeToStrSizeBase64(size_t sourceSize) encodeToStrSizeBase64(size_t sourceSize)
{ {
@ -93,9 +89,7 @@ encodeToStrSizeBase64(size_t sourceSize)
FUNCTION_TEST_RETURN(encodeGroupTotal * 4); FUNCTION_TEST_RETURN(encodeGroupTotal * 4);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Decode a string to binary data
***********************************************************************************************************************************/
static const int decodeBase64Lookup[256] = static const int decodeBase64Lookup[256] =
{ {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@ -154,9 +148,7 @@ decodeToBinBase64(const char *source, unsigned char *destination)
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Size of the destination param required by decodeToBinBase64()
***********************************************************************************************************************************/
size_t size_t
decodeToBinSizeBase64(const char *source) decodeToBinSizeBase64(const char *source)
{ {
@ -184,9 +176,7 @@ decodeToBinSizeBase64(const char *source)
FUNCTION_TEST_RETURN(destinationSize); FUNCTION_TEST_RETURN(destinationSize);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Validate the encoded string
***********************************************************************************************************************************/
void void
decodeToBinValidateBase64(const char *source) decodeToBinValidateBase64(const char *source)
{ {

View File

@ -9,10 +9,19 @@ The high-level functions in encode.c should be used in preference to these low-l
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Encode binary data to a printable string
void encodeToStrBase64(const unsigned char *source, size_t sourceSize, char *destination); void encodeToStrBase64(const unsigned char *source, size_t sourceSize, char *destination);
// Size of the destination param required by encodeToStrBase64() minus space for the null terminator
size_t encodeToStrSizeBase64(size_t sourceSize); size_t encodeToStrSizeBase64(size_t sourceSize);
// Decode a string to binary data
void decodeToBinBase64(const char *source, unsigned char *destination); void decodeToBinBase64(const char *source, unsigned char *destination);
// Size of the destination param required by decodeToBinBase64()
size_t decodeToBinSizeBase64(const char *source); size_t decodeToBinSizeBase64(const char *source);
// Validate the encoded string
void decodeToBinValidateBase64(const char *source); void decodeToBinValidateBase64(const char *source);
#endif #endif

View File

@ -88,18 +88,14 @@ static char messageBuffer[ERROR_MESSAGE_BUFFER_SIZE];
static char messageBufferTemp[ERROR_MESSAGE_BUFFER_SIZE]; static char messageBufferTemp[ERROR_MESSAGE_BUFFER_SIZE];
static char stackTraceBuffer[ERROR_MESSAGE_BUFFER_SIZE]; static char stackTraceBuffer[ERROR_MESSAGE_BUFFER_SIZE];
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error type code
***********************************************************************************************************************************/
int int
errorTypeCode(const ErrorType *errorType) errorTypeCode(const ErrorType *errorType)
{ {
return errorType->code; return errorType->code;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get error type using a code
***********************************************************************************************************************************/
const ErrorType * const ErrorType *
errorTypeFromCode(int code) errorTypeFromCode(int code)
{ {
@ -122,35 +118,27 @@ errorTypeFromCode(int code)
return result; return result;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error type name
***********************************************************************************************************************************/
const char * const char *
errorTypeName(const ErrorType *errorType) errorTypeName(const ErrorType *errorType)
{ {
return errorType->name; return errorType->name;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error type parent
***********************************************************************************************************************************/
const ErrorType * const ErrorType *
errorTypeParent(const ErrorType *errorType) errorTypeParent(const ErrorType *errorType)
{ {
return errorType->parentType; return errorType->parentType;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get the depth of the current try statement (0 if none)
***********************************************************************************************************************************/
unsigned int errorTryDepth(void) unsigned int errorTryDepth(void)
{ {
return (unsigned int)errorContext.tryTotal; return (unsigned int)errorContext.tryTotal;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Does the child error type extend the parent error type?
***********************************************************************************************************************************/
bool bool
errorTypeExtends(const ErrorType *child, const ErrorType *parent) errorTypeExtends(const ErrorType *child, const ErrorType *parent)
{ {
@ -170,81 +158,63 @@ errorTypeExtends(const ErrorType *child, const ErrorType *parent)
return false; return false;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error type
***********************************************************************************************************************************/
const ErrorType * const ErrorType *
errorType(void) errorType(void)
{ {
return errorContext.error.errorType; return errorContext.error.errorType;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error code (pulled from error type)
***********************************************************************************************************************************/
int int
errorCode(void) errorCode(void)
{ {
return errorTypeCode(errorType()); return errorTypeCode(errorType());
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error filename
***********************************************************************************************************************************/
const char * const char *
errorFileName(void) errorFileName(void)
{ {
return errorContext.error.fileName; return errorContext.error.fileName;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error function name
***********************************************************************************************************************************/
const char * const char *
errorFunctionName(void) errorFunctionName(void)
{ {
return errorContext.error.functionName; return errorContext.error.functionName;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error file line number
***********************************************************************************************************************************/
int int
errorFileLine(void) errorFileLine(void)
{ {
return errorContext.error.fileLine; return errorContext.error.fileLine;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error message
***********************************************************************************************************************************/
const char * const char *
errorMessage(void) errorMessage(void)
{ {
return errorContext.error.message; return errorContext.error.message;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error name (pulled from error type)
***********************************************************************************************************************************/
const char * const char *
errorName(void) errorName(void)
{ {
return errorTypeName(errorType()); return errorTypeName(errorType());
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Error stack trace
***********************************************************************************************************************************/
const char * const char *
errorStackTrace(void) errorStackTrace(void)
{ {
return errorContext.error.stackTrace; return errorContext.error.stackTrace;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Is this error an instance of the error type?
***********************************************************************************************************************************/
bool bool
errorInstanceOf(const ErrorType *errorTypeTest) errorInstanceOf(const ErrorType *errorTypeTest)
{ {
@ -260,18 +230,14 @@ errorInternalState(void)
return errorContext.tryList[errorContext.tryTotal].state; return errorContext.tryList[errorContext.tryTotal].state;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
True when in try state
***********************************************************************************************************************************/
bool bool
errorInternalStateTry(void) errorInternalStateTry(void)
{ {
return errorInternalState() == errorStateTry; return errorInternalState() == errorStateTry;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
True when in catch state and the expected error matches
***********************************************************************************************************************************/
bool bool
errorInternalStateCatch(const ErrorType *errorTypeCatch) errorInternalStateCatch(const ErrorType *errorTypeCatch)
{ {
@ -281,27 +247,21 @@ errorInternalStateCatch(const ErrorType *errorTypeCatch)
return false; return false;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
True when in final state
***********************************************************************************************************************************/
bool bool
errorInternalStateFinal(void) errorInternalStateFinal(void)
{ {
return errorInternalState() == errorStateFinal; return errorInternalState() == errorStateFinal;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Return jump buffer for current try
***********************************************************************************************************************************/
jmp_buf * jmp_buf *
errorInternalJump(void) errorInternalJump(void)
{ {
return &errorContext.jumpList[errorContext.tryTotal - 1]; return &errorContext.jumpList[errorContext.tryTotal - 1];
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Begin the try block
***********************************************************************************************************************************/
bool bool
errorInternalTry(const char *fileName, const char *functionName, int fileLine) errorInternalTry(const char *fileName, const char *functionName, int fileLine)
{ {
@ -320,9 +280,7 @@ errorInternalTry(const char *fileName, const char *functionName, int fileLine)
return true; return true;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Propagate the error up so it can be caught
***********************************************************************************************************************************/
void void
errorInternalPropagate(void) errorInternalPropagate(void)
{ {
@ -341,9 +299,7 @@ errorInternalPropagate(void)
exit(UnhandledError.code); exit(UnhandledError.code);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process the error through each try and state
***********************************************************************************************************************************/
bool bool
errorInternalProcess(bool catch) errorInternalProcess(bool catch)
{ {
@ -385,9 +341,7 @@ errorInternalProcess(bool catch)
return false; return false;
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Throw an error
***********************************************************************************************************************************/
void void
errorInternalThrow(const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *message) errorInternalThrow(const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *message)
{ {
@ -429,9 +383,7 @@ errorInternalThrowFmt(
errorInternalThrow(errorType, fileName, functionName, fileLine, messageBufferTemp); errorInternalThrow(errorType, fileName, functionName, fileLine, messageBufferTemp);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Throw a system error
***********************************************************************************************************************************/
void void
errorInternalThrowSys( errorInternalThrowSys(
#ifdef DEBUG_COVERAGE #ifdef DEBUG_COVERAGE

View File

@ -61,28 +61,55 @@ typedef struct ErrorType ErrorType;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions to get information about a generic error type Functions to get information about a generic error type
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Error type code
int errorTypeCode(const ErrorType *errorType); int errorTypeCode(const ErrorType *errorType);
// Get error type using a code
const ErrorType *errorTypeFromCode(int code); const ErrorType *errorTypeFromCode(int code);
// Error type name
const char *errorTypeName(const ErrorType *errorType); const char *errorTypeName(const ErrorType *errorType);
// Error type parent
const ErrorType *errorTypeParent(const ErrorType *errorType); const ErrorType *errorTypeParent(const ErrorType *errorType);
// Does the child error type extend the parent error type?
bool errorTypeExtends(const ErrorType *child, const ErrorType *parent); bool errorTypeExtends(const ErrorType *child, const ErrorType *parent);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions to get information about the current error Functions to get information about the current error
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Error type
const ErrorType *errorType(void); const ErrorType *errorType(void);
// Error code (pulled from error type)
int errorCode(void); int errorCode(void);
// Error filename
const char *errorFileName(void); const char *errorFileName(void);
// Error function name
const char *errorFunctionName(void); const char *errorFunctionName(void);
// Error file line number
int errorFileLine(void); int errorFileLine(void);
// Is this error an instance of the error type?
bool errorInstanceOf(const ErrorType *errorTypeTest); bool errorInstanceOf(const ErrorType *errorTypeTest);
// Error message
const char *errorMessage(void); const char *errorMessage(void);
// Error name (pulled from error type)
const char *errorName(void); const char *errorName(void);
// Error stack trace
const char *errorStackTrace(void); const char *errorStackTrace(void);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions to get information about the try stack Functions to get information about the try stack
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Get the depth of the current try statement (0 if none)
unsigned int errorTryDepth(void); unsigned int errorTryDepth(void);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
@ -233,13 +260,28 @@ Internal functions
These functions are used by the macros to implement the error handler and should never be called independently. These functions are used by the macros to implement the error handler and should never be called independently.
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Begin the try block
bool errorInternalTry(const char *fileName, const char *functionName, int fileLine); bool errorInternalTry(const char *fileName, const char *functionName, int fileLine);
// Return jump buffer for current try
jmp_buf *errorInternalJump(void); jmp_buf *errorInternalJump(void);
// True when in try state
bool errorInternalStateTry(void); bool errorInternalStateTry(void);
// True when in catch state and the expected error matches
bool errorInternalStateCatch(const ErrorType *errorTypeCatch); bool errorInternalStateCatch(const ErrorType *errorTypeCatch);
// True when in final state
bool errorInternalStateFinal(void); bool errorInternalStateFinal(void);
// Process the error through each try and state
bool errorInternalProcess(bool catch); bool errorInternalProcess(bool catch);
// Propagate the error up so it can be caught
void errorInternalPropagate(void) __attribute__((__noreturn__)); void errorInternalPropagate(void) __attribute__((__noreturn__));
// Throw an error
void errorInternalThrow( void errorInternalThrow(
const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *message) const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *message)
__attribute__((__noreturn__)); __attribute__((__noreturn__));
@ -247,6 +289,7 @@ void errorInternalThrowFmt(
const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *format, ...) const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *format, ...)
__attribute__((format(printf, 5, 6))) __attribute__((__noreturn__)); __attribute__((format(printf, 5, 6))) __attribute__((__noreturn__));
// Throw a system error
void errorInternalThrowSys( void errorInternalThrowSys(
#ifdef DEBUG_COVERAGE #ifdef DEBUG_COVERAGE
bool error, bool error,

View File

@ -105,9 +105,7 @@ OBJECT_DEFINE_FREE_RESOURCE_BEGIN(EXEC, LOG, logLevelTrace)
} }
OBJECT_DEFINE_FREE_RESOURCE_END(LOG); OBJECT_DEFINE_FREE_RESOURCE_END(LOG);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
Exec * Exec *
execNew(const String *command, const StringList *param, const String *name, TimeMSec timeout) execNew(const String *command, const StringList *param, const String *name, TimeMSec timeout)
{ {
@ -296,9 +294,7 @@ execHandleRead(const THIS_VOID)
FUNCTION_TEST_RETURN(this->handleRead); FUNCTION_TEST_RETURN(this->handleRead);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Execute command
***********************************************************************************************************************************/
void void
execOpen(Exec *this) execOpen(Exec *this)
{ {
@ -372,9 +368,7 @@ execOpen(Exec *this)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get read interface
***********************************************************************************************************************************/
IoRead * IoRead *
execIoRead(const Exec *this) execIoRead(const Exec *this)
{ {
@ -387,9 +381,7 @@ execIoRead(const Exec *this)
FUNCTION_TEST_RETURN(this->ioReadExec); FUNCTION_TEST_RETURN(this->ioReadExec);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get write interface
***********************************************************************************************************************************/
IoWrite * IoWrite *
execIoWrite(const Exec *this) execIoWrite(const Exec *this)
{ {
@ -402,9 +394,7 @@ execIoWrite(const Exec *this)
FUNCTION_TEST_RETURN(this->ioWriteExec); FUNCTION_TEST_RETURN(this->ioWriteExec);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get the object mem context
***********************************************************************************************************************************/
MemContext * MemContext *
execMemContext(const Exec *this) execMemContext(const Exec *this)
{ {

View File

@ -29,13 +29,19 @@ Exec *execNew(const String *command, const StringList *param, const String *name
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Execute command
void execOpen(Exec *this); void execOpen(Exec *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Getters Getters
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Read interface
IoRead *execIoRead(const Exec *this); IoRead *execIoRead(const Exec *this);
// Write interface
IoWrite *execIoWrite(const Exec *this); IoWrite *execIoWrite(const Exec *this);
// Exec MemContext
MemContext *execMemContext(const Exec *this); MemContext *execMemContext(const Exec *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************

View File

@ -69,9 +69,7 @@ exitOnSignal(int signalType)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Setup signal handlers
***********************************************************************************************************************************/
void void
exitInit(void) exitInit(void)
{ {
@ -87,9 +85,7 @@ exitInit(void)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Do cleanup and return result code
***********************************************************************************************************************************/
int int
exitSafe(int result, bool error, SignalType signalType) exitSafe(int result, bool error, SignalType signalType)
{ {

View File

@ -20,7 +20,10 @@ typedef enum
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Setup signal handlers
void exitInit(void); void exitInit(void);
// Do cleanup and return result code
int exitSafe(int result, bool error, SignalType signalType); int exitSafe(int result, bool error, SignalType signalType);
#endif #endif

View File

@ -11,9 +11,7 @@ Fork Handler
#include "common/error.h" #include "common/error.h"
#include "common/log.h" #include "common/log.h"
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Fork a new process and throw an error if it fails
***********************************************************************************************************************************/
int int
forkSafe(void) forkSafe(void)
{ {
@ -26,10 +24,7 @@ forkSafe(void)
FUNCTION_LOG_RETURN(INT, result); FUNCTION_LOG_RETURN(INT, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Detach a forked process so it can continue running after the parent process has exited. This is not a typical daemon startup
because the parent process may continue to run and perform work for some time.
***********************************************************************************************************************************/
void void
forkDetach(void) forkDetach(void)
{ {

View File

@ -7,7 +7,11 @@ Fork Handler
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Fork a new process and throw an error if it fails
int forkSafe(void); int forkSafe(void);
// Detach a forked process so it can continue running after the parent process has exited. This is not a typical daemon startup
// because the parent process may continue to run and perform work for some time.
void forkDetach(void); void forkDetach(void);
#endif #endif

View File

@ -26,9 +26,7 @@ struct Ini
OBJECT_DEFINE_MOVE(INI); OBJECT_DEFINE_MOVE(INI);
OBJECT_DEFINE_FREE(INI); OBJECT_DEFINE_FREE(INI);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Create a new Ini object
***********************************************************************************************************************************/
Ini * Ini *
iniNew(void) iniNew(void)
{ {
@ -84,9 +82,7 @@ iniGetInternal(const Ini *this, const String *section, const String *key, bool r
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get an ini value -- error if it does not exist
***********************************************************************************************************************************/
const String * const String *
iniGet(const Ini *this, const String *section, const String *key) iniGet(const Ini *this, const String *section, const String *key)
{ {
@ -106,9 +102,7 @@ iniGet(const Ini *this, const String *section, const String *key)
FUNCTION_TEST_RETURN(varStr(result)); FUNCTION_TEST_RETURN(varStr(result));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get an ini value -- if it does not exist then return specified default
***********************************************************************************************************************************/
const String * const String *
iniGetDefault(const Ini *this, const String *section, const String *key, const String *defaultValue) iniGetDefault(const Ini *this, const String *section, const String *key, const String *defaultValue)
{ {
@ -129,9 +123,7 @@ iniGetDefault(const Ini *this, const String *section, const String *key, const S
FUNCTION_TEST_RETURN(result == NULL ? defaultValue : varStr(result)); FUNCTION_TEST_RETURN(result == NULL ? defaultValue : varStr(result));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Internal function to get an ini value list
***********************************************************************************************************************************/
StringList * StringList *
iniGetList(const Ini *this, const String *section, const String *key) iniGetList(const Ini *this, const String *section, const String *key)
{ {
@ -151,9 +143,7 @@ iniGetList(const Ini *this, const String *section, const String *key)
FUNCTION_TEST_RETURN(result == NULL ? NULL : strLstNewVarLst(varVarLst(result))); FUNCTION_TEST_RETURN(result == NULL ? NULL : strLstNewVarLst(varVarLst(result)));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Internal function to get an ini value list
***********************************************************************************************************************************/
bool bool
iniSectionKeyIsList(const Ini *this, const String *section, const String *key) iniSectionKeyIsList(const Ini *this, const String *section, const String *key)
{ {
@ -173,9 +163,7 @@ iniSectionKeyIsList(const Ini *this, const String *section, const String *key)
FUNCTION_TEST_RETURN(varType(result) == varTypeVariantList); FUNCTION_TEST_RETURN(varType(result) == varTypeVariantList);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get a list of keys for a section
***********************************************************************************************************************************/
StringList * StringList *
iniSectionKeyList(const Ini *this, const String *section) iniSectionKeyList(const Ini *this, const String *section)
{ {
@ -208,9 +196,7 @@ iniSectionKeyList(const Ini *this, const String *section)
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get a list of sections
***********************************************************************************************************************************/
StringList * StringList *
iniSectionList(const Ini *this) iniSectionList(const Ini *this)
{ {
@ -234,9 +220,7 @@ iniSectionList(const Ini *this)
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Parse ini from a string
***********************************************************************************************************************************/
void void
iniParse(Ini *this, const String *content) iniParse(Ini *this, const String *content)
{ {
@ -313,9 +297,7 @@ iniParse(Ini *this, const String *content)
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Set an ini value
***********************************************************************************************************************************/
void void
iniSet(Ini *this, const String *section, const String *key, const String *value) iniSet(Ini *this, const String *section, const String *key, const String *value)
{ {
@ -346,9 +328,7 @@ iniSet(Ini *this, const String *section, const String *key, const String *value)
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Load an ini file and return data to a callback
***********************************************************************************************************************************/
void void
iniLoad( iniLoad(
IoRead *read, void (*callbackFunction)(void *data, const String *section, const String *key, const String *value), IoRead *read, void (*callbackFunction)(void *data, const String *section, const String *key, const String *value),

View File

@ -24,21 +24,35 @@ Ini *iniNew(void);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Move to a new parent mem context
Ini *iniMove(Ini *this, MemContext *parentNew); Ini *iniMove(Ini *this, MemContext *parentNew);
// Parse ini from a string
void iniParse(Ini *this, const String *content); void iniParse(Ini *this, const String *content);
// Set an ini value
void iniSet(Ini *this, const String *section, const String *key, const String *value); void iniSet(Ini *this, const String *section, const String *key, const String *value);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Getters Getters
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Get an ini value -- error if it does not exist
const String *iniGet(const Ini *this, const String *section, const String *key); const String *iniGet(const Ini *this, const String *section, const String *key);
// Get an ini value -- if it does not exist then return specified default
const String *iniGetDefault(const Ini *this, const String *section, const String *key, const String *defaultValue); const String *iniGetDefault(const Ini *this, const String *section, const String *key, const String *defaultValue);
// Ini key list
StringList *iniGetList(const Ini *this, const String *section, const String *key); StringList *iniGetList(const Ini *this, const String *section, const String *key);
// The key's value is a list
bool iniSectionKeyIsList(const Ini *this, const String *section, const String *key); bool iniSectionKeyIsList(const Ini *this, const String *section, const String *key);
// List of keys for a section
StringList *iniSectionKeyList(const Ini *this, const String *section); StringList *iniSectionKeyList(const Ini *this, const String *section);
// List of sections
StringList *iniSectionList(const Ini *this); StringList *iniSectionList(const Ini *this);
String *iniFileName(const Ini *this);
bool iniFileExists(const Ini *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Destructor Destructor
@ -48,6 +62,7 @@ void iniFree(Ini *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Helper Functions Helper Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Load an ini file and return data to a callback
void iniLoad( void iniLoad(
IoRead *read, void (*callbackFunction)(void *data, const String *section, const String *key, const String *value), IoRead *read, void (*callbackFunction)(void *data, const String *section, const String *key, const String *value),
void *callbackData); void *callbackData);

View File

@ -84,9 +84,7 @@ ioBufferReadEof(THIS_VOID)
FUNCTION_LOG_RETURN(BOOL, this->eof); FUNCTION_LOG_RETURN(BOOL, this->eof);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoRead * IoRead *
ioBufferReadNew(const Buffer *buffer) ioBufferReadNew(const Buffer *buffer)
{ {

View File

@ -48,9 +48,7 @@ ioBufferWrite(THIS_VOID, const Buffer *buffer)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoWrite * IoWrite *
ioBufferWriteNew(Buffer *buffer) ioBufferWriteNew(Buffer *buffer)
{ {

View File

@ -106,9 +106,7 @@ ioBufferInputSame(const THIS_VOID)
FUNCTION_TEST_RETURN(this->inputSame); FUNCTION_TEST_RETURN(this->inputSame);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
ioBufferNew(void) ioBufferNew(void)
{ {

View File

@ -27,8 +27,6 @@ OBJECT_DEFINE_MOVE(IO_FILTER);
OBJECT_DEFINE_FREE(IO_FILTER); OBJECT_DEFINE_FREE(IO_FILTER);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
New object
Allocations will be in the memory context of the caller. Allocations will be in the memory context of the caller.
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
IoFilter * IoFilter *
@ -64,9 +62,7 @@ ioFilterNew(const String *type, void *driver, VariantList *paramList, IoFilterIn
FUNCTION_LOG_RETURN(IO_FILTER, this); FUNCTION_LOG_RETURN(IO_FILTER, this);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Filter input only (a result is expected)
***********************************************************************************************************************************/
void void
ioFilterProcessIn(IoFilter *this, const Buffer *input) ioFilterProcessIn(IoFilter *this, const Buffer *input)
{ {
@ -88,9 +84,7 @@ ioFilterProcessIn(IoFilter *this, const Buffer *input)
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Filter input and produce output
***********************************************************************************************************************************/
void void
ioFilterProcessInOut(IoFilter *this, const Buffer *input, Buffer *output) ioFilterProcessInOut(IoFilter *this, const Buffer *input, Buffer *output)
{ {
@ -117,8 +111,6 @@ ioFilterProcessInOut(IoFilter *this, const Buffer *input, Buffer *output)
} }
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Is the filter done?
If done is not defined by the filter then check inputSame. If inputSame is true then the filter is not done. Even if the filter If done is not defined by the filter then check inputSame. If inputSame is true then the filter is not done. Even if the filter
is done the interface will not report done until the interface is flushing. is done the interface will not report done until the interface is flushing.
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
@ -139,9 +131,7 @@ ioFilterDone(const IoFilter *this)
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Driver for the filter
***********************************************************************************************************************************/
void * void *
ioFilterDriver(IoFilter *this) ioFilterDriver(IoFilter *this)
{ {
@ -154,11 +144,7 @@ ioFilterDriver(IoFilter *this)
FUNCTION_TEST_RETURN(this->driver); FUNCTION_TEST_RETURN(this->driver);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Does the filter need the same input again?
If the filter cannot get all its output into the output buffer then it may need access to the same input again.
***********************************************************************************************************************************/
bool bool
ioFilterInputSame(const IoFilter *this) ioFilterInputSame(const IoFilter *this)
{ {
@ -171,9 +157,7 @@ ioFilterInputSame(const IoFilter *this)
FUNCTION_TEST_RETURN(this->interface.inputSame != NULL ? this->interface.inputSame(this->driver) : false); FUNCTION_TEST_RETURN(this->interface.inputSame != NULL ? this->interface.inputSame(this->driver) : false);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Interface for the filter
***********************************************************************************************************************************/
const IoFilterInterface * const IoFilterInterface *
ioFilterInterface(const IoFilter *this) ioFilterInterface(const IoFilter *this)
{ {
@ -186,11 +170,7 @@ ioFilterInterface(const IoFilter *this)
FUNCTION_TEST_RETURN(&this->interface); FUNCTION_TEST_RETURN(&this->interface);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Does filter produce output?
All In filters produce output.
***********************************************************************************************************************************/
bool bool
ioFilterOutput(const IoFilter *this) ioFilterOutput(const IoFilter *this)
{ {
@ -203,9 +183,7 @@ ioFilterOutput(const IoFilter *this)
FUNCTION_TEST_RETURN(this->interface.inOut != NULL); FUNCTION_TEST_RETURN(this->interface.inOut != NULL);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
List of filter parameters
***********************************************************************************************************************************/
const VariantList * const VariantList *
ioFilterParamList(const IoFilter *this) ioFilterParamList(const IoFilter *this)
{ {
@ -218,9 +196,7 @@ ioFilterParamList(const IoFilter *this)
FUNCTION_TEST_RETURN(this->paramList); FUNCTION_TEST_RETURN(this->paramList);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get filter result
***********************************************************************************************************************************/
Variant * Variant *
ioFilterResult(const IoFilter *this) ioFilterResult(const IoFilter *this)
{ {
@ -233,11 +209,7 @@ ioFilterResult(const IoFilter *this)
FUNCTION_TEST_RETURN(this->interface.result ? this->interface.result(this->driver) : NULL); FUNCTION_TEST_RETURN(this->interface.result ? this->interface.result(this->driver) : NULL);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get filter type
This name identifies the filter and is used when pulling results from the filter group.
***********************************************************************************************************************************/
const String * const String *
ioFilterType(const IoFilter *this) ioFilterType(const IoFilter *this)
{ {
@ -250,9 +222,7 @@ ioFilterType(const IoFilter *this)
FUNCTION_TEST_RETURN(this->type); FUNCTION_TEST_RETURN(this->type);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Render as string for logging
***********************************************************************************************************************************/
String * String *
ioFilterToLog(const IoFilter *this) ioFilterToLog(const IoFilter *this)
{ {

View File

@ -25,7 +25,10 @@ typedef struct IoFilter IoFilter;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Getters Getters
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Get filter result
Variant *ioFilterResult(const IoFilter *this); Variant *ioFilterResult(const IoFilter *this);
// Identifies the filter and is used when pulling results from the filter group
const String *ioFilterType(const IoFilter *this); const String *ioFilterType(const IoFilter *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************

View File

@ -57,18 +57,35 @@ IoFilter *ioFilterNew(const String *type, void *driver, VariantList *paramList,
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Filter input only (a result is expected)
void ioFilterProcessIn(IoFilter *this, const Buffer *input); void ioFilterProcessIn(IoFilter *this, const Buffer *input);
// Filter input and produce output
void ioFilterProcessInOut(IoFilter *this, const Buffer *input, Buffer *output); void ioFilterProcessInOut(IoFilter *this, const Buffer *input, Buffer *output);
// Move filter to a new parent mem context
IoFilter *ioFilterMove(IoFilter *this, MemContext *parentNew); IoFilter *ioFilterMove(IoFilter *this, MemContext *parentNew);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Getters Getters
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Is the filter done?
bool ioFilterDone(const IoFilter *this); bool ioFilterDone(const IoFilter *this);
// Driver for the filter
void *ioFilterDriver(IoFilter *this); void *ioFilterDriver(IoFilter *this);
// Does the filter need the same input again? If the filter cannot get all its output into the output buffer then it may need access
// to the same input again.
bool ioFilterInputSame(const IoFilter *this); bool ioFilterInputSame(const IoFilter *this);
// Interface for the filter
const IoFilterInterface *ioFilterInterface(const IoFilter *this); const IoFilterInterface *ioFilterInterface(const IoFilter *this);
// Does filter produce output? All In filters produce output.
bool ioFilterOutput(const IoFilter *this); bool ioFilterOutput(const IoFilter *this);
// List of filter parameters
const VariantList *ioFilterParamList(const IoFilter *this); const VariantList *ioFilterParamList(const IoFilter *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************

View File

@ -55,9 +55,7 @@ struct IoFilterGroup
OBJECT_DEFINE_FREE(IO_FILTER_GROUP); OBJECT_DEFINE_FREE(IO_FILTER_GROUP);
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New Object
***********************************************************************************************************************************/
IoFilterGroup * IoFilterGroup *
ioFilterGroupNew(void) ioFilterGroupNew(void)
{ {
@ -81,9 +79,7 @@ ioFilterGroupNew(void)
FUNCTION_LOG_RETURN(IO_FILTER_GROUP, this); FUNCTION_LOG_RETURN(IO_FILTER_GROUP, this);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Add a filter
***********************************************************************************************************************************/
IoFilterGroup * IoFilterGroup *
ioFilterGroupAdd(IoFilterGroup *this, IoFilter *filter) ioFilterGroupAdd(IoFilterGroup *this, IoFilter *filter)
{ {
@ -106,9 +102,7 @@ ioFilterGroupAdd(IoFilterGroup *this, IoFilter *filter)
FUNCTION_LOG_RETURN(IO_FILTER_GROUP, this); FUNCTION_LOG_RETURN(IO_FILTER_GROUP, this);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Insert a filter before an index
***********************************************************************************************************************************/
IoFilterGroup * IoFilterGroup *
ioFilterGroupInsert(IoFilterGroup *this, unsigned int listIdx, IoFilter *filter) ioFilterGroupInsert(IoFilterGroup *this, unsigned int listIdx, IoFilter *filter)
{ {
@ -147,9 +141,7 @@ ioFilterGroupGet(const IoFilterGroup *this, unsigned int filterIdx)
FUNCTION_TEST_RETURN((IoFilterData *)lstGet(this->filterList, filterIdx)); FUNCTION_TEST_RETURN((IoFilterData *)lstGet(this->filterList, filterIdx));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Clear filters
***********************************************************************************************************************************/
IoFilterGroup * IoFilterGroup *
ioFilterGroupClear(IoFilterGroup *this) ioFilterGroupClear(IoFilterGroup *this)
{ {
@ -169,9 +161,7 @@ ioFilterGroupClear(IoFilterGroup *this)
} }
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Open filter group Setup the filter group and allocate any required buffers
Setup the filter group and allocate any required buffers.
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
void void
ioFilterGroupOpen(IoFilterGroup *this) ioFilterGroupOpen(IoFilterGroup *this)
@ -233,9 +223,7 @@ ioFilterGroupOpen(IoFilterGroup *this)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Process filters
***********************************************************************************************************************************/
void void
ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output) ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output)
{ {
@ -361,9 +349,7 @@ ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Close filter group and gather results
***********************************************************************************************************************************/
void void
ioFilterGroupClose(IoFilterGroup *this) ioFilterGroupClose(IoFilterGroup *this)
{ {
@ -403,9 +389,7 @@ ioFilterGroupClose(IoFilterGroup *this)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Is the filter group done processing?
***********************************************************************************************************************************/
bool bool
ioFilterGroupDone(const IoFilterGroup *this) ioFilterGroupDone(const IoFilterGroup *this)
{ {
@ -419,11 +403,7 @@ ioFilterGroupDone(const IoFilterGroup *this)
FUNCTION_TEST_RETURN(this->done); FUNCTION_TEST_RETURN(this->done);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Should the same input be passed again?
A buffer of input can produce multiple buffers of output, e.g. when a file containing all zeroes is being decompressed.
***********************************************************************************************************************************/
bool bool
ioFilterGroupInputSame(const IoFilterGroup *this) ioFilterGroupInputSame(const IoFilterGroup *this)
{ {
@ -437,9 +417,7 @@ ioFilterGroupInputSame(const IoFilterGroup *this)
FUNCTION_TEST_RETURN(this->inputSame); FUNCTION_TEST_RETURN(this->inputSame);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get all filters and parameters so they can be passed to a remote
***********************************************************************************************************************************/
Variant * Variant *
ioFilterGroupParamAll(const IoFilterGroup *this) ioFilterGroupParamAll(const IoFilterGroup *this)
{ {
@ -467,9 +445,7 @@ ioFilterGroupParamAll(const IoFilterGroup *this)
FUNCTION_LOG_RETURN(VARIANT, varNewVarLst(result)); FUNCTION_LOG_RETURN(VARIANT, varNewVarLst(result));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get filter results
***********************************************************************************************************************************/
const Variant * const Variant *
ioFilterGroupResult(const IoFilterGroup *this, const String *filterType) ioFilterGroupResult(const IoFilterGroup *this, const String *filterType)
{ {
@ -492,9 +468,7 @@ ioFilterGroupResult(const IoFilterGroup *this, const String *filterType)
FUNCTION_LOG_RETURN_CONST(VARIANT, result); FUNCTION_LOG_RETURN_CONST(VARIANT, result);
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Get all filter results
***********************************************************************************************************************************/
const Variant * const Variant *
ioFilterGroupResultAll(const IoFilterGroup *this) ioFilterGroupResultAll(const IoFilterGroup *this)
{ {
@ -508,9 +482,7 @@ ioFilterGroupResultAll(const IoFilterGroup *this)
FUNCTION_LOG_RETURN_CONST(VARIANT, varNewKv(this->filterResult)); FUNCTION_LOG_RETURN_CONST(VARIANT, varNewKv(this->filterResult));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Set all filter results
***********************************************************************************************************************************/
void void
ioFilterGroupResultAllSet(IoFilterGroup *this, const Variant *filterResult) ioFilterGroupResultAllSet(IoFilterGroup *this, const Variant *filterResult)
{ {
@ -532,9 +504,7 @@ ioFilterGroupResultAllSet(IoFilterGroup *this, const Variant *filterResult)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Return total number of filters
***********************************************************************************************************************************/
unsigned int unsigned int
ioFilterGroupSize(const IoFilterGroup *this) ioFilterGroupSize(const IoFilterGroup *this)
{ {
@ -545,9 +515,7 @@ ioFilterGroupSize(const IoFilterGroup *this)
FUNCTION_TEST_RETURN(lstSize(this->filterList)); FUNCTION_TEST_RETURN(lstSize(this->filterList));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
Render as string for logging
***********************************************************************************************************************************/
String * String *
ioFilterGroupToLog(const IoFilterGroup *this) ioFilterGroupToLog(const IoFilterGroup *this)
{ {

View File

@ -29,22 +29,47 @@ IoFilterGroup *ioFilterGroupNew(void);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Add a filter
IoFilterGroup *ioFilterGroupAdd(IoFilterGroup *this, IoFilter *filter); IoFilterGroup *ioFilterGroupAdd(IoFilterGroup *this, IoFilter *filter);
// Insert a filter before an index
IoFilterGroup *ioFilterGroupInsert(IoFilterGroup *this, unsigned int listIdx, IoFilter *filter); IoFilterGroup *ioFilterGroupInsert(IoFilterGroup *this, unsigned int listIdx, IoFilter *filter);
// Clear filters
IoFilterGroup *ioFilterGroupClear(IoFilterGroup *this); IoFilterGroup *ioFilterGroupClear(IoFilterGroup *this);
// Open filter group
void ioFilterGroupOpen(IoFilterGroup *this); void ioFilterGroupOpen(IoFilterGroup *this);
// Process filters
void ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output); void ioFilterGroupProcess(IoFilterGroup *this, const Buffer *input, Buffer *output);
// Close filter group and gather results
void ioFilterGroupClose(IoFilterGroup *this); void ioFilterGroupClose(IoFilterGroup *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Getters Getters
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
// Is the filter group done processing?
bool ioFilterGroupDone(const IoFilterGroup *this); bool ioFilterGroupDone(const IoFilterGroup *this);
// Should the same input be passed again? A buffer of input can produce multiple buffers of output, e.g. when a file containing all
// zeroes is being decompressed.
bool ioFilterGroupInputSame(const IoFilterGroup *this); bool ioFilterGroupInputSame(const IoFilterGroup *this);
// Get all filters and their parameters so they can be passed to a remote
Variant *ioFilterGroupParamAll(const IoFilterGroup *this); Variant *ioFilterGroupParamAll(const IoFilterGroup *this);
// Get filter results
const Variant *ioFilterGroupResult(const IoFilterGroup *this, const String *filterType); const Variant *ioFilterGroupResult(const IoFilterGroup *this, const String *filterType);
// Get all filter results
const Variant *ioFilterGroupResultAll(const IoFilterGroup *this); const Variant *ioFilterGroupResultAll(const IoFilterGroup *this);
// Set all filter results
void ioFilterGroupResultAllSet(IoFilterGroup *this, const Variant *filterResult); void ioFilterGroupResultAllSet(IoFilterGroup *this, const Variant *filterResult);
// Return total number of filters
unsigned int ioFilterGroupSize(const IoFilterGroup *this); unsigned int ioFilterGroupSize(const IoFilterGroup *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************

View File

@ -52,9 +52,7 @@ ioSinkProcess(THIS_VOID, const Buffer *input, Buffer *output)
FUNCTION_LOG_RETURN_VOID(); FUNCTION_LOG_RETURN_VOID();
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
ioSinkNew(void) ioSinkNew(void)
{ {

View File

@ -79,9 +79,7 @@ ioSizeResult(THIS_VOID)
FUNCTION_LOG_RETURN(VARIANT, varNewUInt64(this->size)); FUNCTION_LOG_RETURN(VARIANT, varNewUInt64(this->size));
} }
/*********************************************************************************************************************************** /**********************************************************************************************************************************/
New object
***********************************************************************************************************************************/
IoFilter * IoFilter *
ioSizeNew(void) ioSizeNew(void)
{ {

Some files were not shown because too many files have changed in this diff Show More