Esempio n. 1
0
static void log_add_full_v(logtype_t typ, char *pname, char *format, va_list argp)
{
    char *leader = NULL;
    char *xlated_fmt = gettext(format);
    char linebuf[STR_SIZE];
    size_t n;
    static gboolean in_log_add = 0;

    /* avoid recursion */
    if (in_log_add)
	return;

    /* format error message */

    if((int)typ <= (int)L_BOGUS || (int)typ > (int)L_MARKER) typ = L_BOGUS;

    if(multiline > 0) {
	leader = g_strdup("  ");		/* continuation line */
    } else {
	leader = g_strjoin(NULL, logtype_str[(int)typ], " ", pname, " ", NULL);
    }

    /* use sizeof(linebuf)-2 to save space for a trailing newline */
    g_vsnprintf(linebuf, sizeof(linebuf)-2, xlated_fmt, argp);
						/* -1 to allow for '\n' */

    /* avoid recursive call from error() */

    in_log_add = 1;

    /* append message to the log file */

    if(multiline == -1) open_log();

    if (full_write(logfd, leader, strlen(leader)) < strlen(leader)) {
	error(_("log file write error: %s"), strerror(errno));
	/*NOTREACHED*/
    }

    amfree(leader);

    /* add a newline if necessary */
    n = strlen(linebuf);
    if(n == 0 || linebuf[n-1] != '\n') linebuf[n++] = '\n';
    linebuf[n] = '\0';

    if (full_write(logfd, linebuf, n) < n) {
	error(_("log file write error: %s"), strerror(errno));
	/*NOTREACHED*/
    }

    if(multiline != -1) multiline++;
    else close_log();

    in_log_add = 0;
}
Esempio n. 2
0
char *
getindex_sorted_gz_fname(
    char *	host,
    char *	disk,
    char *	date,
    int		level)
{
  char *conf_indexdir;
  char *buf;
  char level_str[NUM_STR_SIZE];
  char datebuf[14 + 1];
  char *dc = NULL;
  char *pc;
  int ch;

  if (date != NULL) {
    dc = date;
    pc = datebuf;
    while (pc < datebuf + sizeof(datebuf)) {
      ch = *dc++;
      *pc++ = (char)ch;
      if (ch == '\0') {
        break;
      } else if (! isdigit (ch)) {
        pc--;
      }
    }
    datebuf[sizeof(datebuf)-1] = '\0';
    dc = datebuf;

    g_snprintf(level_str, sizeof(level_str), "%d", level);
  }

  host = sanitise_filename(host);
  if (disk != NULL) {
    disk = sanitise_filename(disk);
  }

  conf_indexdir = config_dir_relative(getconf_str(CNF_INDEXDIR));
  /*
   * Note: g_strjoin(NULL, ) will stop at the first NULL, which might be
   * "disk" or "dc" (datebuf) rather than the full file name.
   */
  buf = g_strjoin(NULL, conf_indexdir, "/",
		  host, "/",
		  disk, "/",
		  dc, "_",
		  level_str, "-sorted", COMPRESS_SUFFIX,
		  NULL);

  amfree(conf_indexdir);
  amfree(host);
  amfree(disk);

  return buf;
}
Esempio n. 3
0
void
cd_glob(
    char *	glob)
{
    char *regex;
    char *regex_path;
    char *s;
    char *uqglob;

    char *path_on_disk = NULL;

    if (disk_name == NULL) {
	g_printf(_("Must select disk before changing directory\n"));
	return;
    }

    uqglob = unquote_string(glob);
    regex = glob_to_regex(uqglob);
    dbprintf(_("cd_glob (%s) -> %s\n"), uqglob, regex);
    if ((s = validate_regexp(regex)) != NULL) {
        g_printf(_("\"%s\" is not a valid shell wildcard pattern: "), glob);
        puts(s);
	amfree(regex);
	amfree(uqglob);
        return;
    }
    /*
     * glob_to_regex() anchors the beginning of the pattern with ^,
     * but we will be tacking it onto the end of the current directory
     * in add_file, so strip that off.  Also, it anchors the end with
     * $, but we need to match a trailing /, add it if it is not there
     */
    regex_path = g_strdup(regex + 1);
    amfree(regex);
    if(regex_path[strlen(regex_path) - 2] != '/' ) {
	regex_path[strlen(regex_path) - 1] = '\0';
	strappend(regex_path, "/$");
    }

    /* convert path (assumed in cwd) to one on disk */
    if (g_str_equal(disk_path, "/"))
        path_on_disk = g_strconcat("/", regex_path, NULL);
    else {
        char *clean_disk_path = clean_regex(disk_path, 0);
        path_on_disk = g_strjoin(NULL, clean_disk_path, "/", regex_path, NULL);
        amfree(clean_disk_path);
    }

    cd_dir(path_on_disk, uqglob);

    amfree(regex_path);
    amfree(path_on_disk);
    amfree(uqglob);
}
Esempio n. 4
0
void
gw_window_save_size (GwWindow *window)
{
    GwWindowPrivate *priv;
    GwApplication *application;
    LwPreferences *preferences;
    gchar buffer[500];
    gchar *new_buffer;
    gchar **atoms;
    gchar *atom;
    gchar **ptr;
    const gchar *NAME;

    priv = window->priv;
    application = gw_window_get_application (window);
    preferences = gw_application_get_preferences (application);
    new_buffer = NULL;
    NAME = G_OBJECT_TYPE_NAME (window);

    atom = g_strdup_printf ("%s:%d,%d", NAME, priv->width, priv->height);
    if (atom != NULL)  //Atom is sometimes freed as part of g_strfreev!
    {
      lw_preferences_get_string_by_schema (preferences, buffer, LW_SCHEMA_BASE, LW_KEY_WINDOW_SIZE, 500);
      atoms = g_strsplit (buffer, ";", -1);
      if (atoms != NULL)
      {
        ptr = atoms;
        while (*ptr != NULL && strncmp(*ptr, NAME, strlen(NAME)) != 0) ptr++;

        if (*ptr != NULL)
        {
          g_free (*ptr);
          *ptr = atom;
          new_buffer = g_strjoinv (";", atoms);
        }
        else
        {
          if (*buffer != '\0')
            new_buffer = g_strjoin (";", buffer, atom, NULL);
          else
            new_buffer = g_strdup (atom);
          g_free (atom); atom = NULL;
        }
        g_strfreev (atoms); atoms = NULL;
      }
    }

    //set our new buffer to the prefs
    if (new_buffer != NULL)
    {
      lw_preferences_set_string_by_schema (preferences, LW_SCHEMA_BASE, LW_KEY_WINDOW_SIZE, new_buffer);
      g_free (new_buffer); new_buffer = NULL;
    }
}
static gboolean
gst_neonhttp_src_set_location (GstNeonhttpSrc * src, const gchar * uri,
                               GError ** err)
{
    ne_uri_free (&src->uri);
    if (src->location) {
        ne_free (src->location);
        src->location = NULL;
    }
    if (src->query_string) {
        ne_free (src->query_string);
        src->query_string = NULL;
    }

    if (ne_uri_parse (uri, &src->uri) != 0)
        goto parse_error;

    if (src->uri.scheme == NULL)
        src->uri.scheme = g_strdup ("http");

    if (src->uri.host == NULL)
        src->uri.host = g_strdup (DEFAULT_LOCATION);

    if (src->uri.port == 0) {
        if (!strcmp (src->uri.scheme, "https"))
            src->uri.port = HTTPS_DEFAULT_PORT;
        else
            src->uri.port = HTTP_DEFAULT_PORT;
    }

    if (!src->uri.path)
        src->uri.path = g_strdup ("");

    src->query_string = g_strjoin ("?", src->uri.path, src->uri.query, NULL);

    src->location = ne_uri_unparse (&src->uri);

    return TRUE;

    /* ERRORS */
parse_error:
    {
        if (src->location) {
            ne_free (src->location);
            src->location = NULL;
        }
        if (src->query_string) {
            ne_free (src->query_string);
            src->query_string = NULL;
        }
        ne_uri_free (&src->uri);
        return FALSE;
    }
}
Esempio n. 6
0
/** Sets $environ[$key] to the absolute path to $fname. */
void checkmore_set_absolute_env(const gchar *key, const gchar *fname)
{
	gchar *cwd, *path;

	cwd = g_get_current_dir();
	path = g_strjoin(cwd, "/", fname, NULL);
	if (!g_setenv(key, path, 0))
		g_error("g_setenv(): %m");
	g_free(path);
	g_free(cwd);
}
Esempio n. 7
0
/**
 * zif_package_id_build:
 * @name: The package name, e.g. "hal"
 * @version: The package version, e.g. "1.0.0-fc14"
 * @arch: The package architecture, e.g. "i386"
 * @data: The package data, typically the repo name, or "installed"
 *
 * Formats a PackageId structure.
 *
 * Return value: A PackageId value, or %NULL if invalid
 *
 * Since: 0.2.4
 **/
