#include <stdio.h>#include <stdlib.h>#include <string.h>#include <limits.h>#include <ctype.h>#include "bstraux.h"Data Structures | |
| struct | bUuInOut |
| struct | bsUuCtx |
| struct | bwriteStream |
Macros | |
| #define | B64_PAD (-2) |
| #define | B64_ERR (-1) |
| #define | UU_DECODE_BYTE(b) |
| #define | UU_MAX_LINELEN 45 |
| #define | UU_ENCODE_BYTE(b) |
| #define | MAX_OB_LEN (64) |
| #define | INIT_SECURE_INPUT_LENGTH (256) |
| #define | BWS_BUFF_SZ (BUFSIZ) |
| #define | internal_bwswriteout(ws, b) |
Functions | |
| bstring | bTail (bstring b, int n) |
| bstring | bHead (bstring b, int n) |
| int | bFill (bstring b, char c, int len) |
| int | bReplicate (bstring b, int n) |
| int | bReverse (bstring b) |
| int | bInsertChrs (bstring b, int pos, int len, unsigned char c, unsigned char fill) |
| int | bJustifyLeft (bstring b, int space) |
| int | bJustifyRight (bstring b, int width, int space) |
| int | bJustifyCenter (bstring b, int width, int space) |
| int | bJustifyMargin (bstring b, int width, int space) |
| static size_t | readNothing (BSTR_UNUSED void *buff, BSTR_UNUSED size_t elsize, BSTR_UNUSED size_t nelem, BSTR_UNUSED void *parm) |
| struct bStream * | bsFromBstr (const bstring b) |
| static size_t | readRef (void *buff, size_t elsize, size_t nelem, void *parm) |
| static struct bStream * | bsFromBstrRef (struct tagbstring *t) |
| char * | bStr2NetStr (const bstring b) |
| bstring | bNetStr2Bstr (const char *buff) |
| bstring | bBase64Encode (const bstring b) |
| static int | base64DecodeSymbol (unsigned char alpha) |
| bstring | bBase64DecodeEx (const bstring b, int *boolTruncError) |
| static int | bUuDecLine (void *parm, int ofs, int len) |
| bstring | bUuDecodeEx (const bstring src, int *badlines) |
| static size_t | bsUuDecodePart (void *buff, size_t elsize, size_t nelem, void *parm) |
| struct bStream * | bsUuDecode (struct bStream *sInp, int *badlines) |
| bstring | bUuEncode (const bstring src) |
| bstring | bYEncode (const bstring src) |
| bstring | bYDecode (const bstring src) |
| bstring | bStrfTime (const char *fmt, const struct tm *timeptr) |
| int | bSetCstrChar (bstring b, int pos, char c) |
| int | bSetChar (bstring b, int pos, char c) |
| bstring | bSecureInput (int maxlen, int termchar, bNgetc vgetchar, void *vgcCtx) |
| struct bwriteStream * | bwsOpen (bNwrite writeFn, void *parm) |
| int | bwsWriteFlush (struct bwriteStream *ws) |
| int | bwsWriteBstr (struct bwriteStream *ws, const bstring b) |
| int | bwsWriteBlk (struct bwriteStream *ws, void *blk, int len) |
| int | bwsIsEOF (const struct bwriteStream *ws) |
| int | bwsBuffLength (struct bwriteStream *ws, int sz) |
| void * | bwsClose (struct bwriteStream *ws) |
Variables | |
| static char | b64ETable [] |
| #define B64_ERR (-1) |
| #define B64_PAD (-2) |
| #define BWS_BUFF_SZ (BUFSIZ) |
| #define INIT_SECURE_INPUT_LENGTH (256) |
| #define internal_bwswriteout | ( | ws, | |
| b ) |
| #define MAX_OB_LEN (64) |
| #define UU_DECODE_BYTE | ( | b | ) |
| #define UU_ENCODE_BYTE | ( | b | ) |
| #define UU_MAX_LINELEN 45 |
|
static |
Decode a base64 block of data.
All MIME headers are assumed to have been removed.
See: RFC1341
| int bFill | ( | bstring | a, |
| char | c, | ||
| int | len ) |
Fill a given bstring with the character in parameter c, for a length n.
| int bInsertChrs | ( | bstring | b, |
| int | pos, | ||
| int | len, | ||
| unsigned char | c, | ||
| unsigned char | fill ) |
Insert a repeated sequence of a given character into the string at position pos for a length len.
| int bJustifyCenter | ( | bstring | b, |
| int | width, | ||
| int | space ) |
Center a string's non-white space characters to within a given width by inserting whitespaces at the beginning.
| int bJustifyLeft | ( | bstring | b, |
| int | space ) |
Left justify a string.
| int bJustifyMargin | ( | bstring | b, |
| int | width, | ||
| int | space ) |
Stretch a string to flush against left and right margins by evenly distributing additional white space between words.
If the line is too long to be margin justified, it is left justified.
| int bJustifyRight | ( | bstring | b, |
| int | width, | ||
| int | space ) |
Right justify a string to within a given width.
| bstring bNetStr2Bstr | ( | const char * | buf | ) |
Convert a netstring to a bstring.
See http://cr.yp.to/proto/netstrings.txt for a description of netstrings.
Note that the terminating "," must be present, however a following '\0' is not required.
| int bReplicate | ( | bstring | b, |
| int | n ) |
Replicate the contents of b end to end n times and replace it in b.
| int bReverse | ( | bstring | b | ) |
Reverse the contents of b in place.
Read input from an abstracted input interface, for a length of at most maxlen characters.
If maxlen <= 0, then there is no length limit put on the input. The result is terminated early if vgetchar() return EOF or the user specified value termchar.
| int bSetChar | ( | bstring | b, |
| int | pos, | ||
| char | c ) |
Sets the character at position pos to the character c in the bstring a.
The string is not truncated if the character c is NUL ('\0'). pos must be in the position between 0 and b->slen inclusive, otherwise BSTR_ERR will be returned.
| int bSetCstrChar | ( | bstring | a, |
| int | pos, | ||
| char | c ) |
Sets the character at position pos to the character c in the bstring a.
If the character c is NUL ('\0') then the string is truncated at this point. Note: this does not enable any other '\0' character in the bstring as terminator indicator for the string. pos must be in the position between 0 and b->slen inclusive, otherwise BSTR_ERR will be returned.
|
static |
The "by reference" version of the above function.
This function puts a number of restrictions on the call site (the passed in struct tagbstring will be modified by this function, and the source data must remain alive and constant for the lifetime of the bStream). Hence it is not presented as an extern.
| char * bStr2NetStr | ( | const bstring | b | ) |
Convert a bstring to a netstring.
See http://cr.yp.to/proto/netstrings.txt for a description of netstrings.
Note: 1) The value returned should be freed with a call to bcstrfree() at the point when it will no longer be referenced to avoid a memory leak. 2) If the returned value is non-NULL, then it also '\0' terminated in the character position one past the "," terminator.
| bstring bStrfTime | ( | const char * | fmt, |
| const struct tm * | timeptr ) |
Takes a format string that is compatible with strftime and a struct tm pointer, formats the time according to the format string and outputs the bstring as a result.
Note that if there is an early generation of a '\0' character, the bstring will be truncated to this end point.
Creates a bStream which performs the UUDecode of an an input stream.
If there are errors in the decoding, they are counted up and returned in "badlines", if badlines is not NULL. It is assumed that the "begin" and "end" lines have already been stripped off. The potential security problem of writing the filename in the begin line is something that is beyond the scope of a portable library.
|
static |
|
static |
Performs a UUDecode of a block of data.
If there are errors in the decoding, they are counted up and returned in "badlines", if badlines is not NULL. It is assumed that the "begin" and "end" lines have already been stripped off. The potential security problem of writing the filename in the begin line is something that is beyond the scope of a portable library.
Performs a UUEncode of a block of data.
The "begin" and "end" lines are not appended.
| int bwsBuffLength | ( | struct bwriteStream * | stream, |
| int | sz ) |
Set the length of the buffer used by the bwsStream.
If sz is zero, the length is not set. This function returns with the previous length.
| void * bwsClose | ( | struct bwriteStream * | stream | ) |
Close the bwriteStream, and return the handle to the stream that was originally used to open the given stream.
Note that even if the stream is at EOF it still needs to be closed with a call to bwsClose.
| int bwsIsEOF | ( | const struct bwriteStream * | stream | ) |
Returns 0 if the stream is currently writable, 1 if the core stream has responded by not accepting the previous attempted write.
| struct bwriteStream * bwsOpen | ( | bNwrite | writeFn, |
| void * | parm ) |
Wrap a given open stream (described by a fwrite work-a-like function pointer and stream handle) into an open bwriteStream suitable for write streaming functions.
| int bwsWriteBlk | ( | struct bwriteStream * | stream, |
| void * | blk, | ||
| int | len ) |
Send a block of data a bwriteStream.
If the stream is at EOF BSTR_ERR is returned.
| int bwsWriteBstr | ( | struct bwriteStream * | stream, |
| const bstring | b ) |
Send a bstring to a bwriteStream.
If the stream is at EOF BSTR_ERR is returned. Note that there is no deterministic way to determine the exact cut off point where the core stream stopped accepting data.
| int bwsWriteFlush | ( | struct bwriteStream * | stream | ) |
Force any pending data to be written to the core stream.
Performs a YDecode of a block of data.
See: https://yence.sourceforge.net/docs/protocol/version1_3_draft.html
Performs a YEncode of a block of data.
No header or tail info is appended.
See: https://yence.sourceforge.net/docs/protocol/version1_3_draft.html
|
static |
|
static |
|
static |