Ejemplo n.º 1
0
Archivo: main.c Proyecto: dzruyk/ntx
static void
disconnect_cb (const GError *err, gpointer user_data)
{
  g_debug ("disconnect_cb");

  if (err != NULL)
    g_fprintf (stderr, "disconnect cause: %s\r\n", err->message);

  gtk_main_quit ();
}
Ejemplo n.º 2
0
static MPI_Fint _trace_write_comm (MPI_Comm comm)
{
  MPI_Fint ret = MPI_Comm_c2f (comm);
  MPI_Group world_group, group;
  gint rk, sz, i;
  gint world_rk, world_sz;
  gint *world_rks, *comm_rks;

  MPI_Comm_group (MPI_COMM_WORLD, &world_group);
  MPI_Comm_group (comm, &group);

  MPI_Comm_rank (MPI_COMM_WORLD, &world_rk);
  MPI_Comm_size (MPI_COMM_WORLD, &world_sz);

  MPI_Comm_rank (comm, &rk);
  MPI_Comm_size (comm, &sz);

  world_rks = g_malloc (world_sz * sizeof (int));
  comm_rks = g_malloc (world_sz * sizeof (int));

  for (i=0; i<world_sz; i++)
    world_rks[i] = i;

  MPI_Group_translate_ranks (world_group, world_sz, world_rks, group, comm_rks);

  g_fprintf (_trace_file, "comm=%d rk=%d sz=%d translate={",
	     ret, rk, sz);

  for (i=0; i<world_sz; i++)
    {
      g_fprintf (_trace_file, "%d ", comm_rks[i]);
    }

  g_fprintf (_trace_file, "}\n");

  MPI_Group_free (&world_group);
  MPI_Group_free (&group);

  g_free (world_rks);
  g_free (comm_rks);

  return ret;
}
Ejemplo n.º 3
0
/* Callback when GeoClue disappears from the bus */
static void
on_name_vanished(GDBusConnection *connection, const gchar *name,
		 gpointer user_data)
{
	get_location_data_t *data = (get_location_data_t *)user_data;

	g_fprintf(stderr, _("Unable to connect to GeoClue.\n"));

	g_main_loop_quit(data->loop);
}
Ejemplo n.º 4
0
void
mono_hwcap_print(FILE *f)
{
	g_fprintf (f, "mono_hwcap_arm_is_v5 = %i\n", mono_hwcap_arm_is_v5);
	g_fprintf (f, "mono_hwcap_arm_is_v6 = %i\n", mono_hwcap_arm_is_v6);
	g_fprintf (f, "mono_hwcap_arm_is_v7 = %i\n", mono_hwcap_arm_is_v7);
	g_fprintf (f, "mono_hwcap_arm_has_vfp = %i\n", mono_hwcap_arm_has_vfp);
	g_fprintf (f, "mono_hwcap_arm_has_vfp3 = %i\n", mono_hwcap_arm_has_vfp3);
	g_fprintf (f, "mono_hwcap_arm_has_vfp3_d16 = %i\n", mono_hwcap_arm_has_vfp3_d16);
	g_fprintf (f, "mono_hwcap_arm_has_thumb = %i\n", mono_hwcap_arm_has_thumb);
	g_fprintf (f, "mono_hwcap_arm_has_thumb2 = %i\n", mono_hwcap_arm_has_thumb2);
}
Ejemplo n.º 5
0
/*  The tape drive does not have an idea of current slot so
 *  we use a file to store the current slot.  It is not ideal
 *  but it gets the job done  
 */
