Blame src/ostree/ot-remote-builtin-add-cookie.c

rpm-build 0fba15
/*
rpm-build 0fba15
 * Copyright (C) 2015 Red Hat, Inc.
rpm-build 0fba15
 * Copyright (C) 2016 Sjoerd Simons <sjoerd@luon.net>
rpm-build 0fba15
 *
rpm-build 0fba15
 * SPDX-License-Identifier: LGPL-2.0+
rpm-build 0fba15
 *
rpm-build 0fba15
 * This library is free software; you can redistribute it and/or
rpm-build 0fba15
 * modify it under the terms of the GNU Lesser General Public
rpm-build 0fba15
 * License as published by the Free Software Foundation; either
rpm-build 0fba15
 * version 2 of the License, or (at your option) any later version.
rpm-build 0fba15
 *
rpm-build 0fba15
 * This library is distributed in the hope that it will be useful,
rpm-build 0fba15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 0fba15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 0fba15
 * Lesser General Public License for more details.
rpm-build 0fba15
 *
rpm-build 0fba15
 * You should have received a copy of the GNU Lesser General Public
rpm-build 0fba15
 * License along with this library; if not, write to the
rpm-build 0fba15
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
rpm-build 0fba15
 * Boston, MA 02111-1307, USA.
rpm-build 0fba15
 */
rpm-build 0fba15
rpm-build 0fba15
#include "config.h"
rpm-build 0fba15
rpm-build 0fba15
#include "otutil.h"
rpm-build 0fba15
rpm-build 0fba15
#include "ot-main.h"
rpm-build 0fba15
#include "ot-remote-builtins.h"
rpm-build 0fba15
#include "ostree-repo-private.h"
rpm-build 0fba15
#include "ot-remote-cookie-util.h"
rpm-build 0fba15
rpm-build 0fba15
/* ATTENTION:
rpm-build 0fba15
 * Please remember to update the bash-completion script (bash/ostree) and
rpm-build 0fba15
 * man page (man/ostree-remote.xml) when changing the option list.
rpm-build 0fba15
 */
rpm-build 0fba15
rpm-build 0fba15
static GOptionEntry option_entries[] = {
rpm-build 0fba15
  { NULL }
rpm-build 0fba15
};
rpm-build 0fba15
rpm-build 0fba15
gboolean
rpm-build 0fba15
ot_remote_builtin_add_cookie (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
rpm-build 0fba15
{
rpm-build 0fba15
  g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME VALUE");
rpm-build 0fba15
  g_autoptr(OstreeRepo) repo = NULL;
rpm-build 0fba15
  if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
rpm-build 0fba15
                                    invocation, &repo, cancellable, error))
rpm-build 0fba15
    return FALSE;
rpm-build 0fba15
rpm-build 0fba15
  if (argc < 6)
rpm-build 0fba15
    {
rpm-build 0fba15
      ot_util_usage_error (context, "NAME, DOMAIN, PATH, COOKIE_NAME and VALUE must be specified", error);
rpm-build 0fba15
      return FALSE;
rpm-build 0fba15
    }
rpm-build 0fba15
rpm-build 0fba15
  const char *remote_name = argv[1];
rpm-build 0fba15
  const char *domain = argv[2];
rpm-build 0fba15
  const char *path = argv[3];
rpm-build 0fba15
  const char *cookie_name = argv[4];
rpm-build 0fba15
  const char *value = argv[5];
rpm-build 0fba15
  g_autofree char *cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
rpm-build 0fba15
  if (!ot_add_cookie_at (ostree_repo_get_dfd (repo), cookie_file, domain, path, cookie_name, value, error))
rpm-build 0fba15
    return FALSE;
rpm-build 0fba15
rpm-build 0fba15
  return TRUE;
rpm-build 0fba15
}