Esempio n. 1
0
static void AddOsAndCs(FILE *makefile) {
  char *arg, ch;
  int flag = 0;
  char *eop;

  reset_args();
  arg = get_arg(&flag,&ch);
  while ((arg = get_arg(&flag,&ch)) != NULL) {
    if (flag) {
    } else {
      if (arg[(strlen(arg)-2)] == '.') {
	if (arg[(strlen(arg)-1)] == 'c') {
	  arg[(strlen(arg)-1)] = 'o';
	  eop = strrchr(arg,'/');
	  if (eop != NULL) {
	    eop++;
	    fprintf(makefile," \\\n\t%s",eop);
	    arg[(strlen(arg)-1)] = 'c';
	  } else {
	    fprintf(makefile," \\\n\t%s",arg);
	  }
	} else if (arg[(strlen(arg)-1)] == 'o') {
	  fprintf(makefile," \\\n\t%s",arg);
	}
      }
    }
  }
}
      void go() override
         {
         std::unique_ptr<Botan::Public_Key> key(Botan::X509::load_key(get_arg("pubkey")));
         if(!key)
            {
            throw CLI_Error("Unable to load public key");
            }

         const std::string sig_padding =
            get_arg_or("emsa", algo_default_emsa(key->algo_name())) + "(" + get_arg("hash") + ")";

         Botan::PK_Verifier verifier(*key, sig_padding);
         auto onData = [&verifier](const uint8_t b[], size_t l)
            {
            verifier.update(b, l);
            };
         this->read_file(get_arg("file"), onData);

         const Botan::secure_vector<uint8_t> signature =
            Botan::base64_decode(this->slurp_file_as_str(get_arg("signature")));

         const bool valid = verifier.check_signature(signature);

         output() << "Signature is " << (valid ? "valid" : "invalid") << "\n";
         }
int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	ulong a, b;
	char buf[16];
	int w;

	/* Validate arguments */
	if ((argc != 5) || (strlen(argv[3]) != 1)) {
		cmd_usage(cmdtp);
		return 1;
	}

	w = cmd_get_data_size(argv[0], 4);

	a = get_arg(argv[2], w);
	b = get_arg(argv[4], w);

	switch (argv[3][0]) {
	case '|': sprintf(buf, "%lx", (a | b)); break;
	case '&': sprintf(buf, "%lx", (a & b)); break;
	case '+': sprintf(buf, "%lx", (a + b)); break;
	case '^': sprintf(buf, "%lx", (a ^ b)); break;
	case '-': sprintf(buf, "%lx", (a - b)); break;
	case '*': sprintf(buf, "%lx", (a * b)); break;
	case '/': sprintf(buf, "%lx", (a / b)); break;
	case '%': sprintf(buf, "%lx", (a % b)); break;
	default:
		printf("invalid op\n");
		return 1;
	}

	setenv(argv[1], buf);

	return 0;
}
Esempio n. 4
0
void cmdFlash(char *buf)
{
	unsigned char buf2[10240];
	int size=128;
	int n = get_arg(buf);	//引数の数.
	if( n != 0 ) {
		size = arg_val[0];
	}

	if(size) {
		dumpmem(0x1000,0,size,buf2);
	}
#if	0
	unsigned char data[128];
	int size = 32;
	int n = get_arg(buf);	//引数の数.
	if(n != 0) {
		int i;
		for(i=0;i<64;i++) data[i]=i;

		UsbFlash(adrs,AREA_PGMEM,data,size);

	}
#endif

}
Esempio n. 5
0
static int config_channel(struct timer *tr, char **arg_text)
{
	char *which_text = get_arg(arg_text);
	char *value_text = get_arg(arg_text);
	address_t which;
	address_t value;

	if (!(which_text && value_text)) {
		printc_err("timer: config: expected channel and value\n");
		return -1;
	}

	if (expr_eval(which_text, &which) < 0) {
		printc_err("timer: can't parse channel number: %s\n",
			   which_text);
		return -1;
	}

	if (expr_eval(value_text, &value) < 0) {
		printc_err("timer: can't parse channel value: %s\n",
			   value_text);
		return -1;
	}

	if (which > tr->size) {
		printc_err("timer: invalid channel number: %d\n", which);
		return -1;
	}

	trigger_capture(tr, which, tr->ctls[which] & CCI, value);

	return 0;
}
Esempio n. 6
0
      void go() override
         {
         const Botan::BigInt n(get_arg("n"));
         const Botan::BigInt mod(get_arg("mod"));

         output() << Botan::inverse_mod(n, mod) << "\n";
         }
