~eric-rnd/mysql-proxy/mysql-proxy-fixes

« back to all changes in this revision

Viewing changes to src/chassis.c

  • Committer: jan at mysql
  • Date: 2009-09-10 12:57:09 UTC
  • Revision ID: jan@mysql.com-20090910125709-9t4j7gpkrkfpmt5e
removed binary name tracking as there is no "mysql-cli"

Show diffs side-by-side

added added

removed removed

Lines of Context:
345
345
        GKeyFile *keyfile = NULL;
346
346
        chassis_log *log;
347
347
 
348
 
        /* holds argv[0] cleansed of the potential suffix on this platform (.exe on win32) */
349
 
        gchar *executable_name = NULL;
350
 
        
351
348
        /* can't appear in the configfile */
352
349
        GOptionEntry base_main_entries[] = 
353
350
        {
674
671
 
675
672
        /* if not plugins are specified, load admin and proxy */
676
673
        if (!plugin_names) {
677
 
                plugin_names = g_new0(char *, 4); /* make sure we allocate _enough_ memory */
 
674
                plugin_names = g_new(char *, 3);
678
675
 
679
 
#define IS_PNAME(pname) \
680
 
                ((strlen(executable_name) >= sizeof(pname) - 1) && \
681
 
                0 == strcmp(executable_name + strlen(executable_name) - (sizeof(pname) - 1), pname) \
682
 
                )
683
 
#ifdef WIN32
684
 
                /* on Windows allow for the executable and -svc suffix */
685
 
                if (g_str_has_suffix(argv[0], "-svc.exe")) {
686
 
                        executable_name = g_strndup(argv[0], strlen(argv[0]) - (sizeof("-svc.exe") - 1));
687
 
                } else if (g_str_has_suffix(argv[0], ".exe")) {
688
 
                        executable_name = g_strndup(argv[0], strlen(argv[0]) - (sizeof(".exe") - 1));
689
 
                } else {
690
 
                        executable_name = g_strdup(argv[0]);
691
 
                }
692
 
#else
693
 
                executable_name = argv[0];
694
 
#endif
695
 
                /* check what we are called as */
696
 
                if (IS_PNAME("mysql-proxy")) {
697
 
                        plugin_names[0] = g_strdup("admin");
698
 
                        plugin_names[1] = g_strdup("proxy");
699
 
                        plugin_names[2] = NULL;
700
 
                } else if (IS_PNAME("mysql-cli")) {
701
 
                        plugin_names[0] = g_strdup("cli");
702
 
                        plugin_names[1] = NULL;
703
 
                }
704
 
#ifdef WIN32
705
 
                /* cleanup executable_name since we dup'ed it */
706
 
                if (executable_name) {
707
 
                        g_free(executable_name);
708
 
                }
709
 
#endif
 
676
                plugin_names[0] = g_strdup("admin");
 
677
                plugin_names[1] = g_strdup("proxy");
 
678
                plugin_names[2] = NULL;
710
679
        }
711
680
 
712
681
        /* load the plugins */
1012
981
        if (plugin_dir) g_free(plugin_dir);
1013
982
 
1014
983
        if (plugin_names) {
1015
 
                for (i = 0; plugin_names[i]; i++) {
1016
 
                        g_free(plugin_names[i]);
1017
 
                }
1018
 
                g_free(plugin_names);
 
984
                g_strfreev(plugin_names);
1019
985
        }
1020
986
 
1021
987
        chassis_log_free(log);