380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
|
** Usage: %fossil help COMMAND
** Display information on how to use COMMAND
*/
void help_cmd(void){
int rc, idx;
const char *z;
if( g.argc!=3 ){
printf("Usage: %s help <command>.\nAvailable commands:\n", g.argv[0]);
cmd_cmd_list();
return;
}
rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
if( rc==1 ){
fossil_fatal("unknown command: %s", g.argv[2]);
}else if( rc==2 ){
|
|
|
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
|
** Usage: %fossil help COMMAND
** Display information on how to use COMMAND
*/
void help_cmd(void){
int rc, idx;
const char *z;
if( g.argc!=3 ){
printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n", g.argv[0]);
cmd_cmd_list();
return;
}
rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
if( rc==1 ){
fossil_fatal("unknown command: %s", g.argv[2]);
}else if( rc==2 ){
|
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
*/
cgi_reply();
}
/*
** COMMAND: cgi
**
** The single argument is the name of a file that is the CGI script
** that is being run. This file should look something like this:
**
** #!/usr/bin/fossil
** repository: /home/somebody/project.db
**
** We are interested in the line that defines the name of the repository.
** Read the file, find the repository line. Then open the respository
** database.
**
** Also do the usual CGI initialization stuff in the cgi.c module.
**
** After all of the above setup, call process_one_web_page() to do the
** web page processing and return the result.
*/
void cmd_cgi(void){
const char *zFile;
Blob config, line, key, value;
if( g.argc==3 && strcmp(g.argv[1],"cgi")==0 ){
zFile = g.argv[2];
}else{
|
>
>
|
>
>
>
|
|
|
<
<
<
<
<
|
|
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
*/
cgi_reply();
}
/*
** COMMAND: cgi
**
** Usage: %fossil ?cgi? SCRIPT
**
** The SCRIPT argument is the name of a file that is the CGI script
** that is being run. The command name, "cgi", may be omitted if
** the GATEWAY_INTERFACE environment variable is set to "CGI" (which
** should always be the case for CGI scripts run by a webserver.) The
** SCRIPT file should look something like this:
**
** #!/usr/bin/fossil
** repository: /home/somebody/project.db
**
** The second line defines the name of the repository. After locating
** the repository, fossil will generate a webpage on stdout based on
** the values of standard CGI environment variables.
*/
void cmd_cgi(void){
const char *zFile;
Blob config, line, key, value;
if( g.argc==3 && strcmp(g.argv[1],"cgi")==0 ){
zFile = g.argv[2];
}else{
|
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
cgi_init();
process_one_web_page();
}
/*
** COMMAND: http
**
** Handle a single HTTP request appearing on standard input. This
** method is used to launch an HTTP request handler from INETD, for
** example.
**
** The argument is the name of the repository.
*/
void cmd_http(void){
if( g.argc!=2 && g.argc!=3 ){
cgi_panic("no repository specified");
}
g.cgiPanic = 1;
if( g.argc==3 ){
db_open_repository(g.argv[2]);
}else{
db_must_be_within_tree();
}
cgi_handle_http_request();
process_one_web_page();
}
/*
** COMMAND: server
**
** Open a socket and begin listening for incoming HTTP requests.
** As each connection is received, fork a new child process to handle
** the request.
**
** The argument is the name of the repository.
*/
void cmd_webserver(void){
int iPort;
const char *zPort;
zPort = find_option("port", "P", 1);
if( zPort ){
|
>
>
|
|
|
<
|
|
<
<
>
>
|
>
>
|
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
cgi_init();
process_one_web_page();
}
/*
** COMMAND: http
**
** Usage: %fossil http REPOSITORY
**
** Handle a single HTTP request appearing on stdin. The resulting webpage
** is delivered on stdout. This method is used to launch an HTTP request
** handler from inetd, for example. The argument is the name of the
** repository.
*/
void cmd_http(void){
if( g.argc!=2 && g.argc!=3 ){
cgi_panic("no repository specified");
}
g.cgiPanic = 1;
if( g.argc==3 ){
db_open_repository(g.argv[2]);
}else{
db_must_be_within_tree();
}
cgi_handle_http_request();
process_one_web_page();
}
/*
** COMMAND: server
**
** Usage: %fossil server ?-P|--port TCPPORT? ?REPOSITORY?
**
** Open a socket and begin listening and responding to HTTP requests on
** TCP port 8080, or on any other TCP port defined by the -P or
** --port option. The optional argument is the name of the repository.
** The repository argument may be omitted if the working directory is
** within an open checkout.
*/
void cmd_webserver(void){
int iPort;
const char *zPort;
zPort = find_option("port", "P", 1);
if( zPort ){
|