Blame src/stream.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_stream_h__
Packit ae9e2a
#define INCLUDE_stream_h__
Packit ae9e2a
Packit ae9e2a
#include "common.h"
Packit ae9e2a
#include "git2/sys/stream.h"
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(int) git_stream_connect(git_stream *st)
Packit ae9e2a
{
Packit ae9e2a
	return st->connect(st);
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(int) git_stream_is_encrypted(git_stream *st)
Packit ae9e2a
{
Packit ae9e2a
	return st->encrypted;
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(int) git_stream_certificate(git_cert **out, git_stream *st)
Packit ae9e2a
{
Packit ae9e2a
	if (!st->encrypted) {
Packit ae9e2a
		giterr_set(GITERR_INVALID, "an unencrypted stream does not have a certificate");
Packit ae9e2a
		return -1;
Packit ae9e2a
	}
Packit ae9e2a
Packit ae9e2a
	return st->certificate(out, st);
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(int) git_stream_supports_proxy(git_stream *st)
Packit ae9e2a
{
Packit ae9e2a
	return st->proxy_support;
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(int) git_stream_set_proxy(git_stream *st, const git_proxy_options *proxy_opts)
Packit ae9e2a
{
Packit ae9e2a
	if (!st->proxy_support) {
Packit ae9e2a
		giterr_set(GITERR_INVALID, "proxy not supported on this stream");
Packit ae9e2a
		return -1;
Packit ae9e2a
	}
Packit ae9e2a
Packit ae9e2a
	return st->set_proxy(st, proxy_opts);
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(ssize_t) git_stream_read(git_stream *st, void *data, size_t len)
Packit ae9e2a
{
Packit ae9e2a
	return st->read(st, data, len);
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(ssize_t) git_stream_write(git_stream *st, const char *data, size_t len, int flags)
Packit ae9e2a
{
Packit ae9e2a
	return st->write(st, data, len, flags);
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(int) git_stream_close(git_stream *st)
Packit ae9e2a
{
Packit ae9e2a
	return st->close(st);
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
GIT_INLINE(void) git_stream_free(git_stream *st)
Packit ae9e2a
{
Packit ae9e2a
	if (!st)
Packit ae9e2a
		return;
Packit ae9e2a
Packit ae9e2a
	st->free(st);
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
#endif