alsa.audio: use correct name of libasound so file
[AROS.git] / workbench / utilities / Clock / main.c
blob285030b98d1ab4508a18de3f875ca5fe1529151a
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 //#define DEBUG 1
7 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <workbench/startup.h>
12 #include <proto/exec.h>
13 #include <proto/dos.h>
14 #include <proto/intuition.h>
15 #include <proto/icon.h>
16 #include <proto/alib.h>
18 #define MUIMASTER_YES_INLINE_STDARG
19 #include <proto/muimaster.h>
20 #include <libraries/mui.h>
21 #include <zune/clock.h>
23 #include <string.h> /* memset() */
24 #include <stdlib.h> /* exit() */
26 #include "locale.h"
27 #include "version.h"
29 /*** Version string *********************************************************/
31 char *versionString = VERSIONSTR;
33 /*** Argument parsing *******************************************************/
35 #define ARG_TEMPLATE "LEFT/N,TOP/N,WIDTH/N,HEIGHT/N,PUBSCREEN/K"
37 enum {
38 ARG_LEFT = 0,
39 ARG_TOP,
40 ARG_WIDTH,
41 ARG_HEIGHT,
42 ARG_PUBSCREEN,
43 NUM_ARGS
46 /*** Variables **************************************************************/
47 /* Options ******************************************************************/
49 static LONG optionLeft = MUIV_Window_LeftEdge_Centered,
50 optionTop = MUIV_Window_TopEdge_Centered,
51 optionWidth = 150,
52 optionHeight = 150;
53 static STRPTR optionPubscr = NULL;
55 /* User interface ***********************************************************/
56 Object *application, *window;
59 /*** Functions **************************************************************/
61 void ShowMessage(CONST_STRPTR title, CONST_STRPTR text, CONST_STRPTR gadgets)
63 MUI_RequestA(application, window, 0, title, gadgets, text, NULL);
66 void Cleanup(CONST_STRPTR message)
68 if(message != NULL)
72 IntuitionBase != NULL
73 && ((struct Process *) FindTask(NULL))->pr_CLI == BNULL
76 ShowMessage("Clock", message, MSG(MSG_OK));
78 else
80 Printf("Clock: %s\n", message);
84 FreeVec(optionPubscr);
85 Locale_Deinitialize();
87 if (message != NULL)
88 exit(20);
89 else
90 exit(0);
93 static void GetArguments(int argc, char **argv)
95 if (argc == 0) /* started from WB */
97 UBYTE **array = ArgArrayInit(argc, (UBYTE **)argv);
98 optionLeft = ArgInt(array, "LEFT", optionLeft);
99 optionTop = ArgInt(array, "TOP", optionTop);
100 optionWidth = ArgInt(array, "WIDTH", optionWidth);
101 optionHeight = ArgInt(array, "HEIGHT", optionHeight);
102 optionPubscr = StrDup(ArgString(array, "PUBSCREEN", optionPubscr));
103 ArgArrayDone();
105 else
107 # define TMPSIZE 256
108 TEXT tmp[TMPSIZE];
109 struct RDArgs *rdargs = NULL;
110 IPTR args[NUM_ARGS];
112 memset(args, 0, sizeof(args));
113 rdargs = ReadArgs(ARG_TEMPLATE, args, NULL);
114 if (rdargs == NULL)
116 Fault(IoErr(), 0, tmp, TMPSIZE);
117 Cleanup(tmp);
120 if (args[ARG_LEFT]) optionLeft = *(LONG*)args[ARG_LEFT];
121 if (args[ARG_TOP]) optionTop = *(LONG*)args[ARG_TOP];
122 if (args[ARG_WIDTH]) optionWidth = *(LONG*)args[ARG_WIDTH];
123 if (args[ARG_HEIGHT]) optionHeight = *(LONG*)args[ARG_HEIGHT];
124 if (args[ARG_HEIGHT]) optionPubscr = StrDup((STRPTR)args[ARG_PUBSCREEN]);
126 FreeArgs(rdargs);
127 # undef TMPSIZE
129 D(bug("Clock left %d top %d width %d height %d pubscr %s\n",
130 optionLeft, optionTop, optionWidth, optionHeight, optionPubscr));
133 int main(int argc, char **argv)
135 Locale_Initialize();
136 GetArguments(argc, argv);
138 application = (Object *)ApplicationObject,
139 MUIA_Application_Title, (IPTR) MSG(MSG_WINDOW_TITLE),
140 MUIA_Application_Version, (IPTR) versionString,
141 MUIA_Application_Copyright, (IPTR)"© 2006, The AROS Development Team",
142 MUIA_Application_Description, (IPTR) MSG(MSG_DESCRIPTION),
143 MUIA_Application_Base, (IPTR) "CLOCK",
144 SubWindow, (IPTR) (window = (Object *)WindowObject,
145 MUIA_Window_Title, (IPTR) MSG(MSG_WINDOW_TITLE),
146 MUIA_Window_Activate, TRUE,
147 MUIA_Window_NoMenus, TRUE,
148 MUIA_Window_LeftEdge, optionLeft,
149 MUIA_Window_TopEdge, optionTop,
150 MUIA_Window_Width, optionWidth,
151 MUIA_Window_Height, optionHeight,
152 MUIA_Window_PublicScreen, (IPTR) optionPubscr,
153 MUIA_Window_ID, MAKE_ID('C','K','W','N'),
154 WindowContents, (IPTR) ClockObject,
155 End,
156 End),
157 End;
159 if (application)
161 DoMethod
163 window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
164 (IPTR) application, 2,
165 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
168 SetAttrs(window, MUIA_Window_Open, TRUE, TAG_DONE);
170 DoMethod(application, MUIM_Application_Execute);
172 SetAttrs(window, MUIA_Window_Open, FALSE, TAG_DONE);
173 MUI_DisposeObject(application);
175 else
177 Cleanup(MSG(MSG_ERROR_CANT_CREATE_APPLICATION));
180 Cleanup(NULL);
182 return 0;