home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / DOpus4-GPL / Program / main3.c < prev    next >
C/C++ Source or Header  |  2000-01-27  |  18KB  |  705 lines

  1. /*
  2.  
  3. Directory Opus 4
  4. Original GPL release version 4.12
  5. Copyright 1993-2000 Jonathan Potter
  6.  
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. All users of Directory Opus 4 (including versions distributed
  22. under the GPL) are entitled to upgrade to the latest version of
  23. Directory Opus version 5 at a reduced price. Please see
  24. http://www.gpsoft.com.au for more information.
  25.  
  26. The release of Directory Opus 4 under the GPL in NO WAY affects
  27. the existing commercial status of Directory Opus 5.
  28.  
  29. */
  30.  
  31. #include "DOpus.h"
  32.  
  33. #define OLD_ACTION_Dummy            20000
  34.  
  35. #define OLD_ACTION_SET_USER         (OLD_ACTION_Dummy+0)
  36. #define OLD_ACTION_SET_GROUP        (OLD_ACTION_Dummy+1)
  37. #define OLD_ACTION_UID_TO_USERINFO  (OLD_ACTION_Dummy+2)
  38. #define OLD_ACTION_GID_TO_GROUPINFO (OLD_ACTION_Dummy+3)
  39.  
  40. #define ACTION_UID_TO_USERINFO      1037
  41. #define ACTION_GID_TO_GROUPINFO     1038
  42.  
  43. doparent(str)
  44. char *str;
  45. {
  46.     int i,b,c;
  47.  
  48.     c=strlen(str);
  49.     if (c==0) return(0);
  50.     i=c-1;
  51.     if (str[i]==':') {
  52.         char tempbuf[256];
  53.  
  54.         expand_path(str,tempbuf);
  55.         if ((LStrCmpI(str,tempbuf))==0 ||
  56.             !(doparent(tempbuf))) return(0);
  57.         strcpy(str,tempbuf);
  58.         return(1);
  59.     }
  60.     if (str[i]=='/') --i;
  61.     for (b=i;b>-1;b--) {
  62.         if (str[b]=='/') { ++b; break; }
  63.         if (str[b]==':') { ++b; break; }
  64.     }
  65.     if (b<0) expand_path("",str);
  66.     else str[b]=0;
  67.     return(1);
  68. }
  69.  
  70. doroot(str)
  71. char *str;
  72. {
  73.     int i,b,f=0,c;
  74.  
  75.     c=strlen(str);
  76.     if (c==0) return(0);
  77.     i=c;
  78.     for (b=0;b<i;b++) if (str[b]==':') { ++b; f=1; break; }
  79.     if (f==1 && b==i) {
  80.         char tempbuf[256];
  81.  
  82.         expand_path(str,tempbuf);
  83.         if ((LStrCmpI(str,tempbuf))==0 ||
  84.             !(doroot(tempbuf))) return(0);
  85.         strcpy(str,tempbuf);
  86.         return(1);
  87.     }
  88.     else if (f>0) str[b]=0;
  89.     else expand_path("",str);
  90.     return(1);
  91. }
  92.  
  93. addfile(dir,win,name,size,type,date,comment,protection,subtype,show,dispstr,addafter,ownerid,groupid)
  94. struct DirectoryWindow *dir;
  95. int win;
  96. char *name;
  97. int size,type;
  98. struct DateStamp *date;
  99. char *comment;
  100. int protection,subtype,show;
  101. char *dispstr;
  102. struct Directory *addafter;
  103. UWORD ownerid,groupid;
  104. {
  105.     struct Directory *addposition=NULL,*entry,*workfirst,*newentry;
  106.     int a,b,reverse=0,check=0,sortmethod,endwhile,selsortmethod;
  107.     char *description=NULL,*owner=NULL,*group=NULL,*ptr;
  108.  
  109.     if (status_iconified && status_flags&STATUS_ISINBUTTONS) return(1);
  110.  
  111.     if (config->sortflags&(1<<win)) reverse=1;
  112.  
  113.     selsortmethod=config->sortmethod[win];
  114.     if (selsortmethod<0 || selsortmethod>DISPLAY_LAST) selsortmethod=DISPLAY_NAME;
  115.  
  116.     if (type==ENTRY_DEVICE) sortmethod=DISPLAY_NAME;
  117.     else if (type>=ENTRY_DIRECTORY) {
  118.         switch (selsortmethod) {
  119.             case DISPLAY_SIZE:
  120.             case DISPLAY_FILETYPE:
  121.                 sortmethod=DISPLAY_NAME;
  122.                 break;
  123.             case DISPLAY_OWNER:
  124.             case DISPLAY_GROUP:
  125.             case DISPLAY_NETPROT:
  126.                 if (!AccountsBase) {
  127.                     sortmethod=DISPLAY_NAME;
  128.                     break;
  129.                 }
  130.             default:
  131.                 sortmethod=selsortmethod;
  132.                 break;
  133.         }
  134.     }
  135.     else {
  136.         if (!AccountsBase &&
  137.             (selsortmethod==DISPLAY_OWNER ||
  138.             selsortmethod==DISPLAY_GROUP ||
  139.             selsortmethod==DISPLAY_NETPROT))
  140.             sortmethod=DISPLAY_NAME;
  141.         else sortmethod=selsortmethod;
  142.     }
  143.  
  144.     if (win<0 || !dir || (type!=ENTRY_CUSTOM && protection&128 && config->hiddenbit))
  145.         return(-1);
  146.  
  147.     if (type<=ENTRY_FILE) {
  148.         if (config->showpat[0] && !(LMatchPatternI(config->showpatparsed,name)))
  149.             return(-1);
  150.         if (config->hidepat[0] && (LMatchPatternI(config->hidepatparsed,name)))
  151.             return(-1);
  152.     }
  153.  
  154.     if (type==ENTRY_CUSTOM) {
  155.         workfirst=dir->firstentry;
  156.         if (addafter) addposition=addafter;
  157.         else {
  158.             switch (subtype) {
  159.                 case CUSTOMENTRY_BUFFERLIST:
  160.                     entry=dir->firstentry;
  161.                     while (entry) {
  162.                         if (inter_sort(comment,entry->comment)<=0) {
  163.                             if (entry->last) addposition=entry->last;
  164.                             else addposition=(struct Directory *)-1;
  165.                             break;
  166.                         }
  167.                         entry=entry->next;
  168.                     }
  169.                     break;
  170.             }
  171.         }
  172.     }
  173.     else {
  174.         if (type!=ENTRY_DEVICE) {
  175.             for (a=0;a<DISPLAY_LAST+1;a++) {
  176.                 if (config->displaypos[win][a]==DISPLAY_FILETYPE && !description)
  177.                     description=getfiledescription(name,win);
  178.                 else if (AccountsBase) {
  179.                     if (config->displaypos[win][a]==DISPLAY_OWNER && !owner && ownerid) {
  180.                         if (dir->last_owner==ownerid) owner=dir->owner_name;
  181.                         else if (user_info &&
  182.                             !(EnvoyPacket(dir->realdevice,
  183.                                 ACTION_UID_TO_USERINFO,OLD_ACTION_UID_TO_USERINFO,ownerid,user_info))) {
  184.                             owner=user_info->ui_UserName;
  185.                             dir->last_owner=ownerid;
  186.                             strcpy(dir->owner_name,owner);
  187.                         }
  188.                     }
  189.                     else if (config->displaypos[win][a]==DISPLAY_GROUP && !group && groupid) {
  190.                         if (dir->last_group==groupid) group=dir->group_name;
  191.                         else if (group_info &&
  192.                             !(EnvoyPacket(dir->realdevice,
  193.                                 ACTION_GID_TO_GROUPINFO,OLD_ACTION_GID_TO_GROUPINFO,groupid,group_info))) {
  194.                             group=group_info->gi_GroupName;
  195.                             dir->last_group=groupid;
  196.                             strcpy(dir->group_name,group);
  197.                         }
  198.                     }
  199.                 }
  200.             }
  201.         }
  202.         workfirst=addposition=NULL;
  203.  
  204.         if (addafter) {
  205.             if (!(workfirst=addafter->next)) workfirst=addposition=addafter;
  206.         }
  207.         else {
  208.             switch (config->separatemethod[win]) {
  209.                 case SEPARATE_DIRSFIRST:
  210.                     if (dir->firstfile || dir->firstentry) {
  211.                         if (type<=ENTRY_FILE) {
  212.                             workfirst=dir->firstfile;
  213.                             if (!workfirst) {
  214.                                 workfirst=dir->firstentry;
  215.                                 while (workfirst->next) workfirst=workfirst->next;
  216.                                 addposition=workfirst;
  217.                             }
  218.                         }
  219.                         else workfirst=dir->firstentry;
  220.                     }
  221.                     check=1;
  222.                     break;
  223.                 case SEPARATE_FILESFIRST:
  224.                     if (dir->firstdir || dir->firstentry) {
  225.                         if (type>=ENTRY_DEVICE) {
  226.                             workfirst=dir->firstdir;
  227.                             if (!workfirst) {
  228.                                 workfirst=dir->firstentry;
  229.                                 while (workfirst->next) workfirst=workfirst->next;
  230.                                 addposition=workfirst;
  231.                             }
  232.                         }
  233.                         else workfirst=dir->firstentry;
  234.                     }
  235.                     check=1;
  236.                     break;
  237.                 default:
  238.                     workfirst=dir->firstentry;
  239.                     break;
  240.             }
  241.         }
  242.  
  243.         if (workfirst && !addposition) {
  244.             entry=workfirst; endwhile=0;
  245.             while (entry) {
  246.                 if (check) {
  247.                     switch (config->separatemethod[win]) {
  248.                         case SEPARATE_DIRSFIRST:
  249.                             if (entry->type<=ENTRY_FILE && type>=ENTRY_DEVICE) {
  250.                                 if (entry->last) addposition=entry->last;
  251.                                 else addposition=(struct Directory *)-1;
  252.                                 endwhile=1;
  253.                             }
  254.                             break;
  255.                         case SEPARATE_FILESFIRST:
  256.                             if (type<=ENTRY_FILE && entry->type>=ENTRY_DEVICE) {
  257.                                 if (entry->last) addposition=entry->last;
  258.                                 else addposition=(struct Directory *)-1;
  259.                                 endwhile=1;
  260.                             }
  261.                             break;
  262.                     }
  263.                 }
  264.                 switch (sortmethod) {
  265.                     case -1:
  266.                         if (!entry->next) {
  267.                             addposition=entry;
  268.                             endwhile=2;
  269.                         }
  270.                         break;
  271.  
  272.                     case DISPLAY_NAME:
  273. sortname:
  274.                         if ((reverse && (namesort(name,entry->name)>=0)) ||
  275.                             (!reverse && (namesort(name,entry->name)<=0))) endwhile=1;
  276.                         break;
  277.  
  278.                     case DISPLAY_SIZE:
  279.                         if (size==entry->size) goto sortname;
  280.                         if ((reverse && size>=entry->size) || (!reverse && size<=entry->size))
  281.                             endwhile=1;
  282.                         break;
  283.  
  284.                     case DISPLAY_PROTECT:
  285.                         a=(entry->protection&255)^15;
  286.                         b=(protection&255)^15;
  287.                         if (a==b) goto sortname;
  288.                         if ((reverse && b>=a) || (!reverse && b<=a)) endwhile=1;
  289.                         break;
  290.  
  291.                     case DISPLAY_DATE:
  292.                         if ((a=CompareDate(date,(&entry->date)))==0) goto sortname;
  293.                         if ((reverse && a>=0) || (!reverse && a<=0)) endwhile=1;
  294.                         break;
  295.  
  296.                     case DISPLAY_COMMENT:
  297.                         if (comment && entry->comment)
  298.                             a=LStrCmpI(comment,entry->comment);
  299.                         else if (comment) a=1;
  300.                         else if (entry->comment) a=-1;
  301.                         else a=0;
  302.                         if (a==0) goto sortname;
  303.                         if ((reverse && a>=0) || (!reverse && a<=0)) endwhile=1;
  304.                         break;
  305.  
  306.                     case DISPLAY_FILETYPE:
  307.                         if (description && entry->description)
  308.                             a=LStrCmpI(description,entry->description);
  309.                         else if (description) a=1;
  310.                         else if (entry->description) a=-1;
  311.                         else a=0;
  312.                         if (a==0) goto sortname;
  313.                         if ((reverse && a>=0) || (!reverse && a<=0)) endwhile=1;
  314.                         break;
  315.  
  316.                     case DISPLAY_OWNER:
  317.                         if (owner && entry->network && entry->network->owner)
  318.                             a=LStrCmpI(owner,entry->network->owner);
  319.                         else if (owner) a=1;
  320.                         else if (entry->network && entry->network->owner) a=-1;
  321.                         else a=0;
  322.                         if (a==0) goto sortname;
  323.                         if ((reverse && a>=0) || (!reverse && a<=0)) endwhile=1;
  324.                         break;
  325.  
  326.                     case DISPLAY_GROUP:
  327.                         if (group && entry->network && entry->network->group)
  328.                             a=LStrCmpI(group,entry->network->group);
  329.                         else if (group) a=1;
  330.                         else if (entry->network && entry->network->group) a=-1;
  331.                         else a=0;
  332.                         if (a==0) goto sortname;
  333.                         if ((reverse && a>=0) || (!reverse && a<=0)) endwhile=1;
  334.                         break;
  335.  
  336.                     case DISPLAY_NETPROT:
  337.                         a=entry->protection&(~255);
  338.                         b=protection&(~255);
  339.                         if (a==b) goto sortname;
  340.                         if ((reverse && b>=a) || (!reverse && b<=a)) endwhile=1;
  341.                         break;
  342.                 }
  343.                 if (endwhile) {
  344.                     if (endwhile==1) {
  345.                         if (entry->last) addposition=entry->last;
  346.                         else addposition=(struct Directory *)-1;
  347.                     }
  348.                     break;
  349.                 }
  350.                 entry=entry->next;
  351.             }
  352.         }
  353.         else workfirst=NULL;
  354.     }
  355.  
  356.     if (!(newentry=LibAllocPooled(dir_memory_pool,sizeof(struct Directory))))
  357.         return(0);
  358.     newentry->last=NULL;
  359.     newentry->next=NULL;
  360.     newentry->comment=NULL;
  361.     newentry->dispstr=NULL;
  362.     newentry->description=NULL;
  363.     newentry->network=NULL;
  364.  
  365.     if (addposition==(struct Directory *)-1) {    /* Add at head of list */
  366.         newentry->next=workfirst;
  367.         if (workfirst) workfirst->last=newentry;
  368.         switch (config->separatemethod[win]) {
  369.             case SEPARATE_DIRSFIRST:
  370.                 if (type<=ENTRY_FILE) dir->firstfile=newentry;
  371.                 break;
  372.             case SEPARATE_FILESFIRST:
  373.                 if (type>=ENTRY_DEVICE) dir->firstdir=newentry;
  374.                 break;
  375.         }
  376.         dir->firstentry=newentry;
  377.     }
  378.     else if (addposition) {    /* Add after this entry */
  379.         if (addposition->next) {
  380.             newentry->next=addposition->next;
  381.             addposition->next->last=newentry;
  382.         }
  383.         newentry->last=addposition;
  384.         addposition->next=newentry;
  385.         if (addposition->type>=ENTRY_DEVICE && type<=ENTRY_FILE)
  386.             dir->firstfile=newentry;
  387.         else if (addposition->type<=ENTRY_FILE && type>=ENTRY_DEVICE)
  388.             dir->firstdir=newentry;
  389.     }
  390.     else {
  391.         if (workfirst) {    /* Add at end of list */
  392.             while (workfirst->next) workfirst=workfirst->next;
  393.             workfirst->next=newentry;
  394.             newentry->last=workfirst;
  395.         }
  396.         else {    /* Starting a new list */
  397.             dir->firstentry=newentry;
  398.             if (type<=ENTRY_FILE) dir->firstfile=newentry;
  399.             else dir->firstdir=newentry;
  400.         }
  401.     }
  402.  
  403.     if (type==ENTRY_CUSTOM) {
  404.         if (dispstr && dispstr[0]) {
  405.             if (!(newentry->dispstr=LibAllocPooled(dir_memory_pool,strlen(dispstr)+1)))
  406.                 return(0);
  407.             strcpy(newentry->dispstr,dispstr);
  408.         }
  409.         lsprintf(newentry->name,"%ld",dir->total);
  410.     }
  411.     else {
  412.         LStrnCpy(newentry->name,name,30);
  413.         if (type!=ENTRY_DEVICE && description &&
  414.             (newentry->description=LibAllocPooled(dir_memory_pool,strlen(description)+1))) {
  415.             strcpy(newentry->description,description);
  416.         }
  417.         if (AccountsBase &&
  418.             (newentry->network=LibAllocPooled(dir_memory_pool,sizeof(struct NetworkStuff)))) {
  419.  
  420.             if (owner && (newentry->network->owner=LibAllocPooled(dir_memory_pool,strlen(owner)+1)))
  421.                 strcpy(newentry->network->owner,owner);
  422.  
  423.             if (group && (newentry->network->group=LibAllocPooled(dir_memory_pool,strlen(group)+1)))
  424.                 strcpy(newentry->network->group,group);
  425.  
  426.             ptr=newentry->network->net_protbuf;
  427.             for (a=FIBB_GRP_READ,b=0;a>=FIBB_GRP_DELETE;a--,b++) {
  428.                 if (!(protection&(1<<a))) *ptr++=globstring[STR_PROTBIT_RWED][0];
  429.                 else *ptr++=globstring[STR_PROTBIT_RWED][b+4];
  430.             }
  431.             *ptr++=' ';
  432.             for (a=FIBB_OTR_READ,b=0;a>=FIBB_OTR_DELETE;a--,b++) {
  433.                 if (!(protection&(1<<a))) *ptr++=globstring[STR_PROTBIT_RWED][0];
  434.                 else *ptr++=globstring[STR_PROTBIT_RWED][b+4];
  435.             }
  436.         }
  437.     }
  438.     newentry->size=size;
  439.     newentry->owner_id=ownerid;
  440.     newentry->group_id=groupid;
  441.  
  442.     if ((newentry->type=type)==ENTRY_DEVICE) {
  443.         switch (size) {
  444.             case DLT_DEVICE: comment="<DEV>"; break;
  445.             case DLT_DIRECTORY: comment="<ASN>"; break;
  446.             case DLT_VOLUME: comment="<VOL>"; break;
  447.             case DLT_LATE: comment="<DFR>"; break;
  448.             case DLT_NONBINDING: comment="<NBD>"; break;
  449.         }
  450.     }
  451.     if (date) {
  452.         newentry->date.ds_Days=date->ds_Days;
  453.         newentry->date.ds_Minute=date->ds_Minute;
  454.         newentry->date.ds_Tick=date->ds_Tick;
  455.     }
  456.  
  457.     if (comment && comment[0]) {
  458.         if ((newentry->comment=LibAllocPooled(dir_memory_pool,strlen(comment)+1)))
  459.             strcpy(newentry->comment,comment);
  460.         else if (type==ENTRY_CUSTOM) return(0);
  461.     }
  462.  
  463.     newentry->protection=protection;
  464.     if (type!=ENTRY_CUSTOM) getprot(protection,newentry->protbuf);
  465.  
  466.     if (date) seedate(date,newentry->datebuf,1);
  467.     newentry->subtype=subtype;
  468.     newentry->selected=FALSE;
  469.     switch (ENTRYTYPE(type)) {
  470.         case ENTRY_FILE:
  471.             ++dir->filetot;
  472.             dir->bytestot+=size;
  473.             break;
  474.         case ENTRY_DIRECTORY:
  475.             if (size>-1) dir->bytestot+=size;
  476.         case ENTRY_DEVICE:
  477.             ++dir->dirtot;
  478.             break;
  479.     }
  480.     ++dir->total;
  481.  
  482.     if (newentry->next) {
  483.         if (newentry->name[0] && (LStrCmpI(newentry->name,newentry->next->name))==0)
  484.             removefile(newentry->next,dir,win,0);
  485.         else if (type==ENTRY_CUSTOM && subtype==CUSTOMENTRY_BUFFERLIST &&
  486.             (LStrCmpI(newentry->comment,newentry->next->comment))==0)
  487.             removefile(newentry->next,dir,win,0);
  488.     }
  489.     if (show && type!=ENTRY_DEVICE) {
  490.         refreshwindow(win,1);
  491.         doposprop(win);
  492.     }
  493.     return((int)newentry);
  494. }
  495.  
  496. namesort(str1,str2)
  497. char *str1,*str2;
  498. {
  499.     int n1,n2;
  500.  
  501.     if (isdigit(str1[0]) && isdigit(str2[0])) {
  502.         n1=atoi(str1); n2=atoi(str2);
  503.         if (n1!=n2) return((n1-n2));
  504.         str1=getstrafternum(str1);
  505.         str2=getstrafternum(str2);
  506.     }
  507.     return(inter_sort(str1,str2));
  508. }
  509.  
  510. inter_sort(str1,str2)
  511. char *str1,*str2;
  512. {
  513.     if (UtilityBase) return(Stricmp(str1,str2));
  514.     return(LStrCmpI(str1,str2));
  515. }
  516.  
  517. char *getstrafternum(str)
  518. char *str;
  519. {
  520.     char *ptr=str;
  521.  
  522.     while (*ptr) {
  523.         if (!isdigit(*ptr)) break;
  524.         ++ptr;
  525.     }
  526.     return(ptr);
  527. }
  528.  
  529. void removefile(file,dir,win,show)
  530. struct Directory *file;
  531. struct DirectoryWindow *dir;
  532. int win,show;
  533. {
  534.     int ty=file->type,sz=file->size,se=file->selected;
  535.  
  536.     if (win<0 || !dir || (status_iconified && status_flags&STATUS_ISINBUTTONS)) return;
  537.  
  538.     if (file==last_selected_entry) last_selected_entry=NULL;
  539.  
  540.     if (file==dir->firstfile) {
  541.         if (file->next) {
  542.             dir->firstfile=file->next;
  543.             if (file->last) dir->firstfile->last=file->last;
  544.             else dir->firstfile->last=NULL;
  545.         }
  546.         else dir->firstfile=NULL;
  547.     }
  548.     else if (file==dir->firstdir) {
  549.         if (file->next) {
  550.             dir->firstdir=file->next;
  551.             if (file->last) dir->firstdir->last=file->last;
  552.             else dir->firstdir->last=NULL;
  553.         }
  554.         else dir->firstdir=NULL;
  555.     }
  556.     if (file==dir->firstentry) {
  557.         if (file->next) {
  558.             dir->firstentry=file->next;
  559.             if (dir->firstentry->next) dir->firstentry->next->last=dir->firstentry;
  560.             dir->firstentry->last=NULL;
  561.         }
  562.         else dir->firstentry=NULL;
  563.     }
  564.     else {
  565.         if (file->next) {
  566.             file->last->next=file->next;
  567.             file->next->last=file->last;
  568.         }
  569.         else file->last->next=NULL;
  570.     }
  571.     if (func_single_entry && func_single_entry==file) func_entry_deleted=1;
  572.     free_file_memory(file);
  573.     --dir->total;
  574.     if (ty<0) {
  575.         --dir->filetot; dir->bytestot-=sz;
  576.         if (se) {
  577.             --dir->filesel;
  578.             dir->bytessel-=sz;
  579.         }
  580.     }
  581.     else {
  582.         --dir->dirtot;
  583.         if (ty>0 && sz>0) dir->bytestot-=sz;
  584.         if (se) {
  585.             --dir->dirsel;
  586.             if (ty>0 && sz>0) dir->bytessel-=sz;
  587.         }
  588.     }
  589.     if (dir->offset>(dir->total-scrdata_dispwin_lines))
  590.         dir->offset=dir->total-scrdata_dispwin_lines;
  591.     if (dir->offset<0) dir->offset=0;
  592.     if (show) refreshwindow(win,1);
  593. }
  594.  
  595. dorun(name,state,workbench)
  596. char *name;
  597. int state,workbench;
  598. {
  599.     char argbuf[256],louise[80],buf[256];
  600.     int rec,len;
  601.     struct dopusfuncpar par;
  602.  
  603.     argbuf[0]=0;
  604.     if (workbench) {
  605.         buf[0]=FC_WORKBENCH;
  606.         buf[1]=0;
  607.     }
  608.     else buf[0]=0;
  609.     StrConcat(buf,"\"",256);
  610.     StrConcat(buf,name,256);
  611.     StrConcat(buf,"\"",256);
  612.  
  613.     len=256-strlen(buf);
  614.     if (state) {
  615.         lsprintf(louise,globstring[STR_ENTER_ARGUMENTS_FOR],BaseName(name));
  616.         if (!(rec=whatsit(louise,len,argbuf,globstring[STR_SKIP]))) {
  617.             myabort();
  618.             return(-1);
  619.         }
  620.         if (rec==2) return(-2);
  621.     }
  622.     else rec=1;
  623.     if (!rec) {
  624.         myabort();
  625.         return(0);
  626.     }
  627.     if (argbuf[0]) {
  628.         StrConcat(buf," ",256);
  629.         StrConcat(buf,argbuf,256);
  630.     }
  631.     defaultpar(&par);
  632.     dofunctionstring(buf,NULL,BaseName(name),&par);
  633.     return(1);
  634. }
  635.  
  636. void busy()
  637. {
  638.     if (!(status_flags&STATUS_BUSY)) {
  639.         size_gadgets[0].GadgetType=GTYP_BOOLGADGET;
  640.         size_gadgets[1].GadgetType=GTYP_BOOLGADGET;
  641.         if (!Window->FirstRequest) {
  642.             InitRequester(&dopus_busy_requester);
  643.             dopus_busy_requester.Flags=NOISYREQ;
  644.             Request(&dopus_busy_requester,Window);
  645.         }
  646.         endnotifies();
  647.         status_flags|=STATUS_BUSY;
  648.     }
  649.     SetBusyPointer(Window);
  650. }
  651.  
  652. void unbusy()
  653. {
  654.     if (status_flags&STATUS_BUSY) {
  655.         struct Message *msg;
  656.  
  657.         if (Window->FirstRequest) EndRequest(&dopus_busy_requester,Window);
  658.         flushidcmp();
  659.         while (msg=GetMsg(count_port)) ReplyMsg(msg);
  660.         startnotifies();
  661.         size_gadgets[0].GadgetType=GTYP_SIZING;
  662.         size_gadgets[1].GadgetType=GTYP_SIZING;
  663.         status_flags&=~STATUS_BUSY;
  664.     }
  665.     ClearPointer(Window);
  666. }
  667.  
  668. void flushidcmp()
  669. {
  670.     while (getintuimsg()) ReplyMsg((struct Message *)IMsg);
  671. }
  672.  
  673. void setnullpointer(wind)
  674. struct Window *wind;
  675. {
  676.     SetPointer(wind,null_pointer,1,16,0,0);
  677. }
  678.  
  679. void free_file_memory(file)
  680. struct Directory *file;
  681. {
  682.     if (file) {
  683.         if (file->comment)
  684.             LibFreePooled(dir_memory_pool,file->comment,strlen(file->comment)+1);
  685.  
  686.         if (file->type==ENTRY_CUSTOM && file->dispstr)
  687.             LibFreePooled(dir_memory_pool,file->dispstr,strlen(file->dispstr)+1);
  688.  
  689.         if (file->description)
  690.             LibFreePooled(dir_memory_pool,file->description,strlen(file->description)+1);
  691.  
  692.         if (file->network) {
  693.             if (file->network->owner)
  694.                 LibFreePooled(dir_memory_pool,file->network->owner,strlen(file->network->owner)+1);
  695.  
  696.             if (file->network->group)
  697.                 LibFreePooled(dir_memory_pool,file->network->group,strlen(file->network->group)+1);
  698.  
  699.             LibFreePooled(dir_memory_pool,file->network,sizeof(struct NetworkStuff));
  700.         }
  701.  
  702.         LibFreePooled(dir_memory_pool,file,sizeof(struct Directory));
  703.     }
  704. }
  705.