HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Jelly Bean
|
4.1.1_r1
下载
查看原文件
收藏
根目录
external
stlport
test
eh
mwerks_console_OS_X.c
/* Metrowerks Standard Library * Copyright 1995-2002 Metrowerks Corporation. All rights reserved. * * $Date$ * $Revision$ */ #include
#include
#include
#include
#if __MACH__ short InstallConsole(short fd) { #pragma unused (fd) return 0; } #else #include
typedef int (*ReadPtr)(int, void *, __std(size_t)); typedef int (*WritePtr)(int, const void *, __std(size_t)); static struct { Boolean isLoaded; CFBundleRef theBundle; ReadPtr theRead; WritePtr theWrite; } __msl_os_x; static OSErr __msl_CreateFrameworkBundleFromName(CFStringRef theFrameworkName, CFBundleRef *theBundle) { OSErr theErr; FSRef theRef; CFURLRef theFrameworkURL; CFURLRef theBundleURL; /* Find the folder containing all the frameworks */ theErr = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, false, &theRef); if (theErr == noErr) { /* Turn the framework folder FSRef into a CFURL */ theFrameworkURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &theRef); if (theFrameworkURL != NULL) { /* Create a CFURL pointing to the desired framework */ theBundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, theFrameworkURL, theFrameworkName, false); CFRelease(theFrameworkURL); if (theBundleURL != NULL) { /* Turn the CFURL into a bundle reference */ *theBundle = CFBundleCreate(kCFAllocatorSystemDefault, theBundleURL); CFRelease(theBundleURL); } } } return theErr; } short InstallConsole(short fd) { #pragma unused (fd) OSErr theErr; short theResult; theResult = -1; /* Start with no bundle */ __msl_os_x.isLoaded = false; __msl_os_x.theBundle = NULL; __msl_os_x.theRead = NULL; __msl_os_x.theWrite = NULL; /* Create a bundle reference based on its name */ theErr = __msl_CreateFrameworkBundleFromName(CFSTR("System.framework"), &__msl_os_x.theBundle); if ((theErr == noErr) && (__msl_os_x.theBundle != NULL)) { theResult = 0; __msl_os_x.isLoaded = CFBundleLoadExecutable(__msl_os_x.theBundle); if (__msl_os_x.isLoaded) { /* Lookup the functions in the bundle by name */ __msl_os_x.theRead = (ReadPtr) CFBundleGetFunctionPointerForName(__msl_os_x.theBundle, CFSTR("read")); __msl_os_x.theWrite = (WritePtr) CFBundleGetFunctionPointerForName(__msl_os_x.theBundle, CFSTR("write")); } } return theResult; } #endif void RemoveConsole(void) { #if !__MACH__ if (__msl_os_x.theBundle != NULL) { if (__msl_os_x.isLoaded) { __msl_os_x.theRead = NULL; __msl_os_x.theWrite = NULL; CFBundleUnloadExecutable(__msl_os_x.theBundle); __msl_os_x.isLoaded = false; } CFRelease(__msl_os_x.theBundle); __msl_os_x.theBundle = NULL; } #endif } long WriteCharsToConsole(char *buffer, long n) { #if __MACH__ return write(1, buffer, n); #else /* Call the function if it was found */ if (__msl_os_x.theWrite == NULL) return -1; else return __msl_os_x.theWrite(1, buffer, n); #endif } #if __MACH__ long WriteCharsToErrorConsole(char *buffer, long n) { return write(2, buffer, n); } #endif long ReadCharsFromConsole(char *buffer, long n) { #if __MACH__ return read(0, buffer, n); #else /* Call the function if it was found */ if (__msl_os_x.theRead == NULL) return -1; else return __msl_os_x.theRead(0, buffer, n); #endif } /* JWW - This code should never be reached, but it's needed for link purposes */ char *__ttyname(long fildes) { #pragma unused (fildes) /* all streams have the same name */ static char *__devicename = "Terminal"; if (fildes >= 0 && fildes <= 2) return (__devicename); return (0L); } int kbhit(void) { return 0; } int getch(void) { return 0; } void clrscr() { return; } /* Change record: * JWW 010919 Created Mach-O console stubs file * JWW 020418 Use __std() for all size_t, and #include
to get proper C++ definitions */
C++程序
|
193行
|
4.09 KB
原始内容
高亮显示
复制内容
×
已收藏
收藏成功,您可以在我收藏的代码页面中查看,其地址为:
https://www.androidos.net.cn/my/collect/code
。
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册