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_patch_parse_h__ 8 #define INCLUDE_patch_parse_h__ 9 10 #include "common.h" 11 12 #include "parse.h" 13 #include "patch.h" 14 15 typedef struct { 16 git_refcount rc; 17 18 git_patch_options opts; 19 20 git_parse_ctx parse_ctx; 21 } git_patch_parse_ctx; 22 23 extern git_patch_parse_ctx *git_patch_parse_ctx_init( 24 const char *content, 25 size_t content_len, 26 const git_patch_options *opts); 27 28 extern void git_patch_parse_ctx_free(git_patch_parse_ctx *ctx); 29 30 /** 31 * Create a patch for a single file from the contents of a patch buffer. 32 * 33 * @param out The patch to be created 34 * @param contents The contents of a patch file 35 * @param contents_len The length of the patch file 36 * @param opts The git_patch_options 37 * @return 0 on success, <0 on failure. 38 */ 39 extern int git_patch_from_buffer( 40 git_patch **out, 41 const char *contents, 42 size_t contents_len, 43 const git_patch_options *opts); 44 45 extern int git_patch_parse( 46 git_patch **out, 47 git_patch_parse_ctx *ctx); 48 49 extern int git_patch_parsed_from_diff(git_patch **, git_diff *, size_t); 50 51 #endif 52