Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / prefs / serial / main.c
blob87084ced4224429612472212630fd194c18760c8
1 /*
2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*********************************************************************************************/
12 #include <proto/intuition.h>
13 #include <proto/muimaster.h>
14 #include <proto/utility.h>
15 #include <proto/dos.h>
18 #include <linklibs/coolimages.h>
20 #include <stdlib.h> /* for exit() */
21 #include <stdio.h>
22 #include <string.h>
24 #include <intuition/intuition.h>
25 #include <intuition/gadgetclass.h>
26 #include <intuition/iobsolete.h>
27 #include <libraries/gadtools.h>
29 #include <libraries/mui.h>
30 #include <zune/systemprefswindow.h>
32 #include <prefs/serial.h>
34 #include "locale.h"
35 #include "global.h"
36 #include "sereditor.h"
38 /* #define DEBUG 1 */
39 #include <aros/debug.h>
41 #define VERSION "$VER: Serial 2.0 (09.06.2008) AROS Dev Team"
42 /*********************************************************************************************/
45 #define ARG_FROM 0
46 #define ARG_EDIT 1
47 #define ARG_USE 2
48 #define ARG_SAVE 3
49 #define ARG_MAP 4
50 #define ARG_PUBSCREEN 5
52 #define NUM_ARGS 6
54 /*********************************************************************************************/
56 STATIC CONST_STRPTR TEMPLATE=(CONST_STRPTR) "FROM,EDIT/S,USE/S,SAVE/S,MAP/K,PUBSCREEN/K";
57 static struct RDArgs *myargs;
58 static IPTR args[NUM_ARGS];
60 /*********************************************************************************************/
62 #define NUM_BUTTONS 2
64 /*********************************************************************************************/
67 * safe (?) error display
70 VOID ShowMsg(char *msg)
72 struct EasyStruct es;
74 if (msg)
76 if (IntuitionBase)
78 es.es_StructSize = sizeof(es);
79 es.es_Flags = 0;
80 es.es_Title = (CONST_STRPTR) "Serial";
81 es.es_TextFormat = (CONST_STRPTR) msg;
82 es.es_GadgetFormat = MSG(MSG_OK);
84 EasyRequestArgs(NULL, &es, NULL, NULL); /* win=NULL -> wb screen */
85 } else {
86 printf("Serial: %s\n", msg);
91 /*********************************************************************************************/
93 STATIC ULONG GetArguments(void)
95 char buf[256];
96 if (!(myargs = ReadArgs(TEMPLATE, args, NULL)))
98 Fault(IoErr(), NULL, (STRPTR) buf, 255);
99 ShowMsg(buf);
100 return 0;
103 if (!args[ARG_FROM]) args[ARG_FROM] = (IPTR)CONFIGNAME_ENV;
105 return 1;
108 /*********************************************************************************************/
110 STATIC VOID FreeArguments(void)
112 if (myargs) FreeArgs(myargs);
116 int main(void)
118 Object *application;
119 Object *window;
121 D(bug("[serial prefs] InitLocale\n"));
122 InitLocale();
124 D(bug("[serial prefs] started\n"));
126 /* init */
127 if( GetArguments() &&
128 InitPrefs((STRPTR)args[ARG_FROM], (args[ARG_USE] ? TRUE : FALSE), (args[ARG_SAVE] ? TRUE : FALSE)) )
131 D(bug("[serial prefs] initialized\n"));
133 application = ApplicationObject,
134 MUIA_Application_Title, MSG(MSG_WINTITLE),
135 MUIA_Application_Version, (IPTR) VERSION,
136 MUIA_Application_Description, MSG(MSG_WINTITLE),
137 MUIA_Application_Base, (IPTR) "SERIALPREF",
138 SubWindow, (IPTR) (window = SystemPrefsWindowObject,
139 //MUIA_Window_ID, MAKE_ID('S','O','1','I'),
140 MUIA_Window_ID, ID_SERL,
141 WindowContents, (IPTR) SerEditorObject,
142 TAG_DONE),
143 End),
144 End;
146 if (application != NULL && window != NULL)
148 SET(window, MUIA_Window_Open, TRUE);
149 DoMethod(application, MUIM_Application_Execute);
150 SET(window, MUIA_Window_Open, FALSE);
152 MUI_DisposeObject(application);
154 } /* if init */
156 FreeArguments();
157 CleanupLocale();
158 return 0;
161 /*********************************************************************************************/