Mercurial > emacs
comparison src/mac.c @ 90208:890cc78a5a24
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-74
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 493-503)
- Update from CVS
- Update from CVS: lisp/startup.el (command-line): Fix typo.
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 95-98)
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 29 Jul 2005 01:54:54 +0000 |
parents | 187d6a1f84f7 b9746f88defa |
children | 2d92f5c9d6ae |
comparison
equal
deleted
inserted
replaced
90207:43ea22612328 | 90208:890cc78a5a24 |
---|---|
57 | 57 |
58 #include <utime.h> | 58 #include <utime.h> |
59 #include <dirent.h> | 59 #include <dirent.h> |
60 #include <sys/types.h> | 60 #include <sys/types.h> |
61 #include <sys/stat.h> | 61 #include <sys/stat.h> |
62 #include <string.h> | |
63 #include <pwd.h> | 62 #include <pwd.h> |
64 #include <grp.h> | 63 #include <grp.h> |
65 #include <sys/param.h> | 64 #include <sys/param.h> |
66 #include <stdlib.h> | |
67 #include <fcntl.h> | 65 #include <fcntl.h> |
68 #if __MWERKS__ | 66 #if __MWERKS__ |
69 #include <unistd.h> | 67 #include <unistd.h> |
70 #endif | 68 #endif |
71 | 69 |
3445 } | 3443 } |
3446 | 3444 |
3447 | 3445 |
3448 DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1, 1, 0, | 3446 DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1, 1, 0, |
3449 doc: /* Get the creator code of FILENAME as a four character string. */) | 3447 doc: /* Get the creator code of FILENAME as a four character string. */) |
3450 (filename) | 3448 (filename) |
3451 Lisp_Object filename; | 3449 Lisp_Object filename; |
3452 { | 3450 { |
3453 OSErr status; | 3451 OSErr status; |
3454 #ifdef MAC_OSX | 3452 #ifdef MAC_OSX |
3455 FSRef fref; | 3453 FSRef fref; |
3500 return result; | 3498 return result; |
3501 } | 3499 } |
3502 | 3500 |
3503 DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0, | 3501 DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0, |
3504 doc: /* Get the type code of FILENAME as a four character string. */) | 3502 doc: /* Get the type code of FILENAME as a four character string. */) |
3505 (filename) | 3503 (filename) |
3506 Lisp_Object filename; | 3504 Lisp_Object filename; |
3507 { | 3505 { |
3508 OSErr status; | 3506 OSErr status; |
3509 #ifdef MAC_OSX | 3507 #ifdef MAC_OSX |
3510 FSRef fref; | 3508 FSRef fref; |
3557 | 3555 |
3558 DEFUN ("mac-set-file-creator", Fmac_set_file_creator, Smac_set_file_creator, 1, 2, 0, | 3556 DEFUN ("mac-set-file-creator", Fmac_set_file_creator, Smac_set_file_creator, 1, 2, 0, |
3559 doc: /* Set creator code of file FILENAME to CODE. | 3557 doc: /* Set creator code of file FILENAME to CODE. |
3560 If non-nil, CODE must be a 4-character string. Otherwise, 'EMAx' is | 3558 If non-nil, CODE must be a 4-character string. Otherwise, 'EMAx' is |
3561 assumed. Return non-nil if successful. */) | 3559 assumed. Return non-nil if successful. */) |
3562 (filename, code) | 3560 (filename, code) |
3563 Lisp_Object filename, code; | 3561 Lisp_Object filename, code; |
3564 { | 3562 { |
3565 OSErr status; | 3563 OSErr status; |
3566 #ifdef MAC_OSX | 3564 #ifdef MAC_OSX |
3567 FSRef fref; | 3565 FSRef fref; |
3617 } | 3615 } |
3618 | 3616 |
3619 DEFUN ("mac-set-file-type", Fmac_set_file_type, Smac_set_file_type, 2, 2, 0, | 3617 DEFUN ("mac-set-file-type", Fmac_set_file_type, Smac_set_file_type, 2, 2, 0, |
3620 doc: /* Set file code of file FILENAME to CODE. | 3618 doc: /* Set file code of file FILENAME to CODE. |
3621 CODE must be a 4-character string. Return non-nil if successful. */) | 3619 CODE must be a 4-character string. Return non-nil if successful. */) |
3622 (filename, code) | 3620 (filename, code) |
3623 Lisp_Object filename, code; | 3621 Lisp_Object filename, code; |
3624 { | 3622 { |
3625 OSErr status; | 3623 OSErr status; |
3626 #ifdef MAC_OSX | 3624 #ifdef MAC_OSX |
3627 FSRef fref; | 3625 FSRef fref; |
3764 return osaerror; | 3762 return osaerror; |
3765 } | 3763 } |
3766 | 3764 |
3767 | 3765 |
3768 DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0, | 3766 DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0, |
3769 doc: /* Compile and execute AppleScript SCRIPT and retrieve and return the result. | 3767 doc: /* Compile and execute AppleScript SCRIPT and return the result. |
3770 If compilation and execution are successful, the resulting script | 3768 If compilation and execution are successful, the resulting script |
3771 value is returned as a string. Otherwise the function aborts and | 3769 value is returned as a string. Otherwise the function aborts and |
3772 displays the error message returned by the AppleScript scripting | 3770 displays the error message returned by the AppleScript scripting |
3773 component. */) | 3771 component. */) |
3774 (script) | 3772 (script) |
3775 Lisp_Object script; | 3773 Lisp_Object script; |
3776 { | 3774 { |
3777 char *result, *temp; | 3775 char *result, *temp; |
3778 Lisp_Object lisp_result; | 3776 Lisp_Object lisp_result; |
3779 long status; | 3777 long status; |
3809 } | 3807 } |
3810 | 3808 |
3811 | 3809 |
3812 DEFUN ("mac-file-name-to-posix", Fmac_file_name_to_posix, | 3810 DEFUN ("mac-file-name-to-posix", Fmac_file_name_to_posix, |
3813 Smac_file_name_to_posix, 1, 1, 0, | 3811 Smac_file_name_to_posix, 1, 1, 0, |
3814 doc: /* Convert Macintosh filename to Posix form. */) | 3812 doc: /* Convert Macintosh FILENAME to Posix form. */) |
3815 (mac_filename) | 3813 (filename) |
3816 Lisp_Object mac_filename; | 3814 Lisp_Object filename; |
3817 { | 3815 { |
3818 char posix_filename[MAXPATHLEN+1]; | 3816 char posix_filename[MAXPATHLEN+1]; |
3819 | 3817 |
3820 CHECK_STRING (mac_filename); | 3818 CHECK_STRING (filename); |
3821 | 3819 |
3822 if (mac_to_posix_pathname (SDATA (mac_filename), posix_filename, | 3820 if (mac_to_posix_pathname (SDATA (filename), posix_filename, MAXPATHLEN)) |
3823 MAXPATHLEN)) | |
3824 return build_string (posix_filename); | 3821 return build_string (posix_filename); |
3825 else | 3822 else |
3826 return Qnil; | 3823 return Qnil; |
3827 } | 3824 } |
3828 | 3825 |
3829 | 3826 |
3830 DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac, | 3827 DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac, |
3831 Sposix_file_name_to_mac, 1, 1, 0, | 3828 Sposix_file_name_to_mac, 1, 1, 0, |
3832 doc: /* Convert Posix filename to Mac form. */) | 3829 doc: /* Convert Posix FILENAME to Mac form. */) |
3833 (posix_filename) | 3830 (filename) |
3834 Lisp_Object posix_filename; | 3831 Lisp_Object filename; |
3835 { | 3832 { |
3836 char mac_filename[MAXPATHLEN+1]; | 3833 char mac_filename[MAXPATHLEN+1]; |
3837 | 3834 |
3838 CHECK_STRING (posix_filename); | 3835 CHECK_STRING (filename); |
3839 | 3836 |
3840 if (posix_to_mac_pathname (SDATA (posix_filename), mac_filename, | 3837 if (posix_to_mac_pathname (SDATA (filename), mac_filename, MAXPATHLEN)) |
3841 MAXPATHLEN)) | |
3842 return build_string (mac_filename); | 3838 return build_string (mac_filename); |
3843 else | 3839 else |
3844 return Qnil; | 3840 return Qnil; |
3845 } | 3841 } |
3846 | 3842 |
3851 | 3847 |
3852 DEFUN ("mac-get-preference", Fmac_get_preference, Smac_get_preference, 1, 4, 0, | 3848 DEFUN ("mac-get-preference", Fmac_get_preference, Smac_get_preference, 1, 4, 0, |
3853 doc: /* Return the application preference value for KEY. | 3849 doc: /* Return the application preference value for KEY. |
3854 KEY is either a string specifying a preference key, or a list of key | 3850 KEY is either a string specifying a preference key, or a list of key |
3855 strings. If it is a list, the (i+1)-th element is used as a key for | 3851 strings. If it is a list, the (i+1)-th element is used as a key for |
3856 the CFDictionary value obtained by the i-th element. If lookup is | 3852 the CFDictionary value obtained by the i-th element. Return nil if |
3857 failed at some stage, nil is returned. | 3853 lookup is failed at some stage. |
3858 | 3854 |
3859 Optional arg APPLICATION is an application ID string. If omitted or | 3855 Optional arg APPLICATION is an application ID string. If omitted or |
3860 nil, that stands for the current application. | 3856 nil, that stands for the current application. |
3861 | 3857 |
3862 Optional arg FORMAT specifies the data format of the return value. If | 3858 Optional arg FORMAT specifies the data format of the return value. If |
3883 alists or hash tables, are used as the targets of the conversion from | 3879 alists or hash tables, are used as the targets of the conversion from |
3884 CFDictionary. If HASH-BOUND is a negative integer or nil, always | 3880 CFDictionary. If HASH-BOUND is a negative integer or nil, always |
3885 generate alists. If HASH-BOUND >= 0, generate an alist if the number | 3881 generate alists. If HASH-BOUND >= 0, generate an alist if the number |
3886 of keys in the dictionary is smaller than HASH-BOUND, and a hash table | 3882 of keys in the dictionary is smaller than HASH-BOUND, and a hash table |
3887 otherwise. */) | 3883 otherwise. */) |
3888 (key, application, format, hash_bound) | 3884 (key, application, format, hash_bound) |
3889 Lisp_Object key, application, format, hash_bound; | 3885 Lisp_Object key, application, format, hash_bound; |
3890 { | 3886 { |
3891 CFStringRef app_id, key_str; | 3887 CFStringRef app_id, key_str; |
3892 CFPropertyListRef app_plist = NULL, plist; | 3888 CFPropertyListRef app_plist = NULL, plist; |
3893 Lisp_Object result = Qnil, tmp; | 3889 Lisp_Object result = Qnil, tmp; |
4120 Each encoding is specified by either a coding system symbol, a mime | 4116 Each encoding is specified by either a coding system symbol, a mime |
4121 charset string, or an integer as a CFStringEncoding value. | 4117 charset string, or an integer as a CFStringEncoding value. |
4122 On Mac OS X 10.2 and later, you can do Unicode Normalization by | 4118 On Mac OS X 10.2 and later, you can do Unicode Normalization by |
4123 specifying the optional argument NORMALIZATION-FORM with a symbol NFD, | 4119 specifying the optional argument NORMALIZATION-FORM with a symbol NFD, |
4124 NFKD, NFC, NFKC, HFS+D, or HFS+C. | 4120 NFKD, NFC, NFKC, HFS+D, or HFS+C. |
4125 On successful conversion, returns the result string, else returns | 4121 On successful conversion, return the result string, else return nil. */) |
4126 nil. */) | 4122 (string, source, target, normalization_form) |
4127 (string, source, target, normalization_form) | |
4128 Lisp_Object string, source, target, normalization_form; | 4123 Lisp_Object string, source, target, normalization_form; |
4129 { | 4124 { |
4130 Lisp_Object result = Qnil; | 4125 Lisp_Object result = Qnil; |
4131 CFStringEncoding src_encoding, tgt_encoding; | 4126 CFStringEncoding src_encoding, tgt_encoding; |
4132 CFStringRef str = NULL; | 4127 CFStringRef str = NULL; |
4181 #endif /* TARGET_API_MAC_CARBON */ | 4176 #endif /* TARGET_API_MAC_CARBON */ |
4182 | 4177 |
4183 | 4178 |
4184 DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0, | 4179 DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0, |
4185 doc: /* Clear the font name table. */) | 4180 doc: /* Clear the font name table. */) |
4186 () | 4181 () |
4187 { | 4182 { |
4188 check_mac (); | 4183 check_mac (); |
4189 mac_clear_font_name_table (); | 4184 mac_clear_font_name_table (); |
4190 return Qnil; | 4185 return Qnil; |
4191 } | 4186 } |
4481 | 4476 |
4482 /* Fetch the pathname of the application bundle as a C string into | 4477 /* Fetch the pathname of the application bundle as a C string into |
4483 app_bundle_pathname. */ | 4478 app_bundle_pathname. */ |
4484 | 4479 |
4485 bundle = CFBundleGetMainBundle (); | 4480 bundle = CFBundleGetMainBundle (); |
4486 if (!bundle) | 4481 if (!bundle || CFBundleGetIdentifier (bundle) == NULL) |
4487 return; | 4482 { |
4483 /* We could not find the bundle identifier. For now, prevent | |
4484 the fatal error by bringing it up in the terminal. */ | |
4485 inhibit_window_system = 1; | |
4486 return; | |
4487 } | |
4488 | 4488 |
4489 bundleURL = CFBundleCopyBundleURL (bundle); | 4489 bundleURL = CFBundleCopyBundleURL (bundle); |
4490 if (!bundleURL) | 4490 if (!bundleURL) |
4491 return; | 4491 return; |
4492 | 4492 |