"kds_s2000w_client.c"
"kds_s2000w_debug.c"
"kds_s2000w_config.c"
- "kds_s2000w_heartbeat.c")
+ "kds_s2000w_heartbeat.c"
+ "kds_s2000w_image_type_check.c")
IF(NOT WITHOUT_IMAGEMAGICK)
LIST(APPEND SOURCES "kds_s2000w_image_converter_magick.c")
#endif
#include <string.h>
#include "kds_s2000w_image_converter.h"
+#include "kds_s2000w_image_type_check.h"
#include "kds_s2000w_debug.h"
-int _kds_s2000w_image_converter_is_tiff(blobdata* image)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_tiff");
-
- if (image->size < 4)
- return 0;
-
- char* image_data = (char*) image->data;
-
- int result = image_data[0] == (char)0x49;
- result = result && image_data[1] == (char)0x49;
- result = result && image_data[2] == (char)0x2A;
- return result && image_data[3] == (char)0x00;
-}
-
-int _kds_s2000w_image_converter_is_pnm(blobdata* image)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_pnm");
-
- if (image->size < 2)
- return 0;
-
- char* image_data = (char*) image->data;
- if (strncmp(image_data, "P6", 2) == 0)
- return 1;
-
- return strncmp(image_data, "P4", 2) == 0;
-}
-
-int _kds_s2000w_image_converter_is_jpeg(blobdata* image)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_jpeg");
-
- if (image->size < 2)
- return 0;
-
- char* image_data = (char*) image->data;
-
- int result = image_data[0] == (char)0xff;
- return result && image_data[1] == (char)0xd8;
-}
-
-
void _kds_s2000w_image_converter_to_pnm_depth(blobdata* in,
blobdata* out,
int depth,
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_jpg_to_pnm_With_depth");
- if (!_kds_s2000w_image_converter_is_jpeg(in))
+ if (!kds_s2000w_image_type_check_is_jpeg(in))
return;
_kds_s2000w_image_converter_to_pnm_depth(in, out, depth, "jpg");
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_convert_tiff_to_pnm");
- if (!_kds_s2000w_image_converter_is_tiff(in))
+ if (!kds_s2000w_image_type_check_is_tiff(in))
return;
_kds_s2000w_image_converter_to_pnm_depth(in, out, -1, "tiff");
#include <netpbm/pnm.h>
#include <jpeglib.h>
#include "kds_s2000w_image_converter.h"
+#include "kds_s2000w_image_type_check.h"
#include "kds_s2000w_debug.h"
#define SPACE 0x0a
#define RGB 3
#define GRAY 1
-int _kds_s2000w_image_converter_is_tiff(blobdata* image)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_tiff");
-
- if (image->size < 4)
- return 0;
-
- char* image_data = (char*) image->data;
-
- int result = image_data[0] == (char)0x49;
- result = result && image_data[1] == (char)0x49;
- result = result && image_data[2] == (char)0x2A;
- return result && image_data[3] == (char)0x00;
-}
-
-int _kds_s2000w_image_converter_is_pnm(blobdata* image)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_pnm");
-
- if (image->size < 2)
- return 0;
-
- char* image_data = (char*) image->data;
- if (strncmp(image_data, "P6", 2) == 0)
- return 1;
-
- return strncmp(image_data, "P4", 2) == 0;
-}
-
-int _kds_s2000w_image_converter_is_jpeg(blobdata* image)
-{
- kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_is_jpeg");
-
- if (image->size < 2)
- return 0;
-
- char* image_data = (char*) image->data;
-
- int result = image_data[0] == (char)0xff;
- return result && image_data[1] == (char)0xd8;
-}
-
int _kds_s2000w_image_converter_find_char(blobdata* image, int start, const char cfind)
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_find_char");
if (image->size < 2)
return;
- if (_kds_s2000w_image_converter_is_pnm(image)) {
+ if (kds_s2000w_image_type_check_is_pnm(image)) {
_kds_s2000w_image_converter_pnm_metadata(image, mdata);
return;
}
- if (_kds_s2000w_image_converter_is_jpeg(image)) {
+ if (kds_s2000w_image_type_check_is_jpeg(image)) {
_kds_s2000w_image_converter_jpeg_metadata(image, mdata);
return;
}
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_jpg_to_pnm");
- if (!_kds_s2000w_image_converter_is_jpeg(in))
+ if (!kds_s2000w_image_type_check_is_jpeg(in))
return;
FILE* jpeg_stream = fmemopen(in->data, in->size, "r");
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_image_converter_tiff_to_pnm");
- if (!_kds_s2000w_image_converter_is_tiff(in))
+ if (!kds_s2000w_image_type_check_is_tiff(in))
return;
return;
--- /dev/null
+#include <string.h>
+#include "kds_s2000w_debug.h"
+#include "kds_s2000w_image_type_check.h"
+
+int kds_s2000w_image_type_check_is_tiff(blobdata* image)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_type_check_is_tiff");
+
+ if (image->size < 4)
+ return 0;
+
+ char* image_data = (char*) image->data;
+
+ int result = image_data[0] == (char)0x49;
+ result = result && image_data[1] == (char)0x49;
+ result = result && image_data[2] == (char)0x2A;
+ return result && image_data[3] == (char)0x00;
+}
+
+int kds_s2000w_image_type_check_is_pnm(blobdata* image)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_type_check_is_pnm");
+
+ if (image->size < 2)
+ return 0;
+
+ char* image_data = (char*) image->data;
+ if (strncmp(image_data, "P6", 2) == 0)
+ return 1;
+
+ return strncmp(image_data, "P4", 2) == 0;
+}
+
+int kds_s2000w_image_type_check_is_jpeg(blobdata* image)
+{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_image_type_check_is_jpeg");
+
+ if (image->size < 2)
+ return 0;
+
+ char* image_data = (char*) image->data;
+
+ int result = image_data[0] == (char)0xff;
+ return result && image_data[1] == (char)0xd8;
+}
\ No newline at end of file
--- /dev/null
+#ifndef KDS_S2000W_IMAGE_TYPE_CHECK_H
+#define KDS_S2000W_IMAGE_TYPE_CHECK_H
+#include "kds_s2000w_image_converter.h"
+
+int kds_s2000w_image_type_check_is_tiff(blobdata* image);
+int kds_s2000w_image_type_check_is_pnm(blobdata* image);
+int kds_s2000w_image_type_check_is_jpeg(blobdata* image);
+
+#endif
\ No newline at end of file