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

  1. #define MAX_NUM_ENVS 20
  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 _env env[MAX_NUM_ENVS];
  18.  
  19. enter_env_shells( name, initial_shell_header)
  20. char *name;
  21. struct env_shell *initial_shell_header;
  22.  
  23. {
  24.  
  25.     static int i = 0;
  26.     int key;
  27.  
  28.     if( i == 0 )
  29.     {
  30.         for ( i=0 ; i<MAX_NUM_ENVS ; i++ )
  31.         {
  32.             env[i].initial_shells = NULL;
  33.         }
  34.     }
  35.  
  36.     key = ((*name) * *(name+1))%MAX_NUM_ENVS;
  37.  
  38.     while( env[key].initial_shells != NULL )
  39.         key = ++key % MAX_NUM_ENVS ;
  40.  
  41.     env[key].initial_shells = initial_shell_header ;
  42.  
  43.  
  44.     env[key].name = (char *)XtMalloc((strlen(name) + 1));
  45.     strcpy( env[key].name, name);
  46.  
  47.  
  48. }
  49.  
  50. struct env_shell *get_env_shells(name)
  51. char *name;
  52.  
  53. {
  54.     int key;
  55.     key = ((*name) * *(name+1))%MAX_NUM_ENVS;
  56.  
  57.     while( env[key].initial_shells != NULL 
  58.         && strcmp(env[key].name, name) != 0)
  59.         key++;
  60.  
  61.  
  62.     return(env[key].initial_shells);
  63.  
  64. }
  65.  
  66.  
  67.  
  68.