Changeset 7ed3199 for lib


Ignore:
Timestamp:
2006-06-25T14:07:01Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
6e1fed7
Parents:
df1694b
Message:

Moved Base64-related functions to a separate file and added decode funtions.

Location:
lib
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • lib/Makefile

    rdf1694b r7ed3199  
    1010
    1111# [SH] Program variables
    12 objects = $(EVENT_HANDLER) http_client.o ini.o md5.o misc.o proxy.o rc4.o sha.o $(SSL_CLIENT) url.o
     12objects = base64.o $(EVENT_HANDLER) http_client.o ini.o md5.o misc.o proxy.o rc4.o sha.o $(SSL_CLIENT) url.o
    1313
    1414CFLAGS += -Wall
  • lib/misc.c

    rdf1694b r7ed3199  
    8282
    8383        return ret;
    84 }
    85 
    86 char *tobase64(const char *text)
    87 {
    88         char *out;
    89         int len;
    90        
    91         len = strlen(text);
    92         out = g_malloc((len + 2)    /* the == padding */
    93                             / 3     /* every 3-byte block */
    94                             * 4     /* becomes a 4-byte one */
    95                             + 1);   /* and of course, ASCIIZ! */
    96        
    97         base64_encode_real(text, len, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");
    98        
    99         return out;
    100 }
    101 
    102 void base64_encode_real(const unsigned char *in, int inlen, unsigned char *out, char *b64digits)
    103 {
    104         for (; inlen >= 3; inlen -= 3)
    105         {
    106                 *out++ = b64digits[in[0] >> 2];
    107                 *out++ = b64digits[((in[0]<<4) & 0x30) | (in[1]>>4)];
    108                 *out++ = b64digits[((in[1]<<2) & 0x3c) | (in[2]>>6)];
    109                 *out++ = b64digits[in[2] & 0x3f];
    110                 in += 3;
    111         }
    112         if (inlen > 0)
    113         {
    114                 *out++ = b64digits[in[0] >> 2];
    115                 if (inlen > 1)
    116                 {
    117                         *out++ = b64digits[((in[0]<<4) & 0x30) | (in[1]>>4)];
    118                         *out++ = b64digits[((in[1]<<2) & 0x3c)];
    119                 }
    120                 else
    121                 {
    122                         *out++ = b64digits[((in[0]<<4) & 0x30) | (in[1]>>4)];
    123                         *out++ = b64digits[64];
    124                 }
    125                 *out++ = b64digits[64];
    126         }
    127         *out = '\0';
    12884}
    12985
  • lib/misc.h

    rdf1694b r7ed3199  
    3030G_MODULE_EXPORT char *add_cr( char *text );
    3131G_MODULE_EXPORT char *strip_newlines(char *source);
    32 G_MODULE_EXPORT char *tobase64( const char *text );
    33 G_MODULE_EXPORT void base64_encode_real( const unsigned char *in, int inlen, unsigned char *out, char *b64digits );
    3432G_MODULE_EXPORT char *normalize( const char *s );
    3533G_MODULE_EXPORT void info_string_append( GString *str, char *newline, char *name, char *value );
  • lib/proxy.c

    rdf1694b r7ed3199  
    4141#include "nogaim.h"
    4242#include "proxy.h"
     43#include "base64.h"
    4344
    4445char proxyhost[128] = "";
  • lib/rc4.c

    rdf1694b r7ed3199  
    55*                                                                           *
    66*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
    7 *                                                                           *
    87*                                                                           *
    98*  This program is free software; you can redistribute it and/or modify     *
  • lib/rc4.h

    rdf1694b r7ed3199  
    55*                                                                           *
    66*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
    7 *                                                                           *
    87*                                                                           *
    98*  This program is free software; you can redistribute it and/or modify     *
Note: See TracChangeset for help on using the changeset viewer.