(Page 12 of 14 in this chapter)
agmOpen
Description
- Creates an AGM library context and returns a handle to it. Also opens the configuration and report files specified.
Prototype
- DWORD agmOpen ( char *config,
char *report,
AGM_OPTIONS *options,
AGM_ERROR_HANDLER errorhandler,
AGMHD *agmhd)
- config Pointer to a character string containing the name of the configuration file (e.g. ag.cfg).
- report Pointer to a character string containing the name of the report file (e.g. ag.rpt).
- options Pointer to an optional AGM_OPTIONS structure, or NULL. If the structure is provided, any field except size may be given a zero value to indicate that the default should be used. AGM_OPTIONS is defined as:
typedef struct
{
DWORD size ;
DWORD mode ;
DWORD maxwait ;
DWORD loadsize ;
DWORD testlevel ;
DWORD traceflags ;
DWORD reserved ;
} AGM_OPTIONS ;
- errorhandler Pointer to an error handler callback function, as described in the Details section.
- agmhd Pointer to the returned AGM handle.
Return Values
Details
- This function opens an AGM context and returns a handle (agmhd) to the context for use in subsequent AGM library calls.
- config is the name of a file containing the AG board configuration information. If the file is not present in the current directory, the file is searched for in the directories specified by the AGLOAD environment variable.
- report is the name of the report file to which the configuration record (including information about hardware detected and files downloaded) is written. The report file is written in the current directory if the argument does not specify a full path name.
- The fields of AGM_OPTIONS are:
- The errorhandler argument is a pointer to a function that is called when the AGM library encounters an error and needs to notify the caller about the error.
- The AGM errorhandler function's prototype is:
- typedef DWORD ( NMSSTDCALLPTR AGM_ERROR_HANDLER)
( AGMHD agmhd,
int boardnum,
DWORD severity,
char *errtxt)
- The errorhandler function arguments are:
See Also
- agmClose
Example
/* An error handler callback to register with agmOpen(). */
DWORD NMSSTDCALL my_errorhandler(
AGMHD agmhd, /* AGM handle */
int boardnum, /* The AG board number, or -1 if N/A */
DWORD severity, /* AGM_CALLBACK_{ERROR,WARNING,INFORMATIONAL} */
char *errtxt ) /* Error text */
{
char *errtype;
switch (severity)
{
case AGM_CALLBACK_ERROR:
errtype = "ERROR";
break;
case AGM_CALLBACK_WARNING:
errtype = "Warning";
break;
case AGM_CALLBACK_INFORMATIONAL:
errtype = "Info";
break;
default:
errtype = "<unknown severity>";
break;
}
if (boardnum == -1)
printf ("%s: %s\n", errtype, errtxt);
else
printf ("%s: [Board %d] %s", boardnum, errtype, errtxt);
return SUCCESS;
} /* ErrorHandler
(Page 12 of 14 in this chapter)
tech_support@nmss.com
Copyright © 1998, Natural MicroSystems, Inc. All rights
reserved.