예제 #1
0
static void generate_interface_xml(GString *gstr, struct interface_data *iface)
{
	const GDBusMethodTable *method;
	const GDBusSignalTable *signal;

	for (method = iface->methods; method && method->name; method++) {
		if (!strlen(method->signature) && !strlen(method->reply))
			g_string_append_printf(gstr, "\t\t<method name=\"%s\"/>\n",
								method->name);
		else {
			g_string_append_printf(gstr, "\t\t<method name=\"%s\">\n",
								method->name);
			print_arguments(gstr, method->signature, "in");
			print_arguments(gstr, method->reply, "out");
			g_string_append_printf(gstr, "\t\t</method>\n");
		}
	}

	for (signal = iface->signals; signal && signal->name; signal++) {
		if (!strlen(signal->signature))
			g_string_append_printf(gstr, "\t\t<signal name=\"%s\"/>\n",
								signal->name);
		else {
			g_string_append_printf(gstr, "\t\t<signal name=\"%s\">\n",
								signal->name);
			print_arguments(gstr, signal->signature, NULL);
			g_string_append_printf(gstr, "\t\t</signal>\n");
		}
	}
}
예제 #2
0
파일: object.c 프로젝트: blammit/bluez
static void generate_interface_xml(GString *gstr, struct interface_data *iface)
{
	const GDBusMethodTable *method;
	const GDBusSignalTable *signal;

	for (method = iface->methods; method && method->name; method++) {
		gboolean deprecated = method->flags &
						G_DBUS_METHOD_FLAG_DEPRECATED;
		gboolean noreply = method->flags &
						G_DBUS_METHOD_FLAG_NOREPLY;

		if (!deprecated && !noreply &&
				!(method->in_args && method->in_args->name) &&
				!(method->out_args && method->out_args->name))
			g_string_append_printf(gstr, "\t\t<method name=\"%s\"/>\n",
								method->name);
		else {
			g_string_append_printf(gstr, "\t\t<method name=\"%s\">\n",
								method->name);
			print_arguments(gstr, method->in_args, "in");
			print_arguments(gstr, method->out_args, "out");

			if (deprecated)
				g_string_append_printf(gstr, "\t\t\t<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n");

			if (noreply)
				g_string_append_printf(gstr, "\t\t\t<annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n");

			g_string_append_printf(gstr, "\t\t</method>\n");
		}
	}

	for (signal = iface->signals; signal && signal->name; signal++) {
		gboolean deprecated = signal->flags &
						G_DBUS_SIGNAL_FLAG_DEPRECATED;

		if (!deprecated && !(signal->args && signal->args->name))
			g_string_append_printf(gstr, "\t\t<signal name=\"%s\"/>\n",
								signal->name);
		else {
			g_string_append_printf(gstr, "\t\t<signal name=\"%s\">\n",
								signal->name);
			print_arguments(gstr, signal->args, NULL);

			if (deprecated)
				g_string_append_printf(gstr, "\t\t\t<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n");

			g_string_append_printf(gstr, "\t\t</signal>\n");
		}
	}
}
예제 #3
0
int main(int argc, char *argv[]){
    
    print_arguments(argc, argv);

    return 0;

}
예제 #4
0
int main(int argc , char *argv[])
{
	print_arguments(argc, argv);
	find_negative(argc, argv);
	//printf("Argc is %d.\n",argc);
	return 0;
}
예제 #5
0
파일: hworld.c 프로젝트: papaloizouc/misc
int main(int argc, char *argv[]) {

	print_arguments(argc, argv);

    int a = 1;
    int b = 2;
    char _string[] = "string";
    int areas[] = {10, 12, 13, 14, 20};
    int numbers[4] = {0, 1};

    printf("a: %d, b: %d \n", a, b);
    printf("%s \n", _string);
 	printf("The number of ints in areas: %ld\n",
           sizeof(areas) / sizeof(int));
 	printf("numbers: %d %d %d %d\n",
            numbers[0], numbers[1],
            numbers[2], numbers[3]);

 	int i = 0;
    for(i = 1; i < argc; i++) {
        printf("arg %d: %s\n", i, argv[i]);
    }

    return 0;
}
예제 #6
0
/* Prints the instruction by calling print_arguments after proper matching: */
int
print_insn_crx(bfd_vma memaddr, struct disassemble_info *info)
{
  int is_decoded;     /* Nonzero means instruction has a match.  */

  /* Initialize global variables: */
  cst4flag = 0;
  size_changed = 0;

  /* Retrieve the encoding from current memory location: */
  get_words_at_PC(memaddr, info);
  /* Find a matching opcode in table: */
  is_decoded = match_opcode();
  /* If found, print the instruction's mnemonic and arguments: */
  if ((is_decoded > 0) && (((words[0] << 16) != 0) || (words[1] != 0)))
    {
      info->fprintf_func(info->stream, "%s", instruction->mnemonic);
      if ((currInsn.nargs = get_number_of_operands()) != 0)
	info->fprintf_func(info->stream, "\t");
      make_instruction();
      print_arguments(&currInsn, memaddr, info);
      return currInsn.size;
    }

  /* No match found: */
  info->fprintf_func(info->stream, "%s ", ILLEGAL);
  return 2;
}
예제 #7
0
/* mon_backtrace prints the current stack backtrace. */
int mon_backtrace(int argc, char **argv)
{
	int *fp = NULL;
	int pc = 0;

	(void) argc;
	(void) argv;
	
	fp = read_fp();
	pc = fp[0];

	while (fp != NULL) {
		int lr = fp[-1];
		struct DebugInfo info = get_debug_info(pc);

		if ((int) fp == lr)
			break;

		kprintf("  fp: %x, lr: %x\n", fp, lr);
		kprintf("    %s:%s:%d\n", info.file, info.function,
			info.source_line_number);

		if (info.arg_count != 0)
			print_arguments(&info, fp);

		pc = lr;
		fp = (int *) fp[-3];
	}

	return 0;
}
예제 #8
0
int main(int argc, char *argv[])
{
  print_arguments(argc, argv);
  //char derp[] = "for reals";
  //char *herp[] = {"for reals", "for srs"};
  //printf("%s\n", derp);
  //printf("%s\n", herp[1]);
  return 0;
}
예제 #9
0
파일: daemon.cpp 프로젝트: film42/drake
int main(int argc, char ** argv) {
  print_arguments();


  std::cout << "Starting Reactor" << std::endl;

  reactor_loop_init();

  return 0;
}
예제 #10
0
 void visit(const CompressedNode * e){
   if(e->arguments.size() == 1){
     e->arguments[0]->accept(this);
   }
   else{
     stream << '{';
     print_arguments(e);
     stream << '}';
   }
 }
