OSErr InitializeConnection(Boolean readPrefs, ConnHandle* connection) { Handle theStrings; Ptr configString = nil; CMErr err; CMBufferSizes bufSizes; short procID; StringPtr temp = nil; Str255 toolName; *connection = nil; // get a Connection Tool name if (readPrefs) { err = GetToolname(toolName); if (err != noErr) { readPrefs = false; // if there is a serial tool, use that name PLstrcpy(toolName, "\pSerial Tool"); procID = CMGetProcID(toolName); if (procID == -1) { // we could not find the serial tool, use what ever is first err = CRMGetIndToolName(classCM, 1, toolName); if (err != noErr) { err = -1; return err; } } } } else {
OSErr TotalHack(CFragConnectionID connID) { Handle theStrings; CMBufferSizes bufSizes; short procID; Str255 toolName; OSErr error; FSSpec where; short ref; char* end; Ptr tempString; char* here; short baud; Boolean prefsChanged = false; THz myZone; ser_t* storage; gConnection = nil; // get a Connection Tool name strcpy((char *)toolName, "Apple Modem Tool"); // so try to use the Apple modem tool c2pstr((char *)toolName); end = (char *)(toolName + toolName[0] + 1); memset(end, '\0', 255 - toolName[0]); // init the CMBufferSizes variable so that Tool will init with defaults bufSizes[cmDataIn] = 0; bufSizes[cmDataOut] = 0; bufSizes[cmCntlIn] = 0; bufSizes[cmCntlOut] = 0; bufSizes[cmAttnIn] = 0; bufSizes[cmAttnOut] = 0; bufSizes[cmRsrvIn] = 0; bufSizes[cmRsrvOut] = 0; error = noErr; myZone = GetZone(); SetZone(SystemZone()); // get a process ID for the tool procID = CMGetProcID(toolName); if (procID == -1) { error = -2; } // now get a conn record set up if (error == noErr) { gConnection = CMNew(procID, cmData|cmNoMenus|cmQuiet, bufSizes, 0, 0); if (gConnection != nil) { storage = (ser_t*)NewPtrClear(sizeof(ser_t)); storage->sConnection = gConnection; error = SetData(connID, (unsigned long)storage); } } return error; }
OSErr VerifyToolExists(char* toolName) { Str255 tempName; short index; short result; OSErr error = noErr; result = CMGetProcID(toolName); if (result == -1) { error = -7; } return error; }