Format source code.

This commit is contained in:
Jordan Bancino 2023-03-16 12:29:38 +00:00
parent 7d9770fc12
commit 6ee1857f5f
10 changed files with 190 additions and 53 deletions

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Io.h>
#include <Memory.h>
@ -41,7 +64,7 @@ IoCreate(void *cookie, IoFunctions funcs)
}
ssize_t
IoRead(Io *io, void *buf, size_t nBytes)
IoRead(Io * io, void *buf, size_t nBytes)
{
if (!io || !io->io.read)
{
@ -53,7 +76,7 @@ IoRead(Io *io, void *buf, size_t nBytes)
}
ssize_t
IoWrite(Io *io, void *buf, size_t nBytes)
IoWrite(Io * io, void *buf, size_t nBytes)
{
if (!io || !io->io.write)
{
@ -65,7 +88,7 @@ IoWrite(Io *io, void *buf, size_t nBytes)
}
off_t
IoSeek(Io *io, off_t offset, int whence)
IoSeek(Io * io, off_t offset, int whence)
{
if (!io)
{
@ -83,7 +106,7 @@ IoSeek(Io *io, off_t offset, int whence)
}
int
IoClose(Io *io)
IoClose(Io * io)
{
int ret;
@ -108,7 +131,7 @@ IoClose(Io *io)
}
int
IoVprintf(Io *io, const char *fmt, va_list ap)
IoVprintf(Io * io, const char *fmt, va_list ap)
{
char *buf;
size_t write;
@ -134,13 +157,13 @@ IoVprintf(Io *io, const char *fmt, va_list ap)
return write;
}
/* Number of bytes to write exceeded buffer size; this should
* be rare, but may occasionally happen. If it does, realloc to
* the correct size and try again.
*/
/* Number of bytes to write exceeded buffer size; this should be
* rare, but may occasionally happen. If it does, realloc to the
* correct size and try again. */
if (write >= IO_BUFFER)
{
char *new = Realloc(buf, write + 1);
if (!new)
{
Free(buf);
@ -160,7 +183,7 @@ IoVprintf(Io *io, const char *fmt, va_list ap)
}
int
IoPrintf(Io *io, const char *fmt, ...)
IoPrintf(Io * io, const char *fmt,...)
{
va_list ap;
int ret;
@ -173,7 +196,7 @@ IoPrintf(Io *io, const char *fmt, ...)
}
ssize_t
IoCopy(Io *in, Io *out)
IoCopy(Io * in, Io * out)
{
ssize_t nBytes = 0;
char buf[IO_BUFFER];

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Io.h>
#include <Memory.h>

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Io.h>
#include <stdio.h>
@ -35,7 +58,7 @@ IoCloseFile(void *cookie)
}
Io *
IoFile(FILE *fp)
IoFile(FILE * fp)
{
IoFunctions f;
@ -51,4 +74,3 @@ IoFile(FILE *fp)
return IoCreate(fp, f);
}

View file

@ -745,10 +745,9 @@ JsonConsumeWhitespace(JsonParserState * state)
}
}
/* As soon as we've successfully read a byte, treat
* future EAGAINs as EOF, because some clients don't
* properly shutdown their sockets.
*/
/* As soon as we've successfully read a byte, treat future
* EAGAINs as EOF, because some clients don't properly shutdown
* their sockets. */
readFlg = 1;
tries = 0;

View file

@ -204,9 +204,9 @@ RegTokenCreate(Db * db, char *name, char *owner, unsigned long expires, int uses
return NULL;
}
/* -1 indicates infinite uses; zero and all positive values are a valid
* number of uses; althought zero would be rather useless. Anything less
* than -1 doesn't make sense. */
/* -1 indicates infinite uses; zero and all positive values are a
* valid number of uses; althought zero would be rather useless.
* Anything less than -1 doesn't make sense. */
if (uses < -1)
{
return NULL;

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Stream.h>
#include <Io.h>

View file

@ -429,7 +429,7 @@ UserDeactivate(User * user)
}
int
UserDeactivated(User *user)
UserDeactivated(User * user)
{
HashMap *json;

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef TELODENDRIA_IO_H
#define TELODENDRIA_IO_H
@ -11,9 +34,9 @@
typedef struct Io Io;
typedef ssize_t (IoReadFunc) (void *, void *, size_t);
typedef ssize_t (IoWriteFunc) (void *, void *, size_t);
typedef off_t (IoSeekFunc) (void *, off_t, int);
typedef ssize_t(IoReadFunc) (void *, void *, size_t);
typedef ssize_t(IoWriteFunc) (void *, void *, size_t);
typedef off_t(IoSeekFunc) (void *, off_t, int);
typedef int (IoCloseFunc) (void *);
typedef struct IoFunctions
@ -25,36 +48,36 @@ typedef struct IoFunctions
} IoFunctions;
extern Io *
IoCreate(void *, IoFunctions);
IoCreate(void *, IoFunctions);
extern ssize_t
IoRead(Io *, void *, size_t);
IoRead(Io *, void *, size_t);
extern ssize_t
IoWrite(Io *, void *, size_t);
IoWrite(Io *, void *, size_t);
extern off_t
IoSeek(Io *, off_t, int);
IoSeek(Io *, off_t, int);
extern int
IoClose(Io *);
IoClose(Io *);
extern int
IoVprintf(Io *, const char *, va_list);
IoVprintf(Io *, const char *, va_list);
extern int
IoPrintf(Io *, const char *, ...);
IoPrintf(Io *, const char *,...);
extern ssize_t
IoCopy(Io *, Io *);
IoCopy(Io *, Io *);
extern Io *
IoFd(int);
IoFd(int);
extern Io *
IoOpen(const char *, int, mode_t);
IoOpen(const char *, int, mode_t);
extern Io *
IoFile(FILE *);
IoFile(FILE *);
#endif /* TELODENDRIA_IO_H */

View file

@ -67,7 +67,8 @@ ROUTE(RouteRegister); /* /_matrix/client/(r0|v3)/register */
ROUTE(RouteRefresh); /* /_matrix/client/(r0|v3)/refresh */
ROUTE(RouteWhoami); /* /_matrix/client/(r0|v3)/whoami */
ROUTE(RouteTokenValid); /* /_matrix/client/v1/register/m.login.registration_token/validity */
ROUTE(RouteTokenValid); /* /_matrix/client/v1/register/m.logi
* n.registration_token/validity */
#undef ROUTE

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef TELODENDRIA_STREAM_H
#define TELODENDRIA_STREAM_H
@ -8,45 +31,45 @@
typedef struct Stream Stream;
extern Stream *
StreamIo(Io *io);
StreamIo(Io * io);
extern Stream *
StreamFd(int);
StreamFd(int);
extern Stream *
StreamOpen(const char *, const char *);
StreamOpen(const char *, const char *);
extern int
StreamClose(Stream *);
StreamClose(Stream *);
extern int
StreamVprintf(Stream *, const char *, va_list);
StreamVprintf(Stream *, const char *, va_list);
extern int
StreamPrintf(Stream *, const char *, ...);
StreamPrintf(Stream *, const char *,...);
extern int
StreamGetc(Stream *);
StreamGetc(Stream *);
extern int
StreamUngetc(Stream *, int);
StreamUngetc(Stream *, int);
extern int
StreamPutc(Stream *, int);
StreamPutc(Stream *, int);
extern int
StreamEof(Stream *);
StreamEof(Stream *);
extern int
StreamError(Stream *);
StreamError(Stream *);
extern void
StreamClearError(Stream *);
StreamClearError(Stream *);
extern int
StreamFlush(Stream *);
StreamFlush(Stream *);
extern ssize_t
StreamCopy(Stream *, Stream *);
StreamCopy(Stream *, Stream *);
#endif /* TELODENDRIA_STREAM_H */