static int convert_mail_conf_time(const char *name, int *intval, int def_unit) { const char *strval; if ((strval = mail_conf_lookup_eval(name)) == 0) return (0); if (conv_time(strval, intval, def_unit) == 0) msg_fatal("parameter %s: bad time value or unit: %s", name, strval); return (1); }
int timescmd(shinstance *psh, int argc, char **argv) { shtms tms; int u, s, cu, cs; char us[8], ss[8], cus[8], css[8]; nextopt(psh, ""); sh_times(psh, &tms); u = conv_time(tms.tms_utime, us, sizeof(us)); s = conv_time(tms.tms_stime, ss, sizeof(ss)); cu = conv_time(tms.tms_cutime, cus, sizeof(cus)); cs = conv_time(tms.tms_cstime, css, sizeof(css)); outfmt(psh->out1, "%dm%ss %dm%ss\n%dm%ss %dm%ss\n", u, us, s, ss, cu, cus, cs, css); return 0; }
int timescmd(int argc, char **argv) { struct tms tms; int u, s, cu, cs; char us[8], ss[8], cus[8], css[8]; nextopt(""); times(&tms); u = conv_time(tms.tms_utime, us, sizeof(us)); s = conv_time(tms.tms_stime, ss, sizeof(ss)); cu = conv_time(tms.tms_cutime, cus, sizeof(cus)); cs = conv_time(tms.tms_cstime, css, sizeof(css)); outfmt(out1, "%dm%ss %dm%ss\n%dm%ss %dm%ss\n", u, us, s, ss, cu, cus, cs, css); return 0; }
int main(int argc, char **argv) { const char *verify_sender; const char *valid_sender; msg_vstream_init(argv[0], VSTREAM_ERR); /* * Prepare to talk to the address rewriting service. */ mail_conf_read(); vstream_printf("using config files in %s\n", var_config_dir); if (chdir(var_queue_dir) < 0) msg_fatal("chdir %s: %m", var_queue_dir); /* * Parse JCL. */ if (argc != 3) msg_fatal("usage: %s address_verify_sender address_verify_sender_ttl", argv[0]); var_verify_sender = argv[1]; if (conv_time(argv[2], &var_verify_sender_ttl, 's') == 0) msg_fatal("bad time value: %s", argv[2]); verify_time = time((time_t *) 0); /* * Compute the current probe sender address. */ verify_sender = make_verify_sender_addr(); /* * Check two past time slots. */ if (var_verify_sender_ttl > 0) { verify_time -= 2 * var_verify_sender_ttl; vstream_printf("\"%s\" matches prev2: \"%s\"\n", verify_sender, (valid_sender = valid_verify_sender_addr(verify_sender)) != 0 ? valid_sender : "nope"); verify_time += var_verify_sender_ttl; vstream_printf("\"%s\" matches prev1: \"%s\"\n", verify_sender, (valid_sender = valid_verify_sender_addr(verify_sender)) != 0 ? valid_sender : "nope"); verify_time += var_verify_sender_ttl; } /* * Check the current time slot. */ vstream_printf("\"%s\" matches self: \"%s\"\n", verify_sender, (valid_sender = valid_verify_sender_addr(verify_sender)) != 0 ? valid_sender : "nope"); /* * Check two future time slots. */ if (var_verify_sender_ttl > 0) { verify_time += var_verify_sender_ttl; vstream_printf("\"%s\" matches next1: \"%s\"\n", verify_sender, (valid_sender = valid_verify_sender_addr(verify_sender)) != 0 ? valid_sender : "nope"); verify_time += var_verify_sender_ttl; vstream_printf("\"%s\" matches next2: \"%s\"\n", verify_sender, (valid_sender = valid_verify_sender_addr(verify_sender)) != 0 ? valid_sender : "nope"); } vstream_fflush(VSTREAM_OUT); exit(0); }