deps/libgit2/src/libgit2/parse.h

filter: Statementstmt 100% 2 / 2 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 6 / 6 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« deps/libgit2/src/libgit2/oid.h ↑ Summary deps/libgit2/src/libgit2/reflog.h »
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_parse_h__
8 #define INCLUDE_parse_h__
9  
10 #include "common.h"
11  
12 typedef struct {
13 /* Original content buffer */
14 const char *content;
15 size_t content_len;
16  
17 /* The remaining (unparsed) buffer */
18 const char *remain;
19 size_t remain_len;
20  
21 const char *line;
22 size_t line_len;
23 size_t line_num;
24 } git_parse_ctx;
25  
26 #define GIT_PARSE_CTX_INIT { 0 }
27  
28 int git_parse_ctx_init(git_parse_ctx *ctx, const char *content, size_t content_len);
29 void git_parse_ctx_clear(git_parse_ctx *ctx);
30  
31 #define git_parse_ctx_contains_s(ctx, str) \
32 git_parse_ctx_contains(ctx, str, sizeof(str) - 1)
33  
34 40 GIT_INLINE(bool) git_parse_ctx_contains(
35 git_parse_ctx *ctx, const char *str, size_t len)
36 {
37 40 ▶ return (ctx->line_len >= len && memcmp(ctx->line, str, len) == 0);
Branch: 2 branches
BranchTrueFalseTotal
return (ctx->line_len >= len && memcmp(ctx->line, str, len) == 0); 35 5 40
return (ctx->line_len >= len && memcmp(ctx->line, str, len) == 0); 6 29 35
38 }
39  
40 void git_parse_advance_line(git_parse_ctx *ctx);
41 void git_parse_advance_chars(git_parse_ctx *ctx, size_t char_cnt);
42 int git_parse_advance_expected(
43 git_parse_ctx *ctx,
44 const char *expected,
45 size_t expected_len);
46  
47 #define git_parse_advance_expected_str(ctx, str) \
48 git_parse_advance_expected(ctx, str, strlen(str))
49  
50 int git_parse_advance_ws(git_parse_ctx *ctx);
51 int git_parse_advance_nl(git_parse_ctx *ctx);
52 int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base);
53 int git_parse_advance_oid(git_oid *out, git_parse_ctx *ctx);
54  
55 enum GIT_PARSE_PEEK_FLAGS {
56 GIT_PARSE_PEEK_SKIP_WHITESPACE = (1 << 0)
57 };
58  
59 int git_parse_peek(char *out, git_parse_ctx *ctx, int flags);
60  
61 #endif
« deps/libgit2/src/libgit2/oid.h ↑ Summary deps/libgit2/src/libgit2/reflog.h »