gchar *
zif_package_id_build (const gchar *name, const gchar *version,
		      const gchar *arch, const gchar *data)
{
	g_return_val_if_fail (name != NULL, NULL);
	return g_strjoin (";", name,
			  version != NULL ? version : "",
			  arch != NULL ? arch : "",
			  data != NULL ? data : "",
			  NULL);
}
Esempio n. 8
0
File: main.c Progetto: jcape/gnoMint
void __recent_add_utf8_filename (const gchar *utf8_filename)
{
        GtkRecentData *recent_data;
        gchar         *filename;
        gchar         *uri;
	gchar         *pwd;

        static gchar *groups[2] = {
                "gnomint",
                NULL
        };


        recent_data = g_slice_new (GtkRecentData);

        recent_data->display_name = NULL;
        recent_data->description  = NULL;
        recent_data->mime_type    = GNOMINT_MIME_TYPE;
        recent_data->app_name     = (gchar *) g_get_application_name ();
        recent_data->app_exec     = g_strjoin (" ", g_get_prgname (), "%f", NULL);
        recent_data->groups       = groups;
        recent_data->is_private = FALSE;

        filename = g_filename_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
        if ( filename != NULL )
        {

		if (! g_path_is_absolute (filename)) {
			gchar *absolute_filename;

			pwd = g_get_current_dir ();
			absolute_filename = g_build_filename (pwd, filename, NULL);
			g_free (pwd);
			g_free (filename);
			filename = absolute_filename;
		}


                uri = g_filename_to_uri (filename, NULL, NULL);
                if ( uri != NULL )
                {

                        gtk_recent_manager_add_full (recent_manager, uri, recent_data);
                        g_free (uri);

                }
                g_free (filename);

        }

        g_free (recent_data->app_exec);
        g_slice_free (GtkRecentData, recent_data);

}
Esempio n. 9
0
static FILE *
open_txinfofile(
    char *	host,
    char *	disk,
    char *	mode)
{
    FILE *infof;
    char *myhost;
    char *mydisk;

    assert(infofile == (char *)0);

    writing = (*mode == 'w');

    myhost = sanitise_filename(host);
    mydisk = sanitise_filename(disk);

    infofile = g_strjoin(NULL, infodir,
			 "/", myhost,
			 "/", mydisk,
			 "/info",
			 NULL);

    amfree(myhost);
    amfree(mydisk);

    /* create the directory structure if in write mode */
    if (writing) {
        if (mkpdir(infofile, 0755, (uid_t)-1, (gid_t)-1) == -1) {
	    amfree(infofile);
	    return NULL;
	}
    }

    newinfofile = g_strconcat(infofile, ".new", NULL);

    if(writing) {
	infof = fopen(newinfofile, mode);
	if(infof != NULL)
	    amflock(fileno(infof), "info");
    }
    else {
	infof = fopen(infofile, mode);
	/* no need to lock readers */
    }

    if(infof == (FILE *)0) {
	amfree(infofile);
	amfree(newinfofile);
	return NULL;
    }

    return infof;
}
Esempio n. 10
0
GimpPDBStatusType
screenshot_osx_shoot (ScreenshotValues *shootvals,
                      GdkScreen        *screen,
                      gint32           *image_ID)
{
  gchar *mode    = " ";
  gchar *delay   = NULL;
  gchar *cursor  = " ";
  gchar *command = NULL;

  switch (shootvals->shoot_type)
    {
    case SHOOT_REGION:
      mode = "-is";
      break;

    case SHOOT_WINDOW:
      mode = "-iwo";
      if (shootvals->decorate)
        mode = "-iw";
      break;

    case SHOOT_ROOT:
      mode = " ";
      break;

    default:
      break;
    }

  delay = g_strdup_printf ("-T %i", shootvals->select_delay);

  if (shootvals->show_cursor)
    cursor = "-C";

  command = g_strjoin (" ",
                       "/usr/sbin/screencapture",
                       mode,
                       cursor,
                       delay,
                       "/tmp/screenshot.png",
                       NULL);

  system ((const char *) command);

  g_free (command);
  g_free (delay);

  *image_ID = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
                              "/tmp/screenshot.png", "/tmp/screenshot.png");
  gimp_image_set_filename (*image_ID, "screenshot.png");

  return GIMP_PDB_SUCCESS;
}
Esempio n. 11
0
static void update_ms_header (MenuStart *menu, gchar *title, gchar *stock_id)
{
	gchar *markup;

	markup = g_strjoin (NULL, "<big><b>", title, "</b></big>", NULL);

	gtk_label_set_markup (GTK_LABEL (menu->title), markup);
	gtk_image_set_from_stock (GTK_IMAGE (menu->menu_image), stock_id,
				  GTK_ICON_SIZE_LARGE_TOOLBAR);

	g_free (markup);
}
Esempio n. 12
0
GSList * i_backend_list_lookup( void )
{
    GDir * backend_directory;
    GSList * backend_list = NULL;

    backend_directory = g_dir_open( AMIDIPLUGBACKENDDIR , 0 , NULL );
    if ( backend_directory != NULL )
    {
        const gchar * backend_directory_entry = g_dir_read_name( backend_directory );
        while ( backend_directory_entry != NULL )
        {
            /* simple filename checking */
            if ( i_str_has_pref_and_suff( backend_directory_entry , "ap-" , ".so" ) == TRUE )
            {
                GModule * module;
                gchar * (*getapmoduleinfo)( gchar ** , gchar ** , gchar ** , gint * );
                gchar * module_pathfilename = g_strjoin( "" , AMIDIPLUGBACKENDDIR , "/" ,
                                              backend_directory_entry , NULL );
                /* seems to be a backend for amidi-plug , try to load it */
                module = g_module_open( module_pathfilename , G_MODULE_BIND_LOCAL );
                if ( module == NULL )
                    g_warning( "Error loading module %s - %s\n" , module_pathfilename , g_module_error() );
                else
                {
                    /* try to get the module name */
                    if ((getapmoduleinfo = get_symbol (module , "backend_info_get")))
                    {
                        /* module name found, ok! add its name and filename to the list */
                        amidiplug_sequencer_backend_name_t * mn = g_malloc(sizeof(amidiplug_sequencer_backend_name_t));
                        /* name and desc dinamically allocated */
                        getapmoduleinfo( &mn->name , &mn->longname , &mn->desc , &mn->ppos );
                        mn->filename = g_strdup(module_pathfilename); /* dinamically allocated */
                        DEBUGMSG( "Backend found and added in list, filename: %s and lname: %s\n" ,
                                  mn->filename, mn->longname );
                        backend_list = g_slist_append( backend_list , mn );
                    }
                    else
                    {
                        /* module name not found, this is not a backend for amidi-plug */
                        g_warning( "File %s is not a backend for amidi-plug!\n" , module_pathfilename );
                    }
                    g_module_close( module );
                }
            }
            backend_directory_entry = g_dir_read_name( backend_directory );
        }
        g_dir_close( backend_directory );
    }
    else
        g_warning( "Unable to open the backend directory %s\n" , AMIDIPLUGBACKENDDIR );

    return backend_list;
}
Esempio n. 13
0
//make sure we don't have file:///
gchar *get_full_command(const gchar *command, const gchar *file)
{
	gchar *fc;
	GRegex *regex;

	regex = g_regex_new("%f", G_REGEX_MULTILINE | G_REGEX_RAW, 0, NULL);

	if (g_regex_match (regex,command,0,0))
	{
		//if using custom complex command, replace %f with filename
		fc = g_strstrip(g_regex_replace_literal(regex, command, -1, 0, get_file_path(file), 0, NULL));
	}
	else
	{
		fc = g_strjoin (" ", command, g_strjoin("", "\"", get_file_path(file), "\"", NULL), NULL);
	}
	
	g_regex_unref(regex);

	return fc;
}
Esempio n. 14
0
/**
 * dnf_package_id_build:
 **/
