Mercurial > gftp.yaz
view docs/parse-netrc.pl @ 124:65048c959029
2003-4-6 Brian Masney <masneyb@gftp.org>
* lib/config_file.c src/text/gftp-text.c - changed arguments of
gftp_read_config_file() and gftp_read_bookmarks() to take an argument
to the path of the global config directory. The text/gtk+ port will
just pass SHARE_DIR. The native MacOS X port that is in the works
needs this (Nathan Robertson is currently working on this port)
* lib/gftp.h lib/config_file.c - removed config variable type
gftp_option_type_textarray
* lib/gftp.h lib/config_file.c - removed copy_function from
gftp_option_type_var. This is implemented with memcpy() instead
* lib/rfc959.c - remember to rename all instances of firewall_* to
ftp_proxy_*
* lib/sshv2.c - improved generating the argument list for the ssh
client
* lib/sshv2.c lib/misc.c lib/gftp.h - added len argument to
ptym_open()
* lib/protocols.c lib/misc.c lib/config_file.c - use g_strdup()
instead of g_malloc()/strcpy()
author | masneyb |
---|---|
date | Tue, 08 Apr 2003 01:43:33 +0000 |
parents | 8b1883341c6f |
children |
line wrap: on
line source
#!/usr/bin/perl -w # Brian Masney <masneyb@gftp.org> my ($host, $user, $pass, $account, $descr, %bmhash); use strict; open NRC, "<.netrc" or die "Can't open .netrc: $!\n"; open BM, "+>>.gftp/bookmarks" or die "Can't open .gftp/bookmarks: $!\nTry running gFTP once to create a default bookmarks file\n"; seek (BM, 0, 0); while (<BM>) { ($descr) = /\[(.*?)\]/; next if !defined ($descr); $bmhash{$descr} = 1; } seek (BM, 0, 2); while (<NRC>) { if (/machine /) { print_bookmark (); ($host) = /machine (.*?)\s+/; } if (/login /) { ($user) = /login (.*?)\s+/; } if (/password /) { ($pass) = /password (.*?)\s+/; } if (/account /) { ($account) = /account (.*?)\s+/; } } print_bookmark (); close NRC; close BM; print "The contents of your .netrc file should now be stored in .gftp/bookmarks\n"; sub print_bookmark { my $i; return if !defined ($host); if (!defined ($bmhash{$host})) { $descr = $host; } else { for ($i=0; ; $i++) { $descr = "$host ($i)"; last if !defined ($bmhash{$descr}); } } print BM "[$descr]\n"; print BM "hostname=$host\n"; print BM "port=21\n"; print BM "protocol=FTP\n"; print BM "remote directory=\n"; print BM "local directory=\n"; if (!defined ($user)) { $user = "anonymous"; } print BM "username=$user\n"; if ($user eq "anonymous" || !defined ($pass)) { $pass = "\@EMAIL\@"; } print BM "password=$pass\n"; if (!defined ($account)) { $account = ""; } print BM "account=$account\n\n"; print "Added $descr = $user\@$host\n"; undef ($host); undef ($user); undef ($pass); undef ($account); }