Esempio n. 7
0
int Command::run(const std::vector<std::string>& params)
   {
   try
      {
      m_args.reset(new Argument_Parser(m_spec,
                                       {"verbose", "help"},
                                       {"output", "error-output", "rng-type", "drbg-seed"}));

      m_args->parse_args(params);

      if(m_args->has_arg("output"))
         {
         const std::string output_file = get_arg("output");

         if(output_file != "")
            {
            m_output_stream.reset(new std::ofstream(output_file, std::ios::binary));
            if(!m_output_stream->good())
               throw CLI_IO_Error("opening", output_file);
            }
         }

      if(m_args->has_arg("error-output"))
         {
         const std::string output_file = get_arg("error-output");

         if(output_file != "")
            {
            m_error_output_stream.reset(new std::ofstream(output_file, std::ios::binary));
            if(!m_error_output_stream->good())
               throw CLI_IO_Error("opening", output_file);
            }
         }

      if(flag_set("help"))
         {
         output() << help_text() << "\n";
         return 2;
         }

      this->go();
      return m_return_code;
      }
   catch(CLI_Usage_Error& e)
      {
      error_output() << "Usage error: " << e.what() << "\n";
      error_output() << help_text() << "\n";
      return 1;
      }
   catch(std::exception& e)
      {
      error_output() << "Error: " << e.what() << "\n";
      return 2;
      }
   catch(...)
      {
      error_output() << "Error: unknown exception\n";
      return 2;
      }
   }
