Beispiel #1
0
static void
set_dbm_safety ()
{
  mu_url_t hints = mu_dbm_get_hint ();
  const char *param[] = { "+all" };
  mu_url_add_param (hints, 1, param);
}
Beispiel #2
0
int
main (int argc, char **argv)
{
  int i = 1, rc;
  mu_url_t url = NULL;
  const char *arg;
  
  mu_set_program_name (argv[0]);
  
  if (argc > 1)
    {
      if (strcmp (argv[1], "help") == 0 ||
	  strcmp (argv[1], "--help") == 0 ||
	  strcmp (argv[1], "-h") == 0)
	usage (stdout, 0);

      if (strncmp (argv[1], "url=", 4) == 0)
	{
	  MU_ASSERT (mu_url_create (&url, argv[1] + 4));
	  i = 2;
	}
    }

  if (!url)
    {
      MU_ASSERT (mu_url_create_null (&url));
      i = 1;
    }
  
  for (; i < argc; i++)
    {
      if (strncmp (argv[i], "scheme=", 7) == 0)
	{
	  MU_ASSERT (mu_url_set_scheme (url, strval (argv[i] + 7)));
	}
      else if (strncmp (argv[i], "user="******"path=", 5) == 0)
	{
	  MU_ASSERT (mu_url_set_path (url, strval (argv[i] + 5)));
	}
      else if (strncmp (argv[i], "host=", 5) == 0)
	{
	  MU_ASSERT (mu_url_set_host (url, strval (argv[i] + 5)));
	}
      else if (strncmp (argv[i], "port=", 5) == 0)
	{
	  MU_ASSERT (mu_url_set_port (url, atoi (argv[i] + 5)));
	}
      else if (strncmp (argv[i], "service=", 8) == 0)
	{
	  MU_ASSERT (mu_url_set_service (url, strval (argv[i] + 8)));
	}
      else if (strncmp (argv[i], "auth=", 5) == 0)
	{
	  MU_ASSERT (mu_url_set_auth (url, strval (argv[i] + 5)));
	}
      else if (strncmp (argv[i], "pass="******"param=", 6) == 0)
	{
	  arg = strval (argv[i] + 6);
	  if (arg)
	    MU_ASSERT (mu_url_add_param (url, 1, (const char **)&arg));
	  else
	    MU_ASSERT (mu_url_clear_param (url));
	}
      else if (strncmp (argv[i], "query=", 6) == 0)
	{
	  arg = strval (argv[i] + 6);
	  if (arg)
	    MU_ASSERT (mu_url_add_query (url, 1, (const char **)&arg));
	  else
	    MU_ASSERT (mu_url_clear_query (url));
	}
      else
	{
	  mu_error ("unrecognized argument: %s", argv[i]);
	  return 1;
	}
    }
		       
  rc = mu_url_sget_name (url, &arg);
  if (rc)
    {
      mu_error ("%s", mu_strerror (rc));
      return 1;
    }
  

  printf ("%s\n", arg);
  return 0;
}