2021-08-25 00:30:10 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* libragephoto RAGE Photo Parser
|
|
|
|
* Copyright (C) 2021 Syping
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* This software is provided as-is, no warranties are given to you, we are not
|
|
|
|
* responsible for anything with use of the software, you are self responsible.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2021-08-27 01:47:09 +02:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
|
|
|
#include <iconv.h>
|
2021-08-25 00:30:10 +02:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2021-08-27 01:47:09 +02:00
|
|
|
char photoHeader[256] = {
|
|
|
|
0x50, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x54, 0x00,
|
|
|
|
0x4f, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00,
|
|
|
|
0x30, 0x00, 0x32, 0x00, 0x2f, 0x00, 0x30, 0x00,
|
|
|
|
0x31, 0x00, 0x2f, 0x00, 0x31, 0x00, 0x37, 0x00,
|
|
|
|
0x20, 0x00, 0x30, 0x00, 0x38, 0x00, 0x3a, 0x00,
|
|
|
|
0x34, 0x00, 0x32, 0x00, 0x3a, 0x00, 0x34, 0x00,
|
|
|
|
0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
|
};
|
2021-11-06 20:17:28 +01:00
|
|
|
char photoHeader_string[256];
|
2021-08-27 01:47:09 +02:00
|
|
|
iconv_t iconv_in = iconv_open("UTF-8", "UTF-16LE");
|
|
|
|
if (iconv_in == (iconv_t)-1)
|
|
|
|
return -1;
|
|
|
|
size_t src_s = sizeof(photoHeader);
|
2021-11-06 20:17:28 +01:00
|
|
|
size_t dst_s = sizeof(photoHeader_string);
|
2021-08-27 01:47:09 +02:00
|
|
|
char *src = photoHeader;
|
2021-11-06 20:17:28 +01:00
|
|
|
char *dst = photoHeader_string;
|
2021-10-20 08:49:35 +02:00
|
|
|
const size_t ret = iconv(iconv_in, &src, &src_s, &dst, &dst_s);
|
2021-08-27 01:47:09 +02:00
|
|
|
iconv_close(iconv_in);
|
|
|
|
if (ret == static_cast<size_t>(-1)) {
|
|
|
|
return -1;
|
|
|
|
}
|
2021-11-06 20:17:28 +01:00
|
|
|
return strcmp(photoHeader_string, "PHOTO - 02/01/17 08:42:44");
|
2021-08-25 00:30:10 +02:00
|
|
|
}
|