Esempio n. 8
0
int cmd_mw(char **arg)
{
	char *off_text = get_arg(arg);
	char *byte_text;
	address_t offset = 0;
	address_t length = 0;
	uint8_t buf[1024];

	if (!off_text) {
		printc_err("md: offset must be specified\n");
		return -1;
	}

	if (expr_eval(off_text, &offset) < 0) {
		printc_err("md: can't parse offset: %s\n", off_text);
		return -1;
	}

	while ((byte_text = get_arg(arg))) {
		if (length >= sizeof(buf)) {
			printc_err("md: maximum length exceeded\n");
			return -1;
		}

		buf[length++] = strtoul(byte_text, NULL, 16);
	}

	if (!length)
		return 0;

	if (device_writemem(offset, buf, length) < 0)
		return -1;

	return 0;
}
Esempio n. 9
0
File: parse.c Progetto: elboza/WiCE
char* get_b_arg(struct expr_node **expr,char *p,int line_count)
{
	struct expr_node *new_expr,*new_expr2,*new_expr3;
	char s1[MAXSTR];
	p=get_arg(&new_expr,p,line_count);
	p=skip_space(p);
	if((*p=='\n')||(*p==','))
	{
		*expr=new_expr;
		return p;
	}
	//if is_bool_op(p)
	if(is_bool_op(p,line_count))
	{
		new_expr2=(struct expr_node*)malloc(sizeof(struct expr_node));
		if(new_expr2==NULL)
		{ sprintf(s1,"at line %d, error malloc exr_node",line_count);die(s1);}
		new_expr2->type=OP_BOOL;
		p=get_token(p);
		strncpy(new_expr2->str,my_token,MAXSTR);
		new_expr2->left=new_expr;
		new_expr2->right=NULL;
		p=skip_space(p);
		p=get_arg(&new_expr3,p,line_count);
		new_expr2->right=new_expr3;
		*expr=new_expr2;
	}
	return p;
}
Esempio n. 10
0
void chat_command_handler::do_chanmsg()
{
	if (get_data(1).empty()) return command_failed_need_arg(1);
	if (get_data(2).empty()) return command_failed_need_arg(2);
	chat_handler_.send_chat_room_message(get_arg(1), get_data(2));
	chat_handler_.add_chat_room_message_sent(get_arg(1), get_data(2));
}
Esempio n. 11
0
/* ECMA-262 3rd Edition    15.8.2.12 */
static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
        VARIANT *retv, jsexcept_t *ei)
{
    DOUBLE min, d;
    DWORD i;
    HRESULT hres;

    TRACE("\n");

    if(!arg_cnt(dp)) {
        if(retv)
            num_set_inf(retv, TRUE);
        return S_OK;
    }

    hres = to_number(ctx, get_arg(dp, 0), ei, &min);
    if(FAILED(hres))
        return hres;

    for(i=1; i < arg_cnt(dp); i++) {
        hres = to_number(ctx, get_arg(dp, i), ei, &d);
        if(FAILED(hres))
            return hres;

        if(d < min || isnan(d))
            min = d;
    }

    if(retv)
        num_set_val(retv, min);
    return S_OK;
}
Esempio n. 12
0
void chat_command_handler::do_whisper()
{
	if (get_data(1).empty()) return command_failed_need_arg(1);
	if (get_data(2).empty()) return command_failed_need_arg(2);
	chat_handler_.send_whisper(get_arg(1), get_data(2));
	chat_handler_.add_whisper_sent(get_arg(1), get_data(2));
}
Esempio n. 13
0
/* ECMA-262 3rd Edition    15.8.2.13 */
static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
        VARIANT *retv, jsexcept_t *ei)
{
    double x, y;
    HRESULT hres;

    TRACE("\n");

    if(arg_cnt(dp) < 2) {
        if(retv) num_set_nan(retv);
        return S_OK;
    }

    hres = to_number(ctx, get_arg(dp, 0), ei, &x);
    if(FAILED(hres))
        return hres;

    hres = to_number(ctx, get_arg(dp, 1), ei, &y);
    if(FAILED(hres))
        return hres;

    if(retv)
        num_set_val(retv, pow(x, y));
    return S_OK;
}
Esempio n. 14
0
void chat_command_handler::do_register() {
	config data;
	config& nickserv = data.add_child("nickserv");

	if (get_data(1).empty()) return command_failed_need_arg(1);

	config &reg = nickserv.add_child("register");
	reg["password"] = get_arg(1);
	if (!get_data(2).empty()) {
		reg["mail"] = get_arg(2);
	}
	std::string msg;
	if (get_data(2).empty()) {
		msg = _("registering with password *** and no email address");
	}
	else {
		utils::string_map symbols;
		symbols["email"] = get_data(2);
		msg = VGETTEXT("registering with password *** and "
			"email address $email", symbols);
	}
	print(_("nick registration"), msg);

	chat_handler_.send_to_server(data);
}
Esempio n. 15
0
      void go() override
         {
         std::unique_ptr<Botan::Private_Key> key(
            Botan::PKCS8::load_key(
               get_arg("key"),
               rng(),
               get_arg("passphrase")));

         if(!key)
            {
            throw CLI_Error("Unable to load private key");
            }

         const std::string sig_padding =
            get_arg_or("emsa", algo_default_emsa(key->algo_name())) + "(" + get_arg("hash") + ")";

         Botan::PK_Signer signer(*key, rng(), sig_padding);

         auto onData = [&signer](const uint8_t b[], size_t l)
            {
            signer.update(b, l);
            };
         this->read_file(get_arg("file"), onData);

         output() << Botan::base64_encode(signer.signature(rng())) << "\n";
         }
