× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This module is part of a procedure I wrote last year for my company that
wanted to automatically get mail and attachment.

Specifically the attachment  was an excel document containg a list of items
and prices. The procedure gets the attachemnt, decodes and put into the IFS,
then opens and reads with POI and updates the database.


----- Original Message ----- 
From: <Rick.Chevalier@xxxxxxxxxxxxxxx>
To: <rpg400-l@xxxxxxxxxxxx>
Sent: Wednesday, November 10, 2004 5:32 PM
Subject: RE: Base64 Encoding


> Beppe,
>
> I've been looking over your code below and I have a understand everything
except where you are using 255 in the %bitand function.  I don't see where
it has any effect on the result.  Am I missing something?
>
> Rick
>
> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx
> [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Beppe Costagliola
> Sent: Wednesday, November 10, 2004 3:22 AM
> To: RPG programming on the AS400 / iSeries
> Subject: Re: Base64 Encoding
>
>
> This is what I'm using to decode mail attachements:
>
> d QUSPTRUS        PR                  extpgm('QUSPTRUS')
> d  UserSpace                    20    const
> d  UserSpacePtr                   *
>
> D Input           S              4A   based(i_attachement)
> D Output          S              3A   based(o_attachement)
>
> D attachement     DS                  based(p_attachement)
> D  attachName                   64
> D  attachSize                   10
> D  attachFiller                 22
>
> D s_attachement   S             10I 0
>
> D tbBase64        S             65A
>
> D w               S             10I 0 dim(4)
> D Char            ds
> D ww                             3U 0
> D wa                             1A   overlay(ww)
>
> D iPos            S             10I 0
> D oPos            S             10I 0
>
> D MimeDecode      PR            10I 0
> D  Input                         1A   const
>
>  /free
>
>   // initialize the table
>   tbBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
>              'abcdefghijklmnopqrstuvwxyz' +
>              '0123456789+/=';
>
>   // get workspaces
>   QUSPTRUS ('BASE64    QTEMP     ' : i_attachement);
>   QUSPTRUS ('ATTACHMENTQTEMP     ' : p_attachement);
>  // set the output pointer past the header (name+size)
>  o_attachement = p_attachement + %size(attachement);
>
>  // decode
>  dow Input <> *loval;
>
>    iPos = 1;
>    oPos = 1;
>    w(1) = MimeDecode(%subst(Input: iPos: 1));
>    w(2) = MimeDecode(%subst(Input: iPos + 1: 1));
>    w(3) = MimeDecode(%subst(Input: iPos + 2: 1));
>    w(4) = MimeDecode(%subst(Input: iPos + 3: 1));
>
>    ww = %bitand ((w(1) * 4 + %Int(w(2) / 16)):255);
>    %subst(Output: oPos: 1) = wa;
>
>    ww = %bitand ((w(2) * 16 + %Int(w(3) / 4)):255);
>    %subst(Output: oPos + 1: 1)  = wa;
>
>    ww = %bitand ((w(3) * 64 + w(4)):255);
>     %subst(Output: oPos + 2: 1)  = wa;
>
>     i_attachement += 4;
>     o_attachement += 3;
>
>   enddo;
>
>   // set the final attachement size into workspace
>   s_attachement = o_attachement - p_attachement - %size(attachement);
>   attachSize = %trim(%editc(s_attachement:'Z'));
>
>   *inlr = *on;
>
>  /end-free
>
> P MimeDecode      B
> D MimeDecode      PI            10I 0
> D  Input                         1A   const
>  /free
>
>   return %scan(Input: tbBase64) - 1;
>  /end-free
> P MimeDecode      E
>
>
>
> --
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.
>


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.