1 /******************************************************************************* 2 * libproxy - A library for proxy configuration 3 * Copyright (C) 2006 Nathaniel McCallum <nathaniel@natemccallum.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 ******************************************************************************/ 19 20 #include "../extension_wpad.hpp" 21 using namespace libproxy; 22 23 class dns_alias_wpad_extension : public wpad_extension { 24 public: dns_alias_wpad_extension()25 dns_alias_wpad_extension() : lasturl(NULL), lastpac(NULL) { } found()26 bool found() { return lastpac != NULL; } 27 rewind()28 void rewind() { 29 if (lasturl) delete lasturl; 30 if (lastpac) delete lastpac; 31 lasturl = NULL; 32 lastpac = NULL; 33 } 34 next(char ** pac)35 url* next(char** pac) { 36 if (lasturl) return NULL; 37 38 lasturl = new url("http://wpad/wpad.dat"); 39 lastpac = *pac = lasturl->get_pac(); 40 if (!lastpac) { 41 delete lasturl; 42 lasturl = NULL; 43 return NULL; 44 } 45 46 return lasturl; 47 } 48 49 private: 50 url* lasturl; 51 char* lastpac; 52 }; 53 54 MM_MODULE_INIT_EZ(dns_alias_wpad_extension, true, NULL, NULL); 55