ReactOS 0.4.16-dev-340-g0540c21
mwerks_console_OS_X.c File Reference
#include <ansi_parms.h>
#include <size_t.h>
#include <console.h>
#include <unistd.h>
#include <Carbon.h>
Include dependency graph for mwerks_console_OS_X.c:

Go to the source code of this file.

Typedefs

typedef int(* ReadPtr) (int, void *, __std(size_t))
 
typedef int(* WritePtr) (int, const void *, __std(size_t))
 

Functions

static OSErr __msl_CreateFrameworkBundleFromName (CFStringRef theFrameworkName, CFBundleRef *theBundle)
 
short InstallConsole (short fd)
 
void RemoveConsole (void)
 
long WriteCharsToConsole (char *buffer, long n)
 
long ReadCharsFromConsole (char *buffer, long n)
 
char__ttyname (long fildes)
 
int kbhit (void)
 
int getch (void)
 
void clrscr ()
 

Variables

struct {
   Boolean   isLoaded
 
   CFBundleRef   theBundle
 
   ReadPtr   theRead
 
   WritePtr   theWrite
 
__msl_os_x
 

Typedef Documentation

◆ ReadPtr

typedef int(* ReadPtr) (int, void *, __std(size_t))

Definition at line 23 of file mwerks_console_OS_X.c.

◆ WritePtr

typedef int(* WritePtr) (int, const void *, __std(size_t))

Definition at line 24 of file mwerks_console_OS_X.c.

Function Documentation

◆ __msl_CreateFrameworkBundleFromName()

static OSErr __msl_CreateFrameworkBundleFromName ( CFStringRef  theFrameworkName,
CFBundleRef *  theBundle 
)
static

Definition at line 34 of file mwerks_console_OS_X.c.

36 {
37 OSErr theErr;
38 FSRef theRef;
39 CFURLRef theFrameworkURL;
40 CFURLRef theBundleURL;
41
42 /* Find the folder containing all the frameworks */
43 theErr = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, false, &theRef);
44
45 if (theErr == noErr)
46 {
47 /* Turn the framework folder FSRef into a CFURL */
48 theFrameworkURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &theRef);
49
50 if (theFrameworkURL != NULL)
51 {
52 /* Create a CFURL pointing to the desired framework */
53 theBundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault,
54 theFrameworkURL, theFrameworkName, false);
55
56 CFRelease(theFrameworkURL);
57
58 if (theBundleURL != NULL)
59 {
60 /* Turn the CFURL into a bundle reference */
61 *theBundle = CFBundleCreate(kCFAllocatorSystemDefault, theBundleURL);
62
63 CFRelease(theBundleURL);
64 }
65 }
66 }
67
68 return theErr;
69 }
#define NULL
Definition: types.h:112
CFBundleRef theBundle

Referenced by InstallConsole().

◆ __ttyname()

char * __ttyname ( long  fildes)

Definition at line 163 of file mwerks_console_OS_X.c.

164{
165#pragma unused (fildes)
166 /* all streams have the same name */
167 static char *__devicename = "Terminal";
168
169 if (fildes >= 0 && fildes <= 2)
170 return (__devicename);
171
172 return (0L);
173}
#define L(x)
Definition: ntvdm.h:50

◆ clrscr()

void clrscr ( )

Definition at line 185 of file mwerks_console_OS_X.c.

186{
187 return;
188}

◆ getch()

int getch ( void  )

Definition at line 180 of file mwerks_console_OS_X.c.

181{
182 return 0;
183}

Referenced by interact(), main(), and tokenize().

◆ InstallConsole()

short InstallConsole ( short  fd)

Definition at line 71 of file mwerks_console_OS_X.c.

72 {
73 #pragma unused (fd)
74 OSErr theErr;
75 short theResult;
76
77 theResult = -1;
78
79 /* Start with no bundle */
80 __msl_os_x.isLoaded = false;
81 __msl_os_x.theBundle = NULL;
82 __msl_os_x.theRead = NULL;
83 __msl_os_x.theWrite = NULL;
84
85 /* Create a bundle reference based on its name */
86 theErr = __msl_CreateFrameworkBundleFromName(CFSTR("System.framework"),
87 &__msl_os_x.theBundle);
88
89 if ((theErr == noErr) && (__msl_os_x.theBundle != NULL))
90 {
91 theResult = 0;
92
93 __msl_os_x.isLoaded = CFBundleLoadExecutable(__msl_os_x.theBundle);
94
95 if (__msl_os_x.isLoaded)
96 {
97 /* Lookup the functions in the bundle by name */
98 __msl_os_x.theRead = (ReadPtr)
99 CFBundleGetFunctionPointerForName(__msl_os_x.theBundle, CFSTR("read"));
100 __msl_os_x.theWrite = (WritePtr)
101 CFBundleGetFunctionPointerForName(__msl_os_x.theBundle, CFSTR("write"));
102 }
103 }
104
105 return theResult;
106 }
int(* ReadPtr)(int, void *, __std(size_t))
int(* WritePtr)(int, const void *, __std(size_t))
static OSErr __msl_CreateFrameworkBundleFromName(CFStringRef theFrameworkName, CFBundleRef *theBundle)
static struct @4277 __msl_os_x

◆ kbhit()

int kbhit ( void  )

Definition at line 175 of file mwerks_console_OS_X.c.

176{
177 return 0;
178}

◆ ReadCharsFromConsole()

long ReadCharsFromConsole ( char buffer,
long  n 
)

Definition at line 149 of file mwerks_console_OS_X.c.

150{
151#if __MACH__
152 return read(0, buffer, n);
153#else
154 /* Call the function if it was found */
155 if (__msl_os_x.theRead == NULL)
156 return -1;
157 else
158 return __msl_os_x.theRead(0, buffer, n);
159#endif
160}
#define read
Definition: acwin.h:96
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915

◆ RemoveConsole()

void RemoveConsole ( void  )

Definition at line 109 of file mwerks_console_OS_X.c.

110{
111#if !__MACH__
112 if (__msl_os_x.theBundle != NULL)
113 {
114 if (__msl_os_x.isLoaded)
115 {
116 __msl_os_x.theRead = NULL;
117 __msl_os_x.theWrite = NULL;
118
119 CFBundleUnloadExecutable(__msl_os_x.theBundle);
120 __msl_os_x.isLoaded = false;
121 }
122
123 CFRelease(__msl_os_x.theBundle);
124 __msl_os_x.theBundle = NULL;
125 }
126#endif
127}

◆ WriteCharsToConsole()

long WriteCharsToConsole ( char buffer,
long  n 
)

Definition at line 129 of file mwerks_console_OS_X.c.

130{
131#if __MACH__
132 return write(1, buffer, n);
133#else
134 /* Call the function if it was found */
135 if (__msl_os_x.theWrite == NULL)
136 return -1;
137 else
138 return __msl_os_x.theWrite(1, buffer, n);
139#endif
140}
#define write
Definition: acwin.h:97

Variable Documentation

◆ 

struct { ... } __msl_os_x

◆ isLoaded

Boolean isLoaded

Definition at line 28 of file mwerks_console_OS_X.c.

◆ theBundle

CFBundleRef theBundle

Definition at line 29 of file mwerks_console_OS_X.c.

Referenced by __msl_CreateFrameworkBundleFromName().

◆ theRead

ReadPtr theRead

Definition at line 30 of file mwerks_console_OS_X.c.

◆ theWrite

WritePtr theWrite

Definition at line 31 of file mwerks_console_OS_X.c.