summaryrefslogtreecommitdiffstats
path: root/usr.bin/ncftp/tips.c
blob: 30330b6138c72ec2cdb4352046f60afeec289282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* tips.c */

/*  $RCSfile: tips.c,v $
 *  $Revision: 14020.11 $
 *  $Date: 93/05/21 05:44:39 $
 */

#include "sys.h"

#ifndef NO_TIPS

#include "util.h"

/* Make sure that the indentations are spaces, not tabs.
 * Try newform -i-4 < tips.c > tips.c.new
 *
 * Always add new tips right above the last one.
 */

static char *tiplist[] = {
    "Have you tried typing 'open' by itself lately?",

    "If you don't want a .ncrecent file in your home directory, put the \n\
     command '#unset recent-list' in your .ncftprc file.",

    "pseudo-filename-completion is supported in some commands.  To use it,\n\
     use a wildcard expression that will match exactly one file.  I.e., if you\n\
     want to fetch obnoxiouslylongfilename.zip, try 'get obn*.zip.'  Note that\n\
     you can't use the cd command with this feature (yet).",

    "You don't need to type the exact site name with open.  If a site is in\n\
     your .ncftprc or the recent-file (.ncrecent), just type a unique\n\
     abbreviation (substring really).   I.e. 'open wuar' if you have the site\n\
     wuarchive.wustl.edu in your rc or recent-file.",

    "You can put set commands in your .ncftprc, by adding lines such\n\
     as '#set local-dir /usr/tmp' to the file, which will be run at startup.",

    "Use the .ncftprc file to set variables at startup and to add sites that \n\
     need init macros.\n\
     Sample .ncftprc:\n\
     #set pager \"less -M\"\n\
     \n\
     machine wuarchive.wustl.edu\n\
         macdef init\n\
         cd /pub\n\
         get README\n\
         dir\n\
         (blank line to end macro)",
    
    "If you want to keep your .netrc's for ftp and ncftp separate, name\n\
     ncftp's rc to .ncftprc.",

    "Type 'open' by itself to get a list of the sites in your recent-file and\n\
     your .ncftprc.  You can then supply '#5' at the prompt, or use 'open #5'\n\
     later.",

    "Colon-mode is a quick way to get a file from your shell.  Try something\n\
     like 'ncftp wuarchive.wustl.edu:/pub/README.'",

    "The open command accepts several flags.  Do a 'help open' for details.",

    "Sometimes a directory listing is several screens long and you won't\n\
     remember the thing you wanted.  Use the 'predir' command to re-view the\n\
     listing.  The program keeps the copy locally, so you won't have to wait\n\
     for the remote server to re-send it to you.",

    "Use the 'page' (or 'more') command to view a remote file with your pager.",

    "ncftp may be keeping detailed information on everything you transfer.\n\
     Run the 'version' command and if you see SYSLOG, your actions are being\n\
     recorded on the system log.",

    "Try the 'redir' command to re-display the last directory listing (ls,\n\
     dir, ls -lrt, etc).  'predir' does the same, only with your pager.",

    "This program is pronounced Nik-F-T-P.  NCEMRSoft is Nik'-mer-soft.",

#ifdef GETLINE
    "NcFTP was compiled with the Getline command-line/history editor! (by\n\
     Chris Thewalt <thewalt@ce.berkeley.edu>).  To activate it, use the up\n\
     and down arrows to scroll through the history, and/or use EMACS-style\n\
     commands to edit the line.",
#endif

#ifdef READLINE
    "NcFTP was compiled with the GNU Readline command-line/history editor!\n\
     To activate it, use the up & down arrows to scroll through the history,\n\
     and/or use EMACS-style (or maybe VI-style) commands to edit the line.",
#endif

    "You can get the newest version of NcFTP from ftp.cs.unl.edu, in the\n\
     /pub/ncftp directory, AFTER business hours.",

    "The type of progress-meter that will be used depends if the remote host\n\
     supports the SIZE command, and whether your terminal is capable of ANSI\n\
     escape codes.",

    "To report a bug, mail your message to mgleason@cse.unl.edu.  Include the\n\
     output of the 'version' command in your message.  An easy way to do that\n\
     is to compose your message, then do a 'ncftp -H >> msg.'",

    "Don't put a site in your .ncftprc unless you want an 'init' macro.  The \n\
     recent-file saves sites with the last directory you were in, unlike \n\
     the rc file, while still letting you use sitename abbreviations.",

    "You can use World Wide Web style paths instead of colon-mode paths.\n\
     For example, if the colon-mode path was 'ftp.cs.unl.edu:pub/ncftp',\n\
     the WWW-style path would be 'ftp://ftp.cs.unl.edu/pub/ncftp'.",

    "Sick and tired of these tips?  Put '#unset tips' in your .ncftprc."
};

/* Not another dinky header, por favor. */
#define NTIPS ((int) (sizeof(tiplist) / sizeof(char *)))
void PrintTip(void);
extern int fromatty, debug;

int tips = 1;
#endif  /* NO_TIPS */

void PrintTip(void)
{
#ifndef NO_TIPS
    int cheap_rn, i, tn;
    string str;

    if (tips && fromatty) {
        cheap_rn = (int) getpid() % NTIPS;
        if (debug) {
            (void) printf("pid: %d;  ntips: %d\n", getpid(), NTIPS);
            (void) Gets("*** Tip# (-1 == all): ", str, sizeof(str));
            tn = atoi(str) - 1;
			if (tn == -1)
				tn = 0;
            if (tn < -1)
                for(i=0; i<NTIPS; i++)
                    (void) printf("Tip: %s\n", tiplist[i]);
            else if (tn < NTIPS)
                (void) printf("Tip: %s\n", tiplist[tn]);
        } else
            (void) printf("Tip: %s\n", tiplist[cheap_rn]);
    }
#endif  /* NO_TIPS */
}   /* PrintTip */

/* tips.c */
OpenPOWER on IntegriCloud