mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
57 lines
2.6 KiB
C
57 lines
2.6 KiB
C
/*
|
|
* USBDOS: USB DOS bootable stick creation utility
|
|
* Copyright (c) 2011 Pete Batard <pete@akeo.ie>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#define USBDOS_DEBUG
|
|
|
|
#define APP_VERSION "USBDOS v0.1.0.1"
|
|
#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
|
|
|
|
#define safe_free(p) do {free((void*)p); p = NULL;} while(0)
|
|
#define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
|
#define safe_min(a, b) min((size_t)(a), (size_t)(b))
|
|
#define safe_strcp(dst, dst_max, src, count) do {memcpy(dst, src, safe_min(count, dst_max)); \
|
|
((char*)dst)[safe_min(count, dst_max)-1] = 0;} while(0)
|
|
#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1)
|
|
#define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, dst_max - safe_strlen(dst) - 1))
|
|
#define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1)
|
|
#define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
|
|
#define safe_stricmp(str1, str2) _stricmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
|
|
#define safe_strncmp(str1, str2, count) strncmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
|
|
#define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
|
#define safe_sprintf _snprintf
|
|
#define safe_strlen(str) ((((char*)str)==NULL)?0:strlen(str))
|
|
#define safe_strdup _strdup
|
|
|
|
#if defined(_MSC_VER)
|
|
#define safe_vsnprintf(buf, size, format, arg) _vsnprintf_s(buf, size, _TRUNCATE, format, arg)
|
|
#else
|
|
#define safe_vsnprintf vsnprintf
|
|
#endif
|
|
|
|
#if !defined(GUID_DEVINTERFACE_DISK)
|
|
const GUID GUID_DEVINTERFACE_DISK = { 0x53f56307L, 0xb6bf, 0x11d0, {0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} };
|
|
#endif
|
|
|
|
typedef struct _SCSI_PASS_THROUGH_WITH_BUFFERS {
|
|
SCSI_PASS_THROUGH Spt;
|
|
ULONG Filler;
|
|
UCHAR SenseBuf[32];
|
|
UCHAR DataBuf[512];
|
|
} SCSI_PASS_THROUGH_WITH_BUFFERS, *PSCSI_PASS_THROUGH_WITH_BUFFERS;
|