/* */ #include "sm/generic.h" SM_IDSTR(id, "@(#)$Id: t-da-id.c,v 1.1 2006/12/11 01:09:34 ca Exp $") #include "sm/io.h" #include "sm/mta.h" #include "sm/test.h" #include /* ** TESTIDX -- test extraction of DA index from DA ta id ** ** Parameters: ** debug -- debug level ** ** Returns: ** usual sm_error code. */ static int testidx(int debug) { sessta_id_T da_id; uint i, j, id_count, c_id; int r; id_count = 1234; j = 4567; for (i = 0; i < 256; i++) { id_count++; sm_snprintf(da_id, SMTP_STID_SIZE, SMTPC_STID_FORMAT, i, id_count, j); r = SMTPC_GETCID(da_id, c_id); SM_TEST(r == 1); SM_TEST(c_id == i); if (c_id != i) { sm_io_fprintf(smioerr, "idx=%u/%X, j=%u/%X, da_id=%s\n", c_id, c_id, i, i, da_id); return -1; } } return 0; } int main(int argc, char *argv[]) { int c, debug; sm_ret_T ret; debug = 0; while ((c = getopt(argc, argv, "d:s:")) != -1) { switch (c) { case 'd': debug = strtol(optarg, NULL, 0); break; #if 0 default: usage(argv[0]); return(1); #endif } } sm_test_begin(argc, argv, "test smtpc id"); ret = testidx(debug); return sm_test_end(); }