Subversion Repositories filter_foundry

Compare Revisions

Regard whitespace Rev 455 → Rev 456

/trunk/3264_mixer/foundry_3264_mixer.cpp
28,102 → 28,147
#include <fstream>
#include <vector>
 
bool update_pe_timestamp(LPCTSTR filename, time_t timestamp) {
size_t peoffset;
FILE* fptr;
typedef struct _PE32 {
uint32_t magic; // 0x50450000
IMAGE_FILE_HEADER fileHeader; // COFF Header without Signature
IMAGE_OPTIONAL_HEADER32 optHeader; // Standard COFF fields, Windows Specific Fields, Data Directories
} PE32;
 
fptr = _wfopen(filename, L"rb+");
if (fptr == NULL) return false;
#ifdef UNICODE
typedef std::wstring tstring;
#else
typedef std::string tstring;
#endif
 
fseek(fptr, 0x3C, SEEK_SET);
fread(&peoffset, sizeof(peoffset), 1, fptr);
int binary_file_string_replace(tstring file_name, const char* asearch, const char* areplace) {
std::ifstream input(file_name, std::ios::binary);
 
fseek(fptr, (long)peoffset + 8, SEEK_SET);
fwrite(&timestamp, sizeof(time_t), 1, fptr);
std::vector<char> buffer((std::istreambuf_iterator<char>(input)), (std::istreambuf_iterator<char>()));
std::vector<char>::iterator itbegin = buffer.begin();
std::vector<char>::iterator itend = buffer.end();
 
fclose(fptr);
if (strlen(asearch) != strlen(areplace)) {
printf("Replace value length greater than original!\n");
return -1;
}
int MAX_BUFFER = strlen(asearch);
 
return true;
char* needed_str = (char*)malloc(MAX_BUFFER);
if (needed_str == 0) return -1;
char* replace_str = (char*)malloc(MAX_BUFFER);
if (replace_str == 0) return -1;
 
memcpy(needed_str, asearch, MAX_BUFFER);
memcpy(replace_str, areplace, MAX_BUFFER);
 
int ifound = 0;
 
for (auto it = itbegin; it < itend; it++) {
if (memcmp(it._Ptr, needed_str, MAX_BUFFER) == 0) {
strncpy(it._Ptr, replace_str, MAX_BUFFER);
it += MAX_BUFFER - 1; // -1 because it++ will be set on the next loop
ifound++;
}
}
 
bool update_pe_stackSizeCommit(LPCTSTR filename, size_t stackReserve, size_t stackCommit) {
size_t peoffset;
FILE* fptr;
if (ifound > 0) {
std::ofstream ofile(file_name, std::ios::out | std::ios::binary);
ofile.write((char*)&buffer[0], buffer.size() * sizeof(char));
ofile.close();
}
 
fptr = _wfopen(filename, L"rb+");
if (fptr == NULL) return false;
return ifound;
}
 
fseek(fptr, 0x3C, SEEK_SET);
fread(&peoffset, sizeof(peoffset), 1, fptr);
int binary_file_string_find(tstring file_name, const char* asearch) {
std::ifstream input(file_name, std::ios::binary);
 
fseek(fptr, (long)peoffset + 12 * 8, SEEK_SET);
fwrite(&stackReserve, sizeof(size_t), 1, fptr);
std::vector<char> buffer((std::istreambuf_iterator<char>(input)), (std::istreambuf_iterator<char>()));
std::vector<char>::iterator itbegin = buffer.begin();
std::vector<char>::iterator itend = buffer.end();
 
fseek(fptr, (long)peoffset + 12 * 8 + 4, SEEK_SET);
fwrite(&stackCommit, sizeof(size_t), 1, fptr);
int MAX_BUFFER = strlen(asearch);
 
fclose(fptr);
char* needed_str = (char*)malloc(MAX_BUFFER);
if (needed_str == 0) return -1;
 
return true;
memcpy(needed_str, asearch, MAX_BUFFER);
 
int ifound = 0;
 
for (auto it = itbegin; it < itend; it++) {
if (memcmp(it._Ptr, needed_str, MAX_BUFFER) == 0) {
it += MAX_BUFFER - 1; // -1 because it++ will be set on the next loop
ifound++;
}
}
 
bool update_pe_heapSizeCommit(LPCTSTR filename, size_t heapReserve, size_t heapCommit) {
return ifound;
}
 
void _set_pe_int32(FILE* fptr, size_t fieldoffset, int32_t val) {
size_t peoffset;
FILE* fptr;
 
fptr = _wfopen(filename, L"rb+");
if (fptr == NULL) return false;
fseek(fptr, 0x3C, SEEK_SET);
fread(&peoffset, sizeof(peoffset), 1, fptr);
 
fseek(fptr, (long)peoffset + fieldoffset, SEEK_SET);
fwrite(&val, sizeof(int32_t), 1, fptr);
}
 
int32_t _get_pe_int32(FILE* fptr, size_t fieldoffset) {
size_t peoffset;
int32_t res;
 
fseek(fptr, 0x3C, SEEK_SET);
fread(&peoffset, sizeof(peoffset), 1, fptr);
 
fseek(fptr, (long)peoffset + 13 * 8, SEEK_SET);
fwrite(&heapReserve, sizeof(size_t), 1, fptr);
fseek(fptr, (long)peoffset + fieldoffset, SEEK_SET);
fread(&res, sizeof(int32_t), 1, fptr);
 
fseek(fptr, (long)peoffset + 13 * 8 + 4, SEEK_SET);
fwrite(&heapCommit, sizeof(size_t), 1, fptr);
return res;
}
 
bool update_pe_timestamp(LPCTSTR filename, __time32_t timestamp) {
FILE* fptr = _wfopen(filename, L"rb+");
if (fptr == NULL) return false;
 
_set_pe_int32(fptr, /*0x0008*/offsetof(PE32, fileHeader.TimeDateStamp), timestamp);
 
fclose(fptr);
 
return true;
}
 
bool openWatcomCosmetics(LPCTSTR filename) {
if (binary_file_string_find(filename, "Open Watcom") > 0) {
FILE* fptr = _wfopen(filename, L"rb+");
if (fptr == NULL) return false;
 
//DOS .EXE header
struct image_dos_header
{
uint16_t e_magic; // Magic number
uint16_t e_cblp; // Bytes on last page of file
uint16_t e_cp; // Pages in file
uint16_t e_crlc; // Relocations
uint16_t e_cparhdr; // Size of header in paragraphs
uint16_t e_minalloc; // Minimum extra paragraphs needed
uint16_t e_maxalloc; // Maximum extra paragraphs needed
uint16_t e_ss; // Initial (relative) SS value
uint16_t e_sp; // Initial SP value
uint16_t e_csum; // Checksum
uint16_t e_ip; // Initial IP value
uint16_t e_cs; // Initial (relative) CS value
uint16_t e_lfarlc; // File address of relocation table
uint16_t e_ovno; // Overlay number
uint16_t e_res[4]; // Reserved words
uint16_t e_oemid; // OEM identifier (for e_oeminfo)
uint16_t e_oeminfo; // OEM information; e_oemid specific
uint16_t e_res2[10]; // Reserved words
int32_t e_lfanew; // File address of new exe header
};
// Min OS Version 1.11 ... But the actual minimal Windows version is Windows NT 3.11
int32_t minOsVersion = _get_pe_int32(fptr, /*0x0040*/offsetof(PE32, optHeader.MajorOperatingSystemVersion));
if (minOsVersion == 0x000B0001) {
_set_pe_int32(fptr, /*0x0040*/offsetof(PE32, optHeader.MajorOperatingSystemVersion), 0x00000003); // Windows 3.0
}
 
struct image_file_header
{
uint16_t Machine;
uint16_t NumberOfSections;
uint32_t TimeDateStamp;
uint32_t PointerToSymbolTable;
uint32_t NumberOfSymbols;
uint16_t SizeOfOptionalHeader;
uint16_t Characteristics;
};
// Stack reserved cannot be changed with linker option "OPTION STACK=1m" (Rejected https://github.com/open-watcom/open-watcom-v2/issues/780)
// It is not required for DLLs, but everybody does it, and I think it is cosmetics to fill these fields, even if not required.
_set_pe_int32(fptr, /*0x0060*/offsetof(PE32, optHeader.SizeOfStackReserve), 0x00100000);
_set_pe_int32(fptr, /*0x0064*/offsetof(PE32, optHeader.SizeOfStackCommit), 0x00001000);
// Heap reserved can be changed with linker option "OPTION HEAP=1m"
_set_pe_int32(fptr, /*0x0068*/offsetof(PE32, optHeader.SizeOfHeapReserve), 0x00100000);
_set_pe_int32(fptr, /*0x006C*/offsetof(PE32, optHeader.SizeOfHeapCommit), 0x00001000);
 
fclose(fptr);
 
// 32 bit (OpenWatcom cosmetics): Export table name "FilterFoundry.dll" => "FilterFoundry.8bf"
// since OpenWatcom cannot link a 8BF file natively.
binary_file_string_replace(filename, "FilterFoundry.dll", "FilterFoundry.8bf");
}
 
return true;
}
 
uint32_t calculate_checksum(LPCTSTR filename) {
//Calculate checksum of image
// Taken from "PE Bliss" Cross-Platform Portable Executable C++ Library
132,7 → 177,7
 
FILE* fptr;
unsigned long long checksum = 0;
struct image_dos_header header;
IMAGE_DOS_HEADER header;
size_t filesize;
unsigned long long top;
unsigned long pe_checksum_pos;
144,7 → 189,7
 
//Read DOS header
fseek(fptr, 0, SEEK_SET);
fread(&header, sizeof(struct image_dos_header), 1, fptr);
fread(&header, sizeof(IMAGE_DOS_HEADER), 1, fptr);
 
//Calculate PE checksum
fseek(fptr, 0, SEEK_SET);
154,7 → 199,7
//"CheckSum" field position in optional PE headers - it's always 64 for PE and PE+
//Calculate real PE headers "CheckSum" field position
//Sum is safe here
pe_checksum_pos = header.e_lfanew + sizeof(struct image_file_header) + sizeof(uint32_t) + checksum_pos_in_optional_headers;
pe_checksum_pos = header.e_lfanew + sizeof(IMAGE_FILE_HEADER) + sizeof(uint32_t) + checksum_pos_in_optional_headers;
 
//Calculate checksum for each byte of file
fseek(fptr, 0L, SEEK_END);
190,7 → 235,6
}
 
bool repair_pe_checksum(LPCTSTR filename) {
size_t peoffset;
FILE* fptr;
 
uint32_t checksum = calculate_checksum(filename);
199,12 → 243,8
fptr = _wfopen(filename, L"rb+");
if (fptr == NULL) return false;
 
fseek(fptr, 0x3C, SEEK_SET);
fread(&peoffset, sizeof(peoffset), 1, fptr);
_set_pe_int32(fptr, /*0x0058*/offsetof(PE32, optHeader.CheckSum), (int32_t)checksum);
 
fseek(fptr, (long)peoffset + 88, SEEK_SET);
fwrite(&checksum, sizeof(uint32_t), 1, fptr);
 
fclose(fptr);
 
return true;
272,51 → 312,7
return bSuccessful;
}
 
#ifdef UNICODE
int binary_file_string_replace(std::wstring file_name, const char* asearch, const char* areplace) {
#else
int binary_file_string_replace(std::string file_name, const char* asearch, const char* areplace) {
#endif
std::ifstream input(file_name, std::ios::binary);
 
std::vector<char> buffer((std::istreambuf_iterator<char>(input)), (std::istreambuf_iterator<char>()));
std::vector<char>::iterator itbegin = buffer.begin();
std::vector<char>::iterator itend = buffer.end();
 
if (strlen(asearch) != strlen(areplace)) {
printf("Replace value length greater than original!\n");
return -1;
}
int MAX_BUFFER = strlen(asearch);
 
char* needed_str = (char*)malloc(MAX_BUFFER);
if (needed_str == 0) return -1;
char* replace_str = (char*)malloc(MAX_BUFFER);
if (replace_str == 0) return -1;
memcpy(needed_str, asearch, MAX_BUFFER);
memcpy(replace_str, areplace, MAX_BUFFER);
 
int ifound = 0;
 
for (auto it = itbegin; it < itend ; it++) {
if (memcmp(it._Ptr, needed_str, MAX_BUFFER) == 0) {
strncpy(it._Ptr, replace_str, MAX_BUFFER);
it += MAX_BUFFER - 1; // -1 because it++ will be set on the next loop
ifound++;
}
}
 
if (ifound > 0) {
std::ofstream ofile(file_name, std::ios::out | std::ios::binary);
ofile.write((char*)&buffer[0], buffer.size() * sizeof(char));
ofile.close();
}
 
return ifound;
}
 
 
int main()
{
LPCTSTR lpTemplateType = L"TPLT";
397,23 → 393,13
removeFromFile(file64tmp, lpTemplateType, lpName64Pipl, wLanguageNeutral);
}
 
// 32 bit (OpenWatcom cosmetics): Export table name "filterfoundry.dll" => "FilterFoundry.8bf"
// since OpenWatcom cannot link a 8BF file natively.
binary_file_string_replace(file32tmp, "filterfoundry.dll", "FilterFoundry.8bf");
binary_file_string_replace(file32out, "filterfoundry.dll", "FilterFoundry.8bf");
// Do some cosmetics to OpenWatcom binaries
openWatcomCosmetics(file32tmp);
openWatcomCosmetics(file32out);
 
// More OpenWatcom cosmetics! https://github.com/open-watcom/open-watcom-v2/issues/780 (Rejected)
// Stack reserved cannot be changed with linker option "OPTION STACK=1m" (Rejected)
// It is not required for DLLs, but everybody does it, and I think it is cosmetics to fill these fields, even if not required.
update_pe_stackSizeCommit(file32tmp, 1024 * 1024, 4096);
update_pe_stackSizeCommit(file32out, 1024 * 1024, 4096);
// Heap reserved can be changed with linker option "OPTION HEAP=1m"
update_pe_heapSizeCommit(file32tmp, 1024 * 1024, 4096);
update_pe_heapSizeCommit(file32out, 1024 * 1024, 4096);
 
// 3. Update timestamp of 32/64 "TMP"
{
if (!update_pe_timestamp(file32tmp, time(0))) {
if (!update_pe_timestamp(file32tmp, (__time32_t)time(0))) {
DeleteFile(file32out);
DeleteFile(file64out);
printf("Error: Update TMP timestamp 32\n");
420,7 → 406,7
return 1;
}
 
if (!update_pe_timestamp(file64tmp, time(0))) {
if (!update_pe_timestamp(file64tmp, (__time32_t)time(0))) {
DeleteFile(file32out);
DeleteFile(file64out);
printf("Error: Update TMP timestamp 64\n");
566,7 → 552,7
 
// 9. Update timestamp of 32/64 "OUT"
{
if (!update_pe_timestamp(file32out, time(0))) {
if (!update_pe_timestamp(file32out, (__time32_t)time(0))) {
DeleteFile(file32out);
DeleteFile(file64out);
printf("Error: Update OUT timestamp 32\n");
573,7 → 559,7
return 1;
}
 
if (!update_pe_timestamp(file64out, time(0))) {
if (!update_pe_timestamp(file64out, (__time32_t)time(0))) {
DeleteFile(file32out);
DeleteFile(file64out);
printf("Error: Update OUT timestamp 64\n");
/trunk/3264_mixer/foundry_3264_mixer.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/ff.h
56,7 → 56,7
PS_FILTER_FILETYPE = '8BFM'
};
 
typedef struct{
typedef struct globals_t_ {
Boolean standalone;
Boolean parmloaded; // this means that the filter is loaded, but without PARM (title, author, etc.)
Boolean obfusc;
101,7 → 101,7
void DoStart (FilterRecordPtr epb);
OSErr DoContinue (FilterRecordPtr epb);
void DoFinish (FilterRecordPtr epb);
void RequestNext (FilterRecordPtr epb,long);
void RequestNext (FilterRecordPtr epb);
InternalState saveInternalState();
void restoreInternalState(InternalState state);
 
/trunk/load_win.c
49,7 → 49,7
// load first PARM resource
if ((resinfo = FindResource(hm, MAKEINTRESOURCE(parm_id), PARM_TYPE))) {
if ((h = LoadResource(hm, resinfo)) && (pparm = (Ptr)LockResource(h))) {
int res = readPARM(&gdata->parm, pparm);
Boolean res = readPARM(&gdata->parm, pparm);
gdata->obfusc = false;
return res;
}
62,7 → 62,7
// We need to copy the information, because the resource data is read-only
DWORD resSize = SizeofResource(hm, resinfo);
if (resSize == sizeof(PARM_T)) {
int res;
Boolean res;
PARM_T* copy = (PARM_T*)malloc(resSize);
if (!copy) return false;
memcpy(copy, pparm, resSize);
/trunk/main.c
393,7 → 393,8
 
int checkandinitparams(Handle params){
char *reasonstr,*reason;
int i,bUninitializedParams;
int i;
Boolean bUninitializedParams;
Boolean showdialog;
 
if (!host_preserves_parameters()) {
471,7 → 472,7
if(!gdata->standalone){
// no saved settings (not standalone)
for(i = 0; i < 8; ++i)
slider[i] = i*10+100;
slider[i] = (uint8_t)(i*10+100);
for(i = 0; i < 4; ++i)
if(expr[i])
free(expr[i]);
582,7 → 583,7
}
}
 
void RequestNext(FilterRecordPtr pb,long toprow){
void RequestNext(FilterRecordPtr pb){
/* Request next block of the image */
 
pb->inLoPlane = pb->outLoPlane = 0;
672,7 → 673,7
chunksize = needall ? (FILTER_RECT(pb).bottom - FILTER_RECT(pb).top) : CHUNK_ROWS;
toprow = FILTER_RECT(pb).top;
}
RequestNext(pb, toprow);
RequestNext(pb);
}
 
OSErr DoContinue(FilterRecordPtr pb){
703,7 → 704,7
{
toprow += chunksize;
if (toprow < BIGDOC_FILTER_RECT(pb).bottom)
RequestNext(pb, toprow);
RequestNext(pb);
else {
SETRECT(BIGDOC_IN_RECT(pb), 0, 0, 0, 0);
BIGDOC_OUT_RECT(pb) = BIGDOC_MASK_RECT(pb) = BIGDOC_IN_RECT(pb);
733,7 → 734,7
{
toprow += chunksize;
if(toprow < FILTER_RECT(pb).bottom)
RequestNext(pb,toprow);
RequestNext(pb);
else{
SETRECT(IN_RECT(pb),0,0,0,0);
OUT_RECT(pb) = MASK_RECT(pb) = IN_RECT(pb);
/trunk/make.c
75,7 → 75,7
 
uplim = 0;
for (k=1; k<4; k++) {
int mask;
int mask = 0;
if (k == 1) mask = 1;//0b1;
if (k == 2) mask = 2;//0b11;
if (k == 3) mask = 4;//0b111;
/trunk/make_win.c
30,6 → 30,12
 
extern HINSTANCE hDllInstance;
 
typedef struct _PE32 {
uint32_t magic; // 0x50450000
IMAGE_FILE_HEADER fileHeader; // COFF Header without Signature
IMAGE_OPTIONAL_HEADER32 optHeader; // Standard COFF fields, Windows Specific Fields, Data Directories
} PE32;
 
Boolean doresources(FSSpec* dst, int bits);
 
void dbglasterror(TCHAR *func){
210,7 → 216,9
return dwError;
}
 
Boolean update_pe_timestamp(const FSSpec* dst, time_t timestamp) {
typedef long __time32_t;
 
Boolean update_pe_timestamp(const FSSpec* dst, __time32_t timestamp) {
size_t peoffset;
FILEREF fptr;
Boolean res;
222,8 → 230,8
SetFPos(fptr, fsFromStart, 0x3C) ||
(cnt = sizeof(peoffset), noErr) ||
FSRead(fptr, &cnt, &peoffset) ||
SetFPos(fptr, fsFromStart, (long)peoffset + 8) ||
(cnt = sizeof(time_t), noErr) ||
SetFPos(fptr, fsFromStart, (long)peoffset + /*0x0008*/offsetof(PE32, fileHeader.TimeDateStamp)) ||
(cnt = sizeof(__time32_t), noErr) ||
FSWrite(fptr, &cnt, &timestamp);
 
FSClose(fptr);
262,41 → 270,6
return found;
}
 
//DOS .EXE header
struct image_dos_header
{
uint16_t e_magic; // Magic number
uint16_t e_cblp; // Bytes on last page of file
uint16_t e_cp; // Pages in file
uint16_t e_crlc; // Relocations
uint16_t e_cparhdr; // Size of header in paragraphs
uint16_t e_minalloc; // Minimum extra paragraphs needed
uint16_t e_maxalloc; // Maximum extra paragraphs needed
uint16_t e_ss; // Initial (relative) SS value
uint16_t e_sp; // Initial SP value
uint16_t e_csum; // Checksum
uint16_t e_ip; // Initial IP value
uint16_t e_cs; // Initial (relative) CS value
uint16_t e_lfarlc; // File address of relocation table
uint16_t e_ovno; // Overlay number
uint16_t e_res[4]; // Reserved words
uint16_t e_oemid; // OEM identifier (for e_oeminfo)
uint16_t e_oeminfo; // OEM information; e_oemid specific
uint16_t e_res2[10]; // Reserved words
int32_t e_lfanew; // File address of new exe header
};
 
struct image_file_header
{
uint16_t Machine;
uint16_t NumberOfSections;
uint32_t TimeDateStamp;
uint32_t PointerToSymbolTable;
uint32_t NumberOfSymbols;
uint16_t SizeOfOptionalHeader;
uint16_t Characteristics;
};
 
uint32_t calculate_checksum(FSSpec* dst) {
//Calculate checksum of image
// Taken from "PE Bliss" Cross-Platform Portable Executable C++ Library
305,7 → 278,7
 
FILEREF fptr;
unsigned long long checksum = 0;
struct image_dos_header header;
IMAGE_DOS_HEADER header;
FILEPOS filesize, i;
unsigned long long top;
unsigned long pe_checksum_pos;
316,7 → 289,7
 
//Read DOS header
SetFPos(fptr, fsFromStart, 0);
cnt = sizeof(struct image_dos_header);
cnt = sizeof(IMAGE_DOS_HEADER);
FSRead(fptr, &cnt, &header);
 
//Calculate PE checksum
327,7 → 300,7
//"CheckSum" field position in optional PE headers - it's always 64 for PE and PE+
//Calculate real PE headers "CheckSum" field position
//Sum is safe here
pe_checksum_pos = header.e_lfanew + sizeof(struct image_file_header) + sizeof(uint32_t) + checksum_pos_in_optional_headers;
pe_checksum_pos = header.e_lfanew + sizeof(IMAGE_FILE_HEADER) + sizeof(uint32_t) + checksum_pos_in_optional_headers;
 
//Calculate checksum for each byte of file
filesize = 0;
378,7 → 351,7
SetFPos(fptr, fsFromStart, 0x3C) ||
(cnt = sizeof(peoffset), noErr) ||
FSRead(fptr, &cnt, &peoffset) ||
SetFPos(fptr, fsFromStart, (long)peoffset + 88) ||
SetFPos(fptr, fsFromStart, (long)peoffset + /*0x0058*/offsetof(PE32, optHeader.CheckSum)) ||
(cnt = sizeof(uint32_t), noErr) ||
FSWrite(fptr, &cnt, &checksum);
 
547,7 → 520,7
}
}
 
if (!update_pe_timestamp(dst, time(0))) {
if (!update_pe_timestamp(dst, (__time32_t)time(0))) {
simplewarning((TCHAR*)TEXT("update_pe_timestamp failed"));
}
 
/trunk/read.c
80,8 → 80,8
int v;
v = atoi(linebuf);
if (v < 0) v = 0;
if (v > 255) v = 255;
slider[linecnt-1] = v;
else if (v > 255) v = 255;
slider[linecnt-1] = (uint8_t)v;
}else{
if(lineptr){
/* it's not an empty line; append it to current expr string */
301,8 → 301,8
gdata->parm.val[i] = *((uint32_t*)q);
v = *((uint32_t*)q);
if (v < 0) v = 0;
if (v > 255) v = 255;
slider[i] = v;
else if (v > 255) v = 255;
slider[i] = (uint8_t)v;
q += sizeof(uint32_t);
}
 
360,7 → 360,6
}
 
Boolean readPARM(PARM_T* pparm, Ptr p){
int i;
Boolean towin, tomac, fromwin, frommac;
unsigned int signature = *((unsigned int*)p);
unsigned int standalone = *((unsigned int*)p+1);
404,6 → 403,8
 
// Do we need to do string conversion?
if (frommac) {
int i;
 
/* Mac PARM resource stores Pascal strings - convert to C strings, since this is what we work internally with (regardles of OS) */
myp2cstr((unsigned char*)pparm->szCategory);
myp2cstr((unsigned char*)pparm->szTitle);
421,13 → 422,13
 
// Convert copyright CRLF to CR (actually, just removing LF)
char copyrightCRLF[256] = { 0 };
char* p = &copyrightCRLF[0];
char* pCopyright = &copyrightCRLF[0];
for (i = 0; i < strlen(pparm->szCopyright); i++) {
if (pparm->szCopyright[i] != LF) {
*p++ = pparm->szCopyright[i];
*pCopyright++ = pparm->szCopyright[i];
}
}
*p++ = '\0';
*pCopyright++ = '\0';
strcpy(pparm->szCopyright, copyrightCRLF);
 
// these are the only numeric fields we *have* to swap
449,14 → 450,14
 
// Convert CR in the copyright field to CRLF.
char copyrightCRLF[256] = { 0 };
char* p = &copyrightCRLF[0];
char* pCopyright = &copyrightCRLF[0];
for (i = 0; i < strlen(pparm->szCopyright); i++) {
*p++ = pparm->szCopyright[i];
*pCopyright++ = pparm->szCopyright[i];
if (pparm->szCopyright[i] == CR) {
*p++ = LF;
*pCopyright++ = LF;
}
}
*p++ = '\0';
*pCopyright++ = '\0';
strcpy(pparm->szCopyright, copyrightCRLF);
 
// these are the only numeric fields we *have* to swap
466,7 → 467,8
}
 
// Now set the values in pparm into the working variables expr[] and slider[], so that they are visible in the GUI
 
{
int i;
for(i = 0; i < 4; ++i){
if(expr[i]) free(expr[i]);
expr[i] = my_strdup(pparm->szFormula[i]);
482,6 → 484,7
}
*/
}
}
 
return true;
}
762,8 → 765,8
}
v = atoi(tmp);
if (v < 0) v = 0;
if (v > 255) v = 255;
gdata->parm.val[i] = slider[i] = v;
else if (v > 255) v = 255;
gdata->parm.val[i] = slider[i] = (uint8_t)v;
}
 
// Map names
/trunk/scripting.c
142,11 → 142,11
else {
int i;
for (i = 0; i <= 7; ++i) {
if (key == getAeteKey('0' + i, gdata->standalone ? &gdata->parm : NULL)) {
if (key == getAeteKey((char)('0'+i), gdata->standalone ? &gdata->parm : NULL)) {
PIGetInt(token, &v);
if (v < 0) v = 0;
if (v > 255) v = 255;
slider[i] = v;
else if (v > 255) v = 255;
slider[i] = (uint8_t)v;
}
}
}
190,7 → 190,7
allctls = checksliders(4, ctls, maps);
for (i = 0; i <= 7; ++i) {
if (allctls || ctls[i]) {
PIPutInt(token, getAeteKey('0' + i, gdata->standalone ? &gdata->parm : NULL), slider[i]);
PIPutInt(token, getAeteKey((char)('0'+i), gdata->standalone ? &gdata->parm : NULL), slider[i]);
}
}
 
/trunk/telegraphics_common/tt/compat_string.c
33,7 → 33,7
if(str1[0]+n > 255)
n = 255 - str1[0];
memcpy(str1+1+str1[0],str2+1,n);
str1[0] += n;
str1[0] += (unsigned char)n;
return str1;
}
const unsigned char *PLstrrchr(const unsigned char *str1, int ch1){
/trunk/ui.c
191,9 → 191,9
void slidermoved(DIALOGREF dp,int i){
int v = GETSLIDERVALUE(dp,i);
if (v < 0) v = 0;
if (v > 255) v = 255;
else if (v > 255) v = 255;
i -= FIRSTCTLITEM;
slider[i] = v;
slider[i] = (uint8_t)v;
SETCTLTEXTINT(dp,i+FIRSTCTLTEXTITEM,v,false);
}
 
200,10 → 200,10
void slidertextchanged(DIALOGREF dp,int i){
int v = GETCTLTEXTINT(dp,i,NULL,false);
if (v < 0) v = 0;
if (v > 255) v = 255;
else if (v > 255) v = 255;
i -= FIRSTCTLTEXTITEM;
SETSLIDERVALUE(dp,i+FIRSTCTLITEM,v);
slider[i] = v;
slider[i] = (uint8_t)v;
}
 
void maindlgupdate(DIALOGREF dp){
/trunk/ui_build.c
52,12 → 52,12
SetDlgItemTextA(dp,AUTHORITEM, "Anonymous");
strcpy(s,"Map X");
for(i = 0; i < 4; ++i){
s[4] = '0'+i;
s[4] = (char)('0' + i);
SetDlgItemTextA(dp,FIRSTMAPNAMEITEM+i,s);
}
strcpy(s,"ctl(X)");
for(i = 0; i < 8; ++i){
s[4] = '0'+i;
s[4] = (char)('0' + i);
SetDlgItemTextA(dp,FIRSTCTLNAMEITEM+i,s);
}
}
242,7 → 242,7
gdata->parm.popDialog = needui; //true if need to pop a parameter dialog
gdata->parm.unknown1 = gdata->parm.unknown2 = gdata->parm.unknown3 = 0;
gdata->parm.iProtected = ISDLGBUTTONCHECKED(dp,PROTECTITEM); // == 1 means protected
gdata->obfusc = ISDLGBUTTONCHECKED(dp,PROTECTITEM);
gdata->obfusc = (Boolean)ISDLGBUTTONCHECKED(dp,PROTECTITEM);
 
// TODO: Unicode!
//xstrcpy(fname, gdata->parm.szTitle);
/trunk/ui_win.c
84,7 → 84,7
 
Boolean simplealert(TCHAR* s){
HWND hwnd;
TCHAR title[256];
TCHAR title[256] = { 0 };
if (gdata && gdata->standalone) {
#ifdef UNICODE
mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
101,7 → 101,7
 
Boolean simplewarning(TCHAR* s) {
HWND hwnd;
TCHAR title[256];
TCHAR title[256] = { 0 };
if (gdata && gdata->standalone) {
#ifdef UNICODE
mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
117,7 → 117,7
 
Boolean showmessage(TCHAR *s) {
HWND hwnd;
TCHAR title[256];
TCHAR title[256] = { 0 };
if (gdata && gdata->standalone) {
#ifdef UNICODE
mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
226,7 → 226,7
int item,i;
POINT newpos;
DRAWITEMSTRUCT *pdi;
Point newscroll;
Point newscroll = { 0, 0 };
HGDIOBJ hfnt;
 
extern Boolean doupdates;
238,8 → 238,8
int sliderNum = (int)wParam - FIRSTCTLITEM;
int sliderVal = (lParam & 0xFFFF);
if (sliderVal < 0) sliderVal = 0;
if (sliderVal > 255) sliderVal = 255;
slider[sliderNum] = sliderVal;
else if (sliderVal > 255) sliderVal = 255;
slider[sliderNum] = (uint8_t)sliderVal;
 
SETCTLTEXTINT(hDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false);
REPAINTCTL(hDlg, FIRSTCTLTEXTITEM + sliderNum);
310,14 → 310,6
SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, WM_SETFONT,(WPARAM)hfnt,false);
}
 
maindlginit(hDlg);
 
// Some versions of Windows (NT 3.x) won't show the preview if it is calculated here.
// So we need to put it in a timer.
// Note that 1 millisecond is enough, even if the window needs longer than 1 millisecond to load.
//recalc_preview(gpb, hDlg);
SetTimer(hDlg, IDT_TIMER_INITPREVIEW_DRAW, 1, (TIMERPROC)NULL);
 
// Implement "up" and "down" keys for the edit controls
// TODO: Better use a spin-edit?
for (i = 0; i < 8; ++i) {
328,6 → 320,14
#endif
}
 
maindlginit(hDlg);
 
// Some versions of Windows (NT 3.x) won't show the preview if it is calculated here.
// So we need to put it in a timer.
// Note that 1 millisecond is enough, even if the window needs longer than 1 millisecond to load.
//recalc_preview(gpb, hDlg);
SetTimer(hDlg, IDT_TIMER_INITPREVIEW_DRAW, 1, (TIMERPROC)NULL);
 
break;
case WM_DESTROY:
gdata->hWndMainDlg = 0;
/trunk/wpj/filterfoundry.tgt
28,7 → 28,7
6
MItem
17
filterfoundry.dll
FilterFoundry.dll
7
WString
4