1 /*
2  * gvars.c -- global variables
3  *
4  * Yet Another FTP Client
5  * Copyright (C) 1998-2001, Martin Hedenfalk <mhe@stacken.kth.se>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version. See COPYING for more details.
11  */
12 
13 #include "syshdr.h"
14 #include "ftp/ftp.h"
15 #include "libmhe/linklist.h"
16 #include "stats.h"
17 
18 /* time (in seconds) before a cached directory times out, 0 == never */
19 int gvCacheTimeout = 0;
20 
21 /* list of Ftp objects */
22 list *gvFtpList = 0;
23 
24 /* pointer to an Ftp item in gvFtpList */
25 listitem *gvCurrentFtp = 0;
26 
27 FILE *gvLogfp = 0;
28 
29 char *gvWorkingDirectory = 0;
30 
31 /* try to login automagically */
32 bool gvAutologin = true;
33 
34 /* do reverse DNS lookups? */
35 bool gvReverseDNS = true;
36 
37 /* add ... while waiting for a completion? */
38 bool gvWaitingDots = true;
39 
40 /* various ssh options like -C */
41 char *gvSSHOptions = 0;
42 
43 /* try to use scp */
44 bool gvSSHTrySCP = true;
45 
46 /* automatically reconnect on connection timeout */
47 bool gvAutoReconnect = true;
48 
49 /* issue a SYST command upon login */
50 bool gvStartupSyst = false;
51 
52 /* use tab completion for remote files */
53 bool gvRemoteCompletion = true;
54 
55 /* quit program when Ctrl-D is pressed */
56 bool gvQuitOnEOF = true;
57 
58 /* default security mechanism to use */
59 list *gvDefaultMechanism = 0;  /* list of (char *) */
60 
61 char *gvXtermTitle1 = 0;
62 char *gvXtermTitle2 = 0;
63 char *gvXtermTitle3 = 0;
64 char *gvXtermTitleTerms = 0;
65 char *gvTerm = 0;
66 
67 /* password used for anonymous logins */
68 char *gvAnonPasswd = 0;
69 
70 /* name of local host */
71 char *gvLocalHost = 0;
72 
73 /* not connected */
74 char *gvPrompt1;
75 /* connected but not logged in */
76 char *gvPrompt2;
77 /* logged in */
78 char *gvPrompt3;
79 
80 /* beep if didn't complete within gvLongCommandTime seconds */
81 bool gvBeepLongCommand = true;
82 /* number of seconds for command to be 'long' */
83 int gvLongCommandTime = 30;
84 
85 bool gvSighupReceived = false;
86 bool gvInTransfer = false;
87 bool gvInterrupted = false;
88 
89 /* bookmark list */
90 list *gvBookmarks = 0;      /* list of url_t's */
91 url_t *gvDefaultUrl = 0;
92 url_t *gvLocalUrl = 0;
93 
94 list *gvLocalTagList = 0; /* list of char* */
95 
96 /* default transfer type, binary (image) or ascii */
97 transfer_mode_t gvDefaultType = tmBinary;
98 
99 /* used by bookmark --edit */
100 char *gvEditor = 0;
101 
102 /* name of user running yafc */
103 char *gvUsername = 0;
104 
105 /* print what yafc is doing in environment string
106  * (seen when issuing a ps)
107  */
108 bool gvUseEnvString = true;
109 
110 /* list of aliases */
111 list *gvAliases = 0;
112 
113 /* list of shell-glob-format filemasks to transfer in ascii mode */
114 list *gvAsciiMasks = 0;  /* list of (char *) */
115 
116 /* list of shell-glob-format filemasks to transfer before other files */
117 list *gvTransferFirstMasks = 0;  /* list of (char *) */
118 
119 /* list of shell-glob-format filemasks to never transfer */
120 list *gvIgnoreMasks = 0;  /* list of (char *) */
121 
122 bool gvUseHistory = true;
123 int gvHistoryMax = 128;
124 
125 char *gvLocalHomeDir = 0;
126 char *gvLocalPrevDir = 0;
127 char *gvHistoryFile = 0;
128 
129 bool gvVerbose = false;
130 bool gvDebug = false;
131 bool gvTrace = false;
132 bool gvPasvmode = true;
133 bool gvReadNetrc = false;
134 
135 int gvAutoBookmark = 1; /* 0 = no, 1 = yes, 2 = ask */
136 int gvAutoBookmarkUpdate = 1; /* 0 = no, 1 = yes, 2 = ask */
137 bool gvAutoBookmarkSilent = false;
138 bool gvAutoBookmarkSavePasswd = false;
139 
140 int gvLoadTaglist = 2;  /* 0 = no, 1 = yes, 2 = ask */
141 
142 bool gvTilde = true;
143 
144 /* seconds to wait before attempting to re-connect */
145 int gvConnectWaitTime = 30;
146 /* number of times to try to re-connect */
147 unsigned int gvConnectAttempts = 10;
148 
149 unsigned int gvCommandTimeout = 42;
150 unsigned int gvConnectionTimeout = 30;
151 
152 /* mailaddress to send mail to when nohup transfer is finished */
153 char *gvNohupMailAddress = 0;
154 /* path to sendmail */
155 char *gvSendmailPath = 0;
156 
157 char *gvTransferBeginString = 0;
158 char *gvTransferString = 0;
159 char *gvTransferEndString = 0;
160 char *gvTransferXtermString = 0;
161 
162 Stats *gvStatsTransfer = 0;
163 int gvStatsThreshold = 20;
164 
165 int gvProxyType = 0;
166 url_t *gvProxyUrl = 0;
167 list *gvProxyExclude = 0;
168 
169 #ifdef HAVE_POSIX_SIGSETJMP
170 sigjmp_buf gvRestartJmp;
171 #else
172 jmp_buf gvRestartJmp;
173 #endif
174 bool gvJmpBufSet = false;
175 
gvars_destroy(void)176 void gvars_destroy(void)
177 {
178   free(gvEditor);
179   gvEditor = NULL;
180   free(gvAnonPasswd);
181   gvAnonPasswd = NULL;
182   free(gvPrompt1);
183   gvPrompt1 = NULL;
184   free(gvPrompt2);
185   gvPrompt2 = NULL;
186   free(gvPrompt3);
187   gvPrompt3 = NULL;
188   free(gvLocalHomeDir);
189   gvLocalHomeDir = NULL;
190   free(gvLocalPrevDir);
191   gvLocalPrevDir = NULL;
192   free(gvUsername);
193   gvUsername = NULL;
194   free(gvHistoryFile);
195   gvHistoryFile = NULL;
196   free(gvNohupMailAddress);
197   gvNohupMailAddress = NULL;
198   free(gvSendmailPath);
199   gvSendmailPath = NULL;
200   free(gvLocalHost);
201   gvLocalHost = NULL;
202   free(gvTransferBeginString);
203   gvTransferBeginString = NULL;
204   free(gvTransferString);
205   gvTransferString = NULL;
206   free(gvTransferEndString);
207   gvTransferEndString = NULL;
208   free(gvSSHOptions);
209   gvSSHOptions = NULL;
210   free(gvWorkingDirectory);
211   gvWorkingDirectory = NULL;
212   list_free(gvAsciiMasks);
213   gvAsciiMasks = NULL;
214   list_free(gvIgnoreMasks);
215   gvIgnoreMasks = NULL;
216   list_free(gvAliases);
217   gvAliases = NULL;
218   list_free(gvLocalTagList);
219   gvLocalTagList = NULL;
220   list_free(gvBookmarks);
221   gvBookmarks = NULL;
222   list_free(gvFtpList);
223   gvFtpList = NULL;
224   url_destroy(gvDefaultUrl);
225   gvDefaultUrl = NULL;
226   url_destroy(gvLocalUrl);
227   gvLocalUrl = NULL;
228   stats_destroy(gvStatsTransfer);
229   gvStatsTransfer = NULL;
230   free(gvTerm);
231   gvTerm = NULL;
232   free(gvXtermTitle1);
233   gvXtermTitle1 = NULL;
234   free(gvXtermTitle2);
235   gvXtermTitle2 = NULL;
236   free(gvXtermTitle3);
237   gvXtermTitle3 = NULL;
238   free(gvXtermTitleTerms);
239   gvXtermTitleTerms = NULL;
240   list_free(gvDefaultMechanism);
241   gvDefaultMechanism = NULL;
242   free(gvTransferXtermString);
243   gvTransferXtermString = NULL;
244   list_free(gvTransferFirstMasks);
245   gvTransferFirstMasks = NULL;
246   list_free(gvProxyExclude);
247   gvProxyExclude = NULL;
248 
249   if(gvLogfp)
250     fclose(gvLogfp);
251   gvLogfp = NULL;
252 }
253