Fossil SCM

Needed coding style clean up that was missed.

amb 2013-07-18 07:28 ssh-transport-changes
Commit 087cae847dbf0c7b0101b334688a27077a05593f
+14 -7
--- src/clone.c
+++ src/clone.c
@@ -178,29 +178,36 @@
178178
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
179179
fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
180180
db_end_transaction(0);
181181
}
182182
183
+/*
184
+** Look for SSH clone command line options and setup in globals.
185
+*/
183186
void clone_ssh_options(void){
184187
const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
185188
const char *zSshCmd; /* SSH command string */
186189
187190
zSshFossilCmd = find_option("ssh-fossil","f",1);
188191
if( zSshFossilCmd && zSshFossilCmd[0] ){
189
- g.fSshFossilCmd = mprintf("%s", zSshFossilCmd);
192
+ g.zSshFossilCmd = mprintf("%s", zSshFossilCmd);
190193
}
191194
zSshCmd = find_option("ssh-command","c",1);
192195
if( zSshCmd && zSshCmd[0] ){
193
- g.fSshCmd = mprintf("%s", zSshCmd);
196
+ g.zSshCmd = mprintf("%s", zSshCmd);
194197
}
195198
}
196199
200
+/*
201
+** Set SSH options discovered in global variables (set from command line
202
+** options). If not found, attempt to retrieve from database if present.
203
+*/
197204
void clone_ssh_db_options(void){
198
- if( g.fSshFossilCmd && g.fSshFossilCmd[0] ){
199
- db_set("ssh-fossil", g.fSshFossilCmd, 0);
205
+ if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
206
+ db_set("ssh-fossil", g.zSshFossilCmd, 0);
200207
}else{
201
- g.fSshFossilCmd = db_get("ssh-fossil","fossil");
208
+ g.zSshFossilCmd = db_get("ssh-fossil","fossil");
202209
}
203
- if( g.fSshCmd && g.fSshCmd[0] ){
204
- db_set("ssh-command", g.fSshCmd, 0);
210
+ if( g.zSshCmd && g.zSshCmd[0] ){
211
+ db_set("ssh-command", g.zSshCmd, 0);
205212
}
206213
}
207214
--- src/clone.c
+++ src/clone.c
@@ -178,29 +178,36 @@
178 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
179 fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
180 db_end_transaction(0);
181 }
182
 
 
 
