move regex to vger.h

This commit is contained in:
prx 2022-08-17 21:32:06 +02:00
parent 2b835bc39c
commit 26ca6c422d
2 changed files with 16 additions and 15 deletions

15
vger.c
View File

@ -514,21 +514,6 @@ split_request(const char *request, char *hostname, char *path, char *query)
char buf[BUFSIZ] = {'\0'}; /* to handle error messages */
int ret = 0;
const char *gemini_regex = "^gemini://+([^/|^\?]*)/*([^\?]*)[\?]?(.*)$";
/*
* ^gemini://+ : in case of gemini:///
* 1: hostname
* ([^/|^\?]*) :
* catch everything, stop when / or ? is found
* then skip multiple /
* 2: path
* ([^\?]*) :
* catch everything and stop at ? if any
* 3 : query
* [\?]?(.*)$:
* catch everything after ? if any
*/
if ((ret = regcomp(&greg, gemini_regex, REG_EXTENDED)) != 0) {
regerror(ret, &greg, buf, sizeof(buf));
regfree(&greg);

16
vger.h
View File

@ -11,6 +11,22 @@
*/
#define GEMINI_REQUEST_MAX 1025
/* gemini_regex:
* =============
* ^gemini://+ : in case of gemini:///
* 1: hostname
* ([^/|^\?]*) :
* catch everything, stop when / or ? is found
* then skip multiple /
* 2: path
* ([^\?]*) :
* catch everything and stop at ? if any
* 3 : query
* [\?]?(.*)$:
* catch everything after ? if any
*/
const char *gemini_regex = "^gemini://+([^/|^\?]*)/*([^\?]*)[\?]?(.*)$";
/* global vars */
static int _retcode = 0;
static ssize_t _datasiz = 0;