예제 #1
0
void
hm_init()	/* dust.100315: 載入個人倒數計時器 */
{
  FILE *fp;
  char fpath[64];
  MCD_info meter;

  memset(&curr_CDmeter, 0, sizeof(MCD_info));

  usr_fpath(fpath, cuser.userid, FN_MCD);
  if(fp = fopen(fpath, "rb"))
  {
    while(fread(&meter, sizeof(MCD_info), 1, fp) > 0)
    {						/* 篩掉已經截止的計時器 */
      if((meter.warning & DEFMETER_BIT) && DCD_AlterVer(&meter, NULL) > 0)
      {
	meter.warning &= ~DEFMETER_BIT;	/* 還原回原本的數字 */
	curr_CDmeter = meter;
	break;
      }
    }
    fclose(fp);
  }
}
예제 #2
0
int main_classtable(void)
{
	char c;
	int x = 1, y = 1;
	int fd;

#ifdef	HAVE_CLASSTABLEALERT
	classtable_free();
#endif
	usr_fpath(fpath_classtable, cuser.userid, FN_CLASSTABLE2);

	init_classtable();
	show_icon_classtable(x, y, 1);

	do
	{
		c = vkey();
		switch (c)
		{
		case 'q' :
			break;
		case KEY_DOWN :
			show_icon_classtable(x, y, 0);
			x++;
			if (x == 14) x = 1;
			show_icon_classtable(x, y, 1);
			break;
		case KEY_UP:
			show_icon_classtable(x, y, 0);
			x--;
			if (x == 0) x = 13;
			show_icon_classtable(x, y, 1);
			break;
		case KEY_LEFT:
			show_icon_classtable(x, y, 0);
			y--;
			if (y == 0) y = 6;
			show_icon_classtable(x, y, 1);
			break;
		case KEY_RIGHT :
			show_icon_classtable(x, y, 0);
			y++;
			if (y == 7) y = 1;
			show_icon_classtable(x, y, 1);
			break;
		case 'a' :
			add_classtable(x, y);
			break;
		case 'd' :
			del_classtable(x, y);
			break;
		case 'e' :
			edit_classtable(x, y);
			break;
		case 'i' :
			import_classtable(x, y);
			break;
		case 'c' :
			if (vans("確定刪除嗎?[y/N] ") == 'y')
			{
				memset(tmp_table, 0, sizeof(CLASS_TABLE2)*78);
				show_table();
			}
			break;
		case '\n' :
			if (tmp_table[x+y*13-14].valid == 1)
				edit_classtable(x, y);
			else
				add_classtable(x, y);
			break;
		}
	}
	while (c != 'q');

	fd = open(fpath_classtable, O_WRONLY | O_CREAT | O_TRUNC, 0600);
	if (fd >= 0)
	{
		write(fd, tmp_table, sizeof(CLASS_TABLE2)*78);
		close(fd);
	}
#ifdef	HAVE_CLASSTABLEALERT
	classtable_main();
#endif

	vmsg(NULL);
	return 0;
}
예제 #3
0
int
main(void)
{
  int i, j;
  FILE *fp;
  int max, item, maxhoroscope;
  char c;

  int act[12];

  char *name[13] = {"¨d¦Ï",
                    "ª÷¤û",
                    "Âù¤l",
                    "¥¨ÃÉ",
                    "·à¤l",
                    "³B¤k",
                    "¤Ñ¯¯",
                    "¤ÑÃÈ",
                    "®g¤â",
                    "¼¯½~",
                    "¤ô²~",
                    "Âù³½",
                    ""
                           };
  char    *blk[10] =
  {
      "  ","¢j", "¢k", "¢l", "¢m",
      "¢n","¢o", "¢p", "¢i", "¢i",
  };

  chdir(BBSHOME);
  memset(act, 0, sizeof(act));

  for (c = 'a'; c <= 'z'; c++)
  {
    char buf[64];
    struct dirent *de;
    DIR *dirp;

    sprintf(buf, BBSHOME "/usr/%c", c);

    if (!(dirp = opendir(buf)))
      continue;

    while ((de = readdir(dirp)))
    {
      ACCT cuser;
      USER_ATTR	attr;
      
      int fd;
      if (de->d_name[0] <= ' ' || de->d_name[0] == '.')
        continue;

      usr_fpath(buf,de->d_name,".ACCT");
      if ((fd = open(buf, O_RDONLY)) < 0)
        continue;

      read(fd, &cuser, sizeof(cuser));
      close(fd);
      memset(&attr,0,sizeof(USER_ATTR));
      if(attr_get(cuser.userid,ATTR_USER_KEY,&attr) < 0)
        continue;  

    switch (attr.month)
    {
      case 1:
        if (attr.day <=19)
          act[9]++;
        else
          act[10]++;
        break;
      case 2:
        if (attr.day <=18)
          act[10]++;
        else
          act[11]++;
        break;
      case 3:
        if (attr.day <=20)
          act[11]++;
        else
          act[0]++;
        break;
      case 4:
        if (attr.day <=19)
          act[0]++;
        else
          act[1]++;
        break;
      case 5:
        if (attr.day <=20)
          act[1]++;
        else
          act[2]++;
        break;
      case 6:
        if (attr.day <=21)
          act[2]++;
        else
          act[3]++;
        break;
      case 7:
        if (attr.day <=22)
          act[3]++;
        else
          act[4]++;
        break;
      case 8:
        if (attr.day <=22)
          act[4]++;
        else
          act[5]++;
        break;
      case 9:
        if (attr.day <=22)
          act[5]++;
        else
          act[6]++;
       break;
      case 10:
        if (attr.day <=23)
          act[6]++;
        else
          act[7]++;
       break;
      case 11:
        if (attr.day <=22)
          act[7]++;
        else
          act[8]++;
       break;
      case 12:
        if (attr.day <=21)
          act[8]++;
        else
          act[9]++;
       break;
    }


    } /* while */
    closedir(dirp);
  } /* for */



  for (i = max  = maxhoroscope = 0; i < 12; i++)
  {
    if (act[i] > max)
    {
      max = act[i];
      maxhoroscope = i;
    }
  }

  item = max / 30 + 1;

  if ((fp = fopen(OUTFILE, "w")) == NULL)
  {
    printf("cann't open %s\n",OUTFILE);
    return 0;
  }

  for(i = 0;i < 12;i++)
  {
    fprintf(fp," %s®y ", name[i]);
    for(j = 0; j < act[i]/item; j++)
    {
      fprintf(fp,"%2s",blk[9]);
    }
    /* ¬°¤F­è¦n¤@­¶ */
    if (i != 11)
      fprintf(fp,"%2s %d\n\n",blk[(act[i] % item) * 10 / item],
            act[i]);
    else
      fprintf(fp,"%2s %d\n",blk[(act[i] % item) * 10 / item],
            act[i]);
  }
  fclose(fp);
  return 0;
}