Exemple #1
0
int watch (int argc, char * argv []) {
    (void) argc;
    (void) argv;

	logi ("Running watch...");
    struct watcher * W = watch_init ();

    for (;;) {
        watch_update (W, sample_callback, NULL);
        sleep (1);
    }

    watch_del (W);

    return 0;
}
Exemple #2
0
bool grouppholder_init(WGroupPHolder *ph, WGroup *ws,
                       const WStacking *st,
                       const WGroupAttachParams *param)
{
    WRegion *stack_above=NULL;
    
    pholder_init(&(ph->ph));

    watch_init(&(ph->stack_above_watch));
    ph->next=NULL;
    ph->prev=NULL;
    ph->group=NULL;
    ph->recreate_pholder=NULL;
    ph->param=(param==NULL ? dummy_param : *param);

    if(st!=NULL){
        /* TODO? Just link to the stacking structure to remember 
         * stacking order? 
         */
        
        ph->param.szplcy_set=TRUE;
        ph->param.szplcy=st->szplcy;
        ph->param.level_set=TRUE;
        ph->param.level=st->level;
        
        if(st->reg!=NULL){
            ph->param.geom_set=TRUE;
            ph->param.geom=REGION_GEOM(st->reg);
        }
        
        if(st->above!=NULL && st->above->reg!=NULL)
            ph->param.stack_above=st->above->reg;
        
        ph->param.bottom=(st==ws->bottom);
    }
    
    ph->param.switchto_set=FALSE;
    
    stack_above=ph->param.stack_above;
    ph->param.stack_above=NULL;
    
    grouppholder_do_link(ph, ws, stack_above);
    
    return TRUE;
}
Exemple #3
0
static ObjList *mknode(void *obj)
{
    ObjList *node;
    
    if(obj==NULL)
        return NULL;
    
    node=ALLOC(ObjList);
    
    if(node==NULL)
        return FALSE;
        
    watch_init(&(node->watch));
    
    if(!watch_setup(&(node->watch), obj, watch_handler)){
        free(node);
        return NULL;
    }
    
    return node;
}
Exemple #4
0
int main(const int argc, const char * argv[]) {
    watch_t w;
    watch_init(&w);

    watch_callback_t wc = {
        .data = NULL,
        .func = NULL,
    };

    watch_add(&w, "/dev/mqueue", IN_CREATE | IN_ATTRIB, &wc);

    dispatch_t d;
    dispatch_init(&d);

    dispatch_callback_t dc = {
        .data = NULL,
        .func = callback,
    };

    dispatch_add(&d, watch_fileno(&w), EPOLLIN, &dc);
    dispatch_wait(&d);

    return 0;
}
Exemple #5
0
void plugin_init(G_GNUC_UNUSED GeanyData *gdata)
{
	GeanyKeyGroup *scope_key_group;
	char *gladefile = g_build_filename(PLUGINDATADIR, "scope.glade", NULL);
	GError *gerror = NULL;
	GtkWidget *menubar1 = find_widget(geany->main_widgets->window, "menubar1");
	guint item;
	const MenuKey *menu_key = debug_menu_keys;
	ToolItem *tool_item = toolbar_items;
	const ScopeCallback *scb;

	main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
	scope_key_group = plugin_set_key_group(geany_plugin, "scope", COUNT_KB, NULL);
	builder = gtk_builder_new();
	gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE);
	scp_tree_store_register_dynamic();

	if (!gtk_builder_add_from_file(builder, gladefile, &gerror))
	{
		msgwin_status_add(_("Scope: %s."), gerror->message);
		g_warning(_("Scope: %s."), gerror->message);
		g_error_free(gerror);
		g_object_unref(builder);
		builder = NULL;
	}

	g_free(gladefile);
	if (!builder)
		return;

	/* interface */
#ifndef G_OS_UNIX
	gtk_widget_hide(get_widget("terminal_show"));
