var_tab[var] = xstrdup(value);
}
+void
+set_cur_mail_length_var(int len, struct list* hash)
+{
+ char* buf;
+ struct variable* pv;
+
+ pv = get_var_struct(INT_VAR_MAIL_LEN, VAR_INTERN, hash);
+
+ if (! pv) /* user is not interested */
+ return;
+
+ buf = xmalloc(INT_TO_STRING_LEN);
+ sscanf(buf,"%d", &len);
+ set_var(pv->varcode, buf);
+ free_string(buf);
+}
+
+static void
+set_exit_code_var(int code, struct list* hash)
+{
+ char* buf;
+ struct variable* pv;
+
+ pv = get_var_struct(INT_VAR_LAST_EXIT, VAR_INTERN, hash);
+
+ if (! pv) /* user is not interested */
+ return;
+
+ buf = xmalloc(INT_TO_STRING_LEN);
+ sscanf(buf,"%d", &code);
+ set_var(pv->varcode, buf);
+ free_string(buf);
+}
+
+static void
+set_last_pipe_var(char* buf, struct list* hash)
+{
+ struct variable* pv;
+
+ pv = get_var_struct(INT_VAR_LAST_EXIT, VAR_INTERN, hash);
+
+ if (! pv) /* user is not interested */
+ return;
+ set_var(pv->varcode, buf);
+}
+
static char*
get_var(int var)
{
destroy_body(current_body);
current_headers = make_hlist(f->fd);
current_body = get_body(f->fd);
-// set_cur_mail_length_var(current_email_len);
-// set_exit_code_var(f->exit);
+ set_cur_mail_length_var(curr_email_len, hash);
+ set_exit_code_var(f->exit, hash);
unlink(f->name);
free(f);
buf = xmalloc(pos);
read(f->fd, buf, pos);
- //set_last_pipe_var(buf);
+ set_exit_code_var(f->exit, hash);
+ set_last_pipe_var(buf, hash);
free(buf);
unlink(f->name);
#include "lists.h"
+/* definitions of internal variables */
+#define INT_VAR_MAIL_LEN "MAIL_LEN"
+#define INT_VAR_LAST_EXIT "LAST_EXIT_CODE"
+#define INT_VAR_PIPE_RES "LAST_OUTPUT"
+
/* cond.h */
int yylex (void);
void yyerror (char const *);
void interp(struct list* ins, struct list* hash);
void free_string(char* c);
void __attribute__ ((noreturn)) bye(int code, char* msg, ...);
+void set_cur_mail_length_var(int len, struct list* hash);
/* ham.c */
char* default_mailbox;