static OSErr InitializeApplication( void ) { OSErr err; static const EventTypeSpec sApplicationEvents[] = { { kEventClassCommand, kEventCommandProcess } }; BlockZero( &g, sizeof(g) ); g.mainBundle = CFBundleGetMainBundle(); if ( g.mainBundle == NULL ) { err = -1; goto Bail; } err = CreateNibReferenceWithCFBundle( g.mainBundle, CFSTR("WindowFun"), &g.mainNib ); if ( err != noErr ) goto Bail; if ( g.mainNib == NULL ) { err = -1; goto Bail; } err = SetMenuBarFromNib( g.mainNib, CFSTR("MenuBar") ); if ( err != noErr ) goto Bail; InstallApplicationEventHandler( NewEventHandlerUPP(AppEventEventHandlerProc), GetEventTypeCount(sApplicationEvents), sApplicationEvents, 0, NULL ); // Force the document group to be created first, so we can position our groups between the floating and document groups (void) GetWindowGroupOfClass( kDocumentWindowClass ); // Create our default WindowGroups and set their z-order err = CreateWindowGroup( 0, &g.windowGroups[0] ); err = CreateWindowGroup( 0, &g.windowGroups[1] ); err = CreateWindowGroup( 0, &g.windowGroups[2] ); // Position our groups behind the floating group and in front of the document group SendWindowGroupBehind( g.windowGroups[2], GetWindowGroupOfClass( kDocumentWindowClass ) ); SendWindowGroupBehind( g.windowGroups[1], g.windowGroups[2] ); SendWindowGroupBehind( g.windowGroups[0], g.windowGroups[1] ); Bail: return( err ); }
Handle NewHandleClear(Size byteCount) { Handle h = NewHandle(byteCount); BlockZero(*h, byteCount); // no need to HLock(), no one knows about it yet return h; }
Ptr NewPtrClear(Size byteCount) { Ptr p = NewPtr(byteCount); BlockZero(p, byteCount); return p; }
void* calloc(size_t nmemb, size_t size) { size *= nmemb; void* ptr = malloc(size); if (ptr != NULL) { BlockZero(ptr, size); } return ptr; }
void flext::ZeroMem(void *dst,int bytes) { #if FLEXT_OS == FLEXT_OS_WIN ZeroMemory(dst,bytes); #elif FLEXT_OS == FLEXT_OS_MAC # ifdef __LP64__ // 64 bits compilation bzero(dst,bytes); # else BlockZero(dst,bytes); # endif #else memset(dst,0,bytes); #endif }
static void DebugCreateProxiesEntity(void) // Used for debugging MoreSCCreateProxiesEntity. { OSStatus err; MoreSCProxiesDigest proxy; CFDictionaryRef entity; BlockZero(&proxy, sizeof(proxy)); entity = NULL; err = MoreSCCreateProxiesEntity(&proxy, &entity); if (err == noErr) { PrintPropertyList(entity); } CFQRelease(entity); }
static CWResult LocateFile(CWPluginContext context, const char* filename, FSSpec& file) { /* prefill the CWFileInfo struct */ CWFileInfo fileinfo; BlockZero(&fileinfo, sizeof(fileinfo)); // memset(&fileinfo, 0, sizeof(fileinfo)); fileinfo.fullsearch = true; fileinfo.suppressload = true; fileinfo.dependencyType = cwNormalDependency; fileinfo.isdependentoffile = kCurrentCompiledFile; /* locate the file name using the project's access paths */ CWResult err = CWFindAndLoadFile(context, filename, &fileinfo); if (err == cwNoErr) { file = fileinfo.filespec; } else if (err == cwErrFileNotFound) { char errmsg[200]; sprintf(errmsg, "Can't locate file \"%s\".", filename); CWResult callbackResult = CWReportMessage(context, 0, errmsg, 0, messagetypeError, 0); } return (err); }
static void DebugCreatePPPoE(void) { OSStatus err; CFStringRef setID; setID = NULL; err = MoreSCFindSetByUserVisibleNameAndCopyID(kPPPoESetName, &setID); if (err == noErr && setID != NULL) { err = MoreSCDeleteSet(setID); CFQRelease(setID); setID = NULL; } if (err == noErr) { MoreSCPPPDigest ppp; BlockZero(&ppp, sizeof(ppp)); ppp.active = true; ppp.authName = CFSTR("Quinn"); ppp.authPassword = CFSTR("eskimo"); err = MoreSCMakeNewPPPoESet(NULL, kPPPoESetName, &ppp, NULL, NULL, &setID); } if (err == noErr) { fprintf(stderr, "PPPoE set ID is "); CFShow(setID); } CFQRelease(setID); if (err == noErr) { fprintf(stderr, "Success!\n"); } else { fprintf(stderr, "*** Failed with error %ld\n", err); } }
static OSErr InitializeApplication( void ) { OSErr err; static const EventTypeSpec sApplicationEvents[] = { { kEventClassCommand, kEventCommandProcess } }; BlockZero( &g, sizeof(g) ); g.mainBundle = CFBundleGetMainBundle(); if ( g.mainBundle == NULL ) { err = -1; goto Bail; } if ( MPLibraryIsLoaded() == false ) { err = -1; goto Bail; } err = CreateNibReferenceWithCFBundle( g.mainBundle, CFSTR("main"), &g.mainNib ); if ( err != noErr ) goto Bail; if ( g.mainNib == NULL ) { err = -1; goto Bail; } err = SetMenuBarFromNib( g.mainNib, CFSTR("MenuBar") ); if ( err != noErr ) goto Bail; InstallApplicationEventHandler( NewEventHandlerUPP(AppEventEventHandlerProc), GetEventTypeCount(sApplicationEvents), sApplicationEvents, 0, NULL ); Bail: return( err ); }
static CWResult Compile(CWPluginContext context) { CWResult err = CWGetMainFileSpec(context, &gSourceFile); if (!CWSUCCESS(err)) return (err); long fileNum; err = CWGetMainFileNumber(context, &fileNum); if (!CWSUCCESS(err)) return (err); // get the name of the source file to compile. gSourcePath = p2c_strdup(gSourceFile.name); if (gSourcePath == NULL) return cwErrOutOfMemory; // build an argument list and call the compiler. XPIDLSettings settings = { kXPIDLSettingsVersion, kXPIDLModeHeader, false, false }; GetSettings(context, settings); #if 0 // if generating .xpt files, let the IDE tell us where to put the output file. // otherwise, put them in the project's output directory. if (settings.mode == kXPIDLModeTypelib) err = CWGetSuggestedObjectFileSpec(context, fileNum, &gOutputFile); else err = CWGetOutputFileDirectory(gPluginContext, &gOutputFile); #else // always generate the output file into the project target's data directory. err = CWGetSuggestedObjectFileSpec(context, fileNum, &gOutputFile); #endif if (!CWSUCCESS(err)) return (err); int argc = 3; char* modes[] = { "header", "java", "typelib", "doc" }; char* argv[] = { "xpidl", "-m", modes[settings.mode - 1], NULL, NULL, NULL, NULL, }; if (settings.warnings) argv[argc++] = "-w"; if (settings.verbose) argv[argc++] = "-v"; argv[argc++] = gSourcePath; if (setjmp(exit_jump) == 0) { if (xpidl_main(argc, argv) != 0) err = cwErrRequestFailed; } else { // evidently the good old exit function got called. if (exit_status != 0) err = cwErrRequestFailed; } // if the compilation succeeded, tell CodeWarrior about the output file. // this ensures several things: 1. if the output file is deleted by the user, // then the IDE will know to recompile it, which is good for dirty builds, // where the output files may be hand deleted; 2. if the user elects to remove // objects, the output files are deleted. Thanks to [email protected] for // pointing this new CWPro4 API out. if (err == cwNoErr) { CWObjectData objectData; BlockZero(&objectData, sizeof(objectData)); // for fun, show how large the output file is in the data area. long dataSize, rsrcSize; if (FSpGetFileSize(&gOutputFile, &dataSize, &rsrcSize) == noErr) objectData.idatasize = dataSize; // tell the IDE that this file was generated by the compiler. objectData.objectfile = &gOutputFile; err = CWStoreObjectData(context, fileNum, &objectData); } else { // an error occured, delete the output file, which might be a partial file. if (gOutputFile.name[0] != 0) { ::FSpDelete(&gOutputFile); } } delete[] gSourcePath; gSourcePath = NULL; return (err); }
int bzero(char *block,long size) { BlockZero(block,size); }
static void TestISP(void) // A routine to test the ISP support routines. { OSStatus err; CFStringRef setID; CFStringRef setID2; CFStringRef newSetID; setID = NULL; setID2 = NULL; newSetID = NULL; err = MoreSCFindSetByUserVisibleNameAndCopyID(CFSTR(kDefaultLocationName), &setID); if (err == noErr) { if (setID == NULL) { fprintf(stderr, "*** Couldn't find the set '%s'\n", kDefaultLocationName); } else if (!gRunQuiet) { fprintf(stderr, "Set ID for '%s' is\n", kDefaultLocationName); CFShow(setID); } } if (err == noErr) { err = MoreSCFindSetByUserVisibleNameAndCopyID(CFSTR("Who would give a set such a silly name"), &setID2); if (setID2 != NULL) { fprintf(stderr, "*** Found set that shouldn't exist\n"); } } if (err == noErr) { MoreSCPPPDigest ppp; BlockZero(&ppp, sizeof(ppp)); ppp.active = true; ppp.authName = CFSTR("Quinn"); ppp.authPassword = CFSTR("eskimo"); ppp.commRemoteAddress = CFSTR("123 4567"); err = MoreSCMakeNewDialupSet(NULL, CFSTR("Frog PPP"), NULL, &ppp, NULL, NULL, &newSetID); } if (err == noErr) { err = MoreSCDeleteSet(newSetID); } CFQRelease(newSetID); newSetID = NULL; PrintTestResult(err, "dialup"); err = noErr; if (err == noErr) { MoreSCPPPDigest ppp; BlockZero(&ppp, sizeof(ppp)); ppp.active = true; ppp.authName = CFSTR("Quinn"); ppp.authPassword = CFSTR("eskimo"); err = MoreSCMakeNewPPPoESet(NULL, CFSTR("Frog PPPoE"), &ppp, NULL, NULL, &newSetID); } if (err == noErr) { err = MoreSCDeleteSet(newSetID); } CFQRelease(setID); CFQRelease(setID2); CFQRelease(newSetID); PrintTestResult(err, "PPPoE"); }