Beispiel #1
0
/**
 * Initialize IPC stuff
 *
 * @return zero on success, non-zero otherwise
 */
int
wt_ipc_init (void)
{
  read_config ();

  if (blacklisting)
    {
      if (ipc_blacklist_init (blacklist_file, reset_timeout))
        {
          blacklisting_error = TRUE;
          return -1;
        }
    }

  if (ipc_init (host, port))
    {
      return -1;
    }

  ipc_enabled = TRUE;

  hook_register (CORE_ACTIVATE, wt_ipc_start, 0, HOOK_PRIORITY_NORMAL);
  hook_register (CORE_DEACTIVATE, wt_ipc_stop, 0, HOOK_PRIORITY_NORMAL);

  mutex = mutex_create ();

  wt_ipc_builtin_init ();

  return 0;
}
Beispiel #2
0
/* -------------------------------------------------------------------------- *
 * Module hooks                                                               *
 * -------------------------------------------------------------------------- */
int lc_cookie_load(void)
{
  if(hook_register(lclient_login, HOOK_DEFAULT, lc_cookie_hook) == NULL)
    return -1;

  hook_register(lclient_release, HOOK_DEFAULT, lc_cookie_release);

  lc_cookie_seed = timer_mtime;

  lc_cookie_msg = msg_find("PONG");

  if(lc_cookie_msg == NULL)
  {
    log(lclient_log, L_warning, "You need to load m_pong.so before this module");

    return -1;
  }

  lc_cookie_msg->handlers[MSG_UNREGISTERED] = mr_pong;

  mem_static_create(&lc_cookie_heap, sizeof(struct lc_cookie),
                    LCLIENT_BLOCK_SIZE / 4);
  mem_static_note(&lc_cookie_heap, "cookie heap");

  return 0;
}
Beispiel #3
0
/* -------------------------------------------------------------------------- *
 * Module hooks                                                               *
 * -------------------------------------------------------------------------- */
int um_operator_load(void)
{
  if(usermode_register(&um_operator))
    return -1;

  hook_register(oper_up, HOOK_DEFAULT, um_oper_up_hook);
  hook_register(user_whois, HOOK_DEFAULT, um_oper_whois_hook);

  return 0;
}
Beispiel #4
0
/* -------------------------------------------------------------------------- *
 * Module hooks                                                               *
 * -------------------------------------------------------------------------- */
int cm_op_load(void)
{
    /* register the channel mode */
    if(chanmode_register(&cm_op_mode) == NULL)
        return -1;

    hook_register(channel_join, HOOK_2ND, cm_op_hook);
    hook_register(chanuser_kick, HOOK_DEFAULT, cm_op_kick);

    return 0;
}
Beispiel #5
0
int main()
{
	test(hook_register("hook1", "callback1", callback1));
	test(hook_register("hook1", "callback1", callback1));
	test(hook_register("hook1", "callback2", callback2));
	test(hook_register("hook1", "callback2", callback2));
	test(hook_unregister("hook1", "callback1"));
	test(hook_unregister("hook1", "callback1"));
	test(hook_unregister("hook1", "callback2"));
	test(hook_unregister("hook1", "callback2"));
	test(hook_register("hook1", "callback1", callback1));
	test(hook_register("hook1", "callback1", callback1));
	test(hook_register("hook1", "callback2", callback2));
	test(hook_register("hook1", "callback2", callback2));

	gds_slist_node_t *returns = NULL;
	hook_invoke("hook1", &returns, 1, 2, 3);
	gds_iterator_t *it = gds_slist_iterator_new(returns);
	gds_iterator_reset(it);
	while (!gds_iterator_step(it)) {
		void *data = gds_iterator_get(it);
		printf("%p\n", data);
	}
	gds_iterator_free(it);
	gds_slist_free(returns, NULL);

	return 0;
}
Beispiel #6
0
/* -------------------------------------------------------------------------- *
 * Module hooks                                                               *
 * -------------------------------------------------------------------------- */
int cm_noext_load(void)
{
  /* register the channel mode */
  if(chanmode_register(&cm_noext_mode) == NULL)
    return -1;

  hook_register(channel_message, HOOK_DEFAULT, cm_noext_hook);

  return 0;
}
Beispiel #7
0
/* -------------------------------------------------------------------------- *
 * Module hooks                                                               *
 * -------------------------------------------------------------------------- */
int cm_ban_load(void)
{
  /* register the channel mode */
  if(chanmode_register(&cm_ban_mode) == NULL)
    return -1;

  /* register a hook in channel_join */
  hook_register(channel_join, HOOK_DEFAULT, cm_ban_hook);

  return 0;
}
Beispiel #8
0
/* -------------------------------------------------------------------------- *
 * Module hooks                                                               *
 * -------------------------------------------------------------------------- */
