Ejemplo n.º 1
0
static VALUE set_public_alias(VALUE self, VALUE nickname)
{
  PurpleAccount *account = PURPLE_ACCOUNT(self);
  PurpleConnection *connection = NULL;
  PurplePlugin *prpl = NULL;
  const char *alias = NULL;
  void (*set_alias) (PurpleConnection *gc, const char *alias);
  
  alias = RSTRING_PTR( nickname );
  
  connection = purple_account_get_connection( account );
  
  if (!connection) {
    purple_account_set_public_alias( account, alias, NULL, NULL );
    return Qnil;
  }

  prpl = purple_connection_get_prpl( connection );
  if (!g_module_symbol( prpl->handle, "set_alias", (void *) &set_alias ) ) {
    // purple_account_set_public_alias( account, alias, NULL, NULL );
    return Qnil;
  }

  set_alias( connection, alias );
  
  return Qnil;
}
Ejemplo n.º 2
0
set_guild(string hmm) {
  guild = hmm;
  name = RAND->gimme_a_male_name();
  set_name(name);
  set_short(CAP(name)+" the bartender");
  set_long(CAP(name)+" is the new bartender of the "+CAP(guild)+"'s Tavern.\n");
  set_level(1);
  set_alias("bartender");
  set_alt_name("std_bartender");
  set_gender(1);
  set_race("human");
  set_hp(50);
  set_al(0);
  set_wc(50);
  set_new_ac(9);
  set_skill("combat", 9);
  set_skill("unarmed", 9);
  set_skill("perception", 5);
  set_skill("resist", 5);
  add_money(25);
  load_chat(1, 
    ({
      CAP(name) + " says: I don't know what to say?\n",
      CAP(name) + " asks: Want some more alcohol?\n",
      CAP(name) + " says: Alcohol makes people smarter.\n",
      CAP(name) + " asks: Who needs brain cells?\n",
    })
  );
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    char *a0 = argv[0] + strlen(argv[0]) - 1;
    while ( a0>argv[0] && a0[-1]!='/' && a0[-1]!='\\' ) a0--;
    
	if (argc < 2) return usage(a0);
    if ( !known_alias(a0) ) a0 = "htscmd";

    int i = 0, nbuf = 0;
    char *buf = NULL;
    while (cmds[i].func)
    {
        if ( set_alias(&cmds[i], a0, &buf, &nbuf) )
        {
            if ( !strcmp(argv[1],buf) ) 
            {
                free(buf);
                return cmds[i].func(argc-1,argv+1);
            }
        }
        i++;
    }
    if ( buf ) free(buf);
    fprintf(stderr, "[E::%s] unrecognized command '%s'\n", __func__, argv[1]);
    return 1;
}
Ejemplo n.º 4
0
static int usage(char *argv0)
{
	fprintf(stderr, "\n");
    fprintf(stderr, "Version: %s\n", HTS_VERSION);
	fprintf(stderr, "Usage:   %s <command> <argument>\n", argv0);
	fprintf(stderr, "Commands:\n");

    if ( !known_alias(argv0) ) argv0 = "htscmd";

    int i = 0, nbuf = 0;
    char *buf = NULL;
    const char *sep = NULL;
    while (cmds[i].func)
    {
        if ( cmds[i].sep ) sep = cmds[i].sep;
        if ( set_alias(&cmds[i], argv0, &buf, &nbuf) )
        {
            if ( sep )
            {
                printf("\n -- %s\n", sep);
                sep = NULL;
            }
            printf("\t%-15s %s\n", buf, cmds[i].help);
        }
        i++;
    }
    if ( buf ) free(buf);

    fprintf(stderr,"\n");
	return 1;
}
Ejemplo n.º 5
0
void reset(int arg) {
  ::reset(arg);
  if( !arg ) {
    object crown;

    set_name("frog");
    set_alias("toad");
    set_short("a frog");
    set_long("It is your typical frog: small, green, and warty.  However,\n"+
	"perched atop its head is a tiny crown.  Perhaps it is a prince\n"+
	"or princess enchanted by some witch?\n");
    set_race("frog");
    set_level(1);
    set_frog(1);
    set_wc(4);

    crown = clone_object("/std/simple_armour");
    crown->set_name("crown");
    crown->add_alias("iron crown");
    crown->set_short("An iron crown");
    crown->set_long("Actually, it is made of iron and seems to only be "+
	"painted gold.\nIt is tiny and would barely fit you.\n");
    crown->set_class(1);
    crown->set_weight(2);
    crown->set_type("helmet"); /* Added by Banshee. 960118 */
    crown->set_value(18);
    move_object(crown, this_object());
    command("wear crown");
  }
}
Ejemplo n.º 6
0
void create_object() {
  set_name("notepad");
  set_alias("pad");
  set_short("a little blue notepad");
  set_long(
"Commands:\n"+
"  messages       \n"+
"  add <message>  \n"+
"  del <num>      \n"+
"\n\n");
}
Ejemplo n.º 7
0
void world_session::HandleNewAliasOpcode(world_packet &recvPacket)
{
	try
    {
		set_alias(recvPacket.read<uint8>(), recvPacket.read<uint16>(), recvPacket.read<uint16>(), recvPacket.read<uint32>());
    }
    catch(ByteBuffer::error &)
    {
        //sLog.outDetail("Incomplete packet");
        return;
    }
}
Ejemplo n.º 8
0
static int known_alias(char *argv0)
{
    int i = 0, nbuf = 0, known = 0;
    char *buf = NULL;
    while (cmds[i].func)
    {
        if ( (known = set_alias(&cmds[i], argv0, &buf, &nbuf)) ) break;
        i++;
    }
    if ( buf ) free(buf);
    return known;
}
Ejemplo n.º 9
0
		virtual void read(boost::shared_ptr<nscapi::settings_proxy> proxy, bool oneliner, bool is_sample) {
			parent::read(proxy, oneliner, is_sample);
			set_alias(boost::algorithm::to_lower_copy(get_alias()));
			set_command(get_value());

			nscapi::settings_helper::settings_registry settings(proxy);
			nscapi::settings_helper::path_extension root_path = settings.path(get_path());
			if (is_sample)
				root_path.set_sample();

			if (!oneliner) {
				root_path.add_path()
					("script: " + get_alias(), "The configuration section for the  " + get_alias() + " script.")
					;

				root_path.add_key()
					("command", sh::string_fun_key(boost::bind(&command_object::set_command, this, _1)),
						"COMMAND", "Command to execute")

					("user", nscapi::settings_helper::string_key(&user),
						"USER", "The user to run the command as", true)

					("domain", nscapi::settings_helper::string_key(&domain),
						"DOMAIN", "The user to run the command as", true)

					("password", nscapi::settings_helper::string_key(&password),
						"PASSWORD", "The user to run the command as", true)

					("session", nscapi::settings_helper::string_key(&session),
						"SESSION", "Session you want to invoke the client in either the number of current for the one with a UI", true)

					("display", nscapi::settings_helper::bool_key(&display),
						"DISPLAY", "Set to true if you want to display the resulting window or not", true)

					("encoding", nscapi::settings_helper::string_key(&encoding),
						"ENCODING", "The encoding to parse the command as", true)

					("ignore perfdata", nscapi::settings_helper::bool_key(&ignore_perf),
						"IGNORE PERF DATA", "Do not parse performance data from the output", false)

					("capture output", nscapi::settings_helper::bool_key(&no_fork),
						"CAPTURE OUTPUT", "This should be set to false if you want to run commands which never terminates (i.e. relinquish control from NSClient++). The effect of this is that the command output will not be captured. The main use is to protect from socket reuse issues", true)

					;

				settings.register_all();
				settings.notify();
			}
		}
