1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-06-18 23:57:33 +02:00

More C type cleanup.

* Remove typec.h entirely.
* Order all typdefs above local includes.
This commit is contained in:
David Steele
2018-04-06 21:46:45 -04:00
parent f3b56cf8f3
commit e00f2dd4ad
36 changed files with 70 additions and 109 deletions

View File

@ -64,7 +64,7 @@
</release-item> </release-item>
<release-item> <release-item>
<p>Cleanup C types. Remove <backrest/> defined types included with the C types. Remove redefinition of standard C types.</p> <p>Cleanup C types. Remove <code>typec.h</code>. Order all typdefs above local includes.</p>
</release-item> </release-item>
<release-item> <release-item>

View File

@ -4,12 +4,16 @@ Block Cipher Header
#ifndef CIPHER_BLOCK_H #ifndef CIPHER_BLOCK_H
#define CIPHER_BLOCK_H #define CIPHER_BLOCK_H
#include "cipher/cipher.h" /***********************************************************************************************************************************
CipherBlock object
// Track cipher state ***********************************************************************************************************************************/
typedef struct CipherBlock CipherBlock; typedef struct CipherBlock CipherBlock;
// Functions #include "cipher/cipher.h"
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
CipherBlock *cipherBlockNew( CipherBlock *cipherBlockNew(
CipherMode mode, const char *cipherName, const unsigned char *pass, size_t passSize, const char *digestName); CipherMode mode, const char *cipherName, const unsigned char *pass, size_t passSize, const char *digestName);
size_t cipherBlockProcessSize(CipherBlock *this, size_t sourceSize); size_t cipherBlockProcessSize(CipherBlock *this, size_t sourceSize);

View File