183 void clone_ssh_options(void){
184 const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
185 const char *zSshCmd; /* SSH command string */
186
187 zSshFossilCmd = find_option("ssh-fossil","f",1);
188 if( zSshFossilCmd && zSshFossilCmd[0] ){
189 g.fSshFossilCmd = mprintf("%s", zSshFossilCmd);
190 }
191 zSshCmd = find_option("ssh-command","c",1);
192 if( zSshCmd && zSshCmd[0] ){
193 g.fSshCmd = mprintf("%s", zSshCmd);
194 }
195 }
196
 
 
 
 
197 void clone_ssh_db_options(void){
198 if( g.fSshFossilCmd && g.fSshFossilCmd[0] ){
199 db_set("ssh-fossil", g.fSshFossilCmd, 0);
200 }else{
201 g.fSshFossilCmd = db_get("ssh-fossil","fossil");
202 }
203 if( g.fSshCmd && g.fSshCmd[0] ){
204 db_set("ssh-command", g.fSshCmd, 0);
205 }
206 }
207
--- src/clone.c
+++ src/clone.c
@@ -178,29 +178,36 @@
178 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
179 fossil_print("admin-user: %s (password is \"%s\")\n", g.zLogin, zPassword);
180 db_end_transaction(0);
181 }
182
183 /*
184 ** Look for SSH clone command line options and setup in globals.
185 */
186 void clone_ssh_options(void){
187 const char *zSshFossilCmd; /* Path to remote fossil command for SSH */
188 const char *zSshCmd; /* SSH command string */
189
190 zSshFossilCmd = find_option("ssh-fossil","f",1);
191 if( zSshFossilCmd && zSshFossilCmd[0] ){
192 g.zSshFossilCmd = mprintf("%s", zSshFossilCmd);
193 }
194 zSshCmd = find_option("ssh-command","c",1);
195 if( zSshCmd && zSshCmd[0] ){
196 g.zSshCmd = mprintf("%s", zSshCmd);
197 }
198 }
199
200 /*
201 ** Set SSH options discovered in global variables (set from command line
202 ** options). If not found, attempt to retrieve from database if present.
203 */
204 void clone_ssh_db_options(void){
205 if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
206 db_set("ssh-fossil", g.zSshFossilCmd, 0);
207 }else{
208 g.zSshFossilCmd = db_get("ssh-fossil","fossil");
209 }
210 if( g.zSshCmd && g.zSshCmd[0] ){
211 db_set("ssh-command", g.zSshCmd, 0);
212 }
213 }
214
--- src/http_transport.c
+++ src/http_transport.c
@@ -129,16 +129,16 @@
129129
/* Only win32 (and specifically PLINK.EXE) support the -pw option */
130130
if( g.urlPasswd && g.urlPasswd[0] ){
131131
Blob pw;
132132
blob_zero(&pw);
133133
if( g.urlPasswd[0]=='*' ){
134
- char *zPrompt;
135
- zPrompt = mprintf("Password for [%s]: ", zHost);
136
- prompt_for_password(zPrompt, &pw, 0);
137
- free(zPrompt);
134
+ char *zPrompt;
135
+ zPrompt = mprintf("Password for [%s]: ", zHost);
136
+ prompt_for_password(zPrompt, &pw, 0);
137
+ free(zPrompt);
138138
}else{
139
- blob_init(&pw, g.urlPasswd, -1);
139
+ blob_init(&pw, g.urlPasswd, -1);
140140
}
141141
blob_append(&zCmd, " -pw ", -1);
142142
shell_escape(&zCmd, blob_str(&pw));
143143
blob_reset(&pw);
144144
fossil_print(" -pw ********"); /* Do not show the password text */
@@ -148,13 +148,13 @@
148148
zHost = mprintf("%s", g.urlName);
149149
}
150150
n = blob_size(&zCmd);
151151
blob_append(&zCmd, " ", 1);
152152
shell_escape(&zCmd, zHost);
153
- if( g.fSshFossilCmd && g.fSshFossilCmd[0] ){
153
+ if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
154154
blob_append(&zCmd, " ", 1);
155
- shell_escape(&zCmd, mprintf("%s", g.fSshFossilCmd));
155
+ shell_escape(&zCmd, mprintf("%s", g.zSshFossilCmd));
156156
}else{
157157
blob_append(&zCmd, " fossil", 7);
158158
}
159159
blob_append(&zCmd, " http", 5);
160160
if( g.urlPath && g.urlPath[0] ){
@@ -467,24 +467,32 @@
467467
}
468468
if( g.fSshTrace ) printf("Got line: [%s]\n", &transport.pBuf[iStart]);
469469
return &transport.pBuf[iStart];
470470
}
471471
472
+/*
473
+** Global transport shutdown
474
+*/
472475
void transport_global_shutdown(void){
473
- transport_ssh_close();
476
+ if( g.urlIsSsh ){
477
+ transport_ssh_close();
478
+ }
474479
if( g.urlIsHttps ){
475480
#ifdef FOSSIL_ENABLE_SSL
476481
ssl_global_shutdown();
477482
#endif
478483
}else{
479484
socket_global_shutdown();
480485
}
481486
}
482487
488
+/*
489
+** Close SSH transport.
490
+*/
483491
void transport_ssh_close(void){
484
- if( g.urlIsSsh && sshPid ){
492
+ if( sshPid ){
485493
/*printf("Closing SSH tunnel: ");*/
486494
fflush(stdout);
487495
pclose2(sshIn, sshOut, sshPid);
488496
sshPid = 0;
489497
}
490498
}
491499
--- src/http_transport.c
+++ src/http_transport.c
@@ -129,16 +129,16 @@
129 /* Only win32 (and specifically PLINK.EXE) support the -pw option */
130 if( g.urlPasswd && g.urlPasswd[0] ){
131 Blob pw;
132 blob_zero(&pw);
133 if( g.urlPasswd[0]=='*' ){
134 char *zPrompt;
135 zPrompt = mprintf("Password for [%s]: ", zHost);
136 prompt_for_password(zPrompt, &pw, 0);
137 free(zPrompt);
138 }else{
139 blob_init(&pw, g.urlPasswd, -1);
140 }
141 blob_append(&zCmd, " -pw ", -1);
142 shell_escape(&zCmd, blob_str(&pw));
143 blob_reset(&pw);
144 fossil_print(" -pw ********"); /* Do not show the password text */
@@ -148,13 +148,13 @@
148 zHost = mprintf("%s", g.urlName);
149 }
150 n = blob_size(&zCmd);
151 blob_append(&zCmd, " ", 1);
152 shell_escape(&zCmd, zHost);
153 if( g.fSshFossilCmd && g.fSshFossilCmd[0] ){
154 blob_append(&zCmd, " ", 1);
155 shell_escape(&zCmd, mprintf("%s", g.fSshFossilCmd));
156 }else{
157 blob_append(&zCmd, " fossil", 7);
158 }
159 blob_append(&zCmd, " http", 5);
160 if( g.urlPath && g.urlPath[0] ){
@@ -467,24 +467,32 @@
467 }
468 if( g.fSshTrace ) printf("Got line: [%s]\n", &transport.pBuf[iStart]);
469 return &transport.pBuf[iStart];
470 }
471
 
 
 
