home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / x / volume10 / contool / part01 / load.c < prev    next >
C/C++ Source or Header  |  1990-10-30  |  3KB  |  95 lines

  1. /************************************************************************/
  2. /*    Copyright 1988-1990 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.  This     */
  15. /*    software may not be sold without the prior explicit permission    */
  16. /*    of Harris Corporation.                        */
  17. /************************************************************************/
  18.  
  19. /************************************************************************/
  20. /*                                    */
  21. /*    load.c        contool load dialog manager            */
  22. /*                                    */
  23. /************************************************************************/
  24.  
  25. #include    <stdio.h>
  26. #include    <sys/param.h>
  27. #include    <sys/types.h>
  28. #include    <xview/xview.h>
  29. #include    <xview/panel.h>
  30. #include    <xview/xv_xrect.h>
  31.  
  32. #include    "manifest.h"
  33. #include    "contool.h"
  34. #include    "contool_ui.h"
  35.  
  36. PRIVATE    contool_load_objects    *contool_load = NULL;
  37.  
  38. /************************************************************************/
  39. EXPORT    Menu_item    popup_load_config(item, op)
  40.  
  41. Menu_item    item;
  42. Menu_generate    op;
  43.  
  44. {    contool_base_objects * ip = (contool_base_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  45.  
  46.     if (op == MENU_NOTIFY) {
  47.        if (contool_load == NULL) {
  48.           contool_load = contool_load_objects_initialize(NULL, ip->base);
  49.           xv_set(contool_load->load_file,
  50.                       PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
  51.                       PANEL_NOTIFY_STRING, "\n\r ",
  52.                    NULL);
  53.           xv_set(contool_load->load_type, PANEL_VALUE, 3, NULL);
  54.           place_dialog(ip->base, contool_load->load);
  55.           }
  56.        xv_set(contool_load->load_file, PANEL_VALUE, filter_file, NULL);
  57.        xv_set(contool_load->load, XV_SHOW, TRUE, NULL);
  58.        }
  59.     return item;
  60. }
  61.  
  62. /************************************************************************/
  63. EXPORT    void    load_filters(item, event)
  64.  
  65. Panel_item    item;
  66. Event        *event;
  67.  
  68. {    contool_load_objects    *ip = (contool_load_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  69.     int    kind;
  70.     char    *path;
  71.  
  72.     path = expand_tilde(xv_get(ip->load_file, PANEL_VALUE));
  73.     if (lex_init(path)) {
  74.        yyparse();
  75.        if (parse_errors_occured) {
  76.           error("Error in configuration file.  Configuration not loaded");
  77.           xv_set(ip->accept_load, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  78.           }
  79.        else {
  80.           kind = (int) xv_get(ip->load_type, PANEL_VALUE);
  81.           if (kind & 1 && parsed_defaults)
  82.              defaults = *parsed_defaults;
  83.           if (kind & 2)
  84.              filters = parsed_filters;
  85.           free(parsed_defaults);
  86.           filter_file = path;
  87.           }
  88.        }
  89.     else {
  90.        error("Unable to read configuration file");
  91.        xv_set(ip->accept_load, PANEL_NOTIFY_STATUS, XV_ERROR, NULL);
  92.        free(path);
  93.        }
  94. }
  95.