static gchar *
dnf_package_id_build(const gchar *name,
              const gchar *version,
              const gchar *arch,
              const gchar *data)
{
    return g_strjoin(";", name,
              version != NULL ? version : "",
              arch != NULL ? arch : "",
              data != NULL ? data : "",
              NULL);
}
Esempio n. 15
0
static char *test_object_get_xml (TestObject *self)
{
  char *result, *value, *child;

  value = g_strdup_printf ("%d", self->value);

  if (self->child)
    {
      char *child_xml = test_object_get_xml (self->child);
      child = g_strjoin ("", "<child>", child_xml, "</child>", NULL);
      g_free (child_xml);
    }
  else
    child = g_strdup ("");

  result = g_strjoin ("", "<TestObject><value>", value, "</value>",
			  child, "</TestObject>", NULL);
  g_free (value);
  g_free (child);
  return result;
}
Esempio n. 16
0
static xsltStylesheetPtr
render_load_stylesheet (const gchar *xsltName)
{
	xsltStylesheetPtr	i18n_filter;
	xsltStylesheetPtr	xslt;
	xmlDocPtr		xsltDoc, resDoc;
	gchar			*filename;

	if (!stylesheets)
		render_init ();

	/* try to serve the stylesheet from the cache */
	xslt = (xsltStylesheetPtr)g_hash_table_lookup (stylesheets, xsltName);
	if (xslt)
		return xslt;

	/* or load and translate it... */

	/* 1. load localization stylesheet */
	i18n_filter = xsltParseStylesheetFile (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "xslt" G_DIR_SEPARATOR_S "i18n-filter.xslt");
	if (!i18n_filter) {
		g_warning ("fatal: could not load localization stylesheet!");
		return NULL;
	}

	/* 2. load and localize the rendering stylesheet */
	filename = g_strjoin (NULL, PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "xslt" G_DIR_SEPARATOR_S, xsltName, ".xml", NULL);
	xsltDoc = xmlParseFile (filename);
	if (!xsltDoc)
		g_warning ("fatal: could not load rendering stylesheet (%s)!", xsltName);

	g_free (filename);

	resDoc = xsltApplyStylesheet (i18n_filter, xsltDoc, (const gchar **)langParams->params);
	if (!resDoc)
		g_warning ("fatal: applying localization stylesheet failed (%s)!", xsltName);

	/* Use the following to debug XSLT transformation problems */
	/* xsltSaveResultToFile (stdout, resDoc, i18n_filter); */

	/* 3. create localized rendering stylesheet */
	xslt = xsltParseStylesheetDoc(resDoc);
	if (!xslt)
		g_warning("fatal: could not load rendering stylesheet (%s)!", xsltName);

	xmlFreeDoc (xsltDoc);
	xsltFreeStylesheet (i18n_filter);

	g_hash_table_insert (stylesheets, g_strdup (xsltName), xslt);
	
	return xslt;
}
Esempio n. 17
0
/*called by timed capture [-c seconds] command line option*/
gboolean
Image_capture_timer(gpointer data)
{
    struct ALL_DATA * all_data = (struct ALL_DATA *) data;
    struct GLOBAL *global = all_data->global;
    struct GWIDGET *gwidget = all_data->gwidget;
    struct vdIn *videoIn = all_data->videoIn; 
    
    global->image_picn++;   

	if(global->image_inc > 0)
	{
		/*increment image name */
	    videoIn->ImageFName = incFilename(videoIn->ImageFName, 
    	    global->imgFPath,
    	    global->image_inc);
        
    	if(!global->no_display)
    	{
        	char *message = g_strjoin(" ", _("capturing photo to"), videoIn->ImageFName, NULL);
			gtk_statusbar_pop (GTK_STATUSBAR(gwidget->status_bar), gwidget->status_warning_id);
			gtk_statusbar_push (GTK_STATUSBAR(gwidget->status_bar), gwidget->status_warning_id, message);
			g_free(message);
    	}
    
    	global->image_inc++;
    }
    else
    	videoIn->ImageFName = joinPath(videoIn->ImageFName, global->imgFPath);
    
    videoIn->capImage = TRUE;

    if(global->image_picn >= global->image_npics) 
    {   /*destroy timer*/
        if(!global->no_display)
        {
            //gdk_threads_enter();
            gtk_button_set_label(GTK_BUTTON(gwidget->CapImageButt),_("Cap. Image"));
            set_sensitive_img_contrls(TRUE, gwidget);/*enable image controls*/
            gdk_flush();
            //gdk_threads_leave();
        }
        global->image_timer=0;
        global->image_picn=0;
        //if exit_on_close then shutdown
        if(global->exit_on_close)
            shutd (0, data);
        
        return (FALSE);
    }
    else return (TRUE);/*keep the timer*/
}
Esempio n. 18
0
/**
 * @brief Open a new resource and create a new instance
 *
 * @param inner_path The path, relative to the avroot, for the
 *                   resource
 *
 * @return A new Resource object
 * @retval NULL Error while opening resource
 */
