static int make_dir(string dir) { if( !valid( dir, MODE_WRITE ) ) { #ifdef ENABLE_STACK_SECURITY console_msg( "Access to "+dir+" denied\n" ); return 0; #else console_msg("Access to "+dir+" would have been denied, ignoring...\n"); #endif } return ::make_dir( dir ); }
static int write_file(string file, string str, varargs int offset) { if( !valid( file, MODE_WRITE ) ) { #ifdef ENABLE_STACK_SECURITY console_msg( "Access to "+file+" denied\n" ); return 0; #else console_msg("Access to "+file+" would have been denied, ignoring...\n"); #endif } return ::write_file( file, str, offset ); }
static int remove_file(string file) { if (!valid(file, MODE_WRITE)) { #ifdef ENABLE_STACK_SECURITY console_msg("Access to " + file + " denied\n"); return 0; #else console_msg("Access to " + file + " would have been denied, ignoring...\n"); #endif } return::remove_file(file); }
static string read_file(string file, varargs int offset, int size) { if (!valid(file, MODE_READ)) { #ifdef ENABLE_STACK_SECURITY console_msg("Access to " + file + " denied\n"); return nil; #else console_msg("Access to " + file + " would have been denied, ignoring...\n"); #endif } return::read_file(file, offset, size); }
int msg(const char *message) { if(!opt_verbose) return 0; console_msg(message); return strlen(message); }
nomask static int file_exists( string file ) { if( !valid( file, MODE_READ ) ) { #ifdef ENABLE_STACK_SECURITY return 0; #else console_msg("Access to "+file+" would have been denied, ignoring...\n"); #endif } return ::file_exists( file ); }
nomask void destruct_object(object ob) { argcheck(ob, 1, "object"); if (find_object(COMPILER_D) && COMPILER_D->allow_object(ob->base_name())) { ob->_F_destruct(); } else { console_msg("WARNING: destruct_object() used on an inheritable: " + ob->base_name() + "\n"); ::destruct_object(ob); } }
int ok_or_ng(const char *s) { assert(s); if (!strncmp(s, "+OK", 3)) return 1; if (!strncmp(s, "+GO", 3)) return 2; if (!strncmp(s, "-NG", 3)){ console_msg(s); return -1; } return 0; }
void target_add_progress(target_context_t *tc, size_t progress) { char str[256]; assert(tc); if (!tc->goal) return; tc->progress += progress; assert(tc->progress <= tc->goal); if (tc->progress >= tc->goal) { sprintf(str, "%s: completed 0x%08zx (%zu) bytes. \n", tc->medium, tc->goal, tc->goal); console_msg(str); tc->goal = 0; tc->progress = 0; } else { sprintf(str, "%s: 0x%08zx (%zu) bytes of %zu...%c", tc->medium, tc->progress, tc->progress, tc->goal, opt_verbose ? '\n' : '\r'); console_msg(str); } }
int msgf(const char *format, ...) { va_list ap; char str[1024]; if (!opt_verbose) return 0; va_start(ap, format); vsprintf(str, format, ap); va_end(ap); console_msg(str); return strlen(str); }