Skip to main content
Version: 16.8.2

GW2GetFileTypeID

Every file type has an associated ID in the Glasswall Engine. This API provides the Glasswall file type ID in string format for the associated file extension supplied.


#include "glasswall.core2.api.h"

int GW2GetFileTypeID(
Session session,
const char *fileType,
size_t *bufferLength,
char **outputBuffer);

Parameters

session The ID of the session as returned by GW2OpenSession

fileType A string containing the file extension. Eg "bmp".

bufferLength An output parameter which is populated with size in bytes of the memory pointed to by outputBuffer.

outputBuffer A string pointer output parameter which is populated with the file type ID associated with the supplied extension. The memory used by this pointer does not need to be freed by the user.

Returns

  Returns an integer indicating whether the function call was successful. Negative numbers indicate a failure. See the Return Types table for an explanation of the return codes. If successful, the outputBuffer is populated with the file type ID.

Example


#include "glasswall.core2.api.h"

char *outbuf = NULL;
size_t buflen = 0;

if (GW2OpenSession() < 0)
/* error opening session */
else
{
int status = GW2GetFileTypeID(session, fileType, &buflen, &outbuf);

/* outbuf points to a buffer containing the XML file.
* Either process the data pointed to, or copy the data and process it
* after GW2CloseSession is called
*/

if (GW2CloseSession() < 0)
/* error closing session */
}