× 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 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

----- Original Message ----- 
From: <Rick.Chevalier@xxxxxxxxxxxxxxx>
To: <rpg400-l@xxxxxxxxxxxx>
Sent: Wednesday, November 10, 2004 12:35 AM
Subject: Base64 Encoding


Does anyone know where I can find RPG examples of decoding a base64 string?
Numerous searches result in lots of mine hits, and standards documents but
nothing I can use in RPG.

Rick
--
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.