int get_current_slot(char *count_file)
{
  FILE *inf;
  int retval;
  if ((inf=fopen(count_file,"r")) == NULL) {
    g_fprintf(stderr, _("%s: unable to open current slot file (%s)\n"),
            get_pname(), count_file);
    return 0;
  }

  if (fscanf(inf, "%d", &retval) != 1) {
    g_fprintf(stderr, _("%s: unable to read current slot file (%s)\n"),
            get_pname(), count_file);
    retval = 0;
  }

  fclose(inf);
  return retval;
}
Ejemplo n.º 6
0
static void
ac_free(gpointer p)
{
    ac* tmp = (ac*) p;
    g_free(tmp->path);
    g_free(tmp->name);
    g_free(tmp);
    if (DEBUG) {
        g_fprintf(stderr, "ac_free %p\n", p);
    }
}
Ejemplo n.º 7
0
static int myXErrorHandler(Display *display, XErrorEvent *theEvent)
{
  (void)g_fprintf (stderr,
                   _("Ignoring Xlib error: error code %d request code %d\n"),
                   theEvent->error_code,
                   theEvent->request_code);
  // No exit on X errors!
  //  mainly to handle out of memory error when requesting large pixbuf from user request
  //  see vikwindow.c::save_image_file ()
  return 0;
}
Ejemplo n.º 8
0
void test_printerr (const gchar *fmt, ...)
{
  va_list ap;

  if (sz > 1)
    g_fprintf (stderr, "%d: ", rk);

  va_start (ap, fmt);
  g_vfprintf (stderr, fmt, ap);
  va_end (ap);
}
Ejemplo n.º 9
0
static int list_config(char *interface, unsigned int remote_port)
{
	unsigned inc = 0;
	char* ipfilter;

	if (!interface) {
		g_fprintf(stderr, "ERROR: No interface specified.\n");
		return EXIT_FAILURE;
	}

	if (g_strcmp0(interface, SSH_EXTCAP_INTERFACE)) {
		errmsg_print("ERROR: interface must be %s\n", SSH_EXTCAP_INTERFACE);
		return EXIT_FAILURE;
	}

	ipfilter = local_interfaces_to_filter(remote_port);

	printf("arg {number=%u}{call=--remote-host}{display=Remote SSH server address}"
		"{type=string}{tooltip=The remote SSH host. It can be both "
		"an IP address or a hostname}{required=true}\n", inc++);
	printf("arg {number=%u}{call=--remote-port}{display=Remote SSH server port}"
		"{type=unsigned}{default=22}{tooltip=The remote SSH host port (1-65535)}"
		"{range=1,65535}\n", inc++);
	printf("arg {number=%u}{call=--remote-username}{display=Remote SSH server username}"
		"{type=string}{default=%s}{tooltip=The remote SSH username. If not provided, "
		"the current user will be used}\n", inc++, g_get_user_name());
	printf("arg {number=%u}{call=--remote-password}{display=Remote SSH server password}"
		"{type=password}{tooltip=The SSH password, used when other methods (SSH agent "
		"or key files) are unavailable.}\n", inc++);
	printf("arg {number=%u}{call=--sshkey}{display=Path to SSH private key}"
		"{type=fileselect}{tooltip=The path on the local filesystem of the private ssh key}\n",
		inc++);
	printf("arg {number=%u}{call=--sshkey-passphrase}{display=SSH key passphrase}"
		"{type=password}{tooltip=Passphrase to unlock the SSH private key}\n",
		inc++);
	printf("arg {number=%u}{call=--remote-interface}{display=Remote interface}"
		"{type=string}{default=eth0}{tooltip=The remote network interface used for capture"
		"}\n", inc++);
	printf("arg {number=%u}{call=--remote-capture-bin}{display=Remote capture binary}"
		"{type=string}{default=%s}{tooltip=The remote dumpcap binary used "
		"for capture.}\n", inc++, DEFAULT_CAPTURE_BIN);
	printf("arg {number=%u}{call=--remote-filter}{display=Remote capture filter}"
		"{type=string}{tooltip=The remote capture filter}", inc++);
	if (ipfilter)
		printf("{default=%s}", ipfilter);
	printf("\n");
	printf("arg {number=%u}{call=--remote-count}{display=Packets to capture}"
		"{type=unsigned}{default=0}{tooltip=The number of remote packets to capture. (Default: inf)}\n",
		inc++);

	g_free(ipfilter);

	return EXIT_SUCCESS;
}
Ejemplo n.º 10
0
static void
strange_header(
    dumpfile_t *file,
    const char *buffer,
    size_t	buflen,
    const char *expected,
    const char *actual)
{
    if (actual == NULL)
	actual = "<null>";
    if (expected == NULL)
	expected = "<null>";

    g_fprintf(stderr, _("%s: strange amanda header: \"%.*s\"\n"), get_pname(),
		(int)buflen, buffer);

    g_fprintf(stderr, _("%s: Expected: \"%s\"  Actual: \"%s\"\n"), get_pname(),
		expected, actual);

    file->type = F_WEIRD;
}
Ejemplo n.º 11
0
void /*TODO: transform this into a fancy GtkInfoBar */
error_dialog(const char *message) {
	GtkWidget *dialog;

	g_fprintf(stderr, message);

	dialog = gtk_message_dialog_new(GTK_WINDOW(lightpad->window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, message);
	gtk_window_set_title(GTK_WINDOW(dialog), "Error!");
	gtk_dialog_run(GTK_DIALOG(dialog));
	gtk_widget_destroy(dialog);
}
Ejemplo n.º 12
0
void
changer_find(
     void *	user_data,
     int	(*user_init)(void *, int, int, int, int),
     int	(*user_slot)(void *, int, char *, char *),
     char *	searchlabel)
{
    char *slotstr, *device = NULL, *curslotstr = NULL;
    int nslots, checked, backwards, rc, done, searchable;

    rc = changer_query(&nslots, &curslotstr, &backwards, &searchable);

    if (rc != 0) {
        /* Problem with the changer script. Bail. */
        g_fprintf(stderr, _("Changer problem: %s\n"), changer_resultstr);
        amfree(curslotstr);
        return;
    }

    done = user_init(user_data, rc, nslots, backwards, searchable);
    amfree(curslotstr);
   
    if (searchlabel != NULL)
    {
      dbprintf(_("changer_find: looking for %s changer is searchable = %d\n"),
		searchlabel, searchable);
    } else {
      dbprintf(_("changer_find: looking for NULL changer is searchable = %d\n"),
		searchable);
    }

    if ((searchlabel!=NULL) && searchable && !done){
      rc=changer_search(searchlabel, &curslotstr, &device);
      if(rc == 0)
        done = user_slot(user_data, rc, curslotstr, device);
    }
 
    slotstr = "current";
    checked = 0;

    while(!done && checked < nslots) {
	rc = changer_loadslot(slotstr, &curslotstr, &device);
	if(rc > 0)
	    done = user_slot(user_data, rc, curslotstr, device);
	else if(!done)
	    done = user_slot(user_data, 0,  curslotstr, device);
	amfree(curslotstr);
	amfree(device);

	checked += 1;
	slotstr = "next";
    }
}
Ejemplo n.º 13
0
int maus_gpio_interrupt(gint pin)
{
    char path[BUFSZ] = {0};
    const char when_to_return[] = "both";
    int fd;

    g_snprintf(path, BUFSZ, "/sys/class/gpio/gpio%d/edge", pin);
    fd = g_open(path, O_WRONLY);
    if (-1 == fd) {
        g_fprintf(stderr, "Failed to open gpio edge for writing\n");
        return -1;
    }

    if (-1 == write(fd, when_to_return, 4)) {
        g_fprintf(stderr, "Failed to configure gpio as interrupt source\n");
        return -1;
    }

    close(fd);
    return 0;
}
Ejemplo n.º 14
0
static inline void print_netlist_entry(gpointer data, gpointer userdata G_GNUC_UNUSED)
{
    struct sydbox_addr *saddr = (struct sydbox_addr *) data;

    if (NULL == saddr)
        return;

    switch (saddr->family) {
        case AF_UNIX:
            g_fprintf(stderr, "\t{family=AF_UNIX path=%s}\n", saddr->addr);
            break;
        case AF_INET:
            g_fprintf(stderr, "\t{family=AF_INET addr=%s port=%d}\n", saddr->addr, saddr->port);
            break;
        case AF_INET6:
            g_fprintf(stderr, "\t{family=AF_INET6 addr=%s port=%d}\n", saddr->addr, saddr->port);
            break;
        default:
            g_assert_not_reached();
    }
}
Ejemplo n.º 15
0
static int
holding_cleanup_disk(
    gpointer datap,
    G_GNUC_UNUSED char *base,
    G_GNUC_UNUSED char *element,
    char *fqpath,
    int is_cruft)
{
    holding_cleanup_datap_t *data = (holding_cleanup_datap_t *)datap;

    if (data->verbose_output) {
	if (is_cruft)
	    g_fprintf(data->verbose_output, 
		_("Invalid holding disk '%s'\n"), fqpath);
	else
	    g_fprintf(data->verbose_output, 
		_("Cleaning up holding disk '%s'\n"), fqpath);
    }

    return 1;
}
Ejemplo n.º 16
0
static void
bat_free(gpointer p)
{
    bat* tmp = (bat*) p;
    g_free(tmp->path);
    g_free(tmp->name);
    g_free(tmp->status);
    g_free(tmp);
    if (DEBUG) {
        g_fprintf(stderr, "bat_free %p\n", p);
    }
}
Ejemplo n.º 17
0
void
ttl_sgml_print (OntologyDescription *description,
                Ontology *ontology,
                FILE *f,
                FILE *fts,
                const gchar *explanation_file)
{
        gchar *upper_name;

        upper_name = g_ascii_strup (description->localPrefix, -1);

        qname_init (description->baseUrl, description->localPrefix, NULL);
	print_sgml_header (f, description);

        /* FIXME: make desc files sgml */
	print_sgml_explanation (f, explanation_file);

        g_fprintf (f, "<section id='%s-classes'>\n", description->localPrefix);
	g_fprintf (f, "<title>%s Ontology Classes</title>\n", upper_name);
	g_hash_table_foreach (ontology->classes, print_ontology_class, f);
        g_fprintf (f, "</section>\n");

        g_fprintf (f, "<section id='%s-properties'>\n", description->localPrefix);
	g_fprintf (f, "<title>%s Ontology Properties</title>\n", upper_name);
	g_hash_table_foreach (ontology->properties, print_ontology_property, f);
        g_fprintf (f, "</section>\n");

	print_sgml_footer (f);

        g_free (upper_name);

        if (fts) {
                g_hash_table_foreach (ontology->properties, print_fts_properties, fts);
        }
}
Ejemplo n.º 18
0
static gboolean
test_validate_glob(void)
{
    gboolean ok = TRUE;
    struct {
	char *glob;
	gboolean should_validate;
    } tests[] = {
	{ "foo.*", TRUE },
	{ "*.txt", TRUE },
	{ "x[abc]y", TRUE },
	{ "x[!abc]y", TRUE },
	{ "[abc", FALSE },
	{ "[!abc", FALSE },
	{ "??*", TRUE },
	{ "**?", TRUE }, /* legal, but weird */
	{ "foo\\", FALSE }, /* un-escaped \ is illegal */
	{ "foo\\\\", TRUE }, /* but escaped is OK */
	{ "(){}+.^$|", TRUE }, /* funny characters OK */
	{ "/usr/bin/*", TRUE }, /* filename seps are OK */
	{ NULL, FALSE },
    }, *t;

    for (t = tests; t->glob; t++) {
	char *validated_err = validate_glob(t->glob);
	if (!validated_err != !!t->should_validate) {
	    ok = FALSE;
	    if (t->should_validate) {
		g_fprintf(stderr, "should have validated glob %s: %s\n",
			t->glob, validated_err);
	    } else {
		g_fprintf(stderr, "unexpectedly validated glob %s\n",
			t->glob);
	    }
	}
    }

    return ok;
}
Ejemplo n.º 19
0
int maus_gpio_direction(gint pin, gint dir)
{
    const char s_directions_str[]  = "in\0out";

    gchar path[BUFSZ] = {0};
    int fd;

    g_snprintf(path, BUFSZ, "/sys/class/gpio/gpio%d/direction", pin);
    fd = g_open(path, O_WRONLY);
    if (-1 == fd) {
        g_fprintf(stderr, "Failed to open gpio direction for writing\n");
        return -1;
    }

    if (-1 == write(fd, &s_directions_str[DIRECTION_IN == dir ? 0 : 3], DIRECTION_IN == dir ? 2 : 3)) {
        g_fprintf(stderr, "Failed to set gpio direction\n");
        return -1;
    }

    close(fd);
    return 0;
}
Ejemplo n.º 20
0
static int
test_strquotedstr_edge_valid(void)
{
    gboolean success = TRUE;
    char *valid[] = {
	/* input */	    /* expected (omitting "X") */
	"X abc\\ def",      "abc\\ def", /* backslashed space */
	"X \"abc\\ def\"",  "\"abc\\ def\"", /* quoted, backslashed space */
	"X a\"  \"b",       "a\"  \"b", /* quoted spaces */
	NULL, NULL
    };
    char **iter;

    /* run strquotedstr on a bunch of valid, but tricky, tokens.  It should return NULL */

    for (iter = valid; *iter; iter += 2) {
	char *copy = g_strdup(*iter);
	char *expected = *(iter+1);
	char *tok;
	char *saveptr = NULL;

	tok = strtok_r(copy, " ", &saveptr);
	tok = strquotedstr(&saveptr);
	if (tok == NULL) {
	    g_fprintf(stderr, "while parsing valid '%s', strquotedstr returned NULL\n",
		      *iter);
	    success = FALSE;
	} else if (0 != strcmp(tok, expected)) {
	    g_fprintf(stderr, "while parsing valid '%s', strquotedstr returned '%s' while "
		      "'%s' was expected\n",
		      *iter, tok, expected);
	    success = FALSE;
	}

	amfree(copy);
    }

    return success;
}
Ejemplo n.º 21
0
static void mux_pad_has_caps_cb(GstPad *pad, GParamSpec * unused, App * app)
{
    GstCaps *caps;

    g_object_get (G_OBJECT (pad), "caps", &caps, NULL);

    if (caps)
    {
        g_fprintf(stdout, "%s:%s has CAPS: %s\n", GST_DEBUG_PAD_NAME(pad), gst_caps_to_string(caps));
        fflush(stdout);
        gst_caps_unref (caps);
    }
}
Ejemplo n.º 22
0
int maus_gpio_write(gint pin, gint value)
{
    const char s_values_str[] = "01";

    char path[BUFSZ] = {0};
    int fd;

    snprintf(path, BUFSZ, "/sys/class/gpio/gpio%d/value", pin);
    fd = g_open(path, O_WRONLY);
    if (-1 == fd) {
        g_fprintf(stderr, "Failed to open gpio value for writing\n");
        return -1;
    }

    if (1 != write(fd, &s_values_str[VALUE_LOW == value ? 0 : 1], 1)) {
        g_fprintf(stderr, "Failed to write value\n");
        return -1;
    }

    close(fd);
    return 0;
}
Ejemplo n.º 23
0
void moto_rman_node_writeln(MotoRManNode *self, guint indent_num, const gchar *fmt, ...)
{
    MotoRManNodePriv* priv = MOTO_RMAN_NODE_GET_PRIVATE(self);
    if(!priv->out)
        return;
    FILE* out = priv->out;

    GString *indent = g_string_new("");
    guint i;
    for(i = 0; i < indent_num; ++i)
        g_string_append(indent, "    ");

    g_fprintf(out, "%s", indent->str);
    g_string_free(indent, TRUE);

    va_list ap;
    va_start(ap, fmt);
    g_vfprintf(out, fmt, ap);
    va_end(ap);

    g_fprintf(out, "\n");
}
Ejemplo n.º 24
0
void
FILE_taperscan_output_callback(
    void *data,
    char *msg)
{
    if(!msg) return;
    if(strlen(msg) == 0) return;

    if(data)
        g_fprintf((FILE *)data, "%s", msg);
    else
        g_printf("%s", msg);
}
Ejemplo n.º 25
0
times_t
curclock(void)
{
    GTimeVal end_time;

    if(!clock_running) {
        g_fprintf(stderr,_("curclock botch\n"));
        exit(1);
    }

    g_get_current_time(&end_time);
    return timesub(end_time,start_time);
}
Ejemplo n.º 26
0
static void
print_sgml_explanation (FILE *f, const gchar *explanation_file)
{
	gchar *raw_content;
	gsize length;

	if (explanation_file && g_file_test (explanation_file, G_FILE_TEST_EXISTS)) {
		if (!g_file_get_contents (explanation_file, &raw_content, &length, NULL)) {
			g_error ("Unable to load '%s'", explanation_file );
		}
		g_fprintf (f, "%s", raw_content);
	}
}
Ejemplo n.º 27
0
static inline void _trace_file_open ()
{
  if (_trace_file == NULL)
    {
      gint initted, rk, sz;
      gchar filename[256];
      GTimeVal now;
      const gchar *trace_dir = g_getenv ("VSG_PACKED_MSG_TRACE_DIR");
      gchar *trace_path;

      MPI_Initialized (&initted);
      if (initted != 0)
        {
          MPI_Comm_rank (MPI_COMM_WORLD, &rk);
          MPI_Comm_size (MPI_COMM_WORLD, &sz);
        }
      else
        {
          rk = 0;
          sz = 1;
        }
      _msgid = rk+1;
      _msgid_incr = sz;

      g_sprintf (filename, "vsg-packed-msg-%04d.trace", rk);

      if (trace_dir != NULL)
	trace_path = g_build_filename (trace_dir, filename, NULL);
      else
	trace_path = g_strdup (filename);

/*       g_printerr ("%d : opening trace \"%s\"\n", rk, trace_path); */

      _trace_file = fopen (trace_path, "w");

      g_free (trace_path);

      _trace_comm_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
						NULL, g_free);

      g_get_current_time (&now);
      _timer = g_timer_new ();

      g_fprintf (_trace_file, "opening processor %d: %ld %ld\n", rk, now.tv_sec, now.tv_usec);

      _trace_comm_id (MPI_COMM_WORLD);
      _trace_comm_id (MPI_COMM_SELF);

      g_atexit (_trace_atexit);
    }
}
Ejemplo n.º 28
0
void s_test_write_xml_result( struct STest* stest ) {
	FILE* fdis = g_fopen( test_result_fname, "w" );
	if( fdis == NULL ) {
		// TODO Error handling
		return;
	}

	// Print beginning of report
	g_fprintf( fdis, "%s%s", XMLDEC, START_TESTSUITES );

	for( GSList* group_iter = stest->groups; group_iter; group_iter = group_iter->next ) {
		struct TestGroup* c_group = (struct TestGroup*)group_iter->data;
		
		// Print test suite header
		g_fprintf( fdis, START_TESTSUITE, c_group->name, c_group->stat.tests, 0,
				c_group->stat.failures, c_group->stat.time, "" );

		for( GSList* test_iter = c_group->tests; test_iter; test_iter = test_iter->next ) {
			struct Test* c_test = (struct Test*)test_iter->data;

			// print test case header
			g_fprintf( fdis, START_TEST, c_test->name, c_group->name, c_test->name, c_test->result.time );

			// Show failure
			if( ! c_test->result.passed ) {
				g_fprintf( fdis, START_FAILURE, "Assert failed", "" );

				for( GSList* msg_iter = c_test->result.msgs; msg_iter; msg_iter = msg_iter->next ) {
					g_fprintf( fdis, "%s\n", (gchar*)msg_iter->data );
				}

				g_fprintf( fdis, "%s", END_FAILURE );
			}

			g_fprintf( fdis, "%s", END_TEST );
		}

		g_fprintf( fdis, "%s", END_TESTSUITE );
	}
	g_fprintf( fdis, "%s", END_TESTSUITES );

	fclose( fdis );
}
Ejemplo n.º 29
0
static void
print_reference (gpointer item, gpointer user_data)
{
	gchar *shortname, *id;
	FILE *f = (FILE *)user_data;

	shortname = qname_to_shortname ((gchar *) item);
        id = shortname_to_id (shortname);

	g_fprintf (f,"<link linkend='%s'>%s</link>, ", id , shortname);

	g_free (shortname);
	g_free (id);
}
Ejemplo n.º 30
0
/**
 * aran_wigner_write:
 * @aw: an #AranWigner structure.
 * @file: output file.
 *
 * Writes @aw to @file.
 */
void aran_wigner_write (AranWigner * aw, FILE * file)
{
  gint i, j, k;

  g_return_if_fail (aw != NULL);

  g_fprintf (file, "[");

  for (i = 0; i <= aw->lmax; i++)
    {
      for (j = 0; j <= i; j++)
        {
          for (k = -i; k <= i; k++)
            {
              g_fprintf (file, "[%d,%d,%d]=%g ", i, j, k,
                         *aran_wigner_term (aw, i, j, k));
            }
        }
    }

  g_fprintf (file, "]");

}