commit 155554d8ec25d911c973b5979ae7a3be4cc99303
parent e0142677f028fa10fe60feb95af7ea06bfb492af
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Tue, 5 Jan 2021 15:00:16 -0800
Improve configuration file
Move macro size definitions to gawk.h and document more variables.
Diffstat:
4 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/command.c b/command.c
@@ -21,7 +21,6 @@
#include <string.h>
#include <unistd.h>
-#include "config.h"
#include "gawk.h"
#include "util.h"
diff --git a/config.def.h b/config.def.h
@@ -1,31 +1,24 @@
-#include "command.h"
-#include "gawk.h"
+/* gawk configuration */
-/* default gopher hole (path, host, port): */
-static char const *default_address[] = { "/", "localhost", "70" };
-
-/* how long to wait for response */
-static int timeout = 5 * 1000;
+/* how long to wait for response in ms */
+static int const timeout = 5 * 1000;
/* command which gets run when a file is cached */
-static const char cache_command[] = "p";
+static char const cache_command[] = "p";
+
+/* default address if arguments are ommited */
+static char const *default_address[] = {
+ /* path, host, port */
+ "/", "localhost", "70"
+};
-/* statement, command, argument */
+/* statement, command, and argument separators */
static char const *const separators[] = {
";\n", "|", " \t,"
};
-/* arbitrary limits */
-#define CHUNK_SIZE 256 /* for slurping data */
-#define MY_ARGV_MAX 12
-#define MY_FILTER_MAX 4
-#define MY_INPUT_MAX 128
-#define MY_LINE_MAX 256
-#define MY_PATH_MAX 128
-#define MY_PIPE_MAX 12
-#define MY_URL_MAX 72
-
static const struct command item_commands[] = {
+ /* name, function */
{ 'e', cextern },
{ 'f', cfetch },
{ 'g', cgoto },
@@ -37,6 +30,7 @@ static const struct command item_commands[] = {
};
static const struct command commands[] = {
+ /* name, function */
{ 'u', sunwind },
{ 'G', sgoto },
{ 'q', sexit }
diff --git a/gawk.h b/gawk.h
@@ -3,6 +3,16 @@
#define LEN(X) (sizeof(X) / sizeof(*X))
+/* arbitrary limits */
+#define CHUNK_SIZE 256 /* for slurping data */
+#define MY_ARGV_MAX 12
+#define MY_FILTER_MAX 4
+#define MY_INPUT_MAX 128
+#define MY_LINE_MAX 256
+#define MY_PATH_MAX 128
+#define MY_PIPE_MAX 12
+#define MY_URL_MAX 72
+
/* NOTE: don't change address order, see itemtoaddr() */
enum address { AR_PATH, AR_HOST, AR_PORT, AR_NULL };
enum gphitem { GI_INFO, GI_PATH, GI_HOST, GI_PORT, GI_PLUS, GI_NULL };
diff --git a/main.c b/main.c
@@ -27,9 +27,9 @@
#include <unistd.h>
#include "command.h"
-#include "config.h"
#include "gawk.h"
#include "util.h"
+#include "config.h" /* must be included last */
static char tmpdir[] = "/tmp/gawk-XXXXXXXXXXX";
static int fatal;