AmigaGuide library bug and inconsistancy
Posted: Thu Jun 07, 2012 9:49 pm
Someone at Amigans.net wants to open an AmigaGuide at a specified node from CLI and when I looked at the autodocs it looked like a simple task. However, there seems to be a bug in OpenAmigaGuide() or the autodoc is incorrect. The short example for OpenAmigaGuide() shows the return value (AMIGAGUIDECONTEXT) being checked for an error condition (which I assume is to be reported to the user). If there is no error then CloseAmigaGuide() is called. The problem is that a value is always returned even if there is an error (bad filename etc.). Also, the CloseAmigaGuide() autodoc specifies that it should be called to close a synchronous or asynchronous client. Since OpenAmigaGuide() is synchrouous and doesn't return until the client is closed, closing it with CloseAmigaGuide() makes no sense. Please copy & compile the source of the small command I wrote and test it to confirm these bugs. The command will not report an error if the amigaguide file doesn't exist, the node doesn't exist or the pubscreen doesn't exist. According to the docs and example that should not be the case. I'm listing my source instead of the autodoc example so it can be easily copied and compiled for testing:
Code: Select all
/* compile: gcc -N -O2 OpenGuide.c -o OpenGuide -Wall -lauto */
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/amigaguide.h>
#define TEMPLATE "NAME/A,NODE/K,PUBSCREEN/K"
enum
{
OG_NAME, OG_NODE, OG_SCREEN, OG_MAX
};
int main(int argc, char **argv)
{
int32 args[OG_MAX] = {0};
struct RDArgs *argsdata;
char *screen = NULL;
char *node = NULL;
struct NewAmigaGuide nag = { 0 };
AMIGAGUIDECONTEXT handle;
if (argc == 0)
{
IDOS->PutErrStr("Error: Shell program\n");
return(RETURN_ERROR);
}
argsdata = IDOS->ReadArgs(TEMPLATE, args, NULL);
if (!argsdata)
{
IDOS->PrintFault(IDOS->IoErr(), "Error");
return(RETURN_ERROR);
}
if (args[OG_SCREEN]) screen = (char *)args[OG_SCREEN];
if (args[OG_NODE]) node = (char *)args[OG_NODE];
nag.nag_Name = (char *)args[OG_NAME];
nag.nag_PubScreen = screen;
nag.nag_Flags = 0;
nag.nag_Node = node;
nag.nag_Client = NULL;
if((handle = IAmigaGuide->OpenAmigaGuide(&nag, NULL)))
{
IAmigaGuide->CloseAmigaGuide(handle);
}
else
{
IDOS->PrintFault(IDOS->IoErr(), "Error");
if (argsdata) IDOS->FreeArgs(argsdata);
return(RETURN_ERROR);
}
if (argsdata) IDOS->FreeArgs(argsdata);
return(RETURN_OK);
}