Resource *r_open(const char *inner_path)
{
    Resource *r = NULL;
    const Demuxer *dmx;
    gchar *mrl = g_strjoin ("/",
                            feng_default_vhost->document_root,
                            inner_path,
                            NULL);

    /* Since right now we don't support any non-file-backed file, we
     * can check here if the file exists and if not simply return,
     * rather than passing through all the other code.
     */
    if ( access(mrl, R_OK) != 0 ) {
        xlog(LOG_ERR, "access");
        goto error;
    }

    if ( (dmx = r_find_demuxer(mrl)) == NULL ) {
        xlog(LOG_DBG,
                "[MT] Could not find a valid demuxer for resource %s\n",
                mrl);
        goto error;
    }

    /* From here on, we don't care any more of the doom of the mrl
     * variable, the called functions will save it for use later, or
     * will free it as needed.
     */

    xlog(LOG_DBG, "[MT] registrered demuxer \"%s\" for resource"
                               "\"%s\"\n", dmx->name, mrl);

    switch(dmx->source) {
#ifdef LIVE_STREAMING
        case LIVE_SOURCE:
            r = r_open_hashed(mrl, dmx);
            break;
#endif
        case STORED_SOURCE:
            r = r_open_direct(mrl, dmx);
            break;
        default:
            g_assert_not_reached();
            break;
    }

    return r;
 error:
    g_free(mrl);
    return NULL;
}
Esempio n. 19
0
/**
 * afsql_dd_create_index:
 *
 * This function creates an index for the column specified and returns
 * TRUE to indicate success.
 *
 * NOTE: This function can only be called from the database thread.
 **/
