예제 #1
0
파일: dump.c 프로젝트: svn2github/irssi
void proxy_outdata(CLIENT_REC *client, const char *data, ...)
{
	va_list args;
	char *str;

	g_return_if_fail(client != NULL);
	g_return_if_fail(data != NULL);

	va_start(args, data);

	str = g_strdup_vprintf(data, args);
	net_transmit(client->handle, str, strlen(str));
	g_free(str);

	va_end(args);
}
예제 #2
0
파일: util.c 프로젝트: PDXostc/navit
gchar *
g_strconcat_printf(gchar *buffer, gchar *fmt, ...)
{
	gchar *str,*ret;
	va_list ap;

	va_start(ap, fmt);
        str=g_strdup_vprintf(fmt, ap);
        va_end(ap);
	if (! buffer)
		return str;
	ret=g_strconcat(buffer, str, NULL);
	g_free(buffer);
	g_free(str);
	return ret;
}
예제 #3
0
static void fail (const char *format, ...)
{
  char *str;

  va_list args;

  va_start (args, format);
  str = g_strdup_vprintf (format, args);
  va_end (args);

  fprintf (stderr, "Error: %s\n", str);

  g_free (str);

  exit (1);
}
예제 #4
0
void add_to_statusbar(camera_parameters_t *camera_params, int enter_threads, const char *psz_format, ...)
{
  va_list args;
  gchar *msg;
  va_start( args, psz_format );
  if(enter_threads)
    gdk_threads_enter();
  gtk_statusbar_pop (GTK_STATUSBAR(camera_params->objects->main_status_bar), 0);
  msg =   g_strdup_vprintf(psz_format,args);
  gtk_statusbar_push (GTK_STATUSBAR(camera_params->objects->main_status_bar), 0, msg);
  g_free (msg);
  if(enter_threads)
    gdk_threads_leave();
  va_end( args );

}
예제 #5
0
void
fb_util_vdebug(FbDebugLevel level, const gchar *format, va_list ap)
{
    const gchar *lstr;
    gchar *str;

    static gboolean debug = FALSE;
    static gboolean setup = FALSE;

    g_return_if_fail(format != NULL);

    if (G_UNLIKELY(!setup)) {
        debug = (g_getenv("BITLBEE_DEBUG") != NULL) ||
                (g_getenv("BITLBEE_DEBUG_FACEBOOK") != NULL);
        setup = TRUE;
    }

    if (!debug) {
        return;
    }

    switch (level) {
    case FB_UTIL_DEBUG_LEVEL_MISC:
        lstr = "MISC";
        break;
    case FB_UTIL_DEBUG_LEVEL_INFO:
        lstr = "INFO";
        break;
    case FB_UTIL_DEBUG_LEVEL_WARN:
        lstr = "WARN";
        break;
    case FB_UTIL_DEBUG_LEVEL_ERROR:
        lstr = "ERROR";
        break;
    case FB_UTIL_DEBUG_LEVEL_FATAL:
        lstr = "FATAL";
        break;

    default:
        g_return_if_reached();
        return;
    }

    str = g_strdup_vprintf(format, ap);
    g_print("[%s] %s: %s\n", lstr, "facebook", str);
    g_free(str);
}
예제 #6
0
/**
 * xfdashboard_notify:
 * @inSender: The sending #ClutterActor or %NULL
 * @inIconName: The icon name to display in notification or %NULL
 * @inFormat: A standard printf() format string for notification text
 * @...: The parameters to insert into the format string
 *
 * Shows a notification with the formatted text as specified in @inFormat
 * and the parameters at the monitor where the sending actor @inSender
 * is placed on.
 *
 * If @inSender is NULL the primary monitor is used.
 *
 * If @inIconName is NULL no icon will be shown in notification.
 */
