#include "tw_config.h"
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
struct tw_config config;
-void tw_config_init(void) {}
+void tw_config_init(void) {
+ int i;
+ for(i = 0; i < MAX_PORTS + 1; i++) {
+ config.ports[i] = -1;
+ }
+}
int tw_config_read(const char* path) {
cm_log("Config", "Reading %s", path);
free(vhost);
vhost = NULL;
}
+ } else if(cm_strcaseequ(r[0], "Listen") || cm_strcaseequ(r[0], "ListenSSL")) {
+ for(i = 1; r[i] != NULL; i++) {
+ uint64_t port = atoi(r[i]);
+ cm_log("Config", "Going to listen at port %d%s", (int)port, cm_strcaseequ(r[0], "ListenSSL") ? " with SSL" : "");
+ if(cm_strcaseequ(r[0], "ListenSSL")) port |= (1ULL << 32);
+ int j;
+ for(j = 0; config.ports[j] != -1; j++)
+ ;
+ config.ports[j] = port;
+ }
} else {
if(r[0] != NULL) {
cm_log("Config", "Unknown directive `%s' at line %d", r[0], ln);
#ifndef __TW_CONFIG_H__
#define __TW_CONFIG_H__
+#include <stdint.h>
+
+/* I don't think you would listen to 1024 ports */
+#define MAX_PORTS 1024
+
struct tw_config_entry {};
struct tw_config {
+ uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */
struct tw_config_entry root;
};