#endif
/** \test magic lib calls -- init */
-int MagicInitTest01(void) {
+int MagicInitTest01(void)
+{
+ int result = 0;
magic_t magic_ctx;
magic_ctx = magic_open(0);
-
- if (magic_load(magic_ctx, NULL) == -1)
+ if (magic_ctx == NULL) {
+ printf("failure retrieving magic_ctx\n");
return 0;
+ }
+
+ if (magic_load(magic_ctx, NULL) == -1) {
+ printf("failure magic_load\n");
+ goto end;
+ }
+ result = 1;
+ end:
magic_close(magic_ctx);
- return 1;
+ return result;
}
/** \test magic init through api */
-int MagicInitTest02(void) {
+int MagicInitTest02(void)
+{
if (g_magic_ctx != NULL) {
printf("g_magic_ctx != NULL at start of the test: ");
return 0;
}
- MagicInit();
+ if (MagicInit() < 0) {
+ printf("MagicInit() failure\n");
+ return 0;
+ }
if (g_magic_ctx == NULL) {
printf("g_magic_ctx == NULL: ");
}
/** \test magic lib calls -- lookup */
-int MagicDetectTest01(void) {
+int MagicDetectTest01(void)
+{
magic_t magic_ctx;
char *result = NULL;
char buffer[] = { 0x25, 'P', 'D', 'F', '-', '1', '.', '3', 0x0d, 0x0a};
int retval = 0;
magic_ctx = magic_open(0);
-
- if (magic_load(magic_ctx, NULL) == -1)
+ if (magic_ctx == NULL) {
+ printf("failure retrieving magic_ctx\n");
return 0;
+ }
+
+ if (magic_load(magic_ctx, NULL) == -1) {
+ printf("magic_load failure\n");
+ goto end;
+ }
result = (char *)magic_buffer(magic_ctx, (void *)buffer, buffer_len);
if (result == NULL || strncmp(result, "PDF document", 12) != 0) {
}
/** \test magic lib calls -- lookup */
-int MagicDetectTest02(void) {
+int MagicDetectTest02(void)
+{
magic_t magic_ctx;
char *result = NULL;
int retval = 0;
magic_ctx = magic_open(0);
-
- if (magic_load(magic_ctx, NULL) == -1)
+ if (magic_ctx == NULL) {
+ printf("failure retrieving magic_ctx\n");
return 0;
+ }
+
+ if (magic_load(magic_ctx, NULL) == -1) {
+ printf("magic_load failure\n");
+ goto end;
+ }
result = (char *)magic_buffer(magic_ctx, (void *)buffer, buffer_len);
if (result == NULL || strcmp(result, MICROSOFT_OFFICE_DOC) != 0) {
int retval = 0;
magic_ctx = magic_open(0);
-
- if (magic_load(magic_ctx, NULL) == -1)
+ if (magic_ctx == NULL) {
+ printf("failure retrieving magic_ctx\n");
return 0;
+ }
+
+ if (magic_load(magic_ctx, NULL) == -1) {
+ printf("magic_load failure\n");
+ goto end;
+ }
result = (char *)magic_buffer(magic_ctx, (void *)buffer, buffer_len);
if (result == NULL || strcmp(result, "OpenDocument Text") != 0) {
int retval = 0;
magic_ctx = magic_open(0);
-
- if (magic_load(magic_ctx, NULL) == -1)
+ if (magic_ctx == NULL) {
+ printf("failure retrieving magic_ctx\n");
return 0;
+ }
+
+ if (magic_load(magic_ctx, NULL) == -1) {
+ printf("magic_load failure\n");
+ goto end;
+ }
result = (char *)magic_buffer(magic_ctx, (void *)buffer, buffer_len);
if (result == NULL || strcmp(result, "OpenOffice.org 1.x Database file") != 0) {
size_t buffer_len = sizeof(buffer);
int retval = 0;
- MagicInit();
+ if (MagicInit() < 0) {
+ printf("MagicInit() failure\n");
+ return 0;
+ }
result = MagicGlobalLookup(buffer, buffer_len);
if (result == NULL || strncmp(result, "PDF document", 12) != 0) {
size_t buffer_len = sizeof(buffer);
int retval = 0;
- MagicInit();
+ if (MagicInit() < 0) {
+ printf("MagicInit() failure\n");
+ return 0;
+ }
result = MagicGlobalLookup(buffer, buffer_len);
if (result == NULL || strcmp(result, MICROSOFT_OFFICE_DOC) != 0) {
size_t buffer_len = sizeof(buffer);
int retval = 0;
- MagicInit();
+ if (MagicInit() < 0) {
+ printf("MagicInit() failure\n");
+ return 0;
+ }
result = MagicGlobalLookup(buffer, buffer_len);
if (result == NULL || strcmp(result, "OpenDocument Text") != 0) {
size_t buffer_len = sizeof(buffer);
int retval = 0;
- MagicInit();
+ if (MagicInit() < 0) {
+ printf("MagicInit() failure\n");
+ return 0;
+ }
result = MagicGlobalLookup(buffer, buffer_len);
if (result == NULL || strcmp(result, "OpenOffice.org 1.x Database file") != 0) {
size_t buffer_len = sizeof(buffer);
int retval = 0;
- MagicInit();
+ if (MagicInit() < 0) {
+ printf("MagicInit() failure\n");
+ return 0;
+ }
result1 = MagicGlobalLookup(buffer, buffer_len);
if (result1 == NULL || strncmp(result1, "PDF document", 12) != 0) {
size_t buffer_len = sizeof(buffer);
int retval = 0;
- MagicInit();
+ if (MagicInit() < 0) {
+ printf("MagicInit() failure\n");
+ return 0;
+ }
result = MagicGlobalLookup(buffer, buffer_len);
if (result == NULL || strncmp(result, "JPEG", 4) != 0) {