* Initialize the structure. The second parameter can be zero or a bigger
* number to allocate memory, in case you want to prevent further reallocs.
*/
* Initialize the structure. The second parameter can be zero or a bigger
* number to allocate memory, in case you want to prevent further reallocs.
*/
* To clear a strbuf in preparation for further use without the overhead
* of free()ing and malloc()ing again, use strbuf_reset() instead.
*/
* To clear a strbuf in preparation for further use without the overhead
* of free()ing and malloc()ing again, use strbuf_reset() instead.
*/
* The strbuf that previously held the string is reset to `STRBUF_INIT` so
* it can be reused after calling this function.
*/
* The strbuf that previously held the string is reset to `STRBUF_INIT` so
* it can be reused after calling this function.
*/
* malloc()ed, and after attaching, the pointer cannot be relied upon
* anymore, and neither be free()d directly.
*/
* malloc()ed, and after attaching, the pointer cannot be relied upon
* anymore, and neither be free()d directly.
*/
-extern void strbuf_attach(struct strbuf *, void *, size_t, size_t);
+void strbuf_attach(struct strbuf *sb, void *str, size_t len, size_t mem);
-extern void strbuf_trim(struct strbuf *);
-extern void strbuf_rtrim(struct strbuf *);
-extern void strbuf_ltrim(struct strbuf *);
+void strbuf_trim(struct strbuf *sb);
+void strbuf_rtrim(struct strbuf *sb);
+void strbuf_ltrim(struct strbuf *sb);
/**
* Replace the contents of the strbuf with a reencoded form. Returns -1
* on error, 0 on success.
*/
/**
* Replace the contents of the strbuf with a reencoded form. Returns -1
* on error, 0 on success.
*/
/**
* Compare two buffers. Returns an integer less than, equal to, or greater
* than zero if the first buffer is found, respectively, to be less than,
* to match, or be greater than the second buffer.
*/
/**
* Compare two buffers. Returns an integer less than, equal to, or greater
* than zero if the first buffer is found, respectively, to be less than,
* to match, or be greater than the second buffer.
*/
/**
* Insert data to the given position of the buffer. The remaining contents
* will be shifted, not overwritten.
*/
/**
* Insert data to the given position of the buffer. The remaining contents
* will be shifted, not overwritten.
*/
-extern void strbuf_insert(struct strbuf *, size_t pos, const void *, size_t);
+void strbuf_insert(struct strbuf *sb, size_t pos, const void *, size_t);
-extern void strbuf_splice(struct strbuf *, size_t pos, size_t len,
- const void *, size_t);
+void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
+ const void *data, size_t data_len);
/**
* Add a NUL-terminated string to the buffer. Each line will be prepended
* by a comment character and a blank.
*/
/**
* Add a NUL-terminated string to the buffer. Each line will be prepended
* by a comment character and a blank.
*/
-extern void strbuf_add_commented_lines(struct strbuf *out, const char *buf, size_t size);
+void strbuf_add_commented_lines(struct strbuf *out,
+ const char *buf, size_t size);
* parameters to the callback, `strbuf_expand()` passes a context pointer,
* which can be used by the programmer of the callback as she sees fit.
*/
* parameters to the callback, `strbuf_expand()` passes a context pointer,
* which can be used by the programmer of the callback as she sees fit.
*/
-typedef size_t (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
-extern void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn, void *context);
+typedef size_t (*expand_fn_t) (struct strbuf *sb,
+ const char *placeholder,
+ void *context);
+void strbuf_expand(struct strbuf *sb,
+ const char *format,
+ expand_fn_t fn,
+ void *context);
-extern size_t strbuf_expand_dict_cb(struct strbuf *sb, const char *placeholder, void *context);
+size_t strbuf_expand_dict_cb(struct strbuf *sb,
+ const char *placeholder,
+ void *context);
* destination. This is useful for literal data to be fed to either
* strbuf_expand or to the *printf family of functions.
*/
* destination. This is useful for literal data to be fed to either
* strbuf_expand or to the *printf family of functions.
*/
/**
* Add a formatted string to the buffer.
*/
__attribute__((format (printf,2,3)))
/**
* Add a formatted string to the buffer.
*/
__attribute__((format (printf,2,3)))
/**
* Add a formatted string prepended by a comment character and a
* blank to the buffer.
*/
__attribute__((format (printf, 2, 3)))
/**
* Add a formatted string prepended by a comment character and a
* blank to the buffer.
*/
__attribute__((format (printf, 2, 3)))
* `suppress_tz_name`, when set, expands %Z internally to the empty
* string rather than passing it to `strftime`.
*/
* `suppress_tz_name`, when set, expands %Z internally to the empty
* string rather than passing it to `strftime`.
*/
-extern void strbuf_addftime(struct strbuf *sb, const char *fmt,
- const struct tm *tm, int tz_offset,
- int suppress_tz_name);
+void strbuf_addftime(struct strbuf *sb, const char *fmt,
+ const struct tm *tm, int tz_offset,
+ int suppress_tz_name);
* `strbuf_read()`, `strbuf_read_file()` and `strbuf_getline_*()`
* family of functions have the same behaviour as well.
*/
* `strbuf_read()`, `strbuf_read_file()` and `strbuf_getline_*()`
* family of functions have the same behaviour as well.
*/
/**
* Read the contents of a given file descriptor. The third argument can be
* used to give a hint about the file size, to avoid reallocs. If read fails,
* any partial read is undone.
*/
/**
* Read the contents of a given file descriptor. The third argument can be
* used to give a hint about the file size, to avoid reallocs. If read fails,
* any partial read is undone.
*/
* Return the number of bytes read or a negative value if some error
* occurred while opening or reading the file.
*/
* Return the number of bytes read or a negative value if some error
* occurred while opening or reading the file.
*/
/**
* Read the target of a symbolic link, specified by its path. The third
* argument can be used to give a hint about the size, to avoid reallocs.
*/
/**
* Read the target of a symbolic link, specified by its path. The third
* argument can be used to give a hint about the size, to avoid reallocs.
*/
typedef int (*strbuf_getline_fn)(struct strbuf *, FILE *);
/* Uses LF as the line terminator */
typedef int (*strbuf_getline_fn)(struct strbuf *, FILE *);
/* Uses LF as the line terminator */
/**
* Add a path to a buffer, converting a relative path to an
* absolute one in the process. Symbolic links are not
* resolved.
*/
/**
* Add a path to a buffer, converting a relative path to an
* absolute one in the process. Symbolic links are not
* resolved.
*/
* Callers that don't mind links should use the more lightweight
* strbuf_add_absolute_path() instead.
*/
* Callers that don't mind links should use the more lightweight
* strbuf_add_absolute_path() instead.
*/
* normalize_path_copy() for details. If an error occurs, the contents of "sb"
* are left untouched, and -1 is returned.
*/
* normalize_path_copy() for details. If an error occurs, the contents of "sb"
* are left untouched, and -1 is returned.
*/
/**
* Strip whitespace from a buffer. The second parameter controls if
* comments are considered contents to be removed or not.
*/
/**
* Strip whitespace from a buffer. The second parameter controls if
* comments are considered contents to be removed or not.
*/
* For lighter-weight alternatives, see string_list_split() and
* string_list_split_in_place().
*/
* For lighter-weight alternatives, see string_list_split() and
* string_list_split_in_place().
*/
-extern struct strbuf **strbuf_split_buf(const char *, size_t,
- int terminator, int max);
+struct strbuf **strbuf_split_buf(const char *str, size_t len,
+ int terminator, int max);
{
return strbuf_split_buf(sb->buf, sb->len, terminator, max);
}
{
return strbuf_split_buf(sb->buf, sb->len, terminator, max);
}
* 'element1, element2, ..., elementN'
* to str. If only one element, just write "element1" to str.
*/
* 'element1, element2, ..., elementN'
* to str. If only one element, just write "element1" to str.
*/
-extern void strbuf_add_separated_string_list(struct strbuf *str,
- const char *sep,
- struct string_list *slist);
+void strbuf_add_separated_string_list(struct strbuf *str,
+ const char *sep,
+ struct string_list *slist);
/**
* Free a NULL-terminated list of strbufs (for example, the return
* values of the strbuf_split*() functions).
*/
/**
* Free a NULL-terminated list of strbufs (for example, the return
* values of the strbuf_split*() functions).
*/
-extern void strbuf_add_unique_abbrev(struct strbuf *sb,
- const struct object_id *oid,
- int abbrev_len);
+void strbuf_add_unique_abbrev(struct strbuf *sb,
+ const struct object_id *oid,
+ int abbrev_len);
* run in. If the buffer is NULL the editor is launched as usual but the
* file's contents are not read into the buffer upon completion.
*/
* run in. If the buffer is NULL the editor is launched as usual but the
* file's contents are not read into the buffer upon completion.
*/
-extern int launch_editor(const char *path, struct strbuf *buffer, const char *const *env);
+int launch_editor(const char *path,
+ struct strbuf *buffer,
+ const char *const *env);
/**
* Append s to sb, with the characters '<', '>', '&' and '"' converted
* into XML entities.
*/
/**
* Append s to sb, with the characters '<', '>', '&' and '"' converted
* into XML entities.
*/
* If "allowed" is non-zero, restrict the set of allowed expansions. See
* interpret_branch_name() for details.
*/
* If "allowed" is non-zero, restrict the set of allowed expansions. See
* interpret_branch_name() for details.
*/