home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / XARCHIE0.TAR / actions.c next >
Encoding:
C/C++ Source or Header  |  1991-08-27  |  3.6 KB  |  144 lines

  1. /*
  2.  * actions.c : Widget action procedures
  3.  *
  4.  * This file defines the global actionTable used in XtAppAddActions() and
  5.  * defines the action procedures, except those used on the settingsPanel
  6.  * which are imported. Eventually there may be more actions, and they'll
  7.  * be put here.
  8.  *
  9.  * George Ferguson, ferguson@cs.rochester.edu, 21 Aug 1991.
  10.  *
  11.  */
  12.  
  13. #include <X11/Intrinsic.h>
  14. #include <X11/StringDefs.h>
  15. #include <X11/Xaw/Text.h>
  16. #include <X11/Xaw/Cardinals.h>
  17. #include "procquery.h"
  18. #include "xarchie.h"
  19. #include "types.h"
  20. #include "appres.h"
  21. #include "db.h"
  22. #include "settings.h"        /* for settings actions */
  23. #include "ftp.h"
  24. #include "alert.h"
  25.  
  26. /*
  27.  * Functions defined here
  28.  */
  29. static void quitAction(),queryAction(),ftpAction();
  30.  
  31. /*
  32.  * Data defined here:
  33.  */
  34. XtActionsRec actionTable[15] = {    /* check size in actions.h! */
  35.     { "quit",            quitAction },
  36.     { "query",            queryAction },
  37.     { "ftp",            ftpAction },
  38.     { "settings",        settingsAction },
  39.     { "apply-settings",        applySettingsAction },
  40.     { "default-settings",    defaultSettingsAction },
  41.     { "done-settings",        doneSettingsAction },
  42.     { "set-search-type",    setSearchTypeAction },
  43.     { "set-search-type-now",    setSearchTypeNowAction },
  44.     { "set-sort-type",        setSortTypeAction },
  45.     { "set-sort-type-now",    setSortTypeNowAction },
  46.     { "set-host",        setHostAction },
  47.     { "set-host-now",        setHostNowAction },
  48.     { "set-nice-level",        setNiceLevelAction },
  49.     { "set-nice-level-now",    setNiceLevelNowAction },
  50. };
  51.  
  52. /*    -    -    -    -    -    -    -    -    */
  53.  
  54. /*ARGSUSED*/
  55. static void
  56. quitAction(w,event,params,num_params)
  57. Widget w;
  58. XEvent *event;
  59. String *params;
  60. Cardinal *num_params;
  61. {
  62.     XtDestroyApplicationContext(appContext);
  63.     exit(0);
  64. }
  65.  
  66. /*ARGSUSED*/
  67. static void
  68. queryAction(w,event,params,num_params)
  69. Widget w;
  70. XEvent *event;
  71. String *params;
  72. Cardinal *num_params;
  73. {
  74.     Arg args[1];
  75.     char *s;
  76.     int len;
  77.     Boolean gif;
  78.  
  79.     XtSetArg(args[0],XtNstring,&s);
  80.     XtGetValues(searchText,args,ONE);
  81.     if (*s == '\0') {
  82.     alert0("No search term specified.");
  83.     return;
  84.     }
  85. #ifndef DONT_CATCH_GIFS
  86.     len = strlen(s);
  87.     gif = False;
  88.     switch (appResources.searchType) {
  89.     case GfExact:
  90.         gif = ((len > 4 &&
  91.             (!strcmp(s+len-4,".gif") || !strcmp(s+len-4,".GIF"))) ||
  92.            (len > 6 &&
  93.             (!strcmp(s+len-6,".gif.Z") || !strcmp(s+len-6,".GIF.Z"))));
  94.         break;
  95.     case GfSubstr:
  96.     case GfExactSubstr:
  97.     case GfSubcase:
  98.     case GfExactSubcase:
  99.         gif = (sindex(s,"gif") || sindex(s,"GIF"));
  100.         break;
  101.     case GfRegexp:
  102.     case GfExactRegexp:
  103.         gif = (re_comp(s) == NULL &&
  104.            (re_exec("@PrObAbLyNoTaFiLe@.gif") ||
  105.             re_exec("@PrObAbLyNoTaFiLe@.gif.Z")));
  106.         break;
  107.     }
  108.     if (gif) {
  109.     if (!confirm0("Your search term will match GIFs. Do it anyway?"))
  110.         return;
  111.     else if (appResources.niceLevel <= 0 &&
  112.          !confirm0("Really do it without increasing niceness?"))
  113.         return;
  114.     }
  115. #endif /* DONT_CATCH_GIFS */
  116.     if (appResources.sortType == GfInvdate)
  117.     procquery(appResources.archieHost,s,appResources.maxHits,
  118.           appResources.offset,appResources.searchType,True,0);
  119.     else
  120.     procquery(appResources.archieHost,s,appResources.maxHits,
  121.           appResources.offset,appResources.searchType,False,0);
  122. }
  123.  
  124. /*ARGSUSED*/
  125. static void
  126. ftpAction(w,event,params,num_params)
  127. Widget w;
  128. XEvent *event;
  129. String *params;
  130. Cardinal *num_params;
  131. {
  132.     if (selectedHostEntry == HOST_NULL || selectedLocEntry == LOC_NULL ||
  133.     selectedFileEntry == FILE_NULL) {
  134.     alert0("You must specify a host, location and file before invoking ftp()");
  135.     return;
  136.     }
  137.     if (selectedFileEntry->modes[0] == 'd') {
  138.     alert0("Sorry, can't fetch whole directories yet.");
  139.     return;
  140.     }
  141.     ftp(selectedHostEntry->hostname,selectedLocEntry->linkpath,
  142.     selectedFileEntry->name);
  143. }
  144.