Ejemplo n.º 1
0
int print_attribute( pwr_tObjid objid, pwr_tClassId classid, char *object_p, char *attributename,
		  int array_element, int index, FILE *fp)
{
  pwr_tTypeId tid;
  pwr_tUInt32 size, offs, elem;
  char objectname[120];
  char parname[120];
  char *s;
  int sts;
  char buf[1024];

  strcpy( objectname, attributename);
  s = strchr( objectname, '.');
  strcpy( parname, s+1);
  *s = 0;

  sts = gdh_GetAttributeCharacteristics( attributename, &tid, &size, &offs, &elem);
  if ( EVEN(sts)) return sts;

  if ( !array_element) {
    sts = gdh_GetObjectInfo( attributename, buf, sizeof(buf));
    if ( EVEN(sts)) return sts;

    print_attr( buf, objid, objectname, parname, tid, size, 
		0, elem, fp);
  }
  else {
    print_attr( object_p, objid, objectname, parname, tid, size, offs,
		elem, fp);
  }
  return 1;
}
Ejemplo n.º 2
0
void IdealGraphPrinter::print_method(ciMethod *method, int bci, InlineTree *tree) {
  begin_head(METHOD_ELEMENT);

  stringStream str;
  method->print_name(&str);

  stringStream shortStr;
  method->print_short_name(&shortStr);

  print_attr(METHOD_NAME_PROPERTY, str.as_string());
  print_attr(METHOD_SHORT_NAME_PROPERTY, shortStr.as_string());
  print_attr(METHOD_BCI_PROPERTY, bci);

  end_head();

  head(BYTECODES_ELEMENT);
  _xml->print_cr("<![CDATA[");
  method->print_codes_on(_xml);
  _xml->print_cr("]]>");
  tail(BYTECODES_ELEMENT);

  if (tree != NULL && tree->subtrees().length() > 0) {
    head(INLINE_ELEMENT);
    GrowableArray<InlineTree *> subtrees = tree->subtrees();
    for (int i = 0; i < subtrees.length(); i++) {
      print_inline_tree(subtrees.at(i));
    }
    tail(INLINE_ELEMENT);
  }

  tail(METHOD_ELEMENT);
  _xml->flush();
}
// Print current ideal graph
void IdealGraphPrinter::print(Compile* compile, const char *name, Node *node, int level, bool clear_nodes) {

  if (!_current_method || !_should_send_method || level > PrintIdealGraphLevel) return;

  this->C = compile;

  // Warning, unsafe cast?
  _chaitin = (PhaseChaitin *)C->regalloc();

  begin_head(GRAPH_ELEMENT);
  print_attr(GRAPH_NAME_PROPERTY, (const char *)name);
  end_head();

  VectorSet temp_set(Thread::current()->resource_area());

  head(NODES_ELEMENT);
  walk_nodes(node, false, &temp_set);
  tail(NODES_ELEMENT);

  head(EDGES_ELEMENT);
  walk_nodes(node, true, &temp_set);
  tail(EDGES_ELEMENT);
  if (C->cfg() != NULL) {
    head(CONTROL_FLOW_ELEMENT);
    for (uint i = 0; i < C->cfg()->number_of_blocks(); i++) {
      Block* block = C->cfg()->get_block(i);
      begin_head(BLOCK_ELEMENT);
      print_attr(BLOCK_NAME_PROPERTY, block->_pre_order);
      end_head();

      head(SUCCESSORS_ELEMENT);
      for (uint s = 0; s < block->_num_succs; s++) {
        begin_elem(SUCCESSOR_ELEMENT);
        print_attr(BLOCK_NAME_PROPERTY, block->_succs[s]->_pre_order);
        end_elem();
      }
      tail(SUCCESSORS_ELEMENT);

      head(NODES_ELEMENT);
      for (uint s = 0; s < block->number_of_nodes(); s++) {
        begin_elem(NODE_ELEMENT);
        print_attr(NODE_ID_PROPERTY, get_node_id(block->get_node(s)));
        end_elem();
      }
      tail(NODES_ELEMENT);

      tail(BLOCK_ELEMENT);
    }
    tail(CONTROL_FLOW_ELEMENT);
  }
  tail(GRAPH_ELEMENT);
  output()->flush();
}
Ejemplo n.º 4
0
int main(int argc, char * argv[]) {
    BigFile bf = {0};
    BigBlock bb = {0};

    int opt;
    while(-1 != (opt = getopt(argc, argv, "l"))) {
        switch(opt) {
            case 'l':
                longfmt = 1;
                break;
            default:
                usage();
        }
    }
    argv += optind - 1;
    if(argc - optind < 2) {
        usage();
    }

    if(0 != big_file_open(&bf, argv[1])) {
        fprintf(stderr, "failed to open file : %s %s\n", argv[1], big_file_get_error_message());
        exit(1);
    }
    if(0 != big_file_open_block(&bf, &bb, argv[2])) {
        fprintf(stderr, "failed to open block: %s %s\n", argv[2], big_file_get_error_message());
        exit(1);
    }
    int i; 
    if(argc - optind == 2) {
        size_t nattr;
        BigAttr * attrs = big_block_list_attrs(&bb, &nattr);
        for(i = 0; i < nattr; i ++) {
            BigAttr * attr = &attrs[i];
            print_attr(attr, 0);
        }
    }
    for(i = 3; i < argc - optind + 1; i ++) {
        BigAttr * attr = big_block_lookup_attr(&bb, argv[i]);
        if(attr) {
            print_attr(attr, argc - optind == 3);
        } else {
            printf("%s, not attr:\n", argv[i]);
        }
    }
    big_block_close(&bb);
    big_file_close(&bf);
    return 0;
}
Ejemplo n.º 5
0
void IdealGraphPrinter::print_prop(const char *name, const char *val) {
  begin_head(PROPERTY_ELEMENT);
  print_attr(PROPERTY_NAME_PROPERTY, name);
  end_head();
  text(val);
  tail(PROPERTY_ELEMENT);
}
Ejemplo n.º 6
0
Archivo: client.c Proyecto: twonly/mis
int	ppfs_chmod (const char *path, mode_t mt){
  fprintf(stderr, "ppfs_chmod path : %s\n", path);

  ppacket *s = createpacket_s(4+strlen(path)+4, CLTOMD_CHMOD,-1);
  uint8_t* ptr = s->startptr+HEADER_LEN;

  put32bit(&ptr, strlen(path));
  memcpy(ptr, path, strlen(path));
  ptr+=strlen(path);
  put32bit(&ptr, mt);

  sendpacket(fd, s);
  free(s);

  s = receivepacket(fd);
  const uint8_t* ptr2 = s->startptr;
  int status = get32bit(&ptr2);

  if(status == 0){
    print_attr((const attr*)ptr2);

    attr_cache* ac;
    if(lookup_attr_cache(path,&ac) == 0){
      ac->a.mode = mt;
    }

  }
  free(s);

  return status;
}
Ejemplo n.º 7
0
Archivo: client.c Proyecto: twonly/mis
int	ppfs_chown (const char *path, uid_t uid, gid_t gid){
  fprintf(stderr, "ppfs_chown path : %s\n", path);


  ppacket *s = createpacket_s(4+strlen(path)+8, CLTOMD_CHOWN, -1);
  uint8_t* ptr = s->startptr+HEADER_LEN;

  put32bit(&ptr, strlen(path));
  memcpy(ptr, path, strlen(path));
  ptr+=strlen(path);
  put32bit(&ptr, uid);
  put32bit(&ptr, gid);

  sendpacket(fd, s);
  free(s);

  s = receivepacket(fd);
  const uint8_t* ptr2 = s->startptr;
  int status = get32bit(&ptr2);

  if(status == 0){
    print_attr((const attr*)ptr2);

    attr_cache* ac;
    if(lookup_attr_cache(path,&ac) == 0){
      ac->a.uid = uid;
      ac->a.gid = gid;
    }
  }
  free(s);

  return status;
}
Ejemplo n.º 8
0
void
dump_gesture_event(GeisEvent event)
{
  GeisSize i;
  GeisTouchSet touchset;
  GeisGroupSet groupset;
  GeisAttr     attr;

  attr = geis_event_attr_by_name(event, GEIS_EVENT_ATTRIBUTE_TOUCHSET);
  touchset = geis_attr_value_to_pointer(attr);

  attr = geis_event_attr_by_name(event, GEIS_EVENT_ATTRIBUTE_GROUPSET);
  groupset = geis_attr_value_to_pointer(attr);

  printf("gesture\n");
  for (i= 0; i < geis_groupset_group_count(groupset); ++i)
  {
    GeisSize j;
    GeisGroup group = geis_groupset_group(groupset, i);
    printf("+group %u\n", geis_group_id(group));

    for (j=0; j < geis_group_frame_count(group); ++j)
    {
      GeisSize k;
      GeisFrame frame = geis_group_frame(group, j);
      GeisSize attr_count = geis_frame_attr_count(frame);

      printf("+frame %u\n", geis_frame_id(frame));
      for (k = 0; k < attr_count; ++k)
      {
        print_attr(geis_frame_attr(frame, k));
      }

      for (k = 0; k < geis_frame_touchid_count(frame); ++k)
      {
        GeisSize  touchid = geis_frame_touchid(frame, k);
        GeisTouch touch = geis_touchset_touch_by_id(touchset, touchid);
        GeisSize  n;
        printf("+touch %lu\n", k);
        for (n = 0; n < geis_touch_attr_count(touch); ++n)
        {
          print_attr(geis_touch_attr(touch, n));
        }
      }
    }
  }
}
Ejemplo n.º 9
0
int print_object( pwr_tOid oid, pwr_tCid cid, char *object_p, 
		  int offset, char *prefix, FILE *fp)
{
  int		sts;
  unsigned long	elements;
  int		i, j;
  char		objectname[120];
  gdh_sAttrDef 	*bd;
  int 		rows;
  char		idx[20];

  sts = gdh_GetObjectBodyDef( cid, &bd, &rows, oid);
  if ( EVEN(sts)) return sts;

  for ( i = 0; i < rows; i++) {

    if ( bd[i].attr->Param.Info.Flags & PWR_MASK_RTVIRTUAL || 
	 bd[i].attr->Param.Info.Flags & PWR_MASK_PRIVATE)
      continue;

    elements = 1;
    if ( bd[i].attr->Param.Info.Flags & PWR_MASK_ARRAY)
      elements = bd[i].attr->Param.Info.Elements;
    else
      elements = 1;

    if ( bd[i].attr->Param.Info.Flags & PWR_MASK_CLASS) {
      if ( elements == 1) {
	strcpy( objectname, prefix);
	strcat( objectname, ".");
	strcat( objectname, bd[i].attrName);
	print_object( oid, bd[i].attr->Param.TypeRef, object_p, 
		      offset + bd[i].attr->Param.Info.Offset, objectname, fp);
      }
      else {
	for ( j = 0; j < elements; j++) {
	  strcpy( objectname, prefix);
	  strcat( objectname, ".");
	  strcat( objectname, bd[i].attrName);
	  sprintf( idx, "[%d]", j);
	  strcat( objectname, idx);
	  print_object( oid, bd[i].attr->Param.TypeRef, object_p, 
			offset + bd[i].attr->Param.Info.Offset + 
			j * bd[i].attr->Param.Info.Size / elements, objectname, fp);
	}
      }
    }
    else
      print_attr( object_p, oid, prefix, bd[i].attrName, bd[i].attr->Param.Info.Type, 
		  bd[i].attr->Param.Info.Size,
		  offset + bd[i].attr->Param.Info.Offset, elements, fp);

  }
  return 1;
}
Ejemplo n.º 10
0
static int print_media_desc( pjmedia_sdp_media *m, char *buf, int len)
{
    char *p = buf;
    char *end = buf+len;
    unsigned i;
    int printed;

    /* check length for the "m=" line. */
    if (len < m->desc.media.slen+m->desc.transport.slen+12+24) {
	return -1;
    }
    *p++ = 'm';	    /* m= */
    *p++ = '=';
    pj_memcpy(p, m->desc.media.ptr, m->desc.media.slen);
    p += m->desc.media.slen;
    *p++ = ' ';
    printed = pj_utoa(m->desc.port, p);
    p += printed;
    if (m->desc.port_count > 1) {
	*p++ = '/';
	printed = pj_utoa(m->desc.port_count, p);
	p += printed;
    }
    *p++ = ' ';
    pj_memcpy(p, m->desc.transport.ptr, m->desc.transport.slen);
    p += m->desc.transport.slen;
    for (i=0; i<m->desc.fmt_count; ++i) {
	*p++ = ' ';
	pj_memcpy(p, m->desc.fmt[i].ptr, m->desc.fmt[i].slen);
	p += m->desc.fmt[i].slen;
    }
    *p++ = '\r';
    *p++ = '\n';

    /* print connection info, if present. */
    if (m->conn) {
	printed = print_connection_info(m->conn, p, end-p);
	if (printed < 0) {
	    return -1;
	}
	p += printed;
    }

    /* print attributes. */
    for (i=0; i<m->attr_count; ++i) {
	printed = print_attr(m->attr[i], p, end-p);
	if (printed < 0) {
	    return -1;
	}
	p += printed;
    }

    return p-buf;
}
Ejemplo n.º 11
0
int main(void)
{
	struct person persona = {"Juan", "Tanamera", 23, 956123123};

	print_person(&persona);

	print_attr(&persona, PHONE);

	printf("\n");

	return 0;
}
Ejemplo n.º 12
0
struct tag *
print_otag(struct html *h, enum htmltag tag,
		int sz, const struct htmlpair *p)
{
	int		 i;
	struct tag	*t;

	/* Push this tags onto the stack of open scopes. */

	if ( ! (HTML_NOSTACK & htmltags[tag].flags)) {
		t = mandoc_malloc(sizeof(struct tag));
		t->tag = tag;
		t->next = h->tags.head;
		h->tags.head = t;
	} else
		t = NULL;

	if ( ! (HTML_NOSPACE & h->flags))
		if ( ! (HTML_CLRLINE & htmltags[tag].flags)) {
			/* Manage keeps! */
			if ( ! (HTML_KEEP & h->flags)) {
				if (HTML_PREKEEP & h->flags)
					h->flags |= HTML_KEEP;
				putchar(' ');
			} else
				printf("&#160;");
		}

	if ( ! (h->flags & HTML_NONOSPACE))
		h->flags &= ~HTML_NOSPACE;
	else
		h->flags |= HTML_NOSPACE;

	/* Print out the tag name and attributes. */

	printf("<%s", htmltags[tag].name);
	for (i = 0; i < sz; i++)
		print_attr(h, htmlattrs[p[i].key], p[i].val);

	/* Accommodate for "well-formed" singleton escaping. */

	if (HTML_AUTOCLOSE & htmltags[tag].flags)
		putchar('/');

	putchar('>');

	h->flags |= HTML_NOSPACE;

	if ((HTML_AUTOCLOSE | HTML_CLRLINE) & htmltags[tag].flags)
		putchar('\n');

	return t;
}
Ejemplo n.º 13
0
static void
dump_extra_attrs (GSList *attrs, GString *string)
{
  GSList *l;

  for (l = attrs; l; l = l->next)
    {
      PangoAttribute *attr = l->data;

      g_string_append (string, "  ");
      print_attr (attr, string);
    }
}
Ejemplo n.º 14
0
int main()
{
  mqd_t  mqd;
  
  puts( "*** POSIX Message Queue Default Attributes Report ***" );

  mqd = mq_open( "/testq", O_CREAT|O_RDWR, 0777, NULL );
  if ( mqd == (mqd_t) -1 ) {
    perror("mq_open" );
  }
  assert( mqd != (mqd_t) -1 );

  print_attr( mqd );

  puts( "*** END OF POSIX Message Queue Default Attributes Report ***" );
  exit( 0 );
}
Ejemplo n.º 15
0
void
dump_device_event(GeisEvent event)
{
  GeisDevice device;
  GeisAttr attr;
  GeisSize i;
  GeisInputDeviceId device_id = 0;

  attr = geis_event_attr_by_name(event, GEIS_EVENT_ATTRIBUTE_DEVICE);
  device = geis_attr_value_to_pointer(attr);
  printf("device %02d \"%s\"\n",
         geis_device_id(device), geis_device_name(device));
  for (i = 0; i < geis_device_attr_count(device); ++i)
  {
    print_attr(geis_device_attr(device, i));
  }
}
Ejemplo n.º 16
0
/*
 * Dump STUN message to a printable string output.
 */
PJ_DEF(char*) pj_stun_msg_dump(const pj_stun_msg *msg,
			       char *buffer,
			       unsigned length,
			       unsigned *printed_len)
{
    char *p, *end;
    int len;
    unsigned i;

    PJ_ASSERT_RETURN(msg && buffer && length, NULL);

    PJ_CHECK_STACK();
    
    p = buffer;
    end = buffer + length;

    len = pj_ansi_snprintf(p, end-p, "STUN %s %s\n",
			   pj_stun_get_method_name(msg->hdr.type),
			   pj_stun_get_class_name(msg->hdr.type));
    APPLY();

    len = pj_ansi_snprintf(p, end-p, 
			   " Hdr: length=%d, magic=%08x, tsx_id=%08x%08x%08x\n"
			   " Attributes:\n",
			   msg->hdr.length,
			   msg->hdr.magic,
			   *(pj_uint32_t*)&msg->hdr.tsx_id[0],
			   *(pj_uint32_t*)&msg->hdr.tsx_id[4],
			   *(pj_uint32_t*)&msg->hdr.tsx_id[8]);
    APPLY();

    for (i=0; i<msg->attr_count; ++i) {
	len = print_attr(p, (unsigned)(end-p), msg->attr[i]);
	APPLY();
    }

on_return:
    *p = '\0';
    if (printed_len)
	*printed_len = (unsigned)(p-buffer);
    return buffer;

#undef APPLY
}
Ejemplo n.º 17
0
static void
dump_attrs (PangoAttrList *attrs, GString *string)
{
  PangoAttrIterator *iter;

  iter = pango_attr_list_get_iterator (attrs);
  do {
    gint start, end;
    GSList *list, *l;

    pango_attr_iterator_range (iter, &start, &end);
    g_string_append_printf (string, "range %d %d\n", start, end);
    list = pango_attr_iterator_get_attrs (iter);
    for (l = list; l; l = l->next)
      {
        PangoAttribute *attr = l->data;
        print_attr (attr, string);
      }
    g_slist_free_full (list, (GDestroyNotify)pango_attribute_destroy);
  } while (pango_attr_iterator_next (iter));

  pango_attr_iterator_destroy (iter);
}
Ejemplo n.º 18
0
static int print_session(const pjmedia_sdp_session *ses, 
			 char *buf, pj_ssize_t len)
{
    char *p = buf;
    char *end = buf+len;
    unsigned i;
    int printed;

    /* Check length for v= and o= lines. */
    if (len < 5+ 
	      2+ses->origin.user.slen+18+
	      ses->origin.net_type.slen+ses->origin.addr.slen + 2)
    {
	return -1;
    }

    /* SDP version (v= line) */
    pj_memcpy(p, "v=0\r\n", 5);
    p += 5;

    /* Owner (o=) line. */
    *p++ = 'o';
    *p++ = '=';
    pj_memcpy(p, ses->origin.user.ptr, ses->origin.user.slen);
    p += ses->origin.user.slen;
    *p++ = ' ';
    printed = pj_utoa(ses->origin.id, p);
    p += printed;
    *p++ = ' ';
    printed = pj_utoa(ses->origin.version, p);
    p += printed;
    *p++ = ' ';
    pj_memcpy(p, ses->origin.net_type.ptr, ses->origin.net_type.slen);
    p += ses->origin.net_type.slen;
    *p++ = ' ';
    pj_memcpy(p, ses->origin.addr_type.ptr, ses->origin.addr_type.slen);
    p += ses->origin.addr_type.slen;
    *p++ = ' ';
    pj_memcpy(p, ses->origin.addr.ptr, ses->origin.addr.slen);
    p += ses->origin.addr.slen;
    *p++ = '\r';
    *p++ = '\n';

    /* Session name (s=) line. */
    if ((end-p)  < 8+ses->name.slen) {
	return -1;
    }
    *p++ = 's';
    *p++ = '=';
    pj_memcpy(p, ses->name.ptr, ses->name.slen);
    p += ses->name.slen;
    *p++ = '\r';
    *p++ = '\n';

    /* Connection line (c=) if exist. */
    if (ses->conn) {
	printed = print_connection_info(ses->conn, p, end-p);
	if (printed < 1) {
	    return -1;
	}
	p += printed;
    }


    /* Time */
    if ((end-p) < 24) {
	return -1;
    }
    *p++ = 't';
    *p++ = '=';
    printed = pj_utoa(ses->time.start, p);
    p += printed;
    *p++ = ' ';
    printed = pj_utoa(ses->time.stop, p);
    p += printed;
    *p++ = '\r';
    *p++ = '\n';

    /* Print all attribute (a=) lines. */
    for (i=0; i<ses->attr_count; ++i) {
	printed = print_attr(ses->attr[i], p, end-p);
	if (printed < 0) {
	    return -1;
	}
	p += printed;
    }

    /* Print media (m=) lines. */
    for (i=0; i<ses->media_count; ++i) {
	printed = print_media_desc(ses->media[i], p, end-p);
	if (printed < 0) {
	    return -1;
	}
	p += printed;
    }

    return p-buf;
}
Ejemplo n.º 19
0
/* Check if the response is an error, redirect response
 * or it includes a warning
 * @param response - the LoST response body
 * @param resp_type - the response type: ERROR, REDIRECT, WARNING or OK
 * @returns the root node of the parsed xml body
 */ 
