diff options
Diffstat (limited to 'src/mac.c')
| -rw-r--r-- | src/mac.c | 125 |
1 files changed, 49 insertions, 76 deletions
| @@ -28,7 +28,9 @@ Boston, MA 02110-1301, USA. */ | |||
| 28 | 28 | ||
| 29 | #include "lisp.h" | 29 | #include "lisp.h" |
| 30 | #include "process.h" | 30 | #include "process.h" |
| 31 | #undef init_process | 31 | #ifdef MAC_OSX |
| 32 | #undef select | ||
| 33 | #endif | ||
| 32 | #include "systime.h" | 34 | #include "systime.h" |
| 33 | #include "sysselect.h" | 35 | #include "sysselect.h" |
| 34 | #include "blockinput.h" | 36 | #include "blockinput.h" |
| @@ -79,8 +81,10 @@ static ComponentInstance as_scripting_component; | |||
| 79 | /* The single script context used for all script executions. */ | 81 | /* The single script context used for all script executions. */ |
| 80 | static OSAID as_script_context; | 82 | static OSAID as_script_context; |
| 81 | 83 | ||
| 84 | #ifndef MAC_OSX | ||
| 82 | static OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *)); | 85 | static OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *)); |
| 83 | static OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int)); | 86 | static OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int)); |
| 87 | #endif | ||
| 84 | 88 | ||
| 85 | /* When converting from Mac to Unix pathnames, /'s in folder names are | 89 | /* When converting from Mac to Unix pathnames, /'s in folder names are |
| 86 | converted to :'s. This function, used in copying folder names, | 90 | converted to :'s. This function, used in copying folder names, |
| @@ -449,15 +453,10 @@ mac_coerce_file_name_ptr (type_code, data_ptr, data_size, | |||
| 449 | char *buf; | 453 | char *buf; |
| 450 | 454 | ||
| 451 | buf = xmalloc (data_size + 1); | 455 | buf = xmalloc (data_size + 1); |
| 452 | if (buf) | 456 | memcpy (buf, data_ptr, data_size); |
| 453 | { | 457 | buf[data_size] = '\0'; |
| 454 | memcpy (buf, data_ptr, data_size); | 458 | err = posix_pathname_to_fsspec (buf, &fs); |
| 455 | buf[data_size] = '\0'; | 459 | xfree (buf); |
| 456 | err = posix_pathname_to_fsspec (buf, &fs); | ||
| 457 | xfree (buf); | ||
| 458 | } | ||
| 459 | else | ||
| 460 | err = memFullErr; | ||
| 461 | if (err == noErr) | 460 | if (err == noErr) |
| 462 | err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result); | 461 | err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result); |
| 463 | #endif | 462 | #endif |
| @@ -485,14 +484,11 @@ mac_coerce_file_name_ptr (type_code, data_ptr, data_size, | |||
| 485 | { | 484 | { |
| 486 | size = AEGetDescDataSize (&desc); | 485 | size = AEGetDescDataSize (&desc); |
| 487 | buf = xmalloc (size); | 486 | buf = xmalloc (size); |
| 488 | if (buf) | 487 | err = AEGetDescData (&desc, buf, size); |
| 489 | { | 488 | if (err == noErr) |
| 490 | err = AEGetDescData (&desc, buf, size); | 489 | url = CFURLCreateWithBytes (NULL, buf, size, |
| 491 | if (err == noErr) | 490 | kCFStringEncodingUTF8, NULL); |
| 492 | url = CFURLCreateWithBytes (NULL, buf, size, | 491 | xfree (buf); |
| 493 | kCFStringEncodingUTF8, NULL); | ||
| 494 | xfree (buf); | ||
| 495 | } | ||
| 496 | AEDisposeDesc (&desc); | 492 | AEDisposeDesc (&desc); |
| 497 | } | 493 | } |
| 498 | } | 494 | } |
| @@ -577,21 +573,16 @@ mac_coerce_file_name_desc (from_desc, to_type, handler_refcon, result) | |||
| 577 | data_size = GetHandleSize (from_desc->dataHandle); | 573 | data_size = GetHandleSize (from_desc->dataHandle); |
| 578 | #endif | 574 | #endif |
| 579 | data_ptr = xmalloc (data_size); | 575 | data_ptr = xmalloc (data_size); |
| 580 | if (data_ptr) | ||
| 581 | { | ||
| 582 | #if TARGET_API_MAC_CARBON | 576 | #if TARGET_API_MAC_CARBON |
| 583 | err = AEGetDescData (from_desc, data_ptr, data_size); | 577 | err = AEGetDescData (from_desc, data_ptr, data_size); |
| 584 | #else | 578 | #else |
| 585 | memcpy (data_ptr, *(from_desc->dataHandle), data_size); | 579 | memcpy (data_ptr, *(from_desc->dataHandle), data_size); |
| 586 | #endif | 580 | #endif |
| 587 | if (err == noErr) | 581 | if (err == noErr) |
| 588 | err = mac_coerce_file_name_ptr (from_type, data_ptr, | 582 | err = mac_coerce_file_name_ptr (from_type, data_ptr, |
| 589 | data_size, to_type, | 583 | data_size, to_type, |
| 590 | handler_refcon, result); | 584 | handler_refcon, result); |
| 591 | xfree (data_ptr); | 585 | xfree (data_ptr); |
| 592 | } | ||
| 593 | else | ||
| 594 | err = memFullErr; | ||
| 595 | } | 586 | } |
| 596 | 587 | ||
| 597 | if (err != noErr) | 588 | if (err != noErr) |
| @@ -687,8 +678,6 @@ create_apple_event_from_event_ref (event, num_params, names, types, result) | |||
| 687 | if (err != noErr) | 678 | if (err != noErr) |
| 688 | break; | 679 | break; |
| 689 | buf = xmalloc (size); | 680 | buf = xmalloc (size); |
| 690 | if (buf == NULL) | ||
| 691 | break; | ||
| 692 | err = GetEventParameter (event, names[i], types[i], NULL, | 681 | err = GetEventParameter (event, names[i], types[i], NULL, |
| 693 | size, NULL, buf); | 682 | size, NULL, buf); |
| 694 | if (err == noErr) | 683 | if (err == noErr) |
| @@ -1222,7 +1211,7 @@ parse_value (p) | |||
| 1222 | && '0' <= P[1] && P[1] <= '7' | 1211 | && '0' <= P[1] && P[1] <= '7' |
| 1223 | && '0' <= P[2] && P[2] <= '7') | 1212 | && '0' <= P[2] && P[2] <= '7') |
| 1224 | { | 1213 | { |
| 1225 | *q++ = (P[0] - '0' << 6) + (P[1] - '0' << 3) + (P[2] - '0'); | 1214 | *q++ = ((P[0] - '0') << 6) + ((P[1] - '0') << 3) + (P[2] - '0'); |
| 1226 | P += 3; | 1215 | P += 3; |
| 1227 | } | 1216 | } |
| 1228 | else | 1217 | else |
| @@ -1592,8 +1581,6 @@ xrm_get_preference_database (application) | |||
| 1592 | 1581 | ||
| 1593 | count = CFSetGetCount (key_set); | 1582 | count = CFSetGetCount (key_set); |
| 1594 | keys = xmalloc (sizeof (CFStringRef) * count); | 1583 | keys = xmalloc (sizeof (CFStringRef) * count); |
| 1595 | if (keys == NULL) | ||
| 1596 | goto out; | ||
| 1597 | CFSetGetValues (key_set, (const void **)keys); | 1584 | CFSetGetValues (key_set, (const void **)keys); |
| 1598 | for (index = 0; index < count; index++) | 1585 | for (index = 0; index < count; index++) |
| 1599 | { | 1586 | { |
| @@ -2789,7 +2776,7 @@ link (const char *name1, const char *name2) | |||
| 2789 | /* Determine the path name of the file specified by VREFNUM, DIRID, | 2776 | /* Determine the path name of the file specified by VREFNUM, DIRID, |
| 2790 | and NAME and place that in the buffer PATH of length | 2777 | and NAME and place that in the buffer PATH of length |
| 2791 | MAXPATHLEN. */ | 2778 | MAXPATHLEN. */ |
| 2792 | int | 2779 | static int |
| 2793 | path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num, | 2780 | path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num, |
| 2794 | long dir_id, ConstStr255Param name) | 2781 | long dir_id, ConstStr255Param name) |
| 2795 | { | 2782 | { |
| @@ -2834,6 +2821,8 @@ path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num, | |||
| 2834 | } | 2821 | } |
| 2835 | 2822 | ||
| 2836 | 2823 | ||
| 2824 | #ifndef MAC_OSX | ||
| 2825 | |||
| 2837 | static OSErr | 2826 | static OSErr |
| 2838 | posix_pathname_to_fsspec (ufn, fs) | 2827 | posix_pathname_to_fsspec (ufn, fs) |
| 2839 | const char *ufn; | 2828 | const char *ufn; |
| @@ -2866,8 +2855,6 @@ fsspec_to_posix_pathname (fs, ufn, ufnbuflen) | |||
| 2866 | return fnfErr; | 2855 | return fnfErr; |
| 2867 | } | 2856 | } |
| 2868 | 2857 | ||
| 2869 | #ifndef MAC_OSX | ||
| 2870 | |||
| 2871 | int | 2858 | int |
| 2872 | readlink (const char *path, char *buf, int bufsiz) | 2859 | readlink (const char *path, char *buf, int bufsiz) |
| 2873 | { | 2860 | { |
| @@ -3124,8 +3111,7 @@ get_temp_dir_name () | |||
| 3124 | short vol_ref_num; | 3111 | short vol_ref_num; |
| 3125 | long dir_id; | 3112 | long dir_id; |
| 3126 | OSErr err; | 3113 | OSErr err; |
| 3127 | Str255 dir_name, full_path; | 3114 | Str255 full_path; |
| 3128 | CInfoPBRec cpb; | ||
| 3129 | char unix_dir_name[MAXPATHLEN+1]; | 3115 | char unix_dir_name[MAXPATHLEN+1]; |
| 3130 | DIR *dir; | 3116 | DIR *dir; |
| 3131 | 3117 | ||
| @@ -3217,8 +3203,7 @@ get_path_to_system_folder () | |||
| 3217 | short vol_ref_num; | 3203 | short vol_ref_num; |
| 3218 | long dir_id; | 3204 | long dir_id; |
| 3219 | OSErr err; | 3205 | OSErr err; |
| 3220 | Str255 dir_name, full_path; | 3206 | Str255 full_path; |
| 3221 | CInfoPBRec cpb; | ||
| 3222 | static char system_folder_unix_name[MAXPATHLEN+1]; | 3207 | static char system_folder_unix_name[MAXPATHLEN+1]; |
| 3223 | DIR *dir; | 3208 | DIR *dir; |
| 3224 | 3209 | ||
| @@ -3947,7 +3932,6 @@ DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1, | |||
| 3947 | #else | 3932 | #else |
| 3948 | FSSpec fss; | 3933 | FSSpec fss; |
| 3949 | #endif | 3934 | #endif |
| 3950 | OSType cCode; | ||
| 3951 | Lisp_Object result = Qnil; | 3935 | Lisp_Object result = Qnil; |
| 3952 | CHECK_STRING (filename); | 3936 | CHECK_STRING (filename); |
| 3953 | 3937 | ||
| @@ -4002,7 +3986,6 @@ DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0, | |||
| 4002 | #else | 3986 | #else |
| 4003 | FSSpec fss; | 3987 | FSSpec fss; |
| 4004 | #endif | 3988 | #endif |
| 4005 | OSType cCode; | ||
| 4006 | Lisp_Object result = Qnil; | 3989 | Lisp_Object result = Qnil; |
| 4007 | CHECK_STRING (filename); | 3990 | CHECK_STRING (filename); |
| 4008 | 3991 | ||
| @@ -4296,11 +4279,6 @@ Each type should be a string of length 4 or the symbol | |||
| 4296 | Lisp_Object result = Qnil; | 4279 | Lisp_Object result = Qnil; |
| 4297 | DescType src_desc_type, dst_desc_type; | 4280 | DescType src_desc_type, dst_desc_type; |
| 4298 | AEDesc dst_desc; | 4281 | AEDesc dst_desc; |
| 4299 | #ifdef MAC_OSX | ||
| 4300 | FSRef fref; | ||
| 4301 | #else | ||
| 4302 | FSSpec fs; | ||
| 4303 | #endif | ||
| 4304 | 4282 | ||
| 4305 | CHECK_STRING (src_data); | 4283 | CHECK_STRING (src_data); |
| 4306 | if (EQ (src_type, Qundecoded_file_name)) | 4284 | if (EQ (src_type, Qundecoded_file_name)) |
| @@ -4422,18 +4400,20 @@ otherwise. */) | |||
| 4422 | } | 4400 | } |
| 4423 | 4401 | ||
| 4424 | if (NILP (key)) | 4402 | if (NILP (key)) |
| 4425 | if (EQ (format, Qxml)) | 4403 | { |
| 4426 | { | 4404 | if (EQ (format, Qxml)) |
| 4427 | CFDataRef data = CFPropertyListCreateXMLData (NULL, plist); | 4405 | { |
| 4428 | if (data == NULL) | 4406 | CFDataRef data = CFPropertyListCreateXMLData (NULL, plist); |
| 4429 | goto out; | 4407 | if (data == NULL) |
| 4430 | result = cfdata_to_lisp (data); | 4408 | goto out; |
| 4431 | CFRelease (data); | 4409 | result = cfdata_to_lisp (data); |
| 4432 | } | 4410 | CFRelease (data); |
| 4433 | else | 4411 | } |
| 4434 | result = | 4412 | else |
| 4435 | cfproperty_list_to_lisp (plist, EQ (format, Qt), | 4413 | result = |
| 4436 | NILP (hash_bound) ? -1 : XINT (hash_bound)); | 4414 | cfproperty_list_to_lisp (plist, EQ (format, Qt), |
| 4415 | NILP (hash_bound) ? -1 : XINT (hash_bound)); | ||
| 4416 | } | ||
| 4437 | 4417 | ||
| 4438 | out: | 4418 | out: |
| 4439 | if (app_plist) | 4419 | if (app_plist) |
| @@ -4550,11 +4530,8 @@ cfstring_create_normalized (str, symbol) | |||
| 4550 | if (in_text == NULL) | 4530 | if (in_text == NULL) |
| 4551 | { | 4531 | { |
| 4552 | buffer = xmalloc (sizeof (UniChar) * length); | 4532 | buffer = xmalloc (sizeof (UniChar) * length); |
| 4553 | if (buffer) | 4533 | CFStringGetCharacters (str, CFRangeMake (0, length), buffer); |
| 4554 | { | 4534 | in_text = buffer; |
| 4555 | CFStringGetCharacters (str, CFRangeMake (0, length), buffer); | ||
| 4556 | in_text = buffer; | ||
| 4557 | } | ||
| 4558 | } | 4535 | } |
| 4559 | 4536 | ||
| 4560 | if (in_text) | 4537 | if (in_text) |
| @@ -4562,15 +4539,12 @@ cfstring_create_normalized (str, symbol) | |||
| 4562 | while (err == noErr) | 4539 | while (err == noErr) |
| 4563 | { | 4540 | { |
| 4564 | out_buf = xmalloc (out_size); | 4541 | out_buf = xmalloc (out_size); |
| 4565 | if (out_buf == NULL) | 4542 | err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar), |
| 4566 | err = mFulErr; | 4543 | in_text, |
| 4567 | else | 4544 | kUnicodeDefaultDirectionMask, |
| 4568 | err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar), | 4545 | 0, NULL, NULL, NULL, |
| 4569 | in_text, | 4546 | out_size, &out_read, &out_len, |
| 4570 | kUnicodeDefaultDirectionMask, | 4547 | out_buf); |
| 4571 | 0, NULL, NULL, NULL, | ||
| 4572 | out_size, &out_read, &out_len, | ||
| 4573 | out_buf); | ||
| 4574 | if (err == noErr && out_read < length * sizeof (UniChar)) | 4548 | if (err == noErr && out_read < length * sizeof (UniChar)) |
| 4575 | { | 4549 | { |
| 4576 | xfree (out_buf); | 4550 | xfree (out_buf); |
| @@ -4701,7 +4675,6 @@ mac_get_system_locale () | |||
| 4701 | 4675 | ||
| 4702 | 4676 | ||
| 4703 | #ifdef MAC_OSX | 4677 | #ifdef MAC_OSX |
| 4704 | #undef select | ||
| 4705 | 4678 | ||
| 4706 | extern int inhibit_window_system; | 4679 | extern int inhibit_window_system; |
| 4707 | extern int noninteractive; | 4680 | extern int noninteractive; |