home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.sustworks.com 2018
/
ftp.sustworks.com.zip
/
ftp.sustworks.com
/
SetupAP.cp.sit.hqx
/
SetupAP.cp
next >
Wrap
Text File
|
1996-08-29
|
3KB
|
98 lines
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <OpenTransport.h>
#include <OpenTptInternet.h>
#include <OpenTptDevLinks.h>
#include <stropts.h>
// open stream flags (read/write)
#define O_RDWR 0x02
#define debugMe false
// forward function declaration
void SetupAutopush(Boolean pushOn);
// ---------------------------------------------------------------------------
// Ñ Main
// ---------------------------------------------------------------------------
// Just setup autopush and exit
void main(void)
{
if (debugMe) printf ("\nHello World, this is SetupAP");
// Setup to autopush our Proxy module on top of the PPP link
SetupAutopush(false); // remove any previous autopush
SetupAutopush(true);
if (debugMe) printf ("\nGoodbye");
}
// ---------------------------------------------------------------------------
// Ñ SetupAutopush
// ---------------------------------------------------------------------------
// Setup to Autopush or not Autopush our Proxy module on top of the PPP link
void
SetupAutopush(Boolean pushOn)
{
OSStatus err = kOTNoError;
OTPortRecord portInfo;
UInt32 index;
UInt16 deviceType;
// open a stream to the sad device
StreamRef myStreamRef = OTStreamOpen(kSADModuleName, O_RDWR, &err);
if (err != noErr) {
printf ("\nSetupAP: unable to open stream to sad device.");
return;
}
// Scan available ports
index = 0;
deviceType = 0;
while (OTGetIndexedPort(&portInfo, index)) {
deviceType = OTGetDeviceTypeFromPortRef(portInfo.fRef);
index += 1;
// setup target devices for autopush
if ((deviceType == kOTPPPDevice) ||
(deviceType == kOTSLIPDevice) ||
(deviceType == kOTMDEVDevice)) {
// setup autopush info structure
OTAutopushInfo myAutopushInfo;
if (pushOn) myAutopushInfo.sap_cmd = kSAP_ALL; // Autopush or not?
else myAutopushInfo.sap_cmd = kSAP_CLEAR;
strcpy((char*)myAutopushInfo.sap_device_name,
portInfo.fModuleName); // name of data link module
myAutopushInfo.sap_minor = 0;
myAutopushInfo.sap_lastminor = 0;
myAutopushInfo.sap_npush = 1; // number of modules to push
strcpy((char*)myAutopushInfo.sap_list[0], "Proxym"); // name of module to push
// send ioctl to set autopush info
struct strioctl stri;
stri.ic_cmd = I_SAD_SAP;
stri.ic_dp = (char*)&myAutopushInfo;
stri.ic_len = sizeof(OTAutopushInfo);
stri.ic_timout = -1;
err = OTStreamIoctl(myStreamRef, I_STR, (void*)&stri);
if (err != kOTNoError ) {
if (!pushOn && (err == kENODEVErr)) {
// The module specified is not configured for autopush,
// so there is nothing to clear. Ignore.
} else {
printf ("\nSetupAP: Set autopush ioctl failed with error code %d.", err);
}
}
}
}
// close SAD stream to free up resources
err = OTStreamClose(myStreamRef);
}