Esempio n. 16
0
int main(int argc, char **argv)
{
	
	init_daemon(argv[0],LOG_INFO);

	if(get_arg("home_dir")==0) {
		sprintf(home_dir,"%s","/tmp");
	}

	if(get_arg("ip")==0) {
		get_addr("eth0");
	}

	if(get_arg("port")==0) {
		sprintf(port,"%s","80");
	}

	if(get_arg("back")==0) {
		sprintf(back,"%s","5");
	}

    int sock_fd = socket_bind(ip, atoi((const char *)&port));
    
	do_epoll(sock_fd);
    
    close(sock_fd);
	
    return 0;
} 
Esempio n. 17
0
int cmd_set(char **arg)
{
	char *reg_text = get_arg(arg);
	char *val_text = get_arg(arg);
	int reg;
	address_t value = 0;
	address_t regs[DEVICE_NUM_REGS];

	if (!(reg_text && val_text)) {
		printc_err("set: must specify a register and a value\n");
		return -1;
	}

	reg = dis_reg_from_name(reg_text);
	if (reg < 0) {
		printc_err("set: unknown register: %s\n", reg_text);
		return -1;
	}

	if (expr_eval(val_text, &value) < 0) {
		printc_err("set: can't parse value: %s\n", val_text);
		return -1;
	}

	if (device_getregs(regs) < 0)
		return -1;
	regs[reg] = value;
	if (device_setregs(regs) < 0)
		return -1;

	show_regs(regs);
	return 0;
}
Esempio n. 18
0
static int cmd_set(cproc_t cp, char **arg)
{
    device_t dev = cproc_device(cp);
    stab_t stab = cproc_stab(cp);
    char *reg_text = get_arg(arg);
    char *val_text = get_arg(arg);
    int reg;
    int value = 0;
    uint16_t regs[DEVICE_NUM_REGS];

    if (!(reg_text && val_text)) {
        fprintf(stderr, "set: must specify a register and a value\n");
        return -1;
    }

    reg = dis_reg_from_name(reg_text);
    if (reg < 0) {
        fprintf(stderr, "set: unknown register: %s\n", reg_text);
        return -1;
    }

    if (expr_eval(stab, val_text, &value) < 0) {
        fprintf(stderr, "set: can't parse value: %s\n", val_text);
        return -1;
    }

    if (dev->getregs(dev, regs) < 0)
        return -1;
    regs[reg] = value;
    if (dev->setregs(dev, regs) < 0)
        return -1;

    cproc_regs(cp, regs);
    return 0;
}
Esempio n. 19
0
      void go() override
         {
         const std::string comp_type = get_arg("type");

         std::unique_ptr<Botan::Transform> compress;

#if defined(BOTAN_HAS_COMPRESSION)
         compress.reset(Botan::make_compressor(comp_type, get_arg_sz("level")));
#endif

         if(!compress)
            {
            throw CLI_Error_Unsupported("Compression", comp_type);
            }

         const std::string in_file = get_arg("file");
         std::ifstream in(in_file);

         if(!in.good())
            {
            throw CLI_IO_Error("reading", in_file);
            }

         const std::string out_file = output_filename(in_file, comp_type);
         std::ofstream out(out_file);
         if(!in.good())
            {
            throw CLI_IO_Error("writing", out_file);
            }

         do_compress(*compress, in, out, get_arg_sz("buf-size"));
         }
	void help()
	{
		//print command-specific help if available, otherwise list commands
		if (help_command(get_arg(1))) {
			return;
		}
		std::stringstream ss;
		bool show_unavail = show_unavailable_ || get_arg(1) == "all";
		for (typename command_map::value_type i : command_map_) {
			if (show_unavail || is_enabled(i.second)) {
				ss << i.first;
				//if (!i.second.usage.empty()) {
				//	ss << " " << i.second.usage;
				//}
				//uncomment the above to display usage information in command list
				//which might clutter it somewhat
				if (!i.second.flags.empty()) {
					ss << " (" << i.second.flags << ") ";
				}
				ss << "; ";
			}
		}
		utils::string_map symbols;
		symbols["flags_description"] = get_flags_description();
		symbols["list_of_commands"] = ss.str();
		symbols["help_command"] = cmd_prefix_ + "help";
		print(_("help"), VGETTEXT("Available commands $flags_description:\n$list_of_commands", symbols));
		print(_("help"), VGETTEXT("Type $help_command <command> for more info.", symbols));
	}
