diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
commit | a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch) | |
tree | b88cc7a8457658d67e0321718556ac807f6bccf3 /src/include/srs2.h | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/include/srs2.h')
-rw-r--r-- | src/include/srs2.h | 88 |
1 files changed, 43 insertions, 45 deletions
diff --git a/src/include/srs2.h b/src/include/srs2.h index e993928..9856636 100644 --- a/src/include/srs2.h +++ b/src/include/srs2.h @@ -19,12 +19,12 @@ */ /* This is ugly, but reasonably safe. */ -#undef TRUE +#undef TRUE #define TRUE 1 -#undef FALSE +#undef FALSE #define FALSE 0 -#define SRSSEP '=' +#define SRSSEP '=' #define SRS0TAG "SRS0" #define SRS1TAG "SRS1" @@ -37,15 +37,15 @@ #define SRS_ERRTYPE_SYNTAX 0x4000 #define SRS_ERRTYPE_SRS 0x8000 -#define SRS_SUCCESS (0) -#define SRS_ENOTSRSADDRESS (1) -#define SRS_ENOTREWRITTEN (2) +#define SRS_SUCCESS (0) +#define SRS_ENOTSRSADDRESS (1) +#define SRS_ENOTREWRITTEN (2) #define SRS_ENOSECRETS (SRS_ERRTYPE_CONFIG | 1) #define SRS_ESEPARATORINVALID (SRS_ERRTYPE_CONFIG | 2) -#define SRS_ENOSENDERATSIGN (SRS_ERRTYPE_INPUT | 1) -#define SRS_EBUFTOOSMALL (SRS_ERRTYPE_INPUT | 2) +#define SRS_ENOSENDERATSIGN (SRS_ERRTYPE_INPUT | 1) +#define SRS_EBUFTOOSMALL (SRS_ERRTYPE_INPUT | 2) #define SRS_ENOSRS0HOST (SRS_ERRTYPE_SYNTAX | 1) #define SRS_ENOSRS0USER (SRS_ERRTYPE_SYNTAX | 2) @@ -58,69 +58,67 @@ #define SRS_EHASHTOOSHORT (SRS_ERRTYPE_SYNTAX | 9) #define SRS_ETIMESTAMPOUTOFDATE (SRS_ERRTYPE_SRS | 1) -#define SRS_EHASHINVALID (SRS_ERRTYPE_SRS | 2) +#define SRS_EHASHINVALID (SRS_ERRTYPE_SRS | 2) #define SRS_ERROR_TYPE(x) ((x) & SRS_ERRTYPE_MASK) /* SRS implementation */ -#define SRS_IS_SRS_ADDRESS(x) ( \ - (strncasecmp((x),"SRS",3) == 0) && \ - (strchr("01", (x)[3]) != NULL) && \ - (strchr("-+=", (x)[4]) != NULL) \ -) +#define SRS_IS_SRS_ADDRESS(x) \ + ((strncasecmp((x), "SRS", 3) == 0) && (strchr("01", (x)[3]) != NULL) \ + && (strchr("-+=", (x)[4]) != NULL)) typedef void *(*srs_malloc_t)(size_t); -typedef void *(*srs_realloc_t)(void *,size_t); +typedef void *(*srs_realloc_t)(void *, size_t); typedef void (*srs_free_t)(void *); typedef int srs_bool; typedef struct _srs_t { /* Rewriting parameters */ -// stralloc cookies; + // stralloc cookies; char **secrets; int numsecrets; char separator; /* Security parameters */ - int maxage; /* Maximum allowed age in seconds */ + int maxage; /* Maximum allowed age in seconds */ int hashlen; int hashmin; /* Behaviour parameters */ - srs_bool alwaysrewrite; /* Rewrite even into same domain? */ - srs_bool noforward; /* Never perform forwards rewriting */ - srs_bool noreverse; /* Never perform reverse rewriting */ - char **neverrewrite; /* A list of non-rewritten domains */ + srs_bool alwaysrewrite; /* Rewrite even into same domain? */ + srs_bool noforward; /* Never perform forwards rewriting */ + srs_bool noreverse; /* Never perform reverse rewriting */ + char **neverrewrite; /* A list of non-rewritten domains */ } srs_t; /* Interface */ -int srs_set_malloc(srs_malloc_t m,srs_realloc_t r,srs_free_t f); +int srs_set_malloc(srs_malloc_t m, srs_realloc_t r, srs_free_t f); srs_t *srs_new(); void srs_init(srs_t *); void srs_free(srs_t *); -int srs_forward(srs_t *,char *,int,const char *,const char *); -int srs_forward_alloc(srs_t *,char **,const char *,const char *); -int srs_reverse(srs_t *,char *,int, const char *); -int srs_reverse_alloc(srs_t *,char **,const char *); +int srs_forward(srs_t *, char *, int, const char *, const char *); +int srs_forward_alloc(srs_t *, char **, const char *, const char *); +int srs_reverse(srs_t *, char *, int, const char *); +int srs_reverse_alloc(srs_t *, char **, const char *); const char *srs_strerror(int); -int srs_add_secret(srs_t *,const char *); -const char * srs_get_secret(srs_t *,int); - /* You probably shouldn't call these. */ -int srs_timestamp_create(srs_t *,char *,time_t); -int srs_timestamp_check(srs_t *,const char *); - -#define SRS_PARAM_DECLARE(n, t) \ - int srs_set_ ## n (srs_t *srs, t value); \ - t srs_get_ ## n (srs_t *srs); - -SRS_PARAM_DECLARE(alwaysrewrite,srs_bool) -SRS_PARAM_DECLARE(separator,char) -SRS_PARAM_DECLARE(maxage,int) -SRS_PARAM_DECLARE(hashlen,int) -SRS_PARAM_DECLARE(hashmin,int) -SRS_PARAM_DECLARE(noforward,srs_bool) -SRS_PARAM_DECLARE(noreverse,srs_bool) - -#endif /* SRS2_H */ +int srs_add_secret(srs_t *, const char *); +const char *srs_get_secret(srs_t *, int); +/* You probably shouldn't call these. */ +int srs_timestamp_create(srs_t *, char *, time_t); +int srs_timestamp_check(srs_t *, const char *); + +#define SRS_PARAM_DECLARE(n, t) \ + int srs_set_##n(srs_t *srs, t value); \ + t srs_get_##n(srs_t *srs); + +SRS_PARAM_DECLARE(alwaysrewrite, srs_bool) +SRS_PARAM_DECLARE(separator, char) +SRS_PARAM_DECLARE(maxage, int) +SRS_PARAM_DECLARE(hashlen, int) +SRS_PARAM_DECLARE(hashmin, int) +SRS_PARAM_DECLARE(noforward, srs_bool) +SRS_PARAM_DECLARE(noreverse, srs_bool) + +#endif /* SRS2_H */ |