Re: [fossil-users] Help with making a subroutine x-platform to windows

2018-06-28 Thread Thomas Schnurrenberger
On 27.06.2018 21:24, Richard Hipp wrote:
> If anybody can suggest patches that will get this routine
> (https://fossil-scm.org/fossil/info/5e083abf6?ln=47) to compile and
> work on windows, that would really be helpful.  Thanks.
> 

Sample Windows program, needs the dnsapi.lib for linking:

#include   /* Windows */
#include/* DNS API's */
#include   /* Windows sockets */
#include/* For strdup() */
#include /* Standard I/O */

char *smtp_mx_host(const char *zDomain){
  DNS_STATUS status;   /* Return status */
  PDNS_RECORD pDnsRecord, p;   /* Pointer to DNS_RECORD structure */
  int iBestPriority = 999; /* Best priority */
  unsigned char *pBest = 0;/* RDATA for the best answer */

  status = DnsQuery_UTF8(zDomain,/* Domain name */
 DNS_TYPE_MX,/* DNS record type */
 DNS_QUERY_STANDARD, /* Query options */
 NULL,   /* List of DNS servers */
 &pDnsRecord,/* Query results */
 NULL);  /* Reserved */
  if( status ) return NULL;

  p = pDnsRecord;
  while( p ){
if( p->Data.MX.wPreferenceData.MX.wPreference;
  pBest = p->Data.MX.pNameExchange;
}
p = p->pNext;
  }
  if( pBest ){
pBest = strdup(pBest);
  }
  DnsRecordListFree(pDnsRecord, DnsFreeRecordListDeep);
  return pBest;
}



int main(int argc, char *argv[]){
  int i;

  for(i=1; ihttp://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Fossil with IPv6 support on Windows XP

2018-01-05 Thread Thomas Schnurrenberger
On 03.01.2018 23:33, Florian Balmer wrote:
> The startup delay for `fossil ui' and `fossil server' on Windows XP is
> more obvious than possibly sluggish browser navigation, which I
> *think* is due to waiting for StartServiceCtrlDispatcherW. This could
> be cut down by skipping the call to StartServiceCtrlDispatcherW for
> the `ui' and `server' commands, as Fossil always runs in a console
> session, and not as a service, in these cases.
> 
I measured the time it takes to call StartServiceCtrlDispatcherW on my
8 year old Windows 7 64bit box: roughly 600 microseconds, I don't think
this is noticeable!

This is the program for taking the time:

* Start of code *
#include 
#include 
#include 
#include 

static void WINAPI win32_http_service_main(
  DWORD argc,
  LPWSTR *argv
){
  return;
}

int main(void){
  LARGE_INTEGER Frequency;
  LARGE_INTEGER StartingTime;
  LARGE_INTEGER EndingTime;
  LARGE_INTEGER ElapsedMicroseconds;
  doubleElapsedSeconds;
  int   rc = 0;

  /* Define the service table. */
  SERVICE_TABLE_ENTRYW ServiceTable[] =
{{L"", (LPSERVICE_MAIN_FUNCTIONW)win32_http_service_main},
 {NULL, NULL}};

  /* Get frequency and the start time. */
  QueryPerformanceFrequency(&Frequency);
  QueryPerformanceCounter(&StartingTime);

  /* Activity to be timed */
  if( !StartServiceCtrlDispatcherW(ServiceTable) ){
if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){
  rc = 1;
}else{
  rc = 2;
}
  }
  /* Get end time and convert to seconds. */
  QueryPerformanceCounter(&EndingTime);
  ElapsedMicroseconds.QuadPart = EndingTime.QuadPart
   - StartingTime.QuadPart;
  ElapsedMicroseconds.QuadPart *= 100;
  ElapsedMicroseconds.QuadPart /= Frequency.QuadPart;
  ElapsedSeconds = (double)(EndingTime.QuadPart
  - StartingTime.QuadPart)/Frequency.QuadPart;
  printf("Elapsed microseconds: %"PRId64"\n",
 ElapsedMicroseconds.QuadPart);
  printf("Elapsed seconds : %f\n", ElapsedSeconds);
  printf("rc  : %d\n", rc);

  return 0;
}
* End of code *

It would be interesting to known time on your XP boxes.

-- 
Thomas Schnurrenberger
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Issue with crlf-glob *

2017-04-09 Thread Thomas Schnurrenberger
On 08.04.2017 22:46, Thomas wrote:
> C:\fos>fossil settings crlf-glob *.obj
> C:\fos>
> C:\fos>fossil settings crlf-glob *
> Usage: fossil settings ?PROPERTY? ?VALUE? ?-global?
> C:\fos>fossil settings crlf-glob * -global
> Usage: fossil settings ?PROPERTY? ?VALUE? ?-global?
> C:\fos>fossil settings crlf-glob "*"
> Usage: fossil settings ?PROPERTY? ?VALUE? ?-global?
> C:\fos>fossil settings crlf-glob "*" -global
> Usage: fossil settings ?PROPERTY? ?VALUE? ?-global?
> 
> Does anyone know how to unveil the secret of getting the mentioned
> asterisk into the crlf-glob setting without consulting the web interface?
> 

You could make use of the "--args" option in Fossil:

$ echo *|fossil test-echo --args -


I have written a small wrapper for invoking Fossil without
expanding wildcards:

--- content of fng.cmd ---
@echo off
rem
rem Invoke Fossil without command line globbing.
rem 2014-08-03 Thomas Schnurrenberger
rem
setlocal
if "%~1" == "fossil" goto loop
rem
rem Invoke ourself and pass the output to fossil.
"%~f0" fossil %*|fossil --args -
goto leave
rem
rem Output each argument on a single line.
:loop
if "%~2" == "" goto leave
echo %~2
shift
goto loop
:leave
endlocal
--- end of content ---

HTH

-- 
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Crash with this AMEND command

2017-03-20 Thread Thomas Schnurrenberger
On 18.03.2017 00:59, Tony Papadimitriou wrote:
> The following command crashes fossil (older and up to current version).
> *fossil am trunk -R your_repo_here.fossil –e*
> (I thought the –R option was supported for this command, but regardless it 
> shouldn’t crash.)
> 

If the following two lines in info.c

http://www.fossil-scm.org/index.html/file/src/info.c?ln=2953-2954

are moved before the line with the call to "db_must_be_within_tree()",
the problem should be solved.

-- 
tsbg



___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Fossil server

2015-11-01 Thread Thomas Schnurrenberger
On 01.11.2015 13:06, Damien Sykes-Pendleton wrote:
> What reasons could Fossil be unable to listen on a certain port and is there 
> anything I’m missing that I should be doing to allow it access?
> 

Did you check the settings of the Windows Firewall?

-- 
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] fossil ui not working with recent chrome browser

2015-03-19 Thread Thomas Schnurrenberger

On 14.03.2015 13:12, a...@gmx-topmail.de wrote:


I am having problems to access my local fossil repositories with a
recent versions of chrome, it looks like only part of the html code is
served by the standalone webserver.

My question is whether this is a known problem and others can verify it
with a similar setup.



Is there a virus scanner sitting between the network and the browser,
like a local proxy?

--
tsbg


___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] symlinks

