Last active
August 29, 2015 14:07
-
-
Save qunwang6/795c645c0271c91d32e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Command-line dictionary lookup. | |
* | |
* Build with: | |
* clang -framework CoreServices | |
*/ | |
#import <CoreFoundation/CoreFoundation.h> | |
#import <CoreServices/CoreServices.h> | |
int main(int argc, char *argv[]) { | |
if (argc < 2) | |
return 1; | |
for (int i = 1; i < argc; i++) { | |
CFStringRef searchPhrase = CFStringCreateWithCString(NULL, argv[i], kCFStringEncodingUTF8); | |
if (searchPhrase) { | |
CFRange searchRange = DCSGetTermRangeInString(NULL, searchPhrase, 0); | |
CFStringRef definition = DCSCopyTextDefinition(NULL, searchPhrase, searchRange); | |
if (definition) { | |
printf("--- definition of %s:\n", argv[i]); | |
CFShow(definition); | |
CFRelease(definition); | |
} | |
else | |
printf("--- no definition found for %s\n\n", argv[i]); | |
CFRelease(searchPhrase); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment