#include <stdio.h>
+#include <string.h>
#include <pwd.h>
#include "umpf.h"
+void
+init(void)
+{
+ list_init(&input_code);
+ var_hash = new_var_hash();
+ const_tab = xmalloc(BUFSIZE);
+ cur_const_n = 1;
+ cur_const_s = BUFSIZE;
+ empty = "";
+}
+
int
main(int argc, char** argv)
{
int res;
+ int i;
- //FIXME:
+ if (argc < 2)
+ die("Usage: ./umpf conf_file [default_mailbox]");
+
struct passwd* p;
p = getpwuid(getuid());
- char* default_mbox = cat("/var/mail/", p->pw_name);
- get_default_mailbox(default_mbox);
-
- if (argc < 2)
- die("Usage: ./umpf conf_file");
+ if (argc < 3)
+ default_mailbox = cat("/var/mail/", p->pw_name);
+ else
+ default_mailbox = argv[2];
save_gids();
read_conf(argv[1]);
-
+ init();
// yydebug=1;
res = yyparse ();
if (res)
return res;
-// print_tree(input_tree,0);
+ temp_varcode_start = current_varcode;
+ compile(input_tree, NULL);
- var_hash = new_var_hash();
+ var_tab = xmalloc((max_varcode + 1) * sizeof(char*));
+ for (i = 0; i <= max_varcode; i++) {
+ var_tab[i] = empty;
+ }
- current_headers = make_hlist();
- current_body = get_body();
+ current_headers = make_hlist(0);
// print_headers(current_headers);
-
+ current_body = get_body(0);
save_current_headers(var_hash);
- interp(input_tree, var_hash);
-
-// print_vars(var_hash);
+ set_cur_mail_length_var(curr_email_len, var_hash);
+
+ interp(&input_code, var_hash);
return 0;
}