static gboolean
afsql_dd_create_index(AFSqlDestDriver *self, gchar *table, gchar *column)
{
  GString *query_string;
  gboolean success = TRUE;

  query_string = g_string_sized_new(64);

  if (strcmp(self->type, s_oracle) == 0)
    {
      /* NOTE: oracle index indentifier length is max 30 characters
       * so we use the first 30 characters of the table_column md5 hash */
      if ((strlen(table) + strlen(column)) > 25)
        {

#if ENABLE_SSL
          guchar hash[MD5_DIGEST_LENGTH];
          gchar hash_str[31];
          gchar *cat = g_strjoin("_", table, column, NULL);

          MD5((guchar *)cat, strlen(cat), hash);
          g_free(cat);

          format_hex_string(hash, sizeof(hash), hash_str, sizeof(hash_str));
          hash_str[0] = 'i';
          g_string_printf(query_string, "CREATE INDEX %s ON %s (%s)",
              hash_str, table, column);
#else
          msg_warning("The name of the index would be too long for Oracle to handle and OpenSSL was not detected which would be used to generate a shorter name. Please enable SSL support in order to use this combination.",
                      evt_tag_str("table", table),
                      evt_tag_str("column", column),
                      NULL);
#endif
        }
      else
        g_string_printf(query_string, "CREATE INDEX %s_%s_idx ON %s (%s)",
            table, column, table, column);
    }
  else
    g_string_printf(query_string, "CREATE INDEX %s_%s_idx ON %s (%s)",
                    table, column, table, column);
  if (!afsql_dd_run_query(self, query_string->str, FALSE, NULL))
    {
      msg_error("Error adding missing index",
                evt_tag_str("table", table),
                evt_tag_str("column", column),
                NULL);
      success = FALSE;
    }
  g_string_free(query_string, TRUE);
  return success;
}
Esempio n. 20
0
static ip_watched_file_t *
ip_watched_file_new (const gchar *dirname,
                     const gchar *filename)
{
  ip_watched_file_t *file;

  file = g_new0 (ip_watched_file_t, 1);
  file->path = g_strjoin ("/", dirname, filename, NULL);
  file->filename = g_strdup (filename);
  file->wd = -1;

  return file;
}
Esempio n. 21
0
void josm_elemstyles_colorize_node(const style_t *style, node_t *node) {
  node->zoom_max = style->node.zoom_max;
  elemstyle_t *elemstyle = style->elemstyles;

  gboolean somematch = FALSE;
  while(elemstyle) {
    // Rule without conditions matches everything (should it?)
    gboolean match = elemstyle->condition ? TRUE : FALSE;

    // For rule with conditions, if any condition mismatches->rule mismatches
    elemstyle_condition_t *cond;
    for (cond = elemstyle->condition; cond && match; cond = cond->next) {
      if(cond->key) {
        const char *value = osm_node_get_value(node, (char*)cond->key);
        if(!value || (cond->value && strcasecmp(value, (char*)cond->value) != 0))
          match = FALSE;
      } else if(cond->value) {
        if(!osm_node_has_value(node, (char*)cond->value))
          match = FALSE;
      }
    }

    somematch = match ? TRUE : somematch;

    if(match && elemstyle->icon) {
      char *name = g_strjoin("/", "styles", style->icon.path_prefix,
				   elemstyle->icon->filename, NULL);

      /* free old icon if there's one present */
      if(node->icon_buf) {
	icon_free(style->iconP, node->icon_buf);
	node->icon_buf = NULL;
      }

      node->icon_buf = icon_load(style->iconP, name);
      g_free(name);

      if (elemstyle->icon->zoom_max > 0) {
        node->zoom_max = elemstyle->icon->zoom_max;
      }
    }

    elemstyle = elemstyle->next;
  }

  /* clear icon for node if not matched at least one rule and has an icon attached */
  if (!somematch && node->icon_buf) {
    icon_free(style->iconP, node->icon_buf);
    node->icon_buf = NULL;
  }
}
Esempio n. 22
0
File: dialogs.c Progetto: aufau/xqf
void about_dialog (GtkWidget *widget, gpointer data) {
	GtkWidget* aboutwindow = NULL;
	GtkWidget* w = NULL, *w2 = NULL;
	char *intro = _("XQF Game Server Browser");
	char *version = g_strdup_printf(_("Version %s"),XQF_VERSION);

	/* translators can use the copyright symbol instead of (C) */
	char *author = _("Copyright (C) 1998-2002 Roman Pozlevich");
	char *urls = "http://www.linuxgames.com/xqf\n"
		"http://sourceforge.net/projects/xqf\n";
	char *contrib1 = _("Maintainers:");
	char *contrib2 =
		"Thomas Debesse <*****@*****.**>\n"
		"Ludwig Nussel <*****@*****.**>\n"
		"Alex Burger <*****@*****.**>\n"
		"Jordi Mallach <*****@*****.**>\n"
		"Bill Adams <*****@*****.**>\n";
	char *contrib3 = _("Contributors:");
	char *contrib4 = 
		"Jochen Baier <*****@*****.**>\n"
		"Luca Camillo <*****@*****.**>\n";
	char *bugs1 = _("Bug reports and feature requests:");
	char *bugs2 = "http://sourceforge.net/projects/xqf\n"
		"[email protected]\n";

	char *text = NULL;//  dialog_ok (_("About XQF"), "%s", text);
	aboutwindow = create_AboutWindow();

	w2 = load_pixmap(aboutwindow, "splash.png");

	w = gtk_object_get_data(GTK_OBJECT(aboutwindow),"AboutVBox");
	gtk_box_pack_start (GTK_BOX (w), w2, FALSE, FALSE, 0);
	gtk_box_reorder_child(GTK_BOX(w), w2, 0);
	gtk_widget_show(w2);

	w = gtk_object_get_data(GTK_OBJECT(aboutwindow),"AboutLabel");

	text = g_strjoin("\n", intro, version, author, urls, contrib1, contrib2,
			contrib3, contrib4, bugs1, bugs2, NULL);
	g_free(version);

	gtk_label_set_text(GTK_LABEL(w), text);

	g_free(text);

	gtk_window_set_transient_for (GTK_WINDOW (aboutwindow), GTK_WINDOW (top_window()));

	register_window(aboutwindow);

	gtk_widget_show(aboutwindow);
}
Esempio n. 23
0
static void
amstar_selfcheck(
    application_argument_t *argument)
{
    fprintf(stdout, "OK amstar\n");
    if (argument->dle.disk) {
	char *qdisk = quote_string(argument->dle.disk);
	fprintf(stdout, "OK %s\n", qdisk);
	amfree(qdisk);
    }
    if (argument->dle.device) {
	char *qdevice = quote_string(argument->dle.device);
	fprintf(stdout, "OK %s\n", qdevice);
	amfree(qdevice);
    }
    if (star_directory) {
	char *qdirectory = quote_string(star_directory);
	fprintf(stdout, "OK %s\n", qdirectory);
	amfree(qdirectory);
    }

    if (argument->dle.include_list &&
	argument->dle.include_list->nb_element >= 0) {
	fprintf(stdout, "ERROR include-list not supported for backup\n");
    }

    if (!star_path) {
	fprintf(stdout, "ERROR STAR-PATH not defined\n");
    } else {
	check_file(star_path, X_OK);
    }

    if (argument->calcsize) {
	char *calcsize = g_strjoin(NULL, amlibexecdir, "/", "calcsize", NULL);
	check_file(calcsize, X_OK);
	check_suid(calcsize);
	amfree(calcsize);
    }

    {
	char *amandates_file;
	amandates_file = getconf_str(CNF_AMANDATES);
	check_file(amandates_file, R_OK|W_OK);
    }

    set_root_privs(1);
    if (argument->dle.device) {
	check_dir(argument->dle.device, R_OK);
    }
    set_root_privs(0);
}
Esempio n. 24
0
int main (int argc, char *argv[])
{
	PREFS images;															/* Create preferences object */
	gchar *window_name;												/* String to hold window's name */
	gchar *xmlpath;														/* Path to Glade's XML file */
	gchar *iconpath;													/* Path to MESSyFront's icon */

	gtk_init (&argc, &argv);									/* Initialize GTK */
	glade_init ();														/* Initialize Glade */

	/* Create Glade Interface */
	xmlpath = g_strjoin (DIR_SEP, INSTALL_PREFIX, XML_DIRECTORY, XML_FILENAME, NULL);
	images.xml = glade_xml_new (xmlpath, NULL, NULL);
	if (!images.xml)
	{
		g_warning ("MESSYFRONT: Unable to create interface with libglade!");
		exit (EXIT_FAILURE);
	}

	/* Connect homemade signals */
	connect_signals (&images);

	/* Connect Glade-made signals */
	glade_xml_signal_autoconnect (images.xml);

	/* Set window's name and icon */
	window_name = g_strjoin (" ", MESSY_APP_NAME, MESSY_VERSION, NULL);
	change_window_name (&images, window_name);
	iconpath = g_strjoin (DIR_SEP, INSTALL_PREFIX, ICON_PATH, ICON_NAME, NULL);
	change_window_icon (&images, iconpath);

	get_prefs_from_file (&images);						/* Get user's preferences */
	populate_object_from_fields (&images);		/* Initialize object "images" */

	gtk_main ();															/* Start the main event loop */

	return EXIT_SUCCESS;											/* End of story. */
}
Esempio n. 25
0
static s4_t *
xmms_medialib_database_convert (const gchar *database_name,
                                const gchar *indices[])
{
	const gchar *coll_conf, *conv_conf;
	gchar *cmdline, *new_name, *obsolete_name;
	xmms_config_property_t *cfg;
	gint exit_status;
	s4_t *s4;

	cfg = xmms_config_lookup ("collection.directory");
	coll_conf = xmms_config_property_get_string (cfg);

	cfg = xmms_config_lookup ("sqlite2s4.path");
	conv_conf = xmms_config_property_get_string (cfg);

	new_name = xmms_medialib_database_converted_name (database_name);

	cmdline = g_strjoin (" ", conv_conf, database_name,
	                     new_name, coll_conf, NULL);

	xmms_log_info ("Attempting to migrate database to new format.");

	if (!g_spawn_command_line_sync (cmdline, NULL, NULL, &exit_status, NULL) || exit_status) {
		xmms_log_fatal ("Could not run \"%s\", try to run it manually", cmdline);
	}

	g_free (cmdline);

	s4 = s4_open (new_name, indices, 0);
	/* Now we give up */
	if (s4 == NULL) {
		xmms_log_fatal ("Could not open the S4 database");
	}

	xmms_log_info ("Migration successful.");

	/* Move the sqlite database */
	obsolete_name = g_strconcat (database_name, ".obsolete", NULL);
	g_rename (database_name, obsolete_name);
	g_free (obsolete_name);

	/* Update the config path */
	cfg = xmms_config_lookup ("medialib.path");
	xmms_config_property_set_data (cfg, new_name);

	g_free (new_name);

	return s4;
}
Esempio n. 26
0
sip_header*
sip_authentication_header_create(const gchar *response)
{
    gchar      *value;
    gchar start[] = "Digest response=\"";
    gchar end[]   = "\",algorithm=\"SHA1-sess-v4\"";
    sip_header *header;

    value = g_strjoin("", start, response, end, NULL);
    header = sip_header_create("A", value);
    g_free(value);
    
    return header;
}
Esempio n. 27
0
void trex_callback(SoupServer *server, SoupMessage *msg,
	const char *path, GHashTable *query, const char *dest)
{
	SoupMessage *new_msg;
	SoupSession *session;
	char *uri_str;

	struct destination_info *to = malloc(sizeof(struct destination_info));
	to->server = server;
	to->msg = msg;

	session = soup_session_async_new();

	uri_str = soup_uri_to_string(soup_message_get_uri(msg), true);
	/*
	 * TODO Memory Leak :-)
	*/
	uri_str = g_strjoin(NULL, dest, uri_str, NULL);

	g_print("[%p] %s %s HTTP/1.%d\n", msg, msg->method, uri_str,
		soup_message_get_http_version(msg));

	/* build new request */
	new_msg = soup_message_new(msg->method, uri_str);
	soup_message_headers_foreach(msg->request_headers, copy_header,
		new_msg->request_headers);
	soup_message_headers_remove(new_msg->request_headers, "Host");
	if (msg->request_body->length) {
		SoupBuffer *request =
			soup_message_body_flatten(msg->request_body);
		soup_message_body_append_buffer(new_msg->request_body,
			request);
		soup_buffer_free(request);
	}
	soup_message_headers_set_encoding(msg->response_headers,
		SOUP_ENCODING_CHUNKED);

	soup_server_pause_message(server, msg);

	g_signal_connect(new_msg, "got_headers",
		G_CALLBACK(recv_headers), to);
	g_signal_connect(new_msg, "got_chunk",
		G_CALLBACK(recv_chunk), to);

	soup_session_queue_message(session, new_msg, finish_msg, to);

	g_object_ref(msg);

	g_object_unref(session);
}
Esempio n. 28
0
/****************************************************************
 * gnc_ui_qif_account_picker_new_cb
 *
 * This handler is invoked when the user wishes to create a new
 * account.
 ****************************************************************/
