Format headers as well.

indent(1) does a weird thing with prototype functions, but it's good
enough for me, as long as it's consistent.
This commit is contained in:
Jordan Bancino 2022-07-25 15:25:06 -04:00
parent aabb2a0203
commit 3437c5db2c
9 changed files with 94 additions and 86 deletions

View File

@ -74,7 +74,7 @@ recipe_clean() {
}
recipe_format() {
find src -name '*.c' | while IFS= read -r src; do
find src -name '*.c' -or -name '*.h' | while IFS= read -r src; do
echo "indent $src"
indent -bad -bap -bbb -nbc -bl -c36 -cd36 -ncdb -nce \
-ci8 -cli1 -d0 -di1 -ndj -ei -fc1 -i4 -ip -l72 \

View File

@ -6,27 +6,27 @@
typedef struct Array Array;
extern Array *
ArrayCreate(void);
ArrayCreate(void);
extern size_t
ArraySize(Array *array);
ArraySize(Array * array);
extern void *
ArrayGet(Array *array, size_t index);
ArrayGet(Array * array, size_t index);
extern int
ArrayInsert(Array *, void *value, size_t index);
ArrayInsert(Array *, void *value, size_t index);
extern int
ArrayAdd(Array *array, void *value);
ArrayAdd(Array * array, void *value);
extern void *
ArrayDelete(Array *array, size_t index);
ArrayDelete(Array * array, size_t index);
extern void
ArrayFree(Array *array);
ArrayFree(Array * array);
extern int
ArrayTrim(Array *array);
ArrayTrim(Array * array);
#endif

View File

@ -4,22 +4,21 @@
#include <stddef.h>
extern size_t
Base64EncodedSize(size_t inputSize);
Base64EncodedSize(size_t inputSize);
extern size_t
Base64DecodedSize(const char *base64, size_t len);
Base64DecodedSize(const char *base64, size_t len);
extern char *
Base64Encode(const char *input, size_t len);
Base64Encode(const char *input, size_t len);
extern char *
Base64Decode(const char *input, size_t len);
Base64Decode(const char *input, size_t len);
extern void
Base64Unpad(char *base64, size_t length);
Base64Unpad(char *base64, size_t length);
extern int
Base64Pad(char **base64Ptr, size_t length);
Base64Pad(char **base64Ptr, size_t length);
#endif

View File

@ -11,27 +11,27 @@ typedef struct ConfigDirective ConfigDirective;
typedef struct ConfigParseResult ConfigParseResult;
extern ConfigParseResult *
ConfigParse(FILE *stream);
ConfigParse(FILE * stream);
extern unsigned int
ConfigParseResultOk(ConfigParseResult *result);
ConfigParseResultOk(ConfigParseResult * result);
extern size_t
ConfigParseResultLineNumber(ConfigParseResult *result);
ConfigParseResultLineNumber(ConfigParseResult * result);
extern HashMap *
ConfigParseResultGet(ConfigParseResult *result);
ConfigParseResultGet(ConfigParseResult * result);
extern void
ConfigParseResultFree(ConfigParseResult *result);
ConfigParseResultFree(ConfigParseResult * result);
extern Array *
ConfigValuesGet(ConfigDirective *directive);
ConfigValuesGet(ConfigDirective * directive);
extern HashMap *
ConfigChildrenGet(ConfigDirective *directive);
ConfigChildrenGet(ConfigDirective * directive);
extern void
ConfigFree(HashMap *conf);
ConfigFree(HashMap * conf);
#endif /* TELODENDRIA_CONFIG_H */
#endif /* TELODENDRIA_CONFIG_H */

View File

@ -32,10 +32,10 @@ typedef struct HashMap HashMap;
* the heap.
*/
extern HashMap *
HashMapCreate(void);
HashMapCreate(void);
extern void
HashMapMaxLoadSet(HashMap *map, float load);
HashMapMaxLoadSet(HashMap * map, float load);
/*
* HashMapSet: Set the given key in the HashMap to the given value. Note
@ -49,7 +49,7 @@ HashMapMaxLoadSet(HashMap *map, float load);
* use HashMapDelete.
*/
extern void *
HashMapSet(HashMap * map, const char *key, void *value);
HashMapSet(HashMap * map, const char *key, void *value);
/*
* HashMapGet: Get the value for the given key.
@ -58,7 +58,7 @@ HashMapSet(HashMap * map, const char *key, void *value);
* exist, no map was provided, or no key was provided.
*/
extern void *
HashMapGet(HashMap * map, const char *key);
HashMapGet(HashMap * map, const char *key);
/*
* HashMapDelete: Delete the value for the given key.
@ -67,10 +67,10 @@ HashMapGet(HashMap * map, const char *key);
* exist or the map or key was not provided.
*/
extern void *
HashMapDelete(HashMap *map, const char *key);
HashMapDelete(HashMap * map, const char *key);
extern void
HashMapIterate(HashMap *map, void (*iteratorFunc)(void *));
HashMapIterate(HashMap * map, void (*iteratorFunc) (void *));
/*
* HashMapFree: Free the hash map, returning its memory to the operating
@ -80,6 +80,6 @@ HashMapIterate(HashMap *map, void (*iteratorFunc)(void *));
* free the values using your own algorithm.
*/
extern void
HashMapFree(HashMap *map);
HashMapFree(HashMap * map);
#endif /* TELODENDRIA_HASHMAP_H */
#endif /* TELODENDRIA_HASHMAP_H */

View File

@ -1,7 +1,8 @@
#ifndef TELODENDRIA_HTTP_H
#define TELODENDRIA_HTTP_H
typedef enum HttpRequestMethod {
typedef enum HttpRequestMethod
{
HTTP_GET,
HTTP_HEAD,
HTTP_POST,
@ -13,7 +14,8 @@ typedef enum HttpRequestMethod {
HTTP_PATCH
} HttpRequestMethod;
typedef enum HttpStatus {
typedef enum HttpStatus
{
/* Informational responses */
HTTP_CONTINUE = 100,
HTTP_SWITCHING_PROTOCOLS = 101,
@ -74,23 +76,25 @@ typedef enum HttpStatus {
HTTP_NETWORK_AUTH_REQUIRED = 511
} HttpStatus;
struct HttpRequest {
struct HttpRequest
{
HttpRequestMethod method;
};
struct HttpResponse {
struct HttpResponse
{
HttpStatus status;
};
extern char *
HttpGetStatusString(const HttpStatus httpStatus);
HttpGetStatusString(const HttpStatus httpStatus);
extern HttpRequestMethod
HttpRequestMethodFromString(const char *requestMethod);
HttpRequestMethodFromString(const char *requestMethod);
typedef struct HttpRequest HttpRequest;
typedef struct HttpResponse HttpResponse;
typedef void (*HttpHandler)(HttpRequest *, HttpResponse *);
typedef void (*HttpHandler) (HttpRequest *, HttpResponse *);
#endif

View File

@ -4,7 +4,8 @@
#include <HashMap.h>
#include <Array.h>
typedef enum JsonType {
typedef enum JsonType
{
JSON_OBJECT,
JSON_ARRAY,
JSON_STRING,
@ -14,56 +15,58 @@ typedef enum JsonType {
JSON_NULL
} JsonType;
typedef struct JsonValue {
typedef struct JsonValue
{
JsonType type;
union as {
union as
{
HashMap *object;
Array *array;
char *string;
int64_t integer;
double floating;
int boolean : 1;
int boolean:1;
};
} JsonValue;
extern JsonType
JsonValueType(JsonValue *value);
JsonValueType(JsonValue * value);
extern JsonValue *
JsonValueObject(HashMap *object);
JsonValueObject(HashMap * object);
extern HashMap *
JsonValueAsObject(JsonValue *value);
JsonValueAsObject(JsonValue * value);
extern JsonValue *
JsonValueArray(Array *array);
JsonValueArray(Array * array);
extern Array *
JsonValueAsArray(JsonValue *value);
JsonValueAsArray(JsonValue * value);
extern JsonValue *
JsonValueString(char *string);
JsonValueString(char *string);
extern JsonValue *
JsonValueInteger(int64_t integer);
JsonValueInteger(int64_t integer);
extern JsonValue *
JsonValueFloat(double floating);
JsonValueFloat(double floating);
extern JsonValue *
JsonValueBoolean(int boolean);
JsonValueBoolean(int boolean);
extern JsonValue *
JsonValueNull(void);
JsonValueNull(void);
extern void *
JsonValueFree(JsonValue *value);
JsonValueFree(JsonValue * value);
extern char *
JsonEncode(HashMap *object);
JsonEncode(HashMap * object);
extern HashMap *
JsonDecode(char *string);
JsonDecode(char *string);
#endif

View File

@ -4,7 +4,8 @@
#include <stdio.h>
#include <stddef.h>
typedef enum LogLevel {
typedef enum LogLevel
{
LOG_ERROR,
LOG_WARNING,
LOG_TASK,
@ -12,52 +13,53 @@ typedef enum LogLevel {
LOG_DEBUG
} LogLevel;
typedef enum LogFlag {
LOG_FLAG_COLOR = (1 << 0)
typedef enum LogFlag
{
LOG_FLAG_COLOR = (1 << 0)
} LogFlag;
typedef struct LogConfig LogConfig;
extern LogConfig *
LogConfigCreate(void);
LogConfigCreate(void);
extern void
LogConfigFree(LogConfig *config);
LogConfigFree(LogConfig * config);
extern void
LogConfigLevelSet(LogConfig *config, LogLevel level);
LogConfigLevelSet(LogConfig * config, LogLevel level);
extern LogLevel
LogConfigLevelGet(LogConfig *config);
LogConfigLevelGet(LogConfig * config);
extern void
LogConfigIndentSet(LogConfig *config, size_t indent);
LogConfigIndentSet(LogConfig * config, size_t indent);
extern size_t
LogConfigIndentGet(LogConfig *config);
LogConfigIndentGet(LogConfig * config);
extern void
LogConfigIndent(LogConfig *config);
LogConfigIndent(LogConfig * config);
extern void
LogConfigUnindent(LogConfig *config);
LogConfigUnindent(LogConfig * config);
extern void
LogConfigOutputSet(LogConfig *config, FILE *out);
LogConfigOutputSet(LogConfig * config, FILE * out);
extern void
LogConfigFlagSet(LogConfig *config, int flags);
LogConfigFlagSet(LogConfig * config, int flags);
extern void
LogConfigFlagClear(LogConfig *config, int flags);
LogConfigFlagClear(LogConfig * config, int flags);
extern int
LogConfigFlagGet(LogConfig *config, int flags);
LogConfigFlagGet(LogConfig * config, int flags);
extern void
LogConfigTimeStampFormatSet(LogConfig *config, char *tsFmt);
LogConfigTimeStampFormatSet(LogConfig * config, char *tsFmt);
extern void
Log(LogConfig *config, LogLevel level, const char *msg, ...);
Log(LogConfig * config, LogLevel level, const char *msg,...);
#endif