ReactOS 0.4.15-dev-7918-g2a2556c
pref.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PrefOpt
 

Macros

#define kFirewallPrefFileName   "firewall"
 
#define kGlobalFirewallPrefFileName   "/etc/ncftp.firewall"
 
#define kGlobalFixedFirewallPrefFileName   "/etc/ncftp.firewall.fixed"
 
#define kGlobalPrefFileName   "/etc/ncftp.prefs_v3"
 
#define kGlobalFixedPrefFileName   "/etc/ncftp.prefs_v3.fixed"
 
#define kPrefFileName   "prefs_v3"
 
#define kPrefFileNameV2   "prefs"
 
#define kFirstFileName   "init_v3"
 
#define kOpenSelectedBookmarkFileName   "bm2open"
 
#define kPrefOptObselete   (-1)
 
#define kPrefOptInvisible   0
 
#define kPrefOptVisible   1
 
#define PREFOBSELETE   (PrefProc) 0, kPrefOptObselete,
 

Typedefs

typedef void(* PrefProc) (int i, const char *const, FILE *const fp)
 
typedef struct PrefOpt PrefOpt
 

Functions

void SetAnonPass (int, const char *const, FILE *const)
 
void SetAutoAscii (int t, const char *const val, FILE *const fp)
 
void SetAutoResume (int, const char *const, FILE *const)
 
void SetAutoSaveChangesToExistingBookmarks (int t, const char *const val, FILE *const fp)
 
void SetConfirmClose (int, const char *const, FILE *const)
 
void SetConnTimeout (int, const char *const, FILE *const)
 
void SetCtrlTimeout (int, const char *const, FILE *const)
 
void SetLogSize (int t, const char *const val, FILE *const fp)
 
void SetNoAds (int t, const char *const val, FILE *const fp)
 
void SetOneTimeMessages (int t, const char *const val, FILE *const)
 
void SetPager (int, const char *const, FILE *const)
 
void SetPassive (int, const char *const, FILE *const)
 
void SetProgressMeter (int, const char *const, FILE *const)
 
void SetRedialDelay (int t, const char *const val, FILE *const fp)
 
void SetSavePasswords (int, const char *const, FILE *const)
 
void SetSOBufsize (int t, const char *const val, FILE *const fp)
 
void SetXferTimeout (int, const char *const, FILE *const)
 
void SetXtTitle (int, const char *const, FILE *const)
 
void Set (const char *const, const char *const)
 
void ProcessPrefsFile (FILE *const fp)
 
void LoadPrefs (void)
 
void InitPrefs (void)
 
void PostInitPrefs (void)
 
void SavePrefs (void)
 
void WriteDefaultFirewallPrefs (FILE *)
 
void ProcessFirewallPrefFile (FILE *)
 
void LoadFirewallPrefs (int)
 
void CheckForNewV3User (void)
 
int HasSeenOneTimeMessage (const char *const msg)
 
void SetSeenOneTimeMessage (const char *const msg)
 
int OneTimeMessage (const char *const msg)
 

Macro Definition Documentation

◆ kFirewallPrefFileName

#define kFirewallPrefFileName   "firewall"

Definition at line 18 of file pref.h.

◆ kFirstFileName

#define kFirstFileName   "init_v3"

Definition at line 25 of file pref.h.

◆ kGlobalFirewallPrefFileName

#define kGlobalFirewallPrefFileName   "/etc/ncftp.firewall"

Definition at line 19 of file pref.h.

◆ kGlobalFixedFirewallPrefFileName

#define kGlobalFixedFirewallPrefFileName   "/etc/ncftp.firewall.fixed"

Definition at line 20 of file pref.h.

◆ kGlobalFixedPrefFileName

#define kGlobalFixedPrefFileName   "/etc/ncftp.prefs_v3.fixed"

Definition at line 22 of file pref.h.

◆ kGlobalPrefFileName

#define kGlobalPrefFileName   "/etc/ncftp.prefs_v3"

Definition at line 21 of file pref.h.

◆ kOpenSelectedBookmarkFileName

#define kOpenSelectedBookmarkFileName   "bm2open"

Definition at line 28 of file pref.h.

◆ kPrefFileName

#define kPrefFileName   "prefs_v3"

Definition at line 23 of file pref.h.

◆ kPrefFileNameV2

#define kPrefFileNameV2   "prefs"

Definition at line 24 of file pref.h.

◆ kPrefOptInvisible

#define kPrefOptInvisible   0

Definition at line 38 of file pref.h.

