const char* domain;
} srs_config_t;
-static const char* decoder_ptr = "decoder";
-static const char* encoder_ptr = "encoder";
+
+/* Server {{{1
+ */
+
+static const char* const decoder_ptr = "decoder";
+static const char* const encoder_ptr = "encoder";
static void *srsd_new_decoder(void)
{
return (void*)encoder_ptr;
}
-static void *srsd_stater(server_t *server)
+static void *srsd_starter(server_t *server)
{
return server->data;
}
+int start_listener(int port, bool decoder)
+{
+ return start_server(port, decoder ? srsd_new_decoder : srsd_new_encoder, NULL);
+}
+
+
+/* Processing {{{1
+ */
+
void urldecode(char *s, char *end)
{
char *p = s;
return 0;
}
-int start_listener(int port, bool decoder)
-{
- return start_server(port, decoder ? srsd_new_decoder : srsd_new_encoder, NULL);
-}
-/* }}} */
-/* administrivia {{{ */
+/* config {{{1
+ */
+static srs_config_t config = {
+ .srs = NULL,
+ .domain = NULL
+};
-void usage(void)
+/** overload srs_free since the lib is not properly maintained.
+ */
+#undef srs_free
+
+inline void srs_free(srs_t* srs)
{
- fputs("usage: "DAEMON_NAME" [options] domain secrets\n"
- "\n"
- "Options:\n"
- " -e <port> port to listen to for encoding requests\n"
- " (default: "STR(DEFAULT_ENCODER_PORT)")\n"
- " -d <port> port to listen to for decoding requests\n"
- " (default: "STR(DEFAULT_DECODER_PORT)")\n"
- " -p <pidfile> file to write our pid to\n"
- " -u unsafe mode: don't drop privilegies\n"
- " -f stay in foreground\n"
- , stderr);
+ int i;
+ for (i = 0; i < srs->numsecrets; i++) {
+ memset(srs->secrets[i], 0, strlen(srs->secrets[i]));
+ free(srs->secrets[i]);
+ srs->secrets[i] = '\0';
+ }
+ if (srs->secrets) {
+ free(srs->secrets);
+ }
+ free(srs);
+}
+
+static void config_shutdown(void)
+{
+ if (config.srs) {
+ srs_free(config.srs);
+ config.srs = NULL;
+ }
}
-/* }}} */
+module_exit(config_shutdown);
static srs_t *srs_read_secrets(const char *sfile)
{
return NULL;
}
+/* administrivia {{{1
+ */
+
+void usage(void)
+{
+ fputs("usage: "DAEMON_NAME" [options] domain secrets\n"
+ "\n"
+ "Options:\n"
+ " -e <port> port to listen to for encoding requests\n"
+ " (default: "STR(DEFAULT_ENCODER_PORT)")\n"
+ " -d <port> port to listen to for decoding requests\n"
+ " (default: "STR(DEFAULT_DECODER_PORT)")\n"
+ " -p <pidfile> file to write our pid to\n"
+ " -u unsafe mode: don't drop privilegies\n"
+ " -f stay in foreground\n"
+ , stderr);
+}
+
+/* }}}
+ */
+
int main(int argc, char *argv[])
{
bool unsafe = false;
int port_enc = DEFAULT_ENCODER_PORT;
int port_dec = DEFAULT_DECODER_PORT;
const char *pidfile = NULL;
- srs_config_t config;
for (int c = 0; (c = getopt(argc, argv, "hfu" "e:d:p:")) >= 0; ) {
switch (c) {
|| start_listener(port_dec, true) < 0) {
return EXIT_FAILURE;
}
- return server_loop(srsd_stater, NULL, process_srs, &config);
+ return server_loop(srsd_starter, NULL, process_srs, &config);
}