Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/ba0895121b44b21d351ee69a07613f524f322617
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/ba0895121b44b21d351ee69a07613f524f322617
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/ba0895121b44b21d351ee69a07613f524f322617

The branch, master has been updated
       via  ba0895121b44b21d351ee69a07613f524f322617 (commit)
       via  9d694f56bbe28ba61eeeffd7472a4b7962a513c0 (commit)
       via  433418a8e9655fe19ab704129ee652b7316dc343 (commit)
       via  34a587849c9999f12d4199d744e7c72204369eab (commit)
      from  68e8152f3eb95395cd47e0d703ed709e4ddaef89 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=ba0895121b44b21d351ee69a07613f524f322617
commit ba0895121b44b21d351ee69a07613f524f322617
Author: Chris Young <[email protected]>
Commit: Chris Young <[email protected]>

    Ensure we close all opened resources when we early exit

diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index dd1f4b6..f849f3b 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -429,10 +429,18 @@ bool ami_locate_resource(char *fullpath, const char *file)
        return found;
 }
 
-static bool ami_open_resources(void)
+static void ami_gui_resources_free(void)
 {
+       ami_schedule_free();
+       ami_object_fini();
 
-       ami_object_init();
+       FreeSysObject(ASOT_PORT, appport);
+       FreeSysObject(ASOT_PORT, sport);
+       FreeSysObject(ASOT_PORT, schedulermsgport);
+}
+
+static bool ami_gui_resources_open(void)
+{
        urlStringClass = MakeStringClass();
 
     if(!(appport = AllocSysObjectTags(ASOT_PORT,
@@ -452,6 +460,8 @@ static bool ami_open_resources(void)
                return false;
        }
 
+       ami_object_init();
+
        return true;
 }
 
@@ -3080,12 +3090,7 @@ static void gui_quit(void)
        FreeObjList(window_list);
 
        ami_clipboard_free();
-       ami_schedule_free();
-       ami_object_fini();
-
-       FreeSysObject(ASOT_PORT, appport);
-       FreeSysObject(ASOT_PORT, sport);
-       FreeSysObject(ASOT_PORT, schedulermsgport);
+       ami_gui_resources_free();
 
        LOG("Closing screen");
        ami_gui_close_screen(scrn, locked_screen, FALSE);
@@ -5530,20 +5535,20 @@ static char *ami_gui_get_user_dir(STRPTR current_user)
        }
 
        int len = strlen(current_user);
-       FreeVec(current_user);
-
        len += strlen(users_dir);
        len += 2; /* for poss path sep and NULL term */
 
        current_user_dir = malloc(len);
        if(current_user_dir == NULL) {
                ami_misc_fatal_error("Failed to allocate memory");
+               FreeVec(current_user);
                return NULL;
        }
 
        strlcpy(current_user_dir, users_dir, len);
        AddPart(current_user_dir, current_user, len);
        FreeVec(users_dir);
+       FreeVec(current_user);
 
        LOG("User dir: %s", current_user_dir);
 
@@ -5669,7 +5674,7 @@ int main(int argc, char** argv)
        struct Interupt *memhandler = ami_memory_init();
 #endif
 
-       if (ami_open_resources() == false) { /* alloc message ports */
+       if (ami_gui_resources_open() == false) { /* alloc msgports, objects and 
other miscelleny */
                ami_misc_fatal_error("Unable to allocate resources");
                ami_gui_splash_close(splash_window);
                ami_libs_close();
@@ -5681,7 +5686,7 @@ int main(int argc, char** argv)
 
        current_user_dir = ami_gui_get_user_dir(current_user);
        if(current_user_dir == NULL) {
-               ami_schedule_free();
+               ami_gui_resources_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
@@ -5704,7 +5709,7 @@ int main(int argc, char** argv)
        ret = nsoption_init(ami_set_options, &nsoptions, &nsoptions_default);
        if (ret != NSERROR_OK) {
                ami_misc_fatal_error("Options failed to initialise");
-               ami_schedule_free();
+               ami_gui_resources_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
@@ -5717,8 +5722,9 @@ int main(int argc, char** argv)
 
        if (ami_locate_resource(messages, "Messages") == false) {
                ami_misc_fatal_error("Cannot open Messages file");
+               ami_nsoption_free();
                nsoption_finalise(nsoptions, nsoptions_default);
-               ami_schedule_free();
+               ami_gui_resources_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
@@ -5735,8 +5741,9 @@ int main(int argc, char** argv)
 
        if (ret != NSERROR_OK) {
                ami_misc_fatal_error("NetSurf failed to initialise");
+               ami_nsoption_free();
                nsoption_finalise(nsoptions, nsoptions_default);
-               ami_schedule_free();
+               ami_gui_resources_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=9d694f56bbe28ba61eeeffd7472a4b7962a513c0
commit 9d694f56bbe28ba61eeeffd7472a4b7962a513c0
Author: Chris Young <[email protected]>
Commit: Chris Young <[email protected]>

    Tidy-up init a bit

diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index b97cb10..dd1f4b6 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -217,7 +217,6 @@ static bool cli_force = false;
 
 #define USERS_DIR "PROGDIR:Users"
 static char *users_dir = NULL;
-static char *current_user = NULL;
 static char *current_user_dir;
 static char *current_user_faviconcache;
 
@@ -432,6 +431,8 @@ bool ami_locate_resource(char *fullpath, const char *file)
 
 static bool ami_open_resources(void)
 {
+
+       ami_object_init();
        urlStringClass = MakeStringClass();
 
     if(!(appport = AllocSysObjectTags(ASOT_PORT,
@@ -446,6 +447,11 @@ static bool ami_open_resources(void)
                                                        ASO_NoTrack, FALSE,
                                                        TAG_DONE))) return 
false;
 
+       if(ami_schedule_create(schedulermsgport) != NSERROR_OK) {
+               ami_misc_fatal_error("Failed to initialise scheduler");
+               return false;
+       }
+
        return true;
 }
 
@@ -906,11 +912,12 @@ static struct RDArgs *ami_gui_commandline(int *restrict 
argc, char ** argv,
        return NULL;
 }
 
-static void ami_gui_read_tooltypes(struct WBArg *wbarg)
+static char *ami_gui_read_tooltypes(struct WBArg *wbarg)
 {
        struct DiskObject *dobj;
        STRPTR *toolarray;
        char *s;
+       char *current_user = NULL;
 
        if((*wbarg->wa_Name) && (dobj = GetDiskObject(wbarg->wa_Name))) {
                toolarray = (STRPTR *)dobj->do_ToolTypes;
@@ -920,13 +927,16 @@ static void ami_gui_read_tooltypes(struct WBArg *wbarg)
 
                FreeDiskObject(dobj);
        }
+       return current_user;
 }
 
-static void ami_gui_read_all_tooltypes(int argc, char **argv)
+static STRPTR ami_gui_read_all_tooltypes(int argc, char **argv)
 {
        struct WBStartup *WBenchMsg;
        struct WBArg *wbarg;
        char i = 0;
+       char *current_user = NULL;
+       char *cur_user = NULL;
 
        if(argc == 0) { /* Started from WB */
                WBenchMsg = (struct WBStartup *)argv;
@@ -935,11 +945,17 @@ static void ami_gui_read_all_tooltypes(int argc, char 
**argv)
                        if((wbarg->wa_Lock) && (*wbarg->wa_Name))
                                olddir = SetCurrentDir(wbarg->wa_Lock);
 
-                       ami_gui_read_tooltypes(wbarg);
+                       cur_user = ami_gui_read_tooltypes(wbarg);
+                       if(cur_user != NULL) {
+                               if(current_user != NULL) FreeVec(current_user);
+                               current_user = cur_user;
+                       }
 
                        if(olddir !=-1) SetCurrentDir(olddir);
                }
        }
+
+       return current_user;
 }
 
 void ami_gui_set_default_gg(void)
@@ -5464,6 +5480,84 @@ uint32 ami_gui_get_app_id(void)
        return ami_appid;
 }
 
+/* Get current user directory for user-specific NetSurf data
+ * Returns NULL on error
+ */
+static char *ami_gui_get_user_dir(STRPTR current_user)
+{
+       BPTR lock = 0;
+       char temp[1024];
+       int32 user = 0;
+
+       if(current_user == NULL) {
+               user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
+               current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
+       }
+       LOG("User: %s", current_user);
+
+       if(users_dir == NULL) {
+               users_dir = ASPrintf("%s", USERS_DIR);
+               if(users_dir == NULL) {
+                       ami_misc_fatal_error("Failed to allocate memory");
+                       FreeVec(current_user);
+                       return NULL;
+               }
+       }
+
+       if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
+#ifdef __amigaos4__
+               struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
+               if(infodata == NULL) {
+                       ami_misc_fatal_error("Failed to allocate memory");
+                       FreeVec(current_user);
+                       return NULL;
+               }
+               GetDiskInfoTags(GDI_StringNameInput, users_dir,
+                                       GDI_InfoData, infodata,
+                                       TAG_DONE);
+               if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
+                       FreeDosObject(DOS_INFODATA, infodata);
+                       ami_misc_fatal_error("User directory MUST be on a 
writeable volume");
+                       FreeVec(current_user);
+                       return NULL;
+               }
+               FreeDosObject(DOS_INFODATA, infodata);
+#else
+#warning FIXME for OS3 and older OS4
+#endif
+       } else {
+//TODO: check volume write status using old API
+       }
+
+       int len = strlen(current_user);
+       FreeVec(current_user);
+
+       len += strlen(users_dir);
+       len += 2; /* for poss path sep and NULL term */
+
+       current_user_dir = malloc(len);
+       if(current_user_dir == NULL) {
+               ami_misc_fatal_error("Failed to allocate memory");
+               return NULL;
+       }
+
+       strlcpy(current_user_dir, users_dir, len);
+       AddPart(current_user_dir, current_user, len);
+       FreeVec(users_dir);
+
+       LOG("User dir: %s", current_user_dir);
+
+       if((lock = CreateDirTree(current_user_dir)))
+               UnLock(lock);
+
+       ami_nsoption_set_location(current_user_dir);
+
+       current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
+       if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
+
+       return current_user_dir;
+}
+
 static struct gui_window_table amiga_window_table = {
        .create = gui_window_create,
        .destroy = gui_window_destroy,
@@ -5527,8 +5621,8 @@ int main(int argc, char** argv)
        char script[1024];
        char temp[1024];
        STRPTR current_user_cache = NULL;
+       STRPTR current_user = NULL;
        BPTR lock = 0;
-       int32 user = 0;
        nserror ret;
        int nargc = 0;
        char *nargv = NULL;
@@ -5575,8 +5669,6 @@ int main(int argc, char** argv)
        struct Interupt *memhandler = ami_memory_init();
 #endif
 
-       ami_object_init();
-
        if (ami_open_resources() == false) { /* alloc message ports */
                ami_misc_fatal_error("Unable to allocate resources");
                ami_gui_splash_close(splash_window);
@@ -5584,90 +5676,17 @@ int main(int argc, char** argv)
                return RETURN_FAIL;
        }
 
-       if(ami_schedule_create(schedulermsgport) != NSERROR_OK) {
-               ami_misc_fatal_error("Failed to initialise scheduler");
-               ami_gui_splash_close(splash_window);
-               ami_libs_close();
-               return RETURN_FAIL;
-       }
-
-       ami_gui_read_all_tooltypes(argc, argv);
+       current_user = ami_gui_read_all_tooltypes(argc, argv);
        struct RDArgs *args = ami_gui_commandline(&argc, argv, &nargc, &nargv);
 
-       if(current_user == NULL) {
-               user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
-               current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
-       }
-       LOG("User: %s", current_user);
-
-       if(users_dir == NULL) {
-               users_dir = ASPrintf("%s", USERS_DIR);
-               if(users_dir == NULL) {
-                       ami_misc_fatal_error("Failed to allocate memory");
-                       ami_schedule_free();
-                       ami_gui_splash_close(splash_window);
-                       ami_libs_close();
-                       return RETURN_FAIL;
-               }
-       }
-
-       if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
-#ifdef __amigaos4__
-               struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
-               if(infodata == NULL) {
-                       ami_misc_fatal_error("Failed to allocate memory");
-                       ami_schedule_free();
-                       ami_gui_splash_close(splash_window);
-                       ami_libs_close();
-                       return RETURN_FAIL;
-               }
-               GetDiskInfoTags(GDI_StringNameInput, users_dir,
-                                       GDI_InfoData, infodata,
-                                       TAG_DONE);
-               if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
-                       FreeDosObject(DOS_INFODATA, infodata);
-                       ami_misc_fatal_error("User directory MUST be on a 
writeable volume");
-                       ami_schedule_free();
-                       ami_gui_splash_close(splash_window);
-                       ami_libs_close();
-                       return RETURN_FAIL;
-               }
-               FreeDosObject(DOS_INFODATA, infodata);
-#else
-#warning FIXME for OS3 and older OS4
-#endif
-       } else {
-//TODO: check volume write status using old API
-       }
-
-       int len = strlen(current_user);
-       len += strlen(users_dir);
-       len += 2; /* for poss path sep and NULL term */
-
-       current_user_dir = malloc(len);
+       current_user_dir = ami_gui_get_user_dir(current_user);
        if(current_user_dir == NULL) {
-               ami_misc_fatal_error("Failed to allocate memory");
                ami_schedule_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
        }
 
-       strlcpy(current_user_dir, users_dir, len);
-       AddPart(current_user_dir, current_user, len);
-       FreeVec(users_dir);
-       LOG("User dir: %s", current_user_dir);
-
-       if((lock = CreateDirTree(current_user_dir)))
-               UnLock(lock);
-
-       ami_nsoption_set_location(current_user_dir);
-       current_user_cache = ASPrintf("%s/Cache", current_user_dir);
-       current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
-
-       if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
-       if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
-
        ami_mime_init("PROGDIR:Resources/mimetypes");
        sprintf(temp, "%s/mimetypes.user", current_user_dir);
        ami_mime_init(temp);
@@ -5707,7 +5726,13 @@ int main(int argc, char** argv)
 
        ret = messages_add_from_file(messages);
 
+       current_user_cache = ASPrintf("%s/Cache", current_user_dir);
+       if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
+
        ret = netsurf_init(current_user_cache);
+
+       if(current_user_cache != NULL) FreeVec(current_user_cache);
+
        if (ret != NSERROR_OK) {
                ami_misc_fatal_error("NetSurf failed to initialise");
                nsoption_finalise(nsoptions, nsoptions_default);
@@ -5717,7 +5742,6 @@ int main(int argc, char** argv)
                return RETURN_FAIL;
        }
 
-       if(current_user_cache != NULL) FreeVec(current_user_cache);
        ret = amiga_icon_init();
 
        search_web_init(nsoption_charp(search_engines_file));
@@ -5766,7 +5790,6 @@ int main(int argc, char** argv)
        ami_nsoption_free();
        free(current_user_dir);
        FreeVec(current_user_faviconcache);
-       FreeVec(current_user);
 
 #ifndef __amigaos4__
        /* OS3 low memory handler */


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=433418a8e9655fe19ab704129ee652b7316dc343
commit 433418a8e9655fe19ab704129ee652b7316dc343
Author: Chris Young <[email protected]>
Commit: Chris Young <[email protected]>

    Finalise bitmap code last as purging the cache needs it

diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 4d3af0b..b97cb10 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3065,14 +3065,12 @@ static void gui_quit(void)
 
        ami_clipboard_free();
        ami_schedule_free();
+       ami_object_fini();
 
        FreeSysObject(ASOT_PORT, appport);
        FreeSysObject(ASOT_PORT, sport);
        FreeSysObject(ASOT_PORT, schedulermsgport);
 
-       ami_object_fini();
-       ami_bitmap_fini();
-
        LOG("Closing screen");
        ami_gui_close_screen(scrn, locked_screen, FALSE);
        if(nsscreentitle) FreeVec(nsscreentitle);
@@ -5775,6 +5773,7 @@ int main(int argc, char** argv)
        ami_memory_fini(memhandler);
 #endif
 
+       ami_bitmap_fini();
        ami_libs_close();
 
        return RETURN_OK;


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=34a587849c9999f12d4199d744e7c72204369eab
commit 34a587849c9999f12d4199d744e7c72204369eab
Author: Chris Young <[email protected]>
Commit: Chris Young <[email protected]>

    Move as much closedown as possible into gui_quit

diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index bff034c..4d3af0b 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3062,6 +3062,20 @@ static void gui_quit(void)
        FreeStringClass(urlStringClass);
 
        FreeObjList(window_list);
+
+       ami_clipboard_free();
+       ami_schedule_free();
+
+       FreeSysObject(ASOT_PORT, appport);
+       FreeSysObject(ASOT_PORT, sport);
+       FreeSysObject(ASOT_PORT, schedulermsgport);
+
+       ami_object_fini();
+       ami_bitmap_fini();
+
+       LOG("Closing screen");
+       ami_gui_close_screen(scrn, locked_screen, FALSE);
+       if(nsscreentitle) FreeVec(nsscreentitle);
 }
 
 char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
@@ -5756,25 +5770,11 @@ int main(int argc, char** argv)
        FreeVec(current_user_faviconcache);
        FreeVec(current_user);
 
-       ami_clipboard_free();
-       ami_schedule_free();
-
-       FreeSysObject(ASOT_PORT, appport);
-       FreeSysObject(ASOT_PORT, sport);
-       FreeSysObject(ASOT_PORT, schedulermsgport);
-
-       ami_object_fini();
-       ami_bitmap_fini();
-
 #ifndef __amigaos4__
        /* OS3 low memory handler */
        ami_memory_fini(memhandler);
 #endif
 
-       LOG("Closing screen");
-       ami_gui_close_screen(scrn, locked_screen, FALSE);
-       if(nsscreentitle) FreeVec(nsscreentitle);
-
        ami_libs_close();
 
        return RETURN_OK;


-----------------------------------------------------------------------

Summary of changes:
 frontends/amiga/gui.c |  237 +++++++++++++++++++++++++++----------------------
 1 file changed, 133 insertions(+), 104 deletions(-)

diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index bff034c..f849f3b 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -217,7 +217,6 @@ static bool cli_force = false;
 
 #define USERS_DIR "PROGDIR:Users"
 static char *users_dir = NULL;
-static char *current_user = NULL;
 static char *current_user_dir;
 static char *current_user_faviconcache;
 
@@ -430,7 +429,17 @@ bool ami_locate_resource(char *fullpath, const char *file)
        return found;
 }
 
-static bool ami_open_resources(void)
+static void ami_gui_resources_free(void)
+{
+       ami_schedule_free();
+       ami_object_fini();
+
+       FreeSysObject(ASOT_PORT, appport);
+       FreeSysObject(ASOT_PORT, sport);
+       FreeSysObject(ASOT_PORT, schedulermsgport);
+}
+
+static bool ami_gui_resources_open(void)
 {
        urlStringClass = MakeStringClass();
 
@@ -446,6 +455,13 @@ static bool ami_open_resources(void)
                                                        ASO_NoTrack, FALSE,
                                                        TAG_DONE))) return 
