]>
cygwin.com Git - cygwin-apps/setup.git/blob - netio.cc
2 * Copyright (c) 2000, 2001, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to coordinate the various access
17 methods known to setup. To add a new method, create a pair of
18 nio-*.[ch] files and add the logic to NetIO::open here */
20 static char *cvsid
= "\n%%% $Id$\n";
40 NetIO::NetIO (char *Purl
, BOOL allow_ftp_auth
)
43 ftp_auth
= allow_ftp_auth
;
59 NetIO::set_url (char *Purl
)
71 ep
= strstr (bp
, "://");
83 ep
= bp
+ strcspn (bp
, ":/");
92 ep
= strchr (ep
, '/');
106 NetIO::read (char *buf
, int nbytes
)
112 NetIO::open (char *url
, BOOL allow_ftp_auth
)
115 enum {http
, ftp
, file
} proto
;
116 if (strncmp (url
, "http://", 7) == 0)
118 else if (strncmp (url
, "ftp://", 6) == 0)
124 rv
= new NetIO_File (url
);
125 else if (net_method
== IDC_NET_IE5
)
126 rv
= new NetIO_IE5 (url
);
127 else if (net_method
== IDC_NET_PROXY
)
128 rv
= new NetIO_HTTP (url
, allow_ftp_auth
);
129 else if (net_method
== IDC_NET_DIRECT
)
134 rv
= new NetIO_HTTP (url
);
137 rv
= new NetIO_FTP (url
, allow_ftp_auth
);
152 static char **user
, **passwd
;
153 static int loading
= 0;
156 check_if_enable_ok (HWND h
)
159 if (*user
&& *passwd
)
161 EnableWindow (GetDlgItem (h
, IDOK
), e
);
168 eset (h
, IDC_NET_USER
, *user
);
169 eset (h
, IDC_NET_PASSWD
, *passwd
);
170 check_if_enable_ok (h
);
177 *user
= eget (h
, IDC_NET_USER
, *user
);
178 *passwd
= eget (h
, IDC_NET_PASSWD
, *passwd
);
182 auth_cmd (HWND h
, int id
, HWND hwndctl
, UINT code
)
189 if (code
== EN_CHANGE
&& !loading
)
192 check_if_enable_ok (h
);
209 auth_proc (HWND h
, UINT message
, WPARAM wParam
, LPARAM lParam
)
217 return HANDLE_WM_COMMAND (h
, wParam
, lParam
, auth_cmd
);
223 auth_common (HINSTANCE h
, int id
)
225 return DialogBox (h
, MAKEINTRESOURCE (id
), 0, auth_proc
);
232 passwd
= &net_passwd
;
233 return auth_common (hinstance
, IDD_NET_AUTH
);
237 NetIO::get_proxy_auth ()
239 user
= &net_proxy_user
;
240 passwd
= &net_proxy_passwd
;
241 return auth_common (hinstance
, IDD_PROXY_AUTH
);
245 NetIO::get_ftp_auth ()
254 free (net_ftp_passwd
);
255 net_ftp_passwd
= NULL
;
259 user
= &net_ftp_user
;
260 passwd
= &net_ftp_passwd
;
261 return auth_common (hinstance
, IDD_FTP_AUTH
);
This page took 0.050508 seconds and 6 git commands to generate.