예제 #11
0
void cpn_opts_usage(const struct cpn_opt *opts,
        const char *executable, FILE *out)
{
    fputs("USAGE: ", out);
    print_header(opts, executable, NULL, out);
    if (has_actions(opts) || has_options(opts))
        fputc('\n', out);
    print_arguments(opts, out, 1);
    if (has_actions(opts) && has_options(opts))
        fputc('\n', out);
    print_actions(opts, out, 1);
}
예제 #12
0
static void print_actions(const struct cpn_opt *opts, FILE *out, int indent)
{
    const struct cpn_opt *it;
    int i;

    for (it = opts; it && it->type != CPN_OPTS_TYPE_END; it++) {
        if (it->type != CPN_OPTS_TYPE_ACTION)
            continue;

        for (i = indent; i; i--)
            fputc('\t', out);
        print_header(it->value.action_opts, it->long_name, it->description, out);
        print_arguments(it->value.action_opts, out, indent + 1);
        if (has_actions(it) && has_options(it))
            fputc('\n', out);
        print_actions(it->value.action_opts, out, indent + 1);
    }
}
예제 #13
0
static int check_authorization(DBusConnection *conn)
{
    DBusMessage *msg, *reply;
    DBusMessageIter iter;
    DBusError err;

    msg = dbus_message_new_method_call(AUTHORITY_DBUS, AUTHORITY_PATH,
                                       AUTHORITY_INTF, "CheckAuthorization");
    if (!msg) {
        fprintf(stderr, "Can't allocate new method call\n");
        return -ENOMEM;
    }

    dbus_message_iter_init_append(msg, &iter);
    add_arguments(conn, &iter);

    dbus_error_init(&err);

    reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);

    dbus_message_unref(msg);

    if (!reply) {
        if (dbus_error_is_set(&err)) {
            fprintf(stderr, "%s\n", err.message);
            dbus_error_free(&err);
        } else
            fprintf(stderr, "Can't check authorization\n");
        return -EIO;
    }

    if (dbus_message_has_signature(reply, "(bba{ss})") == TRUE) {
        dbus_message_iter_init(reply, &iter);
        print_arguments(&iter);
    }

    dbus_message_unref(reply);

    return 0;
}
예제 #14
0
int main(int argc, char *argv[]) {
    // note syntax is argv not argv[]
    print_arguments(argc, argv);

    return 0;
}
int main(int argc, char *argv[]) {
    int err = 0;
    double *m = NULL;
    double *c = NULL;
    double *x = NULL;

    gsl_rng_env_setup();
    const gsl_rng_type  *T   = gsl_rng_default;
    gsl_rng            **rng = NULL;

    DEBUGPRINT("### Parsing arguments");
    struct arguments args;
    initialise_arguments(&args);
    argp_parse (&argp, argc, argv, 0, 0, &args);
#ifdef DEBUG
    print_arguments(&args);
#endif

    DEBUGPRINT("### Reading input configuration");
    struct input_config cfg;
    read_input_config(args.input_file, &cfg);
#ifdef DEBUG
    print_input_config(&cfg);
#endif
    
    DEBUGPRINT("### Generating realization");
    int  n_threads = omp_get_max_threads();
    
    rng = malloc(n_threads * sizeof(gsl_rng *));
    if (!rng) {
        printf("Error: Could not allocate memory for 'rng'.\n");
        err = -1;
        goto cleanup;
    }
    for (int i = 0; i < n_threads; i++) {
        rng[i] = gsl_rng_alloc(T);
        gsl_rng_set(rng[i], cfg.rng_seed + i);
    }

    ptrdiff_t  n   = 1;
    double     vol = 1.0;
    for (int i = 0; i < cfg.levy_basis_rank; i++) {
        n *= (ptrdiff_t)cfg.levy_basis_dimension[i];
        vol *= cfg.levy_basis_resolution[i];
    }
    
    x = malloc(n * cfg.levy_seed_dimension * sizeof(double));
    if (!x) {
        printf("Error: Could not allocate memory for 'x'.\n");
        err = -1;
        goto cleanup;
    }
    
    if (strcmp(cfg.levy_seed_family, "normal") == 0) {
        struct normal_seed_parameters *q = cfg.levy_seed_parameters;
        int dim = cfg.levy_seed_dimension;
        m = calloc(dim, sizeof(double));
        c = calloc(dim * dim, sizeof(double));
        for (int i = 0; i < dim; i++)
            m[i] = q->mean[i] * vol;
        for (int i = 0; i < dim * dim; i++)
            c[i] = q->covariance[i] * vol;
        err = generate_multivariate_normal(n_threads, rng, dim, m, c, n, x);
        if (err) {
            printf("Error in generate_multivariate_normal.\n");
            goto cleanup;
        }
        
    }
    else {
        printf("Error: The Levy seed family \"%s\" is not yet supported.\n", cfg.levy_seed_family);
        err = -1;
        goto cleanup;
    }

    DEBUGPRINT("### Writing output");
    write_output(args.output_file, &cfg, x);
    
  cleanup:
    free(c);
    free(m);
    free(x);
    for (int i = 0; i < n_threads; i++)
        gsl_rng_free(rng[i]);
    free(rng);
    return err;
}
예제 #16
0
 void visit(const Tupel * e){
   stream << e->get_open();
   print_arguments(e);
   stream << e->get_close();
 }
예제 #17
0
int main(int argc, char *argv[]) {

    CURL *curl;
    CURLcode ret;
    char *url = NULL;
    char *host_header = NULL;
    char *host_name = NULL;
    char *regex = NULL;

    struct timeval tvBegin, tvEnd, tvDiff;

    /* Commandline switches */
    int verbose_level=0;
    int status_only = false;
    int measure_time = false;
    int nossl_verify = false;
    int follow_location = false;
    int fail_on_curl_error = false;
    int ssl_valid_date = false;

    struct curl_slist *headers = NULL;
    int i;
    int curl_timeout = TIMEOUT;
    char *curl_userpwd = NULL;

    ASN1_TIME * notAfter;
    time_t now;
    time_t expire;
    int time_left;

    pcre *re;
    int pcre_opts=0;
    const char *error;
    int erroffset;
    int ovector[OVECCOUNT];
    int rc;
    int opt;

    wr_error = 0;
    wr_index = 0;

    /* First step, init curl */
    curl = curl_easy_init();
    if(!curl) {
        fprintf(stderr, "couldn't init curl\n");
        exit(EXIT_FAILURE);
    }

    /* 
     * if no arguments are given
     */
    if(argc == 1) {
        fprintf(stderr, "This program needs arguments....\n\n");
        print_arguments(argc, argv);
        print_help(1);
    }

    while((opt = getopt(argc, argv, "?VfcamMlsvp:t:u:h:r:i")) != -1) {
        switch(opt) {
            case 'V':
                fprintf(stderr,"%s %s\n\n", PACKAGE, VERSION);
                exit(0);
                break;
            case 'v':
                verbose_level++;
                break;
            case 'a':
                curl_easy_setopt(curl, CURLOPT_HEADER  , true);
                break;
            case 'i':
                curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
                curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
                nossl_verify = true;
                break;
            case 's':
                status_only = true;
                break;
            case 'm':
                measure_time = true;
                break;
            case 'M':
                pcre_opts |= PCRE_MULTILINE;
                break;
            case 'l':
                follow_location = true;
                curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
                break;
            case 'f':
                fail_on_curl_error = true;
                break;
            case 'p':
                curl_userpwd = optarg;
                break;
            case 'u':
                url = optarg;
                break;
            case 't':
                curl_timeout = atoi(optarg);
                break;
            case 'h':
                host_header = malloc(strlen("Host: ") + strlen(optarg) + 1);
                host_name = optarg;
                strcpy(host_header, "Host: ");
                strcat(host_header, optarg);
                headers = curl_slist_append(headers, host_header);
                curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
                break;
            case 'c':
                ssl_valid_date = true;
            case 'r':
                regex = optarg;
                break;
            case ':':
                fprintf(stderr, "%s: Error - Option `%c' needs a value\n\n", PACKAGE, optopt);
                print_arguments(argc, argv);
                print_help(1);
                break;
            case '?':
                fprintf(stderr, "%s: Error - No such option: `%c'\n", PACKAGE, optopt);
                print_arguments(argc, argv);
                print_help(1);
        }
    }

    if (verbose_level > 3){
        curl_easy_setopt(curl, CURLOPT_VERBOSE , true);
    }

    if (verbose_level > 0){
        fprintf(stderr, "%-17s %s\n", "URL", url);
        fprintf(stderr, "%-17s %s\n", "REGEX", regex);
        fprintf(stderr, "%-17s %i\n", "TIMEOUT", curl_timeout);
        fprintf(stderr, "%-17s %s\n",   "HOST HEADER", host_header);
        fprintf(stderr, "%-17s %i\n\n", "STATUS ONLY", status_only);

        fprintf(stderr, "%-17s %s -t %i -u \"%s\" -r \"%s\"", "CMD ", PACKAGE, curl_timeout, url, regex);
        if ( status_only == true ){
            fprintf(stderr, " -s");
        }
        if ( measure_time  == true ){
            fprintf(stderr, " -m");
        }
        if ( nossl_verify == true ){
            fprintf(stderr, " -i");
             }
        if ( follow_location == true ){
            fprintf(stderr, " -l");
             }
        if ( fail_on_curl_error == true ){
            fprintf(stderr, " -f");
        }
        if ( (pcre_opts & PCRE_MULTILINE) == PCRE_MULTILINE ){
            fprintf(stderr, " -M");
        }
        if (curl_userpwd != NULL){
            fprintf(stderr, " -p %s", curl_userpwd);
        }

        if ( host_name != NULL ){
            fprintf(stderr, " -h %s",host_name);
        }
        fprintf(stderr, "\n");

        fprintf(stderr, "%-17s %s[\"-t\",\"%i\",\"-u\",\"%s\",\"-r\",\"%s\"", "ZABBIX 2.0 ITEM", PACKAGE, curl_timeout, url, regex);
        if ( status_only == true ){
            fprintf(stderr, ",\"-s\"");
        }
        if ( measure_time  == true ){
            fprintf(stderr, ",\"-m\"");
        }
        if ( nossl_verify == true ){
            fprintf(stderr, ",\"-i\"");
             }
        if ( follow_location == true ){
            fprintf(stderr, ",\"-l\"");
             }
        if ( fail_on_curl_error == true ){
            fprintf(stderr, ",\"-f\"");
        }
        if ( (pcre_opts & PCRE_MULTILINE) == PCRE_MULTILINE ){
            fprintf(stderr, ",\"-M\"");
        }
        if (curl_userpwd != NULL){
            fprintf(stderr, ",\"-p\",\"%s\"", curl_userpwd);
        }

        if ( host_name != NULL ){
            fprintf(stderr, ",\"-h\",\"%s\"",host_name);
        }
       fprintf(stderr, "]\n");
    }


    if (((url == NULL) || (regex == NULL)) && (ssl_valid_date == false)){
        print_arguments(argc, argv);
        print_help(EXIT_FAILURE);
    }

    /* Tell curl the URL of the file we're going to retrieve */
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5");

    /* Tell curl that we'll receive data to the function write_data, and
     * also provide it with a context pointer for our error return.
     */
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &wr_error);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
    curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, curl_timeout);

    curl_easy_setopt(curl, CURLOPT_USERPWD, curl_userpwd);

    gettimeofday(&tvBegin, NULL);
    /* Initialize certificate array*/
    for(i=0; i<MAX_CERTS;i++) {
        certificates[i] = 0;
        certificates_error[i] = X509_V_OK;
    }
    curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfunc);
    if(ssl_valid_date == true) {
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
    }

    /* Allow curl to perform the action */
    ret = curl_easy_perform(curl);
    /* Stop execution here if only status is needed */
    if ((ret != 0) || (fail_on_curl_error == true)){
        if (status_only == true){
            printf("0");
            if (verbose_level > 1){
                fprintf(stderr,"returned: '0'\n");
            }
        } else if (measure_time == true){
            printf("0.0");
            if (verbose_level > 1){
                fprintf(stderr,"returned: '0.0'\n");
            }
        }
        exit(EXIT_FAILURE);
    }

    /* Get days until certificate expires */
    if(ssl_valid_date == true) {
        if(ret!=0 || certificates[0]==0) {
            exit(EXIT_FAILURE);
        }
        notAfter = X509_get_notAfter(certificates[0]);
        now = time(NULL);
        expire = ASN1_GetTimeT(notAfter);
        time_left = (expire-now)/(60*60*24);

        printf("%d",time_left);

        if (verbose_level > 1){
            fprintf(stderr,"returned: '%d'\n",time_left);
        }

        curl_easy_cleanup(curl);
        exit(EXIT_SUCCESS);
    }

    re = pcre_compile(regex,    /* the pattern */
                      pcre_opts,        /* default options */
                      &error,   /* for error message */
                      &erroffset,   /* for error offset */
                      NULL);    /* use default character tables */


    rc = pcre_exec(re,          /* the compiled pattern */
                   NULL,        /* no extra data - we didn't study the pattern */
                   wr_buf,      /* the subject string */
                   wr_index,    /* the length of the subject */
                   0,           /* start at offset 0 in the subject */
                   0,           /* default options */
                   ovector,     /* output vector for substring information */
                   OVECCOUNT);  /* number of elements in the output vector */

    if(verbose_level > 2) {
        fprintf(stderr, "out: >>>%s<<< [%i bytes]\n", wr_buf, wr_index);
    }

    /* Evaluate the match and output status */
    if(rc < 0) {
        if (status_only == true) {
            printf("0");
            if (verbose_level > 1){
                fprintf(stderr,"returned: '0'\n");
            }
        } else if (measure_time == true) {
            printf("0.0");
            if (verbose_level > 1){
                fprintf(stderr,"returned: '0.0'\n");
            }
        } else {
            switch (rc) {
                case PCRE_ERROR_NOMATCH      : fprintf(stderr,"String did not match the pattern\n");        break;
                case PCRE_ERROR_NULL         : fprintf(stderr,"Something was null\n");                      break;
                case PCRE_ERROR_BADOPTION    : fprintf(stderr,"A bad option was passed\n");                 break;
                case PCRE_ERROR_BADMAGIC     : fprintf(stderr,"Magic number bad (compiled re corrupt?)\n"); break;
                case PCRE_ERROR_UNKNOWN_NODE : fprintf(stderr,"Something kooky in the compiled re\n");      break;
                case PCRE_ERROR_NOMEMORY     : fprintf(stderr,"Ran out of memory\n");                       break;
                default                      : fprintf(stderr,"Matching error %d\n", rc);                   break;
            }
        }
        pcre_free(re);          /* Release memory used for the compiled pattern */
        exit(EXIT_FAILURE);
    }

    if(rc == 2) {
        if (status_only == true) {
            printf("1");
            if (verbose_level > 1) {
                fprintf(stderr,"returned: '1'\n");
            }
        } else if (measure_time == true) {
            gettimeofday(&tvEnd, NULL);
            timeval_subtract(&tvDiff, &tvEnd, &tvBegin);
            printf("%ld.%06ld", tvDiff.tv_sec, tvDiff.tv_usec);
            if (verbose_level > 1){
                fprintf(stderr,"measure time returned: '%ld.%06ld'\n", tvDiff.tv_sec, tvDiff.tv_usec);
            }
        } else {
            char *substring_start = NULL;
            int substring_length = 0;
            i = 1;
            substring_start = wr_buf + ovector[2 * i];
            substring_length = ovector[2 * i + 1] - ovector[2 * i];
            printf("%.*s", substring_length, substring_start);
            fprintf(stderr,"parsing returned: '%.*s'\n", substring_length, substring_start);
        }
    }
    curl_easy_cleanup(curl);

    exit(EXIT_SUCCESS);
}
예제 #18
0
static void generate_interface_xml(GString *gstr, struct interface_data *iface)
{
	const GDBusMethodTable *method;
	const GDBusSignalTable *signal;
	const GDBusPropertyTable *property;

	for (method = iface->methods; method && method->name; method++) {
		if (check_experimental(method->flags,
					G_DBUS_METHOD_FLAG_EXPERIMENTAL))
			continue;

		g_string_append_printf(gstr, "<method name=\"%s\">",
								method->name);
		print_arguments(gstr, method->in_args, "in");
		print_arguments(gstr, method->out_args, "out");

		if (method->flags & G_DBUS_METHOD_FLAG_DEPRECATED)
			g_string_append_printf(gstr,
						G_DBUS_ANNOTATE_DEPRECATED);

		if (method->flags & G_DBUS_METHOD_FLAG_NOREPLY)
			g_string_append_printf(gstr, G_DBUS_ANNOTATE_NOREPLY);

		g_string_append_printf(gstr, "</method>");
	}

	for (signal = iface->signals; signal && signal->name; signal++) {
		if (check_experimental(signal->flags,
					G_DBUS_SIGNAL_FLAG_EXPERIMENTAL))
			continue;

		g_string_append_printf(gstr, "<signal name=\"%s\">",
								signal->name);
		print_arguments(gstr, signal->args, NULL);

		if (signal->flags & G_DBUS_SIGNAL_FLAG_DEPRECATED)
			g_string_append_printf(gstr,
						G_DBUS_ANNOTATE_DEPRECATED);

		g_string_append_printf(gstr, "</signal>\n");
	}

	for (property = iface->properties; property && property->name;
								property++) {
		if (check_experimental(property->flags,
					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL))
			continue;

		g_string_append_printf(gstr, "<property name=\"%s\""
					" type=\"%s\" access=\"%s%s\">",
					property->name,	property->type,
					property->get ? "read" : "",
					property->set ? "write" : "");

		if (property->flags & G_DBUS_PROPERTY_FLAG_DEPRECATED)
			g_string_append_printf(gstr,
						G_DBUS_ANNOTATE_DEPRECATED);

		g_string_append_printf(gstr, "</property>");
	}
}
예제 #19
0
파일: object.c 프로젝트: intgr/bluez
static void generate_interface_xml(GString *gstr, struct interface_data *iface)
{
	const GDBusMethodTable *method;
	const GDBusSignalTable *signal;
	const GDBusPropertyTable *property;

	for (method = iface->methods; method && method->name; method++) {
		gboolean deprecated = method->flags &
						G_DBUS_METHOD_FLAG_DEPRECATED;
		gboolean noreply = method->flags &
						G_DBUS_METHOD_FLAG_NOREPLY;

		if (!deprecated && !noreply &&
				!(method->in_args && method->in_args->name) &&
				!(method->out_args && method->out_args->name))
			g_string_append_printf(gstr,
						"\t\t<method name=\"%s\"/>\n",
						method->name);
		else {
			g_string_append_printf(gstr,
						"\t\t<method name=\"%s\">\n",
						method->name);
			print_arguments(gstr, method->in_args, "in");
			print_arguments(gstr, method->out_args, "out");

			if (deprecated)
				g_string_append_printf(gstr,
					G_DBUS_ANNOTATE_DEPRECATED("\t\t\t"));
			if (noreply)
				g_string_append_printf(gstr,
					G_DBUS_ANNOTATE_NOREPLY("\t\t\t"));

			g_string_append_printf(gstr, "\t\t</method>\n");
		}
	}

	for (signal = iface->signals; signal && signal->name; signal++) {
		gboolean deprecated = signal->flags &
						G_DBUS_SIGNAL_FLAG_DEPRECATED;

		if (!deprecated && !(signal->args && signal->args->name))
			g_string_append_printf(gstr,
						"\t\t<signal name=\"%s\"/>\n",
						signal->name);
		else {
			g_string_append_printf(gstr,
						"\t\t<signal name=\"%s\">\n",
						signal->name);
			print_arguments(gstr, signal->args, NULL);

			if (deprecated)
				g_string_append_printf(gstr,
					G_DBUS_ANNOTATE_DEPRECATED("\t\t\t"));

			g_string_append_printf(gstr, "\t\t</signal>\n");
		}
	}

	for (property = iface->properties; property && property->name;
								property++) {
		gboolean deprecated = property->flags &
					G_DBUS_PROPERTY_FLAG_DEPRECATED;

		g_string_append_printf(gstr, "\t\t<property name=\"%s\""
					" type=\"%s\" access=\"%s%s\"",
					property->name,	property->type,
					property->get ? "read" : "",
					property->set ? "write" : "");

		if (!deprecated)
			g_string_append_printf(gstr, "/>\n");
		else
			g_string_append_printf(gstr,
				G_DBUS_ANNOTATE_DEPRECATED(">\n\t\t\t"));
	}
}
예제 #20
0
void print_operator_debug_info(scp_operand op) {
    print_arguments(op);
}
예제 #21
0
파일: learn_c.c 프로젝트: lcmust/git6500cgo
int main(int argc, char *argv[])
{
	struct timert t1;
	struct timert *t1Ptr = &t1;
	if (timer_start(t1Ptr)) {
		exit(-1);
	}

	process_optlong(argc, argv, msg, &myargument, longopts);
	print_arguments(myargument);
	// DEBUG_PRINT("%s", "****DEBUG_LOG_ENABLE****");

	if (!myargument.filename) {
		myargument.filename = "/home/love/dic.txt";
	}
	int fd;
	fd = open(myargument.filename, O_RDONLY);
	if (!fd) {
		printf("can't open file(%s)\n", myargument.filename);
		exit(-1);
	}

	DEBUG_PRINT("file(%s)opened(%d)", myargument.filename, fd);
	FILE *fd_File;
	fd_File = fdopen(fd, "r");
	if (!fd_File) {
		printf("fdopen(fd) error....\n");
		exit(-1);
	}

	int month_no;
	char buf[8192] = {};
	char *charPtrTmp;
	charPtrTmp = &buf;
	for ( ; ; ) {
		charPtrTmp = fgets(buf, sizeof(buf), fd_File);
		if (!charPtrTmp) {
			break;
		}

		if (myargument.mode) {
			printf("DEBUG: %s\n", buf);
		}
		
		if (strlen(buf)  > 1) {
			if (myargument.mode)
				DEBUG_PRINT("strlen of buf:%d", strlen(buf));
			buf[strlen(buf) - 1] = '\0';
			month_no = lookup_word(buf, month_names);
			if (month_no >= 0) {
				printf("found at %2d(%s)\n", month_no, month_names[month_no]);
			} else if (myargument.mode) {
				printf("%d\t%s\n", month_no, buf);
			}
		}
	}
	/* int c; */
	/* while((c = getchar()) != EOF) { */
	/* 	putchar(c); */
	/* } */

	mylib_func1();
	if (timer_stop (t1Ptr)) {
		exit(-1);
	}

	int month_names_size = 12;
	// DEBUG_PRINT("%s %d", "sizeof month_names", month_names_size);
	int i;
	for (i = 0; i < month_names_size; i++) {
		unsigned int resu;
		resu = hash3(month_names[i], sizeof(month_names[i]));
		printf("hash(%d) = %x\n", i, resu);
	}
	int a = 23;
	int b = 15;
	printf("a=%d\t b=%d\n", a, b);
	a = a ^ b;
	b = b ^ a;
	a = a ^ b;
	printf("after swap with ^, a=%d\t b=%d\n", a, b);
	printf("\nEND: this program taked %ld useconds!\n",
		   timer_delta_useconds(t1Ptr));
	exit(0);
}
int main(int argc, char *argv[]) {
    herr_t err = 0;
    
    int n_threads = omp_get_max_threads();

    hid_t kernel_file_id = 0;
    hid_t levy_basis_file_id = 0;
    hid_t levy_basis_dataset_id = 0;
    hid_t levy_basis_dataspace_id = 0;
    hid_t output_file_id      = 0;
    hid_t output_dataset_id   = 0;
    hid_t output_dataspace_id = 0;
    hid_t memspace = 0;

    hsize_t n_k = 0;
    double *tmp = NULL;
    double *k_abscissa = NULL;
    double *k_ordinate = NULL;
    double *x1 = NULL;
    double *x2 = NULL;
    double *x3 = NULL;
    
    DEBUGPRINT("### Parsing arguments");
    struct arguments args;
    initialise_arguments(&args);
    argp_parse (&argp, argc, argv, 0, 0, &args);
#ifdef DEBUG
    print_arguments(&args);
#endif
    
    DEBUGPRINT("### Reading kernel");
    kernel_file_id = H5Fopen(args.kernel_file, H5F_ACC_RDONLY, H5P_DEFAULT);
    if (kernel_file_id <= 0) {
        printf("Error: Could not open \"%s\".\n", args.kernel_file);
        err = -1;
        goto cleanup;
    }
    
    err = H5LTget_dataset_info(kernel_file_id, "/abscissa", &n_k, NULL, NULL);
    if (err < 0) {
        printf("Error: Could not read dataset info.\n");
        goto cleanup;
    }
    printf("n_k = %i\n", (int)n_k);
    k_abscissa = malloc(n_k * sizeof(double));
    k_ordinate = malloc(n_k * sizeof(double));
    err = H5LTread_dataset_double(kernel_file_id, "/abscissa", k_abscissa);
    err = H5LTread_dataset_double(kernel_file_id, "/ordinate", k_ordinate);
    
    DEBUGPRINT("### Reading Levy basis");
    hsize_t dims[4];
    hsize_t offset[4];
    hsize_t count[4];
    levy_basis_file_id      = H5Fopen(args.levy_basis_file, H5F_ACC_RDONLY, H5P_DEFAULT);
    levy_basis_dataset_id   = H5Dopen(levy_basis_file_id, "/levy_basis_realization", H5P_DEFAULT);
    levy_basis_dataspace_id = H5Dget_space(levy_basis_dataset_id);
    err = H5Sget_simple_extent_dims(levy_basis_dataspace_id, dims, NULL);
    
    if (dims[0] != dims[1] || dims[1] != dims[2]) {
        printf("Error: The three dimensions must be equal.\n");
        err = -1;
        goto cleanup;
    }

    hsize_t dims_pad[3];
    dims_pad[0] = dims[0];
    dims_pad[1] = dims[1];
    dims_pad[2] = 2 * (dims[2] / 2 + 1);

    hsize_t n_x = dims_pad[0] * dims_pad[1] * dims_pad[2];
    x1 = malloc(n_x * sizeof(double));
    x2 = malloc(n_x * sizeof(double));
    x3 = malloc(n_x * sizeof(double));

    double *x[] = {x1, x2, x3};
    if (!x1 || !x2 || !x3) {
        printf("Error: Could not allocate memory for the Levy basis.\n");
        err = -1;
        goto cleanup;
    }

#pragma omp parallel for 
    for (ptrdiff_t i = 0; i < n_x; i++) {
        x1[i] = 0.0;
        x2[i] = 0.0;
        x3[i] = 0.0;
    }    

    /* Define memory dataspace */
    memspace = H5Screate_simple(3, dims_pad, NULL);
    offset[0] = offset[1] = offset[2] = 0;
    count[0] = dims[0];
    count[1] = dims[1];
    count[2] = dims[2];
    /* Define hyperslab in the memory dataspace */
    err = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset, NULL, count, NULL);
    
    for (int j = 0; j < 3; j++) {
        /* Define hyperslap in the file dataspace */
        offset[3] = j;
        count[3] = 1;
        err = H5Sselect_hyperslab(levy_basis_dataspace_id, H5S_SELECT_SET, offset, NULL, count, NULL);
        /* Read data from hyperslab */
        err = H5Dread(levy_basis_dataset_id, H5T_NATIVE_DOUBLE, 
                      memspace, levy_basis_dataspace_id,
                      H5P_DEFAULT, x[j]);
        if (err < 0) {
            printf("Error: Could not read hyperslab.\n");
            err = -1;
            goto cleanup;
        }
    }
    

    DEBUGPRINT("### Convolving");
    double delta = 2.0 * M_PI / dims[0];
    err = ambit_symmetric_odd_isotropic_circular_convolution_inplace(
        n_threads, n_k, k_abscissa, k_ordinate, dims[0], delta, x1, x2, x3);
    if (err) {
        printf("Error in ambit_symmetric_odd_isotropic_circular_convolution_inplace.\n");
        goto cleanup;
    }

    DEBUGPRINT("### Writing output");
    output_file_id = H5Fcreate(args.output_file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    if (output_file_id < 0) {
        printf("Error: Could not open \"%s\".\n", args.output_file);
        err = -1;
        goto cleanup;
    }
    
    output_dataspace_id = H5Screate_simple(4, dims, NULL);
    output_dataset_id   = H5Dcreate(output_file_id, "/simulation", H5T_NATIVE_DOUBLE, output_dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    for (int j = 0; j < 3; j++) {
        printf("j = %i\n", j);
        /* Define hyperslap in the file dataspace */
        offset[3] = j;
        count[3] = 1;
        err = H5Sselect_hyperslab(output_dataspace_id, H5S_SELECT_SET, offset, NULL, count, NULL);
        /* Write data to hyperslab */
        err = H5Dwrite(output_dataset_id, H5T_NATIVE_DOUBLE, 
                       memspace, output_dataspace_id,
                       H5P_DEFAULT, x[j]);
        if (err < 0) {
            printf("Error: Could not write hyperslab.\n");
            err = -1;
            goto cleanup;
        }
    }
    
  cleanup:
    if (memspace > 0) H5Sclose(memspace);
    if (output_dataspace_id > 0) H5Sclose(output_dataspace_id);
    if (output_dataset_id > 0) H5Dclose(output_dataset_id);
    if (output_file_id > 0) H5Fclose(output_file_id);
    if (levy_basis_dataspace_id > 0) H5Sclose(levy_basis_dataspace_id);
    if (levy_basis_dataset_id > 0) H5Dclose(levy_basis_dataset_id);
    if (levy_basis_file_id > 0) H5Fclose(levy_basis_file_id);
    if (kernel_file_id > 0) H5Fclose(kernel_file_id);
    free(tmp);
    free(k_abscissa);
    free(k_ordinate);
    free(x1);
    free(x2);
    free(x3);    
    return err;
}
예제 #23
0
 void visit(const Function * e){
   stream << e->get_name() << '(';
   print_arguments(e);
   stream << ')';
 }