int print_data( pwr_sAttrRef *arp, FILE *fp)
{
  int		sts;
  char		*s;
  pwr_tClassId	classid;
  char		*object_p;
  pwr_tAName   	dataname;
  pwr_tAName   	objectname;
  pwr_tAName   	attributename;
  pwr_tAttrRef	aref;
  int 		object_backup;
  int		array_element = 0;
  int		index;
  int		nr;

  sts = gdh_AttrrefToName( arp, dataname, sizeof(dataname), cdh_mNName);
  if ( EVEN(sts)) return sts;

  strcpy( objectname, dataname);
  if ( !arp->Flags.b.ObjectAttr && (s = strchr( objectname, '.'))) {
    *s = 0;
    object_backup = 0;
    strcpy( attributename, dataname);
    if ( (s = strchr( dataname, '['))) {
      array_element = 1;

      nr = sscanf( s+1, "%d", &index);
      if ( nr != 1) return 0;
    }
  }
  else {
    object_backup = 1;
  }

  sts = gdh_NameToAttrref( pwr_cNOid, objectname, &aref);
  if ( EVEN(sts)) return sts;

  sts = gdh_AttrRefToPointer( &aref, (void **)&object_p);
  if ( EVEN(sts)) return sts;

  sts = gdh_GetAttrRefTid( &aref, &classid);
  if ( EVEN(sts)) return sts;

  if ( object_backup) {
    print_object( &aref, classid, object_p, 0, objectname, fp);
  }
  else {
    print_attribute( &aref, classid, object_p, attributename, array_element, index, fp);
  }
  return 1;
}
static int meta_print_eopt(FILE *fd, struct tcf_ematch_hdr *hdr, void *data,
			   int data_len)
{
	struct rtattr *tb[TCA_EM_META_MAX+1];
	struct tcf_meta_hdr *meta_hdr;

	if (parse_rtattr(tb, TCA_EM_META_MAX, data, data_len) < 0)
		return -1;

	if (tb[TCA_EM_META_HDR] == NULL) {
		fprintf(stderr, "Missing meta header\n");
		return -1;
	}

	if (RTA_PAYLOAD(tb[TCA_EM_META_HDR]) < sizeof(*meta_hdr)) {
		fprintf(stderr, "Meta header size mismatch\n");
		return -1;
	}

	meta_hdr = RTA_DATA(tb[TCA_EM_META_HDR]);

	if (print_object(fd, &meta_hdr->left, tb[TCA_EM_META_LVALUE]) < 0)
		return -1;

	switch (meta_hdr->left.op) {
		case TCF_EM_OPND_EQ:
			fprintf(fd, " eq ");
			break;
		case TCF_EM_OPND_LT:
			fprintf(fd, " lt ");
			break;
		case TCF_EM_OPND_GT:
			fprintf(fd, " gt ");
			break;
	}

	return print_object(fd, &meta_hdr->right, tb[TCA_EM_META_RVALUE]);
}
Exemple #3
0
int main(int argc, char **argv) {

  while(1) {
    object_t exp = read_stream(stdin);
    printf("--\n");
    print_object(exp);
    if(iscons(exp) && isproperlist(exp))
      printf(" proper list");
    else
      printf(" symbol or improper list");
    printf("\n");
  }

}
Exemple #4
0
void print_object(object *obj)
{
    int first = 1;
    if (!obj)
        return;
    switch (TYPE(obj)) {
        case OBJ_SYMBOL:
            printf("%s", STR(obj));
            break;
        case OBJ_NUMBER:
            printf("%d", NUM(obj));
            break;
        case OBJ_BOOLEAN:
            printf("%s", (NUM(obj) ? "#t" : "#f"));
            break;
        case OBJ_PAIR:
            printf("(");
            while (TYPE(obj) == OBJ_PAIR &&
                   obj != null_object) {
                if (!first)
                    putchar(' ');
                print_object(CAR(obj));
                obj = CDR(obj);
                first = 0;
            }
            if (obj != null_object) {
                printf(" . ");
                print_object(obj);
            }
            printf(")");
            break;
        case OBJ_PRIMITIVE_PROCEDURE:
        case OBJ_COMPOUND_PROCEDURE:
            printf("#<procedure>");
            break;
    }
}
Exemple #5
0
void print_schema(reflection_Schema_table_t S)
{
    reflection_Object_vec_t Objs;
    reflection_Enum_vec_t Enums;
    size_t i;

    Objs = reflection_Schema_objects(S);
    printf("{");
    printf("\"objects\":[");
    for (i = 0; i < reflection_Object_vec_len(Objs); ++i) {
        if (i > 0) {
            printf(",");
        }
        print_object(reflection_Object_vec_at(Objs, i));
    }
    printf("]");
    Enums = reflection_Schema_enums(S);
    printf(",\"enums\":[");
    for (i = 0; i < reflection_Enum_vec_len(Enums); ++i) {
        if (i > 0) {
            printf(",");
        }
        print_enum(reflection_Enum_vec_at(Enums, i));
    }
    printf("]");
    if (reflection_Schema_file_ident_is_present(S)) {
        printf(",\"file_ident\":\"%s\"", reflection_Schema_file_ident(S));
    }
    if (reflection_Schema_file_ext_is_present(S)) {
        printf(",\"file_ext\":\"%s\"", reflection_Schema_file_ext(S));
    }
    if (reflection_Schema_root_table_is_present(S)) {
        printf(",\"root_table\":");
        print_object(reflection_Schema_root_table(S));
    }
    printf("}\n");
}
Exemple #6
0
void new_index(char *hash) {
    char *indexpath = get_repo_troll_dir();
    indexpath = (char *) realloc(indexpath, strlen(indexpath) + 5);
    strcat(indexpath, "index");
    printf("New index at %s\n",indexpath);

    int index = open(indexpath, O_WRONLY | O_TRUNC, 0644);
    free(indexpath);
    lseek(index, 0, SEEK_SET);
    int sout = dup(STDOUT_FILENO);
    dup2(index,STDOUT_FILENO);

    print_object(hash);
    dup2(sout,STDOUT_FILENO);
}
Exemple #7
0
int main(int argc, char **argv) {
  while(1) {
    printf("> ");
    struct node *lines = read_sexp(stdin);
    object_t sexp = parse_sexp(lines);
    
    if(*(char*)lines->data == 'q') {
      auxfor_each(lines, &free_node_and_string);
      return 0;
    }
    print_object(sexp);
    printf("\n");

    auxfor_each(lines, &free_node_and_string);
  }
}
Exemple #8
0
// Render a value to text.
char *print_value(JSON *item,int depth,int fmt)
{
	char *out=0;
	if (!item) return 0;
	switch ((item->type)&255)
	{
	case JSON_NULL:	out = tr50_json_strdup("null");	break;
	case JSON_FALSE:	out = tr50_json_strdup("false"); break;
	case JSON_TRUE:	out = tr50_json_strdup("true"); break;
	case JSON_NUMBER:	out=print_number(item);break;
	case JSON_STRING:	out=print_string(item);break;
	case JSON_ARRAY:	out=print_array(item,depth,fmt);break;
	case JSON_OBJECT:	out=print_object(item,depth,fmt);break;
	}
	return out;
}
Exemple #9
0
/* Render a value to text. */
static char *print_value(cJSON *item,int depth,int fmt)
{
	char *out=0;
	if (!item) return 0;
	switch ((item->type)&255)
	{
		case cJSON_NULL:	out=cJSON_strdup("null");	break;
		case cJSON_False:	out=cJSON_strdup("false");break;
		case cJSON_True:	out=cJSON_strdup("true"); break;
		case cJSON_Number:	out=print_number(item);break;
		case cJSON_String:	out=print_string(item);break;
		case cJSON_Array:	out=print_array(item,depth,fmt);break;
		case cJSON_Object:	out=print_object(item,depth,fmt);break;
	}
	return out;
}
void print_object(FILE *fp, UnionType o)
{
	if (!fp) fp = stdout;
	//fprintf(stderr, "type = [%d]\n", TYPE(o));
	switch (TYPE(o.o)) {
	case Int:
		fprintf(fp, "%d", (int)to_Int(o.o));
		break;
	case Double:
		fprintf(fp, "%f", o.d);
		break;
	case String:
		fprintf(fp, "%s", (to_String(o.o))->s);
		break;
	case Array:
		if (fp != stdout) {
			_print_with_handler(fp, to_Array(o.o));
		} else {
			print(to_Array(o.o));
		}
		break;
	case ArrayRef:
		fprintf(fp, "ARRAY(%p)", to_Ptr(o.o));
		break;
	case Hash:
		print_hash(fp, to_Hash(o.o));
		break;
	case HashRef:
		fprintf(fp, "HASH(%p)", to_Ptr(o.o));
		break;
	case CodeRef:
		fprintf(fp, "CODE(%p)", to_Ptr(o.o));
		break;
	case ObjectType: {
		Object *object = to_Object(o.o);
		print_object(fp, object->v);
		break;
	}
	case BlessedObjectType:
		fprintf(fp, "%s=HASH(%p)", (to_BlessedObject(o.o))->pkg_name, to_Ptr(o.o));
		break;
	default:
		break;
	}
}
Exemple #11
0
/* Render a value to text. */
static char *print_value(cJSON *item,int depth,int fmt, ngx_pool_t *pool)
{
	char *out=0;
	if (!item) return 0;
	switch ((item->type)&255)
	{
        case cJSON_NULL:	out=cJSON_strdup("null", pool);	break;
        case cJSON_False:	out=cJSON_strdup("false", pool);break;
        case cJSON_True:	out=cJSON_strdup("true", pool); break;
        case cJSON_Number:	out=print_number(item, pool);break;
        case cJSON_VerFloat:    out=print_verfloat(item, pool);break;
        case cJSON_String:	out=print_string(item, pool);break;
        case cJSON_Array:	out=print_array(item,depth,fmt, pool);break;
        case cJSON_Object:	out=print_object(item,depth,fmt, pool);break;
        case cJSON_2dFloatArray: out=print_2dfloat_array(item, fmt, pool);break;
	}
	return out;
}
Exemple #12
0
void hoard::print_object(size_t n) {
	char buffer[32];

	size_t divisor = 1;

	while (divisor <= (n / 10))
		divisor *= 10;

	char *p = buffer;
	do {
		*p++ = (char) (((n / divisor) % 10) + '0');
		divisor /= 10;
	}
	while (divisor != 0);

	*p = '\0';

	print_object(buffer);
}
Exemple #13
0
/// Internal: Render a value to text.
static char *print_value(JSON *item, int depth, bool fmt)
{
    char *out = 0;
    if(!item) return 0;
    if(item->original) { //imported item
        item = item->original;
    }
    switch (item->type)
    {
        case JSON_NULL:     out = newstring("null");    break;
        case JSON_FALSE:    out = newstring("false");   break;
        case JSON_TRUE:     out = newstring("true");    break;
        case JSON_NUMBER:   out = print_number(item);   break;
        case JSON_STRING:   out = print_string(item);   break;
        case JSON_ARRAY:    out = print_array( item, depth, fmt);break;
        case JSON_OBJECT:   out = print_object(item, depth, fmt);break;
    }
    return out;
}
Exemple #14
0
static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
		     const char *pathname, unsigned mode, int stage,
		     void *cbdata)
{
	if (baselen == match_baselen) {
		if (S_ISREG(mode))
			print_object(sha1, pathname);
		else if (S_ISDIR(mode)) {
			print_dir(sha1, pathname, base);
			return READ_TREE_RECURSIVE;
		}
	}
	else if (baselen > match_baselen)
		print_dir_entry(sha1, pathname, mode);
	else if (S_ISDIR(mode))
		return READ_TREE_RECURSIVE;

	return 0;
}
Exemple #15
0
Fichier : print.c Projet : ebb/pufn
void print_object(object_t root) {
    switch (root.tag) {
        case OBJECT_FIXNUM_TAG:
            printf("%d", fixnum_unbox(root));
            break;
        case OBJECT_WORD_TAG:
            printf("%s", string_unbox(word_name(root)));
            break;
        case OBJECT_LIST_TAG:
            printf("[ ");
            while (!object_eq(root, list_nil)) {
                print_object(list_head(root));
                printf(" ");
                root = list_tail(root);
            }
            printf("]");
            break;
        case OBJECT_STRING_TAG:
            printf("\"%s\"", string_unbox(root));
            break;
        case OBJECT_PRIMITIVE_TAG:
            printf("0x%p", (void *)primitive_unbox(root));
            break;
        case OBJECT_BOOLEAN_TAG:
            if (object_eq(root, boolean_t))
                printf("t");
            else
                printf("f");
            break;
        case OBJECT_WRAPPER_TAG:
            printf("\\ %s", string_unbox(word_name(wrapper_unbox(root))));
            break;
        case OBJECT_CONTINUATION_TAG:
            printf("0x%p", continuation_unbox(root));
            break;
        case OBJECT_BLOCK_TAG:
            printf("0x%p", block_unbox(root));
            break;
        default:
            fail();
    }
}
Exemple #16
0
word_t heap_what_points_to_in(struct object_heap* oh, struct Object* x, byte_t* memory, word_t memorySize, bool_t print) {
  struct Object* obj = (struct Object*) memory;
  word_t count = 0;
  while (object_in_memory(oh, obj, memory, memorySize)) {
    word_t offset, limit;
    offset = object_first_slot_offset(obj);
    limit = object_last_oop_offset(obj) + sizeof(word_t);
    for (; offset != limit; offset += sizeof(word_t)) {
      struct Object* val = object_slot_value_at_offset(obj, offset);
      if (val == x) {
        if (!object_is_free(obj)) count++;
        if (print && !object_is_free(obj)) {
          fprintf(stderr, "pointed to by "); print_object(obj);
        }
        break;
      }
    }
    obj = object_after(oh, obj);
  }
  return count;
}
Exemple #17
0
/* Render a value to text. */
static char *print_value(struct json *item, int depth, int fmt)
{
	char *out = NULL;
	if (!item)
		return 0;

	if (fmt == item->print_fmt && item->print_out)
		return item->print_out;

	switch ((item->type) & 255) {
	case JSON_T_NULL:
		out = json_strdup("null");
		break;
	case JSON_T_FALSE:
		out = json_strdup("false");
		break;
	case JSON_T_TRUE:
		out = json_strdup("true");
		break;
	case JSON_T_NUMBER:
		out = print_number(item);
		break;
	case JSON_T_STRING:
		out = print_string(item);
		break;
	case JSON_T_ARRAY:
		out = print_array(item, depth, fmt);
		break;
	case JSON_T_OBJECT:
		out = print_object(item, depth, fmt);
		break;
	}

	if (item->print_out)
		json_free(item->print_out);

	item->print_out = out;
	item->print_fmt = fmt;
	return out;
}
Exemple #18
0
void copy_out() {
    char *indexpath = get_repo_troll_dir();
    indexpath = (char *) realloc(indexpath, strlen(indexpath) + 5);
    strcat(indexpath, "index");

    FILE *findex = fopen(indexpath, "r");
    free(indexpath);
    fseek(findex, 0, SEEK_SET);
    
    char hash[41];
    
    int newfile;
    char *trollpath = get_repo_troll_dir();
    char *repo_path = (char *) malloc(strlen(trollpath) - 7);
    strncat(repo_path,trollpath,strlen(trollpath) - 7);

    free(trollpath);
    char *newpath;
    char name[256];
    int sout;
    char *lastchar;
    sout = dup(STDOUT_FILENO);
    while(fgets(hash, 41, findex)) {
      fseek(findex,1,SEEK_CUR);
      fgets(name, 256, findex);

      newpath = (char *) malloc(strlen(repo_path) + strlen(name));
      strcat(newpath, repo_path);
      strcat(newpath, name);
      lastchar = strstr(newpath,"\n");
      *lastchar = '\0';

      newfile = open(newpath, O_WRONLY | O_TRUNC, 0644);
      printf("%s\n",newpath);
      dup2(newfile,STDOUT_FILENO);
      print_object(hash);
      dup2(sout,STDOUT_FILENO);
      close(newfile);
    }
}
Exemple #19
0
void hoard::print_object(void *px) {
	static char const *hexdigits = "0123456789abcdef";

	static char buffer[32];

	size_t n = (size_t) px;

	char *p = buffer;
	*p++ = '0';
	*p++ = 'x';
	int shift = sizeof(void *) * 8;

	do {
		shift -= 4;
		*p++ = hexdigits[(n >> shift) & 15];

	}
	while (shift != 0);

	*p = '\0';
	print_object(buffer);
}
Exemple #20
0
int		see_lists(t_all *all)
{
  t_object	*objects;
  t_spot	*spots;

  objects = all->objects;
  spots = all->spots;
  if (print_global(all) < 0 || printf("\nObjects:\n\n") < 0 ||
      print_object(objects) < 0 || printf("\nSpots:\n\n") < 0)
    return (-1);
  while (spots != NULL)
    {
      if (printf("Spots pos : x = %f, y = %f, z = %f\n",
		 spots->pos.x, spots->pos.y, spots->pos.z) < 0 ||
	  printf("Spots color : r = %f, g = %f, b = %f\n",
		 spots->color.r, spots->color.g, spots->color.b) < 0 ||
	  printf("Orientation = %f\nIntensity = %f\nRadius = %f\n\n",
		 spots->orientation, spots->intensity, spots->radius) < 0)
	return (-1);
      spots = spots->next;
    }
  return ((printf("\n") < 0) ? -1 : 0);
}
Exemple #21
0
static int walk_tree(const unsigned char *sha1, struct strbuf *base,
		const char *pathname, unsigned mode, int stage, void *cbdata)
{
	struct walk_tree_context *walk_tree_ctx = cbdata;

	if (base->len == walk_tree_ctx->match_baselen) {
		if (S_ISREG(mode)) {
			if (print_object(sha1, pathname))
				walk_tree_ctx->match = 1;
		} else if (S_ISDIR(mode)) {
			print_dir(sha1, base->buf, base->len, pathname);
			walk_tree_ctx->match = 2;
			return READ_TREE_RECURSIVE;
		}
	} else if (base->len > walk_tree_ctx->match_baselen) {
		print_dir_entry(sha1, base->buf, base->len, pathname, mode);
		walk_tree_ctx->match = 2;
	} else if (S_ISDIR(mode)) {
		return READ_TREE_RECURSIVE;
	}

	return 0;
}
Exemple #22
0
void evaluate_stack()
{
//    std::cout << "EVALUATE_STACK: " << optic_stack.size() << std::endl;
//    print_stack();

    global_state.type = VOID;
    while(optic_stack.size())
    {
        evaluate_top();

        if(optic_stack.size())
        {
            global_state = optic_stack.back();
            optic_stack.pop_back();
        }
    }

    if(global_state.type != VOID)
    {
        out() << "optic: ";
        print_object(global_state);
        mem_free(global_state);
    }
}
Exemple #23
0
void print_vector (STREAM stream, D instance, BOOL escape_p, int print_depth) {
  int size = vector_size(instance);
  int first = TRUE, i = 0;
  D element;
  int max_size = MIN(size, dylan_print_length);

  put_string("#[", stream);
  if (print_depth < dylan_print_depth) {
    for (; i < max_size; i++) {
      if (first)
        first = FALSE;
      else
        put_string(", ", stream);
      element = vector_ref(instance, i);
      print_object(stream, element, escape_p, print_depth + 1);
    }
  }
  if (size > max_size || print_depth >= dylan_print_depth) {
    if (i > 0)
      put_string(", ", stream);
    format(stream, "... 0x%lx", instance);
  }
  put_string("]", stream);
}
Exemple #24
0
static void test_handles(void)
{
    HWINSTA w1, w2, w3;
    HDESK d1, d2, d3;
    HANDLE hthread;
    DWORD id, flags, le;
    ATOM atom;
    char buffer[20];

    /* win stations */

    w1 = GetProcessWindowStation();
    ok( GetProcessWindowStation() == w1, "GetProcessWindowStation returned different handles\n" );
    ok( !CloseWindowStation(w1), "closing process win station succeeded\n" );
    SetLastError( 0xdeadbeef );
    ok( !CloseHandle(w1), "closing process win station handle succeeded\n" );
    ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %d\n", GetLastError() );
    print_object( w1 );

    flags = 0;
    ok( GetHandleInformation( w1, &flags ), "GetHandleInformation failed\n" );
    ok( !(flags & HANDLE_FLAG_PROTECT_FROM_CLOSE) ||
        broken(flags & HANDLE_FLAG_PROTECT_FROM_CLOSE), /* set on nt4 */
        "handle %p PROTECT_FROM_CLOSE set\n", w1 );

    ok( DuplicateHandle( GetCurrentProcess(), w1, GetCurrentProcess(), (PHANDLE)&w2, 0,
                         TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
    ok( CloseWindowStation(w2), "closing dup win station failed\n" );

    ok( DuplicateHandle( GetCurrentProcess(), w1, GetCurrentProcess(), (PHANDLE)&w2, 0,
                         TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
    ok( CloseHandle(w2), "closing dup win station handle failed\n" );

    w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL );
    le = GetLastError();
    ok( w2 != 0 || le == ERROR_ACCESS_DENIED, "CreateWindowStation failed (%u)\n", le );
    if (w2 != 0)
    {
        ok( w2 != w1, "CreateWindowStation returned default handle\n" );
        SetLastError( 0xdeadbeef );
        ok( !CloseDesktop( (HDESK)w2 ), "CloseDesktop succeeded on win station\n" );
        ok( GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == 0xdeadbeef), /* wow64 */
            "bad last error %d\n", GetLastError() );
        ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" );

        w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL );
        ok( CloseHandle( w2 ), "CloseHandle failed\n" );
    }
    else if (le == ERROR_ACCESS_DENIED)
        win_skip( "Not enough privileges for CreateWindowStation\n" );

    w2 = OpenWindowStation("winsta0", TRUE, WINSTA_ALL_ACCESS );
    ok( w2 != 0, "OpenWindowStation failed\n" );
    ok( w2 != w1, "OpenWindowStation returned default handle\n" );
    ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" );

    w2 = OpenWindowStation("dummy name", TRUE, WINSTA_ALL_ACCESS );
    ok( !w2, "open dummy win station succeeded\n" );

    CreateMutexA( NULL, 0, "foobar" );
    w2 = CreateWindowStation("foobar", 0, WINSTA_ALL_ACCESS, NULL );
    le = GetLastError();
    ok( w2 != 0 || le == ERROR_ACCESS_DENIED, "create foobar station failed (%u)\n", le );

    if (w2 != 0)
    {
        w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS );
        ok( w3 != 0, "open foobar station failed\n" );
        ok( w3 != w2, "open foobar station returned same handle\n" );
        ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" );
        ok( CloseWindowStation( w3 ), "CloseWindowStation failed\n" );

        w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS );
        ok( !w3, "open foobar station succeeded\n" );

        w2 = CreateWindowStation("foobar1", 0, WINSTA_ALL_ACCESS, NULL );
        ok( w2 != 0, "create foobar station failed\n" );
        w3 = CreateWindowStation("foobar2", 0, WINSTA_ALL_ACCESS, NULL );
        ok( w3 != 0, "create foobar station failed\n" );
        ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" );
        ok( GetHandleInformation( w3, &flags ), "GetHandleInformation failed\n" );

        SetProcessWindowStation( w2 );
        atom = GlobalAddAtomA("foo");
        ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" );
        ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer );

        ok( !CloseWindowStation( w2 ), "CloseWindowStation succeeded\n" );
        ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" );

        SetProcessWindowStation( w3 );
        ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" );
        ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" );
        ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" );
        ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer );
    }
    else if (le == ERROR_ACCESS_DENIED)
        win_skip( "Not enough privileges for CreateWindowStation\n" );

    /* desktops */
    d1 = GetThreadDesktop(GetCurrentThreadId());
    initial_desktop = d1;
    ok( GetThreadDesktop(GetCurrentThreadId()) == d1,
        "GetThreadDesktop returned different handles\n" );

    flags = 0;
    ok( GetHandleInformation( d1, &flags ), "GetHandleInformation failed\n" );
    ok( !(flags & HANDLE_FLAG_PROTECT_FROM_CLOSE), "handle %p PROTECT_FROM_CLOSE set\n", d1 );

    SetLastError( 0xdeadbeef );
    ok( !CloseDesktop(d1), "closing thread desktop succeeded\n" );
    ok( GetLastError() == ERROR_BUSY || broken(GetLastError() == 0xdeadbeef), /* wow64 */
        "bad last error %d\n", GetLastError() );

    SetLastError( 0xdeadbeef );
    if (CloseHandle( d1 ))  /* succeeds on nt4 */
    {
        win_skip( "NT4 desktop handle management is completely different\n" );
        return;
    }
    ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %d\n", GetLastError() );

    ok( DuplicateHandle( GetCurrentProcess(), d1, GetCurrentProcess(), (PHANDLE)&d2, 0,
                         TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
    ok( CloseDesktop(d2), "closing dup desktop failed\n" );

    ok( DuplicateHandle( GetCurrentProcess(), d1, GetCurrentProcess(), (PHANDLE)&d2, 0,
                         TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" );
    ok( CloseHandle(d2), "closing dup desktop handle failed\n" );

    d2 = OpenDesktop( "dummy name", 0, TRUE, DESKTOP_ALL_ACCESS );
    ok( !d2, "open dummy desktop succeeded\n" );

    d2 = CreateDesktop( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
    ok( d2 != 0, "create foobar desktop failed\n" );
    SetLastError( 0xdeadbeef );
    ok( !CloseWindowStation( (HWINSTA)d2 ), "CloseWindowStation succeeded on desktop\n" );
    ok( GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == 0xdeadbeef), /* wow64 */
        "bad last error %d\n", GetLastError() );

    SetLastError( 0xdeadbeef );
    d3 = CreateDesktop( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
    ok( d3 != 0, "create foobar desktop again failed\n" );
    ok( GetLastError() == 0xdeadbeef, "bad last error %d\n", GetLastError() );
    ok( CloseDesktop( d3 ), "CloseDesktop failed\n" );

    d3 = OpenDesktop( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS );
    ok( d3 != 0, "open foobar desktop failed\n" );
    ok( d3 != d2, "open foobar desktop returned same handle\n" );
    ok( CloseDesktop( d2 ), "CloseDesktop failed\n" );
    ok( CloseDesktop( d3 ), "CloseDesktop failed\n" );

    d3 = OpenDesktop( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS );
    ok( !d3, "open foobar desktop succeeded\n" );

    ok( !CloseHandle(d1), "closing thread desktop handle succeeded\n" );
    d2 = GetThreadDesktop(GetCurrentThreadId());
    ok( d1 == d2, "got different handles after close\n" );

    register_class();
    trace( "thread 1 desktop: %p\n", d1 );
    print_object( d1 );
    hthread = CreateThread( NULL, 0, thread, (LPVOID)2, 0, &id );
    Sleep(1000);
    trace( "get other thread desktop: %p\n", GetThreadDesktop(id) );
    WaitForSingleObject( hthread, INFINITE );
    CloseHandle( hthread );
}
void print_SignallingIndication(enum SignallingIndication* signallingIndication, Print print) {
	print_object(signallingIndication, &SIGNALLINGINDICATION_TYPE, print);
}
void print_InformationRequestType(struct InformationRequestType* informationRequestType, Print print) {
	print_object(informationRequestType, &INFORMATIONREQUESTTYPE_TYPE, print);
}
Exemple #27
0
void z_show_status (void)
{
    zword global0;
    zword global1;
    zword global2;
    zword addr;

    bool brief = FALSE;

    /* One V5 game (Wishbringer Solid Gold) contains this opcode by
       accident, so just return if the version number does not fit */

    if (h_version >= V4)
        return;

    /* Read all relevant global variables from the memory of the
       Z-machine into local variables */

    addr = h_globals;
    LOW_WORD (addr, global0)
    addr += 2;
    LOW_WORD (addr, global1)
    addr += 2;
    LOW_WORD (addr, global2)

    /* Frotz uses window 7 for the status line. Don't forget to select
       reverse and fixed width text style */

    set_window (7);

    print_char (ZC_NEW_STYLE);
    print_char (REVERSE_STYLE | FIXED_WIDTH_STYLE);

    /* If the screen width is below 55 characters then we have to use
       the brief status line format */

    if (h_screen_cols < 55)
        brief = TRUE;

    /* Print the object description for the global variable 0 */

    print_char (' ');
    print_object (global0);

    /* A header flag tells us whether we have to display the current
       time or the score/moves information */

    if (h_config & CONFIG_TIME) {       /* print hours and minutes */

        zword hours = (global1 + 11) % 12 + 1;

        pad_status_line (brief ? 15 : 20);

        print_string ("Time: ");

        if (hours < 10)
            print_char (' ');
        print_num (hours);

        print_char (':');

        if (global2 < 10)
            print_char ('0');
        print_num (global2);

        print_char (' ');

        print_char ((global1 >= 12) ? 'p' : 'a');
        print_char ('m');

    } else {                            /* print score and moves */

        pad_status_line (brief ? 15 : 30);

        print_string (brief ? "S: " : "Score: ");
        print_num (global1);

        pad_status_line (brief ? 8 : 14);

        print_string (brief ? "M: " : "Moves: ");
        print_num (global2);

    }

    /* Pad the end of the status line with spaces */

    pad_status_line (0);

    /* Return to the lower window */

    set_window (0);

}/* z_show_status */
Exemple #28
0
  template <class T> void do_oop_work(T* p) {
    assert(_containing_obj != NULL, "Precondition");
    assert(!_g1h->is_obj_dead_cond(_containing_obj, _use_prev_marking),
           "Precondition");
    T heap_oop = oopDesc::load_heap_oop(p);
    if (!oopDesc::is_null(heap_oop)) {
      oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
      bool failed = false;
      if (!_g1h->is_in_closed_subset(obj) ||
          _g1h->is_obj_dead_cond(obj, _use_prev_marking)) {
        if (!_failures) {
          gclog_or_tty->print_cr("");
          gclog_or_tty->print_cr("----------");
        }
        if (!_g1h->is_in_closed_subset(obj)) {
          HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
          gclog_or_tty->print_cr("Field "PTR_FORMAT
                                 " of live obj "PTR_FORMAT" in region "
                                 "["PTR_FORMAT", "PTR_FORMAT")",
                                 p, (void*) _containing_obj,
                                 from->bottom(), from->end());
          print_object(gclog_or_tty, _containing_obj);
          gclog_or_tty->print_cr("points to obj "PTR_FORMAT" not in the heap",
                                 (void*) obj);
        } else {
          HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
          HeapRegion* to   = _g1h->heap_region_containing((HeapWord*)obj);
          gclog_or_tty->print_cr("Field "PTR_FORMAT
                                 " of live obj "PTR_FORMAT" in region "
                                 "["PTR_FORMAT", "PTR_FORMAT")",
                                 p, (void*) _containing_obj,
                                 from->bottom(), from->end());
          print_object(gclog_or_tty, _containing_obj);
          gclog_or_tty->print_cr("points to dead obj "PTR_FORMAT" in region "
                                 "["PTR_FORMAT", "PTR_FORMAT")",
                                 (void*) obj, to->bottom(), to->end());
          print_object(gclog_or_tty, obj);
        }
        gclog_or_tty->print_cr("----------");
        _failures = true;
        failed = true;
        _n_failures++;
      }

      if (!_g1h->full_collection()) {
        HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
        HeapRegion* to   = _g1h->heap_region_containing(obj);
        if (from != NULL && to != NULL &&
            from != to &&
            !to->isHumongous()) {
          jbyte cv_obj = *_bs->byte_for_const(_containing_obj);
          jbyte cv_field = *_bs->byte_for_const(p);
          const jbyte dirty = CardTableModRefBS::dirty_card_val();

          bool is_bad = !(from->is_young()
                          || to->rem_set()->contains_reference(p)
                          || !G1HRRSFlushLogBuffersOnVerify && // buffers were not flushed
                              (_containing_obj->is_objArray() ?
                                  cv_field == dirty
                               : cv_obj == dirty || cv_field == dirty));
          if (is_bad) {
            if (!_failures) {
              gclog_or_tty->print_cr("");
              gclog_or_tty->print_cr("----------");
            }
            gclog_or_tty->print_cr("Missing rem set entry:");
            gclog_or_tty->print_cr("Field "PTR_FORMAT
                          " of obj "PTR_FORMAT
                          ", in region %d ["PTR_FORMAT
                          ", "PTR_FORMAT"),",
                          p, (void*) _containing_obj,
                          from->hrs_index(),
                          from->bottom(),
                          from->end());
            _containing_obj->print_on(gclog_or_tty);
            gclog_or_tty->print_cr("points to obj "PTR_FORMAT
                          " in region %d ["PTR_FORMAT
                          ", "PTR_FORMAT").",
                          (void*) obj, to->hrs_index(),
                          to->bottom(), to->end());
            obj->print_on(gclog_or_tty);
            gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.",
                          cv_obj, cv_field);
            gclog_or_tty->print_cr("----------");
            _failures = true;
            if (!failed) _n_failures++;
          }
        }
      }
    }
  }
Exemple #29
0
/* Render a value to text. */
static char* print_value(cJSON *item, int depth, int fmt, printbuffer *p)
{
	char *out = 0;

	if(!item)
	{
		printf("[cJSON] Invalid Item!!\n");
		return 0;
	}

	if(p)
	{
		switch((item->type) & 255)
		{
		case cJSON_NULL:
		{
			out = ensure(p, 5);
			if(out)
				strcpy(out, "null");
			break;
		}
		case cJSON_False:
		{
			out = ensure(p, 6);
			if(out)
				strcpy(out, "false");
			break;
		}
		case cJSON_True:
		{
			out = ensure(p, 5);
			if(out)
				strcpy(out, "true");
			break;
		}
		case cJSON_Number:
			out = print_number(item, p);
			break;
		case cJSON_String:
			out = print_string(item, p);
			break;
		case cJSON_Array:
			out = print_array(item, depth, fmt, p);
			break;
		case cJSON_Object:
			out = print_object(item, depth, fmt, p);
			break;
		case cJSON_Object_Serialized:
			out = print_serialized_obj_val_as_is(item, p);
			break;
		default:
			printf("[cJSON] Unknown Item Type!!\n");
			break;
		}
	}
	else
	{
		switch((item->type) & 255)
		{
		case cJSON_NULL:
			out = cJSON_strdup("null");
			break;
		case cJSON_False:
			out = cJSON_strdup("false");
			break;
		case cJSON_True:
			out = cJSON_strdup("true");
			break;
		case cJSON_Number:
			out = print_number(item, 0);
			break;
		case cJSON_String:
			out = print_string(item, 0);
			break;
		case cJSON_Array:
			out = print_array(item, depth, fmt, 0);
			break;
		case cJSON_Object:
			out = print_object(item, depth, fmt, 0);
			break;
		case cJSON_Object_Serialized:
			out = print_serialized_obj_val_as_is(item, 0);
			break;
		default:
			printf("[cJSON] Unknown Item Type!!\n");
			break;
		}
	}

	return out;
}
Exemple #30
0
static void print_object (stix_t* stix, stix_oow_t mask, stix_oop_t oop)
{
	if (oop == stix->_nil)
	{
		stix_logbfmt (stix, mask, "nil");
	}
	else if (oop == stix->_true)
	{
		stix_logbfmt (stix, mask, "true");
	}
	else if (oop == stix->_false)
	{
		stix_logbfmt (stix, mask, "false");
	}
	else if (STIX_OOP_IS_SMOOI(oop))
	{
		stix_logbfmt (stix, mask, "%zd", STIX_OOP_TO_SMOOI(oop));
	}
	else if (STIX_OOP_IS_CHAR(oop))
	{
		stix_logbfmt (stix, mask, "$%.1C", STIX_OOP_TO_CHAR(oop));
	}
	else if (STIX_OOP_IS_RSRC(oop))
	{
		stix_logbfmt (stix, mask, "%zX", stix->rsrc.ptr[STIX_OOP_TO_RSRC(oop)]);
	}
	else
	{
		stix_oop_class_t c;
		stix_oow_t i;

		STIX_ASSERT (STIX_OOP_IS_POINTER(oop));
		c = (stix_oop_class_t)STIX_OBJ_GET_CLASS(oop); /*STIX_CLASSOF(stix, oop);*/

		if ((stix_oop_t)c == stix->_large_negative_integer)
		{
			stix_oow_t i;
			stix_logbfmt (stix, mask, "-16r");
			for (i = STIX_OBJ_GET_SIZE(oop); i > 0;)
			{
				stix_logbfmt (stix, mask, "%0*lX", (int)(STIX_SIZEOF(stix_liw_t) * 2), (unsigned long)((stix_oop_liword_t)oop)->slot[--i]);
			}
		}
		else if ((stix_oop_t)c == stix->_large_positive_integer)
		{
			stix_oow_t i;
			stix_logbfmt (stix, mask, "16r");
			for (i = STIX_OBJ_GET_SIZE(oop); i > 0;)
			{
				stix_logbfmt (stix, mask, "%0*lX", (int)(STIX_SIZEOF(stix_liw_t) * 2), (unsigned long)((stix_oop_liword_t)oop)->slot[--i]);
			}
		}
		else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_CHAR)
		{
			if ((stix_oop_t)c == stix->_symbol) 
			{
				stix_logbfmt (stix, mask, "#%.*S", STIX_OBJ_GET_SIZE(oop), ((stix_oop_char_t)oop)->slot);
			}
			else /*if ((stix_oop_t)c == stix->_string)*/
			{
				stix_ooch_t ch;
				int escape = 0;

				for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
				{
					ch = ((stix_oop_char_t)oop)->slot[i];
					if (ch < ' ') 
					{
						escape = 1;
						break;
					}
				}

				if (escape)
				{
					stix_ooch_t escaped;

					stix_logbfmt (stix, mask, "S'");
					for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
					{
						ch = ((stix_oop_char_t)oop)->slot[i];
						if (ch < ' ') 
						{
							switch (ch)
							{
								case '\0':
									escaped = '0';
									break;
								case '\n':
									escaped = 'n';
									break;
								case '\r':
									escaped = 'r';
									break;
								case '\t':
									escaped = 't';
									break;
								case '\f':
									escaped = 'f';
									break;
								case '\b':
									escaped = 'b';
									break;
								case '\v':
									escaped = 'v';
									break;
								case '\a':
									escaped = 'a';
									break;
								default:
									escaped = ch;
									break;
							}

							if (escaped == ch)
								stix_logbfmt (stix, mask, "\\x%X", ch);
							else
								stix_logbfmt (stix, mask, "\\%C", escaped);
						}
						else
						{
							stix_logbfmt (stix, mask, "%C", ch);
						}
					}
					
					stix_logbfmt (stix, mask, "'");
				}
				else
				{
					stix_logbfmt (stix, mask, "'%.*S'", STIX_OBJ_GET_SIZE(oop), ((stix_oop_char_t)oop)->slot);
				}
			}
		}
		else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_BYTE)
		{
			stix_logbfmt (stix, mask, "#[");
			for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
			{
				stix_logbfmt (stix, mask, " %d", ((stix_oop_byte_t)oop)->slot[i]);
			}
			stix_logbfmt (stix, mask, "]");
		}
		
		else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_HALFWORD)
		{
			stix_logbfmt (stix, mask, "#[["); /* TODO: fix this symbol/notation */
			for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
			{
				stix_logbfmt (stix, mask, " %zX", (stix_oow_t)((stix_oop_halfword_t)oop)->slot[i]);
			}
			stix_logbfmt (stix, mask, "]]");
		}
		else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_WORD)
		{
			stix_logbfmt (stix, mask, "#[[["); /* TODO: fix this symbol/notation */
			for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
			{
				stix_logbfmt (stix, mask, " %zX", ((stix_oop_word_t)oop)->slot[i]);
			}
			stix_logbfmt (stix, mask, "]]]");
		}
		else if ((stix_oop_t)c == stix->_array)
		{
			stix_logbfmt (stix, mask, "#(");
			for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
			{
				stix_logbfmt (stix, mask, " ");
				print_object (stix, mask, ((stix_oop_oop_t)oop)->slot[i]);
			}
			stix_logbfmt (stix, mask, ")");
		}
		else if ((stix_oop_t)c == stix->_class)
		{
			/* print the class name */
			stix_logbfmt (stix, mask, "%.*S", STIX_OBJ_GET_SIZE(((stix_oop_class_t)oop)->name), ((stix_oop_class_t)oop)->name->slot);
		}
		else if ((stix_oop_t)c == stix->_association)
		{
			stix_logbfmt (stix, mask, "%O -> %O", ((stix_oop_association_t)oop)->key, ((stix_oop_association_t)oop)->value);
		}
		else
		{
			stix_logbfmt (stix, mask, "instance of %.*S(%p)", STIX_OBJ_GET_SIZE(c->name), ((stix_oop_char_t)c->name)->slot, oop);
		}
	}
}