Example #1
0
void
proc_msg(void)
{
    char    *ptr, *key, *val;
    int        n;

    msgbuf[msgcnt] = 0;        /* null terminate message */
    for (ptr = strtok(msgbuf, ";"); ptr != NULL;
                                        ptr = strtok(NULL, ";")) {
        while (isspace(*ptr))
            ptr++;            /* skip leading spaces in key */
        key = ptr;

        if ( (ptr = strchr(ptr, ':')) == NULL)
            continue;    /* missing colon, something wrong, ignore */
        *ptr++ = '\0';    /* null terminate key (overwrite colon) */

        while (isspace(*ptr))
            ptr++;        /* skip leading spaces in val */
        val = ptr;
                        /* remove trailing spaces in val */
        ptr = strchr(val, '\0');
        while (ptr > val && isspace(ptr[-1]))
            --ptr;
        *ptr = '\0';

        if (strcmp(key, "Flushing") == 0) {
            printer_flushing();        /* never returns */

        } else if (strcmp(key, "PrinterError") == 0) {
            log_msg("proc_msg: printer error: %s", val);

        } else if (strcmp(key, "Error") == 0) {
              mail_line("Your PostScript printer job "
                      "produced the error `%s'.\n", val);

        } else if (strcmp(key, "status") == 0) {
            if (strcmp(val, "idle") == 0)
                status = IDLE;
            else if (strcmp(val, "busy") == 0)
                status = BUSY;
            else if (strcmp(val, "waiting") == 0)
                status = WAITING;
            else
                status = UNKNOWN;    /* "printing", "PrinterError",
                       "initializing", or "printing test page". */

        } else if (strcmp(key, "OffendingCommand") == 0) {
              mail_line("The offending command was `%s'.\n", val);

        } else if (strcmp(key, "pagecount") == 0) {
            if (sscanf(val, "%d", &n) == 1 && n >= 0) {
                  if (start_page < 0)
                    start_page = n;
                  else
                    end_page = n;
            }
        }
    }
}
Example #2
0
File: BBS.C Project: jeske/GTalk
void list_bbs(char *directory, struct bbs_board_info *bbs_info,
   int num_files,struct bbs_user_account *bbs_user)
 {
  int file;
  int anyfile = 1;
  int key;
  int abort=0;
  char user_l[80];
  char date_l[80];
  char subject_l[120];
  char num_l[120];
  int count=0;

  FILE *fileptr;

  print_cr();
  file=num_files;

  while ((file>0) && (!abort))
   {
     file--;
     lock_dos();
     if (open_bbs_file(directory,bbs_info,file,&fileptr))
      {
        mail_line(user_l,20,40,fileptr);
        mail_line(subject_l,32,70,fileptr);
        mail_line(date_l,16,40,fileptr);
        g_fclose(fileptr);
        unlock_dos();
        anyfile = 0;
        if (bbs_info[file].filedate > (bbs_user->last_entered_bbs))
         sprintf(num_l,"*%02d: ",file+1);
         else
         sprintf(num_l," %02d: ",file+1);

        special_code(1,tswitch);

        print_string(num_l);
        print_string(user_l);
        print_chr(' ');
        print_string(date_l);
        print_chr(' ');
        print_string(subject_l);
        print_cr();
        count++;
        special_code(0,tswitch);

        key = get_first_char(tswitch);
        if ((key == 27) || (key == 3))
         {
           int_char(tswitch);
           file = -1;
         };
        if (key == 19)
         {
           wait_ch();
           wait_ch();
         };

        if (count>=24)
         { abort= do_page_break();
           count=0;
        }

        lock_dos();
      };
     unlock_dos();
   };
 if (anyfile) print_str_cr("No BBS messages.");
};