3#if !defined(ORG_FOSSIL_SCM_FSL_UTIL_H_INCLUDED)
4#define ORG_FOSSIL_SCM_FSL_UTIL_H_INCLUDED
28#if defined(__cplusplus)
178#define fsl_list_empty_m { .list=NULL, .used=0, .capacity=0 }
220#define fsl_finalizer_empty_m {NULL,NULL}
257#define fsl_state_empty_m {NULL,fsl_finalizer_empty_m}
355#define fsl_outputer_empty_m {NULL,NULL,NULL}
375#define fsl_outputer_FILE_m { \
376 .out = fsl_output_f_FILE, \
377 .flush = fsl_flush_f_FILE, \
398typedef void *(*fsl_realloc_f)(
void * state,
void * mem,
fsl_size_t n);
416#define fsl_allocator_empty_m {NULL,NULL}
432 __attribute__ ((malloc))
764#define fsl_buffer_empty_m \
765 {.mem=NULL,.capacity=0U,.used=0U,.cursor=0U,.errCode=0}
796#define fsl_error_empty_m {.msg = fsl_buffer_empty_m, .code = 0}
824 char const * fmt, ... );
830 char const * fmt, va_list args );
910#define fsl_error_move fsl_error_propagate
1231 char const * fmt, ... );
1235 char const * fmt, va_list args );
1528#define fsl_buffer_size(b) (b)->used
1536#define fsl_buffer_capacity(b) (b)->capacity
1744 char const * filename );
1757 char const * fname );
2129 const char *fmt, va_list ap );
2141 __attribute__ ((__format__ (__printf__, 3, 4)))
2287 void * finalizerState );
2401 const char *zOrigName,
2526FSL_EXPORT bool fsl_wd_isfile_or_link(
const char *zFilename);
2659 char const * zNeedle );
2727FSL_EXPORT char * fsl_mbcs_to_utf8(
char const * mbcs);
2827 const char *zPath,
char **zOut);
2980 char *
const * dirs);
3351#define fsl_fstat_empty_m {FSL_FSTAT_TYPE_UNKNOWN,0,0,-1,0}
3383 bool derefSymlinks);
3465 unsigned char const *zOut,
fsl_size_t lenOut,
3466 unsigned char *zDelta,
fsl_size_t * deltaSize);
3546 unsigned char const *zDelta,
fsl_size_t lenDelta,
3547 unsigned char *zOut );
3557 unsigned char const *zDelta,
3559 unsigned char *zOut,
4002#define fsl_dibu_opt_empty_m {\
4054#define fsl_dline_empty_m {NULL,0U,0U,0U,0U,0U,0U}
4062#define fsl_dline_change_max_spans 8
4097#define fsl_dline_change_empty_m { \
4099 {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, \
4100 {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0} \
4258 uint32_t A, uint32_t B,
4259 uint32_t C, uint32_t D);
4459#define fsl_dibu_empty_m { \
4461 NULL,NULL,NULL, NULL, \
4463 NULL, NULL, NULL,NULL, \
4774 const struct tm *timeptr);
4785 char const * format,
4787 bool convertToLocal);
4801 char const * format,
4802 const struct tm *timeptr);
4962#define fsl_pathfinder_empty_m {\
4963 .ext = fsl_list_empty_m, \
4964 .dirs = fsl_list_empty_m, \
4965 .buf = fsl_buffer_empty_m \
5184#define fsl_zip_writer_empty_m { \
5190 fsl_buffer_empty_m, \
5191 fsl_buffer_empty_m, \
5192 fsl_buffer_empty_m, \
5225 char const * zRoot );
5302 char const * zFilename,
5360 char const * filename );
5471#define fsl_timer_empty_m {.user=0,.system=0,.wall=0}
5495 uint64_t * pUser, uint64_t * pSys,
5565#define fsl_timer_scope3(SUFFIX,TGT,BODY) \
5566 fsl_timer _tm ## SUFFIX; \
5567 fsl_timer_start(&_tm ## SUFFIX); \
5569 fsl_timer_add(&_tm ## SUFFIX, TGT)
5576#define fsl_timer_scope(TGT,BODY) \
5577 fsl_timer_scope3(__COUNTER__,TGT,BODY)
5640 unsigned int numberOfSteps,
5641 unsigned int stepNumber);
5727#define fsl_id_bag_empty_m { \
5728 .entryCount = 0, .capacity = 0, \
5729 .used = 0, .list = NULL \
5827#define fsl_id_bag_reset fsl_id_bag_reuse
5863 unsigned int * conflictCount);
5880 bool escapeSquigglies,
6028#define fsl_confirm_response_empty_m {FSL_CRESPONSE_INVALID, -1}
6102#define fsl_confirm_detail_empty_m \
6103 {FSL_CEVENT_INVALID, NULL, NULL}
6122 void * confirmerState);
6145#define fsl_confirmer_empty_m {NULL,NULL}
6271 char const * separator);
6415#if FSL_PLATFORM_IS_WINDOWS
6416# define fsl_path_splitter_empty_m {NULL,NULL,NULL,";"}
6418# define fsl_path_splitter_empty_m {NULL,NULL,NULL,":;"}
6544#define fsl_url_empty_m { \
6545 .raw=0, .scheme=0, .username=0, .password=0, \
6546 .host=0, .port=0, .path=0, .query=0, \
6547 .fragment=0, .impl = {.b=fsl_buffer_empty_m} \
6706 char const **zCursor,
6731 bool reverse,
int stopFlags);
6750#if defined(__cplusplus)
int32_t fsl_id_t
fsl_id_t is a signed integer type used to store database record IDs.
uint64_t fsl_size_t
fsl_size_t is an unsigned integer type used to denote absolute ranges and lengths.
int64_t fsl_time_t
The type used to represent type values.
int64_t fsl_int_t
fsl_int_t is a signed integer type used to denote "relative" ranges and lengths, or to tell a routine...
uint64_t fsl_uint_t
The unsigned counterpart of fsl_int_t.
Holds an allocator function and its related state.
void * state
State intended to be passed as the first argument to this->f().
fsl_realloc_f f
Base allocator function.
A general-purpose buffer class, analog to Fossil's Blob class, but it is not called fsl_blob to avoid...
fsl_size_t cursor
Used by some routines to keep a cursor into this->mem.
int errCode
When any buffer-related routines encounter an error, they set this flag so that the error can be prop...
unsigned char * mem
The raw memory pointed to by this buffer.
fsl_size_t used
Number of "used" bytes in the buffer.
fsl_size_t capacity
Number of bytes allocated for this buffer.
A struct for passing on interactive questions to fsl_confirmer_callback_f implementations.
const char * filename
Depending on the eventId, this might be NULL or might refer to a filename.
const fsl_list * multi
Depending on the eventId, this might be NULL or might refer to a list of details of a type specified ...
fsl_confirm_event_e eventId
The message ID of this confirmation request.
A response for use with the fsl_confirmer API.
fsl_confirm_response_e response
Client response to the current fsl_confirmer question.
uint16_t multipleChoice
If this->response is FSL_CRESPONSE_MULTI then this must be set to the index of the client's multiple-...
A fsl_confirm_callback_f and its callback state, packaged into a neat little struct for easy copy/rep...
void * callbackState
Opaque state pointer for this->callback.
fsl_confirm_callback_f callback
Callback which can be used for basic interactive confirmation purposes, within the very libfossil-cen...
EXPERIMENTAL AND SUBJECT TO CHANGE.
char const * edit
Color escape sequence for edited or replaced lines.
char const * insertion
Color escape sequence for inserted lines.
char const * deletion
Color escape sequence for inserted lines.
char const * reset
Escape sequence to reset colors.
An instance of this class is used to convey certain state to fsl_dibu objects.
unsigned short columnWidth
Maximum column width hint for side-by-side, a.k.a.
const char * hashRHS
The hash of the object represented by the RHS of the diff.
struct fsl_dibu_opt::fsl_dibu_opt_ansi ansiColor
uint32_t diffFlags
Flags from the fsl_diff2_flag_e enum.
const char * nameRHS
The filename of the object represented by the LHS of the diff.
const char * hashLHS
The hash of the object represented by the LHS of the diff.
const char * nameLHS
The filename of the object represented by the LHS of the diff.
fsl_output_f out
Output destination.
unsigned short contextLines
Number of lines of diff context (number of lines common to the LHS and RHS of the diff).
void * outState
State for this->out().
This class is the basis of libfossil's port of the diff engine added to fossil(1) in 2021-09,...
uint32_t fileCount
A place to store the number of files seen by this builder so far, for builders which need to distingu...
uint32_t lnRHS
Number of lines seen of the RHS content.
int(* chunkHeader)(fsl_dibu *, uint32_t A, uint32_t B, uint32_t C, uint32_t D)
If this is not NULL, it is called one time at the start of each chunk of diff for a given file and is...
unsigned int implFlags
Space for implementation-specific flags which clients may set to modify the dibu's behaviour.
void(* finalize)(fsl_dibu *)
Must free any state owned by this builder, including the builder object.
int(* edit)(fsl_dibu *, fsl_dline const *lineLhs, fsl_dline const *lineRhs)
Tells the builder that the given line represents an "edit" from the LHS to the RHS.
unsigned short passNumber
Gets set to the "pass number" immediately before this->start() is called, starting with pass number 1...
unsigned int pimplFlags
Space for private, implementation-specific flags, e.g.
uint32_t edits
Number of line-level edits performed so far.
int(* insertion)(fsl_dibu *, fsl_dline const *line)
Tells the builder that the given line represents an "insert" into the RHS.
fsl_dibu_opt const * opt
Config info, owned by higher-level routines.
void const * typeID
Can optionally be set by factory functions to some internal opaque value, so that non-member routines...
int(* start)(fsl_dibu *b)
If not NULL, this is called once per pass per diff to give the builder a chance to perform any bootst...
bool twoPass
If true, this builder gets passed through the diff generation process twice.
uint32_t insertions
Number of lines inserted performed so far.
uint32_t lnLHS
Number of lines seen of the LHS content.
int(* common)(fsl_dibu *, fsl_dline const *line)
Tells the builder that the given line represents one line of common output.
struct fsl_dibu::@254044115043113031362313315375067017031033007272 metrics
Metrics maintained by the core diff algorithm.
int(* skip)(fsl_dibu *, uint32_t n)
Tells the builder that n lines of common output are to be skipped.
void * pimpl
Impl-specific diff-generation state.
int(* finish)(fsl_dibu *b)
Must "finish" the diff process.
int(* deletion)(fsl_dibu *, fsl_dline const *line)
Tells the builder that the given line represents a "deletion" - a line removed from the LHS.
int(* replacement)(fsl_dibu *, fsl_dline const *lineLhs, fsl_dline const *lineRhs)
Tells the builder that the given line represents a replacement from the LHS to the RHS.
uint32_t replacements
Number of line replacements performed so far.
uint32_t deletions
Number of lines deleted so far.
State for use with fsl_dircrawl_f() callbacks.
fsl_fstat_type_e entryType
Filesystem entry type.
char const * entryName
Name (no path part) of the entry being visited.
char const * absoluteDir
Absolute directory name of the being-visited directory.
void * callbackState
Opaque client-specified pointer which was passed to fsl_dircrawl().
unsigned int depth
Directory depth of the crawl process, starting at 1 with the directory passed to fsl_dircrawl().
Array of change spans, in left-to-right order.
int iStart1
Byte offset to start of a change on the left.
int iLen1
Length of the left change in bytes.
int iLen2
Length of the change on the right in bytes.
int iStart2
Byte offset to start of a change on the right.
int isMin
True if this change is known to have no useful subdivs.
This "mostly-internal" type describes zero or more (up to fsl_dline_change_max_spans) areas of differ...
struct fsl_dline_change::fsl_dline_change_span a[fsl_dline_change_max_spans]
unsigned char n
Number of change spans (number of used elements in this->a).
Information about each line of a file being diffed.
const char * z
The text of the line.
unsigned int iHash
An array of fsl_dline elements serves two purposes.
unsigned short indent
Index of first non-space char.
unsigned short nw
Number of bytes without leading/trailing space.
unsigned int iNext
1+(Index of next line with same the same hash)
unsigned short n
Number of bytes of z which belong to this line.
uint64_t h
Hash of the line.
A container for storing generic error state.
int code
Error code, generally assumed to be a fsl_rc_e value.
fsl_buffer msg
Error message text is stored in this->msg.mem.
Generic interface for memory finalizers.
fsl_finalizer_f f
Finalizer function.
void * state
State to be passed as the first argument to f().
A simple wrapper around the stat(2) structure resp.
fsl_time_t mtime
Last modification time.
int perm
Contains the filesystem entry's permissions as a bitmask of fsl_fstat_perm_e values.
fsl_size_t size
The size of the stat'd file, in bytes.
fsl_fstat_type_e type
Indicates the type of filesystem object.
fsl_time_t ctime
The time of the last file metadata change (owner, permissions, etc.).
A container type for lists of db record IDs.
fsl_size_t entryCount
Number of entries of this->list which are in use (have a positive value).
fsl_id_t * list
Array of IDs this->capacity elements long.
fsl_size_t capacity
The number of elements allocated for this->list.
fsl_size_t used
The number of elements in this->list which have a zero or positive value.
Generic list container type.
fsl_size_t capacity
Number of slots allocated in this->list.
fsl_size_t used
Number of "used" entries in the list.
void ** list
Array of entries.
An interface which encapsulates data for managing an output destination, primarily intended for use w...
fsl_output_f out
Output channel.
void * state
State to be used when calling this->out(), namely: this->out( this->state, ... ) and this->flush(this...
fsl_flush_f flush
flush() implementation.
A helper type for tokenizing conventional PATH-style strings.
char const * begin
Begining of the input range.
char const * separators
List of token separator characters (ASCII only).
char const * pos
Position for the next token lookup.
char const * end
One-after-the-end of the input range.
The "Path Finder" class is a utility class for searching the filesystem for files matching a set of c...
fsl_buffer buf
Used to build up a path string during fsl_pathfinder_search(), and holds the result of a successful s...
fsl_list ext
Holds the list of search extensions.
fsl_list dirs
Holds the list of search directories.
Generic state-with-finalizer holder.
fsl_finalizer finalize
Finalizer for this->state.
void * state
Arbitrary context-dependent state.
State for the fsl_timer_xxx() family of functions.
uint64_t wall
The microseconds of "wall clock" time.
uint64_t user
The amount of time (microseconds) spent in "user space".
uint64_t system
The amount of time (microseconds) spent in "kernel space".
char const * username
The URL's username or NULL.
char const * raw
The raw, unparsed URL.
char const * fragment
The fragment part, including the '#' prefix.
uint16_t port
The :portNumber part or 0.
char const * scheme
The URL's scheme.
struct fsl_url::@106362302377216014057344117270115016120004110352 impl
Private implementation details.
char const * query
The query string, including the '?
char const * host
The remote host name.
char const * path
The path.
char const * password
The URL's username's password or NULL.
A utility class for creating ZIP-format archives.
int32_t dosDate
Current DOS-format date of the ZIP.
char * rootDir
An artificial root directory which gets prefixed to all inserted filenames.
fsl_time_t unixTime
Current Unix Epoch time of the ZIP.
fsl_size_t entryCount
Number of entries (files + dirs) added to the zip file so far.
fsl_buffer body
The buffer for the ZIP file body.
fsl_list dirs
The current list of directory entries (as (char *)).
int32_t dosTime
Current DOS-format time of the ZIP.
fsl_buffer toc
The buffer for the table of contents.
fsl_buffer scratch
Internal scratchpad for ops which often allocate small buffers.
const fsl_dibu_opt fsl_dibu_opt_empty
Initialized-with-defaults fsl_dibu_opt structure, intended for non-const copy initialization.
FSL_EXPORT int fsl_buffer_compare(fsl_buffer const *lhs, fsl_buffer const *rhs)
Compares the contents of buffers lhs and rhs using memcmp(3) semantics.
FSL_EXPORT void * fsl_malloc(fsl_size_t n)
Semantically behaves like malloc(3), but may introduce instrumentation, error checking,...
FSL_EXPORT const fsl_zip_writer fsl_zip_writer_empty
An initialized-with-defaults fsl_zip_writer instance, intended for copy-initialization.
FSL_EXPORT fsl_int_t fsl_data_uncompressed_size(unsigned char const *mem, fsl_size_t len)
If fsl_data_is_compressed(mem,len) returns true then this function returns the uncompressed size of t...
FSL_EXPORT fsl_int_t fsl_str_to_int(char const *str, fsl_int_t dflt)
Expects str to be a string containing a decimal value, optionally with a leading sign.
FSL_EXPORT int fsl_buffer_delta_apply2(fsl_buffer const *pOriginal, fsl_buffer const *pDelta, fsl_buffer *pTarget, fsl_error *pErr)
Identical to fsl_buffer_delta_apply() except that if delta application fails then any error messages/...
FSL_EXPORT const char * fsl_file_tail(const char *z)
Return the tail of a NUL-terminated file pathname.
FSL_EXPORT int fsl_error_setv(fsl_error *err, int code, char const *fmt, va_list args)
va_list counterpart to fsl_error_set().
FSL_EXPORT void fsl_glob_list_clear(fsl_list *globList)
If globList is not NULL this is equivalent to fsl_list_visit_free(globList, 1), otherwise it is a no-...
FSL_EXPORT bool fsl_is_symlink(const char *zFilename)
Returns true if the given file is a symlink, else false.
FSL_EXPORT fsl_buffer const * fsl_zip_body(fsl_zip_writer const *z)
Returns a pointer to z's ZIP content buffer.
FSL_EXPORT char * fsl_unicode_to_utf8(const void *zUnicode)
Translates Unicode text into UTF-8.
FSL_EXPORT fsl_size_t fsl_strlen_utf8(char const *str, fsl_int_t n)
Returns the number of UTF8 characters which begin within the first n bytes of str (noting that it's p...
FSL_EXPORT bool fsl_str_is_date(const char *z)
Returns true if the first 10 digits of z appear to form the start of an ISO date string (YYYY-MM-DD).
FSL_EXPORT int fsl_output_f_fsl_cx(void *state, void const *src, fsl_size_t n)
fsl_output_f() implementation which requires state to be a (fsl_cx*) to which this routine simply red...
FSL_EXPORT void fsl_temp_dirs_free(char **aDirs)
If aDirs is not NULL then it is expected to be an array created by fsl_temp_dirs_get() and it frees t...
FSL_EXPORT int fsl_url_render(fsl_url const *u, fsl_buffer *pOut, int flags)
Appends a rendering of the given parsed url object to the given buffer.
FSL_EXPORT fsl_int_t fsl_buffer_getline(char **ret, size_t *retsz, fsl_buffer *buf)
Equivalent to fsl_buffer_getdelim() with delim equal to ' '.
FSL_EXPORT bool fsl_starts_with_bom_utf8(fsl_buffer const *b, unsigned int *pBomSize)
Returns true if b starts with a UTF8 BOM.
FSL_EXPORT int fsl_buffer_compare_file(fsl_buffer const *b, char const *zFile)
Bitwise-compares the contents of b against the file named by zFile.
fsl_fstat_perm_e
Bitmask values for use with the fsl_fstat::perms field.
@ FSL_FSTAT_PERM_UNKNOWN
Sentinel value.
@ FSL_FSTAT_PERM_EXE
The executable bit, as understood by Fossil.
FSL_EXPORT int fsl_delta_create2(unsigned char const *zV1, fsl_size_t lenV1, unsigned char const *zV2, fsl_size_t lenV2, fsl_output_f out, void *outState)
Works identically to fsl_delta_create() but sends its output to the given output function.
FSL_EXPORT void fsl_error_propagate(fsl_error *from, fsl_error *to)
Swaps the state between two fsl_error objects and then resets the error state on the from object.
FSL_EXPORT void * fsl_realloc_f_stdalloc(void *state, void *mem, fsl_size_t n)
A fsl_realloc_f() implementation which uses the standard malloc()/free()/realloc().
FSL_EXPORT int fsl_snprintfv(char *dest, fsl_size_t n, char const *fmt, va_list args)
va_list counterpart to fsl_snprintf()
FSL_EXPORT int fsl_zip_end(fsl_zip_writer *z)
Ends the ZIP-creation process, padding all buffers, writing all final required values,...
#define fsl_buffer_capacity(b)
Returns the current capacity of b, or 0 if !b.
FSL_EXPORT int fsl_fprintfv(FILE *fp, char const *fmt, va_list args)
The va_list counterpart of fsl_fprintf().
#define fsl_dline_change_max_spans
Maximum number of change spans for fsl_dline_change.
FSL_EXPORT int fsl_list_reserve(fsl_list *self, fsl_size_t n)
Possibly reallocates self->list, changing its size.
fsl_confirm_response_e
Answers to questions posed to clients via the fsl_confirm_callback_f() interface.
@ FSL_CRESPONSE_YES
Accept the current event and continue processes.
@ FSL_CRESPONSE_MULTI
For events which are documented as being multiple-choice, this answer indicates that the client has s...
@ FSL_CRESPONSE_CANCEL
Reject the current event and stop processesing.
@ FSL_CRESPONSE_ALWAYS
Accept the current event and all identical event types for the current invocation of this particular ...
@ FSL_CRESPONSE_INVALID
Sentinel/default value - not a valid answer.
@ FSL_CRESPONSE_NEVER
Reject the current event and all identical event types for the current invocation of this particular ...
@ FSL_CRESPONSE_NO
Reject the current event and continue processes.
FSL_EXPORT int fsl_buffer_ensure_eol(fsl_buffer *b)
Add an EOL to b if it has content (i.e.
FSL_EXPORT fsl_id_t fsl_id_bag_next(fsl_id_bag const *p, fsl_id_t e)
Returns the next element in the bag after e.
FSL_EXPORT int fsl_zip_end_take(fsl_zip_writer *z, fsl_buffer *dest)
This variant of fsl_zip_end() transfers the current contents of the zip's body to dest,...
FSL_EXPORT char * fsl_htmlize_str(const char *zIn, fsl_int_t n)
Equivalent to fsl_htmlize_to_buffer() but returns the result as a new string which must eventually be...
FSL_EXPORT const fsl_timer fsl_timer_empty
Initialized-with-defaults fsl_timer instance, intended for non-const copy initialization.
FSL_EXPORT int fsl_stricmp(const char *zA, const char *zB)
Case-insensitive form of fsl_strcmp().
FSL_EXPORT int fsl_symlink_read(fsl_buffer *tgt, char const *zFilename)
This function expects its second argument to refer to a symlink (and that the caller has already vali...
FSL_EXPORT int fsl_glob_list_append(fsl_list *tgt, char const *zGlob)
Appends a single blob pattern to tgt, in the form of a new (char *) owned by tgt.
FSL_EXPORT int fsl_find_home_dir(fsl_buffer *tgt, bool requireWriteAccess)
Tries to find the user's home directory.
int fsl_system(const char *zOrigCmd)
Implements a cross-platform system(3) interface.
FSL_EXPORT int fsl_buffer_materialize(fsl_buffer *b)
If b is a "managed" buffer, this is a no-op and returns 0, else b is an "external" buffer and it....
FSL_EXPORT int fsl_buffer_reserve(fsl_buffer *b, fsl_size_t n)
Reserves at least n bytes of capacity in buf.
FSL_EXPORT void fsl_free(void *mem)
Semantically behaves like free(3), but may introduce instrumentation, error checking,...
FSL_EXPORT void fsl_buffer_chomp(fsl_buffer *b)
If b ends with a \n character or a pair of \r\n, the \n or \r\n pair are "chomped" (to use Perl's ter...
FSL_EXPORT bool fsl_is_file(const char *zFilename)
Returns true if the named file is an ordinary file.
FSL_EXPORT int fsl_chdir2(const char *zTo, char *zCurrent, fsl_size_t nCurrent)
Works like fsl_chdir(zTo) but passes (zCurrent,nCurrent,NULL) to fsl_getcwd() to save the current dir...
FSL_EXPORT char * fsl_mprintf(char const *fmt,...)
Works like fsl_appendfv(), but appends all output to a dynamically-allocated string,...
FSL_EXPORT int fsl_tolower(int c)
Returns the upper-case form of c if c is an ASCII alphabet letter, else returns c.
FSL_EXPORT int fsl_output_f_buffer(void *state, void const *src, fsl_size_t n)
A fsl_output_f() impl which requires state to be-a (fsl_buffer*), which this function passes to fsl_b...
FSL_EXPORT char * fsl_filename_to_utf8(const void *zFilename)
Translate text from the OS's character set into UTF-8.
FSL_EXPORT char * fsl_strdup(char const *src)
Equivalent to fsl_strndup(src,-1).
FSL_EXPORT char * fsl_buffer_str(fsl_buffer const *b)
Equivalent to ((char *)b->mem) except that if b->errCode is non-0 then NULL is returned.
FSL_EXPORT int fsl_strcmp_cmp(void const *lhs, void const *rhs)
Equivalent to fsl_strcmp(), but with a signature suitable for use as a generic comparison function (e...
FSL_EXPORT int fsl_dline_cmp_ignore_ws(const fsl_dline *pA, const fsl_dline *pB)
Counterpart of fsl_dline_cmp() but ignores all whitespace when comparing for equivalence.
FSL_EXPORT void fsl_dibu_finalizer(fsl_dibu *b)
This is a generic finalizer function for use as a fsl_dibu::finalize() method.
FSL_EXPORT int fsl_file_rename(const char *zFrom, const char *zTo)
Renames file zFrom to zTo using the OS's equivalent of rename(2).
FSL_EXPORT void fsl_dline_change_spans(const fsl_dline *pLeft, const fsl_dline *pRight, fsl_dline_change *p)
Given two lines of a diff, this routine computes a set of changes between those lines for display pur...
FSL_EXPORT void fsl_id_bag_clear(fsl_id_bag *p)
Frees any memory owned by p, but does not free p.
FSL_EXPORT fsl_size_t fsl_file_simplify_name(char *z, fsl_int_t n_, bool slash)
Simplify a filename by:
FSL_EXPORT int fsl_fprintf(FILE *fp, char const *fmt,...)
Emulates fprintf() using fsl_appendf().
FSL_EXPORT int fsl_rmdir(const char *zFilename)
Deletes an empty directory from the filesystem.
FSL_EXPORT const fsl_buffer fsl_buffer_empty
Empty-initialized fsl_buffer instance, intended for copy initialization.
FSL_EXPORT int fsl_dline_cmp(const fsl_dline *pA, const fsl_dline *pB)
Compares two fsl_dline instances using memcmp() semantics, returning 0 if they are equivalent.
FSL_EXPORT fsl_id_bag * fsl_id_bag_reuse(fsl_id_bag *p)
Resets p's internal list, effectively emptying it for re-use, but does not free its memory.
FSL_EXPORT int fsl_pathfinder_split(fsl_pathfinder *tgt, bool isDirs, char const *path, fsl_int_t pathLen)
Splits a conventional path-separator-delimited string into tokens and adds each as either a directory...
FSL_EXPORT bool fsl_looks_like_binary(fsl_buffer const *b)
Returns true if b appears to contain "binary" (non-UTF8/16) content, else returns false.
FSL_EXPORT int fsl_snprintf(char *dest, fsl_size_t n, char const *fmt,...)
An sprintf(3) clone which uses fsl_appendf() for the formatting.
FSL_EXPORT int fsl_dir_is_empty(const char *path)
Check the given path to determine whether it is an empty directory.
FSL_EXPORT int fsl_zip_root_set(fsl_zip_writer *z, char const *zRoot)
Sets a virtual root directory in z, such that all files added with fsl_zip_file_add() will get this d...
FSL_EXPORT int fsl_appendfv(fsl_output_f pfAppend, void *pfAppendArg, const char *fmt, va_list ap)
This function works similarly to classical printf implementations, but instead of outputing somewhere...
FSL_EXPORT void fsl_buffer_err_clear(fsl_buffer *b)
Resets the error code of the given buffer to 0.
FSL_EXPORT int fsl_strnicmp(const char *zA, const char *zB, fsl_int_t nByte)
fsl_strcmp() variant which compares at most nByte bytes of the given strings, case-insensitively.
FSL_EXPORT int fsl_bytes_fossilize(unsigned char const *inp, fsl_int_t len, fsl_buffer *out)
"Fossilizes" the first len bytes of the given input string.
void(* fsl_finalizer_f)(void *state, void *mem)
Generic interface for finalizing/freeing memory.
void *(* fsl_realloc_f)(void *state, void *mem, fsl_size_t n)
Generic stateful alloc/free/realloc() interface.
FSL_EXPORT void fsl_list_swap(fsl_list *lhs, fsl_list *rhs)
Swaps all contents of both lhs and rhs.
FSL_EXPORT int fsl_finalizer_f_buffer(void *state, void *mem)
fsl_finalizer_f() impl which requires that mem be-a (fsl_buffer*).
FSL_EXPORT int fsl_input_f_buffer(void *state, void *dest, fsl_size_t *n)
A fsl_input_f() implementation which requires that state be a readable (fsl_buffer*) handle.
FSL_EXPORT int fsl_delta_apply2(unsigned char const *zSrc, fsl_size_t lenSrc, unsigned char const *zDelta, fsl_size_t lenDelta, unsigned char *zOut, fsl_error *pErr)
Functionally identical to fsl_delta_apply() but any errors generated during application of the delta ...
FSL_EXPORT int fsl_stricmp_cmp(void const *lhs, void const *rhs)
Equivalent to fsl_stricmp(), but with a signature suitable for use as a generic comparison function (...
FSL_EXPORT int fsl_buffer_strftime(fsl_buffer *b, char const *format, const struct tm *timeptr)
A convenience form of fsl_strftime() which assumes that the formatted string is of "some reasonable s...
FSL_EXPORT bool fsl_is_file_or_link(const char *zFilename)
Returns true if the given filename refers to a plain file or symlink, else returns false.
FSL_EXPORT const fsl_list fsl_list_empty
Empty-initialized fsl_list structure, intended for copy initialization.
FSL_EXPORT int fsl_appendn(fsl_output_f pfAppend, void *pfAppendArg, const char *str, fsl_int_t n)
Works like fsl_appendf() except that it sends the first n bytes of str as-is to pfAppend().
FSL_EXPORT fsl_size_t fsl_buffer_tell(fsl_buffer const *b)
Returns the buffer's current cursor position.
FSL_EXPORT bool fsl_islower(int c)
Returns true if c is a lower-case ASCII alphabet character.
FSL_EXPORT const fsl_confirm_detail fsl_confirm_detail_empty
Empty-initialized fsl_confirm_detail instance to be used for non-const-copy initialization.
fsl_fstat_type_e
Values for use with the fsl_fstat::type field.
@ FSL_FSTAT_TYPE_DIR
Indicates a directory filesystem entry.
@ FSL_FSTAT_TYPE_LINK
Indicates a symlink filesystem entry.
@ FSL_FSTAT_TYPE_FILE
Indicates a non-directory, non-symlink filesystem entry.
@ FSL_FSTAT_TYPE_UNKNOWN
Sentinel value for unknown/invalid filesystem entry types.
FSL_EXPORT int fsl_buffer_append_hex(fsl_buffer *b, void const *src, fsl_uint_t n, bool upperCase)
Hex-encodes n bytes of src into n*2 hex-digit bytes appended to b.
FSL_EXPORT int fsl_toupper(int c)
Returns the lower-case form of c if c is an ASCII alphabet letter, else returns c.
FSL_EXPORT void fsl_buffer_defossilize(fsl_buffer *b)
Defossilizes the contents of b.
FSL_EXPORT int fsl_zip_end_to_filename(fsl_zip_writer *z, char const *filename)
This variant of fsl_zip_end_take() passes z to fsl_zip_end(), write's the ZIP body to the given filen...
const fsl_dibu fsl_dibu_empty
Initialized-with-defaults fsl_dibu structure, intended for non-const copy initialization.
FSL_EXPORT bool fsl_is_simple_pathname(const char *z, bool bStrictUtf8)
Return true if the filename given is a valid filename for a file in a repository.
FSL_EXPORT int fsl_glob_list_parse(fsl_list *tgt, char const *zPatternList)
Parses zPatternList as a comma-and/or-fsl_isspace()-delimited list of glob patterns (as supported by ...
FSL_EXPORT fsl_size_t fsl_strftime(char *dest, fsl_size_t destLen, const char *format, const struct tm *timeptr)
A custom strftime() implementation.
FSL_EXPORT bool fsl_id_bag_remove(fsl_id_bag *p, fsl_id_t e)
Remove element e from the bag if it exists in the bag.
FSL_EXPORT int fsl_is_uuid(char const *str)
If the NUL-terminated input str is exactly FSL_STRLEN_SHA1 or FSL_STRLEN_K256 bytes long and contains...
FSL_EXPORT bool fsl_buffer_eq(fsl_buffer const *b, char const *str, fsl_int_t nStr)
Compares b and the first nStr bytes of the given string.
FSL_EXPORT bool fsl_invalid_utf8(fsl_buffer const *b)
Returns true if b's contents appear to contain anything other than valid UTF8.
FSL_EXPORT int fsl_id_bag_copy(fsl_id_bag const *src, fsl_id_bag *dest)
Copies all entries from src into dest.
FSL_EXPORT bool fsl_str_bool(char const *s)
Returns false if s is NULL or starts with any of (0 (NUL), '0' (ASCII character zero),...
FSL_EXPORT int fsl_file_canonical_name2(const char *zRoot, const char *zOrigName, fsl_buffer *pOut, bool slash)
Computes a canonical pathname for a file or directory.
int(* fsl_list_visitor_f)(void *obj, void *visitorState)
Generic visitor interface for fsl_list lists.
fsl_dibu_e
Type IDs for use with fsl_dibu_factory().
@ FSL_DIBU_TCL
A diff builder which outputs a description of the diff in a TCL-readable form.
@ FSL_DIBU_INVALID
Sentinel entry.
@ FSL_DIBU_DEBUG
A "dummy" diff builder intended only for testing the fsl_dibu interface and related APIs.
@ FSL_DIBU_JSON1
Generates diffs in a compact low(ist)-level form originally designed for use by diff renderers implem...
@ FSL_DIBU_SPLIT_TEXT
A pain-text side-by-side (a.k.a.
@ FSL_DIBU_UNIFIED_TEXT
A diff builder which produces output compatible with the patch(1) command.
FSL_EXPORT void fsl_buffer_swap_free(fsl_buffer *left, fsl_buffer *right, int clearWhich)
Similar fsl_buffer_swap() but it also optionally frees one of the buffer's memories after swapping th...
FSL_EXPORT fsl_id_t fsl_id_bag_first(fsl_id_bag const *p)
Returns the ID of the first element in the bag.
FSL_EXPORT int fsl_id_bag_to_buffer(fsl_id_bag const *bag, fsl_buffer *b, char const *separator)
Appends each ID from the given bag to the given buffer using the given separator string.
FSL_EXPORT int fsl_error_copy(fsl_error const *src, fsl_error *dest)
Copies the error state from src to dest.
FSL_EXPORT void fsl_pathfinder_clear(fsl_pathfinder *pf)
Frees all memory associated with pf, but does not free pf.
FSL_EXPORT int fsl_list_visit_p(fsl_list *self, int order, bool shiftIfNulled, fsl_list_visitor_f visitor, void *visitorState)
Works similarly to the visit operation without the _p suffix except that the pointer the visitor func...
FSL_EXPORT int fsl_htmlize_to_buffer(fsl_buffer *p, const char *zIn, fsl_int_t n)
Functionally equivalent to fsl_htmlize() but optimized to perform only a single allocation.
FSL_EXPORT const fsl_outputer fsl_outputer_FILE
A fsl_outputer instance which is initialized to output to a (FILE*).
FSL_EXPORT int fsl_buffer_to_filename(fsl_buffer const *b, char const *fname)
Writes the given buffer to the given filename.
FSL_EXPORT char const * fsl_last_path_sep(char const *str, fsl_int_t slen)
Given a filename and its length, this function returns a pointer to the last instance of a path separ...
FSL_EXPORT int fsl_list_visit(fsl_list const *self, int order, fsl_list_visitor_f visitor, void *visitorState)
For each item in self->list, visitor(item,visitorState) is called.
FSL_EXPORT void fsl_id_bag_swap(fsl_id_bag *lhs, fsl_id_bag *rhs)
Swaps the contents of the given bags.
char * fsl_uuid_str
fsl_uuid_str and fsl_uuid_cstr are "for documentation andreadability purposes" typedefs used to denot...
FSL_EXPORT void fsl_url_swap(fsl_url *lhs, fsl_url *rhs)
Swaps the contents of the given objects.
FSL_EXPORT int fsl_str_is_date2(const char *z)
Checks if z is syntactically a time-format string in the format:
FSL_EXPORT void fsl_buffer_external(fsl_buffer *b, void const *mem, fsl_int_t n)
Initializes b to be an "external" buffer pointing to n bytes of the given memory.
FSL_EXPORT void fsl_os_str_free(void *pOld)
Deallocate pOld, which must be NULL or must have been allocated by fsl_filename_to_utf8(),...
FSL_EXPORT fsl_size_t fsl_strip_trailing_slashes(char *name, fsl_int_t nameLen)
Strips any trailing slashes ('/') from the given string by assigning those bytes to NUL and returns t...
FSL_EXPORT int fsl_getcwd(char *zBuf, fsl_size_t nBuf, fsl_size_t *outLen)
Writes the absolute path name of the current directory to zBuf, which must be at least nBuf bytes lon...
FSL_EXPORT int fsl_id_bag_insert(fsl_id_bag *p, fsl_id_t e)
Insert element e into the bag if it is not there already.
#define fsl_buffer_size(b)
Returns the "used" size of b, or 0 if !b.
FSL_EXPORT int fsl_buffer_delta_apply(fsl_buffer const *pOriginal, fsl_buffer const *pDelta, fsl_buffer *pTarget)
Apply the delta in pDelta to the original content pOriginal to generate the target content pTarget.
FSL_EXPORT int fsl_delta_apply(unsigned char const *zSrc, fsl_size_t lenSrc, unsigned char const *zDelta, fsl_size_t lenDelta, unsigned char *zOut)
Apply a delta created using fsl_delta_create().
FSL_EXPORT int fsl_dircrawl(char const *dirName, fsl_dircrawl_f callback, void *callbackState)
Recurses into a directory and calls a callback for each filesystem entry.
FSL_EXPORT bool fsl_str_glob(const char *zGlob, const char *z)
Return true if string z matches glob pattern zGlob and false if the pattern does not match.
FSL_EXPORT void fsl_buffer_swap(fsl_buffer *left, fsl_buffer *right)
Swaps the entire state of the left and right arguments.
void fsl_state_finalize(fsl_state *fst)
If fst is not NULL then:
FSL_EXPORT int fsl_decode16(const unsigned char *zIn, unsigned char *pOut, fsl_size_t N)
Decode a N-character base-16 number into base-256.
FSL_EXPORT char const * fsl_glob_list_matches(fsl_list const *globList, char const *zNeedle)
Assumes globList is a list of (char [const] *) glob values and tries to match each one against zNeedl...
FSL_EXPORT char * fsl_getenv(const char *zName)
Returns a (possible) copy of the environment variable with the given key, or NULL if no entry is foun...
FSL_EXPORT int fsl_buffer_appendch(fsl_buffer *b, char c)
Appends the given byte to b.
fsl_url_render_e
Flags for use with fsl_url_render().
@ FSL_URL_RENDER_NO_USER
Elide the user name and password.
@ FSL_URL_RENDER_MASK_PASSWORD
Render any password part of the URL as some unspecified number of "*" characters.
@ FSL_URL_RENDER_NO_PASSWORD
Elide any password part of the URL.
@ FSL_URL_RENDER_NO_QUERY
Elide the query string and fragment.
@ FSL_URL_RENDER_NO_FRAGMENT
Elide the fragment.
@ FSL_URL_RENDER_NO_SCHEME
Elide the scheme:// prefix.
FSL_EXPORT int fsl_pathfinder_ext_add2(fsl_pathfinder *pf, char const *ext, fsl_int_t strLen)
Adds the given directory to pf's search extensions.
FSL_EXPORT bool fsl_file_isexec(const char *zFilename)
Returns true if the argument is fsl_stat()'able and has the executable bit set, else false.
FSL_EXPORT fsl_size_t fsl_htmlize_xlate(int c, char const **xlate)
If c is a character Fossil likes to HTML-escape, assigns *xlate to its transformed form,...
FSL_EXPORT int fsl_diff_v2(fsl_buffer const *pv1, fsl_buffer const *pv2, fsl_dibu *pBuilder)
This counterpart of fsl_diff_text() defines its output format in terms of a fsl_dibu instance which t...
FSL_EXPORT int fsl_dir_check(const char *zFilename)
Returns a positive value if zFilename is a directory, 0 if zFilename does not exist,...
fsl_confirm_event_e
Event IDs for use with fsl_confirm_callback_f implementations.
@ FSL_CEVENT_MULTIPLE_VERSIONS
Indicates that the library cannot determine which of multiple potential versions to choose from and r...
@ FSL_CEVENT_OVERWRITE_MOD_FILE
An operation requests permission to overwrite a locally-modified file.
@ FSL_CEVENT_OVERWRITE_UNMGD_FILE
An operation requests permission to overwrite an SCM-unmanaged file with one which is managed by SCM.
@ FSL_CEVENT_RM_MOD_UNMGD_FILE
An operation requests permission to remove a LOCALLY-MODIFIED file which has been removed from SCM ma...
@ FSL_CEVENT_INVALID
Sentinal value.
FSL_EXPORT void fsl_canonical16(char *z, fsl_size_t n)
The input string is a base16 value.
FSL_EXPORT void fsl_randomness(unsigned int n, void *tgt)
Populates the first n bytes of tgt with random bytes.
const fsl_url fsl_url_empty
Initialized-with-defaults fsl_url structure, intended for non-const copy initialization.
FSL_EXPORT fsl_size_t fsl_str_to_size(char const *str)
Expects str to be a string containing an unsigned decimal value.
FSL_EXPORT int fsl_diff_v2_raw(fsl_buffer const *pv1, fsl_buffer const *pv2, fsl_dibu_opt const *cfg, int **outRaw)
Performs a diff, as for fsl_diff_v2(), but returns the results in the form of an array of COPY,...
FSL_EXPORT int fsl_appendf(fsl_output_f pfAppend, void *pfAppendArg, const char *fmt,...)
Identical to fsl_appendfv() but takes an ellipses list (...) instead of a va_list.
FSL_EXPORT void fsl_timer_start(fsl_timer *t)
Sets t's counter state to the current CPU timer usage, as determined by the OS.
FSL_EXPORT int fsl_looks_like_utf8(fsl_buffer const *b, int stopFlags)
If b appears to contain any non-UTF8 content, returns a truthy value: one or more values from the fsl...
FSL_EXPORT int fsl_buffer_merge3(fsl_buffer *pPivot, fsl_buffer *pV1, fsl_buffer *pV2, fsl_buffer *pOut, unsigned int *conflictCount)
Performs a three-way merge.
FSL_EXPORT int fsl_symlink_create(char const *zTargetFile, char const *zLinkFile, bool realLink)
Creates a symlink or pseudo-symlink named zLinkFile linking to zTargetFile.
FSL_EXPORT void fsl_zip_finalize(fsl_zip_writer *z)
Frees all memory owned by z and resets it to a clean state, but does not free z.
FSL_EXPORT void * fsl_realloc(void *mem, fsl_size_t n)
Behaves like realloc(3).
FSL_EXPORT const fsl_state fsl_state_empty
Empty-initialized fsl_state struct, intended for copy-initializing.
FSL_EXPORT unsigned int fsl_rgb_encode(int r, int g, int b)
For the given red/green/blue values (all in the range of 0 to 255, or truncated to be so!...
FSL_EXPORT int fsl_pathfinder_dir_add(fsl_pathfinder *pf, char const *dir)
Equivalent to fsl_pathfinder_dir_add2() with -1 as a final argument.
FSL_EXPORT void * fsl_utf8_to_unicode(const char *zUtf8)
Translate UTF-8 to Unicode for use in system calls.
FSL_EXPORT int fsl_list_v_fsl_free(void *obj, void *visitorState)
A fsl_list_visitor_f() implementation which requires that obj be arbitrary memory which can legally b...
FSL_EXPORT fsl_size_t fsl_simplify_sql(char *sql, fsl_int_t len)
"Simplifies" an SQL string by making the following modifications inline:
FSL_EXPORT int fsl_file_unlink(const char *zFilename)
Deletes the given file from the filesystem.
FSL_EXPORT fsl_int_t fsl_buffer_getdelim(char **ret, size_t *retsz, int delim, fsl_buffer *buf)
Read from buf until consuming a character matching delim, which must be representable as an unsigned ...
FSL_EXPORT int fsl_pathfinder_search(fsl_pathfinder *pf, char const *base, char const **pOut, fsl_size_t *outLen)
Searches for a file whose name can be constructed by some combination of pf's directory/extension lis...
FSL_EXPORT FILE * fsl_fopen(char const *name, char const *mode)
Almost equivalent to fopen(3) but:
FSL_EXPORT bool fsl_isalnum(int c)
Equivalent to fsl_isdigit(c) || fsl_isalpha().
FSL_EXPORT int fsl_break_into_dlines(const char *z, fsl_int_t n, uint32_t *pnLine, fsl_dline **pOut, uint64_t diff2Flags)
Breaks the first n bytes of z into an array of fsl_dline records, each of which refers back to z (so ...
FSL_EXPORT void fsl_list_visit_free(fsl_list *list, bool freeListMem)
Similar to fsl_list_clear(list, fsl_list_v_fsl_free, NULL), but only frees list->list if the second a...
FSL_EXPORT int fsl_mkdir(const char *zName, bool forceFlag)
Create the directory with the given name if it does not already exist.
FSL_EXPORT fsl_int_t fsl_list_index_of(fsl_list const *li, void const *value, fsl_generic_cmp_f cmpf)
Searches for a value in the given list, using the given comparison function to determine equivalence.
FSL_EXPORT const fsl_fstat fsl_fstat_empty
Empty-initialized fsl_fstat instance, intended for non-const copy construction.
FSL_EXPORT unsigned int fsl_gradient_color(unsigned int c1, unsigned int c2, unsigned int numberOfSteps, unsigned int stepNumber)
For two color values encoded as RRGGBB values (see below for the structure), this function computes a...
FSL_EXPORT bool fsl_isalpha(int c)
Returns true if the given letter is an ASCII alphabet character.
FSL_EXPORT void fsl_bytes_defossilize(unsigned char *inp, fsl_size_t *resultLen)
"Defossilizes" bytes encoded by fsl_bytes_fossilize() in-place.
FSL_EXPORT int fsl_buffer_fill_from(fsl_buffer *dest, fsl_input_f src, void *state)
Uses a fsl_input_f() function to buffer input into a fsl_buffer.
FSL_EXPORT const fsl_pathfinder fsl_pathfinder_empty
Initialized-with-defaults fsl_pathfinder instance, intended for copy initialization.
FSL_EXPORT int fsl_file_copy(char const *zFrom, char const *zTo)
Makes a bitwise copy of the file zFrom to file zTo, creating any directories needed for the target fi...
FSL_EXPORT int fsl_is_uuid_len(int x)
If x is a valid fossil UUID length, it is returned, else 0 is returned.
FSL_EXPORT void fsl_buffer_strip_slashes(fsl_buffer *b)
A convenience from of fsl_strip_trailing_slashes() which strips trailing slashes from the given buffe...
int fsl_path_splitter_next(fsl_path_splitter *pt, char const **token, fsl_size_t *len)
Given a fsl_path_splitter which was formerly initialized using fsl_path_splitter_init(),...
FSL_EXPORT int fsl_file_exec_set(const char *zFilename, bool isExec)
On non-Windows platforms, this function sets or unsets the executable bits on the given filename.
FSL_EXPORT fsl_size_t fsl_id_bag_count(fsl_id_bag const *p)
Return the number of elements in the bag.
FSL_EXPORT char ** fsl_temp_dirs_get(void)
Collects a list of directories intended to use as temp dirs in the current environment.
FSL_EXPORT fsl_size_t fsl_buffer_seek(fsl_buffer *b, fsl_int_t offset, fsl_buffer_seek_e whence)
"Seeks" b's internal cursor to a position specified by the given offset from either the current curso...
FSL_EXPORT void fsl_zip_timestamp_set_julian(fsl_zip_writer *z, double rDate)
Set z's date and time from a Julian Day number.
const fsl_dline_change fsl_dline_change_empty
Initialized-with-defaults fsl_dline_change structure, intended for non-const copy initialization.
FSL_EXPORT int fsl_mkdir_for_file(char const *zName, bool forceFlag)
A convenience form of fsl_mkdir() which can recursively create directories.
FSL_EXPORT int fsl_buffer_stream_lines(fsl_output_f fTo, void *toState, fsl_buffer *pFrom, fsl_size_t N)
Works identically to fsl_buffer_copy_lines() except that it sends its output to the fTo output functi...
fsl_diff2_flag_e
Flags for use with the 2021-era text-diff generation APIs (fsl_dibu and friends).
@ FSL_DIFF2_NOTTOOBIG
Only calculate diff if it's not "too big." Applies to all diff builders and will cause the public API...
@ FSL_DIFF2_IGNORE_ALLWS
Ignore all whitespace.
@ FSL_DIFF2_IGNORE_EOLWS
Ignore end-of-line whitespace.
@ FSL_DIFF2_NOINDEX
Tells diff builders which optionally support an "index" line to NOT include it in their output.
@ FSL_DIFF2_CLIENT4
Reserved for client-defined diff builder use.
@ FSL_DIFF2_CLIENT3
Reserved for client-defined diff builder use.
@ FSL_DIFF2_SLOW_SBS
More precise but slower side-by-side diff algorithm, for diffs which use that.
@ FSL_DIFF2_LINE_NUMBERS
Tells diff builders which support it to include line numbers in their output.
@ FSL_DIFF2_CLIENT2
Reserved for client-defined diff builder use.
@ FSL_DIFF2_CLIENT1
Reserved for client-defined diff builder use.
@ FSL_DIFF2_CONTEXT_ZERO
Use context line count even if it's zero.
@ FSL_DIFF2_NOOPT
Suppress optimizations (debug).
@ FSL_DIFF2_INVERT
Invert the diff.
@ FSL_DIFF2_STRIP_EOLCR
Strip trailing CR before diffing.
FSL_EXPORT char * fsl_mprintfv(char const *fmt, va_list vargs)
va_list counterpart to fsl_mprintf().
FSL_EXPORT int fsl_buffer_esc_arg(fsl_buffer *b, char const *z, bool isFilename)
Equivalent to fsl_buffer_esc_arg_v2() with NULL as its second argument.
FSL_EXPORT void fsl_timer_fetch(fsl_timer const *t, uint64_t *pUser, uint64_t *pSys, uint64_t *pWall)
Sets each of pUser, pSys, and pWall to the number of microseconds which have elapsed since t was pass...
int(* fsl_input_f)(void *state, void *dest, fsl_size_t *n)
Generic interface for streaming in data.
FSL_EXPORT void fsl_fclose(FILE *f)
Passes f to fclose(3) unless f is NULL or one of the C-standard (stdin, stdout, stderr) handles,...
FSL_EXPORT void fsl_url_cleanup(fsl_url *u)
Equivalent to fsl_url_cleanup2(u, true).
FSL_EXPORT int fsl_list_clear(fsl_list *list, fsl_list_visitor_f childFinalizer, void *finalizerState)
A list clean-up routine which takes a callback to clean up its contents.
FSL_EXPORT const fsl_path_splitter fsl_path_splitter_empty
Default-initialized fsl_path_splitter instance, intended for copy initialization.
FSL_EXPORT int fsl_error_get(fsl_error const *err, char const **str, fsl_size_t *len)
Fetches the error state from err.
FSL_EXPORT bool fsl_isspace(int c)
Returns true if c is ' ', '\r' (ASCII 13dec), or '\t' (ASCII 9 dec).
FSL_EXPORT void fsl_error_reset(fsl_error *err)
Sets err->code to 0 and resets its buffer, but keeps any err->msg memory around for later re-use.
fsl_buffer_seek_e
"whence" values for use with fsl_buffer_seek().
FSL_EXPORT int fsl_buffer_delta_create(fsl_buffer const *src, fsl_buffer const *newVers, fsl_buffer *delta)
A fsl_delta_create() wrapper which uses the first two arguments as the original and "new" content ver...
FSL_EXPORT const fsl_error fsl_error_empty
Empty-initialized fsl_error instance, intended for copy initialization.
FSL_EXPORT void fsl_finalizer_f_FILE(void *state, void *mem)
A fsl_finalizer_f() impl which requires that mem be-a (FILE*).
FSL_EXPORT char const * fsl_buffer_cstr(fsl_buffer const *b)
Equivalent to ((char const *)b->mem) except that if b->errCode is non-0, this returns NULL.
FSL_EXPORT void fsl_buffer_clear(fsl_buffer *b)
Convenience equivalent of fsl_buffer_reserve(b,0).
FSL_EXPORT void fsl_error_clear(fsl_error *err)
If err is not NULL, frees up any resources owned by err and sets its error code to 0,...
FSL_EXPORT fsl_time_t fsl_file_mtime(const char *zFilename)
Return the modification time for a file.
FSL_EXPORT bool fsl_isatty(int fd)
Returns the result of calling the platform's equivalent of isatty(fd).
FSL_EXPORT void fsl_list_sort(fsl_list *li, fsl_generic_cmp_f cmp)
Sorts the given list using the given comparison function.
FSL_EXPORT fsl_int_t fsl_file_size(const char *zFilename)
Return the size of a file in bytes.
FSL_EXPORT char * fsl_user_name_guess(void)
Uses fsl_getenv() to look for the environment variables (FOSSIL_USER, (Windows: USERNAME),...
FSL_EXPORT int fsl_file_mtime_set(const char *zFilename, fsl_time_t newMTime)
Sets the mtime (Unix epoch) for a file.
FSL_EXPORT int fsl_delta_applied_size(unsigned char const *zDelta, fsl_size_t lenDelta, fsl_size_t *appliedSize)
Calculates the size (in bytes) of the output from applying a the given delta.
FSL_EXPORT double fsl_unix_to_julian(fsl_time_t unixEpoch)
Old, misleading name for fsl_error_propagate() */ define fsl_error_swap fsl_error_propagate.
FSL_EXPORT bool fsl_url_next_query_arg(fsl_url const *u, char const **zCursor, fsl_buffer *bKey, fsl_buffer *bVal)
Parses key-value pairs from u->query.
FSL_EXPORT int fsl_buffer_uncompress(fsl_buffer const *pIn, fsl_buffer *pOut)
Uncompress buffer pIn and store the result in pOut.
FSL_EXPORT int fsl_filename_preferred_case(bool isCaseSensitive, const char *zDir, const char *zPath, char **zOut)
Attempts to ensure that the name of a file in the filesystem matches the same case as one provided by...
FSL_EXPORT fsl_size_t fsl_strftime_unix(char *dest, fsl_size_t destLen, char const *format, fsl_time_t epochTime, bool convertToLocal)
A convenience form of fsl_strftime() which takes its timestamp in the form of a Unix Epoch time.
FSL_EXPORT int fsl_pathfinder_ext_add(fsl_pathfinder *pf, char const *ext)
Equivalent to fsl_pathfinder_ext_add2() with -1 as a final argument.
FSL_EXPORT int fsl_input_f_fd(void *state, void *dest, fsl_size_t *n)
A fsl_input_f() implementation which requires that state be a readable file descriptor,...
FSL_EXPORT int fsl_stream(fsl_input_f inF, void *inState, fsl_output_f outF, void *outState)
A generic streaming routine which copies data from an fsl_input_f() to an fsl_outpuf_f().
fsl_dibu_impl_flags_e
Flags for use with various concrete fsl_dibu implementations.
@ FSL_DIBU_TCL_TK
Tells the TCL diff builder to generate a complete TCL/TK app as output.
@ FSL_DIBU_TCL_BRACES
Tells the TCL diff builder that the complete output and each line should be wrapped in {....
@ FSL_DIBU_TCL_BRACES_ESC
Tells the TCL diff builder that the squiggly braces embedded in any output (as opposed to the braces ...
FSL_EXPORT int fsl_delta_create(unsigned char const *zSrc, fsl_size_t lenSrc, unsigned char const *zOut, fsl_size_t lenOut, unsigned char *zDelta, fsl_size_t *deltaSize)
Create a new fossil-format delta between the memory zIn and zOut.
FSL_EXPORT bool fsl_id_bag_contains(fsl_id_bag const *p, fsl_id_t e)
Returns true if e is in the given bag.
FSL_EXPORT bool fsl_is_absolute_path(const char *zPath)
Returns true if the given path appears to be absolute, else false.
FSL_EXPORT int fsl_file_dirpart(char const *zFilename, fsl_int_t nLen, fsl_buffer *pOut, bool leaveSlash)
Calculates the "directory part" of zFilename and appends it to pOut.
FSL_EXPORT void fsl_rgb_decode(unsigned int src, int *r, int *g, int *b)
Given an RGB-encoded source value, this function decodes the lower 24 bits into r,...
FSL_EXPORT void fsl_timer_add(fsl_timer const *tStart, fsl_timer *tgt)
Captures the current time and adds the difference of tStart and the current time to tgt's members.
FSL_EXPORT int fsl_chdir(const char *zChDir)
Performs a chdir() to the directory named by zChDir.
FSL_EXPORT int fsl_zip_file_add(fsl_zip_writer *z, char const *zFilename, fsl_buffer const *pContent, int permsFlag)
Adds a file or directory to the ZIP writer z.
FSL_EXPORT int fsl_buffer_compress(fsl_buffer const *pIn, fsl_buffer *pOut)
Compresses the first pIn->used bytes of pIn to pOut.
FSL_EXPORT int fsl_buffer_append(fsl_buffer *b, void const *src, fsl_int_t n)
Appends the first n bytes of src, plus a NUL byte, to b, expanding b as necessary and incrementing b-...
FSL_EXPORT int fsl_stat(const char *zFilename, fsl_fstat *fst, bool derefSymlinks)
Runs the OS's stat(2) equivalent to populate fst (if not NULL) with information about the given file.
int(* fsl_dircrawl_f)(fsl_dircrawl_state const *)
Callback type for use with fsl_dircrawl().
FSL_EXPORT fsl_int_t fsl_list_index_of_cstr(fsl_list const *li, char const *key)
Equivalent to fsl_list_index_of(li, key, fsl_strcmp_cmp).
fsl_lookslike_e
Flags for use with the fsl_looks family of functions.
FSL_EXPORT void * fsl_utf8_to_filename(const char *zUtf8)
Translate text from UTF-8 to the OS's filename character set.
FSL_EXPORT char * fsl_strndup(char const *src, fsl_int_t len)
Similar to strndup(3) but returns NULL if !src.
FSL_EXPORT int fsl_buffer_appendf(fsl_buffer *dest, char const *fmt,...)
Uses fsl_appendf() to append formatted output to the given buffer.
FSL_EXPORT fsl_time_t fsl_julian_to_unix(double J)
Returns the Julian Day time J value converted to a Unix Epoch timestamp.
FSL_EXPORT bool fsl_julian_to_iso8601(double J, char *pOut, bool addMs)
Converts the Julian Day J to an ISO8601 time string.
FSL_EXPORT bool fsl_iso8601_to_julian(char const *zDate, double *pOut)
If zDate is an ISO8601-format string, optionally with a .NNN fractional suffix, then this function re...
FSL_EXPORT void fsl_buffer_rewind(fsl_buffer *b)
Resets b's cursor to the beginning of the buffer.
FSL_EXPORT double fsl_julian_now(void)
Returns the current Unix Epoch time converted to its approximate Julian form.
FSL_EXPORT fsl_dibu * fsl_dibu_alloc(fsl_size_t extra)
Base allocator for fsl_dibu instances.
FSL_EXPORT int fsl_encode16(const unsigned char *pIn, unsigned char *zOut, fsl_size_t N)
Encode a N-digit base-256 in base-16.
FSL_EXPORT int fsl_stream_compare(fsl_input_f in1, void *in1State, fsl_input_f in2, void *in2State)
Consumes two input streams looking for differences.
char const * fsl_uuid_cstr
The const counterpart of fsl_uuid_str.
FSL_EXPORT int fsl_buffer_append_tcl_literal(fsl_buffer *b, bool escapeSquigglies, char const *z, fsl_int_t n)
Appends the first n bytes of string z to buffer b in the form of TCL-format string literal.
FSL_EXPORT const fsl_confirm_response fsl_confirm_response_empty
Empty-initialized fsl_confirm_detail instance to be used for non-const copy initialization.
FSL_EXPORT int fsl_input_f_FILE(void *state, void *dest, fsl_size_t *n)
A fsl_input_f() implementation which requires that state be a readable (FILE*) handle.
const fsl_dline fsl_dline_empty
Initialized-with-defaults fsl_dline structure, intended for non-const copy initialization.
FSL_EXPORT bool fsl_validate16(const char *zIn, fsl_size_t nIn)
Returns true if the input string contains only valid lower-case base-16 digits.
FSL_EXPORT int fsl_buffer_fill_from_FILE(fsl_buffer *dest, FILE *src)
A fsl_buffer_fill_from() proxy which overwrite's dest->mem with the contents of the given FILE handle...
FSL_EXPORT int fsl_errno_to_rc(int errNo, int dflt)
Tries to convert the value of errNo, which is assumed to come from the global errno,...
FSL_EXPORT bool fsl_buffer_is_compressed(fsl_buffer const *buf)
Equivalent to fsl_data_is_compressed(buf->mem, buf->used).
FSL_EXPORT uint64_t fsl_timer_cpu(fsl_timer const *t)
Returns the difference in CPU times in microseconds since t was last passed to fsl_timer_start() or f...
FSL_EXPORT char const * fsl_buffer_cstr2(fsl_buffer const *b, fsl_size_t *len)
If b has any memory allocated to it and b->errCode is non-0, that memory is returned.
FSL_EXPORT bool fsl_buffer_contains_merge_marker(fsl_buffer const *p)
Returns true if p contains a fossil-format merge conflict marker, else returns false.
FSL_EXPORT int fsl_strncmp(const char *zA, const char *zB, fsl_size_t nByte)
fsl_strcmp() variant which compares at most nByte bytes of the given strings, case-sensitively.
FSL_EXPORT const fsl_outputer fsl_outputer_empty
Empty-initialized fsl_outputer instance, intended for copy-initializing.
FSL_EXPORT char * fsl_buffer_take(fsl_buffer *b)
"Takes" the memory refered to by the given buffer, transfering ownership to the caller.
FSL_EXPORT uint64_t fsl_timer_stop(fsl_timer *t)
Resets t's state to contain relative times by subtracting its starting time from the current time.
FSL_EXPORT void fsl_zip_timestamp_set_unix(fsl_zip_writer *z, fsl_time_t epochTime)
Set z's date and time from a Unix Epoch time.
int(* fsl_generic_cmp_f)(void const *lhs, void const *rhs)
A typedef for comparison function used by standard C routines such as qsort().
FSL_EXPORT unsigned char const * fsl_utf8_bom(unsigned int *pnByte)
Returns a static pointer to bytes of a UTF8 BOM.
FSL_EXPORT int fsl_strcmp(char const *lhs, char const *rhs)
Like strcmp(3) except that it accepts NULL pointers.
FSL_EXPORT int fsl_buffer_resize(fsl_buffer *buf, fsl_size_t n)
Similar to fsl_buffer_reserve() except that...
FSL_EXPORT int fsl_buffer_esc_arg_v2(fsl_buffer *b, fsl_error *err, char const *z, bool isFilename)
Expects z to be a single argument intended for future call to system()-like function.
FSL_EXPORT int fsl_url_parse(fsl_url *u, char const *zUrl)
Attempts to parse zUrl as a URL, filling out u with the results.
FSL_EXPORT int fsl_output_f_FILE(void *state, void const *src, fsl_size_t n)
A fsl_output_f() impl which requires state to be-a (FILE*), which this function passes the call on to...
FSL_EXPORT fsl_size_t fsl_strlcpy(char *dst, const char *src, fsl_size_t dstsz)
BSD strlcpy() variant which is less error prone than strncpy.
FSL_EXPORT int fsl_file_access(const char *zFilename, int flags)
Returns 0 if the given file is readable.
FSL_EXPORT int fsl_flush_f_FILE(void *_FILE)
A fsl_flush_f() impl which expects _FILE to be-a (FILE*) opened for writing, which this function pass...
FSL_EXPORT int fsl_buffer_compress2(fsl_buffer const *pIn1, fsl_buffer const *pIn2, fsl_buffer *pOut)
Compress the concatenation of a blobs pIn1 and pIn2 into pOut.
FSL_EXPORT bool fsl_isupper(int c)
Returns true if c is an upper-case ASCII alphabet character.
FSL_EXPORT int fsl_buffer_compare_O1(fsl_buffer const *lhs, fsl_buffer const *rhs)
Compare two buffers in constant (a.k.a.
FSL_EXPORT int fsl_dibu_factory(fsl_dibu_e type, fsl_dibu **pOut)
A factory for creating fsl_dibu instances of types which are built in to the library.
int(* fsl_flush_f)(void *state)
Generic interface for flushing arbitrary output streams.
FSL_EXPORT int fsl_buffer_appendfv(fsl_buffer *dest, char const *fmt, va_list args)
va_list counterpart to fsl_buffer_appendf().
FSL_EXPORT void fsl_to_hex(unsigned char const *pBytes, fsl_size_t nBytes, char *pOut)
Converts the first nBytes bytes from pBytes to hex form, writing the result to pOut.
FSL_EXPORT int fsl_error_set(fsl_error *err, int code, char const *fmt,...)
If err is not NULL, populates err with the given code and formatted string, replacing any existing st...
FSL_EXPORT int fsl_htmlize(fsl_output_f out, void *oState, const char *zIn, fsl_int_t n)
Make the given string safe for HTML by converting every "<" into "<", every ">" into ">",...
FSL_EXPORT int fsl_pathfinder_dir_add2(fsl_pathfinder *pf, char const *dir, fsl_int_t strLen)
Adds the given directory to pf's search path.
FSL_EXPORT int fsl_buffer_fill_from_filename(fsl_buffer *dest, char const *filename)
A wrapper for fsl_buffer_fill_from_FILE() which gets its input from the given file name.
FSL_EXPORT int fsl_output_f_fd(void *state, void const *src, fsl_size_t n)
A fsl_output_f() impl which requires state to be-a (int*) referring to a writable file descriptor,...
FSL_EXPORT int fsl_list_append(fsl_list *self, void *cp)
Appends a bitwise copy of cp to self->list, expanding the list as necessary and adjusting self->used.
FSL_EXPORT int fsl_symlink_copy(char const *zFrom, char const *zTo, bool realLink)
Reads symlink zFrom, as per fsl_symlink_read(), then creates a copy named zTo, as per fsl_symlink_cre...
FSL_EXPORT int fsl_buffer_copy(fsl_buffer *dest, fsl_buffer const *src)
Overwrites dest's contents with a copy of those from src (reusing dest's memory if it has any).
void fsl_path_splitter_init(fsl_path_splitter *pt, char const *path, fsl_int_t len)
Wipes out pt's current state by copying fsl_path_splitter_empty over it and initializes pt to use the...
FSL_EXPORT void fsl_url_cleanup2(fsl_url *u, bool freeBuffer)
Frees all memory owned by u, and zeroes it out, but does not free u.
FSL_EXPORT int fsl_file_tempname(fsl_buffer *tgt, char const *zPrefix, char *const *dirs)
Creates a semi-random temp filename and appends it to the given buffer.
FSL_EXPORT int fsl_file_canonical_name(const char *zOrigName, fsl_buffer *pOut, bool slash)
Equivalent to fsl_file_canonical_name2(NULL, zOrigName, pOut, slash).
FSL_EXPORT fsl_size_t fsl_strlcat(char *dst, const char *src, fsl_size_t dstsz)
BSD strlcat() variant which is less error prone than strncat.
FSL_EXPORT const fsl_confirmer fsl_confirmer_empty
Empty-initialized fsl_confirmer instance for non-const-copy initialization.
FSL_EXPORT int fsl_buffer_err(fsl_buffer const *b)
Returns the current error code of the given buffer.
FSL_EXPORT fsl_size_t fsl_strlen(char const *src)
Equivalent to strlen(3) but returns 0 if src is NULL.
FSL_EXPORT const fsl_id_bag fsl_id_bag_empty
Initialized-with-defaults fsl_id_bag structure, intended for copy initialization.
int(* fsl_output_f)(void *state, void const *src, fsl_size_t n)
Generic interface for streaming out data.
FSL_EXPORT bool fsl_isdigit(int c)
Returns true if c is an ASCII digit in the range '0' to '9'.
FSL_EXPORT bool fsl_data_is_compressed(unsigned char const *mem, fsl_size_t len)
Returns true if this function believes that mem (which must be at least len bytes of valid memory lon...
FSL_EXPORT void fsl_unicode_free(void *)
Deallocates the given memory, which must have been allocated from fsl_unicode_to_utf8(),...
FSL_EXPORT fsl_int_t fsl_buffer_uncompressed_size(fsl_buffer const *b)
The fsl_buffer counterpart of fsl_data_uncompressed_size().
int(* fsl_confirm_callback_f)(fsl_confirm_detail const *detail, fsl_confirm_response *outAnswer, void *confirmerState)
Should present the user (if appropriate) with an option of how to handle the given event write that a...
FSL_EXPORT fsl_size_t fsl_simplify_sql_buffer(fsl_buffer *b)
Convenience form of fsl_simplify_sql() which assumes b holds an SQL string.
FSL_EXPORT fsl_buffer * fsl_buffer_reuse(fsl_buffer *b)
If b is a managed buffer, this resets b->used, b->cursor, and b->mem[0] (if b->mem is not NULL) to 0.
FSL_EXPORT int fsl_uuidcmp(fsl_uuid_cstr lhs, fsl_uuid_cstr rhs)
Equivalent to fsl_strncmp(lhs, rhs, X), where X is either FSL_STRLEN_SHA1 or FSL_STRLEN_K256: if both...
FSL_EXPORT int fsl_buffer_copy_lines(fsl_buffer *pTo, fsl_buffer *pFrom, fsl_size_t N)
Copy N lines of text from pFrom into pTo.