]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Make gtkmain.c contain the actual main().
authorSimon Tatham <anakin@pobox.com>
Wed, 23 Mar 2016 21:58:40 +0000 (21:58 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 23 Mar 2016 21:58:40 +0000 (21:58 +0000)
Instead of main() living in uxputty.c and uxpterm.c, and doing a
little bit of setup before calling the larger pt_main() in gtkmain.c,
I've now turned things backwards: the big function in gtkmain.c *is*
main(), and the small pieces of preliminary setup in uxputty.c and
uxpterm.c are now a function called setup() which is called from
there. This will allow me to reuse the rest of ux{putty,pterm}.c, i.e.
the assorted top-level bits and pieces that distinguish PuTTY from
pterm, in the upcoming OS X application that will have its own main().

unix/gtkmain.c
unix/uxpterm.c
unix/uxputty.c

index 5e8b9fe25fcd5242202f53962a009fb72404b835..eb731ea853a37efb9597019de7788a459a0c8f37 100644 (file)
@@ -534,13 +534,20 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
 
 extern int cfgbox(Conf *conf);
 
-int pt_main(int argc, char **argv)
+int main(int argc, char **argv)
 {
     Conf *conf;
     int need_config_box;
 
     setlocale(LC_CTYPE, "");
 
+    {
+        /* Call the function in ux{putty,pterm}.c to do app-type
+         * specific setup */
+        extern void setup(int);
+        setup(TRUE);     /* TRUE means we are a one-session process */
+    }
+
     progname = argv[0];
 
     /*
index 3211d45a54135ac44ef73b8587278b317dd89ff5..0b848bc721f8eddeae15e63b4e20c6271c636c34 100644 (file)
@@ -43,18 +43,13 @@ char *make_default_wintitle(char *hostname)
     return dupstr("pterm");
 }
 
-int main(int argc, char **argv)
+void setup(int single)
 {
-    extern int pt_main(int argc, char **argv);
     extern void pty_pre_init(void);    /* declared in pty.c */
-    int ret;
 
     cmdline_tooltype = TOOLTYPE_NONNETWORK;
     default_protocol = -1;
 
-    pty_pre_init();
-
-    ret = pt_main(argc, argv);
-    cleanup_exit(ret);
-    return ret;             /* not reached, but placates optimisers */
+    if (single)
+        pty_pre_init();
 }
index d0ba55f68177a7bc68da8084d21e96a8104f692a..7933130fd9abc6689d14c676570a634bc49221e2 100644 (file)
@@ -132,11 +132,8 @@ char *platform_get_x_display(void) {
 const int share_can_be_downstream = TRUE;
 const int share_can_be_upstream = TRUE;
 
-int main(int argc, char **argv)
+void setup(int single)
 {
-    extern int pt_main(int argc, char **argv);
-    int ret;
-
     sk_init();
     flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
     default_protocol = be_default_protocol;
@@ -147,7 +144,4 @@ int main(int argc, char **argv)
        if (b)
            default_port = b->default_port;
     }
-    ret = pt_main(argc, argv);
-    cleanup_exit(ret);
-    return ret;             /* not reached, but placates optimisers */
 }