Пример #1
0
int
verify(const char *const *argv)
{
	struct pkginfo *pkg;
	int rc = 0;

	modstatdb_open(msdbrw_readonly);
	ensure_diversions();

	if (!*argv) {
		struct pkgiterator *it;

		it = pkg_db_iter_new();
		while ((pkg = pkg_db_iter_next_pkg(it)))
			verify_package(pkg);
		pkg_db_iter_free(it);
	} else {
		const char *thisarg;

		while ((thisarg = *argv++)) {
			pkg = dpkg_options_parse_pkgname(cipaction, thisarg);
			if (pkg->status == PKG_STAT_NOTINSTALLED) {
				notice(_("package '%s' is not installed"),
				       pkg_name(pkg, pnaw_nonambig));
				rc = 1;
				continue;
			}

			verify_package(pkg);
		}
	}

	modstatdb_shutdown();

	m_output(stdout, _("<standard output>"));

	return rc;
}
Пример #2
0
static Package *
internal_get_package (const char *name, gboolean warn, gboolean check_compat)
{
  Package *pkg = NULL;
  const char *location;
  
  pkg = g_hash_table_lookup (packages, name);

  if (pkg)
    return pkg;

  debug_spew ("Looking for package '%s'\n", name);
  
  /* treat "name" as a filename if it ends in .pc and exists */
  if ( ends_in_dotpc (name) )
    {
      debug_spew ("Considering '%s' to be a filename rather than a package name\n", name);
      location = name;
    }
  else
    {
      /* See if we should auto-prefer the uninstalled version */
      if (!disable_uninstalled &&
          !name_ends_in_uninstalled (name))
        {
          char *un;

          un = g_strconcat (name, "-uninstalled", NULL);

          pkg = internal_get_package (un, FALSE, FALSE);

          g_free (un);
          
          if (pkg)
            {
              debug_spew ("Preferring uninstalled version of package '%s'\n", name);
              return pkg;
            }
        }
      
      location = g_hash_table_lookup (locations, name);
    }
  
  if (location == NULL && check_compat)
    {
      pkg = get_compat_package (name);

      if (pkg)
        {
          debug_spew ("Returning values for '%s' from a legacy -config script\n",
                      name);
          
          return pkg;
        }
    }
      
  if (location == NULL)
    {
      if (warn)
        verbose_error ("Package %s was not found in the pkg-config search path.\n"
                       "Perhaps you should add the directory containing `%s.pc'\n"
                       "to the PKG_CONFIG_PATH environment variable\n",
                       name, name);

      return NULL;
    }

  debug_spew ("Reading '%s' from file '%s'\n", name, location);
  pkg = parse_package_file (location, ignore_requires, ignore_private_libs);
  
  if (pkg == NULL)
    {
      debug_spew ("Failed to parse '%s'\n", location);
      return NULL;
    }
  
  if (strstr (location, "uninstalled.pc"))
    pkg->uninstalled = TRUE;
  
  if (location != name)
    pkg->key = g_strdup (name);
  else
    {
      /* need to strip package name out of the filename */
      int len = strlen (name);
      const char *end = name + (len - EXT_LEN);
      const char *start = end;

      while (start != name && *start != G_DIR_SEPARATOR)
        --start;

      g_assert (end >= start);
      
      pkg->key = g_strndup (start, end - start);
    }

  pkg->path_position =
    GPOINTER_TO_INT (g_hash_table_lookup (path_positions, pkg->key));

  debug_spew ("Path position of '%s' is %d\n",
              pkg->name, pkg->path_position);
  
  verify_package (pkg);

  debug_spew ("Adding '%s' to list of known packages, returning as package '%s'\n",
              pkg->key, name);
  
  g_hash_table_insert (packages, pkg->key, pkg);

  return pkg;
}
Пример #3
0
int get_rls(const str_t *uri, xcap_query_params_t *xcap_params, 
		const str_t *package, flat_list_t **dst)
{
	char *data = NULL;
	int dsize = 0;
	service_t *service = NULL;
	char *xcap_uri = NULL;
	str_t *filename = NULL;
	int res;

	if (!dst) return RES_INTERNAL_ERR;
	
	/* get basic document */
	xcap_uri = xcap_uri_for_global_document(xcap_doc_rls_services, 
			filename, xcap_params);
	if (!xcap_uri) {
		ERROR_LOG("can't get XCAP uri\n");
		return RES_XCAP_QUERY_ERR;
	}
	
	res = xcap_query(xcap_uri, xcap_params, &data, &dsize);
	if (res != 0) {
		ERROR_LOG("XCAP problems for uri \'%s\'\n", xcap_uri);
		if (data) {
			cds_free(data);
		}
		cds_free(xcap_uri);
		return RES_XCAP_QUERY_ERR;
	}
	cds_free(xcap_uri);
	
	/* parse document as a service element in rls-sources */
	if (parse_service(data, dsize, &service) != 0) {
		ERROR_LOG("Parsing problems!\n");
		if (service) free_service(service);
		if (data) {
			cds_free(data);
		}
		return RES_XCAP_PARSE_ERR;
	}
/*	DEBUG_LOG("%.*s\n", dsize, data);*/
	if (data) cds_free(data);
	
	if (!service) {
		DEBUG_LOG("Empty service!\n");
		return RES_XCAP_QUERY_ERR;
	}

	/* verify the package */
	if (verify_package(service, package) != 0) {
		free_service(service);
		return RES_BAD_EVENT_PACKAGE_ERR;
	}
	
	/* create flat document */
	res = create_flat_list(service, xcap_params, dst);
	if (res != RES_OK) {
		ERROR_LOG("Flat list creation error\n");
		free_service(service);
		free_flat_list(*dst);
		*dst = NULL;
		return res;
	}
	free_service(service);
	
	return RES_OK;
}
Пример #4
0
int get_rls_from_full_doc(const str_t *uri, 
		/* const str_t *filename,  */
		xcap_query_params_t *xcap_params, 
		const str_t *package, flat_list_t **dst)
{
	char *data = NULL;
	int dsize = 0;
	rls_services_t *rls = NULL;
	service_t *service = NULL;
	str_t curi;
	int res;
	char *xcap_uri = NULL;
	str_t *filename = NULL;

	if (!dst) return RES_INTERNAL_ERR;
	

	/* get basic document */
	xcap_uri = xcap_uri_for_global_document(xcap_doc_rls_services, 
			filename, xcap_params);
	if (!xcap_uri) {
		ERROR_LOG("can't get XCAP uri\n");
		return -1;
	}
	
	res = xcap_query(xcap_uri, xcap_params, &data, &dsize);
	if (res != 0) {
		ERROR_LOG("XCAP problems for uri \'%s\'\n", xcap_uri);
		if (data) {
			cds_free(data);
		}
		cds_free(xcap_uri);
		return RES_XCAP_QUERY_ERR;
	}
	cds_free(xcap_uri);
	
	/* parse document as a service element in rls-sources */
	if (parse_rls_services_xml(data, dsize, &rls) != 0) {
		ERROR_LOG("Parsing problems!\n");
		if (rls) free_rls_services(rls);
		if (data) {
			cds_free(data);
		}
		return RES_XCAP_PARSE_ERR;
	}
/*	DEBUG_LOG("%.*s\n", dsize, data);*/
	if (data) cds_free(data);

	/* try to find given service according to uri */
	canonicalize_uri(uri, &curi);
	service = find_service(rls, &curi); 
	if (!service) DEBUG_LOG("Service %.*s not found!\n", FMT_STR(curi));
	str_free_content(&curi);
	
	if (!service) {
		if (rls) free_rls_services(rls);
		return RES_XCAP_QUERY_ERR;
	}

	/* verify the package */
	if (verify_package(service, package) != 0) {
		free_rls_services(rls);
		return RES_BAD_EVENT_PACKAGE_ERR;
	}
	
	/* create flat document */
	res = create_flat_list(service, xcap_params, dst);
	if (res != RES_OK) {
		ERROR_LOG("Flat list creation error\n");
		free_rls_services(rls);
		free_flat_list(*dst);
		*dst = NULL;
		return res;
	}
	free_rls_services(rls);
	
	return RES_OK;
}
Пример #5
0
int
lincity_main (int argc, char *argv[])
{
#if defined (LC_X11)
    char *geometry = NULL;
#endif

#if defined (SVGALIB)
    int q;
    vga_init ();
#endif

#if !defined (WIN32)
    signal (SIGPIPE, SIG_IGN);    /* broken pipes are ignored. */
#endif

    /* Initialize some global variables */
    make_dir_ok_flag = 1;
    main_screen_originx = 1;
    main_screen_originy = 1;
    given_scene[0] = 0;
    quit_flag = network_flag = load_flag = save_flag 
	    = prefs_flag = cheat_flag = monument_bul_flag
	    = river_bul_flag = shanty_bul_flag;
    prefs_drawn_flag = 0;
    kmouse_val = 8;

#ifdef LC_X11
    borderx = 0;
    bordery = 0;
    parse_xargs (argc, argv, &geometry);
#endif

    /* I18n */
    lincity_set_locale ();

    /* Set up the paths to certain files and directories */
    init_path_strings ();

    /* Make sure that things are installed where they should be */
    verify_package ();

    /* Make sure the save directory exists */
    check_savedir ();

    /* Load preferences */
    load_lincityrc ();

#ifndef CS_PROFILE
#ifdef SEED_RAND
    srand (time (0));
#endif
#endif

#ifdef LC_X11
#if defined (commentout)
    borderx = 0;
    bordery = 0;
    parse_xargs (argc, argv, &geometry);
#endif
    Create_Window (geometry);
    pirate_cursor = XCreateFontCursor (display.dpy, XC_pirate);
#elif defined (WIN32)
    /* Deal with all outstanding messages */
    ProcessPendingEvents ();
#else
    parse_args (argc, argv);
    q = vga_setmode (G640x480x256);
    gl_setcontextvga (G640x480x256);
#endif

#if defined (WIN32) || defined (LC_X11)
    initialize_pixmap ();
#endif

    init_fonts ();

#if defined (SKIP_OPENING_SCENE)
    skip_splash_screen = 1;
#endif
    if (!skip_splash_screen) {
	load_start_image ();
    }

#ifdef LC_X11
    unlock_window_size ();
#endif

    Fgl_setfont (8, 8, main_font);
    Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);

    initialize_geometry (&scr);

