home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / sun / volume1 / tooltool2.1c / part02 / symbols.c < prev   
Encoding:
C/C++ Source or Header  |  1989-06-06  |  3.9 KB  |  131 lines

  1. /************************************************************************/
  2. /*    Copyright 1988 by Chuck Musciano and Harris Corporation        */
  3. /*                                    */
  4. /*    Permission to use, copy, modify, and distribute this software    */
  5. /*    and its documentation for any purpose and without fee is    */
  6. /*    hereby granted, provided that the above copyright notice    */
  7. /*    appear in all copies and that both that copyright notice and    */
  8. /*    this permission notice appear in supporting documentation, and    */
  9. /*    that the name of Chuck Musciano and Harris Corporation not be    */
  10. /*    used in advertising or publicity pertaining to distribution    */
  11. /*    of the software without specific, written prior permission.    */
  12. /*    Chuck Musciano and Harris Corporation make no representations    */
  13. /*    about the suitability of this software for any purpose.  It is    */
  14. /*    provided "as is" without express or implied warranty.        */
  15. /*                                    */
  16. /*    The sale of any product based wholely or in part upon the     */
  17. /*    technology provided by tooltool is strictly forbidden without    */
  18. /*    specific, prior written permission from Harris Corporation.    */
  19. /*    Tooltool technology includes, but is not limited to, the source    */
  20. /*    code, executable binary files, specification language, and    */
  21. /*    sample specification files.                    */
  22. /************************************************************************/
  23.  
  24. #include    <stdio.h>
  25. #include    <ctype.h>
  26. #include    <sys/types.h>
  27. #include    <sys/dir.h>
  28. #include    <pwd.h>
  29.  
  30. #include    <suntool/sunview.h>
  31. #include    <suntool/icon_load.h>
  32.  
  33. #include    "tooltool.h"
  34.  
  35. PRIVATE    s_ptr    symbols = NULL;
  36.  
  37. /************************************************************************/
  38. PRIVATE    s_ptr    create_symbol(name, sp)
  39.  
  40. char    *name;
  41. s_ptr    *sp;
  42.  
  43. {
  44.     while (*sp)
  45.        if (strcmp(name, (*sp)->name) < 0)
  46.           sp = &((*sp)->left);
  47.        else
  48.           sp = &((*sp)->right);
  49.     *sp = (s_ptr) safe_malloc(sizeof(s_data));
  50.     (*sp)->name = strsave(name);
  51.     (*sp)->kind = SYMBOL_SYMBOL;
  52.     (*sp)->gadget = NULL;
  53.     (*sp)->dialog = NULL;
  54.     (*sp)->left = NULL;
  55.     (*sp)->right = NULL;
  56.     (*sp)->value = (v_ptr) safe_malloc(sizeof(v_data));
  57.     (*sp)->value->kind = V_NOTHING;
  58.     (*sp)->value->number = 0.0;
  59.     (*sp)->value->str = "";
  60.     (*sp)->value->value = NULL;
  61.     (*sp)->value->left = NULL;
  62.     (*sp)->value->right = NULL;
  63.     (*sp)->value->index = NULL;
  64.     return(*sp);
  65. }
  66.     
  67. /************************************************************************/
  68. EXPORT    s_ptr    tt_find_symbol(name)
  69.  
  70. char    *name;
  71.  
  72. {    s_ptr    s;
  73.     int    i;
  74.  
  75.     for (s = symbols; s; )
  76.        if ((i = strcmp(name, s->name)) == 0)
  77.           break;
  78.        else if (i < 0)
  79.           s = s->left;
  80.        else
  81.           s = s->right;
  82.     if (s == NULL)
  83.        s = create_symbol(name, &symbols);
  84.     return(s);
  85. }
  86.  
  87. /************************************************************************/
  88. EXPORT    v_ptr    tt_get_value(s)
  89.  
  90. s_ptr    s;
  91.  
  92. {    v_ptr    v;
  93.     static    char    buf[20];
  94.  
  95.     if (s == NULL)
  96.        return(NULL);
  97.     else if (s->kind == SYMBOL_SYMBOL)
  98.        return(s->value);
  99.     else if (s->kind == SYMBOL_DIALOG)
  100.        abend("attempted to get value of dialog box %s", s->name);
  101.     else {
  102.        switch (s->gadget->kind) {
  103.           case GADGET_TEXT   : v = tt_string_result(panel_get(s->gadget->panel_item, PANEL_VALUE));
  104.                       break;
  105.           case GADGET_CHOICE : 
  106.           case GADGET_SLIDER : v = tt_int_result(panel_get(s->gadget->panel_item, PANEL_VALUE));
  107.                       break;
  108. /*          case GADGET_LABEL  : v = tt_string_result(panel_get(s->gadget->panel_item, PANEL_LABEL_STRING));
  109.                          break;*/
  110.           default         : v = tt_int_result(0);
  111.           }
  112.        v->kind |= V_GADGET;
  113.        v->gadget = s->gadget;
  114.        return(v);
  115.        }
  116. }
  117.  
  118. /************************************************************************/
  119. EXPORT    tt_make_intrinsic_symbols()
  120.  
  121. {    s_ptr    interval;
  122.  
  123.     tt_mouse_x = tt_find_symbol("mouse_x");
  124.     tt_mouse_y = tt_find_symbol("mouse_y");
  125.     interval = tt_find_symbol("interval");
  126.     interval->value->kind |= V_INTERVAL;
  127.     tt_delimiters = tt_find_symbol("delimiters");
  128.     tt_delimiters->value->kind = 0;
  129.     tt_delimiters->value->str = " \t\n\r\"'";
  130. }
  131.