forked from Telodendria/Telodendria
Renamed String.h to Str.h because Windows is dumb.
This commit is contained in:
parent
148706b517
commit
30c3690287
11 changed files with 50 additions and 50 deletions
20
src/Db.c
20
src/Db.c
|
@ -26,7 +26,7 @@
|
|||
#include <Memory.h>
|
||||
#include <Json.h>
|
||||
#include <Util.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -201,7 +201,7 @@ DbHashKey(Array * args)
|
|||
|
||||
for (i = 0; i < ArraySize(args); i++)
|
||||
{
|
||||
char *tmp = StringConcat(2, str, ArrayGet(args, i));
|
||||
char *tmp = StrConcat(2, str, ArrayGet(args, i));
|
||||
|
||||
Free(str);
|
||||
str = tmp;
|
||||
|
@ -214,13 +214,13 @@ static char *
|
|||
DbDirName(Db * db, Array * args)
|
||||
{
|
||||
size_t i;
|
||||
char *str = StringConcat(2, db->dir, "/");
|
||||
char *str = StrConcat(2, db->dir, "/");
|
||||
|
||||
for (i = 0; i < ArraySize(args) - 1; i++)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = StringConcat(3, str, ArrayGet(args, i), "/");
|
||||
tmp = StrConcat(3, str, ArrayGet(args, i), "/");
|
||||
|
||||
Free(str);
|
||||
|
||||
|
@ -234,12 +234,12 @@ static char *
|
|||
DbFileName(Db * db, Array * args)
|
||||
{
|
||||
size_t i;
|
||||
char *str = StringConcat(2, db->dir, "/");
|
||||
char *str = StrConcat(2, db->dir, "/");
|
||||
|
||||
for (i = 0; i < ArraySize(args); i++)
|
||||
{
|
||||
char *tmp;
|
||||
char *arg = StringDuplicate(ArrayGet(args, i));
|
||||
char *arg = StrDuplicate(ArrayGet(args, i));
|
||||
size_t j = 0;
|
||||
|
||||
/* Sanitize name to prevent directory traversal attacks */
|
||||
|
@ -259,8 +259,8 @@ DbFileName(Db * db, Array * args)
|
|||
j++;
|
||||
}
|
||||
|
||||
tmp = StringConcat(3, str, arg,
|
||||
(i < ArraySize(args) - 1) ? "/" : ".json");
|
||||
tmp = StrConcat(3, str, arg,
|
||||
(i < ArraySize(args) - 1) ? "/" : ".json");
|
||||
|
||||
Free(arg);
|
||||
Free(str);
|
||||
|
@ -504,11 +504,11 @@ DbLockFromArr(Db * db, Array * args)
|
|||
|
||||
for (i = 0; i < ArraySize(args); i++)
|
||||
{
|
||||
ArrayAdd(name, StringDuplicate(ArrayGet(args, i)));
|
||||
ArrayAdd(name, StrDuplicate(ArrayGet(args, i)));
|
||||
}
|
||||
ref->name = name;
|
||||
|
||||
HashMapSet(db->cache, StringDuplicate(hash), ref);
|
||||
HashMapSet(db->cache, StrDuplicate(hash), ref);
|
||||
db->cacheSize += ref->size;
|
||||
|
||||
ref->next = NULL;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <Json.h>
|
||||
|
||||
#include <Memory.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
@ -486,7 +486,7 @@ JsonDecodeString(FILE * in)
|
|||
|
||||
/* Encode the 4-byte UTF-8 buffer into a series
|
||||
* of 1-byte characters */
|
||||
utf8Ptr = StringUtf8Encode(utf8);
|
||||
utf8Ptr = StrUtf8Encode(utf8);
|
||||
if (!utf8Ptr)
|
||||
{
|
||||
/* Mem error */
|
||||
|
@ -494,8 +494,8 @@ JsonDecodeString(FILE * in)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Move the output of StringUtf8Encode() into
|
||||
* our local buffer */
|
||||
/* Move the output of StrUtf8Encode() into our
|
||||
* local buffer */
|
||||
strcpy(a, utf8Ptr);
|
||||
Free(utf8Ptr);
|
||||
break;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <Memory.h>
|
||||
#include <HttpServer.h>
|
||||
#include <Json.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
|
||||
#include <Routes.h>
|
||||
|
||||
|
@ -83,7 +83,7 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
|||
}
|
||||
|
||||
pathParts = MATRIX_PATH_CREATE();
|
||||
requestPathCpy = StringDuplicate(requestPath);
|
||||
requestPathCpy = StrDuplicate(requestPath);
|
||||
key = requestPathCpy;
|
||||
|
||||
while ((pathPart = strtok_r(key, "/", &key)))
|
||||
|
@ -295,8 +295,8 @@ MatrixErrorCreate(MatrixError errorArg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
HashMapSet(errorObj, "errcode", JsonValueString(StringDuplicate(errcode)));
|
||||
HashMapSet(errorObj, "error", JsonValueString(StringDuplicate(error)));
|
||||
HashMapSet(errorObj, "errcode", JsonValueString(StrDuplicate(errcode)));
|
||||
HashMapSet(errorObj, "error", JsonValueString(StrDuplicate(error)));
|
||||
|
||||
return errorObj;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <Json.h>
|
||||
#include <HashMap.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
|
||||
ROUTE_IMPL(RouteLogin, args)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ ROUTE_IMPL(RouteLogin, args)
|
|||
pwdFlow = HashMapCreate();
|
||||
|
||||
HashMapSet(pwdFlow, "type",
|
||||
JsonValueString(StringDuplicate("m.login.password")));
|
||||
JsonValueString(StrDuplicate("m.login.password")));
|
||||
ArrayAdd(enabledFlows, JsonValueObject(pwdFlow));
|
||||
HashMapSet(response, "flows", JsonValueArray(enabledFlows));
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <Memory.h>
|
||||
#include <Json.h>
|
||||
#include <HashMap.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
|
||||
ROUTE_IMPL(RouteMatrix, args)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ ROUTE_IMPL(RouteMatrix, args)
|
|||
|
||||
Free(pathPart);
|
||||
|
||||
ArrayAdd(versions, JsonValueString(StringDuplicate("v1.5")));
|
||||
ArrayAdd(versions, JsonValueString(StrDuplicate("v1.5")));
|
||||
|
||||
response = HashMapCreate();
|
||||
HashMapSet(response, "versions", JsonValueArray(versions));
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <Json.h>
|
||||
#include <HashMap.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
#include <Memory.h>
|
||||
|
||||
#include <User.h>
|
||||
|
@ -84,7 +84,7 @@ ROUTE_IMPL(RouteRegister, args)
|
|||
response = MatrixErrorCreate(M_BAD_JSON);
|
||||
goto finish;
|
||||
}
|
||||
username = StringDuplicate(JsonValueAsString(val));
|
||||
username = StrDuplicate(JsonValueAsString(val));
|
||||
|
||||
if (!UserValidate(username, args->matrixArgs->config->serverName))
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ ROUTE_IMPL(RouteRegister, args)
|
|||
goto finish;
|
||||
}
|
||||
|
||||
password = StringDuplicate(JsonValueAsString(val));
|
||||
password = StrDuplicate(JsonValueAsString(val));
|
||||
|
||||
val = HashMapGet(request, "device_id");
|
||||
if (val)
|
||||
|
@ -147,7 +147,7 @@ ROUTE_IMPL(RouteRegister, args)
|
|||
goto finish;
|
||||
}
|
||||
|
||||
deviceId = StringDuplicate(JsonValueAsString(val));
|
||||
deviceId = StrDuplicate(JsonValueAsString(val));
|
||||
}
|
||||
|
||||
val = HashMapGet(request, "inhibit_login");
|
||||
|
@ -173,7 +173,7 @@ ROUTE_IMPL(RouteRegister, args)
|
|||
goto finish;
|
||||
}
|
||||
|
||||
initialDeviceDisplayName = StringDuplicate(JsonValueAsString(val));
|
||||
initialDeviceDisplayName = StrDuplicate(JsonValueAsString(val));
|
||||
}
|
||||
|
||||
val = HashMapGet(request, "refresh_token");
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <Memory.h>
|
||||
#include <Json.h>
|
||||
#include <HashMap.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
|
||||
ROUTE_IMPL(RouteWellKnown, args)
|
||||
{
|
||||
|
@ -53,14 +53,14 @@ ROUTE_IMPL(RouteWellKnown, args)
|
|||
|
||||
response = HashMapCreate();
|
||||
|
||||
HashMapSet(homeserver, "base_url", JsonValueString(StringDuplicate(args->matrixArgs->config->baseUrl)));
|
||||
HashMapSet(homeserver, "base_url", JsonValueString(StrDuplicate(args->matrixArgs->config->baseUrl)));
|
||||
HashMapSet(response, "m.homeserver", JsonValueObject(homeserver));
|
||||
|
||||
if (args->matrixArgs->config->identityServer)
|
||||
{
|
||||
HashMap *identityServer = HashMapCreate();
|
||||
|
||||
HashMapSet(identityServer, "base_url", JsonValueString(StringDuplicate(args->matrixArgs->config->identityServer)));
|
||||
HashMapSet(identityServer, "base_url", JsonValueString(StrDuplicate(args->matrixArgs->config->identityServer)));
|
||||
HashMapSet(response, "m.identity_server", identityServer);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
|
||||
#include <Memory.h>
|
||||
#include <Util.h>
|
||||
|
@ -33,7 +33,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
char *
|
||||
StringUtf8Encode(unsigned long utf8)
|
||||
StrUtf8Encode(unsigned long utf8)
|
||||
{
|
||||
char *str;
|
||||
|
||||
|
@ -82,7 +82,7 @@ StringUtf8Encode(unsigned long utf8)
|
|||
}
|
||||
|
||||
char *
|
||||
StringDuplicate(const char *inStr)
|
||||
StrDuplicate(const char *inStr)
|
||||
{
|
||||
size_t len;
|
||||
char *outStr;
|
||||
|
@ -100,7 +100,7 @@ StringDuplicate(const char *inStr)
|
|||
}
|
||||
|
||||
char *
|
||||
StringConcat(size_t nStr,...)
|
||||
StrConcat(size_t nStr,...)
|
||||
{
|
||||
va_list argp;
|
||||
char *str;
|
||||
|
@ -150,7 +150,7 @@ StringConcat(size_t nStr,...)
|
|||
}
|
||||
|
||||
char *
|
||||
StringRandom(size_t len)
|
||||
StrRandom(size_t len)
|
||||
{
|
||||
static const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
static pthread_mutex_t seedLock = PTHREAD_MUTEX_INITIALIZER;
|
|
@ -27,7 +27,7 @@
|
|||
#include <HashMap.h>
|
||||
#include <Log.h>
|
||||
#include <Array.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
#include <Db.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -53,7 +53,7 @@
|
|||
}
|
||||
|
||||
#define CONFIG_COPY_STRING(into) \
|
||||
into = StringDuplicate(JsonValueAsString(value));
|
||||
into = StrDuplicate(JsonValueAsString(value));
|
||||
|
||||
#define CONFIG_OPTIONAL_STRING(into, key, default) \
|
||||
value = HashMapGet(config, key); \
|
||||
|
@ -64,12 +64,12 @@
|
|||
Log(lc, LOG_ERR, "Expected " key " to be of type JSON_STRING"); \
|
||||
goto error; \
|
||||
} \
|
||||
into = StringDuplicate(JsonValueAsString(value)); \
|
||||
into = StrDuplicate(JsonValueAsString(value)); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Log(lc, LOG_INFO, "Using default value " #default " for " key "."); \
|
||||
into = default ? StringDuplicate(default) : NULL; \
|
||||
into = default ? StrDuplicate(default) : NULL; \
|
||||
}
|
||||
|
||||
#define CONFIG_OPTIONAL_INTEGER(into, key, default) \
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <UserInteractiveAuth.h>
|
||||
|
||||
#include <Json.h>
|
||||
#include <String.h>
|
||||
#include <Str.h>
|
||||
#include <Matrix.h>
|
||||
|
||||
#include <string.h>
|
||||
|
@ -38,7 +38,7 @@ BuildDummyFlow(void)
|
|||
Array *flows = ArrayCreate();
|
||||
|
||||
ArrayAdd(stages,
|
||||
JsonValueString(StringDuplicate("m.login.dummy")));
|
||||
JsonValueString(StrDuplicate("m.login.dummy")));
|
||||
HashMapSet(dummyFlow, "stages", JsonValueArray(stages));
|
||||
ArrayAdd(flows, JsonValueObject(dummyFlow));
|
||||
|
||||
|
@ -68,7 +68,7 @@ UserInteractiveAuth(HttpServerContext * context, Db * db,
|
|||
{
|
||||
HashMap *response = NULL;
|
||||
HashMap *persist;
|
||||
char *session = StringRandom(24);
|
||||
char *session = StrRandom(24);
|
||||
|
||||
ref = DbLock(db, 1, "user_interactive");
|
||||
if (!ref)
|
||||
|
@ -84,7 +84,7 @@ UserInteractiveAuth(HttpServerContext * context, Db * db,
|
|||
response = BuildDummyFlow();
|
||||
|
||||
HashMapSet(response, "session",
|
||||
JsonValueString(StringDuplicate(session)));
|
||||
JsonValueString(StrDuplicate(session)));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -21,21 +21,21 @@
|
|||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef TELODENDRIA_STRING_H
|
||||
#define TELODENDRIA_STRING_H
|
||||
#ifndef TELODENDRIA_STR_H
|
||||
#define TELODENDRIA_STR_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern char *
|
||||
StringUtf8Encode(unsigned long);
|
||||
StrUtf8Encode(unsigned long);
|
||||
|
||||
extern char *
|
||||
StringDuplicate(const char *);
|
||||
StrDuplicate(const char *);
|
||||
|
||||
extern char *
|
||||
StringConcat(size_t,...);
|
||||
StrConcat(size_t,...);
|
||||
|
||||
extern char *
|
||||
StringRandom(size_t);
|
||||
StrRandom(size_t);
|
||||
|
||||
#endif /* TELODENDRIA_STRING_H */
|
||||
#endif /* TELODENDRIA_STR_H */
|
Loading…
Reference in a new issue