Пример #1
0
Файл: tester.c Проект: moul/junk
int	main(int ac, char **av)
{
  char	*ret;

  printf("[+] init\n");

  printf("[+] Add service test\n");
  service_add("test", test_service,
	      "super service de test qui sert a rien");
  printf("[+] Add service test\n");
  service_add("test2", test2_service,
	      "super service de test2 qui sert toujours a rien");

  printf("[+] List services\n");
  services_list();

  printf("[+] Call service test\n");
  ret = SERVICE_CALL("test", "bite [%s]\n", "bla");

  printf("[+] test return [%s]\n", ret);

  printf("[+] uninit\n");
  return (0);
  (void)ac;
  (void)av;
}
Пример #2
0
int main(const int argc, const char *argv[])
{
    event_set_log_callback(write_to_file_cb);
    event_enable_debug_mode();

    //log_level(LOG_DEBUG);
    log_fileline(LOG_FILELINE_ON);
    log_level(LOG_WARN);

    server_t *server = server_init(DEFAULT_PORT);

    if(server == NULL)
    {
        log_err(__FILE__, __LINE__, "Cannot init server.");
        exit(-1);
    }

    int power = 10;
    server->service_idx = service_index_init(power);
    char *str = NULL;

    str = calloc(sizeof(char), 5);
    memcpy(str, "aaaa", 4);
    service_t *aaaa = service_init(str);
    aaaa = service_add(server->service_idx, power, aaaa);

    server->service_first = aaaa;
    server->service_last  = aaaa;
    server->num_services++;

    str = calloc(sizeof(char), 5);
    memcpy(str, "bbbb", 4);
    service_t *bbbb = service_init(str);
    bbbb = service_add(server->service_idx, power, bbbb);

    aaaa->all_next = bbbb;
    server->service_last = bbbb;
    server->num_services++;

    str = calloc(sizeof(char), 5);
    memcpy(str, "cccc", 4);
    service_t *cccc = service_init(str);
    cccc = service_add(server->service_idx, power, cccc);

    bbbb->all_next = cccc;
    server->service_last = cccc;
    server->num_services++;

    server_event_run(server);

    return 0;
}
Пример #3
0
/**@brief Function for application main entry.
 */
