home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
SREFPRC1
/
MULTSEND.SRF
< prev
next >
Wrap
Text File
|
1997-06-30
|
4KB
|
113 lines
/* ----------------------------------------------------------------------- */
/* multi-part send routine
thevalue: the stuff to send. Possibly text, possibly whatever --
OR; if isfile=1, a fully qualified file name.
thetype: the mime type to use. If not speicfied, text/html is used
status: S,M,E, MS,MM,ME
'S' : Start-- This is the first send
'SS' : Start, but do not close,
'SE' : Start, do not open
'M' : Middle -- An interior send
'MS' : Middle, but do NOT "close" this part
'ME' : Middle, do NOT open part
'E' : End -- The last send
'ES' : End -- do not CLOSE this part
'EE' : End -- do not OPEN this part
'A' : Send, do not OPEN or CLOSE this part
The S,M,E and send a complete message.
To build a message in pieces (retaining older parts of the message)
you can use a sequence of: xS,A,xE (where X is S,M, or E).
Note: MS and ES are the same (but ME and EE are NOT the same)
The default value is A
isfile: If 1, then thevalue is treated as a fully qualified file name,
and the contents are read using charin. If the file can not
be found, an empty string is used.
Default is NOT to interpret thevalue as a file name.
Returns RC code from the send -- check for negative values to indicate
broken connection.
example: foo=multsend('d:\i1.gif','image/gif','S',1)
foo=multsend('d:\i2.gif','image/gif','M',1)
foo=multsend('d:\i3.gif','image/gif','E',1)
example2:foo=multsend('Hello 1','text/plain','S')
foo=multsend('what's up1','text/plain','MS')
foo=multsend('what's up2','text/plain','A')
foo=multsend('what's up3','text/plain','ME')
foo=multsend('good bye','text/plain','E')
*/
/* ----------------------------------------------------------------------- */
sref_multi_send:
parse arg thevalue,thetype,status,isfile,verbose
crlf='0d0a'x /* useful */
bound='asfa235sdfF#234asg#%^6q32472341as'
bound2='asfA235sdfF#234asg#%^6q32472341p'
/* if isfile, then thevalue is a fully qualified file name. Read it */
if isfile=1 then do
afil=stream(thevalue,'c','query exists')
if afil="" then do
thevalue=""
end /* Do */
else do
thevalue=charin(afil,1,chars(afil))
end
end /* Do */
/* if by odd chance a bound string is found in thevalue, it will
be replaced by bound2 */
foo=pos(bound,thevalue)
if foo>0 then thevalue=sref_replacestrg(thevalue,bound,bound2,'ALL')
/* mime tyhpes */
if thetype=0 | thetype="" then thetype="text/html"
if verbose>3 then call pmprintf_sref(' Multipart send: ' status ' = ' thetype)
/* status */
if status=0 | status="" then status="A"
status=strip(upper(status));
mimestart='--'bound''crlf /* starts a MIME multipart section */
mimeend ='--'bound'--'crlf /* ends a MIME multipart section */
/* Send the header and first boundary */
if status='S' | status='SS' then do
'set netbuffer off' /* turn off buffering */
'send type multipart/x-mixed-replace;boundary="'bound'" as MultiSend'
'string' mimestart /* Or could be: 'var name mimestart' */
end
out=""
if wordpos(status,'ME SE EE A')=0 then do
out=out||'Content-type: '||thetype||crlf
out=out||crlf
end
out=out||thevalue||crlf
if status="E" | status="EE" then do
out=out||mimeend /* Mime 'last data' indicator */
end
if wordpos(status,'M ME S SE')>0 then do
out=out||mimestart /* Mime 'start data' indicator */
end
'VAR NAME out' /* send it */
res1=rc
if status="E" | status="EE" then 'SEND Complete' /* and complete the send */
return res1