oRTP: include/ortp/str_utils.h Source File

- Main Page
- Data Structures
- Files

- File List
- Globals

# include/ortp/str_utils.h

    00001 /*
    00002   The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
    00003   Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
    00004
    00005   This library is free software; you can redistribute it and/or
    00006   modify it under the terms of the GNU Lesser General Public
    00007   License as published by the Free Software Foundation; either
    00008   version 2.1 of the License, or (at your option) any later version.
    00009
    00010   This library is distributed in the hope that it will be useful,
    00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013   Lesser General Public License for more details.
    00014
    00015   You should have received a copy of the GNU Lesser General Public
    00016   License along with this library; if not, write to the Free Software
    00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018 */
    00019
    00020 #ifndef STR_UTILS_H
    00021 #define STR_UTILS_H
    00022
    00023
    00024 #include <ortp/port.h>
    00025
    00026
    00027 typedef struct msgb
    00028 {
    00029         struct msgb *b_prev;
    00030         struct msgb *b_next;
    00031         struct msgb *b_cont;
    00032         struct datab *b_datap;
    00033         unsigned char *b_rptr;
    00034         unsigned char *b_wptr;
    00035         uint32_t reserved1;
    00036         uint32_t reserved2;
    00037 } mblk_t;
    00038
    00039 typedef struct datab
    00040 {
    00041         unsigned char *db_base;
    00042         unsigned char *db_lim;
    00043         void (*db_freefn)(void*);
    00044         int db_ref;
    00045 } dblk_t;
    00046
    00047 typedef struct _queue
    00048 {
    00049         mblk_t _q_stopper;
    00050         int q_mcount;   /*number of packet in the q */
    00051 } queue_t;
    00052
    00053 #ifdef __cplusplus
    00054 extern "C" {
    00055 #endif
    00056
    00057 void qinit(queue_t *q);
    00058
    00059 void putq(queue_t *q, mblk_t *m);
    00060
    00061 mblk_t * getq(queue_t *q);
    00062
    00063 void insq(queue_t *q,mblk_t *emp, mblk_t *mp);
    00064
    00065 void remq(queue_t *q, mblk_t *mp);
    00066
    00067 mblk_t * peekq(queue_t *q);
    00068
    00069 /* remove and free all messages in the q */
    00070 #define FLUSHALL 0
    00071 void flushq(queue_t *q, int how);
    00072
    00073 void mblk_init(mblk_t *mp);
    00074
    00075 /* allocates a mblk_t, that points to a datab_t, that points to a buffer of size size. */
    00076 mblk_t *allocb(int size, int unused);
    00077 #define BPRI_MED 0
    00078
    00079 /* allocates a mblk_t, that points to a datab_t, that points to buf; buf will be freed using freefn */
    00080 mblk_t *esballoc(uint8_t *buf, int size, int pri, void (*freefn)(void*) );
    00081
    00082 /* frees a mblk_t, and if the datab ref_count is 0, frees it and the buffer too */
    00083 void freeb(mblk_t *m);
    00084
    00085 /* frees recursively (follow b_cont) a mblk_t, and if the datab
    00086 ref_count is 0, frees it and the buffer too */
    00087 void freemsg(mblk_t *mp);
    00088
    00089 /* duplicates a mblk_t , buffer is not duplicated*/
    00090 mblk_t *dupb(mblk_t *m);
    00091
    00092 /* duplicates a complex mblk_t, buffer is not duplicated */
    00093 mblk_t  *dupmsg(mblk_t* m);
    00094
    00095 /* returns the size of data of a message */
    00096 int msgdsize(const mblk_t *mp);
    00097
    00098 /* concatenates all fragment of a complex message*/
    00099 void msgpullup(mblk_t *mp,int len);
    00100
    00101 /* duplicates a single message, but with buffer included */
    00102 mblk_t *copyb(mblk_t *mp);
    00103
    00104 /* duplicates a complex message with buffer included */
    00105 mblk_t *copymsg(mblk_t *mp);
    00106
    00107 mblk_t * appendb(mblk_t *mp, const char *data, int size, bool_t pad);
    00108 void msgappend(mblk_t *mp, const char *data, int size, bool_t pad);
    00109
    00110 mblk_t *concatb(mblk_t *mp, mblk_t *newm);
    00111
    00112 #define qempty(q) (&(q)->_q_stopper==(q)->_q_stopper.b_next)
    00113 #define qfirst(q) ((q)->_q_stopper.b_next!=&(q)->_q_stopper ? (q)->_q_stopper.b_next : NULL)
    00114 #define qbegin(q) ((q)->_q_stopper.b_next)
    00115 #define qlast(q) ((q)->_q_stopper.b_prev!=&(q)->_q_stopper ? (q)->_q_stopper.b_prev : NULL)
    00116 #define qend(q,mp)      ((mp)==&(q)->_q_stopper || ((mp)==&(q)->_q_stopper))
    00117 #define qnext(q,mp) ((mp)->b_next)
    00118 #ifdef __cplusplus
    00119 }
    00120 #endif
    00121
    00122 #endif