2006-10-28 19:45:02 +00:00
|
|
|
/*
|
|
|
|
* util.h
|
|
|
|
*
|
|
|
|
* This file is a part of NSIS.
|
|
|
|
*
|
2009-02-01 14:44:30 +00:00
|
|
|
* Copyright (C) 1999-2009 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.
|
|
|
|
*/
|
|
|
|
|
2007-04-20 20:32:04 +00:00
|
|
|
#ifndef ___NSIS_UTIL_H___
|
|
|
|
#define ___NSIS_UTIL_H___
|
|
|
|
|
2004-03-12 20:43:54 +00:00
|
|
|
#include "../Platform.h"
|
2002-08-02 10:01:35 +00:00
|
|
|
#include "config.h"
|
2003-12-22 00:28:30 +00:00
|
|
|
#include <shlobj.h>
|
2002-08-02 10:01:35 +00:00
|
|
|
|
|
|
|
extern char ps_tmpbuf[NSIS_MAX_STRLEN*2];
|
2003-09-04 18:25:57 +00:00
|
|
|
char * NSISCALL GetNSISString(char *outbuf, int strtab);
|
|
|
|
#define GetNSISStringTT(strtab) GetNSISString(0, (strtab))
|
|
|
|
#define GetNSISStringNP(strtab) ((const char *)g_blocks[NB_STRINGS].offset+(strtab))
|
|
|
|
#define GetNSISTab(strtab) (strtab < 0 ? LANG_STR_TAB(strtab) : strtab)
|
2007-04-14 13:54:47 +00:00
|
|
|
void NSISCALL myRegGetStr(HKEY root, const char *sub, const char *name, char *out, int x64);
|
2002-08-19 23:18:19 +00:00
|
|
|
int NSISCALL myatoi(char *s);
|
|
|
|
void NSISCALL myitoa(char *s, int d);
|
|
|
|
char * NSISCALL mystrcpy(char *out, const char *in);
|
|
|
|
int NSISCALL mystrlen(const char *in);
|
2005-08-06 12:47:46 +00:00
|
|
|
char * NSISCALL mystrcat(char *out, const char *concat);
|
2003-02-07 23:04:25 +00:00
|
|
|
char * NSISCALL mystrstr(char *a, char *b);
|
2003-07-08 23:18:47 +00:00
|
|
|
WIN32_FIND_DATA * NSISCALL file_exists(char *buf);
|
2003-07-18 14:22:17 +00:00
|
|
|
char * NSISCALL my_GetTempFileName(char *buf, const char *dir);
|
2003-02-07 23:04:25 +00:00
|
|
|
|
2003-12-29 14:27:33 +00:00
|
|
|
//BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val);
|
|
|
|
#define my_SetWindowText SetWindowText
|
2002-09-21 02:34:34 +00:00
|
|
|
BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val);
|
2004-01-04 17:05:03 +00:00
|
|
|
//#define my_SetDialogItemText SetDlgItemText
|
2003-02-07 23:04:25 +00:00
|
|
|
//int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size);
|
|
|
|
#define my_GetWindowText GetWindowText
|
2004-01-04 17:05:03 +00:00
|
|
|
int NSISCALL my_GetDialogItemText(UINT idx, char *val);
|
|
|
|
//#define my_GetDialogItemText GetDlgItemText
|
2002-08-02 10:01:35 +00:00
|
|
|
|
|
|
|
#ifdef NSIS_CONFIG_LOG
|
2006-04-07 16:21:16 +00:00
|
|
|
extern char log_text[2048];
|
2002-08-19 23:18:19 +00:00
|
|
|
void NSISCALL log_write(int close);
|
2005-11-24 16:45:04 +00:00
|
|
|
const char * _RegKeyHandleToName(HKEY hKey);
|
|
|
|
void _LogData2Hex(char *buf, size_t buflen, unsigned char *data, size_t datalen);
|
2003-11-24 14:22:50 +00:00
|
|
|
void log_printf(char *format, ...);
|
2004-01-27 18:44:31 +00:00
|
|
|
#define log_printf2(x1,x2) log_printf(x1,x2);
|
|
|
|
#define log_printf3(x1,x2,x3) log_printf(x1,x2,x3);
|
|
|
|
#define log_printf4(x1,x2,x3,x4) log_printf(x1,x2,x3,x4);
|
|
|
|
#define log_printf5(x1,x2,x3,x4,x5) log_printf(x1,x2,x3,x4,x5);
|
|
|
|
#define log_printf6(x1,x2,x3,x4,x5,x6) log_printf(x1,x2,x3,x4,x5,x6);
|
|
|
|
#define log_printf7(x1,x2,x3,x4,x5,x6,x7) log_printf(x1,x2,x3,x4,x5,x6,x7);
|
|
|
|
#define log_printf8(x1,x2,x3,x4,x5,x6,x7,x8) log_printf(x1,x2,x3,x4,x5,x6,x7,x8);
|
2005-11-24 16:45:04 +00:00
|
|
|
#define RegKeyHandleToName(x1) _RegKeyHandleToName(x1);
|
|
|
|
#define LogData2Hex(x1,x2,x3,x4) _LogData2Hex(x1,x2,x3,x4);
|
2002-08-02 10:01:35 +00:00
|
|
|
extern int log_dolog;
|
|
|
|
extern char g_log_file[1024];
|
|
|
|
#else
|
|
|
|
#define log_printf(x1)
|
|
|
|
#define log_printf2(x1,x2)
|
|
|
|
#define log_printf3(x1,x2,x3)
|
|
|
|
#define log_printf4(x1,x2,x3,x4)
|
|
|
|
#define log_printf5(x1,x2,x3,x4,x5)
|
|
|
|
#define log_printf6(x1,x2,x3,x4,x5,x6)
|
2004-01-27 18:44:31 +00:00
|
|
|
#define log_printf7(x1,x2,x3,x4,x5,x6,x7)
|
2002-08-02 10:01:35 +00:00
|
|
|
#define log_printf8(x1,x2,x3,x4,x5,x6,x7,x8)
|
2005-11-24 16:45:04 +00:00
|
|
|
#define RegKeyHandleToName(x1) NULL
|
|
|
|
#define LogData2Hex(x1,x2,x3,x4)
|
2002-08-02 10:01:35 +00:00
|
|
|
#endif
|
|
|
|
|
2007-04-19 21:20:17 +00:00
|
|
|
HANDLE NSISCALL myCreateProcess(char *cmd);
|
2002-08-19 23:18:19 +00:00
|
|
|
int NSISCALL my_MessageBox(const char *text, UINT type);
|
2002-08-08 15:04:45 +00:00
|
|
|
|
2004-08-06 17:03:07 +00:00
|
|
|
void NSISCALL myDelete(char *buf, int flags);
|
2002-08-11 18:56:30 +00:00
|
|
|
|
2002-08-19 23:18:19 +00:00
|
|
|
HANDLE NSISCALL myOpenFile(const char *fn, DWORD da, DWORD cd);
|
|
|
|
int NSISCALL validpathspec(char *ubuf);
|
2002-09-25 02:13:38 +00:00
|
|
|
char * NSISCALL addtrailingslash(char *str);
|
2003-02-20 18:47:58 +00:00
|
|
|
//char NSISCALL lastchar(const char *str);
|
|
|
|
#define lastchar(str) *CharPrev(str,str+mystrlen(str))
|
2004-02-04 20:03:30 +00:00
|
|
|
char * NSISCALL findchar(char *str, char c);
|
2007-04-24 19:09:51 +00:00
|
|
|
char * NSISCALL trimslashtoend(char *buf);
|
2003-09-23 19:01:19 +00:00
|
|
|
char * NSISCALL skip_root(char *path);
|
2002-08-19 23:18:19 +00:00
|
|
|
int NSISCALL is_valid_instpath(char *s);
|
2005-07-30 12:33:20 +00:00
|
|
|
void NSISCALL validate_filename(char *fn);
|
2003-09-09 14:25:16 +00:00
|
|
|
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
|
2004-05-08 16:07:22 +00:00
|
|
|
void NSISCALL mini_memcpy(void *out, const void *in, int len);
|
2006-11-25 11:32:19 +00:00
|
|
|
void NSISCALL remove_ro_attr(char *file);
|
2002-09-22 19:05:43 +00:00
|
|
|
|
2007-04-20 20:32:04 +00:00
|
|
|
enum myGetProcAddressFunctions {
|
|
|
|
MGA_GetDiskFreeSpaceExA,
|
|
|
|
MGA_MoveFileExA,
|
|
|
|
MGA_RegDeleteKeyExA,
|
|
|
|
MGA_OpenProcessToken,
|
|
|
|
MGA_LookupPrivilegeValueA,
|
|
|
|
MGA_AdjustTokenPrivileges,
|
|
|
|
MGA_GetUserDefaultUILanguage,
|
2007-07-10 21:33:06 +00:00
|
|
|
MGA_SHAutoComplete,
|
|
|
|
MGA_SHGetFolderPathA
|
2007-04-20 20:32:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
2005-09-09 15:21:45 +00:00
|
|
|
void NSISCALL MessageLoop(UINT uCheckedMsg);
|
2005-09-02 11:35:45 +00:00
|
|
|
|
2002-09-22 19:05:43 +00:00
|
|
|
// Turn a pair of chars into a word
|
|
|
|
// Turn four chars into a dword
|
|
|
|
#ifdef __BIG_ENDIAN__ // Not very likely, but, still...
|
|
|
|
#define CHAR2_TO_WORD(a,b) (((WORD)(b))|((a)<<8))
|
2003-07-12 15:19:49 +00:00
|
|
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(c,d))|(CHAR2_TO_WORD(a,b)<<16))
|
2002-09-22 19:05:43 +00:00
|
|
|
#else
|
|
|
|
#define CHAR2_TO_WORD(a,b) (((WORD)(a))|((b)<<8))
|
2003-07-12 15:19:49 +00:00
|
|
|
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16))
|
2002-09-22 19:05:43 +00:00
|
|
|
#endif
|
2007-04-20 20:32:04 +00:00
|
|
|
|
|
|
|
#endif//!___NSIS_UTIL_H___
|