void xfdashboard_notify(ClutterActor *inSender,
							const gchar *inIconName,
							const gchar *inFormat, ...)
{
	XfdashboardStage					*stage;
	va_list								args;
	gchar								*text;

	g_return_if_fail(inSender==NULL || CLUTTER_IS_ACTOR(inSender));

	stage=NULL;

	/* Build text to display */
	va_start(args, inFormat);
	text=g_strdup_vprintf(inFormat, args);
	va_end(args);

	/* Get stage of sending actor if available */
	if(inSender) stage=XFDASHBOARD_STAGE(clutter_actor_get_stage(inSender));

	/* No sending actor specified or no stage found so get default stage */
	if(!stage)
	{
		XfdashboardCssSelector			*selector;

		/* Traverse through actors to find stage */
		selector=xfdashboard_css_selector_new_from_string("XfdashboardStageInterface");
		xfdashboard_traverse_actor(NULL, selector, _xfdashboard_notify_traverse_callback, &stage);
		g_object_unref(selector);

		/* If we still do not have found a stage to show notification
		 * stop further processing and show notification text as a critical
		 * warning in addition to the critical warning that we could not
		 * find any stage.
		 */
		if(!stage)
		{
			g_critical(_("Could find any stage to show notification: %s"), text);
		}
	}

	/* Show notification on stage (if any found) */
	if(stage) xfdashboard_stage_show_notification(stage, inIconName, text);

	/* Release allocated resources */
	g_free(text);
}
예제 #7
0
/* schreibt auf ein GtkLabel wie mit printf */
gboolean label_printf(GtkWidget *label, const gchar *format, ...)
{
    gchar *text;
    va_list ap;

    va_start(ap, format);
    text = g_strdup_vprintf(format, ap);
    va_end(ap);

    if (text == NULL)
        return FALSE;

    gtk_label_set_text(GTK_LABEL(label), text);
    g_free(text);

    return TRUE;
}
예제 #8
0
/*
 * Push a formatted message referring to the current filter onto the statusbar.
 */
void
statusbar_push_filter_msg(const gchar *msg_format, ...)
{
    va_list ap;
    gchar *msg;

    if (higher_priority_status_level(STATUS_LEVEL_FILTER))
        return;
    status_levels[STATUS_LEVEL_FILTER]++;

    va_start(ap, msg_format);
    msg = g_strdup_vprintf(msg_format, ap);
    va_end(ap);

    gtk_statusbar_push(GTK_STATUSBAR(info_bar), filter_ctx, msg);
    g_free(msg);
}
예제 #9
0
파일: util.c 프로젝트: kjell/libvips
/* Test for file exists.
 */