#if defined (SVGALIB)
    set_vga_mode ();
#endif

    initialize_monthgraph ();
    init_mouse_registry ();
    init_mini_map_mouse ();

#ifdef LC_X11
    x_key_value = 0;
#elif defined (WIN32)
    RefreshScreen ();
#endif
    setcustompalette ();
    draw_background ();
    prog_box (_("Loading the game"), 1);
    init_types ();
    init_modules();
    init_mappoint_array ();
    initialize_tax_rates ();
    prog_box ("", 95);
    mouse_hide_count = 0;
    suppress_ok_buttons = 0;
    prog_box ("", 100);
#ifdef USE_PIXMAPS
    prog_box (_("Creating pixmaps"), 1);
    init_pixmaps ();
    prog_box ("", 100);
#endif
    //draw_normal_mouse (1, 1);
#if defined (LC_X11)
    init_x_mouse ();
#endif
    init_timer_buttons();
    mouse_initialized = 1;
    //set_selected_module (CST_TRACK_LR);
    screen_setup ();

    /* Main loop! */
    client_main_loop ();

#if defined (SVGALIB)
    mouse_close ();
    vga_setmode (TEXT);
#endif

    print_results ();

#if defined (WIN32) || defined (LC_X11)
    free_pixmap ();
#endif

#if defined (WIN32)
    return 0;
#else
    exit (0);
#endif
}