false;
 
+       if(ami_schedule_create(schedulermsgport) != NSERROR_OK) {
+               ami_misc_fatal_error("Failed to initialise scheduler");
+               return false;
+       }
+
+       ami_object_init();
+
        return true;
 }
 
@@ -906,11 +922,12 @@ static struct RDArgs *ami_gui_commandline(int *restrict 
argc, char ** argv,
        return NULL;
 }
 
-static void ami_gui_read_tooltypes(struct WBArg *wbarg)
+static char *ami_gui_read_tooltypes(struct WBArg *wbarg)
 {
        struct DiskObject *dobj;
        STRPTR *toolarray;
        char *s;
+       char *current_user = NULL;
 
        if((*wbarg->wa_Name) && (dobj = GetDiskObject(wbarg->wa_Name))) {
                toolarray = (STRPTR *)dobj->do_ToolTypes;
@@ -920,13 +937,16 @@ static void ami_gui_read_tooltypes(struct WBArg *wbarg)
 
                FreeDiskObject(dobj);
        }
+       return current_user;
 }
 
-static void ami_gui_read_all_tooltypes(int argc, char **argv)
+static STRPTR ami_gui_read_all_tooltypes(int argc, char **argv)
 {
        struct WBStartup *WBenchMsg;
        struct WBArg *wbarg;
        char i = 0;
+       char *current_user = NULL;
+       char *cur_user = NULL;
 
        if(argc == 0) { /* Started from WB */
                WBenchMsg = (struct WBStartup *)argv;
@@ -935,11 +955,17 @@ static void ami_gui_read_all_tooltypes(int argc, char 
**argv)
                        if((wbarg->wa_Lock) && (*wbarg->wa_Name))
                                olddir = SetCurrentDir(wbarg->wa_Lock);
 
-                       ami_gui_read_tooltypes(wbarg);
+                       cur_user = ami_gui_read_tooltypes(wbarg);
+                       if(cur_user != NULL) {
+                               if(current_user != NULL) FreeVec(current_user);
+                               current_user = cur_user;
+                       }
 
                        if(olddir !=-1) SetCurrentDir(olddir);
                }
        }
