From 47984a765b17c31b2a2817fd9f4e1586e9e380c1 Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Sun, 23 Oct 2011 00:13:42 +0200 Subject: [PATCH] uniform - added 'valid' member; macro fix --- include/psyc.h | 10 +++++----- include/psyc/uniform.h | 1 + src/uniform.c | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/psyc.h b/include/psyc.h index 416f9eb..692e5c6 100644 --- a/include/psyc.h +++ b/include/psyc.h @@ -22,10 +22,10 @@ #define PSYC_EPOCH 1440444041 // 2015-08-24 21:20:41 CET (Monday) -#define PSYC_C2STR(string) {sizeof(string)-1, string} -#define PSYC_C2ARG(string) string, sizeof(string)-1 -#define PSYC_S2ARG(string) string.ptr, string.length -#define PSYC_S2ARG2(string) string.length, string.ptr +#define PSYC_C2STR(str) {sizeof(str)-1, str} +#define PSYC_C2ARG(str) str, sizeof(str)-1 +#define PSYC_S2ARG(str) (str).ptr, (str).length +#define PSYC_S2ARG2(str) (str).length, (str).ptr typedef enum { @@ -92,7 +92,7 @@ typedef struct /// Length of the data pointed to by ptr size_t length; /// pointer to the data - const char *ptr; + char *ptr; } psycString; typedef struct diff --git a/include/psyc/uniform.h b/include/psyc/uniform.h index a07f3b7..24324cf 100644 --- a/include/psyc/uniform.h +++ b/include/psyc/uniform.h @@ -15,6 +15,7 @@ typedef enum { typedef struct { // essential parts + uint8_t valid; psycScheme type; psycString scheme; psycString user; diff --git a/src/uniform.c b/src/uniform.c index 5a52158..519e5c0 100644 --- a/src/uniform.c +++ b/src/uniform.c @@ -9,6 +9,7 @@ int psyc_parseUniform2 (psycUniform *uni, const char *str, size_t length) psycString *p; size_t pos = 0, part = PSYC_UNIFORM_SCHEME; + uni->valid = 0; uni->full.ptr = str; uni->full.length = length; @@ -161,6 +162,7 @@ int psyc_parseUniform2 (psycUniform *uni, const char *str, size_t length) if (uni->host.length == 0) return PSYC_PARSE_UNIFORM_INVALID_HOST; + uni->valid = 1; return uni->type; }