Exemplo n.º 1
0
/* in response to a TOPIC message from the server */
static void p_topic(char *from, char **ArgList)
{
    struct channel *tmp;

    if (!ArgList[1]) {
	fake();
	return;
    }
    tmp = lookup_channel(ArgList[0], from_server, CHAN_NOUNLINK);
    malloc_strcpy(&tmp->topic, ArgList[1]);
    if (check_ignore(from, FromUserHost, tmp->channel, IGNORE_TOPICS | IGNORE_CRAP, NULL) != IGNORED) {
	message_from(ArgList[0], LOG_CRAP);
	if (do_hook(TOPIC_LIST, "%s %s %s", from, ArgList[0], ArgList[1])) {
	    if (ArgList[1] && *ArgList[1]) {
		if (get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET))
		    put_it("%s",
			   convert_output_format(get_format(FORMAT_TOPIC_CHANGE_HEADER_FSET), "%s %s %s %s", update_clock(GET_TIME),
						 from, ArgList[0], ArgList[1]));
		put_it("%s",
		       convert_output_format(get_format(FORMAT_TOPIC_CHANGE_FSET), "%s %s %s %s", update_clock(GET_TIME), from,
					     ArgList[0], ArgList[1]));
	    } else
		put_it("%s",
		       convert_output_format(get_format(FORMAT_TOPIC_UNSET_FSET), "%s %s %s", update_clock(GET_TIME), from,
					     ArgList[0]));
	}

	message_from(NULL, LOG_CRAP);
    }
    update_all_status(curr_scr_win, NULL, 0);
}
Exemplo n.º 2
0
static	void parse_server_notice(char *from, char *line)
{
	int	flag = 0;
	int	up_status = 0;
const	char	*f;	
				
	f = from;
	if (!f || !*f)
		if (!(f = get_server_itsname(from_server)))
			f = get_server_name(from_server);
			
	if (*line != '*'  && *line != '#' && strncmp(line, "MOTD ", 4))
		flag = 1;
	else
		flag = 0;

	if (do_hook(SERVER_NOTICE_LIST, flag?"%s *** %s":"%s %s", f, line))
	{
#ifdef WANT_OPERVIEW
		if (handle_oper_vision(f, line, &up_status))
			reset_display_target();
		else 
#endif
		if (strstr(line, "***"))
		{
			set_display_target(NULL, LOG_SNOTE);
#ifdef WANT_OPERVIEW
			if (get_int_var(OV_VAR) && !(get_server_ircop_flags(from_server) & SERVER_CRAP))
				goto done1;
#endif
			if (do_hook(SERVER_NOTICE_LIST, flag ? "%s *** %s" : "%s %s", f, line))
			{
				char *for_;
				for_ = next_arg(line,&line);
				serversay(1, from_server, "%s", 
				convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), 
				f, stripansicodes(line)));
				add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line);
			}
		}
		else
		{
			set_display_target(NULL, LOG_SNOTE);
#ifdef WANT_OPERVIEW
			if (get_int_var(OV_VAR) && !(get_server_ircop_flags(from_server) & SERVER_CRAP))
				goto done1;
#endif
			if (do_hook(SERVER_NOTICE_LIST, flag ? "%s *** %s" : "%s %s", f, line))
				serversay(1, from_server, "%s", 
				convert_output_format(fget_string_var(FORMAT_SERVER_NOTICE_FSET), "%s %s %s", update_clock(GET_TIME), 
				f, stripansicodes(line)));
			add_last_type(&last_servermsg[0], MAX_LAST_MSG, NULL, NULL, NULL, line);
		}
	}
	if (up_status)
		update_all_status(current_window, NULL, 0);
done1:
	reset_display_target();
}
Exemplo n.º 3
0
static void init_system()
{
	cur_sale = make_new_sale(1);
	cursor_hide();
	init_clock();
	update_clock();
}
Exemplo n.º 4
0
/*
 * Process clockface
 */
