killlian 发表于 2008-4-25 17:28

recorder.h

/**************************************************************************************/
/*Function name: int get_today()                  */
/*Instruction:提取当日节目菜单                                                                   */
/*argument:                                       */
/*               int n,struct mission * hand          */
/*return:                                           */
/*                            none                  */
/**************************************************************************************/
int get_today(int n, struct mission * head)
    {
    struct mission * p = head;
    struct mission * to_p;
    long ist_date, ien_date;
    int date, w, to_n = {0};
    int i, j, k;
    w = get_date(&date, &date, &date);

    if (head != NULL)
      do
                  {
         returnnextday(&date, &date, &date);
         for(i = 0; i < n; i++)
                           {
         for(k = 0; k < 2; k++)
                                 {
            if(dcmp(date, p->st_date) != 1 &&
               dcmp(date, p->en_date) != -1)
                                       {
               for(j = 0; j < 7; j++)
                  if(p->wdate == 1 && w == j)
                                                         {
                      to_p] = p;
                      to_n++;
                                                         }
                                       }               
            if ( p->next != NULL)
               p = p->next;
                           }
                     }
      }while(get_time() == 1439);//在每天的23:59:00重新提取;
   queue(&to_n, to_p);
   play_today(&to_n, to_p);

   return 0;
}

/**************************************************************************************/
/*Function name: int queue()                        */
/*Instruction:将节目菜单排序                                                                     */
/*argument:                                       */
/*             int a,struct mission *b       */
/*return:                                           */
/*                              none                  */
/**************************************************************************************/
int queue(int a, struct mission *b)
{
    struct mission *t;
    int l, m, k;

    for(k = 0; k < 2; k++)//区分今日与明日;
       for(m = 0; m < a - 1; m++)//冒泡;
         for(l = 0; l < a - m - 1; l++)
                              {
             if(tcmp((b)->st_time, (b)->st_time) == -1)
                                       {
                t = b;
                b = b;
                b = t;
                                       }
                              }

    //printf("下一预约:%s\n", &b->name);

return 0;
}
/**************************************************************************************/
/*Function name: int play_today()                   */
/*Instruction:慢慢地把预约逐个播放                                                         */
/*argument:                                       */
/*            int c,struct mission *d      */
/*return:                                           */
/*                                  none            */
/**************************************************************************************/
int play_today(int c, struct mission *d)
      {
    int i, j, z;
    int dst_time;
    for(i = 0 ; i <= c; i++)
               {
       dst_time = d->st_time * 60 +
                     d->st_time      ;
       dst_time = d->en_time * 60 +
                     d->en_time      ;
          z = (dst_time - dst_time) * 60;
       if(dst_time - 1 == get_time())
                      {
         countsec(30);
         for(j = 3 ; j > 0 ; j--)
                           {
            countsec(10);
            printf("%d\n", j);
                            }
         printf("0\n录像中。。。\n");
         if(i != c - 1)
         printf("下一预约:%s\n", d->name);
         else
                            {
         if(c == 0)            
             printf("明天没有预约!!\n");
         else
             printf("下一预约:%s\n", d->name);
                            }
         countsec(z);
         printf("录像结束\n等待中。。。\n");
                     }
         if(i != c - 1)
         countsec(d->st_time * 60 +
                  d->st_time    -
                  dst_time                );   
               }

    if(d->st_time * 60 + d->st_time == 0)   // 0时判断;
               {
       for(j = 0; ; j++)
         if(get_time() == 2359)
                           {
            countsec(30);
            for(j = 3 ; j >= 0 ; j--)
                                    {
               countsec(10);
               printf("%d\n", j);            
                                     }
            printf("录像中。。。\n");
                            }
                     }

   return 0;
}
/**************************************************************************************/
/*Function name: int countsec()                     */
/*Instruction:计时                                                                                             */
/*argument:                                       */
/*                         int n                      */
/*return:                                           */
/*               none                               */
/**************************************************************************************/
int countsec(int n)
{
   int i;
   struct tm *ptr;

   time_t st, et;
   st = time(NULL);

   for(i = 0; ; i++)
         {
      et = time(NULL);
      if(et - st == n)
      break;
            }

   return 0;

}
/**************************************************************************************/
/*Function name: int get_time()                     */
/*Instruction: 提取系统的时间                                                                     */
/*argument:                                       */
/*                           none                     */
/*return:                                           */
/*                           int ti                   */
/**************************************************************************************/
int get_time(void)
{
   struct tm *ptr;
   time_t lt;
   int i, ti;
   char tim;

   lt = time(NULL);
   ptr = localtime(&lt);
   strftime(tim,5,"%H%M",ptr);
   for(i = 0,ti = 0; i < 4; i++)
      ti = ti * 10 + tim - 48;
   ti = (int)(ti / 100) * 60 + ti % 100;
   return ti;

}
页: [1]
查看完整版本: recorder.h