/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ #if !defined(ORG_FOSSIL_SCM_LIBFOSSIL_DEPRECATED_H_INCLUDED) #define ORG_FOSSIL_SCM_LIBFOSSIL_DEPRECATED_H_INCLUDED /* Copyright 2013-2021 The Libfossil Authors, see LICENSES/BSD-2-Clause.txt SPDX-License-Identifier: BSD-2-Clause-FreeBSD SPDX-FileCopyrightText: 2021 The Libfossil Authors SPDX-ArtifactOfProjectName: Libfossil SPDX-FileType: Code Heavily indebted to the Fossil SCM project (https://fossil-scm.org). */ /** @file deprecated.h This file holds APIs which are deprecated or otherwise "on the chopping block." The libfossil public API has gathered a good deal of cruft over the years, some of it rather unnecessary. */ /** @deprecated fsl_db_role_name() is easier to deal with. Similar to fsl_cx_db_file_ckout() and friends except that it applies to DB name (as opposed to DB _file_ name) implied by the specified role (2nd parameter). If no such role is opened, or the role is invalid, NULL is returned. If the 3rd argument is not NULL, it is set to the length, in bytes, of the returned string. The returned strings are NUL-terminated and are either static or owned by the db handle they correspond to. If the client does not care whether the db in question is actually opened, the name for the corresponding role can be fetched via fsl_db_role_name(). This is the "easiest" way to figure out the DB name of the given role, independent of what order f's databases were opened (because the first-opened DB is always called "main"). The Fossil-standard names of its primary databases are: "localdb" (checkout), "repository", and "configdb" (global config DB), but libfossil uses "ckout", "repo", and "cfg", respective. So long as queries use table names which unambiguously refer to a given database, the DB name is normally not needed. It is needed when creating new non-TEMP db tables and views. By default such tables/views would go into the "main" DB, and which one is the "main" db is dependent on the order the DBs are opened, so it's important to use the correct DB name when creating such constructs. Note that the role of FSL_DBROLE_TEMP is invalid here. */ FSL_EXPORT char const * fsl_cx_db_name_for_role(fsl_cx const * const f, fsl_dbrole_e r, fsl_size_t * len); /** Flags for use with text-diff generation APIs, e.g. fsl_diff_text(). Maintenance reminders: - These values are holy and must not be changed without also changing the corresponding code in diff.c. - Where these entries semantically overlap with their fsl_diff2_flag_e counterparts, they MUST have the same values because some internal APIs are used by both of the diff APIs. @deprecated Prefer fsl_diff2_flag_e and fsl_diff_v2() instead. */ enum fsl_diff_flag_e { /** Ignore end-of-line whitespace */ FSL_DIFF_IGNORE_EOLWS = 0x01, /** Ignore end-of-line whitespace */ FSL_DIFF_IGNORE_ALLWS = 0x03, /** Generate a side-by-side diff */ FSL_DIFF_SIDEBYSIDE = 0x04, /** Missing shown as empty files */ FSL_DIFF_VERBOSE = 0x08, /** Show filenames only. Not used in this impl! */ FSL_DIFF_BRIEF = 0x10, /** Render HTML. */ FSL_DIFF_HTML = 0x20, /** Show line numbers. */ FSL_DIFF_LINENO = 0x40, /** Suppress optimizations (debug). */ FSL_DIFF_NOOPT = 0x0100, /** Invert the diff (debug). */ FSL_DIFF_INVERT = 0x0200, /* ACHTUNG: do not use 0x0400 because of semantic collision with FSL_DIFF2_CONTEXT_ZERO */ /** Only display if not "too big." */ FSL_DIFF_NOTTOOBIG = 0x0800, /** Strip trailing CR */ FSL_DIFF_STRIP_EOLCR = 0x1000, /** This flag tells text-mode diff generation to add ANSI color sequences to some output. The colors are currently hard-coded and non-configurable. This has no effect for HTML output, and that flag trumps this one. It also currently only affects unified diffs, not side-by-side. Maintenance reminder: this one currently has no counterpart in fossil(1), is not tracked in the same way, and need not map to an internal flag value. */ FSL_DIFF_ANSI_COLOR = 0x2000 }; /** Generates a textual diff from two text inputs and writes it to the given output function. pA and pB are the buffers to diff. contextLines is the number of lines of context to output. This parameter has a built-in limit of 2^16, and values larger than that get truncated. A value of 0 is legal, in which case no surrounding context is provided. A negative value translates to some unspecified default value. sbsWidth specifies the width (in characters) of the side-by-side columns. If sbsWidth is not 0 then this function behaves as if diffFlags contains the FSL_DIFF_SIDEBYSIDE flag. If sbsWidth is negative, OR if diffFlags explicitly contains FSL_DIFF_SIDEBYSIDE and sbsWidth is 0, then some default width is used. This parameter has a built-in limit of 255, and values larger than that get truncated to 255. diffFlags is a mask of fsl_diff_flag_t values. Not all of the fsl_diff_flag_t flags are yet [sup]ported. The output is sent to out(outState,...). If out() returns non-0 during processing, processing stops and that result is returned to the caller of this function. Returns 0 on success, FSL_RC_OOM on allocation error, FSL_RC_MISUSE if any arguments are invalid, FSL_RC_TYPE if any of the content appears to be binary (contains embedded NUL bytes), FSL_RC_RANGE if some range is exceeded (e.g. the maximum number of input lines). None of (pA, pB, out) may be NULL. TODOs: - Add a predicate function for outputing only matching differences, analog to fossil(1)'s regex support (but more flexible). - Expose the raw diff-generation bits via the internal API to facilitate/enable the creation of custom diff formats. @see fsl_diff_v2() @deprecated Prefer fsl_diff_v2() for new code. */ FSL_EXPORT int fsl_diff_text(fsl_buffer const *pA, fsl_buffer const *pB, fsl_output_f out, void * outState, short contextLines, short sbsWidth, int diffFlags ); /** Functionally equivalent to: ``` fsl_diff_text(pA, pB, fsl_output_f_buffer, pOut, contextLines, sbsWidth, diffFlags); ``` Except that it returns FSL_RC_MISUSE if !pOut. @see fsl_diff_v2() @deprecated Prefer fsl_diff_v2() for new code. */ FSL_EXPORT int fsl_diff_text_to_buffer(fsl_buffer const *pA, fsl_buffer const *pB, fsl_buffer *pOut, short contextLines, short sbsWidth, int diffFlags ); /** Equivalent to `fcli_setup_v2(argc,argv,fcli.cliFlags,fcli.appHelp)`. @see fcli_pre_setup() @see fcli_setup_v2() @see fcli_end_of_main() @deprecated Its signature will change to fcli_setup_v2()'s at some point. */ FSL_EXPORT int fcli_setup(int argc, char const * const * argv ); /** @internal Performs the same job as fsl_diff_text() but produces the results in the low-level form of an array of "copy/delete/insert triples." This is primarily intended for internal use in other library-internal algorithms, not for client code. Note all FSL_DIFF_xxx flags apply to this form. Returns 0 on success, any number of non-0 codes on error. On success *outRaw will contain the resulting array, which must eventually be fsl_free()'d by the caller. On error *outRaw is not modified. @deprecated Use fsl_diff_v2_raw() instead. */ int fsl__diff_text_raw(fsl_buffer const *p1, fsl_buffer const *p2, int diffFlags, int ** outRaw); /** @deprecated fsl_close_scm_dbs() As of 2021-01-01, this functions identically to fsl_close_scm_dbs(). If fsl_repo_open_xxx() has been used to open a respository db, perhaps indirectly via opening of a checkout, this call closes that db and any corresponding checkout db. Returns 0 on success or if no repo/checkout db is opened. It may propagate an error from the db layer if closing/detaching the db fails. @see fsl_repo_open() @see fsl_repo_create() */ int fsl_repo_close( fsl_cx * const f ); /** @deprecated use fsl_close_scm_dbs() instead As of 2021-01-01, this functions identically to fsl_close_scm_dbs(). If fsl_ckout_open_dir() (or similar) has been used to open a checkout db, this call closes that db, as well as any corresponding repository db. Returns 0 on success or if no checkout db is opened. It may propagate an error from the db layer if closing/detaching the db fails. Returns FSL_RC_MISUSE if f has any transactions pending. This also closes the repository which was implicitly opened for the checkout. */ int fsl_ckout_close( fsl_cx * const f ); #endif /* ORG_FOSSIL_SCM_LIBFOSSIL_DEPRECATED_H_INCLUDED */