◆ kPrefOptObselete

#define kPrefOptObselete   (-1)

Definition at line 37 of file pref.h.

◆ kPrefOptVisible

#define kPrefOptVisible   1

Definition at line 39 of file pref.h.

◆ PREFOBSELETE

#define PREFOBSELETE   (PrefProc) 0, kPrefOptObselete,

Definition at line 41 of file pref.h.

Typedef Documentation

◆ PrefOpt

◆ PrefProc

typedef void(* PrefProc) (int i, const char *const, FILE *const fp)

Definition at line 30 of file pref.h.

Function Documentation

◆ CheckForNewV3User()

void CheckForNewV3User ( void  )

Definition at line 738 of file pref.c.

739{
740 FILE *fp;
741 struct stat st;
742 char pathName[256];
743 char line[256];
744
745 gNumProgramRuns = 0;
746
747 /* Don't create in root directory. */
748 if (gOurDirectoryPath[0] != '\0') {
749 (void) OurDirectoryPath(pathName, sizeof(pathName), kFirstFileName);
750
751 if ((stat(pathName, &st) < 0) && (errno == ENOENT)) {
752 gNumProgramRuns = 1;
753 gPrefsDirty++;
754
755 /* Create a blank one. */
756 fp = fopen(pathName, FOPEN_WRITE_TEXT);
757 if (fp == NULL)
758 return;
759 (void) fprintf(fp, "# NcFTP uses this file to mark that you have run it before, and that you do not\n# need any special first-time instructions or setup.\n#\nruns=%d\n", gNumProgramRuns);
760 (void) fclose(fp);
761 } else {
762 fp = fopen(pathName, FOPEN_READ_TEXT);
763 if (fp != NULL) {
764 while (fgets(line, sizeof(line) - 1, fp) != NULL) {
765 if (strncmp(line, "runs=", 5) == 0) {
766 (void) sscanf(line + 5, "%d",
768 break;
769 }
770 }
771 (void) fclose(fp);
772 }
773
774 /* Increment the count of program runs. */
776 if (gNumProgramRuns == 1)
777 gPrefsDirty++;
778
779 /* Race condition between other ncftp processes.
780 * This isn't a big deal because this counter isn't
781 * critical.
782 */
783
784 fp = fopen(pathName, FOPEN_WRITE_TEXT);
785 if (fp != NULL) {
786 (void) fprintf(fp, "# NcFTP uses this file to mark that you have run it before, and that you do not\n# need any special first-time instructions or setup.\n#\nruns=%d\n", gNumProgramRuns);
787 (void) fclose(fp);
788 }
789 }
790 }
791} /* CheckForNewV3User */
#define ENOENT
Definition: acclib.h:79
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define stat
Definition: acwin.h:99
#define NULL
Definition: types.h:112
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
char * OurDirectoryPath(char *const dst, const size_t siz, const char *const fname)
Definition: util.c:486
#define FOPEN_READ_TEXT
Definition: syshdrs.h:82
#define FOPEN_WRITE_TEXT
Definition: syshdrs.h:83
int gPrefsDirty
Definition: pref.c:67
int gNumProgramRuns
Definition: preffw.c:14
char gOurDirectoryPath[]
Definition: util.c:17
#define kFirstFileName
Definition: pref.h:25
#define errno
Definition: errno.h:18
Definition: parser.c:49
Definition: stat.h:55

Referenced by PreInit().

◆ HasSeenOneTimeMessage()

int HasSeenOneTimeMessage ( const char *const  msg)

Definition at line 477 of file pref.c.

478{
479 char buf[256];
480 char *a, *b;
481
483 for (a = buf; (b = strtok(a, ",\n")) != NULL; a = NULL) {
484 if (strcmp(msg, b) == 0)
485 return (1);
486 }
487 return (0);
488} /* HasSeenOneTimeMessage */
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
#define msg(x)
Definition: auth_time.c:54
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char gOneTimeMessagesSeen[256]
Definition: pref.c:47

Referenced by OneTimeMessage().

◆ InitPrefs()

void InitPrefs ( void  )

Definition at line 616 of file pref.c.

617{
618 char *tok1;
619
620 /* Set default values. */
621 gPager[0] = '\0';
623 gXferTimeout = 3600;
624 gConnTimeout = 20;
625 gCtrlTimeout = 135;
628 gAutoResume = 0;
629 gSOBufsize = 0;
630 gMaxLogSize = 10240;
631 gConfirmClose = 1;
634 STRNCPY(gAutoAscii, "|.txt|.asc|.html|.htm|.css|.xml|.ini|.sh|.pl|.hqx|.cfg|.c|.h|.cpp|.hpp|.bat|.m3u|.pls|");
635
636 /* PLEASE do not change the default from 0, and please
637 * don't hack out the portion in main.c which displays
638 * a plug every 7th time you run the program. This is
639 * not much to ask for all the work I've put into this
640 * since 1991.
641 */
643
644#if (defined(WIN32) || defined(_WINDOWS)) && defined(_CONSOLE)
646#else
648#endif
649
650 gSavePasswords = -1;
651#ifdef ncftp
653#endif
654
655 tok1 = getenv("PAGER");
656 if ((tok1 != NULL) && (tok1[0] != '\0')) {
657#ifdef HAVE_STRSTR
658 /* I prefer "less", but it doesn't work well here
659 * because it clears the screen after it finishes,
660 * and the default at EOF is to stay in less
661 * instead of exiting.
662 */
663 if (strstr(gPager, "less") != NULL)
664 (void) STRNCPY(gPager, "more");
665 else
666 (void) STRNCPY(gPager, tok1);
667#else
668 (void) STRNCPY(gPager, tok1);
669#endif
670 } else {
671 (void) STRNCPY(gPager, "more");
672 }
673} /* InitPrefs */
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define STRNCPY(dst, src, n)
Definition: rdesktop.h:168
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
FTPProgressMeterProc gProgressMeter
void PrStatBar(const FTPCIPtr cip, int mode)
Definition: progress.c:203
#define kDefaultRedialDelay
Definition: ncftp.h:342
#define kFallBackToSendPortMode
Definition: ncftp.h:297
int gSOBufsize
Definition: pref.c:50
FTPConnectionInfo gConn
Definition: main.c:37
char gPager[128]
Definition: pref.c:21
int gAutoResume
Definition: pref.c:30
int gMaySetXtermTitle
Definition: pref.c:41
int gConnTimeout
Definition: pref.c:24
int gConfirmClose
Definition: pref.c:33
int gSavePasswords
Definition: pref.c:39
int gMaxLogSize
Definition: pref.c:53
int gDataPortMode
Definition: preffw.c:26
int gAutoSaveChangesToExistingBookmarks
Definition: pref.c:36
char gAutoAscii[512]
Definition: pref.c:56
int gXferTimeout
Definition: pref.c:24
int gRedialDelay
Definition: pref.c:44
int gDoNotDisplayAds
Definition: pref.c:64
int gCtrlTimeout
Definition: pref.c:24
#define memset(x, y, z)
Definition: compat.h:39
int dataPortMode
Definition: ncftp.h:152

Referenced by PreInit().

◆ LoadFirewallPrefs()

void LoadFirewallPrefs ( int  forceReload)

Definition at line 268 of file preffw.c.

269{
270 FILE *fp, *fp2;
271 char pathName[256];
272 char *cp;
273 int userFile = 0;
274 int sysFile = 0;
275
276 if ((gFirewallPrefsLoaded != 0) && (forceReload == 0))
277 return;
279
280 if (gOurDirectoryPath[0] == '\0')
281 return; /* Don't create in root directory. */
282 (void) OurDirectoryPath(pathName, sizeof(pathName), kFirewallPrefFileName);
283
284 /* Set default values. */
286 gFirewallPort = 0;
287 gFirewallHost[0] = '\0';
288 gFirewallUser[0] = '\0';
289 gFirewallPass[0] = '\0';
290 gFirewallExceptionList[0] = '\0';
291
293 if (fp2 != NULL) {
294 /* Initialize to system-wide defaults. */
296 (void) fclose(fp2);
297 sysFile++;
298 }
299
300 fp = fopen(pathName, FOPEN_READ_TEXT);
301 if (fp != NULL) {
302 /* Do user's firewall file. */
304 (void) fclose(fp);
305 userFile = 1;
306 }
307
309 if (fp2 != NULL) {
310 /* Override with system-wide settings. */
312 (void) fclose(fp2);
313 sysFile++;
314 }
315
316 if ((userFile == 0) && (sysFile == 0)) {
317 /* Create a blank one, if
318 * there were no system-wide files.
319 */
320 fp = fopen(pathName, FOPEN_WRITE_TEXT);
321 if (fp != NULL) {
323 (void) fclose(fp);
324 (void) _chmod(pathName, 00600);
325 gNumProgramRuns = 1;
326 }
327 }
328
329 if (gFirewallExceptionList[0] == '\0') {
331 cp = strchr(gLib.ourHostName, '.');
332
333 if (cp != NULL) {
335 (void) STRNCAT(gFirewallExceptionList, ",localdomain");
336 }
337 }
338} /* LoadFirewallPrefs */
#define STRNCAT(d, s)
Definition: Strn.h:48
char * strchr(const char *String, int ch)
Definition: utclib.c:501
POINT cp
Definition: magnifier.c:59
#define kFirewallNotInUse
Definition: ncftp.h:388
void FTPInitializeOurHostName(const FTPLIPtr)
Definition: open.c:63
#define kGlobalFixedFirewallPrefFileName
Definition: pref.h:20
#define kFirewallPrefFileName
Definition: pref.h:18
#define kGlobalFirewallPrefFileName
Definition: pref.h:19
unsigned int gFirewallPort
Definition: preffw.c:22
char gFirewallHost[64]
Definition: preffw.c:18
char gFirewallExceptionList[256]
Definition: preffw.c:21
FTPLibraryInfo gLib
Definition: main.c:36
int gNumProgramRuns
Definition: preffw.c:14
char gFirewallUser[32]
Definition: preffw.c:19
char gFirewallPass[32]
Definition: preffw.c:20
int gFirewallPrefsLoaded
Definition: preffw.c:23
int gFirewallType
Definition: preffw.c:17
void ProcessFirewallPrefFile(FILE *fp)
Definition: preffw.c:213
char gOurDirectoryPath[]
Definition: util.c:17
void WriteDefaultFirewallPrefs(FILE *fp)
Definition: preffw.c:39
_Check_return_ _CRTIMP int __cdecl _chmod(_In_z_ const char *_Filename, _In_ int _Mode)
char ourHostName[64]
Definition: ncftp.h:118

Referenced by main(), and PreInit().

◆ LoadPrefs()

void LoadPrefs ( void  )

Definition at line 555 of file pref.c.

556{
557 FILE *fp;
558 char pathName[256];
559
560 /* As with the firewall preference file, there can be
561 * site-wide preferences and user-specific preferences.
562 * The user pref file is of course kept in the user's
563 * NcFTP home directory.
564 *
565 * The way we do this is we first look for a global
566 * preferences file. We then process the user's pref
567 * file, which could override the global prefs. Finally,
568 * we open a "global fixed" prefs file which then
569 * overrides anything the user may have done.
570 */
571
573 if (fp != NULL) {
574 /* Opened the global (but user-overridable) prefs file. */
576 (void) fclose(fp);
577 }
578
579 if (gOurDirectoryPath[0] != '\0') {
580 (void) OurDirectoryPath(pathName, sizeof(pathName), kPrefFileName);
581
582 fp = fopen(pathName, FOPEN_READ_TEXT);
583 if (fp == NULL) {
584 /* Try loading the version 2 prefs.
585 * There will be options we no longer recognize, but
586 * we'd like to import the prefs when possible.
587 */
588 gPrefsDirty++;
589 (void) OurDirectoryPath(pathName, sizeof(pathName), kPrefFileNameV2);
590 fp = fopen(pathName, FOPEN_READ_TEXT);
591 }
592
593 if (fp == NULL) {
594 /* Write a new one when we're done. */
595 gPrefsDirty++;
596 } else {
597 /* Opened the preferences file. */
599 (void) fclose(fp);
600 }
601 }
602
604 if (fp != NULL) {
605 /* Opened the global (and not overridable) prefs file. */
607 (void) fclose(fp);
608 }
609} /* LoadPrefs */
void ProcessPrefsFile(FILE *const fp)
Definition: pref.c:520
#define kGlobalFixedPrefFileName
Definition: pref.h:22
#define kPrefFileNameV2
Definition: pref.h:24
#define kPrefFileName
Definition: pref.h:23
#define kGlobalPrefFileName
Definition: pref.h:21

Referenced by PreInit().

◆ OneTimeMessage()

int OneTimeMessage ( const char *const  msg)

Definition at line 508 of file pref.c.

509{
511 return (0);
513 return (1);
514} /* OneTimeMessage */
void SetSeenOneTimeMessage(const char *const msg)
Definition: pref.c:494
int HasSeenOneTimeMessage(const char *const msg)
Definition: pref.c:477

Referenced by NcFTPConfirmResumeDownloadProc(), NcFTPConfirmResumeUploadProc(), and PrSizeAndRateMeter().

◆ PostInitPrefs()

void PostInitPrefs ( void  )

Definition at line 680 of file pref.c.

681{
682 if (gLib.defaultAnonPassword[0] == '\0') {
684 gPrefsDirty++;
685 }
686 if (gFwDataPortMode >= 0)
688} /* PostInitPrefs */
void FTPInitializeAnonPassword(const FTPLIPtr)
Definition: open.c:81
FTPLibraryInfo gLib
Definition: main.c:36
int gFwDataPortMode
Definition: pref.c:27
char defaultAnonPassword[80]
Definition: ncftp.h:121

Referenced by PostInit().

◆ ProcessFirewallPrefFile()

void ProcessFirewallPrefFile ( FILE fp)

Definition at line 213 of file preffw.c.

214{
215 char line[256];
216 char *tok1, *tok2;
217 int n;
218
219 /* Opened the firewall preferences file. */
220 line[sizeof(line) - 1] = '\0';
221 while (fgets(line, sizeof(line) - 1, fp) != NULL) {
222 tok1 = strtok(line, " =\t\r\n");
223 if ((tok1 == NULL) || (tok1[0] == '#'))
224 continue;
225 tok2 = strtok(NULL, "\r\n");
226 if (tok2 == NULL)
227 continue;
228 if (ISTREQ(tok1, "firewall-type")) {
229 n = atoi(tok2);
230 if ((n > 0) && (n <= kFirewallLastType))
232 } else if (ISTREQ(tok1, "firewall-host")) {
233 (void) STRNCPY(gFirewallHost, tok2);
234 } else if (ISTREQ(tok1, "firewall-port")) {
235 n = atoi(tok2);
236 if (n > 0)
237 gFirewallPort = (unsigned int) n;
238 } else if (ISTREQ(tok1, "firewall-user")) {
239 (void) STRNCPY(gFirewallUser, tok2);
240 } else if (ISTREQ(tok1, "firewall-pass")) {
241 (void) STRNCPY(gFirewallPass, tok2);
242 } else if (ISTREQ(tok1, "firewall-password")) {
243 (void) STRNCPY(gFirewallPass, tok2);
244 } else if (ISTREQ(tok1, "firewall-exception-list")) {
246 } else if (ISTREQ(tok1, "passive")) {
247 if (ISTREQ(tok2, "optional")) {
249 } else if (ISTREQ(tok2, "on")) {
251 } else if (ISTREQ(tok2, "off")) {
253 } else if ((int) isdigit(tok2[0])) {
255 }
256 }
257 }
258} /* ProcessFirewallPrefFile */
#define isdigit(c)
Definition: acclib.h:68
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLdouble n
Definition: glext.h:7729
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define ISTREQ(a, b)
Definition: util.h:33
#define kSendPortMode
Definition: ncftp.h:295
#define kPassiveMode
Definition: ncftp.h:296
#define kFirewallLastType
Definition: ncftp.h:396
int gDataPortMode
Definition: preffw.c:26
int gFwDataPortMode
Definition: preffw.c:31

Referenced by LoadFirewallPrefs().

◆ ProcessPrefsFile()

void ProcessPrefsFile ( FILE *const  fp)

Definition at line 520 of file pref.c.

521{
522 char line[1024];
523 char *tok1, *tok2;
524 int t;
525
526 line[sizeof(line) - 1] = '\0';
527 while (fgets(line, sizeof(line) - 1, fp) != NULL) {
528 tok1 = strtok(line, " =\t\r\n");
529 if ((tok1 == NULL) || (tok1[0] == '#'))
530 continue;
531 tok2 = strtok(NULL, "\r\n");
532 if (tok2 == NULL)
533 continue;
534
535 for (t=0; t<gNumPrefOpts; t++) {
536 if (ISTREQ(tok1, gPrefOpts[t].varname)) {
537 if (gPrefOpts[t].visible == kPrefOptObselete) {
538 /* Probably converting an
539 * old 2.4.2 file.
540 */
541 gPrefsDirty++;
542 } else if (gPrefOpts[t].proc != (PrefProc) 0) {
543 (*gPrefOpts[t].proc)(t, tok2, NULL);
544 }
545 }
546 }
547 }
548} /* ProcessPrefsFile */
GLdouble GLdouble t
Definition: gl.h:2047
static HANDLE proc()
Definition: pdb.c:34
PrefOpt gPrefOpts[]
Definition: pref.c:73
int gNumPrefOpts
Definition: pref.c:113
void(* PrefProc)(int i, const char *const, FILE *const fp)
Definition: pref.h:30
#define kPrefOptObselete
Definition: pref.h:37
PrefProc proc
Definition: pref.h:33

Referenced by LoadPrefs().

◆ SavePrefs()

void SavePrefs ( void  )

Definition at line 695 of file pref.c.

696{
697 char pathName[256];
698 char pathName2[256];
699 char tName[32];
700 int t;
701 FILE *fp;
702
703 if (gPrefsDirty == 0)
704 return; /* Don't need to save -- no changes made. */
705
706 (void) OurDirectoryPath(pathName, sizeof(pathName), kPrefFileName);
707
708 (void) sprintf(tName, "tpref%06u.txt", (unsigned int) getpid());
709 (void) OurDirectoryPath(pathName2, sizeof(pathName2), tName);
710
711 fp = fopen(pathName2, FOPEN_WRITE_TEXT);
712 if (fp == NULL) {
713 perror("could not save preferences file");
714 } else {
715 (void) fprintf(fp, "%s", "# NcFTP 3 preferences file\n# This file is loaded and overwritten each time NcFTP is run.\n#\n");
716 for (t=0; t<gNumPrefOpts; t++) {
717 if (gPrefOpts[t].visible != kPrefOptObselete) {
718 (void) fprintf(fp, "%s=", gPrefOpts[t].varname);
719 (*gPrefOpts[t].proc)(t, NULL, fp);
720 (void) fprintf(fp, "\n");
721 }
722 }
723 (void) fclose(fp);
724 (void) unlink(pathName);
725 if (rename(pathName2, pathName) < 0) {
726 perror("could not finish saving preferences file");
727 (void) unlink(pathName2);
728 };
729 }
730} /* SavePrefs */
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
#define unlink
Definition: syshdrs.h:54
#define sprintf(buf, format,...)
Definition: sprintf.c:55
_Check_return_ int __cdecl rename(_In_z_ const char *_OldFilename, _In_z_ const char *_NewFilename)
#define getpid
Definition: wintirpc.h:52

Referenced by PostShell().

◆ Set()

void Set ( const char * const  tok1,
const char * const  tok2 
)

Definition at line 430 of file pref.c.

431{
432 int t;
433
434 if ((tok1 == NULL) || (ISTREQ(tok1, "all"))) {
435 /* Show all. */
436 for (t=0; t<gNumPrefOpts; t++) {
437 if (gPrefOpts[t].visible == kPrefOptVisible)
438 Show1(t);
439 }
440 } else if (tok2 == NULL) {
441 /* Show one. */
442 for (t=0; t<gNumPrefOpts; t++) {
443 if (ISTREQ(tok1, gPrefOpts[t].varname)) {
444 if (gPrefOpts[t].visible == kPrefOptObselete) {
445 (void) printf("The \"%s\" option is obselete or not implemented.\n", tok1);
446 } else {
447 Show1(t);
448 }
449 break;
450 }
451 }
452 if (t >= gNumPrefOpts) {
453 (void) printf("Unknown option \"%s\" -- try \"show all\" to list available options.\n", tok1);
454 }
455 } else {
456 /* Set one. */
457 for (t=0; t<gNumPrefOpts; t++) {
458 if (ISTREQ(tok1, gPrefOpts[t].varname)) {
459 if (gPrefOpts[t].visible == kPrefOptObselete) {
460 (void) printf("The \"%s\" option is obselete or not implemented.\n", tok1);
461 } else if (gPrefOpts[t].proc != (PrefProc) 0) {
462 (*gPrefOpts[t].proc)(t, tok2, NULL);
463 gPrefsDirty++;
464 }
465 break;
466 }
467 }
468 if (t >= gNumPrefOpts) {
469 (void) printf("Unknown option \"%s\" -- try \"show all\" to list available options.\n", tok1);
470 }
471 }
472} /* Set */
#define printf
Definition: freeldr.h:93
static void Show1(int t)
Definition: pref.c:415
#define kPrefOptVisible
Definition: pref.h:39

◆ SetAnonPass()

void SetAnonPass ( int  ,
const char * const  ,
FILE * const   
)

◆ SetAutoAscii()

void SetAutoAscii ( int  t,
const char *const  val,
FILE *const  fp 
)

◆ SetAutoResume()

void SetAutoResume ( int  ,
const char * const  ,
FILE * const   
)

◆ SetAutoSaveChangesToExistingBookmarks()

void SetAutoSaveChangesToExistingBookmarks ( int  t,
const char *const  val,
FILE *const  fp 
)

◆ SetConfirmClose()

void SetConfirmClose ( int  ,
const char * const  ,
FILE * const   
)

◆ SetConnTimeout()

void SetConnTimeout ( int  ,
const char * const  ,
FILE * const   
)

◆ SetCtrlTimeout()

void SetCtrlTimeout ( int  ,
const char * const  ,
FILE * const   
)

◆ SetLogSize()

void SetLogSize ( int  t,
const char *const  val,
FILE *const  fp 
)

◆ SetNoAds()

void SetNoAds ( int  t,
const char *const  val,
FILE *const  fp 
)

◆ SetOneTimeMessages()

void SetOneTimeMessages ( int  t,
const char *const  val,
FILE * const   
)

◆ SetPager()

void SetPager ( int  ,
const char * const  ,
FILE * const   
)

◆ SetPassive()

void SetPassive ( int  ,
const char * const  ,
FILE * const   
)

◆ SetProgressMeter()

void SetProgressMeter ( int  ,
const char * const  ,
FILE * const   
)

◆ SetRedialDelay()

void SetRedialDelay ( int  t,
const char *const  val,
FILE *const  fp 
)

◆ SetSavePasswords()

void SetSavePasswords ( int  ,
const char * const  ,
FILE * const   
)

◆ SetSeenOneTimeMessage()

void SetSeenOneTimeMessage ( const char *const  msg)

Definition at line 494 of file pref.c.

495{
496 gPrefsDirty++;
497 if (gOneTimeMessagesSeen[0] == '\0')
499 else {
502 }
503} /* SetSeenOneTimeMessage */

Referenced by OneTimeMessage().

◆ SetSOBufsize()

void SetSOBufsize ( int  t,
const char *const  val,
FILE *const  fp 
)

◆ SetXferTimeout()

void SetXferTimeout ( int  ,
const char * const  ,
FILE * const   
)

◆ SetXtTitle()

void SetXtTitle ( int  ,
const char * const  ,
FILE * const   
)

◆ WriteDefaultFirewallPrefs()

void WriteDefaultFirewallPrefs ( FILE fp)

Definition at line 39 of file preffw.c.

40{
41 char *cp;
42 time_t now;
43
45 cp = strchr(gLib.ourHostName, '.');
46
47 (void) fprintf(fp, "%s", "\
48# NcFTP firewall preferences\n\
49# ==========================\n\
50#\n\
51");
52
53 (void) fprintf(fp, "%s", "\
54# If you need to use a proxy for FTP, you can configure it below.\n\
55# If you do not need one, leave the ``firewall-type'' variable set\n\
56# to 0. Any line that does not begin with the ``#'' character is\n\
57# considered a configuration command line.\n\
58");
59 (void) fprintf(fp, "%s", "\
60#\n\
61# NOTE: NcFTP does NOT support HTTP proxies that do FTP, such as \"squid\"\n\
62# or Netscape Proxy Server. Why? Because you have to communicate with\n\
63# them using HTTP, and this is a FTP only program.\n\
64");
65 (void) fprintf(fp, "%s", "\
66#\n\
67# Types of firewalls:\n\
68# ------------------\n\
69#\n\
70# type 1: Connect to firewall host, but send \"USER user@real.host.name\"\n\
71#\n\
72");
73 (void) fprintf(fp, "%s", "\
74# type 2: Connect to firewall, login with \"USER fwuser\" and\n\
75# \"PASS fwpassword\", and then \"USER user@real.host.name\"\n\
76#\n\
77# type 3: Connect to and login to firewall, and then use\n\
78# \"SITE real.host.name\", followed by the regular USER and PASS.\n\
79#\n\
80");
81 (void) fprintf(fp, "%s", "\
82# type 4: Connect to and login to firewall, and then use\n\
83# \"OPEN real.host.name\", followed by the regular USER and PASS.\n\
84#\n\
85# type 5: Connect to firewall host, but send\n\
86# \"USER user@fwuser@real.host.name\" and\n\
87# \"PASS pass@fwpass\" to login.\n\
88#\n\
89");
90 (void) fprintf(fp, "%s", "\
91# type 6: Connect to firewall host, but send\n\
92# \"USER fwuser@real.host.name\" and\n\
93# \"PASS fwpass\" followed by a regular\n\
94# \"USER user\" and\n\
95# \"PASS pass\" to complete the login.\n\
96#\n\
97");
98 (void) fprintf(fp, "%s", "\
99# type 7: Connect to firewall host, but send\n\
100# \"USER user@real.host.name fwuser\" and\n\
101# \"PASS pass\" followed by\n\
102# \"ACCT fwpass\" to complete the login.\n\
103#\n\
104# type 0: Do NOT use a firewall (most users will choose this).\n\
105#\n\
106firewall-type=0\n\
107#\n\
108#\n\
109#\n\
110");
111 (void) fprintf(fp, "%s", "\
112# The ``firewall-host'' variable should be the IP address or hostname of\n\
113# your firewall server machine.\n\
114#\n\
115");
116
117 if (cp == NULL) {
118 (void) fprintf(fp, "firewall-host=firewall.domain.com\n");
119 } else {
120 (void) fprintf(fp, "firewall-host=firewall%s\n", cp);
121 }
122
123 (void) fprintf(fp, "%s", "\
124#\n\
125#\n\
126#\n\
127# The ``firewall-user'' variable tells NcFTP what to use as the user ID\n\
128# when it logs in to the firewall before connecting to the outside world.\n\
129#\n\
130");
131 (void) fprintf(fp, "firewall-user=%s\n", gUser);
132 (void) fprintf(fp, "%s", "\
133#\n\
134#\n\
135#\n\
136# The ``firewall-password'' variable is the password associated with\n\
137# the firewall-user ID. If you set this here, be sure to change the\n\
138# permissions on this file so that no one (except the superuser) can\n\
139# see your password. You may also leave this commented out, and then\n\
140# NcFTP will prompt you each time for the password.\n\
141");
142 (void) fprintf(fp, "%s", "\
143#\n\
144firewall-password=fwpass\n\
145#\n\
146#\n\
147#\n\
148# Your firewall may require you to connect to a non-standard port for\n\
149# outside FTP services, instead of the internet standard port number (21).\n\
150#\n\
151firewall-port=21\n\
152");
153 (void) fprintf(fp, "%s", "\
154#\n\
155#\n\
156#\n\
157# You probably do not want to FTP to the firewall for hosts on your own\n\
158# domain. You can set ``firewall-exception-list'' to a list of domains\n\
159# or hosts where the firewall should not be used. For example, if your\n\
160# domain was ``probe.net'' you could set this to ``.probe.net''.\n\
161#\n\
162");
163 (void) fprintf(fp, "%s", "\
164# If you leave this commented out, the default behavior is to attempt to\n\
165# lookup the current domain, and exclude hosts for it. Otherwise, set it\n\
166# to a list of comma-delimited domains or hostnames. The special token\n\
167# ``localdomain'' is used for unqualified hostnames, so if you want hosts\n\
168# without explicit domain names to avoid the firewall, be sure to include\n\
169# that in your list.\n\
170#\n\
171");
172
173 if (cp != NULL) {
174 (void) fprintf(fp, "firewall-exception-list=%s,localhost,localdomain\n", cp);
175 } else {
176 (void) fprintf(fp, "firewall-exception-list=.probe.net,localhost,foo.bar.com,localdomain\n");
177 }
178
179 (void) fprintf(fp, "%s", "\
180#\n\
181#\n\
182#\n\
183# You may also specify passive mode here. Normally this is set in the\n\
184# regular $HOME/.ncftp/prefs file. This must be set to one of\n\
185# \"on\", \"off\", or \"optional\", which mean always use PASV,\n\
186# always use PORT, and try PASV then PORT, respectively.\n\
187#\n\
188#passive=on\n");
189
190 time(&now);
191 (void) fprintf(fp, "\
192#\n\
193#\n\
194#\n\
195# NOTE: This file was created for you on %s\
196# by NcFTP %.5s. Removing this file will cause the next run of NcFTP\n\
197# to generate a new one, possibly with more configurable options.\n",
198 ctime(&now),
199 gVersion + 11);
200 (void) fprintf(fp, "\
201#\n\
202# ALSO: A %s file, if present, is processed before this file,\n\
203# and a %s file, if present, is processed after.\n",
206 );
207} /* CreateDefaultFirewallPrefs */
__kernel_time_t time_t
Definition: linux.h:252
time_t now
Definition: finger.c:65
__u16 ctime
Definition: mkdosfs.c:4
__u16 time
Definition: mkdosfs.c:8
char gUser[]
Definition: preffw.c:34
char gVersion[]
Definition: preffw.c:34

Referenced by DumpFirewallPrefsTemplate(), and LoadFirewallPrefs().