472 void transport_global_shutdown(void){
473 transport_ssh_close();
 
 
474 if( g.urlIsHttps ){
475 #ifdef FOSSIL_ENABLE_SSL
476 ssl_global_shutdown();
477 #endif
478 }else{
479 socket_global_shutdown();
480 }
481 }
482
 
 
 
483 void transport_ssh_close(void){
484 if( g.urlIsSsh && sshPid ){
485 /*printf("Closing SSH tunnel: ");*/
486 fflush(stdout);
487 pclose2(sshIn, sshOut, sshPid);
488 sshPid = 0;
489 }
490 }
491
--- src/http_transport.c
+++ src/http_transport.c
@@ -129,16 +129,16 @@
129 /* Only win32 (and specifically PLINK.EXE) support the -pw option */
130 if( g.urlPasswd && g.urlPasswd[0] ){
131 Blob pw;
132 blob_zero(&pw);
133 if( g.urlPasswd[0]=='*' ){
134 char *zPrompt;
135 zPrompt = mprintf("Password for [%s]: ", zHost);
136 prompt_for_password(zPrompt, &pw, 0);
137 free(zPrompt);
138 }else{
139 blob_init(&pw, g.urlPasswd, -1);
140 }
141 blob_append(&zCmd, " -pw ", -1);
142 shell_escape(&zCmd, blob_str(&pw));
143 blob_reset(&pw);
144 fossil_print(" -pw ********"); /* Do not show the password text */
@@ -148,13 +148,13 @@
148 zHost = mprintf("%s", g.urlName);
149 }
150 n = blob_size(&zCmd);
151 blob_append(&zCmd, " ", 1);
152 shell_escape(&zCmd, zHost);
153 if( g.zSshFossilCmd && g.zSshFossilCmd[0] ){
154 blob_append(&zCmd, " ", 1);
155 shell_escape(&zCmd, mprintf("%s", g.zSshFossilCmd));
156 }else{
157 blob_append(&zCmd, " fossil", 7);
158 }
159 blob_append(&zCmd, " http", 5);
160 if( g.urlPath && g.urlPath[0] ){
@@ -467,24 +467,32 @@
467 }
468 if( g.fSshTrace ) printf("Got line: [%s]\n", &transport.pBuf[iStart]);
469 return &transport.pBuf[iStart];
470 }
471
472 /*
473 ** Global transport shutdown
474 */
475 void transport_global_shutdown(void){
476 if( g.urlIsSsh ){
477 transport_ssh_close();
478 }
479 if( g.urlIsHttps ){
480 #ifdef FOSSIL_ENABLE_SSL
481 ssl_global_shutdown();
482 #endif
483 }else{
484 socket_global_shutdown();
485 }
486 }
487
488 /*
489 ** Close SSH transport.
490 */
491 void transport_ssh_close(void){
492 if( sshPid ){
493 /*printf("Closing SSH tunnel: ");*/
494 fflush(stdout);
495 pclose2(sshIn, sshOut, sshPid);
496 sshPid = 0;
497 }
498 }
499
+4 -4
--- src/main.c
+++ src/main.c
@@ -134,12 +134,12 @@
134134
int fSqlPrint; /* True if -sqlprint flag is present */
135135
int fQuiet; /* True if -quiet flag is present */
136136
int fHttpTrace; /* Trace outbound HTTP requests */
137137
int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138138
int fSshTrace; /* Trace the SSH setup traffic */
139
- char *fSshFossilCmd; /* Path to remoe fossil command for SSH */
140
- char *fSshCmd; /* SSH command string */
139
+ char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
140
+ char *zSshCmd; /* SSH command string */
141141
int fNoSync; /* Do not do an autosync ever. --nosync */
142142
char *zPath; /* Name of webpage being served */
143143
char *zExtra; /* Extra path information past the webpage name */
144144
char *zBaseURL; /* Full text of the URL being served */
145145
char *zTop; /* Parent directory of zPath */
@@ -578,12 +578,12 @@
578578
g.fQuiet = find_option("quiet", 0, 0)!=0;
579579
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
580580
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
581581
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
582582
g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
583
- g.fSshFossilCmd = 0;
584
- g.fSshCmd = 0;
583
+ g.zSshFossilCmd = 0;
584
+ g.zSshCmd = 0;
585585
if( g.fSqlTrace ) g.fSqlStats = 1;
586586
g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
587587
g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
588588
g.zLogin = find_option("user", "U", 1);
589589
g.zSSLIdentity = find_option("ssl-identity", 0, 1);
590590
--- src/main.c
+++ src/main.c
@@ -134,12 +134,12 @@
134 int fSqlPrint; /* True if -sqlprint flag is present */
135 int fQuiet; /* True if -quiet flag is present */
136 int fHttpTrace; /* Trace outbound HTTP requests */
137 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138 int fSshTrace; /* Trace the SSH setup traffic */
139 char *fSshFossilCmd; /* Path to remoe fossil command for SSH */
140 char *fSshCmd; /* SSH command string */
141 int fNoSync; /* Do not do an autosync ever. --nosync */
142 char *zPath; /* Name of webpage being served */
143 char *zExtra; /* Extra path information past the webpage name */
144 char *zBaseURL; /* Full text of the URL being served */
145 char *zTop; /* Parent directory of zPath */
@@ -578,12 +578,12 @@
578 g.fQuiet = find_option("quiet", 0, 0)!=0;
579 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
580 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
581 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
582 g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
583 g.fSshFossilCmd = 0;
584 g.fSshCmd = 0;
585 if( g.fSqlTrace ) g.fSqlStats = 1;
586 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
587 g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
588 g.zLogin = find_option("user", "U", 1);
589 g.zSSLIdentity = find_option("ssl-identity", 0, 1);
590
--- src/main.c
+++ src/main.c
@@ -134,12 +134,12 @@
134 int fSqlPrint; /* True if -sqlprint flag is present */
135 int fQuiet; /* True if -quiet flag is present */
136 int fHttpTrace; /* Trace outbound HTTP requests */
137 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
138 int fSshTrace; /* Trace the SSH setup traffic */
139 char *zSshFossilCmd; /* Path to remoe fossil command for SSH */
140 char *zSshCmd; /* SSH command string */
141 int fNoSync; /* Do not do an autosync ever. --nosync */
142 char *zPath; /* Name of webpage being served */
143 char *zExtra; /* Extra path information past the webpage name */
144 char *zBaseURL; /* Full text of the URL being served */
145 char *zTop; /* Parent directory of zPath */
@@ -578,12 +578,12 @@
578 g.fQuiet = find_option("quiet", 0, 0)!=0;
579 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
580 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
581 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
582 g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
583 g.zSshFossilCmd = 0;
584 g.zSshCmd = 0;
585 if( g.fSqlTrace ) g.fSqlStats = 1;
586 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
587 g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
588 g.zLogin = find_option("user", "U", 1);
589 g.zSSLIdentity = find_option("ssl-identity", 0, 1);
590

Keyboard Shortcuts

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