/* mail stuff */
OBJ(mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d", obj->data.local_mail.mail_count);
+ print_mails(obj, p, p_max_size);
}
OBJ(new_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.new_mail_count);
+ print_new_mails(obj, p, p_max_size);
}
OBJ(seen_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.seen_mail_count);
+ print_seen_mails(obj, p, p_max_size);
}
OBJ(unseen_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.unseen_mail_count);
+ print_unseen_mails(obj, p, p_max_size);
}
OBJ(flagged_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.flagged_mail_count);
+ print_flagged_mails(obj, p, p_max_size);
}
OBJ(unflagged_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.unflagged_mail_count);
+ print_unflagged_mails(obj, p, p_max_size);
}
OBJ(forwarded_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.forwarded_mail_count);
+ print_forwarded_mails(obj, p, p_max_size);
}
OBJ(unforwarded_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.unforwarded_mail_count);
+ print_unforwarded_mails(obj, p, p_max_size);
}
OBJ(replied_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.replied_mail_count);
+ print_replied_mails(obj, p, p_max_size);
}
OBJ(unreplied_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.unreplied_mail_count);
+ print_unreplied_mails(obj, p, p_max_size);
}
OBJ(draft_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.draft_mail_count);
+ print_draft_mails(obj, p, p_max_size);
}
OBJ(trashed_mails) {
- update_mail_count(&obj->data.local_mail);
- snprintf(p, p_max_size, "%d",
- obj->data.local_mail.trashed_mail_count);
+ print_trashed_mails(obj, p, p_max_size);
}
OBJ(mboxscan) {
mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output,
END OBJ(kernel, 0)
END OBJ(machine, 0)
END OBJ(mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- /* Kapil: Changed from MAIL_FILE to
- current_mail_spool since the latter
- is a copy of the former if undefined
- but the latter should take precedence
- if defined */
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(new_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(seen_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(unseen_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(flagged_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(unflagged_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(forwarded_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(unforwarded_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(replied_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(unreplied_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(draft_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(trashed_mails, 0)
- float n1;
- char mbox[256], dst[256];
-
- if (!arg) {
- n1 = 9.5;
- strncpy(mbox, current_mail_spool, sizeof(mbox));
- } else {
- if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
- n1 = 9.5;
- strncpy(mbox, arg, sizeof(mbox));
- }
- }
-
- variable_substitute(mbox, dst, sizeof(dst));
- obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
- obj->data.local_mail.interval = n1;
+ parse_local_mail_args(obj, arg);
END OBJ(mboxscan, 0)
obj->data.mboxscan.args = (char *) malloc(text_buffer_size);
obj->data.mboxscan.output = (char *) malloc(text_buffer_size);
}
}
+void parse_local_mail_args(struct text_object *obj, const char *arg)
+{
+ float n1;
+ char mbox[256], dst[256];
+
+ if (!arg) {
+ n1 = 9.5;
+ /* Kapil: Changed from MAIL_FILE to
+ current_mail_spool since the latter
+ is a copy of the former if undefined
+ but the latter should take precedence
+ if defined */
+ strncpy(mbox, current_mail_spool, sizeof(mbox));
+ } else {
+ if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
+ n1 = 9.5;
+ strncpy(mbox, arg, sizeof(mbox));
+ }
+ }
+
+ variable_substitute(mbox, dst, sizeof(dst));
+ obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
+ obj->data.local_mail.interval = n1;
+}
+
+#define PRINT_MAILS_GENERATOR(x) \
+void print_##x##mails(struct text_object *obj, char *p, int p_max_size) \
+{ \
+ update_mail_count(&obj->data.local_mail); \
+ snprintf(p, p_max_size, "%d", obj->data.local_mail.x##mail_count); \
+}
+
+PRINT_MAILS_GENERATOR()
+PRINT_MAILS_GENERATOR(new_)
+PRINT_MAILS_GENERATOR(seen_)
+PRINT_MAILS_GENERATOR(unseen_)
+PRINT_MAILS_GENERATOR(flagged_)
+PRINT_MAILS_GENERATOR(unflagged_)
+PRINT_MAILS_GENERATOR(forwarded_)
+PRINT_MAILS_GENERATOR(unforwarded_)
+PRINT_MAILS_GENERATOR(replied_)
+PRINT_MAILS_GENERATOR(unreplied_)
+PRINT_MAILS_GENERATOR(draft_)
+PRINT_MAILS_GENERATOR(trashed_)
+
#define MAXDATASIZE 1000
struct mail_s *parse_mail_args(char type, const char *arg)