int main(void)
{
    gpio_config();

    bool success = nrf6350_lcd_init();
    APP_ERROR_CHECK_BOOL(success);
    success = nrf6350_lcd_write_string("    BLE ANCS    ", MAX_CHARACTERS_PER_LINE, LCD_UPPER_LINE, 0);
    APP_ERROR_CHECK_BOOL(success);

    // Initialize.
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
    ble_stack_init();    
    bond_manager_init();
    gap_params_init();
    service_add();    
    advertising_init();
    conn_params_init();
    sec_params_init();
    radio_notification_init();
    
    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }

}
Пример #4
0
void _modinit(module_t *m)
{
	hook_add_event("user_identify");
	hook_add_user_identify(on_user_identify);

	hostsvs = service_add("hostserv", NULL, &conf_hs_table);
}
Пример #5
0
static int dev_configuration(struct net_device *dev)
{
        struct net_addr dst;
        struct service_id default_service;
        int ret;

        memset(&default_service, 0, sizeof(default_service));

        if (ifname && strcmp(dev->name, ifname) != 0)
                return 0;

        if (dev->flags & IFF_POINTOPOINT)
                ret = dev_get_ipv4_addr(dev, IFADDR_ADDRESS, &dst);
        else
                ret = dev_get_ipv4_addr(dev, IFADDR_BROADCAST, &dst);

        if (ret == 1) {
#if defined(ENABLE_DEBUG)
                {
                        char buf[16];
                        LOG_DBG("dev %s bc=%s\n", 
                                dev->name, 
                                inet_ntop(AF_INET, &dst, buf, 16));
                }
#endif
                service_add(&default_service, 0, SERVICE_RULE_FORWARD, 0, 
                            BROADCAST_SERVICE_DEFAULT_PRIORITY,
                            BROADCAST_SERVICE_DEFAULT_WEIGHT, 
                            &dst, sizeof(dst), make_dev_target(dev), 
                            GFP_ATOMIC);
        } 
        return ret;
}
Пример #6
0
void _modinit(module_t *m)
{
	chanfix_persist_record_t *rec = mowgli_global_storage_get("atheme.chanfix.main.persist");

	chanfix_gather_init(rec);

	if (rec != NULL)
	{
		free(rec);
		return;
	}

	chanfix = service_add("chanfix", NULL);
	service_bind_command(chanfix, &cmd_list);
	service_bind_command(chanfix, &cmd_chanfix);
	service_bind_command(chanfix, &cmd_scores);
	service_bind_command(chanfix, &cmd_info);
	service_bind_command(chanfix, &cmd_help);
	service_bind_command(chanfix, &cmd_mark);
	service_bind_command(chanfix, &cmd_nofix);

	hook_add_event("channel_can_register");
	hook_add_channel_can_register(chanfix_can_register);

	add_bool_conf_item("AUTOFIX", &chanfix->conf_table, 0, &chanfix_do_autofix, false);

	chanfix_autofix_timer = mowgli_timer_add(base_eventloop, "chanfix_autofix", chanfix_autofix_ev, NULL, 60);
}
Пример #7
0
void _modinit(module_t *m)
{
	funserv = service_add("funserv", NULL);

	service_bind_command(funserv, &funserv_requestbot);
	service_bind_command(funserv, &funserv_help);
}
Пример #8
0
void _modinit(module_t *m)
{
        hook_add_event("config_ready");
        hook_add_config_ready(nickserv_config_ready);

        hook_add_event("nick_check");
        hook_add_nick_check(nickserv_handle_nickchange);

	nicksvs.me = service_add("nickserv", nickserv, &ns_cmdtree, &conf_ni_table);
	authservice_loaded++;
}
Пример #9
0
void _modinit(module_t *m)
{
	hook_add_event("user_identify");
	hook_add_user_identify(on_user_identify);

	hook_add_event("user_away");
	hook_add_user_away(on_user_away);

	memosvs = service_add("memoserv", NULL);

	add_uint_conf_item("MAXMEMOS", &memosvs->conf_table, 0, &maxmemos, 1, INT_MAX, 30);
}
Пример #10
0
void _modinit(module_t *m)
{
	mygroups_init();
	groupsvs = service_add("groupserv", NULL, &conf_gs_table);
	add_uint_conf_item("MAXGROUPS", &conf_gs_table, 0, &maxgroups, 0, 65535, 5);
	add_uint_conf_item("MAXGROUPACS", &conf_gs_table, 0, &maxgroupacs, 0, 65535, 0);
	add_bool_conf_item("ENABLE_OPEN_GROUPS", &conf_gs_table, 0, &enable_open_groups, false);

	gs_db_init();
	gs_hooks_init();
	basecmds_init();
	set_init();
}
Пример #11
0
void _modinit(module_t *m)
{
	hook_add_event("user_identify");
	hook_add_user_identify(on_user_identify);
	hook_add_event("operserv_info");
	hook_add_operserv_info(osinfo_hook);

	hostsvs = service_add("hostserv", NULL);

	/* Minimum number of days between when users may reuse the HOSTSERV TAKE command to get another vhost. */
	add_uint_conf_item("REQUEST_TIME", &hostsvs->conf_table, 0, &hostsvs_req_time, 0, INT_MAX, 60);
	add_bool_conf_item("LIMIT_FIRST_REQUEST", &hostsvs->conf_table, 0, &hostsvs_limit_first_req, false);
}
Пример #12
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    // Initialize.
    app_trace_init();

    const app_uart_comm_params_t comm_params =
           {
               RX_PIN_NUMBER,
               TX_PIN_NUMBER,
               RTS_PIN_NUMBER,
               CTS_PIN_NUMBER,
               APP_UART_FLOW_CONTROL_ENABLED,
               false,
               UART_BAUDRATE_BAUDRATE_Baud38400
           };

    APP_UART_FIFO_INIT(&comm_params,
                          UART_RX_BUF_SIZE,
                          UART_TX_BUF_SIZE,
                          uart_error_handle,
                          APP_IRQ_PRIORITY_LOW,
                          err_code);
    APP_ERROR_CHECK(err_code);
                     
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
    APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
    ble_stack_init();
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), button_event_handler);
    APP_ERROR_CHECK(err_code);
    printf("BLE ANCS\n");
    device_manager_init();
    gap_params_init();
    service_add();
    advertising_init();
    conn_params_init();

    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }

}
void _modinit(module_t *m)
{
        loveserv = service_add("LoveServ", NULL);

	service_bind_command(loveserv, &ls_admirer);
	service_bind_command(loveserv, &ls_rose);
	service_bind_command(loveserv, &ls_chocolate);
	service_bind_command(loveserv, &ls_candy);
	service_bind_command(loveserv, &ls_hug);
	service_bind_command(loveserv, &ls_kiss);
	service_bind_command(loveserv, &ls_lovenote);
	service_bind_command(loveserv, &ls_apology);
	service_bind_command(loveserv, &ls_thankyou);
	service_bind_command(loveserv, &ls_spank);
	service_bind_command(loveserv, &ls_chocobo);
	service_bind_command(loveserv, &ls_help);
}
Пример #14
0
/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    bool is_notification_mode    = false;
    bool is_non_connectable_mode = false;

    timers_init();

    APP_GPIOTE_INIT(1);
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);
#if BUTTONS_NUMBER > 2

    // Check button states.
    // Notification Start button.
    err_code = bsp_button_is_pressed(NOTIF_BUTTON_ID, &(is_notification_mode));
    APP_ERROR_CHECK(err_code);
    // Non-connectable advertisement start button.
    if (!is_notification_mode)
    {
        err_code = bsp_button_is_pressed(NON_CONN_ADV_BUTTON_ID, &(is_non_connectable_mode));
        APP_ERROR_CHECK(err_code);
    }
    // Un-configured button.
    else
    {
    }

