Blame include/git2/signature.h

Packit ae9e2a
/*
Packit ae9e2a
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit ae9e2a
 *
Packit ae9e2a
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit ae9e2a
 * a Linking Exception. For full terms see the included COPYING file.
Packit ae9e2a
 */
Packit ae9e2a
#ifndef INCLUDE_git_signature_h__
Packit ae9e2a
#define INCLUDE_git_signature_h__
Packit ae9e2a
Packit ae9e2a
#include "common.h"
Packit ae9e2a
#include "types.h"
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * @file git2/signature.h
Packit ae9e2a
 * @brief Git signature creation
Packit ae9e2a
 * @defgroup git_signature Git signature creation
Packit ae9e2a
 * @ingroup Git
Packit ae9e2a
 * @{
Packit ae9e2a
 */
Packit ae9e2a
GIT_BEGIN_DECL
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a new action signature.
Packit ae9e2a
 *
Packit ae9e2a
 * Call `git_signature_free()` to free the data.
Packit ae9e2a
 *
Packit ae9e2a
 * Note: angle brackets ('<' and '>') characters are not allowed
Packit ae9e2a
 * to be used in either the `name` or the `email` parameter.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out new signature, in case of error NULL
Packit ae9e2a
 * @param name name of the person
Packit ae9e2a
 * @param email email of the person
Packit ae9e2a
 * @param time time when the action happened
Packit ae9e2a
 * @param offset timezone offset in minutes for the time
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_signature_new(git_signature **out, const char *name, const char *email, git_time_t time, int offset);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a new action signature with a timestamp of 'now'.
Packit ae9e2a
 *
Packit ae9e2a
 * Call `git_signature_free()` to free the data.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out new signature, in case of error NULL
Packit ae9e2a
 * @param name name of the person
Packit ae9e2a
 * @param email email of the person
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_signature_now(git_signature **out, const char *name, const char *email);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a new action signature with default user and now timestamp.
Packit ae9e2a
 *
Packit ae9e2a
 * This looks up the user.name and user.email from the configuration and
Packit ae9e2a
 * uses the current time as the timestamp, and creates a new signature
Packit ae9e2a
 * based on that information.  It will return GIT_ENOTFOUND if either the
Packit ae9e2a
 * user.name or user.email are not set.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out new signature
Packit ae9e2a
 * @param repo repository pointer
Packit ae9e2a
 * @return 0 on success, GIT_ENOTFOUND if config is missing, or error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_signature_default(git_signature **out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a new signature by parsing the given buffer, which is
Packit ae9e2a
 * expected to be in the format "Real Name <email> timestamp tzoffset",
Packit ae9e2a
 * where `timestamp` is the number of seconds since the Unix epoch and
Packit ae9e2a
 * `tzoffset` is the timezone offset in `hhmm` format (note the lack
Packit ae9e2a
 * of a colon separator).
Packit ae9e2a
 *
Packit ae9e2a
 * @param out new signature
Packit ae9e2a
 * @param buf signature string
Packit ae9e2a
 * @return 0 on success, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_signature_from_buffer(git_signature **out, const char *buf);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a copy of an existing signature.  All internal strings are also
Packit ae9e2a
 * duplicated.
Packit ae9e2a
 *
Packit ae9e2a
 * Call `git_signature_free()` to free the data.
Packit ae9e2a
 *
Packit ae9e2a
 * @param dest pointer where to store the copy
Packit ae9e2a
 * @param sig signature to duplicate
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_signature_dup(git_signature **dest, const git_signature *sig);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Free an existing signature.
Packit ae9e2a
 *
Packit ae9e2a
 * Because the signature is not an opaque structure, it is legal to free it
Packit ae9e2a
 * manually, but be sure to free the "name" and "email" strings in addition
Packit ae9e2a
 * to the structure itself.
Packit ae9e2a
 *
Packit ae9e2a
 * @param sig signature to free
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_signature_free(git_signature *sig);
Packit ae9e2a
Packit ae9e2a
/** @} */
Packit ae9e2a
GIT_END_DECL
Packit ae9e2a
#endif