Exemplo n.º 1
0
Arquivo: start.c Projeto: bengras/umon
/* init0():
 * The code in this function was originally part of start().  It has been
 * moved out so that this portion of the initialization can be re-used by
 * AppWarmStart().  See notes in AppWarmStart() for more details on this.
 */
void
init0(void)
{
    /* Store the base address of memory that is used by application.
     * Start it off on the next 4K boundary after the end of monitor ram.
     * Usually APPRAMBASE and BOOTROMBASE can be retrieved from bss_end and
     * boot_base; but they can be overridden with values specified in the
     * target-specific config.h file.
     */
#ifdef APPRAMBASE_OVERRIDE
    APPLICATION_RAMSTART = APPRAMBASE_OVERRIDE;
#else
    APPLICATION_RAMSTART = (((ulong)&bss_end) | 0xfff) + 1;
#endif

#ifdef BOOTROMBASE_OVERRIDE
    BOOTROM_BASE = BOOTROMBASE_OVERRIDE;
#else
    BOOTROM_BASE = (ulong)&boot_base;
#endif

    /* Load bottom of stack with 0xdeaddead to be used by stkchk().
     */
    MonStack[0] = 0xdeaddead;

    /* Set up default loops-per-millisecond count.
     */
    LoopsPerMillisecond = LOOPS_PER_SECOND/1000;

    /* Clear any user-installed command list.
     */
    addcommand(0,0);
}
Exemplo n.º 2
0
void addctcp(void *module, const char *command, int (*function) (struct userlist *, const char *))
{
	ctcplist = addcommand(module,ctcplist, command, function, 99, 0);
}
Exemplo n.º 3
0
Arquivo: irc.c Projeto: rdgout/ircbot
void initservercmds() {
    /* Numeric "commands" here */
    addcommand("001", 0, CTYPE_SERVER, bot_initserver, NULL); /* Connected to server */
    addcommand("005", 0, CTYPE_SERVER, bot_initsettings, NULL); /* Known settings on IRCd */
    addcommand("302", 0, CTYPE_SERVER, bot_userhost, NULL); /* Our host */
    addcommand("324", 0, CTYPE_SERVER, bot_getmodes, NULL); /* /MODE */
    addcommand("353", 0, CTYPE_SERVER, bot_names, NULL); /* /NAMES */
    addcommand("354", 0, CTYPE_SERVER, bot_whoreply, NULL); /* custom /WHO reply */
    addcommand("366", 0, CTYPE_SERVER, bot_endnames, NULL); /* End of /NAMES */
    addcommand("367", 0, CTYPE_SERVER, bot_getban, NULL); /* /MODE +b */
    addcommand("433", 0, CTYPE_SERVER, bot_nicktaken, NULL); /* nick "..." has been taken */

    /* Word "commands" here */
    addcommand("PRIVMSG", 0, CTYPE_SERVER, bot_privmsg, NULL);
    addcommand("MODE", 0, CTYPE_SERVER, bot_modemsg, NULL);
    addcommand("JOIN", 0, CTYPE_SERVER, bot_joinmsg, NULL);
    addcommand("PART", 0, CTYPE_SERVER, bot_partmsg, NULL);
    addcommand("QUIT", 0, CTYPE_SERVER, bot_quitmsg, NULL);
    addcommand("KICK", 0, CTYPE_SERVER, bot_kickmsg, NULL);
    addcommand("INVITE", 0, CTYPE_SERVER, bot_invitemsg, NULL);
    addcommand("NICK", 0, CTYPE_SERVER, bot_nickmsg, NULL);

    /* All done! */
}
Exemplo n.º 4
0
void addservercommand(void *module, const char *command, int (*function) (socket_info *, struct inputstruct *))
{
	servercommandlist = addcommand(module,servercommandlist, command, function, 99, 0);

}
Exemplo n.º 5
0
void addrwusrcommand(void *module, const char *command, int (*function)(const char *, struct userlist *, char *), int user_access ) {
	usercommandlist=addcommand(module, usercommandlist, command, function, user_access,cmd_param_rw);
}
Exemplo n.º 6
0
int
main(int argc, char **argv)
{
	char c;
	FILE *f;

	while ((c = getopt(argc, argv, "dhi:ns:")) != -1) {
		switch (c) {
		case 'd':
			debugmode = 1;
			break;
		case 'i':
			increment = strtol(optarg, NULL, 10);
			if (increment == 0)
				errx(1, "increment must be grater than 0");
			break;
		case 'n':
			noalloc = 1;
			break;
		case 's':
			startsize = strtol(optarg, NULL, 10);
			if (startsize == 0)
				errx(1, "startsize must be greater than 0");
			break;
		case 'h':
		default:
			usage();
		}
	}

	argc -= optind;
	argv += optind;

	if (argc > 1)
		usage();

	if (argc == 1) {
		if (argv[0][0] == '-' && argv[0][1] == '\0')
			f = stdin;
		else
			if ((f = fopen(argv[0], "r")) == NULL)
				err(1, "cannot open file `%s'", argv[0]);
	} else
		f = stdin;

	commands_size = startsize;
	commands = calloc(1, commands_size);

	if (commands == NULL)
		err(1, "cannot alloc commands array");

	data_size = startsize;
	data = ptr = calloc(1, data_size);

	if (data == NULL)
		err(1, "cannot alloc data memory");

	while ((c = fgetc(f)) != EOF)
		if (iscommand(c))
			addcommand(c);

	fclose(f);

	run();

	free(commands);
	free(data);

	return (0);
}