int
vips_existsf( const char *name, ... )
{
        va_list ap;
	char *path; 
        int result; 

        va_start( ap, name );
	path = g_strdup_vprintf( name, ap ); 
        va_end( ap );

        result = g_access( path, R_OK );

	g_free( path ); 

        return( !result );
}
예제 #10
0
void
liferea_shell_set_status_bar (const char *format, ...)
{
	va_list		args;
	gchar		*text;
	
	if (shell->priv->statusbarLocked)
		return;

	g_return_if_fail (format != NULL);

	va_start (args, format);
	text = g_strdup_vprintf (format, args);
	va_end (args);

	g_idle_add ((GSourceFunc)liferea_shell_set_status_bar_default_cb, (gpointer)text);
}
예제 #11
0
파일: xtrace.c 프로젝트: cdsi/elrond
XUL_APIEXPORT void
xul_trace(xul_t * xul, const gchar * format, ...)
{
        g_assert(XUL_IS_VALID(xul));

        va_list args;

        va_start(args, format);
        gchar *formatted = g_strdup_vprintf(format, args);
        va_end(args);

        gchar *message = g_strdup_printf("MARK: %s: %s", g_get_prgname(), formatted);
        access(message, F_OK);

        g_free(formatted);
        g_free(message);
}
예제 #12
0
void
vivi_decompiler_block_add_warning (ViviDecompilerBlock *block,
    const char *format, ...)
{
  ViviCodeStatement *stmt;
  va_list varargs;
  char *s;

  va_start (varargs, format);
  s = g_strdup_vprintf (format, varargs);
  va_end (varargs);

  stmt = vivi_code_comment_new (s);
  g_printerr ("WARNING: %s\n", s);
  g_free (s);
  vivi_code_block_add_statement (VIVI_CODE_BLOCK (block), stmt);
}
예제 #13
0
파일: chat.c 프로젝트: acieroid/tetristar
void chat_add_colored_text(Chat *chat, const gchar *tagname, const gchar *format, ...)
{
  va_list ap;
  gchar *text;
  GtkTextIter end;
  GtkTextBuffer *buffer;

  va_start(ap, format);
  text = g_strdup_vprintf(format, ap);
  va_end(ap);

  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(chat->text_view));
  gtk_text_buffer_get_end_iter(buffer, &end);
  gtk_text_buffer_insert_with_tags_by_name(buffer, &end, text, -1, tagname, NULL);

  g_free(text);
}
예제 #14
0
파일: ibuserror.c 프로젝트: colorant/ibus
IBusError *
ibus_error_new_from_printf (const gchar *name,
                            const gchar *format_message,
                             ...)
{
    IBusError *error;
    gchar *message;
    va_list va_args;

    va_start (va_args, format_message);
    message = g_strdup_vprintf (format_message, va_args);

    error = ibus_error_new_from_text (name, message);
    g_free (message);

    return error;
}
예제 #15
0
static void 
show_warning_dialog (gchar *mesg,...) 
{
	GtkWidget *dialog;
	char *tmp;
	va_list ap;

	va_start (ap,mesg);
	tmp = g_strdup_vprintf (mesg,ap);
	dialog = gtk_message_dialog_new (NULL,
			0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
			mesg, NULL);
	gtk_dialog_run (GTK_DIALOG (dialog));
	gtk_widget_destroy (dialog);
	g_free (tmp);
	va_end (ap);
}
예제 #16
0
void
eh_exit_on_error( GError* error , const gchar* format , ... )
{
   if ( error )
   {
      gchar* err_s;
      va_list ap;
      va_start( ap , format );

      err_s = g_strdup_vprintf( format , ap );
      eh_error( eh_render_error_str( error , err_s ) );
      eh_exit( EXIT_FAILURE );

      va_end(ap);
      eh_free( err_s );
   }
}
static void
throw_error (GDBusMethodInvocation *context,
             gint                   error_code,
             const gchar           *format,
             ...)
{
        va_list args;
        gchar *message;

        va_start (args, format);
        message = g_strdup_vprintf (format, args);
        va_end (args);

        g_dbus_method_invocation_return_error (context, ERROR, error_code, "%s", message);

        g_free (message);
}
예제 #18
0
void js_fill_exception(JSContextRef ctx,
                       JSValueRef* excp,
                       const char* format,
                       ...)
{
    va_list args;
    va_start (args, format);
    char* str = g_strdup_vprintf(format, args);
    va_end(args);

    JSStringRef string = JSStringCreateWithUTF8CString(str);
    JSValueRef exc_str = JSValueMakeString(ctx, string);
    JSStringRelease(string);
    g_free(str);

    *excp= JSValueToObject(ctx, exc_str, NULL);
}
예제 #19
0
void
gtk_snapshot_push_rounded_clip (GtkSnapshot          *snapshot,
                                const GskRoundedRect *bounds,
                                const char           *name,
                                ...)
{
  GskRoundedRect *real_bounds;
  cairo_region_t *clip;
  cairo_rectangle_int_t rect;
  char *str;

  real_bounds = g_slice_new (GskRoundedRect);
  gsk_rounded_rect_init_copy (real_bounds, bounds);
  gsk_rounded_rect_offset (real_bounds, snapshot->state->translate_x, snapshot->state->translate_y);

  if (name)
    {
      va_list args;

      va_start (args, name);
      str = g_strdup_vprintf (name, args);
      va_end (args);
    }
  else
    str = NULL;
  
  rectangle_init_from_graphene (&rect, &real_bounds->bounds);
  if (snapshot->state->clip_region)
    {
      clip = cairo_region_copy (snapshot->state->clip_region);
      cairo_region_intersect_rectangle (clip, &rect);
    }
  else
    {
      clip = cairo_region_create_rectangle (&rect);
    }
  snapshot->state = gtk_snapshot_state_new (snapshot->state,
                                            str,
                                            clip,
                                            snapshot->state->translate_x,
                                            snapshot->state->translate_y,
                                            gtk_snapshot_collect_rounded_clip,
                                            real_bounds);

  cairo_region_destroy (clip);
}
void
tf_content_sending_failed (TfContent *content,
    const gchar *message_format, ...)
{
  gchar *message;
  va_list valist;

  g_return_if_fail (content != NULL);
  g_return_if_fail (message_format != NULL);

  va_start (valist, message_format);
  message = g_strdup_vprintf (message_format, valist);
  va_end (valist);

  tf_content_sending_failed_literal (content, message);
  g_free (message);
}
예제 #21
0
/**
 * gedit_debug_message:
 * @section: debug section.
 * @file: file name.
 * @line: line number.
 * @function: name of the function that is calling gedit_debug_message().
 * @format: A g_vprintf() format string.
 * @...: The format string arguments.
 *
 * If @section is enabled, then logs the trace information @file, @line, and
 * @function along with the message obtained by formatting @format with the
 * given format string arguments.
 */
