예제 #1
0
파일: test-store.c 프로젝트: mvollmer/dpm
void
dump_packages (ss_val file)
{
  ss_val packages = ss_dict_get (file_packages_dict, file);
  int len = packages? ss_len (packages) : 0, i;

  dyn_print ("%r:", file);
  for (i = 0; i < len; i++)
    {
      ss_val pkg = ss_ref (packages, i);
      dyn_print (" %r", pkg);
    }
  dyn_print ("\n");
}
예제 #2
0
void SawaiWave::inner_printState(const pState s, int frame) const {
  switch (int(printmode)) {
  case 0:
    dyn_print(s, frame);
    break;
  case 1:
    stat_print(s, frame);
    break;
  default:
    stat_print(s, frame);
  }
}
예제 #3
0
파일: test-db.c 프로젝트: mvollmer/dpm
void
show (const char *package, const char *version)
{
  if (package)
    {
      dpm_db_open ();
      
      dpm_package pkg = dpm_db_find_package (package);
      dpm_version ver_to_show = NULL;

      if (pkg)
	{
	  ss_val versions = dpm_db_available (pkg);
	  dyn_print ("%r [%d]:", dpm_pkg_name (pkg), dpm_pkg_id (pkg));
	  if (versions)
	    for (int i = 0; i < ss_len (versions); i++)
	      {
		dpm_version ver = ss_ref (versions, i);
		dyn_print (" %r (%r) [%d]",
			   dpm_ver_version (ver),
			   dpm_ver_architecture (ver),
			   dpm_ver_id (ver));
		if (!ver_to_show)
                  {
                    if (version == NULL
                        || ss_equal_blob (dpm_ver_version (ver),
                                          strlen (version), version))
                      ver_to_show = ver;
                  }
	      }
	  dyn_print ("\n");
	}

      if (ver_to_show)
	dpm_db_show_version (ver_to_show);

      dpm_db_done ();
    }
}
예제 #4
0
파일: test-store.c 프로젝트: mvollmer/dpm
void
dump_package_info (ss_val pkg, const char *field)
{
  ss_val info = ss_dict_get (package_info_dict, pkg);
  if (info)
    {
      if (field)
	{
	  ss_val key = intern_soft (field);
	  int n = ss_len (info), i;
	  for (i = 0; i < n; i += 2)
	    {
	      if (ss_ref (info, i) == key)
		dyn_print ("%r\n", ss_ref (info, i+1));
	    }
	}
      else
	{
	  int n = ss_len (info), i;
	  for (i = 0; i < n; i += 2)
	    dyn_print ("%r: %r\n", ss_ref (info, i), ss_ref (info, i+1));
	}
    }
}
예제 #5
0
파일: test-store.c 프로젝트: mvollmer/dpm
void
rem_list (ss_val pkg)
{
  ss_val files = ss_dict_get (package_files_dict, pkg);
  if (files)
    {
      int len = ss_len (files), i;
      for (i = 0; i < len; i++)
	{
	  ss_val file = ss_ref (files, i);
	  ss_dict_del (file_packages_dict, file, pkg);
	}
      dyn_print ("%r: removed %d files\n", pkg, len);
    }

  ss_dict_set (package_files_dict, pkg, NULL);
}
예제 #6
0
파일: test-store.c 프로젝트: mvollmer/dpm
void
set_list (ss_val pkg, char *file)
{
  FILE *f;
  char *line = NULL;
  size_t len = 0;
  ssize_t l;

  int n;
  ss_val lines[10240];
  
  rem_list (pkg);

  if (file == NULL)
    file = dyn_format ("/var/lib/dpkg/info/%.*s.list",
		       ss_len (pkg), ss_blob_start (pkg));

  n = 0;
  f = fopen (file, "r");
  if (f)
    {
      while ((l = getline (&line, &len, f)) != -1)
	{
	  if (l > 0 && line[l-1] == '\n')
	    l -= 1;
	  line[l] = 0;

	  if (n < 10240)
	    {
	      ss_val file = intern (line);
	      lines[n++] = file;
	      ss_dict_add (file_packages_dict, file, pkg);
	    }
	}
      free (line);
      fclose (f);
    }

  dyn_print ("%r: added %d files\n", pkg, n);

  ss_dict_set (package_files_dict, pkg, ss_newv (store, 0, n, lines));
}
예제 #7
0
파일: test-db.c 프로젝트: mvollmer/dpm
static void
info (const char *package)
{
  if (package)
    {
      dpm_db_open ();

      dpm_package pkg = dpm_db_find_package (package);
      
      if (pkg)
	{
	  ss_val versions = dpm_db_available (pkg);
	  dpm_version installed = dpm_db_installed (pkg);
	  int installed_shown = 0;

	  dyn_print ("%r:", dpm_pkg_name (pkg));
	  if (versions)
	    for (int i = 0; i < ss_len (versions); i++)
	      {
		dpm_version ver = ss_ref (versions, i);
		if (ver == installed)
		  {
		    dyn_print (" [%r]", dpm_ver_version (ver));
		    installed_shown = 1;
		  }
		else
		  dyn_print (" %r", dpm_ver_version (ver));

		dyn_foreach (dpm_package_index idx,
			     dpm_db_version_foreach_pkgindex, ver)
		  {
		    dpm_release_index release = dpm_pkgidx_release (idx);
		    if (release)
		      dyn_print (" (%r)", dpm_relidx_dist (release));
		  }
	      }
	  if (!installed_shown && installed)
	    dyn_print (" [%r]", dpm_ver_version (installed));
	  dyn_print ("\n");
	}

      dpm_db_done ();
    }
예제 #8
0
파일: test-store.c 프로젝트: mvollmer/dpm
int
main (int argc, char **argv)
{
  if (argc < 2)
    usage ();

  dyn_begin ();

  if (strcmp (argv[1], "add") == 0)
    {
      init (argv[2], SS_WRITE);

      while (argc > 3)
	{
	  set_list (intern (argv[3]), NULL);
	  argc--;
	  argv++;
	}
      
      ss_tab_dump (table);
      finish (SS_WRITE);
    }
  else if (strcmp (argv[1], "rem") == 0)
    {
      init (argv[2], SS_WRITE);

      while (argc > 3)
	{
	  rem_list (intern (argv[3]));
	  argc--;
	  argv++;
	}
      
      ss_tab_dump (table);
      finish (SS_WRITE);
    }
  else if (strcmp (argv[1], "set-list") == 0)
    {
      init (argv[2], SS_WRITE);

      if (argc > 4)
	set_list (intern (argv[3]), argv[4]);
      
      ss_tab_dump (table);
      finish (SS_WRITE);
    }
  else if (strcmp (argv[1], "list") == 0)
    {
      init (argv[2], SS_READ);

      if (argc > 3)
	{
	  int i;

	  ss_val files = ss_dict_get (package_files_dict,
				      intern_soft (argv[3]));
	  if (files)
	    {
	      for (i = 0; i < ss_len (files); i++)
		{
		  ss_val b = ss_ref (files, i);
		  dyn_print ("%r\n", b);
		}
	    }
	  else
	    printf ("%s not found\n", argv[3]);
	}

      finish (SS_READ);
    }
  else if (strcmp (argv[1], "search") == 0)
    {
      init (argv[2], SS_READ);

      if (argc > 3)
	{
	  ss_val file = intern_soft (argv[3]);
	  if (file && ss_dict_get (file_packages_dict, file))
	    dump_packages (file);
	  else 
	    {
	      dyn_foreach (ss_val blob,
			   ss_tab_foreach, table)
		{
		  grep_blob (blob, argv[3]);
		}
	    }
예제 #9
0
파일: test-store.c 프로젝트: mvollmer/dpm
void
dump_file (ss_val key, ss_val val)
{
  dyn_print ("%r\n", key);
}
예제 #10
0
파일: test-store.c 프로젝트: mvollmer/dpm
void
dump_package (ss_val key, ss_val val)
{
  dyn_print ("%r: %d files\n", key, ss_len (val));
}
예제 #11
0
파일: test-store.c 프로젝트: mvollmer/dpm
void
dump_entry (ss_val key, ss_val val, void *data)
{
  dyn_print ("%r: %r\n", key, val);
}