├── done.png ├── AppIcon.png ├── dropper.png ├── DictUnifier.icns ├── .gitignore ├── ddk ├── add_body_record ├── build_key_index ├── make_dict_package ├── normalize_key_text ├── add_key_index_record ├── add_supplementary_key ├── build_reference_index ├── add_reference_index_record ├── extract_property.xsl ├── make_readonly.pl ├── extract_front_matter_id.pl ├── normalize_key_text.pl ├── make_line.pl ├── remove_duplicate_key.pl ├── pick_referred_entry_id.pl ├── make_body.pl ├── replace_entryid_bodyid.pl └── extract_referred_id.pl ├── English.lproj ├── InfoPlist.strings └── Localizable.strings ├── zh_CN.lproj ├── InfoPlist.strings ├── Localizable.strings └── MainMenu.strings ├── Makefile ├── sdconv ├── mdk.h ├── convert.h ├── index.h ├── storage.h ├── include │ ├── glib │ │ ├── gi18n.h │ │ ├── gi18n-lib.h │ │ ├── gmappedfile.h │ │ ├── gqsort.h │ │ ├── gpattern.h │ │ ├── gprimes.h │ │ ├── gdir.h │ │ ├── gshell.h │ │ ├── gbase64.h │ │ ├── gquark.h │ │ ├── gprintf.h │ │ ├── galloca.h │ │ ├── gtimer.h │ │ ├── gerror.h │ │ ├── gbacktrace.h │ │ ├── gcompletion.h │ │ ├── gatomic.h │ │ ├── gcache.h │ │ ├── grand.h │ │ ├── gslice.h │ │ ├── grel.h │ │ ├── gstdio.h │ │ ├── gtree.h │ │ ├── gfileutils.h │ │ ├── gwin32.h │ │ ├── ghash.h │ │ ├── gconvert.h │ │ ├── gqueue.h │ │ ├── gasyncqueue.h │ │ ├── gslist.h │ │ ├── gthreadpool.h │ │ ├── glist.h │ │ ├── gdataset.h │ │ ├── gmarkup.h │ │ ├── gmem.h │ │ ├── gspawn.h │ │ ├── gnode.h │ │ ├── goption.h │ │ ├── ghook.h │ │ ├── gstring.h │ │ └── garray.h │ ├── glib.h │ └── glibconfig.h ├── dict.h ├── index.cpp ├── storage.cpp ├── convert.cpp └── sdconv.cpp ├── DictUnifier_Prefix.pch ├── DictUnifier.xcodeproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ ├── IDEWorkspaceChecks.plist │ └── WorkspaceSettings.xcsettings ├── DUWindow.h ├── DUImageView.h ├── main.m ├── README.md ├── templates ├── DictInfo.plist └── Dictionary.css ├── Info.plist ├── DictUnifierAppDelegate.h ├── DUImageView.m ├── DUWindow.m └── scripts └── test.lua /done.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/done.png -------------------------------------------------------------------------------- /AppIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/AppIcon.png -------------------------------------------------------------------------------- /dropper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/dropper.png -------------------------------------------------------------------------------- /DictUnifier.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/DictUnifier.icns -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pbxuser 2 | *.perspectivev3 3 | zh_CN.lproj/MainMenu.xib 4 | build/ 5 | xcuserdata 6 | -------------------------------------------------------------------------------- /ddk/add_body_record: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/ddk/add_body_record -------------------------------------------------------------------------------- /ddk/build_key_index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/ddk/build_key_index -------------------------------------------------------------------------------- /ddk/make_dict_package: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/ddk/make_dict_package -------------------------------------------------------------------------------- /ddk/normalize_key_text: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/ddk/normalize_key_text -------------------------------------------------------------------------------- /ddk/add_key_index_record: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/ddk/add_key_index_record -------------------------------------------------------------------------------- /ddk/add_supplementary_key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/ddk/add_supplementary_key -------------------------------------------------------------------------------- /ddk/build_reference_index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/ddk/build_reference_index -------------------------------------------------------------------------------- /English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /ddk/add_reference_index_record: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/ddk/add_reference_index_record -------------------------------------------------------------------------------- /zh_CN.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isee15/mac-dictionary-kit/HEAD/zh_CN.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | default: 2 | xcodebuild -configuration Release 3 | 4 | install: 5 | sudo xcodebuild install -configuration Release DSTROOT=/ INSTALL_PATH=/Applications DEPLOYMENT_LOCATION=YES 6 | -------------------------------------------------------------------------------- /sdconv/mdk.h: -------------------------------------------------------------------------------- 1 | // mdk.h: main include file for Mac Dictionary Kit 2 | 3 | #ifndef MDK_H 4 | #define MDK_H 5 | 6 | #include "dict.h" 7 | #include "convert.h" 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /DictUnifier_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'DictUnifier' target in the 'DictUnifier' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /DictUnifier.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DUWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // DUWindow.h 3 | // DictUnifier 4 | // 5 | // Created by Jjgod Jiang on 3/11/10. 6 | // 7 | 8 | #import 9 | #import "DictUnifierAppDelegate.h" 10 | 11 | @interface DUWindow : NSWindow { 12 | IBOutlet DictUnifierAppDelegate *controller; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /DUImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DUImageView.h 3 | // DictUnifier 4 | // 5 | // Created by Jjgod Jiang on 3/11/10. 6 | // 7 | 8 | #import 9 | #import "DictUnifierAppDelegate.h" 10 | 11 | @interface DUImageView : NSImageView { 12 | IBOutlet DictUnifierAppDelegate *controller; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DictUnifier 4 | // 5 | // Created by Jiang Jiang on 3/7/10. 6 | // Copyright Jjgod Jiang 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /DictUnifier.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DictUnifier.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Latest 7 | 8 | 9 | -------------------------------------------------------------------------------- /ddk/extract_property.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ddk/make_readonly.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # 4 | # 5 | # make_readonly.pl 6 | # 7 | 8 | use strict; 9 | use utf8; 10 | use open ':utf8'; 11 | use open ':std'; 12 | 13 | 14 | # 15 | # 16 | # 17 | my $content = get_content(); 18 | 19 | $content =~ s/IDXIndexWritable<\/key>[[:blank:]\n]*/IDXIndexWritable<\/key>\n\t\t\t/g; 20 | 21 | print $content; 22 | exit(0); 23 | 24 | 25 | # 26 | # 27 | # 28 | sub get_content 29 | { 30 | my $content_lines; 31 | while ( my $line = <> ) { 32 | $content_lines = $content_lines . $line; 33 | } 34 | # printf "content_lines [%s]\n", $content_lines; 35 | 36 | return $content_lines; 37 | } 38 | -------------------------------------------------------------------------------- /ddk/extract_front_matter_id.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # 4 | # 5 | # extract_front_matter_id.pl 6 | # 7 | 8 | use strict; 9 | use utf8; 10 | use open ':utf8'; 11 | use open ':std'; 12 | 13 | 14 | # 15 | # 16 | # 17 | my $content = get_content(); 18 | 19 | if ( $content =~ /DCSDictionaryFrontMatterReferenceID<\/key>[[:blank:]\n]*(.*?)<\/string>/ ) 20 | { 21 | my $front_matter_id = $1; 22 | printf "%s\n", $front_matter_id; 23 | } 24 | 25 | exit(0); 26 | 27 | 28 | # 29 | # 30 | # 31 | sub get_content 32 | { 33 | my $content_lines; 34 | while ( my $line = <> ) { 35 | $content_lines = $content_lines . $line; 36 | } 37 | # printf "content_lines [%s]\n", $content_lines; 38 | 39 | return $content_lines; 40 | } 41 | -------------------------------------------------------------------------------- /zh_CN.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* No comment provided by engineer. */ 2 | "Building %@..." = "正在构建 %@..."; 3 | 4 | /* No comment provided by engineer. */ 5 | "Convert %@ failed, abort now." = "%@ 转换失败,已放弃"; 6 | 7 | /* No comment provided by engineer. */ 8 | "Converting %@..." = "正在转换 %@..."; 9 | 10 | /* No comment provided by engineer. */ 11 | "Done" = "完成"; 12 | 13 | /* No comment provided by engineer. */ 14 | "Drop a dictionary file to convert" = "拖入词典源文件开始转换"; 15 | 16 | /* No comment provided by engineer. */ 17 | "Enter a name to start building" = "输入要创建的词典名字"; 18 | 19 | /* No comment provided by engineer. */ 20 | "Installing into %@..." = "正在安装到 %@..."; 21 | 22 | /* No comment provided by engineer. */ 23 | "Start" = "开始"; 24 | 25 | /* No comment provided by engineer. */ 26 | "Stop" = "停止"; 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mac Dictionary Kit, a.k.a., DictUnifier 2 | 3 | Dictionary conversion tool for Mac OS X 10.5 and above. 4 | 5 | ## 词典包地址 6 | http://download.huzheng.org/zh_CN/index.html 7 | 8 | ## 转换好的一些词典 9 | https://github.com/isee15/mac-dictionary-kit/releases/download/v2.2/Dictionaries.zip 10 | 解压到~/Library/Dictionaries 11 | 12 | ## Download 13 | 14 | Download it from [GitHub releases, v2.2](https://github.com/isee15/mac-dictionary-kit/releases/download/v2.2/DictUnifier.zip). 15 | 16 | ## Build instructions 17 | 18 | Install static build of glib before trying to build: 19 | ``` 20 | brew update 21 | brew install glib 22 | // brew install glib --with-static 23 | ``` 24 | 25 | 26 | 27 | ## TODO 28 | 29 | - Remove glib dependency 30 | - Better dictionary format support 31 | 32 | Pull requests are welcomed! 33 | -------------------------------------------------------------------------------- /templates/DictInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | zh-Hans 7 | CFBundleDisplayName 8 | $DICT_NAME 9 | CFBundleIdentifier 10 | com.apple.dictionary.$DICT_ID 11 | CFBundleName 12 | $DICT_NAME 13 | CFBundleShortVersionString 14 | 1.0 15 | DCSDictionaryCopyright 16 | GNU General Public License 17 | DCSDictionaryManufacturerName 18 | stardict 19 | DCSDictionaryUseSystemAppearance 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sdconv/convert.h: -------------------------------------------------------------------------------- 1 | // convert.h 2 | 3 | #ifndef MDK_CONVERT_H 4 | #define MDK_CONVERT_H 5 | 6 | #include 7 | #include 8 | 9 | struct convert_module { 10 | const char *name; 11 | int req_file; /* need to specify another file */ 12 | bool (*init)(const char *file); 13 | bool (*convert)(gchar *src, GString *dest); 14 | void (*fini)(); 15 | }; 16 | 17 | GString *mdk_start_convert(struct convert_module *mod); 18 | void mdk_finish_convert(struct convert_module *mod, GString *dest); 19 | struct convert_module *mdk_get_convert_module(const char *name); 20 | void mdk_convert_index_with_module(struct convert_module *mod, 21 | mdk_dict *dict, 22 | unsigned int index, 23 | GString *dest); 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /English.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* No comment provided by engineer. */ 2 | "Building %@..." = "Building %@..."; 3 | 4 | /* No comment provided by engineer. */ 5 | "Convert %@ failed, abort now." = "Convert %@ failed, abort now."; 6 | 7 | /* No comment provided by engineer. */ 8 | "Converting %@..." = "Converting %@..."; 9 | 10 | /* No comment provided by engineer. */ 11 | "Done" = "Done"; 12 | 13 | /* No comment provided by engineer. */ 14 | "Drop a dictionary file to convert" = "Drop a dictionary file to convert"; 15 | 16 | /* No comment provided by engineer. */ 17 | "Enter a name to start building" = "Enter a name to start building"; 18 | 19 | /* No comment provided by engineer. */ 20 | "Installing into %@..." = "Installing into %@..."; 21 | 22 | /* No comment provided by engineer. */ 23 | "Start" = "Start"; 24 | 25 | /* No comment provided by engineer. */ 26 | "Stop" = "Stop"; 27 | 28 | -------------------------------------------------------------------------------- /sdconv/index.h: -------------------------------------------------------------------------------- 1 | // index.h: dictionary index 2 | 3 | #ifndef MDK_INDEX_H 4 | #define MDK_INDEX_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef ARM 11 | static inline guint32 get_uint32(const gchar *addr) 12 | { 13 | guint32 result; 14 | memcpy(&result, addr, sizeof(guint32)); 15 | return result; 16 | } 17 | #else 18 | #define get_uint32(x) *reinterpret_cast(x) 19 | #endif 20 | 21 | typedef struct mdk_entry { 22 | const gchar *key; 23 | guint32 offset; 24 | guint32 size; 25 | } mdk_entry; 26 | 27 | class mdk_index { 28 | public: 29 | mdk_index(); 30 | ~mdk_index(); 31 | 32 | bool load(const gchar *file, 33 | guint32 entry_count, 34 | guint32 fsize); 35 | bool get_entry(guint32 index, mdk_entry *entry); 36 | 37 | size_t entry_count(); 38 | 39 | private: 40 | gchar *entry_buffer; 41 | std::vector entry_list; 42 | }; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /sdconv/storage.h: -------------------------------------------------------------------------------- 1 | #ifndef _STARDICT_RESOURCE_STORAGE_H_ 2 | #define _STARDICT_RESOURCE_STORAGE_H_ 3 | 4 | #include 5 | 6 | class File_ResourceStorage { 7 | public: 8 | File_ResourceStorage(const char *resdir); 9 | const char *get_file_path(const char *key); 10 | const char *get_file_content(const char *key); 11 | private: 12 | std::string resdir; 13 | std::string filepath; 14 | }; 15 | 16 | class Database_ResourceStorage { 17 | public: 18 | Database_ResourceStorage(); 19 | bool load(const char *rifofilename); 20 | const char *get_file_path(const char *key); 21 | const char *get_file_content(const char *key); 22 | }; 23 | 24 | class ResourceStorage { 25 | public: 26 | ResourceStorage(); 27 | ~ResourceStorage(); 28 | bool load(const char *dirname); 29 | int is_file_or_db; 30 | const char *get_file_path(const char *key); 31 | const char *get_file_content(const char *key); 32 | private: 33 | File_ResourceStorage *file_storage; 34 | Database_ResourceStorage *database_storage; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /templates/Dictionary.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | @namespace d url(http://www.apple.com/DTDs/DictionaryService-1.0.rng); 3 | 4 | d|entry { 5 | } 6 | 7 | h1 { 8 | font-size: 150%; 9 | } 10 | 11 | html.apple_client-panel h1 { 12 | font-size: 100%; 13 | } 14 | 15 | h3 { 16 | font-size: 100%; 17 | } 18 | 19 | pre { 20 | /* overflow: auto; */ 21 | white-space: pre-wrap; 22 | } 23 | 24 | html.apple_client-panel pre { 25 | white-space: normal; 26 | } 27 | 28 | span.column { 29 | display: block; 30 | border: solid 2px #c0c0c0; 31 | margin-left: 2em; 32 | margin-right: 2em; 33 | margin-top: 0.5em; 34 | margin-bottom: 0.5em; 35 | padding: 0.5em; 36 | } 37 | 38 | div.y:before { 39 | content: "/"; 40 | } 41 | 42 | div.y:after { 43 | content: "/"; 44 | } 45 | 46 | div.y { 47 | margin-top: 0.5em; 48 | margin-bottom: 0.5em; 49 | font-size: 120%; 50 | color: #333; 51 | } 52 | 53 | @media (prefers-dark-interface) 54 | { 55 | body { 56 | color: white; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | AppIcon.png 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 2.1 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 5 25 | NSMainNibFile 26 | MainMenu 27 | NSPrincipalClass 28 | NSApplication 29 | 30 | 31 | -------------------------------------------------------------------------------- /DictUnifierAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // DictUnifierAppDelegate.h 3 | // DictUnifier 4 | // 5 | // Created by Jjgod Jiang on 3/11/10. 6 | // Copyright 2010 Jjgod Jiang. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DictUnifierAppDelegate : NSObject { 12 | IBOutlet NSImageView *dropper; 13 | IBOutlet NSTextField *label; 14 | IBOutlet NSTextField *nameField; 15 | IBOutlet NSProgressIndicator *progressBar; 16 | IBOutlet NSButton *button; 17 | 18 | NSString *tempDir; 19 | NSString *dictDir; 20 | NSString *dictID; 21 | NSTask *buildTask; 22 | NSUInteger totalEntries; 23 | } 24 | 25 | @property (retain) NSString *tempDir, *dictDir, *dictID; 26 | @property (retain) NSTask *buildTask; 27 | @property (assign) NSUInteger totalEntries; 28 | 29 | - (void) setStatus: (NSString *) str; 30 | - (void) error: (NSString *) str; 31 | - (void) startConversion: (NSString *) dictFile; 32 | - (IBAction) startBuilding: (id) sender; 33 | - (IBAction) stop: (id) sender; 34 | - (void) cleanup; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /DUImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DUImageView.m 3 | // DictUnifier 4 | // 5 | // Created by Jjgod Jiang on 3/11/10. 6 | // 7 | 8 | #import "DUImageView.h" 9 | 10 | @implementation DUImageView 11 | 12 | - (void) awakeFromNib 13 | { 14 | [self registerForDraggedTypes: [NSArray arrayWithObjects: NSPasteboardTypeFileURL, nil]]; 15 | } 16 | 17 | - (NSDragOperation) draggingEntered: (id < NSDraggingInfo >) sender 18 | { 19 | NSPasteboard *pboard = [sender draggingPasteboard]; 20 | NSDragOperation opType = NSDragOperationNone; 21 | 22 | if ([[pboard types] containsObject: NSPasteboardTypeFileURL]) 23 | opType = NSDragOperationCopy; 24 | 25 | return opType; 26 | } 27 | 28 | - (BOOL) performDragOperation: (id < NSDraggingInfo >) sender 29 | { 30 | NSPasteboard *pboard = [sender draggingPasteboard]; 31 | BOOL successful = NO; 32 | 33 | if (pboard.pasteboardItems.count <= 1) { 34 | //直接获取文件路径 35 | 36 | NSString *fileURL = [[NSURL URLFromPasteboard:pboard] path]; 37 | [controller startConversion:fileURL]; 38 | successful = NO; 39 | } 40 | 41 | 42 | return successful; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /DUWindow.m: -------------------------------------------------------------------------------- 1 | // 2 | // DUWindow.m 3 | // DictUnifier 4 | // 5 | // Created by Jjgod Jiang on 3/11/10. 6 | // 7 | 8 | #import "DUWindow.h" 9 | 10 | @implementation DUWindow 11 | 12 | - (void) awakeFromNib 13 | { 14 | [self registerForDraggedTypes: [NSArray arrayWithObjects: NSPasteboardTypeFileURL, nil]]; 15 | } 16 | 17 | - (NSDragOperation) draggingEntered: (id < NSDraggingInfo >) sender 18 | { 19 | NSPasteboard *pboard = [sender draggingPasteboard]; 20 | NSDragOperation opType = NSDragOperationNone; 21 | 22 | if ([[pboard types] containsObject: NSPasteboardTypeFileURL]) 23 | opType = NSDragOperationCopy; 24 | 25 | return opType; 26 | } 27 | 28 | - (BOOL) performDragOperation: (id < NSDraggingInfo >) sender 29 | { 30 | NSPasteboard *pboard = [sender draggingPasteboard]; 31 | BOOL successful = NO; 32 | 33 | // 判断是否拖进单文件 34 | 35 | if (pboard.pasteboardItems.count <= 1) { 36 | //直接获取文件路径 37 | 38 | NSString *fileURL = [[NSURL URLFromPasteboard:pboard] path]; 39 | [controller startConversion:fileURL]; 40 | successful = NO; 41 | } 42 | 43 | 44 | return successful; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /ddk/normalize_key_text.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # Normalize key_text 4 | # 5 | # normalize_key_text.pl < infile > outfile 6 | # 7 | 8 | use strict; 9 | use utf8; 10 | use open ':utf8'; 11 | use open ':std'; 12 | # require bytes; 13 | 14 | 15 | # ============================================================= 16 | # main 17 | # ============================================================= 18 | 19 | while ( my $record = ) 20 | { 21 | chomp $record; 22 | if ( $record =~ /^$/ ) 23 | { 24 | next; 25 | } 26 | 27 | my ( $key_text, $body_id, $flags, $title, $anchor, $yomi, $entry_title ) = split /\t/, $record; 28 | if ( not defined $anchor ) 29 | { 30 | printf STDERR "*** Unknown format. Skipped [%s]\n", $record; 31 | next; 32 | } 33 | 34 | my $normalized_key = createSearchKey( $key_text ); 35 | printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", 36 | $normalized_key, $body_id, $flags, $title, $anchor, $yomi, $entry_title; 37 | } 38 | exit 0; 39 | 40 | 41 | # 42 | sub createSearchKey 43 | { 44 | $_ = lc shift; 45 | #tr/àáâãäåāăçćčèéêëęěíîïłñńňóôõöøřśşšţùúûüýź/aaaaaaaaccceeeeeeiiilnnnooooorssstuuuuyz/; 46 | #s/[Æ]/AE/g; 47 | s/[æ]/ae/g; 48 | s/[œ]/oe/g; 49 | s/–/-/g; 50 | s/‛/'/g; 51 | s/“/"/g; 52 | s/”/"/g; 53 | s/’/'/g; 54 | #s/^-//; 55 | s/й/и/g; 56 | s/ё/е/g; 57 | return $_; 58 | } 59 | -------------------------------------------------------------------------------- /scripts/test.lua: -------------------------------------------------------------------------------- 1 | output = "" 2 | inol = 0 3 | inul = 0 4 | 5 | for line in input:gmatch("[^\r\n]+") do 6 | pr = line:match("^\/(.*)\/") 7 | if pr then 8 | output = string.format("| %s |\n", pr) .. output 9 | else 10 | n = line:match("^%d+ ") 11 | if n then 12 | if tonumber(n) == 1 then 13 | output = output .. "
    \n" 14 | inol = 1 15 | end 16 | if inul == 1 then 17 | output = output .. "\n" 18 | inul = 0 19 | end 20 | output = output .. string.format("
  1. %s\n", line:gsub("^%d+ ", "")) 21 | else 22 | if line:match("^\*") then 23 | if inul == 0 then 24 | output = output .. "
      \n" 25 | inul = 1 26 | end 27 | output = output .. string.format("
    • %s
    • \n", line:gsub("\*%s?", "")) 28 | else 29 | output = output .. line .. "\n" 30 | end 31 | end 32 | end 33 | end 34 | 35 | if inol == 1 then 36 | if inul == 1 then 37 | output = output .. "
  2. \n" 38 | inul = 0 39 | end 40 | output = output .. "
