home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: DFÜ und Kommunikation / SOS-DFUE.ISO / programm / dos / utility / pccp076 / vcemanip.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-20  |  4.9 KB  |  233 lines

  1. /* Copyright (C) 1992 Peter Edward Cann */
  2.  
  3. #include<stdio.h>
  4. #include<dos.h>
  5. #include<process.h>
  6. #include<graph.h>
  7. #include<time.h>
  8.  
  9. #define MAXTIMES 1024
  10.  
  11. long times[MAXTIMES];
  12.  
  13. int ntimes;
  14.  
  15. main(argc, argv)
  16.     int argc;
  17.     char **argv;
  18.     {
  19.     int i, j, topind, curind, flag;
  20.     char str[256], str1[256], c;
  21.     long tmptime;
  22.     struct tm *tptr;
  23.     struct find_t buf;
  24.     printf("VCEMANIP Copyright (C) 1992,1993 Peter Edward Cann\n");
  25.     if((argc!=3)&&(argc!=4))
  26.         {
  27.         printf("USAGE: vcemanip <com#> <play speed> [<directory>]\n");
  28.         exit(73);
  29.         }
  30.     if(!strcmp(getenv("REMOTE"), "YES"))
  31.         {
  32.         printf("You appear to be logged in remotely, judging by the environment\n");
  33.         printf("variable REMOTE, so this is probably a very bad idea.\n");
  34.         printf("Are you sure you want to run VCEMANIP? (y or n) --> ");
  35.         if(getchar()!='y') /* Note getchar() and not getch()! */
  36.             {
  37.             printf("n\nI didn't think so!\n");
  38.             exit(99);
  39.             }
  40.         else
  41.             printf("y\nOK, you're the boss!\n");
  42.         }
  43.     if(argc==4)
  44.         sprintf(str, "%s\\*.vce", argv[3]);
  45.     else
  46.         sprintf(str, "*.vce");
  47.     if(_dos_findfirst(str, _A_NORMAL, &buf))
  48.         {
  49.         printf("No .vce files found in directory.\n");
  50.         exit(1);
  51.         }
  52.     ntimes=0;
  53.     if(sscanf(buf.name, "%lx", ×[ntimes++])!=1)
  54.         ntimes--;
  55.     while(!_dos_findnext(&buf))
  56.         {
  57.         if(sscanf(buf.name, "%lx", ×[ntimes++])!=1)
  58.             ntimes--;
  59.         if(ntimes>=MAXTIMES)
  60.             break;
  61.         }
  62.     for(i=0;i<ntimes;++i)
  63.         for(j=i+1;j<ntimes;++j)
  64.             if(times[i]<times[j])
  65.                 {
  66.                 tmptime=times[i];
  67.                 times[i]=times[j];
  68.                 times[j]=tmptime;
  69.                 }
  70.     topind=curind=0;
  71.     while(1)
  72.         {
  73.         _settextwindow(1,1,1,80);
  74.         _settextcolor(0);
  75.         _setbkcolor((long)7);
  76.         _clearscreen(_GWINDOW);
  77.         printf("        n=next   p=previous   l=listen   r=rename   d=delete   q=quit");
  78.         _settextwindow(2,1,25,80);
  79.         _settextcolor(7);
  80.         _setbkcolor((long)0);
  81.         _clearscreen(_GWINDOW);
  82.         if(curind<12)
  83.             topind=0;
  84.         else if((ntimes-curind)<13)
  85.             topind=ntimes-25;
  86.         for(i=0;(i<24)&&(i<(ntimes-topind));++i)
  87.             {
  88.             tptr=localtime(×[topind+i]);
  89.             _settextposition(i+1, 1);
  90.             printf("%02d.%02d.%02d @ %02d:%02d:%02d",
  91.                 tptr->tm_year,
  92.                 (tptr->tm_mon)+1,
  93.                 tptr->tm_mday,
  94.                 tptr->tm_hour,
  95.                 tptr->tm_min,
  96.                 tptr->tm_sec
  97.                 );
  98.             }
  99.         flag=1;
  100.         while((curind-topind<24)&&(curind>=topind)&&flag)
  101.             {
  102.             _settextposition(curind-topind+1, 21);
  103.             switch(getch())
  104.                 {
  105.                 case 0:
  106.                     /* Funny key */
  107.                     switch(getch())
  108.                         {
  109.                         case 0x50:
  110.                             if(curind>=(ntimes-1))
  111.                                 putch(0x07);
  112.                             else
  113.                                 curind++;
  114.                             break;
  115.                         case 0x48:
  116.                             if(curind==0)
  117.                                 putch(0x07);
  118.                             else
  119.                                 curind--;
  120.                             break;
  121.                         default:
  122.                             putch(0x07);
  123.                         }
  124.                     break;
  125.                 case 'n':
  126.                 case 'N':
  127.                     if(curind>=(ntimes-1))
  128.                         putch(0x07);
  129.                     else
  130.                         curind++;
  131.                     break;
  132.                 case 'p':
  133.                 case 'P':
  134.                     if(curind==0)
  135.                         putch(0x07);
  136.                     else
  137.                         curind--;
  138.                     break;
  139.                 case 'q':
  140.                 case 'Q':
  141.                     _settextposition(24, 1);
  142.                     exit(0);
  143.                     break;
  144.                 case 'd':
  145.                 case 'D':
  146.                     printf("Really delete? (Y/N) --> ");
  147.                     c=getch();
  148.                     if((c!='Y')&&(c!='y'))
  149.                         {
  150.                         _settextposition(curind-topind+1, 21);
  151.                         printf("\t\t\t\t");
  152.                         break;
  153.                         }
  154.                     flag=0;
  155.                     if(argc==4)
  156.                         sprintf(str, "%s\\%08lx.vce", argv[3], times[curind]);
  157.                     else
  158.                         sprintf(str, "%08lx.vce", times[curind]);
  159.                     if(unlink(str))
  160.                         {
  161.                         putch(7);
  162.                         break;
  163.                         }
  164.                     --ntimes;
  165.                     if(!ntimes)
  166.                         {
  167.                         _settextposition(24,1);
  168.                         printf("\nNo more files.\n");
  169.                         exit(0);
  170.                         }
  171.                     for(i=curind;i<ntimes;++i)
  172.                         times[i]=times[i+1];
  173.                     if(curind==ntimes)
  174.                         curind--;
  175.                     break;
  176.                 case 'r':
  177.                 case 'R':
  178.                     flag=0;
  179.                     printf("New name --> ");
  180.                     gets(str1);
  181.                     if(!str1[0])
  182.                         {
  183.                         _settextposition(curind-topind+1, 21);
  184.                         printf("\t\t\t\t\t\t\t");
  185.                         break;
  186.                         }
  187.                     flag=0;
  188.                     if(argc==4)
  189.                         sprintf(str, "%s\\%08lx.vce", argv[3], times[curind]);
  190.                     else
  191.                         sprintf(str, "%08lx.vce", times[curind]);
  192.                     if(rename(str,str1))
  193.                         {
  194.                         putch(7);
  195.                         break;
  196.                         }
  197.                     --ntimes;
  198.                     if(!ntimes)
  199.                         {
  200.                         _settextposition(24,1);
  201.                         printf("\nNo more files.\n");
  202.                         exit(0);
  203.                         }
  204.                     for(i=curind;i<ntimes;++i)
  205.                         times[i]=times[i+1];
  206.                     if(curind==ntimes)
  207.                         curind--;
  208.                     break;
  209.                 case 'l':
  210.                 case 'L':
  211.                     _settextposition(24,1);
  212.                     printf("\nSpawning RFXTOPCX...\n");
  213.                     if(argc==4)
  214.                         sprintf(str, "%s\\%08lx.vce", argv[3], times[curind]);
  215.                     else
  216.                         sprintf(str, "%08lx.vce", times[curind]);
  217.                     spawnlp(P_WAIT, "voicetx", "voicetx", argv[1], argv[2], str, NULL);
  218.                     printf("\nPress any key to resume VCEMANIP: --> ");
  219.                     getch();
  220.                     flag=0;
  221.                     break;
  222.                 default:
  223.                     putch(0x07);
  224.                     break;
  225.                 }
  226.             }
  227.         if(curind>12)
  228.             topind=curind-12;
  229.         else
  230.             topind=0;
  231.         }
  232.     }
  233.