Beispiel #1
0
int rcptfilter_ctlmsg()
{
	std::string cmd=getcmd();

	std::cerr << "200 Ok" << std::endl;

	if (is_cmd(cmd.c_str(), "subscribe") ||
	    is_cmd(cmd.c_str(), "alias-subscribe"))
		return 99;

	return 0;
}
Beispiel #2
0
int smtpfilter_ctlmsg()
{
	std::string cmd=getcmd();
	std::string msg(readmsg());

	std::string addr;

	{
		const char *address_cstr;

		if ((address_cstr=is_cmd(cmd.c_str(), "subscribe")) != 0)
		{
			addr=returnaddr(msg, address_cstr);
		}
		else if ((address_cstr=is_cmd(cmd.c_str(), "alias-subscribe"))
			 != 0)
		{
			addr=extract_alias_to_subscribe(msg);
		}
		else
		{
			std::cerr << "200 Ok" << std::endl;
			return 0;
		}
	}

	uaddrlower(addr);

	if (cmdget_s("UNICODE") != "1")
	{
		std::string::const_iterator b=addr.begin(), e=addr.end();

		while (b != e)
		{
			if (*b & 0x80)
			{
				std::cerr << "550 This mailing list does not "
					"accept Unicode E-mail addresses, yet."
					  << std::endl;
				return EX_SOFTWARE;
			}
			++b;
		}
	}

	std::cerr << "200 Ok" << std::endl;
	return 0;
}
Beispiel #3
0
int		print_pkg(t_env *env, int cs, int ret)
{
	int		i;
	char	*tmp;

	tmp = NULL;
	if (env->fds[cs].buff_read[ret - 1] == '\n')
	{
		i = 0;
		save_char(env, cs, ret);
		if (is_cmd(env, cs) && env->fds[cs].channel != -1)
		{
			tmp = ft_strdup(env->fds[cs].nick);
			env->fds[cs].save = ft_joinfree(tmp, env->fds[cs].save, 3);
			while (i <= env->max_fd)
			{
				if ((env->fds[i].type == FD_CLIENT) && (i != cs)
					&& (env->fds[cs].channel == env->fds[i].channel))
					ft_strcat(env->fds[i].buff_write, env->fds[cs].save);
				i++;
			}
		}
		return (1);
	}
	else
		save_char(env, cs, ret);
	return (0);
}
static void process_cmd(char *p, unsigned char is_job)
{
    char cmd[64];
    int i = 0;
    char *p_saved = p;

    get_str(&p, cmd);

    /* table commands */
    while (console_cmd_list[i].name != NULL)
    {
        if (is_cmd(console_cmd_list[i].name))
        {
            
            if (!is_job && console_cmd_list[i].is_job)
            {
                
                create_cmdjob(p_saved);
            }
            else
            {
                console_cmd_list[i].handler(p);
            }
            return;
        }
        i++;
    }
    bdt_log("%s : unknown command\n", p_saved);
    do_help(NULL);
}
Beispiel #5
0
void		define_type_loop(t_liste *tmp, char **path)
{
  if (is_builtin(tmp->data) == 0)
    tmp->type = BUILTIN;
  else if (is_token(tmp->data) == 0)
    tmp->type = TOKEN;
  else if (is_separator(tmp->data) == 0)
    tmp->type = SEPARATOR;
  else if (is_cmd(tmp->data, path) == 0 || tmp->prev == NULL
    || tmp->prev->type == TOKEN)
    tmp->type = CMD;
  else
    tmp->type = OTHER;
}
Beispiel #6
0
int main(int argc, char** argv)
{
    FILE *file;
    char *filename;
    int status;

    if (argc < 2) {
        print_usage();
        return EXIT_SUCCESS;
    }

    if (is_cmd(argv[1])) {
        if (argc == 3) {
            filename = argv[2];
            file = fopen(filename, "r");
            if (file == NULL) {
                fprintf(stderr, "Cannot open file");
                return EXIT_FAILURE;
            }
        } else {
            filename = ":stdin:";
            file = stdin;
        }

        if (argv[1][0] == 'l') {
            status = cmd_lex(file, filename);
        } else {
            status = cmd_parse_expr(file, filename, argv[1]);
        }

        if (argc == 3) {
            fclose(file);
        }
        return status;
    }
    print_usage();
    return EXIT_SUCCESS;
}
Beispiel #7
0
static int innostore_drv_control(ErlDrvData handle, unsigned int cmd,
                              char* inbuf, int inbuf_sz,
                              char** outbuf, int outbuf_sz)
{
    PortState* state = (PortState*)handle;

    // Grab the worker lock.
    erl_drv_mutex_lock(state->worker_lock);

    assert(state->op == 0);

    // Verify that caller is not attempting cursor operation when no cursor is
    // active (or vice-versa)
    if (state->port_state == STATE_READY && is_cmd(CMD_CURSOR_OPS))
    {
        erl_drv_mutex_unlock(state->worker_lock);
        send_error_atom(state, "cursor_not_open");
        return 0;
    }
    else if (state->port_state == STATE_CURSOR && !is_cmd(CMD_CURSOR_OPS))
    {
        erl_drv_mutex_unlock(state->worker_lock);
        send_error_atom(state, "cursor_is_open");
        return 0;
    }

    // Copy inbuf into our work buffer
    if (inbuf_sz > 0)
    {
        state->work_buffer = driver_alloc(inbuf_sz);
        memcpy(state->work_buffer, inbuf, inbuf_sz);
    }

    // Select the appropriate async op
    switch (cmd)
    {
    case CMD_SET_CFG:
        state->op = &do_set_cfg;
        break;

    case CMD_START:
        state->op = &do_start;
        break;

    case CMD_INIT_TABLE:
        state->op = &do_init_table;
        break;

    case CMD_IS_STARTED:
        // Check the global state -- prior to doing that, release our worker lock
        // so as to avoid weird locking overlaps. Store the true/false value as
        // a single byte in outbuf. No need to do any allocation as the VM always
        // provides a 64-byte outbuf buffer by default.
        assert(outbuf_sz > 0);
        erl_drv_mutex_unlock(state->worker_lock);
        erl_drv_mutex_lock(G_ENGINE_STATE_LOCK);
        (*outbuf)[0] = (G_ENGINE_STATE == ENGINE_STARTED);
        erl_drv_mutex_unlock(G_ENGINE_STATE_LOCK);
        return 1;

    case CMD_GET:
        state->op = &do_get;
        break;

    case CMD_PUT:
        state->op = &do_put;
        break;

    case CMD_DELETE:
        state->op = &do_delete;
        break;

    case CMD_LIST_TABLES:
        state->op = &do_list_tables;
        break;

    case CMD_CURSOR_OPEN:
        state->op = &do_cursor_open;
        break;

    case CMD_CURSOR_MOVE:
        state->op = &do_cursor_move;
        break;

    case CMD_CURSOR_CLOSE:
        state->op = &do_cursor_close;
        break;

    case CMD_DROP_TABLE:
        state->op = &do_drop_table;
        break;

    case CMD_STATUS:
        state->op = &do_status;
        break;
    }

    // Signal the worker
    erl_drv_cond_signal(state->worker_cv);
    erl_drv_mutex_unlock(state->worker_lock);
    *outbuf = 0;
    return 0;
}