diff -r 7c7812a37eff ABQuery.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ABQuery.m Sun Sep 26 22:16:18 2010 -0700 @@ -0,0 +1,73 @@ +/* ABQuery + * + * Copyright 2003 Brendan Cully + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA. + * + * + * $Id: ABQuery.m,v 1.3 2005-10-29 14:48:16 roland Exp $ + */ + +#import +#import + +int main (int argc, const char *argv[]) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + ABAddressBook *book = [ABAddressBook sharedAddressBook]; + ABSearchElement *firstNameSearch, *lastNameSearch, *emailSearch, *search; + NSArray *searchTerms; + NSArray *results; + NSEnumerator *addressEnum; + ABPerson *person; + NSString *key = [NSString stringWithCString:argv[1]]; + + firstNameSearch = [ABPerson searchElementForProperty:kABFirstNameProperty + label:nil + key:nil + value:key + comparison:kABContainsSubStringCaseInsensitive]; + lastNameSearch = [ABPerson searchElementForProperty:kABLastNameProperty + label:nil + key:nil + value:key + comparison:kABContainsSubStringCaseInsensitive]; + emailSearch = [ABPerson searchElementForProperty:kABEmailProperty + label:nil + key:nil + value:key + comparison:kABContainsSubStringCaseInsensitive]; + searchTerms = [NSArray arrayWithObjects:firstNameSearch, lastNameSearch, emailSearch, nil]; + search = [ABSearchElement searchElementForConjunction:kABSearchOr + children:searchTerms]; + results = [book recordsMatchingSearchElement:search]; + + addressEnum = [results objectEnumerator]; + + while (person = (ABPerson*)[addressEnum nextObject]) { + NSString *fullName = [NSString stringWithFormat:@"%@ %@", [[person valueForProperty:kABFirstNameProperty] description], [[person valueForProperty:kABLastNameProperty] description]]; + + ABMultiValue *emails = [person valueForProperty:kABEmailProperty]; + int count = [emails count]; + int i; + for (i = 0; i < count; i++) { + NSString *email = [emails valueAtIndex:i]; + printf("%s\t%s\t(AddressBook)\n", [email cString], [fullName UTF8String]); + } + } + + [pool release]; + + return 0; +} diff -r 7c7812a37eff ABQuery/ABQuery.m --- a/ABQuery/ABQuery.m Sun Sep 26 21:48:56 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* ABQuery - * - * Copyright 2003 Brendan Cully - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA. - * - * - * $Id: ABQuery.m,v 1.3 2005-10-29 14:48:16 roland Exp $ - */ - -#import -#import - -int main (int argc, const char *argv[]) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - ABAddressBook *book = [ABAddressBook sharedAddressBook]; - ABSearchElement *firstNameSearch, *lastNameSearch, *emailSearch, *search; - NSArray *searchTerms; - NSArray *results; - NSEnumerator *addressEnum; - ABPerson *person; - NSString *key = [NSString stringWithCString:argv[1]]; - - firstNameSearch = [ABPerson searchElementForProperty:kABFirstNameProperty - label:nil - key:nil - value:key - comparison:kABContainsSubStringCaseInsensitive]; - lastNameSearch = [ABPerson searchElementForProperty:kABLastNameProperty - label:nil - key:nil - value:key - comparison:kABContainsSubStringCaseInsensitive]; - emailSearch = [ABPerson searchElementForProperty:kABEmailProperty - label:nil - key:nil - value:key - comparison:kABContainsSubStringCaseInsensitive]; - searchTerms = [NSArray arrayWithObjects:firstNameSearch, lastNameSearch, emailSearch, nil]; - search = [ABSearchElement searchElementForConjunction:kABSearchOr - children:searchTerms]; - results = [book recordsMatchingSearchElement:search]; - - addressEnum = [results objectEnumerator]; - - while (person = (ABPerson*)[addressEnum nextObject]) { - NSString *fullName = [NSString stringWithFormat:@"%@ %@", [[person valueForProperty:kABFirstNameProperty] description], [[person valueForProperty:kABLastNameProperty] description]]; - - ABMultiValue *emails = [person valueForProperty:kABEmailProperty]; - int count = [emails count]; - int i; - for (i = 0; i < count; i++) { - NSString *email = [emails valueAtIndex:i]; - printf("%s\t%s\t(AddressBook)\n", [email cString], [fullName UTF8String]); - } - } - - [pool release]; - - return 0; -} diff -r 7c7812a37eff ABQuery/ABQuery.pbproj/project.pbxproj --- a/ABQuery/ABQuery.pbproj/project.pbxproj Sun Sep 26 21:48:56 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 38; - objects = { - 014CEA4F0018CE4811CA2923 = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = NO; - OPTIMIZATION_CFLAGS = "-O0"; - }; - isa = PBXBuildStyle; - name = Development; - }; - 014CEA500018CE4811CA2923 = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = YES; - }; - isa = PBXBuildStyle; - name = Deployment; - }; -//010 -//011 -//012 -//013 -//014 -//030 -//031 -//032 -//033 -//034 - 034768E6FF38A76511DB9C8B = { - isa = PBXExecutableFileReference; - path = ABQuery; - refType = 3; - }; -//030 -//031 -//032 -//033 -//034 -//080 -//081 -//082 -//083 -//084 - 08FB7793FE84155DC02AAC07 = { - buildStyles = ( - 014CEA4F0018CE4811CA2923, - 014CEA500018CE4811CA2923, - ); - hasScannedForEncodings = 1; - isa = PBXProject; - mainGroup = 08FB7794FE84155DC02AAC07; - projectDirPath = ""; - targets = ( - 08FB779FFE84155DC02AAC07, - ); - }; - 08FB7794FE84155DC02AAC07 = { - children = ( - 08FB7795FE84155DC02AAC07, - C6859EA2029092E104C91782, - 08FB779DFE84155DC02AAC07, - 1AB674ADFE9D54B511CA2CBB, - ); - isa = PBXGroup; - name = ABQuery; - refType = 4; - }; - 08FB7795FE84155DC02AAC07 = { - children = ( - 32A70AAB03705E1F00C91783, - 08FB7796FE84155DC02AAC07, - ); - isa = PBXGroup; - name = Source; - refType = 4; - }; - 08FB7796FE84155DC02AAC07 = { - fileEncoding = 4; - isa = PBXFileReference; - path = ABQuery.m; - refType = 4; - }; - 08FB779DFE84155DC02AAC07 = { - children = ( - 08FB779EFE84155DC02AAC07, - C6B583C60405C207001D6ECE, - ); - isa = PBXGroup; - name = "External Frameworks and Libraries"; - refType = 4; - }; - 08FB779EFE84155DC02AAC07 = { - isa = PBXFrameworkReference; - name = Foundation.framework; - path = /System/Library/Frameworks/Foundation.framework; - refType = 0; - }; - 08FB779FFE84155DC02AAC07 = { - buildPhases = ( - 08FB77A0FE84155DC02AAC07, - 08FB77A1FE84155DC02AAC07, - 08FB77A3FE84155DC02AAC07, - 08FB77A5FE84155DC02AAC07, - C6859EA4029092FD04C91782, - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ""; - HEADER_SEARCH_PATHS = ""; - INSTALL_PATH = "$(HOME)/bin"; - LIBRARY_SEARCH_PATHS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRECOMPILE_PREFIX_HEADER = YES; - PREFIX_HEADER = ABQuery_Prefix.h; - PRODUCT_NAME = ABQuery; - REZ_EXECUTABLE = YES; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - }; - dependencies = ( - ); - isa = PBXToolTarget; - name = ABQuery; - productInstallPath = "$(HOME)/bin"; - productName = ABQuery; - productReference = 034768E6FF38A76511DB9C8B; - }; - 08FB77A0FE84155DC02AAC07 = { - buildActionMask = 2147483647; - files = ( - 32A70AAC03705E1F00C91783, - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 08FB77A1FE84155DC02AAC07 = { - buildActionMask = 2147483647; - files = ( - 08FB77A2FE84155DC02AAC07, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 08FB77A2FE84155DC02AAC07 = { - fileRef = 08FB7796FE84155DC02AAC07; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 08FB77A3FE84155DC02AAC07 = { - buildActionMask = 2147483647; - files = ( - 08FB77A4FE84155DC02AAC07, - C6B583C70405C207001D6ECE, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 08FB77A4FE84155DC02AAC07 = { - fileRef = 08FB779EFE84155DC02AAC07; - isa = PBXBuildFile; - settings = { - }; - }; - 08FB77A5FE84155DC02AAC07 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; -//080 -//081 -//082 -//083 -//084 -//1A0 -//1A1 -//1A2 -//1A3 -//1A4 - 1AB674ADFE9D54B511CA2CBB = { - children = ( - 034768E6FF38A76511DB9C8B, - ); - isa = PBXGroup; - name = Products; - refType = 4; - }; -//1A0 -//1A1 -//1A2 -//1A3 -//1A4 -//320 -//321 -//322 -//323 -//324 - 32A70AAB03705E1F00C91783 = { - fileEncoding = 4; - isa = PBXFileReference; - path = ABQuery_Prefix.h; - refType = 4; - }; - 32A70AAC03705E1F00C91783 = { - fileRef = 32A70AAB03705E1F00C91783; - isa = PBXBuildFile; - settings = { - }; - }; -//320 -//321 -//322 -//323 -//324 -//C60 -//C61 -//C62 -//C63 -//C64 - C6859EA2029092E104C91782 = { - children = ( - ); - isa = PBXGroup; - name = Documentation; - refType = 4; - }; - C6859EA4029092FD04C91782 = { - buildActionMask = 8; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - C6B583DD0405DFD5001D6ECE, - ); - isa = PBXCopyFilesBuildPhase; - runOnlyForDeploymentPostprocessing = 1; - }; - C6B583C60405C207001D6ECE = { - isa = PBXFrameworkReference; - name = AddressBook.framework; - path = /System/Library/Frameworks/AddressBook.framework; - refType = 0; - }; - C6B583C70405C207001D6ECE = { - fileRef = C6B583C60405C207001D6ECE; - isa = PBXBuildFile; - settings = { - }; - }; - C6B583DD0405DFD5001D6ECE = { - fileRef = 034768E6FF38A76511DB9C8B; - isa = PBXBuildFile; - settings = { - }; - }; - }; - rootObject = 08FB7793FE84155DC02AAC07; -} diff -r 7c7812a37eff ABQuery/ABQuery_Prefix.h --- a/ABQuery/ABQuery_Prefix.h Sun Sep 26 21:48:56 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -// -// Prefix header for all source files of the 'ABQuery' target in the 'ABQuery' project. -// - -#ifdef __OBJC__ - #import -#endif diff -r 7c7812a37eff Makefile.in --- a/Makefile.in Sun Sep 26 21:48:56 2010 -0700 +++ b/Makefile.in Sun Sep 26 22:16:18 2010 -0700 @@ -75,7 +75,7 @@ $(install_prefix)$(sysconfdir)/lbdb_ldap.rc; \ fi if [ "$(XCODEBUILD)" != "no" -o "$(PBXBUILD)" != "no" ]; then \ - $(INSTALL) -m 755 ABQuery/sym/ABQuery $(install_prefix)$(libdir); \ + $(INSTALL) -m 755 ABQuery $(install_prefix)$(libdir); \ fi if [ "$(VFORMAT)" != "no" ]; then \ $(INSTALL) -m 755 vcquery $(install_prefix)$(libdir); \ @@ -148,27 +148,19 @@ vcquery: vcquery.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $? -lvformat -m_osx_addressbook: ABQuery/sym/ABQuery +m_osx_addressbook: ABQuery -ABQuery/sym/ABQuery: ABQuery/pbxbuild.sh ABQuery/ABQuery.m - ABQuery/pbxbuild.sh - -ABQuery/pbxbuild.sh: - if [ "$(XCODEBUILD)" != "no" ]; then \ - (cd ABQuery; xcodebuild -buildstyle Deployment; printf '#!/bin/sh\nmkdir ABQuery/sym\nEXE=ABQuery/build/ABQuery\nif test -x ABQuery/build/Deployment/ABQuery; then EXE=ABQuery/build/Deployment/ABQuery; fi\ncp $$EXE ABQuery/sym\n' > pbxbuild.sh; chmod a+x pbxbuild.sh) \ - else \ - (cd ABQuery; pbxbuild -buildstyle Deployment export) \ - fi +ABQuery: ABQuery.m + $(CC) $(CFLAGS) $(DEFS) -framework Foundation -framework AddressBook -o $@ $^ clean: - -rm -f *.o *~ $(ALL) munge.awk munge-keeporder.awk tac.awk \ + -rm -f *.o *~ $(ALL) munge.awk munge-keeporder.awk tac.awk ABQuery \ nodelist2lbdb.pl palm_lsaddr.pl mutt_ldap_query.pl lbdb_dotlock - -rm -rf ABQuery/sym ABQuery/obj + -rm -rf ABQuery.dSYM distclean: clean -rm -f config.status config.cache config.log Makefile -rm -f *.sh - -rm -rf ABQuery/pbxbuild.data ABQuery/pbxbuild.sh -rm -f vcquery Makefile: Makefile.in