Funcion "cmimeenc"

Funcion "cmimeenc"

Postby jgvivasc » Sun Nov 30, 2008 3:48 am

Quisiera saber donde puedo conseguir la funcion "cmimeenc".
jgvivasc
 
Posts: 11
Joined: Mon Oct 27, 2008 2:18 pm

Postby Antonio Linares » Mon Dec 08, 2008 8:53 am

Son funciones que proporciona FiveWin. Aqui tienes su código fuente:
Code: Select all  Expand view  RUN
//&& 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby jgvivasc » Tue Dec 09, 2008 3:54 am

Diciembre 08, 2008

Muchas gracias Antonio,

Voy a efectuar pruebas a ver si logro que la aplicación funcione.


Saludos,


Julio Vivas
Caracas - Venezuela
jgvivasc
 
Posts: 11
Joined: Mon Oct 27, 2008 2:18 pm


Return to FiveWin para CA-Clipper

Who is online

Users browsing this forum: No registered users and 4 guests