annotate docs/parse-netrc.pl @ 219:b9584a877daf

2003-7-9 Brian Masney <masneyb@gftp.org> * lib/sshv2.c - if we are logging in to the server, and the message size is too big from the server, assume that an error message follows and log the ASCII text to the log window * src/gtk/options_dialog.c - make sure the value is set properly for the textcomboedt option types (the FTP proxy server type uses this) * lib/rfc2068.c - HTTP proxy bug fixes. Also, moved rfc2068_connect() call to rfc2068_send_command() and removed it from the now unneeded places. Also, fix in call to HEAD command * src/text/gftp-text.c - fixed NULL pointer deference in changing directory * docs/sample.gftp/gftprc - enable require SSH user/pass by default
author masneyb
date Wed, 09 Jul 2003 23:25:57 +0000
parents 8b1883341c6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
1 #!/usr/bin/perl -w
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
2
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
3 # Brian Masney <masneyb@gftp.org>
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
4
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
5 my ($host, $user, $pass, $account, $descr, %bmhash);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
6 use strict;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
7
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
8 open NRC, "<.netrc" or die "Can't open .netrc: $!\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
9 open BM, "+>>.gftp/bookmarks" or die "Can't open .gftp/bookmarks: $!\nTry running gFTP once to create a default bookmarks file\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
10 seek (BM, 0, 0);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
11 while (<BM>)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
12 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
13 ($descr) = /\[(.*?)\]/;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
14 next if !defined ($descr);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
15 $bmhash{$descr} = 1;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
16 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
17
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
18 seek (BM, 0, 2);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
19
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
20 while (<NRC>)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
21 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
22 if (/machine /)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
23 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
24 print_bookmark ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
25 ($host) = /machine (.*?)\s+/;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
26 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
27
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
28 if (/login /)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
29 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
30 ($user) = /login (.*?)\s+/;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
31 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
32
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
33 if (/password /)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
34 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
35 ($pass) = /password (.*?)\s+/;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
36 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
37
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
38 if (/account /)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
39 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
40 ($account) = /account (.*?)\s+/;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
41 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
42 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
43
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
44 print_bookmark ();
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
45
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
46 close NRC;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
47 close BM;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
48
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
49 print "The contents of your .netrc file should now be stored in .gftp/bookmarks\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
50
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
51
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
52 sub print_bookmark
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
53 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
54 my $i;
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
55
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
56 return if !defined ($host);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
57
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
58 if (!defined ($bmhash{$host}))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
59 { $descr = $host; }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
60 else
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
61 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
62 for ($i=0; ; $i++)
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
63 {
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
64 $descr = "$host ($i)";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
65 last if !defined ($bmhash{$descr});
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
66 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
67 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
68
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
69
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
70 print BM "[$descr]\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
71 print BM "hostname=$host\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
72 print BM "port=21\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
73 print BM "protocol=FTP\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
74 print BM "remote directory=\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
75 print BM "local directory=\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
76 if (!defined ($user))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
77 { $user = "anonymous"; }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
78 print BM "username=$user\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
79 if ($user eq "anonymous" || !defined ($pass))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
80 { $pass = "\@EMAIL\@"; }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
81 print BM "password=$pass\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
82 if (!defined ($account))
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
83 { $account = ""; }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
84 print BM "account=$account\n\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
85
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
86 print "Added $descr = $user\@$host\n";
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
87
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
88 undef ($host);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
89 undef ($user);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
90 undef ($pass);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
91 undef ($account);
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
92 }
8b1883341c6f Initial revision
masneyb
parents:
diff changeset
93