@ -4,9 +4,11 @@ Cipher Header
#ifndef CIPHER_CIPHER_H #ifndef CIPHER_CIPHER_H
#define CIPHER_CIPHER_H #define CIPHER_CIPHER_H
#include "common/typec.h" #include <stdbool.h>
// Define cipher modes /***********************************************************************************************************************************
Cipher modes
***********************************************************************************************************************************/
typedef enum typedef enum
{ {
cipherModeEncrypt, cipherModeEncrypt,

View File

@ -4,7 +4,9 @@ Random Header
#ifndef CIPHER_RANDOM_H #ifndef CIPHER_RANDOM_H
#define CIPHER_RANDOM_H #define CIPHER_RANDOM_H
// Functions /***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
void randomBytes(unsigned char *buffer, size_t size); void randomBytes(unsigned char *buffer, size_t size);
#endif #endif

View File

@ -2,6 +2,7 @@
Archive Push Command Archive Push Command
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include <libgen.h> #include <libgen.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
@ -12,7 +13,6 @@ Archive Push Command
#include "common/log.h" #include "common/log.h"
#include "common/memContext.h" #include "common/memContext.h"
#include "common/regExp.h" #include "common/regExp.h"
#include "common/typec.h"
#include "common/wait.h" #include "common/wait.h"
#include "config/config.h" #include "config/config.h"
#include "perl/exec.h" #include "perl/exec.h"

View File

@ -6,7 +6,6 @@ Help Command
#include "common/io/handle.h" #include "common/io/handle.h"
#include "common/memContext.h" #include "common/memContext.h"
#include "common/typec.h"
#include "config/config.h" #include "config/config.h"
#include "config/define.h" #include "config/define.h"
#include "version.h" #include "version.h"

View File

@ -1,6 +1,7 @@
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Binary to String Encode/Decode Binary to String Encode/Decode
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include <stdbool.h>
#include <string.h> #include <string.h>
#include "common/encode.h" #include "common/encode.h"

View File

@ -6,8 +6,6 @@ These high-level functions are preferred to the low-level functions for each enc
#ifndef COMMON_ENCODE_H #ifndef COMMON_ENCODE_H
#define COMMON_ENCODE_H #define COMMON_ENCODE_H
#include "common/typec.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Encoding types Encoding types
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -6,8 +6,6 @@ The high-level functions in encode.c should be used in preference to these low-l
#ifndef COMMON_ENCODE_BASE64_H #ifndef COMMON_ENCODE_BASE64_H
#define COMMON_ENCODE_BASE64_H #define COMMON_ENCODE_BASE64_H
#include "common/typec.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -2,6 +2,7 @@
Error Handler Error Handler
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -39,8 +39,7 @@ IMPORTANT: Never call return from within any of the error-handling blocks.
#include <errno.h> #include <errno.h>
#include <setjmp.h> #include <setjmp.h>
#include <stdbool.h>
#include "common/typec.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Error type object Error type object

View File

@ -4,6 +4,7 @@ Log Handler
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include <time.h> #include <time.h>

View File

@ -4,7 +4,7 @@ Log Handler
#ifndef COMMON_LOG_H #ifndef COMMON_LOG_H
#define COMMON_LOG_H #define COMMON_LOG_H
#include "common/typec.h" #include <stdbool.h>
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Log types Log types

View File

@ -4,8 +4,14 @@ Memory Context Manager
#ifndef COMMON_MEMCONTEXT_H #ifndef COMMON_MEMCONTEXT_H
#define COMMON_MEMCONTEXT_H #define COMMON_MEMCONTEXT_H
#include <stddef.h>
/***********************************************************************************************************************************
Memory context object
***********************************************************************************************************************************/
typedef struct MemContext MemContext;
#include "common/error.h" #include "common/error.h"
#include "common/typec.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Memory context names cannot be larger than this size (excluding terminator) or an error will be thrown Memory context names cannot be larger than this size (excluding terminator) or an error will be thrown
@ -27,11 +33,6 @@ Space is reserved for this many allocations when a context is created. When mor
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#define MEM_CONTEXT_ALLOC_INITIAL_SIZE 4 #define MEM_CONTEXT_ALLOC_INITIAL_SIZE 4
/***********************************************************************************************************************************
Memory context object
***********************************************************************************************************************************/
typedef struct MemContext MemContext;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Memory context callback function type, useful for casts in memContextCallback() Memory context callback function type, useful for casts in memContextCallback()
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -6,7 +6,6 @@ Regular Expression Handler
#include "common/memContext.h" #include "common/memContext.h"
#include "common/regExp.h" #include "common/regExp.h"
#include "common/typec.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Contains information about the regular expression handler Contains information about the regular expression handler

View File

@ -5,7 +5,7 @@ Regular Expression Handler
#define COMMON_REGEXP_H #define COMMON_REGEXP_H
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Ini object RegExp object
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef struct RegExp RegExp; typedef struct RegExp RegExp;

View File

@ -1,10 +1,10 @@
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Time Management Time Management
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include "stdio.h"
#include "sys/time.h" #include "sys/time.h"
#include "common/time.h" #include "common/time.h"
#include "common/typec.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Constants describing number of sub-units in an interval Constants describing number of sub-units in an interval

View File

@ -4,7 +4,7 @@ Time Management
#ifndef COMMON_TIME_H #ifndef COMMON_TIME_H
#define COMMON_TIME_H #define COMMON_TIME_H
#include "common/typec.h" #include <stdint.h>
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Time types Time types

View File

@ -1,6 +1,8 @@
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Key Value Handler Key Value Handler
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include <limits.h>
#include "common/memContext.h" #include "common/memContext.h"
#include "common/type/keyValue.h" #include "common/type/keyValue.h"
#include "common/type/list.h" #include "common/type/list.h"

View File

@ -5,7 +5,7 @@ Key Value Handler
#define COMMON_TYPE_KEYVALUE_H #define COMMON_TYPE_KEYVALUE_H
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Key value object KeyValue object
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef struct KeyValue KeyValue; typedef struct KeyValue KeyValue;

View File

@ -4,6 +4,11 @@ List Handler
#ifndef COMMON_TYPE_LIST_H #ifndef COMMON_TYPE_LIST_H
#define COMMON_TYPE_LIST_H #define COMMON_TYPE_LIST_H
/***********************************************************************************************************************************
List object
***********************************************************************************************************************************/
typedef struct List List;
#include "common/memContext.h" #include "common/memContext.h"
#include "common/type/string.h" #include "common/type/string.h"
@ -12,11 +17,6 @@ Define initial size of a list
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#define LIST_INITIAL_SIZE 8 #define LIST_INITIAL_SIZE 8
/***********************************************************************************************************************************
List type
***********************************************************************************************************************************/
typedef struct List List;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -3,6 +3,7 @@ String Handler
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -9,11 +9,11 @@ String object
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef struct String String; typedef struct String String;
#include "common/type/buffer.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include "common/type/buffer.h"
String *strNew(const char *string); String *strNew(const char *string);
String *strNewBuf(const Buffer *buffer); String *strNewBuf(const Buffer *buffer);
String *strNewFmt(const char *format, ...) __attribute__((format(printf, 1, 2))); String *strNewFmt(const char *format, ...) __attribute__((format(printf, 1, 2)));

View File

@ -5,7 +5,7 @@ String List Handler
#define COMMON_TYPE_STRINGLIST_H #define COMMON_TYPE_STRINGLIST_H
/*********************************************************************************************************************************** /***********************************************************************************************************************************
String list type StringList object
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef struct StringList StringList; typedef struct StringList StringList;

View File

@ -2,6 +2,7 @@
Variant Data Type Variant Data Type
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>

View File

@ -4,7 +4,12 @@ Variant Data Type
#ifndef COMMON_TYPE_VARIANT_H #ifndef COMMON_TYPE_VARIANT_H
#define COMMON_TYPE_VARIANT_H #define COMMON_TYPE_VARIANT_H
#include "common/typec.h" #include <stdint.h>
/***********************************************************************************************************************************
Variant object
***********************************************************************************************************************************/
typedef struct Variant Variant;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Variant type Variant type
@ -20,18 +25,13 @@ typedef enum
varTypeVariantList, varTypeVariantList,
} VariantType; } VariantType;
/***********************************************************************************************************************************
Variant object
***********************************************************************************************************************************/
typedef struct Variant Variant;
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
#include "common/type/keyValue.h" #include "common/type/keyValue.h"
#include "common/type/string.h" #include "common/type/string.h"
#include "common/type/variantList.h" #include "common/type/variantList.h"
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
Variant *varNewBool(bool data); Variant *varNewBool(bool data);
bool varBool(const Variant *this); bool varBool(const Variant *this);
bool varBoolForce(const Variant *this); bool varBoolForce(const Variant *this);