static void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {

  #ifndef TESTING_MEMORY_LEAK
    // Only update the date if the day has changed
    if (tick_time->tm_mday != previous_mday) {
      strftime(date_text, sizeof(date_text), DATE_FORMAT, tick_time);
      if (!icon_state[IS_ALARM])
        text_layer_set_text(ui.text_date_smart_alarm_range_layer, date_text);
      previous_mday = tick_time->tm_mday;
    }
  #else
    // Use the line to show heap space in testing mode
    snprintf(date_text, sizeof(date_text), "%d", heap_bytes_free());
    text_layer_set_text(text_date_smart_alarm_range_layer, date_text);
  #endif

  // Perform all background processing
  uint16_t last_movement;
  if (is_animation_complete()) {
    last_movement = every_minute_processing();
  } else {
    last_movement = CLOCK_UPDATE_THRESHOLD;
  }
  
  // Do the power nap countdown
  power_nap_countdown();

  // Only update the clock every five minutes unless awake
  if (last_movement >= CLOCK_UPDATE_THRESHOLD || (tick_time->tm_min % 5 == 0)) {
    update_clock();
  }
}
Exemplo n.º 5
0
/* forces everything on screen to be redrawn -- perfect for keeping track of settings! */
void forceScreenRedraw() {
  // maybe the colors changed!
  for(int i = 0; i < 4; i++) {
    ClockDigit_setColor(&clockDigits[i], globalSettings.timeColor, globalSettings.timeBgColor);
  }

  window_set_background_color(mainWindow, globalSettings.timeBgColor);

  // or maybe the sidebar position changed!
  if(globalSettings.sidebarOnRight) {
    layer_set_frame(sidebarLayer, GRect(114, 0, 30, 168));

    for(int i = 0; i < 4; i++) {
      ClockDigit_offsetPosition(&clockDigits[i], 0);
    }
  } else {
    layer_set_frame(sidebarLayer, GRect(0, 0, 30, 168));

    for(int i = 0; i < 4; i++) {
      ClockDigit_offsetPosition(&clockDigits[i], 30);
    }
  }

  // maybe the language changed!
  update_clock();
}
Exemplo n.º 6
0
static void main_window_load(Window *window) {

  #ifdef PBL_ROUND
    GPoint digitPoints[4] = {GPoint(40, 17), GPoint(90, 17), GPoint(40, 92), GPoint(90, 92)};
  #else
    GPoint digitPoints[4] = {GPoint(7, 7), GPoint(60, 7), GPoint(7, 90), GPoint(60, 90)};
  #endif

  ClockDigit_construct(&clockDigits[0], digitPoints[0]);
  ClockDigit_construct(&clockDigits[1], digitPoints[1]);
  ClockDigit_construct(&clockDigits[2], digitPoints[2]);
  ClockDigit_construct(&clockDigits[3], digitPoints[3]);

  for(int i = 0; i < 4; i++) {
    ClockDigit_setColor(&clockDigits[i], globalSettings.timeColor, globalSettings.timeBgColor);
    layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(clockDigits[i].imageLayer));
  }

  window_set_background_color(window, globalSettings.timeBgColor);

  // create the sidebar
  Sidebar_init(window);

  // Make sure the time is displayed from the start
  redrawScreen();
  update_clock();
}
Exemplo n.º 7
0
Arquivo: vars.c Projeto: jnbek/TekNap
static void set_clock_format (Window *win, char *value, int unused)
{
	extern char *time_format; /* XXXX bogus XXXX */
	malloc_strcpy(&time_format, value);
	update_clock(RESET_TIME);
	update_all_status(current_window, NULL, 0);
}
Exemplo n.º 8
0
static void p_part(char *from, char **ArgList)
{
    char *channel;

    if (!from || !*from)
	return;
    channel = ArgList[0];

    PasteArgs(ArgList, 1);
    message_from(channel, LOG_CRAP);
    in_on_who = 1;

    if ((check_ignore(from, FromUserHost, channel, IGNORE_PARTS | IGNORE_CRAP, NULL) != IGNORED) &&
	do_hook(LEAVE_LIST, "%s %s %s %s", from, channel, FromUserHost, ArgList[1] ? ArgList[1] : empty_str))
	put_it("%s",
	       convert_output_format(get_format(FORMAT_LEAVE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost,
				     channel, ArgList[1] ? ArgList[1] : empty_str));
    if (!my_stricmp(from, get_server_nickname(from_server))) {
	remove_channel(channel, from_server);
	remove_from_mode_list(channel, from_server);
	remove_from_join_list(channel, from_server);
	set_input_prompt(curr_scr_win, get_string_var(INPUT_PROMPT_VAR), 0);
    } else {
	remove_from_channel(channel, from, from_server, 0, NULL);
    }
    update_all_status(curr_scr_win, NULL, 0);
    update_input(UPDATE_ALL);
    message_from(NULL, LOG_CRAP);
    in_on_who = 0;
}
static void
on_schema_change (GSettings *schema,
                  const char *key,
                  gpointer user_data)
{
	g_debug ("Updating clock because schema changed");
	update_clock (user_data);
}
Exemplo n.º 10
0
void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  // every 30 minutes, request new weather data
  if(tick_time->tm_min % 30 == 0) {
    messaging_requestNewWeatherData();
  }

  update_clock();
}
Exemplo n.º 11
0
static void p_silence(char *from, char **ArgList)
{
    char *target = ArgList[0];
    char *mag = target++;

    if (do_hook(SILENCE_LIST, "%c %s", *mag, target))
	put_it("%s", convert_output_format(get_format(FORMAT_SILENCE_FSET), "%s %c %s", update_clock(GET_TIME), *mag, target));
}
Exemplo n.º 12
0
void TimeBar::update(int flush)
{
	draw_time();
// Need to redo these when range is drawn to get the background updated.
	update_labels();
	update_points();


 	EDL *edl = get_edl();
	int64_t pixel = -1;

// Draw highlight position
	if(edl &&
		(highlighted || current_operation == TIMEBAR_DRAG) &&
		get_cursor_x() >= 0 &&
		get_cursor_y() < get_w())
	{
//printf("TimeBar::update %d %d\n", __LINE__, get_cursor_x());
		double position = pixel_to_position(get_cursor_x());

		position = get_edl()->align_to_frame(position, 0);
		pixel = position_to_pixel(position);
		update_clock(position);
	}

	if(pixel < 0) 
	{
		double position = test_highlight();
		if(position >= 0) pixel = position_to_pixel(position);
	}


	if(pixel >= 0 && pixel < get_w())
	{
		set_color(mwindow->theme->timebar_cursor_color);
		set_line_dashes(1);
//printf("TimeBar::update %d pane=%d pixel=%jd\n", __LINE__, pane->number, pixel);
		draw_line(pixel, 0, pixel, get_h());
		set_line_dashes(0);
	}
	

 	if(edl)
 	{
 		int64_t pixel = position_to_pixel(
 			edl->local_session->get_selectionstart(1));
// Draw insertion point position.
 		set_color(mwindow->theme->timebar_cursor_color);
 		draw_line(pixel, 0, pixel, get_h());
 	}

	update_highlights();

// Get the labels to show	
	show_window(0);
	flash(flush);
//printf("TimeBar::update %d this=%p %d\n", __LINE__, this, current_operation);
}
Exemplo n.º 13
0
void write_HUC3(uint16_t addr, uint8_t val) {
    
    switch (addr & 0xF000) {
        case 0x0000:
        case 0x1000: 
					ram_banking = val & 0x0A;
                    huc3_ramflag = val;
                    break;
        case 0x2000:
        case 0x3000:/* Set ROM bank  */
                    val = val & 0x7F;
                    cur_ROM_bank = val ? val : 1;
					
                    break;
        case 0x4000: 
        case 0x5000: // Set current RAM bank 0 - 0xF
                     cur_RAM_bank = val & 0xF;
                     break;
        case 0x6000: 
        case 0x7000: //Nothing
                     break;
        case 0xA000:
        case 0xB000: // Write to external RAM bank if RAM banking enabled 
                    if (huc3_ramflag == 0xB) {
						switch (val & 0xF0) {
							case 0x10:  
									if (clock_shift <= 24) {
										huc3_value = (clock_register >> clock_shift) & 0x0F;
										clock_shift += 4;
									}
									break;

							case 0x30: 				 
									if (clock_shift <= 24) {
										clock_register &= ~(0x0F << clock_shift);
										clock_register |= ((val & 0xF) << clock_shift);
										clock_shift += 4;
									}
									break;

							case 0x40:
									update_clock();
							
									switch (val & 0xF) {
							    		case 0x00:
										case 0x03:
										case 0x07: 
										   	clock_shift = 0;
										   	break;	
									}
									break;
						
							case 0x60:
									huc3_value = 0x1; 								
									break;	
						}	
					} else if (huc3_ramflag == 0x0A && ram_banking) {
Exemplo n.º 14
0
static void
on_tz_changed (GFileMonitor      *monitor,
               GFile             *file,
               GFile             *other_file,
               GFileMonitorEvent *event,
               gpointer           user_data)
{
	update_clock (user_data);
}
Exemplo n.º 15
0
/*
 * Display the clock on movement (ensures if you start moving the clock is up to date)
 * Also fired from button press
 */
EXTFN void revive_clock_on_movement(uint16_t last_movement) {

  if (last_movement >= CLOCK_UPDATE_THRESHOLD) {
    time_t now = time(NULL);
    if ((now - last_clock_update) > 60) {
      update_clock();
    }
  }
}
Exemplo n.º 16
0
static void
on_tz_changed (GFileMonitor      *monitor,
               GFile             *file,
               GFile             *other_file,
               GFileMonitorEvent *event,
               gpointer           user_data)
{
	g_debug ("Updating clock because timezone changed");
	update_clock (user_data);
}
Exemplo n.º 17
0
static gboolean
update_timezone (gpointer data)
{
	GnomeWallClock *self = data;

	if (self->priv->timezone != NULL)
		g_time_zone_unref (self->priv->timezone);
	self->priv->timezone = g_time_zone_new_local ();
	g_object_notify ((GObject*)self, "timezone");

	return update_clock (data);
}
Exemplo n.º 18
0
static void main_window_load(Window *window) {
//   APP_LOG(APP_LOG_LEVEL_DEBUG, "trying to construct");
  ClockDigit_construct(&clockDigits[0], GPoint(7, 7));
  ClockDigit_construct(&clockDigits[1], GPoint(60, 7));
  ClockDigit_construct(&clockDigits[2], GPoint(7, 90));
  ClockDigit_construct(&clockDigits[3], GPoint(60, 90));

//   APP_LOG(APP_LOG_LEVEL_DEBUG, "Made it past construction");

  for(int i = 0; i < 4; i++) {
    ClockDigit_setColor(&clockDigits[i], globalSettings.timeColor, globalSettings.timeBgColor);
    layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(clockDigits[i].imageLayer));
  }

//   APP_LOG(APP_LOG_LEVEL_DEBUG, "Made it past color setting");

  // load font
  sidebarFont = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  dateFont = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);

  // init the sidebar layer
  if(globalSettings.sidebarOnRight) {
    sidebarLayer = layer_create(GRect(114, 0, 30, 168));
  } else {
    sidebarLayer = layer_create(GRect(0, 0, 30, 168));
  }
  layer_add_child(window_get_root_layer(window), sidebarLayer);
  layer_set_update_proc(sidebarLayer, sidebarLayerUpdateProc);

  // load the sidebar graphics
  #ifdef PBL_COLOR
    dateImage = gdraw_command_image_create_with_resource(RESOURCE_ID_DATE_BG);
    disconnectImage = gdraw_command_image_create_with_resource(RESOURCE_ID_DISCONNECTED);
    batteryImage = gdraw_command_image_create_with_resource(RESOURCE_ID_BATTERY_BG);
  #else
    dateImage = gbitmap_create_with_resource(RESOURCE_ID_DATE_BG);
    disconnectImage = gbitmap_create_with_resource(RESOURCE_ID_DISCONNECTED);
    batteryImage = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_BG);
  #endif

  if (!dateImage || !disconnectImage) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Failed to load a PDC image.");
  }

  window_set_background_color(window, globalSettings.timeBgColor);

  // Make sure the time is displayed from the start
  forceScreenRedraw();
  update_clock();
}
Exemplo n.º 19
0
/* =====================================================================
 *
 * =====================================================================*/
