Mon Nov 6 06:42:53 2006

Asterisk developer's documentation


utils.h File Reference

Utility functions. More...

#include "asterisk/compat.h"
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <limits.h>
#include "asterisk/lock.h"
#include "asterisk/time.h"
#include "asterisk/strings.h"

Include dependency graph for utils.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_flags
struct  ast_hostent

Defines

#define ast_clear_flag(p, flag)
#define ast_clear_flag_nonstd(p, flag)
#define ast_copy_flags(dest, src, flagz)
#define ast_copy_flags_nonstd(dest, src, flagz)
#define AST_FLAGS_ALL   UINT_MAX
#define ast_pthread_create(a, b, c, d)   ast_pthread_create_stack(a,b,c,d,0)
#define ast_set2_flag(p, value, flag)
#define ast_set2_flag_nonstd(p, value, flag)
#define ast_set_flag(p, flag)
#define ast_set_flag_nonstd(p, flag)
#define AST_STACKSIZE   256 * 1024
#define ast_test_flag(p, flag)
#define ast_test_flag_nonstd(p, flag)
#define inet_ntoa   __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__

Functions

int ast_base64decode (unsigned char *dst, const char *src, int max)
int ast_base64encode (char *dst, const unsigned char *src, int srclen, int max)
void ast_enable_packet_fragmentation (int sock)
 Disable PMTU discovery on a socket.
hostent * ast_gethostbyname (const char *host, struct ast_hostent *hp)
const char * ast_inet_ntoa (char *buf, int bufsiz, struct in_addr ia)
void ast_md5_hash (char *output, char *input)
char * ast_process_quotes_and_slashes (char *start, char find, char replace_with)
 Process a string to find and replace characters.
int ast_pthread_create_stack (pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize)
void ast_uri_decode (char *s)
 Decode URI, URN, URL (overwrite string).
char * ast_uri_encode (char *string, char *outbuf, int buflen, int doreserved)
 Turn text string to URI-encoded XX version At this point, we're converting from ISO-8859-x (8-bit), not UTF8 as in the SIP protocol spec If doreserved == 1 we will convert reserved characters also. RFC 2396, section 2.4 outbuf needs to have more memory allocated than the instring to have room for the expansion. Every char that is converted is replaced by three ASCII characters.
int ast_utils_init (void)
int ast_wait_for_input (int fd, int ms)
int getloadavg (double *list, int nelem)
int test_for_thread_safety (void)

Variables

unsigned int __unsigned_int_flags_dummy


Detailed Description

Utility functions.

Definition in file utils.h.


Define Documentation

#define ast_clear_flag_nonstd ( p,
flag   ) 

Value:

do { \
               ((p)->flags &= ~(flag)); \
               } while(0)

Definition at line 114 of file utils.h.

#define ast_copy_flags_nonstd ( dest,
src,
flagz   ) 

Value:

do { \
               (dest)->flags &= ~(flagz); \
               (dest)->flags |= ((src)->flags & (flagz)); \
               } while (0)

Definition at line 118 of file utils.h.

#define ast_set_flag_nonstd ( p,
flag   ) 

Value:

do { \
               ((p)->flags |= (flag)); \
               } while(0)

Definition at line 110 of file utils.h.

#define ast_test_flag_nonstd ( p,
flag   ) 

Value:

({ \
               ((p)->flags & (flag)); \
               })

Definition at line 106 of file utils.h.


Function Documentation

void ast_enable_packet_fragmentation ( int  sock  ) 

Disable PMTU discovery on a socket.

Parameters:
sock The socket to manipulate
Returns:
Nothing
On Linux, UDP sockets default to sending packets with the Dont Fragment (DF) bit set. This is supposedly done to allow the application to do PMTU discovery, but Asterisk does not do this.

Because of this, UDP packets sent by Asterisk that are larger than the MTU of any hop in the path will be lost. This function can be called on a socket to ensure that the DF bit will not be set.

char* ast_process_quotes_and_slashes ( char *  start,
char  find,
char  replace_with 
)

Process a string to find and replace characters.

Parameters:
start The string to analyze
find The character to find
replace_with The character that will replace the one we are looking for

void ast_uri_decode ( char *  s  ) 

Decode URI, URN, URL (overwrite string).

Parameters:
s String to be decoded

char* ast_uri_encode ( char *  string,
char *  outbuf,
int  buflen,
int  doreserved 
)

Turn text string to URI-encoded XX version At this point, we're converting from ISO-8859-x (8-bit), not UTF8 as in the SIP protocol spec If doreserved == 1 we will convert reserved characters also. RFC 2396, section 2.4 outbuf needs to have more memory allocated than the instring to have room for the expansion. Every char that is converted is replaced by three ASCII characters.

ast_uri_encode

Parameters:
string String to be converted
outbuf Resulting encoded string
buflen Size of output buffer
doreserved Convert reserved characters


Variable Documentation

unsigned int __unsigned_int_flags_dummy

Note:
   Note:
   It is very important to use only unsigned variables to hold
   bit flags, as otherwise you can fall prey to the compiler's
   sign-extension antics if you try to use the top two bits in
   your variable.

   The flag macros below use a set of compiler tricks to verify
   that the caller is using an "unsigned int" variable to hold
   the flags, and nothing else. If the caller uses any other
   type of variable, a warning message similar to this:

   warning: comparison of distinct pointer types lacks cast
   will be generated.

   The "dummy" variable below is used to make these comparisons.

   Also note that at -O2 or above, this type-safety checking
   does _not_ produce any additional object code at all.
 


Generated on Mon Nov 6 06:42:53 2006 for Asterisk - the Open Source PBX by  doxygen 1.5.1