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

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

?? history.c

?? BCAST Implementation for NS2
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* * Copyright (c) 2000, 2001 by Martin C. Shepherd. *  * All rights reserved. *  * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, and/or sell copies of the Software, and to permit persons * to whom the Software is furnished to do so, provided that the above * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. *  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *  * Except as contained in this notice, the name of a copyright holder * shall not be used in advertising or otherwise to promote the sale, use * or other dealings in this Software without prior written authorization * of the copyright holder. */#include <stdlib.h>#include <stdio.h>#include <string.h>#include <ctype.h>#include <time.h>#include <errno.h>#include "history.h"#include "freelist.h"/* * GlLineNode's record the location and length of historical lines in * a buffer array. */typedef struct GlLineNode GlLineNode;struct GlLineNode {  long id;             /* The unique identifier of this history line */  time_t timestamp;    /* The time at which the line was archived */  unsigned group;      /* The identifier of the history group to which the */                       /*  the line belongs. */  GlLineNode *next;    /* The next youngest line in the list */  GlLineNode *prev;    /* The next oldest line in the list */  int start;           /* The start index of the line in the buffer */  int nchar;           /* The total length of the line, including the '\0' */};/* * The number of GlLineNode elements per freelist block. */#define LINE_NODE_BLK 100/* * Lines are organised in the buffer from oldest to newest. The * positions of the lines are recorded in a doubly linked list * of GlLineNode objects. */typedef struct {  FreeList *node_mem;    /* A freelist of GlLineNode objects */   GlLineNode *head;      /* The head of the list of lines */  GlLineNode *tail;      /* The tail of the list of lines */} GlLineList;/* * All elements of the history mechanism are recorded in an object of * the following type. */struct GlHistory {  char *buffer;       /* A circular buffer used to record historical input */                      /*  lines. */  size_t buflen;      /* The length of the buffer array */  GlLineList list;    /* A list of the start of lines in buffer[] */  GlLineNode *recall; /* The last line recalled, or NULL if no recall */                      /*  session is currently active. */  GlLineNode *id_node;/* The node at which the last ID search terminated */  const char *prefix; /* A pointer to the line containing the prefix that */                      /*  is being searched for. */  int prefix_len;     /* The length of the prefix */  unsigned long seq;  /* The next ID to assign to a line node */  unsigned group;     /* The identifier of the current history group */  int nline;          /* The number of lines currently in the history list */  int max_lines;      /* Either -1 or a ceiling on the number of lines */  int enable;         /* If false, ignore history additions and lookups */};static char *_glh_restore_line(GlHistory *glh, char *line, size_t dim);static int _glh_cant_load_history(GlHistory *glh, const char *filename,				  int lineno, const char *message, FILE *fp);static int _glh_write_timestamp(FILE *fp, time_t timestamp);static int _glh_decode_timestamp(char *string, char **endp, time_t *t);static void _glh_discard_node(GlHistory *glh, GlLineNode *node);static GlLineNode *_glh_find_id(GlHistory *glh, GlhLineID id);/*....................................................................... * Create a line history maintenance object. * * Input: *  buflen     size_t    The number of bytes to allocate to the circular *                       buffer that is used to record all of the *                       most recent lines of user input that will fit. *                       If buflen==0, no buffer will be allocated. * Output: *  return  GlHistory *  The new object, or NULL on error. */GlHistory *_new_GlHistory(size_t buflen){  GlHistory *glh;  /* The object to be returned *//* * Allocate the container. */  glh = (GlHistory *) malloc(sizeof(GlHistory));  if(!glh) {    fprintf(stderr, "_new_GlHistory: Insufficient memory.\n");    return NULL;  };/* * Before attempting any operation that might fail, initialize the * container at least up to the point at which it can safely be passed * to _del_GlHistory(). */  glh->buffer = NULL;  glh->buflen = buflen;  glh->list.node_mem = NULL;  glh->list.head = NULL;  glh->list.tail = NULL;  glh->recall = NULL;  glh->id_node = NULL;  glh->prefix = NULL;  glh->prefix_len = 0;  glh->seq = 0;  glh->group = 0;  glh->nline = 0;  glh->max_lines = -1;  glh->enable = 1;/* * Allocate the buffer, if required. */  if(buflen > 0) {    glh->buffer = (char *) malloc(sizeof(char) * buflen);    if(!glh->buffer) {      fprintf(stderr, "_new_GlHistory: Insufficient memory.\n");      return _del_GlHistory(glh);    };  };/* * Allocate the GlLineNode freelist. */  glh->list.node_mem = _new_FreeList("_new_GlHistory", sizeof(GlLineNode),				     LINE_NODE_BLK);  if(!glh->list.node_mem)    return _del_GlHistory(glh);  return glh;}/*....................................................................... * Delete a GlHistory object. * * Input: *  glh    GlHistory *  The object to be deleted. * Output: *  return GlHistory *  The deleted object (always NULL). */GlHistory *_del_GlHistory(GlHistory *glh){  if(glh) {/* * Delete the buffer. */    if(glh->buffer) {      free(glh->buffer);      glh->buffer = NULL;    };/* * Delete the freelist of GlLineNode's. */    glh->list.node_mem = _del_FreeList("_del_GlHistory", glh->list.node_mem, 1);/* * The contents of the list were deleted by deleting the freelist. */    glh->list.head = NULL;    glh->list.tail = NULL;/* * Delete the container. */    free(glh);  };  return NULL;}/*....................................................................... * Add a new line to the end of the history buffer, wrapping round to the * start of the buffer if needed. * * Input: *  glh  GlHistory *  The input-line history maintenance object. *  line      char *  The line to be archived. *  force      int    Unless this flag is non-zero, empty lines and *                    lines which match the previous line in the history *                    buffer, aren't archived. This flag requests that *                    the line be archived regardless. * Output: *  return     int    0 - OK. *                    1 - Error. */int _glh_add_history(GlHistory *glh, const char *line, int force){  GlLineList *list; /* The line location list */  int nchar;        /* The number of characters needed to record the line */  GlLineNode *node; /* The new line location list node */  int empty;        /* True if the string is empty */  const char *nlptr;/* A pointer to a newline character in line[] */  int i;/* * Check the arguments. */  if(!glh || !line)    return 1;/* * Is history enabled? */  if(!glh->enable || !glh->buffer || glh->max_lines == 0)    return 0;/* * Get the line location list. */  list = &glh->list;/* * Cancel any ongoing search. */  if(_glh_cancel_search(glh))    return 1;/* * See how much buffer space will be needed to record the line? * * If the string contains a terminating newline character, arrange to * have the archived line NUL terminated at this point. */  nlptr = strchr(line, '\n');  if(nlptr)    nchar = (nlptr - line) + 1;  else    nchar = strlen(line) + 1;/* * If the line is too big to fit in the buffer, truncate it. */  if(nchar > glh->buflen)    nchar = glh->buflen;/* * Is the line empty? */  empty = 1;  for(i=0; i<nchar-1 && empty; i++)    empty = isspace((int)(unsigned char) line[i]);/* * If the line is empty, don't add it to the buffer unless explicitly * told to. */  if(empty && !force)    return 0;/* * If the new line is the same as the most recently added line, * don't add it again, unless explicitly told to. */  if(!force &&     list->tail && strlen(glh->buffer + list->tail->start) == nchar-1 &&     strncmp(line, glh->buffer + list->tail->start, nchar-1)==0)    return 0;/* * Allocate the list node that will record the line location. */  node = (GlLineNode *) _new_FreeListNode(list->node_mem);  if(!node)    return 1;/* * Is the buffer empty? */  if(!list->head) {/* * Place the line at the beginning of the buffer. */    strncpy(glh->buffer, line, nchar);    glh->buffer[nchar-1] = '\0';/* * Record the location of the line. */    node->start = 0;/* * The buffer has one or more lines in it. */  } else {/* * Place the start of the new line just after the most recently * added line. */    int start = list->tail->start + list->tail->nchar;/* * If there is insufficient room between the end of the most * recently added line and the end of the buffer, we place the * line at the beginning of the buffer. To make as much space * as possible for this line, we first delete any old lines * at the end of the buffer, then shift the remaining contents * of the buffer to the end of the buffer. */    if(start + nchar >= glh->buflen) {      GlLineNode *last; /* The last line in the buffer */      GlLineNode *ln;   /* A member of the list of line locations */      int shift;        /* The shift needed to move the contents of the */                        /*  buffer to its end. *//* * Delete any old lines between the most recent line and the end of the * buffer. */      while(list->head && list->head->start > list->tail->start)	_glh_discard_node(glh, list->head);/* * Find the line that is nearest the end of the buffer. */      last = NULL;      for(ln=list->head; ln; ln=ln->next) {	if(!last || ln->start > last->start)	  last = ln;      };/* * How big a shift is needed to move the existing contents of the * buffer to the end of the buffer? */      shift = last ? (glh->buflen - (last->start + last->nchar)) : 0;/* * Is any shift needed? */      if(shift > 0) {/* * Move the buffer contents to the end of the buffer. */	memmove(glh->buffer + shift, glh->buffer, glh->buflen - shift);/* * Update the listed locations to reflect the shift. */	for(ln=list->head; ln; ln=ln->next)	  ln->start += shift;      };/* * The new line should now be located at the start of the buffer. */      start = 0;    };/* * Make space for the new line at the beginning of the buffer by * deleting the oldest lines. This just involves removing them * from the list of used locations. Also enforce the current * maximum number of lines. */    while(list->head &&	  ((list->head->start >= start && list->head->start - start < nchar) ||	   (glh->max_lines >= 0 && glh->nline>=glh->max_lines))) {      _glh_discard_node(glh, list->head);    };/* * Copy the new line into the buffer. */    memcpy(glh->buffer + start, line, nchar);    glh->buffer[start + nchar - 1] = '\0';/* * Record its location. */    node->start = start;  };/* * Append the line location node to the end of the list. */  node->id = glh->seq++;  node->timestamp = time(NULL);  node->group = glh->group;  node->nchar = nchar;  node->next = NULL;  node->prev = list->tail;  if(list->tail)    list->tail->next = node;  else    list->head = node;  list->tail = node;  glh->nline++;  return 0;}/*....................................................................... * Recall the next oldest line that has the search prefix last recorded * by _glh_search_prefix(). * * Input: *  glh  GlHistory *  The input-line history maintenance object. *  line      char *  The input line buffer. On input this should contain *                    the current input line, and on output, if anything *                    was found, its contents will have been replaced *                    with the matching line. *  dim     size_t    The allocated dimensions of the line buffer. * Output: *  return    char *  A pointer to line[0], or NULL if not found. */char *_glh_find_backwards(GlHistory *glh, char *line, size_t dim){  GlLineNode *node; /* The line location node being checked */  int first;        /* True if this is the start of a new search *//* * Check the arguments. */  if(!glh || !line) {    fprintf(stderr, "_glh_find_backwards: NULL argument(s).\n");    return NULL;  };/* * Is history enabled? */  if(!glh->enable || !glh->buffer || glh->max_lines == 0)    return NULL;/* * Check the line dimensions. */  if(dim < strlen(line) + 1) {    fprintf(stderr,       "_glh_find_backwards: 'dim' inconsistent with strlen(line) contents.\n");    return NULL;  };/* * Is this the start of a new search? */  first = glh->recall==NULL;/* * If this is the first search backwards, save the current line * for potential recall later, and mark it as the last line * recalled. */  if(first) {    if(_glh_add_history(glh, line, 1))      return NULL;    glh->recall = glh->list.tail;  };/* * If there is no search prefix, the prefix last set by glh_search_prefix() * doesn't exist in the history buffer. */  if(!glh->prefix)    return NULL;/* * From where should we start the search? */  if(glh->recall)    node = glh->recall->prev;  else    node = glh->list.tail;/* * Search backwards through the list for the first match with the * prefix string. */  for( ; node &&      (node->group != glh->group ||       strncmp(glh->buffer + node->start, glh->prefix, glh->prefix_len) != 0);      node = node->prev)    ;/* * Was a matching line found? */  if(node) {/* * Recall the found node as the starting point for subsequent * searches. */    glh->recall = node;/* * Copy the matching line into the provided line buffer. */    strncpy(line, glh->buffer + node->start, dim);    line[dim-1] = '\0';    return line;  };/* * No match was found. */  return NULL;}/*....................................................................... * Recall the next newest line that has the search prefix last recorded * by _glh_search_prefix(). * * Input: *  glh  GlHistory *  The input-line history maintenance object. *  line      char *  The input line buffer. On input this should contain *                    the current input line, and on output, if anything *                    was found, its contents will have been replaced *                    with the matching line.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品美女视频| 久久99国内精品| 91视频精品在这里| 1000精品久久久久久久久| 91亚洲午夜精品久久久久久| 亚洲激情一二三区| 色网站国产精品| 午夜私人影院久久久久| 日韩精品一区二区三区中文不卡 | 成人性生交大片免费看在线播放| 久久久不卡网国产精品二区 | 久久国产夜色精品鲁鲁99| 日韩视频一区二区在线观看| 国产一区免费电影| 中文字幕人成不卡一区| 欧美色精品在线视频| 日韩在线a电影| 国产无人区一区二区三区| 99久久精品免费| 亚洲女人的天堂| 宅男在线国产精品| 天天影视色香欲综合网老头| 久久综合久久鬼色| 99精品视频一区| 五月婷婷综合激情| 欧美国产一区二区| 欧美三区在线视频| 国产一区亚洲一区| 亚洲18色成人| 国产女人18水真多18精品一级做| 在线看日本不卡| 国产在线看一区| 亚洲成人手机在线| 日本一区二区三区在线观看| 欧美欧美欧美欧美首页| 国产精品18久久久久久久久久久久| 亚洲精品日日夜夜| ww亚洲ww在线观看国产| 欧美女孩性生活视频| 成人免费视频app| 免费成人在线网站| 亚洲男人的天堂网| 久久久国产午夜精品| 色婷婷av一区| 精品制服美女丁香| 亚洲激情自拍偷拍| 日韩一卡二卡三卡四卡| 波多野结衣亚洲| 婷婷中文字幕综合| 中文字幕第一区第二区| 7777精品久久久大香线蕉| 国产精品1区二区.| 午夜精品福利一区二区三区av | 91精品国产91久久久久久一区二区| 紧缚捆绑精品一区二区| 亚洲日本在线观看| 亚洲精品一区二区三区福利 | 日韩欧美一级特黄在线播放| 国产成人av在线影院| 亚洲一区二区中文在线| 国产精品蜜臀av| 久久久99精品久久| 久久夜色精品一区| 精品国产乱码久久久久久夜甘婷婷| 欧美日韩精品久久久| 欧美天堂亚洲电影院在线播放| av中文字幕不卡| 大胆欧美人体老妇| 国产成人福利片| 成人精品免费视频| 高清国产一区二区| 懂色一区二区三区免费观看| 国产不卡免费视频| 精品一区二区免费| 国产在线一区观看| 国产在线看一区| 丁香六月综合激情| www.爱久久.com| 91在线高清观看| 色综合天天综合网国产成人综合天 | 99re在线视频这里只有精品| 狠狠色狠狠色综合系列| 久久国产日韩欧美精品| 久久精品国产精品亚洲精品| 美女视频网站久久| 韩国精品久久久| 国产成人亚洲综合a∨婷婷图片 | 中文字幕一区日韩精品欧美| 国产精品久久久久影院老司| 亚洲人成网站影音先锋播放| 亚洲精品欧美激情| 一区二区三区免费看视频| 亚洲成人资源在线| 麻豆国产91在线播放| 国产成人免费视频网站| 99视频精品免费视频| 欧美亚洲综合久久| 制服丝袜日韩国产| 久久精品视频在线免费观看| 国产精品嫩草影院com| 亚洲欧美在线视频观看| 亚洲最大的成人av| 欧美性感一类影片在线播放| 91成人在线精品| 欧美日韩精品一区二区| 日韩欧美亚洲一区二区| 欧美大片日本大片免费观看| 欧美一区二区精品在线| 69av一区二区三区| 91免费看视频| 欧美中文字幕久久| 欧美日韩精品一区二区天天拍小说 | gogo大胆日本视频一区| 成人精品小蝌蚪| 成人性色生活片| 99久久国产免费看| 欧美影院精品一区| 欧美一区二区久久| 久久精品亚洲国产奇米99| 亚洲丝袜美腿综合| 蜜桃av噜噜一区二区三区小说| 国产激情视频一区二区在线观看| 99久精品国产| 日韩亚洲欧美在线| 中文字幕一区二区5566日韩| 日本女人一区二区三区| www.av精品| 精品sm捆绑视频| 亚洲国产毛片aaaaa无费看| 国产盗摄精品一区二区三区在线 | 欧美变态tickling挠脚心| 成人免费小视频| 国产一区二区视频在线| 在线影院国内精品| 欧美高清在线视频| 麻豆精品一区二区| 欧美亚日韩国产aⅴ精品中极品| 久久久久久久久久电影| 日韩国产欧美三级| 91豆麻精品91久久久久久| 国产精品欧美一区二区三区| 乱中年女人伦av一区二区| 欧美一a一片一级一片| 国产精品美女久久久久久久久久久 | 久久久久久影视| 亚洲激情网站免费观看| 国产精品1区2区3区在线观看| 7777精品伊人久久久大香线蕉超级流畅 | 日本欧美加勒比视频| 99精品视频一区| 国产精品电影院| 国产精品一区专区| 精品国产乱码久久久久久久久| 亚洲成av人片在线| 欧洲av一区二区嗯嗯嗯啊| 国产精品看片你懂得| 粉嫩av亚洲一区二区图片| 久久婷婷综合激情| 九九国产精品视频| 日韩一级精品视频在线观看| 午夜精品久久久久影视| 欧美猛男gaygay网站| 亚洲v精品v日韩v欧美v专区| 在线观看欧美日本| 亚洲精品欧美在线| 欧美亚洲一区二区三区四区| 91福利视频久久久久| 中文字幕精品三区| 成人永久免费视频| 国产精品无人区| 不卡的av在线| 亚洲免费在线看| 色综合中文字幕国产| 亚洲免费在线电影| 色噜噜久久综合| 亚洲国产精品综合小说图片区| 欧美视频日韩视频在线观看| 亚洲va韩国va欧美va| 欧美一级欧美一级在线播放| 久久精品国产99久久6| 精品成人私密视频| 国产成人啪午夜精品网站男同| 中文字幕不卡在线播放| 不卡的av在线播放| 亚洲国产视频网站| 日韩视频在线你懂得| 国产成a人亚洲精| 亚洲男人电影天堂| 91精品国产aⅴ一区二区| 国产伦精品一区二区三区免费迷| 久久精品一级爱片| 色综合天天综合在线视频| 视频一区二区三区在线| 精品少妇一区二区三区日产乱码| 国产一区二区三区在线观看免费视频| 国产免费观看久久| 欧美性极品少妇| 激情综合网激情| 中文字幕乱码久久午夜不卡| 欧美四级电影在线观看|