ConfigHandler::ConfigHandler(User *user, const std::string &from, const std::string &id) : m_from(from), m_user(user) { setRequestType(CALLER_ADHOC); std::string bare(JID(from).bare()); IQ _response(IQ::Result, from, id); Tag *response = _response.tag(); response->addAttribute("from", Transport::instance()->jid()); AdhocTag *adhocTag = new AdhocTag(Transport::instance()->getId(), "transport_irc_config", "executing"); adhocTag->setAction("complete"); adhocTag->setTitle("IRC Nickserv password configuration"); adhocTag->setInstructions("Choose the server you want to change password for."); std::map <std::string, std::string> values; std::map<std::string, UserRow> users = Transport::instance()->sql()->getUsersByJid(bare); for (std::map<std::string, UserRow>::iterator it = users.begin(); it != users.end(); it++) { std::string server = (*it).second.jid.substr(bare.size()); values[server] = stringOf((*it).second.id); m_userId.push_back(stringOf((*it).second.id)); } adhocTag->addListSingle("IRC server", "irc_server", values); adhocTag->addTextPrivate("New NickServ password", "password"); response->addChild(adhocTag); Transport::instance()->send(response); }
int main P2C(int, ac, string *, av) { #ifdef __EMX__ _wildcard (&ac, &av); _response (&ac, &av); #endif extern void mainbody P1H(void); argc = ac; argv = av; mainbody (); return EXIT_SUCCESS; }
static int process_arglist(int argc, char **argv) { int option; int count = 0; fpin = stdin; fpo = stdout; dbgout = stderr; #ifdef __EMX__ _response (&argc, &argv); /* expand response files (@filename) */ _wildcard (&argc, &argv); /* expand wildcards (*.*) */ #endif /* default: no token length checking */ max_token_len = 0; while (1) { int option_index = 0; int this_option_optind = optind ? optind : 1; const char *name; option = getopt_long_chk(argc, argv, OPTIONS, longopts_bogoutil, &option_index); if (option == -1) break; name = (option_index == 0) ? argv[this_option_optind] : longopts_bogoutil[option_index].name; count += process_arg(option, name, optarg, PR_NONE, PASS_1_CLI); } if (max_token_len != 0 && max_multi_token_len == 0) { /* token length checking ... */ if (multi_token_count == 1) max_multi_token_len = max_token_len + MAX_PREFIX_LEN; else max_multi_token_len = max_token_len = (max_token_len+1) * multi_token_count + MAX_PREFIX_LEN; } if (count != 1) { usage(stderr); fprintf(stderr, "%s: Exactly one of the file or directory commands must be present.\n", progname); exit(EX_ERROR); } return count; }
static int process_arglist(int argc, char **argv) { int count = 1; bulk_mode = B_CMDLINE; #ifdef __EMX__ _response (&argc, &argv); /* expand response files (@filename) */ _wildcard (&argc, &argv); /* expand wildcards (*.*) */ #endif #define OPTIONS ":-:c:Cd:DeEM:n:qr:s:tT:vVx:" while (1) { int option; int option_index = 0; const char *val; option = getopt_long_chk(argc, argv, OPTIONS, longopts_bogotune, &option_index); if (option == -1) break; val = optarg; process_arg(option, NULL, val, PR_NONE, PASS_1_CLI); } if (ds_flag == DS_NONE) /* default is "wordlist on disk" */ ds_flag = DS_DSK; if (ds_flag == DS_ERR) { fprintf(stderr, "Only one '-d dir' or '-D' option is allowed.\n"); exit(EX_ERROR); } if (bogolex_file == NULL && (spam_files->count == 0 || ham_files->count == 0)) { fprintf(stderr, "Bogotune needs both non-spam and spam message sets for its parameter testing.\n"); exit(EX_ERROR); } if (!suppress_config_file) process_config_files(false, longopts_bogotune); return count; }
main (int ac, string *av) #endif { # ifdef __EMX__ _wildcard(&ac, &av); _response(&ac, &av); # endif # ifdef WIN32 # ifdef _MSC_VER _set_invalid_parameter_handler(myInvalidParameterHandler); # endif av[0] = kpse_program_basename (av[0]); _setmaxstdio(2048); /* We choose to crash for fatal errors: SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); */ setmode(fileno(stdin), _O_BINARY); # endif lua_initialize(ac, av); # ifdef WIN32 if (ac > 1) { char *pp; if ((strlen(av[ac-1]) > 2) && isalpha(av[ac-1][0]) && (av[ac-1][1] == ':') && (av[ac-1][2] == '\\')) { for (pp=av[ac-1]+2; *pp; pp++) { if (IS_KANJI(pp)) { pp++; continue; } if (*pp == '\\') *pp = '/'; } } } # endif /* Call the real main program. */ main_body(); return EXIT_SUCCESS; }
Tag * AdhocTag::generateResponse(const std::string &action) { IQ _response(IQ::Result, m_from, m_id); _response.setFrom(Transport::instance()->jid()); Tag *response = _response.tag(); if (action != "") { response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), action) ); return response; } if (hasAttribute("action", "cancel")) response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), "canceled") ); else response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), "completed") ); return response; }
/* The entry point for all the programs except TeX and Metafont, which have more to do. We just have to set up the command line. web2c transforms Pascal's main block into a procedure `main_body'. */ int main (int ac, string* av) { #ifdef __EMX__ _wildcard (&ac, &av); _response (&ac, &av); #endif #ifdef WIN32 _setmaxstdio(2048); #endif argc = ac; argv = av; mainbody (); return EXIT_SUCCESS; }
virtual void completed(const ::Ice::AsyncResultPtr& __result) const { ::zerocexample::MessageIcePrx __proxy = ::zerocexample::MessageIcePrx::uncheckedCast(__result->getProxy()); ::std::string __ret; try { __ret = __proxy->end_getContent(__result); } catch(const ::Ice::Exception& ex) { Cpp11FnCallbackNC::exception(__result, ex); return; } if(_response != nullptr) { _response(__ret); } }
/** * Simple MySQL test. Connect to MySQL and read Server Handshake Packet. * If we can read the packet and it is not an error packet we assume the * server is up and working. * * @see http://dev.mysql.com/doc/internals/en/client-server-protocol.html */ int check_mysql(Socket_T socket) { ASSERT(socket); mysql_packet_t pkt; if (_response(socket, &pkt)) { short protocol_version = pkt.msg[0]; unsigned char *server_version = pkt.msg + 1; // Protocol is 10 for MySQL 5.x if ((protocol_version > 12) || (protocol_version < 9)) socket_setError(socket, "Invalid protocol version %d", protocol_version); // Handshake packet should have sequence id 0 else if (pkt.seq != 0) socket_setError(socket, "Invalid packet sequence id %d", pkt.seq); else { DEBUG("MySQL: Protocol: %d, Server Version: %s\n", protocol_version, server_version); return TRUE; } } return FALSE; }
static void process_arglist(int argc, char **argv) { int option; fpin = stdin; dbgout = stderr; #ifdef __EMX__ _response (&argc, &argv); /* expand response files (@filename) */ _wildcard (&argc, &argv); /* expand wildcards (*.*) */ #endif while (1) { int option_index = 0; int this_option_optind = optind ? optind : 1; const char *name; #ifdef __EMX__ if (optind == 1) optind = 0; #endif option = getopt_long_chk(argc, argv, OPTIONS, longopts_bogolexer, &option_index); if (option == -1) break; name = (option_index == 0) ? argv[this_option_optind] : longopts_bogolexer[option_index].name; process_arg(option, name, optarg, PR_COMMAND, PASS_1_CLI); } if (optind < argc) { fprintf(stderr, "Extra arguments given, first: %s. Aborting.\n", argv[optind]); exit(EX_ERROR); } }
int main(int argc, char *argv[]) { int r = EXIT_OK; int i, ii; int m; time_t t_total; #if defined(__EMX__) _response(&argc,&argv); _wildcard(&argc,&argv); #endif if (argv[0]) argv0 = argv[0]; align_mem(); (void) my_clock(); printf("\nLZO real-time data compression library (v%s, %s).\n", LZO_VERSION_STRING, LZO_VERSION_DATE); printf("Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer\n\n"); if (lzo_init() != LZO_E_OK) { printf("lzo_init() failed !!!\n"); exit(EXIT_LZO_INIT); } if (argc < 2) usage(argv0,-1,0); i = get_options(argc,argv); if (methods_n == 0) add_method(default_method); if (methods_n > 1 && opt_read_from_stdin) { printf("%s: cannot use multiple methods and '-@'\n", argv0); exit(EXIT_USAGE); } if (opt_block_size < 16) opt_block_size = 16; if (opt_block_size > MAX_BLOCK_SIZE) opt_block_size = MAX_BLOCK_SIZE; dict_len = 0; #ifndef USE_DICT opt_dict = 0; #else if (opt_dict) { opt_optimize_compressed_data = 0; if (opt_dictionary_file) { read_dict(opt_dictionary_file); if (opt_max_dict_len > 0 && dict_len > (lzo_uint) opt_max_dict_len) dict_len = opt_max_dict_len; if (dict_len > 0) printf("Using dictionary '%s', %ld bytes, ID 0x%08lx.\n", opt_dictionary_file, (long) dict_len, (long) dict_adler32); } if (dict_len <= 0) { init_default_dict(); if (opt_max_dict_len > 0 && dict_len > (lzo_uint) opt_max_dict_len) dict_len = opt_max_dict_len; printf("Using default dictionary, %ld bytes, ID 0x%08lx.\n", (long) dict_len, (long) dict_adler32); } if (opt_max_dict_len == -1) printf("Dictionary size will be adjusted to file size.\n"); else if (opt_max_dict_len <= 0) printf("Dictionary size will be adjusted to file size.\n"); } #endif t_total = time(NULL); (void) my_clock(); ii = i; for (m = 0; m < methods_n && r == EXIT_OK; m++) { int method = methods[m]; i = ii; if (i >= argc && opt_calgary_corpus_path == NULL && !opt_read_from_stdin) usage(argv0,-1,0); if (m == 0 && opt_verbose >= 1) printf("%lu block-size\n\n", (long) opt_block_size); if (!info(method,NULL)) info(method,stdout); #ifdef USE_CORPUS if (opt_calgary_corpus_path != NULL) r = do_corpus(calgary_corpus,method,opt_calgary_corpus_path, opt_c_loops,opt_d_loops); else #endif { for ( ; i < argc && r == EXIT_OK; i++) { r = do_file(method,argv[i],opt_c_loops,opt_d_loops,NULL,NULL); if (r == EXIT_FILE) /* ignore file errors */ r = EXIT_OK; } if (opt_read_from_stdin) { char buf[512], *p; while (r == EXIT_OK && fgets(buf,sizeof(buf)-1,stdin) != NULL) { buf[sizeof(buf)-1] = 0; p = buf + strlen(buf); while (p > buf && is_space(p[-1])) *--p = 0; p = buf; while (*p && is_space(*p)) p++; if (*p) r = do_file(method,p,opt_c_loops,opt_d_loops,NULL,NULL); if (r == EXIT_FILE) /* ignore file errors */ r = EXIT_OK; } opt_read_from_stdin = 0; } } } t_total = time(NULL) - t_total; if (opt_totals) print_totals(); if (opt_execution_time || (methods_n > 1 && opt_verbose >= 1)) printf("\n%s: execution time: %lu seconds\n", argv0, (long) t_total); if (r != EXIT_OK) printf("\n%s: exit code: %d\n", argv0, r); return r; }
int main(int argc, char *argv[]) { int r; int lazy; const int max_try_lazy = 5; const lzo_uint big = 65536L; /* can result in very slow compression */ const lzo_uint32 flags = 0x1; lzo_byte *in; lzo_uint in_len; lzo_byte *out; lzo_uint out_len = 0; lzo_byte *wrkmem; lzo_uint wrk_len; lzo_uint best_len; int best_compress = -1; int best_lazy = -1; lzo_uint orig_len; lzo_uint32 uncompressed_checksum; lzo_uint32 compressed_checksum; FILE *f; const char *progname = NULL; const char *in_name = NULL; const char *out_name = NULL; long l; #if defined(__EMX__) _response(&argc,&argv); _wildcard(&argc,&argv); #endif printf("\nLZO real-time data compression library (v%s, %s).\n", lzo_version_string(), lzo_version_date()); printf("Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer\n\n"); progname = argv[0]; if (argc < 2 || argc > 3) { printf("usage: %s file [output-file]\n", progname); exit(1); } in_name = argv[1]; out_name = (argc > 2) ? argv[2] : NULL; /* * Step 1: initialize the LZO library */ if (lzo_init() != LZO_E_OK) { printf("lzo_init() failed !!!\n"); exit(1); } /* * Step 2: allocate the work-memory */ wrk_len = 1; #ifdef USE_LZO1X if (wrk_len < LZO1X_999_MEM_COMPRESS) wrk_len = LZO1X_999_MEM_COMPRESS; #endif #ifdef USE_LZO1Y if (wrk_len < LZO1Y_999_MEM_COMPRESS) wrk_len = LZO1Y_999_MEM_COMPRESS; #endif wrkmem = (lzo_bytep) lzo_malloc(wrk_len); if (wrkmem == NULL) { printf("%s: out of memory\n", progname); exit(1); } /* * Step 3: open the input file */ f = fopen(in_name,"rb"); if (f == NULL) { printf("%s: cannot open file %s\n", progname, in_name); exit(1); } fseek(f,0,SEEK_END); l = ftell(f); fseek(f,0,SEEK_SET); if (l <= 0) { printf("%s: %s: empty file\n", progname, in_name); fclose(f); exit(1); } in_len = (lzo_uint) l; best_len = in_len; /* * Step 4: allocate compression buffers and read the file */ in = (lzo_bytep) lzo_malloc(in_len); out = (lzo_bytep) lzo_malloc(in_len + in_len / 64 + 16 + 3); if (in == NULL || out == NULL) { printf("%s: out of memory\n", progname); exit(1); } in_len = lzo_fread(f,in,in_len); printf("%s: loaded file %s: %ld bytes\n", progname, in_name, (long) in_len); fclose(f); /* * Step 5: compute a checksum of the uncompressed data */ uncompressed_checksum = lzo_adler32(0,NULL,0); uncompressed_checksum = lzo_adler32(uncompressed_checksum,in,in_len); /* * Step 6a: compress from `in' to `out' with LZO1X-999 */ #ifdef USE_LZO1X for (lazy = 0; lazy <= max_try_lazy; lazy++) { r = lzo1x_999_compress_internal(in,in_len,out,&out_len,wrkmem, NULL, 0, 0, lazy, big, big, big, big, flags); if (r != LZO_E_OK) { /* this should NEVER happen */ printf("internal error - compression failed: %d\n", r); exit(1); } printf("LZO1X-999: lazy =%2d: %8lu -> %8lu\n", lazy, (long) in_len, (long) out_len); if (out_len < best_len) { best_len = out_len; best_lazy = lazy; best_compress = 1; /* LZO1X-999 */ } } #endif /* USE_LZO1X */ /* * Step 6b: compress from `in' to `out' with LZO1Y-999 */ #ifdef USE_LZO1Y for (lazy = 0; lazy <= max_try_lazy; lazy++) { r = lzo1y_999_compress_internal(in,in_len,out,&out_len,wrkmem, NULL, 0, 0, lazy, big, big, big, big, flags); if (r != LZO_E_OK) { /* this should NEVER happen */ printf("internal error - compression failed: %d\n", r); exit(1); } printf("LZO1Y-999: lazy =%2d: %8lu -> %8lu\n", lazy, (long) in_len, (long) out_len); if (out_len < best_len) { best_len = out_len; best_lazy = lazy; best_compress = 2; /* LZO1Y-999 */ } } #endif /* USE_LZO1Y */ /* * Step 7: check if compressible */ if (best_len >= in_len) { printf("This file contains incompressible data.\n"); return 0; } /* * Step 8: compress data again using the best compressor found */ if (best_compress == 1) r = lzo1x_999_compress_internal(in,in_len,out,&out_len,wrkmem, NULL, 0, 0, best_lazy, big, big, big, big, flags); else if (best_compress == 2) r = lzo1y_999_compress_internal(in,in_len,out,&out_len,wrkmem, NULL, 0, 0, best_lazy, big, big, big, big, flags); else r = -100; assert(r == LZO_E_OK); assert(out_len == best_len); /* * Step 9: optimize compressed data (compressed data is in `out' buffer) */ #if 1 /* Optimization does not require any data in the buffer that will * hold the uncompressed data. To prove this, we clear the buffer. */ lzo_memset(in,0,in_len); #endif orig_len = in_len; if (best_compress == 1) r = lzo1x_optimize(out,out_len,in,&orig_len,NULL); else if (best_compress == 2) r = lzo1y_optimize(out,out_len,in,&orig_len,NULL); else r = -100; if (r != LZO_E_OK || orig_len != in_len) { /* this should NEVER happen */ printf("internal error - optimization failed: %d\n", r); exit(1); } /* * Step 10: compute a checksum of the compressed data */ compressed_checksum = lzo_adler32(0,NULL,0); compressed_checksum = lzo_adler32(compressed_checksum,out,out_len); /* * Step 11: write compressed data to a file */ printf("%s: %s: %ld -> %ld, checksum 0x%08lx 0x%08lx\n", progname, in_name, (long) in_len, (long) out_len, (long) uncompressed_checksum, (long) compressed_checksum); if (out_name && out_name[0]) { printf("%s: writing to file %s\n", progname, out_name); f = fopen(out_name,"wb"); if (f == NULL) { printf("%s: cannot open output file %s\n", progname, out_name); exit(1); } if (lzo_fwrite(f,out,out_len) != out_len || fclose(f) != 0) { printf("%s: write error !!\n", progname); exit(1); } } /* * Step 12: verify decompression */ #ifdef PARANOID orig_len = in_len; if (best_compress == 1) r = lzo1x_decompress(out,out_len,in,&orig_len,NULL); else if (best_compress == 2) r = lzo1y_decompress(out,out_len,in,&orig_len,NULL); else r = -100; if (r != LZO_E_OK || orig_len != in_len) { /* this should NEVER happen */ printf("internal error - decompression failed: %d\n", r); exit(1); } if (uncompressed_checksum != lzo_adler32(lzo_adler32(0,NULL,0),in,in_len)) { /* this should NEVER happen */ printf("internal error - decompression data error\n"); exit(1); } /* Now you could also verify decompression under similar conditions as in * your application, e.g. overlapping assembler decompression etc. */ #endif lzo_free(in); lzo_free(out); lzo_free(wrkmem); return 0; }
void interrupt(void) { /********************************* * vars **********************************/ usi i; usi custom_code_a, custom_code_b; usi data_code_a, data_code_b; usi result; // receive return value from functinos INTCON &= 0x7F; // interrupt => forbidden INTCON &= 0xEF; // INT interrupt => forbidden INTCON &= 0xFD; // INT interrupt flag => cleared ///////////////////////////////////////////////// // Reader ///////////////////////////////////////////////// ////////////////////////////////// // 9.0 ms ////////////////////////////////// TMR0 = 0; // RB0 => off(i.e. 5V -> 0V) // Notice: Pullup is on // => hence, no signal means 5V // at the pin /********************************* * listen: PORTB **********************************/ _while_PORTB_0x01(0); // 9.0ms => passed? // If less than 9.0 or more // => return: i.e. exit from interrupt process ////////////////////////////////// // judge ////////////////////////////////// result = _judge_TMR_(156, 196); if (result == false) { // _pulse(1); return; } ////////////////////////////////// // 4.5 ms ////////////////////////////////// ////////////////////////////////// // Reset: TMR0 ////////////////////////////////// TMR0 = 0; ////////////////////////////////// // Listen ////////////////////////////////// _while_PORTB_0x01(1); ////////////////////////////////// // judge ////////////////////////////////// result = _judge_TMR_(68, 108); if (result == false) { // _pulse(1); return; } ////////////////////////////////// // Response ////////////////////////////////// _response(); ////////////////////////////////// // reset: interruption config ////////////////////////////////// // INTCON => reset INTCON |= 0x10; // INT interrupt => permitted INTCON |= 0x80; }//void interrupt(void)