push: teach --force-with-lease to smart-http transport
[alt-git.git] / line-range.h
blobae3d0123b447c1c619695c2d0aaf619d1daaa991
1 #ifndef LINE_RANGE_H
2 #define LINE_RANGE_H
4 /*
5 * Parse one item in an -L begin,end option w.r.t. the notional file
6 * object 'cb_data' consisting of 'lines' lines.
8 * The 'nth_line_cb' callback is used to determine the start of the
9 * line 'lno' inside the 'cb_data'. The caller is expected to already
10 * have a suitable map at hand to make this a constant-time lookup.
12 * Returns 0 in case of success and -1 if there was an error. The
13 * actual range is stored in *begin and *end. The counting starts
14 * at 1! In case of error, the caller should show usage message.
17 typedef const char *(*nth_line_fn_t)(void *data, long lno);
19 extern int parse_range_arg(const char *arg,
20 nth_line_fn_t nth_line_cb,
21 void *cb_data, long lines,
22 long *begin, long *end,
23 const char *path);
26 * Scan past a range argument that could be parsed by
27 * 'parse_range_arg', to help the caller determine the start of the
28 * filename in '-L n,m:file' syntax.
30 * Returns a pointer to the first character after the 'n,m' part, or
31 * NULL in case the argument is obviously malformed.
34 extern const char *skip_range_arg(const char *arg);
36 #endif /* LINE_RANGE_H */