home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / disks / misc / afcopy_v4.4 / sourcecode / afcopy_misc.c < prev    next >
C/C++ Source or Header  |  1981-06-29  |  36KB  |  1,111 lines

  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <exec/types.h>
  6. #include <exec/memory.h>
  7. #include <exec/execbase.h>
  8. #include <libraries/dos.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/gadgetclass.h>
  11. #include <proto/exec.h>
  12. #include <proto/dos.h>
  13. #include <proto/intuition.h>
  14. #include <proto/graphics.h>
  15. #include <libraries/reqtools.h>
  16. #include <libraries/dos.h>
  17. #include <clib/reqtools_protos.h>
  18. #include <clib/gadtools_protos.h>
  19. #include <clib/macros.h>
  20.  
  21.  
  22. #include "afcopy_defines.h"
  23. #include "afcopy_protos.h"
  24. #include "afcopy_vars.h"          /* define external vars */
  25.  
  26.  
  27. #define SPACEBETWEENGADGETS 0
  28.  
  29. char *upcase(char *str)
  30. {
  31.   // converts str into uppercase and returns a pointer to a new
  32.   // string.
  33.   // returns NULL if it fails.
  34.  
  35.   char *outstr=NULL;
  36.   short loop;
  37.  
  38.   if (outstr=strdup(str))
  39.   {
  40.     for (loop=0;str[loop];loop++) outstr[loop]=toupper(str[loop]);
  41.   }
  42.   return(outstr);
  43. }
  44.  
  45. short position(char *substr,char *str)
  46. {
  47.   // returns an character offset of a substring in a string
  48.   // this version is CASE SENSITIVE
  49.   // returns -1 if substring not found in the string
  50.  
  51.   char *whstr;
  52.   return((short)((whstr=strstr(str,substr)) ? (short)((LONG)whstr-(LONG)str) : -1));
  53. }
  54.  
  55. short iposition(char *substr,char *str)
  56. {
  57.   // returns an character offset of a substring in a string
  58.   // this version is CASE INSENSITIVE
  59.   // returns -1 if substring not found in the string
  60.   //      or -2 if memory allocation error
  61.  
  62.   short where=-2;
  63.   char *isubstr,*istr;
  64.  
  65.   if (isubstr=upcase(substr))
  66.   {
  67.     if (istr=upcase(str))
  68.     {
  69.       where=position(isubstr,istr);
  70.       free(isubstr);
  71.     }
  72.     free(istr);
  73.   }
  74.   return(where);
  75. }
  76.  
  77. void strpad(char *str,int newlength)
  78. {
  79.   short loop;
  80.  
  81. // slow way of doing it ..  while (strlen(str)<newlength) strcat(str," ");
  82.  
  83.   for (loop=strlen(str);loop<newlength;loop++)
  84.   {
  85.     str[loop]=32;
  86.   }
  87.   str[newlength]=0;
  88. }
  89.  
  90. void OutTextXY(struct Window *Win,UWORD X,UWORD Y, char *string)
  91. {
  92.   Move(Win->RPort,X,Y);
  93.   Text(Win->RPort,string,strlen(string) < 70 ? strlen(string) : 70);
  94. }
  95.  
  96. void addterm(char *s)
  97. {
  98.   if (s[strlen(s)-1]!=':' && s[strlen(s)-1]!='/') strcat(s,"/");
  99. }
  100.  
  101. void delterm(char *s)
  102. {
  103.   if (s[strlen(s)-1]=='/') s[strlen(s)-1]='\0';
  104. }
  105.  
  106. void getparent(char *s)
  107. {
  108.   int l;
  109.  
  110.   addterm(s);
  111.   l=strlen(s);
  112.   if (s[l-1]=='/')
  113.   {
  114.     l--;
  115.     while (s[l-1]!='/' && s[l-1]!=':') l--;
  116.     s[l]='\0';
  117.   }
  118. }
  119.  
  120. BOOL inrect(int X,int Y,int X1,int Y1,int X2, int Y2)
  121. {
  122.   if (X>=X1 && X<=X2 && Y>=Y1 && Y<=Y2) return(TRUE); else return(FALSE);
  123. }
  124.  
  125. void IoErrMsg(char *MsgString,int ErrorNum)
  126. {
  127.   switch (ErrorNum)
  128.   {
  129.     case 1:strcpy(MsgString,"Operation Cancelled");break;
  130.     case 103:strcpy(MsgString,"No Free Store");break;
  131.     case 105:strcpy(MsgString,"Task Table Full");break;
  132.     case 114:strcpy(MsgString,"Bad Template");break;
  133.     case 115:strcpy(MsgString,"Bad Number");break;
  134.     case 116:strcpy(MsgString,"Required Arg Missing");break;
  135.     case 117:strcpy(MsgString,"Key Needs Arg");break;
  136.     case 118:strcpy(MsgString,"Too Many Args");break;
  137.     case 119:strcpy(MsgString,"Unmatched Quotes");break;
  138.     case 120:strcpy(MsgString,"Line Too Long");break;
  139.     case 121:strcpy(MsgString,"File Not Object");break;
  140.     case 122:strcpy(MsgString,"Invalid Resident Library");break;
  141.     case 201:strcpy(MsgString,"No Default Dir");break;
  142.     case 202:strcpy(MsgString,"Object In Use");break;
  143.     case 203:strcpy(MsgString,"Object Exists");break;
  144.     case 204:strcpy(MsgString,"Dir Not Found");break;
  145.     case 205:strcpy(MsgString,"Object Not Found");break;
  146.     case 206:strcpy(MsgString,"Bad Stream Name");break;
  147.     case 207:strcpy(MsgString,"Object Too Large");break;
  148.     case 209:strcpy(MsgString,"Action Not Known");break;
  149.     case 210:strcpy(MsgString,"Invalid Component Name");break;
  150.     case 211:strcpy(MsgString,"Invalid Lock");break;
  151.     case 212:strcpy(MsgString,"Object Wrong Type");break;
  152.     case 213:strcpy(MsgString,"Disk Not Validated");break;
  153.     case 214:strcpy(MsgString,"Disk Write Protected");break;
  154.     case 215:strcpy(MsgString,"Rename Across Devices");break;
  155.     case 216:strcpy(MsgString,"Directory Not Empty");break;
  156.     case 217:strcpy(MsgString,"Too Many Levels");break;
  157.     case 218:strcpy(MsgString,"Device Not Mounted");break;
  158.     case 219:strcpy(MsgString,"Seek Error");break;
  159.     case 220:strcpy(MsgString,"Comment Too Big");break;
  160.     case 221:strcpy(MsgString,"Disk Full");break;
  161.     case 222:strcpy(MsgString,"Delete Protected");break;
  162.     case 223:strcpy(MsgString,"Write Protected");break;
  163.     case 224:strcpy(MsgString,"Read Protected or Read Error");break;
  164.     case 225:strcpy(MsgString,"Not a DOS Disk");break;
  165.     case 226:strcpy(MsgString,"No Disk");break;
  166.     case 232:strcpy(MsgString,"No More Entries");break;
  167.     case 233:strcpy(MsgString,"Is Soft Link");break;
  168.     case 234:strcpy(MsgString,"Object Linked");break;
  169.     case 235:strcpy(MsgString,"Bad Hunk");break;
  170.     case 236:strcpy(MsgString,"Not Implemented");break;
  171.     case 240:strcpy(MsgString,"Record Not Locked");break;
  172.     case 241:strcpy(MsgString,"Lock Collision");break;
  173.     case 242:strcpy(MsgString,"Lock Timeout");break;
  174.     case 243:strcpy(MsgString,"Unlock Error");break;
  175.     default:strcpy(MsgString,"Undefined Error!");break;
  176.   }
  177. }
  178.  
  179. /****************************************************************************************
  180.  
  181.           Main Gadget And Gadget Config Routines.
  182.  
  183. ****************************************************************************************/
  184.  
  185.  
  186. struct Gadget *createAllGadgets(struct Gadget **glistptr, void *vi,
  187.     UWORD topborder, struct Gadget *my_gads[])
  188. {
  189.   struct NewGadget ng;
  190.   struct Gadget *gad;
  191.  
  192.   gad = CreateContext(glistptr);
  193.  
  194.   ng.ng_TopEdge    = 1+topborder;
  195.   ng.ng_LeftEdge   = 286-18;
  196.   ng.ng_Width      = 17;
  197.   ng.ng_Height     = 11;
  198.   ng.ng_TextAttr   = &ScreenFontAttr;
  199.   ng.ng_VisualInfo = vi;
  200.  
  201.   ng.ng_GadgetText = "S";
  202.   ng.ng_GadgetID   = G_SortLeft;
  203.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  204.   my_gads[G_SortLeft] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  205.  
  206.   ng.ng_LeftEdge   -= (ng.ng_Width+1);
  207.   ng.ng_GadgetText = "D";
  208.   ng.ng_GadgetID   = G_DisplayLeft;
  209.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  210.   my_gads[G_DisplayLeft] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  211.  
  212.   ng.ng_GadgetText = "S";
  213.   ng.ng_LeftEdge   = 286+68+1;
  214.   ng.ng_GadgetID   = G_SortRight;
  215.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  216.   my_gads[G_SortRight] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  217.  
  218.   ng.ng_LeftEdge   += (ng.ng_Width+1);
  219.   ng.ng_GadgetText = "D";
  220.   ng.ng_GadgetID   = G_DisplayRight;
  221.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  222.   my_gads[G_DisplayRight] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  223.  
  224.  
  225.   ng.ng_Height     = (lines_per_side*FILEHEIGHT+83) / 23;
  226.   ng.ng_Width      = 68;
  227.   ng.ng_LeftEdge   = 286;
  228.   ng.ng_GadgetText = "_Copy";
  229.   ng.ng_GadgetID   = G_Copy;
  230.   my_gads[G_Copy] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  231.  
  232.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  233.   ng.ng_GadgetText = "_Swap";
  234.   ng.ng_GadgetID   = G_Swap;
  235.   my_gads[G_Swap] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  236.  
  237.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  238.   ng.ng_GadgetText = "_Rename";
  239.   ng.ng_GadgetID   = G_Rename;
  240.   my_gads[G_Rename] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  241.  
  242.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  243.   ng.ng_GadgetText = "_Delete";
  244.   ng.ng_GadgetID   = G_Delete;
  245.   my_gads[G_Delete] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  246.  
  247.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  248.   ng.ng_GadgetText = "Cl_one";
  249.   ng.ng_GadgetID   = G_Clone;
  250.   my_gads[G_Clone] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  251.  
  252.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  253.   ng.ng_GadgetText = "_View";
  254.   ng.ng_GadgetID   = G_View;
  255.   my_gads[G_View] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  256.  
  257.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  258.   ng.ng_GadgetText = "Re_ad";
  259.   ng.ng_GadgetID   = G_Read;
  260.   my_gads[G_Read] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  261.  
  262.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  263.   ng.ng_GadgetText = "_Edit";
  264.   ng.ng_GadgetID   = G_Edit;
  265.   my_gads[G_Edit] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  266.  
  267.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  268.   ng.ng_GadgetText = "_Hear";
  269.   ng.ng_GadgetID   = G_Hear;
  270.   my_gads[G_Hear] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  271.  
  272.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  273.   ng.ng_GadgetText = "_Info";
  274.   ng.ng_GadgetID   = G_Info;
  275.   my_gads[G_Info] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  276.  
  277.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  278.   ng.ng_GadgetText = "E_xecute";
  279.   ng.ng_GadgetID   = G_Execute;
  280.   my_gads[G_Execute] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  281.  
  282.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  283.   ng.ng_GadgetText = "Run";
  284.   ng.ng_GadgetID   = G_Run;
  285.   my_gads[G_Run] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  286.  
  287.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  288.   ng.ng_GadgetText = "Commen_t";
  289.   ng.ng_GadgetID   = G_Comment;
  290.   my_gads[G_Comment] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  291.  
  292.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  293.   ng.ng_GadgetText = "_Protect";
  294.   ng.ng_GadgetID   = G_Protect;
  295.   my_gads[G_Protect] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  296.  
  297.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  298.   ng.ng_GadgetText = "Archive";
  299.   ng.ng_GadgetID   = G_Archive;
  300.   my_gads[G_Archive] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  301.  
  302.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  303.   ng.ng_GadgetText = "_Unarc";
  304.   ng.ng_GadgetID   = G_Unarc;
  305.   my_gads[G_Unarc] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  306.  
  307.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  308.   ng.ng_GadgetText = "_MakeDir";
  309.   ng.ng_GadgetID   = G_Makedir;
  310.   my_gads[G_Makedir] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  311.  
  312.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  313.   ng.ng_GadgetText = "Mark";
  314.   ng.ng_GadgetID   = G_Mark;
  315.   my_gads[G_Mark] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  316.  
  317.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  318.   ng.ng_GadgetText = "UnMark";
  319.   ng.ng_GadgetID   = G_Unmark;
  320.   my_gads[G_Unmark] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  321.  
  322.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  323.   ng.ng_GadgetText = "Reverse";
  324.   ng.ng_GadgetID   = G_Reverse;
  325.   my_gads[G_Reverse] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  326.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  327.   ng.ng_GadgetText = "Dos";
  328.   ng.ng_GadgetID   = G_Dos;
  329.   my_gads[G_Dos] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  330.  
  331.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  332.   ng.ng_GadgetText = "_Batch";
  333.   ng.ng_GadgetID   = G_Batch;
  334.   my_gads[G_Batch] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  335.  
  336.   ng.ng_TopEdge    += SPACEBETWEENGADGETS+ng.ng_Height;
  337.   ng.ng_GadgetText = "Vo_lumes";
  338.   ng.ng_GadgetID   = G_Volumes;
  339.   my_gads[G_Volumes] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  340.  
  341.   ng.ng_LeftEdge   = filexpos[0]-1;
  342.   ng.ng_TopEdge    = lines_per_side * FILEHEIGHT+2+FILEYPOS+topborder; /* + 2 to avoid border clash! */
  343.   ng.ng_Width      = FILEWIDTH-12;
  344.   ng.ng_Height     = 14;
  345.   ng.ng_GadgetText = NULL;
  346.   ng.ng_GadgetID   = G_Pathleft;
  347.   my_gads[G_Pathleft] = gad = CreateGadget(STRING_KIND, gad, &ng,
  348.                      GTST_String,   NULL,
  349.                      GTST_MaxChars, 300,
  350.                      TAG_END);
  351.   ng.ng_LeftEdge   = filexpos[1]+14;
  352.   ng.ng_Width      = ng.ng_Width;
  353.   ng.ng_GadgetID   = G_Pathright;
  354.   my_gads[G_Pathright] = gad = CreateGadget(STRING_KIND, gad, &ng,
  355.                      GTST_String,   NULL,
  356.                      GTST_MaxChars, 300,
  357.                      TAG_END);
  358.   ng.ng_LeftEdge   = 268;
  359.   ng.ng_TopEdge    = FILEYPOS+topborder-1;
  360.   ng.ng_Width      = 17;
  361.   ng.ng_Height     = lines_per_side * FILEHEIGHT+2;
  362.   ng.ng_GadgetText = NULL;
  363.   ng.ng_GadgetID   = G_Sliderleft;
  364.   ng.ng_Flags      = NG_HIGHLABEL;
  365.   my_gads[G_Sliderleft] = gad = CreateGadget(SCROLLER_KIND, gad, &ng,
  366.                      GTSC_Top,         0,
  367.                      GTSC_Total,       1,
  368.                      GTSC_Visible,     1,
  369.                      GTSC_Arrows,      10,
  370.                      PGA_Freedom,      LORIENT_VERT,
  371.                      GT_Underscore,    '_',
  372.                      TAG_END);
  373.  
  374.   ng.ng_LeftEdge   = 355;
  375.   ng.ng_GadgetID   = G_Sliderright;
  376.   my_gads[G_Sliderright] = gad = CreateGadget(SCROLLER_KIND, gad, &ng,
  377.                      GTSC_Top,         0,
  378.                      GTSC_Total,       1,
  379.                      GTSC_Visible,     1,
  380.                      GTSC_Arrows,      10,
  381.                      PGA_Freedom,      LORIENT_VERT,
  382.                      GT_Underscore,    '_',
  383.                      TAG_END);
  384.   ng.ng_LeftEdge   = 268;
  385.   ng.ng_TopEdge   += ng.ng_Height+1;
  386.   ng.ng_Width      = 17;
  387.   ng.ng_Height     = 14;
  388.   ng.ng_GadgetText = "/";
  389.   ng.ng_GadgetID   = G_Parentleft;
  390.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  391.   my_gads[G_Parentleft] = gad = CreateGadget(BUTTON_KIND, gad, &ng,
  392.                      TAG_END);
  393.   ng.ng_Width      = 14;
  394.   ng.ng_LeftEdge  -= ng.ng_Width+1;
  395.   ng.ng_GadgetText = "R";
  396.   ng.ng_GadgetID   = G_Regetleft;
  397.   my_gads[G_Regetleft] = gad = CreateGadget(BUTTON_KIND, gad, &ng,
  398.                      TAG_END);
  399.  
  400.   ng.ng_LeftEdge   = 355;
  401.   ng.ng_Width      = 17;
  402.   ng.ng_GadgetID   = G_Parentright;
  403.   ng.ng_GadgetText = "/";
  404.   my_gads[G_Parentright] = gad = CreateGadget(BUTTON_KIND, gad, &ng,
  405.                      TAG_END);
  406.   ng.ng_LeftEdge  += ng.ng_Width+1;
  407.   ng.ng_Width      = 14;
  408.   ng.ng_GadgetText = "R";
  409.   ng.ng_GadgetID   = G_Regetright;
  410.   my_gads[G_Regetright] = gad = CreateGadget(BUTTON_KIND, gad, &ng,
  411.                      TAG_END);
  412.  
  413. /* Device Gadgets Bottom Left First Row */
  414.  
  415.   ng.ng_LeftEdge   = filexpos[0]-1;
  416.   ng.ng_TopEdge   += ng.ng_Height+1;
  417.   ng.ng_Width      = 45;
  418.   ng.ng_Height     = 10;
  419.   ng.ng_GadgetText = devicegadnames[0][0];
  420.   ng.ng_GadgetID   = G_Deviceleft0;
  421.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  422.   my_gads[G_Deviceleft0] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  423.   ng.ng_LeftEdge  += ng.ng_Width+2;
  424.   ng.ng_GadgetText = devicegadnames[0][1];
  425.   ng.ng_GadgetID   = G_Deviceleft1;
  426.   my_gads[G_Deviceleft1] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  427.   ng.ng_LeftEdge  += ng.ng_Width+2;
  428.   ng.ng_GadgetText = devicegadnames[0][2];
  429.   ng.ng_GadgetID   = G_Deviceleft2;
  430.   my_gads[G_Deviceleft2] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  431.   ng.ng_LeftEdge  += ng.ng_Width+2;
  432.   ng.ng_GadgetText = devicegadnames[0][3];
  433.   ng.ng_GadgetID   = G_Deviceleft3;
  434.   my_gads[G_Deviceleft3] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  435.   ng.ng_LeftEdge  += ng.ng_Width+2;
  436.   ng.ng_GadgetText = devicegadnames[0][4];
  437.   ng.ng_GadgetID   = G_Deviceleft4;
  438.   my_gads[G_Deviceleft4] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  439.   ng.ng_LeftEdge  += ng.ng_Width+2;
  440.   ng.ng_GadgetText = devicegadnames[0][5];
  441.   ng.ng_GadgetID   = G_Deviceleft5;
  442.   ng.ng_Width      = 44;
  443.   my_gads[G_Deviceleft5] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  444.  
  445. /* Device Gadgets Bottom Right First Row */
  446.  
  447.   ng.ng_LeftEdge   = 355;
  448.   ng.ng_Width      = 45;
  449.   ng.ng_GadgetText = devicegadnames[1][0];
  450.   ng.ng_GadgetID   = G_Deviceright0;
  451.   my_gads[G_Deviceright0] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  452.   ng.ng_LeftEdge  += ng.ng_Width+2;
  453.   ng.ng_GadgetText = devicegadnames[1][1];
  454.   ng.ng_GadgetID   = G_Deviceright1;
  455.   my_gads[G_Deviceright1] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  456.   ng.ng_LeftEdge  += ng.ng_Width+2;
  457.   ng.ng_GadgetText = devicegadnames[1][2];
  458.   ng.ng_GadgetID   = G_Deviceright2;
  459.   my_gads[G_Deviceright2] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  460.   ng.ng_LeftEdge  += ng.ng_Width+2;
  461.   ng.ng_GadgetText = devicegadnames[1][3];
  462.   ng.ng_GadgetID   = G_Deviceright3;
  463.   my_gads[G_Deviceright3] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  464.   ng.ng_LeftEdge  += ng.ng_Width+2;
  465.   ng.ng_GadgetText = devicegadnames[1][4];
  466.   ng.ng_GadgetID   = G_Deviceright4;
  467.   my_gads[G_Deviceright4] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  468.   ng.ng_LeftEdge  += ng.ng_Width+2;
  469.   ng.ng_GadgetText = devicegadnames[1][5];
  470.   ng.ng_GadgetID   = G_Deviceright5;
  471.   ng.ng_Width      = 44;
  472.   my_gads[G_Deviceright5] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  473.  
  474.  
  475. /* Device Gadgets Bottom Left Second Row */
  476.  
  477.   ng.ng_LeftEdge   = filexpos[0]-1;
  478.   ng.ng_Width      = 45;
  479.   ng.ng_TopEdge   += ng.ng_Height+1;
  480.   ng.ng_GadgetText = devicegadnames[0][6];
  481.   ng.ng_GadgetID   = G_Deviceleft6;
  482.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  483.   my_gads[G_Deviceleft6] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  484.   ng.ng_LeftEdge  += ng.ng_Width+2;
  485.   ng.ng_GadgetText = devicegadnames[0][7];
  486.   ng.ng_GadgetID   = G_Deviceleft7;
  487.   my_gads[G_Deviceleft7] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  488.   ng.ng_LeftEdge  += ng.ng_Width+2;
  489.   ng.ng_GadgetText = devicegadnames[0][8];
  490.   ng.ng_GadgetID   = G_Deviceleft8;
  491.   my_gads[G_Deviceleft8] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  492.   ng.ng_LeftEdge  += ng.ng_Width+2;
  493.   ng.ng_GadgetText = devicegadnames[0][9];
  494.   ng.ng_GadgetID   = G_Deviceleft9;
  495.   my_gads[G_Deviceleft9] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  496.   ng.ng_LeftEdge  += ng.ng_Width+2;
  497.   ng.ng_GadgetText = devicegadnames[0][10];
  498.   ng.ng_GadgetID   = G_Deviceleft10;
  499.   my_gads[G_Deviceleft10] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  500.   ng.ng_LeftEdge  += ng.ng_Width+2;
  501.   ng.ng_GadgetText = devicegadnames[0][11];
  502.   ng.ng_GadgetID   = G_Deviceleft11;
  503.   ng.ng_Width      = 44;
  504.   my_gads[G_Deviceleft11] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  505.  
  506. /* Device Gadgets Bottom Right Second Row */
  507.  
  508.   ng.ng_LeftEdge   = 355;
  509.   ng.ng_Width      = 45;
  510.   ng.ng_GadgetText = devicegadnames[1][6];
  511.   ng.ng_GadgetID   = G_Deviceright6;
  512.   my_gads[G_Deviceright6] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  513.   ng.ng_LeftEdge  += ng.ng_Width+2;
  514.   ng.ng_GadgetText = devicegadnames[1][7];
  515.   ng.ng_GadgetID   = G_Deviceright7;
  516.   my_gads[G_Deviceright7] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  517.   ng.ng_LeftEdge  += ng.ng_Width+2;
  518.   ng.ng_GadgetText = devicegadnames[1][8];
  519.   ng.ng_GadgetID   = G_Deviceright8;
  520.   my_gads[G_Deviceright8] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  521.   ng.ng_LeftEdge  += ng.ng_Width+2;
  522.   ng.ng_GadgetText = devicegadnames[1][9];
  523.   ng.ng_GadgetID   = G_Deviceright9;
  524.   my_gads[G_Deviceright9] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  525.   ng.ng_LeftEdge  += ng.ng_Width+2;
  526.   ng.ng_GadgetText = devicegadnames[1][10];
  527.   ng.ng_GadgetID   = G_Deviceright10;
  528.   my_gads[G_Deviceright10] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  529.   ng.ng_LeftEdge  += ng.ng_Width+2;
  530.   ng.ng_GadgetText = devicegadnames[1][11];
  531.   ng.ng_GadgetID   = G_Deviceright11;
  532.   ng.ng_Width      = 44;
  533.   my_gads[G_Deviceright11] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  534.  
  535. /* User Gadgets Bottom Left First Row */
  536.  
  537.   ng.ng_LeftEdge   = filexpos[0]-1;
  538.   ng.ng_TopEdge   += ng.ng_Height+1;
  539.   ng.ng_Width      = 55;
  540.   ng.ng_Height     = 10;
  541.   ng.ng_GadgetText = usergadnames[0][0];
  542.   ng.ng_GadgetID   = G_Userleft0;
  543.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  544.   my_gads[G_Userleft0] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  545.   ng.ng_LeftEdge  += ng.ng_Width+1;
  546.   ng.ng_GadgetText = usergadnames[0][1];
  547.   ng.ng_GadgetID   = G_Userleft1;
  548.   my_gads[G_Userleft1] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  549.   ng.ng_LeftEdge  += ng.ng_Width+1;
  550.   ng.ng_GadgetText = usergadnames[0][2];
  551.   ng.ng_GadgetID   = G_Userleft2;
  552.   my_gads[G_Userleft2] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  553.   ng.ng_LeftEdge  += ng.ng_Width+1;
  554.   ng.ng_GadgetText = usergadnames[0][3];
  555.   ng.ng_GadgetID   = G_Userleft3;
  556.   my_gads[G_Userleft3] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  557.   ng.ng_LeftEdge  += ng.ng_Width+1;
  558.   ng.ng_GadgetText = usergadnames[0][4];
  559.   ng.ng_GadgetID   = G_Userleft4;
  560.   my_gads[G_Userleft4] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  561.  
  562. /* User Gadgets Bottom Right First Row */
  563.  
  564.   ng.ng_LeftEdge   = 355;
  565.   ng.ng_GadgetText = usergadnames[1][0];
  566.   ng.ng_GadgetID   = G_Userright0;
  567.   my_gads[G_Userright0] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  568.   ng.ng_LeftEdge  += ng.ng_Width+1;
  569.   ng.ng_GadgetText = usergadnames[1][1];
  570.   ng.ng_GadgetID   = G_Userright1;
  571.   my_gads[G_Userright1] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  572.   ng.ng_LeftEdge  += ng.ng_Width+1;
  573.   ng.ng_GadgetText = usergadnames[1][2];
  574.   ng.ng_GadgetID   = G_Userright2;
  575.   my_gads[G_Userright2] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  576.   ng.ng_LeftEdge  += ng.ng_Width+1;
  577.   ng.ng_GadgetText = usergadnames[1][3];
  578.   ng.ng_GadgetID   = G_Userright3;
  579.   my_gads[G_Userright3] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  580.   ng.ng_LeftEdge  += ng.ng_Width+1;
  581.   ng.ng_GadgetText = usergadnames[1][4];
  582.   ng.ng_GadgetID   = G_Userright4;
  583.   my_gads[G_Userright4] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  584.  
  585.  
  586. /* User Gadgets Bottom Left Second Row */
  587.  
  588.   ng.ng_LeftEdge   = filexpos[0]-1;
  589.   ng.ng_TopEdge   += ng.ng_Height+0;
  590.   ng.ng_GadgetText = usergadnames[0][5];
  591.   ng.ng_GadgetID   = G_Userleft5;
  592.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  593.   my_gads[G_Userleft5] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  594.   ng.ng_LeftEdge  += ng.ng_Width+1;
  595.   ng.ng_GadgetText = usergadnames[0][6];
  596.   ng.ng_GadgetID   = G_Userleft6;
  597.   my_gads[G_Userleft6] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  598.   ng.ng_LeftEdge  += ng.ng_Width+1;
  599.   ng.ng_GadgetText = usergadnames[0][7];
  600.   ng.ng_GadgetID   = G_Userleft7;
  601.   my_gads[G_Userleft7] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  602.   ng.ng_LeftEdge  += ng.ng_Width+1;
  603.   ng.ng_GadgetText = usergadnames[0][8];
  604.   ng.ng_GadgetID   = G_Userleft8;
  605.   my_gads[G_Userleft8] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  606.   ng.ng_LeftEdge  += ng.ng_Width+1;
  607.   ng.ng_GadgetText = usergadnames[0][9];
  608.   ng.ng_GadgetID   = G_Userleft9;
  609.   my_gads[G_Userleft9] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  610.  
  611. /* User Gadgets Bottom Right Second Row */
  612.  
  613.   ng.ng_LeftEdge   = 355;
  614.   ng.ng_GadgetText = usergadnames[1][5];
  615.   ng.ng_GadgetID   = G_Userright5;
  616.   my_gads[G_Userright5] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  617.   ng.ng_LeftEdge  += ng.ng_Width+1;
  618.   ng.ng_GadgetText = usergadnames[1][6];
  619.   ng.ng_GadgetID   = G_Userright6;
  620.   my_gads[G_Userright6] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  621.   ng.ng_LeftEdge  += ng.ng_Width+1;
  622.   ng.ng_GadgetText = usergadnames[1][7];
  623.   ng.ng_GadgetID   = G_Userright7;
  624.   my_gads[G_Userright7] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  625.   ng.ng_LeftEdge  += ng.ng_Width+1;
  626.   ng.ng_GadgetText = usergadnames[1][8];
  627.   ng.ng_GadgetID   = G_Userright8;
  628.   my_gads[G_Userright8] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  629.   ng.ng_LeftEdge  += ng.ng_Width+1;
  630.   ng.ng_GadgetText = usergadnames[1][9];
  631.   ng.ng_GadgetID   = G_Userright9;
  632.   my_gads[G_Userright9] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  633.  
  634. /* User Gadgets Bottom Left third Row */
  635.  
  636.   ng.ng_LeftEdge   = filexpos[0]-1;
  637.   ng.ng_TopEdge   += ng.ng_Height+0;
  638.   ng.ng_GadgetText = usergadnames[0][10];
  639.   ng.ng_GadgetID   = G_Userleft10;
  640.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  641.   my_gads[G_Userleft10] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  642.   ng.ng_LeftEdge  += ng.ng_Width+1;
  643.   ng.ng_GadgetText = usergadnames[0][11];
  644.   ng.ng_GadgetID   = G_Userleft11;
  645.   my_gads[G_Userleft11] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  646.   ng.ng_LeftEdge  += ng.ng_Width+1;
  647.   ng.ng_GadgetText = usergadnames[0][12];
  648.   ng.ng_GadgetID   = G_Userleft12;
  649.   my_gads[G_Userleft12] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  650.   ng.ng_LeftEdge  += ng.ng_Width+1;
  651.   ng.ng_GadgetText = usergadnames[0][13];
  652.   ng.ng_GadgetID   = G_Userleft13;
  653.   my_gads[G_Userleft13] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  654.   ng.ng_LeftEdge  += ng.ng_Width+1;
  655.   ng.ng_GadgetText = usergadnames[0][14];
  656.   ng.ng_GadgetID   = G_Userleft14;
  657.   my_gads[G_Userleft14] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  658.  
  659. /* User Gadgets Bottom Right third Row */
  660.  
  661.   ng.ng_LeftEdge   = 355;
  662.   ng.ng_GadgetText = usergadnames[1][10];
  663.   ng.ng_GadgetID   = G_Userright10;
  664.   my_gads[G_Userright10] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  665.   ng.ng_LeftEdge  += ng.ng_Width+1;
  666.   ng.ng_GadgetText = usergadnames[1][11];
  667.   ng.ng_GadgetID   = G_Userright11;
  668.   my_gads[G_Userright11] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  669.   ng.ng_LeftEdge  += ng.ng_Width+1;
  670.   ng.ng_GadgetText = usergadnames[1][12];
  671.   ng.ng_GadgetID   = G_Userright12;
  672.   my_gads[G_Userright12] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  673.   ng.ng_LeftEdge  += ng.ng_Width+1;
  674.   ng.ng_GadgetText = usergadnames[1][13];
  675.   ng.ng_GadgetID   = G_Userright13;
  676.   my_gads[G_Userright13] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  677.   ng.ng_LeftEdge  += ng.ng_Width+1;
  678.   ng.ng_GadgetText = usergadnames[1][14];
  679.   ng.ng_GadgetID   = G_Userright14;
  680.   my_gads[G_Userright14] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
  681.  
  682. /*
  683.  * Keys used in underscore of gadgets are as follows...
  684.  *
  685.  * CSRDOVEAHXTPUM
  686.  * S Swap
  687.  * R Rename
  688.  * D Delete
  689.  * O Clone
  690.  * V View
  691.  * E Edit
  692.  * A Read
  693.  * H Hear
  694.  *
  695.  
  696.  * Keys that'll be used for other stuff
  697.  *
  698.  * ' Run
  699.  * + Mark All
  700.  * - Mark All
  701.  * * Reverse Marks
  702.  *
  703.  */
  704.  
  705. return(gad);
  706. }
  707.  
  708.  
  709. void blankusergads( void )
  710. {
  711.   int loop1,loop2;
  712.   for (loop1=0;loop1<2;loop1++)
  713.   {
  714.     for (loop2=0;loop2<10;loop2++)
  715.     {
  716.       strcpy(usergadnames[loop1][loop2],"");
  717.       strcpy(usergadactual[loop1][loop2],"");
  718.       usergadflags[loop1][loop2]=0;
  719.     }
  720.   }
  721. }
  722.  
  723. void strfcpy(char *dest,char *source,int from)
  724. {
  725.   /*
  726.      copy all chars from "source" to "dest" starting at offset "from"
  727.      (kinda the reverse from strncpy() )
  728.    */
  729.   int loop=from,pos=0;
  730.   if (from<=strlen(source)-1)
  731.   {
  732.     while (source[loop])
  733.     {
  734.       dest[pos]=source[loop];
  735.       loop++;
  736.       pos++;
  737.     }
  738.   }
  739.   dest[pos]=0;
  740. }
  741.  
  742.  
  743. void stripcr(char *s)   /* Strips \n From End Of String */
  744. {
  745.   if (s[strlen(s)-1]==10) s[strlen(s)-1]=0;
  746. }
  747.  
  748. void mfgets(char *str,int len,FILE *f)
  749. {
  750.   char c;
  751.  
  752.   fgets(str,len+2,f);  /* +1 for the ! and +1 cos array starts at 0 */
  753.   c=fgetc(f);
  754.   if (c!=10) ungetc(c,f);
  755.   stripcr(str);
  756. }
  757.  
  758. void swapem(short side,int i, int j)
  759. {
  760.   BOOL tag;
  761.   char string[MAX_FILE_LEN+1];
  762.   LONG type;
  763.   struct DateStamp ds;
  764.   strcpy(string,filename[side][i]);
  765.   strcpy(filename[side][i],filename[side][j]);
  766.   strcpy(filename[side][j],string);
  767.   tag=filetags[side][i];
  768.   filetags[side][i]=filetags[side][j];
  769.   filetags[side][j]=tag;
  770.   type=filetype[side][i];
  771.   filetype[side][i]=filetype[side][j];
  772.   filetype[side][j]=type;
  773.   type=filesize[side][i];
  774.   filesize[side][i]=filesize[side][j];
  775.   filesize[side][j]=type;
  776.   ds=filedate[side][i];
  777.   filedate[side][i]=filedate[side][j];
  778.   filedate[side][j]=ds;
  779. }
  780.  
  781. void qsortdirs(short side,int l,int r)
  782. {
  783.   int i,j;
  784.   int x;
  785.  
  786.  
  787. #ifdef DEBUGALL
  788.   puts("qsortdirs()");
  789. #endif
  790.  
  791.  
  792.   i=l;j=r;x=filetype[side][(l+r) / 2];
  793.   do
  794.   {
  795.     while (filetype[side][i]>x) i++;
  796.     while (x>filetype[side][j]) j--;
  797.     if (i<=j)
  798.     {
  799.       swapem(side,i,j);
  800.  
  801.       i++;j--;
  802.     }
  803.   } while (i<=j);
  804.   if (l<j) qsortdirs(side,l,j);
  805.   if (i<r) qsortdirs(side,i,r);
  806. }
  807.  
  808. void qsortall(short side,int l,int r)
  809. {
  810.   int i,j;
  811.   LONG sz;
  812.   char x[MAX_FILE_LEN+1];
  813.  
  814. #ifdef DEBUGALL
  815.   puts("qsortall()");
  816. #endif
  817.  
  818.   i=l;j=r;
  819.   switch(sortmode[side])
  820.   {
  821.     case S_NAME:
  822.       strcpy(x,filename[side][(l+r) / 2]);
  823.       break;
  824.     case S_DATE:
  825.       sz=filedate[side][(l+r) / 2].ds_Days;
  826.       break;
  827.     case S_SIZE:
  828.       sz=filesize[side][(l+r) / 2];
  829.       break;
  830.   }
  831.   do
  832.   {
  833.     switch (sortmode[side])
  834.     {
  835.       case S_DATE:
  836.         while (filedate[side][i].ds_Days>sz) i++;
  837.         while (sz>filedate[side][j].ds_Days) j--;
  838.         if (i<=j)
  839.         {
  840.           swapem(side,i,j);
  841.  
  842.           i++;j--;
  843.         }
  844.         break;
  845.       case S_NAME:
  846.         while (stricmp(filename[side][i],x)<0) i++;
  847.         while (stricmp(x,filename[side][j])<0) j--;
  848.         if (i<=j)
  849.         {
  850.           swapem(side,i,j);
  851.  
  852.           i++;j--;
  853.         }
  854.         break;
  855.       case S_SIZE:
  856.         while (filesize[side][i]>sz) i++;
  857.         while (sz>filesize[side][j]) j--;
  858.         if (i<=j)
  859.         {
  860.           swapem(side,i,j);
  861.  
  862.           i++;j--;
  863.         }
  864.         break;
  865.     }
  866.   } while (i<=j);
  867.   if (l<j) qsortall(side,l,j);
  868.   if (i<r) qsortall(side,i,r);
  869. }
  870.  
  871.  
  872. void qsortfiles(short side,int l,int r)
  873. {
  874.   int offs=0;
  875.  
  876.   if ((totalfiles[side]>0) && (sortmode[side]!=S_NONE) )
  877.   {
  878.     if (!mixfilesanddraws)
  879.     {
  880.       qsortdirs(side,l,r);
  881.       while (offs<totalfiles[side] && filetype[side][offs]>0) offs++;
  882.       qsortall(side,0, offs > 1 ? offs-1 : 0);
  883.       if (offs!=totalfiles[side])
  884.       {
  885.         qsortall(side,offs,totalfiles[side]-1);
  886.       }
  887.     }
  888.     else
  889.     {
  890.       qsortall(side,l,r);
  891.     }
  892.   }
  893. }
  894.  
  895.  
  896.  
  897. BOOL DoDiskInfo(short side,char *path)
  898. {
  899.   BOOL retval=TRUE;
  900.   BPTR FL;
  901.   struct InfoData *di;
  902.   char outputstr[51]="Error";
  903.  
  904. #ifdef DEBUG
  905.   puts("DoDiskInfo()");
  906. #endif
  907.  
  908.   if (pathok[side] && (FL=Lock(path,ACCESS_READ)))
  909.   {
  910.     if ((di=AllocMem(sizeof(struct InfoData),MEMF_PUBLIC)))
  911.     {
  912.       if (Info(FL,di))
  913.       {
  914.         sprintf(outputstr,"                 %3.0f%% %7.0fk",((float)di->id_NumBlocksUsed/(float)di->id_NumBlocks)*100,
  915.                (float)((di->id_NumBlocks-di->id_NumBlocksUsed) * di->id_BytesPerBlock) / (float)1024);
  916.         outputstr[35]='\0';
  917.       }
  918.       FreeMem(di,sizeof(struct InfoData));
  919.     }
  920.     UnLock(FL);
  921.   }
  922.   else
  923.   {
  924.     strcpy(outputstr,"No Directory");
  925.     retval=FALSE;
  926.   }
  927.   strpad(outputstr,MAX_FILE_LEN);
  928.   SetAPen(W->RPort,2);
  929.   SetBPen(W->RPort,0);
  930.   switch (side)
  931.   {
  932.     case 0:
  933.       OutTextXY(W,filexpos[side]+2,FONTBASELINE+topborder+3,outputstr);
  934.       DrawBevelBox(W->RPort,filexpos[side]-1,topborder+1,(FILEWIDTH+3)-17,11,
  935.                    GT_VisualInfo,vi,TAG_DONE);
  936.       break;
  937.     case 1:
  938.       OutTextXY(W,filexpos[side]+2+17,FONTBASELINE+topborder+3,outputstr);
  939.       DrawBevelBox(W->RPort,filexpos[side]-1+17,topborder+1,(FILEWIDTH+3)-17,11,
  940.                    GT_VisualInfo,vi,TAG_DONE);
  941.       break;
  942.   }
  943.   updateselected(side);
  944.   return(retval);
  945. }
  946.  
  947. void clearside(short side)
  948. {
  949.   SetAPen(W->RPort,0);
  950.   SetBPen(W->RPort,0);
  951.   RectFill(W->RPort,filexpos[side]+1,topborder+FILEYPOS,
  952.                     filexpos[side]+FILEWIDTH-1,topborder+FILEYPOS+(FILEHEIGHT*lines_per_side)-1);
  953. }
  954.  
  955. void updateslider(short side,int offset)
  956. {
  957.   GT_SetGadgetAttrs(my_gads[G_Sliderleft+side], W, NULL,
  958.                     GTSC_Top, offset,
  959.                     GTSC_Total, totalfiles[side],
  960.                     GTSC_Visible, totalfiles[side] < lines_per_side ? totalfiles[side] : lines_per_side,
  961.                     TAG_END);
  962. }
  963.  
  964. void replace(char *dest,char *compare,char *from,char *to)
  965. {
  966.  
  967.   /*
  968.      replace all occurences of "from" in "compare" with "to" and store result in "dest"
  969.      (note: this is dead usefull!!!)
  970.    */
  971.   int where;
  972.   char *mystring=strdup(compare);
  973.  
  974.   strcpy(dest,"");
  975.  
  976.   do
  977.   {
  978.     where=position(from,mystring);
  979.     if (where!=-1)
  980.     {
  981.       strncat(dest,mystring,where);                    /* copy first part of string */
  982.       strcat(dest,to);                                 /* add repeaced chars */
  983.       strfcpy(mystring,mystring,where+strlen(from));   /* copy rest of string  so we find first position of from */
  984.     }
  985.   } while (where!=-1);                                 /* keep doing until "from" is not found */
  986.   strcat(dest,mystring);                               /* add the rest of the string */
  987. }
  988.  
  989. void getextension(char *dest,char *source)
  990. {
  991.   int loop;
  992.  
  993.   strcpy(dest,"");
  994.   if (position(".",source)!=-1)
  995.   {
  996.     for (loop=strlen(source);source[loop-1]!='.';loop--);
  997.     strfcpy(dest,source,loop);
  998.   }
  999. }
  1000.  
  1001. void getname(char *dest,char *source)
  1002. {
  1003.   int loop;
  1004.  
  1005.   if (position(".",source)!=-1)
  1006.   {
  1007.     strcpy(dest,"");
  1008.     for (loop=strlen(source)-1;source[loop]!='.';loop--);
  1009.     strncpy(dest,source,loop);  /* copy from start to position of last "." in "source" -1 */
  1010.     dest[loop]='\0'; /* due to an error with strncpy!!! */
  1011.   }
  1012.   else strcpy(dest,source);
  1013. }
  1014.  
  1015.  
  1016. void createstring(char *tmpstr,char *batchstr,short side,int current,int opts)
  1017. {
  1018.   char temp[33]="";
  1019.  
  1020.  
  1021.   switch (opts)
  1022.   {
  1023.     case CS_ALL:
  1024.       replace(tmpstr,batchstr,"@F@",filename[side][current]);
  1025.       /* note: there is no, and should not be, a "break;" here. */
  1026.     case CS_NOFILES:
  1027.       getextension(temp,filename[side][current]);
  1028.       if (stricmp(temp,"")) replace(tmpstr,tmpstr,"@E@",temp);
  1029.       getname(temp,filename[side][current]);
  1030.       if (stricmp(temp,"")) replace(tmpstr,tmpstr,"@N@",temp);
  1031.       replace(tmpstr,tmpstr,"@<@",cpath[side]);
  1032.       replace(tmpstr,tmpstr,"@>@",cpath[1-side]);
  1033.       replace(tmpstr,tmpstr,"@S@",screenname);
  1034.       break;
  1035.   }
  1036. }
  1037.  
  1038.  
  1039. struct Gadget *createStatGadgets(struct Gadget **glistptr, void *vi,
  1040.     UWORD topborder, struct Gadget *gads[])
  1041. {
  1042.   struct NewGadget ng;
  1043.   struct Gadget *gad;
  1044.  
  1045. #ifdef DEBUG
  1046.   puts("createStatGadgets()");
  1047. #endif
  1048.  
  1049.   gad = CreateContext(glistptr);
  1050.  
  1051.   ng.ng_LeftEdge   = 5;
  1052.   ng.ng_TopEdge    = 1+topborder;
  1053.   ng.ng_Width      = STATWIDTH-10;
  1054.   ng.ng_Height     = 10;
  1055.   ng.ng_GadgetText = "Cancel";
  1056.   ng.ng_TextAttr   = &ScreenFontAttr;
  1057.   ng.ng_VisualInfo = vi;
  1058.   ng.ng_GadgetID   = G_StatCancel;
  1059.   ng.ng_Flags      = NG_HIGHLABEL|PLACETEXT_IN;
  1060.   gads[G_StatCancel] = gad = CreateGadget(BUTTON_KIND, gad, &ng,GT_Underscore, '_',TAG_END);
  1061.  
  1062.   ng.ng_LeftEdge   = 5;
  1063.   ng.ng_TopEdge    = topborder+55;
  1064.   ng.ng_Width      = STATWIDTH-10;
  1065.   ng.ng_Height     = 64;
  1066.   ng.ng_GadgetText = NULL;
  1067.   ng.ng_VisualInfo = vi;
  1068.   ng.ng_GadgetID   = G_ErrorList;
  1069.   ng.ng_Flags      = 0L;
  1070.   gads[G_ErrorList] = gad = CreateGadget(LISTVIEW_KIND, gad, &ng,
  1071.                                           GTLV_Labels,ErrorList,
  1072.                                           GTLV_Top,0,
  1073.                                           GTLV_ScrollWidth,20,
  1074.                                           TAG_END);
  1075.   return(gad);
  1076. }
  1077.  
  1078. struct Window *OpenStatWindow(void)
  1079.  
  1080. {
  1081.  
  1082.   struct Window *win;
  1083.   if (win=OpenWindowTags(NULL,
  1084.                           WA_Left,W->LeftEdge+STATLEFT,
  1085.                           WA_Top,W->TopEdge+STATTOP,
  1086.                           WA_Width,STATWIDTH,
  1087.                           WA_Height,STATHEIGHT,
  1088.                           WA_AutoAdjust,    FALSE,
  1089.                           WA_DragBar,       TRUE,
  1090.                           WA_DepthGadget,   TRUE,
  1091.                           WA_Activate,      TRUE,
  1092.                           WA_SmartRefresh,  TRUE,
  1093.                           WA_Zoom,          zoomcoords,
  1094.                           WA_IDCMP,         BUTTONIDCMP | LISTVIEWIDCMP,
  1095.                           WA_Title,"Status!",
  1096.                           WA_PubScreen, mysc,
  1097.                           WA_Gadgets,statglist,
  1098.                           WA_ScreenTitle,screentitle,
  1099.                           TAG_END))
  1100.   {
  1101.     GT_RefreshWindow(win, NULL);
  1102.   }
  1103.   return(win);
  1104. }
  1105.  
  1106. void remspaces(char *dest,char *source)
  1107. {
  1108.   /* remove white space space from the front of a string */
  1109.   while (source[0]==' ' || source[0]=='\t') strfcpy(dest,source,1);
  1110. }
  1111.