summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-05-13 18:40:42 +0200
committerYorhel <git@yorhel.nl>2012-05-13 18:46:19 +0200
commitf5692e4b3904f64f5edf0aacc96e80b9f1608ca1 (patch)
tree2efe9b97c8626315ec68a2fecf6c353f0765b2a4 /src
parent02923e5175f42a616995e2f1dcda2f66a046eed4 (diff)
Use makeheaders to generate a specific header for each .c file
This is a bit different from the previous approach where a .h file was generated for each .c file as well, except that those .h files contained all the exported definitions. With this new approach, the .h files are not supposed to be included in any file besides the correspondig .c file, and they now contain the exported definitions used from other .c files. This is all explained in the makeheaders documentation at http://www.hwaci.com/sw/mkhdr/makeheaders.html. This will likely need a bit more tweaking here and there.
Diffstat (limited to 'src')
-rw-r--r--src/cc.c1
-rw-r--r--src/commands.c2
-rw-r--r--src/db.c1
-rw-r--r--src/dl.c1
-rw-r--r--src/fl_load.c1
-rw-r--r--src/fl_local.c1
-rw-r--r--src/fl_save.c1
-rw-r--r--src/fl_util.c1
-rw-r--r--src/hub.c1
-rw-r--r--src/listen.c1
-rw-r--r--src/main.c1
-rw-r--r--src/ncdc.h48
-rw-r--r--src/net.c1
-rw-r--r--src/proto.c11
-rw-r--r--src/search.c1
-rw-r--r--src/tth.c1
-rw-r--r--src/ui.c1
-rw-r--r--src/ui_util.c7
-rw-r--r--src/util.c1
-rw-r--r--src/vars.c21
-rw-r--r--src/xmlread.c1
21 files changed, 42 insertions, 63 deletions
diff --git a/src/cc.c b/src/cc.c
index ff2e9fd..8d13cc6 100644
--- a/src/cc.c
+++ b/src/cc.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "cc.h"
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
diff --git a/src/commands.c b/src/commands.c
index e3e0f6f..490c3d1 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -25,6 +25,8 @@
#include "ncdc.h"
+#include "commands.h"
+
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
diff --git a/src/db.c b/src/db.c
index a6cc652..828a4a5 100644
--- a/src/db.c
+++ b/src/db.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "db.h"
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/src/dl.c b/src/dl.c
index ba875c7..8ae717c 100644
--- a/src/dl.c
+++ b/src/dl.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "dl.h"
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
diff --git a/src/fl_load.c b/src/fl_load.c
index 268ea99..1700b8e 100644
--- a/src/fl_load.c
+++ b/src/fl_load.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "fl_load.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
diff --git a/src/fl_local.c b/src/fl_local.c
index 0786341..10c269b 100644
--- a/src/fl_local.c
+++ b/src/fl_local.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "fl_local.h"
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/src/fl_save.c b/src/fl_save.c
index c3a6152..6e4a65e 100644
--- a/src/fl_save.c
+++ b/src/fl_save.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "fl_save.h"
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/fl_util.c b/src/fl_util.c
index 74d38e6..d08cbc9 100644
--- a/src/fl_util.c
+++ b/src/fl_util.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "fl_util.h"
#include <string.h>
diff --git a/src/hub.c b/src/hub.c
index 7294dfe..a21cd74 100644
--- a/src/hub.c
+++ b/src/hub.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "hub.h"
#include <stdlib.h>
#if SUDP_SUPPORT
# include <gnutls/crypto.h>
diff --git a/src/listen.c b/src/listen.c
index af9d4b9..8cbb409 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -24,6 +24,7 @@
*/
#include "ncdc.h"
+#include "listen.h"
#include <errno.h>
#include <unistd.h>
diff --git a/src/main.c b/src/main.c
index ecbc1f3..6209293 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "main.h"
#include <stdlib.h>
#include <locale.h>
#include <signal.h>
diff --git a/src/ncdc.h b/src/ncdc.h
index 0374d56..8a0d1d4 100644
--- a/src/ncdc.h
+++ b/src/ncdc.h
@@ -1,6 +1,6 @@
/* ncdc - NCurses Direct Connect client
- Copyright (c) 2011 Yoran Heling
+ Copyright (c) 2011-2012 Yoran Heling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -53,49 +53,3 @@
// SUDP requires gnutls_rnd(), added in 2.12.0
#define SUDP_SUPPORT (GNUTLS_VERSION_MAJOR > 2 || (GNUTLS_VERSION_MAJOR == 2 && GNUTLS_VERSION_MINOR >= 12))
-
-// forward declaration for data types
-// (some of these remain incomplete, others are defined in interfaces)
-struct cc;
-struct cc_expect;
-struct dl;
-struct dl_user;
-struct dl_user_dl;
-struct fl_list;
-struct hub;
-struct hub_user;
-struct logfile;
-struct net;
-struct search_q;
-struct search_r;
-struct tiger_ctx;
-struct tth_ctx;
-struct ui_listing;
-struct ui_logwindow;
-struct ui_tab;
-struct ui_textinput;
-struct var;
-
-
-// include the auto-generated header files
-#include "cc.h"
-#include "commands.h"
-#include "db.h"
-#include "dl.h"
-#include "fl_load.h"
-#include "fl_local.h"
-#include "fl_save.h"
-#include "fl_util.h"
-#include "hub.h"
-#include "listen.h"
-#include "main.h"
-#include "net.h"
-#include "proto.h"
-#include "search.h"
-#include "tth.h"
-#include "ui.h"
-#include "ui_util.h"
-#include "util.h"
-#include "vars.h"
-#include "xmlread.h"
-
diff --git a/src/net.c b/src/net.c
index ea1b99e..a420ce3 100644
--- a/src/net.c
+++ b/src/net.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "net.h"
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
diff --git a/src/proto.c b/src/proto.c
index d9da406..9278df4 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "proto.h"
#include <stdlib.h>
@@ -172,7 +173,7 @@ char *adc_escape(const char *str, gboolean nmdc) {
#define ADC_TOCMDV(a, b, c) ((a) + ((b)<<8) + ((c)<<16))
#define ADC_TOCMD(str) ADC_TOCMDV((str)[0], (str)[1], (str)[2])
-enum adc_commands {
+enum adc_cmd_type {
#define C(n, a, b, c) ADCC_##n = ADC_TOCMDV(a,b,c)
// Base commands (copied from DC++ / AdcCommand.h)
C(SUP, 'S','U','P'), // F,T,C - PROTOCOL, NORMAL
@@ -195,10 +196,10 @@ enum adc_commands {
struct adc_cmd {
- char type; // B|C|D|E|F|H|I|U
- int cmd; // ADCC_*, but can also be something else. Unhandled commands should be ignored anyway.
- int source; // Only when type = B|D|E|F
- int dest; // Only when type = D|E
+ char type; // B|C|D|E|F|H|I|U
+ adc_cmd_type cmd; // ADCC_*, but can also be something else. Unhandled commands should be ignored anyway.
+ int source; // Only when type = B|D|E|F
+ int dest; // Only when type = D|E
char **argv;
char argc;
};
diff --git a/src/search.c b/src/search.c
index 7cb978b..30bd24d 100644
--- a/src/search.c
+++ b/src/search.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "search.h"
#include <stdlib.h>
#include <string.h>
#if SUDP_SUPPORT
diff --git a/src/tth.c b/src/tth.c
index f28e1c3..919e2df 100644
--- a/src/tth.c
+++ b/src/tth.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "tth.h"
diff --git a/src/ui.c b/src/ui.c
index d72f0b9..915a5d6 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "ui.h"
#include <math.h>
#include <unistd.h>
diff --git a/src/ui_util.c b/src/ui_util.c
index 21123b8..9793e75 100644
--- a/src/ui_util.c
+++ b/src/ui_util.c
@@ -24,6 +24,7 @@
*/
#include "ncdc.h"
+#include "ui_util.h"
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
@@ -79,7 +80,7 @@ struct ui_attr {
int attr;
}
-#define UIC(n) (ui_colors[UIC_##n].a)
+#define UIC(n) (ui_colors[(ui_coltype)UIC_##n].a)
#endif // INTERFACE
@@ -716,6 +717,8 @@ void ui_cmdhist_close() {
// Text input "widget"
+#if INTERFACE
+
struct ui_textinput {
int pos; // position of the cursor, in number of characters
GString *str;
@@ -728,6 +731,8 @@ struct ui_textinput {
int c_cur;
};
+#endif
+
struct ui_textinput *ui_textinput_create(gboolean usehist, void (*complete)(char *, char **)) {
diff --git a/src/util.c b/src/util.c
index 82f9035..58785b5 100644
--- a/src/util.c
+++ b/src/util.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "util.h"
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
diff --git a/src/vars.c b/src/vars.c
index ded9270..01ea2a5 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -25,6 +25,7 @@
#include "ncdc.h"
+#include "vars.h"
#include <string.h>
#include <stdlib.h>
@@ -865,7 +866,7 @@ struct var {
V(ui_time_format, 1,0, f_id, p_id, su_old, NULL, NULL, "[%H:%M:%S]")\
V(upload_rate, 1,0, f_speed, p_speed, NULL, NULL, NULL, NULL)
-enum var_names {
+enum var_type {
#define V(n, gl, h, f, p, su, g, s, d) VAR_##n,
#define C(n, d) VAR_color_##n,
VARS
@@ -905,7 +906,7 @@ int vars_byname(const char *n) {
// Calls setraw() on the specified var
-gboolean var_set(guint64 h, int n, const char *v, GError **err) {
+gboolean var_set(guint64 h, var_type n, const char *v, GError **err) {
if(vars[n].setraw)
return vars[n].setraw(h, vars[n].name, v, err);
db_vars_set(h, vars[n].name, v);
@@ -913,10 +914,15 @@ gboolean var_set(guint64 h, int n, const char *v, GError **err) {
}
+gboolean var_set_bool(guint64 h, var_type n, gboolean v) {
+ return var_set(h, n, v ? "true" : "false", NULL);
+}
+
+
// Calls getraw() on the specified var. If h != 0 and no value is found for
// that hub, then another getraw() will be called with h = 0. If that fails,
// the default value is returned instead.
-char *var_get(guint64 h, int n) {
+char *var_get(guint64 h, var_type n) {
char *r = NULL;
if(vars[n].getraw)
r = vars[n].getraw(h, vars[n].name);
@@ -926,17 +932,12 @@ char *var_get(guint64 h, int n) {
}
-#if INTERFACE
-#define var_set_bool(h, n, v) var_set(h, n, v ? "true" : "false", NULL)
-#endif
-
-
-gboolean var_get_bool(guint64 h, int n) {
+gboolean var_get_bool(guint64 h, var_type n) {
char *r = var_get(h, n);
return bool_raw(r);
}
-int var_get_int(guint64 h, int n) {
+int var_get_int(guint64 h, var_type n) {
char *r = var_get(h, n);
return int_raw(r);
}
diff --git a/src/xmlread.c b/src/xmlread.c
index 7112a28..73bac49 100644
--- a/src/xmlread.c
+++ b/src/xmlread.c
@@ -60,6 +60,7 @@
*/
#include "ncdc.h"
+#include "xmlread.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>