⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xml2wbxml.c

📁 如何搭建wap push gateway
💻 C
📖 第 1 页 / 共 3 页
字号:
    info(0, "Define the client application that will handle the push. Any,");     info(0, "ua, mms, nil and scrap accepted, default ua.");    info(0, "-n");    info(0, "if set, use numeric appid values instead of string ones. For");    info(0, "instance, '4' instead of 'mms.ua'. Default is off.");    info(0, "-s string");    info(0, "supply a message header as a plain string. For instance");     info(0, "-s x-wap-application-id:mms.ua equals -a ua. Default is");    info(0, "x-wap-application-id:mms.ua.");    info(0, "-I string");    info(0, "supply an initiator header as a plain string. For instance");     info(0, "-I x-wap-application-id:http://foo.bar equals -I http://foo.bar");    info(0, "-S string");    info(0, "supply an additional part header (for push content) as a string.");     info(0, "For instance, -S Content-Language: en. Default no additional part");    info(0, "headers.");    info(0, "-b");    info(0, "If true, send username/password in headers. Default false");    info(0, "-v number");    info(0, "    Set log level for stderr logging. Default 0 (debug)");    info(0, "-q");    info(0, "    Do not print debugging information");    info(0, "Default: print it");    info(0, "-r number");    info(0, "    Make `number' requests. Default one request");    info(0, "-i seconds");    info(0, "    Wait 'seconds' seconds between pushes. Default: do not wait");    info(0, "-e transfer encoding");    info(0, "    use transfer encoding to send push contents.");    info(0, "    Currently supported is base64.");    info(0, "-k connection header");    info(0, "Use the connection header. Keep-alive and close accepted,");    info(0, "default close");    info(0, "-H");    info(0, "Use hardcoded MIME message, containing a pap control document.");    info(0, "In addition, use hardcoded username/password in headers (if ");    info(0, "flag -b is set, too");    info(0, "Default: read components from files");    info(0, "-t");    info(0, "number of threads, maximum 1024, default 1");    info(0, "-B");    info(0, "accept binary push content. Default: off.");    info(0, "Binary content consist of hex numbers. In addition, crs, lfs and");    info(0, "spaces are accepted, and ignored.");    info(0, "-d value");    info(0, "set delimiter to be used. Accepted values crlf and lf. Default crlf.");    info(0, "-E");    info(0, "If set, add a hardcoded epilogue (epilogue is to be discarded anyway).");    info(0, "Default off.");    info(0, "-p");    info(0, "If set, add hardcoded preamble. Default is off.");    info(0, "-m value");    info(0, "If set, add push header X-Kannel-DLR-Mask: value");    info(0, "Default off.");    info(0, "-u value");    info(0, "If set, add push header X-Kannel-DLR-Url: value");    info(0, "Default off.");}static void push_thread(void *arg){    HTTPCaller *caller;    long succeeded, failed, in_queue;    unsigned long i;    caller = arg;    succeeded = 0;    failed = 0;       in_queue = 0;    i = 0;    for (;;) {        while (in_queue < MAX_IN_QUEUE) {	        i = counter_increase(counter);            if (i >= max_pushes)	            goto receive_rest;            start_push(caller, i);            if (wait_seconds > 0)                gwthread_sleep(wait_seconds);            ++in_queue;        }        while (in_queue >= MAX_IN_QUEUE) {	        if (receive_push_reply(caller) == -1)	            ++failed;            else	            ++succeeded;            --in_queue;        }    }receive_rest:    while (in_queue > 0) {        if (receive_push_reply(caller) == -1)	        ++failed;        else	        ++succeeded;        --in_queue;    }    http_caller_destroy(caller);    info(0, "TEST_PPG: In thread %ld %ld succeeded, %ld failed",          (long) gwthread_self(), succeeded, failed);}int main(int argc, char **argv){    int opt,        num_threads;    time_t start,           end;    double run_time;    long threads[MAX_THREADS];    long i;    Octstr *fos;    gwlib_init();    num_threads = 1;    while ((opt = getopt(argc, argv, "HhBbnEpv:qr:t:c:a:i:e:k:d:s:S:I:m:u:")) != EOF) {        switch(opt) {	    case 'v':	        log_set_output_level(atoi(optarg));	    break;	    case 'q': 	        verbose = 0;	    break;  	    case 'r':	        max_pushes = atoi(optarg);      	    break;             	    case 'i':                 wait_seconds = atof(optarg);	    break;            case 't': 	        num_threads = atoi(optarg);                if (num_threads > MAX_THREADS)		    num_threads = MAX_THREADS;	    break;	    case 'H': 	        use_hardcoded = 1;	    break;	    case 'c':	        content_flag = octstr_create(optarg);            if (octstr_compare(content_flag, octstr_imm("wml")) != 0 &&                     octstr_compare(content_flag, octstr_imm("si")) != 0 &&                    octstr_compare(content_flag, octstr_imm("sl")) != 0 &&                    octstr_compare(content_flag, octstr_imm("nil")) != 0 &&                    octstr_compare(content_flag, octstr_imm("mms")) != 0 &&                    octstr_compare(content_flag, octstr_imm("scrap")) != 0 &&                    octstr_compare(content_flag, octstr_imm("multipart")) != 0) {		        octstr_destroy(content_flag);		        error(0, "TEST_PPG: Content type not known");		        help();                         exit(1);            }	    break;	    case 'a':	        appid_flag = octstr_create(optarg);                if (octstr_compare(appid_flag, octstr_imm("any")) != 0 &&                         octstr_compare(appid_flag, octstr_imm("ua")) != 0 &&                        octstr_compare(appid_flag, octstr_imm("mms")) != 0 &&                        octstr_compare(appid_flag, octstr_imm("nil")) != 0 &&                        octstr_compare(appid_flag, octstr_imm("scrap")) != 0) {		octstr_destroy(appid_flag);		error(0, "TEST_PPG: Push application id not known");		help();                exit(1);           }	    break;            case 'n':                use_numeric = 1;            break;            case 's':                appid_string = octstr_create(optarg);                use_string = 1;            break;            case 'S':                content_header = octstr_create(optarg);                use_content_header = 1;            break;	    case 'e':		content_transfer_encoding = octstr_create(optarg);                if (octstr_compare(content_transfer_encoding, octstr_imm("base64")) != 0) {	            octstr_destroy(content_transfer_encoding);		    error(0, "TEST_PPG: unknown content transfer"                       " encoding \"%s\"", octstr_get_cstr(content_transfer_encoding));		    help();                    exit(1);		}	    break;	    case 'k':	        connection = octstr_create(optarg);                if (octstr_compare(connection, octstr_imm("close")) != 0 &&                         octstr_compare(connection, octstr_imm("keep-alive")) != 0) {	            octstr_destroy(connection);		    error(0, "TEST_PPG: Connection-header unacceptable");		    help();                    exit(1);                }	    break;	    case 'h':	        help();            exit(1);	    case 'b':	        use_headers = 1;	    break;            case 'B':                accept_binary = 1;            break;            case 'd':                delimiter = octstr_create(optarg);                if (octstr_compare(delimiter, octstr_imm("crlf")) != 0 &&                        octstr_compare(delimiter, octstr_imm("lf")) != 0) {                    octstr_destroy(delimiter);                    error(0, "illegal d value");                    help();                    exit(1);                }            break;            case 'E':                add_epilogue = 1;            break;            case 'p':                add_preamble = 1;            break;            case 'I':                initiator_uri = octstr_create(optarg);		break;            case 'm':                use_dlr_mask = 1;                dlr_mask = octstr_create(optarg);            break;            case 'u':                use_dlr_url = 1;                dlr_url = octstr_create(optarg);            break;	case '?':	    default:	        error(0, "TEST_PPG: Invalid option %c", opt);            help();            error(0, "Stopping");            exit(1);        }    }    if (optind == argc) {        help();        exit(1);    }        push_data = argv + optind;    num_urls = argc - optind;    if (content_flag == NULL)        content_flag = octstr_imm("si");    if (appid_flag == NULL)        appid_flag = octstr_imm("ua");    if (appid_string == NULL)        appid_string = octstr_imm("x-wap-application-id: wml.ua");    if (content_header == NULL)        use_content_header = 0;    if (dlr_mask == NULL)        use_dlr_mask = 0;    if (dlr_url == NULL)        use_dlr_url = 0;    if (delimiter == NULL)        delimiter = octstr_imm("crlf");    if (use_hardcoded) {        username = octstr_imm("troo");        password = octstr_imm("far");    }    if (push_data[0] == NULL) {        error(0, "No ppg address or config file, stopping");        exit(1);    }               use_config = 0;    if (!use_hardcoded) {        if (push_data[1] == NULL) {            info(0, "a configuration file input assumed");            read_test_ppg_config(fos = octstr_format("%s", push_data[0]));            octstr_destroy(fos);            use_config = 1;        }    }    if (!use_config)        push_url = octstr_format("%s", push_data[0]);    if (!use_hardcoded && !use_config && push_data[1] != NULL) {        if (push_data[2] == NULL) {	        error(0, "no pap control document, stopping");            exit(1);        } else {           info(0, "an input without a configuration file assumed");           content_file = octstr_create(push_data[1]);           pap_file = octstr_create(push_data[2]);           debug("test.ppg", 0, "using %s as a content file", push_data[1]);           debug("test.ppg", 0, "using %s as a control file", push_data[2]);        }    }    boundary = "asdlfkjiurwghasf";    counter = counter_create();    time(&start);    if (num_threads == 0)        push_thread(http_caller_create());    else {        for (i = 0; i < num_threads; ++i)	        threads[i] = gwthread_create(push_thread, http_caller_create());	    for (i = 0; i < num_threads; ++i)	        gwthread_join(threads[i]);    }    time(&end);    run_time = difftime(end, start);    info(0, "TEST_PPG: %ld requests in %f seconds, %f requests per second",         max_pushes, run_time, max_pushes / run_time);    octstr_destroy(content_flag);    octstr_destroy(appid_flag);    octstr_destroy(content_header);    octstr_destroy(content_file);    octstr_destroy(pap_file);    octstr_destroy(ssl_client_certkey_file);    octstr_destroy(username);    octstr_destroy(password);    octstr_destroy(push_url);    octstr_destroy(connection);    octstr_destroy(delimiter);    octstr_destroy(dlr_mask);    octstr_destroy(dlr_url);    counter_destroy(counter);    gwlib_shutdown();    exit(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -