Beispiel #1
0
int main() {
  int i; UT_string *p;
  UT_vector v; utvector_init(&v, utvector_utstring);
  UT_string s; utstring_init(&s);
  for(i=0; i<10; i++) {
    utstring_printf(&s, ".");
    utvector_push(&v, &s);
  }
  p=NULL;
  while ( (p=(UT_string*)utvector_next(&v,p))) printf("%s\n",utstring_body(p));

  utvector_fini(&v);
  utstring_done(&s);
  return 0;
}
Beispiel #2
0
int main() {
  int i,*p=NULL;
  UT_vector v;
  utvector_init(&v, utmm_int);
  for(i=0; i<16; i++) utvector_push(&v, &i);

  p=NULL; while ( (p=(int*)utvector_next(&v,p))) printf("%d\n",*p);


  p = (int*)utvector_head(&v);
  printf("head: (%s) %d\n", p?"non-null":"null", p?*p:0);

  p = (int*)utvector_tail(&v);
  printf("tail: (%s) %d\n", p?"non-null":"null", p?*p:0);

  utvector_fini(&v);
  return 0;
}
Beispiel #3
0
void nbt_record_tag(struct nbt_tag *tag, off_t pos, uint32_t count, 
                  UT_vector /* of nbt_stack_frame */ *nbt_stack, 
                  UT_vector /* of struct nbt_record */ *records) {

  /* do not record each item of a list; we record the list itself */
  nbt_stack_frame *top;
  top = (nbt_stack_frame*)utvector_tail(nbt_stack);
  if (top && (top->tag.type == TAG_List)) return;

  /* record the tag. prepend stack tags to "fully-qualify" the name */
  struct nbt_record *r = (struct nbt_record*)utvector_extend(records);
  r->tag = *tag;
  r->pos = pos;
  r->count = count;
  nbt_stack_frame *f = NULL;
  while ( (f = (nbt_stack_frame*)utvector_next(nbt_stack,f))) {
    utstring_printf(&r->fqname, "%.*s.", (int)f->tag.len, f->tag.name);
  }
  utstring_printf(&r->fqname, "%.*s", (int)tag->len, tag->name);
}
Beispiel #4
0
void dump(UT_vector *v) {
  printf("len: %d\n", utvector_len(v));
  UT_string *p=NULL;
  while ( (p=(UT_string*)utvector_next(v,p))) printf("%s\n",utstring_body(p));
}