当前位置: 首页>>代码示例>>C++>>正文


C++ ADVANCE函数代码示例

本文整理汇总了C++中ADVANCE函数的典型用法代码示例。如果您正苦于以下问题:C++ ADVANCE函数的具体用法?C++ ADVANCE怎么用?C++ ADVANCE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ADVANCE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: clear_one_cd_file

/* Clear central directory data about a single file */
static int
clear_one_cd_file(unsigned char **p1, off_t *p2)
{
    unsigned char *data;
    off_t size_left;
    struct cd_file h;
    size_t len;
    int is_zip64;

    data = *p1;
    size_left = *p2;
    memcpy(&h, data, sizeof(h));
    memset(h.mtime, 0, sizeof(h.mtime));
    memset(h.mdate, 0, sizeof(h.mdate));
    memcpy(data, &h, sizeof(h));
    ADVANCE(sizeof(h));
    len = get_u16(h.name_length);
    ADVANCE(len);
    if (clear_file_extra(&data, &size_left, get_u16(h.extra_length), &is_zip64,
			 NULL) != 0)
	return -1;
    len = get_u16(h.comment_length);
    ADVANCE(len);
    *p1 = data;
    *p2 = size_left;
    return 0;
}
开发者ID:boyski,项目名称:Objcmp,代码行数:28,代码来源:zipsum.c

示例2: next_patt

static const char *
next_patt(register const char *pattern, int advance)
{
    wchar_t __nlh_char[1];

    if (CHARAT(pattern) == '[')
    {
	int ch;
	const char *pp = pattern;
	ADVANCE(pp);

	if (CHARAT(pp) == '^')
	    ADVANCE(pp);

	if (CHARAT(pp) == ']')
	    ADVANCE(pp);

	char const *np;
	for (; (ch = next_char(pp, &np)) != '\0'; pp = np)
	    if (ch == ']')
		return (advance ? np : pp);
    }

    next_char(pattern, &pattern);
    return pattern;
}
开发者ID:idunham,项目名称:cdesktop,代码行数:26,代码来源:strwcmp.C

示例3: cmp_one_cd_file

/* Compare central directory data about a single file */
static int
cmp_one_cd_file(const unsigned char **p1, const unsigned char **p2, off_t *p3)
{
    const unsigned char *data1, *data2;
    off_t size_left;
    struct cd_file h1, h2;
    size_t len;
    enum result res;
    int is_zip64;

    data1 = *p1;
    data2 = *p2;
    size_left = *p3;
    memcpy(&h1, data1, sizeof(h1));
    memcpy(&h2, data2, sizeof(h2));
    ADVANCE(sizeof(h1));
    memset(h1.mtime, 0, sizeof(h1.mtime));
    memset(h2.mtime, 0, sizeof(h2.mtime));
    memset(h1.mdate, 0, sizeof(h1.mdate));
    memset(h2.mdate, 0, sizeof(h2.mdate));
    if (memcmp(&h1, &h2, sizeof(h1)) != 0)
	return RES_DIFFERENT;
    len = get_u16(h1.name_length);
    COMPARE_AND_ADVANCE(len);
    res = cmp_file_extra(&data1, &data2, &size_left, get_u16(h1.extra_length),
			 &is_zip64, NULL);
    if (res != RES_SAME)
	return res;
    len = get_u16(h1.comment_length);
    COMPARE_AND_ADVANCE(len);
    *p1 = data1;
    *p2 = data2;
    *p3 = size_left;
    return RES_SAME;
}
开发者ID:boyski,项目名称:Objcmp,代码行数:36,代码来源:zipfile.c

示例4: dbg_history_dump

void dbg_history_dump(char *key)
{
  int cnt;
  char buf[80];
  struct head *p;
  if(history_length)
    {
      fprintf(stderr, "***** %s:%u: history dump start\n", dbg_file_name, dbg_line_number);
      if(histp->addr)
	{
	  cnt = history_length;
	  p = histp;
	}
      else
	{
	  cnt = histp - hist_base;
	  p = hist_base;
	}
      while(cnt--)
	{
	  snprintf(buf, 80, "(alloc: %s:%u size: %lu free: %s:%u)\n",
		  p->file, p->line, (unsigned long)p->size, p->free.file, p->free.line);
	  ADVANCE(p);
	  if(strstr(buf, key)) fputs(buf, stderr);
	}
      fprintf(stderr, "***** %s:%u: history dump end\n", dbg_file_name, dbg_line_number);
    }
}     
开发者ID:BackupTheBerlios,项目名称:avinfo-svn,代码行数:28,代码来源:memleak.c

