home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 455.lha / MyShell / myshell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-10  |  3.7 KB  |  129 lines

  1. /**************************************************************************\
  2. *                                                                          *
  3. *                                 MyShell                                  *
  4. *                                                                          *
  5. \**************************************************************************/
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <dos.h>
  11. #include <libraries/dos.h>
  12. #include <intuition/preferences.h>
  13. #include <intuition/intuitionbase.h>
  14. #include <exec/memory.h>
  15. #include <ctype.h>
  16. #include <proto/all.h>
  17.  
  18. #define INTUITION_REV 34
  19. #define GRAPHICS_REV 34
  20.  
  21. /**************************************************************************\
  22. *                                                                          *
  23. *    WriteOut - handles passing params to AmigaDos Write                   *
  24. *                                                                          *
  25. \**************************************************************************/
  26.  
  27. void WriteOut(char *s)
  28. {
  29. Write(Output(),s,strlen(s));
  30. }
  31.  
  32. /**************************************************************************\
  33. *                                                                          *
  34. *    nullstub - This is used to remove routines that we won't need.        *
  35. *                                                                          *
  36. \**************************************************************************/
  37.  
  38. int nullstub(void)
  39. {
  40. return(0);
  41. }
  42.  
  43. /**************************************************************************\
  44. *                                                                          *
  45. *    Main - This is the big one...                                         *
  46. *                                                                          *
  47. \**************************************************************************/
  48.  
  49. void main(int argc,char **argv)
  50. {
  51. UBYTE TOP,OUT,FULL;
  52. ULONG x,y,rx,ry;
  53. char str[200];
  54. char s1[30],s2[30],s3[80];
  55.  
  56. struct IntuitionBase *IntuitionBase;
  57. struct Screen *WBS;
  58.  
  59. OUT=TOP=0;
  60. FULL=1;
  61.  
  62. if(argc>1&&argv[1][0]=='?')
  63.     {
  64.     sprintf(str,"_MyShell_ Version 1.0 (%s) %s\n",__DATE__,__TIME__);
  65.     WriteOut(str);
  66.     WriteOut("(C) Copyright 1990 by Synthetic Technologies\n");
  67.     WriteOut("Written by Mike Thomas\n\n");
  68.     WriteOut("Usage: MyShell [-S/K] [-C/K] [-T/K] [-O] [-U] [-F]\n");
  69.     WriteOut("       -S/K shell program   default: NewShell\n");
  70.     WriteOut("       -C/K console device  default: CON:\n");
  71.     WriteOut("       -T/K title/options   default: NewShell/CLOSE from s:shell-startup\n");
  72.     WriteOut("       -U   display in upper half of screen\n");
  73.     WriteOut("       -H   display in half width of screen\n");
  74.     WriteOut("       -O   display in outer half of screen\n");
  75.     WriteOut("       -W   pull workbench to front\n\n");
  76.     }
  77. else
  78.     {
  79.     if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L))
  80.         {
  81.         WBS=IntuitionBase->FirstScreen;
  82.  
  83.         strcpy(s1,"NewShell");
  84.         strcpy(s2,"CON:");
  85.         strcpy(s3,"NewShell/CLOSE from s:shell-startup");
  86.  
  87.         for(x=1; x<argc; x++)
  88.             {
  89.             if(argv[x][0]=='-')
  90.                 {
  91.                 switch(toupper(argv[x][1]))
  92.                     {
  93.                     case 'H':
  94.                         FULL=0;
  95.                         break;
  96.                     case 'U':
  97.                         TOP=1;
  98.                         break;
  99.                     case 'O':
  100.                         OUT=1;
  101.                         break;
  102.                     case 'S':
  103.                         strcpy(s1,argv[x]+2);
  104.                         break;
  105.                     case 'C':
  106.                         strcpy(s2,argv[x]+2);
  107.                         break;
  108.                     case 'T':
  109.                         strcpy(s3,argv[x]+2);
  110.                         break;
  111.                     case 'W':
  112.                         WBenchToFront();
  113.                         break;
  114.                     }
  115.                 }
  116.             }
  117.  
  118.         x=WBS->Width;
  119.         y=WBS->Height;
  120.         ry=(y%2);
  121.         rx=(x%2);
  122.  
  123.         sprintf(str,"%s %s%ld/%ld/%ld/%ld/%s\n",s1,s2,(FULL?0:(OUT?x/2:0)),(TOP?0:y/2),(FULL?x:(x/2)+rx),(y/2)+ry,s3);
  124.         Execute(str,NULL,NULL);
  125.         CloseLibrary((struct Library *)IntuitionBase);
  126.         }
  127.     }
  128. }
  129.