gitkrinit.c

Go to the documentation of this file.
00001 
00017 #define GITK_RENDERER_C
00018 #define GITKR_INIT_C
00019 
00020 #include "gitkrincludes.h"
00021 
00024 gboolean gitkr_init(guint *argc, gchar ***argv)
00025 {
00026   g_log_set_handler(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG|G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_WARNING|G_LOG_LEVEL_ERROR, gitk_log_handler, NULL);
00027   gitk_log("html mode render plugin init beg");
00028 
00029   if(!gitkr_init_process_commandline(argc,argv))
00030   {
00031     //-- initialize renderer routines
00032 
00033     //-- start browser instance with cgi request
00034     
00035     gitkr_html_cgi_url = g_strconcat( gitkr_html_cgibin_url, "web.cgi" );
00036 
00037     char *arg_list[] = {
00038       gitkr_html_browser_path, 
00039       gitkr_html_cgi_url, 
00040       NULL 
00041     };
00042 
00043     browser_pid = fork();
00044 
00045     if ( browser_pid == 0 ) {
00046       execvp(gitkr_html_browser_path, arg_list);
00047       fprintf(stderr, "an error occured in execvp");
00048       abort();
00049     }
00050   }
00051 
00052   gitk_log("html mode render plugin init end");
00053   return(TRUE);
00054 }
00055 
00060 gboolean gitkr_init_process_commandline(guint *argc, gchar ***argv)
00061 {
00062   guint i;
00063   gchar *arg;
00064   gboolean info_only=FALSE;
00065   gboolean info_help=FALSE, info_version=FALSE;
00066 
00067   gitk_log("gitkr_init_process_commandline() beg");
00068 
00069   //-- check if there have been passed some parameters for libgitk
00070   for (i=1;i<*argc;)
00071   {
00072     if (!strcmp("--help", (*argv)[i]) || !strcmp("-h", (*argv)[i]))
00073     {
00074       info_only=info_help=TRUE;
00075     }
00076     else if((*argv)[i] && (!strcmp("--version", (*argv)[i])))
00077              {
00078                info_only=info_version=TRUE;
00079              }
00080        else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-html-browser-path"))) 
00081                     {
00082           gitkr_html_browser_path=strdup(arg);
00083           gitk_log1("selected browser_path (par) : \"%s\"",gitkr_html_browser_path);
00084         }
00085                     else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-html-cgibin-url"))) 
00086                            {
00087                  gitkr_html_cgibin_url=strdup(arg);
00088                  gitk_log1("selected cgibin_url (par) : \"%s\"",gitkr_html_cgibin_url);
00089                }
00090     i++;
00091   }
00092 
00093   if(info_help) 
00094   {
00095     gitk_puts(_("GITK-Renderer-Html options"));
00096     gitk_puts(_("      --gitkr-html-browser-path\tpath to the clients browser {mozilla}"));
00097     gitk_puts(_("      --gitkr-html-cgibin-url\turl to the servers cgi-bin directory {http://localhost/cgi-bin/}"));
00098     putchar('\n');
00099   }
00100 
00101   if(info_version) 
00102     puts(PACKAGE_NAME": version "PACKAGE_VERSION" by "PACKAGE_BUGREPORT);
00103 
00104   //-- remove found parameters
00105   cleanup_commandline_args(argc,argv);
00106   gitk_log1("gitk_init_process_commandline()=%1d end",info_only);
00107   return(info_only);
00108 }

Generated on Thu Oct 28 10:59:11 2004 for gitk by doxygen 1.3.6