int main(int argc, char* argv[]) { int ret; MMSConfig config; const char* test_name = NULL; mms_lib_init(argv[0]); mms_lib_default_config(&config); mms_log_default.name = "test_read_ind"; if (argc > 1 && !strcmp(argv[1], "-v")) { mms_log_default.level = MMS_LOGLEVEL_VERBOSE; memmove(argv + 1, argv + 2, (argc-2)*sizeof(argv[0])); argc--; } else { mms_log_default.level = MMS_LOGLEVEL_INFO; mms_task_notification_log.level = MMS_LOGLEVEL_NONE; mms_log_stdout_timestamp = FALSE; } if (argc == 2 && argv[1][0] != '-') { test_name = argv[1]; } if (argc == 1 || test_name) { char* tmpd = g_mkdtemp(g_strdup("/tmp/test_read_ind_XXXXXX")); MMS_VERBOSE("Temporary directory %s", tmpd); config.root_dir = tmpd; config.idle_secs = 0; config.attic_enabled = TRUE; ret = test_run(&config, test_name); remove(tmpd); g_free(tmpd); } else { printf("Usage: test_read_ind [-v] [TEST]\n"); ret = RET_ERR; } mms_lib_deinit(); return ret; }
int main(int argc, char *argv[]) { Octstr *fname, *s; int cfidx; int msize; List *h = NULL; if (argc < 2) return -1; mms_lib_init(); cfidx = get_and_set_debugs(argc, argv, find_own); if (argv[cfidx] == NULL) fname = octstr_imm("mmsc.conf"); else fname = octstr_create(argv[cfidx]); mms_info(0, "mmssend", NULL, "----------------------------------------"); mms_info(0, "mmssend", NULL, " MMSC Message sender runner version %s starting", MMSC_VERSION); /* Load settings. */ settings = mms_load_mmsc_settings(fname, &proxyrelays,1); if (!settings) panic(0, "No global MMSC configuration, or failed to read conf from <%s>!", octstr_get_cstr(fname)); octstr_destroy(fname); if (from == NULL || to == NULL) { mms_error(0, "mmssend", NULL, "Sender and recipient addresses required!\n"); exit(-1); } else { /* fix up 'to' list */ List *l = gwlist_create(); Octstr *x; while ((x = gwlist_extract_first(to)) != NULL) { octstr_strip_blanks(x); _mms_fixup_address(&x, settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL, settings->strip_prefixes, 1); gwlist_append(l, x); } gwlist_destroy(to, NULL); to = l; } /* fix from address. */ _mms_fixup_address(&from, settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL, settings->strip_prefixes, 1); #if 0 mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir)); #endif if (data) { /* try and detect if we are looking at plain text (mime-encoded) or binary encoded message. */ int ch = octstr_get_char(data, 0); if (isprint(ch)) { MIMEEntity *mime = mime_octstr_to_entity(data); if (mime) { m = mms_frommime(mime); mime_entity_destroy(mime); } } else m = mms_frombinary_ex(data, from ? from : octstr_imm("anon@anon"), octstr_get_cstr(settings->unified_prefix), settings->strip_prefixes); if (m) mms_msgdump(m,1); msize = octstr_len(data); octstr_destroy(data); } else msize = 0; if (!m) panic(0, "No Message supplied, or failed to decode binary data!"); h = http_create_empty_headers(); http_header_add(h, "X-Mbuni-Tool", "mmssend"); http_header_add(h, "X-Mbuni-CalledFrom", "Terminal"); if (binfo) { mms_info(0, "add.info", NULL, "Adding extra headers billing info `X-Mms-Binfo' :"); http_header_add(h, "X-Mms-Binfo", octstr_get_cstr(binfo)); } s = settings->qfs->mms_queue_add(from, to, NULL, NULL, NULL, time(NULL), time(NULL) + settings->default_msgexpiry, m, NULL, NULL, NULL, NULL, NULL, h, dlr, octstr_get_cstr(settings->global_queuedir), "MM3", settings->host_alias); if (savetommbox) mmbox = mms_mmbox_addmsg(octstr_get_cstr(settings->mmbox_rootdir), octstr_get_cstr(from), m, NULL, octstr_imm("Sent")); mms_log("Received", from, to, msize, s, NULL, NULL, "MM3",NULL,NULL); printf("Queued: %s, mmbox=%s\n", octstr_get_cstr(s), mmbox ? octstr_get_cstr(mmbox) : ""); octstr_destroy(s); http_destroy_headers(h); mms_cleanup_mmsc_settings(settings); mms_lib_shutdown(); return 0; }
int main(int argc, char* argv[]) { int ret = RET_ERR; gboolean debug = FALSE; gboolean verbose = FALSE; GError* error = NULL; GOptionContext* options; GOptionEntry entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Enable verbose output", NULL }, { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, "Disable timeout for debugging", NULL }, { NULL } }; options = g_option_context_new("[TEST] - MMS read report test"); g_option_context_add_main_entries(options, entries, NULL); if (g_option_context_parse(options, &argc, &argv, &error)) { MMSConfig config; char* tmpd = g_mkdtemp(g_strdup("/tmp/test_read_report_XXXXXX")); char* msgdir = g_strconcat(tmpd, "/msg", NULL); mms_lib_init(argv[0]); mms_lib_default_config(&config); config.idle_secs = 0; config.root_dir = tmpd; mms_log_default.name = "test_read_report"; if (verbose) { mms_log_default.level = MMS_LOGLEVEL_VERBOSE; } else { mms_log_default.level = MMS_LOGLEVEL_INFO; mms_task_decode_log.level = mms_task_retrieve_log.level = mms_task_notification_log.level = MMS_LOGLEVEL_NONE; mms_log_stdout_timestamp = FALSE; } MMS_VERBOSE("Temporary directory %s", tmpd); if (argc < 2) { ret = test_read_report(&config, NULL, debug); } else { int i; for (i=1, ret = RET_OK; i<argc; i++) { int test_status = test_read_report(&config, argv[i], debug); if (ret == RET_OK && test_status != RET_OK) ret = test_status; } } rmdir(msgdir); rmdir(tmpd); remove(tmpd); g_free(tmpd); g_free(msgdir); mms_lib_deinit(); } else { fprintf(stderr, "%s\n", MMS_ERRMSG(error)); g_error_free(error); ret = RET_ERR; } g_option_context_free(options); return ret; }