2014-08-28 Thread Thomas Schnurrenberger

On 28.08.2014 20:01, Warren Young wrote:

3. If your program is running as a Windows service (which Fossil can't
do yet, but may one day be able to) it can't call this function at all,
regardless of permission.  Only programs running under the interactive
desktop can create symlinks.


Fossil can be run as a Windows service. Please take a look at the
'winsrv' command. Obviously, this command exists only in Fossil
for Windows.

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Using doc/ckout from win service

2014-08-23 Thread Thomas Schnurrenberger

Hi Peter

as the original author of the Windows service code, I probably
can explain the behavior you are seeing.

On 23.08.2014 09:13, Petr Ferdus wrote:

I am not very clear, what specifically should I do to run service from open 
repository
(while running fossil server  as "server" or the same command as 
"service",
in both cases it uses the same directory with repositories)
I cant figure out where server/service distinction is made.


You can not run a service from a open checkout, but you can create
a service from a open checkout. In this case, the  service is created
with the repository you specified when you opened the checkout.

A service is never intended to serve a open checkout! It only
serves Fossil repositories.

HTH

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] fossil winsrv - how to use "--files" parameter

2014-08-02 Thread Thomas Schnurrenberger

On 02.08.2014 22:11, Petr Ferdus wrote:

I have checked, what windows show in service dialog in "path to executable 
file" field:
"C:\soft\tools\fossil.exe" server --port 8080 --notfound "fossilcanonical/timeline" 
--files-urlenc %27IMG_3115.JPG%27 "c:/soft/tools"
--files is transformed into --files-urlenc and "'" is encoded as %27