" 41 | inol = 0 42 | end 43 | 44 | return output 45 | -------------------------------------------------------------------------------- /sdconv/include/glib/gi18n.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997, 2002 Peter Mattis, Red Hat, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | #ifndef __G_I18N_H__ 20 | #define __G_I18N_H__ 21 | 22 | #include 23 | #include 24 | 25 | #define _(String) gettext (String) 26 | #define Q_(String) g_strip_context ((String), gettext (String)) 27 | #ifdef gettext_noop 28 | #ifndef N_ 29 | #define N_(String) gettext_noop (String) 30 | #endif 31 | #else 32 | #ifndef N_ 33 | #define N_(String) (String) 34 | #endif 35 | #endif 36 | 37 | #endif /* __G_I18N_H__ */ 38 | 39 | 40 | -------------------------------------------------------------------------------- /sdconv/dict.h: -------------------------------------------------------------------------------- 1 | // dict.h 2 | 3 | #ifndef MDK_DICT_H 4 | #define MDK_DICT_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "index.h" 11 | #include "storage.h" 12 | 13 | class mdk_dict { 14 | private: 15 | guint32 wordcount; 16 | guint32 synwordcount; 17 | guint32 index_file_size; 18 | std::string bookname; 19 | std::string author; 20 | std::string email; 21 | std::string website; 22 | std::string date; 23 | std::string description; 24 | std::string sametypesequence; 25 | std::string dicttype; 26 | 27 | mdk_index *index; 28 | ResourceStorage *storage; 29 | 30 | bool load_ifo(const gchar *file); 31 | FILE *dictfile; 32 | 33 | public: 34 | mdk_dict(); 35 | ~mdk_dict(); 36 | bool load(const std::string&); 37 | 38 | const std::string& dict_name() { return bookname; } 39 | const std::string& dict_type() { return dicttype; } 40 | 41 | size_t get_entry_count() 42 | { 43 | return index->entry_count(); 44 | } 45 | 46 | gchar *get_entry_data(mdk_entry *entry); 47 | 48 | gchar *get_entry_data_by_index(guint32 index) 49 | { 50 | mdk_entry entry; 51 | 52 | if (get_entry_by_index(index, &entry)) 53 | return get_entry_data(&entry); 54 | 55 | return NULL; 56 | } 57 | 58 | bool get_entry_by_index(guint32 idx, mdk_entry *entry) 59 | { 60 | return index->get_entry(idx, entry); 61 | } 62 | }; 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /sdconv/include/glib/gi18n-lib.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997, 2002 Peter Mattis, Red Hat, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | #ifndef __G_I18N_LIB_H__ 20 | #define __G_I18N_LIB_H__ 21 | 22 | #include 23 | 24 | #include 25 | 26 | #ifndef GETTEXT_PACKAGE 27 | #error You must define GETTEXT_PACKAGE before including gi18n-lib.h. 28 | #endif 29 | 30 | #define _(String) dgettext (GETTEXT_PACKAGE, String) 31 | #define Q_(String) g_strip_context ((String), dgettext (GETTEXT_PACKAGE, String)) 32 | #ifdef gettext_noop 33 | #define N_(String) gettext_noop (String) 34 | #else 35 | #define N_(String) (String) 36 | #endif 37 | 38 | #endif /* __G_I18N_LIB_H__ */ 39 | 40 | 41 | -------------------------------------------------------------------------------- /ddk/make_line.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # make_line.pl 4 | # 5 | # this script does and should do just the following: 6 | # 1) top level elements under have line feed after them. 7 | # 2) remove spaces before/after those elements. 8 | # 9 | 10 | use strict; 11 | use utf8; 12 | use open ':utf8'; 13 | use open ':std'; 14 | 15 | my $ns = "d:"; 16 | 17 | makeLines(); 18 | exit 0; 19 | 20 | # ============================================================= 21 | # 22 | # ============================================================= 23 | sub makeLines 24 | { 25 | my $lastPos; 26 | 27 | # Skip other elements than . 28 | $/ = '>'; 29 | while (<>) { 30 | next if /^\n$/; 31 | last if /<${ns}entry/; 32 | $lastPos = tell; 33 | s/^[[:blank:]\n]*//; 34 | s/[[:blank:]\n]*$//; 35 | print $_,"\n"; 36 | # printf "[%s]\n", $_; 37 | } 38 | seek ARGV, $lastPos, 0; 39 | die unless /<${ns}entry/; 40 | print "\n"; 41 | 42 | # Process all entries. 43 | # my $entry = "entry"; 44 | $/ = ""; 45 | while(<>) { 46 | next if /^\n$/; 47 | # last unless s/^[[:blank:]\n]*<${ns}entry/<${ns}entry/; 48 | last unless s/.*?<${ns}entry/<${ns}entry/s; 49 | die unless s|$||; 50 | $lastPos = tell; 51 | print $_,"\n"; # an entry 52 | #print $_,"\n\n"; 53 | # printf "[%s]\n", $_; 54 | } 55 | seek ARGV, $lastPos, 0; 56 | 57 | # Skip other elements than . 58 | $/ = '>'; 59 | while (<>) { 60 | s/^[[:blank:]\n]*//; 61 | s/[[:blank:]\n]*$//; 62 | print $_,"\n"; 63 | # printf "[%s]\n", $_; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /sdconv/include/glib/gmappedfile.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * gmappedfile.h: Simplified wrapper around the mmap function 3 | * 4 | * Copyright 2005 Matthias Clasen 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | #ifndef __G_MAPPED_FILE_H__ 22 | #define __G_MAPPED_FILE_H__ 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | typedef struct _GMappedFile GMappedFile; 29 | 30 | GMappedFile *g_mapped_file_new (const gchar *filename, 31 | gboolean writable, 32 | GError **error) G_GNUC_MALLOC; 33 | gsize g_mapped_file_get_length (GMappedFile *file); 34 | gchar *g_mapped_file_get_contents (GMappedFile *file); 35 | void g_mapped_file_free (GMappedFile *file); 36 | 37 | G_END_DECLS 38 | 39 | #endif /* __G_MAPPED_FILE_H__ */ 40 | -------------------------------------------------------------------------------- /sdconv/include/glib/gqsort.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | 28 | #ifndef __G_QSORT_H__ 29 | #define __G_QSORT_H__ 30 | 31 | #include 32 | 33 | G_BEGIN_DECLS 34 | 35 | void g_qsort_with_data (gconstpointer pbase, 36 | gint total_elems, 37 | gsize size, 38 | GCompareDataFunc compare_func, 39 | gpointer user_data); 40 | 41 | G_END_DECLS 42 | 43 | #endif /* __G_QSORT_H__ */ 44 | 45 | -------------------------------------------------------------------------------- /ddk/remove_duplicate_key.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # Remove duplicate key record 4 | # 5 | # remove_duplicate_key.pl < infile > outfile 6 | # 7 | 8 | use strict; 9 | use utf8; 10 | use open ':utf8'; 11 | use open ':std'; 12 | 13 | 14 | # ============================================================= 15 | my %keyBodyHash; 16 | # ============================================================= 17 | 18 | 19 | # ============================================================= 20 | # main 21 | # ============================================================= 22 | 23 | my $cur_body_id = ''; 24 | 25 | while ( my $record = ) 26 | { 27 | chomp $record; 28 | if ( $record =~ /^$/ ) 29 | { 30 | next; 31 | } 32 | 33 | my ( $key_text, $body_id, $flags, $title, $anchor, $yomi, $entry_title ) = split /\t/, $record; 34 | 35 | if ( ( not defined( $entry_title ) ) or ( not defined( $body_id ) ) ) 36 | { 37 | printf STDERR "*** Unknown format. Skipped [%s]\n", $record; 38 | next; 39 | } 40 | 41 | if ( $body_id eq $cur_body_id ) # Another key for current entry. 42 | { 43 | # If this is a new one for the entry, 44 | # remember the record, and output it. 45 | if ( not defined( $keyBodyHash{ $record } ) ) 46 | { 47 | $keyBodyHash{ $record } = $record; 48 | printf "%s\n", $record; 49 | } 50 | else 51 | { 52 | printf STDERR "* Duplicate index. Skipped [%s]\n", $record; 53 | } 54 | } 55 | else # Next entry. 56 | { 57 | # Clear hash, remember the record, and output it. 58 | $cur_body_id = $body_id; 59 | %keyBodyHash = (); 60 | $keyBodyHash{ $record } = $record; 61 | printf "%s\n", $record; 62 | } 63 | } 64 | 65 | exit 0; 66 | -------------------------------------------------------------------------------- /sdconv/include/glib/gpattern.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997, 1999 Peter Mattis, Red Hat, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | #ifndef __G_PATTERN_H__ 20 | #define __G_PATTERN_H__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | 27 | typedef struct _GPatternSpec GPatternSpec; 28 | 29 | GPatternSpec* g_pattern_spec_new (const gchar *pattern); 30 | void g_pattern_spec_free (GPatternSpec *pspec); 31 | gboolean g_pattern_spec_equal (GPatternSpec *pspec1, 32 | GPatternSpec *pspec2); 33 | gboolean g_pattern_match (GPatternSpec *pspec, 34 | guint string_length, 35 | const gchar *string, 36 | const gchar *string_reversed); 37 | gboolean g_pattern_match_string (GPatternSpec *pspec, 38 | const gchar *string); 39 | gboolean g_pattern_match_simple (const gchar *pattern, 40 | const gchar *string); 41 | 42 | G_END_DECLS 43 | 44 | #endif /* __G_PATTERN_H__ */ 45 | -------------------------------------------------------------------------------- /sdconv/include/glib/gprimes.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_PRIMES_H__ 28 | #define __G_PRIMES_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | /* Prime numbers. 35 | */ 36 | 37 | /* This function returns prime numbers spaced by approximately 1.5-2.0 38 | * and is for use in resizing data structures which prefer 39 | * prime-valued sizes. The closest spaced prime function returns the 40 | * next largest prime, or the highest it knows about which is about 41 | * MAXINT/4. 42 | */ 43 | guint g_spaced_primes_closest (guint num) G_GNUC_CONST; 44 | 45 | G_END_DECLS 46 | 47 | #endif /* __G_PRIMES_H__ */ 48 | -------------------------------------------------------------------------------- /sdconv/include/glib/gdir.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * gdir.c: Simplified wrapper around the DIRENT functions. 5 | * 6 | * Copyright 2001 Hans Breuer 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | */ 23 | #ifndef __G_DIR_H__ 24 | #define __G_DIR_H__ 25 | 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | typedef struct _GDir GDir; 31 | 32 | #ifdef G_OS_WIN32 33 | /* For DLL ABI stability, keep old names for old (non-UTF-8) functionality. */ 34 | #define g_dir_open g_dir_open_utf8 35 | #define g_dir_read_name g_dir_read_name_utf8 36 | #endif 37 | 38 | GDir * g_dir_open (const gchar *path, 39 | guint flags, 40 | GError **error); 41 | G_CONST_RETURN gchar *g_dir_read_name (GDir *dir); 42 | void g_dir_rewind (GDir *dir); 43 | void g_dir_close (GDir *dir); 44 | 45 | G_END_DECLS 46 | 47 | #endif /* __G_DIR_H__ */ 48 | -------------------------------------------------------------------------------- /sdconv/include/glib/gshell.h: -------------------------------------------------------------------------------- 1 | /* gshell.h - Shell-related utilities 2 | * 3 | * Copyright 2000 Red Hat, Inc. 4 | * 5 | * GLib is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * GLib is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with GLib; see the file COPYING.LIB. If not, write 17 | * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_SHELL_H__ 22 | #define __G_SHELL_H__ 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | #define G_SHELL_ERROR g_shell_error_quark () 29 | 30 | typedef enum 31 | { 32 | /* mismatched or otherwise mangled quoting */ 33 | G_SHELL_ERROR_BAD_QUOTING, 34 | /* string to be parsed was empty */ 35 | G_SHELL_ERROR_EMPTY_STRING, 36 | G_SHELL_ERROR_FAILED 37 | } GShellError; 38 | 39 | GQuark g_shell_error_quark (void); 40 | 41 | gchar* g_shell_quote (const gchar *unquoted_string); 42 | gchar* g_shell_unquote (const gchar *quoted_string, 43 | GError **error); 44 | gboolean g_shell_parse_argv (const gchar *command_line, 45 | gint *argcp, 46 | gchar ***argvp, 47 | GError **error); 48 | 49 | G_END_DECLS 50 | 51 | #endif /* __G_SHELL_H__ */ 52 | 53 | 54 | -------------------------------------------------------------------------------- /sdconv/include/glib/gbase64.h: -------------------------------------------------------------------------------- 1 | /* gbase64.h - Base64 coding functions 2 | * 3 | * Copyright (C) 2005 Alexander Larsson 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_BASE64_H__ 22 | #define __G_BASE64_H__ 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | gsize g_base64_encode_step (const guchar *in, 29 | gsize len, 30 | gboolean break_lines, 31 | gchar *out, 32 | gint *state, 33 | gint *save); 34 | gsize g_base64_encode_close (gboolean break_lines, 35 | gchar *out, 36 | gint *state, 37 | gint *save); 38 | gchar* g_base64_encode (const guchar *data, 39 | gsize len) G_GNUC_MALLOC; 40 | gsize g_base64_decode_step (const gchar *in, 41 | gsize len, 42 | guchar *out, 43 | gint *state, 44 | guint *save); 45 | guchar *g_base64_decode (const gchar *text, 46 | gsize *out_len) G_GNUC_MALLOC; 47 | 48 | G_END_DECLS 49 | 50 | #endif /* __G_BASE64_H__ */ 51 | -------------------------------------------------------------------------------- /sdconv/index.cpp: -------------------------------------------------------------------------------- 1 | // index.cpp 2 | 3 | #include "index.h" 4 | #include 5 | #include 6 | 7 | mdk_index::mdk_index() 8 | { 9 | entry_buffer = NULL; 10 | } 11 | 12 | mdk_index::~mdk_index() 13 | { 14 | g_free(entry_buffer); 15 | } 16 | 17 | size_t mdk_index::entry_count() 18 | { 19 | return entry_list.size(); 20 | } 21 | 22 | bool mdk_index::load(const gchar *file, guint32 entry_count, guint32 fsize) 23 | { 24 | size_t len; 25 | 26 | if (g_str_has_suffix(file, ".gz")) 27 | { 28 | gzFile in = gzopen(file, "rb"); 29 | 30 | if (in == NULL) 31 | return false; 32 | 33 | entry_buffer = (gchar *) g_malloc(fsize); 34 | len = gzread(in, entry_buffer, fsize); 35 | gzclose(in); 36 | } else 37 | { 38 | FILE *in = fopen(file, "rb"); 39 | 40 | if (! in) 41 | return false; 42 | 43 | entry_buffer = (gchar *) g_malloc(fsize); 44 | len = fread(entry_buffer, 1, fsize, in); 45 | 46 | fclose(in); 47 | } 48 | 49 | if (len == 0 || len != fsize) 50 | return false; 51 | 52 | entry_list.resize(entry_count); 53 | gchar *p1 = entry_buffer; 54 | guint32 i; 55 | 56 | for (i = 0; i < entry_count; i++) 57 | { 58 | entry_list[i] = p1; 59 | p1 += strlen(p1) + 1 + 2 * sizeof(guint32); 60 | } 61 | 62 | return true; 63 | } 64 | 65 | bool mdk_index::get_entry(guint32 index, mdk_entry *entry) 66 | { 67 | if (index >= entry_count()) 68 | return false; 69 | 70 | gchar *p1 = entry_list[index]; 71 | entry->key = p1; 72 | 73 | p1 += strlen(entry->key) + sizeof(gchar); 74 | entry->offset = ntohl(get_uint32(p1)); 75 | 76 | p1 += sizeof(guint32); 77 | entry->size = ntohl(get_uint32(p1)); 78 | 79 | #if 0 80 | fprintf(stderr, "index = %u, offset = %u, size = %u\n", 81 | index, entry->offset, entry->size); 82 | #endif 83 | 84 | return true; 85 | } 86 | -------------------------------------------------------------------------------- /sdconv/include/glib/gquark.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_QUARK_H__ 28 | #define __G_QUARK_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef guint32 GQuark; 35 | 36 | /* Quarks (string<->id association) 37 | */ 38 | GQuark g_quark_try_string (const gchar *string); 39 | GQuark g_quark_from_static_string (const gchar *string); 40 | GQuark g_quark_from_string (const gchar *string); 41 | G_CONST_RETURN gchar* g_quark_to_string (GQuark quark) G_GNUC_CONST; 42 | 43 | G_CONST_RETURN gchar* g_intern_string (const gchar *string); 44 | G_CONST_RETURN gchar* g_intern_static_string (const gchar *string); 45 | 46 | 47 | G_END_DECLS 48 | 49 | #endif /* __G_QUARK_H__ */ 50 | 51 | -------------------------------------------------------------------------------- /sdconv/include/glib/gprintf.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997, 2002 Peter Mattis, Red Hat, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | #ifndef __G_PRINTF_H__ 20 | #define __G_PRINTF_H__ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | gint g_printf (gchar const *format, 29 | ...) G_GNUC_PRINTF (1, 2); 30 | gint g_fprintf (FILE *file, 31 | gchar const *format, 32 | ...) G_GNUC_PRINTF (2, 3); 33 | gint g_sprintf (gchar *string, 34 | gchar const *format, 35 | ...) G_GNUC_PRINTF (2, 3); 36 | 37 | gint g_vprintf (gchar const *format, 38 | va_list args); 39 | gint g_vfprintf (FILE *file, 40 | gchar const *format, 41 | va_list args); 42 | gint g_vsprintf (gchar *string, 43 | gchar const *format, 44 | va_list args); 45 | gint g_vasprintf (gchar **string, 46 | gchar const *format, 47 | va_list args); 48 | 49 | G_END_DECLS 50 | 51 | #endif /* __G_PRINTF_H__ */ 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ddk/pick_referred_entry_id.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # Output entry_id lines that are referred in the dictionary. 4 | # 5 | # pick_used_reference_id.pl < entry_body_list.txt > reduced_entry_body_list.txt 6 | # 7 | 8 | use strict; 9 | use utf8; 10 | use open ':utf8'; 11 | use open ':std'; 12 | 13 | 14 | # ============================================================= 15 | my %referred_id_hash; 16 | # ============================================================= 17 | 18 | 19 | # ============================================================= 20 | # main 21 | # ============================================================= 22 | 23 | if ( $#ARGV != 0 ) 24 | { 25 | print STDERR "Usage: pick_used_reference_id.pl referred_id_list < entry_body_list > referred_entry_body_list\n"; 26 | exit 2; 27 | } 28 | my $matching_table_file_path = $ARGV[0]; 29 | readUsedIdList( $matching_table_file_path ); 30 | pickUsedId(); 31 | exit 0; 32 | 33 | 34 | # ============================================================= 35 | # pickUsedId 36 | # ============================================================= 37 | sub pickUsedId 38 | { 39 | while ( my $record = ) 40 | { 41 | chomp $record; 42 | if ( $record =~ /^$/ ) 43 | { 44 | next; 45 | } 46 | 47 | my ( $entry_id, $body_id ) = split /\t/, $record; 48 | if ( not defined $body_id ) 49 | { 50 | printf STDERR "*** Unknown format. Skipped [%s]\n", $record; 51 | next; 52 | } 53 | 54 | my $used = $referred_id_hash{ $entry_id }; 55 | if ( defined $used && $used > 0 ) 56 | { 57 | printf "%s\n", $record; 58 | } 59 | } 60 | } 61 | 62 | 63 | # ============================================================= 64 | # readUsedIdList 65 | # ============================================================= 66 | sub readUsedIdList 67 | { 68 | my ( $file_path ) = @_; 69 | open( REFERRED_ID_LIST, $file_path ) 70 | or die "*** Not found: $file_path"; 71 | 72 | 73 | while( ) { 74 | chomp; 75 | my ( $entry_id ) = $_; 76 | if ( defined $entry_id ) 77 | { 78 | $referred_id_hash{ $entry_id } = 1; 79 | } 80 | } 81 | 82 | close REFERRED_ID_LIST; 83 | } 84 | -------------------------------------------------------------------------------- /ddk/make_body.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Create dictionary body and offset/size file. 4 | # 5 | # make_body.pl xml_file 6 | # It makes 2 files. 7 | # - "objects_dir/dict.body" 8 | # - "objects_dir/dict.offsets" 9 | # 10 | 11 | use strict; 12 | use utf8; 13 | use open ':utf8'; 14 | use open ':std'; 15 | require bytes; 16 | 17 | # separator 18 | my $sp = "[[:blank:]\n]"; # 19 | my $reqsp = "[[:blank:]\n]+"; # required space 20 | my $optsp = "[[:blank:]\n]*"; # optional space 21 | 22 | my $qattr = "(\"[^\"]*\"|'[^']*')"; # quoted attribute value 23 | my $qattr_ne = "(\"[^\"]+\"|'[^']+')"; # quoted attribute value (non-empty) 24 | 25 | # namespace 26 | my $ns = "d:"; 27 | # node name 28 | my $index_ndnm = "index"; 29 | 30 | 31 | my $objects_dir = $ENV{ 'DICT_DEV_KIT_OBJ_DIR' }; 32 | if ( ! defined( $objects_dir ) ) 33 | { 34 | print STDERR " * No environment variable 'DICT_DEV_KIT_OBJ_DIR'.\n"; 35 | $objects_dir = "objects"; 36 | printf STDERR " * Using '%s'.\n", $objects_dir; 37 | } 38 | 39 | open( BODY, ">$objects_dir/dict.body") or die "*** Can't open $objects_dir/dict.body\n"; 40 | open( INDEX, ">$objects_dir/dict.offsets") or die "*** Can't open $objects_dir/dict.offsets\n"; 41 | 42 | my $offset = 0; 43 | # my $serial = 1; 44 | 45 | # Skip other lines that does not begin with . 46 | my $lastPos; 47 | while (<>) { 48 | last if /<${ns}entry/; 49 | $lastPos = tell; 50 | # chomp; 51 | # print $_,"\n"; 52 | } 53 | seek ARGV, $lastPos, 0; 54 | 55 | 56 | $/ = "\n"; 57 | while (<>) { 58 | # printf "[%s]\n", $_; 59 | next unless /^<${ns}entry/; 60 | 61 | s|^<${ns}entry|<${ns}entry xmlns:d="http://www.apple.com/DTDs/DictionaryService-1.0.rng"|; 62 | 63 | # Remove . 64 | s/<$ns$index_ndnm$reqsp[^<]+\/>|<$ns$index_ndnm$reqsp[^<]+>$optsp<\/d:index>//g; 65 | s/\n[[:blank:]\t]*\n/\n/g; 66 | 67 | print BODY $_; 68 | 69 | my $bytesize = bytes::length($_); 70 | die "No ID ** [$_] **" unless /^<${ns}entry [^<]+?id$optsp=$optsp($qattr_ne)/; # " 71 | $1 =~ /^(["']{1})([^\1]*)\1$/; 72 | my $entry_id = $2; 73 | print INDEX "$entry_id\t$offset\t$bytesize\n"; 74 | # ++$serial; 75 | $offset += $bytesize; 76 | } 77 | 78 | close INDEX; 79 | close BODY; 80 | exit(0); 81 | -------------------------------------------------------------------------------- /sdconv/include/glib/galloca.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_ALLOCA_H__ 28 | #define __G_ALLOCA_H__ 29 | 30 | #include 31 | 32 | #ifdef __GNUC__ 33 | /* GCC does the right thing */ 34 | # undef alloca 35 | # define alloca(size) __builtin_alloca (size) 36 | #elif defined (GLIB_HAVE_ALLOCA_H) 37 | /* a native and working alloca.h is there */ 38 | # include 39 | #else /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */ 40 | # if defined(_MSC_VER) || defined(__DMC__) 41 | # include 42 | # define alloca _alloca 43 | # else /* !_MSC_VER && !__DMC__ */ 44 | # ifdef _AIX 45 | # pragma alloca 46 | # else /* !_AIX */ 47 | # ifndef alloca /* predefined by HP cc +Olibcalls */ 48 | G_BEGIN_DECLS 49 | char *alloca (); 50 | G_END_DECLS 51 | # endif /* !alloca */ 52 | # endif /* !_AIX */ 53 | # endif /* !_MSC_VER && !__DMC__ */ 54 | #endif /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */ 55 | 56 | #define g_alloca(size) alloca (size) 57 | #define g_newa(struct_type, n_structs) ((struct_type*) g_alloca (sizeof (struct_type) * (gsize) (n_structs))) 58 | 59 | 60 | #endif /* __G_ALLOCA_H__ */ 61 | -------------------------------------------------------------------------------- /sdconv/storage.cpp: -------------------------------------------------------------------------------- 1 | #include "storage.h" 2 | #include 3 | 4 | ResourceStorage::ResourceStorage() 5 | { 6 | file_storage = NULL; 7 | database_storage = NULL; 8 | } 9 | 10 | ResourceStorage::~ResourceStorage() 11 | { 12 | delete file_storage; 13 | delete database_storage; 14 | } 15 | 16 | bool ResourceStorage::load(const char *dirname) 17 | { 18 | std::string resdir(dirname); 19 | resdir += G_DIR_SEPARATOR_S "res"; 20 | if (g_file_test(resdir.c_str(), G_FILE_TEST_IS_DIR)) { 21 | file_storage = new File_ResourceStorage(resdir.c_str()); 22 | is_file_or_db = 1; 23 | return false; 24 | } 25 | std::string rifofilename(dirname); 26 | rifofilename += G_DIR_SEPARATOR_S "res.rifo"; 27 | if (g_file_test(rifofilename.c_str(), G_FILE_TEST_EXISTS)) { 28 | database_storage = new Database_ResourceStorage(); 29 | bool failed = database_storage->load(rifofilename.c_str()); 30 | if (failed) { 31 | delete database_storage; 32 | database_storage = NULL; 33 | return true; 34 | } 35 | is_file_or_db = 0; 36 | return false; 37 | } 38 | return true; 39 | } 40 | 41 | const char *ResourceStorage::get_file_path(const char *key) 42 | { 43 | if (is_file_or_db) 44 | return file_storage->get_file_path(key); 45 | else 46 | return database_storage->get_file_path(key); 47 | } 48 | 49 | const char *ResourceStorage::get_file_content(const char *key) 50 | { 51 | if (is_file_or_db) 52 | return file_storage->get_file_content(key); 53 | else 54 | return database_storage->get_file_content(key); 55 | } 56 | 57 | File_ResourceStorage::File_ResourceStorage(const char *resdir_) 58 | { 59 | resdir = resdir_; 60 | } 61 | 62 | const char *File_ResourceStorage::get_file_path(const char *key) 63 | { 64 | filepath = resdir; 65 | filepath += G_DIR_SEPARATOR; 66 | filepath += key; 67 | return filepath.c_str(); 68 | } 69 | 70 | const char *File_ResourceStorage::get_file_content(const char *key) 71 | { 72 | return NULL; 73 | } 74 | 75 | Database_ResourceStorage::Database_ResourceStorage() 76 | { 77 | } 78 | 79 | bool Database_ResourceStorage::load(const char *rifofilename) 80 | { 81 | return false; 82 | } 83 | 84 | const char *Database_ResourceStorage::get_file_path(const char *key) 85 | { 86 | return NULL; 87 | } 88 | 89 | const char *Database_ResourceStorage::get_file_content(const char *key) 90 | { 91 | return NULL; 92 | } 93 | -------------------------------------------------------------------------------- /sdconv/include/glib/gtimer.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_TIMER_H__ 28 | #define __G_TIMER_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | /* Timer 35 | */ 36 | 37 | /* microseconds per second */ 38 | typedef struct _GTimer GTimer; 39 | 40 | #define G_USEC_PER_SEC 1000000 41 | 42 | GTimer* g_timer_new (void); 43 | void g_timer_destroy (GTimer *timer); 44 | void g_timer_start (GTimer *timer); 45 | void g_timer_stop (GTimer *timer); 46 | void g_timer_reset (GTimer *timer); 47 | void g_timer_continue (GTimer *timer); 48 | gdouble g_timer_elapsed (GTimer *timer, 49 | gulong *microseconds); 50 | 51 | void g_usleep (gulong microseconds); 52 | 53 | void g_time_val_add (GTimeVal *time_, 54 | glong microseconds); 55 | gboolean g_time_val_from_iso8601 (const gchar *iso_date, 56 | GTimeVal *time_); 57 | gchar* g_time_val_to_iso8601 (GTimeVal *time_) G_GNUC_MALLOC; 58 | 59 | G_END_DECLS 60 | 61 | #endif /* __G_TIMER_H__ */ 62 | -------------------------------------------------------------------------------- /sdconv/include/glib/gerror.h: -------------------------------------------------------------------------------- 1 | /* gerror.h - Error reporting system 2 | * 3 | * Copyright 2000 Red Hat, Inc. 4 | * 5 | * The Gnome Library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * The Gnome Library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with the Gnome Library; see the file COPYING.LIB. If not, 17 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_ERROR_H__ 22 | #define __G_ERROR_H__ 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | typedef struct _GError GError; 29 | 30 | struct _GError 31 | { 32 | GQuark domain; 33 | gint code; 34 | gchar *message; 35 | }; 36 | 37 | GError* g_error_new (GQuark domain, 38 | gint code, 39 | const gchar *format, 40 | ...) G_GNUC_PRINTF (3, 4); 41 | 42 | GError* g_error_new_literal (GQuark domain, 43 | gint code, 44 | const gchar *message); 45 | 46 | void g_error_free (GError *error); 47 | GError* g_error_copy (const GError *error); 48 | 49 | gboolean g_error_matches (const GError *error, 50 | GQuark domain, 51 | gint code); 52 | 53 | /* if (err) *err = g_error_new(domain, code, format, ...), also has 54 | * some sanity checks. 55 | */ 56 | void g_set_error (GError **err, 57 | GQuark domain, 58 | gint code, 59 | const gchar *format, 60 | ...) G_GNUC_PRINTF (4, 5); 61 | 62 | /* if (dest) *dest = src; also has some sanity checks. 63 | */ 64 | void g_propagate_error (GError **dest, 65 | GError *src); 66 | 67 | /* if (err && *err) { g_error_free(*err); *err = NULL; } */ 68 | void g_clear_error (GError **err); 69 | 70 | 71 | G_END_DECLS 72 | 73 | #endif /* __G_ERROR_H__ */ 74 | 75 | -------------------------------------------------------------------------------- /sdconv/include/glib/gbacktrace.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_BACKTRACE_H__ 28 | #define __G_BACKTRACE_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | /* Fatal error handlers. 35 | * g_on_error_query() will prompt the user to either 36 | * [E]xit, [H]alt, [P]roceed or show [S]tack trace. 37 | * g_on_error_stack_trace() invokes gdb, which attaches to the current 38 | * process and shows a stack trace. 39 | * These function may cause different actions on non-unix platforms. 40 | * The prg_name arg is required by gdb to find the executable, if it is 41 | * passed as NULL, g_on_error_query() will try g_get_prgname(). 42 | */ 43 | void g_on_error_query (const gchar *prg_name); 44 | void g_on_error_stack_trace (const gchar *prg_name); 45 | 46 | /* Hacker macro to place breakpoints for selected machines. 47 | * Actual use is strongly discouraged of course ;) 48 | */ 49 | #if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__) && __GNUC__ >= 2 50 | # define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END 51 | #elif (defined (_MSC_VER) || defined (__DMC__)) && defined (_M_IX86) 52 | # define G_BREAKPOINT() G_STMT_START{ __asm int 3h }G_STMT_END 53 | #elif defined (__alpha__) && !defined(__osf__) && defined (__GNUC__) && __GNUC__ >= 2 54 | # define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("bpt"); }G_STMT_END 55 | #else /* !__i386__ && !__alpha__ */ 56 | # define G_BREAKPOINT() G_STMT_START{ raise (SIGTRAP); }G_STMT_END 57 | #endif /* __i386__ */ 58 | 59 | G_END_DECLS 60 | 61 | #endif /* __G_BACKTRACE_H__ */ 62 | -------------------------------------------------------------------------------- /ddk/replace_entryid_bodyid.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # 4 | # replace_entryid_bodyid.pl 5 | # 6 | 7 | use strict; 8 | use utf8; 9 | use open ':utf8'; 10 | use open ':std'; 11 | 12 | 13 | # ============================================================= 14 | my %entryToBodyHash; 15 | # ============================================================= 16 | 17 | 18 | 19 | # ============================================================= 20 | # main 21 | # ============================================================= 22 | 23 | if ( $#ARGV != 0 ) 24 | { 25 | print STDERR "Usage: replaceEntryIdByBodyId.pl entry_body_list < key_entry_list > key_body_list\n"; 26 | print STDERR " Input data format\n"; 27 | print STDERR " entry_body_list: entry_idbody_id\n"; 28 | print STDERR " key_entry_list : key_textentry_idflagstitleanchoryomientry_title\n"; 29 | print STDERR " Output data format\n"; 30 | print STDERR " key_body_list : key_textbody_idflagstitleanchoryomientry_title\n"; 31 | exit 2; 32 | } 33 | my $matching_table_file_path = $ARGV[0]; 34 | readMatchingTable( $matching_table_file_path ); 35 | replaceEntryIdByBodyId(); 36 | exit 0; 37 | 38 | 39 | # ============================================================= 40 | # replaceEntryIdByBodyId 41 | # ============================================================= 42 | sub replaceEntryIdByBodyId 43 | { 44 | while ( my $record = ) 45 | { 46 | chomp $record; 47 | if ( $record =~ /^$/ ) 48 | { 49 | next; 50 | } 51 | 52 | my ( $key_text, $entry_id, $flags, $title, $anchor, $yomi, $entry_title ) = split /\t/, $record; 53 | if ( not defined $entry_title ) 54 | { 55 | printf STDERR "*** Unknown format. Skipped [%s]\n", $record; 56 | next; 57 | } 58 | 59 | my $body_id = $entryToBodyHash{ $entry_id }; 60 | if ( not defined $body_id ) 61 | { 62 | printf STDERR "*** No corresponding body_id. Skipped [%s]\n", $record; 63 | next; 64 | } 65 | 66 | printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", 67 | $key_text, $body_id, $flags, $title, $anchor, $yomi, $entry_title; 68 | } 69 | } 70 | 71 | 72 | # ============================================================= 73 | # readMatchingTable 74 | # ============================================================= 75 | sub readMatchingTable 76 | { 77 | my ( $file_path ) = @_; 78 | open( ENTRY_TO_BODY, $file_path ) 79 | or die "*** Not found: $file_path"; 80 | 81 | while( ) { 82 | chomp; 83 | my ( $entry_id, $body_id ) = split /\t/; 84 | if ( defined $entry_id and defined $body_id ) 85 | { 86 | if ( defined( $entryToBodyHash{ $entry_id } ) ) 87 | { 88 | die "*** Duplicate entry_id: [$entry_id]"; 89 | } 90 | $entryToBodyHash{ $entry_id } = $body_id; 91 | } 92 | } 93 | 94 | close ENTRY_TO_BODY; 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /sdconv/include/glib/gcompletion.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_COMPLETION_H__ 28 | #define __G_COMPLETION_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GCompletion GCompletion; 35 | 36 | typedef gchar* (*GCompletionFunc) (gpointer); 37 | 38 | /* GCompletion 39 | */ 40 | 41 | typedef gint (*GCompletionStrncmpFunc) (const gchar *s1, 42 | const gchar *s2, 43 | gsize n); 44 | 45 | struct _GCompletion 46 | { 47 | GList* items; 48 | GCompletionFunc func; 49 | 50 | gchar* prefix; 51 | GList* cache; 52 | GCompletionStrncmpFunc strncmp_func; 53 | }; 54 | 55 | GCompletion* g_completion_new (GCompletionFunc func); 56 | void g_completion_add_items (GCompletion* cmp, 57 | GList* items); 58 | void g_completion_remove_items (GCompletion* cmp, 59 | GList* items); 60 | void g_completion_clear_items (GCompletion* cmp); 61 | GList* g_completion_complete (GCompletion* cmp, 62 | const gchar* prefix, 63 | gchar** new_prefix); 64 | GList* g_completion_complete_utf8 (GCompletion *cmp, 65 | const gchar* prefix, 66 | gchar** new_prefix); 67 | void g_completion_set_compare (GCompletion *cmp, 68 | GCompletionStrncmpFunc strncmp_func); 69 | void g_completion_free (GCompletion* cmp); 70 | 71 | G_END_DECLS 72 | 73 | #endif /* __G_COMPLETION_H__ */ 74 | 75 | -------------------------------------------------------------------------------- /sdconv/include/glib.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_LIB_H__ 28 | #define __G_LIB_H__ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | #ifdef G_PLATFORM_WIN32 81 | #include 82 | #endif 83 | 84 | #endif /* __G_LIB_H__ */ 85 | -------------------------------------------------------------------------------- /sdconv/include/glib/gatomic.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * g_atomic_*: atomic operations. 5 | * Copyright (C) 2003 Sebastian Wilhelmi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | /* 24 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 25 | * file for a list of people on the GLib Team. See the ChangeLog 26 | * files for a list of changes. These files are distributed with 27 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 28 | */ 29 | 30 | #ifndef __G_ATOMIC_H__ 31 | #define __G_ATOMIC_H__ 32 | 33 | #include 34 | 35 | G_BEGIN_DECLS 36 | 37 | gint g_atomic_int_exchange_and_add (volatile gint *atomic, 38 | gint val); 39 | void g_atomic_int_add (volatile gint *atomic, 40 | gint val); 41 | gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic, 42 | gint oldval, 43 | gint newval); 44 | gboolean g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 45 | gpointer oldval, 46 | gpointer newval); 47 | 48 | gint g_atomic_int_get (volatile gint *atomic); 49 | void g_atomic_int_set (volatile gint *atomic, 50 | gint newval); 51 | gpointer g_atomic_pointer_get (volatile gpointer *atomic); 52 | void g_atomic_pointer_set (volatile gpointer *atomic, 53 | gpointer newval); 54 | 55 | #ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED 56 | # define g_atomic_int_get(atomic) (*(atomic)) 57 | # define g_atomic_int_set(atomic, newval) ((void) (*(atomic) = (newval))) 58 | # define g_atomic_pointer_get(atomic) (*(atomic)) 59 | # define g_atomic_pointer_set(atomic, newval) ((void) (*(atomic) = (newval))) 60 | #endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */ 61 | 62 | #define g_atomic_int_inc(atomic) (g_atomic_int_add ((atomic), 1)) 63 | #define g_atomic_int_dec_and_test(atomic) \ 64 | (g_atomic_int_exchange_and_add ((atomic), -1) == 1) 65 | 66 | G_END_DECLS 67 | 68 | #endif /* __G_ATOMIC_H__ */ 69 | -------------------------------------------------------------------------------- /sdconv/include/glib/gcache.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_CACHE_H__ 28 | #define __G_CACHE_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GCache GCache; 35 | 36 | typedef gpointer (*GCacheNewFunc) (gpointer key); 37 | typedef gpointer (*GCacheDupFunc) (gpointer value); 38 | typedef void (*GCacheDestroyFunc) (gpointer value); 39 | 40 | /* Caches 41 | */ 42 | GCache* g_cache_new (GCacheNewFunc value_new_func, 43 | GCacheDestroyFunc value_destroy_func, 44 | GCacheDupFunc key_dup_func, 45 | GCacheDestroyFunc key_destroy_func, 46 | GHashFunc hash_key_func, 47 | GHashFunc hash_value_func, 48 | GEqualFunc key_equal_func); 49 | void g_cache_destroy (GCache *cache); 50 | gpointer g_cache_insert (GCache *cache, 51 | gpointer key); 52 | void g_cache_remove (GCache *cache, 53 | gconstpointer value); 54 | void g_cache_key_foreach (GCache *cache, 55 | GHFunc func, 56 | gpointer user_data); 57 | #ifndef G_DISABLE_DEPRECATED 58 | void g_cache_value_foreach (GCache *cache, 59 | GHFunc func, 60 | gpointer user_data); 61 | #endif 62 | 63 | G_END_DECLS 64 | 65 | #endif /* __G_CACHE_H__ */ 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /zh_CN.lproj/MainMenu.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "NSMenuItem"; title = "Bring All to Front"; ObjectID = "5"; */ 3 | "5.title" = "前置全部窗口"; 4 | 5 | /* Class = "NSMenuItem"; title = "Window"; ObjectID = "19"; */ 6 | "19.title" = "窗口"; 7 | 8 | /* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "23"; */ 9 | "23.title" = "最小化"; 10 | 11 | /* Class = "NSMenu"; title = "Window"; ObjectID = "24"; */ 12 | "24.title" = "窗口"; 13 | 14 | /* Class = "NSMenu"; title = "AMainMenu"; ObjectID = "29"; */ 15 | "29.title" = "AMainMenu"; 16 | 17 | /* Class = "NSMenuItem"; title = "DictUnifier"; ObjectID = "56"; */ 18 | "56.title" = "DictUnifier"; 19 | 20 | /* Class = "NSMenu"; title = "DictUnifier"; ObjectID = "57"; */ 21 | "57.title" = "DictUnifier"; 22 | 23 | /* Class = "NSMenuItem"; title = "About DictUnifier"; ObjectID = "58"; */ 24 | "58.title" = "关于 DictUnifier"; 25 | 26 | /* Class = "NSMenuItem"; title = "Open…"; ObjectID = "72"; */ 27 | "72.title" = "打开…"; 28 | 29 | /* Class = "NSMenuItem"; title = "Close"; ObjectID = "73"; */ 30 | "73.title" = "关闭"; 31 | 32 | /* Class = "NSMenu"; title = "File"; ObjectID = "81"; */ 33 | "81.title" = "文件"; 34 | 35 | /* Class = "NSMenuItem"; title = "File"; ObjectID = "83"; */ 36 | "83.title" = "文件"; 37 | 38 | /* Class = "NSMenuItem"; title = "Help"; ObjectID = "103"; */ 39 | "103.title" = "帮助"; 40 | 41 | /* Class = "NSMenu"; title = "Help"; ObjectID = "106"; */ 42 | "106.title" = "帮助"; 43 | 44 | /* Class = "NSMenuItem"; title = "DictUnifier Help"; ObjectID = "111"; */ 45 | "111.title" = "DictUnifier 帮助"; 46 | 47 | /* Class = "NSMenuItem"; title = "Open Recent"; ObjectID = "124"; */ 48 | "124.title" = "打开最近使用的"; 49 | 50 | /* Class = "NSMenu"; title = "Open Recent"; ObjectID = "125"; */ 51 | "125.title" = "打开最近使用的"; 52 | 53 | /* Class = "NSMenuItem"; title = "Clear Menu"; ObjectID = "126"; */ 54 | "126.title" = "清除菜单"; 55 | 56 | /* Class = "NSMenuItem"; title = "Preferences…"; ObjectID = "129"; */ 57 | "129.title" = "偏好设置…"; 58 | 59 | /* Class = "NSMenu"; title = "Services"; ObjectID = "130"; */ 60 | "130.title" = "服务"; 61 | 62 | /* Class = "NSMenuItem"; title = "Services"; ObjectID = "131"; */ 63 | "131.title" = "服务"; 64 | 65 | /* Class = "NSMenuItem"; title = "Hide DictUnifier"; ObjectID = "134"; */ 66 | "134.title" = "隐藏 DictUnifier"; 67 | 68 | /* Class = "NSMenuItem"; title = "Quit DictUnifier"; ObjectID = "136"; */ 69 | "136.title" = "退出 DictUnifier"; 70 | 71 | /* Class = "NSMenuItem"; title = "Hide Others"; ObjectID = "145"; */ 72 | "145.title" = "隐藏其他"; 73 | 74 | /* Class = "NSMenuItem"; title = "Show All"; ObjectID = "150"; */ 75 | "150.title" = "全部显示"; 76 | 77 | /* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "239"; */ 78 | "239.title" = "缩放窗口"; 79 | 80 | /* Class = "DUWindow"; title = "DictUnifier"; ObjectID = "371"; */ 81 | "371.title" = "DictUnifier"; 82 | 83 | /* Class = "NSTextFieldCell"; title = "Drop a dictionary file to convert"; ObjectID = "462"; */ 84 | "462.title" = "拖入词典源文件开始转换"; 85 | 86 | /* Class = "NSButtonCell"; title = "Start"; ObjectID = "471"; */ 87 | "471.title" = "开始"; 88 | -------------------------------------------------------------------------------- /sdconv/include/glib/grand.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_RAND_H__ 28 | #define __G_RAND_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GRand GRand; 35 | 36 | /* GRand - a good and fast random number generator: Mersenne Twister 37 | * see http://www.math.keio.ac.jp/~matumoto/emt.html for more info. 38 | * The range functions return a value in the intervall [begin, end). 39 | * int -> [0..2^32-1] 40 | * int_range -> [begin..end-1] 41 | * double -> [0..1) 42 | * double_range -> [begin..end) 43 | */ 44 | 45 | GRand* g_rand_new_with_seed (guint32 seed); 46 | GRand* g_rand_new_with_seed_array (const guint32 *seed, 47 | guint seed_length); 48 | GRand* g_rand_new (void); 49 | void g_rand_free (GRand *rand_); 50 | GRand* g_rand_copy (GRand *rand_); 51 | void g_rand_set_seed (GRand *rand_, 52 | guint32 seed); 53 | void g_rand_set_seed_array (GRand *rand_, 54 | const guint32 *seed, 55 | guint seed_length); 56 | 57 | #define g_rand_boolean(rand_) ((g_rand_int (rand_) & (1 << 15)) != 0) 58 | 59 | guint32 g_rand_int (GRand *rand_); 60 | gint32 g_rand_int_range (GRand *rand_, 61 | gint32 begin, 62 | gint32 end); 63 | gdouble g_rand_double (GRand *rand_); 64 | gdouble g_rand_double_range (GRand *rand_, 65 | gdouble begin, 66 | gdouble end); 67 | void g_random_set_seed (guint32 seed); 68 | 69 | #define g_random_boolean() ((g_random_int () & (1 << 15)) != 0) 70 | 71 | guint32 g_random_int (void); 72 | gint32 g_random_int_range (gint32 begin, 73 | gint32 end); 74 | gdouble g_random_double (void); 75 | gdouble g_random_double_range (gdouble begin, 76 | gdouble end); 77 | 78 | 79 | G_END_DECLS 80 | 81 | #endif /* __G_RAND_H__ */ 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ddk/extract_referred_id.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Extract referred ID 4 | # 5 | # extract_referred_id.pl 6 | # 7 | 8 | use strict; 9 | use utf8; 10 | use open ':utf8'; 11 | use open ':std'; 12 | 13 | # separator 14 | my $sp = "[[:blank:]\n]"; # 15 | my $reqsp = "[[:blank:]\n]+"; # required space 16 | my $optsp = "[[:blank:]\n]*"; # optional space 17 | 18 | my $qattr = "(\"[^\"]*\"|'[^']*')"; # quoted attribute value 19 | my $qattr_ne = "(\"[^\"]+\"|'[^']+')"; # quoted attribute value (non-empty) 20 | 21 | # namespace 22 | my $ns = "d:"; 23 | # node name 24 | my $entry_ndnm = "entry"; 25 | # attribute name 26 | my $a_ndnm = "a"; 27 | my $href = "href"; 28 | my $xdict = "x-dictionary"; 29 | 30 | 31 | # ============================================================= 32 | # main 33 | # ============================================================= 34 | # Skip other lines that does not begin with . 35 | my $lastPos; 36 | while (<>) { 37 | last if /<$ns$entry_ndnm/; 38 | $lastPos = tell; 39 | # chomp; 40 | # print $_,"\n"; 41 | } 42 | seek ARGV, $lastPos, 0; 43 | 44 | $/ = "\n"; 45 | while ( <> ) 46 | { 47 | next unless /^<$ns$entry_ndnm/; 48 | process_an_entry( $_ ); 49 | } 50 | exit( 0 ); 51 | 52 | 53 | # ============================================================= 54 | # process_an_entry 55 | # ============================================================= 56 | sub process_an_entry 57 | { 58 | my ( $entry ) = @_; 59 | # printf "== [%s]\n", $entry; 60 | 61 | my $text = $entry; 62 | 63 | while ( $text =~ /((<$a_ndnm$reqsp[^>]+>).*?<\/$a_ndnm>)/ ) 64 | { 65 | $text = $'; #' 66 | #my $reference = $1; 67 | my $a_open_tag = $2; 68 | if ( $a_open_tag =~ /$reqsp$href$optsp=$optsp($qattr_ne)/ ) 69 | { 70 | $1 =~ /^(["']{1})([^\1]*)\1$/; 71 | my $referred_url = $2; 72 | process_a_referred_url( $referred_url ); 73 | } 74 | } 75 | } 76 | 77 | 78 | # ============================================================= 79 | # process_a_referred_url 80 | # ============================================================= 81 | sub process_a_referred_url 82 | { 83 | my ( $referred_url ) = @_; 84 | 85 | # printf "[%s]\n", $referred_url; # 86 | # This contains entry_id and dict_bundle_id formally. 87 | # The dict_bundle_id can be omitted. 88 | 89 | my $referred_id = ''; 90 | my $dict_bundle_id = ''; 91 | if ( $referred_url =~ /^$optsp$xdict:r:(.*?)$optsp$/ ) 92 | { 93 | $referred_id = $1; 94 | 95 | if ( $referred_id ne "" ) 96 | { 97 | # Remove dict_bundle_id part. 98 | if ( $referred_id =~ /^([^:]+):(.*?)$/ ) 99 | { 100 | $referred_id = $1; 101 | $dict_bundle_id = $2; 102 | } 103 | } 104 | } 105 | 106 | if ( $referred_id ne "" ) 107 | { 108 | $referred_id = decode_xml_char( $referred_id ); 109 | # printf "%s\t%s\n", $referred_id, $dict_bundle_id; 110 | printf "%s\n", $referred_id; 111 | } 112 | } 113 | 114 | 115 | # ============================================================= 116 | # decode_xml_char 117 | # ============================================================= 118 | sub decode_xml_char 119 | { 120 | my ( $text ) = @_; 121 | 122 | if ( defined( $text ) && ( $text ne '' ) ) 123 | { 124 | $text =~ s/<//g; 126 | $text =~ s/"/\"/g; 127 | $text =~ s/'/\'/g; 128 | $text =~ s/&/&/g; # "&" should be the last. 129 | } 130 | return $text; 131 | } 132 | -------------------------------------------------------------------------------- /sdconv/include/glib/gslice.h: -------------------------------------------------------------------------------- 1 | /* GLIB sliced memory - fast threaded memory chunk allocator 2 | * Copyright (C) 2005 Tim Janik 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | #ifndef __G_SLICE_H__ 20 | #define __G_SLICE_H__ 21 | 22 | #ifndef __G_MEM_H__ 23 | #error Include instead of 24 | #endif 25 | 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | /* slices - fast allocation/release of small memory blocks 31 | */ 32 | gpointer g_slice_alloc (gsize block_size) G_GNUC_MALLOC; 33 | gpointer g_slice_alloc0 (gsize block_size) G_GNUC_MALLOC; 34 | gpointer g_slice_copy (gsize block_size, 35 | gconstpointer mem_block) G_GNUC_MALLOC; 36 | void g_slice_free1 (gsize block_size, 37 | gpointer mem_block); 38 | void g_slice_free_chain_with_offset (gsize block_size, 39 | gpointer mem_chain, 40 | gsize next_offset); 41 | #define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type))) 42 | #define g_slice_new0(type) ((type*) g_slice_alloc0 (sizeof (type))) 43 | /* MemoryBlockType * 44 | * g_slice_dup (MemoryBlockType, 45 | * MemoryBlockType *mem_block); 46 | * g_slice_free (MemoryBlockType, 47 | * MemoryBlockType *mem_block); 48 | * g_slice_free_chain (MemoryBlockType, 49 | * MemoryBlockType *first_chain_block, 50 | * memory_block_next_field); 51 | * pseudo prototypes for the macro 52 | * definitions following below. 53 | */ 54 | 55 | /* we go through extra hoops to ensure type safety */ 56 | #define g_slice_dup(type, mem) \ 57 | (1 ? g_slice_copy (sizeof (type), (mem)) : (type*) ((type*) 0 == (mem))) 58 | #define g_slice_free(type, mem) do { \ 59 | if (1) g_slice_free1 (sizeof (type), (mem)); \ 60 | else (void) ((type*) 0 == (mem)); \ 61 | } while (0) 62 | #define g_slice_free_chain(type, mem_chain, next) do { \ 63 | if (1) g_slice_free_chain_with_offset (sizeof (type), \ 64 | (mem_chain), G_STRUCT_OFFSET (type, next)); \ 65 | else (void) ((type*) 0 == (mem_chain)); \ 66 | } while (0) 67 | 68 | 69 | /* --- internal debugging API --- */ 70 | typedef enum { 71 | G_SLICE_CONFIG_ALWAYS_MALLOC = 1, 72 | G_SLICE_CONFIG_BYPASS_MAGAZINES, 73 | G_SLICE_CONFIG_WORKING_SET_MSECS, 74 | G_SLICE_CONFIG_COLOR_INCREMENT, 75 | G_SLICE_CONFIG_CHUNK_SIZES, 76 | G_SLICE_CONFIG_CONTENTION_COUNTER 77 | } GSliceConfig; 78 | void g_slice_set_config (GSliceConfig ckey, gint64 value); 79 | gint64 g_slice_get_config (GSliceConfig ckey); 80 | gint64* g_slice_get_config_state (GSliceConfig ckey, gint64 address, guint *n_values); 81 | 82 | G_END_DECLS 83 | 84 | #endif /* __G_SLICE_H__ */ 85 | -------------------------------------------------------------------------------- /sdconv/include/glib/grel.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_REL_H__ 28 | #define __G_REL_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GRelation GRelation; 35 | typedef struct _GTuples GTuples; 36 | 37 | struct _GTuples 38 | { 39 | guint len; 40 | }; 41 | 42 | /* GRelation 43 | * 44 | * Indexed Relations. Imagine a really simple table in a 45 | * database. Relations are not ordered. This data type is meant for 46 | * maintaining a N-way mapping. 47 | * 48 | * g_relation_new() creates a relation with FIELDS fields 49 | * 50 | * g_relation_destroy() frees all resources 51 | * g_tuples_destroy() frees the result of g_relation_select() 52 | * 53 | * g_relation_index() indexes relation FIELD with the provided 54 | * equality and hash functions. this must be done before any 55 | * calls to insert are made. 56 | * 57 | * g_relation_insert() inserts a new tuple. you are expected to 58 | * provide the right number of fields. 59 | * 60 | * g_relation_delete() deletes all relations with KEY in FIELD 61 | * g_relation_select() returns ... 62 | * g_relation_count() counts ... 63 | */ 64 | 65 | GRelation* g_relation_new (gint fields); 66 | void g_relation_destroy (GRelation *relation); 67 | void g_relation_index (GRelation *relation, 68 | gint field, 69 | GHashFunc hash_func, 70 | GEqualFunc key_equal_func); 71 | void g_relation_insert (GRelation *relation, 72 | ...); 73 | gint g_relation_delete (GRelation *relation, 74 | gconstpointer key, 75 | gint field); 76 | GTuples* g_relation_select (GRelation *relation, 77 | gconstpointer key, 78 | gint field); 79 | gint g_relation_count (GRelation *relation, 80 | gconstpointer key, 81 | gint field); 82 | gboolean g_relation_exists (GRelation *relation, 83 | ...); 84 | void g_relation_print (GRelation *relation); 85 | 86 | void g_tuples_destroy (GTuples *tuples); 87 | gpointer g_tuples_index (GTuples *tuples, 88 | gint index_, 89 | gint field); 90 | 91 | G_END_DECLS 92 | 93 | #endif /* __G_REL_H__ */ 94 | 95 | -------------------------------------------------------------------------------- /sdconv/include/glib/gstdio.h: -------------------------------------------------------------------------------- 1 | /* gstdio.h - GFilename wrappers for C library functions 2 | * 3 | * Copyright 2004 Tor Lillqvist 4 | * 5 | * GLib is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * GLib is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with GLib; see the file COPYING.LIB. If not, 17 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_STDIO_H__ 22 | #define __G_STDIO_H__ 23 | 24 | #include 25 | 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | #if defined(G_OS_UNIX) && !defined(G_STDIO_NO_WRAP_ON_UNIX) 31 | 32 | /* Just pass on to the system functions, so there's no potential for data 33 | * format mismatches, especially with large file interfaces. 34 | * A few functions can't be handled in this way, since they are not defined 35 | * in a portable system header that we could include here. 36 | */ 37 | 38 | #define g_chmod chmod 39 | #define g_open open 40 | #define g_creat creat 41 | #define g_rename rename 42 | #define g_mkdir mkdir 43 | #define g_stat stat 44 | #define g_lstat lstat 45 | #define g_remove remove 46 | #define g_fopen fopen 47 | #define g_freopen freopen 48 | 49 | int g_access (const gchar *filename, 50 | int mode); 51 | 52 | int g_chdir (const gchar *path); 53 | 54 | int g_unlink (const gchar *filename); 55 | 56 | int g_rmdir (const gchar *filename); 57 | 58 | #else /* ! G_OS_UNIX */ 59 | 60 | /* Wrappers for C library functions that take pathname arguments. On 61 | * Unix, the pathname is a file name as it literally is in the file 62 | * system. On well-maintained systems with consistent users who know 63 | * what they are doing and no exchange of files with others this would 64 | * be a well-defined encoding, preferrably UTF-8. On Windows, the 65 | * pathname is always in UTF-8, even if that is not the on-disk 66 | * encoding, and not the encoding accepted by the C library or Win32 67 | * API. 68 | */ 69 | 70 | int g_access (const gchar *filename, 71 | int mode); 72 | 73 | int g_chmod (const gchar *filename, 74 | int mode); 75 | 76 | int g_open (const gchar *filename, 77 | int flags, 78 | int mode); 79 | 80 | int g_creat (const gchar *filename, 81 | int mode); 82 | 83 | int g_rename (const gchar *oldfilename, 84 | const gchar *newfilename); 85 | 86 | int g_mkdir (const gchar *filename, 87 | int mode); 88 | 89 | int g_chdir (const gchar *path); 90 | 91 | int g_stat (const gchar *filename, 92 | struct stat *buf); 93 | 94 | int g_lstat (const gchar *filename, 95 | struct stat *buf); 96 | 97 | int g_unlink (const gchar *filename); 98 | 99 | int g_remove (const gchar *filename); 100 | 101 | int g_rmdir (const gchar *filename); 102 | 103 | FILE *g_fopen (const gchar *filename, 104 | const gchar *mode); 105 | 106 | FILE *g_freopen (const gchar *filename, 107 | const gchar *mode, 108 | FILE *stream); 109 | 110 | #endif /* G_OS_UNIX */ 111 | 112 | G_END_DECLS 113 | 114 | #endif /* __G_STDIO_H__ */ 115 | -------------------------------------------------------------------------------- /sdconv/include/glib/gtree.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_TREE_H__ 28 | #define __G_TREE_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GTree GTree; 35 | 36 | typedef gboolean (*GTraverseFunc) (gpointer key, 37 | gpointer value, 38 | gpointer data); 39 | 40 | /* Balanced binary trees 41 | */ 42 | GTree* g_tree_new (GCompareFunc key_compare_func); 43 | GTree* g_tree_new_with_data (GCompareDataFunc key_compare_func, 44 | gpointer key_compare_data); 45 | GTree* g_tree_new_full (GCompareDataFunc key_compare_func, 46 | gpointer key_compare_data, 47 | GDestroyNotify key_destroy_func, 48 | GDestroyNotify value_destroy_func); 49 | void g_tree_destroy (GTree *tree); 50 | void g_tree_insert (GTree *tree, 51 | gpointer key, 52 | gpointer value); 53 | void g_tree_replace (GTree *tree, 54 | gpointer key, 55 | gpointer value); 56 | gboolean g_tree_remove (GTree *tree, 57 | gconstpointer key); 58 | gboolean g_tree_steal (GTree *tree, 59 | gconstpointer key); 60 | gpointer g_tree_lookup (GTree *tree, 61 | gconstpointer key); 62 | gboolean g_tree_lookup_extended (GTree *tree, 63 | gconstpointer lookup_key, 64 | gpointer *orig_key, 65 | gpointer *value); 66 | void g_tree_foreach (GTree *tree, 67 | GTraverseFunc func, 68 | gpointer user_data); 69 | 70 | #ifndef G_DISABLE_DEPRECATED 71 | void g_tree_traverse (GTree *tree, 72 | GTraverseFunc traverse_func, 73 | GTraverseType traverse_type, 74 | gpointer user_data); 75 | #endif /* G_DISABLE_DEPRECATED */ 76 | 77 | gpointer g_tree_search (GTree *tree, 78 | GCompareFunc search_func, 79 | gconstpointer user_data); 80 | gint g_tree_height (GTree *tree); 81 | gint g_tree_nnodes (GTree *tree); 82 | 83 | 84 | 85 | G_END_DECLS 86 | 87 | #endif /* __G_TREE_H__ */ 88 | 89 | -------------------------------------------------------------------------------- /sdconv/include/glib/gfileutils.h: -------------------------------------------------------------------------------- 1 | /* gfileutils.h - File utility functions 2 | * 3 | * Copyright 2000 Red Hat, Inc. 4 | * 5 | * GLib is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * GLib is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with GLib; see the file COPYING.LIB. If not, 17 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_FILEUTILS_H__ 22 | #define __G_FILEUTILS_H__ 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | #define G_FILE_ERROR g_file_error_quark () 29 | 30 | typedef enum 31 | { 32 | G_FILE_ERROR_EXIST, 33 | G_FILE_ERROR_ISDIR, 34 | G_FILE_ERROR_ACCES, 35 | G_FILE_ERROR_NAMETOOLONG, 36 | G_FILE_ERROR_NOENT, 37 | G_FILE_ERROR_NOTDIR, 38 | G_FILE_ERROR_NXIO, 39 | G_FILE_ERROR_NODEV, 40 | G_FILE_ERROR_ROFS, 41 | G_FILE_ERROR_TXTBSY, 42 | G_FILE_ERROR_FAULT, 43 | G_FILE_ERROR_LOOP, 44 | G_FILE_ERROR_NOSPC, 45 | G_FILE_ERROR_NOMEM, 46 | G_FILE_ERROR_MFILE, 47 | G_FILE_ERROR_NFILE, 48 | G_FILE_ERROR_BADF, 49 | G_FILE_ERROR_INVAL, 50 | G_FILE_ERROR_PIPE, 51 | G_FILE_ERROR_AGAIN, 52 | G_FILE_ERROR_INTR, 53 | G_FILE_ERROR_IO, 54 | G_FILE_ERROR_PERM, 55 | G_FILE_ERROR_NOSYS, 56 | G_FILE_ERROR_FAILED 57 | } GFileError; 58 | 59 | /* For backward-compat reasons, these are synced to an old 60 | * anonymous enum in libgnome. But don't use that enum 61 | * in new code. 62 | */ 63 | typedef enum 64 | { 65 | G_FILE_TEST_IS_REGULAR = 1 << 0, 66 | G_FILE_TEST_IS_SYMLINK = 1 << 1, 67 | G_FILE_TEST_IS_DIR = 1 << 2, 68 | G_FILE_TEST_IS_EXECUTABLE = 1 << 3, 69 | G_FILE_TEST_EXISTS = 1 << 4 70 | } GFileTest; 71 | 72 | GQuark g_file_error_quark (void); 73 | /* So other code can generate a GFileError */ 74 | GFileError g_file_error_from_errno (gint err_no); 75 | 76 | #ifdef G_OS_WIN32 77 | #define g_file_test g_file_test_utf8 78 | #define g_file_get_contents g_file_get_contents_utf8 79 | #define g_mkstemp g_mkstemp_utf8 80 | #define g_file_open_tmp g_file_open_tmp_utf8 81 | #endif 82 | 83 | gboolean g_file_test (const gchar *filename, 84 | GFileTest test); 85 | gboolean g_file_get_contents (const gchar *filename, 86 | gchar **contents, 87 | gsize *length, 88 | GError **error); 89 | gboolean g_file_set_contents (const gchar *filename, 90 | const gchar *contents, 91 | gssize length, 92 | GError **error); 93 | gchar *g_file_read_link (const gchar *filename, 94 | GError **error); 95 | 96 | /* Wrapper / workalike for mkstemp() */ 97 | gint g_mkstemp (gchar *tmpl); 98 | 99 | /* Wrapper for g_mkstemp */ 100 | gint g_file_open_tmp (const gchar *tmpl, 101 | gchar **name_used, 102 | GError **error); 103 | 104 | gchar *g_build_path (const gchar *separator, 105 | const gchar *first_element, 106 | ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; 107 | gchar *g_build_pathv (const gchar *separator, 108 | gchar **args) G_GNUC_MALLOC; 109 | 110 | gchar *g_build_filename (const gchar *first_element, 111 | ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; 112 | gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC; 113 | 114 | int g_mkdir_with_parents (const gchar *pathname, 115 | int mode); 116 | 117 | G_END_DECLS 118 | 119 | #endif /* __G_FILEUTILS_H__ */ 120 | -------------------------------------------------------------------------------- /sdconv/include/glib/gwin32.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_WIN32_H__ 28 | #define __G_WIN32_H__ 29 | 30 | #include 31 | 32 | #ifdef G_PLATFORM_WIN32 33 | 34 | G_BEGIN_DECLS 35 | 36 | #ifndef MAXPATHLEN 37 | #define MAXPATHLEN 1024 38 | #endif 39 | 40 | #ifdef G_OS_WIN32 41 | 42 | /* 43 | * To get prototypes for the following POSIXish functions, you have to 44 | * include the indicated non-POSIX headers. The functions are defined 45 | * in OLDNAMES.LIB (MSVC) or -lmoldname-msvc (mingw32). But note that 46 | * for POSIX functions that take or return file names in the system 47 | * codepage, in many cases you would want to use the GLib wrappers in 48 | * gstdio.h and UTF-8 instead. 49 | * 50 | * getcwd: (MSVC), (mingw32) 51 | * getpid: 52 | * access: 53 | * unlink: or 54 | * open, read, write, lseek, close: 55 | * rmdir: 56 | * pipe: (actually, _pipe()) 57 | */ 58 | 59 | /* For some POSIX functions that are not provided by the MS runtime, 60 | * we provide emulation functions in glib, which are prefixed with 61 | * g_win32_. Or that was the idea at some time, but there is just one 62 | * of those: 63 | */ 64 | gint g_win32_ftruncate (gint f, 65 | guint size); 66 | #endif /* G_OS_WIN32 */ 67 | 68 | /* The MS setlocale uses locale names of the form "English_United 69 | * States.1252" etc. We want the Unixish standard form "en", "zh_TW" 70 | * etc. This function gets the current thread locale from Windows and 71 | * returns it as a string of the above form for use in forming file 72 | * names etc. The returned string should be deallocated with g_free(). 73 | */ 74 | gchar* g_win32_getlocale (void); 75 | 76 | /* Translate a Win32 error code (as returned by GetLastError()) into 77 | * the corresponding message. The returned string should be deallocated 78 | * with g_free(). 79 | */ 80 | gchar* g_win32_error_message (gint error); 81 | 82 | #define g_win32_get_package_installation_directory g_win32_get_package_installation_directory_utf8 83 | #define g_win32_get_package_installation_subdirectory g_win32_get_package_installation_subdirectory_utf8 84 | 85 | gchar* g_win32_get_package_installation_directory (const gchar *package, 86 | const gchar *dll_name); 87 | 88 | gchar* g_win32_get_package_installation_subdirectory (const gchar *package, 89 | const gchar *dll_name, 90 | const gchar *subdir); 91 | 92 | guint g_win32_get_windows_version (void); 93 | 94 | gchar* g_win32_locale_filename_from_utf8 (const gchar *utf8filename); 95 | 96 | /* As of GLib 2.14 we only support NT-based Windows */ 97 | #define G_WIN32_IS_NT_BASED() TRUE 98 | #define G_WIN32_HAVE_WIDECHAR_API() TRUE 99 | 100 | G_END_DECLS 101 | 102 | #endif /* G_PLATFORM_WIN32 */ 103 | 104 | #endif /* __G_WIN32_H__ */ 105 | -------------------------------------------------------------------------------- /sdconv/convert.cpp: -------------------------------------------------------------------------------- 1 | // convert.cpp: convert modules 2 | 3 | #include 4 | 5 | #include "dict.h" 6 | #include "convert.h" 7 | #include "index.h" 8 | 9 | GString *mdk_start_convert(struct convert_module *mod) 10 | { 11 | return g_string_new("\n" 12 | "\n\n"); 14 | } 15 | 16 | void mdk_finish_convert(struct convert_module *mod, GString *dest) 17 | { 18 | g_string_append(dest, "\n"); 19 | } 20 | 21 | inline bool convert_with_glib(gchar *src, GString *dest) 22 | { 23 | g_string_append(dest, "
\n");
 24 |     g_string_append(dest, src);
 25 | 	g_string_append(dest, "\n
\n"); 26 | 27 | return true; 28 | } 29 | 30 | struct convert_module convert_module_list[] = { 31 | { "default", 0, NULL, convert_with_glib, NULL }, 32 | { NULL, 0, NULL, NULL, NULL }, 33 | }; 34 | 35 | struct convert_module *mdk_get_convert_module(const char *name) 36 | { 37 | int i; 38 | 39 | for (i = 0; convert_module_list[i].name != NULL; i++) 40 | if (strcmp(convert_module_list[i].name, name) == 0) 41 | return &convert_module_list[i]; 42 | 43 | return NULL; 44 | } 45 | 46 | void convert_with_module(struct convert_module *mod, 47 | gchar *src, GString *dest) 48 | { 49 | size_t data_size, sec_size; 50 | 51 | data_size = get_uint32(src); 52 | src += sizeof(guint32); 53 | 54 | const gchar *p = src; 55 | 56 | while (guint32(p - src) < data_size) 57 | { 58 | switch (*p) 59 | { 60 | case 'm': 61 | case 'l': 62 | p++; 63 | sec_size = strlen(p); 64 | 65 | if (sec_size) 66 | { 67 | gchar *m_str = g_markup_escape_text(p, sec_size); 68 | mod->convert(m_str, dest); 69 | g_free(m_str); 70 | } 71 | 72 | sec_size++; 73 | break; 74 | 75 | case 'g': 76 | p++; 77 | sec_size = strlen(p); 78 | if (sec_size) 79 | { 80 | g_string_append(dest, "
\n");
 81 | 					g_string_append(dest, p);
 82 | 					g_string_append(dest, "\n
"); 83 | } 84 | sec_size++; 85 | break; 86 | 87 | case 'x': 88 | case 'k': 89 | case 'w': 90 | case 'h': 91 | p++; 92 | sec_size = strlen(p) + 1; 93 | 94 | g_string_append(dest, 95 | "

Format not supported.

"); 96 | break; 97 | 98 | case 't': 99 | case 'y': 100 | p++; 101 | sec_size = strlen(p); 102 | if (sec_size) 103 | { 104 | g_string_append_printf(dest, "
", *p); 105 | gchar *m_str = g_markup_escape_text(p, sec_size); 106 | g_string_append(dest, m_str); 107 | g_free(m_str); 108 | g_string_append(dest, "
\n"); 109 | } 110 | sec_size++; 111 | break; 112 | 113 | case 'W': 114 | p++; 115 | sec_size = ntohl(get_uint32(p)); 116 | // enable sound button. 117 | sec_size += sizeof(guint32); 118 | break; 119 | 120 | case 'P': 121 | p++; 122 | sec_size = ntohl(get_uint32(p)); 123 | if (sec_size) { 124 | // TODO: extract images from here 125 | g_string_append(dest, "[Missing Image]"); 126 | } else { 127 | g_string_append(dest, "[Missing Image]"); 128 | } 129 | 130 | sec_size += sizeof(guint32); 131 | break; 132 | 133 | default: 134 | if (g_ascii_isupper(*p)) 135 | { 136 | p++; 137 | sec_size = ntohl(get_uint32(p)); 138 | sec_size += sizeof(guint32); 139 | } else { 140 | p++; 141 | sec_size = strlen(p) + 1; 142 | } 143 | 144 | g_string_append(dest, 145 | "

Unknown data type.

"); 146 | break; 147 | } 148 | 149 | p += sec_size; 150 | } 151 | } 152 | 153 | void mdk_convert_index_with_module(struct convert_module *mod, 154 | mdk_dict *dict, 155 | unsigned int index, 156 | GString *dest) 157 | { 158 | mdk_entry entry; 159 | 160 | dict->get_entry_by_index(index, &entry); 161 | gchar *m_str = g_markup_escape_text(entry.key, strlen(entry.key)); 162 | 163 | g_string_append_printf(dest, "\n" 164 | "\n" 165 | "

%s

\n", 166 | index, m_str, m_str, m_str); 167 | g_free(m_str); 168 | 169 | gchar *src = dict->get_entry_data(&entry); 170 | convert_with_module(mod, src, dest); 171 | g_free(src); 172 | 173 | g_string_append(dest, "\n
\n\n"); 174 | } 175 | -------------------------------------------------------------------------------- /sdconv/include/glib/ghash.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_HASH_H__ 28 | #define __G_HASH_H__ 29 | 30 | #include 31 | #include 32 | 33 | G_BEGIN_DECLS 34 | 35 | typedef struct _GHashTable GHashTable; 36 | 37 | typedef gboolean (*GHRFunc) (gpointer key, 38 | gpointer value, 39 | gpointer user_data); 40 | 41 | /* Hash tables 42 | */ 43 | GHashTable* g_hash_table_new (GHashFunc hash_func, 44 | GEqualFunc key_equal_func); 45 | GHashTable* g_hash_table_new_full (GHashFunc hash_func, 46 | GEqualFunc key_equal_func, 47 | GDestroyNotify key_destroy_func, 48 | GDestroyNotify value_destroy_func); 49 | void g_hash_table_destroy (GHashTable *hash_table); 50 | void g_hash_table_insert (GHashTable *hash_table, 51 | gpointer key, 52 | gpointer value); 53 | void g_hash_table_replace (GHashTable *hash_table, 54 | gpointer key, 55 | gpointer value); 56 | gboolean g_hash_table_remove (GHashTable *hash_table, 57 | gconstpointer key); 58 | void g_hash_table_remove_all (GHashTable *hash_table); 59 | gboolean g_hash_table_steal (GHashTable *hash_table, 60 | gconstpointer key); 61 | void g_hash_table_steal_all (GHashTable *hash_table); 62 | gpointer g_hash_table_lookup (GHashTable *hash_table, 63 | gconstpointer key); 64 | gboolean g_hash_table_lookup_extended (GHashTable *hash_table, 65 | gconstpointer lookup_key, 66 | gpointer *orig_key, 67 | gpointer *value); 68 | void g_hash_table_foreach (GHashTable *hash_table, 69 | GHFunc func, 70 | gpointer user_data); 71 | gpointer g_hash_table_find (GHashTable *hash_table, 72 | GHRFunc predicate, 73 | gpointer user_data); 74 | guint g_hash_table_foreach_remove (GHashTable *hash_table, 75 | GHRFunc func, 76 | gpointer user_data); 77 | guint g_hash_table_foreach_steal (GHashTable *hash_table, 78 | GHRFunc func, 79 | gpointer user_data); 80 | guint g_hash_table_size (GHashTable *hash_table); 81 | GList * g_hash_table_get_keys (GHashTable *hash_table); 82 | GList * g_hash_table_get_values (GHashTable *hash_table); 83 | 84 | /* keeping hash tables alive */ 85 | GHashTable* g_hash_table_ref (GHashTable *hash_table); 86 | void g_hash_table_unref (GHashTable *hash_table); 87 | 88 | #ifndef G_DISABLE_DEPRECATED 89 | 90 | /* The following two functions are deprecated and will be removed in 91 | * the next major release. They do no good. */ 92 | #define g_hash_table_freeze(hash_table) ((void)0) 93 | #define g_hash_table_thaw(hash_table) ((void)0) 94 | 95 | #endif /* G_DISABLE_DEPRECATED */ 96 | 97 | /* Hash Functions 98 | */ 99 | gboolean g_str_equal (gconstpointer v1, 100 | gconstpointer v2); 101 | guint g_str_hash (gconstpointer v); 102 | 103 | gboolean g_int_equal (gconstpointer v1, 104 | gconstpointer v2); 105 | guint g_int_hash (gconstpointer v); 106 | 107 | /* This "hash" function will just return the key's address as an 108 | * unsigned integer. Useful for hashing on plain addresses or 109 | * simple integer values. 110 | * Passing NULL into g_hash_table_new() as GHashFunc has the 111 | * same effect as passing g_direct_hash(). 112 | */ 113 | guint g_direct_hash (gconstpointer v) G_GNUC_CONST; 114 | gboolean g_direct_equal (gconstpointer v1, 115 | gconstpointer v2) G_GNUC_CONST; 116 | 117 | G_END_DECLS 118 | 119 | #endif /* __G_HASH_H__ */ 120 | 121 | -------------------------------------------------------------------------------- /sdconv/include/glib/gconvert.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_CONVERT_H__ 28 | #define __G_CONVERT_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef enum 35 | { 36 | G_CONVERT_ERROR_NO_CONVERSION, 37 | G_CONVERT_ERROR_ILLEGAL_SEQUENCE, 38 | G_CONVERT_ERROR_FAILED, 39 | G_CONVERT_ERROR_PARTIAL_INPUT, 40 | G_CONVERT_ERROR_BAD_URI, 41 | G_CONVERT_ERROR_NOT_ABSOLUTE_PATH 42 | } GConvertError; 43 | 44 | #define G_CONVERT_ERROR g_convert_error_quark() 45 | GQuark g_convert_error_quark (void); 46 | 47 | /* Thin wrappers around iconv 48 | */ 49 | typedef struct _GIConv *GIConv; 50 | 51 | GIConv g_iconv_open (const gchar *to_codeset, 52 | const gchar *from_codeset); 53 | gsize g_iconv (GIConv converter, 54 | gchar **inbuf, 55 | gsize *inbytes_left, 56 | gchar **outbuf, 57 | gsize *outbytes_left); 58 | gint g_iconv_close (GIConv converter); 59 | 60 | 61 | gchar* g_convert (const gchar *str, 62 | gssize len, 63 | const gchar *to_codeset, 64 | const gchar *from_codeset, 65 | gsize *bytes_read, 66 | gsize *bytes_written, 67 | GError **error) G_GNUC_MALLOC; 68 | gchar* g_convert_with_iconv (const gchar *str, 69 | gssize len, 70 | GIConv converter, 71 | gsize *bytes_read, 72 | gsize *bytes_written, 73 | GError **error) G_GNUC_MALLOC; 74 | gchar* g_convert_with_fallback (const gchar *str, 75 | gssize len, 76 | const gchar *to_codeset, 77 | const gchar *from_codeset, 78 | gchar *fallback, 79 | gsize *bytes_read, 80 | gsize *bytes_written, 81 | GError **error) G_GNUC_MALLOC; 82 | 83 | 84 | /* Convert between libc's idea of strings and UTF-8. 85 | */ 86 | gchar* g_locale_to_utf8 (const gchar *opsysstring, 87 | gssize len, 88 | gsize *bytes_read, 89 | gsize *bytes_written, 90 | GError **error) G_GNUC_MALLOC; 91 | gchar* g_locale_from_utf8 (const gchar *utf8string, 92 | gssize len, 93 | gsize *bytes_read, 94 | gsize *bytes_written, 95 | GError **error) G_GNUC_MALLOC; 96 | 97 | /* Convert between the operating system (or C runtime) 98 | * representation of file names and UTF-8. 99 | */ 100 | #ifdef G_OS_WIN32 101 | #define g_filename_to_utf8 g_filename_to_utf8_utf8 102 | #define g_filename_from_utf8 g_filename_from_utf8_utf8 103 | #define g_filename_from_uri g_filename_from_uri_utf8 104 | #define g_filename_to_uri g_filename_to_uri_utf8 105 | #endif 106 | 107 | gchar* g_filename_to_utf8 (const gchar *opsysstring, 108 | gssize len, 109 | gsize *bytes_read, 110 | gsize *bytes_written, 111 | GError **error) G_GNUC_MALLOC; 112 | gchar* g_filename_from_utf8 (const gchar *utf8string, 113 | gssize len, 114 | gsize *bytes_read, 115 | gsize *bytes_written, 116 | GError **error) G_GNUC_MALLOC; 117 | 118 | gchar *g_filename_from_uri (const gchar *uri, 119 | gchar **hostname, 120 | GError **error) G_GNUC_MALLOC; 121 | 122 | gchar *g_filename_to_uri (const gchar *filename, 123 | const gchar *hostname, 124 | GError **error) G_GNUC_MALLOC; 125 | gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC; 126 | gboolean g_get_filename_charsets (G_CONST_RETURN gchar ***charsets); 127 | 128 | gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC; 129 | 130 | gchar **g_uri_list_extract_uris (const gchar *uri_list) G_GNUC_MALLOC; 131 | 132 | G_END_DECLS 133 | 134 | #endif /* __G_CONVERT_H__ */ 135 | -------------------------------------------------------------------------------- /sdconv/include/glib/gqueue.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_QUEUE_H__ 28 | #define __G_QUEUE_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GQueue GQueue; 35 | 36 | struct _GQueue 37 | { 38 | GList *head; 39 | GList *tail; 40 | guint length; 41 | }; 42 | 43 | #define G_QUEUE_INIT { NULL, NULL, 0 } 44 | 45 | /* Queues 46 | */ 47 | GQueue* g_queue_new (void); 48 | void g_queue_free (GQueue *queue); 49 | void g_queue_init (GQueue *queue); 50 | void g_queue_clear (GQueue *queue); 51 | gboolean g_queue_is_empty (GQueue *queue); 52 | guint g_queue_get_length (GQueue *queue); 53 | void g_queue_reverse (GQueue *queue); 54 | GQueue * g_queue_copy (GQueue *queue); 55 | void g_queue_foreach (GQueue *queue, 56 | GFunc func, 57 | gpointer user_data); 58 | GList * g_queue_find (GQueue *queue, 59 | gconstpointer data); 60 | GList * g_queue_find_custom (GQueue *queue, 61 | gconstpointer data, 62 | GCompareFunc func); 63 | void g_queue_sort (GQueue *queue, 64 | GCompareDataFunc compare_func, 65 | gpointer user_data); 66 | 67 | void g_queue_push_head (GQueue *queue, 68 | gpointer data); 69 | void g_queue_push_tail (GQueue *queue, 70 | gpointer data); 71 | void g_queue_push_nth (GQueue *queue, 72 | gpointer data, 73 | gint n); 74 | gpointer g_queue_pop_head (GQueue *queue); 75 | gpointer g_queue_pop_tail (GQueue *queue); 76 | gpointer g_queue_pop_nth (GQueue *queue, 77 | guint n); 78 | gpointer g_queue_peek_head (GQueue *queue); 79 | gpointer g_queue_peek_tail (GQueue *queue); 80 | gpointer g_queue_peek_nth (GQueue *queue, 81 | guint n); 82 | gint g_queue_index (GQueue *queue, 83 | gconstpointer data); 84 | void g_queue_remove (GQueue *queue, 85 | gconstpointer data); 86 | void g_queue_remove_all (GQueue *queue, 87 | gconstpointer data); 88 | void g_queue_insert_before (GQueue *queue, 89 | GList *sibling, 90 | gpointer data); 91 | void g_queue_insert_after (GQueue *queue, 92 | GList *sibling, 93 | gpointer data); 94 | void g_queue_insert_sorted (GQueue *queue, 95 | gpointer data, 96 | GCompareDataFunc func, 97 | gpointer user_data); 98 | 99 | void g_queue_push_head_link (GQueue *queue, 100 | GList *link_); 101 | void g_queue_push_tail_link (GQueue *queue, 102 | GList *link_); 103 | void g_queue_push_nth_link (GQueue *queue, 104 | gint n, 105 | GList *link_); 106 | GList* g_queue_pop_head_link (GQueue *queue); 107 | GList* g_queue_pop_tail_link (GQueue *queue); 108 | GList* g_queue_pop_nth_link (GQueue *queue, 109 | guint n); 110 | GList* g_queue_peek_head_link (GQueue *queue); 111 | GList* g_queue_peek_tail_link (GQueue *queue); 112 | GList* g_queue_peek_nth_link (GQueue *queue, 113 | guint n); 114 | gint g_queue_link_index (GQueue *queue, 115 | GList *link_); 116 | void g_queue_unlink (GQueue *queue, 117 | GList *link_); 118 | void g_queue_delete_link (GQueue *queue, 119 | GList *link_); 120 | 121 | G_END_DECLS 122 | 123 | #endif /* __G_QUEUE_H__ */ 124 | -------------------------------------------------------------------------------- /sdconv/include/glib/gasyncqueue.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_ASYNCQUEUE_H__ 28 | #define __G_ASYNCQUEUE_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GAsyncQueue GAsyncQueue; 35 | 36 | /* Asyncronous Queues, can be used to communicate between threads */ 37 | 38 | /* Get a new GAsyncQueue with the ref_count 1 */ 39 | GAsyncQueue* g_async_queue_new (void); 40 | 41 | /* Lock and unlock a GAsyncQueue. All functions lock the queue for 42 | * themselves, but in certain cirumstances you want to hold the lock longer, 43 | * thus you lock the queue, call the *_unlocked functions and unlock it again. 44 | */ 45 | void g_async_queue_lock (GAsyncQueue *queue); 46 | void g_async_queue_unlock (GAsyncQueue *queue); 47 | 48 | /* Ref and unref the GAsyncQueue. */ 49 | GAsyncQueue* g_async_queue_ref (GAsyncQueue *queue); 50 | void g_async_queue_unref (GAsyncQueue *queue); 51 | 52 | #ifndef G_DISABLE_DEPRECATED 53 | /* You don't have to hold the lock for calling *_ref and *_unref anymore. */ 54 | void g_async_queue_ref_unlocked (GAsyncQueue *queue); 55 | void g_async_queue_unref_and_unlock (GAsyncQueue *queue); 56 | #endif /* !G_DISABLE_DEPRECATED */ 57 | 58 | /* Push data into the async queue. Must not be NULL. */ 59 | void g_async_queue_push (GAsyncQueue *queue, 60 | gpointer data); 61 | void g_async_queue_push_unlocked (GAsyncQueue *queue, 62 | gpointer data); 63 | 64 | void g_async_queue_push_sorted (GAsyncQueue *queue, 65 | gpointer data, 66 | GCompareDataFunc func, 67 | gpointer user_data); 68 | void g_async_queue_push_sorted_unlocked (GAsyncQueue *queue, 69 | gpointer data, 70 | GCompareDataFunc func, 71 | gpointer user_data); 72 | 73 | /* Pop data from the async queue. When no data is there, the thread is blocked 74 | * until data arrives. 75 | */ 76 | gpointer g_async_queue_pop (GAsyncQueue *queue); 77 | gpointer g_async_queue_pop_unlocked (GAsyncQueue *queue); 78 | 79 | /* Try to pop data. NULL is returned in case of empty queue. */ 80 | gpointer g_async_queue_try_pop (GAsyncQueue *queue); 81 | gpointer g_async_queue_try_pop_unlocked (GAsyncQueue *queue); 82 | 83 | 84 | 85 | /* Wait for data until at maximum until end_time is reached. NULL is returned 86 | * in case of empty queue. 87 | */ 88 | gpointer g_async_queue_timed_pop (GAsyncQueue *queue, 89 | GTimeVal *end_time); 90 | gpointer g_async_queue_timed_pop_unlocked (GAsyncQueue *queue, 91 | GTimeVal *end_time); 92 | 93 | /* Return the length of the queue. Negative values mean that threads 94 | * are waiting, positve values mean that there are entries in the 95 | * queue. Actually this function returns the length of the queue minus 96 | * the number of waiting threads, g_async_queue_length == 0 could also 97 | * mean 'n' entries in the queue and 'n' thread waiting. Such can 98 | * happen due to locking of the queue or due to scheduling. 99 | */ 100 | gint g_async_queue_length (GAsyncQueue *queue); 101 | gint g_async_queue_length_unlocked (GAsyncQueue *queue); 102 | void g_async_queue_sort (GAsyncQueue *queue, 103 | GCompareDataFunc func, 104 | gpointer user_data); 105 | void g_async_queue_sort_unlocked (GAsyncQueue *queue, 106 | GCompareDataFunc func, 107 | gpointer user_data); 108 | 109 | /* Private API */ 110 | GMutex* _g_async_queue_get_mutex (GAsyncQueue *queue); 111 | 112 | G_END_DECLS 113 | 114 | #endif /* __G_ASYNCQUEUE_H__ */ 115 | 116 | -------------------------------------------------------------------------------- /sdconv/include/glib/gslist.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_SLIST_H__ 28 | #define __G_SLIST_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GSList GSList; 35 | 36 | struct _GSList 37 | { 38 | gpointer data; 39 | GSList *next; 40 | }; 41 | 42 | /* Singly linked lists 43 | */ 44 | GSList* g_slist_alloc (void) G_GNUC_WARN_UNUSED_RESULT; 45 | void g_slist_free (GSList *list); 46 | void g_slist_free_1 (GSList *list); 47 | #define g_slist_free1 g_slist_free_1 48 | GSList* g_slist_append (GSList *list, 49 | gpointer data) G_GNUC_WARN_UNUSED_RESULT; 50 | GSList* g_slist_prepend (GSList *list, 51 | gpointer data) G_GNUC_WARN_UNUSED_RESULT; 52 | GSList* g_slist_insert (GSList *list, 53 | gpointer data, 54 | gint position) G_GNUC_WARN_UNUSED_RESULT; 55 | GSList* g_slist_insert_sorted (GSList *list, 56 | gpointer data, 57 | GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT; 58 | GSList* g_slist_insert_sorted_with_data (GSList *list, 59 | gpointer data, 60 | GCompareDataFunc func, 61 | gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; 62 | GSList* g_slist_insert_before (GSList *slist, 63 | GSList *sibling, 64 | gpointer data) G_GNUC_WARN_UNUSED_RESULT; 65 | GSList* g_slist_concat (GSList *list1, 66 | GSList *list2) G_GNUC_WARN_UNUSED_RESULT; 67 | GSList* g_slist_remove (GSList *list, 68 | gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; 69 | GSList* g_slist_remove_all (GSList *list, 70 | gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; 71 | GSList* g_slist_remove_link (GSList *list, 72 | GSList *link_) G_GNUC_WARN_UNUSED_RESULT; 73 | GSList* g_slist_delete_link (GSList *list, 74 | GSList *link_) G_GNUC_WARN_UNUSED_RESULT; 75 | GSList* g_slist_reverse (GSList *list) G_GNUC_WARN_UNUSED_RESULT; 76 | GSList* g_slist_copy (GSList *list) G_GNUC_WARN_UNUSED_RESULT; 77 | GSList* g_slist_nth (GSList *list, 78 | guint n); 79 | GSList* g_slist_find (GSList *list, 80 | gconstpointer data); 81 | GSList* g_slist_find_custom (GSList *list, 82 | gconstpointer data, 83 | GCompareFunc func); 84 | gint g_slist_position (GSList *list, 85 | GSList *llink); 86 | gint g_slist_index (GSList *list, 87 | gconstpointer data); 88 | GSList* g_slist_last (GSList *list); 89 | guint g_slist_length (GSList *list); 90 | void g_slist_foreach (GSList *list, 91 | GFunc func, 92 | gpointer user_data); 93 | GSList* g_slist_sort (GSList *list, 94 | GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT; 95 | GSList* g_slist_sort_with_data (GSList *list, 96 | GCompareDataFunc compare_func, 97 | gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; 98 | gpointer g_slist_nth_data (GSList *list, 99 | guint n); 100 | 101 | #define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL) 102 | 103 | #ifndef G_DISABLE_DEPRECATED 104 | void g_slist_push_allocator (gpointer dummy); 105 | void g_slist_pop_allocator (void); 106 | #endif 107 | G_END_DECLS 108 | 109 | #endif /* __G_SLIST_H__ */ 110 | 111 | -------------------------------------------------------------------------------- /sdconv/include/glib/gthreadpool.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_THREADPOOL_H__ 28 | #define __G_THREADPOOL_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GThreadPool GThreadPool; 35 | 36 | /* Thread Pools 37 | */ 38 | 39 | /* The real GThreadPool is bigger, so you may only create a thread 40 | * pool with the constructor function */ 41 | struct _GThreadPool 42 | { 43 | GFunc func; 44 | gpointer user_data; 45 | gboolean exclusive; 46 | }; 47 | 48 | /* Get a thread pool with the function func, at most max_threads may 49 | * run at a time (max_threads == -1 means no limit), exclusive == TRUE 50 | * means, that the threads shouldn't be shared and that they will be 51 | * prestarted (otherwise they are started as needed) user_data is the 52 | * 2nd argument to the func */ 53 | GThreadPool* g_thread_pool_new (GFunc func, 54 | gpointer user_data, 55 | gint max_threads, 56 | gboolean exclusive, 57 | GError **error); 58 | 59 | /* Push new data into the thread pool. This task is assigned to a thread later 60 | * (when the maximal number of threads is reached for that pool) or now 61 | * (otherwise). If necessary a new thread will be started. The function 62 | * returns immediatly */ 63 | void g_thread_pool_push (GThreadPool *pool, 64 | gpointer data, 65 | GError **error); 66 | 67 | /* Set the number of threads, which can run concurrently for that pool, -1 68 | * means no limit. 0 means has the effect, that the pool won't process 69 | * requests until the limit is set higher again */ 70 | void g_thread_pool_set_max_threads (GThreadPool *pool, 71 | gint max_threads, 72 | GError **error); 73 | gint g_thread_pool_get_max_threads (GThreadPool *pool); 74 | 75 | /* Get the number of threads assigned to that pool. This number doesn't 76 | * necessarily represent the number of working threads in that pool */ 77 | guint g_thread_pool_get_num_threads (GThreadPool *pool); 78 | 79 | /* Get the number of unprocessed items in the pool */ 80 | guint g_thread_pool_unprocessed (GThreadPool *pool); 81 | 82 | /* Free the pool, immediate means, that all unprocessed items in the queue 83 | * wont be processed, wait means, that the function doesn't return immediatly, 84 | * but after all threads in the pool are ready processing items. immediate 85 | * does however not mean, that threads are killed. */ 86 | void g_thread_pool_free (GThreadPool *pool, 87 | gboolean immediate, 88 | gboolean wait_); 89 | 90 | /* Set the maximal number of unused threads before threads will be stopped by 91 | * GLib, -1 means no limit */ 92 | void g_thread_pool_set_max_unused_threads (gint max_threads); 93 | gint g_thread_pool_get_max_unused_threads (void); 94 | guint g_thread_pool_get_num_unused_threads (void); 95 | 96 | /* Stop all currently unused threads, but leave the limit untouched */ 97 | void g_thread_pool_stop_unused_threads (void); 98 | 99 | /* Set sort function for priority threading */ 100 | void g_thread_pool_set_sort_function (GThreadPool *pool, 101 | GCompareDataFunc func, 102 | gpointer user_data); 103 | 104 | /* Set maximum time a thread can be idle in the pool before it is stopped */ 105 | void g_thread_pool_set_max_idle_time (guint interval); 106 | guint g_thread_pool_get_max_idle_time (void); 107 | 108 | G_END_DECLS 109 | 110 | #endif /* __G_THREADPOOL_H__ */ 111 | 112 | -------------------------------------------------------------------------------- /sdconv/include/glib/glist.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_LIST_H__ 28 | #define __G_LIST_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GList GList; 35 | 36 | struct _GList 37 | { 38 | gpointer data; 39 | GList *next; 40 | GList *prev; 41 | }; 42 | 43 | /* Doubly linked lists 44 | */ 45 | GList* g_list_alloc (void) G_GNUC_WARN_UNUSED_RESULT; 46 | void g_list_free (GList *list); 47 | void g_list_free_1 (GList *list); 48 | #define g_list_free1 g_list_free_1 49 | GList* g_list_append (GList *list, 50 | gpointer data) G_GNUC_WARN_UNUSED_RESULT; 51 | GList* g_list_prepend (GList *list, 52 | gpointer data) G_GNUC_WARN_UNUSED_RESULT; 53 | GList* g_list_insert (GList *list, 54 | gpointer data, 55 | gint position) G_GNUC_WARN_UNUSED_RESULT; 56 | GList* g_list_insert_sorted (GList *list, 57 | gpointer data, 58 | GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT; 59 | GList* g_list_insert_sorted_with_data (GList *list, 60 | gpointer data, 61 | GCompareDataFunc func, 62 | gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; 63 | GList* g_list_insert_before (GList *list, 64 | GList *sibling, 65 | gpointer data) G_GNUC_WARN_UNUSED_RESULT; 66 | GList* g_list_concat (GList *list1, 67 | GList *list2) G_GNUC_WARN_UNUSED_RESULT; 68 | GList* g_list_remove (GList *list, 69 | gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; 70 | GList* g_list_remove_all (GList *list, 71 | gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; 72 | GList* g_list_remove_link (GList *list, 73 | GList *llink) G_GNUC_WARN_UNUSED_RESULT; 74 | GList* g_list_delete_link (GList *list, 75 | GList *link_) G_GNUC_WARN_UNUSED_RESULT; 76 | GList* g_list_reverse (GList *list) G_GNUC_WARN_UNUSED_RESULT; 77 | GList* g_list_copy (GList *list) G_GNUC_WARN_UNUSED_RESULT; 78 | GList* g_list_nth (GList *list, 79 | guint n); 80 | GList* g_list_nth_prev (GList *list, 81 | guint n); 82 | GList* g_list_find (GList *list, 83 | gconstpointer data); 84 | GList* g_list_find_custom (GList *list, 85 | gconstpointer data, 86 | GCompareFunc func); 87 | gint g_list_position (GList *list, 88 | GList *llink); 89 | gint g_list_index (GList *list, 90 | gconstpointer data); 91 | GList* g_list_last (GList *list); 92 | GList* g_list_first (GList *list); 93 | guint g_list_length (GList *list); 94 | void g_list_foreach (GList *list, 95 | GFunc func, 96 | gpointer user_data); 97 | GList* g_list_sort (GList *list, 98 | GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT; 99 | GList* g_list_sort_with_data (GList *list, 100 | GCompareDataFunc compare_func, 101 | gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; 102 | gpointer g_list_nth_data (GList *list, 103 | guint n); 104 | 105 | 106 | #define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL) 107 | #define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) 108 | 109 | #ifndef G_DISABLE_DEPRECATED 110 | void g_list_push_allocator (gpointer allocator); 111 | void g_list_pop_allocator (void); 112 | #endif 113 | G_END_DECLS 114 | 115 | #endif /* __G_LIST_H__ */ 116 | 117 | -------------------------------------------------------------------------------- /sdconv/include/glib/gdataset.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_DATASET_H__ 28 | #define __G_DATASET_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GData GData; 35 | 36 | typedef void (*GDataForeachFunc) (GQuark key_id, 37 | gpointer data, 38 | gpointer user_data); 39 | 40 | /* Keyed Data List 41 | */ 42 | void g_datalist_init (GData **datalist); 43 | void g_datalist_clear (GData **datalist); 44 | gpointer g_datalist_id_get_data (GData **datalist, 45 | GQuark key_id); 46 | void g_datalist_id_set_data_full (GData **datalist, 47 | GQuark key_id, 48 | gpointer data, 49 | GDestroyNotify destroy_func); 50 | gpointer g_datalist_id_remove_no_notify (GData **datalist, 51 | GQuark key_id); 52 | void g_datalist_foreach (GData **datalist, 53 | GDataForeachFunc func, 54 | gpointer user_data); 55 | 56 | /** 57 | * G_DATALIST_FLAGS_MASK: 58 | * 59 | * A bitmask that restricts the possible flags passed to 60 | * g_datalist_set_flags(). Passing a flags value where 61 | * flags & ~G_DATALIST_FLAGS_MASK != 0 is an error. 62 | */ 63 | #define G_DATALIST_FLAGS_MASK 0x3 64 | 65 | void g_datalist_set_flags (GData **datalist, 66 | guint flags); 67 | void g_datalist_unset_flags (GData **datalist, 68 | guint flags); 69 | guint g_datalist_get_flags (GData **datalist); 70 | 71 | #define g_datalist_id_set_data(dl, q, d) \ 72 | g_datalist_id_set_data_full ((dl), (q), (d), NULL) 73 | #define g_datalist_id_remove_data(dl, q) \ 74 | g_datalist_id_set_data ((dl), (q), NULL) 75 | #define g_datalist_get_data(dl, k) \ 76 | (g_datalist_id_get_data ((dl), g_quark_try_string (k))) 77 | #define g_datalist_set_data_full(dl, k, d, f) \ 78 | g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f)) 79 | #define g_datalist_remove_no_notify(dl, k) \ 80 | g_datalist_id_remove_no_notify ((dl), g_quark_try_string (k)) 81 | #define g_datalist_set_data(dl, k, d) \ 82 | g_datalist_set_data_full ((dl), (k), (d), NULL) 83 | #define g_datalist_remove_data(dl, k) \ 84 | g_datalist_id_set_data ((dl), g_quark_try_string (k), NULL) 85 | 86 | 87 | /* Location Associated Keyed Data 88 | */ 89 | void g_dataset_destroy (gconstpointer dataset_location); 90 | gpointer g_dataset_id_get_data (gconstpointer dataset_location, 91 | GQuark key_id); 92 | void g_dataset_id_set_data_full (gconstpointer dataset_location, 93 | GQuark key_id, 94 | gpointer data, 95 | GDestroyNotify destroy_func); 96 | gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, 97 | GQuark key_id); 98 | void g_dataset_foreach (gconstpointer dataset_location, 99 | GDataForeachFunc func, 100 | gpointer user_data); 101 | #define g_dataset_id_set_data(l, k, d) \ 102 | g_dataset_id_set_data_full ((l), (k), (d), NULL) 103 | #define g_dataset_id_remove_data(l, k) \ 104 | g_dataset_id_set_data ((l), (k), NULL) 105 | #define g_dataset_get_data(l, k) \ 106 | (g_dataset_id_get_data ((l), g_quark_try_string (k))) 107 | #define g_dataset_set_data_full(l, k, d, f) \ 108 | g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f)) 109 | #define g_dataset_remove_no_notify(l, k) \ 110 | g_dataset_id_remove_no_notify ((l), g_quark_try_string (k)) 111 | #define g_dataset_set_data(l, k, d) \ 112 | g_dataset_set_data_full ((l), (k), (d), NULL) 113 | #define g_dataset_remove_data(l, k) \ 114 | g_dataset_id_set_data ((l), g_quark_try_string (k), NULL) 115 | 116 | G_END_DECLS 117 | 118 | #endif /* __G_DATASET_H__ */ 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /sdconv/include/glib/gmarkup.h: -------------------------------------------------------------------------------- 1 | /* gmarkup.h - Simple XML-like string parser/writer 2 | * 3 | * Copyright 2000 Red Hat, Inc. 4 | * 5 | * GLib is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * GLib is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with GLib; see the file COPYING.LIB. If not, 17 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_MARKUP_H__ 22 | #define __G_MARKUP_H__ 23 | 24 | #include 25 | 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | typedef enum 31 | { 32 | G_MARKUP_ERROR_BAD_UTF8, 33 | G_MARKUP_ERROR_EMPTY, 34 | G_MARKUP_ERROR_PARSE, 35 | /* These three are primarily intended for specific GMarkupParser 36 | * implementations to set. 37 | */ 38 | G_MARKUP_ERROR_UNKNOWN_ELEMENT, 39 | G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, 40 | G_MARKUP_ERROR_INVALID_CONTENT 41 | } GMarkupError; 42 | 43 | #define G_MARKUP_ERROR g_markup_error_quark () 44 | 45 | GQuark g_markup_error_quark (void); 46 | 47 | typedef enum 48 | { 49 | G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0, 50 | G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1 51 | } GMarkupParseFlags; 52 | 53 | typedef struct _GMarkupParseContext GMarkupParseContext; 54 | typedef struct _GMarkupParser GMarkupParser; 55 | 56 | struct _GMarkupParser 57 | { 58 | /* Called for open tags */ 59 | void (*start_element) (GMarkupParseContext *context, 60 | const gchar *element_name, 61 | const gchar **attribute_names, 62 | const gchar **attribute_values, 63 | gpointer user_data, 64 | GError **error); 65 | 66 | /* Called for close tags */ 67 | void (*end_element) (GMarkupParseContext *context, 68 | const gchar *element_name, 69 | gpointer user_data, 70 | GError **error); 71 | 72 | /* Called for character data */ 73 | /* text is not nul-terminated */ 74 | void (*text) (GMarkupParseContext *context, 75 | const gchar *text, 76 | gsize text_len, 77 | gpointer user_data, 78 | GError **error); 79 | 80 | /* Called for strings that should be re-saved verbatim in this same 81 | * position, but are not otherwise interpretable. At the moment 82 | * this includes comments and processing instructions. 83 | */ 84 | /* text is not nul-terminated. */ 85 | void (*passthrough) (GMarkupParseContext *context, 86 | const gchar *passthrough_text, 87 | gsize text_len, 88 | gpointer user_data, 89 | GError **error); 90 | 91 | /* Called on error, including one set by other 92 | * methods in the vtable. The GError should not be freed. 93 | */ 94 | void (*error) (GMarkupParseContext *context, 95 | GError *error, 96 | gpointer user_data); 97 | }; 98 | 99 | GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser, 100 | GMarkupParseFlags flags, 101 | gpointer user_data, 102 | GDestroyNotify user_data_dnotify); 103 | void g_markup_parse_context_free (GMarkupParseContext *context); 104 | gboolean g_markup_parse_context_parse (GMarkupParseContext *context, 105 | const gchar *text, 106 | gssize text_len, 107 | GError **error); 108 | 109 | gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context, 110 | GError **error); 111 | G_CONST_RETURN gchar *g_markup_parse_context_get_element (GMarkupParseContext *context); 112 | 113 | /* For user-constructed error messages, has no precise semantics */ 114 | void g_markup_parse_context_get_position (GMarkupParseContext *context, 115 | gint *line_number, 116 | gint *char_number); 117 | 118 | /* useful when saving */ 119 | gchar* g_markup_escape_text (const gchar *text, 120 | gssize length); 121 | 122 | gchar *g_markup_printf_escaped (const char *format, 123 | ...) G_GNUC_PRINTF (1, 2); 124 | gchar *g_markup_vprintf_escaped (const char *format, 125 | va_list args); 126 | 127 | G_END_DECLS 128 | 129 | #endif /* __G_MARKUP_H__ */ 130 | 131 | -------------------------------------------------------------------------------- /sdconv/sdconv.cpp: -------------------------------------------------------------------------------- 1 | // sdconv.cpp 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "mdk.h" 10 | 11 | void show_usage() 12 | { 13 | fprintf(stderr, "usage: sdconv [options] [script] [output.xml]\n\n" 14 | "Available options:\n" 15 | " -m : select convert module, available: python, lua\n" 16 | " -d [num/r] : debug mode [num for start number, r for random]\n" 17 | " -h : show this help page\n\n" 18 | "For additional information, see http://mac-dictionary-kit.googlecode.com/\n"); 19 | exit(1); 20 | } 21 | 22 | enum debug_mode { DEBUG_MODE_OFF, DEBUG_MODE_NUM, DEBUG_MODE_RANDOM }; 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | int i = 1, debug_mode = DEBUG_MODE_OFF; 27 | FILE *fp; 28 | const char *outfile, *module_name = "default", *module_file = NULL; 29 | unsigned int start = 0; 30 | 31 | if (argc < 3) 32 | show_usage(); 33 | 34 | // process options in arguments 35 | while (i < argc) 36 | { 37 | if (strcmp(argv[i], "-d") == 0) 38 | { 39 | debug_mode = DEBUG_MODE_NUM; 40 | i++; 41 | 42 | if (i < argc) 43 | { 44 | // specify an start id 45 | if (isdigit(argv[i][0])) 46 | { 47 | start = (unsigned int)strtol(argv[i++], NULL, 10); 48 | 49 | if (start <= 0) 50 | { 51 | fprintf(stderr, "-d option comes with " 52 | "positive start number.\n"); 53 | return 1; 54 | } 55 | } 56 | 57 | // random mode 58 | else if (strlen(argv[i]) == 1 && argv[i][0] == 'r') 59 | { 60 | debug_mode = DEBUG_MODE_RANDOM; 61 | i++; 62 | } 63 | 64 | // otherwise leave it alone, use default start id (0) 65 | } 66 | } 67 | 68 | else 69 | if (strcmp(argv[i], "-m") == 0) 70 | { 71 | i++; 72 | 73 | if (i >= argc) 74 | { 75 | fprintf(stderr, "-m option must come with a module name.\n"); 76 | return 1; 77 | } 78 | 79 | module_name = argv[i++]; 80 | } 81 | 82 | else 83 | if (strcmp(argv[i], "-h") == 0) 84 | show_usage(); 85 | 86 | else 87 | break; 88 | } 89 | 90 | struct convert_module *mod = mdk_get_convert_module(module_name); 91 | if (! mod) 92 | { 93 | fprintf(stderr, "module '%s' not found.\n", module_name); 94 | return 1; 95 | } 96 | 97 | if (mod->req_file) 98 | { 99 | struct stat st; 100 | 101 | if (argc - i < 1) 102 | show_usage(); 103 | 104 | module_file = argv[i++]; 105 | if (stat(module_file, &st) != 0) 106 | { 107 | fprintf(stderr, "specified module script '%s' not found.\n", 108 | module_file); 109 | return 1; 110 | } 111 | } 112 | 113 | if (mod->init) 114 | { 115 | bool ret = mod->init(module_file); 116 | if (ret != true) 117 | { 118 | fprintf(stderr, "%s: initialize module %s failed.\n", 119 | argv[0], module_file); 120 | return 1; 121 | } 122 | } 123 | 124 | // we must leave at least one argument for input file name 125 | if (argc - i < 1) 126 | show_usage(); 127 | 128 | const char *path = argv[i++]; 129 | const std::string url(path); 130 | size_t end, count; 131 | mdk_dict *dict = new mdk_dict; 132 | 133 | setlocale(LC_ALL, ""); 134 | 135 | if (dict->load(url) != true) 136 | { 137 | fprintf(stderr, "%s: load dictionary file '%s' failed.\n", argv[0], path); 138 | return 1; 139 | } 140 | 141 | count = dict->get_entry_count(); 142 | 143 | if (debug_mode) 144 | { 145 | if (debug_mode == DEBUG_MODE_RANDOM) 146 | { 147 | srandom((unsigned)time(0)); 148 | 149 | double r = random(); 150 | start = count * r / RAND_MAX; 151 | } 152 | 153 | else if (start >= count) 154 | { 155 | fprintf(stderr, "%s: start entry id %u is larger than " 156 | "the total entry number (%lu).\n", 157 | argv[0], start, count); 158 | return 1; 159 | } 160 | count = 1; 161 | } 162 | 163 | printf("%s %lu %u\n", dict->dict_name().c_str(), dict->get_entry_count(), start); 164 | 165 | end = start + count; 166 | 167 | // if we have yet another argument, that's the output file 168 | // otherwise we'll output to stdout 169 | if (i < argc) 170 | { 171 | outfile = argv[i]; 172 | fp = fopen(outfile, "w"); 173 | if (! fp) 174 | { 175 | fprintf(stderr, "%s: write to output file '%s' failed.\n", argv[0], outfile); 176 | return 1; 177 | } 178 | } else 179 | fp = stdout; 180 | 181 | GString *dest = mdk_start_convert(mod); 182 | 183 | for (i = start; i < end; i++) 184 | mdk_convert_index_with_module(mod, dict, i, dest); 185 | 186 | mdk_finish_convert(mod, dest); 187 | fprintf(fp, "%s", dest->str); 188 | g_string_free(dest, TRUE); 189 | if (fp != stdout) 190 | fclose(fp); 191 | 192 | if (mod->fini) 193 | mod->fini(); 194 | 195 | return 0; 196 | } 197 | 198 | -------------------------------------------------------------------------------- /sdconv/include/glib/gmem.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_MEM_H__ 28 | #define __G_MEM_H__ 29 | 30 | #include 31 | #include 32 | 33 | G_BEGIN_DECLS 34 | 35 | typedef struct _GMemVTable GMemVTable; 36 | 37 | 38 | #if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG 39 | # define G_MEM_ALIGN GLIB_SIZEOF_VOID_P 40 | #else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */ 41 | # define G_MEM_ALIGN GLIB_SIZEOF_LONG 42 | #endif /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */ 43 | 44 | 45 | /* Memory allocation functions 46 | */ 47 | gpointer g_malloc (gulong n_bytes) G_GNUC_MALLOC; 48 | gpointer g_malloc0 (gulong n_bytes) G_GNUC_MALLOC; 49 | gpointer g_realloc (gpointer mem, 50 | gulong n_bytes) G_GNUC_WARN_UNUSED_RESULT; 51 | void g_free (gpointer mem); 52 | gpointer g_try_malloc (gulong n_bytes) G_GNUC_MALLOC; 53 | gpointer g_try_malloc0 (gulong n_bytes) G_GNUC_MALLOC; 54 | gpointer g_try_realloc (gpointer mem, 55 | gulong n_bytes) G_GNUC_WARN_UNUSED_RESULT; 56 | 57 | 58 | /* Convenience memory allocators 59 | */ 60 | #define g_new(struct_type, n_structs) \ 61 | ((struct_type *) g_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) 62 | #define g_new0(struct_type, n_structs) \ 63 | ((struct_type *) g_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) 64 | #define g_renew(struct_type, mem, n_structs) \ 65 | ((struct_type *) g_realloc ((mem), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) 66 | 67 | #define g_try_new(struct_type, n_structs) \ 68 | ((struct_type *) g_try_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) 69 | #define g_try_new0(struct_type, n_structs) \ 70 | ((struct_type *) g_try_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) 71 | #define g_try_renew(struct_type, mem, n_structs) \ 72 | ((struct_type *) g_try_realloc ((mem), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs)))) 73 | 74 | 75 | /* Memory allocation virtualization for debugging purposes 76 | * g_mem_set_vtable() has to be the very first GLib function called 77 | * if being used 78 | */ 79 | struct _GMemVTable 80 | { 81 | gpointer (*malloc) (gsize n_bytes); 82 | gpointer (*realloc) (gpointer mem, 83 | gsize n_bytes); 84 | void (*free) (gpointer mem); 85 | /* optional; set to NULL if not used ! */ 86 | gpointer (*calloc) (gsize n_blocks, 87 | gsize n_block_bytes); 88 | gpointer (*try_malloc) (gsize n_bytes); 89 | gpointer (*try_realloc) (gpointer mem, 90 | gsize n_bytes); 91 | }; 92 | void g_mem_set_vtable (GMemVTable *vtable); 93 | gboolean g_mem_is_system_malloc (void); 94 | 95 | GLIB_VAR gboolean g_mem_gc_friendly; 96 | 97 | /* Memory profiler and checker, has to be enabled via g_mem_set_vtable() 98 | */ 99 | GLIB_VAR GMemVTable *glib_mem_profiler_table; 100 | void g_mem_profile (void); 101 | 102 | 103 | /* deprecated memchunks and allocators */ 104 | #if !defined (G_DISABLE_DEPRECATED) || defined (GTK_COMPILATION) || defined (GDK_COMPILATION) 105 | typedef struct _GAllocator GAllocator; 106 | typedef struct _GMemChunk GMemChunk; 107 | #define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \ 108 | g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \ 109 | sizeof (type), \ 110 | sizeof (type) * (pre_alloc), \ 111 | (alloc_type)) \ 112 | ) 113 | #define g_chunk_new(type, chunk) ( \ 114 | (type *) g_mem_chunk_alloc (chunk) \ 115 | ) 116 | #define g_chunk_new0(type, chunk) ( \ 117 | (type *) g_mem_chunk_alloc0 (chunk) \ 118 | ) 119 | #define g_chunk_free(mem, mem_chunk) G_STMT_START { \ 120 | g_mem_chunk_free ((mem_chunk), (mem)); \ 121 | } G_STMT_END 122 | #define G_ALLOC_ONLY 1 123 | #define G_ALLOC_AND_FREE 2 124 | GMemChunk* g_mem_chunk_new (const gchar *name, 125 | gint atom_size, 126 | gulong area_size, 127 | gint type); 128 | void g_mem_chunk_destroy (GMemChunk *mem_chunk); 129 | gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk); 130 | gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk); 131 | void g_mem_chunk_free (GMemChunk *mem_chunk, 132 | gpointer mem); 133 | void g_mem_chunk_clean (GMemChunk *mem_chunk); 134 | void g_mem_chunk_reset (GMemChunk *mem_chunk); 135 | void g_mem_chunk_print (GMemChunk *mem_chunk); 136 | void g_mem_chunk_info (void); 137 | void g_blow_chunks (void); 138 | GAllocator*g_allocator_new (const gchar *name, 139 | guint n_preallocs); 140 | void g_allocator_free (GAllocator *allocator); 141 | #define G_ALLOCATOR_LIST (1) 142 | #define G_ALLOCATOR_SLIST (2) 143 | #define G_ALLOCATOR_NODE (3) 144 | #endif /* G_DISABLE_DEPRECATED */ 145 | 146 | G_END_DECLS 147 | 148 | #endif /* __G_MEM_H__ */ 149 | -------------------------------------------------------------------------------- /sdconv/include/glib/gspawn.h: -------------------------------------------------------------------------------- 1 | /* gspawn.h - Process launching 2 | * 3 | * Copyright 2000 Red Hat, Inc. 4 | * 5 | * GLib is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation; either version 2 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * GLib is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with GLib; see the file COPYING.LIB. If not, write 17 | * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_SPAWN_H__ 22 | #define __G_SPAWN_H__ 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | /* I'm not sure I remember our proposed naming convention here. */ 29 | #define G_SPAWN_ERROR g_spawn_error_quark () 30 | 31 | typedef enum 32 | { 33 | G_SPAWN_ERROR_FORK, /* fork failed due to lack of memory */ 34 | G_SPAWN_ERROR_READ, /* read or select on pipes failed */ 35 | G_SPAWN_ERROR_CHDIR, /* changing to working dir failed */ 36 | G_SPAWN_ERROR_ACCES, /* execv() returned EACCES */ 37 | G_SPAWN_ERROR_PERM, /* execv() returned EPERM */ 38 | G_SPAWN_ERROR_2BIG, /* execv() returned E2BIG */ 39 | G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */ 40 | G_SPAWN_ERROR_NAMETOOLONG, /* "" "" ENAMETOOLONG */ 41 | G_SPAWN_ERROR_NOENT, /* "" "" ENOENT */ 42 | G_SPAWN_ERROR_NOMEM, /* "" "" ENOMEM */ 43 | G_SPAWN_ERROR_NOTDIR, /* "" "" ENOTDIR */ 44 | G_SPAWN_ERROR_LOOP, /* "" "" ELOOP */ 45 | G_SPAWN_ERROR_TXTBUSY, /* "" "" ETXTBUSY */ 46 | G_SPAWN_ERROR_IO, /* "" "" EIO */ 47 | G_SPAWN_ERROR_NFILE, /* "" "" ENFILE */ 48 | G_SPAWN_ERROR_MFILE, /* "" "" EMFLE */ 49 | G_SPAWN_ERROR_INVAL, /* "" "" EINVAL */ 50 | G_SPAWN_ERROR_ISDIR, /* "" "" EISDIR */ 51 | G_SPAWN_ERROR_LIBBAD, /* "" "" ELIBBAD */ 52 | G_SPAWN_ERROR_FAILED /* other fatal failure, error->message 53 | * should explain 54 | */ 55 | } GSpawnError; 56 | 57 | typedef void (* GSpawnChildSetupFunc) (gpointer user_data); 58 | 59 | typedef enum 60 | { 61 | G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0, 62 | G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, 63 | /* look for argv[0] in the path i.e. use execvp() */ 64 | G_SPAWN_SEARCH_PATH = 1 << 2, 65 | /* Dump output to /dev/null */ 66 | G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, 67 | G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, 68 | G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5, 69 | G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6 70 | } GSpawnFlags; 71 | 72 | GQuark g_spawn_error_quark (void); 73 | 74 | #ifdef G_OS_WIN32 75 | #define g_spawn_async g_spawn_async_utf8 76 | #define g_spawn_async_with_pipes g_spawn_async_with_pipes_utf8 77 | #define g_spawn_sync g_spawn_sync_utf8 78 | #define g_spawn_command_line_sync g_spawn_command_line_sync_utf8 79 | #define g_spawn_command_line_async g_spawn_command_line_async_utf8 80 | #endif 81 | 82 | gboolean g_spawn_async (const gchar *working_directory, 83 | gchar **argv, 84 | gchar **envp, 85 | GSpawnFlags flags, 86 | GSpawnChildSetupFunc child_setup, 87 | gpointer user_data, 88 | GPid *child_pid, 89 | GError **error); 90 | 91 | 92 | /* Opens pipes for non-NULL standard_output, standard_input, standard_error, 93 | * and returns the parent's end of the pipes. 94 | */ 95 | gboolean g_spawn_async_with_pipes (const gchar *working_directory, 96 | gchar **argv, 97 | gchar **envp, 98 | GSpawnFlags flags, 99 | GSpawnChildSetupFunc child_setup, 100 | gpointer user_data, 101 | GPid *child_pid, 102 | gint *standard_input, 103 | gint *standard_output, 104 | gint *standard_error, 105 | GError **error); 106 | 107 | 108 | /* If standard_output or standard_error are non-NULL, the full 109 | * standard output or error of the command will be placed there. 110 | */ 111 | 112 | gboolean g_spawn_sync (const gchar *working_directory, 113 | gchar **argv, 114 | gchar **envp, 115 | GSpawnFlags flags, 116 | GSpawnChildSetupFunc child_setup, 117 | gpointer user_data, 118 | gchar **standard_output, 119 | gchar **standard_error, 120 | gint *exit_status, 121 | GError **error); 122 | 123 | gboolean g_spawn_command_line_sync (const gchar *command_line, 124 | gchar **standard_output, 125 | gchar **standard_error, 126 | gint *exit_status, 127 | GError **error); 128 | gboolean g_spawn_command_line_async (const gchar *command_line, 129 | GError **error); 130 | 131 | void g_spawn_close_pid (GPid pid); 132 | 133 | 134 | G_END_DECLS 135 | 136 | #endif /* __G_SPAWN_H__ */ 137 | 138 | 139 | -------------------------------------------------------------------------------- /sdconv/include/glib/gnode.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_NODE_H__ 28 | #define __G_NODE_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GNode GNode; 35 | 36 | /* Tree traverse flags */ 37 | typedef enum 38 | { 39 | G_TRAVERSE_LEAVES = 1 << 0, 40 | G_TRAVERSE_NON_LEAVES = 1 << 1, 41 | G_TRAVERSE_ALL = G_TRAVERSE_LEAVES | G_TRAVERSE_NON_LEAVES, 42 | G_TRAVERSE_MASK = 0x03, 43 | G_TRAVERSE_LEAFS = G_TRAVERSE_LEAVES, 44 | G_TRAVERSE_NON_LEAFS = G_TRAVERSE_NON_LEAVES 45 | } GTraverseFlags; 46 | 47 | /* Tree traverse orders */ 48 | typedef enum 49 | { 50 | G_IN_ORDER, 51 | G_PRE_ORDER, 52 | G_POST_ORDER, 53 | G_LEVEL_ORDER 54 | } GTraverseType; 55 | 56 | typedef gboolean (*GNodeTraverseFunc) (GNode *node, 57 | gpointer data); 58 | typedef void (*GNodeForeachFunc) (GNode *node, 59 | gpointer data); 60 | typedef gpointer (*GCopyFunc) (gconstpointer src, 61 | gpointer data); 62 | 63 | /* N-way tree implementation 64 | */ 65 | struct _GNode 66 | { 67 | gpointer data; 68 | GNode *next; 69 | GNode *prev; 70 | GNode *parent; 71 | GNode *children; 72 | }; 73 | 74 | #define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \ 75 | ((GNode*) (node))->prev == NULL && \ 76 | ((GNode*) (node))->next == NULL) 77 | #define G_NODE_IS_LEAF(node) (((GNode*) (node))->children == NULL) 78 | 79 | GNode* g_node_new (gpointer data); 80 | void g_node_destroy (GNode *root); 81 | void g_node_unlink (GNode *node); 82 | GNode* g_node_copy_deep (GNode *node, 83 | GCopyFunc copy_func, 84 | gpointer data); 85 | GNode* g_node_copy (GNode *node); 86 | GNode* g_node_insert (GNode *parent, 87 | gint position, 88 | GNode *node); 89 | GNode* g_node_insert_before (GNode *parent, 90 | GNode *sibling, 91 | GNode *node); 92 | GNode* g_node_insert_after (GNode *parent, 93 | GNode *sibling, 94 | GNode *node); 95 | GNode* g_node_prepend (GNode *parent, 96 | GNode *node); 97 | guint g_node_n_nodes (GNode *root, 98 | GTraverseFlags flags); 99 | GNode* g_node_get_root (GNode *node); 100 | gboolean g_node_is_ancestor (GNode *node, 101 | GNode *descendant); 102 | guint g_node_depth (GNode *node); 103 | GNode* g_node_find (GNode *root, 104 | GTraverseType order, 105 | GTraverseFlags flags, 106 | gpointer data); 107 | 108 | /* convenience macros */ 109 | #define g_node_append(parent, node) \ 110 | g_node_insert_before ((parent), NULL, (node)) 111 | #define g_node_insert_data(parent, position, data) \ 112 | g_node_insert ((parent), (position), g_node_new (data)) 113 | #define g_node_insert_data_before(parent, sibling, data) \ 114 | g_node_insert_before ((parent), (sibling), g_node_new (data)) 115 | #define g_node_prepend_data(parent, data) \ 116 | g_node_prepend ((parent), g_node_new (data)) 117 | #define g_node_append_data(parent, data) \ 118 | g_node_insert_before ((parent), NULL, g_node_new (data)) 119 | 120 | /* traversal function, assumes that `node' is root 121 | * (only traverses `node' and its subtree). 122 | * this function is just a high level interface to 123 | * low level traversal functions, optimized for speed. 124 | */ 125 | void g_node_traverse (GNode *root, 126 | GTraverseType order, 127 | GTraverseFlags flags, 128 | gint max_depth, 129 | GNodeTraverseFunc func, 130 | gpointer data); 131 | 132 | /* return the maximum tree height starting with `node', this is an expensive 133 | * operation, since we need to visit all nodes. this could be shortened by 134 | * adding `guint height' to struct _GNode, but then again, this is not very 135 | * often needed, and would make g_node_insert() more time consuming. 136 | */ 137 | guint g_node_max_height (GNode *root); 138 | 139 | void g_node_children_foreach (GNode *node, 140 | GTraverseFlags flags, 141 | GNodeForeachFunc func, 142 | gpointer data); 143 | void g_node_reverse_children (GNode *node); 144 | guint g_node_n_children (GNode *node); 145 | GNode* g_node_nth_child (GNode *node, 146 | guint n); 147 | GNode* g_node_last_child (GNode *node); 148 | GNode* g_node_find_child (GNode *node, 149 | GTraverseFlags flags, 150 | gpointer data); 151 | gint g_node_child_position (GNode *node, 152 | GNode *child); 153 | gint g_node_child_index (GNode *node, 154 | gpointer data); 155 | 156 | GNode* g_node_first_sibling (GNode *node); 157 | GNode* g_node_last_sibling (GNode *node); 158 | 159 | #define g_node_prev_sibling(node) ((node) ? \ 160 | ((GNode*) (node))->prev : NULL) 161 | #define g_node_next_sibling(node) ((node) ? \ 162 | ((GNode*) (node))->next : NULL) 163 | #define g_node_first_child(node) ((node) ? \ 164 | ((GNode*) (node))->children : NULL) 165 | 166 | #ifndef G_DISABLE_DEPRECATED 167 | void g_node_push_allocator (gpointer dummy); 168 | void g_node_pop_allocator (void); 169 | #endif 170 | G_END_DECLS 171 | 172 | #endif /* __G_NODE_H__ */ 173 | -------------------------------------------------------------------------------- /sdconv/include/glib/goption.h: -------------------------------------------------------------------------------- 1 | /* goption.h - Option parser 2 | * 3 | * Copyright (C) 2004 Anders Carlsson 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_OPTION_H__ 22 | #define __G_OPTION_H__ 23 | 24 | #include 25 | #include 26 | 27 | G_BEGIN_DECLS 28 | 29 | typedef struct _GOptionContext GOptionContext; 30 | typedef struct _GOptionGroup GOptionGroup; 31 | typedef struct _GOptionEntry GOptionEntry; 32 | 33 | typedef enum 34 | { 35 | G_OPTION_FLAG_HIDDEN = 1 << 0, 36 | G_OPTION_FLAG_IN_MAIN = 1 << 1, 37 | G_OPTION_FLAG_REVERSE = 1 << 2, 38 | G_OPTION_FLAG_NO_ARG = 1 << 3, 39 | G_OPTION_FLAG_FILENAME = 1 << 4, 40 | G_OPTION_FLAG_OPTIONAL_ARG = 1 << 5, 41 | G_OPTION_FLAG_NOALIAS = 1 << 6 42 | } GOptionFlags; 43 | 44 | typedef enum 45 | { 46 | G_OPTION_ARG_NONE, 47 | G_OPTION_ARG_STRING, 48 | G_OPTION_ARG_INT, 49 | G_OPTION_ARG_CALLBACK, 50 | G_OPTION_ARG_FILENAME, 51 | G_OPTION_ARG_STRING_ARRAY, 52 | G_OPTION_ARG_FILENAME_ARRAY, 53 | G_OPTION_ARG_DOUBLE, 54 | G_OPTION_ARG_INT64 55 | } GOptionArg; 56 | 57 | typedef gboolean (*GOptionArgFunc) (const gchar *option_name, 58 | const gchar *value, 59 | gpointer data, 60 | GError **error); 61 | 62 | typedef gboolean (*GOptionParseFunc) (GOptionContext *context, 63 | GOptionGroup *group, 64 | gpointer data, 65 | GError **error); 66 | 67 | typedef void (*GOptionErrorFunc) (GOptionContext *context, 68 | GOptionGroup *group, 69 | gpointer data, 70 | GError **error); 71 | 72 | #define G_OPTION_ERROR (g_option_error_quark ()) 73 | 74 | typedef enum 75 | { 76 | G_OPTION_ERROR_UNKNOWN_OPTION, 77 | G_OPTION_ERROR_BAD_VALUE, 78 | G_OPTION_ERROR_FAILED 79 | } GOptionError; 80 | 81 | GQuark g_option_error_quark (void); 82 | 83 | 84 | struct _GOptionEntry 85 | { 86 | const gchar *long_name; 87 | gchar short_name; 88 | gint flags; 89 | 90 | GOptionArg arg; 91 | gpointer arg_data; 92 | 93 | const gchar *description; 94 | const gchar *arg_description; 95 | }; 96 | 97 | #define G_OPTION_REMAINING "" 98 | 99 | GOptionContext *g_option_context_new (const gchar *parameter_string); 100 | void g_option_context_set_summary (GOptionContext *context, 101 | const gchar *summary); 102 | G_CONST_RETURN gchar *g_option_context_get_summary (GOptionContext *context); 103 | void g_option_context_set_description (GOptionContext *context, 104 | const gchar *description); 105 | G_CONST_RETURN gchar *g_option_context_get_description (GOptionContext *context); 106 | void g_option_context_free (GOptionContext *context); 107 | void g_option_context_set_help_enabled (GOptionContext *context, 108 | gboolean help_enabled); 109 | gboolean g_option_context_get_help_enabled (GOptionContext *context); 110 | void g_option_context_set_ignore_unknown_options (GOptionContext *context, 111 | gboolean ignore_unknown); 112 | gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context); 113 | 114 | void g_option_context_add_main_entries (GOptionContext *context, 115 | const GOptionEntry *entries, 116 | const gchar *translation_domain); 117 | gboolean g_option_context_parse (GOptionContext *context, 118 | gint *argc, 119 | gchar ***argv, 120 | GError **error); 121 | void g_option_context_set_translate_func (GOptionContext *context, 122 | GTranslateFunc func, 123 | gpointer data, 124 | GDestroyNotify destroy_notify); 125 | void g_option_context_set_translation_domain (GOptionContext *context, 126 | const gchar *domain); 127 | 128 | void g_option_context_add_group (GOptionContext *context, 129 | GOptionGroup *group); 130 | void g_option_context_set_main_group (GOptionContext *context, 131 | GOptionGroup *group); 132 | GOptionGroup *g_option_context_get_main_group (GOptionContext *context); 133 | gchar *g_option_context_get_help (GOptionContext *context, 134 | gboolean main_help, 135 | GOptionGroup *group); 136 | 137 | GOptionGroup *g_option_group_new (const gchar *name, 138 | const gchar *description, 139 | const gchar *help_description, 140 | gpointer user_data, 141 | GDestroyNotify destroy); 142 | void g_option_group_set_parse_hooks (GOptionGroup *group, 143 | GOptionParseFunc pre_parse_func, 144 | GOptionParseFunc post_parse_func); 145 | void g_option_group_set_error_hook (GOptionGroup *group, 146 | GOptionErrorFunc error_func); 147 | void g_option_group_free (GOptionGroup *group); 148 | void g_option_group_add_entries (GOptionGroup *group, 149 | const GOptionEntry *entries); 150 | void g_option_group_set_translate_func (GOptionGroup *group, 151 | GTranslateFunc func, 152 | gpointer data, 153 | GDestroyNotify destroy_notify); 154 | void g_option_group_set_translation_domain (GOptionGroup *group, 155 | const gchar *domain); 156 | 157 | 158 | G_END_DECLS 159 | 160 | #endif /* __G_OPTION_H__ */ 161 | -------------------------------------------------------------------------------- /sdconv/include/glibconfig.h: -------------------------------------------------------------------------------- 1 | /* glibconfig.h 2 | * 3 | * This is a generated file. Please modify 'configure.in' 4 | */ 5 | 6 | #ifndef __G_LIBCONFIG_H__ 7 | #define __G_LIBCONFIG_H__ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #define GLIB_HAVE_ALLOCA_H 14 | #define GLIB_HAVE_SYS_POLL_H 15 | 16 | G_BEGIN_DECLS 17 | 18 | #define G_MINFLOAT FLT_MIN 19 | #define G_MAXFLOAT FLT_MAX 20 | #define G_MINDOUBLE DBL_MIN 21 | #define G_MAXDOUBLE DBL_MAX 22 | #define G_MINSHORT SHRT_MIN 23 | #define G_MAXSHORT SHRT_MAX 24 | #define G_MAXUSHORT USHRT_MAX 25 | #define G_MININT INT_MIN 26 | #define G_MAXINT INT_MAX 27 | #define G_MAXUINT UINT_MAX 28 | #define G_MINLONG LONG_MIN 29 | #define G_MAXLONG LONG_MAX 30 | #define G_MAXULONG ULONG_MAX 31 | 32 | typedef signed char gint8; 33 | typedef unsigned char guint8; 34 | typedef signed short gint16; 35 | typedef unsigned short guint16; 36 | #define G_GINT16_MODIFIER "h" 37 | #define G_GINT16_FORMAT "hi" 38 | #define G_GUINT16_FORMAT "hu" 39 | typedef signed int gint32; 40 | typedef unsigned int guint32; 41 | #define G_GINT32_MODIFIER "" 42 | #define G_GINT32_FORMAT "i" 43 | #define G_GUINT32_FORMAT "u" 44 | #define G_HAVE_GINT64 1 /* deprecated, always true */ 45 | 46 | G_GNUC_EXTENSION typedef signed long long gint64; 47 | G_GNUC_EXTENSION typedef unsigned long long guint64; 48 | 49 | #define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) 50 | #define G_GUINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##ULL)) 51 | #define G_GINT64_MODIFIER "ll" 52 | #define G_GINT64_FORMAT "lli" 53 | #define G_GUINT64_FORMAT "llu" 54 | 55 | #define GLIB_SIZEOF_VOID_P 4 56 | #define GLIB_SIZEOF_LONG 4 57 | #define GLIB_SIZEOF_SIZE_T 4 58 | 59 | typedef signed long gssize; 60 | typedef unsigned long gsize; 61 | #define G_GSIZE_MODIFIER "l" 62 | #define G_GSSIZE_FORMAT "li" 63 | #define G_GSIZE_FORMAT "lu" 64 | 65 | #define G_MAXSIZE G_MAXULONG 66 | #define G_MINSSIZE G_MINLONG 67 | #define G_MAXSSIZE G_MAXLONG 68 | 69 | typedef gint64 goffset; 70 | #define G_MINOFFSET G_MININT64 71 | #define G_MAXOFFSET G_MAXINT64 72 | 73 | 74 | #define GPOINTER_TO_INT(p) ((gint) (p)) 75 | #define GPOINTER_TO_UINT(p) ((guint) (p)) 76 | 77 | #define GINT_TO_POINTER(i) ((gpointer) (i)) 78 | #define GUINT_TO_POINTER(u) ((gpointer) (u)) 79 | 80 | #ifdef NeXT /* @#%@! NeXTStep */ 81 | # define g_ATEXIT(proc) (!atexit (proc)) 82 | #else 83 | # define g_ATEXIT(proc) (atexit (proc)) 84 | #endif 85 | 86 | #define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END 87 | 88 | #define GLIB_MAJOR_VERSION 2 89 | #define GLIB_MINOR_VERSION 14 90 | #define GLIB_MICRO_VERSION 3 91 | 92 | #define G_OS_UNIX 93 | 94 | #define G_VA_COPY va_copy 95 | 96 | #ifdef __cplusplus 97 | #define G_HAVE_INLINE 1 98 | #else /* !__cplusplus */ 99 | #define G_HAVE_INLINE 1 100 | #define G_HAVE___INLINE 1 101 | #define G_HAVE___INLINE__ 1 102 | #endif /* !__cplusplus */ 103 | 104 | #ifdef __cplusplus 105 | #define G_CAN_INLINE 1 106 | #else /* !__cplusplus */ 107 | #define G_CAN_INLINE 1 108 | #endif 109 | 110 | #ifndef __cplusplus 111 | # define G_HAVE_ISO_VARARGS 1 112 | #endif 113 | #ifdef __cplusplus 114 | # define G_HAVE_ISO_VARARGS 1 115 | #endif 116 | 117 | /* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi 118 | * is passed ISO vararg support is turned off, and there is no work 119 | * around to turn it on, so we unconditionally turn it off. 120 | */ 121 | #if __GNUC__ == 2 && __GNUC_MINOR__ == 95 122 | # undef G_HAVE_ISO_VARARGS 123 | #endif 124 | 125 | #define G_HAVE_GNUC_VARARGS 1 126 | #define G_HAVE_GROWING_STACK 0 127 | 128 | #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) 129 | #define G_GNUC_INTERNAL __hidden 130 | #elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY) 131 | #define G_GNUC_INTERNAL __attribute__((visibility("hidden"))) 132 | #else 133 | #define G_GNUC_INTERNAL 134 | #endif 135 | 136 | #define G_THREADS_ENABLED 137 | #define G_THREADS_IMPL_POSIX 138 | typedef struct _GStaticMutex GStaticMutex; 139 | struct _GStaticMutex 140 | { 141 | struct _GMutex *runtime_mutex; 142 | union { 143 | char pad[44]; 144 | double dummy_double; 145 | void *dummy_pointer; 146 | long dummy_long; 147 | } static_mutex; 148 | }; 149 | #define G_STATIC_MUTEX_INIT { NULL, { { -89,-85,-86,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} } } 150 | #define g_static_mutex_get_mutex(mutex) \ 151 | (g_thread_use_default_impl ? ((GMutex*) ((mutex)->static_mutex.pad)) : \ 152 | g_static_mutex_get_mutex_impl_shortcut (&((mutex)->runtime_mutex))) 153 | /* This represents a system thread as used by the implementation. An 154 | * alien implementaion, as loaded by g_thread_init can only count on 155 | * "sizeof (gpointer)" bytes to store their info. We however need more 156 | * for some of our native implementations. */ 157 | typedef union _GSystemThread GSystemThread; 158 | union _GSystemThread 159 | { 160 | char data[4]; 161 | double dummy_double; 162 | void *dummy_pointer; 163 | long dummy_long; 164 | }; 165 | 166 | #define GINT16_TO_LE(val) ((gint16) (val)) 167 | #define GUINT16_TO_LE(val) ((guint16) (val)) 168 | #define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val)) 169 | #define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val)) 170 | #define GINT32_TO_LE(val) ((gint32) (val)) 171 | #define GUINT32_TO_LE(val) ((guint32) (val)) 172 | #define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val)) 173 | #define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) 174 | #define GINT64_TO_LE(val) ((gint64) (val)) 175 | #define GUINT64_TO_LE(val) ((guint64) (val)) 176 | #define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val)) 177 | #define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val)) 178 | #define GLONG_TO_LE(val) ((glong) GINT32_TO_LE (val)) 179 | #define GULONG_TO_LE(val) ((gulong) GUINT32_TO_LE (val)) 180 | #define GLONG_TO_BE(val) ((glong) GINT32_TO_BE (val)) 181 | #define GULONG_TO_BE(val) ((gulong) GUINT32_TO_BE (val)) 182 | #define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val)) 183 | #define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val)) 184 | #define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val)) 185 | #define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val)) 186 | #define G_BYTE_ORDER G_LITTLE_ENDIAN 187 | 188 | #define GLIB_SYSDEF_POLLIN =1 189 | #define GLIB_SYSDEF_POLLOUT =4 190 | #define GLIB_SYSDEF_POLLPRI =2 191 | #define GLIB_SYSDEF_POLLHUP =16 192 | #define GLIB_SYSDEF_POLLERR =8 193 | #define GLIB_SYSDEF_POLLNVAL =32 194 | 195 | #define G_MODULE_SUFFIX "so" 196 | 197 | typedef int GPid; 198 | 199 | G_END_DECLS 200 | 201 | #endif /* GLIBCONFIG_H */ 202 | -------------------------------------------------------------------------------- /sdconv/include/glib/ghook.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_HOOK_H__ 28 | #define __G_HOOK_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | 35 | /* --- typedefs --- */ 36 | typedef struct _GHook GHook; 37 | typedef struct _GHookList GHookList; 38 | 39 | typedef gint (*GHookCompareFunc) (GHook *new_hook, 40 | GHook *sibling); 41 | typedef gboolean (*GHookFindFunc) (GHook *hook, 42 | gpointer data); 43 | typedef void (*GHookMarshaller) (GHook *hook, 44 | gpointer marshal_data); 45 | typedef gboolean (*GHookCheckMarshaller) (GHook *hook, 46 | gpointer marshal_data); 47 | typedef void (*GHookFunc) (gpointer data); 48 | typedef gboolean (*GHookCheckFunc) (gpointer data); 49 | typedef void (*GHookFinalizeFunc) (GHookList *hook_list, 50 | GHook *hook); 51 | typedef enum 52 | { 53 | G_HOOK_FLAG_ACTIVE = 1 << 0, 54 | G_HOOK_FLAG_IN_CALL = 1 << 1, 55 | G_HOOK_FLAG_MASK = 0x0f 56 | } GHookFlagMask; 57 | #define G_HOOK_FLAG_USER_SHIFT (4) 58 | 59 | 60 | /* --- structures --- */ 61 | struct _GHookList 62 | { 63 | gulong seq_id; 64 | guint hook_size : 16; 65 | guint is_setup : 1; 66 | GHook *hooks; 67 | gpointer dummy3; 68 | GHookFinalizeFunc finalize_hook; 69 | gpointer dummy[2]; 70 | }; 71 | struct _GHook 72 | { 73 | gpointer data; 74 | GHook *next; 75 | GHook *prev; 76 | guint ref_count; 77 | gulong hook_id; 78 | guint flags; 79 | gpointer func; 80 | GDestroyNotify destroy; 81 | }; 82 | 83 | 84 | /* --- macros --- */ 85 | #define G_HOOK(hook) ((GHook*) (hook)) 86 | #define G_HOOK_FLAGS(hook) (G_HOOK (hook)->flags) 87 | #define G_HOOK_ACTIVE(hook) ((G_HOOK_FLAGS (hook) & \ 88 | G_HOOK_FLAG_ACTIVE) != 0) 89 | #define G_HOOK_IN_CALL(hook) ((G_HOOK_FLAGS (hook) & \ 90 | G_HOOK_FLAG_IN_CALL) != 0) 91 | #define G_HOOK_IS_VALID(hook) (G_HOOK (hook)->hook_id != 0 && \ 92 | (G_HOOK_FLAGS (hook) & \ 93 | G_HOOK_FLAG_ACTIVE)) 94 | #define G_HOOK_IS_UNLINKED(hook) (G_HOOK (hook)->next == NULL && \ 95 | G_HOOK (hook)->prev == NULL && \ 96 | G_HOOK (hook)->hook_id == 0 && \ 97 | G_HOOK (hook)->ref_count == 0) 98 | 99 | 100 | /* --- prototypes --- */ 101 | /* callback maintenance functions */ 102 | void g_hook_list_init (GHookList *hook_list, 103 | guint hook_size); 104 | void g_hook_list_clear (GHookList *hook_list); 105 | GHook* g_hook_alloc (GHookList *hook_list); 106 | void g_hook_free (GHookList *hook_list, 107 | GHook *hook); 108 | GHook * g_hook_ref (GHookList *hook_list, 109 | GHook *hook); 110 | void g_hook_unref (GHookList *hook_list, 111 | GHook *hook); 112 | gboolean g_hook_destroy (GHookList *hook_list, 113 | gulong hook_id); 114 | void g_hook_destroy_link (GHookList *hook_list, 115 | GHook *hook); 116 | void g_hook_prepend (GHookList *hook_list, 117 | GHook *hook); 118 | void g_hook_insert_before (GHookList *hook_list, 119 | GHook *sibling, 120 | GHook *hook); 121 | void g_hook_insert_sorted (GHookList *hook_list, 122 | GHook *hook, 123 | GHookCompareFunc func); 124 | GHook* g_hook_get (GHookList *hook_list, 125 | gulong hook_id); 126 | GHook* g_hook_find (GHookList *hook_list, 127 | gboolean need_valids, 128 | GHookFindFunc func, 129 | gpointer data); 130 | GHook* g_hook_find_data (GHookList *hook_list, 131 | gboolean need_valids, 132 | gpointer data); 133 | GHook* g_hook_find_func (GHookList *hook_list, 134 | gboolean need_valids, 135 | gpointer func); 136 | GHook* g_hook_find_func_data (GHookList *hook_list, 137 | gboolean need_valids, 138 | gpointer func, 139 | gpointer data); 140 | /* return the first valid hook, and increment its reference count */ 141 | GHook* g_hook_first_valid (GHookList *hook_list, 142 | gboolean may_be_in_call); 143 | /* return the next valid hook with incremented reference count, and 144 | * decrement the reference count of the original hook 145 | */ 146 | GHook* g_hook_next_valid (GHookList *hook_list, 147 | GHook *hook, 148 | gboolean may_be_in_call); 149 | /* GHookCompareFunc implementation to insert hooks sorted by their id */ 150 | gint g_hook_compare_ids (GHook *new_hook, 151 | GHook *sibling); 152 | /* convenience macros */ 153 | #define g_hook_append( hook_list, hook ) \ 154 | g_hook_insert_before ((hook_list), NULL, (hook)) 155 | /* invoke all valid hooks with the (*GHookFunc) signature. 156 | */ 157 | void g_hook_list_invoke (GHookList *hook_list, 158 | gboolean may_recurse); 159 | /* invoke all valid hooks with the (*GHookCheckFunc) signature, 160 | * and destroy the hook if FALSE is returned. 161 | */ 162 | void g_hook_list_invoke_check (GHookList *hook_list, 163 | gboolean may_recurse); 164 | /* invoke a marshaller on all valid hooks. 165 | */ 166 | void g_hook_list_marshal (GHookList *hook_list, 167 | gboolean may_recurse, 168 | GHookMarshaller marshaller, 169 | gpointer marshal_data); 170 | void g_hook_list_marshal_check (GHookList *hook_list, 171 | gboolean may_recurse, 172 | GHookCheckMarshaller marshaller, 173 | gpointer marshal_data); 174 | 175 | G_END_DECLS 176 | 177 | #endif /* __G_HOOK_H__ */ 178 | 179 | -------------------------------------------------------------------------------- /sdconv/include/glib/gstring.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_STRING_H__ 28 | #define __G_STRING_H__ 29 | 30 | #include 31 | #include 32 | #include /* for G_CAN_INLINE */ 33 | 34 | G_BEGIN_DECLS 35 | 36 | typedef struct _GString GString; 37 | typedef struct _GStringChunk GStringChunk; 38 | 39 | struct _GString 40 | { 41 | gchar *str; 42 | gsize len; 43 | gsize allocated_len; 44 | }; 45 | 46 | /* String Chunks 47 | */ 48 | GStringChunk* g_string_chunk_new (gsize size); 49 | void g_string_chunk_free (GStringChunk *chunk); 50 | void g_string_chunk_clear (GStringChunk *chunk); 51 | gchar* g_string_chunk_insert (GStringChunk *chunk, 52 | const gchar *string); 53 | gchar* g_string_chunk_insert_len (GStringChunk *chunk, 54 | const gchar *string, 55 | gssize len); 56 | gchar* g_string_chunk_insert_const (GStringChunk *chunk, 57 | const gchar *string); 58 | 59 | 60 | /* Strings 61 | */ 62 | GString* g_string_new (const gchar *init); 63 | GString* g_string_new_len (const gchar *init, 64 | gssize len); 65 | GString* g_string_sized_new (gsize dfl_size); 66 | gchar* g_string_free (GString *string, 67 | gboolean free_segment); 68 | gboolean g_string_equal (const GString *v, 69 | const GString *v2); 70 | guint g_string_hash (const GString *str); 71 | GString* g_string_assign (GString *string, 72 | const gchar *rval); 73 | GString* g_string_truncate (GString *string, 74 | gsize len); 75 | GString* g_string_set_size (GString *string, 76 | gsize len); 77 | GString* g_string_insert_len (GString *string, 78 | gssize pos, 79 | const gchar *val, 80 | gssize len); 81 | GString* g_string_append (GString *string, 82 | const gchar *val); 83 | GString* g_string_append_len (GString *string, 84 | const gchar *val, 85 | gssize len); 86 | GString* g_string_append_c (GString *string, 87 | gchar c); 88 | GString* g_string_append_unichar (GString *string, 89 | gunichar wc); 90 | GString* g_string_prepend (GString *string, 91 | const gchar *val); 92 | GString* g_string_prepend_c (GString *string, 93 | gchar c); 94 | GString* g_string_prepend_unichar (GString *string, 95 | gunichar wc); 96 | GString* g_string_prepend_len (GString *string, 97 | const gchar *val, 98 | gssize len); 99 | GString* g_string_insert (GString *string, 100 | gssize pos, 101 | const gchar *val); 102 | GString* g_string_insert_c (GString *string, 103 | gssize pos, 104 | gchar c); 105 | GString* g_string_insert_unichar (GString *string, 106 | gssize pos, 107 | gunichar wc); 108 | GString* g_string_overwrite (GString *string, 109 | gsize pos, 110 | const gchar *val); 111 | GString* g_string_overwrite_len (GString *string, 112 | gsize pos, 113 | const gchar *val, 114 | gssize len); 115 | GString* g_string_erase (GString *string, 116 | gssize pos, 117 | gssize len); 118 | GString* g_string_ascii_down (GString *string); 119 | GString* g_string_ascii_up (GString *string); 120 | void g_string_vprintf (GString *string, 121 | const gchar *format, 122 | va_list args); 123 | void g_string_printf (GString *string, 124 | const gchar *format, 125 | ...) G_GNUC_PRINTF (2, 3); 126 | void g_string_append_vprintf (GString *string, 127 | const gchar *format, 128 | va_list args); 129 | void g_string_append_printf (GString *string, 130 | const gchar *format, 131 | ...) G_GNUC_PRINTF (2, 3); 132 | 133 | /* -- optimize g_strig_append_c --- */ 134 | #ifdef G_CAN_INLINE 135 | static inline GString* 136 | g_string_append_c_inline (GString *gstring, 137 | gchar c) 138 | { 139 | if (gstring->len + 1 < gstring->allocated_len) 140 | { 141 | gstring->str[gstring->len++] = c; 142 | gstring->str[gstring->len] = 0; 143 | } 144 | else 145 | g_string_insert_c (gstring, -1, c); 146 | return gstring; 147 | } 148 | #define g_string_append_c(gstr,c) g_string_append_c_inline (gstr, c) 149 | #endif /* G_CAN_INLINE */ 150 | 151 | 152 | #ifndef G_DISABLE_DEPRECATED 153 | 154 | /* The following two functions are deprecated and will be removed in 155 | * the next major release. They use the locale-specific tolower and 156 | * toupper, which is almost never the right thing. 157 | */ 158 | 159 | GString* g_string_down (GString *string); 160 | GString* g_string_up (GString *string); 161 | 162 | /* These aliases are included for compatibility. */ 163 | #define g_string_sprintf g_string_printf 164 | #define g_string_sprintfa g_string_append_printf 165 | 166 | #endif /* G_DISABLE_DEPRECATED */ 167 | 168 | G_END_DECLS 169 | 170 | #endif /* __G_STRING_H__ */ 171 | 172 | -------------------------------------------------------------------------------- /sdconv/include/glib/garray.h: -------------------------------------------------------------------------------- 1 | /* GLIB - Library of useful routines for C programming 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library 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 GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | /* 21 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22 | * file for a list of people on the GLib Team. See the ChangeLog 23 | * files for a list of changes. These files are distributed with 24 | * GLib at ftp://ftp.gtk.org/pub/gtk/. 25 | */ 26 | 27 | #ifndef __G_ARRAY_H__ 28 | #define __G_ARRAY_H__ 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | typedef struct _GArray GArray; 35 | typedef struct _GByteArray GByteArray; 36 | typedef struct _GPtrArray GPtrArray; 37 | 38 | struct _GArray 39 | { 40 | gchar *data; 41 | guint len; 42 | }; 43 | 44 | struct _GByteArray 45 | { 46 | guint8 *data; 47 | guint len; 48 | }; 49 | 50 | struct _GPtrArray 51 | { 52 | gpointer *pdata; 53 | guint len; 54 | }; 55 | 56 | /* Resizable arrays. remove fills any cleared spot and shortens the 57 | * array, while preserving the order. remove_fast will distort the 58 | * order by moving the last element to the position of the removed. 59 | */ 60 | 61 | #define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1) 62 | #define g_array_prepend_val(a,v) g_array_prepend_vals (a, &(v), 1) 63 | #define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1) 64 | #define g_array_index(a,t,i) (((t*) (a)->data) [(i)]) 65 | 66 | GArray* g_array_new (gboolean zero_terminated, 67 | gboolean clear_, 68 | guint element_size); 69 | GArray* g_array_sized_new (gboolean zero_terminated, 70 | gboolean clear_, 71 | guint element_size, 72 | guint reserved_size); 73 | gchar* g_array_free (GArray *array, 74 | gboolean free_segment); 75 | GArray* g_array_append_vals (GArray *array, 76 | gconstpointer data, 77 | guint len); 78 | GArray* g_array_prepend_vals (GArray *array, 79 | gconstpointer data, 80 | guint len); 81 | GArray* g_array_insert_vals (GArray *array, 82 | guint index_, 83 | gconstpointer data, 84 | guint len); 85 | GArray* g_array_set_size (GArray *array, 86 | guint length); 87 | GArray* g_array_remove_index (GArray *array, 88 | guint index_); 89 | GArray* g_array_remove_index_fast (GArray *array, 90 | guint index_); 91 | GArray* g_array_remove_range (GArray *array, 92 | guint index_, 93 | guint length); 94 | void g_array_sort (GArray *array, 95 | GCompareFunc compare_func); 96 | void g_array_sort_with_data (GArray *array, 97 | GCompareDataFunc compare_func, 98 | gpointer user_data); 99 | 100 | /* Resizable pointer array. This interface is much less complicated 101 | * than the above. Add appends a pointer. Remove fills any cleared 102 | * spot and shortens the array. remove_fast will again distort order. 103 | */ 104 | #define g_ptr_array_index(array,index_) ((array)->pdata)[index_] 105 | GPtrArray* g_ptr_array_new (void); 106 | GPtrArray* g_ptr_array_sized_new (guint reserved_size); 107 | gpointer* g_ptr_array_free (GPtrArray *array, 108 | gboolean free_seg); 109 | void g_ptr_array_set_size (GPtrArray *array, 110 | gint length); 111 | gpointer g_ptr_array_remove_index (GPtrArray *array, 112 | guint index_); 113 | gpointer g_ptr_array_remove_index_fast (GPtrArray *array, 114 | guint index_); 115 | gboolean g_ptr_array_remove (GPtrArray *array, 116 | gpointer data); 117 | gboolean g_ptr_array_remove_fast (GPtrArray *array, 118 | gpointer data); 119 | void g_ptr_array_remove_range (GPtrArray *array, 120 | guint index_, 121 | guint length); 122 | void g_ptr_array_add (GPtrArray *array, 123 | gpointer data); 124 | void g_ptr_array_sort (GPtrArray *array, 125 | GCompareFunc compare_func); 126 | void g_ptr_array_sort_with_data (GPtrArray *array, 127 | GCompareDataFunc compare_func, 128 | gpointer user_data); 129 | void g_ptr_array_foreach (GPtrArray *array, 130 | GFunc func, 131 | gpointer user_data); 132 | 133 | 134 | /* Byte arrays, an array of guint8. Implemented as a GArray, 135 | * but type-safe. 136 | */ 137 | 138 | GByteArray* g_byte_array_new (void); 139 | GByteArray* g_byte_array_sized_new (guint reserved_size); 140 | guint8* g_byte_array_free (GByteArray *array, 141 | gboolean free_segment); 142 | GByteArray* g_byte_array_append (GByteArray *array, 143 | const guint8 *data, 144 | guint len); 145 | GByteArray* g_byte_array_prepend (GByteArray *array, 146 | const guint8 *data, 147 | guint len); 148 | GByteArray* g_byte_array_set_size (GByteArray *array, 149 | guint length); 150 | GByteArray* g_byte_array_remove_index (GByteArray *array, 151 | guint index_); 152 | GByteArray* g_byte_array_remove_index_fast (GByteArray *array, 153 | guint index_); 154 | GByteArray* g_byte_array_remove_range (GByteArray *array, 155 | guint index_, 156 | guint length); 157 | void g_byte_array_sort (GByteArray *array, 158 | GCompareFunc compare_func); 159 | void g_byte_array_sort_with_data (GByteArray *array, 160 | GCompareDataFunc compare_func, 161 | gpointer user_data); 162 | 163 | 164 | G_END_DECLS 165 | 166 | #endif /* __G_ARRAY_H__ */ 167 | 168 | --------------------------------------------------------------------------------