亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? buffer.c

?? Open DMT Client C Source code
?? C
字號:
// ----------------------------------------------------------------------------// Copyright 2006-2007, Martin D. Flynn// All rights reserved// ----------------------------------------------------------------------------//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at// // http://www.apache.org/licenses/LICENSE-2.0// // Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.//// ----------------------------------------------------------------------------// Description://  Circular buffer utility.// Notes://  This implementation uses 'malloc' to allocate space for the buffer.// ---// Change History://  2006/01/04  Martin D. Flynn//     -Initial release//  2007/01/28  Martin D. Flynn//     -WindowsCE port//     -Added 'bufferClear'//     -'bufferGetSize' and 'bufferGetLength' now return 'long'//     -Fixed byte addressing problem in 'bufferPutData'// ----------------------------------------------------------------------------#include "stdafx.h" // TARGET_WINCE#define SKIP_TRANSPORT_MEDIA_CHECK // only if TRANSPORT_MEDIA not used in this file #include "custom/defaults.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <stdarg.h>#include "custom/log.h"#include "tools/stdtypes.h"#include "tools/strtools.h"#include "tools/buffer.h"// ----------------------------------------------------------------------------/* create buffer */CircleBuffer_t *bufferCreate(long size){    CircleBuffer_t *cb = (CircleBuffer_t*)malloc(sizeof(CircleBuffer_t) + size + 1); // [MALLOC]    if (cb) {        cb->head = 0L; // next available char        cb->tail = 0L; // fist valid char        cb->size = size + 1L; // 1 byte is used as the marker byte at the head    } else {        logCRITICAL(LOGSRC,"OUT OF MEMORY!!");    }    return cb;}/* destroy buffer */void bufferDestroy(CircleBuffer_t *cb){    if (cb) {        free((void*)cb);    }}/* clear all data in buffer */void bufferClear(CircleBuffer_t *cb){    if (cb) {        cb->head = 0L; // next available char        cb->tail = 0L; // fist valid char    }}// ----------------------------------------------------------------------------/* return total size of buffer */long bufferGetSize(CircleBuffer_t *cb){    // return size of buffer    return cb? cb->size - 1L : 0L;}/* return amount of data in buffer */long bufferGetLength(CircleBuffer_t *cb){    // return length of data currently in buffer    if (!cb) {        return 0;    } else    if (cb->head >= cb->tail) {        return cb->head - cb->tail;    } else {        return cb->size - (cb->tail - cb->head);    }}// ----------------------------------------------------------------------------/* put character into buffer */utBool bufferPutChar(CircleBuffer_t *cb, UInt8 c){        /* save pointer to current head */    UInt8 *p = &cb->buff[cb->head];        /* advance head */    int newHead = cb->head + 1;    if (newHead >= cb->size) {         //logDEBUG(LOGSRC,"bufferPutChar", "Buffer wrap-around");        newHead = 0;     }    if (newHead == cb->tail) {        return utFalse; // buffer overflow    }        /* save char */    *p = c;    cb->head = newHead;    return utTrue;    }/* get character from buffer */int bufferGetChar(CircleBuffer_t *cb){    if (cb->head == cb->tail) {        return -1;    } else {        UInt8 c = cb->buff[cb->tail++];        if (cb->tail >= cb->size) { cb->tail = 0; }        return c;    }}// ----------------------------------------------------------------------------/* put data block into buffer */int bufferPutData(CircleBuffer_t *cb, const void *data, int dataLen){        /* precheck availability in buffer */    if (dataLen >= (bufferGetSize(cb) - bufferGetLength(cb))) {        return 0;    }        /* add data */    int i;    UInt8 *s = (UInt8*)data;    for (i = 0; i < dataLen; i++) {        bufferPutChar(cb, s[i]);    }        return dataLen;    }/* get data block from buffer */int bufferGetData(CircleBuffer_t *cb, void *data, int dataLen){    if (!cb) {        return -1;    } else    if (bufferGetLength(cb) <= 0) {        return 0;    } else {        UInt8 *d = (UInt8*)data;        int i = 0;        for (;i < dataLen; i++) {            int c = bufferGetChar(cb);            if (c < 0) {                // we've run out of buffer before we got to the end of the data                memset(&d[i], 0, dataLen - i); // clear remainder of buffer                break;            } else {                d[i] = (UInt8)c;            }        }        return i;    }}// ----------------------------------------------------------------------------/* put null-terminated string into buffer */utBool bufferPutString(CircleBuffer_t *cb, const char *s){        /* precheck availability in buffer */    int slen = strlen(s) + 1; // include terminator in length    if (slen >= (bufferGetSize(cb) - bufferGetLength(cb))) {        return utFalse;    }        /* add string */    // could be optimized (most of the time this strng will not wrap around)    for (; (*s); s++) {        bufferPutChar(cb, *s);    }        /* add string terminator */    bufferPutChar(cb, 0);        return utTrue;    }/* get null-terminated string from buffer */int bufferGetString(CircleBuffer_t *cb, char *d, int dlen){    if (bufferGetLength(cb) <= 0) {                /* buffer is empty */        return 0;            } else {                /* if destination string is NULL, then just throw away the next string */        if (!d) { dlen = bufferGetSize(cb); }                /* get */        int i = 0;        for (; i < (dlen - 1); i++) { // <-- save room for terminator            int c = bufferGetChar(cb);            if (c < 0) {                // we've run out of buffer before we got to the terminator                if (d) { d[i] = 0; } // terminate                break;            } else            if (c == 0) {                // here's the terminator                if (d) { d[i] = 0; } // terminate                break;            } else {                if (d) { d[i] = (UInt8)c; }            }        }                /* check final termination */        if (i >= (dlen - 1)) {            // we've run out of space in the destination string            if (d) { d[dlen - 1] = 0; } // make sure string is terminated        }                return strlen(d);            }}// ----------------------------------------------------------------------------/* copy the next string into the buffer, do not advance buffer pointers */char *bufferCopyString(CircleBuffer_t *cb, char *d, int dlen){    if (bufferGetLength(cb) <= 0) {                /* buffer is empty */        return (char*)0;            } else {                /* save current head/tail values */        int oldHead = cb->head;        int oldTail = cb->tail;                /* if destination string is NULL, then just throw away the next string */        if (!d) { dlen = bufferGetSize(cb); }                /* copy */        int i = 0;        for (; i < (dlen - 1); i++) { // <-- save room for terminator            int c = bufferGetChar(cb);            if (c < 0) {                // we've run out of buffer before we got to the terminator                if (d) { d[i] = 0; } // terminate                break;            } else            if (c == 0) {                // here's the terminator                if (d) { d[i] = 0; } // terminate                break;            } else {                if (d) { d[i] = (UInt8)c; }            }        }                /* check final termination */        if (i >= (dlen - 1)) {            // we've run out of space in the destination string            if (d) { d[dlen - 1] = 0; } // make sure string is terminated        }                /* restore prior values */        cb->head = oldHead;        cb->tail = oldTail;                return d;    }}// ----------------------------------------------------------------------------/* count the number of strings in the buffer */int bufferGetStringCount(CircleBuffer_t *cb){    int count = 0;    int t = cb->tail;    for (;t != cb->head;) {        if (!cb->buff[t]) { count++; }        t++;        if (t > cb->size) { t = 0; }    }    return count;}// ----------------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲视频免费观看| 丝袜美腿高跟呻吟高潮一区| 在线欧美日韩精品| 国内外成人在线| 亚洲精品伦理在线| 337p日本欧洲亚洲大胆精品| 欧美视频一区二区三区在线观看| 在线91免费看| 狠狠色狠狠色综合日日91app| 欧美一级高清大全免费观看| 99久久精品国产一区| 日韩精品91亚洲二区在线观看| 在线观看av一区二区| 粉嫩久久99精品久久久久久夜| 精品国产制服丝袜高跟| 欧美日韩在线播| 成人一区二区在线观看| 蜜桃精品视频在线| 五月婷婷综合激情| 日韩毛片高清在线播放| 国产视频一区二区在线| 日韩一二三四区| 欧美精品日日鲁夜夜添| 日本精品免费观看高清观看| 成人18精品视频| 国产成人午夜99999| 久久99久久99| 免费在线观看精品| 琪琪一区二区三区| 亚洲一区二区三区在线| 樱花影视一区二区| 亚洲女同ⅹxx女同tv| 亚洲欧洲性图库| 国产精品久久久久久久久免费樱桃 | 欧美精品一区二区三区视频| 精品视频999| 欧美性受xxxx黑人xyx性爽| 日本高清不卡视频| 一本久久精品一区二区| 国产成人在线视频免费播放| 国产麻豆91精品| 国产一区二区不卡| 粉嫩绯色av一区二区在线观看| 亚洲人成精品久久久久| 国产精品久久久久三级| 1000精品久久久久久久久| 国产精品午夜春色av| 国产精品系列在线| 中文字幕在线不卡一区| 亚洲精选一二三| 亚洲香肠在线观看| 亚洲777理论| 日本不卡高清视频| 蜜臀va亚洲va欧美va天堂 | 肉丝袜脚交视频一区二区| 亚洲综合清纯丝袜自拍| 亚洲精品免费在线播放| 三级一区在线视频先锋 | 日韩欧美亚洲国产另类| 亚洲精品一区二区三区在线观看| 99精品视频一区| 日本二三区不卡| 欧美系列日韩一区| 日韩免费成人网| 久久久精品国产免大香伊| 国产精品免费视频一区| 亚洲免费观看在线观看| 日韩成人av影视| 国产91精品入口| 日本高清不卡aⅴ免费网站| 欧美一区中文字幕| 国产午夜亚洲精品午夜鲁丝片| 欧美一级生活片| 欧美国产精品v| 亚洲一区二区三区四区在线观看 | 日韩视频在线一区二区| 久久久久久久国产精品影院| 中文字幕一区二| 日韩电影在线免费观看| 国产黄色成人av| 色噜噜狠狠一区二区三区果冻| 国产成人在线观看免费网站| 91久久一区二区| 精品福利二区三区| 一区二区三区精品在线| 精品一区二区三区av| 91福利精品视频| 久久免费的精品国产v∧| 亚洲黄色av一区| 麻豆91免费观看| 日本精品免费观看高清观看| 精品国产91亚洲一区二区三区婷婷| 精品久久久久久综合日本欧美| 717成人午夜免费福利电影| 久久精品欧美日韩| 亚洲一区二区三区中文字幕在线| 一区二区国产视频| 国产剧情一区二区| 欧美日韩中字一区| 国产精品久久777777| 麻豆精品精品国产自在97香蕉| 男人的j进女人的j一区| 色av成人天堂桃色av| 国产日产欧美一区二区视频| 视频一区欧美精品| 99精品热视频| 国产视频一区在线播放| 另类综合日韩欧美亚洲| 色婷婷亚洲一区二区三区| 国产欧美视频在线观看| 久久国产精品99久久久久久老狼| 精品一区二区三区免费观看| 欧美日韩一二三| 亚洲激情综合网| 成人免费毛片片v| 欧美r级在线观看| 日韩精品国产精品| 欧美综合久久久| 一区二区三区在线观看视频| 成人h动漫精品一区二区| 久久婷婷国产综合国色天香 | 亚洲精品日韩专区silk| 国产不卡一区视频| 久久精品亚洲国产奇米99| 美女一区二区在线观看| 欧美亚洲动漫精品| 亚洲黄一区二区三区| 91丝袜呻吟高潮美腿白嫩在线观看| 欧美体内she精高潮| 亚洲天堂中文字幕| 91在线播放网址| 亚洲色欲色欲www| 91毛片在线观看| 中文字幕一区二区三| 99国内精品久久| 亚洲欧美另类久久久精品2019| 日本va欧美va欧美va精品| 欧美精品一卡两卡| 天涯成人国产亚洲精品一区av| 激情久久久久久久久久久久久久久久| 成人免费电影视频| 国产精品久久久久久久久动漫 | 亚洲女性喷水在线观看一区| 91麻豆成人久久精品二区三区| 欧美精品tushy高清| 三级欧美在线一区| 3atv一区二区三区| 美女精品自拍一二三四| 久久综合狠狠综合久久激情 | 亚洲国产一区二区a毛片| 在线观看一区二区精品视频| 一级日本不卡的影视| 精品视频1区2区3区| 全部av―极品视觉盛宴亚洲| 欧美www视频| 福利视频网站一区二区三区| 国产精品系列在线| 在线国产亚洲欧美| 日韩av不卡在线观看| 久久欧美中文字幕| 91丨国产丨九色丨pron| 亚洲综合av网| 精品国产乱码久久久久久老虎| 一区二区在线观看免费视频播放| 国产精品一二三四| 中文字幕视频一区| 欧美三级乱人伦电影| 精品一区二区三区在线播放| 国产精品你懂的在线欣赏| 欧美视频在线观看一区| 精品亚洲aⅴ乱码一区二区三区| 欧美女孩性生活视频| 国产乱一区二区| 亚洲综合区在线| 久久蜜桃av一区二区天堂| 色先锋资源久久综合| 看电影不卡的网站| 综合久久综合久久| 欧美zozozo| 欧美午夜电影网| 国产福利一区二区三区视频在线| 日韩女同互慰一区二区| 播五月开心婷婷综合| 亚洲一二三区在线观看| 国产无一区二区| 欧美日韩国产首页| 成人三级伦理片| 蜜桃精品视频在线观看| 亚洲人123区| 欧美精品一区二区三区蜜臀| 91丨九色丨尤物| 国产精品一级二级三级| 天天色天天爱天天射综合| 国产欧美日产一区| 日韩一级欧美一级| 欧美三级中文字| 91色婷婷久久久久合中文| 黄色成人免费在线| 日日欢夜夜爽一区| 亚洲黄色av一区|