static gboolean ok_timeout()
{
  timer_id = 0;
  gc_bonus_display(gamewon, GC_BONUS_SMILEY);
  if (!gamewon)
    errors--;
  if (errors >= 1)
    update_clock();

  g_object_set (highlight_image_item,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);
  return FALSE;
}
Exemplo n.º 20
0
void loop()
{
	while (1)
	{
		reset_screens();

		display_time(&time1);
		display_time(&time2);
		display_time(&time3);
		display_time(&time4);

		update_clock(&cclock);
		sleep(60);
	}
}
Exemplo n.º 21
0
static void
on_schema_change (GSettings *schema,
                  const char *key,
                  gpointer user_data)
{
	if (g_strcmp0 (key, "clock-format") != 0 &&
	    g_strcmp0 (key, "clock-show-seconds") != 0 &&
	    g_strcmp0 (key, "clock-show-weekday") != 0 &&
	    g_strcmp0 (key, "clock-show-date") != 0) {
		return;
	}

	g_debug ("Updating clock because schema changed");
	update_clock (user_data);
}
Exemplo n.º 22
0
/**
 * Return the current time broken into a timeval structure.
 *
 * @param tv A pointer to a timeval structure.
 * @param tz Added for compatability - not used.
 * @return 0 for success (this function cannot return non-zero currently).
 */
