aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mac.c')
-rw-r--r--src/mac.c98
1 files changed, 76 insertions, 22 deletions
diff --git a/src/mac.c b/src/mac.c
index cce1b858cb3..44d763562b0 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -25,20 +25,8 @@ Boston, MA 02111-1307, USA. */
25#include <stdio.h> 25#include <stdio.h>
26#include <errno.h> 26#include <errno.h>
27#include <time.h> 27#include <time.h>
28#include <utime.h>
29#include <dirent.h>
30#include <sys/types.h>
31#include <sys/stat.h>
32#include <string.h>
33#include <pwd.h>
34#include <grp.h>
35#include <sys/param.h>
36#include <stdlib.h>
37#include <fcntl.h>
38#if __MWERKS__
39#include <unistd.h>
40#endif
41 28
29#ifdef HAVE_CARBON
42#ifdef MAC_OSX 30#ifdef MAC_OSX
43#undef mktime 31#undef mktime
44#undef DEBUG 32#undef DEBUG
@@ -57,7 +45,12 @@ Boston, MA 02111-1307, USA. */
57#define realloc unexec_realloc 45#define realloc unexec_realloc
58#undef init_process 46#undef init_process
59#define init_process emacs_init_process 47#define init_process emacs_init_process
60#else /* not MAC_OSX */ 48#else /* not MAC_OSX */
49#undef SIGHUP
50#define OLDP2C 1
51#include <Carbon.h>
52#endif /* not MAC_OSX */
53#else /* not HAVE_CARBON */
61#include <Files.h> 54#include <Files.h>
62#include <MacTypes.h> 55#include <MacTypes.h>
63#include <TextUtils.h> 56#include <TextUtils.h>
@@ -69,7 +62,24 @@ Boston, MA 02111-1307, USA. */
69#include <OSA.h> 62#include <OSA.h>
70#include <AppleScript.h> 63#include <AppleScript.h>
71#include <Scrap.h> 64#include <Scrap.h>
72#endif /* not MAC_OSX */ 65#include <Events.h>
66#include <Processes.h>
67#include <EPPC.h>
68#endif /* not HAVE_CARBON */
69
70#include <utime.h>
71#include <dirent.h>
72#include <sys/types.h>
73#include <sys/stat.h>
74#include <string.h>
75#include <pwd.h>
76#include <grp.h>
77#include <sys/param.h>
78#include <stdlib.h>
79#include <fcntl.h>
80#if __MWERKS__
81#include <unistd.h>
82#endif
73 83
74#include "lisp.h" 84#include "lisp.h"
75#include "process.h" 85#include "process.h"
@@ -812,8 +822,6 @@ sys_fopen (const char *name, const char *mode)
812} 822}
813 823
814 824
815#include <Events.h>
816
817long target_ticks = 0; 825long target_ticks = 0;
818 826
819#ifdef __MRC__ 827#ifdef __MRC__
@@ -856,7 +864,24 @@ select (n, rfds, wfds, efds, timeout)
856 struct timeval *timeout; 864 struct timeval *timeout;
857{ 865{
858#if TARGET_API_MAC_CARBON 866#if TARGET_API_MAC_CARBON
859 return 1; 867 OSErr err;
868 EventTimeout timeout_sec =
869 (timeout
870 ? (EMACS_SECS (*timeout) * kEventDurationSecond
871 + EMACS_USECS (*timeout) * kEventDurationMicrosecond)
872 : kEventDurationForever);
873
874 if (FD_ISSET (0, rfds))
875 {
876 BLOCK_INPUT;
877 err = ReceiveNextEvent (0, NULL, timeout_sec, kEventLeaveInQueue, NULL);
878 UNBLOCK_INPUT;
879 if (err == noErr)
880 return 1;
881 else
882 FD_ZERO (rfds);
883 }
884 return 0;
860#else /* not TARGET_API_MAC_CARBON */ 885#else /* not TARGET_API_MAC_CARBON */
861 EventRecord e; 886 EventRecord e;
862 UInt32 sleep_time = EMACS_SECS (*timeout) * 60 + 887 UInt32 sleep_time = EMACS_SECS (*timeout) * 60 +
@@ -1421,6 +1446,39 @@ path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num,
1421 return 1; /* success */ 1446 return 1; /* success */
1422} 1447}
1423 1448
1449
1450OSErr
1451posix_pathname_to_fsspec (ufn, fs)
1452 const char *ufn;
1453 FSSpec *fs;
1454{
1455 Str255 mac_pathname;
1456
1457 if (posix_to_mac_pathname (ufn, mac_pathname, sizeof (mac_pathname)) == 0)
1458 return fnfErr;
1459 else
1460 {
1461 c2pstr (mac_pathname);
1462 return FSMakeFSSpec (0, 0, mac_pathname, fs);
1463 }
1464}
1465
1466OSErr
1467fsspec_to_posix_pathname (fs, ufn, ufnbuflen)
1468 const FSSpec *fs;
1469 char *ufn;
1470 int ufnbuflen;
1471{
1472 char mac_pathname[MAXPATHLEN];
1473
1474 if (path_from_vol_dir_name (mac_pathname, sizeof (mac_pathname) - 1,
1475 fs->vRefNum, fs->parID, fs->name)
1476 && mac_to_posix_pathname (mac_pathname, ufn, ufnbuflen))
1477 return noErr;
1478 else
1479 return fnfErr;
1480}
1481
1424#ifndef MAC_OSX 1482#ifndef MAC_OSX
1425 1483
1426int 1484int
@@ -1899,9 +1957,6 @@ uname (struct utsname *name)
1899} 1957}
1900 1958
1901 1959
1902#include <Processes.h>
1903#include <EPPC.h>
1904
1905/* Event class of HLE sent to subprocess. */ 1960/* Event class of HLE sent to subprocess. */
1906const OSType kEmacsSubprocessSend = 'ESND'; 1961const OSType kEmacsSubprocessSend = 'ESND';
1907 1962
@@ -2770,7 +2825,6 @@ and t is the same as `SECONDARY'. */)
2770 return Qnil; 2825 return Qnil;
2771} 2826}
2772 2827
2773extern void mac_clear_font_name_table P_ ((void));
2774 2828
2775DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0, 2829DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0,
2776 doc: /* Clear the font name table. */) 2830 doc: /* Clear the font name table. */)