Skip to main content
Version: 16.9.0

GW2GetFileType

File type IDs are mapped to file types supported by the Glasswall Engine. This API provides the formal name of the file type in string format given a file type ID number.


#include "glasswall.core2.api.h"

int GW2GetFileType(
Session session,
size_t fileId,
size_t *bufferLength,
char **outputBuffer);

Parameters

session The ID of the session as returned by GW2OpenSession

fileId An integer representing the file type ID

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 formal name of the file type associated with the supplied file ID, eg. "BMP Image". 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 formal name associated with the file type.

Example


#include "glasswall.core2.api.h"
#include "filetype.h" // ft_t enum which includes ft_bmp

char *outbuf = NULL;
size_t buflen = 0;

if (GW2OpenSession() < 0)
/* Error opening session */
else
{
int status = GW2GetFileType(session, ft_bmp, &buflen, &outbuf);

/* In this example outbuf will point to the string "BMP Image". */

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