示例5: parse_next_atom

/* NOTE: This functions record the fact that it has read to the end of
 * the buffer by setting the position to *beyond* the end of the
 * buffer. */
static int
parse_next_atom(struct simple_buffer *buffer, enum lsh_atom *result)
{
  uint32_t i;

  assert (buffer->pos <=buffer->capacity);

  for(i = 0; i < LEFT; i++)
    {
      if (HERE[i] == ',')
	break;
      if (i == 64)
	/* Atoms can be no larger than 64 characters */
	return 0;
    }

  /* NOTE: ssh-2.0.13, server string "SSH-1.99-2.0.13
   * (non-commercial)", sends USERAUTH_FAILURE messages with strings
   * like "publickey,password,". It's not entirely clear to me if that
   * is allowed for the spec, but it seems safe and straightforward to
   * treat empty atoms as any other unknown atom. */
  if (!i)
    {
      verbose("parse_next_atom: Received an empty atom.\n");
      /* Treat empty atoms as unknown */
      *result = 0;
    }
  else
    *result = lookup_atom(i, HERE);

  ADVANCE(i+1);  /* If the atom was terminated at the end of the
		  * buffer, rather than by a comma, this points beyond
		  * the end of the buffer */
  return 1;
}
开发者ID:jeremyfrench,项目名称:lsh,代码行数:38,代码来源:parse.c

示例6: parse_boolean

int
parse_boolean(struct simple_buffer *buffer, int *result)
{
  if (!LEFT)
    return 0;
  *result = HERE[0];
  ADVANCE(1);
  return 1;
}
开发者ID:jeremyfrench,项目名称:lsh,代码行数:9,代码来源:parse.c

示例7: parse_rest

void
parse_rest(struct simple_buffer *buffer,
	   uint32_t *length, const uint8_t **start)
{
  *length = LEFT;
  *start = HERE;

  ADVANCE(*length);
}
开发者ID:jeremyfrench,项目名称:lsh,代码行数:9,代码来源:parse.c

示例8: parse_octets

/* NOTE: This is used in one single place: For copying the cookie in
   received KEYEXCHANGE_INIT messages. */
int
parse_octets(struct simple_buffer *buffer,
	     uint32_t length, uint8_t *start)
{
  if (LEFT < length)
    return 0;
  memcpy(start, HERE, length);
  ADVANCE(length);
  return 1;
}
开发者ID:jeremyfrench,项目名称:lsh,代码行数:12,代码来源:parse.c

示例9: parse_uint32

int
parse_uint32(struct simple_buffer *buffer, uint32_t *result)
{
  if (LEFT < 4)
    return 0;

  *result = READ_UINT32(HERE);
  ADVANCE(4);
  return 1;
}
开发者ID:jeremyfrench,项目名称:lsh,代码行数:10,代码来源:parse.c

示例10: parse_uint16

/* Used by client_x11.c, for parsing xauth */
int
parse_uint16(struct simple_buffer *buffer, uint32_t *result)
{
  if (LEFT < 2)
    return 0;

  *result = READ_UINT16(HERE);
  ADVANCE(2);
  return 1;
}
开发者ID:jeremyfrench,项目名称:lsh,代码行数:11,代码来源:parse.c

示例11: parse_uint8

int
parse_uint8(struct simple_buffer *buffer, unsigned *result)
{
  if (!LEFT)
    return 0;

  *result = HERE[0];
  ADVANCE(1);
  return 1;
}
开发者ID:jeremyfrench,项目名称:lsh,代码行数:10,代码来源:parse.c

示例12: conf_print_rtm

