#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.57 2014/05/06 18:20:39 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.58 2014/05/13 16:41:06 christos Exp $")
#endif
#include <assert.h>
cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,
const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
const cdf_dir_t *dir, cdf_stream_t *scn)
+{
+ return cdf_read_user_stream(info, h, sat, ssat, sst, dir,
+ "\05SummaryInformation", scn);
+}
+
+int
+cdf_read_user_stream(const cdf_info_t *info, const cdf_header_t *h,
+ const cdf_sat_t *sat, const cdf_sat_t *ssat, const cdf_stream_t *sst,
+ const cdf_dir_t *dir, const char *name, cdf_stream_t *scn)
{
size_t i;
const cdf_directory_t *d;
- static const char name[] = "\05SummaryInformation";
+ size_t name_len = strlen(name) + 1;
for (i = dir->dir_len; i > 0; i--)
if (dir->dir_tab[i - 1].d_type == CDF_DIR_TYPE_USER_STREAM &&
- cdf_namecmp(name, dir->dir_tab[i - 1].d_name, sizeof(name))
+ cdf_namecmp(name, dir->dir_tab[i - 1].d_name, name_len)
== 0)
break;
if (i == 0) {
- DPRINTF(("Cannot find summary information section\n"));
+ DPRINTF(("Cannot find user stream `%s'\n", name));
errno = ESRCH;
return -1;
}
const cdf_directory_t **);
int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
cdf_property_info_t **, size_t *, size_t *);
+int cdf_read_user_stream(const cdf_info_t *, const cdf_header_t *,
+ const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
+ const cdf_dir_t *, const char *, cdf_stream_t *);
int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
const cdf_dir_t *, cdf_stream_t *);
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.42 2014/05/07 10:13:12 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.43 2014/05/07 21:26:06 christos Exp $")
#endif
#include <assert.h>
int len;
if (!NOTMIME(ms) && root_storage)
- str = cdf_clsid_to_mime(root_storage->d_storage_uuid, clsid2mime);
+ str = cdf_clsid_to_mime(root_storage->d_storage_uuid,
+ clsid2mime);
for (i = 0; i < count; i++) {
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
break;
}
if (root_storage) {
- str = cdf_clsid_to_mime(root_storage->d_storage_uuid, clsid2desc);
+ str = cdf_clsid_to_mime(root_storage->d_storage_uuid,
+ clsid2desc);
if (str)
if (file_printf(ms, ", %s", str) == -1)
return -2;
}
#endif
+ if ((i = cdf_read_user_stream(&info, &h, &sat, &ssat, &sst, &dir,
+ "FileHeader", &scn)) != -1) {
+#define HWP5_SIGNATURE "HWP Document File"
+ if (scn.sst_dirlen >= sizeof(HWP5_SIGNATURE) - 1
+ && memcmp(scn.sst_tab, HWP5_SIGNATURE,
+ sizeof(HWP5_SIGNATURE) - 1) == 0) {
+ if (NOTMIME(ms)) {
+ if (file_printf(ms,
+ "Hangul (Korean) Word Processor File 5.x") == -1)
+ return -1;
+ } else {
+ if (file_printf(ms, "application/x-hwp") == -1)
+ return -1;
+ }
+ i = 1;
+ goto out5;
+ } else {
+ free(scn.sst_tab);
+ scn.sst_tab = NULL;
+ scn.sst_len = 0;
+ scn.sst_dirlen = 0;
+ }
+ }
+
if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
&scn)) == -1) {
if (errno == ESRCH) {
i = 1;
}
}
+out5:
free(scn.sst_tab);
out4:
free(sst.sst_tab);