2 Copyright © 2012, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <proto/muimaster.h>
9 #include <proto/intuition.h>
10 #include <proto/utility.h>
11 #include <proto/dos.h>
12 #include <proto/icon.h>
13 #include <proto/alib.h>
15 #include <libraries/mui.h>
16 #include <workbench/startup.h>
18 #include "unarcgroup_class.h"
21 #define ARGTEMPLATE "ARCHIVE,DESTINATION,PUBSCREEN/K"
32 static void cleanup_exit(CONST_STRPTR str
);
34 static Object
*app
, *win
;
35 static struct DiskObject
*dobj
;
36 static struct RDArgs
*rda
;
37 static IPTR args
[ARG_COUNT
];
38 static BPTR olddir
= (BPTR
)-1;
41 int main(int argc
, char **argv
)
45 STRPTR archive
= NULL
;
46 STRPTR destination
= NULL
;
47 STRPTR pubscreen
= NULL
;
49 if (argc
) // started from CLI
51 rda
= ReadArgs(ARGTEMPLATE
, args
, NULL
);
54 cleanup_exit(_(MSG_ERR_READARGS
));
56 archive
= (STRPTR
)args
[ARG_ARCHIVE
];
57 destination
= (STRPTR
)args
[ARG_DESTINATION
];
58 pubscreen
= (STRPTR
)args
[ARG_PUBSCREEN
];
60 else // started from Wanderer
62 struct WBStartup
*wbmsg
= (struct WBStartup
*)argv
;
63 struct WBArg
*wbarg
= wbmsg
->sm_ArgList
;
66 dobj
= GetDiskObject(wbarg
->wa_Name
);
69 toolarray
= dobj
->do_ToolTypes
;
70 archive
= FindToolType(toolarray
, "ARCHIVE");
71 destination
= FindToolType(toolarray
, "DESTINATION");
73 if (wbmsg
->sm_NumArgs
> 1 && wbarg
[1].wa_Lock
)
75 olddir
= CurrentDir(wbarg
[1].wa_Lock
);
76 archive
= wbarg
[1].wa_Name
;
80 app
= ApplicationObject
,
81 MUIA_Application_Author
, (IPTR
)"The AROS Development Team",
82 MUIA_Application_Base
, (IPTR
)"UNARC",
83 MUIA_Application_Title
, (IPTR
)"Unarc",
84 MUIA_Application_Version
, (IPTR
)"$VER: Unarc 1.1 (11.02.2012)",
85 MUIA_Application_Copyright
, __(MSG_AppCopyright
),
86 MUIA_Application_Description
, __(MSG_AppDescription
),
87 SubWindow
, (IPTR
)(win
= WindowObject
,
88 MUIA_Window_Title
, __(MSG_WI_TITLE
),
89 MUIA_Window_ID
, MAKE_ID('U', 'N', 'W', 'I'),
90 pubscreen
? MUIA_Window_PublicScreen
: TAG_IGNORE
, (IPTR
)pubscreen
,
91 WindowContents
, (IPTR
)(UnarcGroupObject
,
92 MUIA_UnarcGroup_Archive
, (IPTR
)archive
,
93 MUIA_UnarcGroup_Destination
, (IPTR
)destination
,
99 cleanup_exit(_(MSG_ERR_NO_APPLICATION
));
103 win
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
104 app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
107 SET(win
, MUIA_Window_Open
, TRUE
);
108 DoMethod(app
, MUIM_Application_Execute
);
114 static void cleanup_exit(CONST_STRPTR str
)
118 struct EasyStruct es
=
120 sizeof(struct EasyStruct
), 0,
121 _(MSG_ERR
), str
, _(MSG_OK
)
123 EasyRequestArgs(NULL
, &es
, NULL
, NULL
);
125 MUI_DisposeObject(app
);
126 if (dobj
) FreeDiskObject(dobj
);
127 if (rda
) FreeArgs(rda
);
128 if (olddir
!= (BPTR
)-1) CurrentDir(olddir
);
129 Locale_Deinitialize();