5
* Mathias Roslund <vice.emu@amidog.se>
7
* This file is part of VICE, the Versatile Commodore Emulator.
8
* See README for copyright notice.
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
30
#define __USE_INLINE__
33
#include <proto/dos.h>
55
static char *boot_path = NULL;
56
static int run_from_wb = 0;
59
struct Library *SocketBase;
62
int archdep_network_init(void)
65
if (SocketBase == NULL) {
66
SocketBase = OpenLibrary("bsdsocket.library", 3);
67
if (SocketBase == NULL) {
76
void archdep_network_shutdown(void)
79
if (SocketBase != NULL) {
80
CloseLibrary(SocketBase);
86
int archdep_init_extra(int *argc, char **argv)
88
if (*argc == 0) { /* run from WB */
90
} else { /* run from CLI */
97
char *archdep_program_name(void)
99
static char *program_name = NULL;
101
if (program_name == NULL) {
104
GetProgramName(name, 1024);
108
program_name = lib_stralloc(p);
115
const char *archdep_boot_path(void)
120
char *archdep_default_sysfile_pathlist(const char *emu_id)
122
static char *default_path;
124
if (default_path == NULL) {
125
const char *boot_path;
127
boot_path = archdep_boot_path();
129
default_path = util_concat(emu_id, ARCHDEP_FINDPATH_SEPARATOR_STRING,
130
boot_path, emu_id, ARCHDEP_FINDPATH_SEPARATOR_STRING,
131
"DRIVES", ARCHDEP_FINDPATH_SEPARATOR_STRING,
132
boot_path, "DRIVES", ARCHDEP_FINDPATH_SEPARATOR_STRING,
133
"PRINTER", ARCHDEP_FINDPATH_SEPARATOR_STRING,
134
boot_path, "PRINTER", NULL);
140
/* Return a malloc'ed backup file name for file `fname'. */
141
char *archdep_make_backup_filename(const char *fname)
143
return util_concat(fname, "~", NULL);
146
char *archdep_default_resource_file_name(void)
150
home = archdep_boot_path();
151
return util_concat(home, "vice-sdl.ini", NULL);
154
char *archdep_default_fliplist_file_name(void)
158
home = archdep_boot_path();
159
return util_concat(home, "fliplist-", machine_name, ".vfl", NULL);
162
char *archdep_default_autostart_disk_image_file_name(void)
166
home = archdep_boot_path();
167
return util_concat(home, "autostart-", machine_name, ".d64", NULL);
170
char *archdep_default_hotkey_file_name(void)
174
home = archdep_boot_path();
175
return util_concat(home, "sdl-hotkey-", machine_name, ".vkm", NULL);
178
char *archdep_default_joymap_file_name(void)
182
home = archdep_boot_path();
183
return util_concat(home, "sdl-joymap-", machine_name, ".vjm", NULL);
186
char *archdep_default_save_resource_file_name(void)
188
return archdep_default_resource_file_name();
191
FILE *archdep_open_default_log_file(void)
197
fname = util_concat(archdep_boot_path(), "vice.log", NULL);
198
f = fopen(fname, MODE_WRITE_TEXT);
207
int archdep_num_text_lines(void)
212
int archdep_num_text_columns(void)
217
int archdep_default_logger(const char *level_string, const char *txt)
223
if (fputs(level_string, stdout) == EOF || fprintf(stdout, txt) < 0 || fputc ('\n', stdout) == EOF) {
230
int archdep_path_is_relative(const char *path)
236
return (strchr(path, ':') == NULL);
239
int archdep_spawn(const char *name, char **argv, char **stdout_redir, const char *stderr_redir)
244
/* return malloc'd version of full pathname of orig_name */
245
int archdep_expand_path(char **return_path, const char *orig_name)
249
lock = Lock(orig_name, ACCESS_READ);
253
rc = NameFromLock(lock, name, 1024);
256
*return_path = lib_stralloc(name);
260
*return_path = lib_stralloc(orig_name);
264
void archdep_startup_log_error(const char *format, ...)
267
va_start(ap, format);
268
vfprintf(stderr, format, ap);
272
char *archdep_filename_parameter(const char *name)
274
return lib_stralloc(name);
277
char *archdep_quote_parameter(const char *name)
279
return lib_stralloc(name);
282
char *archdep_tmpnam(void)
284
return lib_stralloc(tmpnam(NULL));
287
FILE *archdep_mkstemp_fd(char **filename, const char *mode)
292
tmp = lib_stralloc(tmpnam(NULL));
294
fd = fopen(tmp, mode);
305
int archdep_file_is_gzip(const char *name)
307
size_t l = strlen(name);
309
if ((l < 4 || strcasecmp(name + l - 3, ".gz")) && (l < 3 || strcasecmp(name + l - 2, ".z")) && (l < 4 || toupper(name[l - 1]) != 'Z' || name[l - 4] != '.')) {
316
int archdep_file_set_gzip(const char *name)
321
int archdep_mkdir(const char *pathname, int mode)
323
return mkdir(pathname, (mode_t)mode);
326
int archdep_stat(const char *file_name, unsigned int *len, unsigned int *isdir)
330
if (stat(file_name, &statbuf) < 0) {
334
*len = statbuf.st_size;
335
*isdir = S_ISDIR(statbuf.st_mode);
340
int archdep_file_is_blockdev(const char *name)
345
int archdep_file_is_chardev(const char *name)
350
int archdep_require_vkbd(void)
355
void archdep_shutdown_extra(void)