void
conf_print_rtm(FILE *output, struct rt_msghdr *rtm, char *delim, int af)
{
	int i;
	char *cp, flags[64];
	struct sockaddr *dst = NULL, *gate = NULL, *mask = NULL;
	struct sockaddr *sa;
	struct sockaddr_in sin;

	sin.sin_addr.s_addr = htonl(INADDR_BROADCAST);

	cp = ((char *)rtm + rtm->rtm_hdrlen);
	for (i = 1; i; i <<= 1)
		if (i & rtm->rtm_addrs) {
			sa = (struct sockaddr *)cp;
			switch (i) {
			case RTA_DST:
				/* allow arp to get printed with af==AF_LINK */
				if ((sa->sa_family == af) ||
				    (af == AF_LINK && sa->sa_family == AF_INET)) {
					if (rtm->rtm_flags & RTF_REJECT)
						snprintf(flags, sizeof(flags),
						    " reject");
					else
						flags[0] = '\0';
					dst = sa;
				}
				break;
			case RTA_GATEWAY:
				if (sa->sa_family == af)
					gate = sa;
				break;
			case RTA_NETMASK:
				/* netmasks will not have a valid sa_family */
				mask = sa;
				break;
			}
			ADVANCE(cp, sa);
		}
	if (dst && gate && mask && (af == AF_INET || af == AF_INET6)) {
		/*
		 * Suppress printing IPv4 route if it's the default
		 * route and dhcp (dhclient) is enabled.
		 */
		if (!(af == AF_INET && isdefaultroute(dst, mask)
		    && dhclient_isenabled(routename(gate)))) {
			fprintf(output, "%s%s ", delim, netname(dst, mask));
			fprintf(output, "%s%s\n", routename(gate), flags);
		}
	} else if (dst && gate && (af == AF_LINK)) {
		/* print arp */
		fprintf(output, "%s%s ", delim, routename(dst));
		fprintf(output, "%s\n", routename(gate));
	}
}
开发者ID:gonzopancho,项目名称:nsh,代码行数:55,代码来源:conf.c

示例13: kbintr

static void __interrupt __far kbintr()
{
	unsigned char code;
	int key, press;

	code = inp(KB_PORT);

	if(code >= 128) {
		press = 0;
		code -= 128;

		if(num_pressed > 0) {
			num_pressed--;
		}
	} else {
		press = 1;

		num_pressed++;
	}

	key = scantbl[code];

	if(press) {
		/* append to buffer */
		last_key = key;
		if(buffer_size > 0) {
			buffer[buf_widx] = key;
			ADVANCE(buf_widx);
			/* if the write end overtook the read end, advance the read end
			 * too, to discard the oldest keypress from the buffer
			 */
			if(buf_widx == buf_ridx) {
				ADVANCE(buf_ridx);
			}
		}
	}

	/* and update keystate table */
	keystate[key] = press;

	outp(PIC1_CMD_PORT, OCW2_EOI);	/* send end-of-interrupt */
}
开发者ID:jtsiomb,项目名称:colcycle,代码行数:42,代码来源:keyb.c

示例14: parse_rest_copy

struct lsh_string *
parse_rest_copy(struct simple_buffer *buffer)
{
  uint32_t length = LEFT;
  struct lsh_string *s = ssh_format("%ls", length, HERE);

  ADVANCE(length);
  assert(!LEFT);

  return s;
}
开发者ID:jeremyfrench,项目名称:lsh,代码行数:11,代码来源:parse.c

示例15: clear_file_extra

/* Clear per-file extra data;
   Update compressed_size if it is not NULL, otherwise assume compressed_size
   is not present in the zip64 header. */
static int
clear_file_extra(unsigned char **p1, off_t *p2, size_t extra_len, int *is_zip64,
		 unsigned long long *compressed_size)
{
    unsigned char *data;
    off_t size_left;

    data = *p1;
    size_left = *p2;
    while (extra_len >= sizeof(struct extra_header)) {
	struct extra_header eh;
	size_t len;

	memcpy(&eh, data, sizeof(eh));
	ADVANCE(sizeof(eh));
	len = get_u16(eh.data_size);
	if (extra_len < sizeof(eh) + len)
	    return -1;
	extra_len -= sizeof(eh) + len;
	if (memcmp(eh.id, eh_id_zip64, sizeof(eh_id_zip64)) == 0) {
	    *is_zip64 = 1;
	    if (compressed_size != NULL)
		*compressed_size = get_u64(data + 8);
	    ADVANCE(len);
	} else if (memcmp(eh.id, eh_id_ext_timestamp,
			  sizeof(eh_id_ext_timestamp)) == 0) {
	    if (len < 1)
		return -1;
	    ADVANCE(1);		/* Time presence flags */
	    memset(data, 0, len - 1);	/* mtime, atime, ctime - if present */
	    ADVANCE(len - 1);
	} else
	    ADVANCE(len);
    }
    if (extra_len != 0)
	return -1;
    *p1 = data;
    *p2 = size_left;
    return 0;
}
开发者ID:boyski,项目名称:Objcmp,代码行数:43,代码来源:zipsum.c


注:本文中的ADVANCE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。