├── de.lproj ├── InfoPlist.strings ├── Localizable.strings └── MainMenu.strings ├── en.lproj ├── InfoPlist.strings ├── Localizable.strings └── MainMenu.strings ├── fr.lproj ├── InfoPlist.strings ├── Localizable.strings └── MainMenu.strings ├── nl.lproj ├── InfoPlist.strings ├── Localizable.strings └── MainMenu.strings ├── HostsPrefpane ├── de.lproj │ ├── InfoPlist.strings │ └── HostsPrefpane.strings ├── en.lproj │ ├── InfoPlist.strings │ └── HostsPrefpane.strings ├── fr.lproj │ ├── InfoPlist.strings │ └── HostsPrefpane.strings ├── nl.lproj │ ├── InfoPlist.strings │ └── HostsPrefpane.strings ├── 32x32.tiff ├── icon_256x256.png ├── HostsPrefpane.tiff ├── HostsPrefpane-Prefix.pch ├── HostsPrefpane.m ├── HostsPrefpane.h ├── HostsPrefpane-Info.plist └── Base.lproj │ └── HostsPrefpane.xib ├── icon.icns ├── screenshots ├── edit.png └── locked.png ├── Hosts_Prefix.pch ├── c └── parser │ ├── hosts.txt │ ├── hosts.h │ ├── hostsparser.yy │ ├── main.c │ ├── Makefile │ ├── hostsparser.h │ ├── hosts.c │ └── hostsparser.y ├── .gitignore ├── Hosts.pmdoc ├── 01hosts-contents.xml ├── 01hosts.xml └── index.xml ├── .bartycrouch.toml ├── main.m ├── pm ├── utils │ ├── NLPERMANENTMARKERSHOSTSParserCallbacks.h │ ├── PMModalDelegate.m │ ├── PMModalDelegate.h │ ├── NLPERMANENTMARKERSHOSTSFileWriter.h │ ├── NLPERMANENTMARKERSHOSTSParserCallbacks.m │ └── NLPERMANENTMARKERSHOSTSFileWriter.m ├── auth │ ├── NLPERMANENTMARKERSHOSTSAuthorization.h │ └── NLPERMANENTMARKERSHOSTSAuthorization.m ├── controllers │ ├── NLPERMANENTMARKERSHOSTSListController.h │ ├── NLPERMANENTMARKERSHOSTSAppController.h │ ├── NLPERMANENTMARKERSHOSTSAppController.m │ └── NLPERMANENTMARKERSHOSTSListController.m ├── NLPERMANENTMARKERSHOSTSConstants.h └── models │ ├── NLPERMANENTMARKERSHOSTSHostEntry.h │ ├── NLPERMANENTMARKERSHOSTSFileModel.h │ ├── NLPERMANENTMARKERSHOSTSHostEntry.m │ └── NLPERMANENTMARKERSHOSTSFileModel.m ├── HostsAppDelegate.m ├── Hosts-Info.plist ├── HostsAppDelegate.h ├── BuildNotices.txt ├── Hosts.xcodeproj └── xcshareddata │ └── xcschemes │ ├── parser.xcscheme │ ├── HostsPrefpane.xcscheme │ └── HostsApp.xcscheme ├── README.mdown ├── Base.lproj └── MainMenu.xib └── LICENSE /de.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /fr.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /nl.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /HostsPrefpane/de.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /HostsPrefpane/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /HostsPrefpane/fr.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /HostsPrefpane/nl.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crogram/Hosts/master/icon.icns -------------------------------------------------------------------------------- /screenshots/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crogram/Hosts/master/screenshots/edit.png -------------------------------------------------------------------------------- /screenshots/locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crogram/Hosts/master/screenshots/locked.png -------------------------------------------------------------------------------- /HostsPrefpane/32x32.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crogram/Hosts/master/HostsPrefpane/32x32.tiff -------------------------------------------------------------------------------- /HostsPrefpane/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crogram/Hosts/master/HostsPrefpane/icon_256x256.png -------------------------------------------------------------------------------- /HostsPrefpane/HostsPrefpane.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crogram/Hosts/master/HostsPrefpane/HostsPrefpane.tiff -------------------------------------------------------------------------------- /Hosts_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Hosts' target in the 'Hosts' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /HostsPrefpane/HostsPrefpane-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'HostsPrefpane' target in the 'HostsPrefpane' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /c/parser/hosts.txt: -------------------------------------------------------------------------------- 1 | #hosts 2 | 127.0.0.1 localhost 3 | fe80::1 localhost 4 | fe80::1%lo0 localhost 5 | ::1 localhost 6 | 7 | # lmao 8 | 134.5.5.2 hhh.lol kkk.hai 9 | # lal kut hoer 10 | 134.5.5.2 myhost.lol bla.hai # noob 11 | 134.5.5.2 Dyhost.lol bla.hai34 12 | 126.4.4.7 localhost hahah #jnkjnkjn 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | 17 | c/parser/hosts 18 | c/parser/hosts\.dSYM 19 | c/parser/hostsparser\.o 20 | c/parser/hostsparser\.output 21 | c/parser/hostsparser\.tab\.c 22 | c/parser/hostsparser\.tab\.h 23 | c/parser/hostsscanner\.h 24 | c/parser/lex\.yy\.c 25 | c/parser/lex.NLPERMANENTMARKERSHOSTS.c 26 | pm/.DS_Store 27 | .DS_Store 28 | -------------------------------------------------------------------------------- /Hosts.pmdoc/01hosts-contents.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.bartycrouch.toml: -------------------------------------------------------------------------------- 1 | [update] 2 | tasks = ["interfaces", "code", "transform", "normalize"] 3 | 4 | [update.interfaces] 5 | path = "." 6 | defaultToBase = false 7 | ignoreEmptyStrings = false 8 | unstripped = false 9 | 10 | [update.code] 11 | codePath = "." 12 | localizablePath = "." 13 | defaultToKeys = false 14 | additive = true 15 | unstripped = false 16 | 17 | [update.transform] 18 | codePath = "." 19 | localizablePath = "." 20 | transformer = "foundation" 21 | supportedLanguageEnumPath = "." 22 | typeName = "BartyCrouch" 23 | translateMethodName = "translate" 24 | 25 | [update.normalize] 26 | path = "." 27 | sourceLocale = "en" 28 | harmonizeWithSource = true 29 | sortByKeys = true 30 | 31 | [lint] 32 | path = "." 33 | duplicateKeys = true 34 | emptyValues = true 35 | -------------------------------------------------------------------------------- /Hosts.pmdoc/01hosts.xml: -------------------------------------------------------------------------------- 1 | nl.permanentmarkers.hosts.Hosts.pkg0.1.3build/Release/Hosts.prefPane/Library/PreferencePanesinstallTo.isRelativeTypeinstallTorelocatableinstallTo.isAbsoluteTypeinstallFrom.pathrequireAuthorizationparentincludeRootinstallTo.pathversion01hosts-contents.xml/CVS$/\.svn$/\.cvsignore$/\.cvspass$/\.DS_Store$ -------------------------------------------------------------------------------- /Hosts.pmdoc/index.xml: -------------------------------------------------------------------------------- 1 | Hosts/Users/ebone/Sites/hosts/build/Release/Hosts-1.3.pkgDeveloper ID Installer: PermanentMarkersnl.permanentmarkersInstalls a preference pane to edit your hosts file01hosts.xmldescriptionproperties.titleproperties.userDomainproperties.anywhereDomainproperties.systemDomain -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | 20 | #import 21 | 22 | int main(int argc, char *argv[]) 23 | { 24 | return NSApplicationMain(argc, (const char **) argv); 25 | } 26 | -------------------------------------------------------------------------------- /pm/utils/NLPERMANENTMARKERSHOSTSParserCallbacks.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import "c/parser/hosts.h" 20 | 21 | void NLPERMANENTMARKERSHOSTSonHostEntryFound(NLPERMANENTMARKERSHOSTS_CHostEntry * entry); 22 | void NLPERMANENTMARKERSHOSTSonHostsParseError(NLPERMANENTMARKERSHOSTS_CHostEntryError * error); -------------------------------------------------------------------------------- /pm/utils/PMModalDelegate.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import "PMModalDelegate.h" 20 | 21 | 22 | @implementation PMModalDelegate 23 | @synthesize choice; 24 | 25 | - (void)alertEnded:(NSAlert *)alert code:(int)aChoice context:(void *) v { 26 | self.choice = aChoice; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /pm/utils/PMModalDelegate.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | 21 | 22 | @interface PMModalDelegate : NSObject { 23 | @private 24 | int choice; 25 | } 26 | 27 | - (void)alertEnded:(NSAlert *)alert code:(int)choice context:(void *) v; 28 | 29 | @property (assign) int choice; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HostsAppDelegate.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | 21 | #import "HostsAppDelegate.h" 22 | 23 | @implementation HostsAppDelegate 24 | 25 | @synthesize appController, window; 26 | 27 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 28 | [appController setUp:[window undoManager]]; 29 | } 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /pm/utils/NLPERMANENTMARKERSHOSTSFileWriter.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | #import "pm/auth/NLPERMANENTMARKERSHOSTSAuthorization.h" 21 | 22 | @interface NLPERMANENTMARKERSHOSTSFileWriter : NSObject { 23 | @private 24 | NLPERMANENTMARKERSHOSTSAuthorization *authorization; 25 | } 26 | 27 | + (void) backupHostsFileWithExtension:(NSString *) extension; 28 | - (void) writeHostEntries:(NSArray *) hostEntries; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | 2 | /* deletion: message format string */ 3 | "Are you sure you want to permanently remove:\n%@ from /etc/hosts?" = "Are you sure you want to permanently remove:\n%@from /etc/hosts?"; 4 | 5 | /* deletion: title */ 6 | "Confirm deletion" = "Confirm deletion"; 7 | 8 | /* undo: redo insert 9 | undo: undo insert */ 10 | "Delete host entry" = "Delete host entry"; 11 | 12 | /* undo: undo edit */ 13 | "Edit" = "Edit"; 14 | 15 | /* error: description */ 16 | "In /private/etc/hosts on line:%i %s\n\n%s\n\nShould this line be permanently removed from /private/etc/hosts?\nChoose no to quit Hosts and manually correct the error." = "In /private/etc/hosts on line:%i %s\n\n%s\n\nShould this line be permanently removed from /private/etc/hosts?\nChoose No to quit Hosts and manually correct the error."; 17 | 18 | /* undo: redo delete 19 | undo: undo delete */ 20 | "Insert host entry" = "Insert host entry"; 21 | 22 | /* error: title */ 23 | "Parse error" = "Parse error"; 24 | 25 | /* validation: valid hostname */ 26 | "Please enter a valid hostname" = "Please enter a valid hostname"; 27 | 28 | /* validation: valid ip address */ 29 | "Please enter a valid ip address" = "Please enter a valid ip address"; 30 | 31 | /* No comment provided by engineer. */ 32 | "No" = "No"; 33 | 34 | /* No comment provided by engineer. */ 35 | "Yes" = "Yes"; 36 | -------------------------------------------------------------------------------- /HostsPrefpane/en.lproj/HostsPrefpane.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSButtonCell"; alternateTitle = "Add a hosts entry below selection"; ObjectID = "113"; */ 3 | "113.alternateTitle" = "Add a hosts entry below selection"; 4 | 5 | /* Class = "NSWindow"; title = "<< do not localize >>"; ObjectID = "12"; */ 6 | "12.title" = "<< do not localize >>"; 7 | 8 | /* Class = "NSTableColumn"; headerCell.title = "IP Address"; ObjectID = "2cX-DG-ekV"; */ 9 | "2cX-DG-ekV.headerCell.title" = "IP Address"; 10 | 11 | /* Class = "NSTableColumn"; headerCell.title = "Hostname"; ObjectID = "h3b-vn-bLp"; */ 12 | "h3b-vn-bLp.headerCell.title" = "Hostname"; 13 | 14 | /* Class = "NSTableColumn"; headerCell.title = "Use"; ObjectID = "PJ8-A3-VaR"; */ 15 | "PJ8-A3-VaR.headerCell.title" = "Use"; 16 | 17 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "FaI-jq-uuM"; */ 18 | "FaI-jq-uuM.title" = ""; 19 | 20 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "KzZ-Jn-xJd"; */ 21 | "KzZ-Jn-xJd.title" = ""; 22 | 23 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "oBC-88-DM7"; */ 24 | "oBC-88-DM7.title" = ""; 25 | 26 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "ySc-46-QRX"; */ 27 | "ySc-46-QRX.title" = ""; 28 | 29 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "Z13-5C-F7g"; */ 30 | "Z13-5C-F7g.title" = ""; 31 | -------------------------------------------------------------------------------- /HostsPrefpane/nl.lproj/HostsPrefpane.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSButtonCell"; alternateTitle = "Add a hosts entry below selection"; ObjectID = "113"; */ 3 | "113.alternateTitle" = "Voeg een hosts item toe onder selectie"; 4 | 5 | /* Class = "NSWindow"; title = "<< do not localize >>"; ObjectID = "12"; */ 6 | "12.title" = "<< do not localize >>"; 7 | 8 | /* Class = "NSTableColumn"; headerCell.title = "IP Address"; ObjectID = "2cX-DG-ekV"; */ 9 | "2cX-DG-ekV.headerCell.title" = "IP-adres"; 10 | 11 | /* Class = "NSTableColumn"; headerCell.title = "Hostname"; ObjectID = "h3b-vn-bLp"; */ 12 | "h3b-vn-bLp.headerCell.title" = "Hostnaam"; 13 | 14 | /* Class = "NSTableColumn"; headerCell.title = "Use"; ObjectID = "PJ8-A3-VaR"; */ 15 | "PJ8-A3-VaR.headerCell.title" = "Actief"; 16 | 17 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "FaI-jq-uuM"; */ 18 | "FaI-jq-uuM.title" = ""; 19 | 20 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "KzZ-Jn-xJd"; */ 21 | "KzZ-Jn-xJd.title" = ""; 22 | 23 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "oBC-88-DM7"; */ 24 | "oBC-88-DM7.title" = ""; 25 | 26 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "ySc-46-QRX"; */ 27 | "ySc-46-QRX.title" = ""; 28 | 29 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "Z13-5C-F7g"; */ 30 | "Z13-5C-F7g.title" = ""; 31 | -------------------------------------------------------------------------------- /HostsPrefpane/de.lproj/HostsPrefpane.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSButtonCell"; alternateTitle = "Add a hosts entry below selection"; ObjectID = "113"; */ 3 | "113.alternateTitle" = "Host-Eintrag unter ausgewählter Zeile einfügen"; 4 | 5 | /* Class = "NSWindow"; title = "<< do not localize >>"; ObjectID = "12"; */ 6 | "12.title" = "<< do not localize >>"; 7 | 8 | /* Class = "NSTableColumn"; headerCell.title = "IP Address"; ObjectID = "2cX-DG-ekV"; */ 9 | "2cX-DG-ekV.headerCell.title" = "IP-Adresse"; 10 | 11 | /* Class = "NSTableColumn"; headerCell.title = "Hostname"; ObjectID = "h3b-vn-bLp"; */ 12 | "h3b-vn-bLp.headerCell.title" = "Hostname"; 13 | 14 | /* Class = "NSTableColumn"; headerCell.title = "Use"; ObjectID = "PJ8-A3-VaR"; */ 15 | "PJ8-A3-VaR.headerCell.title" = "Aktiv"; 16 | 17 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "FaI-jq-uuM"; */ 18 | "FaI-jq-uuM.title" = ""; 19 | 20 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "KzZ-Jn-xJd"; */ 21 | "KzZ-Jn-xJd.title" = ""; 22 | 23 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "oBC-88-DM7"; */ 24 | "oBC-88-DM7.title" = ""; 25 | 26 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "ySc-46-QRX"; */ 27 | "ySc-46-QRX.title" = ""; 28 | 29 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "Z13-5C-F7g"; */ 30 | "Z13-5C-F7g.title" = ""; 31 | -------------------------------------------------------------------------------- /pm/auth/NLPERMANENTMARKERSHOSTSAuthorization.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | 20 | #import 21 | #import 22 | 23 | @interface NLPERMANENTMARKERSHOSTSAuthorization : NSObject { 24 | @private 25 | SFAuthorizationView * authView; 26 | AuthorizationRights hostFileRights; 27 | } 28 | 29 | - (id) initWithAuthView:(SFAuthorizationView *) anAuthView; 30 | - (void) obtain; 31 | - (void) conditionallyInstallAuthorizationRule; 32 | @end 33 | -------------------------------------------------------------------------------- /HostsPrefpane/fr.lproj/HostsPrefpane.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSButtonCell"; alternateTitle = "Add a hosts entry below selection"; ObjectID = "113"; */ 3 | "113.alternateTitle" = "Ajouter une entrée d'hôte sous la sélection"; 4 | 5 | /* Class = "NSWindow"; title = "<< do not localize >>"; ObjectID = "12"; */ 6 | "12.title" = "<< do not localize >>"; 7 | 8 | /* Class = "NSTableColumn"; headerCell.title = "IP Address"; ObjectID = "2cX-DG-ekV"; */ 9 | "2cX-DG-ekV.headerCell.title" = "Adresse IP"; 10 | 11 | /* Class = "NSTableColumn"; headerCell.title = "Hostname"; ObjectID = "h3b-vn-bLp"; */ 12 | "h3b-vn-bLp.headerCell.title" = "Nom d'hôte"; 13 | 14 | /* Class = "NSTableColumn"; headerCell.title = "Use"; ObjectID = "PJ8-A3-VaR"; */ 15 | "PJ8-A3-VaR.headerCell.title" = "En activité"; 16 | 17 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "FaI-jq-uuM"; */ 18 | "FaI-jq-uuM.title" = ""; 19 | 20 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "KzZ-Jn-xJd"; */ 21 | "KzZ-Jn-xJd.title" = ""; 22 | 23 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "oBC-88-DM7"; */ 24 | "oBC-88-DM7.title" = ""; 25 | 26 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "ySc-46-QRX"; */ 27 | "ySc-46-QRX.title" = ""; 28 | 29 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "Z13-5C-F7g"; */ 30 | "Z13-5C-F7g.title" = ""; 31 | -------------------------------------------------------------------------------- /HostsPrefpane/HostsPrefpane.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | #import "HostsPrefpane.h" 21 | 22 | 23 | @implementation HostsPrefpane 24 | 25 | @synthesize appController, window; 26 | 27 | - (void)mainViewDidLoad 28 | { 29 | [appController setUp:nil]; 30 | } 31 | 32 | - (void)didUnselect { 33 | [[appController hostfile] clear]; 34 | } 35 | 36 | - (void) willSelect { 37 | NSLog(@"hi there"); 38 | [[appController hostfile] load]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /nl.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | 2 | /* deletion: message format string */ 3 | "Are you sure you want to permanently remove:\n%@ from /etc/hosts?" = "Weet u zeker dat u de \n%@van /etc/hosts permanent wilt verwijderen?"; 4 | 5 | /* deletion: title */ 6 | "Confirm deletion" = "Bevestig de verwijdering"; 7 | 8 | /* undo: redo insert 9 | undo: undo insert */ 10 | "Delete host entry" = "Verwijderen van gastheer-invoer"; 11 | 12 | /* undo: undo edit */ 13 | "Edit" = "Wijzig"; 14 | 15 | /* error: description */ 16 | "In /private/etc/hosts on line:%i %s\n\n%s\n\nShould this line be permanently removed from /private/etc/hosts?\nChoose no to quit Hosts and manually correct the error." = "In /private/etc/hosts on line:%i %s\n\n%s\n\nMoet deze lijn permanent worden verwijderd uit /private/etc/hosts?\nKies nee om Hosts te verlaten en corrigeer de fout handmatig."; 17 | 18 | /* undo: redo delete 19 | undo: undo delete */ 20 | "Insert host entry" = "Gastheer-invoer invoegen"; 21 | 22 | /* error: title */ 23 | "Parse error" = "Parsefout"; 24 | 25 | /* validation: valid hostname */ 26 | "Please enter a valid hostname" = "Voer een geldige hostnaam in"; 27 | 28 | /* validation: valid ip address */ 29 | "Please enter a valid ip address" = "Voer een geldig IP-adres in"; 30 | 31 | /* No comment provided by engineer. */ 32 | "No" = "Nee"; 33 | 34 | /* No comment provided by engineer. */ 35 | "Yes" = "Ja"; 36 | -------------------------------------------------------------------------------- /Hosts-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | icon.icns 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | Hosts 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(MARKETING_VERSION) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(CURRENT_PROJECT_VERSION) 25 | LSApplicationCategoryType 26 | public.app-category.developer-tools 27 | LSMinimumSystemVersion 28 | ${MACOSX_DEPLOYMENT_TARGET} 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | NSRequiresAquaSystemAppearance 34 | false 35 | NSSupportsSuddenTermination 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /HostsPrefpane/HostsPrefpane.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | #import "pm/controllers/NLPERMANENTMARKERSHOSTSAppController.h" 21 | 22 | @interface HostsPrefpane : NSPreferencePane { 23 | @private 24 | NLPERMANENTMARKERSHOSTSAppController * appController; 25 | NSWindow *window; 26 | } 27 | 28 | - (void)mainViewDidLoad; 29 | 30 | @property (assign) IBOutlet NLPERMANENTMARKERSHOSTSAppController *appController; 31 | @property (assign) IBOutlet NSWindow *window; 32 | @end 33 | -------------------------------------------------------------------------------- /HostsAppDelegate.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | #import 21 | #import "pm/controllers/NLPERMANENTMARKERSHOSTSAppController.h" 22 | 23 | @interface HostsAppDelegate : NSObject { 24 | IBOutlet NLPERMANENTMARKERSHOSTSAppController * appController; 25 | NSWindow *window; 26 | } 27 | 28 | @property (assign) IBOutlet NLPERMANENTMARKERSHOSTSAppController * appController; 29 | @property (assign) IBOutlet NSWindow *window; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /de.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | 2 | /* deletion: message format string */ 3 | "Are you sure you want to permanently remove:\n%@ from /etc/hosts?" = "Sind Sie sicher, dass Sie \n%@aus /etc/hosts löschen möchten?"; 4 | 5 | /* deletion: title */ 6 | "Confirm deletion" = "Löschen bestätigen"; 7 | 8 | /* undo: redo insert 9 | undo: undo insert */ 10 | "Delete host entry" = "Host-Eintrag löschen"; 11 | 12 | /* undo: undo edit */ 13 | "Edit" = "Bearbeiten"; 14 | 15 | /* error: description */ 16 | "In /private/etc/hosts on line:%i %s\n\n%s\n\nShould this line be permanently removed from /private/etc/hosts?\nChoose no to quit Hosts and manually correct the error." = "In /private/etc/hosts in der Zeile:%i %s\n\n%s\n\nSoll diese Zeile dauerhaft von /private/etc/hosts entfernt werden?\nWähle Nein, um Hosts zu beenden und den Fehler manuell zu beheben."; 17 | 18 | /* undo: redo delete 19 | undo: undo delete */ 20 | "Insert host entry" = "Host-Eintrag einfügen"; 21 | 22 | /* error: title */ 23 | "Parse error" = "Parsing-Fehler"; 24 | 25 | /* validation: valid hostname */ 26 | "Please enter a valid hostname" = "Bitte geben Sie einen gültigen Hostnamen ein."; 27 | 28 | /* validation: valid ip address */ 29 | "Please enter a valid ip address" = "Bitte geben Sie eine gültige IP-Adresse ein."; 30 | 31 | /* No comment provided by engineer. */ 32 | "No" = "Nein"; 33 | 34 | /* No comment provided by engineer. */ 35 | "Yes" = "Ja"; 36 | -------------------------------------------------------------------------------- /fr.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | 2 | /* deletion: message format string */ 3 | "Are you sure you want to permanently remove:\n%@ from /etc/hosts?" = "Êtes-vous sûr de vouloir supprimer définitivement:\n%@de /etc/hosts ?"; 4 | 5 | /* deletion: title */ 6 | "Confirm deletion" = "Confirmer la suppression"; 7 | 8 | /* undo: redo insert 9 | undo: undo insert */ 10 | "Delete host entry" = "Supprimer l'entrée de l'hôte"; 11 | 12 | /* undo: undo edit */ 13 | "Edit" = "Éditer"; 14 | 15 | /* error: description */ 16 | "In /private/etc/hosts on line:%i %s\n\n%s\n\nShould this line be permanently removed from /private/etc/hosts?\nChoose no to quit Hosts and manually correct the error." = "Dans /private/etc/hosts on line:%i %s\n\n%s\n\nCette ligne doit-elle être définitivement supprimée de /private/etc/hosts?\nChoisissez non pour quitter Hosts et corriger manuellement l'erreur."; 17 | 18 | /* undo: redo delete 19 | undo: undo delete */ 20 | "Insert host entry" = "Insérer l'entrée de l'hôte"; 21 | 22 | /* error: title */ 23 | "Parse error" = "Erreur d'analyse"; 24 | 25 | /* validation: valid hostname */ 26 | "Please enter a valid hostname" = "Veuillez entrer un nom d'hôte valide"; 27 | 28 | /* validation: valid ip address */ 29 | "Please enter a valid ip address" = "Veuillez entrer une adresse IP valide"; 30 | 31 | /* No comment provided by engineer. */ 32 | "No" = "Non"; 33 | 34 | /* No comment provided by engineer. */ 35 | "Yes" = "Oui"; 36 | -------------------------------------------------------------------------------- /pm/controllers/NLPERMANENTMARKERSHOSTSListController.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | 21 | 22 | @interface NLPERMANENTMARKERSHOSTSListController : NSArrayController { 23 | IBOutlet NSTableView * tableView; 24 | } 25 | 26 | - (void)insertObject:(id)object afterArrangedObjectIndex:(NSUInteger)index; 27 | - (void)alertEnded:(NSAlert *)alert code:(int)aChoice context:(void *) v; 28 | 29 | - (IBAction) insertHostEntry: (id)sender; 30 | - (IBAction) confirmDeleteItem:(id)sender; 31 | 32 | @property (assign) IBOutlet NSTableView * tableView; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /pm/NLPERMANENTMARKERSHOSTSConstants.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #ifndef PMCONSTANTS_H 20 | #define PMCONSTANTS_H 21 | 22 | #define PM_AUTHENTICATION_RULE "nl.permanentmarkers.hosts" 23 | #define PM_HOSTS_FILE_LOCATION "/private/etc/hosts" 24 | #define PM_AUTHORISED_FILE "sys.openfile.readwrite./private/etc/hosts" 25 | #define PM_AUTHENTICATION_RULE_COMMENT "Hosts.app /etc/hosts edit rule, will be reset if changed!" 26 | #define PM_HOST_ENTRY_DATA_TYPE @"nl.permanentmarkers.NLPERMANENTMARKERSHOSTSHostEntry" 27 | #define PMHOSTS_DEFAULTS_KEY @"NLPERMANENTMARKERSHOSTS_HOSTS_DEFAULTS_KEY" 28 | 29 | #endif -------------------------------------------------------------------------------- /HostsPrefpane/HostsPrefpane-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | icon.icns 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleShortVersionString 20 | $(MARKETING_VERSION) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(CURRENT_PROJECT_VERSION) 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2011 PermanentMarkers. All rights reserved. 29 | NSMainNibFile 30 | HostsPrefpane 31 | NSPrefPaneIconFile 32 | icon_256x256.png 33 | NSPrefPaneIconLabel 34 | Hosts 35 | NSPrincipalClass 36 | HostsPrefpane 37 | NSRequiresAquaSystemAppearance 38 | false 39 | NSSupportsSuddenTermination 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /pm/controllers/NLPERMANENTMARKERSHOSTSAppController.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | #import 21 | 22 | #import "pm/models/NLPERMANENTMARKERSHOSTSFileModel.h" 23 | #import "pm/auth/NLPERMANENTMARKERSHOSTSAuthorization.h" 24 | 25 | @interface NLPERMANENTMARKERSHOSTSAppController : NSObject { 26 | //@private 27 | IBOutlet SFAuthorizationView *authView; 28 | NLPERMANENTMARKERSHOSTSFileModel *hostfile; 29 | NLPERMANENTMARKERSHOSTSAuthorization *authorization; 30 | } 31 | 32 | - (BOOL) isAuthenticated; 33 | - (void) setUp:(NSUndoManager *)undoManager; 34 | 35 | //@property (assign) IBOutlet PMHostListController *controller; 36 | @property (assign) IBOutlet NLPERMANENTMARKERSHOSTSFileModel *hostfile; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /c/parser/hosts.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #ifndef HOSTS_H 20 | #define HOSTS_H 21 | 22 | // host entry 23 | typedef struct { 24 | char * address; 25 | char * hostnames; 26 | char * comment; 27 | } NLPERMANENTMARKERSHOSTS_CHostEntry; 28 | 29 | NLPERMANENTMARKERSHOSTS_CHostEntry * NLPERMANENTMARKERSHOSTS_chostentry_create(char * address, char * hostnames, char * comment); 30 | NLPERMANENTMARKERSHOSTS_CHostEntry * NLPERMANENTMARKERSHOSTS_chostentry_add_hostname(NLPERMANENTMARKERSHOSTS_CHostEntry *host_entry, char * hostname); 31 | void NLPERMANENTMARKERSHOSTS_chostentry_destroy(NLPERMANENTMARKERSHOSTS_CHostEntry * host_entry); 32 | 33 | // host entry parse errors 34 | typedef struct { 35 | int linenumber; 36 | char * error; 37 | char * token; 38 | } NLPERMANENTMARKERSHOSTS_CHostEntryError; 39 | 40 | // validation 41 | int NLPERMANENTMARKERSHOSTS_is_ip_address(const char * alledged_ip); 42 | int NLPERMANENTMARKERSHOSTS_is_hostname(const char * alledged_hostname); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /pm/models/NLPERMANENTMARKERSHOSTSHostEntry.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | #import "c/parser/hosts.h" 21 | 22 | #define PM_HOST_ENTRY_ERROR_DOMAIN @"nl.permanentmarkers.PMHostsEntry.PM_HOST_ENTRY_ERROR_DOMAIN" 23 | #define PM_HOST_ENTRY_INVALID_IP 1000 24 | #define PM_HOST_ENTRY_INVALID_HOSTNAME 1001 25 | 26 | @interface NLPERMANENTMARKERSHOSTSHostEntry : NSObject { 27 | NSNumber * use; 28 | NSString * address; 29 | NSString * hostnames; 30 | NSString * comment; 31 | } 32 | 33 | - (id) initWithCHostEntry:(NLPERMANENTMARKERSHOSTS_CHostEntry *)host_entry; 34 | - (void)addObserverForAll:(id)observer; 35 | - (void)removeAllObservers:(id)observer; 36 | - (NSString *)toString; 37 | - (void)writeToFileHandle:(NSFileHandle *)handle; 38 | - (void) pushUndoState:(NSDictionary *)change withManager:(NSUndoManager *)undoManager forKeyPath:(NSString *)keyPath; 39 | 40 | @property(readwrite, copy) NSNumber *use; 41 | @property(readwrite, copy) NSString *address; 42 | @property(readwrite, copy) NSString *hostnames; 43 | @property(readonly, copy) NSString *comment; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /c/parser/hostsparser.yy: -------------------------------------------------------------------------------- 1 | %{ 2 | // Hosts, a system preference pane to manage your hosts file. 3 | // Copyright (C) 2011 PermanentMarkers 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program 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 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // contact maintainer at hosts@permanentmarkers.nl 19 | 20 | #include 21 | #include "hosts.h" 22 | #include "hostsparser.tab.h" 23 | 24 | #define yyterminate() return END 25 | %} 26 | 27 | %option nounput never-interactive yylineno reentrant noyywrap 28 | %option prefix="NLPERMANENTMARKERSHOSTS" 29 | %option bison-bridge 30 | 31 | DIGIT [0-9] 32 | IPV4ADDRESS (([[:digit:]]{1,3}"."){3}([[:digit:]]{1,3})) 33 | HEX4 ([[:xdigit:]]{1,4}) 34 | HEXSEQ ({HEX4}(:{HEX4})*) 35 | HEXPART ({HEXSEQ}|({HEXSEQ}::({HEXSEQ}?))|::{HEXSEQ}) 36 | ZONEID (%[a-z0-9]+) 37 | IPV6ADDRESS ({HEXPART}(":"{IPV4ADDRESS})?) 38 | 39 | 40 | %% 41 | 42 | ^{IPV6ADDRESS}{ZONEID}? { 43 | yylval->string = strdup(yytext); 44 | return ADDRESS; 45 | } 46 | 47 | ^{IPV4ADDRESS} { 48 | yylval->string = strdup(yytext); 49 | return ADDRESS; 50 | } 51 | 52 | #[^\n]* { 53 | yylval->string = strdup(yytext); 54 | return COMMENT; 55 | } 56 | 57 | [A-Za-z0-9]+[^\n#: \t]* { 58 | yylval->string = strdup(yytext); 59 | return HOSTNAME; 60 | } 61 | 62 | [[:blank:]] 63 | 64 | "\n" return NEWLINE; 65 | 66 | 67 | %% 68 | -------------------------------------------------------------------------------- /c/parser/main.c: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #include 20 | #include 21 | #include 22 | #include "hosts.h" 23 | 24 | void print_chost_entry(NLPERMANENTMARKERSHOSTS_CHostEntry * entry) { 25 | printf("CHostentry by print_chost_entry callback: %s\t%s\t%s\n", entry->address, entry->hostnames, entry->comment); 26 | NLPERMANENTMARKERSHOSTS_chostentry_destroy(entry); 27 | } 28 | 29 | int main(void){ 30 | NLPERMANENTMARKERSHOSTS_CHostEntry * a = NLPERMANENTMARKERSHOSTS_chostentry_create(NULL, NULL, NULL); 31 | NLPERMANENTMARKERSHOSTS_chostentry_add_hostname(a, "lamo"); 32 | printf("woot %s", a->hostnames); 33 | NLPERMANENTMARKERSHOSTS_chostentry_add_hostname(a, " more!!"); 34 | printf("woot %s\n", a->hostnames); 35 | NLPERMANENTMARKERSHOSTS_chostentry_destroy(a); 36 | NLPERMANENTMARKERSHOSTSparsefile("/etc/hosts", print_chost_entry, NULL); 37 | printf("Het is een ip %d\n", NLPERMANENTMARKERSHOSTS_is_ip_address("127.0.0.1")); 38 | printf("Het is geen ip %d\n", NLPERMANENTMARKERSHOSTS_is_ip_address("127.0.0.1kaka")); 39 | printf("Het is geen ip %d\n", NLPERMANENTMARKERSHOSTS_is_ip_address("ben je sukkel")); 40 | return 0; 41 | } -------------------------------------------------------------------------------- /BuildNotices.txt: -------------------------------------------------------------------------------- 1 | Bison path setting in parser target: 2 | 3 | Original path: /opt/local/bin/bison 4 | Homebrew path: /usr/local/opt/bison/bin/bison 5 | 6 | 7 | Localization: 8 | 9 | - Done with BartyCrouch (https://github.com/Flinesoft/BartyCrouch) 10 | - Project folder contains setup-file .bartycrouch.toml 11 | - To update, run "bartycrouch update" in the project folder 12 | - Known Issue: Localized strings are not used in preference pane, only in app. 13 | 14 | 15 | Notarization: 16 | 17 | You cannot select the archive of a pref pane for notarization, this is why I made an installer. I did it along these steps: 18 | 19 | Find out your developer identities: 20 | security find-identity -p basic -v 21 | 22 | Note the one called "Developer ID Application". I will refer to the actual name with "Your Name (ABCDEFG1234)". 23 | 24 | Sign the pane: 25 | codesign -v -f -s "Developer ID Application: Your Name (ABCDEFG1234)" Hosts.prefPane 26 | 27 | Build Package (pane in folder "build"): 28 | pkgbuild --root build --identifier "nl.your-domain.hosts" --version "1.4.5" --install-location "/Library/PreferencePanes" --sign "Developer ID Installer: Your Name (ABCDEFG1234)" Hosts-PrefPane-1.4.5.pkg 29 | 30 | To certify the installer, you need your ProviderShortname. For this, you have to give altool its app-specific password: 31 | xcrun altool --list-providers -u "your.name@your-domain.nl" -p "@keychain:Developer-altool" 32 | 33 | Certify package: 34 | xcrun altool --notarize-app --primary-bundle-id "nl.your-domain.hosts" --username "your.name@your-domain.nl" --password "@keychain:Developer-altool" --asc-provider "YourName123456" --file "Hosts-PrefPane-1.4.5.pkg" 35 | 36 | Wait, check status: 37 | xcrun altool --notarization-info "YourRequestUUID" --username "your.name@your-domain.nl" --password "@keychain:Developer-altool" 38 | 39 | Staple notarization ticket to package for offline installation: 40 | xcrun stapler staple Hosts-PrefPane-1.4.5.pkg 41 | 42 | 43 | Issue with Check Box disabling: 44 | https://stackoverflow.com/questions/29616204/unable-to-disable-checkbox-nsbutton-inside-a-disabled-nstableview 45 | 46 | -------------------------------------------------------------------------------- /c/parser/Makefile: -------------------------------------------------------------------------------- 1 | # Hosts, a system preference pane to manage your hosts file. 2 | # Copyright (C) 2011 PermanentMarkers 3 | # 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 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | # 17 | # contact maintainer at hosts@permanentmarkers.nl 18 | ifndef BISON_PATH 19 | BISON_PATH := $(shell which bison) 20 | endif 21 | BISON_VERSION_GT_2_5 = $(shell $(BISON_PATH) --version | head -n1 | cut -d' ' -f4 | cut -c 3 | xargs echo "2.5 <= " | bc) 22 | 23 | 24 | 25 | .PHONY: 26 | ifneq ($(BISON_VERSION_GT_2_5), 1) 27 | @echo `$(BISON_PATH) --version | head -n1` 28 | @echo "bison version must be greater then 2.5, make sure bison 2.5 is on your PATH or BISON_PATH is set to the correct bison in the parser's build settings." 29 | @false 30 | endif 31 | 32 | all: .PHONY libs 33 | gcc -Wno-implicit-function-declaration -o hosts -g main.c hostsparser.o 34 | 35 | libs: .PHONY 36 | $(BISON_PATH) -d hostsparser.y 37 | flex --header-file=hostsscanner.h hostsparser.yy 38 | $(BISON_PATH) --report=state hostsparser.y 39 | cc -Wno-implicit-function-declaration -c -g hosts.c lex.NLPERMANENTMARKERSHOSTS.c hostsparser.tab.c 40 | ld -r hosts.o lex.NLPERMANENTMARKERSHOSTS.o hostsparser.tab.o -o hostsparser.o 41 | release: clean libs 42 | gcc -Wno-implicit-function-declaration -O3 -o hosts main.c hostsparser.o 43 | strip hosts 44 | 45 | clean: 46 | -rm -f *.exe *.o hostsparser.tab.c 1 *~ hosts hostsscanner.h hostsparser.output hostsparser.tab.h lex.*.c 47 | -rm -fr hosts.dSYM 48 | 49 | install: 50 | 51 | -------------------------------------------------------------------------------- /pm/models/NLPERMANENTMARKERSHOSTSFileModel.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | #import "pm/utils/NLPERMANENTMARKERSHOSTSFileWriter.h" 21 | #import "pm/auth/NLPERMANENTMARKERSHOSTSAuthorization.h" 22 | #import "pm/controllers/NLPERMANENTMARKERSHOSTSListController.h" 23 | 24 | extern NSMutableArray * NLPERMANENTMARKERSHOSTShostsEntries; 25 | 26 | @interface NLPERMANENTMARKERSHOSTSFileModel : NSObject { 27 | @private 28 | NSUndoManager *undoManager; 29 | NLPERMANENTMARKERSHOSTSFileWriter *writer; 30 | NLPERMANENTMARKERSHOSTSAuthorization *authorization; 31 | IBOutlet NLPERMANENTMARKERSHOSTSListController *controller; 32 | BOOL needsLoad; 33 | } 34 | 35 | - (void) clear; 36 | - (void) load; 37 | 38 | - (NSUInteger) countOfHosts; 39 | - (void) removeObjectFromHostsAtIndex:(NSUInteger) index; 40 | - (id) objectInHostsAtIndex: (NSUInteger) index; 41 | - (id) objectInHostsAtIndexes: (NSIndexSet *) range; 42 | - (void)getHosts:(id *)aBuffer range:(NSRange)aRange; 43 | - (void) insertObject:(id)object inHostsAtIndex:(NSUInteger) index; 44 | - (NSMutableArray *) hosts; 45 | - (void) setHosts:(NSMutableArray *)hosts; 46 | 47 | @property (retain) NSUndoManager *undoManager; 48 | //@property (assign) NSMutableArray *hosts; 49 | @property (retain) NLPERMANENTMARKERSHOSTSAuthorization *authorization; 50 | @end 51 | -------------------------------------------------------------------------------- /c/parser/hostsparser.h: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #ifndef HOSTSPARSER_H 20 | #define HOSTSPARSER_H 21 | 22 | # include "hosts.h" 23 | 24 | /** 25 | * Set the callback that will be called each time a line from the /etc/hosts file 26 | * was parsed. 27 | * 28 | * @param callback the function that will be called after a line was parsed. It 29 | * should accept a HostEntry * as a parameter. 30 | */ 31 | void NLPERMANENTMARKERSHOSTSset_callback(void (*callback)(NLPERMANENTMARKERSHOSTS_CHostEntry *)); 32 | 33 | /** 34 | * Set the error handler that will be called when an error occurs during parsing. 35 | * 36 | * @param error_handler the function that will be called when an error occurred. It 37 | * should accept a NLPERMANENTMARKERSHOSTS_CHostEntryError * as a parameter. 38 | */ 39 | void NLPERMANENTMARKERSHOSTSset_error_callback(void (*error_handler)(NLPERMANENTMARKERSHOSTS_CHostEntryError *)); 40 | 41 | /** 42 | * Parse a hosts file. 43 | * http://publib.boulder.ibm.com/infocenter/zvm/v5r3/index.jsp?topic=/com.ibm.zvm.v53.kill0/hcsk5b2021.htm 44 | * 45 | * @param file_name the name and path to the hosts file. 46 | * @param callback this function will be called each time a hostentry is parsed. 47 | * @param error_handler this function will be called each time a parse error occurred. 48 | */ 49 | void NLPERMANENTMARKERSHOSTSparsefile(char * filename, void (*callback)(NLPERMANENTMARKERSHOSTS_CHostEntry *), void (*error_handler)(NLPERMANENTMARKERSHOSTS_CHostEntryError *) ); 50 | 51 | #endif -------------------------------------------------------------------------------- /pm/controllers/NLPERMANENTMARKERSHOSTSAppController.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import "pm/controllers/NLPERMANENTMARKERSHOSTSAppController.h" 20 | #import "pm/NLPERMANENTMARKERSHOSTSConstants.h" 21 | 22 | @implementation NLPERMANENTMARKERSHOSTSAppController 23 | 24 | @synthesize hostfile; 25 | 26 | - (void) setUp:(NSUndoManager *)undoManager { 27 | // Insert code here to initialize your application 28 | 29 | NSLog(@"setUp"); 30 | hostfile.undoManager = undoManager; 31 | NSLog(@"undomanager is %@", hostfile.undoManager); 32 | 33 | // initialize authorisation settings 34 | authorization = [[NLPERMANENTMARKERSHOSTSAuthorization alloc] initWithAuthView:authView]; 35 | hostfile.authorization = authorization; 36 | authView.delegate = self; 37 | 38 | // We do not really change the value here, but we inform that it has changed 39 | // (actual value is from SFAuthorizationViewUnlockedState) 40 | [self willChangeValueForKey:@"authenticated"]; 41 | [self didChangeValueForKey:@"authenticated"]; 42 | } 43 | 44 | #pragma mark authorisation delegates 45 | 46 | 47 | - (void)authorizationViewDidAuthorize:(SFAuthorizationView *)view { 48 | NSLog(@"i can do what i want"); 49 | [authorization conditionallyInstallAuthorizationRule]; 50 | 51 | // see above 52 | [self willChangeValueForKey:@"authenticated"]; 53 | [self didChangeValueForKey:@"authenticated"]; 54 | } 55 | 56 | - (void)authorizationViewDidDeauthorize:(SFAuthorizationView *)view { 57 | NSLog(@"I can not do what i want"); 58 | 59 | // see above 60 | [self willChangeValueForKey:@"authenticated"]; 61 | [self didChangeValueForKey:@"authenticated"]; 62 | } 63 | 64 | - (BOOL)isAuthenticated{ 65 | return [authView authorizationState] == SFAuthorizationViewUnlockedState; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Hosts.xcodeproj/xcshareddata/xcschemes/parser.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 52 | 53 | 59 | 60 | 66 | 67 | 68 | 69 | 71 | 72 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Hosts.xcodeproj/xcshareddata/xcschemes/HostsPrefpane.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 52 | 53 | 59 | 60 | 66 | 67 | 68 | 69 | 71 | 72 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Hosts.xcodeproj/xcshareddata/xcschemes/HostsApp.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /pm/utils/NLPERMANENTMARKERSHOSTSParserCallbacks.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import 20 | #import "pm/utils/NLPERMANENTMARKERSHOSTSParserCallbacks.h" 21 | #import "pm/models/NLPERMANENTMARKERSHOSTSHostEntry.h" 22 | 23 | 24 | // We need a class here to find the NSBundle for string localization. 25 | // In case we run this as a Pref Pane, NSLocalizedString does not help, and since the 26 | // strings are needed outside a class, we just declare one here. 27 | @interface LocalizationSupportClass: NSObject 28 | @end 29 | 30 | @implementation LocalizationSupportClass 31 | @end 32 | 33 | 34 | // defined in NLPERMANENTMARKERSHOSTSFileModel.m 35 | extern NSMutableArray * NLPERMANENTMARKERSHOSTShostsEntries; 36 | 37 | // callback for the hosts file parser. 38 | void NLPERMANENTMARKERSHOSTSonHostEntryFound(NLPERMANENTMARKERSHOSTS_CHostEntry * entry) { 39 | NLPERMANENTMARKERSHOSTSHostEntry * host_entry = [[NLPERMANENTMARKERSHOSTSHostEntry alloc] initWithCHostEntry:entry]; 40 | [NLPERMANENTMARKERSHOSTShostsEntries addObject:host_entry]; 41 | [host_entry release]; 42 | NLPERMANENTMARKERSHOSTS_chostentry_destroy(entry); 43 | } 44 | 45 | // error handler for the hosts file parser 46 | void NLPERMANENTMARKERSHOSTSonHostsParseError(NLPERMANENTMARKERSHOSTS_CHostEntryError * error) { 47 | LocalizationSupportClass *foo = [[LocalizationSupportClass alloc] init]; 48 | NSBundle *myBundle = [NSBundle bundleForClass:[foo class]]; 49 | 50 | NSString *windowTitle = [myBundle localizedStringForKey:@"Parse error" value:@"" table:nil]; 51 | NSString *errorFormatString = [myBundle localizedStringForKey:@"In /private/etc/hosts on line:%i %s\n\n%s\n\nShould this line be permanently removed from /private/etc/hosts?\nChoose no to quit Hosts and manually correct the error." 52 | value:@"" 53 | table:nil]; 54 | 55 | NSString *errorString = [NSString stringWithFormat:errorFormatString, error->linenumber, error->token, error->error]; 56 | 57 | NSAlert *alert = [NSAlert 58 | alertWithMessageText:windowTitle 59 | defaultButton:[myBundle localizedStringForKey:@"Yes" value:@"" table:nil] 60 | alternateButton:[myBundle localizedStringForKey:@"No" value:@"" table:nil] 61 | otherButton:nil 62 | informativeTextWithFormat:@"%@", errorString]; 63 | 64 | if ([alert runModal] == NSModalResponseCancel) { 65 | [[NSApplication sharedApplication] terminate:nil]; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /pm/utils/NLPERMANENTMARKERSHOSTSFileWriter.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import "pm/NLPERMANENTMARKERSHOSTSConstants.h" 20 | #import "pm/utils/NLPERMANENTMARKERSHOSTSFileWriter.h" 21 | #import "pm/models/NLPERMANENTMARKERSHOSTSHostEntry.h" 22 | 23 | @implementation NLPERMANENTMARKERSHOSTSFileWriter 24 | 25 | + (void) backupHostsFileWithExtension:(NSString *)extension { 26 | NSFileManager *fileManager = [NSFileManager defaultManager]; 27 | 28 | NSString *folder = @"~/Library/Application Support/Hosts/"; 29 | folder = [folder stringByExpandingTildeInPath]; 30 | 31 | if ([fileManager fileExistsAtPath: folder] == NO) 32 | { 33 | [fileManager createDirectoryAtPath:folder withIntermediateDirectories:YES attributes:nil error:nil]; 34 | } 35 | 36 | NSString *fileName = [NSString stringWithFormat:@"hosts.%@", extension]; 37 | folder = [folder stringByAppendingPathComponent: fileName]; 38 | NSLog(@"copying %@ to %@", @PM_HOSTS_FILE_LOCATION, folder); 39 | 40 | if ([fileManager fileExistsAtPath:folder]) { 41 | NSString *backupPath = [folder stringByAppendingPathExtension:@"bck"]; 42 | [fileManager moveItemAtPath:folder toPath:backupPath error:nil]; 43 | [fileManager copyItemAtPath:@PM_HOSTS_FILE_LOCATION toPath:folder error:nil]; 44 | [fileManager removeItemAtPath:backupPath error:nil]; 45 | } else { 46 | [fileManager copyItemAtPath:@PM_HOSTS_FILE_LOCATION toPath:folder error:nil]; 47 | } 48 | 49 | //NSLog(@"Huh an error occurred %@", error); 50 | } 51 | 52 | - (id) initWithAuthorization:(NLPERMANENTMARKERSHOSTSAuthorization *) aNauthorization { 53 | self = [super init]; 54 | if (self) { 55 | authorization = aNauthorization; 56 | [authorization retain]; 57 | } 58 | return self; 59 | } 60 | 61 | - (void) writeHostEntries:(NSArray *)hostEntries { 62 | [authorization obtain]; 63 | [[NSProcessInfo processInfo] disableSuddenTermination]; 64 | // update /etc/hosts 65 | NSPipe * stdIn = [NSPipe pipe]; 66 | NSTask * hostsWriter = [[NSTask alloc] init]; 67 | [hostsWriter setLaunchPath:@"/usr/libexec/authopen"]; 68 | [hostsWriter setArguments:[NSArray arrayWithObjects:@"-w", @PM_HOSTS_FILE_LOCATION, nil]]; 69 | [hostsWriter setStandardInput:stdIn]; 70 | NSFileHandle * stdInHandle = [stdIn fileHandleForWriting]; 71 | 72 | // write hosts data to stdin of hostWriter, so it gets written to /etc/hosts. 73 | for (NLPERMANENTMARKERSHOSTSHostEntry * entry in hostEntries) { 74 | [entry writeToFileHandle:stdInHandle]; 75 | } 76 | [stdInHandle closeFile]; 77 | 78 | [hostsWriter launch]; 79 | [hostsWriter waitUntilExit]; 80 | [hostsWriter release]; 81 | [[NSProcessInfo processInfo] enableSuddenTermination]; 82 | } 83 | 84 | - (void) dealloc { 85 | [authorization release]; 86 | [super dealloc]; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /README.mdown: -------------------------------------------------------------------------------- 1 | ## Hosts, a system preference pane to manage your hosts file 2 | 3 | Hosts adds a preference pane to your system preferences which lets you toggle your 4 | host file entries on and off, as well as add and remove them. 5 | 6 | Hosts.prefpane likes to keep your hosts file clean. When an entry is toggled off, 7 | it is not commented out in the hosts file, but instead stored in the app's 8 | preferences storage. This means you will have to uncomment all your unused host 9 | entries and untoggle them in the prefpane if you want to use them. Comments are 10 | treated as comments and will never show up in the list of host entries! 11 | 12 | Of course Hosts.prefpane will detect edits you made to the ``/etc/hosts`` directly and 13 | merge them into the listing. 14 | 15 | Backups of your hosts file are made in ``~/Library/Application Support/Hosts``. 16 | The backup or your hosts file from before you started using Hosts.prefpane is 17 | called *hosts.orig* and each session a backup is made called *hosts.session*. 18 | 19 | The default host entries that are needed by the OS are hidden and can not be 20 | edited using Hosts.prefpane. 21 | 22 | Many thanks to the [contributors](https://github.com/specialunderwear/Hosts.prefpane/graphs/contributors) 23 | for helping getting the latest release done! 24 | 25 | ![](https://github.com/specialunderwear/Hosts.prefpane/raw/master/screenshots/locked.png) 26 | ![](https://github.com/specialunderwear/Hosts.prefpane/raw/master/screenshots/edit.png) 27 | 28 | ## Download 29 | For now you'll find the latest pre-built preference pane and the app on [Dirk-'s website](https://www.dirk-froehling.de/downloads/downloads.html). ``Hosts App 1.4.5.zip`` includes the app which can be used from any location on your disk. ``Hosts PrefPane 1.4.5.pkg`` is an installer for the preference pane. It will get installed into ``/Library/PreferencePanes``, so you have to enter your admin credentials during installation. The installer is neccessary for macOS Catalina, since all executables have to be notarized, and you cannot notarize a preference pane. 30 | 31 | ## Development hints 32 | ### Compiling the parser 33 | To compile the parser protion of the Hosts PrefPane, you need to have ``bison`` installed somewhere. The current compiler setting expects bison to be in ``/usr/local/opt/bison/bin/``. This is where [Homebrew](https://brew.sh/) installs it (``brew install bison``). 34 | 35 | ### Catalina Installation 36 | Preparing the app for installation on Catalina (macOS 10.15) or higher is straightforward. Just "Archive" the app from Xcode and go through the normal notarization process. 37 | 38 | Preparing the preference pane for installation on Catalina is not that easy. You have to build an installer by using command line tools and deal with all the right developer certificates. Here is a [good description of the process](https://scriptingosx.com/2019/09/notarize-a-command-line-tool/) using a command line tool as an example project. 39 | 40 | ## Licence 41 | 42 | Hosts, a system preference pane to manage your hosts file. 43 | Copyright (C) 2011 PermanentMarkers 44 | 45 | This program is free software: you can redistribute it and/or modify 46 | it under the terms of the GNU General Public License as published by 47 | the Free Software Foundation, either version 3 of the License, or 48 | (at your option) any later version. 49 | 50 | This program is distributed in the hope that it will be useful, 51 | but WITHOUT ANY WARRANTY; without even the implied warranty of 52 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 53 | GNU General Public License for more details. 54 | 55 | You should have received a copy of the GNU General Public License 56 | along with this program. If not, see . 57 | 58 | Contact maintainer at hosts@permanentmarkers.nl 59 | 60 | -------------------------------------------------------------------------------- /c/parser/hosts.c: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #ifndef HOSTS_C 20 | #define HOSTS_C 21 | 22 | #include 23 | #include 24 | #include 25 | #include "hosts.h" 26 | #include "hostsparser.tab.h" 27 | #include "hostsscanner.h" 28 | 29 | // host entry 30 | 31 | NLPERMANENTMARKERSHOSTS_CHostEntry * NLPERMANENTMARKERSHOSTS_chostentry_create(char * address, char * hostnames, char * comment) { 32 | NLPERMANENTMARKERSHOSTS_CHostEntry * host_entry = malloc(sizeof(NLPERMANENTMARKERSHOSTS_CHostEntry)); 33 | host_entry->address = address; 34 | host_entry->hostnames = hostnames; 35 | host_entry->comment = comment; 36 | return host_entry; 37 | } 38 | 39 | NLPERMANENTMARKERSHOSTS_CHostEntry * NLPERMANENTMARKERSHOSTS_chostentry_add_hostname(NLPERMANENTMARKERSHOSTS_CHostEntry *host_entry, char * hostname) { 40 | if (host_entry->hostnames == NULL) { 41 | host_entry->hostnames = malloc((size_t) (strlen(hostname) + 1)); 42 | strcpy(host_entry->hostnames, hostname); 43 | } else { 44 | int length = strlen(host_entry->hostnames) + strlen(hostname) + 2; 45 | char * hostnames = malloc((size_t) length); 46 | strcpy(hostnames, host_entry->hostnames); 47 | strcat(hostnames, " "); 48 | strcat(hostnames, hostname); 49 | free(host_entry->hostnames); 50 | host_entry->hostnames = hostnames; 51 | } 52 | return host_entry; 53 | } 54 | 55 | void NLPERMANENTMARKERSHOSTS_chostentry_destroy(NLPERMANENTMARKERSHOSTS_CHostEntry * host_entry) { 56 | if (host_entry->hostnames != NULL) 57 | free(host_entry->hostnames); 58 | if (host_entry->address != NULL) 59 | free(host_entry->address); 60 | if (host_entry->comment != NULL) 61 | free(host_entry->comment); 62 | 63 | free(host_entry); 64 | } 65 | 66 | // validation 67 | 68 | int NLPERMANENTMARKERSHOSTS_parsed_value_equals(const char * value, int target) { 69 | int result = 0; 70 | yyscan_t scanner; 71 | YYSTYPE NLPERMANENTMARKERSHOSTSlval={}; 72 | NLPERMANENTMARKERSHOSTSlex_init( &scanner ); 73 | YY_BUFFER_STATE handle = NLPERMANENTMARKERSHOSTS_scan_string(value, scanner); 74 | if (NLPERMANENTMARKERSHOSTSlex(&NLPERMANENTMARKERSHOSTSlval, scanner) == target && strcmp(NLPERMANENTMARKERSHOSTSlval.string, value) == 0) { 75 | result = 1; 76 | } 77 | // if lex found a match and set the string it is on the heap. 78 | if (NLPERMANENTMARKERSHOSTSlval.string != NULL) { 79 | NLPERMANENTMARKERSHOSTSfree(NLPERMANENTMARKERSHOSTSlval.string, scanner); 80 | } 81 | NLPERMANENTMARKERSHOSTSlex_destroy(scanner); 82 | return result; 83 | } 84 | 85 | int NLPERMANENTMARKERSHOSTS_is_ip_address(const char * alledged_ip) { 86 | return NLPERMANENTMARKERSHOSTS_parsed_value_equals(alledged_ip, ADDRESS); 87 | } 88 | 89 | int NLPERMANENTMARKERSHOSTS_is_hostname(const char * alledged_hostname) { 90 | return NLPERMANENTMARKERSHOSTS_parsed_value_equals(alledged_hostname, HOSTNAME); 91 | } 92 | #endif -------------------------------------------------------------------------------- /pm/auth/NLPERMANENTMARKERSHOSTSAuthorization.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import "pm/auth/NLPERMANENTMARKERSHOSTSAuthorization.h" 20 | #import "pm/NLPERMANENTMARKERSHOSTSConstants.h" 21 | #import "pm/utils/NLPERMANENTMARKERSHOSTSFileWriter.h" 22 | 23 | @implementation NLPERMANENTMARKERSHOSTSAuthorization 24 | 25 | - (void) conditionallyInstallAuthorizationRule { 26 | AuthorizationRef hostsAuthorizationRef = [[authView authorization] authorizationRef]; 27 | OSStatus updateRightsStatus; 28 | CFDictionaryRef registeredRights = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 29 | 30 | // store rights dictionary in registeredRights. 31 | AuthorizationRightGet(PM_AUTHORISED_FILE, ®isteredRights); 32 | 33 | NSString * rule = [(NSDictionary *)registeredRights valueForKey:@"comment"]; 34 | if ([rule isEqualToString:@PM_AUTHENTICATION_RULE_COMMENT]) { 35 | NSLog(@"the rule is correct"); 36 | } else { 37 | [NLPERMANENTMARKERSHOSTSFileWriter backupHostsFileWithExtension:@"orig"]; 38 | NSArray *keys = [NSArray arrayWithObjects:@"class", @"comment", @"group", @"shared", @"timeout" , nil]; 39 | NSArray *values = [NSArray arrayWithObjects:@"user", @PM_AUTHENTICATION_RULE_COMMENT, @"admin", [NSNumber numberWithBool:YES], [NSNumber numberWithInt:300], nil]; 40 | NSDictionary *rightDefinition = [NSDictionary dictionaryWithObjects:values forKeys:keys]; 41 | updateRightsStatus = AuthorizationRightSet(hostsAuthorizationRef, PM_AUTHORISED_FILE, 42 | (CFDictionaryRef)rightDefinition, 43 | NULL, NULL, NULL); 44 | if (updateRightsStatus == errAuthorizationSuccess) { 45 | NSLog(@"i could write the right"); 46 | } else { 47 | // TODO: raise error. 48 | } 49 | } 50 | CFRelease(registeredRights); 51 | } 52 | 53 | - (id) initWithAuthView:(SFAuthorizationView *) anAuthView { 54 | self = [super init]; 55 | 56 | if (self) { 57 | authView = anAuthView; 58 | 59 | AuthorizationItem hostsAuthorizationItems[2]; 60 | hostsAuthorizationItems[0].name = PM_AUTHENTICATION_RULE; 61 | hostsAuthorizationItems[0].valueLength = 0; 62 | hostsAuthorizationItems[0].value = NULL; 63 | hostsAuthorizationItems[0].flags = 0; 64 | hostsAuthorizationItems[1].name = PM_AUTHORISED_FILE; 65 | hostsAuthorizationItems[1].valueLength = 0; 66 | hostsAuthorizationItems[1].value = NULL; 67 | hostsAuthorizationItems[1].flags = 0; 68 | 69 | hostFileRights.count = 2; 70 | hostFileRights.items = hostsAuthorizationItems; 71 | 72 | [authView setAuthorizationRights:&hostFileRights]; 73 | [authView updateStatus:self]; 74 | [authView setAutoupdate:YES]; 75 | } 76 | return self; 77 | } 78 | 79 | - (void) obtain { 80 | [authView authorize:self]; 81 | } 82 | 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /en.lproj/MainMenu.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSMenuItem"; title = "Preferences…"; ObjectID = "129"; */ 3 | "129.title" = "Preferences…"; 4 | 5 | /* Class = "NSMenu"; title = "Services"; ObjectID = "130"; */ 6 | "130.title" = "Services"; 7 | 8 | /* Class = "NSMenuItem"; title = "Services"; ObjectID = "131"; */ 9 | "131.title" = "Services"; 10 | 11 | /* Class = "NSMenuItem"; title = "Hide Hosts"; ObjectID = "134"; */ 12 | "134.title" = "Hide Hosts"; 13 | 14 | /* Class = "NSMenuItem"; title = "Quit Hosts"; ObjectID = "136"; */ 15 | "136.title" = "Quit Hosts"; 16 | 17 | /* Class = "NSMenuItem"; title = "Hide Others"; ObjectID = "145"; */ 18 | "145.title" = "Hide Others"; 19 | 20 | /* Class = "NSMenuItem"; title = "Show All"; ObjectID = "150"; */ 21 | "150.title" = "Show All"; 22 | 23 | /* Class = "NSMenuItem"; title = "Window"; ObjectID = "19"; */ 24 | "19.title" = "Window"; 25 | 26 | /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "197"; */ 27 | "197.title" = "Copy"; 28 | 29 | /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "198"; */ 30 | "198.title" = "Select All"; 31 | 32 | /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "199"; */ 33 | "199.title" = "Cut"; 34 | 35 | /* Class = "NSMenuItem"; title = "Delete"; ObjectID = "202"; */ 36 | "202.title" = "Delete"; 37 | 38 | /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "203"; */ 39 | "203.title" = "Paste"; 40 | 41 | /* Class = "NSMenu"; title = "Edit"; ObjectID = "205"; */ 42 | "205.title" = "Edit"; 43 | 44 | /* Class = "NSMenuItem"; title = "Undo"; ObjectID = "207"; */ 45 | "207.title" = "Undo"; 46 | 47 | /* Class = "NSMenuItem"; title = "Redo"; ObjectID = "215"; */ 48 | "215.title" = "Redo"; 49 | 50 | /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "217"; */ 51 | "217.title" = "Edit"; 52 | 53 | /* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "23"; */ 54 | "23.title" = "Minimize"; 55 | 56 | /* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "239"; */ 57 | "239.title" = "Zoom"; 58 | 59 | /* Class = "NSMenu"; title = "Window"; ObjectID = "24"; */ 60 | "24.title" = "Window"; 61 | 62 | /* Class = "NSMenu"; title = "AMainMenu"; ObjectID = "29"; */ 63 | "29.title" = "AMainMenu"; 64 | 65 | /* Class = "NSWindow"; title = "Hosts"; ObjectID = "371"; */ 66 | "371.title" = "Hosts"; 67 | 68 | /* Class = "NSMenuItem"; title = "Help"; ObjectID = "490"; */ 69 | "490.title" = "Help"; 70 | 71 | /* Class = "NSMenu"; title = "Help"; ObjectID = "491"; */ 72 | "491.title" = "Help"; 73 | 74 | /* Class = "NSMenuItem"; title = "Hosts Help"; ObjectID = "492"; */ 75 | "492.title" = "Hosts Help"; 76 | 77 | /* Class = "NSMenuItem"; title = "Hosts"; ObjectID = "56"; */ 78 | "56.title" = "Hosts"; 79 | 80 | /* Class = "NSButtonCell"; alternateTitle = "Add a hosts entry below selection"; ObjectID = "566"; */ 81 | "566.alternateTitle" = "Add a hosts entry below selection"; 82 | 83 | /* Class = "NSMenu"; title = "Hosts"; ObjectID = "57"; */ 84 | "57.title" = "Hosts"; 85 | 86 | /* Class = "NSMenuItem"; title = "About Hosts"; ObjectID = "58"; */ 87 | "58.title" = "About Hosts"; 88 | 89 | /* Class = "NSTableColumn"; headerCell.title = "Hostname"; ObjectID = "DPq-b8-uEm"; */ 90 | "DPq-b8-uEm.headerCell.title" = "Hostname"; 91 | 92 | /* Class = "NSTableColumn"; headerCell.title = "IP Address"; ObjectID = "llA-ny-U2n"; */ 93 | "llA-ny-U2n.headerCell.title" = "IP Address"; 94 | 95 | /* Class = "NSTableColumn"; headerCell.title = "Use"; ObjectID = "OZc-d4-idN"; */ 96 | "OZc-d4-idN.headerCell.title" = "Use"; 97 | 98 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "iaE-NJ-j5x"; */ 99 | "iaE-NJ-j5x.title" = ""; 100 | 101 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "kVo-EQ-WiS"; */ 102 | "kVo-EQ-WiS.title" = ""; 103 | 104 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "l1U-1D-OMc"; */ 105 | "l1U-1D-OMc.title" = ""; 106 | 107 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "QYR-GS-HJ6"; */ 108 | "QYR-GS-HJ6.title" = ""; 109 | 110 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "XY1-Fl-mJ4"; */ 111 | "XY1-Fl-mJ4.title" = ""; 112 | -------------------------------------------------------------------------------- /nl.lproj/MainMenu.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSMenuItem"; title = "Preferences…"; ObjectID = "129"; */ 3 | "129.title" = "Vorkeuren…"; 4 | 5 | /* Class = "NSMenu"; title = "Services"; ObjectID = "130"; */ 6 | "130.title" = "Voorzieningen"; 7 | 8 | /* Class = "NSMenuItem"; title = "Services"; ObjectID = "131"; */ 9 | "131.title" = "Voorzieningen"; 10 | 11 | /* Class = "NSMenuItem"; title = "Hide Hosts"; ObjectID = "134"; */ 12 | "134.title" = "Verberg Hosts"; 13 | 14 | /* Class = "NSMenuItem"; title = "Quit Hosts"; ObjectID = "136"; */ 15 | "136.title" = "Stop Hosts"; 16 | 17 | /* Class = "NSMenuItem"; title = "Hide Others"; ObjectID = "145"; */ 18 | "145.title" = "Verberg andere"; 19 | 20 | /* Class = "NSMenuItem"; title = "Show All"; ObjectID = "150"; */ 21 | "150.title" = "Toon alles"; 22 | 23 | /* Class = "NSMenuItem"; title = "Window"; ObjectID = "19"; */ 24 | "19.title" = "Venster"; 25 | 26 | /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "197"; */ 27 | "197.title" = "Kopieer"; 28 | 29 | /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "198"; */ 30 | "198.title" = "Selecteer alles"; 31 | 32 | /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "199"; */ 33 | "199.title" = "Knip"; 34 | 35 | /* Class = "NSMenuItem"; title = "Delete"; ObjectID = "202"; */ 36 | "202.title" = "Verwijder"; 37 | 38 | /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "203"; */ 39 | "203.title" = "Plak"; 40 | 41 | /* Class = "NSMenu"; title = "Edit"; ObjectID = "205"; */ 42 | "205.title" = "Wijzig"; 43 | 44 | /* Class = "NSMenuItem"; title = "Undo"; ObjectID = "207"; */ 45 | "207.title" = "Herstel"; 46 | 47 | /* Class = "NSMenuItem"; title = "Redo"; ObjectID = "215"; */ 48 | "215.title" = "Opnieuw"; 49 | 50 | /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "217"; */ 51 | "217.title" = "Wijzig"; 52 | 53 | /* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "23"; */ 54 | "23.title" = "Minimaliseer"; 55 | 56 | /* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "239"; */ 57 | "239.title" = "Zoom"; 58 | 59 | /* Class = "NSMenu"; title = "Window"; ObjectID = "24"; */ 60 | "24.title" = "Venster"; 61 | 62 | /* Class = "NSMenu"; title = "AMainMenu"; ObjectID = "29"; */ 63 | "29.title" = "AMainMenu"; 64 | 65 | /* Class = "NSWindow"; title = "Hosts"; ObjectID = "371"; */ 66 | "371.title" = "Hosts"; 67 | 68 | /* Class = "NSMenuItem"; title = "Help"; ObjectID = "490"; */ 69 | "490.title" = "Help"; 70 | 71 | /* Class = "NSMenu"; title = "Help"; ObjectID = "491"; */ 72 | "491.title" = "Help"; 73 | 74 | /* Class = "NSMenuItem"; title = "Hosts Help"; ObjectID = "492"; */ 75 | "492.title" = "Hosts Help"; 76 | 77 | /* Class = "NSMenuItem"; title = "Hosts"; ObjectID = "56"; */ 78 | "56.title" = "Hosts"; 79 | 80 | /* Class = "NSButtonCell"; alternateTitle = "Add a hosts entry below selection"; ObjectID = "566"; */ 81 | "566.alternateTitle" = "Voeg een hosts item toe onder selectie"; 82 | 83 | /* Class = "NSMenu"; title = "Hosts"; ObjectID = "57"; */ 84 | "57.title" = "Hosts"; 85 | 86 | /* Class = "NSMenuItem"; title = "About Hosts"; ObjectID = "58"; */ 87 | "58.title" = "Over Hosts"; 88 | 89 | /* Class = "NSTableColumn"; headerCell.title = "Hostname"; ObjectID = "DPq-b8-uEm"; */ 90 | "DPq-b8-uEm.headerCell.title" = "Hostnaam"; 91 | 92 | /* Class = "NSTableColumn"; headerCell.title = "IP Address"; ObjectID = "llA-ny-U2n"; */ 93 | "llA-ny-U2n.headerCell.title" = "IP-adres"; 94 | 95 | /* Class = "NSTableColumn"; headerCell.title = "Use"; ObjectID = "OZc-d4-idN"; */ 96 | "OZc-d4-idN.headerCell.title" = "Actief"; 97 | 98 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "iaE-NJ-j5x"; */ 99 | "iaE-NJ-j5x.title" = ""; 100 | 101 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "kVo-EQ-WiS"; */ 102 | "kVo-EQ-WiS.title" = ""; 103 | 104 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "l1U-1D-OMc"; */ 105 | "l1U-1D-OMc.title" = ""; 106 | 107 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "QYR-GS-HJ6"; */ 108 | "QYR-GS-HJ6.title" = ""; 109 | 110 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "XY1-Fl-mJ4"; */ 111 | "XY1-Fl-mJ4.title" = ""; 112 | -------------------------------------------------------------------------------- /fr.lproj/MainMenu.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSMenuItem"; title = "Preferences…"; ObjectID = "129"; */ 3 | "129.title" = "Préférences…"; 4 | 5 | /* Class = "NSMenu"; title = "Services"; ObjectID = "130"; */ 6 | "130.title" = "Services"; 7 | 8 | /* Class = "NSMenuItem"; title = "Services"; ObjectID = "131"; */ 9 | "131.title" = "Services"; 10 | 11 | /* Class = "NSMenuItem"; title = "Hide Hosts"; ObjectID = "134"; */ 12 | "134.title" = "Masquer Hosts"; 13 | 14 | /* Class = "NSMenuItem"; title = "Quit Hosts"; ObjectID = "136"; */ 15 | "136.title" = "Quitter Hosts"; 16 | 17 | /* Class = "NSMenuItem"; title = "Hide Others"; ObjectID = "145"; */ 18 | "145.title" = "Masquer le autres"; 19 | 20 | /* Class = "NSMenuItem"; title = "Show All"; ObjectID = "150"; */ 21 | "150.title" = "Tout afficher"; 22 | 23 | /* Class = "NSMenuItem"; title = "Window"; ObjectID = "19"; */ 24 | "19.title" = "Fenêtre"; 25 | 26 | /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "197"; */ 27 | "197.title" = "Copier"; 28 | 29 | /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "198"; */ 30 | "198.title" = "Tout sélectionner"; 31 | 32 | /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "199"; */ 33 | "199.title" = "Couper"; 34 | 35 | /* Class = "NSMenuItem"; title = "Delete"; ObjectID = "202"; */ 36 | "202.title" = "Supprimer"; 37 | 38 | /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "203"; */ 39 | "203.title" = "Coller"; 40 | 41 | /* Class = "NSMenu"; title = "Edit"; ObjectID = "205"; */ 42 | "205.title" = "Édition"; 43 | 44 | /* Class = "NSMenuItem"; title = "Undo"; ObjectID = "207"; */ 45 | "207.title" = "Annuler"; 46 | 47 | /* Class = "NSMenuItem"; title = "Redo"; ObjectID = "215"; */ 48 | "215.title" = "Rétablir"; 49 | 50 | /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "217"; */ 51 | "217.title" = "Édition"; 52 | 53 | /* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "23"; */ 54 | "23.title" = "Réduire"; 55 | 56 | /* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "239"; */ 57 | "239.title" = "Zoom"; 58 | 59 | /* Class = "NSMenu"; title = "Window"; ObjectID = "24"; */ 60 | "24.title" = "Fenêtre"; 61 | 62 | /* Class = "NSMenu"; title = "AMainMenu"; ObjectID = "29"; */ 63 | "29.title" = "AMainMenu"; 64 | 65 | /* Class = "NSWindow"; title = "Hosts"; ObjectID = "371"; */ 66 | "371.title" = "Hosts"; 67 | 68 | /* Class = "NSMenuItem"; title = "Help"; ObjectID = "490"; */ 69 | "490.title" = "Aide"; 70 | 71 | /* Class = "NSMenu"; title = "Help"; ObjectID = "491"; */ 72 | "491.title" = "Aide"; 73 | 74 | /* Class = "NSMenuItem"; title = "Hosts Help"; ObjectID = "492"; */ 75 | "492.title" = "Aide de Hosts"; 76 | 77 | /* Class = "NSMenuItem"; title = "Hosts"; ObjectID = "56"; */ 78 | "56.title" = "Hosts"; 79 | 80 | /* Class = "NSButtonCell"; alternateTitle = "Add a hosts entry below selection"; ObjectID = "566"; */ 81 | "566.alternateTitle" = "Ajouter une entrée d'hôte sous la sélection"; 82 | 83 | /* Class = "NSMenu"; title = "Hosts"; ObjectID = "57"; */ 84 | "57.title" = "Hosts"; 85 | 86 | /* Class = "NSMenuItem"; title = "About Hosts"; ObjectID = "58"; */ 87 | "58.title" = "À propos de Hosts"; 88 | 89 | /* Class = "NSTableColumn"; headerCell.title = "Hostname"; ObjectID = "DPq-b8-uEm"; */ 90 | "DPq-b8-uEm.headerCell.title" = "Nom d'hôte"; 91 | 92 | /* Class = "NSTableColumn"; headerCell.title = "IP Address"; ObjectID = "llA-ny-U2n"; */ 93 | "llA-ny-U2n.headerCell.title" = "Adresse IP"; 94 | 95 | /* Class = "NSTableColumn"; headerCell.title = "Use"; ObjectID = "OZc-d4-idN"; */ 96 | "OZc-d4-idN.headerCell.title" = "En activité"; 97 | 98 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "iaE-NJ-j5x"; */ 99 | "iaE-NJ-j5x.title" = ""; 100 | 101 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "kVo-EQ-WiS"; */ 102 | "kVo-EQ-WiS.title" = ""; 103 | 104 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "l1U-1D-OMc"; */ 105 | "l1U-1D-OMc.title" = ""; 106 | 107 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "QYR-GS-HJ6"; */ 108 | "QYR-GS-HJ6.title" = ""; 109 | 110 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "XY1-Fl-mJ4"; */ 111 | "XY1-Fl-mJ4.title" = ""; 112 | -------------------------------------------------------------------------------- /de.lproj/MainMenu.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSMenuItem"; title = "Preferences…"; ObjectID = "129"; */ 3 | "129.title" = "Einstellungen…"; 4 | 5 | /* Class = "NSMenu"; title = "Services"; ObjectID = "130"; */ 6 | "130.title" = "Dienste"; 7 | 8 | /* Class = "NSMenuItem"; title = "Services"; ObjectID = "131"; */ 9 | "131.title" = "Dienste"; 10 | 11 | /* Class = "NSMenuItem"; title = "Hide Hosts"; ObjectID = "134"; */ 12 | "134.title" = "Hosts ausblenden"; 13 | 14 | /* Class = "NSMenuItem"; title = "Quit Hosts"; ObjectID = "136"; */ 15 | "136.title" = "Hosts beenden"; 16 | 17 | /* Class = "NSMenuItem"; title = "Hide Others"; ObjectID = "145"; */ 18 | "145.title" = "Andere ausblenden"; 19 | 20 | /* Class = "NSMenuItem"; title = "Show All"; ObjectID = "150"; */ 21 | "150.title" = "Alle einblenden"; 22 | 23 | /* Class = "NSMenuItem"; title = "Window"; ObjectID = "19"; */ 24 | "19.title" = "Fenster"; 25 | 26 | /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "197"; */ 27 | "197.title" = "Kopieren"; 28 | 29 | /* Class = "NSMenuItem"; title = "Select All"; ObjectID = "198"; */ 30 | "198.title" = "Alles auswählen"; 31 | 32 | /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "199"; */ 33 | "199.title" = "Ausschneiden"; 34 | 35 | /* Class = "NSMenuItem"; title = "Delete"; ObjectID = "202"; */ 36 | "202.title" = "Löschen"; 37 | 38 | /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "203"; */ 39 | "203.title" = "Einfügen"; 40 | 41 | /* Class = "NSMenu"; title = "Edit"; ObjectID = "205"; */ 42 | "205.title" = "Bearbeiten"; 43 | 44 | /* Class = "NSMenuItem"; title = "Undo"; ObjectID = "207"; */ 45 | "207.title" = "Widerrufen"; 46 | 47 | /* Class = "NSMenuItem"; title = "Redo"; ObjectID = "215"; */ 48 | "215.title" = "Wiederholen"; 49 | 50 | /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "217"; */ 51 | "217.title" = "Bearbeiten"; 52 | 53 | /* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "23"; */ 54 | "23.title" = "Minimieren"; 55 | 56 | /* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "239"; */ 57 | "239.title" = "Zoom"; 58 | 59 | /* Class = "NSMenu"; title = "Window"; ObjectID = "24"; */ 60 | "24.title" = "Fenster"; 61 | 62 | /* Class = "NSMenu"; title = "AMainMenu"; ObjectID = "29"; */ 63 | "29.title" = "AMainMenu"; 64 | 65 | /* Class = "NSWindow"; title = "Hosts"; ObjectID = "371"; */ 66 | "371.title" = "Hosts"; 67 | 68 | /* Class = "NSMenuItem"; title = "Help"; ObjectID = "490"; */ 69 | "490.title" = "Hilfe"; 70 | 71 | /* Class = "NSMenu"; title = "Help"; ObjectID = "491"; */ 72 | "491.title" = "Hilfe"; 73 | 74 | /* Class = "NSMenuItem"; title = "Hosts Help"; ObjectID = "492"; */ 75 | "492.title" = "Hosts Hilfe"; 76 | 77 | /* Class = "NSMenuItem"; title = "Hosts"; ObjectID = "56"; */ 78 | "56.title" = "Hosts"; 79 | 80 | /* Class = "NSButtonCell"; alternateTitle = "Add a hosts entry below selection"; ObjectID = "566"; */ 81 | "566.alternateTitle" = "Host-Eintrag unter ausgewählter Zeile einfügen"; 82 | 83 | /* Class = "NSMenu"; title = "Hosts"; ObjectID = "57"; */ 84 | "57.title" = "Hosts"; 85 | 86 | /* Class = "NSMenuItem"; title = "About Hosts"; ObjectID = "58"; */ 87 | "58.title" = "Über Hosts"; 88 | 89 | /* Class = "NSTableColumn"; headerCell.title = "Hostname"; ObjectID = "DPq-b8-uEm"; */ 90 | "DPq-b8-uEm.headerCell.title" = "Hostname"; 91 | 92 | /* Class = "NSTableColumn"; headerCell.title = "IP Address"; ObjectID = "llA-ny-U2n"; */ 93 | "llA-ny-U2n.headerCell.title" = "IP-Adresse"; 94 | 95 | /* Class = "NSTableColumn"; headerCell.title = "Use"; ObjectID = "OZc-d4-idN"; */ 96 | "OZc-d4-idN.headerCell.title" = "Aktiv"; 97 | 98 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "iaE-NJ-j5x"; */ 99 | "iaE-NJ-j5x.title" = ""; 100 | 101 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "kVo-EQ-WiS"; */ 102 | "kVo-EQ-WiS.title" = ""; 103 | 104 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "l1U-1D-OMc"; */ 105 | "l1U-1D-OMc.title" = ""; 106 | 107 | /* Class = "NSTextFieldCell"; title = "Table View Cell"; ObjectID = "QYR-GS-HJ6"; */ 108 | "QYR-GS-HJ6.title" = ""; 109 | 110 | /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "XY1-Fl-mJ4"; */ 111 | "XY1-Fl-mJ4.title" = ""; 112 | -------------------------------------------------------------------------------- /c/parser/hostsparser.y: -------------------------------------------------------------------------------- 1 | %{ 2 | // Hosts, a system preference pane to manage your hosts file. 3 | // Copyright (C) 2011 PermanentMarkers 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program 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 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // contact maintainer at hosts@permanentmarkers.nl 19 | 20 | #include 21 | #include 22 | #include 23 | #include "hosts.h" 24 | #include "hostsparser.h" 25 | 26 | #ifndef YYSTYPE 27 | #define YYSTYPE NLPERMANENTMARKERSHOSTS_YYSTYPE 28 | #define YYSTYPE_IS_TRIVIAL 1 29 | #define yystype YYSTYPE 30 | #define YYSTYPE_IS_DECLARED 1 31 | typedef union YYSTYPE 32 | { 33 | NLPERMANENTMARKERSHOSTS_CHostEntry * hostentry; 34 | char * string; 35 | } YYSTYPE; 36 | #endif 37 | 38 | // predeclare bison functions 39 | void NLPERMANENTMARKERSHOSTSerror (void * scanner, char const * error); 40 | 41 | // predeclare lex functions. 42 | FILE *NLPERMANENTMARKERSHOSTSget_in (void * scanner); 43 | void NLPERMANENTMARKERSHOSTSset_in (FILE * in_str , void * scanner); 44 | YYSTYPE * NLPERMANENTMARKERSHOSTSget_lval (void * scanner ); 45 | 46 | // callback for parser results. 47 | void (*NLPERMANENTMARKERSHOSTS_callback)(NLPERMANENTMARKERSHOSTS_CHostEntry *) = NULL; 48 | // callback for parser errors. 49 | void (*NLPERMANENTMARKERSHOSTS_error_callback)(NLPERMANENTMARKERSHOSTS_CHostEntryError *) = NULL; 50 | 51 | void NLPERMANENTMARKERSHOSTSparsefile(char * filename, void (*callback)(NLPERMANENTMARKERSHOSTS_CHostEntry *), void (*error_handler)(NLPERMANENTMARKERSHOSTS_CHostEntryError *) ) { 52 | void * scanner; 53 | NLPERMANENTMARKERSHOSTS_callback = callback; 54 | NLPERMANENTMARKERSHOSTS_error_callback = error_handler; 55 | 56 | NLPERMANENTMARKERSHOSTSlex_init (&scanner); 57 | FILE *file_handle = fopen(filename, "r"); 58 | NLPERMANENTMARKERSHOSTSset_in(file_handle, scanner); 59 | NLPERMANENTMARKERSHOSTSparse(scanner); 60 | NLPERMANENTMARKERSHOSTSlex_destroy(scanner); 61 | } 62 | %} 63 | 64 | %define api.pure 65 | %error-verbose 66 | %name-prefix="NLPERMANENTMARKERSHOSTS" 67 | 68 | %expect 2 69 | %token COMMENT ADDRESS HOSTNAME NEWLINE 70 | %token END 0 71 | 72 | %union { 73 | NLPERMANENTMARKERSHOSTS_CHostEntry * hostentry; 74 | char * string; 75 | } 76 | 77 | %type ADDRESS COMMENT HOSTNAME 78 | %type hostnames 79 | %type rule 80 | 81 | %destructor { free($$); } ADDRESS COMMENT HOSTNAME 82 | %destructor { NLPERMANENTMARKERSHOSTS_chostentry_destroy($$);} hostnames rule 83 | 84 | %parse-param {void *scanner} 85 | %lex-param {yyscan_t *scanner} 86 | 87 | %% 88 | 89 | input: 90 | | input line 91 | ; 92 | 93 | hostnames: HOSTNAME { $$ = NLPERMANENTMARKERSHOSTS_chostentry_create(NULL, $1, NULL); } 94 | | hostnames HOSTNAME { $$ = NLPERMANENTMARKERSHOSTS_chostentry_add_hostname($1, $2); } 95 | ; 96 | 97 | line: rule NEWLINE { NLPERMANENTMARKERSHOSTS_callback($1); } 98 | | rule { NLPERMANENTMARKERSHOSTS_callback($1);} 99 | | NEWLINE { NLPERMANENTMARKERSHOSTS_callback(NLPERMANENTMARKERSHOSTS_chostentry_create(NULL, NULL, NULL)); } 100 | | error NEWLINE {yyerrok;} 101 | ; 102 | 103 | rule: ADDRESS hostnames COMMENT { $2->address = $1; $2->comment = $3; $$ = $2;} 104 | | ADDRESS hostnames { $2->address = $1; $$ = $2;} 105 | | COMMENT { $$ = NLPERMANENTMARKERSHOSTS_chostentry_create(NULL, NULL, $1);} 106 | ; 107 | 108 | %% 109 | 110 | void NLPERMANENTMARKERSHOSTSerror (void * scanner, char const * error) { 111 | YYSTYPE * lval = NLPERMANENTMARKERSHOSTSget_lval(scanner); 112 | 113 | if (NLPERMANENTMARKERSHOSTS_error_callback != NULL) { 114 | NLPERMANENTMARKERSHOSTS_CHostEntryError error_obj; 115 | 116 | error_obj.linenumber = NLPERMANENTMARKERSHOSTSget_lineno(scanner); 117 | error_obj.error = strdup(error); 118 | error_obj.token = strdup(lval->string); 119 | 120 | NLPERMANENTMARKERSHOSTS_error_callback(&error_obj); 121 | 122 | free(error_obj.error); 123 | free(error_obj.token); 124 | 125 | } else { 126 | printf("Error parsing /etc/hosts line:%i %s\n%s\n", NLPERMANENTMARKERSHOSTSget_lineno(scanner), lval->string, error); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /pm/controllers/NLPERMANENTMARKERSHOSTSListController.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | 20 | #import "pm/controllers/NLPERMANENTMARKERSHOSTSListController.h" 21 | #import "pm/models/NLPERMANENTMARKERSHOSTSHostEntry.h" 22 | 23 | #define PM_HOST_ENTRY_DATA_TYPE @"nl.permanentmarkers.NLPERMANENTMARKERSHOSTSHostEntry" 24 | 25 | @implementation NLPERMANENTMARKERSHOSTSListController 26 | 27 | //@synthesize tableView; 28 | 29 | - (id) initWithCoder:(NSCoder *)aDecoder { 30 | self = [super initWithCoder:aDecoder]; 31 | 32 | // filter default rules, comments and empty lines. 33 | self.clearsFilterPredicateOnInsertion = NO; 34 | NSString * predicate = @"(NOT (hostnames in { '', 'localhost', 'broadcasthost' }) AND (address != '')) OR (comment == NIL)"; 35 | self.filterPredicate = [NSPredicate predicateWithFormat:predicate]; 36 | return self; 37 | } 38 | 39 | - (IBAction) insertHostEntry:(id)sender; 40 | { 41 | NLPERMANENTMARKERSHOSTSHostEntry * new_entry = [[NLPERMANENTMARKERSHOSTSHostEntry alloc] init]; 42 | 43 | NSUInteger at_index = [self selectionIndex]; 44 | if (at_index == NSNotFound) { 45 | [self addObject:new_entry]; 46 | // new item is automatically selected. 47 | at_index = [self selectionIndex]; 48 | } else { 49 | [self insertObject:new_entry afterArrangedObjectIndex:at_index]; 50 | at_index++; 51 | } 52 | 53 | [new_entry release]; 54 | [tableView editColumn:1 row:at_index withEvent:nil select:YES]; 55 | } 56 | 57 | - (IBAction) confirmDeleteItem:(id)sender { 58 | NSUInteger at_index = [self selectionIndex]; 59 | NLPERMANENTMARKERSHOSTSHostEntry *entry = [[self arrangedObjects] objectAtIndex:at_index]; 60 | 61 | NSString *title = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Confirm deletion" value:@"" table:nil]; 62 | NSString *description = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Are you sure you want to permanently remove:\n%@ from /etc/hosts?" value:@"" table:nil]; 63 | description = [NSString stringWithFormat:description, [entry toString]]; 64 | NSAlert *alert = [NSAlert alertWithMessageText:title 65 | defaultButton:[[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Yes" value:@"" table:nil] 66 | alternateButton:[[NSBundle bundleForClass: [self class]] localizedStringForKey:@"No" value:@"" table:nil] 67 | otherButton:nil 68 | informativeTextWithFormat:@"%@", description]; 69 | [alert beginSheetModalForWindow:[[NSApplication sharedApplication] mainWindow] modalDelegate:self didEndSelector:@selector(alertEnded:code:context:) contextInfo:NULL]; 70 | } 71 | 72 | - (void)alertEnded:(NSAlert *)alert code:(int)aChoice context:(void *) v { 73 | if (aChoice == NSAlertDefaultReturn) { 74 | [self remove:nil]; 75 | } 76 | } 77 | 78 | 79 | - (void)insertObject:(id)object afterArrangedObjectIndex:(NSUInteger)index { 80 | // get selected object and it's index in the content array 81 | id selected_object = [[self arrangedObjects] objectAtIndex:index]; 82 | NSUInteger real_index = [[self content] indexOfObject:selected_object]; 83 | 84 | // get binding and send message to insert object in content array. 85 | // no you can't write to 'content', it is a proxy object. 86 | NSDictionary * bindingInfo = [self infoForBinding:@"contentArray"]; 87 | [[bindingInfo valueForKey:NSObservedObjectKey] 88 | insertValue:object atIndex:real_index + 1 89 | inPropertyWithKey:[bindingInfo valueForKey:NSObservedKeyPathKey] 90 | ]; 91 | // update view 92 | [self rearrangeObjects]; 93 | // make tab work correctly. 94 | [self setSelectionIndex:index + 1]; 95 | } 96 | 97 | - (id) tableView { 98 | return tableView; 99 | } 100 | 101 | - (void)setTableView:(NSTableView *)tableViewArgument { 102 | NSLog(@"tableview set"); 103 | [self willChangeValueForKey:@"tableView"]; 104 | tableView = tableViewArgument; 105 | [tableView registerForDraggedTypes:[NSArray arrayWithObject:PM_HOST_ENTRY_DATA_TYPE]]; 106 | [self didChangeValueForKey:@"tableView"]; 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /pm/models/NLPERMANENTMARKERSHOSTSHostEntry.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import "NLPERMANENTMARKERSHOSTSHostEntry.h" 20 | #import "c/parser/hosts.h" 21 | 22 | @implementation NLPERMANENTMARKERSHOSTSHostEntry 23 | 24 | @synthesize use, address, hostnames, comment; 25 | 26 | - (id) init { 27 | self = [super init]; 28 | if (self) { 29 | use = [NSNumber numberWithInteger:NSOnState]; 30 | address = nil; 31 | hostnames = nil; 32 | comment = nil; 33 | } 34 | return self; 35 | } 36 | 37 | - (id) initWithCHostEntry:(NLPERMANENTMARKERSHOSTS_CHostEntry *) entry { 38 | self = [super init]; 39 | use = [NSNumber numberWithInteger:NSOnState]; 40 | address = [NSString alloc]; 41 | hostnames = [NSString alloc]; 42 | comment = [NSString alloc]; 43 | 44 | if (entry->address != NULL) { 45 | address = [address initWithCString:entry->address encoding:NSUTF8StringEncoding]; 46 | } else { 47 | address = [address init]; 48 | } 49 | 50 | if (entry->hostnames != NULL) { 51 | hostnames = [hostnames initWithCString:entry->hostnames encoding:NSUTF8StringEncoding]; 52 | } else { 53 | hostnames = [hostnames init]; 54 | } 55 | 56 | if (entry->comment != NULL) { 57 | comment = [comment initWithCString:entry->comment encoding:NSUTF8StringEncoding]; 58 | } else { 59 | comment = [comment init]; 60 | } 61 | 62 | return self; 63 | } 64 | 65 | - (BOOL) isEqualToHostEntry:(NLPERMANENTMARKERSHOSTSHostEntry *) object { 66 | return [use isEqualToNumber: object.use] && 67 | [address isEqualToString: object.address] && 68 | [hostnames isEqualToString: object.hostnames] && 69 | [comment isEqualToString: object.comment]; 70 | } 71 | 72 | - (void) pushUndoState:(NSDictionary *)change withManager:(NSUndoManager *)undoManager forKeyPath:(NSString *) keyPath{ 73 | // NSLog(@"is edit with undoManager %@ can undo %@", undoManager, [undoManager canUndo]); 74 | id oldValue = [change objectForKey:NSKeyValueChangeOldKey]; 75 | if (oldValue == [NSNull null]) { 76 | oldValue = nil; 77 | } 78 | NSLog(@"old value %@", oldValue); 79 | [[undoManager prepareWithInvocationTarget:self] setValue:oldValue forKeyPath:keyPath]; 80 | NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Edit" value:@"" table:nil]; 81 | [undoManager setActionName:undoActionName]; 82 | 83 | } 84 | 85 | - (void) dealloc { 86 | [use release]; 87 | [address release]; 88 | [hostnames release]; 89 | [comment release]; 90 | [super dealloc]; 91 | } 92 | 93 | #pragma mark - 94 | #pragma mark validation 95 | 96 | - (BOOL) validateAddress:(id *)ioValue error:(NSError **)outError { 97 | NSLog(@"validateAddress"); 98 | if (*ioValue != nil && NLPERMANENTMARKERSHOSTS_is_ip_address([*ioValue UTF8String])) { 99 | NSLog(@"Is ip"); 100 | return YES; 101 | } else { 102 | NSLog(@"is not an ip"); 103 | if (outError != NULL) { 104 | NSString * errorStr = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Please enter a valid ip address" value:@"" table:nil]; 105 | NSDictionary * userInfoDict = [NSDictionary dictionaryWithObject:errorStr 106 | forKey:NSLocalizedDescriptionKey]; 107 | NSError *error = [NSError errorWithDomain:PM_HOST_ENTRY_ERROR_DOMAIN 108 | code:PM_HOST_ENTRY_INVALID_IP 109 | userInfo:userInfoDict]; 110 | *outError = error; 111 | } 112 | return NO; 113 | } 114 | } 115 | 116 | - (BOOL) validateArrayOfHostnames:(NSArray *) hostNames { 117 | BOOL result = YES; 118 | for (NSString * hostname in hostNames) { 119 | result = result && NLPERMANENTMARKERSHOSTS_is_hostname([hostname UTF8String]); 120 | } 121 | 122 | return result; 123 | } 124 | 125 | - (BOOL) validateHostnames:(id *)ioValue error:(NSError **) outError { 126 | NSLog(@"hostnames validation"); 127 | NSArray * hostNames = [*ioValue componentsSeparatedByString:@" "]; 128 | if (*ioValue != nil && [self validateArrayOfHostnames:hostNames]) { 129 | NSLog(@"is hostname"); 130 | return YES; 131 | } else { 132 | if (outError != NULL) { 133 | NSString * errorStr = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Please enter a valid hostname" value:@"" table:nil]; 134 | NSDictionary * userInfoDict = [NSDictionary dictionaryWithObject:errorStr 135 | forKey:NSLocalizedDescriptionKey]; 136 | NSError *error = [NSError errorWithDomain:PM_HOST_ENTRY_ERROR_DOMAIN 137 | code:PM_HOST_ENTRY_INVALID_HOSTNAME 138 | userInfo:userInfoDict]; 139 | *outError = error; 140 | } 141 | return NO; 142 | } 143 | } 144 | 145 | #pragma mark coder methods 146 | 147 | - (void) encodeWithCoder:(NSCoder *)aCoder { 148 | [aCoder encodeObject:use forKey:@"use"]; 149 | [aCoder encodeObject:address forKey:@"address"]; 150 | [aCoder encodeObject:hostnames forKey:@"hostnames"]; 151 | [aCoder encodeObject:comment forKey:@"comment"]; 152 | } 153 | 154 | - (id)initWithCoder:(NSCoder *)aDecoder { 155 | self = [super init]; 156 | use = [[aDecoder decodeObjectForKey:@"use"] retain]; 157 | address = [[aDecoder decodeObjectForKey:@"address"] retain]; 158 | hostnames = [[aDecoder decodeObjectForKey:@"hostnames"] retain]; 159 | comment = [[aDecoder decodeObjectForKey:@"comment"] retain]; 160 | return self; 161 | } 162 | 163 | #pragma mark observer helpers 164 | 165 | - (void)addObserverForAll:(id)observer { 166 | [self addObserver:observer forKeyPath:@"use" options:NSKeyValueObservingOptionOld context:nil]; 167 | [self addObserver:observer forKeyPath:@"address" options:NSKeyValueObservingOptionOld context:nil]; 168 | [self addObserver:observer forKeyPath:@"hostnames" options:NSKeyValueObservingOptionOld context:nil]; 169 | [self addObserver:observer forKeyPath:@"comment" options:NSKeyValueObservingOptionOld context:nil]; 170 | } 171 | 172 | - (void)removeAllObservers:(id)observer { 173 | [self removeObserver:observer forKeyPath:@"use"]; 174 | [self removeObserver:observer forKeyPath:@"address"]; 175 | [self removeObserver:observer forKeyPath:@"hostnames"]; 176 | [self removeObserver:observer forKeyPath:@"comment"]; 177 | } 178 | 179 | #pragma mark serialize to hosts file 180 | 181 | - (NSString *)toString { 182 | NSString * line; 183 | if ([comment length] && [address length]) { 184 | assert([hostnames length]); 185 | line = [NSString stringWithFormat:@"%@\t%@ %@\n", address, hostnames, comment]; 186 | } else if ([address length]) { 187 | line = [NSString stringWithFormat:@"%@\t%@\n", address, hostnames]; 188 | } else { 189 | line = [NSString stringWithFormat:@"%@\n", comment]; 190 | } 191 | return line; 192 | } 193 | 194 | - (void)writeToFileHandle:(NSFileHandle *)handle { 195 | if ([use integerValue] == NSOnState) { 196 | NSString *line = [self toString]; 197 | [handle writeData:[line dataUsingEncoding:NSUTF8StringEncoding]]; 198 | } 199 | } 200 | 201 | @end 202 | -------------------------------------------------------------------------------- /pm/models/NLPERMANENTMARKERSHOSTSFileModel.m: -------------------------------------------------------------------------------- 1 | // Hosts, a system preference pane to manage your hosts file. 2 | // Copyright (C) 2011 PermanentMarkers 3 | // 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 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | // contact maintainer at hosts@permanentmarkers.nl 18 | 19 | #import "c/parser/hostsparser.h" 20 | #import "pm/NLPERMANENTMARKERSHOSTSConstants.h" 21 | #import "pm/models/NLPERMANENTMARKERSHOSTSFileModel.h" 22 | #import "pm/models/NLPERMANENTMARKERSHOSTSHostEntry.h" 23 | #import "pm/utils/NLPERMANENTMARKERSHOSTSFileWriter.h" 24 | #import "pm/utils/NLPERMANENTMARKERSHOSTSParserCallbacks.h" 25 | 26 | // The hosts array, initialized by NLPERMANENTMARKERSHOSTSFileModel.initialize 27 | NSMutableArray * NLPERMANENTMARKERSHOSTShostsEntries; 28 | 29 | @implementation NLPERMANENTMARKERSHOSTSFileModel 30 | 31 | @synthesize undoManager, authorization; 32 | 33 | #pragma mark class methods 34 | + (void) initialize { 35 | if (self == [NLPERMANENTMARKERSHOSTSFileModel class]) { 36 | // initialize hosts array 37 | NLPERMANENTMARKERSHOSTShostsEntries = [NSMutableArray new]; 38 | 39 | // initialize hosts default storage. 40 | NSData * current_hosts_archive = [NSKeyedArchiver archivedDataWithRootObject:NLPERMANENTMARKERSHOSTShostsEntries]; 41 | NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithObject:current_hosts_archive forKey:PMHOSTS_DEFAULTS_KEY]; 42 | [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; 43 | } 44 | } 45 | 46 | #pragma mark kvc compliance for hosts key 47 | 48 | - (NSUInteger) countOfHosts { 49 | return [NLPERMANENTMARKERSHOSTShostsEntries count]; 50 | } 51 | 52 | - (id) objectInHostsAtIndex: (NSUInteger) index { 53 | return [NLPERMANENTMARKERSHOSTShostsEntries objectAtIndex:index]; 54 | } 55 | 56 | - (id) objectInHostsAtIndexes: (NSIndexSet *) range { 57 | return [NLPERMANENTMARKERSHOSTShostsEntries objectsAtIndexes:range]; 58 | } 59 | 60 | - (void)getHosts:(id *)aBuffer range:(NSRange)aRange { 61 | return [NLPERMANENTMARKERSHOSTShostsEntries getObjects:aBuffer range:aRange]; 62 | } 63 | 64 | - (void) insertObject:(id)object inHostsAtIndex:(NSUInteger) index { 65 | NSLog(@"inserting in hosts"); 66 | [NLPERMANENTMARKERSHOSTShostsEntries insertObject:object atIndex:index]; 67 | [object addObserverForAll:self]; 68 | if (undoManager != nil) { 69 | [[undoManager prepareWithInvocationTarget:self] removeObjectFromHostsAtIndex:index]; 70 | if ([undoManager isUndoing]) { 71 | NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Delete host entry" value:@"" table:nil]; 72 | [undoManager setActionName:undoActionName]; 73 | } else { 74 | NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Insert host entry" value:@"" table:nil]; 75 | [undoManager setActionName:undoActionName]; 76 | } 77 | } 78 | } 79 | 80 | - (void) removeObjectFromHostsAtIndex:(NSUInteger) index { 81 | if (undoManager != nil) { 82 | NLPERMANENTMARKERSHOSTSHostEntry * deletedObject = [NLPERMANENTMARKERSHOSTShostsEntries objectAtIndex:index]; 83 | [undoManager removeAllActionsWithTarget:deletedObject]; 84 | [[undoManager prepareWithInvocationTarget:self] insertObject:deletedObject inHostsAtIndex:index]; 85 | if ([undoManager isUndoing]) { 86 | NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Insert host entry" value:@"" table:nil]; 87 | [undoManager setActionName:undoActionName]; 88 | } else { 89 | NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Delete host entry" value:@"" table:nil]; 90 | [undoManager setActionName:undoActionName]; 91 | } 92 | } 93 | [[NLPERMANENTMARKERSHOSTShostsEntries objectAtIndex:index] removeAllObservers:self]; 94 | [NLPERMANENTMARKERSHOSTShostsEntries removeObjectAtIndex:index]; 95 | } 96 | 97 | - (NSMutableArray *) hosts { 98 | return NLPERMANENTMARKERSHOSTShostsEntries; 99 | } 100 | 101 | - (void) setHosts:(NSMutableArray *)hosts { 102 | if (! [hosts isEqualTo:NLPERMANENTMARKERSHOSTShostsEntries]) { 103 | [self willChangeValueForKey:@"hosts"]; 104 | [hosts retain]; 105 | [NLPERMANENTMARKERSHOSTShostsEntries release]; 106 | NLPERMANENTMARKERSHOSTShostsEntries = hosts; 107 | [self didChangeValueForKey:@"hosts"]; 108 | assert(NO); 109 | } 110 | } 111 | 112 | #pragma mark drag and drop 113 | - (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard 114 | { 115 | // Copy the row numbers to the pasteboard. 116 | NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes]; 117 | [pboard declareTypes:[NSArray arrayWithObject:PM_HOST_ENTRY_DATA_TYPE] owner:self]; 118 | [pboard setData:data forType:PM_HOST_ENTRY_DATA_TYPE]; 119 | return YES; 120 | } 121 | 122 | - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id )info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)op 123 | { 124 | // Add code here to validate the drop 125 | NSLog(@"validate Drop"); 126 | if (op == NSTableViewDropOn || row >= [tv numberOfRows]) { 127 | return NSDragOperationNone; 128 | } 129 | return NSDragOperationEvery; 130 | } 131 | 132 | - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info 133 | row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation 134 | { 135 | NSPasteboard* pboard = [info draggingPasteboard]; 136 | NSData* rowData = [pboard dataForType:PM_HOST_ENTRY_DATA_TYPE]; 137 | NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:rowData]; 138 | NSInteger dragRow = [rowIndexes firstIndex]; 139 | 140 | // Move the specified row to its new location... 141 | NLPERMANENTMARKERSHOSTSHostEntry * entry = [[controller arrangedObjects] objectAtIndex:dragRow]; 142 | NLPERMANENTMARKERSHOSTSHostEntry * targetEntry = [[controller arrangedObjects] objectAtIndex:row]; 143 | 144 | NSUInteger index = [NLPERMANENTMARKERSHOSTShostsEntries indexOfObject:entry]; 145 | [self removeObjectFromHostsAtIndex:index]; 146 | 147 | NSUInteger targetIndex = [NLPERMANENTMARKERSHOSTShostsEntries indexOfObject:targetEntry]; 148 | [self insertObject:entry inHostsAtIndex:targetIndex]; 149 | 150 | return YES; 151 | } 152 | 153 | 154 | #pragma mark observers 155 | 156 | - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 157 | 158 | [authorization obtain]; 159 | 160 | if (undoManager != nil && [object isKindOfClass:[NLPERMANENTMARKERSHOSTSHostEntry class]]) { 161 | [object pushUndoState:change withManager:undoManager forKeyPath:keyPath]; 162 | } 163 | 164 | // disable sudden termination to make sure that we don't get the defaults and /etc/hosts running out of sync. 165 | [[NSProcessInfo processInfo] disableSuddenTermination]; 166 | // update stored defaults 167 | NSData * current_hosts_archive = [NSKeyedArchiver archivedDataWithRootObject:NLPERMANENTMARKERSHOSTShostsEntries]; 168 | [[NSUserDefaults standardUserDefaults] setObject:current_hosts_archive forKey:PMHOSTS_DEFAULTS_KEY]; 169 | 170 | // update /etc/hosts 171 | [writer writeHostEntries:NLPERMANENTMARKERSHOSTShostsEntries]; 172 | [[NSProcessInfo processInfo] enableSuddenTermination]; 173 | } 174 | 175 | 176 | // 177 | #pragma mark private methods 178 | - (void) insertInactiveItems:(NSMutableArray *)parsed_data { 179 | NSData * stored_items_data = [[NSUserDefaults standardUserDefaults] objectForKey:PMHOSTS_DEFAULTS_KEY]; 180 | NSMutableArray * stored_items = [NSKeyedUnarchiver unarchiveObjectWithData:stored_items_data]; 181 | [stored_items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 182 | if ([[obj use] integerValue] == NSOffState) { 183 | @try { 184 | [NLPERMANENTMARKERSHOSTShostsEntries insertObject:obj atIndex:idx]; 185 | } 186 | @catch (NSException *exception) { 187 | [NLPERMANENTMARKERSHOSTShostsEntries addObject:obj]; 188 | } 189 | } 190 | }]; 191 | } 192 | 193 | #pragma mark initializers 194 | - (id)init 195 | { 196 | self = [super init]; 197 | if (self) { 198 | writer = [[NLPERMANENTMARKERSHOSTSFileWriter alloc] init]; 199 | [NLPERMANENTMARKERSHOSTSFileWriter backupHostsFileWithExtension:@"session"]; 200 | 201 | // parse hosts file. 202 | needsLoad = YES; 203 | [self load]; 204 | } 205 | 206 | return self; 207 | } 208 | 209 | - (void) clear { 210 | NSLog(@"reset called"); 211 | for (NLPERMANENTMARKERSHOSTSHostEntry * entry in NLPERMANENTMARKERSHOSTShostsEntries) { 212 | [entry removeAllObservers:self]; 213 | } 214 | // remove observer before clearing array to avoid update of hosts file. 215 | [self removeObserver:self forKeyPath:@"hosts"]; 216 | [NLPERMANENTMARKERSHOSTShostsEntries removeAllObjects]; 217 | 218 | needsLoad = YES; 219 | } 220 | 221 | -(void) load { 222 | NSLog(@"Load called"); 223 | if (needsLoad) { 224 | [self willChangeValueForKey:@"hosts"]; 225 | NSLog(@"Load was needed"); 226 | [[NSProcessInfo processInfo] disableSuddenTermination]; 227 | [NLPERMANENTMARKERSHOSTSFileWriter backupHostsFileWithExtension:@"session"]; 228 | NLPERMANENTMARKERSHOSTSparsefile(PM_HOSTS_FILE_LOCATION, NLPERMANENTMARKERSHOSTSonHostEntryFound, NLPERMANENTMARKERSHOSTSonHostsParseError); 229 | 230 | [self insertInactiveItems:NLPERMANENTMARKERSHOSTShostsEntries]; 231 | 232 | // observe for existing items for changes. 233 | for (NLPERMANENTMARKERSHOSTSHostEntry * entry in NLPERMANENTMARKERSHOSTShostsEntries) { 234 | [entry addObserverForAll:self]; 235 | } 236 | 237 | // observe hosts array for inserts and removal. 238 | [self addObserver:self forKeyPath:@"hosts" options:0 context:nil]; 239 | needsLoad = NO; 240 | [[NSProcessInfo processInfo] enableSuddenTermination]; 241 | [self didChangeValueForKey:@"hosts"]; 242 | } 243 | } 244 | 245 | // 246 | - (void)dealloc 247 | { 248 | [NLPERMANENTMARKERSHOSTShostsEntries release]; 249 | [undoManager release]; 250 | [authorization release]; 251 | [writer release]; 252 | 253 | [super dealloc]; 254 | } 255 | 256 | @end 257 | -------------------------------------------------------------------------------- /HostsPrefpane/Base.lproj/HostsPrefpane.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 43 | 57 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 164 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | use 190 | address 191 | hostnames 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | -------------------------------------------------------------------------------- /Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 171 | 185 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 294 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | use 324 | address 325 | hostnames 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | --------------------------------------------------------------------------------