]>
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 */
21 static const char *cvsid
=
43 NetIO::NetIO (char const *Purl
, BOOL allow_ftp_auth
)
46 ftp_auth
= allow_ftp_auth
;
62 NetIO::set_url (char const *Purl
)
74 ep
= strstr (bp
, "://");
86 ep
= bp
+ strcspn (bp
, ":/");
95 ep
= strchr (ep
, '/');
109 NetIO::read (char *buf
, int nbytes
)
115 NetIO::open (char const *url
, BOOL allow_ftp_auth
)
121 if (strncmp (url
, "http://", 7) == 0)
123 else if (strncmp (url
, "ftp://", 6) == 0)
129 rv
= new NetIO_File (url
);
130 else if (net_method
== IDC_NET_IE5
)
131 rv
= new NetIO_IE5 (url
);
132 else if (net_method
== IDC_NET_PROXY
)
133 rv
= new NetIO_HTTP (url
, allow_ftp_auth
);
134 else if (net_method
== IDC_NET_DIRECT
)
139 rv
= new NetIO_HTTP (url
);
142 rv
= new NetIO_FTP (url
, allow_ftp_auth
);
145 rv
= new NetIO_File (url
);
160 static char **user
, **passwd
;
161 static int loading
= 0;
164 check_if_enable_ok (HWND h
)
167 if (*user
&& *passwd
)
169 EnableWindow (GetDlgItem (h
, IDOK
), e
);
176 eset (h
, IDC_NET_USER
, *user
);
177 eset (h
, IDC_NET_PASSWD
, *passwd
);
178 check_if_enable_ok (h
);
185 *user
= eget (h
, IDC_NET_USER
, *user
);
186 *passwd
= eget (h
, IDC_NET_PASSWD
, *passwd
);
190 auth_cmd (HWND h
, int id
, HWND hwndctl
, UINT code
)
197 if (code
== EN_CHANGE
&& !loading
)
200 check_if_enable_ok (h
);
218 auth_proc (HWND h
, UINT message
, WPARAM wParam
, LPARAM lParam
)
226 return HANDLE_WM_COMMAND (h
, wParam
, lParam
, auth_cmd
);
232 auth_common (HINSTANCE h
, int id
, HWND owner
)
234 return DialogBox (h
, MAKEINTRESOURCE (id
), owner
, auth_proc
);
238 NetIO::get_auth (HWND owner
)
241 passwd
= &net_passwd
;
242 return auth_common (hinstance
, IDD_NET_AUTH
, owner
);
246 NetIO::get_proxy_auth (HWND owner
)
248 user
= &net_proxy_user
;
249 passwd
= &net_proxy_passwd
;
250 return auth_common (hinstance
, IDD_PROXY_AUTH
, owner
);
254 NetIO::get_ftp_auth (HWND owner
)
263 free (net_ftp_passwd
);
264 net_ftp_passwd
= NULL
;
268 user
= &net_ftp_user
;
269 passwd
= &net_ftp_passwd
;
270 return auth_common (hinstance
, IDD_FTP_AUTH
, owner
);
This page took 0.051697 seconds and 6 git commands to generate.