xmlNode* get_LoST_resp_type(str response, lost_resp_type * resp_type, str * reason){
			
	xmlNode * root, * node, * child;

	reason->s = NULL;
	reason->len = 0;

	root = xml_parse_string(response);
	if(!root)
		return root;

#ifdef LOST_DEBUG	
	print_element_names(root);
#endif

	if(strcmp((char*)root->name, LOST_ERR_NODE_NAME) == 0){
		DEBUG_LOG("LoST response has an error response\n");
		
		node = child_node(root);
		if(node){
			DEBUG_LOG("reason %s\n", node->name);
			reason->s = (char*)node->name;
			reason->len = strlen(reason->s);			
#ifdef LOST_DEBUG
			print_attr(node, LOST_MSG_ATTR_NAME);
#endif
		}else {
			DEBUG_LOG("the message has no reason\n");
		}

		*resp_type = LOST_ERR;

	} else if(strcmp((char*)root->name, LOST_REDIR_NODE_NAME) == 0){

		DEBUG_LOG("LoST response has a redirect response\n");
#ifdef LOST_DEBUG		
		print_attr(root, LOST_TGT_ATTR_NAME);
#endif
		*resp_type = LOST_REDIR;

	} else 	if(strcmp((char*)root->name, LOST_FINDSRESP_NODE_NAME) != 0){

		ERROR_LOG("invalid LoST response\n");
		*resp_type = LOST_ERR;

	} else {
		
		node = child_named_node(root, LOST_WRNG_NODE_NAME);
		if(node){
			DEBUG_LOG("LoST response has a response with warning\n");
			if((child = child_node(node))){
				DEBUG_LOG("reason %s\n", child->name);
				reason->s = (char*)child->name;
				reason->len = strlen(reason->s);			
#ifdef LOST_DEBUG
				print_attr(node, LOST_MSG_ATTR_NAME);
#endif
			}else {
				DEBUG_LOG("warning without reason\n");
			}

			*resp_type = LOST_WRNG;
		}else
			*resp_type = LOST_OK;
	}

	return root;
}
struct tag *
print_otag(struct html *h, enum htmltag tag, 
		int sz, const struct htmlpair *p)
{
	int		 i;
	struct tag	*t;

	/* Push this tags onto the stack of open scopes. */

	if ( ! (HTML_NOSTACK & htmltags[tag].flags)) {
		t = mandoc_malloc(sizeof(struct tag));
		t->tag = tag;
		t->next = h->tags.head;
		h->tags.head = t;
	} else
		t = NULL;

	if ( ! (HTML_NOSPACE & h->flags))
		if ( ! (HTML_CLRLINE & htmltags[tag].flags)) {
			/* Manage keeps! */
			if ( ! (HTML_KEEP & h->flags)) {
				if (HTML_PREKEEP & h->flags)
					h->flags |= HTML_KEEP;
				putchar(' ');
			} else
				printf("&#160;");
		}

	if ( ! (h->flags & HTML_NONOSPACE))
		h->flags &= ~HTML_NOSPACE;
	else
		h->flags |= HTML_NOSPACE;

	/* Print out the tag name and attributes. */

	printf("<%s", htmltags[tag].name);
	for (i = 0; i < sz; i++)
		print_attr(h, htmlattrs[p[i].key], p[i].val);

	/* Add non-overridable attributes. */

	if (TAG_HTML == tag && HTML_XHTML_1_0_STRICT == h->type) {
		print_attr(h, "xmlns", "http://www.w3.org/1999/xhtml");
		print_attr(h, "xml:lang", "en");
		print_attr(h, "lang", "en");
	}

	/* Accommodate for XML "well-formed" singleton escaping. */

	if (HTML_AUTOCLOSE & htmltags[tag].flags)
		switch (h->type) {
		case (HTML_XHTML_1_0_STRICT):
			putchar('/');
			break;
		default:
			break;
		}

	putchar('>');

	h->flags |= HTML_NOSPACE;

	if ((HTML_AUTOCLOSE | HTML_CLRLINE) & htmltags[tag].flags)
		putchar('\n');

	return(t);
}
Ejemplo n.º 21
0
Archivo: client.c Proyecto: twonly/mis
int ppfs_getattr(const char* path, struct stat* stbuf){
  fprintf(stderr, "ppfs_getattr path : %s\n", path);

  attr_cache* ac;
  if(lookup_attr_cache(path,&ac) == 0){
    stbuf->st_mode = ac->a.mode; //S_IFREG | 0755;
    stbuf->st_nlink = ac->a.link;
    if(stbuf->st_mode & S_IFDIR )
      stbuf->st_size = 4096;
    else
      stbuf->st_size = ac->a.size;

    stbuf->st_ctime = ac->a.ctime;
    stbuf->st_atime = ac->a.atime;
    stbuf->st_mtime = ac->a.mtime;

    stbuf->st_uid = ac->a.uid;
    stbuf->st_gid = ac->a.gid;
    stbuf->st_blocks = 0;

    return 0;
  }

  ppacket *s = createpacket_s(4+strlen(path), CLTOMD_GETATTR,-1);
  fprintf(stderr, "createpacket_s packet size:%u, cmd:%X\n", s->size, s->cmd); //5,4096
  uint8_t* ptr = s->startptr+HEADER_LEN;

  put32bit(&ptr, strlen(path));
  memcpy(ptr, path, strlen(path));
  ptr += strlen(path);

  sendpacket(fd, s);
  free(s);

  s = receivepacket(fd);
  const uint8_t* ptr2 = s->startptr;
  int status = get32bit(&ptr2);
  fprintf(stderr,"status:%d\n",status);

  if(status == 0){
    print_attr((const attr*)ptr2);

    memset(stbuf, 0, sizeof(struct stat));
    const attr* a = (const attr*)ptr2;

    stbuf->st_mode = a->mode; //S_IFREG | 0755;
    stbuf->st_nlink = a->link;
    if(stbuf->st_mode & S_IFDIR )
      stbuf->st_size = 4096;
    else
      stbuf->st_size = a->size;

    stbuf->st_ctime = a->ctime;
    stbuf->st_atime = a->atime;
    stbuf->st_mtime = a->mtime;

    stbuf->st_uid = a->uid;
    stbuf->st_gid = a->gid;

    stbuf->st_blocks = 0;

    attr_cache_add(path,*a);
  }

  free(s);

  return status;
} //always called before open
Ejemplo n.º 22
0
void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {

  if (edges) {

    // Output edge
    node_idx_t dest_id = n->_idx;
    for ( uint i = 0; i < n->len(); i++ ) {
      if ( n->in(i) ) {
        Node *source = n->in(i);
        begin_elem(EDGE_ELEMENT);
        print_attr(FROM_PROPERTY, source->_idx);
        print_attr(TO_PROPERTY, dest_id);
        print_attr(INDEX_PROPERTY, i);
        end_elem();
      }
    }

  } else {

    // Output node
    begin_head(NODE_ELEMENT);
    print_attr(NODE_ID_PROPERTY, n->_idx);
    end_head();

    head(PROPERTIES_ELEMENT);

    Node *node = n;
#ifndef PRODUCT
    Compile::current()->_in_dump_cnt++;
    print_prop(NODE_NAME_PROPERTY, (const char *)node->Name());
    const Type *t = node->bottom_type();
    print_prop("type", t->msg());
    print_prop("idx", node->_idx);
#ifdef ASSERT
    print_prop("debug_idx", node->_debug_idx);
#endif

    if (C->cfg() != NULL) {
      Block* block = C->cfg()->get_block_for_node(node);
      if (block == NULL) {
        print_prop("block", C->cfg()->get_block(0)->_pre_order);
      } else {
        print_prop("block", block->_pre_order);
      }
    }

    const jushort flags = node->flags();
    if (flags & Node::Flag_is_Copy) {
      print_prop("is_copy", "true");
    }
    if (flags & Node::Flag_rematerialize) {
      print_prop("rematerialize", "true");
    }
    if (flags & Node::Flag_needs_anti_dependence_check) {
      print_prop("needs_anti_dependence_check", "true");
    }
    if (flags & Node::Flag_is_macro) {
      print_prop("is_macro", "true");
    }
    if (flags & Node::Flag_is_Con) {
      print_prop("is_con", "true");
    }
    if (flags & Node::Flag_is_cisc_alternate) {
      print_prop("is_cisc_alternate", "true");
    }
    if (flags & Node::Flag_is_dead_loop_safe) {
      print_prop("is_dead_loop_safe", "true");
    }
    if (flags & Node::Flag_may_be_short_branch) {
      print_prop("may_be_short_branch", "true");
    }
    if (flags & Node::Flag_has_call) {
      print_prop("has_call", "true");
    }

    if (C->matcher() != NULL) {
      if (C->matcher()->is_shared(node)) {
        print_prop("is_shared", "true");
      } else {
        print_prop("is_shared", "false");
      }
      if (C->matcher()->is_dontcare(node)) {
        print_prop("is_dontcare", "true");
      } else {
        print_prop("is_dontcare", "false");
      }

#ifdef ASSERT
      Node* old = C->matcher()->find_old_node(node);
      if (old != NULL) {
        print_prop("old_node_idx", old->_idx);
      }
#endif
    }

    if (node->is_Proj()) {
      print_prop("con", (int)node->as_Proj()->_con);
    }

    if (node->is_Mach()) {
      print_prop("idealOpcode", (const char *)NodeClassNames[node->as_Mach()->ideal_Opcode()]);
    }

    buffer[0] = 0;
    stringStream s2(buffer, sizeof(buffer) - 1);

    node->dump_spec(&s2);
    if (t != NULL && (t->isa_instptr() || t->isa_klassptr())) {
      const TypeInstPtr  *toop = t->isa_instptr();
      const TypeKlassPtr *tkls = t->isa_klassptr();
      ciKlass*           klass = toop ? toop->klass() : (tkls ? tkls->klass() : NULL );
      if( klass && klass->is_loaded() && klass->is_interface() ) {
        s2.print("  Interface:");
      } else if( toop ) {
        s2.print("  Oop:");
      } else if( tkls ) {
        s2.print("  Klass:");
      }
      t->dump_on(&s2);
    } else if( t == Type::MEMORY ) {
      s2.print("  Memory:");
      MemNode::dump_adr_type(node, node->adr_type(), &s2);
    }

    assert(s2.size() < sizeof(buffer), "size in range");
    print_prop("dump_spec", buffer);

    if (node->is_block_proj()) {
      print_prop("is_block_proj", "true");
    }

    if (node->is_block_start()) {
      print_prop("is_block_start", "true");
    }

    const char *short_name = "short_name";
    if (strcmp(node->Name(), "Parm") == 0 && node->as_Proj()->_con >= TypeFunc::Parms) {
      int index = node->as_Proj()->_con - TypeFunc::Parms;
      if (index >= 10) {
        print_prop(short_name, "PA");
      } else {
        sprintf(buffer, "P%d", index);
        print_prop(short_name, buffer);
      }
    } else if (strcmp(node->Name(), "IfTrue") == 0) {
      print_prop(short_name, "T");
    } else if (strcmp(node->Name(), "IfFalse") == 0) {
      print_prop(short_name, "F");
    } else if ((node->is_Con() && node->is_Type()) || node->is_Proj()) {

      if (t->base() == Type::Int && t->is_int()->is_con()) {
        const TypeInt *typeInt = t->is_int();
        assert(typeInt->is_con(), "must be constant");
        jint value = typeInt->get_con();

        // max. 2 chars allowed
        if (value >= -9 && value <= 99) {
          sprintf(buffer, "%d", value);
          print_prop(short_name, buffer);
        } else {
          print_prop(short_name, "I");
        }
      } else if (t == Type::TOP) {
        print_prop(short_name, "^");
      } else if (t->base() == Type::Long && t->is_long()->is_con()) {
        const TypeLong *typeLong = t->is_long();
        assert(typeLong->is_con(), "must be constant");
        jlong value = typeLong->get_con();

        // max. 2 chars allowed
        if (value >= -9 && value <= 99) {
          sprintf(buffer, JLONG_FORMAT, value);
          print_prop(short_name, buffer);
        } else {
          print_prop(short_name, "L");
        }
      } else if (t->base() == Type::KlassPtr) {
        const TypeKlassPtr *typeKlass = t->is_klassptr();
        print_prop(short_name, "CP");
      } else if (t->base() == Type::Control) {
        print_prop(short_name, "C");
      } else if (t->base() == Type::Memory) {
        print_prop(short_name, "M");
      } else if (t->base() == Type::Abio) {
        print_prop(short_name, "IO");
      } else if (t->base() == Type::Return_Address) {
        print_prop(short_name, "RA");
      } else if (t->base() == Type::AnyPtr) {
        print_prop(short_name, "P");
      } else if (t->base() == Type::RawPtr) {
        print_prop(short_name, "RP");
      } else if (t->base() == Type::AryPtr) {
        print_prop(short_name, "AP");
      }
    }

    JVMState* caller = NULL;
    if (node->is_SafePoint()) {
      caller = node->as_SafePoint()->jvms();
    } else {
      Node_Notes* notes = C->node_notes_at(node->_idx);
      if (notes != NULL) {
        caller = notes->jvms();
      }
    }

    if (caller != NULL) {
      stringStream bciStream;
      ciMethod* last = NULL;
      int last_bci;
      while(caller) {
        if (caller->has_method()) {
          last = caller->method();
          last_bci = caller->bci();
        }
        bciStream.print("%d ", caller->bci());
        caller = caller->caller();
      }
      print_prop("bci", bciStream.as_string());
      if (last != NULL && last->has_linenumber_table() && last_bci >= 0) {
        print_prop("line", last->line_number_from_bci(last_bci));
      }
    }

#ifdef ASSERT
    if (node->debug_orig() != NULL) {
      temp_set->Clear();
      stringStream dorigStream;
      Node* dorig = node->debug_orig();
      while (dorig && temp_set->test_set(dorig->_idx)) {
        dorigStream.print("%d ", dorig->_idx);
      }
      print_prop("debug_orig", dorigStream.as_string());
    }
#endif

    if (_chaitin && _chaitin != (PhaseChaitin *)0xdeadbeef) {
      buffer[0] = 0;
      _chaitin->dump_register(node, buffer);
      print_prop("reg", buffer);
      uint lrg_id = 0;
      if (node->_idx < _chaitin->_lrg_map.size()) {
        lrg_id = _chaitin->_lrg_map.live_range_id(node);
      }
      print_prop("lrg", lrg_id);
    }

    Compile::current()->_in_dump_cnt--;
#endif

    tail(PROPERTIES_ELEMENT);
    tail(NODE_ELEMENT);
  }
}
Ejemplo n.º 23
0
/*
 * Print the update entry information
 */
