本文整理汇总了C++中safe_strcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ safe_strcpy函数的具体用法?C++ safe_strcpy怎么用?C++ safe_strcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_strcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scenario_load_list
/**
* Searches and grabs the metadata for all the scenarios.
*/
void scenario_load_list()
{
utf8 directory[MAX_PATH];
// Clear scenario list
gScenarioListCount = 0;
// Get scenario directory from RCT2
safe_strcpy(directory, gConfigGeneral.game_path, sizeof(directory));
safe_strcat_path(directory, "Scenarios", sizeof(directory));
scenario_list_include(directory);
// Get scenario directory from user directory
platform_get_user_directory(directory, "scenario");
scenario_list_include(directory);
scenario_list_sort();
scenario_scores_load();
utf8 scoresPath[MAX_PATH];
scenario_scores_legacy_get_path(scoresPath);
scenario_scores_legacy_load(scoresPath);
scenario_scores_legacy_load(get_file_path(PATH_ID_SCORES));
}
示例2: session_new
static session *
session_new (server *serv, char *from, int type, int focus)
{
session *sess;
sess = malloc (sizeof (struct session));
if (sess == NULL)
{
return NULL;
}
memset (sess, 0, sizeof (struct session));
sess->server = serv;
sess->logfd = -1;
sess->scrollfd = -1;
sess->type = type;
sess->alert_beep = SET_DEFAULT;
sess->alert_taskbar = SET_DEFAULT;
sess->alert_tray = SET_DEFAULT;
sess->text_hidejoinpart = SET_DEFAULT;
sess->text_logging = SET_DEFAULT;
sess->text_scrollback = SET_DEFAULT;
sess->lastact_idx = LACT_NONE;
if (from != NULL)
safe_strcpy (sess->channel, from, CHANLEN);
sess_list = g_slist_prepend (sess_list, sess);
fe_new_window (sess, focus);
return sess;
}
示例3: mset
static void mset(char *arg, int from_tty)
{
int argc;
char *set_args, *p, *argv[5], tmpCmdLine[1024];
static char *macsbug_set_keywords[] = {"DITTO", "UNMANGLE", NULL};
gdb_setup_argv(safe_strcpy(tmpCmdLine, arg), "mset", &argc, argv, 4);
if (argc > 1) {
if (argc == 2)
p = "";
else if (argc == 3)
p = argv[2];
else
p = NULL;
if (p) {
if (gdb_strcmpl(argv[1], "ditto")) {
if (ditto_args)
gdb_free(ditto_args);
ditto_args = strcpy((char *)gdb_malloc(strlen(arg)+1), p);
macsbug_set("mset", &ditto_args, &ditto, "Ditto-display in memory dumps", from_tty, NULL);
} else if (gdb_strcmpl(argv[1], "unmangle")) {
if (unmangle_args)
gdb_free(unmangle_args);
unmangle_args = strcpy((char *)gdb_malloc(strlen(arg)+1), p);
macsbug_set("mset", &unmangle_args, &unmangle, "Unmangling of symbols", from_tty, set_gdb_demangle);
} else
gdb_error("usage: MSET DITTO | UNMANGLE [ON | OFF | NOW | SHOW] (invalid arguments)");
} else
gdb_error("usage: MSET DITTO | UNMANGLE [ON | OFF | NOW | SHOW] (invalid arguments)");
}
gdb_set_int("$__lastcmd__", 40);
}
示例4: SearchNick
static int
SearchNick (char *text, char *nicks)
{
char S[300]; /* size of bluestring in xchatprefs */
char *n;
char *p;
char *t;
int ns;
if (nicks == NULL)
return 0;
text = strip_color (text);
safe_strcpy (S, nicks, sizeof (S));
n = strtok (S, ",");
while (n != NULL)
{
t = text;
ns = strlen (n);
while ((p = nocasestrstr (t, n)))
{
if ((p == text || !isalnum (*(p - 1))) && !isalnum (*(p + ns)))
{
free (text);
return 1;
}
t = p + 1;
}
n = strtok (NULL, ",");
}
free (text);
return 0;
}
示例5: delete_project_owned_file
// Delete the file located at path.
// If "retry" is set, do retries for 5 sec in case some
// other program (e.g. virus checker) has the file locked.
// Don't do this if deleting directories - it can lock up the Manager.
//
int delete_project_owned_file(const char* path, bool retry) {
int retval = 0;
if (!boinc_file_or_symlink_exists(path)) {
return 0;
}
retval = delete_project_owned_file_aux(path);
if (retval && retry) {
double start = dtime();
do {
boinc_sleep(drand()*2); // avoid lockstep
retval = delete_project_owned_file_aux(path);
if (!retval) break;
} while (dtime() < start + FILE_RETRY_INTERVAL);
}
if (retval) {
safe_strcpy(boinc_failed_file, path);
return ERR_UNLINK;
}
if (log_flags.slot_debug) {
msg_printf(0, MSG_INFO, "[slot] removed file %s", path);
}
return 0;
}
示例6: window_multiplayer_groups_paint
static void window_multiplayer_groups_paint(rct_window *w, rct_drawpixelinfo *dpi)
{
window_draw_widgets(w, dpi);
window_multiplayer_draw_tab_images(w, dpi);
rct_widget* widget = &window_multiplayer_groups_widgets[WIDX_DEFAULT_GROUP];
sint32 group = network_get_group_index(network_get_default_group());
if (group != -1) {
char buffer[300];
char* lineCh;
lineCh = buffer;
lineCh = utf8_write_codepoint(lineCh, FORMAT_WINDOW_COLOUR_2);
safe_strcpy(lineCh, network_get_group_name(group), sizeof(buffer) - (lineCh - buffer));
set_format_arg(0, const char *, buffer);
gfx_draw_string_centred_clipped(
dpi,
STR_STRING,
gCommonFormatArgs,
COLOUR_BLACK,
w->x + (widget->left + widget->right - 11) / 2,
w->y + widget->top,
widget->right - widget->left - 8
);
}
示例7: wu_delete_files
int wu_delete_files(WORKUNIT& wu) {
char* p;
char filename[256], pathname[256], buf[BLOB_SIZE];
bool no_delete=false;
int count_deleted = 0, retval, mthd_retval = 0;
if (strstr(wu.name, "nodelete")) return 0;
safe_strcpy(buf, wu.xml_doc);
p = strtok(buf, "\n");
strcpy(filename, "");
while (p) {
if (parse_str(p, "<name>", filename, sizeof(filename))) {
} else if (match_tag(p, "<file_info>")) {
no_delete = false;
strcpy(filename, "");
} else if (match_tag(p, "<no_delete/>")) {
no_delete = true;
} else if (match_tag(p, "</file_info>")) {
if (!no_delete) {
retval = get_file_path(
filename, config.download_dir, config.uldl_dir_fanout,
pathname
);
if (retval == ERR_OPENDIR) {
log_messages.printf(MSG_CRITICAL,
"[WU#%d] missing dir for %s\n",
wu.id, filename
);
mthd_retval = ERR_UNLINK;
} else if (retval) {
log_messages.printf(MSG_CRITICAL,
"[WU#%d] get_file_path: %s: %s\n",
wu.id, filename, boincerror(retval)
);
} else {
log_messages.printf(MSG_NORMAL,
"[WU#%d] deleting %s\n", wu.id, filename
);
retval = unlink(pathname);
if (retval) {
log_messages.printf(MSG_CRITICAL,
"[WU#%d] unlink %s failed: %s\n",
wu.id, filename, boincerror(retval)
);
mthd_retval = ERR_UNLINK;
} else {
count_deleted++;
}
// delete the cached MD5 file if needed
//
if (config.cache_md5_info) {
strcat(pathname,".md5");
log_messages.printf(MSG_NORMAL,
"[WU#%d] deleting %s\n", wu.id, filename
);
retval = unlink(pathname);
if (retval) {
log_messages.printf(MSG_CRITICAL,
"[WU#%d] unlink %s failed: %s\n",
wu.id, filename, boincerror(retval)
);
}
}
}
}
}
p = strtok(0, "\n");
}
log_messages.printf(MSG_DEBUG,
"[WU#%d] deleted %d file(s)\n", wu.id, count_deleted
);
return mthd_retval;
}
示例8: platform_get_openrct_data_path
void platform_get_openrct_data_path(utf8 *outPath, size_t outSize)
{
safe_strcpy(outPath, _openrctDataDirectoryPath, outSize);
}
示例9: cmdline_parse
void __init cmdline_parse(const char *cmdline)
{
char opt[100], *optval, *optkey, *q;
const char *p = cmdline;
struct kernel_param *param;
int bool_assert;
if ( cmdline == NULL )
return;
safe_strcpy(saved_cmdline, cmdline);
for ( ; ; )
{
/* Skip whitespace. */
while ( *p == ' ' )
p++;
if ( *p == '\0' )
break;
/* Grab the next whitespace-delimited option. */
q = optkey = opt;
while ( (*p != ' ') && (*p != '\0') )
{
if ( (q-opt) < (sizeof(opt)-1) ) /* avoid overflow */
*q++ = *p;
p++;
}
*q = '\0';
/* Search for value part of a key=value option. */
optval = strchr(opt, '=');
if ( optval != NULL )
{
*optval++ = '\0'; /* nul-terminate the option value */
q = strpbrk(opt, "([{<");
}
else
{
optval = q; /* default option value is empty string */
q = NULL;
}
/* Boolean parameters can be inverted with 'no-' prefix. */
bool_assert = !!strncmp("no-", optkey, 3);
if ( !bool_assert )
optkey += 3;
for ( param = &__setup_start; param < &__setup_end; param++ )
{
if ( strcmp(param->name, optkey) )
{
if ( param->type == OPT_CUSTOM && q &&
strlen(param->name) == q + 1 - opt &&
!strncmp(param->name, opt, q + 1 - opt) )
{
optval[-1] = '=';
((void (*)(const char *))param->var)(q);
optval[-1] = '\0';
}
continue;
}
switch ( param->type )
{
case OPT_STR:
strlcpy(param->var, optval, param->len);
break;
case OPT_UINT:
assign_integer_param(
param,
simple_strtoll(optval, NULL, 0));
break;
case OPT_BOOL:
case OPT_INVBOOL:
if ( !parse_bool(optval) )
bool_assert = !bool_assert;
assign_integer_param(
param,
(param->type == OPT_BOOL) == bool_assert);
break;
case OPT_SIZE:
assign_integer_param(
param,
parse_size_and_unit(optval, NULL));
break;
case OPT_CUSTOM:
if ( !bool_assert )
{
if ( *optval )
break;
safe_strcpy(opt, "no");
optval = opt;
}
((void (*)(const char *))param->var)(optval);
break;
default:
BUG();
break;
}
//.........这里部分代码省略.........
示例10: negprot_spnego
static DATA_BLOB negprot_spnego(void)
{
DATA_BLOB blob;
nstring dos_name;
fstring unix_name;
#ifdef DEVELOPER
size_t slen;
#endif
char guid[17];
const char *OIDs_krb5[] = {OID_KERBEROS5,
OID_KERBEROS5_OLD,
OID_NTLMSSP,
NULL};
const char *OIDs_plain[] = {OID_NTLMSSP, NULL};
global_spnego_negotiated = True;
memset(guid, '\0', sizeof(guid));
safe_strcpy(unix_name, global_myname(), sizeof(unix_name)-1);
strlower_m(unix_name);
push_ascii_nstring(dos_name, unix_name);
safe_strcpy(guid, dos_name, sizeof(guid)-1);
#ifdef DEVELOPER
/* Fix valgrind 'uninitialized bytes' issue. */
slen = strlen(dos_name);
if (slen < sizeof(guid)) {
memset(guid+slen, '\0', sizeof(guid) - slen);
}
#endif
/* strangely enough, NT does not sent the single OID NTLMSSP when
not a ADS member, it sends no OIDs at all
OLD COMMENT : "we can't do this until we teach our sesssion setup parser to know
about raw NTLMSSP (clients send no ASN.1 wrapping if we do this)"
Our sessionsetup code now handles raw NTLMSSP connects, so we can go
back to doing what W2K3 does here. This is needed to make PocketPC 2003
CIFS connections work with SPNEGO. See bugzilla bugs #1828 and #3133
for details. JRA.
*/
if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) {
#if 0
/* Code for PocketPC client */
blob = data_blob(guid, 16);
#else
/* Code for standalone WXP client */
blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE");
#endif
} else {
fstring myname;
char *host_princ_s = NULL;
const char * lkdc_realm =
lp_parm_talloc_string(GLOBAL_SECTION_SNUM,
"com.apple", "lkdc realm", NULL);
myname[0] = '\0';
get_mydnsfullname(myname);
strlower_m(myname);
/* If we have a LKDC, use it unless there is a managed realm
* also configured. The managed realm should have precedence.
*/
if (lkdc_realm && (*lp_realm() == '\0' ||
strcmp(lkdc_realm, lp_realm()) == 0)) {
asprintf(&host_princ_s,
"cifs/%[email protected]%s", lkdc_realm, lkdc_realm);
} else {
asprintf(&host_princ_s, "cifs/%[email protected]%s",
myname, lp_realm());
}
blob = spnego_gen_negTokenInit(guid, OIDs_krb5, host_princ_s);
SAFE_FREE(host_princ_s);
TALLOC_FREE(lkdc_realm);
}
return blob;
}
示例11: mangled_map
/* ************************************************************************** **
* MangledMap is a series of name pairs in () separated by spaces.
* If s matches the first of the pair then the name given is the
* second of the pair. A * means any number of any character and if
* present in the second of the pair as well as the first the
* matching part of the first string takes the place of the * in the
* second.
*
* I wanted this so that we could have RCS files which can be used
* by UNIX and DOS programs. My mapping string is (RCS rcs) which
* converts the UNIX RCS file subdirectory to lowercase thus
* preventing mangling.
*
* See 'mangled map' in smb.conf(5).
*
* ************************************************************************** **
*/
static void mangled_map(char *s, const char *MangledMap)
{
const char *start=MangledMap; /* Use this to search for mappings. */
const char *end; /* Used to find the end of strings. */
char *match_string;
pstring new_string; /* Make up the result here. */
char *np; /* Points into new_string. */
DEBUG( 5, ("Mangled Mapping '%s' map '%s'\n", s, MangledMap) );
while( *start ) {
while( (*start) && (*start != '(') )
start++;
if( !*start )
continue; /* Always check for the end. */
start++; /* Skip the ( */
end = start; /* Search for the ' ' or a ')' */
DEBUG( 5, ("Start of first in pair '%s'\n", start) );
while( (*end) && !((*end == ' ') || (*end == ')')) )
end++;
if( !*end ) {
start = end;
continue; /* Always check for the end. */
}
DEBUG( 5, ("End of first in pair '%s'\n", end) );
if( (match_string = map_filename( s, start, end-start )) ) {
int size_left = sizeof(new_string) - 1;
DEBUG( 5, ("Found a match\n") );
/* Found a match. */
start = end + 1; /* Point to start of what it is to become. */
DEBUG( 5, ("Start of second in pair '%s'\n", start) );
end = start;
np = new_string;
while( (*end && size_left > 0) /* Not the end of string. */
&& (*end != ')') /* Not the end of the pattern. */
&& (*end != '*') ) { /* Not a wildcard. */
*np++ = *end++;
size_left--;
}
if( !*end ) {
start = end;
continue; /* Always check for the end. */
}
if( *end == '*' ) {
if (size_left > 0 )
safe_strcpy( np, match_string, size_left );
np += strlen( match_string );
size_left -= strlen( match_string );
end++; /* Skip the '*' */
while ((*end && size_left > 0) /* Not the end of string. */
&& (*end != ')') /* Not the end of the pattern. */
&& (*end != '*')) { /* Not a wildcard. */
*np++ = *end++;
size_left--;
}
}
if (!*end) {
start = end;
continue; /* Always check for the end. */
}
if (size_left > 0)
*np++ = '\0'; /* NULL terminate it. */
DEBUG(5,("End of second in pair '%s'\n", end));
new_string[sizeof(new_string)-1] = '\0';
pstrcpy( s, new_string ); /* Substitute with the new name. */
DEBUG( 5, ("s is now '%s'\n", s) );
}
start = end; /* Skip a bit which cannot be wanted anymore. */
start++;
}
}
示例12: ExtractISO
BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
{
size_t i, k, size;
int j;
uint16_t sl_version;
FILE* fd;
int r = 1;
iso9660_t* p_iso = NULL;
udf_t* p_udf = NULL;
udf_dirent_t* p_udf_root;
LONG progress_style;
char *tmp, *buf;
char path[MAX_PATH];
const char* basedir[] = { "i386", "minint" };
const char* tmp_sif = ".\\txtsetup.sif~";
const char ISOLINUX[] = { 'I', 'S', 'O', 'L', 'I', 'N', 'U', 'X', ' ' };
iso_extension_mask_t iso_extension_mask = ISO_EXTENSION_ALL;
if ((src_iso == NULL) || (dest_dir == NULL))
return FALSE;
scan_only = scan;
cdio_log_set_handler(log_handler);
psz_extract_dir = dest_dir;
progress_style = GetWindowLong(hISOProgressBar, GWL_STYLE);
if (scan_only) {
total_blocks = 0;
memset(&iso_report, 0, sizeof(iso_report));
has_ldlinux_c32 = FALSE;
// String array of all isolinux/syslinux locations
StrArrayCreate(&config_path, 8);
StrArrayCreate(&isolinux_path, 8);
// Change the Window title and static text
SetWindowTextU(hISOProgressDlg, lmprintf(MSG_202));
SetWindowTextU(hISOFileName, lmprintf(MSG_202));
// Change progress style to marquee for scanning
SetWindowLong(hISOProgressBar, GWL_STYLE, progress_style | PBS_MARQUEE);
SendMessage(hISOProgressBar, PBM_SETMARQUEE, TRUE, 0);
} else {
uprintf("Extracting files...\n");
IGNORE_RETVAL(_chdirU(app_dir));
SetWindowTextU(hISOProgressDlg, lmprintf(MSG_231));
if (total_blocks == 0) {
uprintf("Error: ISO has not been properly scanned.\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_ISO_SCAN);
goto out;
}
nb_blocks = 0;
iso_blocking_status = 0;
SetWindowLong(hISOProgressBar, GWL_STYLE, progress_style & (~PBS_MARQUEE));
SendMessage(hISOProgressBar, PBM_SETPOS, 0, 0);
}
SendMessage(hISOProgressDlg, UM_ISO_INIT, 0, 0);
/* First try to open as UDF - fallback to ISO if it failed */
p_udf = udf_open(src_iso);
if (p_udf == NULL)
goto try_iso;
uprintf("Disc image is an UDF image\n");
p_udf_root = udf_get_root(p_udf, true, 0);
if (p_udf_root == NULL) {
uprintf("Couldn't locate UDF root directory\n");
goto out;
}
if (scan_only) {
if (udf_get_logical_volume_id(p_udf, iso_report.label, sizeof(iso_report.label)) <= 0)
iso_report.label[0] = 0;
}
r = udf_extract_files(p_udf, p_udf_root, "");
goto out;
try_iso:
// Perform our first scan with Joliet disabled (if Rock Ridge is enabled), so that we can find if
// there exists a Rock Ridge file with a name > 64 chars or if there are symlinks. If that is the
// case then we also disable Joliet during the extract phase.
if ((!enable_joliet) || (enable_rockridge && (scan_only || iso_report.has_long_filename || iso_report.has_symlinks))) {
iso_extension_mask &= ~ISO_EXTENSION_JOLIET;
}
if (!enable_rockridge) {
iso_extension_mask &= ~ISO_EXTENSION_ROCK_RIDGE;
}
p_iso = iso9660_open_ext(src_iso, iso_extension_mask);
if (p_iso == NULL) {
uprintf("Unable to open '%s' as an ISO image.\n", src_iso);
r = 1;
goto out;
}
uprintf("Disc image is an ISO9660 image\n");
i_joliet_level = iso9660_ifs_get_joliet_level(p_iso);
if (scan_only) {
if (iso9660_ifs_get_volume_id(p_iso, &tmp)) {
safe_strcpy(iso_report.label, sizeof(iso_report.label), tmp);
safe_free(tmp);
} else
iso_report.label[0] = 0;
} else {
if (iso_extension_mask & (ISO_EXTENSION_JOLIET|ISO_EXTENSION_ROCK_RIDGE))
uprintf("This image will be extracted using %s extensions (if present)",
//.........这里部分代码省略.........
示例13: syslog_reader_thread
/*
* Read from the driver installation syslog in real-time
*/
void __cdecl syslog_reader_thread(void* param)
{
#define NB_SYSLOGS 3
char* syslog_name[NB_SYSLOGS] = { "\\inf\\setupapi.dev.log", "\\setupapi.log", "\\setupact.log" };
HANDLE log_handle;
DWORD last_offset, size, read_size, processed_size;
char *buffer = NULL;
char log_path[MAX_PATH_LENGTH];
DWORD duration = 0;
int i;
// Try the various driver installation logs
for (i=0; i<NB_SYSLOGS; i++) {
safe_strcpy(log_path, MAX_PATH_LENGTH, getenv("WINDIR")); // Use %WINDIR% env variable
safe_strcat(log_path, MAX_PATH_LENGTH, syslog_name[i]);
log_handle = CreateFileA(log_path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (log_handle != INVALID_HANDLE_VALUE) {
plog("using syslog '%s'", log_path);
break;
}
}
if (i == NB_SYSLOGS) {
plog("Could not open any syslog");
goto out;
}
// We assert that the log file is never gonna be bigger than 2 GB
// TODO: special case of setupapi.dev.log's last offset not being the end (v2)
last_offset = SetFilePointer(log_handle, 0, NULL, FILE_END);
if (last_offset == INVALID_SET_FILE_POINTER) {
plog("Could not set syslog offset");
goto out;
}
plog("sylog reader thread started");
SetEvent(syslog_ready_event);
processed_size = 0;
while(WaitForSingleObject(syslog_terminate_event, 0) != WAIT_OBJECT_0) {
// Find out if file size has increased since last time
size = GetFileSize(log_handle, NULL);
if (size == INVALID_FILE_SIZE) {
plog("could not read syslog file size");
goto out;
}
size -= last_offset;
if (size != 0) {
// Read from file and add a zero terminator
buffer = malloc(size+1);
if (buffer == NULL) {
plog("could not allocate buffer to read syslog");
goto out;
}
// Keep an extra spare byte at the beginning
if (!ReadFile(log_handle, buffer, size, &read_size, NULL)) {
plog("failed to read syslog");
goto out;
}
buffer[read_size] = 0;
// Send all the complete lines through the pipe
processed_size = process_syslog(buffer, read_size);
safe_free(buffer);
last_offset += processed_size;
// Reposition at start of last line if needed
if (processed_size != read_size) {
last_offset = SetFilePointer(log_handle, processed_size-read_size, NULL, FILE_CURRENT);
if (last_offset == INVALID_SET_FILE_POINTER) {
plog("Could not set syslog offset");
goto out;
}
}
// Reset adaptive sleep duration if we did send data out
if (processed_size !=0) {
duration = 0;
}
}
// Compute adaptive sleep duration
if (((size == 0) || (processed_size == 0)) && (duration < 500)) {
duration += 100; // read log more frequently on recent update
}
Sleep(duration);
}
out:
plog("syslog reader thread terminating");
safe_free(buffer);
CloseHandle(log_handle);
_endthread();
}
示例14: check_iso_props
/*
* Scan and set ISO properties
* Returns true if the the current file does not need to be processed further
*/
static BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_cfg, BOOL* is_old_c32,
int64_t i_file_length, const char* psz_basename, const char* psz_fullpath)
{
size_t i, j;
// Check for an isolinux/syslinux config file anywhere
*is_syslinux_cfg = FALSE;
for (i=0; i<ARRAYSIZE(syslinux_cfg); i++) {
if (safe_stricmp(psz_basename, syslinux_cfg[i]) == 0)
*is_syslinux_cfg = TRUE;
}
// Check for a syslinux v5.0+ file anywhere
if (safe_stricmp(psz_basename, ldlinux_c32) == 0) {
has_ldlinux_c32 = TRUE;
}
// Check for an old incompatible c32 file anywhere
for (i=0; i<NB_OLD_C32; i++) {
is_old_c32[i] = FALSE;
if ((safe_stricmp(psz_basename, old_c32_name[i]) == 0) && (i_file_length <= old_c32_threshold[i]))
is_old_c32[i] = TRUE;
}
if (scan_only) {
// Check for a "bootmgr(.efi)" file in root (psz_path = "")
if (*psz_dirname == 0) {
if (safe_strnicmp(psz_basename, bootmgr_efi_name, safe_strlen(bootmgr_efi_name)-5) == 0) {
iso_report.has_bootmgr = TRUE;
}
if (safe_stricmp(psz_basename, bootmgr_efi_name) == 0) {
iso_report.has_win7_efi = TRUE;
}
}
// Check for ReactOS' setupldr.sys anywhere
if ((iso_report.reactos_path[0] == 0) && (safe_stricmp(psz_basename, reactos_name) == 0))
safe_strcpy(iso_report.reactos_path, sizeof(iso_report.reactos_path), psz_fullpath);
// Check for the EFI boot directory
if (safe_stricmp(psz_dirname, efi_dirname) == 0)
iso_report.has_efi = TRUE;
// Check for PE (XP) specific files in "/i386" or "/minint"
for (i=0; i<ARRAYSIZE(pe_dirname); i++)
if (safe_stricmp(psz_dirname, pe_dirname[i]) == 0)
for (j=0; j<ARRAYSIZE(pe_file); j++)
if (safe_stricmp(psz_basename, pe_file[j]) == 0)
iso_report.winpe |= (1<<i)<<(ARRAYSIZE(pe_dirname)*j);
if (*is_syslinux_cfg) {
// Maintain a list of all the isolinux/syslinux configs identified so far
StrArrayAdd(&config_path, psz_fullpath);
}
if (safe_stricmp(psz_basename, isolinux_bin) == 0) {
// Maintain a list of all the isolinux.bin files found
StrArrayAdd(&isolinux_path, psz_fullpath);
}
for (i=0; i<NB_OLD_C32; i++) {
if (is_old_c32[i])
iso_report.has_old_c32[i] = TRUE;
}
if (i_file_length >= FOUR_GIGABYTES)
iso_report.has_4GB_file = TRUE;
// Compute projected size needed
total_blocks += i_file_length/UDF_BLOCKSIZE;
// NB: ISO_BLOCKSIZE = UDF_BLOCKSIZE
if ((i_file_length != 0) && (i_file_length%ISO_BLOCKSIZE == 0)) //
total_blocks++;
return TRUE;
}
// In case there's an ldlinux.sys on the ISO, prevent it from overwriting ours
if ((*psz_dirname == 0) && (safe_strcmp(psz_basename, ldlinux_name) == 0)) {
uprintf("skipping % file from ISO image\n", ldlinux_name);
return TRUE;
}
return FALSE;
}
示例15: iso_extract_files
// Returns 0 on success, nonzero on error
static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
{
HANDLE file_handle = NULL;
DWORD buf_size, wr_size, err;
BOOL s, is_syslinux_cfg, is_old_c32[NB_OLD_C32], is_symlink;
int i_length, r = 1;
char tmp[128], psz_fullpath[1024], *psz_basename;
const char *psz_iso_name = &psz_fullpath[strlen(psz_extract_dir)];
unsigned char buf[ISO_BLOCKSIZE];
CdioListNode_t* p_entnode;
iso9660_stat_t *p_statbuf;
CdioList_t* p_entlist;
size_t i, j, nul_pos;
lsn_t lsn;
int64_t i_file_length;
if ((p_iso == NULL) || (psz_path == NULL))
return 1;
i_length = _snprintf(psz_fullpath, sizeof(psz_fullpath), "%s%s/", psz_extract_dir, psz_path);
if (i_length < 0)
return 1;
psz_basename = &psz_fullpath[i_length];
p_entlist = iso9660_ifs_readdir(p_iso, psz_path);
if (!p_entlist) {
uprintf("Could not access directory %s\n", psz_path);
return 1;
}
_CDIO_LIST_FOREACH(p_entnode, p_entlist) {
if (FormatStatus) goto out;
p_statbuf = (iso9660_stat_t*) _cdio_list_node_data(p_entnode);
// Eliminate . and .. entries
if ( (strcmp(p_statbuf->filename, ".") == 0)
|| (strcmp(p_statbuf->filename, "..") == 0) )
continue;
// Rock Ridge requires an exception
is_symlink = FALSE;
if ((p_statbuf->rr.b3_rock == yep) && enable_rockridge) {
safe_strcpy(psz_basename, sizeof(psz_fullpath)-i_length-1, p_statbuf->filename);
if (safe_strlen(p_statbuf->filename) > 64)
iso_report.has_long_filename = TRUE;
// libcdio has a memleak for Rock Ridge symlinks. It doesn't look like there's an easy fix there as
// a generic list that's unaware of RR extensions is being used, so we prevent that memleak ourselves
is_symlink = (p_statbuf->rr.psz_symlink != NULL);
if (is_symlink)
iso_report.has_symlinks = TRUE;
if (scan_only)
safe_free(p_statbuf->rr.psz_symlink);
} else {
iso9660_name_translate_ext(p_statbuf->filename, psz_basename, i_joliet_level);
}
if (p_statbuf->type == _STAT_DIR) {
if (!scan_only) _mkdirU(psz_fullpath);
if (iso_extract_files(p_iso, psz_iso_name))
goto out;
} else {
i_file_length = p_statbuf->size;
if (check_iso_props(psz_path, &is_syslinux_cfg, is_old_c32, i_file_length, psz_basename, psz_fullpath)) {
continue;
}
// Replace slashes with backslashes and append the size to the path for UI display
nul_pos = safe_strlen(psz_fullpath);
for (i=0; i<nul_pos; i++)
if (psz_fullpath[i] == '/') psz_fullpath[i] = '\\';
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, TRUE, FALSE));
uprintf("Extracting: %s\n", psz_fullpath);
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(i_file_length, FALSE, FALSE));
SetWindowTextU(hISOFileName, psz_fullpath);
// ISO9660 cannot handle backslashes
for (i=0; i<nul_pos; i++) if (psz_fullpath[i] == '\\') psz_fullpath[i] = '/';
psz_fullpath[nul_pos] = 0;
for (i=0; i<NB_OLD_C32; i++) {
if (is_old_c32[i] && use_own_c32[i]) {
static_sprintf(tmp, "%s/syslinux-%s/%s", FILES_DIR, embedded_sl_version_str[0], old_c32_name[i]);
if (CopyFileA(tmp, psz_fullpath, FALSE)) {
uprintf(" Replaced with local version\n");
break;
}
uprintf(" Could not replace file: %s\n", WindowsErrorString());
}
}
if (i < NB_OLD_C32)
continue;
if (sanitize_filename(psz_fullpath))
uprintf(" File name sanitized to '%s'\n", psz_fullpath);
if (is_symlink) {
if (i_file_length == 0)
uprintf(" Ignoring Rock Ridge symbolic link to '%s'\n", p_statbuf->rr.psz_symlink);
safe_free(p_statbuf->rr.psz_symlink);
}
file_handle = CreateFileU(psz_fullpath, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file_handle == INVALID_HANDLE_VALUE) {
err = GetLastError();
uprintf(" Unable to create file: %s\n", WindowsErrorString());
if ((err == ERROR_ACCESS_DENIED) && (safe_strcmp(&psz_fullpath[3], autorun_name) == 0))
uprintf(stupid_antivirus);
//.........这里部分代码省略.........