added HandleURLString

This commit is contained in:
chombier 2001-03-18 00:30:54 +00:00
parent 3489e34296
commit a7239c7990
3 changed files with 65 additions and 37 deletions

View File

@ -72,6 +72,7 @@ char *gURLSchemeNames[] = {
"tn3270:", "tn3270:",
"finger:", "finger:",
"whois:", "whois:",
"ssh:",
nil nil
}; };
@ -93,6 +94,60 @@ Boolean MyStrNEqual (char *s1, char *s2, short n)
#define isLWSP(a) ((a) == ' ' || (a) == '\t') #define isLWSP(a) ((a) == ' ' || (a) == '\t')
#define isLWSPorCR(a) (isLWSP(a) || (a) == CR) #define isLWSPorCR(a) (isLWSP(a) || (a) == CR)
static void LaunchURL(Handle urlH, short w)
{
TURLKind urlKind;
OSErr err;
OSType sig;
short returnedSize;
long fakeSelBegin, fakeSelEnd, handleSize;
HLock(urlH);
urlKind = ParseURL(urlH, &returnedSize);
if (urlKind != 100) {
if ( w >= 0 )
FlashSelection(w);
if (urlKind == kTelnetURL || urlKind == kSSHURL) {
//we handle this, send apple event to ourselves
ProcessSerialNumber psn;
unsigned short launchControlFlags;
launchControlFlags = launchContinue | launchNoFileFlags | launchDontSwitch;
GetCurrentProcess( &psn );
err = LaunchAppWithEventAndString(TRUE, NULL, &psn,
kGetURLEventClass, kGetURLEventID,
keyDirectObject, *urlH, 0, launchControlFlags);
} else {
fakeSelBegin = 0;
fakeSelEnd = returnedSize;
ICFindConfigFile(inst, 0, 0);
ICLaunchURL(inst, aligned_pstring("\p"), *urlH, returnedSize, &fakeSelBegin, &fakeSelEnd);
}
return;
}
// sig = GetHelperInfo(urlKind);
// if (sig == NULL)
// return;
// err = OpenHelperWithURL(sig, *urlH);
}
void HandleURLString(ConstStr255Param urlString)
{
Handle urlH;
urlH = NewHandle(urlString[0] + 1);
if (MemError() != noErr) {
return;
}
HLock(urlH);
BlockMoveData(urlString + 1, *urlH, urlString[0]);
(*urlH)[urlString[0] + 1] = ' ';
LaunchURL(urlH, -1);
DisposeHandle(urlH);
}
void HandleURL(short w) void HandleURL(short w)
{ {
Handle urlH; Handle urlH;
@ -106,10 +161,9 @@ void HandleURL(short w)
if ((urlH == (char **)-1L) || (urlH == nil)) { if ((urlH == (char **)-1L) || (urlH == nil)) {
return; return;
} }
// 12/10/97, RJZ. Increase size by one
// 12/10/97, RJZ. Increase size by one // so there is room for a NULL
// so there is room for a NULL // terminator.
// terminator.
handleSize = GetHandleSize(urlH); handleSize = GetHandleSize(urlH);
SetHandleSize(urlH, handleSize + 1); SetHandleSize(urlH, handleSize + 1);
if (MemError() != noErr) { if (MemError() != noErr) {
@ -117,41 +171,12 @@ void HandleURL(short w)
return; return;
} }
HLock(urlH); HLock(urlH);
(*urlH)[handleSize] = ' '; (*urlH)[handleSize] = ' ';
LaunchURL(urlH, w);
urlKind = ParseURL(urlH, &returnedSize); DisposeHandle(urlH);
if (urlKind == 100)
return;
else if ((urlKind == kTelnetURL)/*||(urlKind == kRloginURL)*/)
{ //we handle this, send apple event to ourselves
ProcessSerialNumber psn;
unsigned short launchControlFlags;
FlashSelection(w);
launchControlFlags = launchContinue | launchNoFileFlags;
launchControlFlags |= launchDontSwitch;
GetCurrentProcess(&psn);
err = LaunchAppWithEventAndString(TRUE, NULL, &psn,
kGetURLEventClass, kGetURLEventID,
keyDirectObject, *urlH, 0, launchControlFlags);
return;
}
else {
fakeSelBegin = 0;
fakeSelEnd = returnedSize;
FlashSelection(w);
ICFindConfigFile(inst, 0, 0);
ICLaunchURL(inst, aligned_pstring("\p"), *urlH, returnedSize, &fakeSelBegin, &fakeSelEnd);
}
// sig = GetHelperInfo(urlKind);
// if (sig == NULL)
// return;
// err = OpenHelperWithURL(sig, *urlH);
return;
} }
TURLKind ParseURL(Handle urlH, short *returnedSize) TURLKind ParseURL(Handle urlH, short *returnedSize)
{ {
short size; short size;

View File

@ -13,5 +13,6 @@ typedef enum TURLKind {
kRloginURL, kRloginURL,
kTn3270URL, kTn3270URL,
kFingerURL, kFingerURL,
kWhoisURL kWhoisURL,
kSSHURL
} TURLKind; } TURLKind;

View File

@ -1,3 +1,5 @@
void HandleURL(short w); void HandleURL(short w);
void HandleURLString(ConstStr255Param urlString);
Boolean FindURLAroundPoint(Point curr, short w); Boolean FindURLAroundPoint(Point curr, short w);
void UnloadURL(void); void UnloadURL(void);