static void
print_update(kdb_hlog_t *ulog, uint32_t entry, bool_t verbose)
{
	XDR		xdrs;
	uint32_t	start_sno, i, j, indx;
	char		*dbprinc;
	kdb_ent_header_t *indx_log;
	kdb_incr_update_t upd;

	if (entry && (entry < ulog->kdb_num))
		start_sno = ulog->kdb_last_sno - entry;
	else
		start_sno = ulog->kdb_first_sno - 1;

	for (i = start_sno; i < ulog->kdb_last_sno; i++) {
		indx = i % ulog->kdb_num;

		indx_log = (kdb_ent_header_t *)INDEX(ulog, indx);

		/*
		 * Check for corrupt update entry
		 */
		if (indx_log->kdb_umagic != KDB_UMAGIC) {
			(void) fprintf(stderr,
			    gettext("Corrupt update entry\n\n"));
			exit(1);
		}

		(void) memset((char *)&upd, 0, sizeof (kdb_incr_update_t));
		xdrmem_create(&xdrs, (char *)indx_log->entry_data,
		    indx_log->kdb_entry_size, XDR_DECODE);
		if (!xdr_kdb_incr_update_t(&xdrs, &upd)) {
			(void) printf(gettext("Entry data decode failure\n\n"));
			exit(1);
		}

		(void) printf("---\n");
		(void) printf(gettext("Update Entry\n"));

		(void) printf(gettext("\tUpdate serial # : %u\n"),
		    indx_log->kdb_entry_sno);

		(void) printf(gettext("\tUpdate operation : "));
		if (upd.kdb_deleted)
			(void) printf(gettext("Delete\n"));
		else
			(void) printf(gettext("Add\n"));

		dbprinc = malloc(upd.kdb_princ_name.utf8str_t_len + 1);
		if (dbprinc == NULL) {
			(void) printf(gettext("Could not allocate "
			    "principal name\n\n"));
			exit(1);
		}
		(void) strlcpy(dbprinc, upd.kdb_princ_name.utf8str_t_val,
		    (upd.kdb_princ_name.utf8str_t_len + 1));
		(void) printf(gettext("\tUpdate principal : %s\n"), dbprinc);

		(void) printf(gettext("\tUpdate size : %u\n"),
		    indx_log->kdb_entry_size);

		(void) printf(gettext("\tUpdate committed : %s\n"),
		    indx_log->kdb_commit ? "True" : "False");

		if (indx_log->kdb_time.seconds == 0L)
			(void) printf(gettext("\tUpdate time stamp : None\n"));
		else
			(void) printf(gettext("\tUpdate time stamp : %s"),
			    ctime((time_t *)&(indx_log->kdb_time.seconds)));

		(void) printf(gettext("\tAttributes changed : %d\n"),
		    upd.kdb_update.kdbe_t_len);

		if (verbose)
			for (j = 0; j < upd.kdb_update.kdbe_t_len; j++)
				print_attr(
				    upd.kdb_update.kdbe_t_val[j].av_type);

		xdr_free(xdr_kdb_incr_update_t, (char *)&upd);
		if (dbprinc)
			free(dbprinc);
	} /* for */
}
Ejemplo n.º 24
0
void IdealGraphPrinter::print_attr(const char *name, intptr_t val) {
  stringStream stream;
  stream.print(INTX_FORMAT, val);
  print_attr(name, stream.as_string());
}