mirror of
https://github.com/krustur/IconSnap.git
synced 2026-09-12 03:50:41 +00:00
CleanExit
This commit is contained in:
@@ -24,7 +24,8 @@
|
|||||||
"exec_pragmas.h": "c",
|
"exec_pragmas.h": "c",
|
||||||
"dirent.h": "c",
|
"dirent.h": "c",
|
||||||
"unistd.h": "c",
|
"unistd.h": "c",
|
||||||
"intuition.h": "c"
|
"intuition.h": "c",
|
||||||
|
"signal.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+37
-11
@@ -15,6 +15,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/syslimits.h>
|
#include <sys/syslimits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
// TODO: Scripted tests!
|
// TODO: Scripted tests!
|
||||||
|
|
||||||
@@ -68,6 +69,10 @@ long argArray[] =
|
|||||||
0,
|
0,
|
||||||
0};
|
0};
|
||||||
unsigned char argumentString[] = "FILE/K,DIR/K,PADLEFT/N,PADTOP/N,ALIGNX/N,ALIGNY/N,CENTERX/S,BOTTOMY/S,VERBOSE/S";
|
unsigned char argumentString[] = "FILE/K,DIR/K,PADLEFT/N,PADTOP/N,ALIGNX/N,ALIGNY/N,CENTERX/S,BOTTOMY/S,VERBOSE/S";
|
||||||
|
struct RDArgs *rdargs = NULL;
|
||||||
|
|
||||||
|
// clean exit handling
|
||||||
|
void CleanExit();
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
short verbose = FALSE;
|
short verbose = FALSE;
|
||||||
@@ -93,6 +98,17 @@ long Align(long orig, long pad, long align, long alignoffset);
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
atexit(CleanExit);
|
||||||
|
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
//Opened from WB
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// printf("fignal\n");
|
||||||
|
// signal(SIGINT, intHandler);
|
||||||
|
}
|
||||||
// Open libraries
|
// Open libraries
|
||||||
DosBase = OpenLibrary("dos.library", DosVersion);
|
DosBase = OpenLibrary("dos.library", DosVersion);
|
||||||
if (!DosBase)
|
if (!DosBase)
|
||||||
@@ -112,7 +128,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
// check arguments
|
// check arguments
|
||||||
|
|
||||||
struct RDArgs *rdargs = ReadArgs(argumentString, argArray, NULL);
|
rdargs = ReadArgs(argumentString, argArray, NULL);
|
||||||
|
|
||||||
if (!rdargs)
|
if (!rdargs)
|
||||||
{
|
{
|
||||||
@@ -223,18 +239,30 @@ int main(int argc, char **argv)
|
|||||||
// return RETURN_ERROR;
|
// return RETURN_ERROR;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (rdargs)
|
|
||||||
{
|
|
||||||
FreeArgs(rdargs);
|
|
||||||
}
|
|
||||||
CloseLibrary(DosBase);
|
|
||||||
CloseLibrary(IconBase);
|
|
||||||
|
|
||||||
Verbose("Stack used: %lu\n", (unsigned long)__stack_usage);
|
Verbose("Stack used: %lu\n", (unsigned long)__stack_usage);
|
||||||
|
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CleanExit()
|
||||||
|
{
|
||||||
|
if (rdargs != NULL)
|
||||||
|
{
|
||||||
|
FreeArgs(rdargs);
|
||||||
|
rdargs = NULL;
|
||||||
|
}
|
||||||
|
if (DosBase != NULL)
|
||||||
|
{
|
||||||
|
CloseLibrary(DosBase);
|
||||||
|
DosBase = NULL;
|
||||||
|
}
|
||||||
|
if (IconBase != NULL)
|
||||||
|
{
|
||||||
|
CloseLibrary(IconBase);
|
||||||
|
IconBase = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
void Verbose(const char *fmt, ...)
|
void Verbose(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
@@ -378,7 +406,7 @@ unsigned int AlignIcon(unsigned char *diskObjectName)
|
|||||||
if (iconLibraryV44Enabled)
|
if (iconLibraryV44Enabled)
|
||||||
{
|
{
|
||||||
Verbose("Icon found (>=V44): %s\n", fixedDiskObjectName);
|
Verbose("Icon found (>=V44): %s\n", fixedDiskObjectName);
|
||||||
diskObject = GetIconTags(fixedDiskObjectName, TAG_DONE);//ICONGETA_GetPaletteMappedIcon, FALSE, TAG_DONE);
|
diskObject = GetIconTags(fixedDiskObjectName, TAG_DONE); //ICONGETA_GetPaletteMappedIcon, FALSE, TAG_DONE);
|
||||||
IconControl(diskObject, ICONCTRLA_GetWidth, &iconWidth, TAG_DONE);
|
IconControl(diskObject, ICONCTRLA_GetWidth, &iconWidth, TAG_DONE);
|
||||||
IconControl(diskObject, ICONCTRLA_GetHeight, &iconHeigth, TAG_DONE);
|
IconControl(diskObject, ICONCTRLA_GetHeight, &iconHeigth, TAG_DONE);
|
||||||
}
|
}
|
||||||
@@ -433,8 +461,6 @@ unsigned int AlignIcon(unsigned char *diskObjectName)
|
|||||||
// Verbose(" toolType IM1 not found :'(\n", toolType);
|
// Verbose(" toolType IM1 not found :'(\n", toolType);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// diskObject->do_CurrentX += 10;
|
// diskObject->do_CurrentX += 10;
|
||||||
if (diskObject->do_CurrentX == NO_ICON_POSITION && diskObject->do_CurrentX == NO_ICON_POSITION)
|
if (diskObject->do_CurrentX == NO_ICON_POSITION && diskObject->do_CurrentX == NO_ICON_POSITION)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user