| 1 |
/* |
| 2 |
* fileform.h |
| 3 |
* |
| 4 |
* This file is a part of NSIS. |
| 5 |
* |
| 6 |
* Copyright (C) 1999-2026 Nullsoft and Contributors |
| 7 |
* |
| 8 |
* Licensed under the zlib/libpng license (the "License"); |
| 9 |
* you may not use this file except in compliance with the License. |
| 10 |
* |
| 11 |
* Licence details can be found in the file COPYING. |
| 12 |
* |
| 13 |
* This software is provided 'as-is', without any express or implied |
| 14 |
* warranty. |
| 15 |
* |
| 16 |
* Unicode support by Jim Park -- 08/13/2007 |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef ___MAKENSIS_FILEFORM_H___ |
| 20 |
#define ___MAKENSIS_FILEFORM_H___ |
| 21 |
|
| 22 |
#include "exehead/fileform.h" |
| 23 |
#include "writer.h" |
| 24 |
|
| 25 |
#define DECLARE_WRITER(x) \ |
| 26 |
class x##_writer : public writer \ |
| 27 |
{ \ |
| 28 |
public: \ |
| 29 |
x##_writer(writer_sink *sink) : writer(sink) {} \ |
| 30 |
void write(const x *data); \ |
| 31 |
static void write_block(IGrowBuf *buf, writer_sink *sink) \ |
| 32 |
{ \ |
| 33 |
x *arr = (x *) buf->get(); \ |
| 34 |
size_t l = buf->getlen() / sizeof(x); \ |
| 35 |
x##_writer writer(sink); \ |
| 36 |
for (size_t i = 0; i < l; i++) \ |
| 37 |
{ \ |
| 38 |
writer.write(&arr[i]); \ |
| 39 |
} \ |
| 40 |
} \ |
| 41 |
} |
| 42 |
|
| 43 |
#define DECLARE_PLATFORMITEMWRITER(x) class x##_writer : public writer \ |
| 44 |
{ public: \ |
| 45 |
x##_writer(writer_sink *sink) : writer(sink) {} \ |
| 46 |
void write(const x *data, const writer_target_info&ti); \ |
| 47 |
static void write_block(IGrowBuf *pGB, writer_sink *pS, const writer_target_info *pTI = 0) \ |
| 48 |
{ \ |
| 49 |
x##_writer writer(pS); \ |
| 50 |
if (!pTI) pTI = &pS->get_target_info(); /* Defaults to TI from sink */ \ |
| 51 |
for (size_t l = pGB->getlen() / sizeof(x), i = 0; i < l; i++) \ |
| 52 |
writer.write(&(((x*)pGB->get())[i]), *pTI); \ |
| 53 |
} \ |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
DECLARE_WRITER(firstheader); |
| 58 |
DECLARE_PLATFORMITEMWRITER(block_header); |
| 59 |
DECLARE_PLATFORMITEMWRITER(header); // Platform specific because it writes block_headers |
| 60 |
DECLARE_WRITER(section); |
| 61 |
DECLARE_WRITER(entry); |
| 62 |
DECLARE_WRITER(page); |
| 63 |
DECLARE_PLATFORMITEMWRITER(ctlcolors); |
| 64 |
DECLARE_WRITER(LOGFONT); |
| 65 |
|
| 66 |
class lang_table_writer : public writer |
| 67 |
{ |
| 68 |
public: |
| 69 |
lang_table_writer(writer_sink *sink, const size_t lang_strings) : |
| 70 |
writer(sink), m_lang_strings(lang_strings) {} |
| 71 |
void write(const unsigned char *data); |
| 72 |
static void write_block(IGrowBuf *buf, writer_sink *sink, const size_t table_size); |
| 73 |
|
| 74 |
private: |
| 75 |
size_t m_lang_strings; |
| 76 |
|
| 77 |
}; |
| 78 |
|
| 79 |
#endif//!___MAKENSIS_FILEFORM_H___ |