CMIMEENC, CMIMEDEC. Donde encontrar estas dos funciones?

Post Reply
jgvivasc
Posts: 11
Joined: Mon Oct 27, 2008 2:18 pm

CMIMEENC, CMIMEDEC. Donde encontrar estas dos funciones?

Post by jgvivasc »

A que libreria pertenecen las funciones "cmimeenc" y "cmimedec"?.
Estoy trabajando (bajo 16 bits) en una aplicación para el envio de mensajes empleando TSMTP y me hacen falta estas dos funciones.

Gracias,


Julio Vivas
Caracas - Venezuela
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Julio,

Son funciones que proporciona FiveWin. Aqui tienes el código fuente:

Code: Select all

//&& HEADER FILE --------------------------------------------------------------
//    File Name: mime64.c
//  Description: Mime Based Encoding/Decoding.
//       Author: Jim Gale
// Date created: 8/28/97               Date updated: þ5/1/98
//    Copyright: 1998 by Gale-Force. All Rights Reserved.
//        Email: jg5@gale-force.com
//-----------------------------------------------------------------------------

#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

static char cMime[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

unsigned int at(char c1, char *c2);

CLIPPER CMIMEDEC( PARAMS )
{
   int x, nIn, nLen, nOut;
   unsigned short int n2, n3, n1, n4;
   char far *cIn, *cOut;

   cIn  = _parc(1);
   nIn  = _parclen(1);

   nLen = ((nIn+3)*3/4)+1;

   cOut = ( char * ) _xgrab(nLen);
   nOut = -1;

   for(x=0;x<nIn;x+=4)
   {
      n1 = at((char) cIn[x]  ,cMime);
      n2 = at((char) cIn[x+1],cMime);

      if ( (n3 = at((char) cIn[x+2],cMime))==64 ) {
         cOut[++nOut] =  (( ( n1 << 2) & 252 ) | ((n2 >> 4) & 3) );
         break;
      }

      if ( (n4 = at((char) cIn[x+3],cMime))==64 ) {
         cOut[++nOut] =  (( ( n1 << 2) & 252 ) | ((n2 >> 4) & 3) );
         cOut[++nOut] =  (( ( n2 << 4) & 240 ) | ( (n3 >> 2) & 15) );
         break;
      }

      cOut[++nOut] =  (( ( n1 << 2) & 252 ) |  ((n2 >> 4) & 3) );
      cOut[++nOut] =  (( ( n2 << 4) & 240 ) | ( (n3 >> 2) & 15) );
      cOut[++nOut] =  (( ( n3 << 6) & 192 ) |  ( n4 & 63) );

   }
   _retclen( cOut, nOut+1 );
   _xfree( cOut );

}

unsigned int at(char c1, char *c2)
{
   int x=-1,nLen;
   nLen = 65; //sizeof(c2);
   while(++x<nLen)
   {
      if( (char) c1 == (char) c2[x] )
         return x;
   }
   return 0;
}

CLIPPER CMIMEENC( PARAMS )
{
   int x, nIn, nLen, nOut;
   unsigned short int n2, n3, n1, n4, nA1, nA2, nA3;
   char far *cIn, *cOut;

   cIn  = _parc(1);
   nIn  = _parclen(1);

   nLen = ((nIn+2)*4/3)+1;

   cOut = ( char * ) _xgrab(nLen);
   nOut = -1;

   for(x=0;x<nIn;x+=3)
   {
      switch ( nIn-x )
      {
         case 1 :
            nA1 = ((char) (cIn[x  ]));
            n1  = ( ( nA1 >> 2) & 63 );
            n2  = ( ( nA1 << 4) & 48 );
            cOut[++nOut] =  (char) cMime[n1];
            cOut[++nOut] =  (char) cMime[n2];
            cOut[++nOut] =  '=';
            cOut[++nOut] =  '=';
            break;

         case 2 :
            nA1 = ((char) (cIn[x  ]));
            nA2 = ((char) (cIn[x+1]));
            n1  = ( ( nA1 >> 2) & 63 );
            n2  = ( ( ( nA1 << 4) & 48 ) | ( ( nA2 & 240 ) >> 4 ) );
            n3  = ( ( ( nA2 << 4) & 240 ) >> 2 );
            cOut[++nOut] =  (char) cMime[n1];
            cOut[++nOut] =  (char) cMime[n2];
            cOut[++nOut] =  (char) cMime[n3];
            cOut[++nOut] =  '=';
            break;

         default:
            nA1 = ((char) (cIn[x  ]));
            nA2 = ((char) (cIn[x+1]));
            nA3 = ((char) (cIn[x+2]));

            n1  = ( ( nA1 >> 2) & 63 );
            n2  = ( ( ( nA1 << 4) & 48 ) | ( ( nA2 & 240 ) >> 4 ) );
            n3  = ( ( ( ( nA2 << 4) & 240 ) >> 2 ) | ( ( nA3 >> 6 ) & 3 ) );
            n4  = ( nA3 & 63 );

            cOut[++nOut] =  (char) cMime[n1];
            cOut[++nOut] =  (char) cMime[n2];
            cOut[++nOut] =  (char) cMime[n3];
            cOut[++nOut] =  (char) cMime[n4];

      }

   }
   cOut[nOut+1] = 0;

   _retclen( cOut, nOut+1 );
   _xfree( cOut );

}
regards, saludos

Antonio Linares
www.fivetechsoft.com
jgvivasc
Posts: 11
Joined: Mon Oct 27, 2008 2:18 pm

Post by jgvivasc »

Diciembre 08, 2008

Muchas gracias Antonio, supuse que serian funciones del mismo FIVEWIN, pero la version que tengo no las contiene, no se si es porque el fivewin que utilizo es muy antiguo o porque en algun momento perdí las fuentes de "mime64.c".

Nuevamente gracias y perdona las molestias.




Julio Vivas
Caracas - Venezuela
Post Reply