eudora-mac/url.c

1 line
73 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define FILE_NUM 66 /* Copyright (c) 1994 by QUALCOMM Incorporated */ #pragma segment URL #include "url.h" #include <LaunchServices.h> Boolean gHelpWinClick = false; typedef struct { Str31 scheme; Boolean isSite; Str127 site; Str255 path; Boolean isQuery; Str255 query; Boolean isFragment; Str255 fragment; } DeepURL, *DeepURLPtr, **DeepURLHandle; OSErr SFURLApp(PStr proto,AliasHandle *alias); OSErr SFURLAppStd(PStr proto,AliasHandle *alias, SFTypeList types, Str255 prompt, FSSpec *spec, URLHookOptionsPtr optionsPtr, Boolean *good); OSErr BuildGURL(ProcessSerialNumberPtr psn,PStr url,AppleEvent *ae,Boolean newWindow); OSErr BuildGURLPtr(ProcessSerialNumberPtr psn,UPtr url,short length,AppleEvent *ae,Boolean newWindow); pascal OSErr HandleAEURL(AppleEvent *event,AppleEvent *reply,long refCon); Boolean IsURLCharLo(Byte c); OSErr MailtoURL(PStr query,AEDescList *dox,Boolean spool); OSErr FileURL(PStr path); void DeepURLParse(PStr url, DeepURLHandle duh); PStr URLCombinePaths(PStr into,PStr base,PStr rel); PStr RemLastComponent(PStr path); PStr DuhString(PStr url,DeepURLHandle duh); Byte URLToken(PStr url,PStr token,UPtr *spot); Boolean TrailingDotDot(PStr string); PStr URLPathEscape(PStr path); OSErr ClearLink(PETEHandle pte,Boolean clear,long start, long end,long *urlStart, long *newStart, long *newEnd,PStr oldURL); Handle URLVarSub(Ptr *string, long *len); Boolean IsHostname(PStr string); OSErr HostnameURL(PStr hostname); OSErr JumpURL(PStr action); void TurnBareLFs2BareCRs(Ptr s,long len); void SubVar(Handle h,PStr find,PStr replace); pascal Boolean URLDlgFilter(DialogPtr dgPtr,EventRecord *event,short *item); Boolean PeteLinkAt(PETEHandle pte,long offset,Handle *hURL,PStr link); void URLHelpTag(PETEHandle pte,Point mouse); short URLIsNaughty(PStr linkText,Handle hURL,Boolean interact); short URLIsNaughtyLo(PStr linkText,Handle hURL,PStr urlHost,PStr linkHost); PStr StripCountryFromHost(PStr stripped,PStr clothed); #define IsSchemeChar(x) (IsWordChar[x] || x==':' || x=='.' || x=='-' || x=='+' || '0'<=x && x<='9') #define IsURLChar(x) (IsWordChar[x] || IsURLCharLo(x)) #define IsSlackURLChar(x) (IsURLChar(x)&&!IsLWSP(x)&&(x)!='('&&(x)!=')') #define IsHostChar(x) (IsSchemeChar(x)) // This used to disallow colon, too. I'm not sure why, but it messed up host:port syntax #define kW3Class 'WWW!' #define kOpenURL 'OURL' #define keyW3Window 'WIND' /************************************