]>
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
)
67 url
= new char[strlen (Purl
) + 1];
75 ep
= strstr (bp
, "://");
83 proto
= new char [strlen (bp
)+1];
88 ep
= bp
+ strcspn (bp
, ":/");
91 host
= new char [strlen (bp
) + 1];
98 ep
= strchr (ep
, '/');
103 path
= new char [strlen (ep
)+1];
115 NetIO::read (char *buf
, int nbytes
)
121 NetIO::open (char const *url
, BOOL allow_ftp_auth
)
127 if (strncmp (url
, "http://", 7) == 0)
129 else if (strncmp (url
, "ftp://", 6) == 0)
135 rv
= new NetIO_File (url
);
136 else if (net_method
== IDC_NET_IE5
)
137 rv
= new NetIO_IE5 (url
);
138 else if (net_method
== IDC_NET_PROXY
)
139 rv
= new NetIO_HTTP (url
, allow_ftp_auth
);
140 else if (net_method
== IDC_NET_DIRECT
)
145 rv
= new NetIO_HTTP (url
);
148 rv
= new NetIO_FTP (url
, allow_ftp_auth
);
151 rv
= new NetIO_File (url
);
166 static char **user
, **passwd
;
167 static int loading
= 0;
170 check_if_enable_ok (HWND h
)
175 EnableWindow (GetDlgItem (h
, IDOK
), e
);
182 eset (h
, IDC_NET_USER
, *user
);
183 eset (h
, IDC_NET_PASSWD
, *passwd
);
184 check_if_enable_ok (h
);
191 *user
= eget (h
, IDC_NET_USER
, *user
);
192 *passwd
= eget (h
, IDC_NET_PASSWD
, *passwd
);
194 *passwd
= new char[1];
200 auth_cmd (HWND h
, int id
, HWND hwndctl
, UINT code
)
207 if (code
== EN_CHANGE
&& !loading
)
210 check_if_enable_ok (h
);
221 LogSingleton::GetInstance().exit (1);
228 auth_proc (HWND h
, UINT message
, WPARAM wParam
, LPARAM lParam
)
236 return HANDLE_WM_COMMAND (h
, wParam
, lParam
, auth_cmd
);
242 auth_common (HINSTANCE h
, int id
, HWND owner
)
244 return DialogBox (h
, MAKEINTRESOURCE (id
), owner
, auth_proc
);
248 NetIO::get_auth (HWND owner
)
251 passwd
= &net_passwd
;
252 return auth_common (hinstance
, IDD_NET_AUTH
, owner
);
256 NetIO::get_proxy_auth (HWND owner
)
258 user
= &net_proxy_user
;
259 passwd
= &net_proxy_passwd
;
260 return auth_common (hinstance
, IDD_PROXY_AUTH
, owner
);
264 NetIO::get_ftp_auth (HWND owner
)
268 delete[] net_ftp_user
;
273 delete[] net_ftp_passwd
;
274 net_ftp_passwd
= NULL
;
278 user
= &net_ftp_user
;
279 passwd
= &net_ftp_passwd
;
280 return auth_common (hinstance
, IDD_FTP_AUTH
, owner
);
This page took 0.046673 seconds and 5 git commands to generate.