void
gnc_ui_qif_account_picker_new_cb(GtkButton * w, gpointer user_data)
{
    QIFAccountPickerDialog * wind = user_data;
    SCM name_setter = scm_c_eval_string("qif-map-entry:set-gnc-name!");
    const gchar *name;
    int response;
    gchar *fullname;
    GtkWidget *dlg, *entry;

    /* Create a dialog to get the new account name. */
    dlg = gtk_message_dialog_new(GTK_WINDOW(wind->dialog),
                                 GTK_DIALOG_DESTROY_WITH_PARENT,
                                 GTK_MESSAGE_QUESTION,
                                 GTK_BUTTONS_OK_CANCEL,
                                 "%s", _("Enter a name for the account"));
    gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_OK);
    entry = gtk_entry_new();
    gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
    gtk_entry_set_max_length(GTK_ENTRY(entry), 250);
    gtk_widget_show(entry);
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dlg)->vbox), entry);

    /* Run the dialog to get the new account name. */
    response = gtk_dialog_run(GTK_DIALOG(dlg));
    name = gtk_entry_get_text(GTK_ENTRY(entry));

    /* Did the user enter a name and click OK? */
    if (response == GTK_RESPONSE_OK && name && *name)
    {
        /* If an account is selected, this will be a new subaccount. */
        if (wind->selected_name && *(wind->selected_name))
            /* We have the short name; determine the full name. */
            fullname = g_strjoin(gnc_get_account_separator_string(),
                                 wind->selected_name, name, (char *)NULL);
        else
            fullname = g_strdup(name);

        /* Save the full name and update the map entry. */
        g_free(wind->selected_name);
        wind->selected_name = fullname;
        scm_call_2(name_setter, wind->map_entry, scm_from_utf8_string(fullname));
    }
    gtk_widget_destroy(dlg);

    /* Refresh the tree display and give it the focus. */
    build_acct_tree(wind, wind->qif_wind);
    gtk_widget_grab_focus(GTK_WIDGET(wind->treeview));
}
Esempio n. 29
0
static Hunhandle*
lw_morphologyengine_hunspell_new_by_locale (const gchar *LOCALE)
{
    gchar **pathlist;
    gchar *path, *dpath, *affpath;
    gchar *locale;
    gint i;
    Hunhandle *handle;

    handle = NULL;

    locale = lw_morphologyengine_hunspell_build_noramalized_locale (LOCALE);
    if (locale != NULL)
    {
      pathlist = lw_morphologyengine_hunspell_get_dictionary_paths ();
      if (pathlist != NULL)
      {
        for (i = 0; handle == NULL && pathlist[i] != NULL; i++)
        {
          path = g_build_filename (pathlist[i], locale, NULL);
          dpath = g_strjoin (".", path, "dic", NULL);
          affpath = g_strjoin (".", path, "aff", NULL);
          if (g_file_test (affpath, G_FILE_TEST_IS_REGULAR) && 
              g_file_test (dpath, G_FILE_TEST_IS_REGULAR))
            handle = Hunspell_create (affpath, dpath);
          if (path != NULL) g_free (path); path = NULL;
          if (dpath != NULL) g_free (dpath); dpath = NULL;
          if (affpath != NULL) g_free (affpath); affpath = NULL;
        }
        g_strfreev (pathlist); pathlist = NULL;
      }
      g_free (locale); locale = NULL;
    }
    
    return handle;
}
Esempio n. 30
0
/* kill a bts process running in background mode */
int kill_background(void)
{
	FILE *fp;				/* FILE handle to open the pid file */
	int fd;					/* file descriptor */
	char *lockfile;			     	/* full path of the PID file */
	pid_t pid = 0;				/* pid from the pid file */
	int ret;

	/* duhet te egzistoj ne rast se thirret bts kur processi eshte i aktivizuem */
	set_globals();

	/* get the full path of the lockfile lockfile. */
	lockfile = g_strjoin(NULL,directory.log_dir,BTS_PATH_SEPARATOR,LOCK_FILE,NULL);

	/* open the lock file */
	if ((fp = fopen(lockfile, "r")) == 0) {
		/* lock file does not exist */
		fprintf(stderr, "Unable to open pid file %s errorno  %d - %s\n",lockfile, errno, strerror(errno));
		return 1;
	}

	/* pull the pid from the file */
	if (fscanf(fp, "%d", (int *)(intptr_t)&pid)!=1) { 
	   fprintf(stderr,"Unable to get the pid!\n");
	}

	/* if we have a valid pid */
	if (pid > 0) {
		/* find file descriptor, unlock and remove file*/
		fd = fileno(fp);
		ret = lockf(fd,F_ULOCK ,0);
		if ( ret == -1){
			fprintf(stderr, "Unable to lock file %s errorno  %d - %s\n",lockfile, errno, strerror(errno));
		}
		if( remove(lockfile ) == -1 ){
        	  	fprintf(stderr, "Error deleting lock file%s\n",lockfile );
		}
		/*  send the signal to kill process */
		kill(pid, SIGTERM);

	}
	else {
		fprintf(stderr,"No valid pid found\n");
	}
	/* close the file handle to the lock file */
	fclose(fp);
	return 0;
}