- int mask, length ;
- unsigned int tag ;
- threadref ref ;
- char * limit = pkt + 500 ; /* plausable parsing limit */
- int retval = 1 ;
-
- PKT_TRACE("upk-threadinfo ",pkt) ;
-
- /* info->threadid = 0 ; FIXME: implement zero_threadref */
- info->active = 0 ;
- info->display[0] = '\0' ;
- info->shortname[0] = '\0' ;
- info->more_display[0] = '\0' ;
-
- /* Assume the characters indicating the packet type have been stripped */
- pkt = unpack_int(pkt,&mask) ; /* arg mask */
- pkt = unpack_threadid(pkt , &ref) ;
-
- if (! threadmatch(&ref,expectedref))
- { /* This is an answer to a different request */
- output_string("FAIL Thread mismatch\n") ;
- output_threadid("ref ",&ref) ;
- output_threadid("expected ",expectedref) ;
- return 0 ;
- }
- copy_threadref(&info->threadid,&ref) ;
-
- /* Loop on tagged fields , try to bail if somthing goes wrong */
- if (mask==0) output_string("OOPS NO MASK \n") ;
-
- while ((pkt < limit) && mask && *pkt) /* packets are terminated with nulls */
- {
- pkt = unpack_int(pkt,&tag) ; /* tag */
- pkt = unpack_byte(pkt,&length) ; /* length */
- if (! (tag & mask)) /* tags out of synch with mask */
- {
- output_string("FAIL: threadinfo tag mismatch\n") ;
- retval = 0 ;
- break ;
- }
- if (tag == TAG_THREADID)
- {
- output_string("unpack THREADID\n") ;
- if (length != 16)
- {
- output_string("FAIL: length of threadid is not 16\n") ;
- retval = 0 ;
- break ;
- }
- pkt = unpack_threadid(pkt,&ref) ;
- mask = mask & ~ TAG_THREADID ;
- continue ;
- }
- if (tag == TAG_EXISTS)
- {
- info->active = stub_unpack_int(pkt,length) ;
- pkt += length ;
- mask = mask & ~(TAG_EXISTS) ;
- if (length > 8)
- {
- output_string("FAIL: 'exists' length too long\n") ;
- retval = 0 ;
- break ;
- }
- continue ;
- }
- if (tag == TAG_THREADNAME)
- {
- pkt = unpack_string(pkt,&info->shortname[0],length) ;
- mask = mask & ~TAG_THREADNAME ;
- continue ;
- }
- if (tag == TAG_DISPLAY)
- {
- pkt = unpack_string(pkt,&info->display[0],length) ;
- mask = mask & ~TAG_DISPLAY ;
- continue ;
- }
- if (tag == TAG_MOREDISPLAY)
- {
- pkt = unpack_string(pkt,&info->more_display[0],length) ;
- mask = mask & ~TAG_MOREDISPLAY ;
- continue ;
- }
- output_string("FAIL: unknown info tag\n") ;
- break ; /* Not a tag we know about */
- }
- return retval ;
+ int mask, length;
+ unsigned int tag;
+ threadref ref;
+ char *limit = pkt + 500; /* plausable parsing limit */
+ int retval = 1;
+
+ PKT_TRACE("upk-threadinfo ", pkt);
+
+ /* info->threadid = 0; FIXME: implement zero_threadref */
+ info->active = 0;
+ info->display[0] = '\0';
+ info->shortname[0] = '\0';
+ info->more_display[0] = '\0';
+
+ /* Assume the characters indicating the packet type have been stripped */
+ pkt = unpack_int(pkt, &mask); /* arg mask */
+ pkt = unpack_threadid(pkt, &ref);
+
+ if (! threadmatch(&ref, expectedref))
+ { /* This is an answer to a different request */
+ output_string("FAIL Thread mismatch\n");
+ output_threadid("ref ", &ref);
+ output_threadid("expected ", expectedref);
+ return 0;
+ }
+ copy_threadref(&info->threadid, &ref);
+
+ /* Loop on tagged fields, try to bail if somthing goes wrong */
+ if (mask==0) output_string("OOPS NO MASK \n");
+
+ while ((pkt < limit) && mask && *pkt) /* packets are terminated with nulls */
+ {
+ pkt = unpack_int(pkt, &tag); /* tag */
+ pkt = unpack_byte(pkt, &length); /* length */
+ if (! (tag & mask)) /* tags out of synch with mask */
+ {
+ output_string("FAIL: threadinfo tag mismatch\n");
+ retval = 0;
+ break;
+ }
+ if (tag == TAG_THREADID)
+ {
+ output_string("unpack THREADID\n");
+ if (length != 16)
+ {
+ output_string("FAIL: length of threadid is not 16\n");
+ retval = 0;
+ break;
+ }
+ pkt = unpack_threadid(pkt, &ref);
+ mask = mask & ~ TAG_THREADID;
+ continue;
+ }
+ if (tag == TAG_EXISTS)
+ {
+ info->active = stub_unpack_int(pkt, length);
+ pkt += length;
+ mask = mask & ~(TAG_EXISTS);
+ if (length > 8)
+ {
+ output_string("FAIL: 'exists' length too long\n");
+ retval = 0;
+ break;
+ }
+ continue;
+ }
+ if (tag == TAG_THREADNAME)
+ {
+ pkt = unpack_string(pkt, &info->shortname[0], length);
+ mask = mask & ~TAG_THREADNAME;
+ continue;
+ }
+ if (tag == TAG_DISPLAY)
+ {
+ pkt = unpack_string(pkt, &info->display[0], length);
+ mask = mask & ~TAG_DISPLAY;
+ continue;
+ }
+ if (tag == TAG_MOREDISPLAY)
+ {
+ pkt = unpack_string(pkt, &info->more_display[0], length);
+ mask = mask & ~TAG_MOREDISPLAY;
+ continue;
+ }
+ output_string("FAIL: unknown info tag\n");
+ break; /* Not a tag we know about */
+ }
+ return retval ;