Esempio n. 21
0
static int cmd_hexout(cproc_t cp, char **arg)
{
    device_t dev = cproc_device(cp);
    stab_t stab = cproc_stab(cp);
    char *off_text = get_arg(arg);
    char *len_text = get_arg(arg);
    char *filename = *arg;
    int off;
    int length;
    struct hexout_data hexout;

    if (!(off_text && len_text && *filename)) {
        fprintf(stderr, "hexout: need offset, length and filename\n");
        return -1;
    }

    if (expr_eval(stab, off_text, &off) < 0 ||
            expr_eval(stab, len_text, &length) < 0)
        return -1;

    if (hexout_start(&hexout, filename) < 0)
        return -1;

    while (length) {
        uint8_t buf[128];
        int count = length;

        if (count > sizeof(buf))
            count = sizeof(buf);

        printf("Reading %d bytes from 0x%04x...\n", count, off);
        if (dev->readmem(dev, off, buf, count) < 0) {
            perror("hexout: can't read memory");
            goto fail;
        }

        if (hexout_feed(&hexout, off, buf, count) < 0)
            goto fail;

        length -= count;
        off += count;
    }

    if (hexout_flush(&hexout) < 0)
        goto fail;
    if (fclose(hexout.file) < 0) {
        perror("hexout: error on close");
        return -1;
    }

    return 0;

fail:
    fclose(hexout.file);
    unlink(filename);
    return -1;
}
Esempio n. 22
0
Botan::RandomNumberGenerator& Command::rng()
   {
   if(m_rng == nullptr)
      {
      m_rng = cli_make_rng(get_arg("rng-type"), get_arg("drbg-seed"));
      }

   return *m_rng.get();
   }