void
gedit_debug_message (GeditDebugSection  section,
		     const gchar       *file,
		     gint               line,
		     const gchar       *function,
		     const gchar       *format,
		     ...)
{
	if (G_UNLIKELY (DEBUG_IS_ENABLED (section)))
	{
		va_list args;
		gchar *msg;

#ifdef ENABLE_PROFILING
		gdouble seconds;

		g_return_if_fail (timer != NULL);

		seconds = g_timer_elapsed (timer, NULL);
#endif

		g_return_if_fail (format != NULL);

		va_start (args, format);
		msg = g_strdup_vprintf (format, args);
		va_end (args);

#ifdef ENABLE_PROFILING
		g_print ("[%f (%f)] %s:%d (%s) %s\n",
			 seconds,
			 seconds - last_time,
			 file,
			 line,
			 function,
			 msg);

		last_time = seconds;
#else
		g_print ("%s:%d (%s) %s\n", file, line, function, msg);
#endif

		fflush (stdout);

		g_free (msg);
	}
}
예제 #22
0
void
str_printf (GString * buffer, const char *format, ...)
{
    va_list ap;
    va_start (ap, format);
#if GLIB_CHECK_VERSION (2, 14, 0)
    g_string_append_vprintf (buffer, format, ap);
#else
    {
        gchar *tmp;
        tmp = g_strdup_vprintf (format, ap);
        g_string_append (buffer, tmp);
        g_free (tmp);
    }
#endif
    va_end (ap);
}
예제 #23
0
/**
 * rig_protobuf_c_data_buffer_vprintf:
 * @buffer: the buffer to append to.
 * @format: printf-style format string describing what to append to buffer.
 * @args: values referenced by @format string.
 *
 * Append printf-style content to a buffer, given a va_list.
 */