int gettimeofday(struct timeval *tv, void *tz)
{
	/*
	 * Call the gtod init when we need it - this keeps the code from
	 * being included in the binary if we don't need it.
	 */
	if (!clock.ticks)
		gettimeofday_init();

	update_clock();

	tv->tv_sec = clock.secs;
	tv->tv_usec = clock.usecs;

	return 0;
}
Exemplo n.º 23
0
void funny_print_widelist(void)
{
	int	i;
	char	buffer1[BIG_BUFFER_SIZE];
	char	buffer2[BIG_BUFFER_SIZE];
	char	*ptr;

	if (!wide_list)
		return;

	if (funny_flags & FUNNY_NAME)
		qsort((void *) wide_list, wl_elements, sizeof(WideList *),
		(int (*) (const void *, const void *)) funny_widelist_names);
	else if (funny_flags & FUNNY_USERS)
		qsort((void *) wide_list, wl_elements, sizeof(WideList *),
		(int (*) (const void *, const void *)) funny_widelist_users);

	set_display_target(NULL, LOG_CRAP);
	*buffer1 = '\0';
	for (i = 1; i < wl_elements; i++)
	{
		sprintf(buffer2, "%s(%d) ", wide_list[i]->channel,
				wide_list[i]->users);
		ptr = strchr(buffer1, '\0');
		if (strlen(buffer1) + strlen(buffer2) > current_term->TI_cols - 5)
		{
			if (do_hook(WIDELIST_LIST, "%s", buffer1))
				put_it("%s", convert_output_format(fget_string_var(FORMAT_WIDELIST_FSET), "%s %s", update_clock(GET_TIME), buffer1));
			*buffer1 = 0;
			strcat(buffer1, buffer2);
		}
		else
			strcpy(ptr, buffer2);
	}
	if (*buffer1 && do_hook(WIDELIST_LIST, "%s", buffer1))
		put_it("%s", convert_output_format(fget_string_var(FORMAT_WIDELIST_FSET), "%s %s", update_clock(GET_TIME), buffer1));

	reset_display_target();
	for (i = 0; i < wl_elements; i++)
	{
		new_free(&wide_list[i]->channel);
		new_free((char **)&wide_list[i]);
	}
	new_free((char **)&wide_list);
	wl_elements = wl_size = 0;
}
Exemplo n.º 24
0
static void
gnome_wall_clock_init (GnomeWallClock *self)
{
	GFile *tz;

	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GNOME_TYPE_WALL_CLOCK, GnomeWallClockPrivate);
	
	self->priv->clock_string = NULL;
	
	tz = g_file_new_for_path ("/etc/localtime");
	self->priv->tz_monitor = g_file_monitor_file (tz, 0, NULL, NULL);
	g_object_unref (tz);
	
	g_signal_connect (self->priv->tz_monitor, "changed", G_CALLBACK (on_tz_changed), self);
			
	update_clock (self);
}
Exemplo n.º 25
0
void amsg(IrcCommandDll *intp, char *command, char *args, char *subargs, char *helparg) {
	char *nick,*nnick,*loc;
	
	CHECK_TOC_ONLINE();
	
	/* loc = msg, nick = username to send msg to */
	loc = LOCAL_COPY(args);
	nick = new_next_arg(loc, &loc);
	
	REQUIRED_ARG(nick,command,helparg);
	
	if ( nick[0] == '#' ) {
		struct buddy_chat *b;
		nick++;
		REQUIRED_ARG(nick,command,helparg);
		b = (struct buddy_chat *) find_buddy_chat(nick);
		if ( ! b ) {
			statusprintf("Error not on buddy chat %s", nick);
			return;
		}
		/* chatprintf("sent msg %s to buddy chat %s",loc,nick); */
		serv_chat_send(b->id,loc);
	} else {
		char *ruser,*rnick;
		nnick = (char *) malloc(strlen(nick)+10);
		rnick = rm_space(nick);
		ruser = rm_space(get_dllstring_var("aim_user"));
		sprintf(nnick,"%s@AIM",rnick);
		msgprintf("%s", cparse(fget_string_var(FORMAT_SEND_MSG_FSET), 
			"%s %s %s %s",update_clock(GET_TIME), 
			nnick, ruser, loc));
		serv_send_im(nick,loc);
		RemoveFromLLByKey(msgdthem,rnick);
		AddToLL(msgdthem,rnick,NULL);
#ifdef BITCHX_PATCH
		tks.list = 0;
		tks.pos = -1;
#endif		
		free(rnick); free(ruser);
	}	
	
	debug_printf("sending msg to %s '%s'",nick,loc);	
	return;
}
Exemplo n.º 26
0
static void
gnome_wall_clock_set_property (GObject      *gobject,
			       guint         prop_id,
			       const GValue *value,
			       GParamSpec   *pspec)
{
	GnomeWallClock *self = GNOME_WALL_CLOCK (gobject);

	switch (prop_id)
	{
	case PROP_TIME_ONLY:
		self->priv->time_only = g_value_get_boolean (value);
		update_clock (self);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
		break;
	}
}
Exemplo n.º 27
0
int clock_main()
{
    sys_init();
    gpio_init();
    timer0_init();
    lcd_init();

    ds1623_init();

    lcd_fill_rect(0, 0, 240, 320, 0x0000);
    int i = 0;
    for(;;)
    {
        ms_delay(1000);
        update_clock();
        update_temp();
    }
    return 0;
}
Exemplo n.º 28
0
static void p_nick(char *from, char **ArgList)
{
    int one_prints = 0, ign = 0, its_me = 0;
    struct channel *chan;
    char *line;

    line = ArgList[0];
    if (!my_stricmp(from, get_server_nickname(from_server))) {
	accept_server_nickname(from_server, line);
	its_me = 1;
	user_changing_nickname = 0;
    }
    ign = check_ignore(from, FromUserHost, NULL, IGNORE_NICKS | IGNORE_CRAP, NULL);
    for (chan = server_list[from_server].chan_list; chan; chan = chan->next) {
	message_from(chan->channel, LOG_CRAP);
	if (ign != IGNORED && do_hook(CHANNEL_NICK_LIST, "%s %s %s", chan->channel, from, line))
	    one_prints = 1;
    }
    if (one_prints) {
	if (its_me) {
	    message_from(NULL, LOG_CRAP);
	} else
	    message_from(what_channel(from, from_server), LOG_CRAP);
	if (ign != IGNORED && do_hook(NICKNAME_LIST, "%s %s", from, line))
	    put_it("%s",
		   convert_output_format(get_format
					 (its_me ? FORMAT_NICKNAME_USER_FSET : im_on_channel(what_channel(from, from_server)) ?
					  FORMAT_NICKNAME_FSET : FORMAT_NICKNAME_OTHER_FSET), "%s %s %s %s", update_clock(GET_TIME),
					 from, "-", line));
    }
    rename_nick(from, line, from_server);
    if (!its_me) {
	char *user, *host;

	user = m_strdup(FromUserHost);
	host = strchr(user, '@');
	*host++ = '\0';

	notify_mark(from, user, host, 0);
	notify_mark(line, user, host, 1);
	new_free(&user);
    }
}
Exemplo n.º 29
0
/**
 * Return the current time broken into a timeval structure.
 *
 * @param tv A pointer to a timeval structure.
 * @param tz Added for compatability - not used.
 * @return 0 for success (this function cannot return non-zero currently).
 *
 * WARNING : In this implementation gettimeofday() will not work until the cpu is not initialized.
 */
