Format source code.

This commit is contained in:
Jordan Bancino 2023-06-18 02:53:52 +00:00
parent 861d4146c0
commit e3badbd55c
8 changed files with 208 additions and 147 deletions

View file

@ -109,6 +109,7 @@ main(int argc, char **argv)
for (i = 0; i < (size_t) argc; i++)
{
char *arg = StrDuplicate(argv[i]);
if (!arg || !ArrayAdd(args.args, arg))
{
errLen = snprintf(errBuf, ERR_BUF_SIZE, "Fatal: Unable to allocate heap memory for program argument.\n");

View file

@ -78,26 +78,86 @@ Sha1Transform(UInt32 state[5], const UInt8 buffer[64])
d = state[3];
e = state[4];
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
R0(a, b, c, d, e, 0);
R0(e, a, b, c, d, 1);
R0(d, e, a, b, c, 2);
R0(c, d, e, a, b, 3);
R0(b, c, d, e, a, 4);
R0(a, b, c, d, e, 5);
R0(e, a, b, c, d, 6);
R0(d, e, a, b, c, 7);
R0(c, d, e, a, b, 8);
R0(b, c, d, e, a, 9);
R0(a, b, c, d, e, 10);
R0(e, a, b, c, d, 11);
R0(d, e, a, b, c, 12);
R0(c, d, e, a, b, 13);
R0(b, c, d, e, a, 14);
R0(a, b, c, d, e, 15);
R1(e, a, b, c, d, 16);
R1(d, e, a, b, c, 17);
R1(c, d, e, a, b, 18);
R1(b, c, d, e, a, 19);
R2(a, b, c, d, e, 20);
R2(e, a, b, c, d, 21);
R2(d, e, a, b, c, 22);
R2(c, d, e, a, b, 23);
R2(b, c, d, e, a, 24);
R2(a, b, c, d, e, 25);
R2(e, a, b, c, d, 26);
R2(d, e, a, b, c, 27);
R2(c, d, e, a, b, 28);
R2(b, c, d, e, a, 29);
R2(a, b, c, d, e, 30);
R2(e, a, b, c, d, 31);
R2(d, e, a, b, c, 32);
R2(c, d, e, a, b, 33);
R2(b, c, d, e, a, 34);
R2(a, b, c, d, e, 35);
R2(e, a, b, c, d, 36);
R2(d, e, a, b, c, 37);
R2(c, d, e, a, b, 38);
R2(b, c, d, e, a, 39);
R3(a, b, c, d, e, 40);
R3(e, a, b, c, d, 41);
R3(d, e, a, b, c, 42);
R3(c, d, e, a, b, 43);
R3(b, c, d, e, a, 44);
R3(a, b, c, d, e, 45);
R3(e, a, b, c, d, 46);
R3(d, e, a, b, c, 47);
R3(c, d, e, a, b, 48);
R3(b, c, d, e, a, 49);
R3(a, b, c, d, e, 50);
R3(e, a, b, c, d, 51);
R3(d, e, a, b, c, 52);
R3(c, d, e, a, b, 53);
R3(b, c, d, e, a, 54);
R3(a, b, c, d, e, 55);
R3(e, a, b, c, d, 56);
R3(d, e, a, b, c, 57);
R3(c, d, e, a, b, 58);
R3(b, c, d, e, a, 59);
R4(a, b, c, d, e, 60);
R4(e, a, b, c, d, 61);
R4(d, e, a, b, c, 62);
R4(c, d, e, a, b, 63);
R4(b, c, d, e, a, 64);
R4(a, b, c, d, e, 65);
R4(e, a, b, c, d, 66);
R4(d, e, a, b, c, 67);
R4(c, d, e, a, b, 68);
R4(b, c, d, e, a, 69);
R4(a, b, c, d, e, 70);
R4(e, a, b, c, d, 71);
R4(d, e, a, b, c, 72);
R4(c, d, e, a, b, 73);
R4(b, c, d, e, a, 74);
R4(a, b, c, d, e, 75);
R4(e, a, b, c, d, 76);
R4(d, e, a, b, c, 77);
R4(c, d, e, a, b, 78);
R4(b, c, d, e, a, 79);
state[0] += a;
state[1] += b;
@ -107,7 +167,7 @@ Sha1Transform(UInt32 state[5], const UInt8 buffer[64])
}
static void
Sha1Init(Sha1Context *ctx)
Sha1Init(Sha1Context * ctx)
{
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xEFCDAB89;
@ -120,7 +180,7 @@ Sha1Init(Sha1Context *ctx)
}
static void
Sha1Update(Sha1Context *ctx, const void *buf, UInt32 size)
Sha1Update(Sha1Context * ctx, const void *buf, UInt32 size)
{
UInt32 i, j;
@ -140,7 +200,7 @@ Sha1Update(Sha1Context *ctx, const void *buf, UInt32 size)
memcpy(&ctx->buffer[j], buf, i);
Sha1Transform(ctx->state, ctx->buffer);
for ( ; i + 63 < size; i += 64)
for (; i + 63 < size; i += 64)
{
Sha1Transform(ctx->state, (UInt8 *) buf + i);
}
@ -152,11 +212,11 @@ Sha1Update(Sha1Context *ctx, const void *buf, UInt32 size)
i = 0;
}
memcpy(&ctx->buffer[j], &((UInt8 *)buf)[i], size - i);
memcpy(&ctx->buffer[j], &((UInt8 *) buf)[i], size - i);
}
static void
Sha1Calculate(Sha1Context *ctx, unsigned char *out)
Sha1Calculate(Sha1Context * ctx, unsigned char *out)
{
UInt32 i;
UInt8 count[8];

View file

@ -32,13 +32,13 @@
#include <Str.h>
static HashMap *
ValidateRoomFilter(HashMap *json)
ValidateRoomFilter(HashMap * json)
{
return NULL;
}
static HashMap *
ValidateEventFields(Array *fields)
ValidateEventFields(Array * fields)
{
return NULL;
}
@ -50,7 +50,7 @@ ValidateEventFormat(char *fmt)
}
static HashMap *
ValidateEventFilter(HashMap *json)
ValidateEventFilter(HashMap * json)
{
JsonValue *val;
@ -60,6 +60,7 @@ ValidateEventFilter(HashMap *json)
if (JsonValueType(val) == JSON_INTEGER)
{
long limit = JsonValueAsInteger(val);
if (limit <= 0 || limit > 100)
{
return MatrixErrorCreate(M_BAD_JSON);
@ -75,7 +76,7 @@ ValidateEventFilter(HashMap *json)
}
HashMap *
FilterValidate(HashMap *json)
FilterValidate(HashMap * json)
{
JsonValue *val;
HashMap *response = NULL;
@ -109,4 +110,3 @@ FilterValidate(HashMap *json)
finish:
return response;
}

View file

@ -35,7 +35,7 @@
#include <string.h>
static char *
GetServerName(Db *db)
GetServerName(Db * db)
{
char *name;

View file

@ -35,7 +35,7 @@
#include <Json.h>
static void
HexDump(size_t off, char *hexBuf , char *asciiBuf, void *args)
HexDump(size_t off, char *hexBuf, char *asciiBuf, void *args)
{
char *fmt;
@ -118,7 +118,7 @@ struct Args
};
static void *
TestFunc(Array *path, void *argp)
TestFunc(Array * path, void *argp)
{
struct Args *args = argp;
HttpServerContext *cx = args->cx;
@ -164,7 +164,7 @@ TestFunc(Array *path, void *argp)
}
void
HttpHandle(HttpServerContext *cx, void *argp)
HttpHandle(HttpServerContext * cx, void *argp)
{
struct Args *args = argp;