#endif
	debug_item = get_widget("debug_item");
	if (menubar1)
		gtk_menu_shell_insert(GTK_MENU_SHELL(menubar1), debug_item, DEBUG_MENU_ITEM_POS);
	else
		gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), debug_item);

	menu_connect("debug_menu", &debug_menu_info, NULL);
	ui_add_document_sensitive(get_widget("scope_reset_markers"));
	ui_add_document_sensitive(get_widget("scope_cleanup_files"));

	for (item = 0; item < EVALUATE_KB; item++, menu_key++)
	{
		keybindings_set_item(scope_key_group, item, on_scope_key, 0, 0, menu_key->name,
			_(menu_key->label), debug_menu_items[item].widget);
	}

	geany_statusbar = GTK_STATUSBAR(gtk_widget_get_parent(geany->main_widgets->progressbar));
	debug_statusbar = get_widget("debug_statusbar");
	debug_state_label = GTK_LABEL(get_widget("debug_state_label"));
	gtk_box_pack_end(GTK_BOX(geany_statusbar), debug_statusbar, FALSE, FALSE, 0);

	debug_panel = get_widget("debug_panel");
	gtk_notebook_append_page(GTK_NOTEBOOK(geany->main_widgets->message_window_notebook),
		debug_panel, get_widget("debug_label"));

	/* startup */
	gtk216_init();
	program_init();
	prefs_init();
	conterm_init();
	inspect_init();
	register_init();
	parse_init();
	debug_init();
	views_init();
	thread_init();
	break_init();
	watch_init();
	stack_init();
	local_init();
	memory_init();
	menu_init();
	menu_set_popup_keybindings(scope_key_group, item);

	for (item = 0; tool_item->index != -1; item++, tool_item++)
	{
		GtkMenuItem *menu_item = GTK_MENU_ITEM(debug_menu_items[tool_item->index].widget);
		GtkToolItem *button = gtk_tool_button_new(NULL, gtk_menu_item_get_label(menu_item));

		gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(button),
			gtk_menu_item_get_use_underline(menu_item));
		g_signal_connect(button, "clicked", G_CALLBACK(on_toolbar_button_clicked),
			GINT_TO_POINTER(tool_item->index));
		g_signal_connect(button, "toolbar-reconfigured",
			G_CALLBACK(on_toolbar_reconfigured), tool_item);
		tool_item->widget = GTK_WIDGET(button);
		plugin_add_toolbar_item(geany_plugin, button);
	}

	toolbar_update_state(DS_INACTIVE);
	views_update_state(DS_INACTIVE);
	configure_toolbar();

	g_signal_connect(debug_panel, "switch-page", G_CALLBACK(on_view_changed), NULL);
	for (scb = scope_callbacks; scb->name; scb++)
		plugin_signal_connect(geany_plugin, NULL, scb->name, FALSE, scb->callback, NULL);
}
Exemple #6
0
int
main(int argc, char *argv[])
{
  /* Check to see if the user is running us as root, which is a nono */
  if (!geteuid())
  {
    fprintf(stderr, "ERROR: This server won't run as root/superuser\n");
    return -1;
  }

  /* Setup corefile size immediately after boot -kre */
  setup_corefile();

  /* Save server boot time right away, so getrusage works correctly */
  set_time();

  /* It's not random, but it ought to be a little harder to guess */
  init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));

  dlinkAdd(&me, &me.node, &global_client_list);

  ConfigGeneral.dpath      = DPATH;
  ConfigGeneral.spath      = SPATH;
  ConfigGeneral.mpath      = MPATH;
  ConfigGeneral.configfile = CPATH;    /* Server configuration file */
  ConfigGeneral.klinefile  = KPATH;    /* Server kline file         */
  ConfigGeneral.glinefile  = GPATH;    /* Server gline file         */
  ConfigGeneral.xlinefile  = XPATH;    /* Server xline file         */
  ConfigGeneral.dlinefile  = DLPATH;   /* dline file                */
  ConfigGeneral.resvfile   = RESVPATH; /* resv file                 */

  myargv = argv;
  umask(077);  /* umask 077: u=rwx,g=,o= */

  parseargs(&argc, &argv, myopts);

  if (printVersion)
  {
    printf("ircd: version %s(%s)\n", ircd_version, serno);
    exit(EXIT_SUCCESS);
  }

  if (chdir(ConfigGeneral.dpath))
  {
    perror("chdir");
    exit(EXIT_FAILURE);
  }

  ssl_init();

  if (!server_state.foreground)
  {
    make_daemon();
    close_standard_fds(); /* this needs to be before init_netio()! */
  }
  else
    print_startup(getpid());

  setup_signals();

  /* We need this to initialise the fd array before anything else */
  fdlist_init();
  log_set_file(LOG_TYPE_IRCD, 0, logFileName);

  init_netio();         /* This needs to be setup early ! -- adrian */

  /* Check if there is pidfile and daemon already running */
  check_pidfile(pidFileName);

  mp_pool_init();
  init_dlink_nodes();
  init_isupport();
  dbuf_init();
  hash_init();
  ipcache_init();
  client_init();
  class_init();
  whowas_init();
  watch_init();
  auth_init();          /* Initialise the auth code */
  init_resolver();      /* Needs to be setup before the io loop */
  modules_init();
  read_conf_files(1);   /* cold start init conf files */
  init_uid();
  initialize_server_capabs();   /* Set up default_server_capabs */
  initialize_global_set_options();  /* Has to be called after read_conf_files() */
  channel_init();
  read_links_file();
  motd_init();
  user_usermodes_init();
#ifdef HAVE_LIBGEOIP
  geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE);