int gettimeofday(struct timeval *tv, void *tz)
{
    cpu_khz = (uint32_t)(get_env(envCPUFreq) / 1000);
    if (!(cpu_khz>0)) {
        return -1;
    }
	/*
	 * Call the gtod init when we need it - this keeps the code from
	 * being included in the binary if we don't need it.
	 */
	if (!private_clock.ticks)
		gettimeofday_init();

	update_clock();

	tv->tv_sec = private_clock.secs;
	tv->tv_usec = private_clock.usecs;

	return 0;
}
Exemplo n.º 30
0
int do_parse_json(char * buffer,int* clock)
{
	int i;
	int type_flag = -1;
	int clock_flag = -1;
	
	int parser_return_code;
	jsmntok_t token[10];
	jsmn_parser p;
	
	for(i=0; i<10; i++) token[i].type=-1;

	jsmn_init(&p);
	parser_return_code = jsmn_parse(&p, buffer, token, 10);
	if(parser_return_code != JSMN_SUCCESS) return ERROR;
	
	//SZUKAJ TYPU I ZEGARA
	for(i=0; i<10; i++)
	{
		if(token[i].type == -1) break;
		if( token_string(buffer, token[i], "type") || token_string(buffer, token[i], "Type") || token_string(buffer, token[i], "TYPE") ) type_flag = i+1;
		if( token_string(buffer, token[i], "clock") || token_string(buffer, token[i], "Clock") || token_string(buffer, token[i], "CLOCK") ) clock_flag = i+1;
	}

	fprintf(stderr,"### type_flag: %d, clock_flag: %d\n", type_flag, clock_flag);

	//NIE ZNALEZIONO! BLAD
	if(type_flag == -1 || clock_flag == -1 ) return ERROR;
	//ZLE TYPY! BLAD
	if(token[type_flag].type != JSMN_STRING && token[clock_flag].type != JSMN_PRIMITIVE) return ERROR;

	int rec_clock = strtol( buffer+token[clock_flag].start, NULL, 0 );

	update_clock(rec_clock);
	(*clock) = rec_clock;
	
	if( token_string(buffer, token[type_flag], "order") ) return ORDER;
	else if( token_string(buffer, token[type_flag], "ok") ) return OK;
	else return ERROR;
	
}