View File

@ -5,7 +5,7 @@ Variant List Handler
#define COMMON_TYPE_VARIANTLIST_H #define COMMON_TYPE_VARIANTLIST_H
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Variant list type Variant list object
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef struct VariantList VariantList; typedef struct VariantList VariantList;

View File

@ -1,34 +0,0 @@
/***********************************************************************************************************************************
C Types
***********************************************************************************************************************************/
#ifndef COMMON_TYPEC_H
#define COMMON_TYPEC_H
/***********************************************************************************************************************************
Include true/false
***********************************************************************************************************************************/
#include <stdbool.h>
/***********************************************************************************************************************************
Include NULL
***********************************************************************************************************************************/
#include <stdio.h>
/***********************************************************************************************************************************
Include limits for data types
***********************************************************************************************************************************/
#include <limits.h>
/***********************************************************************************************************************************
Define standard integer types for portability
***********************************************************************************************************************************/
#include <stdint.h>
/***********************************************************************************************************************************
Ensure that ints are at least 32 bits
***********************************************************************************************************************************/
#if INT_MAX < 2147483647L
#error "int type must be at least 32 bits"
#endif
#endif

View File

@ -5,7 +5,7 @@ Wait Handler
#define COMMON_WAIT_H #define COMMON_WAIT_H
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Ini object Wait object
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef struct Wait Wait; typedef struct Wait Wait;

View File

@ -2,6 +2,7 @@
Command and Option Configuration Definition Command and Option Configuration Definition
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include <limits.h> #include <limits.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include "common/error.h" #include "common/error.h"