#endif

  if (EmptyString(ConfigServerInfo.sid))
  {
    ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block.");
    exit(EXIT_FAILURE);
  }

  strlcpy(me.id, ConfigServerInfo.sid, sizeof(me.id));

  if (EmptyString(ConfigServerInfo.name))
  {
    ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block.");
    exit(EXIT_FAILURE);
  }

  strlcpy(me.name, ConfigServerInfo.name, sizeof(me.name));

  /* serverinfo{} description must exist.  If not, error out.*/
  if (EmptyString(ConfigServerInfo.description))
  {
    ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block.");
    exit(EXIT_FAILURE);
  }

  strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info));

  me.from = &me;
  me.servptr = &me;
  me.connection->lasttime = CurrentTime;
  me.connection->since = CurrentTime;
  me.connection->firsttime = CurrentTime;

  SetMe(&me);
  make_server(&me);

  hash_add_id(&me);
  hash_add_client(&me);

  dlinkAdd(&me, make_dlink_node(), &global_server_list);

  load_kline_database();
  load_dline_database();
  load_gline_database();
  load_xline_database();
  load_resv_database();

  load_all_modules(1);
  load_conf_modules();
  load_core_modules(1);

  write_pidfile(pidFileName);

  ilog(LOG_TYPE_IRCD, "Server Ready");

  event_addish(&event_cleanup_glines, NULL);
  event_addish(&event_cleanup_tklines, NULL);

  /* We want try_connections to be called as soon as possible now! -- adrian */
  /* No, 'cause after a restart it would cause all sorts of nick collides */
  event_addish(&event_try_connections, NULL);

  /* Setup the timeout check. I'll shift it later :)  -- adrian */
  event_add(&event_comm_checktimeouts, NULL);

  event_addish(&event_save_all_databases, NULL);

  if (ConfigServerHide.links_delay > 0)
  {
    event_write_links_file.when = ConfigServerHide.links_delay;
    event_addish(&event_write_links_file, NULL);
  }
  else
    ConfigServerHide.links_disabled = 1;

  if (splitmode)
    event_addish(&splitmode_event, NULL);

  io_loop();
  return 0;
}
int main(void)
{
	
	main_time.hours_h = 0;
	main_time.hours_l = 5;	
	main_time.minutes_l = 5;
	main_time.seconds_l = 5;
	
	counter_time.hours_h = 0;
	counter_time.hours_l = 0;
	counter_time.minutes_h = 0;
	counter_time.minutes_l = 0;
	counter_time.seconds_l = 0;
	counter_time.seconds_h = 0;
	
	uint8_t push_flag = 0;
	
	
	void port_init();
	watch_init();
	
	PORTA |= ((1 << PA1));
	_delay_ms(10);
	BIT_CLEAR(&PORTA, PA7);
	
	BIT_SET(&PORTA, PA6);
	
	PORTA &= ~((1 << PA1)); //reset
	
	
    while(1)		
    {			
		if (!(PIND & (1<<PD2)) && (PIND & (1<<PD3)))
		{
			_delay_ms(400);
			if (timer_flag == 1)
			{
				timer_flag = 0;
				timergo = 1;
			}
			else
			{
				timer_flag = 1;
			}
			
		}
		
		if (!(PIND & (1<<PD2)) && timer_flag == 1)
		{
			;
		}
		
		
		
		
		if (!(PIND & (1<<PD3)) && !(PIND & (1<<PD2)))
		{
			reset_flag = 0;
			_delay_ms(250);
			if (push_flag == 0)
			{
				if (set_clock_flag == 1)
				{
					set_clock_flag = 0;
				}
				else
				{
					set_clock_flag = 1;
				}
			}

			push_flag = 1;
		}
		else
		{
			push_flag = 0;
			if (set_clock_flag == 1 && !(PIND & (1<<PD3)) && (PIND & (1<<PD2)))
			{
				_delay_ms(150);
				main_time.minutes_l++;
				if (main_time.minutes_l > 9)
				{
					main_time.minutes_l = 0;
					main_time.minutes_h++;
					if (main_time.minutes_h > 5)
					{
						main_time.minutes_h = 0;
						main_time.hours_l++;
						
						if (((main_time.hours_l > 3) && (main_time.hours_h > 1)))
						{
							main_time.hours_h = 0;
							main_time.hours_l = 0;
						}
						if (main_time.hours_l > 9)
						{
							main_time.hours_l = 0;
							main_time.hours_h++;
						}
					}
				}
			}
			if (set_clock_flag == 1 && (PIND & (1<<PD3)) && !(PIND & (1<<PD2)))
			{
				_delay_ms(150);				
				main_time.hours_l++;
				if (((main_time.hours_l > 3) && (main_time.hours_h > 1)))
				{
					main_time.hours_h = 0;
					main_time.hours_l = 0;
				}
					if (main_time.hours_l > 9)
				{
					main_time.hours_l = 0;
					main_time.hours_h++;
				}				
			}
		}
		
    }
}