Allow specifying location of the users directories on the commandline

Arg USERSDIR/K
This commit is contained in:
Chris Young 2015-11-25 00:11:24 +00:00
parent 80e14dce52
commit d7907bfe4c
2 changed files with 19 additions and 14 deletions

View File

@ -109,10 +109,11 @@ This section contains options for exporting to PDF. It is not enabled in curren
@endnode @endnode
@node cli "Command line options" @node cli "Command line options"
NetSurf URL/K,FORCE/S,NSOPTS/M NetSurf NSOPTS/M,URL/K,USERSDIR/K,FORCE/S
Where: Where:
URL = Address of page to open on startup URL = Address of page to open on startup
USERSDIR = Locations of user directories (see @{"tooltypes" link tooltypes})
FORCE = Force new instance of NetSurf to open (has some limitations, use for debugging only) FORCE = Force new instance of NetSurf to open (has some limitations, use for debugging only)
NSOPTS = Catches everything else and passes it to the NetSurf core command line parser NSOPTS = Catches everything else and passes it to the NetSurf core command line parser
@endnode @endnode

View File

@ -797,12 +797,13 @@ static struct RDArgs *ami_gui_commandline(int *argc, char **argv, int *nargc, ch
{ {
int new_argc = 1; int new_argc = 1;
struct RDArgs *args; struct RDArgs *args;
CONST_STRPTR template = "NSOPTS/M,URL/K,FORCE/S"; CONST_STRPTR template = "NSOPTS/M,URL/K,USERSDIR/K,FORCE/S";
long rarray[] = {0,0,0}; long rarray[] = {0,0,0,0};
enum enum
{ {
A_NSOPTS, /* ignored */ A_NSOPTS, /* ignored */
A_URL, A_URL,
A_USERSDIR,
A_FORCE A_FORCE
}; };
@ -814,6 +815,11 @@ static struct RDArgs *ami_gui_commandline(int *argc, char **argv, int *nargc, ch
temp_homepage_url = ami_to_utf8_easy((char *)rarray[A_URL]); temp_homepage_url = ami_to_utf8_easy((char *)rarray[A_URL]);
} }
if(rarray[A_USERSDIR]) {
LOG("USERSDIR %s specified on command line", rarray[A_USERSDIR]);
users_dir = ASPrintf("%s", rarray[A_USERSDIR]);
}
if(rarray[A_FORCE]) { if(rarray[A_FORCE]) {
LOG("FORCE specified on command line"); LOG("FORCE specified on command line");
cli_force = true; cli_force = true;
@ -5419,6 +5425,8 @@ int main(int argc, char** argv)
BPTR lock = 0; BPTR lock = 0;
int32 user = 0; int32 user = 0;
nserror ret; nserror ret;
int nargc = 0;
char *nargv = NULL;
struct netsurf_table amiga_table = { struct netsurf_table amiga_table = {
.browser = &amiga_browser_table, .browser = &amiga_browser_table,
@ -5470,9 +5478,6 @@ int main(int argc, char** argv)
return RETURN_FAIL; return RETURN_FAIL;
} }
int nargc;
char *nargv;
ami_gui_read_all_tooltypes(argc, argv); ami_gui_read_all_tooltypes(argc, argv);
struct RDArgs *args = ami_gui_commandline(&argc, argv, &nargc, &nargv); struct RDArgs *args = ami_gui_commandline(&argc, argv, &nargc, &nargv);
@ -5493,8 +5498,8 @@ int main(int argc, char** argv)
} }
} }
#ifdef __amigaos4__
if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) { if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
#ifdef __amigaos4__
struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0); struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
if(infodata == NULL) { if(infodata == NULL) {
ami_misc_fatal_error("Failed to allocate memory"); ami_misc_fatal_error("Failed to allocate memory");
@ -5515,13 +5520,12 @@ int main(int argc, char** argv)
return RETURN_FAIL; return RETURN_FAIL;
} }
FreeDosObject(DOS_INFODATA, infodata); FreeDosObject(DOS_INFODATA, infodata);
} else {
#else #else
//FIXME for OS3 and older OS4 #warning FIXME for OS3 and older OS4
#endif #endif
#ifdef __amigaos4__ } else {
//TODO: check volume write status using old API
} }
#endif
int len = strlen(current_user); int len = strlen(current_user);
len += strlen(users_dir); len += strlen(users_dir);