示例#1
0
static void
switch_on_type(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
	boolean_t allocated = B_FALSE;

	if (format == NULL) {
		allocated = B_TRUE;
		format = uc(mlp->name);
	}

	switch (tdp->type) {
	case INTRINSIC:
		print_intrinsic(mlp, tdp, format, level);
		break;
	case POINTER:
		print_pointer(mlp, tdp, format, level);
		break;
	case ARRAY:
		print_array(mlp, tdp, format, level);
		break;
	case FUNCTION:
		print_function(mlp, tdp, format, level);
		break;
	case UNION:
		print_union(mlp, tdp, format, level);
		break;
	case ENUM:
		print_enum(mlp, tdp, format, level);
		break;
	case FORWARD:
		print_forward(mlp, tdp, format, level);
		break;
	case TYPEOF:
		print_typeof(mlp, tdp, format, level);
		break;
	case STRUCT:
		print_struct(mlp, tdp, format, level);
		break;
	case VOLATILE:
		print_volatile(mlp, tdp, format, level);
		break;
	default:
		fprintf(stderr, "Switch to Unknown type\n");
		error = B_TRUE;
		break;
	}
	if (allocated)
		free(format);
}
示例#2
0
文件: gencfile.C 项目: bougyman/sfs
static void
dumpprint (const rpc_sym *s)
{
  switch (s->type) {
  case rpc_sym::STRUCT:
    print_struct (s->sstruct.addr ());
    break;
  case rpc_sym::UNION:
    print_union (s->sunion.addr ());
    break;
  case rpc_sym::ENUM:
    print_enum (s->senum.addr ());
    break;
  case rpc_sym::TYPEDEF:
    print_print (s->stypedef->id);
  default:
    break;
  }
}
示例#3
0
文件: sets.c 项目: KevOrr/Classes
int main(void) {
    char a[LENGTH] = {0};
    char b[LENGTH] = {0};

    printf("Please enter the number of elements in set A: ");
    int num_a;
    scanf("%d", &num_a);
    fill_array(a, num_a, "A");
    
    printf("Please enter the number of elements in set B: ");
    int num_b;
    scanf("%d", &num_b);
    fill_array(b, num_b, "B");

    print_union(a, b, LENGTH);
    print_intersection(a, b, LENGTH);

    return 0;
}
示例#4
0
int main(int argc, char *argv[]) {
	{

	SH_DO(Shore::init(argc, argv));

#ifndef notdef
	    // for the purpose of testing automagically, we can't
	    // have any arguments
	    if (argc != 3) {
		    hack = true;
		    argv[1] = "3";
		    argv[2] = "three";
	    }
#else
	    hack = false;
	    if (argc != 3) {
		    cerr << "usage: " << progname << " test int_val string_val" << endl;
		    return 1;
	    }
#endif

	SH_BEGIN_TRANSACTION(rc);

	if(rc) {
		    // could be because the tx was aborted
		    exit(1);
	    }

	    Ref<I> ip, sp;

	    rc = Ref<I>::lookup("an_int", ip);

	    if (rc != RCOK) {
		    if(!hack) {
			    cout << "First time" << endl;
		    } else {
			    cout << "previous int: ";
			    cout << "integer " << 3 << endl;
			    cout << "previous string: ";
			    cout << "string " << "three" << endl;
		    }

		    SH_DO( Ref<I>::new_persistent ("an_int", 0644, ip) ) ;
		    if (!ip) {
			    cerr << "Cannot create registered object `an_int'" << endl;
			    SH_DO(SH_COMMIT_TRANSACTION);
		    }
		    SH_DO( Ref<I>::new_persistent ("a_string", 0644, sp) ) ;
		    if (!sp) {
			    cerr << "Cannot create registered object `a_string'" << endl;
			    SH_ABORT_TRANSACTION(rc);
		    }
	    }
	    else {
		    SH_DO(Ref<I>::lookup("a_string", sp));

		    cout << "previous int: ";
		    print_union(ip);
		    cout << "previous string: ";
		    print_union(sp);
		    if (strcmp(argv[2],"remove") == 0) {
			    SH_DO(Shore::unlink("an_int"));
			    SH_DO(Shore::unlink("a_string"));
			    SH_DO(SH_COMMIT_TRANSACTION);
			    goto done;
		    }
	    }

	    ip.update()->tv.set_tag(REP_INT);
	    ip.update()->tv.set_int_val() = atoi(argv[1]);

	    sp.update()->tv.set_tag(REP_STRING);
	    sp.update()->tv.set_string_val() = argv[2];
		    

	    SH_DO(SH_COMMIT_TRANSACTION);
	}
done:
    return 0;
}