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

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

?? dhcp-stringbuffer.c

?? this is sample about DHCP-agent
?? C
字號:
/* $Header: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-stringbuffer.c,v 1.11 2002/12/30 06:29:19 actmodern Exp $ * * Copyright 2002 Thamer Alharbash * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *  * Sringbuffer object: *  * (*) allows printfing into a string, * (*) fast string manipulation by keeping track of string length. * (*) alignment of string against columns. * * Internally stringbuffer does not count the terminating null as the length. * Therefore the raw string routines will always assume +1 when given length. */#define MODULE_NAME "dhcp-stringbuffer"#include "dhcp-local.h"#include "dhcp-libutil.h"/* * * * * * * * * * * * * * raw string routines.  * * * * * * * * * * * * * *//* just malloc out a string. */static char *allocate_string(int len){    char *s;    s = xmalloc(sizeof(char) * len + 1); /* add for null termination. */    s[len] = 0;    return s;}/* extend a string. */static char *extend_string(char *str, int cur_len, int ex_len){    str = xrealloc(str, (cur_len * sizeof(char)) + (ex_len * sizeof(char)) + (1 * sizeof(char)));    str[cur_len] = 0; /* make sure it's null terminated. */    return str;}/* get a substring. */static char *substring(char *begin, int len){    char *new_string;    new_string = allocate_string(len);    memcpy(new_string, begin, len);    new_string[len] = 0;    return new_string;}/* FIXME: get rid of pesky strlen() *//* used in aligning -- we try to get words up to end. */static char *get_string_align(char *s, int end, int *len){    char *cur_ptr;    if(s == 0 || *s == 0) /* end of string or no string. */        return NULL;    /* if strlen is smaller than len go ahead and just return it. */    if(strlen(s) < end) {        *len = strlen(s);        return xstrdup(s);    }    /* otherwise we need to hop to len */    cur_ptr = &s[end - 1];    /* now check to see if we have a whitespace behind cur_ptr     * if we do return at that point. */    for(; cur_ptr != s; cur_ptr--) {        if(*cur_ptr == ' ' || *cur_ptr == '\t') {            /* copy here and return. */            *len = (cur_ptr - s) + 1;            return (substring(s, *len));        }    }    /* keep walking till we find whitspace or end. */    for(cur_ptr = &s[end - 1]; *cur_ptr != 0 && *cur_ptr != ' ' && *cur_ptr != '\t'; cur_ptr++);    *len = (cur_ptr - s) + 1;    return (substring(s, *len));}/* zap newlines by placing spaces in their place. * we use this before aligning. */static void stringbuffer_zap_newline(stringbuffer_t *sb){    stringbuffer_replace_c(sb, '\n', ' ');    stringbuffer_replace_c(sb, '\r', ' ');}/* * * * * * * * * * * * * * * * stringbuffer routines.    * * * * * * * * * * * * * * * *//* create a new stringbuffer */stringbuffer_t *stringbuffer_create(void){    stringbuffer_t *sb;    sb = xmalloc(sizeof(stringbuffer_t));    sb->len = 0;    sb->capacity = 0;    sb->buf = allocate_string(0);    return sb;}/* destroy the stringbuffer */void stringbuffer_destroy(stringbuffer_t *sb){    xfree(sb->buf);    xfree(sb);}/* clear a string. */void stringbuffer_clear(stringbuffer_t *sb){    sb->len = 0;    sb->buf[0] = 0;}/* append character to stringbuffer */void stringbuffer_append_c(stringbuffer_t *sb, char c){    if(sb->capacity <= (sb->len)) {        sb->buf = extend_string(sb->buf, sb->len, STRINGBUFFER_CHUNKSIZE);        sb->capacity += STRINGBUFFER_CHUNKSIZE;    }    sb->buf[sb->len] = c;    sb->len++;    sb->buf[sb->len] = 0;}/* append string to stringbuffer */void stringbuffer_append(stringbuffer_t *sb, const char *s){    int len = strlen(s);    /* increase capacity if needed. */    if(sb->capacity <= (len + sb->len)) {        /* if we're bigger than the chunksize then allocate len. */        if(len > STRINGBUFFER_CHUNKSIZE) {            sb->buf = extend_string(sb->buf, sb->capacity, len);            sb->capacity += len;        } else {            /* otherwise allocate chunksize. */            sb->buf = extend_string(sb->buf, sb->capacity, STRINGBUFFER_CHUNKSIZE);            sb->capacity += STRINGBUFFER_CHUNKSIZE;        }    }    /* copy new string into place: keep in mind we know all     * lengths so strcat() would be less effecient. */    memcpy(&sb->buf[sb->len], s, len);    sb->len += len;    sb->buf[sb->len] = 0;    return;}/* remove whitespace (including tabs) */stringbuffer_t *stringbuffer_trim_whitespace(stringbuffer_t *sb){    char *newbuf;    int new_len;    int i, j;    if(sb->len == 0) /* empty string. */        return sb;    /* find beginning of string after tabs and whitespaces. */    for(i = 0; i < sb->len && (sb->buf[i] == ' ' || sb->buf[i] == '\t'); i++);    if(sb->buf[i] != '\0') {        /* we do have whitespace in the beginning so find the end. */        for(j = (sb->len -1);(sb->buf[j] == ' ' || sb->buf[j] == '\t'); j--);        /* increment j since it's on the non whitespace character. */        j++;        /* create a new string. */        new_len = j - i;        newbuf = allocate_string(new_len);        /* copy in. */        memcpy(newbuf, &sb->buf[i], (j - i) * sizeof(char));        newbuf[new_len] = 0;        /* free up old. */        xfree(sb->buf);        /* set new. */        sb->buf = newbuf;        sb->len = new_len;        sb->capacity = new_len;    } else {        /* zap beginning of string. since its all whitespace. */        sb->buf[0] = 0;        sb->len = 0;    }    return sb;}/* get the last occurance of a specific character. useful for slicing. */char *stringbuffer_get_last_occurance(stringbuffer_t *sb, char c){    char *ptr, *ptrend = NULL;    int i;    ptr = sb->buf;    for(i = 0;i < sb->len;i++) {        if(ptr[i] == c)            ptrend = &ptr[i];    }    return ptrend;}/* remove the last newline character. */void stringbuffer_trim_newline(stringbuffer_t *sb){    char *ptr;    ptr = stringbuffer_get_last_occurance(sb, '\n');    if(ptr != NULL)        *ptr = 0;    ptr = stringbuffer_get_last_occurance(sb, '\r');    if(ptr != NULL)        *ptr = 0;    sb->len = strlen(sb->buf);    return;}/* return the C string from the buffer. */const char *stringbuffer_getstring(stringbuffer_t *sb){    return sb->buf;}/* set a string into a stringbuffer */void stringbuffer_set(stringbuffer_t *dest, const char *s){    stringbuffer_clear(dest); /* zap */    stringbuffer_append(dest, s);}/* copy a stringbuffer into another stringbuffer */void stringbuffer_copy(stringbuffer_t *dest, stringbuffer_t *src){    stringbuffer_set(dest, stringbuffer_getstring(src));}/* replace in stringbuffer occurances of c with replace */void stringbuffer_replace_c(stringbuffer_t *sb, char c, char replace){    int i;    for(i = 0;i < sb->len;i++) {        if(sb->buf[i] == c)            sb->buf[i] = replace;    }    return;}/* replace in stringbuffer occurances of c with replace */void stringbuffer_replace(stringbuffer_t *sb, const char *string, const char *replace){    char *ptr;    int i;    int str_len = strlen(string);    stringbuffer_t *sb_replace;    if(string[0] == 0)        return; /* nothing to replace. */    sb_replace = stringbuffer_create();    ptr = sb->buf;    for(i = 0; i < sb->len; i++) {        if((sb->len - i) < str_len) {            /* copy in. */            stringbuffer_copy(sb, sb_replace);            /* append what's left. */            stringbuffer_append(sb, &ptr[i]);            /* free up. */            stringbuffer_destroy(sb_replace);            /* we're done. */            return;        }        if(ptr[i] == string[0]) {            /* we know that we have at least enough to complete string. */            if(!memcmp(&ptr[i], string, str_len)) {                                /* we have a match, replace. */                stringbuffer_append(sb_replace, replace);                i += (str_len - 1);                continue;            }        }        stringbuffer_append_c(sb_replace, ptr[i]);    }    /* we're done: we should only get here if the last string to       be replaced ended the string itself. */    /* copy in. */    stringbuffer_copy(sb, sb_replace);    /* free up. */    stringbuffer_destroy(sb_replace);    /* we're done. */    return;}/* align a stringbuffer on begin and end columns. */void stringbuffer_align(stringbuffer_t *sb, int begin, int end){    char *ptr, *word_string;    stringbuffer_t *aligned_string;    int len, i;    stringbuffer_zap_newline(sb);    aligned_string = stringbuffer_create();    ptr = sb->buf;    while(1) {        word_string = get_string_align(ptr, end, &len);        if(word_string == NULL)            break;        ptr += len;        for(i = 0; i < begin; i++)            stringbuffer_append(aligned_string, " ");        stringbuffer_append(aligned_string, word_string);        stringbuffer_append(aligned_string, "\n");        xfree(word_string);    }    stringbuffer_copy(sb, aligned_string);    stringbuffer_destroy(aligned_string);    return;}/* stringbuffer_*printf* these all use snprintf/snvprintf internally *//* append vprintf with alignment. */void stringbuffer_avprintf_align(stringbuffer_t *sb, int start, int end, const char *fmt, va_list ap){    stringbuffer_t *tmp_sb;    char *str;    int total, len;    /* our first malloc is bogus. */    len = 1;    str = xmalloc(sizeof(char) * len);    total = vsnprintf(str, len, fmt, ap);    /* total is the real length needed. */    xfree(str);    len = total + 1;    str = xmalloc(sizeof(char) * len);    vsnprintf(str, len, fmt, ap);    /* now align if we want to align. */    if(start != 0 && end != 0) {        tmp_sb = stringbuffer_create();        stringbuffer_append(tmp_sb, str);        stringbuffer_align(tmp_sb, start, end);        stringbuffer_append(sb, stringbuffer_getstring(tmp_sb));        stringbuffer_destroy(tmp_sb);    } else {        stringbuffer_append(sb, str);    }    xfree(str);    return;}/* append printf. */void stringbuffer_aprintf(stringbuffer_t *sb, const char *fmt, ...){    va_list ap;    va_start(ap, fmt);    stringbuffer_avprintf(sb, fmt, ap);    va_end(ap);}/* append printf with alignment. */void stringbuffer_aprintf_align(stringbuffer_t *sb, int start, int end, const char *fmt, ...){    va_list ap;    va_start(ap, fmt);    stringbuffer_avprintf_align(sb, start, end, fmt, ap);    va_end(ap);}/* append vprintf. */void stringbuffer_avprintf(stringbuffer_t *sb, const char *fmt, va_list ap){    stringbuffer_avprintf_align(sb, 0, 0, fmt, ap);}/* newline marking and sweeping. this wrecks the string inside * the stringbuffer. *//* mark newlines to walk through.  * our sentinel is the null terminator. * two null terminations marks the end of the string. * we're guaranteed it is a unique sentinel since * we never accept null terminators from outside sources * and never build our own strings (obviously!) with * null terminators inside of them. */int stringbuffer_marknewlines(stringbuffer_t *sb){    char *c;    int newline_count = 0;    /* first append one null termination to the end     * to act as a proper terminator. */    stringbuffer_append_c(sb, 0);    c = sb->buf;    while(1) {        if(*c == '\n') {            newline_count++;            *c = 0;        }        c++;        if(*c == 0)            break;    }    return newline_count; /* return our line count. */}/* called _after_ newlines are marked. */const char *stringbuffer_getnextline(stringbuffer_t *sb, const char *cptr){    const char *ptr;    if(cptr == NULL) {        /* get first line. */        cptr = sb->buf;    } else {        for(ptr = cptr; *ptr != 0; ptr++);        if(*ptr == 0 && *(ptr + 1) == 0) {            return NULL;        } else {            cptr = ptr + 1;        }    }    return cptr;}int stringbuffer_getlen(stringbuffer_t *sb){    return sb->len;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品18久久久久久久网站| 日韩亚洲欧美综合| 成人免费在线播放视频| 成人性色生活片| 国产精品丝袜黑色高跟| 99精品国产99久久久久久白柏 | 理论电影国产精品| 日韩精品一区二区三区在线| 韩国av一区二区三区四区| 久久久久国产精品人| 国产91露脸合集magnet| 亚洲欧美aⅴ...| 欧美精品免费视频| 国产另类ts人妖一区二区| 国产精品久久久久久久久搜平片 | 秋霞成人午夜伦在线观看| 欧美一区二区高清| 国产成人综合在线播放| 综合久久国产九一剧情麻豆| 欧美日本免费一区二区三区| 久草这里只有精品视频| 中文字幕在线不卡国产视频| 欧美在线视频日韩| 久久精品国产久精国产| 国产精品不卡一区| 欧美日韩一区小说| 福利电影一区二区| 亚洲国产精品一区二区www在线| 日韩欧美色综合网站| av一区二区久久| 欧美经典三级视频一区二区三区| 日本韩国精品在线| 国产精品资源站在线| 亚洲一区二区在线播放相泽| 精品国产sm最大网站免费看| 91老司机福利 在线| 蜜桃久久久久久| 亚洲女性喷水在线观看一区| 2020国产精品久久精品美国| 欧洲精品在线观看| 成人自拍视频在线| 免费在线观看不卡| 亚洲美女屁股眼交| 国产性做久久久久久| 911精品国产一区二区在线| 成人av网站在线观看| 美女国产一区二区三区| 亚洲精品亚洲人成人网| 久久精品欧美日韩精品 | av成人免费在线观看| 久久精品国产一区二区| 亚洲成人自拍一区| 伊人色综合久久天天人手人婷| 久久夜色精品一区| 日韩无一区二区| 欧美日韩精品欧美日韩精品一综合| 国产成人午夜视频| 国产在线视频一区二区| 男人的j进女人的j一区| 亚洲动漫第一页| 一区二区三区免费在线观看| 亚洲国产精品成人综合色在线婷婷| 日韩一区二区电影网| 欧美日韩不卡视频| 欧美三级三级三级| 96av麻豆蜜桃一区二区| 成人伦理片在线| 成人综合日日夜夜| 粉嫩av一区二区三区| 国产一二精品视频| 韩国v欧美v日本v亚洲v| 国产在线视视频有精品| 国产一区激情在线| 欧美日韩视频在线一区二区| 欧美视频一区二区在线观看| 色一情一伦一子一伦一区| 一本一本大道香蕉久在线精品 | 一区二区三区免费看视频| 亚洲日韩欧美一区二区在线| 中文字幕在线播放不卡一区| 中文字幕一区二区三区不卡在线| 中文字幕 久热精品 视频在线| 国产午夜亚洲精品午夜鲁丝片| 国产午夜精品久久| 国产精品久久久久三级| 亚洲猫色日本管| 一区二区欧美视频| 日韩在线播放一区二区| 免费观看日韩av| 国产在线一区二区| 成人小视频在线观看| 成人免费黄色在线| 91丨九色丨国产丨porny| 91丨九色丨尤物| 欧美乱妇15p| 精品剧情在线观看| 国产女人aaa级久久久级| 亚洲欧洲精品一区二区三区不卡| 夜夜揉揉日日人人青青一国产精品 | 国产欧美日韩一区二区三区在线观看| 久久色视频免费观看| 国产精品美女www爽爽爽| 亚洲在线免费播放| 美女一区二区三区在线观看| 国产河南妇女毛片精品久久久| 97久久超碰国产精品电影| 欧美网站一区二区| 欧美精品一区二区不卡| 日本一区二区三区四区在线视频 | 日本美女一区二区| 国产成人鲁色资源国产91色综| 99精品黄色片免费大全| 91精品国产福利| 欧美激情综合在线| 亚洲网友自拍偷拍| 国产精品亚洲专一区二区三区| 色综合视频在线观看| 日韩欧美国产一区二区三区| 欧美激情一区三区| 日本系列欧美系列| 北条麻妃一区二区三区| 7777精品伊人久久久大香线蕉超级流畅| 精品国产乱码久久久久久图片| 亚洲天堂a在线| 韩国视频一区二区| 欧美亚洲综合久久| 国产午夜一区二区三区| 首页综合国产亚洲丝袜| av高清久久久| 久久奇米777| 免费在线观看一区| 久久蜜桃一区二区| 日韩av电影免费观看高清完整版| 国产成人免费在线| 日韩欧美国产系列| 亚洲福中文字幕伊人影院| 成人丝袜18视频在线观看| 制服丝袜成人动漫| 亚洲激情图片一区| 成人免费毛片aaaaa**| 26uuu亚洲综合色欧美| 亚洲成a人在线观看| 91丨porny丨中文| 欧美激情综合五月色丁香| 精品一区二区三区免费视频| 欧美婷婷六月丁香综合色| 国产精品理论片在线观看| 国产一区二区三区精品欧美日韩一区二区三区 | 久88久久88久久久| 日韩欧美一卡二卡| 偷拍日韩校园综合在线| 欧美色视频一区| 一片黄亚洲嫩模| 色综合天天狠狠| 亚洲老妇xxxxxx| 91在线视频播放| 国产精品三级av在线播放| 国产米奇在线777精品观看| 欧美v国产在线一区二区三区| 日韩在线一区二区三区| 欧美美女一区二区| 亚洲成人自拍偷拍| 欧美日韩一区二区不卡| 亚洲风情在线资源站| 91成人在线观看喷潮| 一区二区三区精密机械公司| 91网页版在线| 亚洲一区二区三区四区五区中文| 91啦中文在线观看| 亚洲国产视频a| 欧美伦理视频网站| 久久成人久久鬼色| 久久久综合网站| 国产91富婆露脸刺激对白| 国产区在线观看成人精品| 国产不卡一区视频| 中文字幕日本不卡| 91久久香蕉国产日韩欧美9色| 亚洲人成伊人成综合网小说| 色婷婷精品久久二区二区蜜臂av| 亚洲色大成网站www久久九九| 99riav一区二区三区| 一区二区三区中文字幕在线观看| 欧洲另类一二三四区| 亚洲1区2区3区4区| 欧美成人一区二区| 国产成人免费xxxxxxxx| 亚洲欧美一区二区三区孕妇| 欧美色中文字幕| 伦理电影国产精品| 欧美激情综合在线| 欧美性xxxxxx少妇| 美女视频黄免费的久久| 欧美国产日产图区| 在线观看不卡视频| 久久成人免费网| 亚洲精品欧美专区| 日韩欧美精品在线视频| 国产 欧美在线| 丁香婷婷综合色啪|