home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFPRC1
/
PUBURLS.SRF
< prev
next >
Wrap
Text File
|
1997-07-06
|
5KB
|
136 lines
/* See if there is a match to a public_url *** */
sref_public_urls:
parse arg sel,host_nickname,enmadd,ddir,home_dir,verbose,specific_mime,check_rec
tsel=strip(translate(sel))
if length(tsel)>1 then
if abbrev(tsel,'/')=1 | abbrev(tsel,'\')=1 then tsel=substr(tsel,2)
gotit=0 ; doexact=0 ;asterat=0 ; afteraster=0
call get_public_urls(host_nickname)
/* look for matching public_Urls -- check for exact or best match */
do m=1 to public_urls.0
if public_urls.m=' ' then iterate
parse var public_urls.m purl isliteral aname0
purl=strip(purl)
ares=sref_wildcard(tsel,purl||' '||aname0,doexact)
parse var ares astat "," aurl ; astat=strip(astat)
if astat=0 then iterate /* no match */
if astat=1 then do
gotit=m
usesel=sel ;
useliteral=strip(upper(isliteral))
exact_name=' ' ; ispurl=purl
exact_name=strip(aname0)
leave /*first exact match rules */
end
/* astat=2;; non exact: see if it's a "better match" (more chars before/after *) */
foo1=pos('*',purl)
if foo1 >= asterat then do
tmp1=length(purl)-foo1
if foo1>asterat | tmp1>afteraster then do
asterat=foo1 ; afteraster=tmp1
usesel=sel ;
useliteral=strip(upper(isliteral));
exact_name=' ' ; ispurl=purl
exact_name=strip(aname0)
gotit=m
end /* either condition */
end /* ge asterat */
end /* do public urls */
/* special case: check for NORECORD option on the public url */
if check_rec=1 then do
if gotit=0 then return 0
isnorec=pos('NORECORD',useliteral)+pos('NOPOST',useliteral)
if isnorec=0 then return 0
return 1
end
if gotit=0 then return ' 0 , no match '
/* got a match, process it */
/* if it's a literal public file, minimal processing is required */
islit=pos('LITERAL',useliteral)
isnorec=pos('NORECORD',useliteral)+pos('NOPOST',useliteral)
if isnorec>0 then isnorec=1
if islit>0 then do
if verbose>1 then call pmprintf_sref(" Literal public_url: " usesel)
if exact_name<>"" then do
if pos('*',exact_name)=0 then
afile=exact_name
else do
afile=sref_wildcard(tsel,ispurl||' '||exact_name,0)
parse var afile . ',' afile; afile=strip(afile)
end
end
else do /* see if in data direcotyr */
parse var usesel asel '?' .
afile=ddir||asel
if pos('~',afile)>0 then do
afile=sref_home_dir(afile,home_dir)
end
afile=translate(afile,'\','/')
end
ii=stream(afile,'c','query exists') /* check for existence of file*/
if ii="" then do
call pmprintf_sref(' Warning: literal public_url to a non-existent file: ' sel ',' afile)
end
else do /* ship the file (and maybe record it */
if specific_mime<>0 & specific_mime<>' ' then do
aa=translate(specific_mime,' ','_')
m1=strip(word(aa,1)); m2=strip(word(aa,2))
atype=m1||'/'||m2
end
else do
atype=sref_mediatype(afile)
end
'FILE TYPE ' atype ' NAME ' afile
return ' 1 1 ' isnorec ', Literal public file returned:' ||afile /* else, do post filtering */
end /* no such file */
end /* literal */
/* if here, non-literal public_url, or literal public_url that failed to
connect to a file (but which might match if aliases are checked for */
if verbose>1 then call pmprintf_sref(" public_url. " gotit " being used for: " sel)
return ' 1 0 ' isnorec ' , non-literal match '
/* ------------ */
/* get public urls for this host
If host, then get host specific ones
else, get non-host specific ones
Note that "first" best match always rules, or first exact.
*/
/*----------------*/
get_public_urls:procedure expose public_urls. enmadd
parse arg hname
os2e='os2environment'
nin=0
a1='public_urls.'
addit=''
if hname<>' ' then addit='.'||strip(hname)
do mm=1 to 1000000
tt=0
moe=enmadd||a1||mm||addit ; moe=strip(moe)
tt=strip(value(moe,,os2e))
if tt="" | tt=0 then leave
nin=nin+1
public_urls.nin=tt
end
public_Urls.0=nin
return nin