home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume4 / xgen / part03 / hash_shell_descrip.c < prev    next >
C/C++ Source or Header  |  1989-06-29  |  1KB  |  69 lines

  1. #define MAX_NUM_SHELLS 50
  2. #include <stdio.h>
  3. #include <X11/IntrinsicP.h>
  4. #include <X11/Intrinsic.h>
  5. #include <X11/CompositeP.h>
  6. #include <X11/CommandP.h>
  7. #include <X11/LabelP.h>
  8. #include <X11/Box.h>
  9. #include <X11/StringDefs.h>
  10. #include <X11/Shell.h>
  11. #include <X11/Viewport.h>
  12. #include <X11/Form.h>
  13. #include <X11/Core.h>
  14. #include <X11/VPaned.h>
  15. #include "application.h"
  16.  
  17. static struct shell *app_shell[MAX_NUM_SHELLS];
  18.  
  19. enter_shell_descrip( pres_shell)
  20. struct shell *pres_shell;
  21. {
  22.  
  23.     static int i = 0;
  24.     int key;
  25.     char *name;
  26.  
  27.     if( i == 0 )
  28.     {
  29.         for ( i=0 ; i<MAX_NUM_SHELLS ; i++ )
  30.         {
  31.             app_shell[i] = NULL;
  32.         }
  33.     }
  34.  
  35.     name = pres_shell->name;
  36.  
  37.     key = ((*name) * *(name+1))%MAX_NUM_SHELLS;
  38.  
  39.  
  40.     while( app_shell[key] != NULL )
  41.         key = ++key%MAX_NUM_SHELLS;
  42.  
  43.     app_shell[key] = pres_shell;
  44.  
  45. }
  46.  
  47. struct shell *get_shell(name)
  48. char *name;
  49.  
  50. {
  51.     int key;
  52.  
  53.     key = ((*name) * *(name+1))%MAX_NUM_SHELLS;
  54.  
  55.  
  56.     while( strcmp(app_shell[key]->name, name) != 0)
  57.  
  58.     {
  59.         key++;
  60.         if( app_shell[key] == NULL )
  61.         {
  62.             fprintf(stderr, "shell %s: Not found.\n", name );
  63.             return( NULL );
  64.         }
  65.     }
  66.  
  67.     return(app_shell[key]);
  68. }
  69.