Rule*** Rulesets = NULL;
size_t NumRulesets = 0;
-#define FETCH_RULES
-#include "config.h"
-
static Rule*** BuiltinRules = (Rule**[]){
(Rule*[]){ /* Match URLS and open them with the browser */
&(Rule){ ISSET, "BROWSER", NULL },
&(Rule){ LAUNCH, "picktag fetch tags \"$data\"", NULL },
&(Rule){ COMPLETE, NULL, NULL }
},
-// (Rule*[]){ /* Look up .c or .h files in Code/ */
-// &(Rule){ MATCHES, "data", "\\.[ch]$" },
-// &(Rule){ ISDIR, "Code", NULL },
-// &(Rule){ EXEC, "[[ \"$(find Code -type f -name \"*$data\")\" ]]", NULL },
-// &(Rule){ LAUNCH, "find Code -type f -name \"*$data\" | xargs -r edit", NULL },
-// &(Rule){ COMPLETE, NULL, NULL }
-// },
(Rule*[]){ /* Open man pages in a tide window */
&(Rule){ ISSET, "BROWSER", NULL },
&(Rule){ MATCHES, "data", "(.+)\\(([0-9]+)\\)" },
/******************************************************************************/
-bool complete(void)
-{
- exit(0);
- return false;
-}
-
-bool matches(char* var, char* patt)
+static bool matches(char* var, char* patt)
{
bool ret = false;
regex_t regex = {0};
return ret;
}
-bool var_is(char* var, char* val)
+static bool var_is(char* var, char* val)
{
return (strcmp(getvar(var), eval(val)) == 0);
}
-bool var_isset(char* var)
+static bool var_isset(char* var)
{
return (getenv(var) != NULL);
}
-bool var_isdir(char* var)
+static bool var_isdir(char* var)
{
bool ret = false;
struct stat st = {0};
return ret;
}
-bool var_isfile(char* var)
+static bool var_isfile(char* var)
{
bool ret = false;
struct stat st = {0};
return ret;
}
-bool var_set(char* var, char* val)
+static bool var_set(char* var, char* val)
{
return (setenv(var, eval(val), 1) == 0);
}
-bool var_unset(char* var)
+static bool var_unset(char* var)
{
return (unsetenv(var) == 0);
}
-void runcmd(char* cmd)
+static void runcmd(char* cmd)
{
char* shellcmd[] = { getvar("SHELL"), "-c", cmd, NULL };
if (!shellcmd[0]) shellcmd[0] = "/bin/sh";
_exit(execvp(shellcmd[0], shellcmd));
}
-bool exec(char* cmd)
+static bool exec(char* cmd)
{
bool ret = false;
int pid, status;
return ret;
}
-bool launch(char* cmd)
+static bool launch(char* cmd)
{
bool ret = false;
int pid = fork();
return ret;
}
-bool apply_rule(Rule* rule)
+static bool apply_rule(Rule* rule)
{
bool ret = false;
switch (rule->type)
/******************************************************************************/
-void usage(char* pname)
+static void usage(char* pname)
{
fprintf(stderr, "Usage: %s [ITEM]\n", pname);
exit(1);
}
-char* type2str(int type)
+static char* type2str(int type)
{
char* ret = "UNKNOWN";
switch (type)
return ret;
}
-char* nextline(char** raw)
+static char* nextline(char** raw)
{
char* line = NULL;
char* eol = strchr(*raw, '\n');
return line;
}
-char* nextfield(char** raw)
+static char* nextfield(char** raw)
{
char* field = *raw;
/* skip whitespace */
return (field && *field ? field : NULL);
}
-void parse_args1(int type, Rule* rule, char* args)
+static void parse_args1(int type, Rule* rule, char* args)
{
rule->type = type;
rule->arg1 = args;
}
}
-void parse_args2(int type, Rule* rule, char* args)
+static void parse_args2(int type, Rule* rule, char* args)
{
rule->type = type;
rule->arg1 = nextfield(&args);
}
}
-Rule* parse_rule(char* act, char* args)
+static Rule* parse_rule(char* act, char* args)
{
Rule* rule = calloc(1, sizeof(Rule));
if (!strcmp(act, "is"))
return rule;
}
-void add_ruleset(Rule** rules, size_t nrules, Rule* rule)
+static void add_ruleset(Rule** rules, size_t nrules, Rule* rule)
{
if (rules)
{
Rulesets[NumRulesets-1] = rules;
}
-void parse_rules(char* path)
+static void parse_rules(char* path)
{
char* line = NULL;
char* raw = readfile(path);
{
add_ruleset(rules, nrules, calloc(1, sizeof(Rule)));
}
-// add_ruleset(NULL, 0, NULL);
}
- telem_send("DONE\n", path);
}
-void check_ruleset(Rule** rule)
+static void check_ruleset(Rule** rule)
{
for (; (*rule)->type != COMPLETE; rule++)
{
/* load rules from files */
parse_rules("fetch.rules");
parse_rules(homedir_path("config/tide/fetch.rules"));
- add_ruleset(NULL, 0, NULL);
+ add_ruleset(NULL, 0, NULL); // terminate the parsed set of rules
telem_send("FETCH(%s)\n", argv[1]);
setenv("data", argv[1], 1);