コード例 #1
0
ファイル: test-line-buffer.c プロジェクト: 1tgr/git
static void handle_command(const char *command, const char *arg, struct line_buffer *buf)
{
	switch (*command) {
	case 'b':
		if (starts_with(command, "binary ")) {
			struct strbuf sb = STRBUF_INIT;
			strbuf_addch(&sb, '>');
			buffer_read_binary(buf, &sb, strtouint32(arg));
			fwrite(sb.buf, 1, sb.len, stdout);
			strbuf_release(&sb);
			return;
		}
	case 'c':
		if (starts_with(command, "copy ")) {
			buffer_copy_bytes(buf, strtouint32(arg));
			return;
		}
	case 's':
		if (starts_with(command, "skip ")) {
			buffer_skip_bytes(buf, strtouint32(arg));
			return;
		}
	default:
		die("unrecognized command: %s", command);
	}
}
コード例 #2
0
ファイル: fast_export.c プロジェクト: MikeBrWade/git
void fast_export_blob(uint32_t mode, uint32_t mark, uint32_t len, struct line_buffer *input)
{
	if (mode == REPO_MODE_LNK) {
		/* svn symlink blobs start with "link " */
		buffer_skip_bytes(input, 5);
		len -= 5;
	}
	printf("blob\nmark :%"PRIu32"\ndata %"PRIu32"\n", mark, len);
	buffer_copy_bytes(input, len);
	fputc('\n', stdout);
}
コード例 #3
0
ファイル: fast_export.c プロジェクト: AndyStricker/git
void fast_export_blob_delta(uint32_t mode,
				uint32_t old_mode, const char *old_data,
				off_t len, struct line_buffer *input)
{
	long postimage_len;

	assert(len >= 0);
	postimage_len = apply_delta(len, input, old_data, old_mode);
	if (mode == REPO_MODE_LNK) {
		buffer_skip_bytes(&postimage, strlen("link "));
		postimage_len -= strlen("link ");
	}
	printf("data %ld\n", postimage_len);
	buffer_copy_bytes(&postimage, postimage_len);
	fputc('\n', stdout);
}
コード例 #4
0
ファイル: fast_export.c プロジェクト: AndyStricker/git
void fast_export_data(uint32_t mode, off_t len, struct line_buffer *input)
{
	assert(len >= 0);
	if (mode == REPO_MODE_LNK) {
		/* svn symlink blobs start with "link " */
		if (len < 5)
			die("invalid dump: symlink too short for \"link\" prefix");
		len -= 5;
		if (buffer_skip_bytes(input, 5) != 5)
			die_short_read(input);
	}
	printf("data %"PRIuMAX"\n", (uintmax_t) len);
	if (buffer_copy_bytes(input, len) != len)
		die_short_read(input);
	fputc('\n', stdout);
}
コード例 #5
0
ファイル: test-line-buffer.c プロジェクト: Barklad/first_app
int main(int argc, char *argv[])
{
	char *s;

	if (argc != 1)
		usage("test-line-buffer < input.txt");
	if (buffer_init(NULL))
		die_errno("open error");
	while ((s = buffer_read_line())) {
		s = buffer_read_string(strtouint32(s));
		fputs(s, stdout);
		fputc('\n', stdout);
		buffer_skip_bytes(1);
		if (!(s = buffer_read_line()))
			break;
		buffer_copy_bytes(strtouint32(s) + 1);
	}
	if (buffer_deinit())
		die("input error");
	if (ferror(stdout))
		die("output error");
	buffer_reset();
	return 0;
}