Esempio n. 23
0
void fcgi_upgrade_2_1_4(void) {
    rc_ty s;
    const sx_hashfs_volume_t *vol = NULL;
    const char *startname, *startrev = NULL;
    struct rplfiles ctx;

    if(!has_arg("maxrev"))
        quit_errmsg(400, "Parameter maxrev is required");

    startname = strchr(path, '/');
    if(!startname) {
        s = sx_hashfs_volume_by_name(hashfs, path, &vol);
    } else {
        unsigned int vnamelen = startname - path;
        char *vname = malloc(vnamelen + 1);
        if(!vname)
            quit_errmsg(503, "Out of memory");
        memcpy(vname, path, vnamelen);
        vname[vnamelen] = '\0';
        s = sx_hashfs_volume_by_name(hashfs, vname, &vol);
        free(vname);
        startname++;
        if(strlen(startname))
            startrev = get_arg("startrev");
        else
            startname = NULL;
    }
    if(s != OK)
        quit_errmsg(rc2http(s), msg_get_reason());

    if(!sx_hashfs_is_or_was_my_volume(hashfs, vol, 0))
        quit_errnum(404);

    ctx.bytes_sent = 0;
    ctx.b = sx_blob_new();
    if(!ctx.b)
        quit_errmsg(503, "Out of memory");

    s = sx_hashfs_file_find(hashfs, vol, startname, startrev, get_arg("maxrev"), upgrade_2_1_4_cb, &ctx);
    if(s == FAIL_ETOOMANY || s == ITER_NO_MORE) {
        sx_blob_reset(ctx.b);
        if(!sx_blob_add_string(ctx.b, "$FILE$") && !sx_blob_add_string(ctx.b, ctx.lastfile.name) &&
           !sx_blob_add_string(ctx.b, ctx.lastfile.revision))
            send_rplfiles_header(&ctx);
    }
    if(s == ITER_NO_MORE) {
        sx_blob_reset(ctx.b);
        if(!sx_blob_add_string(ctx.b, "$THEEND$"))
            send_rplfiles_header(&ctx);
        sx_blob_free(ctx.b);
        return;
    }

    sx_blob_free(ctx.b);
    if(s != FAIL_ETOOMANY && !ctx.bytes_sent)
        quit_errmsg(rc2http(s), msg_get_reason());
}
Esempio n. 24
0
static int config_channel(struct timer *tr, char **arg_text)
{
    char *which_text = get_arg(arg_text);
    char *value_text = get_arg(arg_text);
    address_t which;
    address_t value;
    int oldval;
    uint16_t edge_flags = 0;

    if (!(which_text && value_text)) {
        printc_err("timer: config: expected channel and value\n");
        return -1;
    }

    if (expr_eval(which_text, &which) < 0) {
        printc_err("timer: can't parse channel number: %s\n",
                   which_text);
        return -1;
    }

    if (expr_eval(value_text, &value) < 0) {
        printc_err("timer: can't parse channel value: %s\n",
                   value_text);
        return -1;
    }

    if (which > tr->size) {
        printc_err("timer: invalid channel number: %d\n", which);
        return -1;
    }

    oldval = tr->ctls[which] & CCI;
    tr->ctls[which] &= ~CCI;
    if (value)
        tr->ctls[which] |= CCI;

    if (oldval && !value)
        edge_flags |= CM1;
    if (!oldval && value)
        edge_flags |= CM0;

    printc_dbg("Timer channel %d: %s => %s\n",
               which, oldval ? "H" : "L", value ? "H" : "L");

    if ((tr->ctls[which] & edge_flags) && (tr->ctls[which] & CAP)) {
        if (tr->ctls[which] & CCIFG) {
            printc_dbg("Timer capture overflow\n");
            tr->ctls[which] |= COV;
        } else {
            printc_dbg("Timer capture interrupt triggered\n");
            tr->ccrs[which] = tr->tar;
            tr->ctls[which] |= CCIFG;
        }
    }

    return 0;
}
Esempio n. 25
0
      void go() override
         {
         std::unique_ptr<Botan::Private_Key> key;
         std::string pass_in = get_arg("pass-in");

         if (pass_in.empty())
         {
            key.reset(Botan::PKCS8::load_key(get_arg("key"), rng()));
         }
         else
         {
            key.reset(Botan::PKCS8::load_key(get_arg("key"), rng(), pass_in));
         }

         const std::chrono::milliseconds pbe_millis(get_arg_sz("pbe-millis"));
         const std::string pbe = get_arg("pbe");
         const bool der_out = flag_set("der-out");

         if(flag_set("pub-out"))
            {
            if(der_out)
               {
               write_output(Botan::X509::BER_encode(*key));
               }
            else
               {
               output() << Botan::X509::PEM_encode(*key);
               }
            }
         else
            {
            const std::string pass_out = get_arg("pass-out");

            if(der_out)
               {
               if(pass_out.empty())
                  {
                  write_output(Botan::PKCS8::BER_encode(*key));
                  }
               else
                  {
                  write_output(Botan::PKCS8::BER_encode(*key, rng(), pass_out, pbe_millis, pbe));
                  }
               }
            else
               {
               if(pass_out.empty())
                  {
                  output() << Botan::PKCS8::PEM_encode(*key);
                  }
               else
                  {
                  output() << Botan::PKCS8::PEM_encode(*key, rng(), pass_out, pbe_millis, pbe);
                  }
               }
            }
         }
