Fix a strange compilation bug

This commit is contained in:
Quentin 2021-01-05 10:56:54 +01:00
parent 9747457ce3
commit fa02001a08
6 changed files with 16 additions and 10 deletions

View file

@ -11,7 +11,7 @@ int main(int argc, char** argv) {
setvbuf(stdout, NULL, _IONBF, 0);
printf("~ Donar ~\n");
timing_fx_init (&static_tfx, TIMING_ACTIVATED | TIMING_DISPLAY_END, "", "fn=%s");
timing_fx_init (static_tfx(), TIMING_ACTIVATED | TIMING_DISPLAY_END, "", "fn=%s");
struct donar_params dp = {0};
donar_init_params (&dp);

View file

@ -335,7 +335,7 @@ void spawn_udp_server(struct evt_core_ctx* evts) {
printf("--- UDP server is listening\n");
}
void spawn_tor_server(struct evt_core_ctx* evts, uint16_t *ports) {
void spawn_tcp_server(struct evt_core_ctx* evts, uint16_t *ports) {
char buffer[1024];
int tcp_serv_sock, err;
@ -438,13 +438,13 @@ int main(int argc, char** argv) {
if (mctx.mc.is_server && strcmp(mctx.transport, "udp") == 0) {
spawn_udp_server (&evts);
mctx.is_from_needed = 1;
}
else if (mctx.mc.is_server && strcmp(mctx.transport, "tor") == 0) {
spawn_tor_server(&evts, ports);
spawn_tcp_server(&evts, ports);
measlat_create_onion_services (&tos, &tctl, ports, ports_count, mctx.tor_flags);
printf("--- Onion services created\n");
}
else if (mctx.mc.is_server && strcmp(mctx.transport, "tcp") == 0) spawn_tcp_server(&evts, ports);
else if (strcmp(mctx.transport, "udp") == 0) spawn_udp_client(&evts);
else if (strcmp(mctx.transport, "tor") == 0) spawn_tor_client(&evts);
else exit(EXIT_FAILURE);

View file

@ -1,4 +1,5 @@
#pragma once
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>

View file

@ -1,5 +1,9 @@
#include "stopwatch.h"
struct timing_fx _static_tfx;
struct timing_fx* static_tfx() { return &_static_tfx; }
void timing_fx_init(struct timing_fx* tfx, enum timing_config conf, char* startt, char* endt) {
tfx->config = conf;
strncpy (tfx->start_template, startt, sizeof(tfx->start_template) - 1);

View file

@ -1,4 +1,5 @@
#pragma once
#ifndef donar_stopwatch
#define donar_stopwatch
#include <string.h>
#include <stdint.h>
@ -22,8 +23,8 @@ struct timing_fx {
char start_template[255], end_template[255];
};
struct timing_fx static_tfx;
struct timing_fx* static_tfx();
void timing_fx_init(struct timing_fx* tfx, enum timing_config conf, char* startt, char* endt);
void timing_fx_start(struct timing_fx* tfx, ...);
double timing_fx_stop(struct timing_fx* tfx, ...);
#endif

View file

@ -10,9 +10,9 @@ int main(int argc, char** argv) {
setvbuf(stdout, NULL, _IONBF, 0);
printf("~ test ~\n");
timing_fx_init (&static_tfx, TIMING_ACTIVATED|TIMING_DISPLAY_END, "", "info=%s");
timing_fx_start (&static_tfx);
timing_fx_init (static_tfx (), TIMING_ACTIVATED|TIMING_DISPLAY_END, "", "info=%s");
timing_fx_start (static_tfx());
sleep(1);
timing_fx_stop(&static_tfx, "sleep(1)");
timing_fx_stop(static_tfx(), "sleep(1)");
}