#else
    is_notification_mode = true;
#endif

    // Initialize SoftDevice.
    ble_stack_init();

    if (!is_notification_mode && !is_non_connectable_mode)
    {
        // The startup was not because of button presses. This is the first start. 
        // Go into System-Off mode. Button presses will wake the chip up.
        err_code = sd_power_system_off();  
        APP_ERROR_CHECK(err_code);
    }
    
    // If we reach this point, the application was woken up by pressing one of the two configured
    // buttons.
    gap_params_init();

    if (is_notification_mode)
    {
        // Notification button is pressed. Start connectable advertisement.
        connectable_adv_init();
        service_add();
    }
    else
    {
        non_connectable_adv_init();
    }
    
    advertising_data_init();
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Пример #15
0
Файл: main.c Проект: alyx/atheme
/*
 * Copyright (c) 2005 Atheme Development Group
 * Rights to this code are documented in doc/LICENSE.
 *
 * This file contains the main() routine.
 */

#include "atheme.h"

service_t *gs;

static void
mod_init(module_t *const restrict m)
{
	gs = service_add("gameserv", NULL);
}

static void
mod_deinit(const module_unload_intent_t intent)
{
        if (gs != NULL)
                service_delete(gs);
}

SIMPLE_DECLARE_MODULE_V1("gameserv/main", MODULE_UNLOAD_CAPABILITY_OK)
Пример #16
0
void _modinit(module_t * m)
{
    statsvs = service_add("statserv", NULL);
    service_named_bind_command("statserv", &ss_help);
}
Пример #17
0
void _modinit(module_t *m)
{
  siteserv = service_add("siteserv", NULL);

  service_bind_command(siteserv, &siteserv_help);
}
Пример #18
0
/**@brief Function for application main entry.
 */
