本文整理汇总了C++中packet_write函数的典型用法代码示例。如果您正苦于以下问题:C++ packet_write函数的具体用法?C++ packet_write怎么用?C++ packet_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了packet_write函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: show_ref
static void show_ref(const char *path, const unsigned char *sha1)
{
if (ref_is_hidden(path))
return;
if (sent_capabilities) {
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
} else {
struct strbuf cap = STRBUF_INIT;
strbuf_addstr(&cap,
"report-status delete-refs side-band-64k quiet");
if (advertise_atomic_push)
strbuf_addstr(&cap, " atomic");
if (prefer_ofs_delta)
strbuf_addstr(&cap, " ofs-delta");
if (push_cert_nonce)
strbuf_addf(&cap, " push-cert=%s", push_cert_nonce);
strbuf_addf(&cap, " agent=%s", git_user_agent_sanitized());
packet_write(1, "%s %s%c%s\n",
sha1_to_hex(sha1), path, 0, cap.buf);
strbuf_release(&cap);
sent_capabilities = 1;
}
}
开发者ID:86joca,项目名称:git,代码行数:25,代码来源:receive-pack.c
示例2: send_ref
static int send_ref(const char *refname, const struct object_id *oid,
int flag, void *cb_data)
{
static const char *capabilities = "multi_ack thin-pack side-band"
" side-band-64k ofs-delta shallow no-progress"
" include-tag multi_ack_detailed";
const char *refname_nons = strip_namespace(refname);
struct object_id peeled;
if (mark_our_ref(refname_nons, refname, oid))
return 0;
if (capabilities) {
struct strbuf symref_info = STRBUF_INIT;
format_symref_info(&symref_info, cb_data);
packet_write(1, "%s %s%c%s%s%s%s%s agent=%s\n",
oid_to_hex(oid), refname_nons,
0, capabilities,
(allow_unadvertised_object_request & ALLOW_TIP_SHA1) ?
" allow-tip-sha1-in-want" : "",
(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1) ?
" allow-reachable-sha1-in-want" : "",
stateless_rpc ? " no-done" : "",
symref_info.buf,
git_user_agent_sanitized());
strbuf_release(&symref_info);
} else {
packet_write(1, "%s %s\n", oid_to_hex(oid), refname_nons);
}
capabilities = NULL;
if (!peel_ref(refname, peeled.hash))
packet_write(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons);
return 0;
}
开发者ID:1tgr,项目名称:git,代码行数:35,代码来源:upload-pack.c
示例3: send_ref
static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
static const char *capabilities = "multi_ack thin-pack side-band"
" side-band-64k ofs-delta shallow no-progress"
" include-tag multi_ack_detailed";
const char *refname_nons = strip_namespace(refname);
unsigned char peeled[20];
if (mark_our_ref(refname, sha1, flag, NULL))
return 0;
if (capabilities) {
struct strbuf symref_info = STRBUF_INIT;
format_symref_info(&symref_info, cb_data);
packet_write(1, "%s %s%c%s%s%s%s agent=%s\n",
sha1_to_hex(sha1), refname_nons,
0, capabilities,
allow_tip_sha1_in_want ? " allow-tip-sha1-in-want" : "",
stateless_rpc ? " no-done" : "",
symref_info.buf,
git_user_agent_sanitized());
strbuf_release(&symref_info);
} else {
packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname_nons);
}
capabilities = NULL;
if (!peel_ref(refname, peeled))
packet_write(1, "%s %s^{}\n", sha1_to_hex(peeled), refname_nons);
return 0;
}
开发者ID:AViscatanius,项目名称:git,代码行数:31,代码来源:upload-pack.c
示例4: send_ref
static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
static const char *capabilities = "multi_ack thin-pack side-band"
" side-band-64k ofs-delta shallow no-progress"
" include-tag multi_ack_detailed";
struct object *o = parse_object(sha1);
if (!o)
die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
if (capabilities)
packet_write(1, "%s %s%c%s%s\n", sha1_to_hex(sha1), refname,
0, capabilities,
stateless_rpc ? " no-done" : "");
else
packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname);
capabilities = NULL;
if (!(o->flags & OUR_REF)) {
o->flags |= OUR_REF;
nr_our_refs++;
}
if (o->type == OBJ_TAG) {
o = deref_tag(o, refname, 0);
if (o)
packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
}
return 0;
}
开发者ID:Wushaowei001,项目名称:omnibus,代码行数:28,代码来源:upload-pack.c
示例5: cmd_upload_archive
int cmd_upload_archive(int argc, const char **argv, const char *prefix)
{
const char *sent_argv[MAX_ARGS];
struct child_process cld = { sent_argv };
cld.out = cld.err = -1;
cld.git_cmd = 1;
if (argc != 2)
usage(upload_archive_usage);
if (!enter_repo(argv[1], 0))
die("'%s' does not appear to be a git repository", argv[1]);
prepare_argv(sent_argv, argv);
if (start_command(&cld)) {
int err = errno;
packet_write(1, "NACK fork failed on the remote side\n");
die("upload-archive: %s", strerror(err));
}
/* parent - read from child, multiplex and send out to fd#1 */
packet_write(1, "ACK\n");
packet_flush(1);
while (1) {
struct pollfd pfd[2];
int status;
pfd[0].fd = cld.out;
pfd[0].events = POLLIN;
pfd[1].fd = cld.err;
pfd[1].events = POLLIN;
if (poll(pfd, 2, -1) < 0) {
if (errno != EINTR) {
error("poll failed resuming: %s",
strerror(errno));
sleep(1);
}
continue;
}
if (pfd[1].revents & POLLIN)
/* Status stream ready */
if (process_input(pfd[1].fd, 2))
continue;
if (pfd[0].revents & POLLIN)
/* Data stream ready */
if (process_input(pfd[0].fd, 1))
continue;
if (waitpid(cld.pid, &status, 0) < 0)
error_clnt("%s", lostchild);
else if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
error_clnt("%s", deadchild);
packet_flush(1);
break;
}
return 0;
}
开发者ID:ericherman,项目名称:git,代码行数:58,代码来源:upload-archive.c
示例6: show_ref
static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
if (!capabilities_to_send)
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
else
packet_write(1, "%s %s%c%s\n",
sha1_to_hex(sha1), path, 0, capabilities_to_send);
capabilities_to_send = NULL;
return 0;
}
开发者ID:AndyA,项目名称:git-andya,代码行数:10,代码来源:builtin-receive-pack.c
示例7: show_ref
static void show_ref(const char *path, const unsigned char *sha1)
{
if (sent_capabilities)
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
else
packet_write(1, "%s %s%c%s%s\n",
sha1_to_hex(sha1), path, 0,
" report-status delete-refs side-band-64k",
prefer_ofs_delta ? " ofs-delta" : "");
sent_capabilities = 1;
}
开发者ID:FerretH5N1,项目名称:git-po,代码行数:11,代码来源:receive-pack.c
示例8: cmd_upload_archive
int cmd_upload_archive(int argc, const char **argv, const char *prefix)
{
struct child_process writer = { argv };
/*
* Set up sideband subprocess.
*
* We (parent) monitor and read from child, sending its fd#1 and fd#2
* multiplexed out to our fd#1. If the child dies, we tell the other
* end over channel #3.
*/
argv[0] = "upload-archive--writer";
writer.out = writer.err = -1;
writer.git_cmd = 1;
if (start_command(&writer)) {
int err = errno;
packet_write(1, "NACK unable to spawn subprocess\n");
die("upload-archive: %s", strerror(err));
}
packet_write(1, "ACK\n");
packet_flush(1);
while (1) {
struct pollfd pfd[2];
pfd[0].fd = writer.out;
pfd[0].events = POLLIN;
pfd[1].fd = writer.err;
pfd[1].events = POLLIN;
if (poll(pfd, 2, -1) < 0) {
if (errno != EINTR) {
error("poll failed resuming: %s",
strerror(errno));
sleep(1);
}
continue;
}
if (pfd[1].revents & POLLIN)
/* Status stream ready */
if (process_input(pfd[1].fd, 2))
continue;
if (pfd[0].revents & POLLIN)
/* Data stream ready */
if (process_input(pfd[0].fd, 1))
continue;
if (finish_command(&writer))
error_clnt("%s", deadchild);
packet_flush(1);
break;
}
return 0;
}
开发者ID:00027jang27,项目名称:git,代码行数:54,代码来源:upload-archive.c
示例9: run_remote_archiver
static int run_remote_archiver(int argc, const char **argv,
const char *remote, const char *exec,
const char *name_hint)
{
char buf[LARGE_PACKET_MAX];
int fd[2], i, len, rv;
struct transport *transport;
struct remote *_remote;
_remote = remote_get(remote);
if (!_remote->url[0])
die(_("git archive: Remote with no URL"));
transport = transport_get(_remote, _remote->url[0]);
transport_connect(transport, "git-upload-archive", exec, fd);
/*
* Inject a fake --format field at the beginning of the
* arguments, with the format inferred from our output
* filename. This way explicit --format options can override
* it.
*/
if (name_hint) {
const char *format = archive_format_from_filename(name_hint);
if (format)
packet_write(fd[1], "argument --format=%s\n", format);
}
for (i = 1; i < argc; i++)
packet_write(fd[1], "argument %s\n", argv[i]);
packet_flush(fd[1]);
len = packet_read_line(fd[0], buf, sizeof(buf));
if (!len)
die(_("git archive: expected ACK/NAK, got EOF"));
if (buf[len-1] == '\n')
buf[--len] = 0;
if (strcmp(buf, "ACK")) {
if (len > 5 && !prefixcmp(buf, "NACK "))
die(_("git archive: NACK %s"), buf + 5);
die(_("git archive: protocol error"));
}
len = packet_read_line(fd[0], buf, sizeof(buf));
if (len)
die(_("git archive: expected a flush"));
/* Now, start reading from fd[0] and spit it out to stdout */
rv = recv_sideband("archive", fd[0], 1);
rv |= transport_disconnect(transport);
return !!rv;
}
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:51,代码来源:archive.c
示例10: report
static void report(const char *unpack_status)
{
struct command *cmd;
packet_write(1, "unpack %s\n",
unpack_status ? unpack_status : "ok");
for (cmd = commands; cmd; cmd = cmd->next) {
if (!cmd->error_string)
packet_write(1, "ok %s\n",
cmd->ref_name);
else
packet_write(1, "ng %s %s\n",
cmd->ref_name, cmd->error_string);
}
packet_flush(1);
}
开发者ID:AndyA,项目名称:git-andya,代码行数:15,代码来源:builtin-receive-pack.c
示例11: show_ref
static void show_ref(const char *path, const unsigned char *sha1)
{
if (ref_is_hidden(path))
return;
if (sent_capabilities)
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
else
packet_write(1, "%s %s%c%s%s agent=%s\n",
sha1_to_hex(sha1), path, 0,
" report-status delete-refs side-band-64k quiet",
prefer_ofs_delta ? " ofs-delta" : "",
git_user_agent_sanitized());
sent_capabilities = 1;
}
开发者ID:BenBergman,项目名称:git,代码行数:15,代码来源:receive-pack.c
示例12: daemon_error
static int daemon_error(const char *dir, const char *msg)
{
if (!informative_errors)
msg = "access denied or repository not exported";
packet_write(1, "ERR %s: %s", msg, dir);
return -1;
}
开发者ID:00027jang27,项目名称:git,代码行数:7,代码来源:daemon.c
示例13: get_info_refs
static void get_info_refs(char *arg)
{
const char *service_name = get_parameter("service");
struct strbuf buf = STRBUF_INIT;
hdr_nocache();
if (service_name) {
const char *argv[] = {NULL /* service name */,
"--stateless-rpc", "--advertise-refs",
".", NULL};
struct rpc_service *svc = select_service(service_name);
strbuf_addf(&buf, "application/x-git-%s-advertisement",
svc->name);
hdr_str(content_type, buf.buf);
end_headers();
packet_write(1, "# service=git-%s\n", svc->name);
packet_flush(1);
argv[0] = svc->name;
run_service(argv);
} else {
select_getanyfile();
for_each_namespaced_ref(show_text_ref, &buf);
send_strbuf("text/plain", &buf);
}
strbuf_release(&buf);
}
开发者ID:120011676,项目名称:git,代码行数:31,代码来源:http-backend.c
示例14: get_common_commits
static int get_common_commits(void)
{
static char line[1000];
unsigned char sha1[20];
char last_hex[41];
save_commit_buffer = 0;
for (;;) {
int len = packet_read_line(0, line, sizeof(line));
reset_timeout();
if (!len) {
if (have_obj.nr == 0 || multi_ack)
packet_write(1, "NAK\n");
if (stateless_rpc)
exit(0);
continue;
}
strip(line, len);
if (!prefixcmp(line, "have ")) {
switch (got_sha1(line+5, sha1)) {
case -1: /* they have what we do not */
if (multi_ack && ok_to_give_up()) {
const char *hex = sha1_to_hex(sha1);
if (multi_ack == 2)
packet_write(1, "ACK %s ready\n", hex);
else
packet_write(1, "ACK %s continue\n", hex);
}
break;
default:
memcpy(last_hex, sha1_to_hex(sha1), 41);
if (multi_ack == 2)
packet_write(1, "ACK %s common\n", last_hex);
else if (multi_ack)
packet_write(1, "ACK %s continue\n", last_hex);
else if (have_obj.nr == 1)
packet_write(1, "ACK %s\n", last_hex);
break;
}
continue;
}
if (!strcmp(line, "done")) {
if (have_obj.nr > 0) {
if (multi_ack)
packet_write(1, "ACK %s\n", last_hex);
return 0;
}
packet_write(1, "NAK\n");
return -1;
}
die("git upload-pack: expected SHA1 list, got '%s'", line);
}
}
开发者ID:meejah,项目名称:git,代码行数:55,代码来源:upload-pack.c
示例15: cmd_send_cache_hash
int cmd_send_cache_hash (SESSION * session)
{
int ret;
struct buf* buf = buf_new();
buf_append_data(buf, session->cache_hash, sizeof (session->cache_hash));
ret = packet_write (session, 0x0f, buf->ptr, buf->len);
DSFYDEBUG ("packet_write() returned %d\n", ret);
buf_free(buf);
return ret;
}
开发者ID:Tsarpf,项目名称:DespotifyWindowsPort,代码行数:12,代码来源:commands.c
示例16: getenv
/*
* Open a connection using Git's native protocol.
*
* The caller is responsible for freeing hostandport, but this function may
* modify it (for example, to truncate it to remove the port part).
*/
static struct child_process *git_connect_git(int fd[2], char *hostandport,
const char *path, const char *prog,
enum protocol_version version,
int flags)
{
struct child_process *conn;
struct strbuf request = STRBUF_INIT;
/*
* Set up virtual host information based on where we will
* connect, unless the user has overridden us in
* the environment.
*/
char *target_host = getenv("GIT_OVERRIDE_VIRTUAL_HOST");
if (target_host)
target_host = xstrdup(target_host);
else
target_host = xstrdup(hostandport);
transport_check_allowed("git");
/*
* These underlying connection commands die() if they
* cannot connect.
*/
if (git_use_proxy(hostandport))
conn = git_proxy_connect(fd, hostandport);
else
conn = git_tcp_connect(fd, hostandport, flags);
/*
* Separate original protocol components prog and path
* from extended host header with a NUL byte.
*
* Note: Do not add any other headers here! Doing so
* will cause older git-daemon servers to crash.
*/
strbuf_addf(&request,
"%s %s%chost=%s%c",
prog, path, 0,
target_host, 0);
/* If using a new version put that stuff here after a second null byte */
if (version > 0) {
strbuf_addch(&request, '\0');
strbuf_addf(&request, "version=%d%c",
version, '\0');
}
packet_write(fd[1], request.buf, request.len);
free(target_host);
strbuf_release(&request);
return conn;
}
开发者ID:alexhenrie,项目名称:git-po,代码行数:59,代码来源:connect.c
示例17: connection_write
/** Returns -1 if there was an error writing.
* Otherwise the number of bytes written is returned */
int connection_write( struct connection * c,
const struct packet * p )
{
uint16_t buff_size = p->size + 4;
unsigned char * buffer = malloc( buff_size );
init_packet( buffer, p->size + 4 );
packet_write( buffer, p );
int16_t nb_bytes = write( c->fd_out, buffer, buff_size );
if ( nb_bytes == -1 ) {
#ifndef EMBEDDED
perror("write");
#endif
return -1;
}
free( buffer );
return nb_bytes;
}
开发者ID:medrimonia,项目名称:ProjetSE,代码行数:19,代码来源:connection.c
示例18: udp_write
static void udp_write(struct dechunkiser_ctx *o, int id, uint8_t *data, int size)
{
int i = 0;
while (i < size) {
int stream, psize;
udp_payload_header_parse(data + i, &psize, &stream);
if (stream > o->ports) {
fprintf(stderr, "Bad stream %d > %d\n", stream, o->ports);
return;
}
packet_write(o->outfd, o->ip, o->port[stream], data + i + UDP_PAYLOAD_HEADER_SIZE, psize);
i += UDP_PAYLOAD_HEADER_SIZE + psize;
}
}
开发者ID:lucabe72,项目名称:GRAPES,代码行数:18,代码来源:output-stream-udp.c
示例19: main
int main(int argc, char *argv[]) {
int fd, opt;
char pktbuf[1500], *iface_name = NULL;
ssize_t len;
while((opt = getopt(argc, argv, "hi:")) != -1) {
switch (opt) {
case 'i':
iface_name = optarg;
break;
case 'h':
default:
usage();
return EXIT_FAILURE;
}
}
if (iface_name == NULL) {
fprintf(stderr, "No interface set\n");
return EXIT_FAILURE;
}
fd = sock_open_raw(iface_name);
if (fd < 0) {
perror("sock_open_raw");
return EXIT_FAILURE;
}
len = packet_read(STDIN_FILENO, pktbuf, sizeof(pktbuf));
if (len < 0) {
perror("packet_read");
return EXIT_FAILURE;
}
close(STDIN_FILENO);
if (packet_write(fd, pktbuf, (size_t)len) != len) {
perror("packet_write");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
开发者ID:sebcat,项目名称:packet,代码行数:43,代码来源:send_link.c
示例20: stream_write
static error_t
stream_write (struct pq *pq, void *source,
char *data, size_t data_len, size_t *amount)
{
struct packet *packet = pq_tail (pq, PACKET_TYPE_DATA, source);
if (packet_readable (packet) > 0
&& data_len > PACKET_SIZE_LARGE
&& (! page_aligned (data - packet->buf_end)
|| ! packet_ensure_efficiently (packet, data_len)))
/* Put a large page-aligned transfer in its own packet, if it's
page-aligned `differently' than the end of the current packet, or if
the current packet can't be extended in place. */
packet = pq_queue (pq, PACKET_TYPE_DATA, source);
if (!packet)
return ENOBUFS;
else
return packet_write (packet, data, data_len, amount);
}
开发者ID:diegonc,项目名称:console-xkb-support,代码行数:20,代码来源:stream.c
注:本文中的packet_write函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论