Fossil SCM

Make "fossil ui" on Windows aware of current checkout. Allows using special names prev/next/current in ui

drh 2014-09-13 16:04 trunk merge
Commit f62bedf1efe98e60100f2aa094e741b3a89f79a2
3 files changed +22 -21 +22 -21 +7 -3
+22 -21
--- src/main.c
+++ src/main.c
@@ -1843,52 +1843,52 @@
18431843
process_one_web_page(zNotFound, pFileGlob);
18441844
}
18451845
}
18461846
18471847
/*
1848
-** If g.argv[2] exists then it is either the name of a repository
1848
+** If g.argv[arg] exists then it is either the name of a repository
18491849
** that will be used by a server, or else it is a directory that
1850
-** contains multiple repositories that can be served. If g.argv[2]
1850
+** contains multiple repositories that can be served. If g.argv[arg]
18511851
** is a directory, the repositories it contains must be named
1852
-** "*.fossil". If g.argv[2] does not exists, then we must be within
1852
+** "*.fossil". If g.argv[arg] does not exists, then we must be within
18531853
** a check-out and the repository to be served is the repository of
18541854
** that check-out.
18551855
**
1856
-** Open the repository to be served if it is known. If g.argv[2] is
1856
+** Open the repository to be served if it is known. If g.argv[arg] is
18571857
** a directory full of repositories, then set g.zRepositoryName to
18581858
** the name of that directory and the specific repository will be
18591859
** opened later by process_one_web_page() based on the content of
18601860
** the PATH_INFO variable.
18611861
**
18621862
** If disallowDir is set, then the directory full of repositories method
18631863
** is disallowed.
18641864
*/
1865
-static void find_server_repository(int disallowDir){
1866
- if( g.argc<3 ){
1865
+static void find_server_repository(int disallowDir, int arg){
1866
+ if( g.argc<=arg ){
18671867
db_must_be_within_tree();
1868
- }else if( file_isdir(g.argv[2])==1 ){
1868
+ }else if( file_isdir(g.argv[arg])==1 ){
18691869
if( disallowDir ){
1870
- fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]);
1870
+ fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[arg]);
18711871
}else{
1872
- g.zRepositoryName = mprintf("%s", g.argv[2]);
1872
+ g.zRepositoryName = mprintf("%s", g.argv[arg]);
18731873
file_simplify_name(g.zRepositoryName, -1, 0);
18741874
}
18751875
}else{
1876
- db_open_repository(g.argv[2]);
1876
+ db_open_repository(g.argv[arg]);
18771877
}
18781878
}
18791879
18801880
/*
18811881
** undocumented format:
18821882
**
1883
-** fossil http REPOSITORY INFILE OUTFILE IPADDR
1883
+** fossil http INFILE OUTFILE IPADDR ?REPOSITORY?
18841884
**
18851885
** The argv==6 form is used by the win32 server only.
18861886
**
18871887
** COMMAND: http*
18881888
**
1889
-** Usage: %fossil http REPOSITORY ?OPTIONS?
1889
+** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
18901890
**
18911891
** Handle a single HTTP request appearing on stdin. The resulting webpage
18921892
** is delivered on stdout. This method is used to launch an HTTP request
18931893
** handler from inetd, for example. The argument is the name of the
18941894
** repository.
@@ -1959,30 +1959,31 @@
19591959
g.cgiOutput = 1;
19601960
19611961
/* We should be done with options.. */
19621962
verify_all_options();
19631963
1964
- if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
1964
+ if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
19651965
fossil_fatal("no repository specified");
19661966
}
19671967
g.fullHttpReply = 1;
1968
- if( g.argc==6 ){
1969
- g.httpIn = fossil_fopen(g.argv[3], "rb");
1970
- g.httpOut = fossil_fopen(g.argv[4], "wb");
1971
- zIpAddr = g.argv[5];
1968
+ if( g.argc>=5 ){
1969
+ g.httpIn = fossil_fopen(g.argv[2], "rb");
1970
+ g.httpOut = fossil_fopen(g.argv[3], "wb");
1971
+ zIpAddr = g.argv[4];
1972
+ find_server_repository(0, 5);
19721973
}else{
19731974
g.httpIn = stdin;
19741975
g.httpOut = stdout;
19751976
zIpAddr = 0;
1977
+ find_server_repository(0, 2);
19761978
}
19771979
if( zIpAddr==0 ){
19781980
zIpAddr = cgi_ssh_remote_addr(0);
19791981
if( zIpAddr && zIpAddr[0] ){
19801982
g.fSshClient |= CGI_SSH_CLIENT;
19811983
}
19821984
}
1983
- find_server_repository(0);
19841985
g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
19851986
if( useSCGI ){
19861987
cgi_handle_scgi_request();
19871988
}else if( g.fSshClient & CGI_SSH_CLIENT ){
19881989
ssh_request_loop(zIpAddr, glob_create(zFileGlob));
@@ -2018,11 +2019,11 @@
20182019
Th_InitTraceLog();
20192020
login_set_capabilities("sx", 0);
20202021
g.useLocalauth = 1;
20212022
g.httpIn = stdin;
20222023
g.httpOut = stdout;
2023
- find_server_repository(0);
2024
+ find_server_repository(0, 2);
20242025
g.cgiOutput = 1;
20252026
g.fullHttpReply = 1;
20262027
zIpAddr = cgi_ssh_remote_addr(0);
20272028
if( zIpAddr && zIpAddr[0] ){
20282029
g.fSshClient |= CGI_SSH_CLIENT;
@@ -2155,11 +2156,11 @@
21552156
isUiCmd = g.argv[1][0]=='u';
21562157
if( isUiCmd ){
21572158
flags |= HTTP_SERVER_LOCALHOST;
21582159
g.useLocalauth = 1;
21592160
}
2160
- find_server_repository(isUiCmd && zNotFound==0);
2161
+ find_server_repository(isUiCmd && zNotFound==0, 2);
21612162
if( zPort ){
21622163
int i;
21632164
for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
21642165
if( i>0 ){
21652166
zIpAddr = mprintf("%.*s", i, zPort);
@@ -2205,11 +2206,11 @@
22052206
g.httpOut = stdout;
22062207
if( g.fHttpTrace || g.fSqlTrace ){
22072208
fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
22082209
}
22092210
g.cgiOutput = 1;
2210
- find_server_repository(isUiCmd && zNotFound==0);
2211
+ find_server_repository(isUiCmd && zNotFound==0, 2);
22112212
g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
22122213
if( flags & HTTP_SERVER_SCGI ){
22132214
cgi_handle_scgi_request();
22142215
}else{
22152216
cgi_handle_http_request(0);
22162217
--- src/main.c
+++ src/main.c
@@ -1843,52 +1843,52 @@
1843 process_one_web_page(zNotFound, pFileGlob);
1844 }
1845 }
1846
1847 /*
1848 ** If g.argv[2] exists then it is either the name of a repository
1849 ** that will be used by a server, or else it is a directory that
1850 ** contains multiple repositories that can be served. If g.argv[2]
1851 ** is a directory, the repositories it contains must be named
1852 ** "*.fossil". If g.argv[2] does not exists, then we must be within
1853 ** a check-out and the repository to be served is the repository of
1854 ** that check-out.
1855 **
1856 ** Open the repository to be served if it is known. If g.argv[2] is
1857 ** a directory full of repositories, then set g.zRepositoryName to
1858 ** the name of that directory and the specific repository will be
1859 ** opened later by process_one_web_page() based on the content of
1860 ** the PATH_INFO variable.
1861 **
1862 ** If disallowDir is set, then the directory full of repositories method
1863 ** is disallowed.
1864 */
1865 static void find_server_repository(int disallowDir){
1866 if( g.argc<3 ){
1867 db_must_be_within_tree();
1868 }else if( file_isdir(g.argv[2])==1 ){
1869 if( disallowDir ){
1870 fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]);
1871 }else{
1872 g.zRepositoryName = mprintf("%s", g.argv[2]);
1873 file_simplify_name(g.zRepositoryName, -1, 0);
1874 }
1875 }else{
1876 db_open_repository(g.argv[2]);
1877 }
1878 }
1879
1880 /*
1881 ** undocumented format:
1882 **
1883 ** fossil http REPOSITORY INFILE OUTFILE IPADDR
1884 **
1885 ** The argv==6 form is used by the win32 server only.
1886 **
1887 ** COMMAND: http*
1888 **
1889 ** Usage: %fossil http REPOSITORY ?OPTIONS?
1890 **
1891 ** Handle a single HTTP request appearing on stdin. The resulting webpage
1892 ** is delivered on stdout. This method is used to launch an HTTP request
1893 ** handler from inetd, for example. The argument is the name of the
1894 ** repository.
@@ -1959,30 +1959,31 @@
1959 g.cgiOutput = 1;
1960
1961 /* We should be done with options.. */
1962 verify_all_options();
1963
1964 if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
1965 fossil_fatal("no repository specified");
1966 }
1967 g.fullHttpReply = 1;
1968 if( g.argc==6 ){
1969 g.httpIn = fossil_fopen(g.argv[3], "rb");
1970 g.httpOut = fossil_fopen(g.argv[4], "wb");
1971 zIpAddr = g.argv[5];
 
1972 }else{
1973 g.httpIn = stdin;
1974 g.httpOut = stdout;
1975 zIpAddr = 0;
 
1976 }
1977 if( zIpAddr==0 ){
1978 zIpAddr = cgi_ssh_remote_addr(0);
1979 if( zIpAddr && zIpAddr[0] ){
1980 g.fSshClient |= CGI_SSH_CLIENT;
1981 }
1982 }
1983 find_server_repository(0);
1984 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
1985 if( useSCGI ){
1986 cgi_handle_scgi_request();
1987 }else if( g.fSshClient & CGI_SSH_CLIENT ){
1988 ssh_request_loop(zIpAddr, glob_create(zFileGlob));
@@ -2018,11 +2019,11 @@
2018 Th_InitTraceLog();
2019 login_set_capabilities("sx", 0);
2020 g.useLocalauth = 1;
2021 g.httpIn = stdin;
2022 g.httpOut = stdout;
2023 find_server_repository(0);
2024 g.cgiOutput = 1;
2025 g.fullHttpReply = 1;
2026 zIpAddr = cgi_ssh_remote_addr(0);
2027 if( zIpAddr && zIpAddr[0] ){
2028 g.fSshClient |= CGI_SSH_CLIENT;
@@ -2155,11 +2156,11 @@
2155 isUiCmd = g.argv[1][0]=='u';
2156 if( isUiCmd ){
2157 flags |= HTTP_SERVER_LOCALHOST;
2158 g.useLocalauth = 1;
2159 }
2160 find_server_repository(isUiCmd && zNotFound==0);
2161 if( zPort ){
2162 int i;
2163 for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
2164 if( i>0 ){
2165 zIpAddr = mprintf("%.*s", i, zPort);
@@ -2205,11 +2206,11 @@
2205 g.httpOut = stdout;
2206 if( g.fHttpTrace || g.fSqlTrace ){
2207 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
2208 }
2209 g.cgiOutput = 1;
2210 find_server_repository(isUiCmd && zNotFound==0);
2211 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
2212 if( flags & HTTP_SERVER_SCGI ){
2213 cgi_handle_scgi_request();
2214 }else{
2215 cgi_handle_http_request(0);
2216
--- src/main.c
+++ src/main.c
@@ -1843,52 +1843,52 @@
1843 process_one_web_page(zNotFound, pFileGlob);
1844 }
1845 }
1846
1847 /*
1848 ** If g.argv[arg] exists then it is either the name of a repository
1849 ** that will be used by a server, or else it is a directory that
1850 ** contains multiple repositories that can be served. If g.argv[arg]
1851 ** is a directory, the repositories it contains must be named
1852 ** "*.fossil". If g.argv[arg] does not exists, then we must be within
1853 ** a check-out and the repository to be served is the repository of
1854 ** that check-out.
1855 **
1856 ** Open the repository to be served if it is known. If g.argv[arg] is
1857 ** a directory full of repositories, then set g.zRepositoryName to
1858 ** the name of that directory and the specific repository will be
1859 ** opened later by process_one_web_page() based on the content of
1860 ** the PATH_INFO variable.
1861 **
1862 ** If disallowDir is set, then the directory full of repositories method
1863 ** is disallowed.
1864 */
1865 static void find_server_repository(int disallowDir, int arg){
1866 if( g.argc<=arg ){
1867 db_must_be_within_tree();
1868 }else if( file_isdir(g.argv[arg])==1 ){
1869 if( disallowDir ){
1870 fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[arg]);
1871 }else{
1872 g.zRepositoryName = mprintf("%s", g.argv[arg]);
1873 file_simplify_name(g.zRepositoryName, -1, 0);
1874 }
1875 }else{
1876 db_open_repository(g.argv[arg]);
1877 }
1878 }
1879
1880 /*
1881 ** undocumented format:
1882 **
1883 ** fossil http INFILE OUTFILE IPADDR ?REPOSITORY?
1884 **
1885 ** The argv==6 form is used by the win32 server only.
1886 **
1887 ** COMMAND: http*
1888 **
1889 ** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
1890 **
1891 ** Handle a single HTTP request appearing on stdin. The resulting webpage
1892 ** is delivered on stdout. This method is used to launch an HTTP request
1893 ** handler from inetd, for example. The argument is the name of the
1894 ** repository.
@@ -1959,30 +1959,31 @@
1959 g.cgiOutput = 1;
1960
1961 /* We should be done with options.. */
1962 verify_all_options();
1963
1964 if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
1965 fossil_fatal("no repository specified");
1966 }
1967 g.fullHttpReply = 1;
1968 if( g.argc>=5 ){
1969 g.httpIn = fossil_fopen(g.argv[2], "rb");
1970 g.httpOut = fossil_fopen(g.argv[3], "wb");
1971 zIpAddr = g.argv[4];
1972 find_server_repository(0, 5);
1973 }else{
1974 g.httpIn = stdin;
1975 g.httpOut = stdout;
1976 zIpAddr = 0;
1977 find_server_repository(0, 2);
1978 }
1979 if( zIpAddr==0 ){
1980 zIpAddr = cgi_ssh_remote_addr(0);
1981 if( zIpAddr && zIpAddr[0] ){
1982 g.fSshClient |= CGI_SSH_CLIENT;
1983 }
1984 }
 
1985 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
1986 if( useSCGI ){
1987 cgi_handle_scgi_request();
1988 }else if( g.fSshClient & CGI_SSH_CLIENT ){
1989 ssh_request_loop(zIpAddr, glob_create(zFileGlob));
@@ -2018,11 +2019,11 @@
2019 Th_InitTraceLog();
2020 login_set_capabilities("sx", 0);
2021 g.useLocalauth = 1;
2022 g.httpIn = stdin;
2023 g.httpOut = stdout;
2024 find_server_repository(0, 2);
2025 g.cgiOutput = 1;
2026 g.fullHttpReply = 1;
2027 zIpAddr = cgi_ssh_remote_addr(0);
2028 if( zIpAddr && zIpAddr[0] ){
2029 g.fSshClient |= CGI_SSH_CLIENT;
@@ -2155,11 +2156,11 @@
2156 isUiCmd = g.argv[1][0]=='u';
2157 if( isUiCmd ){
2158 flags |= HTTP_SERVER_LOCALHOST;
2159 g.useLocalauth = 1;
2160 }
2161 find_server_repository(isUiCmd && zNotFound==0, 2);
2162 if( zPort ){
2163 int i;
2164 for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
2165 if( i>0 ){
2166 zIpAddr = mprintf("%.*s", i, zPort);
@@ -2205,11 +2206,11 @@
2206 g.httpOut = stdout;
2207 if( g.fHttpTrace || g.fSqlTrace ){
2208 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
2209 }
2210 g.cgiOutput = 1;
2211 find_server_repository(isUiCmd && zNotFound==0, 2);
2212 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
2213 if( flags & HTTP_SERVER_SCGI ){
2214 cgi_handle_scgi_request();
2215 }else{
2216 cgi_handle_http_request(0);
2217
+22 -21
--- src/main.c
+++ src/main.c
@@ -1843,52 +1843,52 @@
18431843
process_one_web_page(zNotFound, pFileGlob);
18441844
}
18451845
}
18461846
18471847
/*
1848
-** If g.argv[2] exists then it is either the name of a repository
1848
+** If g.argv[arg] exists then it is either the name of a repository
18491849
** that will be used by a server, or else it is a directory that
1850
-** contains multiple repositories that can be served. If g.argv[2]
1850
+** contains multiple repositories that can be served. If g.argv[arg]
18511851
** is a directory, the repositories it contains must be named
1852
-** "*.fossil". If g.argv[2] does not exists, then we must be within
1852
+** "*.fossil". If g.argv[arg] does not exists, then we must be within
18531853
** a check-out and the repository to be served is the repository of
18541854
** that check-out.
18551855
**
1856
-** Open the repository to be served if it is known. If g.argv[2] is
1856
+** Open the repository to be served if it is known. If g.argv[arg] is
18571857
** a directory full of repositories, then set g.zRepositoryName to
18581858
** the name of that directory and the specific repository will be
18591859
** opened later by process_one_web_page() based on the content of
18601860
** the PATH_INFO variable.
18611861
**
18621862
** If disallowDir is set, then the directory full of repositories method
18631863
** is disallowed.
18641864
*/
1865
-static void find_server_repository(int disallowDir){
1866
- if( g.argc<3 ){
1865
+static void find_server_repository(int disallowDir, int arg){
1866
+ if( g.argc<=arg ){
18671867
db_must_be_within_tree();
1868
- }else if( file_isdir(g.argv[2])==1 ){
1868
+ }else if( file_isdir(g.argv[arg])==1 ){
18691869
if( disallowDir ){
1870
- fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]);
1870
+ fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[arg]);
18711871
}else{
1872
- g.zRepositoryName = mprintf("%s", g.argv[2]);
1872
+ g.zRepositoryName = mprintf("%s", g.argv[arg]);
18731873
file_simplify_name(g.zRepositoryName, -1, 0);
18741874
}
18751875
}else{
1876
- db_open_repository(g.argv[2]);
1876
+ db_open_repository(g.argv[arg]);
18771877
}
18781878
}
18791879
18801880
/*
18811881
** undocumented format:
18821882
**
1883
-** fossil http REPOSITORY INFILE OUTFILE IPADDR
1883
+** fossil http INFILE OUTFILE IPADDR ?REPOSITORY?
18841884
**
18851885
** The argv==6 form is used by the win32 server only.
18861886
**
18871887
** COMMAND: http*
18881888
**
1889
-** Usage: %fossil http REPOSITORY ?OPTIONS?
1889
+** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
18901890
**
18911891
** Handle a single HTTP request appearing on stdin. The resulting webpage
18921892
** is delivered on stdout. This method is used to launch an HTTP request
18931893
** handler from inetd, for example. The argument is the name of the
18941894
** repository.
@@ -1959,30 +1959,31 @@
19591959
g.cgiOutput = 1;
19601960
19611961
/* We should be done with options.. */
19621962
verify_all_options();
19631963
1964
- if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
1964
+ if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
19651965
fossil_fatal("no repository specified");
19661966
}
19671967
g.fullHttpReply = 1;
1968
- if( g.argc==6 ){
1969
- g.httpIn = fossil_fopen(g.argv[3], "rb");
1970
- g.httpOut = fossil_fopen(g.argv[4], "wb");
1971
- zIpAddr = g.argv[5];
1968
+ if( g.argc>=5 ){
1969
+ g.httpIn = fossil_fopen(g.argv[2], "rb");
1970
+ g.httpOut = fossil_fopen(g.argv[3], "wb");
1971
+ zIpAddr = g.argv[4];
1972
+ find_server_repository(0, 5);
19721973
}else{
19731974
g.httpIn = stdin;
19741975
g.httpOut = stdout;
19751976
zIpAddr = 0;
1977
+ find_server_repository(0, 2);
19761978
}
19771979
if( zIpAddr==0 ){
19781980
zIpAddr = cgi_ssh_remote_addr(0);
19791981
if( zIpAddr && zIpAddr[0] ){
19801982
g.fSshClient |= CGI_SSH_CLIENT;
19811983
}
19821984
}
1983
- find_server_repository(0);
19841985
g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
19851986
if( useSCGI ){
19861987
cgi_handle_scgi_request();
19871988
}else if( g.fSshClient & CGI_SSH_CLIENT ){
19881989
ssh_request_loop(zIpAddr, glob_create(zFileGlob));
@@ -2018,11 +2019,11 @@
20182019
Th_InitTraceLog();
20192020
login_set_capabilities("sx", 0);
20202021
g.useLocalauth = 1;
20212022
g.httpIn = stdin;
20222023
g.httpOut = stdout;
2023
- find_server_repository(0);
2024
+ find_server_repository(0, 2);
20242025
g.cgiOutput = 1;
20252026
g.fullHttpReply = 1;
20262027
zIpAddr = cgi_ssh_remote_addr(0);
20272028
if( zIpAddr && zIpAddr[0] ){
20282029
g.fSshClient |= CGI_SSH_CLIENT;
@@ -2155,11 +2156,11 @@
21552156
isUiCmd = g.argv[1][0]=='u';
21562157
if( isUiCmd ){
21572158
flags |= HTTP_SERVER_LOCALHOST;
21582159
g.useLocalauth = 1;
21592160
}
2160
- find_server_repository(isUiCmd && zNotFound==0);
2161
+ find_server_repository(isUiCmd && zNotFound==0, 2);
21612162
if( zPort ){
21622163
int i;
21632164
for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
21642165
if( i>0 ){
21652166
zIpAddr = mprintf("%.*s", i, zPort);
@@ -2205,11 +2206,11 @@
22052206
g.httpOut = stdout;
22062207
if( g.fHttpTrace || g.fSqlTrace ){
22072208
fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
22082209
}
22092210
g.cgiOutput = 1;
2210
- find_server_repository(isUiCmd && zNotFound==0);
2211
+ find_server_repository(isUiCmd && zNotFound==0, 2);
22112212
g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
22122213
if( flags & HTTP_SERVER_SCGI ){
22132214
cgi_handle_scgi_request();
22142215
}else{
22152216
cgi_handle_http_request(0);
22162217
--- src/main.c
+++ src/main.c
@@ -1843,52 +1843,52 @@
1843 process_one_web_page(zNotFound, pFileGlob);
1844 }
1845 }
1846
1847 /*
1848 ** If g.argv[2] exists then it is either the name of a repository
1849 ** that will be used by a server, or else it is a directory that
1850 ** contains multiple repositories that can be served. If g.argv[2]
1851 ** is a directory, the repositories it contains must be named
1852 ** "*.fossil". If g.argv[2] does not exists, then we must be within
1853 ** a check-out and the repository to be served is the repository of
1854 ** that check-out.
1855 **
1856 ** Open the repository to be served if it is known. If g.argv[2] is
1857 ** a directory full of repositories, then set g.zRepositoryName to
1858 ** the name of that directory and the specific repository will be
1859 ** opened later by process_one_web_page() based on the content of
1860 ** the PATH_INFO variable.
1861 **
1862 ** If disallowDir is set, then the directory full of repositories method
1863 ** is disallowed.
1864 */
1865 static void find_server_repository(int disallowDir){
1866 if( g.argc<3 ){
1867 db_must_be_within_tree();
1868 }else if( file_isdir(g.argv[2])==1 ){
1869 if( disallowDir ){
1870 fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[2]);
1871 }else{
1872 g.zRepositoryName = mprintf("%s", g.argv[2]);
1873 file_simplify_name(g.zRepositoryName, -1, 0);
1874 }
1875 }else{
1876 db_open_repository(g.argv[2]);
1877 }
1878 }
1879
1880 /*
1881 ** undocumented format:
1882 **
1883 ** fossil http REPOSITORY INFILE OUTFILE IPADDR
1884 **
1885 ** The argv==6 form is used by the win32 server only.
1886 **
1887 ** COMMAND: http*
1888 **
1889 ** Usage: %fossil http REPOSITORY ?OPTIONS?
1890 **
1891 ** Handle a single HTTP request appearing on stdin. The resulting webpage
1892 ** is delivered on stdout. This method is used to launch an HTTP request
1893 ** handler from inetd, for example. The argument is the name of the
1894 ** repository.
@@ -1959,30 +1959,31 @@
1959 g.cgiOutput = 1;
1960
1961 /* We should be done with options.. */
1962 verify_all_options();
1963
1964 if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
1965 fossil_fatal("no repository specified");
1966 }
1967 g.fullHttpReply = 1;
1968 if( g.argc==6 ){
1969 g.httpIn = fossil_fopen(g.argv[3], "rb");
1970 g.httpOut = fossil_fopen(g.argv[4], "wb");
1971 zIpAddr = g.argv[5];
 
1972 }else{
1973 g.httpIn = stdin;
1974 g.httpOut = stdout;
1975 zIpAddr = 0;
 
1976 }
1977 if( zIpAddr==0 ){
1978 zIpAddr = cgi_ssh_remote_addr(0);
1979 if( zIpAddr && zIpAddr[0] ){
1980 g.fSshClient |= CGI_SSH_CLIENT;
1981 }
1982 }
1983 find_server_repository(0);
1984 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
1985 if( useSCGI ){
1986 cgi_handle_scgi_request();
1987 }else if( g.fSshClient & CGI_SSH_CLIENT ){
1988 ssh_request_loop(zIpAddr, glob_create(zFileGlob));
@@ -2018,11 +2019,11 @@
2018 Th_InitTraceLog();
2019 login_set_capabilities("sx", 0);
2020 g.useLocalauth = 1;
2021 g.httpIn = stdin;
2022 g.httpOut = stdout;
2023 find_server_repository(0);
2024 g.cgiOutput = 1;
2025 g.fullHttpReply = 1;
2026 zIpAddr = cgi_ssh_remote_addr(0);
2027 if( zIpAddr && zIpAddr[0] ){
2028 g.fSshClient |= CGI_SSH_CLIENT;
@@ -2155,11 +2156,11 @@
2155 isUiCmd = g.argv[1][0]=='u';
2156 if( isUiCmd ){
2157 flags |= HTTP_SERVER_LOCALHOST;
2158 g.useLocalauth = 1;
2159 }
2160 find_server_repository(isUiCmd && zNotFound==0);
2161 if( zPort ){
2162 int i;
2163 for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
2164 if( i>0 ){
2165 zIpAddr = mprintf("%.*s", i, zPort);
@@ -2205,11 +2206,11 @@
2205 g.httpOut = stdout;
2206 if( g.fHttpTrace || g.fSqlTrace ){
2207 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
2208 }
2209 g.cgiOutput = 1;
2210 find_server_repository(isUiCmd && zNotFound==0);
2211 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
2212 if( flags & HTTP_SERVER_SCGI ){
2213 cgi_handle_scgi_request();
2214 }else{
2215 cgi_handle_http_request(0);
2216
--- src/main.c
+++ src/main.c
@@ -1843,52 +1843,52 @@
1843 process_one_web_page(zNotFound, pFileGlob);
1844 }
1845 }
1846
1847 /*
1848 ** If g.argv[arg] exists then it is either the name of a repository
1849 ** that will be used by a server, or else it is a directory that
1850 ** contains multiple repositories that can be served. If g.argv[arg]
1851 ** is a directory, the repositories it contains must be named
1852 ** "*.fossil". If g.argv[arg] does not exists, then we must be within
1853 ** a check-out and the repository to be served is the repository of
1854 ** that check-out.
1855 **
1856 ** Open the repository to be served if it is known. If g.argv[arg] is
1857 ** a directory full of repositories, then set g.zRepositoryName to
1858 ** the name of that directory and the specific repository will be
1859 ** opened later by process_one_web_page() based on the content of
1860 ** the PATH_INFO variable.
1861 **
1862 ** If disallowDir is set, then the directory full of repositories method
1863 ** is disallowed.
1864 */
1865 static void find_server_repository(int disallowDir, int arg){
1866 if( g.argc<=arg ){
1867 db_must_be_within_tree();
1868 }else if( file_isdir(g.argv[arg])==1 ){
1869 if( disallowDir ){
1870 fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[arg]);
1871 }else{
1872 g.zRepositoryName = mprintf("%s", g.argv[arg]);
1873 file_simplify_name(g.zRepositoryName, -1, 0);
1874 }
1875 }else{
1876 db_open_repository(g.argv[arg]);
1877 }
1878 }
1879
1880 /*
1881 ** undocumented format:
1882 **
1883 ** fossil http INFILE OUTFILE IPADDR ?REPOSITORY?
1884 **
1885 ** The argv==6 form is used by the win32 server only.
1886 **
1887 ** COMMAND: http*
1888 **
1889 ** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
1890 **
1891 ** Handle a single HTTP request appearing on stdin. The resulting webpage
1892 ** is delivered on stdout. This method is used to launch an HTTP request
1893 ** handler from inetd, for example. The argument is the name of the
1894 ** repository.
@@ -1959,30 +1959,31 @@
1959 g.cgiOutput = 1;
1960
1961 /* We should be done with options.. */
1962 verify_all_options();
1963
1964 if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
1965 fossil_fatal("no repository specified");
1966 }
1967 g.fullHttpReply = 1;
1968 if( g.argc>=5 ){
1969 g.httpIn = fossil_fopen(g.argv[2], "rb");
1970 g.httpOut = fossil_fopen(g.argv[3], "wb");
1971 zIpAddr = g.argv[4];
1972 find_server_repository(0, 5);
1973 }else{
1974 g.httpIn = stdin;
1975 g.httpOut = stdout;
1976 zIpAddr = 0;
1977 find_server_repository(0, 2);
1978 }
1979 if( zIpAddr==0 ){
1980 zIpAddr = cgi_ssh_remote_addr(0);
1981 if( zIpAddr && zIpAddr[0] ){
1982 g.fSshClient |= CGI_SSH_CLIENT;
1983 }
1984 }
 
1985 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
1986 if( useSCGI ){
1987 cgi_handle_scgi_request();
1988 }else if( g.fSshClient & CGI_SSH_CLIENT ){
1989 ssh_request_loop(zIpAddr, glob_create(zFileGlob));
@@ -2018,11 +2019,11 @@
2019 Th_InitTraceLog();
2020 login_set_capabilities("sx", 0);
2021 g.useLocalauth = 1;
2022 g.httpIn = stdin;
2023 g.httpOut = stdout;
2024 find_server_repository(0, 2);
2025 g.cgiOutput = 1;
2026 g.fullHttpReply = 1;
2027 zIpAddr = cgi_ssh_remote_addr(0);
2028 if( zIpAddr && zIpAddr[0] ){
2029 g.fSshClient |= CGI_SSH_CLIENT;
@@ -2155,11 +2156,11 @@
2156 isUiCmd = g.argv[1][0]=='u';
2157 if( isUiCmd ){
2158 flags |= HTTP_SERVER_LOCALHOST;
2159 g.useLocalauth = 1;
2160 }
2161 find_server_repository(isUiCmd && zNotFound==0, 2);
2162 if( zPort ){
2163 int i;
2164 for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
2165 if( i>0 ){
2166 zIpAddr = mprintf("%.*s", i, zPort);
@@ -2205,11 +2206,11 @@
2206 g.httpOut = stdout;
2207 if( g.fHttpTrace || g.fSqlTrace ){
2208 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
2209 }
2210 g.cgiOutput = 1;
2211 find_server_repository(isUiCmd && zNotFound==0, 2);
2212 g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
2213 if( flags & HTTP_SERVER_SCGI ){
2214 cgi_handle_scgi_request();
2215 }else{
2216 cgi_handle_http_request(0);
2217
+7 -3
--- src/winhttp.c
+++ src/winhttp.c
@@ -111,14 +111,18 @@
111111
}
112112
wanted -= got;
113113
}
114114
fclose(out);
115115
out = 0;
116
- sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s\n%s",
117
- get_utf8_bom(0), g.zRepositoryName, zRequestFName, zReplyFName,
118
- inet_ntoa(p->addr.sin_addr)
116
+ sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s",
117
+ get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr)
119118
);
119
+ /* if g.zLocalRoot is set, then we are in a checkout directory,
120
+ ** even if the db handle is now closed */
121
+ if( !g.zLocalRoot || !g.zLocalRoot[0] ){
122
+ sqlite3_snprintf(sizeof(zCmd), zCmd, "%s\n%s", zCmd, g.zRepositoryName);
123
+ }
120124
out = fossil_fopen(zCmdFName, "wb");
121125
if( out==0 ) goto end_request;
122126
fwrite(zCmd, 1, strlen(zCmd), out);
123127
fclose(out);
124128
125129
--- src/winhttp.c
+++ src/winhttp.c
@@ -111,14 +111,18 @@
111 }
112 wanted -= got;
113 }
114 fclose(out);
115 out = 0;
116 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s\n%s",
117 get_utf8_bom(0), g.zRepositoryName, zRequestFName, zReplyFName,
118 inet_ntoa(p->addr.sin_addr)
119 );
 
 
 
 
 
120 out = fossil_fopen(zCmdFName, "wb");
121 if( out==0 ) goto end_request;
122 fwrite(zCmd, 1, strlen(zCmd), out);
123 fclose(out);
124
125
--- src/winhttp.c
+++ src/winhttp.c
@@ -111,14 +111,18 @@
111 }
112 wanted -= got;
113 }
114 fclose(out);
115 out = 0;
116 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s",
117 get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr)
 
118 );
119 /* if g.zLocalRoot is set, then we are in a checkout directory,
120 ** even if the db handle is now closed */
121 if( !g.zLocalRoot || !g.zLocalRoot[0] ){
122 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s\n%s", zCmd, g.zRepositoryName);
123 }
124 out = fossil_fopen(zCmdFName, "wb");
125 if( out==0 ) goto end_request;
126 fwrite(zCmd, 1, strlen(zCmd), out);
127 fclose(out);
128
129

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button