SYNOPSIS#include <stdio.h>
#include "api3.h"
APICP * openapicp(void)
APICP * closeapicp(cp)
APICP * cp;
DESCRIPTIONOpenapicp
returns a pointer to a structure that contains all of
the default parameters needed by the Metamorph API. Each of the
members of the structure are initialized in a manner that will
allow for simple modification of its contents by the calling
program. Closeapicp
frees all the memory allocated by openapicp
and returns an APICP *)NULL
.
The following describes how to modify each of the variable types
within the APICP
structure:
(byte) : Direct assignment
eg: cp->suffixproc=(byte)1;
(int) : Direct assignment
eg: cp->minwordlen=2;
(byte *) : Free original pointer and assign new allocated pointer
eg: free(cp->sdexp);
cp->sdexp=(byte *)malloc(strlen("string")+1);
strcpy(cp->sdexp,"string");
(byte **) : Free original pointers and assign new allocated pointers
eg: #define MYLISTSZ 3
static char *mylist[MYLISTSZ]={"new","list",""};
int i;
for(i=0;*cp->noise[i]!='\0';i++)
free(cp->noise[i]);
free(cp->noise[i]); /* free empty string at end */
free(cp->noise); /* free the array pointer */
cp->noise=(byte **)calloc(MYLISTSZ,sizeof(byte *));
for(i=0;i<MYLISTSZ;i++)
{
cp->noise[i]=(byte *)malloc(strlen(mylist[i])+1);
strcpy(cp->noise[i],mylist[i]);
}
int (*)() : Direct assignment
eg: cp->eqedit=myeditfunction;
WARNING: The closeapicp()
will free all variable pointers. Do
not assign static data pointers or attempt to free any
pointers placed in the APICP
structure.