Ejemplo n.º 10
0
/********************************************************************
 * FUNCTION handle_alias_parm
 * 
 * alias def
 * alias def=def-value
 *
 * Handle the alias command, based on the parameter
 *
 * INPUTS:
 *    varstr == alias command line
 *    setonly == TRUE if expecting set version only; ignore show alias
 *               FALSE if expecting show alias or set alias
 *    loginfo == TRUE if log-level=info should be used
 *               FALSE if log-level=debug2 should be used
 * RETURNS:
 *   status
 *********************************************************************/
static status_t
    handle_alias_parm (const xmlChar *varstr,
                       boolean setonly,
                       boolean loginfo)
{
    const xmlChar *valptr = NULL;    
    uint32    nlen = 0;
    status_t  res;

    res = parse_alias(varstr, &nlen, &valptr);
    if (res == NO_ERR) {
        if (valptr) {
            /* setting an alias */
            alias_cb_t *alias = find_alias(varstr, nlen);
            if (alias) {
                if (LOGDEBUG3) {
                    log_debug3("\nAbout to replace alias '%s'"
                               "\n  old value: '%s'"
                               "\n  new value: '%s'",
                               alias->name, 
                               alias->value ? alias->value : EMPTY_STRING,
                               valptr);
                }
                /* modify an existing alias */
                res = set_alias(alias, valptr);
                if (res == NO_ERR) {
                    if (loginfo) {
                        log_info("\nUpdated alias '%s'\n", alias->name);
                    } else {
                        log_debug2("\nUpdated alias '%s'", alias->name);
                    }
                } else {
                    log_error("\nError: invalid alias value '%s'\n",
                              valptr);
                }
            } else {
                /* create a new alias */
                alias = new_alias(varstr, nlen);
                if (alias == NULL) {
                    res = ERR_INTERNAL_MEM;
                } else {
                    res = set_alias(alias, valptr);
                    if (res == NO_ERR) {
                        res = add_alias(alias);
                        if (res == NO_ERR) {
                            if (loginfo) {
                                log_info("\nAdded alias '%s'\n", alias->name);
                            } else {
                                log_debug2("\nAdded alias '%s'", alias->name);
                            }
                        } else {
                            log_error("\nError: alias was not added '%s'\n",
                                      get_error_string(res));
                        }
                    } else {
                        log_error("\nError: invalid alias value '%s'\n",
                                  valptr);
                        free_alias(alias);
                    }
                }
            }
        } else if (!setonly) {
            /* just provided a name; show alias */
            show_alias_name(varstr, nlen);
        } else if (LOGDEBUG) {
            log_debug("\nSkipping alias '%s' because no value set", varstr);
        }
    } else if (res == ERR_NCX_INVALID_NAME) {
        log_error("\nError: invalid alias (%s)", get_error_string(res));
    } else {
        log_error("\nError: invalid alias '%s' (%s)", varstr,
                  get_error_string(res));
    }
    return res;

}  /* handle_alias_parm */