Esempio n. 26
0
static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
        VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
    FunctionInstance *function;
    DISPPARAMS args = {NULL,NULL,0,0};
    DWORD argc, i;
    IDispatch *this_obj = NULL;
    HRESULT hres = S_OK;

    TRACE("\n");

    if(!(function = function_this(jsthis)))
        return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL);

    argc = arg_cnt(dp);
    if(argc) {
        VARIANT *v = get_arg(dp,0);

        if(V_VT(v) != VT_EMPTY && V_VT(v) != VT_NULL) {
            hres = to_object(ctx, v, &this_obj);
            if(FAILED(hres))
                return hres;
        }
    }

    if(argc >= 2) {
        jsdisp_t *arg_array = NULL;

        if(V_VT(get_arg(dp,1)) == VT_DISPATCH) {
            arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(get_arg(dp,1)));
            if(arg_array &&
               (!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) {
                jsdisp_release(arg_array);
                arg_array = NULL;
            }
        }

        if(arg_array) {
            hres = array_to_args(ctx, arg_array, ei, caller, &args);
            jsdisp_release(arg_array);
        }else {
            FIXME("throw TypeError\n");
            hres = E_FAIL;
        }
    }

    if(SUCCEEDED(hres))
       hres = call_function(ctx, function, this_obj, &args, retv, ei, caller);

    if(this_obj)
        IDispatch_Release(this_obj);
    for(i=0; i<args.cArgs; i++)
        VariantClear(args.rgvarg+i);
    heap_free(args.rgvarg);
    return hres;
}
Esempio n. 27
0
void chat_command_handler::do_gen_room_query()
{
	if (get_data(1).empty()) return command_failed_need_arg(1);
	config data;
	config& q = data.add_child("room_query");
	q["room"] = get_arg(1);
	config& c = q.add_child(get_arg(2));
	c["value"] = get_data(3);
	chat_handler_.send_to_server(data);
}
Esempio n. 28
0
void chat_command_handler::do_remove()
{
	for (int i = 1;!get_arg(i).empty();i++) {
		preferences::remove_acquaintance(get_arg(i));
		chat_handler_.user_relation_changed(get_arg(i));
		utils::string_map symbols;
		symbols["nick"] = get_arg(i);
		print(_("friends and ignores list"), VGETTEXT("Removed from list: $nick", symbols));
	}
}
Esempio n. 29
0
File: error.c Progetto: bilboed/wine
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, DISPPARAMS *dp,
        VARIANT *retv, jsexcept_t *ei, DispatchEx *constr) {
    DispatchEx *err;
    VARIANT numv;
    UINT num;
    BSTR msg = NULL;
    HRESULT hres;

    V_VT(&numv) = VT_NULL;

    if(arg_cnt(dp)) {
        hres = to_number(ctx, get_arg(dp, 0), ei, &numv);
        if(FAILED(hres) || (V_VT(&numv)==VT_R8 && isnan(V_R8(&numv))))
            hres = to_string(ctx, get_arg(dp, 0), ei, &msg);
        else if(V_VT(&numv) == VT_I4)
            num = V_I4(&numv);
        else
            num = V_R8(&numv);

        if(FAILED(hres))
            return hres;
    }

    if(arg_cnt(dp)>1 && !msg) {
        hres = to_string(ctx, get_arg(dp, 1), ei, &msg);
        if(FAILED(hres))
            return hres;
    }

    switch(flags) {
    case INVOKE_FUNC:
    case DISPATCH_CONSTRUCT:
        if(V_VT(&numv) == VT_NULL)
            hres = create_error(ctx, constr, NULL, msg, &err);
        else
            hres = create_error(ctx, constr, &num, msg, &err);
        SysFreeString(msg);

        if(FAILED(hres))
            return hres;

        if(retv) {
            V_VT(retv) = VT_DISPATCH;
            V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(err);
        }
        else
            jsdisp_release(err);

        return S_OK;

    default:
        FIXME("unimplemented flags %x\n", flags);
        return E_NOTIMPL;
    }
}
Esempio n. 30
0
    virtual void parse(T_arg_list args, bool call_super = true)
    {
        if (call_super)
        {
            super::parse(args);
        }

        pkt_timeout = get_arg("in_order::timeout", pkt_timeout, args).d;
        use_fixed_timeout = get_arg("in_order::use_fixed_timeout", use_fixed_timeout, args).b;
        ASSERT_GT(pkt_timeout, 0);
    }