home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / utils / main.c < prev    next >
C/C++ Source or Header  |  1996-12-11  |  4KB  |  171 lines

  1. /*
  2.     Ixprefs v.2.4--ixemul.library configuration program
  3.     Copyright © 1995,1996 Kriton Kyrimis
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <exec/types.h>
  24. #include <dos/dos.h>
  25. #include <intuition/intuition.h>
  26. #include <proto/exec.h>
  27. #include <proto/intuition.h>
  28. #include <proto/gadtools.h>
  29. #include "ixemul.h"
  30. #include "ixprefs.h"
  31.  
  32. void cleanup(void);
  33. void displayprefs(void);
  34. void showrequester(struct Window*, char *, char *);
  35. extern int parse_cli_commands(int argc, char *argv[]);
  36.  
  37. extern struct ixemul_base *ixemulbase;
  38. int translateslash, membuf, blocks, cases, suppress,
  39.     amigawildcard, noflush, ignoreenv, networking, enforcerhit,
  40.     profilemethod;
  41.  
  42. char ixprefs_version[] = "$VER: ixprefs 2.4 (23.09.96)";
  43.  
  44. int
  45. main(int argc, char *argv[])
  46. {
  47.   long status;
  48.  
  49.   if (ixemulbase->ix_lib.lib_Version < 45) {
  50.     showrequester(NULL,
  51.     "This program requires ixemul.library version 45 or higher",
  52.     "EXIT");
  53.     return RETURN_FAIL;
  54.   }
  55.  
  56.   (void)ixprefsrestore();    /* load ixprefs settings from ixemulbase */
  57.   
  58.   if (argc >= 2) {
  59.     return parse_cli_commands(argc, argv);
  60.   }
  61.  
  62.   atexit(cleanup);
  63.  
  64.   status = SetupScreen();
  65.   if (status != 0) {
  66.     fprintf(stderr, "SetupScreen failed, status = %ld\n", status);
  67.     return RETURN_FAIL;
  68.   }
  69.   ixprefsTop=Scr->BarHeight+1;
  70.   status = OpenixprefsWindow();
  71.   if (status != 0) {
  72.     fprintf(stderr, "OpenixprefsWindow failed, status = %ld\n", status);
  73.     return RETURN_FAIL;
  74.   }
  75.  
  76.   displayprefs();
  77.  
  78.   while (1) {
  79.     WaitPort(ixprefsWnd->UserPort);
  80.     status = HandleixprefsIDCMP();
  81.     if (status == 0) {
  82.       return RETURN_OK;
  83.     }
  84.   }
  85.   return 0;
  86. }
  87.  
  88. void
  89. cleanup()
  90. {
  91.   CloseixprefsWindow();
  92.   CloseDownScreen();
  93. }
  94.  
  95. void
  96. check(int which)
  97. {
  98.   ixprefsGadgets[which]->Flags |= GFLG_SELECTED;
  99. }
  100.  
  101. void
  102. uncheck(int which)
  103. {
  104.   ixprefsGadgets[which]->Flags &= ~GFLG_SELECTED;
  105. }
  106.  
  107. void
  108. showchecked(int which, int checkit)
  109. {
  110.   if (checkit) {
  111.     check(which);
  112.   }else{
  113.     uncheck(which);
  114.   }
  115.   RefreshGList(ixprefsGadgets[which], ixprefsWnd, NULL, 1);
  116. }
  117.  
  118. void
  119. shownum(int which, int num)
  120. {
  121.   sprintf(GetString(ixprefsGadgets[which]), "%d", num);
  122.   GetNumber(ixprefsGadgets[which]) = num;
  123.   RefreshGList(ixprefsGadgets[which], ixprefsWnd, NULL, 1);
  124. }
  125.  
  126. void
  127. showcycle(int which, int num)
  128. {
  129.   GT_SetGadgetAttrs(ixprefsGadgets[which], ixprefsWnd, NULL,
  130.             GTCY_Active, num, TAG_DONE);
  131.   RefreshGList(ixprefsGadgets[which], ixprefsWnd, NULL, 1);
  132. }
  133.  
  134. void
  135. displayprefs(void)
  136. {
  137.   if (Scr == NULL)
  138.     return;
  139.   showchecked(GDX_amigawildcard, amigawildcard);
  140.   showchecked(GDX_case, cases);
  141.   showchecked(GDX_translateslash, translateslash);
  142.   shownum(GDX_membuf, membuf);
  143.   shownum(GDX_blocks, blocks);
  144.   showchecked(GDX_suppress, suppress);
  145.   showchecked(GDX_noflush, noflush);
  146.   showchecked(GDX_ignoreenv, ignoreenv);
  147.   showchecked(GDX_enforcerhit, enforcerhit);
  148.   showcycle(GDX_networking, networking);
  149.   showcycle(GDX_profilemethod, profilemethod);
  150. }
  151.  
  152. void
  153. showrequester(struct Window *win, char *text, char *buttontext)
  154. {
  155.   static struct EasyStruct easy = {
  156.     sizeof(struct EasyStruct),
  157.     0,
  158.     "ixprefs",
  159.     NULL,
  160.     NULL,
  161.   };
  162.  
  163.   if (win /*|| strchr(buttontext, '|')*/) {
  164.     easy.es_TextFormat = (UBYTE *)text;
  165.     easy.es_GadgetFormat = (UBYTE *)buttontext;
  166.     EasyRequest(NULL, &easy, NULL);
  167.   }else{
  168.     fprintf(stderr, "%s\n", text);
  169.   }
  170. }
  171.