2006-10-28 19:45:02 +00:00
|
|
|
/*
|
|
|
|
* fileform.h
|
|
|
|
*
|
|
|
|
* This file is a part of NSIS.
|
|
|
|
*
|
2021-01-01 20:27:52 +00:00
|
|
|
* Copyright (C) 1999-2021 Nullsoft and Contributors
|
2006-10-28 19:45:02 +00:00
|
|
|
*
|
|
|
|
* Licensed under the zlib/libpng license (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* This software is provided 'as-is', without any express or implied
|
|
|
|
* warranty.
|
2010-03-24 17:22:56 +00:00
|
|
|
*
|
|
|
|
* Unicode support by Jim Park -- 08/13/2007
|
2006-10-28 19:45:02 +00:00
|
|
|
*/
|
|
|
|
|
2006-03-11 11:13:50 +00:00
|
|
|
#ifndef ___MAKENSIS_FILEFORM_H___
|
|
|
|
#define ___MAKENSIS_FILEFORM_H___
|
|
|
|
|
|
|
|
#include "exehead/fileform.h"
|
|
|
|
#include "writer.h"
|
|
|
|
|
|
|
|
#define DECLARE_WRITER(x) \
|
|
|
|
class x##_writer : public writer \
|
|
|
|
{ \
|
|
|
|
public: \
|
|
|
|
x##_writer(writer_sink *sink) : writer(sink) {} \
|
|
|
|
void write(const x *data); \
|
|
|
|
static void write_block(IGrowBuf *buf, writer_sink *sink) \
|
|
|
|
{ \
|
|
|
|
x *arr = (x *) buf->get(); \
|
|
|
|
size_t l = buf->getlen() / sizeof(x); \
|
|
|
|
x##_writer writer(sink); \
|
|
|
|
for (size_t i = 0; i < l; i++) \
|
|
|
|
{ \
|
|
|
|
writer.write(&arr[i]); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2014-02-08 00:13:52 +00:00
|
|
|
#define DECLARE_PLATFORMITEMWRITER(x) class x##_writer : public writer \
|
|
|
|
{ public: \
|
|
|
|
x##_writer(writer_sink *sink) : writer(sink) {} \
|
2015-09-18 15:55:56 +00:00
|
|
|
void write(const x *data, const writer_target_info&ti); \
|
|
|
|
static void write_block(IGrowBuf *pGB, writer_sink *pS, const writer_target_info *pTI = 0) \
|
2014-02-08 00:13:52 +00:00
|
|
|
{ \
|
|
|
|
x##_writer writer(pS); \
|
2015-09-18 15:55:56 +00:00
|
|
|
if (!pTI) pTI = &pS->get_target_info(); /* Defaults to TI from sink */ \
|
2014-02-08 00:13:52 +00:00
|
|
|
for (size_t l = pGB->getlen() / sizeof(x), i = 0; i < l; i++) \
|
2015-09-18 15:55:56 +00:00
|
|
|
writer.write(&(((x*)pGB->get())[i]), *pTI); \
|
2014-02-08 00:13:52 +00:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-11 11:13:50 +00:00
|
|
|
DECLARE_WRITER(firstheader);
|
2015-09-18 15:55:56 +00:00
|
|
|
DECLARE_PLATFORMITEMWRITER(block_header);
|
|
|
|
DECLARE_PLATFORMITEMWRITER(header); // Platform specific because it writes block_headers
|
2006-03-11 11:13:50 +00:00
|
|
|
DECLARE_WRITER(section);
|
|
|
|
DECLARE_WRITER(entry);
|
|
|
|
DECLARE_WRITER(page);
|
2014-02-08 00:13:52 +00:00
|
|
|
DECLARE_PLATFORMITEMWRITER(ctlcolors);
|
2006-03-11 11:13:50 +00:00
|
|
|
DECLARE_WRITER(LOGFONT);
|
|
|
|
|
|
|
|
class lang_table_writer : public writer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
lang_table_writer(writer_sink *sink, const size_t lang_strings) :
|
|
|
|
writer(sink), m_lang_strings(lang_strings) {}
|
|
|
|
void write(const unsigned char *data);
|
|
|
|
static void write_block(IGrowBuf *buf, writer_sink *sink, const size_t table_size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
size_t m_lang_strings;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif//!___MAKENSIS_FILEFORM_H___
|