Программирование - вопрос/ответ



         

Программирование - часть 24



  while (nprbytes > 0) {
    *(bufout++) =
 (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
  *(bufout++) =
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
  *(bufout++) =
  (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
  bufin += 4;
    nprbytes -= 4;
  }

     if(nprbytes & 03) {
   if(pr2six[bufin[-2]] > 63)
      nbytesdecoded -= 2;
         else
     nbytesdecoded -= 1;
     }

  ((CHAR *)BufferQueryPtr(pbuffdecoded))[nbytesdecoded] = '\0';

     return TRUE;
}


BOOL
uuencode(
     BYTE * bufin,
     DWORD nbytes,
     BUFFER * pbuffEncoded )
/*++

  Routine Description:

     uuencode a string of data

  Arguments:

     bufin pointer to data to encode
     nbytes number of bytes to encode
     pbuffEncoded pointer to output BUFFER structure

  Return Value:

     Returns TRUE is successful; otherwise FALSE is returned.

--*/
{
    unsigned char *outptr;
    unsigned int i;

    //
    // Resize the buffer to 133% of the incoming data
    //

if ( !BufferResize( pbuffEncoded, nbytes + ((nbytes + 3) / 3) + 4))
    return FALSE;

 outptr = (unsigned char *) BufferQueryPtr(pbuffEncoded);

    for (i=0; i<nbytes; i += 3) {
 *(outptr++) = six2pr[*bufin >> 2]; /* c1 */<*/
 *(outptr++) = six2pr[((*bufin << 4) & 060) | ((bufin[1] >> 4) & 017)]; /*c2*/



Содержание  Назад  Вперед