]> mj.ucw.cz Git - umpf.git/blob - umpf.c
save internal vars
[umpf.git] / umpf.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <pwd.h>
4
5 #include "umpf.h"
6
7 void
8 init(void)
9 {
10         list_init(&input_code);
11         var_hash = new_var_hash();
12         const_tab = xmalloc(BUFSIZE);
13         cur_const_n = 1;
14         cur_const_s = BUFSIZE;
15         empty = "";
16 }
17
18 int
19 main(int argc, char** argv)
20 {
21         int res;
22         int i;
23         
24         if (argc < 2)
25                 die("Usage: ./umpf conf_file [default_mailbox]");
26
27         struct passwd* p;
28         p = getpwuid(getuid());
29         if (argc < 3)
30                  default_mailbox = cat("/var/mail/", p->pw_name);
31         else
32                  default_mailbox = argv[2];
33
34         save_gids();
35         read_conf(argv[1]);
36         init();
37 //      yydebug=1;
38         res = yyparse ();
39
40         if (res)
41                 return res;
42
43         temp_varcode_start = current_varcode;
44         compile(input_tree, NULL);
45
46         var_tab = xmalloc((max_varcode + 1) * sizeof(char*));
47         for (i = 0; i <= max_varcode; i++) {
48                 var_tab[i] = empty;
49         }       
50
51         current_headers = make_hlist(0);
52 //      print_headers(current_headers);
53         current_body = get_body(0);
54         save_current_headers(var_hash);
55         set_cur_mail_length_var(curr_email_len, var_hash);
56
57         interp(&input_code, var_hash);
58
59         return 0;
60 }