This seems to be the problem; "fossil server" implements only
the "--files-" option. The only other command that implements
the "--files-urlenc" option is "fossil http".

HTH

--
tsbg


___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] libfossil + fuse

2014-06-15 Thread Thomas Schnurrenberger

On 15.06.2014 15:45, Sergei Gavrikov wrote:
>
> touch foo;f add foo;f ci -m "add foo"
> touch foo-bar;f add foo-bar;f ci -m "add foo-bar"
> mkdir bar;touch bar/.stick;f add --dotfiles bar;f ci -m "add bar"
> mkdir bar-baz;touch bar-baz/.stick;f add --dotfiles bar-baz; f ci -m 
"add bar-baz"

>
> Now there are foo, foo-bar files, and bar, bar-baz directories
>
>% f ls
>bar-baz/.stick
>bar/.stick
>foo
>foo-bar
>
> Expected. Now
>
>% f fusefs /tmp/fusefs
>
> And
>
>% ls /tmp/fusefs/checkins/trunk
>ls: cannot access /tmp/fusefs/checkins/trunk/bar: No such file or 
directory

>bar  bar-baz  foo
>
>% tree /tmp/fusefs/checkins/trunk
>/tmp/fusefs/checkins/trunk
>|-- bar-baz
>`-- foo
>
>1 directory, 1 file
>
>% ls -la  /tmp/fusefs/checkins/trunk
>ls: cannot access /tmp/fusefs/checkins/trunk/bar: No such file or 
directory

>total 0
>dr-xr-xr-x 2 sg sg 0 1970-01-01 03:00 .
>d--x--x--x 2 sg sg 0 1970-01-01 03:00 ..
>?? ? ?  ?  ?? bar
>dr-xr-xr-x 2 sg sg 0 2014-06-15 16:07 bar-baz
>-r--r--r-- 1 sg sg 0 2014-06-15 16:07 foo
>
> Can anyone reproduce this?
>
I can reproduce this on lubuntu 14.04 LTS with Fossil compiled from trunk.

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Problem with "fossil winsrv" (cont'd)

2012-06-06 Thread Thomas Schnurrenberger

On 06.06.2012 20:59, Marcelo wrote:


What do you think of my proposed change?


I have committed a fix to the Fossil repository.
It can be found in the branch "winsrv".

Please try it out.

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Problem with "fossil winsrv" (cont'd)

2012-06-06 Thread Thomas Schnurrenberger

Hi Marcelo



* If I just do


fossil winsrv create XXX


the service gets created with the indicated name

* If I add any parameters, it doesn't, trying instead of create the
service with the default name (and failing if it already exists).



Could you please show the complete command line with all parameters
used? Are you executing the commands in an open checkout or not?



Also, the documented parameters say:

** -p|--port TCPPORT
**
**  Specifies the TCP port (default port is 8080) on which the
**  server should listen.

Notice the LOWERCASE "p".

However, in winhttp.c, line 589:

zPort = find_option("port", "P", 1);

I would say this is a documentation error.



Confirmed, this is a documentation error. I will fix it together
with the service name problem as soon as I have found the solution!

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


[fossil-users] fossil mirrors out of sync

2011-12-02 Thread Thomas Schnurrenberger

Last commit on www2.fossil-scm.org: 2011-11-07 07:07
Last commit on www3.fossil-scm.org: 2011-10-03 16:34

See others the same or am I the only one?

--
tsbg
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Wildcards not working on windows

2011-09-26 Thread Thomas Schnurrenberger

Hi

to make sure that wildcards get expanded on all MinGW versions ( 
 and ),

I include the following piece of code in main.c

/*
** Enable command line globbing on MinGW.
*/
#ifdef __MINGW32__
# ifdef __MINGW64__
int _dowildcard = -1;
# else
int _CRT_glob = -1;
# endif
#endif


For the Microsoft C compiler the following page explains
how to enable wildcard expansion:



I dont know if this also works with older compilers.

--
tsbg
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] new winsrv command: which port does it use?

2011-08-16 Thread Thomas Schnurrenberger
On 16.08.2011 17:20, Stephan Beal wrote:
> On Tue, Aug 16, 2011 at 5:03 PM, Thomas Schnurrenbergerwrote:
>
>> If this port (8080) is already used, the service fails silently.
>> To circumvent this problem either specify a different port when
>> you create the service (-p|--port option) or start the service
>> before you use the "interactive" 'fossil server' or 'fossil ui'
>> commands.
>>
>
> On Linux systems (and, i _assume_ others), if 8080 is already taken fossil
> tries the next port, then the next one... not sure how many time it'll try.
> So --port should only be necessary when you want to hard-code to a specific
> port.
>
A Windows service runs in a other session then interactive users,
at least on the newest Windows versions and by default can not
easily communicate with the logged in user, if any. If the service
would select the TCP port by himself, how to inform the user?
The behavior of a service can be compared with http or email servers
which are running normally with fixed port numbers.

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] new winsrv command: which port does it use?

2011-08-16 Thread Thomas Schnurrenberger
On 15.08.2011 22:26, Jos Groot Lipman wrote:
>
> First I do a 'fossil ui' on an open checkout. This claims port 8080 (note:
> it could also be any other program already using port 8080)
>
> Next I do a 'fossil winsrv create' and a 'fossil winsrv start' inside
> *another* open checkout. This works fine:
>  Service 'Fossil-DSCM' started.
> but no indication about which port is being used.
>
> http://127.0.0.1:8080 still brings me to the first server started with
> 'fossil ui'
> Only/If I stop that server, http://127.0.0.1:8080
> is suddenly served by the 'Fossil-DSCM' Service (another repository)! Very
> confusing.
>
> Maybe I do not understand Windows services very well but should the 'fossil
> server show' command not at the very least show the port it is serving?
>
>
By default, the Windows Service uses port 8080 (this is documented in
the help -> fossil help winsrv).

If this port (8080) is already used, the service fails silently.
To circumvent this problem either specify a different port when
you create the service (-p|--port option) or start the service
before you use the "interactive" 'fossil server' or 'fossil ui'
commands.

HTH

--
tsbg



___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] The "fossil service" command

2011-07-19 Thread Thomas Schnurrenberger
On 19.07.2011 18:36, Ramon Ribó wrote:
>
> Althouth "winsvc" could also be a good solution, what other sub commands, 
> appart
> from "install" and "remove" do you really need?
>
You don't need the "service" command at all. There are command line
utilities and/or GUI's in the Windows OS which have the required
functionality. But not every tool does everything.

The fossil "service" command is a convenience command for Windows
users who are not system administrators. It concentrates the necessary
functionality where it is needed.

--
tsbg
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] The "fossil service" command

2011-07-19 Thread Thomas Schnurrenberger
On 19.07.2011 17:47, Ramon Ribó wrote:
>
> In my opinion, the name "service" is too generic and too windows
> specific. Fossil can give us a lot of services, apart from using the
> Windows services feature.
>
>   I agree with another poster that a good solution could be to make it
> a subcommand of "server". How many times is people going to
> install/uninstall the service?
>
> Something like:
>
> fossil server ?-P|--port TCPPORT? ?--service-install?
> ?--service-remove? ?REPOSITORY?
>
I don't think that this a good idea because the "service" command
has several sub-commands.

It is probably better to change the command-name from "service"
to e.g. "winsvc"

--
tsbg
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] The "fossil service" command

2011-07-19 Thread Thomas Schnurrenberger
On 19.07.2011 15:42, Rene wrote:
> Why not make an option e.g.
> fossil server -service?

because the "service" command consists of several sub-commands?

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] The "fossil service" command

2011-07-19 Thread Thomas Schnurrenberger
On 19.07.2011 06:16, Jeremy Anderson wrote:
>
> Other platforms could either re-direct it (e.g., "fossil service" becomes an
> alias for "fossil server"), or just print a message saying that the command
> is only valid for Windows operating systems.
>
On non Windows platforms, "fossil service" prints the following message:

"The service command is platform specific and not available on
  this platform."

HTH

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Fossil experience & two console windows

2011-07-14 Thread Thomas Schnurrenberger
On 14.07.2011 20:02, Richard Hipp wrote:
>
> I did respond - I asked for a CLA (see
> http://www.fossil-scm.org/fossil/doc/trunk/www/contribute.wiki and
> http://www.fossil-scm.org/fossil/doc/trunk/www/copyright-release.html) so
> that I could incorporate your patch.  I guess my reply never made it to you
> :-(
>
You should have a CLA from me already. I have sent one on the
23. December 2010 via email and some days later the original
dead-tree one via snail mail. But I think the CLA form was reworked
in the meantime and if you require me to sign a new one, I certainly
will do that. Please let me now.

--
tsbg

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] Fossil experience & two console windows

2011-07-14 Thread Thomas Schnurrenberger

On 14.07.2011 17:59, Richard Hipp wrote:


On linux and mac:

 To start:fossil ui&
 To stop:killall fossil

I have no idea how to do something like this on windows.


A few days ago, I have sent a email to your private email address
which contained a patch to enable Fossil to be run as a Windows
service. The subject line was:
"[Fossil]Enable Fossil to run as a Windows Service"

I didn't get a response, so maybe the email was lost on its way!
The patch is now attached to this message.

The patch consists of the following two parts:

1. The embedded http server is modified to be runnable as a Windows
service. There is also a fix with pathnames for temporary files.

2. The 'service' command is added to Fossil. This command makes it easy
to create, delete, show, start and stop a service.


Possible problems:

The service functions are part of the Windows API since Windows NT.
If Fossil needs to run on older Windows versions, like Windows 95, 98
or ME, it would be necessary to modify the code to load this functions
dynamically.


Please take a look at the code. If you have any questions or 
suggestions, i will be trying to provide answers or make the suggested 
changes.


--
tsbg
Index: src/main.c
===
--- src/main.c
+++ src/main.c
@@ -1437,11 +1437,14 @@
   if( isUiCmd ){
 zBrowser = db_get("web-browser", "start");
 zBrowserCmd = mprintf("%s http://127.0.0.1:%%d/";, zBrowser);
   }
   db_close(1);
-  win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile, zNotFound, 
flags);
+  if( win32_http_service(iPort, zNotFound, flags) ){
+win32_http_server(iPort, mxPort, zBrowserCmd,
+  zStopperFile, zNotFound, flags);
+  }
 #endif
 }
 
 /*
 ** COMMAND:  test-echo

Index: src/winhttp.c
===
--- src/winhttp.c
+++ src/winhttp.c
@@ -1,6 +1,6 @@
-/*
+/*
 ** Copyright (c) 2008 D. Richard Hipp
 **
 ** This program is free software; you can redistribute it and/or
 ** modify it under the terms of the Simplified BSD License (also
 ** known as the "2-Clause License" or "FreeBSD License".)
@@ -14,17 +14,18 @@
 **   http://www.hwaci.com/drh/
 **
 ***
 **
 ** This file implements a very simple (and low-performance) HTTP server
-** for windows.
+** for windows. It also implements a Windows Service which allows the HTTP
+** server to be run without any user logged on.
 */
 #include "config.h"
 #ifdef _WIN32
 /* This code is for win32 only */
-#include "winhttp.h"
 #include 
+#include "winhttp.h"
 
 /*
 ** The HttpRequest structure holds information about each incoming
 ** HTTP request.
 */
@@ -60,11 +61,11 @@
 }
 
 /*
 ** Process a single incoming HTTP request.
 */
-void win32_process_one_http_request(void *pAppData){
+static void win32_process_one_http_request(void *pAppData){
   HttpRequest *p = (HttpRequest*)pAppData;
   FILE *in = 0, *out = 0;
   int amt, got;
   int wanted = 0;
   char *z;
@@ -145,10 +146,11 @@
   SOCKET s = INVALID_SOCKET;
   SOCKADDR_IN addr;
   int idCnt = 0;
   int iPort = mnPort;
   Blob options;
+  char zTmpPath[MAX_PATH];
 
   if( zStopper ) file_delete(zStopper);
   blob_zero(&options);
   if( zNotFound ){
 blob_appendf(&options, " --notfound %s", zNotFound);
@@ -189,31 +191,46 @@
 }else{
   fossil_fatal("unable to open listening socket on any"
" port in the range %d..%d", mnPort, mxPort);
 }
   }
-  zTempPrefix = mprintf("fossil_server_P%d_", iPort);
+  if( !GetTempPath(sizeof(zTmpPath), zTmpPath) ){
+fossil_fatal("unable to get path to the temporary directory.");
+  }
+  zTempPrefix = mprintf("%sfossil_server_P%d_", zTmpPath, iPort);
   fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
   if( zBrowser ){
 zBrowser = mprintf(zBrowser, iPort);
 fossil_print("Launch webbrowser: %s\n", zBrowser);
 fossil_system(zBrowser);
   }
   fossil_print("Type Ctrl-C to stop the HTTP server\n");
+  /* Set the service status to running and pass the listener socket to the
+  ** service handling procedures. */
+  win32_http_service_running(s);
   for(;;){
 SOCKET client;
 SOCKADDR_IN client_addr;
 HttpRequest *p;
 int len = sizeof(client_addr);
+int wsaError;
 
 client = accept(s, (struct sockaddr*)&client_addr, &len);
-if( zStopper && file_size(zStopper)>=0 ){
-  break;
-}
 if( client==INVALID_SOCKET ){
-  closesocket(s);
-  fossil_fatal("error from accept()");
+  /* If the service control handler has closed the listener socket, 
+  ** cleanup and return, otherwise report a fatal error. */
+  wsaError =  WSAGetLastError();
+  if( (wsaError==WSAEINTR) || (wsaError==WSAENOTSOCK) ){
+WSACleanup();
+return;
+  }else{
+closesocket(s);
+WSACleanup();
+fossil_fatal("error from accept()");
+   

Re: [fossil-users] Needed: volunteer to autoconf Fossil

2011-06-16 Thread Thomas Schnurrenberger

On 16.06.2011 14:32, Richard Hipp wrote:

On Mon, Jun 13, 2011 at 7:07 PM, Steve Havelka  wrote:


Is it necessary that it's autoconf?  Or would you take a CMake-based build
script?




Though I think autoconf is also necessary (for use by people who do not have
cmake installed) I will also consider having appropriate cmake scripts in
the tree, for use by people have and prefer cmake.  Would anybody care to
contribute the appropriate files?



Attached is my experiment of building Fossil with CMake. I was able to
successfully generate a makefile for MinGW on Windows and for a Linux
distribution based on Debian.
Place the CMakeLists.txt file in the top directory of the Fossil 
development tree.


On Windows, the makeheaders program needs a small patch because the
generated makefile uses the -f option and there was a problem with full
pathnames which include a colon in the device name.

--
tsbg
PROJECT(Fossil C)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# Build options.
OPTION(FOSSIL_BUILD_STATIC "Build Fossil static" TRUE)
OPTION(FOSSIL_ENABLE_SSL "Enable SSL support" FALSE)

# Include some macros.
INCLUDE(CheckIncludeFile)

# Source files which gets processed by the translate program.
SET(TRANS_SRCS
  add allrepo attach bag bisect blob branch browse captcha cgi checkin
  checkout clearsign clone comformat configure content db delta deltacmd
  descendants diff diffcmd doc encode event export file finfo glob graph gzip
  http http_socket http_transport import info leaf login main manifest md5
  merge merge3 name path pivot popen pqueue printf rebuild report rss schema
  search setup sha1 shun skins sqlcmd stash stat style sync tag tar th_main
  timeline tkt tktsetup undo update url user verify vfile wiki wikiformat
  winhttp xfer zip http_ssl
)

# Additional source files.
SET(OTHER_SRCS
  src/sqlite3.c src/shell.c src/th.c src/th_lang.c
)

# Add the resource file on windows to the source files.
IF(WIN32)
  SET(OTHER_SRCS ${OTHER_SRCS} win/fossil.rc)
ENDIF(WIN32)

# Set compile definitions for src/shell.c.
SET(SHELL_COMP_DEFS
  main=sqlite3_shell
  SQLITE_OMIT_LOAD_EXTENSION=1
)
SET_SOURCE_FILES_PROPERTIES(src/shell.c
  PROPERTIES COMPILE_DEFINITIONS "${SHELL_COMP_DEFS}"
)

# Set compile definitions for src/sqlite.c.
SET(SQLITE3_COMP_DEFS
  SQLITE_OMIT_LOAD_EXTENSION=1
  SQLITE_THREADSAFE=0
  SQLITE_DEFAULT_FILE_FORMAT=4
  SQLITE_ENABLE_STAT2
  SQLITE_ENABLE_LOCKING_STYLE=0
  localtime=fossil_localtime
)
SET_SOURCE_FILES_PROPERTIES(src/sqlite3.c
  PROPERTIES COMPILE_DEFINITIONS "${SQLITE3_COMP_DEFS}"
)

# Build the makeheaders program.
ADD_EXECUTABLE(makeheaders src/makeheaders.c)
GET_TARGET_PROPERTY(MAKEHEADERS_LOC makeheaders LOCATION)

# Build the translate program.
ADD_EXECUTABLE(translate src/translate.c)
GET_TARGET_PROPERTY(TRANSLATE_LOC translate LOCATION)

# Build the mkindex program.
ADD_EXECUTABLE(mkindex src/mkindex.c)
GET_TARGET_PROPERTY(MKINDEX_LOC mkindex LOCATION)

# Build the version program.
ADD_EXECUTABLE(version win/version.c)
GET_TARGET_PROPERTY(VERSION_LOC version LOCATION)

# Custom command to build the VERSION.h include file.
ADD_CUSTOM_COMMAND(
  OUTPUT  ${PROJECT_BINARY_DIR}/VERSION.h
  DEPENDS version
  ${PROJECT_SOURCE_DIR}/manifest.uuid
  ${PROJECT_SOURCE_DIR}/manifest
  COMMAND ${VERSION_LOC}
  ARGS${PROJECT_SOURCE_DIR}/manifest.uuid
  ${PROJECT_SOURCE_DIR}/manifest
> ${PROJECT_BINARY_DIR}/VERSION.h
  COMMENT "Generating VERSION.h ..."
)

# Custom commands to build the translated sources.
FOREACH(SRC ${TRANS_SRCS})

  ADD_CUSTOM_COMMAND(
OUTPUT  ${PROJECT_BINARY_DIR}/${SRC}_.c
DEPENDS translate
${PROJECT_SOURCE_DIR}/src/${SRC}.c
COMMAND ${TRANSLATE_LOC}
ARGS${PROJECT_SOURCE_DIR}/src/${SRC}.c
  > ${PROJECT_BINARY_DIR}/${SRC}_.c
COMMENT "Translating src/${SRC}.c ..."
  )

  # Build a list of all the results.
  SET(TRANS_SRC ${TRANS_SRC} ${PROJECT_BINARY_DIR}/${SRC}_.c)

ENDFOREACH(SRC)

# Custom command to build page_index.h.
ADD_CUSTOM_COMMAND(
  OUTPUT  ${PROJECT_BINARY_DIR}/page_index.h
  DEPENDS mkindex
  ${TRANS_SRC}
  COMMAND ${MKINDEX_LOC}
  ARGS${TRANS_SRC}
> ${PROJECT_BINARY_DIR}/page_index.h
  COMMENT "Generating page_index.h ..."
)
ADD_CUSTOM_TARGET(page_index DEPENDS ${PROJECT_BINARY_DIR}/page_index.h)

# Create an input file for the makeheaders program.
FILE(WRITE ${PROJECT_BINARY_DIR}/mkhdr.dat
"# Warning: this file is automatically generated by CMake.
${PROJECT_SOURCE_DIR}/src/sqlite3.h
${PROJECT_SOURCE_DIR}/src/th.h
${PROJECT_BINARY_DIR}/VERSION.h\n"
)
FOREACH(SRC ${TRANS_SRCS})
  FILE(APPEND ${PROJECT_BINARY_DIR}/mkhdr.dat
"${PROJECT_BINARY_DIR}/${SRC}_.c:${PROJECT_BINARY_DIR}/${SRC}.h\n"
  )
  # Build a list of all the generated header files.
  SET(GEN_HDRS ${GEN_HDRS} ${PROJECT_BINARY_DIR}/${SRC}.h)
ENDFOREACH(SRC)

# Custom commands to build the header files.
ADD_CUSTOM_COMMAND(
  OUTPUT  ${PROJECT_BINARY_DIR}/headers ${GEN_HDRS}
  DEPENDS makeheaders
  ${