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

  1. #define MAX_NUM_WIDGETS  200
  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. extern char *string[];
  18.  
  19. static struct _widget_help widget_help[ MAX_NUM_WIDGETS ];
  20.  
  21. enter_hash_help( widget_ptr, help_msg )
  22. Widget widget_ptr;
  23. char *help_msg;
  24.  
  25. {
  26.  
  27.     struct _widget_help *help_item;
  28.     static int i = 0;
  29.     int key;
  30.  
  31.     if( i == 0)
  32.     {
  33.         for ( i =0; i<MAX_NUM_WIDGETS; i++)
  34.         {
  35.             widget_help[i].widget_ptr= NULL;
  36.         }
  37.     }
  38.  
  39.     if( help_msg == NULL )
  40.         return;
  41.  
  42.     key = ((long)(widget_ptr))%MAX_NUM_WIDGETS;
  43.  
  44.     while( widget_help[key].widget_ptr != NULL)
  45.         key = ++key%MAX_NUM_WIDGETS;
  46.     widget_help[key].widget_ptr = widget_ptr;
  47.     /*      printf(" help_msg %s\n",help_msg);
  48. */
  49.     widget_help[key].help_msg = (char *)malloc(
  50.         (strlen(help_msg)+1) * sizeof( char ));
  51.  
  52.     strcpy(widget_help[key].help_msg , help_msg);
  53.  
  54.     return;
  55. }
  56.  
  57.  
  58. char *get_hash_help(widget_ptr)
  59. Widget widget_ptr;
  60. {
  61.  
  62.     int key;
  63.  
  64.     key = ((long)widget_ptr)%MAX_NUM_WIDGETS;
  65.  
  66.     /*printf("  %d   key\n", key);
  67.  
  68.     printf( "widget_ptr %d  widget_he  %d\n", widget_ptr, widget_help[key].widget_ptr);
  69. */
  70.     while(widget_ptr != widget_help[key].widget_ptr)
  71.     {
  72.         key++;
  73.         if( key > MAX_NUM_WIDGETS )
  74.             return(NULL);
  75.     }
  76.     /*printf("msg   %s\n", widget_help[key].help_msg);
  77. */
  78.  
  79.  
  80.     return(widget_help[key].help_msg);
  81. }
  82.