int m_nclock_load(void)
{
  if(msg_register(&ms_nclock_msg) == NULL)
    return -1;

  hook_register(server_login, HOOK_DEFAULT, ms_nclock_hook);

  server_default_caps |= CAP_CLK;

  return 0;
}
Beispiel #9
0
/**
 * Creates a copy of the provided hook. The hook is allowed to be NULL,
 * in which case this function simply returns a NULL.
 *
 * @param hook
 * @return A copy of the hook, or NULL (if the provided hook was NULL
 *         or, if it wasn't, if there was a memory allocation problem while
 *         constructing a copy).
 */
htp_hook_t * hook_copy(htp_hook_t *hook) {
    if (hook == NULL) return NULL;

    htp_hook_t *copy = hook_create();
    if (copy == NULL) return NULL;

    htp_callback_t *callback = NULL;
    list_iterator_reset(hook->callbacks);
    while ((callback = list_iterator_next(hook->callbacks)) != NULL) {
        if (hook_register(&copy, callback->fn) < 0) {
            hook_destroy(copy);
            return NULL;
        }
    }

    return copy;
}
Beispiel #10
0
/**
 * Registers a request callback.
 *
 * @param cfg
 * @param callback_fn 
 */
void htp_config_register_response(htp_cfg_t *cfg, int (*callback_fn)(htp_connp_t *)) {
    hook_register(&cfg->hook_response, callback_fn);
}
Beispiel #11
0
/**
 * Registers a transaction_start callback.
 * 
 * @param cfg
 * @param callback_fn 
 */
void htp_config_register_transaction_start(htp_cfg_t *cfg, int (*callback_fn)(htp_connp_t *)) {
    hook_register(&cfg->hook_transaction_start, callback_fn);
}
void register_checkpoint_hooks(void)
{
	hook_register(&krg_handler[KRG_SIG_CHECKPOINT], krg_task_checkpoint);
}
Beispiel #13
0
/**
 *
 * Initialize Tcl embed library
 *
 * @return TCL_OK if successful, TCL_ERROR otherwise
 */
int
tcllib_init (void)
{
  /* NOTE: Keep order, config.tcl be loaded last */
  static wchar_t *important_files[] = { L"associations.tcl",
                                        L"config.tcl" };
  /* static wchar_t *unimportant_files[] = { L"custom.tcl" }; */
  int i, j, count;
  wchar_t **list;

  interpreter = Tcl_CreateInterp();
  if (interpreter == NULL)
    {
      return TCL_ERROR;
    }

  if (tcllib_init_commands (interpreter) != TCL_OK)
    {
      return TCL_ERROR;
    }

  for  (i = 0; i < sizeof (important_files) / sizeof (important_files[0]); ++i)
    {
      count = get_shared_files (important_files[i], NULL, &list);

      if (count == 0)
        {
          wchar_t msg[1024];
          swprintf (msg, BUF_LEN (msg),
                    _(L"Configuration file \"%ls\" not found"),
                    important_files[i]);
          MESSAGE_ERROR (msg);
          return TCL_ERROR;
        }

      for (j = 0; j < count; ++j)
        {
          if (tcllib_load_file (list[j]) != TCL_OK)
            {
              TCL_RUNTIME_ERROR;

              /* Free memory used by unseen items */
              while (j < count)
                {
                  SAFE_FREE (list[j]);
                  ++j;
                }
              SAFE_FREE (list);

              return TCL_ERROR;
            }
          SAFE_FREE (list[j]);
        }

      SAFE_FREE (list);
    }

  hook_register (L"open-file-hook", _file_associations_hook, 1);

  return TCL_OK;
}
Beispiel #14
0
/**
 * Registers a request_uri_normalize callback.
 *
 * @param cfg
 * @param callback_fn 
 */
void htp_config_register_request_uri_normalize(htp_cfg_t *cfg, int (*callback_fn)(htp_connp_t *)) {
    hook_register(&cfg->hook_request_uri_normalize, callback_fn);
}
Beispiel #15
0
/**
 * Registers a callback that is invoked every time there is a log message.
 *
 * @param cfg
 * @param callback_fn
 */
void htp_config_register_log(htp_cfg_t *cfg, int (*callback_fn)(htp_log_t *)) {
    hook_register(&cfg->hook_log, callback_fn);
}
Beispiel #16
0
/**
 * Registers a request_body_data callback.
 *
 * @param cfg
 * @param callback_fn 
 */
void htp_config_register_response_body_data(htp_cfg_t *cfg, int (*callback_fn)(htp_tx_data_t *)) {
    hook_register(&cfg->hook_response_body_data, callback_fn);
}
Beispiel #17
0
/**
 * Registers a request callback.
 *
 * @param cfg
 * @param callback_fn 
 */
void htp_config_register_request(htp_cfg_t *cfg, int (*callback_fn)(htp_connp_t *)) {
    hook_register(&cfg->hook_request, callback_fn);
}