Example #1
0
int main(int argc, char **args) {
  dpy = XOpenDisplay(NULL);
  if (NULL == dpy) {
    return 1;
  }

  char temp[5], memusage[5], cpuusage[64], unreadmail[2], date[32], gcpct[128], ioutil[2];

  char buf[STATUS_MAX_LENGTH];

  fill_cpu_usage(buf, sizeof(buf));
  sleep(1);

  int terminater = 0;
  terminater = fill_temp(temp, sizeof(temp), "temp1");
  temp[terminater] = '\0';
  terminater = fill_mem_usage(memusage, sizeof(memusage));
  memusage[terminater] = '\0';
  terminater = fill_cpu_usage(cpuusage, sizeof(cpuusage));
  cpuusage[terminater] = '\0';
  terminater = fill_unread_mail(unreadmail, sizeof(unreadmail));
  unreadmail[terminater] = '\0';
  terminater = fill_date(date, sizeof(date));
  date[terminater] = '\0';
  terminater = fill_gcpct(gcpct, sizeof(gcpct));
  gcpct[terminater] = '\0';
  terminater = fill_ioutil(ioutil, sizeof(ioutil));
  ioutil[terminater] = '\0';

  unsigned long sleeps = 0;
  while (1) {
    fill_temp(temp, sizeof(temp), "temp1");
    fill_mem_usage(memusage, sizeof(memusage));
    fill_cpu_usage(cpuusage, sizeof(cpuusage));
    if (sleeps % 20 == 0) {
      fill_date(date, sizeof(date));
      fill_unread_mail(unreadmail, sizeof(unreadmail));
    }
    if (sleeps % 10 == 0) {
      terminater = fill_gcpct(gcpct, sizeof(gcpct));
      gcpct[terminater] = '\0';
    }
    /* sprintf(buf, "%s %s %s%s %s %s %s", gcpct, temp, memusage, ioutil, cpuusage, unreadmail, date); */
    sprintf(buf, "%s %s %s%s %s %s", gcpct, temp, memusage, ioutil, cpuusage, unreadmail);
    setstatus(buf);
    /* printf("%s\n", buf); */
    sleep(1);
    fill_ioutil(ioutil, sizeof(ioutil)); // sleeps 1
    sleeps += 2;
  }
  
  return 0;
}
Example #2
0
void start_client(void)
{
	extern char currmaildir[];

	initialize_mdb();
#ifndef ENABLE_SSH
	initialize_db();
#endif

	initialize_convert_env();
	system_init();

	if (setjmp(byebye)) {
		system_abort();
	}

	strlcpy(BoardName, BBSNAME, sizeof(BoardName));

	if (login_query() == -1) {
		terminal_flush();
		sleep(3);
		exit(1);
	}
#ifndef ENABLE_SSH
	screen_negotiate_size();
#endif // ENABLE_SSH
	screen_init(0);

	user_login();

	setmdir(currmaildir, currentuser.userid);
	RMSG = NA;
	screen_clear();
	editor_restore();
#ifdef TALK_LOG
	tlog_recover();
#endif

	if (strcmp(currentuser.userid, "guest")) {
		if (check_maxmail())
			pressanykey();
		screen_move(9, 0);
		screen_clrtobot();
		if (!DEFINE(DEF_NOLOGINSEND))
			if (session_visible())
				login_msg();
		screen_clear();
		set_numofsig();
	}

	active_board_init(false);
	fill_date();

	if (DEFINE(DEF_LOGFRIEND)
			&& session_count_online_followed(!HAS_PERM(PERM_SEECLOAK)) > 0)
		show_online_followings();

	menu_load("menu.img");
	while (1) {
		if (DEFINE(DEF_NORMALSCR))
			menu_loop("TOPMENU");
		else
			menu_loop("TOPMENU2");
		Goodbye();
	}
}