View File

@ -4,9 +4,6 @@ Command and Option Configuration Definition
#ifndef CONFIG_DEFINE_H #ifndef CONFIG_DEFINE_H
#define CONFIG_DEFINE_H #define CONFIG_DEFINE_H
#include "common/typec.h"
#include "config/define.auto.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Section enum - defines which sections of the config an option can appear in Section enum - defines which sections of the config an option can appear in
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
@ -17,6 +14,8 @@ typedef enum
cfgDefSectionStanza, // command-line or in any config stanza section cfgDefSectionStanza, // command-line or in any config stanza section
} ConfigDefSection; } ConfigDefSection;
#include "config/define.auto.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Define global section name Define global section name
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -10,7 +10,6 @@ Execute Perl for Legacy Functionality
#include "version.h" #include "version.h"
#include "common/error.h" #include "common/error.h"
#include "common/memContext.h" #include "common/memContext.h"
#include "common/typec.h"
#include "config/config.h" #include "config/config.h"
#include "perl/config.h" #include "perl/config.h"

View File

@ -4,7 +4,7 @@ Checksum Implementation for Data Pages
#ifndef POSTGRES_PAGECHECKSUM_H #ifndef POSTGRES_PAGECHECKSUM_H
#define POSTGRES_PAGECHECKSUM_H #define POSTGRES_PAGECHECKSUM_H
#include "common/typec.h" #include <stdint.h>
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions

View File

@ -4,7 +4,10 @@ Storage File
#ifndef STORAGE_FILE_H #ifndef STORAGE_FILE_H
#define STORAGE_FILE_H #define STORAGE_FILE_H
#include "common/type/string.h" /***********************************************************************************************************************************
Storage file object
***********************************************************************************************************************************/
typedef struct StorageFile StorageFile;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Types of storage files, i.e. read or write. The storage module does not allow files to be opened for both read and write since this Types of storage files, i.e. read or write. The storage module does not allow files to be opened for both read and write since this
@ -16,11 +19,6 @@ typedef enum
storageFileTypeWrite, storageFileTypeWrite,
} StorageFileType; } StorageFileType;
/***********************************************************************************************************************************
Storage file object
***********************************************************************************************************************************/
typedef struct StorageFile StorageFile;
#include "storage/storage.h" #include "storage/storage.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************

View File

@ -6,8 +6,14 @@ Storage Manager
#include <sys/types.h> #include <sys/types.h>
/***********************************************************************************************************************************
Storage object
***********************************************************************************************************************************/
typedef struct Storage Storage;
#include "common/type/buffer.h" #include "common/type/buffer.h"
#include "common/type/stringList.h" #include "common/type/stringList.h"
#include "storage/file.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Default buffer size Default buffer size
@ -23,12 +29,6 @@ Default file and path modes
#define STORAGE_FILE_MODE_DEFAULT 0640 #define STORAGE_FILE_MODE_DEFAULT 0640
#define STORAGE_PATH_MODE_DEFAULT 0750 #define STORAGE_PATH_MODE_DEFAULT 0750
/***********************************************************************************************************************************
Storage object
***********************************************************************************************************************************/
typedef struct Storage Storage;
#include "storage/file.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Path expression callback function type - used to modify paths based on expressions enclosed in <> Path expression callback function type - used to modify paths based on expressions enclosed in <>

View File

@ -100,17 +100,6 @@ my $oTestDef =
&TESTDEF_TEST => &TESTDEF_TEST =>
[ [
{
&TESTDEF_NAME => 'typec',
&TESTDEF_TOTAL => 2,
&TESTDEF_C => true,
&TESTDEF_CDEF => '-DNO_ERROR -DNO_LOG',
&TESTDEF_COVERAGE =>
{
'common/typec' => TESTDEF_COVERAGE_NOCODE,
},
},
{ {
&TESTDEF_NAME => 'time', &TESTDEF_NAME => 'time',
&TESTDEF_TOTAL => 2, &TESTDEF_TOTAL => 2,