void     rig_protobuf_c_data_buffer_vprintf             (ProtobufCDataBuffer    *buffer,
					 const char   *format,
					 va_list       args)
{
  gsize size = g_printf_string_upper_bound (format, args);
  if (size < 1024)
    {
      char buf[1024];
      g_vsnprintf (buf, sizeof (buf), format, args);
      rig_protobuf_c_data_buffer_append_string (buffer, buf);
    }
  else
    {
      char *buf = g_strdup_vprintf (format, args);
      rig_protobuf_c_data_buffer_append_foreign (buffer, buf, strlen (buf), g_free, buf);
    }
}
예제 #24
0
파일: error.c 프로젝트: galtgendo/gjiten
void gjiten_print_error_and_wait(const char *fmt, ... ) {
	GtkWidget *dialog;
	va_list args;
	gchar *pstr;

	va_start(args, fmt);
	pstr = g_strdup_vprintf(fmt, args);
	va_end(args);
 
	if (pstr != NULL) {
	  dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR,  GTK_BUTTONS_OK, "%s", pstr );

		gtk_dialog_run(GTK_DIALOG(dialog));
		gtk_widget_destroy(dialog);
	  g_free(pstr);
	}
}
예제 #25
0
파일: libqos.c 프로젝트: stweil/qemu
QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
{
    char *cmdline;

    QOSState *qs = g_new0(QOSState, 1);

    cmdline = g_strdup_vprintf(cmdline_fmt, ap);
    qs->qts = qtest_init(cmdline);
    qs->ops = ops;
    if (ops) {
        qs->alloc = ops->init_allocator(qs->qts, ALLOC_NO_FLAGS);
        qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
    }

    g_free(cmdline);
    return qs;
}
예제 #26
0
void pacman_transaction_tell (PacmanTransaction *transaction, PacmanTransactionStatus status, const gchar *format, ...) {
	va_list args;
	gchar *message;
	
	g_return_if_fail (transaction != NULL);
	g_return_if_fail (status < PACMAN_TRANSACTION_STATUS_LAST);
	
	va_start (args, format);
	message = g_strdup_vprintf (format, args);
	va_end (args);
	
	g_return_if_fail (message != NULL);
	
	g_signal_emit (transaction, transaction_signals[SIGNAL_STATUS], transaction_signal_statuses[status], status, message);
	
	g_free (message);
}
예제 #27
0
static void _dm_log(int level, const char *file, int line, const char *fmt,
                    ...)
{
    va_list ap;
    gchar *msg;

    (void) file;
    (void) line;

    if (level > 4)
        return;
    va_start(ap, fmt);
    msg = g_strdup_vprintf(fmt, ap);
    warn("%s", msg);
    g_free(msg);
    va_end(ap);
}
예제 #28
0
GtkResponseType trace_dialog(GtkWindow *parent, enum trace_dialog_type type,
			     gchar *message, ...)
{
	GtkWidget *dialog;
	GtkMessageType mtype;
	GtkButtonsType btype = GTK_BUTTONS_CLOSE;
	gchar *str;
	va_list ap;
	int result;

	if (!parent)
		parent = GTK_WINDOW(parent_window);

	switch (type) {
	case TRACE_GUI_INFO:
		mtype = GTK_MESSAGE_INFO;
		break;
	case TRACE_GUI_WARNING:
		mtype = GTK_MESSAGE_WARNING;
		break;
	case TRACE_GUI_ERROR:
		mtype = GTK_MESSAGE_ERROR;
		break;
	case TRACE_GUI_ASK:
		mtype = GTK_MESSAGE_WARNING;
		btype = GTK_BUTTONS_YES_NO;
		break;
	}

	va_start(ap, message);
	str = g_strdup_vprintf(message, ap);
	va_end(ap);

	dialog = gtk_message_dialog_new(parent,
					GTK_DIALOG_DESTROY_WITH_PARENT,
					mtype,
					btype,
					"%s", str);
	g_free(str);

	result = gtk_dialog_run(GTK_DIALOG(dialog));

	gtk_widget_destroy(dialog);

	return result;
}
예제 #29
0
static void
my_log(WmfRenderer* renderer, const char* format, ...)
{
    gchar *string;
    va_list args;
  
    g_return_if_fail (format != NULL);
  
    va_start (args, format);
    string = g_strdup_vprintf (format, args);
    va_end (args);

    //fprintf(renderer->file, string);
    g_print("%s", string);

    g_free(string);
}
예제 #30
0
void
_rpmostree_set_prefix_error_from_errno (GError     **error,
                                        gint         errsv,
                                        const char  *format,
                                        ...)
{
  gs_free char *formatted = NULL;
  va_list args;
  
  va_start (args, format);
  formatted = g_strdup_vprintf (format, args);
  va_end (args);
  
  _rpmostree_set_error_from_errno (error, errsv);
  g_prefix_error (error, "%s", formatted);
  errno = errsv;
}