int main(void)
{
    bool is_notification_mode    = false;
    bool is_non_connectable_mode = false;

    buttons_init();

    // Check button states.
    // Notification Start button.
    if (nrf_gpio_pin_read(NOTIF_BUTTON_PIN_NO) == 0)
    {
        is_notification_mode = true;
    }
    // Non-connectable advertisement start button.
    else if (nrf_gpio_pin_read(NON_CONN_ADV_BUTTON_PIN_NO) == 0)
    {
        is_non_connectable_mode = true;
    }
    // Un-configured button.
    else
    {
    }

    // Initialize SoftDevice.
    ble_stack_init();

    if (!is_notification_mode && !is_non_connectable_mode)
    {
        uint32_t err_code;

        // The startup was not because of button presses. This is the first start.
        // Go into System-Off mode. Button presses will wake the chip up.
        err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
    }

    // If we reach this point, the application was woken up by pressing one of the two configured
    // buttons.

    timers_init();
    gap_params_init();

    if (is_notification_mode)
    {
        // Notification button is pressed. Start connectable advertisement.
        connectable_adv_init();
        service_add();
    }
    else
    {
        non_connectable_adv_init();
    }

    advertising_data_init();
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Пример #19
0
void _modinit(module_t *m)
{
        opersvs = service_add("operserv", NULL);
}
Пример #20
0
Файл: main.c Проект: alyx/atheme
/* main.c - rpgserv main() routine.
 * based on elly's rpgserv for atheme-6.x --nenolod
 */

#include "atheme.h"

service_t *rpgserv;

static void
mod_init(module_t *const restrict m)
{
	rpgserv = service_add("rpgserv", NULL);
}

static void
mod_deinit(const module_unload_intent_t intent)
{
	if (rpgserv) {
		service_delete(rpgserv);
		rpgserv = NULL;
	}
}

SIMPLE_DECLARE_MODULE_V1("rpgserv/main", MODULE_UNLOAD_CAPABILITY_OK)
Пример #21
0
static int ctrl_handle_add_service_msg(struct ctrlmsg *cm, int peer)
{
        struct ctrlmsg_service *cmr = (struct ctrlmsg_service *)cm;
        unsigned int num_res = CTRLMSG_SERVICE_NUM(cmr);
        /* TODO - flags, etc */
        unsigned int i, index = 0;
        int err = 0;

        LOG_DBG("adding %u services, msg size %u\n", 
                num_res, CTRLMSG_SERVICE_LEN(cmr));
        
        for (i = 0; i < num_res; i++) {
                struct net_device *dev = NULL;
                struct service_info *entry = &cmr->service[i];
                unsigned short prefix_bits = SERVICE_ID_MAX_PREFIX_BITS;

                if (entry->type == SERVICE_RULE_FORWARD) {
                        dev = resolve_dev(entry);
                        
                        if (!dev)
                                continue;
                }

                if (entry->srvid_prefix_bits > 0)
                        prefix_bits = entry->srvid_prefix_bits;
         
#if defined(ENABLE_DEBUG)
                {
                        char ipstr[18];
                        LOG_DBG("Adding service id: %s(%u) "
                                "@ address %s, priority %u, weight %u\n", 
                                service_id_to_str(&entry->srvid), 
                                prefix_bits, 
                                inet_ntop(AF_INET, &entry->address,
                                          ipstr, sizeof(ipstr)),
                                entry->priority, entry->weight);
                }
#endif
                err = service_add(&entry->srvid, 
                                  prefix_bits, 
                                  entry->type,
                                  entry->srvid_flags, 
                                  entry->priority, 
                                  entry->weight,
                                  &entry->address, 
                                  sizeof(entry->address),
                                  make_target(dev), GFP_KERNEL);
                if (dev)
                        dev_put(dev);

                if (err > 0) {
                        if (index < i) {
                                /* copy it over */
                                memcpy(&cmr->service[index], 
                                       entry, sizeof(*entry));
                        }
                        index++;
                } else {
                        LOG_ERR("Error adding service %s: err=%d\n", 
                                service_id_to_str(&entry->srvid), err);
                }
        }

        if (index == 0) {
                /* Just return the original request with a return value */
                cm->retval = CTRLMSG_RETVAL_NOENTRY;
        } else {
                /* Return the entries added */
                cm->retval = CTRLMSG_RETVAL_OK;
                cm->len = CTRLMSG_SERVICE_NUM_LEN(index);
        }

        ctrl_sendmsg(cm, peer, GFP_KERNEL);

        return 0;
}
Пример #22
0
int main( int argc, char * argv[], char * envp[] )
{

#ifdef WIN32

	//
	// initialize winsock
	//

	WORD	reqver;
	WSADATA	wsadata;
	memset( &wsadata, 0, sizeof( wsadata ) );

	reqver = MAKEWORD( 1, 1 );
	if( WSAStartup( reqver, &wsadata ) )
	{
		printf( "wsastartup failed\n" );
		return false;
	}

	//
	// check command line parameters
	//

	bool service = false;

	for( long count = 1; count < argc; count++ )
	{
		if( !strcmp( argv[ count ], "-service" ) )
			service = true;

		if( !strcmp( argv[ count ], "-register" ) )
		{
			service_add( argv[ 0 ] );
			return 0;
		}

		if( !strcmp( argv[ count ], "-deregister" ) )
		{
			service_del( argv[ 0 ] );
			return 0;
		}
	}

	//
	// are we running as a service
	// or a foreground application
	//

	if( service )
	{
		//
		// running as a service
		//

		SERVICE_TABLE_ENTRY	ste[ 2 ];
		
		ste[ 0 ].lpServiceName = SERVICE_NAME;
		ste[ 0 ].lpServiceProc = service_main;
		ste[ 1 ].lpServiceName = NULL;
		ste[ 1 ].lpServiceProc = NULL;
		
		if( !StartServiceCtrlDispatcher( ste ) )
			printf( "ii : StartServiceCtrlDispatcher error = %d\n", GetLastError() );
	}
	else
	{
		//
		// running as an application
		//

		if( iked.init( 0 ) != LIBIKE_OK )
			return false;

		//
		// run daemon main loop
		//

		iked.loop();
	}

	//
	// release winsock
	//

	WSACleanup(); 

#endif

#ifdef UNIX

	//
	// check that we are root
	//

	if( getuid() )
	{
		printf( "you must be root to run this program !!!\n" );
		return LIBIKE_FAILED;
	}

	//
	// check command line parameters
	//

	char path_conf[ MAX_PATH ] = { 0 };
	char path_log[ MAX_PATH ] = { 0 };
	char path_pid[ MAX_PATH ] = { 0 };
	bool service = true;
	long debuglevel = 0;

	for( long argi = 1; argi < argc; argi++ )
	{
		if( !strcmp( argv[ argi ], "-F" ) )
		{
			service = false;
			continue;
		}

		if( !strcmp( argv[ argi ], "-p" ) )
		{
			if( ( argc - argi ) < 2 )
			{
				printf( "you must specify a path following the -p option\n" );
				return -1;
			}

			strncpy( path_pid, argv[ ++argi ], MAX_PATH );

			continue;
		}

		if( !strcmp( argv[ argi ], "-f" ) )
		{
			if( ( argc - argi ) < 2 )
			{
				printf( "you must specify a path following the -f option\n" );
				return -1;
			}

			strncpy( path_conf, argv[ ++argi ], MAX_PATH );

			continue;
		}

		if( !strcmp( argv[ argi ], "-l" ) )
		{
			if( ( argc - argi ) < 2 )
			{
				printf( "you must specify a path following the -l option\n" );
				return -1;
			}

			strncpy( path_log, argv[ ++argi ], MAX_PATH );

			continue;
		}

		if( !strcmp( argv[ argi ], "-d" ) )
		{
			if( ( argc - argi ) < 2 )
			{
				printf( "you must specify a debug level between 0 and 6 following the -d option\n" );
				return -1;
			}

			debuglevel = atol( argv[ ++argi ] );
			if ( ( debuglevel < 0 ) || (debuglevel > 6) )
			{
				printf( "you must specify a debug level between 0 and 6 following the -d option\n" );
				return -1;
			}

			continue;
		}

		printf( "invalid option %s specified\n", argv[ argi ] );
		return -1;
	}

	//
	// setup stop signal
	//

	signal( SIGINT, daemon_stop );
	signal( SIGTERM, daemon_stop );
	signal( SIGPIPE, SIG_IGN );

	//
	// set config and log file paths
	//

	iked.set_files( path_conf, path_log );

	//
	// initialize
	//

	if( iked.init( debuglevel ) != LIBIKE_OK )
		return -1;

	//
	// are we running as a deamon
	//

	if( service )
		daemon( 0, 0 );

	//
	// create our pid file
	//

	if( path_pid[ 0 ] )
		if( !daemon_pidfile_create( path_pid ) )
			return -1;

	//
	// run daemon main loop
	//

	iked.loop();

	//
	// remove our pidfile
	//

	if( path_pid[ 0 ] )
		daemon_pidfile_remove( path_pid );

#endif

	return 0;
}
Пример #23
0
void _modinit(module_t *m)
{
	proxyscan = service_add("proxyscan", NULL);
}