Fossil

Check-in [0efd9e6a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:On Cygwin, don't set browser to "echo" if it cannot be found, but revert to ShellExecuteW which can do a much better job.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0efd9e6a94104308c8640f7fdca901c8bc120d22
User & Date: jan.nijtmans 2013-09-05 12:42:33
Context
2013-09-05
19:56
Updated changelog based on the 1.27 (pending) diffs. Added a link to the release checklist page. check-in: 08edbd4a user: stephan tags: trunk
12:42
On Cygwin, don't set browser to "echo" if it cannot be found, but revert to ShellExecuteW which can do a much better job. check-in: 0efd9e6a user: jan.nijtmans tags: trunk
02:46
Add $csrf_token TH1 variable. check-in: 2653fb4e user: joel tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/cgi.c.

38
39
40
41
42
43
44




45
46
47
48
49
50
51
....
1433
1434
1435
1436
1437
1438
1439










1440
1441
1442
1443
1444
1445
1446
  typedef int socklen_t;
#endif
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "cgi.h"





#if INTERFACE
/*
** Shortcuts for cgi_parameter.  P("x") returns the value of query parameter
** or cookie "x", or NULL if there is no such parameter or cookie.  PD("x","y")
** does the same except "y" is returned in place of NULL if there is not match.
*/
................................................................................
  if( iPort>mnPort ){
    fossil_print("Listening for %s requests on TCP port %d\n",
       (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP",  iPort);
    fflush(stdout);
  }
  if( zBrowser ){
    zBrowser = mprintf(zBrowser, iPort);










    if( system(zBrowser)<0 ){
      fossil_warning("cannot start browser: %s\n", zBrowser);
    }
  }
  while( 1 ){
    if( nchildren>MAX_PARALLEL ){
      /* Slow down if connections are arriving too fast */







>
>
>
>







 







>
>
>
>
>
>
>
>
>
>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
....
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
  typedef int socklen_t;
#endif
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "cgi.h"
#ifdef __CYGWIN__
  __declspec(dllimport) extern __stdcall int ShellExecuteW(void *, void *,
      void *, void *, void *, int);
#endif

#if INTERFACE
/*
** Shortcuts for cgi_parameter.  P("x") returns the value of query parameter
** or cookie "x", or NULL if there is no such parameter or cookie.  PD("x","y")
** does the same except "y" is returned in place of NULL if there is not match.
*/
................................................................................
  if( iPort>mnPort ){
    fossil_print("Listening for %s requests on TCP port %d\n",
       (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP",  iPort);
    fflush(stdout);
  }
  if( zBrowser ){
    zBrowser = mprintf(zBrowser, iPort);
#if defined(__CYGWIN__)
    /* On Cygwin, we can do better than "echo" */
    if( memcmp(zBrowser, "echo ", 5)==0 ){
      wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
      wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
      if( ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
        fossil_warning("cannot start browser\n");
      }
    }else
#endif
    if( system(zBrowser)<0 ){
      fossil_warning("cannot start browser: %s\n", zBrowser);
    }
  }
  while( 1 ){
    if( nchildren>MAX_PARALLEL ){
      /* Slow down if connections are arriving too fast */

Changes to src/main.c.

1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
  if( isUiCmd ){
#if !defined(__DARWIN__) && !defined(__APPLE__) && !defined(__HAIKU__)
    zBrowser = db_get("web-browser", 0);
    if( zBrowser==0 ){
      static const char *const azBrowserProg[] =
          { "xdg-open", "gnome-open", "firefox", "google-chrome" };
      int i;
#if defined(__CYGWIN__)
      const char *path = fossil_getenv("ProgramFiles(x86)");
      if( !path ){
        path = fossil_getenv("PROGRAMFILES");
      }
      path = fossil_utf8_to_filename(path);
      zBrowser = mprintf("%s/Google/Chrome/Application/chrome.exe", path);
      if( file_access(zBrowser, X_OK) ){
        zBrowser = mprintf("%s/Mozilla Firefox/firefox.exe", path);
      }
      if( file_access(zBrowser, X_OK) ){
        path = fossil_utf8_to_filename(fossil_getenv("PROGRAMFILES"));
        zBrowser = mprintf("%s/Internet Explorer/iexplore.exe", path);
      }
      zBrowser = mprintf("\"%s\"", zBrowser);
#else
      zBrowser = "echo";
#endif
      for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
        if( binaryOnPath(azBrowserProg[i]) ){
          zBrowser = azBrowserProg[i];
          break;
        }
      }
    }







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<







1857
1858
1859
1860
1861
1862
1863
















1864

1865
1866
1867
1868
1869
1870
1871
  if( isUiCmd ){
#if !defined(__DARWIN__) && !defined(__APPLE__) && !defined(__HAIKU__)
    zBrowser = db_get("web-browser", 0);
    if( zBrowser==0 ){
      static const char *const azBrowserProg[] =
          { "xdg-open", "gnome-open", "firefox", "google-chrome" };
      int i;
















      zBrowser = "echo";

      for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
        if( binaryOnPath(azBrowserProg[i]) ){
          zBrowser = azBrowserProg[i];
          break;
        }
      }
    }