+
+       return current_user;
 }
 
 void ami_gui_set_default_gg(void)
@@ -3062,6 +3088,13 @@ static void gui_quit(void)
        FreeStringClass(urlStringClass);
 
        FreeObjList(window_list);
+
+       ami_clipboard_free();
+       ami_gui_resources_free();
+
+       LOG("Closing screen");
+       ami_gui_close_screen(scrn, locked_screen, FALSE);
+       if(nsscreentitle) FreeVec(nsscreentitle);
 }
 
 char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
@@ -5452,6 +5485,84 @@ uint32 ami_gui_get_app_id(void)
        return ami_appid;
 }
 
+/* Get current user directory for user-specific NetSurf data
+ * Returns NULL on error
+ */
+static char *ami_gui_get_user_dir(STRPTR current_user)
+{
+       BPTR lock = 0;
+       char temp[1024];
+       int32 user = 0;
+
+       if(current_user == NULL) {
+               user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
+               current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
+       }
+       LOG("User: %s", current_user);
+
+       if(users_dir == NULL) {
+               users_dir = ASPrintf("%s", USERS_DIR);
+               if(users_dir == NULL) {
+                       ami_misc_fatal_error("Failed to allocate memory");
+                       FreeVec(current_user);
+                       return NULL;
+               }
+       }
+
+       if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
+#ifdef __amigaos4__
+               struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
+               if(infodata == NULL) {
+                       ami_misc_fatal_error("Failed to allocate memory");
+                       FreeVec(current_user);
+                       return NULL;
+               }
+               GetDiskInfoTags(GDI_StringNameInput, users_dir,
+                                       GDI_InfoData, infodata,
+                                       TAG_DONE);
+               if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
+                       FreeDosObject(DOS_INFODATA, infodata);
+                       ami_misc_fatal_error("User directory MUST be on a 
writeable volume");
+                       FreeVec(current_user);
+                       return NULL;
+               }
+               FreeDosObject(DOS_INFODATA, infodata);
+#else
+#warning FIXME for OS3 and older OS4
+#endif
+       } else {
+//TODO: check volume write status using old API
+       }
+
+       int len = strlen(current_user);
+       len += strlen(users_dir);
+       len += 2; /* for poss path sep and NULL term */
+
+       current_user_dir = malloc(len);
+       if(current_user_dir == NULL) {
+               ami_misc_fatal_error("Failed to allocate memory");
+               FreeVec(current_user);
+               return NULL;
+       }
+
+       strlcpy(current_user_dir, users_dir, len);
+       AddPart(current_user_dir, current_user, len);
+       FreeVec(users_dir);
+       FreeVec(current_user);
+
+       LOG("User dir: %s", current_user_dir);
+
+       if((lock = CreateDirTree(current_user_dir)))
+               UnLock(lock);
+
+       ami_nsoption_set_location(current_user_dir);
+
+       current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
+       if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
+
+       return current_user_dir;
+}
+
 static struct gui_window_table amiga_window_table = {
        .create = gui_window_create,
        .destroy = gui_window_destroy,
@@ -5515,8 +5626,8 @@ int main(int argc, char** argv)
        char script[1024];
        char temp[1024];
        STRPTR current_user_cache = NULL;
+       STRPTR current_user = NULL;
        BPTR lock = 0;
-       int32 user = 0;
        nserror ret;
        int nargc = 0;
        char *nargv = NULL;
@@ -5563,99 +5674,24 @@ int main(int argc, char** argv)
        struct Interupt *memhandler = ami_memory_init();
 #endif
 
-       ami_object_init();
-
-       if (ami_open_resources() == false) { /* alloc message ports */
+       if (ami_gui_resources_open() == false) { /* alloc msgports, objects and 
other miscelleny */
                ami_misc_fatal_error("Unable to allocate resources");
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
        }
 
-       if(ami_schedule_create(schedulermsgport) != NSERROR_OK) {
-               ami_misc_fatal_error("Failed to initialise scheduler");
-               ami_gui_splash_close(splash_window);
-               ami_libs_close();
-               return RETURN_FAIL;
-       }
-
-       ami_gui_read_all_tooltypes(argc, argv);
+       current_user = ami_gui_read_all_tooltypes(argc, argv);
        struct RDArgs *args = ami_gui_commandline(&argc, argv, &nargc, &nargv);
 
-       if(current_user == NULL) {
-               user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
-               current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
-       }
-       LOG("User: %s", current_user);
-
-       if(users_dir == NULL) {
-               users_dir = ASPrintf("%s", USERS_DIR);
-               if(users_dir == NULL) {
-                       ami_misc_fatal_error("Failed to allocate memory");
-                       ami_schedule_free();
-                       ami_gui_splash_close(splash_window);
-                       ami_libs_close();
-                       return RETURN_FAIL;
-               }
-       }
-
-       if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
-#ifdef __amigaos4__
-               struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
-               if(infodata == NULL) {
-                       ami_misc_fatal_error("Failed to allocate memory");
-                       ami_schedule_free();
-                       ami_gui_splash_close(splash_window);
-                       ami_libs_close();
-                       return RETURN_FAIL;
-               }
-               GetDiskInfoTags(GDI_StringNameInput, users_dir,
-                                       GDI_InfoData, infodata,
-                                       TAG_DONE);
-               if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
-                       FreeDosObject(DOS_INFODATA, infodata);
-                       ami_misc_fatal_error("User directory MUST be on a 
writeable volume");
-                       ami_schedule_free();
-                       ami_gui_splash_close(splash_window);
-                       ami_libs_close();
-                       return RETURN_FAIL;
-               }
-               FreeDosObject(DOS_INFODATA, infodata);
-#else
-#warning FIXME for OS3 and older OS4
-#endif
-       } else {
-//TODO: check volume write status using old API
-       }
-
-       int len = strlen(current_user);
-       len += strlen(users_dir);
-       len += 2; /* for poss path sep and NULL term */
-
-       current_user_dir = malloc(len);
+       current_user_dir = ami_gui_get_user_dir(current_user);
        if(current_user_dir == NULL) {
-               ami_misc_fatal_error("Failed to allocate memory");
-               ami_schedule_free();
+               ami_gui_resources_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
        }
 
-       strlcpy(current_user_dir, users_dir, len);
-       AddPart(current_user_dir, current_user, len);
-       FreeVec(users_dir);
-       LOG("User dir: %s", current_user_dir);
-
-       if((lock = CreateDirTree(current_user_dir)))
-               UnLock(lock);
-
-       ami_nsoption_set_location(current_user_dir);
-       current_user_cache = ASPrintf("%s/Cache", current_user_dir);
-       current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
-
-       if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
-       if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
-
        ami_mime_init("PROGDIR:Resources/mimetypes");
        sprintf(temp, "%s/mimetypes.user", current_user_dir);
        ami_mime_init(temp);
@@ -5673,7 +5709,7 @@ int main(int argc, char** argv)
        ret = nsoption_init(ami_set_options, &nsoptions, &nsoptions_default);
        if (ret != NSERROR_OK) {
                ami_misc_fatal_error("Options failed to initialise");
-               ami_schedule_free();
+               ami_gui_resources_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
@@ -5686,8 +5722,9 @@ int main(int argc, char** argv)
 
        if (ami_locate_resource(messages, "Messages") == false) {
                ami_misc_fatal_error("Cannot open Messages file");
+               ami_nsoption_free();
                nsoption_finalise(nsoptions, nsoptions_default);
-               ami_schedule_free();
+               ami_gui_resources_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
@@ -5695,17 +5732,23 @@ int main(int argc, char** argv)
 
        ret = messages_add_from_file(messages);
 
+       current_user_cache = ASPrintf("%s/Cache", current_user_dir);
+       if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
+
        ret = netsurf_init(current_user_cache);
+
+       if(current_user_cache != NULL) FreeVec(current_user_cache);
+
        if (ret != NSERROR_OK) {
                ami_misc_fatal_error("NetSurf failed to initialise");
+               ami_nsoption_free();
                nsoption_finalise(nsoptions, nsoptions_default);
-               ami_schedule_free();
+               ami_gui_resources_free();
                ami_gui_splash_close(splash_window);
                ami_libs_close();
                return RETURN_FAIL;
        }
 
-       if(current_user_cache != NULL) FreeVec(current_user_cache);
        ret = amiga_icon_init();
 
        search_web_init(nsoption_charp(search_engines_file));
@@ -5754,27 +5797,13 @@ int main(int argc, char** argv)
        ami_nsoption_free();
        free(current_user_dir);
        FreeVec(current_user_faviconcache);
-       FreeVec(current_user);
-
-       ami_clipboard_free();
-       ami_schedule_free();
-
-       FreeSysObject(ASOT_PORT, appport);
-       FreeSysObject(ASOT_PORT, sport);
-       FreeSysObject(ASOT_PORT, schedulermsgport);
-
-       ami_object_fini();
-       ami_bitmap_fini();
 
 #ifndef __amigaos4__
        /* OS3 low memory handler */
        ami_memory_fini(memhandler);
 #endif
 
-       LOG("Closing screen");
-       ami_gui_close_screen(scrn, locked_screen, FALSE);
-       if(nsscreentitle) FreeVec(nsscreentitle);
-
+       ami_bitmap_fini();
        ami_libs_close();
 
        return RETURN_OK;


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to