libfossil
internal.h
Go to the documentation of this file.
1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* vim: set ts=2 et sw=2 tw=80: */
3#if !defined(ORG_FOSSIL_SCM_FSL_INTERNAL_H_INCLUDED)
4#define ORG_FOSSIL_SCM_FSL_INTERNAL_H_INCLUDED
5/*
6 Copyright 2013-2021 The Libfossil Authors, see LICENSES/BSD-2-Clause.txt
7
8 SPDX-License-Identifier: BSD-2-Clause-FreeBSD
9 SPDX-FileCopyrightText: 2021 The Libfossil Authors
10 SPDX-FileType: Code
11
12 Heavily indebted to the Fossil SCM project (https://fossil-scm.org).
13
14 *****************************************************************************
15 This file declares library-level internal APIs which are shared
16 across the library.
17*/
18
19#include "fossil-scm/repo.h" /* a fossil header MUST come first b/c of config macros */
20#include "fossil-scm/sync.h"
21
22/**
23 Determine whether fsl__mutex_enter() and friends are no-ops. If
24 we'd require C11 then we could use C11's mutexes instead of
25 sqlite3's, but we have those handy so we might as well use them.
26*/
27#if !defined(FSL_ENABLE_MUTEX)
28# if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0
29# define FSL_ENABLE_MUTEX 1
30# else
31# define FSL_ENABLE_MUTEX 0
32# endif
33#endif
34
35#if defined(__cplusplus)
36extern "C" {
37#endif
38
41typedef struct fsl__pq fsl__pq;
43
44/** @internal
45
46 Queue entry type for the fsl__pq class.
47
48 Potential TODO: we don't currently use the (data) member. We can
49 probably remove it.
50*/
52 /** RID of the entry. */
54 /** Raw data associated with this entry. */
55 void * data;
56 /** Priority of this element. */
57 double priority;
58};
59/** @internal
60 Empty-initialized fsl__pq_entry structure.
61*/
62#define fsl__pq_entry_empty_m {0,NULL,0.0}
63
64/** @internal
65
66 A simple priority queue class. Instances _must_ be initialized
67 by copying fsl__pq_empty or fsl__pq_empty_m (depending on where
68 the instance lives).
69*/
70struct fsl__pq {
71 /** Number of items allocated in this->list. */
72 uint16_t capacity;
73 /** Number of items used in this->list. */
74 uint16_t used;
75 /** The queue. It is kept sorted by entry->priority. */
77};
78
79/** @internal
80 Empty-initialized fsl__pq struct, intended for const-copy initialization.
81*/
82#define fsl__pq_empty_m {0,0,NULL}
83
84/** @internal
85 Empty-initialized fsl__pq struct, intended for copy initialization.
86*/
87extern const fsl__pq fsl__pq_empty;
88
89/** @internal
90
91 Clears the contents of p, freeing any memory it owns, but not
92 freeing p. Results are undefined if !p.
93*/
95
96/** @internal
97
98 Insert element e into the queue. Returns 0 on success, FSL_RC_OOM
99 on error. Results are undefined if !p. pData may be NULL.
100*/
102 double v, void *pData);
103
104/** @internal
105
106 Extracts (removes) the first element from the queue (the element
107 with the smallest value) and return its ID. Return 0 if the queue
108 is empty. If pp is not NULL then *pp is (on success) assigned to
109 opaquedata pointer mapped to the entry.
110*/
112
113/** @internal
114
115 Holds one "line" of a fsl__bccache cache.
116*/
118 /**
119 RID of the cached record.
120 */
122 /**
123 Age. Newer is larger.
124 */
126 /**
127 Content of the artifact.
128 */
130};
131/** @internal
132
133 Empty-initialized fsl__bccache_line structure.
134*/
135#define fsl__bccache_line_empty_m { 0,0,fsl_buffer_empty_m }
136
137
138/** @internal
139
140 A cache for tracking the existence of blobs while the internal
141 goings-on of fsl_content_get() and friends are going on.
142
143 "bc" ==> blob cache.
144
145 Historically fossil caches artifacts as their blob content, but
146 libfossil will likely (at some point) to instead cache fsl_deck
147 instances, which contain all of the same data in pre-parsed form.
148 It cost more memory, though. That approach also precludes caching
149 non-structural artifacts (i.e. opaque client blobs).
150
151 Potential TODO: the limits of the cache size are currently
152 hard-coded and changing them "by hand" won't have much effect.
153 We should possibly have an API to tweak these limits.
154*/
156 /**
157 Total amount of buffer memory (in bytes) used by cached content.
158 This does not account for memory held by this->list.
159 */
160 unsigned szTotal;
161 /**
162 Limit on the (approx.) amount of memory (in bytes) which can be
163 taken up by the cached buffers at one time. Fossil's historical
164 value is 50M.
165 */
166 unsigned szLimit;
167 /**
168 Number of entries "used" in this->list.
169 */
170 uint16_t used;
171 /**
172 Approximate upper limit on the number of entries in this->list.
173 This limit may be violated slightly.
174
175 This list gets searched linearly so this number should ideally be
176 relatively small: 3 digits or less. Fossil's historical value is
177 500.
178 */
179 uint16_t usedLimit;
180 /**
181 Number of allocated slots in this->list.
182 */
183 uint16_t capacity;
184 /**
185 Next cache counter age. Higher is newer.
186 */
188
189 /**
190 Gets incremented on each insert for purposes of invalidating
191 this cache. See the notes for fsl__ptl::changeMarker. It's okay
192 if this overflows.
193 */
194 unsigned changeMarker;
195
196 /**
197 List of cached content, ordered by age.
198 */
200 /**
201 RIDs of all artifacts currently in the this->list
202 cache.
203 */
205
206 /**
207 Metrics solely for internal use in looking for
208 optimizations. These are only updated by fsl_content_get().
209 */
210 struct {
211 unsigned hits;
212 unsigned misses;
214};
215/** @internal
216
217 Empty-initialized fsl__bccache structure, intended
218 for const-copy initialization.
219*/
220#define fsl__bccache_empty_m { \
221 .szTotal = 0U, \
222 .szLimit = 20000000U/*Historical fossil value=50M*/, \
223 .used = 0U, .usedLimit = 400U/*Historical fossil value=500*/,\
224 .capacity = 0, \
225 .nextAge = 0, \
226 .changeMarker = 0, \
227 .list = NULL, \
228 .inCache = fsl_id_bag_empty_m, \
229 .metrics = {.hits = 0U, .misses = 0U} \
230}
231
232/** @internal
233
234 Very internal.
235
236 "Manifest cache" for fsl_deck entries encountered during
237 crosslinking. This type is intended only to be embedded in fsl_cx.
238
239 The routines for managing this cache are static in deck.c:
240 fsl__cx_mcache_insert() and fsl__cx_mcache_search().
241
242 The array members in this struct MUST have the same length
243 or results are undefined.
244*/
246 /** Next age value. No clue how the cache will react once this
247 overflows. */
249 /** Counts the number of cache hits. */
250 unsigned hits;
251 /** Counts the number of cache misses. */
252 unsigned misses;
253 /** The virtual age of each deck in the cache. They get evicted
254 oldest first. */
256 /**
257 Stores bitwise copies of decks. Storing a fsl_deck_malloc() deck
258 into the cache requires bitwise-copying is contents, wiping out
259 its contents via assignment from fsl_deck_empty, then
260 fsl_free()'ing it (as opposed to fsl_deck_finalize(), which would
261 attempt to clean up memory which now belongs to the cache's
262 copy).
263
264 Array sizes of 6 and 10 do not appreciably change the hit rate
265 compared to 4, at least not for current (2021-11-18) uses.
266 */
268};
269
270/** @internal
271 Convenience typedef. */
273
274/** @internal
275 Initialized-with-defaults fsl__mcache structure, intended for
276 const-copy initialization. */
277#define fsl__mcache_empty_m { \
278 .nextAge=0, .hits=0, .misses=0, \
279 .aAge = {0,0,0,0}, \
280 .decks = {fsl_deck_empty_m,fsl_deck_empty_m, \
281 fsl_deck_empty_m, fsl_deck_empty_m}\
282}
283
284/**@internal
285 Initialized-with-defaults fsl__mcache structure, intended for
286 non-const copy initialization. */
287extern const fsl__mcache fsl__mcache_empty;
288
289/**
290 This will fail to compile if the arrays fsl__mcache::aAge and
291 fsl__mcache::decks have different sizes. They must have the same
292 size.
293*/
295 ((sizeof(fsl__mcache_empty.aAge)
296 /sizeof(fsl__mcache_empty.aAge[0]))
297 == (sizeof(fsl__mcache_empty.decks)
298 /sizeof(fsl__mcache_empty.decks[0])))
299 ? 1 : -1
300];
301
302/**
303 Expands to a list of the names of all fsl_id_bag members of the
304 fsl__ptl_line struct by invoking macro E(NAME) once for each name.
305*/
306#define fsl__ptl_line_map(E) \
307 E(toVerify/*RIDs of blobs added at this level*/) \
308 E(leafCheck/*Used during the processing of manifests to keep track
309 of "leaf checks" which need to be done downstream.*/) \
310 E(available/*RIDs of known-available content*/) \
311 E(missing/*RIDs of known-missing content*/) \
312 E(dephantomize/*An experiment in queueing up dephantomization work*/)
313
314/**
315 A cache of fsl_cx state which applies per transaction level. We
316 need one of these per level in the transaction stack.
319#define E(X) fsl_id_bag X;
321#undef E
322 /**
323 A poor-man's approach to recognizing when to clear
324 fsl_cx::cache::blobContent when a fsl__ptl stack level is popped.
325 The problem is that fsl__bccache is global to a given fsl_cx
326 instance but may hold RIDs which are invalidated when a
327 transaction level pops. fsl__bccache is not structured such that
328 removing individual entries by RID is easy or cheap, so we
329 invalidate the whole cache if a given transaction level added
330 anything to fsl_cx::cache::blobContent. When pushing a PTL level,
331 we record fsl__bccache::changeMarker here and compare it when the
332 transaction pops. If they differ, the blob content cache is
333 cleared. An improvement to this would be to extend fsl__bccache
334 to be able to remove entries by RID, but that's not on today's
335 proverbial menu.
336 */
337 unsigned changeMarker;
338};
340typedef struct fsl__ptl_line fsl__ptl_line;
341
342/**
343 Enum entries corresponding to fsl__ptl_line members.
345enum fsl__ptl_e {
346 /** Sentinel value needed in slot 0. */
348#define E(X) fsl__ptl_e_ ## X,
350#undef E
352typedef enum fsl__ptl_e fsl__ptl_e;
353
354/**
355 This object manages a stack of fsl__ptl_line objects for a
356 fsl_cx.
358struct fsl__ptl {
359 /** Persistent error code. */
360 int rc;
361 /** Number of levels currently allocated. */
362 uint16_t allocated;
363 /** 0-based level. 0 is for out-of-transaction stuff. */
364 uint16_t level;
365 /**
366 The transaction level in which the first RIDs (in this
367 transaction stack) were added. This is used for determining when
368 to run certain checks. A negative value means no RIDs have been
369 added.
370 */
372 /** Memory living in this->mem. */
374 /** Current line in this->stack. */
376 /** Memory for this->stack. */
378};
380typedef struct fsl__ptl fsl__ptl;
381
382/** Empty-initialized fsl__ptl struct. */
383#define fsl__ptl_empty_m { \
384 .rc = 0, .allocated = 0, .level = 0, \
385 .validateRidLevel = -1, \
386 .stack = NULL, .line = NULL, \
387 .mem = fsl_buffer_empty_m \
388 }
389
390/*
391 The fsl_cx class is documented in main public header. ALL of its
392 members are to be considered private/internal.
393
394 Reminder to self:
395
396 i'd like to rename this to fsl__cx and have a public (typedef struct
397 fsl__cx fsl_cx) like we do for fsl__xfer, but doing so breaks fnc,
398 which uses (struct fsl_cx) in a few places and triggers an "is not a
399 struct" error.
401struct fsl_cx {
402 /**
403 A pointer to the "main" db handle. Exactly which db IS the
404 main db is, because we have three DBs, not generally knowble.
405
406 The internal management of fsl_cx's db handles has changed
407 a couple of times. As of 2022-01-01 the following applies:
408
409 dbMain starts out NULL. When a repo or checkout is opened, dbMain
410 is pointed at the first of those which is opened. When its
411 partner is opened, it is ATTACHed to dbMain. dbMain->role holds
412 a bitmask of fsl_dbrole_e values reflecting which roles are
413 opened/attached to it.
414
415 The db-specific separate handles (this->{repo,ckout}.db) are used
416 to store the name and file path to each db. ONE of those will
417 have a db->dbh value of non-NULL, and that one is the instance
418 which dbMain points to.
419
420 Whichever db is opened first gets its "main" schema aliased to
421 the corresponding fsl_db_role_name() for is role so that SQL code
422 need not care which db is "main" and which is "repo" or
423 "ckout". (Sidebar: when this library was started, the ability to
424 alias a db with another name did not exist, and thus we required
425 a middle-man "main" db to which we ATTACHed the repo and checkout
426 dbs.)
427
428 As of 20211230, f->config.db is its own handle, not ATTACHed with
429 the others. Its db gets aliased to
430 fsl_db_role_name(FSL_DBROLE_CONFIG).
431
432 Internal code should rely as little as possible on the actual
433 arrangement of internal DB handles, and should use
434 fsl_cx_db_repo(), fsl_cx_db_ckout(), and fsl_cx_db_config() to
435 get a handle to the specific db they want. Whether or not they
436 return the same handle or 3 different ones may change at some
437 point, so the public API treats them as separate entities. That
438 is especially important for the global config db, as that one
439 is (for locking reason) almost certain to remain in its own
440 db handle, independent of the repo/checkout dbs.
441
442 In any case, the internals very much rely on the repo and
443 checkout dbs being accessible via a single db handle because the
444 checkout-related SQL requires both dbs for most queries. The
445 internals are less picky about the genuine layout of those
446 handles (e.g. which one, if either, is the MAIN db).
447 */
448 fsl_db * dbMain;
449
450 /**
451 Marker which tells us whether fsl_cx_finalize() needs
452 to fsl_free() this instance or not.
453 */
454 void const * allocStamp;
455
456 /**
457 A bitwise copy of the config object passed to fsl_cx_init() (or
458 some default).
459 */
461
462 struct {
463 /**
464 Holds info directly related to a checkout database.
465 */
466 struct {
467 /**
468 Holds the filename of the current checkout db and possibly
469 related state.
470 */
471 fsl_db db;
472 /**
473 The directory part of an opened checkout db. This is currently
474 only set by fsl_ckout_open_dir(). It contains a trailing slash,
475 largely because that simplifies porting fossil(1) code and
476 appending filenames to this directory name to create absolute
477 paths (a frequently-needed option).
478
479 Useful for doing absolute-to-relative path conversions for
480 checking file lists.
481 */
482 char * dir;
483 /**
484 Optimization: fsl_strlen() of dir. Guaranteed to be set to
485 dir's length if dir is not NULL, else it will be 0.
486 */
488 /**
489 The rid of the current checkout. May be 0 for an empty
490 repo/checkout. Must be negative if not yet known.
491 */
493 /**
494 The UUID of the current checkout. Only set if this->rid is
495 positive. Owned by the containing fsl_cx object.
496 */
498 /**
499 Julian mtime of the checkout version, as reported by the
500 [event] table.
501 */
502 double mtime;
503 } ckout;
504
505 /**
506 Holds info directly related to a repo database.
507 */
508 struct {
509 /**
510 Holds the filename of the current repo db and possibly related
511 state.
512 */
513 fsl_db db;
514 /**
515 The default user name, for operations which need one.
516 See fsl_cx_user_set().
517 */
518 char * user;
519
520 /** The 'main-branch' repo config setting, defaulting to trunk. */
522 } repo;
523
524 /**
525 Holds info directly related to a global config database.
526 */
527 struct {
528 /**
529 Holds the filename of the current global config db and possibly
530 related state. This handle is managed separately from the
531 repo/ckout handles because this db is shared by all fossil
532 instances are we have to ensure that we don't lock it for
533 longer than necessary, thus this db may get opened and closed
534 multiple times within even within a short-lived application.
535 */
537 } gconfig;
543 } db;
544
545 /**
546 State for incrementally preparing a checkin operation.
547 */
548 struct {
549 /**
550 Holds a list of "selected files" in the form
551 of vfile.id values.
552 */
554
555 /**
556 The deck used for incrementally building certain parts of a
557 checkin.
558 */
560 } ckin;
561
562 /**
563 Confirmation callback. Used by routines which may have to
564 interactively ask a user to confirm things.
565 */
567
568 /**
569 Output channel used by fsl_output() and friends.
570
571 This was added primarily so that fossil client apps can share a
572 single output channel which the user can swap out, e.g. to direct
573 all output to a UI widget or a file.
574
575 Though the library has adamantly avoided adding a "warning"
576 output channel, features like:
577
578 https://fossil-scm.org/home/info/52a389d3dbd4b6cc
579
580 arguably call for one.
581 */
583
584 /**
585 Can be used to tie client-specific data to the context. Its
586 finalizer is called when fsl_cx_finalize() cleans up. The library
587 does not use this state. It is intended primarily for tying,
588 e.g., scripting-engine information to the context, e.g. mapping a
589 scripting engine context to this one for later use in fossil-side
590 callbacks.
591 */
593
594 /**
595 Holds error state. As a general rule, this information is updated
596 only by routines which need to return more info than a simple
597 integer error code. e.g. this is often used to hold
598 db-driver-provided error state. It is not used by "simple"
599 routines for which an integer code always suffices. APIs which
600 set this should denote it with a comment like "updates the
601 context's error state on error."
602 */
604
605 /**
606 Reuseable scratchpads for low-level file canonicalization
607 buffering and whatnot. Not intended for huge content: use
608 this->fileContent for that. This list should stay relatively
609 short, as should the buffers (a few kb each, at most).
610
611 @see fsl__cx_scratchpad()
612 @see fsl__cx_scratchpad_yield()
613 */
614 struct {
615 /**
616 Strictly-internal temporary buffers we intend to reuse many
617 times, mostly for filename canonicalization, holding hash
618 values, and small encoding/decoding tasks. These must never be
619 used for values which will be long-lived, nor are they intended
620 to be used for large content, e.g. reading files, with the
621 possible exception of holding versioned config settings, as
622 those are typically rather small. They must also not be held
623 while recursion back into a function holding one of these is
624 possible.
625
626 If needed, the lengths of this->buf[] and this->used[] may be
627 extended, but anything beyond 8, maybe 10, seems a bit extreme.
628 They should only be increased if we find code paths which
629 require it. As of this writing (2021-03-17), the peak
630 concurrently used was 5. In any case fsl__cx_scratchpad() fails
631 fatally if it needs more than it has, so we won't/can't fail to
632 overlook such a case.
633 */
634 fsl_buffer buf[8];
635 /**
636 Flags telling us which of this->buf is currenly in use.
637 */
638 bool used[8];
639 /**
640 A cursor _hint_ to try to speed up fsl__cx_scratchpad() by about
641 half a nanosecond, making it O(1) instead of O(small N) for the
642 common case.
643 */
644 short next;
645 /**
646 A scratchpad specific to fsl__cx_emit() and friends.
647 */
649 /**
650 A scratchpad specific to fsl_cx_format() and friends. This one
651 has to account for potential recursion.
652 */
654 } scratchpads;
655
656 /**
657 Flags, some (or one) of which is runtime-configurable by the
658 client (see fsl_cx_flags_e). We can get rid of this and add the
659 flags to the cache member along with the rest of them.
660 */
662
663 /**
664 Error flag which is intended to be set via signal handlers or a
665 UI thread to tell this context to cancel any currently
666 long-running operation. Not all operations honor this check, but
667 the ones which are prone to "exceedingly long" operation (at
668 least a few seconds) do.
669 */
670 volatile int interrupted;
671
672 /**
673 List of callbacks for deck crosslinking purposes.
674 */
676
677 /**
678 A place for caching generic things.
679 */
680 struct {
681 /**
682 If true, skip "dephantomization" of phantom blobs. This is a
683 detail from fossil(1) with as-yet-undetermined utility. It's
684 apparently only used during the remote-sync process, which this
685 API does not (as of 2021-10) yet have.
686 */
688
689 /**
690 Whether or not a running commit process should be marked as
691 private. This member is used for communicating this flag
692 through multiple levels of API.
693 */
694 bool markPrivate;
695
696 /**
697 True if fsl__crosslink_begin() has been called but
698 fsl__crosslink_end() is still pending.
699 */
700 bool isCrosslinking;
701
702 /**
703 Flag indicating that only cluster control artifacts should be
704 processed by manifest crosslinking. This will only be relevant
705 if/when the sync protocol is implemented.
706 */
708
709 /**
710 Is used to tell the content-save internals that a "final
711 verification" (a.k.a. verify-before-commit) is underway.
712 */
713 bool inFinalVerify;
714
715 /**
716 True when a sync is active, to prevent recursive attempts to
717 sync.
718 */
719 bool isSyncing;
720
721 /**
722 Specifies whether SOME repository-level file-name
723 comparisons/searches will work case-insensitively. <0 means
724 not-yet-determined, 0 = no, >0 = yes.
725 */
726 short caseInsensitive;
727
728 /**
729 Cached copy of the allow-symlinks config option, because it is
730 (hypothetically) needed on many stat() call. Negative
731 value=="not yet determined", 0==no, positive==yes. The negative
732 value means we need to check the repo config resp. the global
733 config to see if this is on.
734
735 As of late 2020, fossil(1) is much more restrictive with
736 symlinks due to vulnerabilities which were discovered by a
737 security researcher, and we definitely must not default any
738 symlink-related features to enabled/on. As of Feb. 2021, my
739 personal preference, and very likely plan of attack, is to only
740 treat SCM'd symlinks as if symlinks support is disabled. It's
741 very unlikely that i will implement "real" symlink support but
742 would, *solely* for compatibility with fossil(1), be convinced
743 to permit such changes if someone else wants to implement them.
744 Patches are joyfully considered!
745 */
746 short allowSymlinks;
747
748 /**
749 Indicates whether or not this repo has ever seen a delta
750 manifest. If none has ever been seen then the repository will
751 prefer to use baseline (non-delta) manifests. Once a delta is
752 seen in the repository, the checkin algorithm is free to choose
753 deltas later on unless it's otherwise prohibited, e.g. by the
754 `forbid-delta-manifests` config db setting.
755
756 This article provides an overview to the topic delta manifests
757 and essentially debunks their ostensible benefits:
758
759 https://fossil-scm.org/home/doc/tip/www/delta-manifests.md
760
761 Values: negative==undetermined, 0==no, positive==yes. This is
762 updated when a repository is first opened and when new content
763 is written to it.
764 */
765 short seenDeltaManifest;
766
767 /**
768 Records whether this repository has an FTS search
769 index. <0=undetermined, 0=no, >0=yes.
770 */
771 short searchIndexExists;
772
773 /**
774 Cache for the `manifest` config setting, as used by
775 fsl_ckout_manifest_setting(), with the caveat that
776 if the setting changes after it is cached, we won't necessarily
777 see that here!
778 */
779 short manifestSetting;
780
781 /**
782 Record ID of rcvfrom entry during commits. This is likely to
783 remain unused in libf until/unless the sync protocol is
784 implemented.
785
786 2025-07-21: this will probably need to be manipulated by
787 fsl__xfer. rcvId is used in fsl__content_put_ex() but it's
788 historically (in this library, not fossil(1)) always been 0.
789 Setting the rcvId requires high-level info that fossil(1) uses,
790 and it's only really relevant for the sync layer.
791 */
793
794 /**
795 A place for temporarily holding file content. We use this in
796 places where we have to loop over files and read their entire
797 contents, so that we can reuse this buffer's memory if
798 possible. The loop and the reading might be happening in
799 different functions, though, and some care must be taken to
800 avoid use in two functions concurrently.
801
802 All access to this must be acquired by fsl__cx_content_buffer()
803 and released by fsl__cx_content_buffer_yield().
804 */
806
807 /**
808 Reusable buffer for creating and fetching deltas via
809 fsl_content_get() and fsl__content_deltify(). The number of
810 allocations this actually saves is pretty small.
811 */
813
814 /**
815 fsl_content_get() cache.
816 */
818
819 /**
820 Per-transaction-level cache.
821 */
823
824 /**
825 An internal cache for fsl__content_mark_availble(). This is
826 only used in that routine but it's called frequently during
827 checkins and sync.
828 */
830
831 /**
832 Infrastructure for fsl_mtime_of_manifest_file(). It
833 remembers the previous RID so that it knows when it has to
834 invalidate/rebuild its ancestry cache.
835 */
837 /**
838 The "project-code" config option. This is primarily for use
839 with the sync protocol. It is managed by
840 fsl_repo_project_code().
841 */
842 char * projectCode;
843
844 /**
845 Internal optimization to avoid duplicate fsl_stat() calls
846 across two functions in some cases.
847 */
849
850 /**
851 Parsed-deck cache.
852 */
854
855 /**
856 Holds various glob lists. That said... these features are
857 actually app-level stuff which the library itself does not
858 resp. should not enforce. We can keep track of these for users
859 but the library internals _generally_ have no business using
860 them.
861
862 _THAT_ said... these have enough generic utility that we can
863 justify storing them and _optionally_ applying them. See
864 fsl_checkin_opt for an example of where we do this.
865 */
866 struct {
867 /**
868 Holds the "ignore-glob" globs.
869 */
871 /**
872 Holds the "binary-glob" globs.
873 */
875 /**
876 Holds the "crnl-glob" globs.
877 */
879 } globs;
880
881 /**
882 Very-frequently-used SQL statements.
883 */
884 struct {
885/*
886 This macro greatly simplifies maintenance of the caches fsl_stmt
887 objects elsewhere, believe it or not. The 1st argument to E is the
888 name of the fsl_cx::cache::stmt member. The 2nd argument is the SQL
889 of that statement.
890
891 Potential TODO: add a fsl_dbrole_e value to each so that we
892 centrally know which db to check for (for error-reporting purposes)
893 before preparation.
895#define fsl__cx_cache_stmt_map(E) \
896 E(deltaR2S,"SELECT srcid FROM delta WHERE rid=?1") \
897 E(deltaS2R,"SELECT rid FROM delta WHERE srcid=?1") \
898 E(uuidToRid,\
899 "SELECT rid FROM blob WHERE uuid=?1") \
900 E(ridToUuid,\
901 "SELECT uuid FROM blob WHERE rid=?1") \
902 E(ridIsLeaf,\
903 "SELECT 1 FROM plink " \
904 "WHERE pid=?1 " \
905 "AND coalesce(" \
906 "(SELECT value FROM tagxref " \
907 "WHERE tagid=8/*FSL_TAGID_BRANCH*/ AND rid=?1), " \
908 "?2 /*main branch name*/)" \
909 "=coalesce((SELECT value FROM tagxref " \
910 "WHERE tagid=8/*FSL_TAGID_BRANCH*/ " \
911 "AND rid=plink.cid), " \
912 "?2 /*main branch name*/)") \
913 E(ridIsPrivate,"SELECT 1 FROM private WHERE rid=?1") \
914 E(contentSize,"SELECT size FROM blob WHERE rid=?1") \
915 E(contentBlob,"SELECT content, size FROM blob WHERE rid=?1") \
916 E(uuidIsShunned,"SELECT 1 FROM shun WHERE uuid=?1") \
917 E(contentNew,\
918 "INSERT INTO blob(rcvid,size,uuid,content) " \
919 "VALUES(0,-1,?1,NULL) " \
920 "RETURNING rid") \
921 E(insertPhantomRid,"INSERT OR IGNORE INTO unclustered VALUES(?1)") \
922 E(insertPrivateRid,"INSERT OR IGNORE INTO private VALUES(?1)") \
923 E(insertUnclusteredRid,"INSERT OR IGNORE INTO unclustered VALUES(?1)") \
924 E(insertUnsentRid,"INSERT OR IGNORE INTO unsent VALUES(?1)") \
925 E(replaceDelta,\
926 "REPLACE INTO delta(rid,srcid) VALUES(?1,?2)") \
927 E(contentUndeltify,\
928 "UPDATE blob SET content=?1, size=?2 WHERE rid=?3") \
929 E(blobRidSize,"SELECT rid, size FROM blob WHERE uuid=?1") \
930 E(blobUpdateContent,\
931 "UPDATE blob SET content=?1 WHERE rid=?2") \
932 E(phantomPopulate,\
933 "UPDATE blob SET rcvid=?1, size=?2, " \
934 "content=?3 WHERE rid=?4") \
935 E(blobInsertFull, \
936 "INSERT INTO blob (rcvid,size,uuid,content) " \
937 "VALUES(?1,?2,?3,?4) RETURNING rid") \
938 E(leafInsert, \
939 "INSERT OR IGNORE INTO leaf VALUES (?1)") \
940 E(leafDelete, \
941 "DELETE FROM leaf WHERE rid=?1") \
942 E(parentsOf, \
943 "SELECT pid FROM plink WHERE cid=?1 AND pid>0") \
944 /*
945 TODO. Something akin to:
947 WITH RECURSIVE
948 dchain(rid,srcid,level) AS (
949 SELECT ?1 rid, NULL srcid, 0 level
950 UNION ALL
951 SELECT delta.rid, delta.srcid, dchain.level+1
952 FROM delta JOIN dchain ON delta.srcid=dchain.rid
953 ORDER BY 2
954 )
955 SELECT rid, srcid FROM dchain WHERE level>0
957 i.e.: for RID ?1, get a list of all deltas which
958 depend on this. (Is it really all?).
959
960 Remember that we can have multiple paths to a parent,
961 as in this simulated delta table:
962
963 drop table if exists dmap;
964 create temp table dmap(rid INTEGER NOT NULL, srcid INTEGER NOT NULL);
965 insert into dmap values(2,4),(4,6),(6,8),(8,10);
966 insert into dmap values(1,11),(11,10);
967 insert into dmap values(20,30),(30,0);
968
969 For a ?1 of 10 that will emit:
970
971 rid|srcid
972 8|10
973 6|8
974 4|6
975 2|4
976 11|10 -- note that we re-visit the root here
977 1|11
978 */ \
979 E(deltaChainForRid,"")
980
981#define STMT(MEMBER,IGNORED) fsl_stmt MEMBER;
983#undef STMT
985 } stmt;
986
987 /**
988 Holds a list of temp-dir names. Must be allocated using
989 fsl_temp_dirs_get() and freed using fsl_temp_dirs_free().
990 */
991 char **tempDirs;
992 } cache;
993
994 /**
995 Ticket-related information.
996 */
997 struct {
998 /**
999 Holds a list of (fsl_card_J*) records representing custom
1000 ticket table fields available in the db.
1001
1002 Each entry's flags member denotes (using fsl_card_J_flags)
1003 whether that field is used by the ticket or ticketchng
1004 tables.
1005
1006 TODO, eventually: add a separate type for these entries. We
1007 use fsl_card_J because the infrastructure is there and they
1008 provide what we need, but fsl_card_J::flags only exists for
1009 this list. A custom type would be smaller than fsl_card_J
1010 (only two members) but adding it requires adding some
1011 infrastructure which isn't worth the effort at the moment.
1012 */
1015 /**
1016 Gets set to true (at some point) if the client has the
1017 ticket db table.
1018 */
1019 bool hasTicket;
1020
1021 /**
1022 Gets set to true (at some point) if the client has the
1023 ticket.tkt_ctime db field.
1024 */
1025 bool hasCTime;
1026
1027 /**
1028 Gets set to true (at some point) if the client has the
1029 ticketchng db table.
1030 */
1031 bool hasChng;
1032
1033 /**
1034 Gets set to true (at some point) if the client has the
1035 ticketchng.rid db field.
1036 */
1037 bool hasChngRid;
1038
1039 /**
1040 The name of the ticket-table field which refers to a ticket's
1041 title. Default = "title". The bytes are owned by this object.
1042 */
1043 char * titleColumn;
1044
1045 /**
1046 The name of the ticket-table field which refers to a ticket's
1047 status. Default = "status". The bytes are owned by this object.
1048 */
1049 char * statusColumn;
1050 } ticket;
1051
1052 struct {
1053 struct {
1054 /**
1055 Number of times the internal content cache was used.
1056 */
1058 /**
1059 Total of the number of "used" bytes of the content cache
1060 each time it was relinquished.
1061 */
1063
1064 /**
1065 The maximum buffer capacity the content buffer had at
1066 relenquish-time.
1067 */
1069
1070 /**
1071 The number of times the content cache buffer was trimmed
1072 below the built-in maximum size.
1073 */
1075 } content;
1077};
1078
1079/** @internal
1080 Initialized-with-defaults fsl_cx instance.
1081*/
1082extern const fsl_cx fsl__cx_empty;
1083
1084/**
1085 Ensure that fsl_cx::scratchpads::buf/used have the same array size.
1086*/
1088 ((sizeof(fsl__cx_empty.scratchpads.buf)
1089 /sizeof(fsl__cx_empty.scratchpads.buf[0]))
1090 == (sizeof(fsl__cx_empty.scratchpads.used)
1091 /sizeof(fsl__cx_empty.scratchpads.used[0])))
1092 ? 1 : -1
1093];
1094
1096 TODO:
1097
1098 int fsl_buffer_append_getenv( fsl_buffer * b, char const * env )
1099
1100 Fetches the given env var and appends it to b. Returns FSL_RC_NOT_FOUND
1101 if the env var is not set. The primary use for this would be to simplify
1102 the Windows implementation of fsl_find_home_dir().
1104
1105
1106/** @internal
1107
1108 Expires the single oldest entry in c. Returns true if it removes
1109 an item, else false.
1110*/
1112
1113/** @internal
1114
1115 Add an entry to the content cache.
1116
1117 This routines transfers the contents of pBlob over to c,
1118 regardless of success or failure. The cache will deallocate the
1119 memory when it has finished with it.
1120
1121 If the cache cannot add the entry due to cache-internal
1122 constraints, as opposed to allocation errors, it clears the buffer
1123 (for consistency's sake) and returns 0.
1124
1125 Returns 0 on success, FSL_RC_OOM on allocation error. Has undefined
1126 behaviour if !c, rid is not semantically valid, !pBlob. An empty
1127 blob is normally semantically illegal but is not strictly illegal
1128 for this cache's purposes.
1129*/
1131 fsl_buffer * pBlob);
1132
1133/** @internal
1134
1135 Frees all memory held by c, and clears out c's state, but does
1136 not free c. Results are undefined if !c.
1139
1140/** @internal
1141
1142 Resets all bags associated with the given cache and frees all
1143 cached buffer memory, but keeps any fsl_id_bag memory intact for
1144 re-use. This does not reset the hit/miss metrics.
1145*/
1147
1148
1149/** @internal
1150
1151 Checks f->cache.blobContent to see if rid is available in the
1152 repository opened by f.
1153
1154 Returns 0 if the content for the given rid is available in the
1155 repo or the cache. Returns FSL_RC_NOT_FOUND if it is not in the
1156 repo nor the cache. Returns some other non-0 code for "real
1157 errors," e.g. FSL_RC_OOM if a cache allocation fails. This
1158 operation may update the cache's contents.
1159
1160 If this function detects a loop in artifact lineage, it fails an
1161 assert() in debug builds and returns FSL_RC_CONSISTENCY in
1162 non-debug builds. That doesn't happen in real life, though.
1163
1164 Reminder to self: it should arguably return FSL_RC_PHANTOM if it's
1165 a phantom but the next call for that same rid would pull from
1166 f->cache.blobContent.missing and lose the distinction between
1167 "wasn't found" and "is a phantom", so would have to return
1168 FSL_RC_NOT_FOUND. If we ever need another fsl_id_bag for tracking
1169 phantoms, we can adjust this to return FSL_RC_PHANTOM by checking
1170 that bag for the RID.
1171*/
1173
1174/** @internal
1175
1176 This is THE ONLY ROUTINE IN THE LIBRARY which is permitted to add
1177 content to the blob table. Only one other routine
1178 (fsl__phantom_new()) adds new blob entries, but that one does not
1179 add blobs with content.
1180
1181 This writes the given buffer content into the repository
1182 database's blob tabe. It Returns the record ID via outRid (if it
1183 is not NULL). If the content is already in the database (as
1184 determined by a lookup of its hash against blob.uuid), this
1185 routine fetches the RID (via *outRid) but has no side effects in
1186 the repo.
1187
1188 If srcId is >0 then pBlob must contain delta content from
1189 the srcId record. srcId might be a phantom.
1190
1191 pBlob is normally uncompressed text, but if uncompSize>0 then the
1192 pBlob value is assumed to be compressed (via fsl_buffer_compress()
1193 or equivalent) and uncompSize is its uncompressed size. If
1194 uncompSize>0 then zUuid must be valid and refer to the hash of the
1195 _uncompressed_ data (which is why this routine does not calculate
1196 it for the client).
1197
1198 Sidebar 2025-08-04: it is legal for the uncompressed size to be 0
1199 when the content is compressed (and larger). That case can't be
1200 represented with the above semantics. Do we actually handle the
1201 empty-file case properly?
1202
1203 Sidebar: we "could" use fsl_buffer_is_compressed() and friends
1204 to determine if pBlob is compressed and get its decompressed
1205 size, then remove the uncompSize parameter, but that would
1206 require that this function decompress the content to calculate
1207 the hash. Since the caller likely just compressed it, that seems
1208 like a huge waste.
1209
1210 zUuid is the UUID of the artifact, if it is not NULL. When
1211 srcId is specified then zUuid must always be specified. If
1212 srcId is zero, and zUuid is zero then the correct zUuid is
1213 computed from pBlob. If zUuid is not NULL then this function
1214 asserts (in debug builds) that fsl_is_uuid() returns true for
1215 zUuid.
1216
1217 If isPrivate is true or if f->cache.markPrivate is true, the blob
1218 is created as a private record.
1219
1220 If the record already exists but is a phantom, the pBlob content
1221 is inserted and the phatom becomes a real record.
1222
1223 The original content of pBlob is not disturbed. The caller continues
1224 to be responsible for pBlob. This routine does *not* take over
1225 responsibility for freeing pBlob.
1226
1227 If outRid is not NULL then on success *outRid is assigned to the
1228 RID of the underlying blob record.
1229
1230 Returns 0 on success and there are too many potential error cases
1231 to name - this function is a massive beast.
1232
1233 On success, the new blob's RID is queued up for pre-commit content
1234 validation. If this is the first call to this function in the
1235 current transaction stack, the RID is queued in the COMMIT handler
1236 for the _parent_ transaction. Subsequent calls will cause the RID
1237 to be queued in that same transaction level. We cannot validate in
1238 _this_ function because the validation would trigger at the end of
1239 the transaction level which _this_ function installs. Content
1240 validation has to be delayed until we believe we have all content
1241 which will be injected in the current transaction stack.
1242
1243 @see fsl__content_put()
1244*/
1246 fsl_buffer const * pBlob,
1247 fsl_uuid_cstr zUuid, fsl_id_t srcId,
1248 fsl_size_t uncompSize, bool isPrivate,
1249 fsl_id_t * outRid);
1250/** @internal
1251
1252 Equivalent to fsl__content_put_ex(f,pBlob,NULL,0,0,false,newRid).
1253
1254 This must only be used for saving raw (non-delta) content.
1255
1256 @see fsl__content_put_ex()
1257*/
1258int fsl__content_put( fsl_cx * f,
1259 fsl_buffer const * pBlob,
1260 fsl_id_t * newRid);
1261
1262
1263/** @internal
1264
1265 If the given blob ID refers to deltified repo content, this routine
1266 undeltifies it and replaces its content with its expanded
1267 form.
1268
1269 Returns 0 on success, FSL_RC_NOT_A_REPO if f has no opened
1270 repository, FSL_RC_RANGE if rid is not positive, and any number of
1271 other potential errors during the db and content operations. This
1272 function treats already unexpanded content as success.
1273
1274 @see fsl__content_deltify()
1275*/
1277
1278
1279/** @internal
1280
1281 The converse of fsl__content_undeltify(), this replaces the storage
1282 of the given blob record so that it is a delta of srcid.
1283
1284 If rid is already a delta from some other place then no conversion
1285 occurs and this is a no-op unless force is true, which case the
1286 content is undeltified and re-delta'd against srcid.
1287
1288 If rid's contents are not available because the the rid is a
1289 phantom or depends to one, no delta is generated and 0 is
1290 returned.
1291
1292 It never generates a delta that carries a private artifact into
1293 a public artifact. Otherwise, when we go to send the public
1294 artifact on a sync operation, the other end of the sync will
1295 never be able to receive the source of the delta. It is OK to
1296 delta private->private, public->private, and public->public.
1297 Just no private->public delta. For such cases this function
1298 returns 0, as opposed to FSL_RC_ACCESS or some similar code, and
1299 leaves the content untouched.
1300
1301 If srcid is a delta that depends on rid, then srcid is
1302 converted to undelta'd text.
1303
1304 If either rid or srcid contain less than some "small,
1305 unspecified number" of bytes (currently 50), or if the resulting
1306 delta does not achieve a compression of at least 25%, the rid is
1307 left untouched.
1308
1309 Returns 0 if a delta is successfully made or none needs to be
1310 made, non-0 on error.
1311
1312 Requires that fsl_cx_txn_level() be greater than 0.
1313
1314 @see fsl__content_undeltify()
1315*/
1317 fsl_id_t srcid, bool force);
1318
1319
1320/** @internal
1321
1322 Creates a new phantom blob with the given UUID and return its
1323 artifact ID via *newId. Returns 0 on success, any of many codes on
1324 error. If isPrivate is true _or_ f has been flagged as being in
1325 "private mode" then the new content is flagged as private. newId
1326 may be NULL, but if it is then the caller will have to find the
1327 record id himself by using the UUID (see fsl_uuid_to_rid()).
1328*/
1330 bool isPrivate, fsl_id_t * newId );
1331
1332/** @internal
1333
1334 Schedules a leaf check for "rid" and its parents. Returns 0 on
1335 success.
1336*/
1338
1339/** @internal
1340
1341 Perform all pending leaf checks. Returns 0 on success or if it
1342 has nothing to do.
1343*/
1345
1346/** @internal
1347
1348 Inserts a tag into f's repo db. It does not create the related
1349 control artifact - use fsl_tag_an_rid() for that.
1351 rid is the artifact to which the tag is being applied.
1352
1353 srcId is the artifact that contains the tag. It is often, but
1354 not always, the same as rid. This is often the RID of the
1355 manifest containing tags added as part of the commit, in which
1356 case rid==srcId. A Control Artifact which tags a different
1357 artifact will have rid!=srcId.
1358
1359 mtime is the Julian timestamp for the tag. Defaults to the
1360 current time if mtime <= 0.0.
1361
1362 If outRid is not NULL then on success *outRid is assigned the
1363 record ID of the generated tag (the tag.tagid db field).
1364
1365 If a more recent (compared to mtime) entry already exists for
1366 this tag/rid combination then its tag.tagid is returned via
1367 *outRid (if outRid is not NULL) and no new entry is created.
1368
1369 Returns 0 on success, and has a huge number of potential error
1370 codes.
1371*/
1372int fsl__tag_insert( fsl_cx * f,
1373 fsl_tagtype_e tagtype,
1374 char const * zTag,
1375 char const * zValue,
1376 fsl_id_t srcId,
1377 double mtime,
1378 fsl_id_t rid,
1379 fsl_id_t *outRid );
1380/** @internal
1381
1382 Propagate all propagatable tags in artifact pid to the children of
1383 pid. Returns 0 on... non-error. Returns FSL_RC_RANGE if pid<=0.
1384*/
1386
1387/** @internal
1388
1389 Propagates a tag through the various internal pipelines.
1390
1391 pid is the artifact id to whose children the tag should be
1392 propagated.
1393
1394 tagid is the id of the tag to propagate (the tag.tagid db value).
1395
1396 tagType is the type of tag to propagate. Must be either
1397 FSL_TAGTYPE_CANCEL or FSL_TAGTYPE_PROPAGATING. Note that
1398 FSL_TAGTYPE_ADD is not permitted. The tag-handling internals
1399 (other than this function) translate ADD to CANCEL for propagation
1400 purposes. A CANCEL tag is used to stop propagation. (That's a
1401 historical behaviour inherited from fossil(1).) A potential TODO
1402 is for this function to simply treat ADD as CANCEL, without
1403 requiring that the caller be sure to never pass an ADD tag.
1404
1405 origId is the artifact id of the origin tag if tagType ==
1406 FSL_TAGTYPE_PROPAGATING, otherwise it is ignored.
1407
1408 zValue is the optional value for the tag. May be NULL.
1409
1410 mtime is the Julian timestamp for the tag. Must be a valid time
1411 (no defaults here).
1412
1413 This function is unforgiving of invalid values/ranges, and may assert
1414 in debug mode if passed invalid ids (values<=0), a NULL f, or if f has
1415 no opened repo.
1416*/
1418 fsl_tagtype_e tagType,
1419 fsl_id_t pid,
1420 fsl_id_t tagid,
1421 fsl_id_t origId,
1422 const char *zValue,
1423 double mtime );
1424
1425/** @internal
1426
1427 Generates an fsl_appendf()-formatted message to stderr and
1428 fatally aborts the application by calling exit(). This is only
1429 (ONLY!) intended for us as a placeholder for certain test cases
1430 and is neither thread-safe nor reantrant.
1432 fmt may be empty or NULL, in which case only the code and its
1433 fsl_rc_cstr() representation are output.
1434
1435 This function does not return.
1436*/
1437void fsl__fatal( int code, char const * fmt, ... )
1438#ifdef __GNUC__
1439 __attribute__ ((noreturn))
1440#endif
1441 ;
1442
1443/** @internal
1444
1445 Translate a normalized, repo-relative filename into a
1446 filename-id (fnid). Create a new fnid if none previously exists
1447 and createNew is true. On success returns 0 and sets *rv to the
1448 filename.fnid record value. If createNew is false and no match
1449 is found, 0 is returned but *rv will be set to 0. Returns non-0
1450 on error. Results are undefined if any parameter is NULL.
1451
1452
1453 In debug builds, this function asserts that no pointer arguments
1454 are NULL and that f has an opened repository.
1455*/
1456int fsl__repo_filename_fnid2( fsl_cx * f, char const * filename,
1457 fsl_id_t * rv, bool createNew );
1458
1460/** @internal
1461
1462 Clears and frees all (char*) members of db but leaves the rest
1463 intact. If alsoBuffers is true then the error state and prep
1464 buffer are also freed, else they are kept as well.
1465*/
1466void fsl__db_clear_strings(fsl_db * db, bool alsoBuffers );
1467
1468/** @internal
1470 Returns 0 if db appears to have a current repository schema, 1
1471 if it appears to have an out of date schema, and -1 if it
1472 appears to not be a repository. Results are undefined if db is
1473 NULL or not opened.
1474*/
1476
1477
1478/** @internal
1479
1480 Flags for APIs which add phantom blobs to the repository. The
1481 values in this enum derive from fossil(1) code and should not be
1482 changed without careful forethought and (afterwards) testing. A
1483 phantom blob is a blob about whose existence we know but for which
1484 we have no content. This normally happens during sync or rebuild
1485 operations, but can also happen when artifacts are stored directly
1486 as files in a repo (like this project's repository does, storing
1487 artifacts from *other* projects for testing purposes).
1488*/
1489enum fsl__phantom_e {
1491 Indicates to fsl__uuid_to_rid2() that no phantom artifact
1492 should be created.
1493*/
1495/**
1496 Indicates to fsl__uuid_to_rid2() that a public phantom
1497 artifact should be created if no artifact is found.
1498*/
1500/**
1501 Indicates to fsl__uuid_to_rid2() that a private phantom
1502 artifact should be created if no artifact is found.
1503*/
1505};
1506typedef enum fsl__phantom_e fsl__phantom_e;
1508/** @internal
1509
1510 Works like fsl_uuid_to_rid(), with these differences:
1511
1512 - uuid is required to be a complete UUID, not a prefix.
1513
1514 - If it finds no entry and the mode argument specifies so then it
1515 will add either a public or private phantom entry and return its
1516 new rid. If mode is FSL_PHANTOM_NONE then this this behaves just
1517 like fsl_uuid_to_rid().
1518
1519 Returns a positive value on success, 0 if it finds no entry and
1520 mode==FSL_PHANTOM_NONE, and1 a negative value on error (e.g. if
1521 fsl_is_uuid(uuid) returns false). Errors which happen after
1522 argument validation will "most likely" update f's error state
1523 with details.
1524*/
1526 fsl__phantom_e mode );
1527
1528/** @internal
1529
1530 Schedules the given rid to be verified before it is commited, but
1531 whether the validation will be done at the commit of the current
1532 transaction level or a higher-up one is as-yet unspecified . This
1533 is used by routines which add artifact records to the blob table.
1534
1535 The only error case, assuming the arguments are valid, is an
1536 allocation error while appending rid to the internal to-verify
1537 queue.
1538
1539 @see fsl__repo_verify_at_commit()
1540 @see fsl_repo_verify_cancel()
1541*/
1543
1544/** @internal
1545
1546 Clears the current transaction level's verify-at-commit list of
1547 RIDs.
1549 @see fsl__repo_verify_at_commit()
1550 @see fsl__repo_verify_before_commit()
1551*/
1553
1554/** @internal
1555
1556 Processes all pending verify-at-commit entries for the current
1557 transaction level and clears the to-verify list. Returns 0 on
1558 success. On error f's error state will likely be updated.
1559
1560 ONLY call this from fsl_db_txn_end() or its delegate (if
1561 refactored).
1563 Verification calls fsl_content_get() to "unpack" content added in
1564 the current transaction. If fetching the content (which applies
1565 any deltas it may need to) fails or its hash does not match its
1566 blob.uuid value then this routine fails and returns non-0.
1567
1568 @see fsl_repo_verify_cancel()
1569 @see fsl__repo_verify_before_commit()
1570*/
1572
1573/** @internal
1574
1575 Removes all entries from the repo's blob table which are listed
1576 in the shun table. Returns 0 on success. This operation is
1577 wrapped in a transaction. Delta content which depend on
1578 to-be-shunned content are replaced with their undeltad forms.
1579
1580 Returns 0 on success. On error, its transaction is aborted or a
1581 pseudo-nested transaction is set into a rollback state.
1582*/
1584
1585/** @internal.
1586
1587 Return a pointer to a string that contains the RHS of an SQL IN
1588 operator which will select config.name values that are part of
1589 the configuration that matches iMatch (a bitmask of
1590 fsl_configset_e values). Ownership of the returned string is
1591 passed to the caller, who must eventually pass it to
1592 fsl_free(). Returns NULL on allocation error.
1593
1594 Reminder to self: this is part of the infrastructure for copying
1595 config state from an existing repo when creating new repo.
1596*/
1597char *fsl__config_inop_rhs(int iMask);
1598
1599/** @internal
1601 Return a pointer to a string that contains the RHS of an IN
1602 operator that will select config.name values that are in the
1603 list of control settings. Ownership of the returned string is
1604 passed to the caller, who must eventually pass it to
1605 fsl_free(). Returns NULL on allocation error.
1607 Reminder to self: this is part of the infrastructure for copying
1608 config state from an existing repo when creating new repo.
1609*/
1611
1612/** @internal
1613
1614 Creates the ticket and ticketchng tables in f's repository db,
1615 DROPPING them if they already exist. The schema comes from
1616 fsl_schema_ticket().
1617
1618 TODO? Add a flag specifying whether to drop or keep existing
1619 copies.
1620
1621 Returns 0 on success.
1622*/
1624
1625/** @internal
1626
1627 Frees all J-card entries in the given list.
1628
1629 li is assumed to be empty or contain (fsl_card_J*)
1630 instances. If alsoListMem is true then any memory owned
1631 by li is also freed. li itself is not freed.
1632
1633 Results are undefined if li is NULL.
1634*/
1635void fsl__card_J_list_free( fsl_list * li, bool alsoListMem );
1637/** @internal
1638
1639 Values for fsl_card_J::flags.
1640*/
1641enum fsl_card_J_flags {
1642/**
1643 Sentinel value.
1644*/
1646/**
1647 Indicates that the field is used by the ticket table.
1648*/
1649FSL_CARD_J_TICKET = 0x01,
1650/**
1651 Indicates that the field is used by the ticketchng table.
1652*/
1653FSL_CARD_J_CHNG = 0x02,
1654/**
1655 Indicates that the field is used by both the ticket and
1656 ticketchng tables.
1657*/
1659};
1660
1661/** @internal
1662
1663 Loads all custom/customizable ticket fields from f's repo's
1664 ticket table info f. If f has already loaded the list and
1665 forceReload is false, this is a no-op.
1666
1667 Returns 0 on success.
1668
1669 @see fsl_cx::ticket::customFields
1670*/
1671int fsl__cx_ticket_load_fields(fsl_cx * f, bool forceReload);
1672
1673/** @internal
1674
1675 A comparison routine for qsort(3) which compares fsl_card_J
1676 instances in a lexical manner based on their names. The order is
1677 important for card ordering in generated manifests.
1678
1679 This routine expects to get passed (fsl_card_J**) (namely from
1680 fsl_list entries), and will not work on an array of J-cards.
1681*/
1682int fsl__qsort_cmp_J_cards( void const * lhs, void const * rhs );
1683
1684/** @internal
1685
1686 This function updates the repo and/or global config databases
1687 with links between the dbs intended for various fossil-level
1688 bookkeeping and housecleaning. These links are not essential to
1689 fossil's functionality but assist in certain "global"
1690 operations.
1691
1692 If no checkout is opened but a repo is, the global config (if
1693 opened) is updated to know about the opened repo db.
1694
1695 If a checkout is opened, global config (if opened) and the
1696 repo are updated to point to the checked-out db.
1697*/
1699
1700/** @internal
1701
1702 Updates f->ckout.uuid and f->ckout.rid to reflect the current
1703 checkout state. If no checkout is opened, the uuid is freed/NULLed
1704 and the rid is set to 0. Returns 0 on success. If it returns an
1705 error (OOM or db-related), the f->ckout state is left in a
1706 potentially inconsistent state, and it should not be relied upon
1707 until/unless the error is resolved.
1708
1709 This is done when a checkout db is opened, when performing a
1710 checkin, and otherwise as needed, and so calling it from other
1711 code is normally not necessary.
1712
1713 @see fsl__ckout_version_write()
1714*/
1716
1717/** @internal
1718
1719 Updates f->ckout's state to reflect the given version info and
1720 writes the 'checkout' and 'checkout-hash' properties to the
1721 currently-opened checkout db. Returns 0 on success,
1722 FSL_RC_NOT_A_CKOUT if no checkout is opened (may assert() in that
1723 case!), or some other code if writing to the db fails.
1724
1725 If vid is 0 then the version info is null'd out. Else if uuid is
1726 NULL then fsl_rid_to_uuid() is used to fetch the UUID for vid.
1727
1728 If the RID differs from f->ckout.rid then f->ckout's version state
1729 is updated to the new values.
1730
1731 This routine also updates or removes the checkout's manifest
1732 files, as per fsl_ckout_manifest_write(). If vid is 0 then it
1733 removes any such files which themselves are not part of the
1734 current checkout.
1735
1736 @see fsl__ckout_version_fetch()
1737 @see fsl_cx_ckout_version_set()
1738*/
1740 fsl_uuid_cstr uuid );
1741
1742/**
1743 @internal
1744
1745 Exports the file with the given [vfile].[id] to the checkout,
1746 overwriting (if possible) anything which gets in its way. If
1747 the file is determined to have not been modified, it is
1748 unchanged.
1749
1750 If the final argument is not NULL then it is set to 0 if the file
1751 was not modified, 1 if only its permissions were modified, and 2 if
1752 its contents were updated (which also requires resetting its
1753 permissions to match their repo-side state).
1754
1755 Returns 0 on success, any number of potential non-0 codes on
1756 error, including, but not limited to:
1757
1758 - FSL_RC_NOT_A_CKOUT - no opened checkout.
1759 - FSL_RC_NOT_FOUND - no matching vfile entry.
1760 - FSL_RC_OOM - we cannot escape this eventuality.
1761
1762 Trivia:
1763
1764 - fossil(1)'s vfile_to_disk() is how it exports a whole vfile, or a
1765 single vfile entry, to disk. e.g. it performs a checkout that way,
1766 whereas we currently perform a checkout using the "repo extraction"
1767 API. The checkout mechanism was probably the first major core
1768 fossil feature which was structured radically differently in
1769 libfossil, compared to the feature's fossil counterpart, when it
1770 was ported over.
1771
1772 - This routine always writes to the vfile.pathname entry, as
1773 opposed to vfile.origname.
1774
1775 Maintenance reminders: internally this code supports handling
1776 multiple files at once, but (A) that's not part of the interface
1777 and may change and (B) the 3rd parameter makes little sense in that
1778 case unless maybe we change it to a callback, which seems like
1779 overkill for our use cases.
1780
1781 BUGS:
1782
1783 - When doing a fsl_ckout_revert(), this function does not recognize
1784 a file which has been modified (only) via a merge as modified, so
1785 does not set `*wasWritten`. Whether that bug is in _this_
1786 function or fsl__is_locally_modified() is not yet clear.
1787 fsl_ckout_revert() works around that so that the client can be
1788 notified of reverted files, but that's only hiding the underlying
1789 discrepancy.
1790*/
1791int fsl__vfile_to_ckout(fsl_cx * f, fsl_id_t vfileId,
1792 int * wasWritten);
1793
1794/** @internal
1795
1796 On Windows platforms (only), if fsl_isalpha(*zFile)
1797 and ':' == zFile[1] then this returns zFile+2,
1798 otherwise it returns zFile.
1799*/
1800char * fsl__file_without_drive_letter(char * zFile);
1801
1802/** @internal
1803
1804 This is identical to the public-API member fsl_deck_F_search(),
1805 except that it returns a non-const F-card.
1806
1807 Locate a file named zName in d->F.list. Return a pointer to the
1808 appropriate fsl_card_F object. Return NULL if not found.
1809
1810 If d->f is set (as it is when loading decks via
1811 fsl_deck_load_rid() and friends), this routine works even if p is
1812 a delta-manifest. The pointer returned might be to the baseline
1813 and d->B.baseline is loaded on demand if needed.
1814
1815 If the returned card's uuid member is NULL, it means that the file
1816 was removed in the checkin represented by d.
1817
1818 If !d, zName is NULL or empty, or FSL_SATYPE_CHECKIN!=d->type, it
1819 asserts in debug builds and returns NULL in non-debug builds.
1820
1821 We assume that filenames are in sorted order and use a binary
1822 search. As an optimization, to support the most common use case,
1823 searches through a deck update d->F.cursor to the last position a
1824 search was found. Because searches are normally done in lexical
1825 order (because of architectural reasons), this is normally an O(1)
1826 operation. It degrades to O(N) if out-of-lexical-order searches
1827 are performed.
1828*/
1829fsl_card_F * fsl__deck_F_seek(fsl_deck * d, const char *zName);
1830
1831/** @internal
1832
1833 Ensures that f's single file content buffer is available for use
1834 and returns it to the caller. If it appears to already be in use,
1835 this function fails fatally via fsl__fatal(), indicating a serious
1836 misuse of the internal API.
1837
1838 Calling this obligates the caller to call
1839 fsl__cx_content_buffer_yield() as soon as they are done with the
1840 buffer.
1841*/
1843
1844/** @internal
1845
1846 Part of the fsl_cx::cache::fileContent optimization. Passes
1847 f->cache.fileContent to fsl_buffer_reuse() and if its capacity is
1848 over a certain (unspecified, unconfigurable) size then it is
1849 trimmed to that size. It also updates some of f's metrics.
1850*/
1852
1853/**
1854 Inserts the given rid into the repo.private table.
1857
1858/**
1859 Deletes the given rid from the repo.private table.
1860*/
1862
1863/**
1864 Inserts the given rid into the repo.unclustered table.
1865*/
1867/**
1868 Inserts the given rid into the repo.phantom table.
1869*/
1871/**
1872 Inserts the given rid into the repo.unsent table.
1873*/
1875/**
1876 Replaces the repo.delta entry with the given rid. This does not
1877 manipulate the related blobs in any way.
1878*/
1879int fsl__delta_replace(fsl_cx * f, fsl_id_t rid, fsl_id_t srcid);
1880/**
1881 Replaces the repo.delta entry with the given rid. This does not
1882 manipulate the related blobs in any way.
1883*/
1884int fsl__delta_delete(fsl_cx * f, fsl_id_t rid);
1885
1887 Expects zTable to name a table with an rid field. That record
1888 is deleted.
1889*/
1890int fsl__rid_delete(fsl_cx * f, fsl_dbrole_e dbRole,
1891 char const *zTable, fsl_id_t rid);
1892
1893/** @internal
1894
1895 Currently disabled (always returns 0) pending resolution of a
1896 "wha???" result from one of the underlying queries.
1897
1898 Queues up the given artifact for a search index update. This is
1899 only intended to be called from crosslinking steps and similar
1900 content updates. Returns 0 on success.
1901
1902 The final argument is intended only for wiki titles (the L-card of
1903 a wiki post).
1904
1905 If the repository database has no search index or the given content
1906 is marked as private, this function returns 0 and makes no changes
1907 to the db.
1908*/
1910 fsl_id_t rid, const char * docName);
1911
1912/** @internal
1913
1914 Returns true if the given file name is a reserved filename
1915 (case-insensitive) on Windows platforms, else returns false.
1916
1917 zPath must be a canonical path with forward-slash directory
1918 separators. nameLen is the length of zPath. If negative, fsl_strlen()
1919 is used to determine its length.
1920*/
1921bool fsl__is_reserved_fn_windows(const char *zPath, fsl_int_t nameLen);
1922
1923/** @internal
1924
1925 Clears any pending merge state from the f's checkout db's vmerge
1926 table. Returns 0 on success, non-0 on db error.
1927
1928 If fullWipe is true, it clears all vfile contents uncondtionally,
1929 else it clears only entries for which the corresponding vfile
1930 entries are marked as unchanged and then cleans up remaining merge
1931 state if no file-level merge changes are pending.
1932*/
1933int fsl__ckout_clear_merge_state( fsl_cx * f, bool fullWipe );
1935/** @internal
1936
1937 Installs or reinstalls the checkout database schema into f's open
1938 checkout db. Returns 0 on success, FSL_RC_NOT_A_CKOUT if f has
1939 no opened checkout, or an code if a lower-level operation fails.
1940
1941 If dropIfExists is true then all affected tables are dropped
1942 beforehand if they exist. "It's the only way to be sure."
1943
1944 If dropIfExists is false and the schema appears to already exists
1945 (without actually validating its validity), 0 is returned.
1946*/
1947int fsl__ckout_install_schema(fsl_cx * f, bool dropIfExists);
1948
1949/** @internal
1950
1951 Attempts to remove empty directories from under a checkout,
1952 starting with tgtDir and working upwards until it either cannot
1953 remove one or it reaches the top of the checkout dir.
1955 The second argument must be the canonicalized absolute path to some
1956 directory under the checkout root. The contents of the buffer may,
1957 for efficiency's sake, be modified by this routine as it traverses
1958 the directory tree. It will never grow the buffer but may mutate
1959 its memory's contents.
1960
1961 Returns the number of directories it is able to remove.
1962
1963 Results are undefined if tgtDir is not an absolute path rooted in
1964 f's current checkout.
1965
1966 There are any number of valid reasons removal of a directory might
1967 fail, and this routine stops at the first one which does.
1968*/
1969unsigned int fsl__ckout_rm_empty_dirs(fsl_cx * f,
1970 fsl_buffer const * tgtDir);
1971
1972/** @internal
1973
1974 This is intended to be passed the name of a file which was just
1975 deleted and "might" have left behind an empty directory. The name
1976 _must_ an absolute path based in f's current checkout. This routine
1977 uses fsl_file_dirpart() to strip path components from the string
1978 and remove directories until either removing one fails or the top
1979 of the checkout is reached. Since removal of a directory can fail for
1980 any given reason, this routine ignores such errors. It returns 0 on
1981 success, FSL_RC_OOM if allocation of the working buffer for the
1982 filename hackery fails, and FSL_RC_MISUSE if zFilename is not
1983 rooted in the checkout (in which case it may assert(), so don't do
1984 that).
1985
1986 @see fsl_is_rooted_in_ckout()
1987 @see fsl_rm_empty_dirs()
1988*/
1989int fsl__ckout_rm_empty_dirs_for_file(fsl_cx * f, char const *zAbsPath);
1990
1991/** @internal
1992
1993 If f->cache.seenDeltaManifest<=0 then this routine sets it to 1
1994 and sets the 'seen-delta-manifest' repository config setting to 1,
1995 else this has no side effects. Returns 0 on success, non-0 if
1996 there is an error while writing to the repository config.
1997*/
1999
2000/** @internal
2001
2002 Very, VERY internal.
2003
2004 Returns the next available buffer from f->scratchpads. Fatally
2005 aborts if there are no free buffers because "that should not
2006 happen." Calling this obligates the caller to eventually pass
2007 its result to fsl__cx_scratchpad_yield().
2008
2009 This function guarantees the returned buffer's 'used' member will be
2010 set to 0.
2011
2012 Maintenance note: the number of buffers is hard-coded in the
2013 fsl_cx::scratchpads anonymous struct.
2014*/
2016
2017/** @internal
2018
2019 Very, VERY internal.
2021 "Yields" a buffer which was returned from fsl__cx_scratchpad(),
2022 making it available for re-use. The caller must treat the buffer as
2023 if this routine frees it: using the buffer after having passed it
2024 to this function will internally be flagged as explicit misuse and
2025 will lead to a fatal crash the next time that buffer is fetched via
2026 fsl__cx_scratchpad(). So don't do that.
2027*/
2029
2030/** @internal
2031
2032 Run automatically by fsl_deck_save(), so it needn't normally be run
2033 aside from that, at least not from average client code.
2034
2035 Runs postprocessing on the Structural Artifact represented by
2036 d. d->f must be set, d->rid must be set and valid and d's contents
2037 must accurately represent the stored manifest for the given
2038 rid. This is normally run just after the insertion of a new
2039 manifest, but is sometimes also run after reading a deck from the
2040 database (in order to rebuild all db relations and add/update the
2041 timeline entry).
2042
2043 Returns 0 on succes, FSL_RC_MISUSE !d->f, FSL_RC_RANGE if
2044 d->rid<=0, FSL_RC_MISUSE (with more error info in f) if d does not
2045 contain all required cards for its d->type value. It may return
2046 various other codes from the many routines it delegates work to.
2047
2048 Crosslinking of ticket artifacts is currently (2021-11) missing.
2049
2050 Design note: d "really should" be const here but some internals
2051 (d->F.cursor and delayed baseline loading) prohibit it.
2052
2053 @see fsl__deck_crosslink_one()
2054*/
2055int fsl__deck_crosslink( fsl_deck /* const */ * d );
2056
2057/** @internal
2058
2059 Run automatically by fsl_deck_save(), so it needn't normally be run
2060 aside from that, at least not from average client code.
2061
2062 This is a convience form of crosslinking which must only be used
2063 when a single deck (and only a single deck) is to be crosslinked.
2064 This function wraps the crosslinking in fsl_crosslink_begin()
2065 and fsl__crosslink_end(), but otherwise behaves the same as
2066 fsl__deck_crosslink(). If crosslinking fails, any in-progress
2067 transaction will be flagged as failed.
2068
2069 Returns 0 on success.
2070*/
2072
2073/** @internal
2074
2075 Checks whether the given filename is "safe" for writing to within
2076 f's current checkout.
2077
2078 zFilename must be in canonical form: only '/' directory separators.
2079 If zFilename is not absolute, it is assumed to be relative to the top
2080 of the current checkout, else it must point to a file under the current
2081 checkout.
2082
2083 Checks made on the filename include:
2084
2085 - It must refer to a file under the current checkout.
2086
2087 - Ensure that each directory listed in the file's path is actually
2088 a directory, and fail if any part other than the final one is a
2089 non-directory.
2090
2091 If the name refers to something not (yet) in the filesystem, that
2092 is not considered an error.
2093
2094 Returns 0 on success. On error f's error state is updated with
2095 information about the problem.
2096*/
2097int fsl__ckout_safe_file_check(fsl_cx * f, char const * zFilename);
2098
2099/** @internal
2100 UNTESTED!
2101
2102 Creates a file named zLinkFile and populates its contents with a
2103 single line: zTgtFile. This behaviour corresponds to how fossil
2104 manages SCM'd symlink entries on Windows and on other platforms
2105 when the 'allow-symlinks' repo-level config setting is disabled.
2106 (In late 2020 fossil defaulted that setting to disabled and made it
2107 non-versionable.)
2108
2109 zLinkFile may be an absolute path rooted at f's current checkout or
2110 may be a checkout-relative path.
2111
2112 Returns 0 on success, non-0 on error:
2113
2114 - FSL_RC_NOT_A_CKOUT if f has no opened checkout.
2115
2116 - FSL_RC_MISUSE if zLinkFile refers to a path outside of the
2117 current checkout.
2118
2119 Potential TODO (maybe!): handle symlinks as described above or
2120 "properly" on systems which natively support them iff f's
2121 'allow-symlinks' repo-level config setting is true. That said: the
2122 addition of symlinks support into fossil was, IMHO, a poor decision
2123 for $REASONS. That might (might) be reflected long-term in this API
2124 by only supporting them in the way fossil does for platforms which
2125 do not support symlinks.
2126*/
2127int fsl__ckout_symlink_create(fsl_cx * f, char const *zTgtFile,
2128 char const * zLinkFile);
2129
2131/** @internal
2132 Compute all file name changes that occur going from check-in iFrom
2133 to check-in iTo. Requires an opened repository.
2135 If revOK is true, the algorithm is free to move backwards in the
2136 chain. This is the opposite of the oneWayOnly parameter for
2137 fsl_vpath_shortest().
2139 On success, the number of name changes is written into *pnChng.
2140 For each name change, two integers are allocated for *piChng. The
2141 first is the filename.fnid for the original name as seen in
2142 check-in iFrom and the second is for new name as it is used in
2143 check-in iTo. If *pnChng is 0 then *aiChng will be NULL.
2145 On error returns non-0, pnChng and aiChng are not modified, and
2146 f's error state might (depending on the error) contain a description
2147 of the problem.
2149 Space to hold *aiChng is obtained from fsl_malloc() and must
2150 be released by the caller.
2151*/
2153 fsl_id_t iFrom,
2154 fsl_id_t iTo,
2155 bool revOK,
2156 uint32_t *pnChng,
2157 fsl_id_t **aiChng);
2158
2159/** @internal
2160 Bitmask of file change types for use with
2161 fsl__is_locally_modified().
2162*/
2163enum fsl__localmod_e {
2164/** Sentinel value. */
2166/**
2167 Permissions changed.
2168*/
2169FSL__LOCALMOD_PERM = 0x01,
2170/**
2171 File size or hash (i.e. content) differ.
2172*/
2174/**
2175 The file type was switched between symlink and normal file. In
2176 this case, no check for content change, beyond the file size
2177 change, is performed.
2178*/
2179FSL__LOCALMOD_LINK = 0x04,
2180/**
2181 File was not found in the local checkout.
2182 */
2184};
2185typedef enum fsl__localmod_e fsl__localmod_e;
2186/** @internal
2187
2188 Checks whether the given file has been locally modified compared to
2189 a known size, hash value, and permissions. Requires that f has an
2190 opened checkout.
2191
2192 If zFilename is not an absolute path, it is assumed to be relative
2193 to the checkout root (as opposed to the current directory) and is
2194 canonicalized into an absolute path for purposes of this function.
2195
2196 fileSize is the "original" version's file size. zOrigHash is the
2197 initial hash of the file to use as a basis for comparison.
2198 zOrigHashLen is the length of zOrigHash, or a negative value if
2199 this function should use fsl_is_uuid() to determine the length. If
2200 the hash length is not that of one of the supported hash types,
2201 FSL_RC_RANGE is returned and f's error state is updated. This
2202 length is used to determine which hash to use for the comparison.
2203
2204 If the file's current size differs from the given size, it is
2205 quickly considered modified, otherwise the file's contents get
2206 hashed and compared to zOrigHash.
2207
2208 Because this is used for comparing local files to their state from
2209 the fossil database, where files have no timestamps, the local
2210 file's timestamp is never considered for purposes of modification
2211 checking.
2212
2213 If isModified is not NULL then on success it is set to a bitmask of
2214 values from the fsl__localmod_e enum specifying the type(s) of
2215 change(s) detected:
2216
2217 - FSL__LOCALMOD_PERM = permissions changed.
2218
2219 - FSL__LOCALMOD_CONTENT = file size or hash (i.e. content) differ.
2220
2221 - FSL__LOCALMOD_LINK = the file type was switched between symlink
2222 and normal file. In this case, no check for content change,
2223 beyond the file size change, is performed.
2224
2225 - FSL__LOCALMOD_NOFOUND = file was not found in the local checkout.
2226
2227 Noting that:
2228
2229 - Combined values of (FSL__LOCALMOD_PERM | FSL__LOCALMOD_CONTENT) are
2230 possible, but FSL__LOCALMOD_NOTFOUND will never be combined with one
2231 of the other values.
2232
2233 If stat() fails for any reason other than file-not-found
2234 (e.g. permissions), an error is triggered.
2235
2236 Returns 0 on success. On error, returns non-0 and f's error state
2237 will be updated and isModified... isNotModified. Errors include,
2238 but are not limited to:
2239
2240 - Invalid hash length: FSL_RC_RANGE
2241 - f has no opened checkout: FSL_RC_NOT_A_CKOUT
2242 - Cannot find the file: FSL_RC_NOT_FOUND
2243 - Error accessing the file: FSL_RC_ACCESS
2244 - Allocation error: FSL_RC_OOM
2245 - I/O error during hashing: FSL_RC_IO
2246
2247 And potentially other errors, roughly translated from errno values,
2248 for corner cases such as passing a directory name instead of a
2249 file.
2250
2251 Results are undefined if any pointer argument is NULL or invalid.
2252
2253 This function currently does NOT follow symlinks for purposes of
2254 resolving zFilename, but that behavior may change in the future or
2255 may become dependent on the repository's 'allow-symlinks' setting.
2256
2257 Internal detail, not relevant for clients: this updates f's
2258 cache stat entry.
2259*/
2261 const char * zFilename,
2262 fsl_size_t fileSize,
2263 const char * zOrigHash,
2264 fsl_int_t zOrigHashLen,
2265 fsl_fileperm_e origPerm,
2266 int * isModified);
2267
2268/** @internal
2269
2270 This routine cleans up the state of selected cards in the given
2271 deck. The 2nd argument is an list of upper-case letters
2272 representing the cards which should be cleaned up, e.g. "ADG". If
2273 it is NULL, all cards are cleaned up but d has non-card state
2274 which is not cleaned up by this routine. Unknown letters are simply
2275 ignored.
2276*/
2277void fsl__deck_clean_cards(fsl_deck * d, char const * letters);
2278
2279/** @internal
2280
2281 This starts a transaction (possibly nested) on the repository db
2282 and initializes some temporary db state needed for the
2283 crosslinking certain artifact types. It "should" (see below) be
2284 called at the start of the crosslinking process. Crosslinking
2285 *can* work without this but certain steps for certain (subject to
2286 change) artifact types will be skipped, possibly leading to
2287 unexpected timeline data or similar funkiness. No permanent
2288 SCM-relevant state will be missing, but the timeline might not be
2289 updated and tickets might not be fully processed. This should be
2290 used before crosslinking any artifact types, but will only have
2291 significant side effects for certain (subject to change) types.
2292
2293 Returns 0 on success.
2294
2295 If it returns 0 then the caller is OBLIGATED to either 1) call
2296 fsl__crosslink_end() or 2) call fsl_db_txn_rollback() and
2297 set f->cache.isCrosslinking to false. This process may install
2298 temporary tables and/or triggers, so failing to call one or the
2299 other of those will result in misbehavior.
2300
2301 @see fsl__deck_crosslink()
2302*/
2304
2305/** @internal
2306
2307 Must not be called unless fsl__crosslink_begin() has
2308 succeeded. This performs crosslink post-processing on certain
2309 artifact types and cleans up any temporary db state initialized by
2310 fsl__crosslink_begin().
2311
2312 If the 2nd argument is not 0 then this routine triggers a rollback
2313 of the transaction started by fsl__crosslink_begin() and
2314 propagates any pending error code from f or (if f has no error
2315 code) from f's db handle.
2316
2317 The second argument is intended to be the value of any pending
2318 result code (0 or otherwise) from any work done _after_
2319 fsl__crosslink_begin() succeeded. If passed 0, it assumes that
2320 there is no propagating error state and will attempt to complete
2321 the crosslinking process. If passed non-0, it triggers a rollback
2322 and unsets the f->cache.isCrosslinking flag, but does no
2323 additional work, then returns resultCode.
2325 Returns 0 on success. On error it initiates (or propagates) a
2326 rollback for the current transaction. If called when a rollback is
2327 pending, it unsets the crosslink-is-running flag and returns the
2328 propagating result code.
2329*/
2330int fsl__crosslink_end(fsl_cx * f, int resultCode);
2331
2332/** @internal
2334 Searches the current repository database for a fingerprint and
2335 returns it as a string in *zOut.
2336
2337 If rcvid<=0 then the fingerprint matches the last entry in the
2338 [rcvfrom] table, where "last" means highest-numbered rcvid (as
2339 opposed to most recent mtime, for whatever reason). If rcvid>0 then
2340 it searches for an exact match.
2341
2342 Returns 0 on non-error. Finding no matching rcvid results in
2343 FSL_RC_NOT_FOUND. If 0 is returned then *zOut will be non-NULL and
2344 ownership of that value is transferred to the caller, who must
2345 eventually pass it to fsl_free(). On error, *zOut is not modified.
2346
2347 Returns FSL_RC_NOT_A_REPO if f has no opened repository, FSL_RC_OOM
2348 on allocation error, or any number of potential db-related codes if
2349 something goes wrong at the db level.
2350
2351 This API internally first checks for "version 1" fossil
2352 fingerprints and falls back to "version 0" fingerprint if a v1
2353 fingerprint is not found. Version 0 was very short-lived and is not
2354 expected to be in many repositories which are accessed via this
2355 library. Practice has, however, revealed some.
2356
2357 @see fsl_ckout_fingerprint_check()
2358*/
2360 char ** zOut);
2361
2362/** @internal
2363
2364 State for running a raw diff.
2365
2366 @see fsl__diff_all()
2367*/
2369 /**
2370 aEdit describes the raw diff. Each triple of integers in aEdit[]
2371 means:
2372
2373 (1) COPY: Number of lines aFrom and aTo have in common
2374 (2) DELETE: Number of lines found only in aFrom
2375 (3) INSERT: Number of lines found only in aTo
2376
2377 The triples repeat until all lines of both aFrom and aTo are
2378 accounted for. The array is terminated with a triple of (0,0,0).
2379 */
2380 int *aEdit /*TODO unsigned*/;
2381 /** Number of integers (3x num of triples) in aEdit[]. */
2382 int nEdit /*TODO unsigned*/;
2383 /** Number of elements allocated for aEdit[]. */
2384 int nEditAlloc /*TODO unsigned*/;
2385 /** File content for the left side of the diff. */
2387 /** Number of lines in aFrom[]. */
2388 int nFrom /*TODO unsigned*/;
2389 /** File content for the right side of the diff. */
2390 fsl_dline *aTo;
2391 /** Number of lines in aTo[]. */
2392 int nTo /*TODO unsigned*/;
2393 /** Predicate for comparing LHS/RHS lines for equivalence. */
2394 int (*cmpLine)(const fsl_dline * const, const fsl_dline *const);
2395};
2396/** @internal
2397 Convenience typeef.
2398*/
2399typedef struct fsl__diff_cx fsl__diff_cx;
2400/** @internal
2401 Initialized-with-defaults fsl__diff_cx structure, intended for
2402 const-copy initialization. */
2403#define fsl__diff_cx_empty_m {\
2404 NULL,0,0,NULL,0,NULL,0,fsl_dline_cmp \
2405}
2406/** @internal
2407 Initialized-with-defaults fsl__diff_cx structure, intended for
2408 non-const copy initialization. */
2409extern const fsl__diff_cx fsl__diff_cx_empty;
2410
2411/** @internal
2412
2413 Compute the differences between two files already loaded into
2414 the fsl__diff_cx structure.
2415
2416 A divide and conquer technique is used. We look for a large
2417 block of common text that is in the middle of both files. Then
2418 compute the difference on those parts of the file before and
2419 after the common block. This technique is fast, but it does
2420 not necessarily generate the minimum difference set. On the
2421 other hand, we do not need a minimum difference set, only one
2422 that makes sense to human readers, which this algorithm does.
2423
2424 Any common text at the beginning and end of the two files is
2425 removed before starting the divide-and-conquer algorithm.
2426
2427 Returns 0 on succes, FSL_RC_OOM on an allocation error.
2428*/
2430
2431/** @internal */
2433
2434
2435
2436/** @internal
2437
2438 Undocumented. For internal debugging only. The 2nd argument is
2439 intended to be __FILE__ and the 3rd is intended to be __LINE__.
2440*/
2441void fsl__dump_triples(fsl__diff_cx const * p,
2442 char const * zFile, int ln );
2443
2444/** @internal
2445
2446 Removes from the BLOB table all artifacts that are in the SHUN
2447 table. Returns 0 on success. Requires (asserts) that a repo is
2448 opened. Note that this is not a simple DELETE operation, as it
2449 requires ensuring that all removed blobs have been undeltified
2450 first so that no stale delta records are left behind.
2451*/
2453
2454/** @internal
2455
2456 This function is, as of this writing, only exposed via a header file
2457 for the sake of fnc, which still relies on it after we moved the
2458 "v1" diff code out of this library and into fnc.
2460 Attempt to shift insertion or deletion blocks so that they begin and
2461 end on lines that are pure whitespace. In other words, try to transform
2462 this:
2463
2464 ```
2465 int func1(int x){
2466 return x*10;
2467 +}
2468 +
2469 +int func2(int x){
2470 + return x*20;
2471 }
2472
2473 int func3(int x){
2474 return x/5;
2475 }
2476 ```
2477
2478 Into one of these:
2479
2480 ```
2481 int func1(int x){ int func1(int x){
2482 return x*10; return x*10;
2483 } }
2484 +
2485 +int func2(int x){ +int func2(int x){
2486 + return x*20; + return x*20;
2487 +} +}
2488 +
2489 int func3(int x){ int func3(int x){
2490 return x/5; return x/5;
2491 } }
2492 ```
2493*/
2495
2496/** @internal
2498 This is a fossil-specific internal detail not needed by the more
2499 generic parts of the fsl_db API. It loops through all "cached"
2500 prepared statements for which stmt->role has been assigned a value
2501 which bitmasks as true against the given role and finalizes
2502 them. If such a statement is currently held by a call to/via
2503 fsl_db_prepare_cachedv() then this will NOT finalize that
2504 statement, will update db's error state, and return
2505 FSL_RC_MISUSE.
2506
2507 Returns 0 on success.
2508
2509 As a special case, if role==0 then ALL cached statements are
2510 closed, with the caveat that the process will still fail if any
2511 statement is currently flagged as active.
2512*/
2514
2515/** @internal
2516
2517 Part of the crosslinking bits: rebuilds the entry for the ticket
2518 with the given K-card value.
2519*/
2520int fsl__ticket_rebuild(fsl_cx * f, char const * zTktId);
2522/** @internal
2523
2524 Calls all registered crosslink link listeners, passing each the
2525 given deck. Returns 0 if there are no listeners or if all return 0,
2526 else it propagates an error from a failed listener.
2527
2528 This must only be called while crosslinking is underway.
2529
2530 @see fsl_xlink_listener()
2531*/
2533
2534/** @internal
2535
2536 Copies symlink zFrom to a new symlink or pseudo-symlink named
2537 zTo.
2538
2539 If realLink is true and this is a non-Windows platform,
2540 symlink zFrom is copied to zTo.
2541
2542 If realLink is false or this is a Windows platform them...
2543
2544 - On Windows this has currently undesired, or at least, highly
2545 arguable, behavior (historical, inherited from fossil(1)), in
2546 that an empty file named zTo will be created. In fossil(1) this
2547 function's counterpart is (apparently) never called on Windows,
2548 so that behavior seems to be moot. It is, however, important that
2549 this library never call it on Windows.
2550
2551 - On non-Windows, a pseudo-symlink will be created: the string
2552 zFrom will be written to a regular file named zTo. That is, the
2553 file zTo will hold, as its contents, what it would point to if
2554 it were a symlink.
2555*/
2556int fsl__symlink_copy(char const *zFrom, char const *zTo, bool realLink);
2557
2558/** @internal
2559
2560 Translates sqliteCode (or, if it's 0, sqlite3_errcode()) to an
2561 approximate FSL_RC_xxx match but treats SQLITE_ROW and SQLITE_DONE
2562 as non-errors (result code 0). If non-0 is returned db's error
2563 state is updated with the current sqlite3_errmsg() string.
2564*/
2565int fsl__db_errcode(fsl_db * db, int sqliteCode);
2566
2567/** @internal
2568
2569 Plug in fsl_cx-specific db functionality into the given db handle.
2570 This must only be passed the MAIN db handle for the context,
2571 immediately after opening that handle, before f->dbMain is
2572 assigned.
2573
2574 This function has very limited applicability and various
2575 preconditions which are assert()ed.
2576*/
2577int fsl__cx_init_db(fsl_cx * f, fsl_db * db);
2578
2579/** @internal
2581 Attaches the given db file to f with the given role. This function "should"
2582 be static but we need it in repo.c when creating a new repository.
2583
2584 This function has tightly-controlled preconditions which will assert
2585 if not met. r must be one of FSL_DBROLE_CKOUT or FSL_DBROLE_REPO.
2587 If createIfNotExists is true and zDbName does not exist in the
2588 filesystem, it is created before/as part of the OPEN or ATTACH. This is
2589 almost never desired, but is required for operations which create a
2590 repo (e.g. the aptly-named fsl_repo_create()) or a checkout db
2591 (e.g. fsl_repo_open_ckout()).
2592*/
2593int fsl__cx_attach_role(fsl_cx * f, const char *zDbName,
2594 fsl_dbrole_e r, bool createIfNotExists);
2595
2596/** @internal
2597
2598 Returns one of f->{repo,ckout}.db or NULL.
2599
2600 ACHTUNG and REMINDER TO SELF: the current (2021-03) design means
2601 that none of these handles except for FSL_DBROLE_MAIN actually has
2602 an sqlite3 db handle assigned to it. This returns a handle to the
2603 "level of abstraction" we need to keep track of each db's name and
2604 db-specific other state.
2605
2606 e.g. passing a role of FSL_DBROLE_CKOUT this does NOT return
2607 the same thing as fsl_cx_db_ckout().
2610
2611/** @internal
2612
2613 Frees/clears the non-db state of f->ckout.
2614*/
2616
2617
2618/** @internal
2619 Register the "files of checkin" (fsl_foci) SQLite3 virtual table.
2620*/
2621int fsl__foci_register(fsl_cx * f, fsl_db * db);
2623/** @internal
2624
2625 If f has an SEE key-fetching function installed, it is called, its
2626 result is returned (but see below), and it is responsible for
2627 populating the final two arguments. If no such function is
2628 installed, or the function returns FSL_RC_UNSUPPORTED, the 3rd
2629 argument is unmodified, *keyType is set to 0, and 0 is
2630 returned. See fsl_cx_config::see and fsl_see_key_f() for details.
2631
2632 If a non-0 value other than FSL_RC_UNSUPPORTED or FSL_RC_OOM are
2633 returned, f's error state will be updated with a generic message
2634 about SEE key init failure.
2635*/
2636int fsl__cx_see_key(fsl_cx * f, const char *zDbFile,
2637 fsl_buffer *pOut, int *keyType);
2638
2639/** @internal
2640
2641 Maximum length of a line in a text file, in bytes. (2**15 = 32k)
2642*/
2643#define FSL__LINE_LENGTH_MASK_SZ 15
2644
2645/** @internal
2646
2647 Bitmask which, when AND-ed with a number, will result in the
2648 bottom FSL__LINE_LENGTH_MASK_SZ bits of that number.
2649*/
2650#define FSL__LINE_LENGTH_MASK ((1<<FSL__LINE_LENGTH_MASK_SZ)-1)
2651
2652/** @internal
2653
2654 Internal impl of fsl_buffer_err(), implemented as a macro for
2655 efficiency's sake.
2656*/
2657#define fsl__buffer_err(B) (B)->errCode
2658
2659//#if FSL_ENABLE_MUTEX
2660/** @internal
2661
2662 If the lib is built with FSL_ENABLE_MUTEX, locks the library's
2663 global non-recursive mutex, which only guards a small amount of
2664 state. If the lib is not built with FSL_ENABLE_MUTEX, this is a
2665 no-op.
2666*/
2667void fsl__mutex_enter(void);
2669/** @internal
2670
2671 If the lib is built with FSL_ENABLE_MUTEX, unlocks the library's
2672 global non-recursive mutex, else it's a no-op.
2673
2674 May assert() that fsl__mutex_enter() has been called.
2675*/
2677
2678/** @internal
2680 Returns true if fsl__mutex_enter() is active, else false. Always
2681 returns true(!) in-single-threaded builds because that's how
2682 SQLite does it. This is only intended for use in assert() and the
2683 like - it must not be used for flow control.
2684
2685 May assert() that fsl__mutex_enter() has been called.
2686*/
2687bool fsl__mutex_held(void);
2688//#else /* !FSL_ENABLE_MUTEX */
2689//#define fsl__mutex_held(X) ((void)(X),1)
2690//#define fsl__mutex_enter() (void)0
2691//#define fsl__mutex_leave() (void)0
2692//#endif
2693/** @internal
2694
2695 Internal helper for parsing manifests and sync protocol lines.
2696 Holds the (mutable) content of a source file or input line and
2697 gets parsed and updated by fsl__tokenizer_next().
2698*/
2699struct fsl__tokenizer {
2700 /**
2701 First char of the next token.
2702 */
2703 unsigned char * z;
2704 /**
2705 One-past-the-end of the input.
2706 */
2707 unsigned char * zEnd;
2708 /**
2709 True if z points to the start of a new line.
2710 */
2711 bool atEol;
2713typedef struct fsl__tokenizer fsl__tokenizer;
2714#define fsl__tokenizer_empty_m {NULL,NULL,false}
2716
2717/** @internal
2718
2719 Returns a pointer to the next space-separated token in pIn. The
2720 token is zero-terminated. Return NULL if there are no more tokens
2721 on the current line, but the call after that will return non-NULL
2722 unless we have reached the end of the input. If this function
2723 returns non-NULL then *pLen (which must not be NULL) is set to the
2724 byte length of the new token. Once the end of the input is reached,
2725 this function always returns NULL.
2726
2727 A token is defined as a sequence of a non-whitespace (0x20),
2728 non-newline (0x0A) bytes. The input is modified, replacing
2729 spaces and newlines with a NUL.
2730*/
2731unsigned char *fsl__tokenizer_next(fsl__tokenizer * pIn,
2732 fsl_size_t * pLen);
2733
2734enum {
2735 /**
2736 Max number of expected tokens in fsl__xfer::line. This number is
2737 inherited from fossil(1).
2738 */
2740};
2741
2742/** @internal
2744 Internal state for an ongoing fsl_sync(). Modelled largely after
2745 fossil(1)'s xfer.c:Xfer class.
2746*/
2747struct fsl__xfer {
2748 /**
2749 This object's fossil context. Errors encountered by the channel
2750 should be sent here using fsl_xfer_error() and friends. A channel's
2751 impl may use the context for other purposes, e.g. fetching or
2752 storing channel-specific configuration info like credentials or
2753 using a db-side cache.
2754
2755 f must outlive this object.
2757 fsl_cx * f;
2758
2759 /**
2760 The underlying communication channel.
2762 fsl_sc * ch;
2763
2764 /**
2765 The configuration object for a given xfer trip. Its initial state
2766 represents the initial request parameters and it may get updated
2767 as the sync progresses.
2770
2771 /**
2772 Almost all APIs which deal with this class (A) become no-ops if
2773 this is non-0, returning this value instead, and (B) set their
2774 result code in this member. This simplifies some internals by
2775 allowing us to forego explicit error checks when making multiple
2776 xfer-related calls in a row.
2778 int rc;
2780 /** One line of sync protocol input, which we tokenize via
2781 fsl__xfer_readln() for ease of processing. */
2782 struct {
2783 /**
2784 Holds the current input line. Populated and tokenized by
2785 fsl__xfer_readln().
2787 fsl_buffer b;
2788 /**
2789 A raw, untokenized copy of b.
2792 /** Holds pointers to the individual tokens of b.
2793 The memory lives in this->b. These are non-const
2794 only so that we can use fsl_bytes_defossilize()
2795 on them. */
2796 unsigned char * aToken[fsl__xfer_max_tokens];
2797 /**
2798 Holds the strlen() of each token in aTokens.
2801 /** The number of tokens in use in aToken. */
2802 uint8_t nToken;
2803 } line;
2804 /** Memory buffers */
2805 struct {
2806 /**
2807 When using compressed responses, this is where it will store
2808 the uncompressed response. We decompress it on behalf of the
2809 fsl_sc so that those impls don't have to all do this on their
2810 own.
2811 */
2813 /** Hashing and UUID-fetching buffer */
2815 /** Generic scratchpad buffer */
2817 /** Card payloads */
2819 /** fsl_xfer_emit() and friends */
2821 } buf;
2822 /** Prepared statements */
2823 struct {
2827 //fsl_stmt gimmeDelete;
2829 } q;
2830 /** Various flags. */
2831 /* TODO: move some of this into fsl_xfer_config. */
2832 struct {
2835 char const *zAltPCode;
2836 /** True to enable syncing private content */
2837 bool syncPrivate;
2838 /** If true, next "file" received is a private artifact. */
2839 bool nextIsPrivate;
2840 } flag;
2841 /** Info about the remote. */
2842 struct {
2843 int releaseVersion;
2844 int manifestDate;
2845 int manifestTime;
2846 /** Seconds of offset from localhost. */
2847 int clockSkewSeen;
2848 /* Reminder to self: calculating the clock skew currently requires
2849 parsing a comment line from the sync protocol. TODO is add a
2850 pragma to simplify that on the remote end. */
2852 struct {
2853 int number;
2854 int date;
2855 int time;
2856 /**
2857 Tells us whether the remote project-code matches this one.
2858 If not, some operations won't work (like logging in - that
2859 only works when project codes match because the project code
2860 is part of the password hash).
2861
2862 Values: <0=unknown, 0=mismatch, >0=match.
2863 */
2864 short projCodeMatch;
2866 struct {
2869 } clone;
2870 /**
2871 Info about the user which is relevant for sync.
2872 */
2873 struct {
2874 /**
2875 User name memory owned by fsl__xfer::url.
2876 */
2877 char const * name;
2878 /**
2879 Password memory owned by fsl__xfer::url.
2881 char const * password;
2882 /**
2883 Password memory owned by this object. Gets extracted from the
2884 repo.user table if no password is otherwise provided.
2886 char * passwordToFree;
2887
2888 /**
2889 Permissions calculated for the current user from sync login
2890 info.
2891 */
2893 } user;
2894 /**
2895 When using compressed responses, we need a layer of buffer to do
2896 the decompression. This object, if populated, is a _partial_
2897 fsl_sc implementation which buffers the whole uncompressed
2898 response and only supports reading.
2899 */
2900 fsl_sc chz;
2901 /** Various counters. */
2903
2904 struct {
2905 /**
2906 Hash of all request payload content, for generating the sync
2907 login card.
2908 */
2911 /**
2912 Number of bytes submitted for the request body.
2913 */
2915 } request;
2916
2917 struct {
2918 int httpVersion;
2920 } response;
2921#if 0
2922 /* From fossil(1) xfer.c:Xfer struct: */
2923 fsl_size_t mxSend; /* Stop sending "file" when pOut reaches this size */
2924 int resync; /* Send igot cards for all holdings */
2925 uint32_t remoteVersion; /* Version of fossil running on the other side */
2926 uint32_t remoteDate; /* Date for specific client software edition */
2927 uint32_t remoteTime; /* Time of date correspoding on remoteDate */
2928 fsl_time_t maxTime; /* Time when this transfer should be finished */
2929#endif
2930};
2931typedef struct fsl__xfer fsl__xfer;
2932/** Empty-initialized fsl__xfer instance, intended for copy
2933 initialization. */
2935
2936
2937/** @internal
2938
2939 Create a child process running shell command "zCmd". *pfdIn gets
2940 assigned to the stdout from the child process. (The caller reads
2941 from *pfdIn in order to receive input from the child.) *ppOut gets
2942 assigned to a FILE that becomes the standard input of the child
2943 process. (The caller writes to *ppOut in order to send text to the
2944 child.) Note that *pfdIn is an unbuffered file descriptor, not a
2945 FILE. The process ID of the child is written into *pChildPid.
2946
2947 On success the values returned via *pfdIn, *ppOut, and *pChildPid
2948 must be passed to fsl_pclose2() to properly clean up.
2949
2950 Return 0 on success, non-0 on error.
2951
2952 @internal
2954int fsl__popen2(const char *zCmd, int *pfdIn, FILE **ppOut,
2955 int *pChildPid);
2956
2957/** @internal
2958
2959 Close the connection to a child process previously created using
2960 fsl__popen2(). All 3 arguments are assumed to values returned via
2961 fsl__popen2()'s output parameters: the input file descriptor,
2962 output FILE handle, and child process PID.
2963
2964 Return the waitpid()-derived exit code of the child process.
2965
2966 On Windows platforms, killing of the child process is not
2967 implemented. (Patches are welcomed.)
2968*/
2969int fsl__pclose2(int fdIn, FILE *pOut, int childPid);
2970
2972/** @internal
2973
2974 Hash value for fsl_xfcard card name hashing.
2975
2976 This algo historically uses 32-bit hashes because the values
2977 (generated at build-time) were used in switch/case contexts, where
2978 64-bit values are not portable.
2979
2980 @internal
2981*/
2982typedef uint32_t fsl_xfcard_hash_t;
2983
2984/**
2985 Lowest-valued legal identifier character in a sync card name. This
2986 plays a role in the hash.
2987*/
2988#define fsl_xfcard_LowestIdChar '$'
2989#define fsl_xfcard_MaxCardNameLen 11 /*==strlen("clone_seqno")*/
2991/** @internal
2992
2993 Internal impl for one hash step of fsl_xfcard_hash() and the HASH#()
2994 family of macros (for compile-time hashes). Arguments:
2995
2996 - H is the current hash value (starting at 0)
2997 - I is the char index into the word we're hashing.
2998 - CHAR is the character at index I of the word.
2999
3000 Reminder to self:
3001
3002 collision with "else" and "eval":
3003 h = (h << 1) + (++i) * (CHAR - 35)
3004*/
3005#if 1
3006#define fsl_xfcard_hash_step_ch(H,I,CHAR) \
3007 (((((fsl_xfcard_hash_t)H << 1) + (I+1)) * (CHAR - fsl_xfcard_LowestIdChar-1)) ^ CHAR)
3008#elif 0
3009#define fsl_xfcard_hash_step_ch(H,I,CHAR) \
3010 ((((H << 1) + (45*I) + CHAR - fsl_xfcard_LowestIdChar-1)) ^ CHAR)
3011#else
3012#define fsl_xfcard_hash_step_ch(H,I,CHAR) \
3013 ((H << 1) + 113*I + (CHAR - fsl_xfcard_LowestIdChar-1))
3014#endif
3015
3016/** @internal
3017
3018 Slightly-convenience form of fsl_xfcard_hash_step_ch() which takes
3019 its 3rd argument as an unquoted word.
3021 The first invocation for a given WORD must pass 0 for H and I. Each
3022 subsequent call must pass the result the previous call as its H, an
3023 incremented-by-1 I value, and the same WORD.
3025#define fsl_xfcard_hash_step(H,I,WORD) \
3026 fsl_xfcard_hash_step_ch(H,I,(#WORD[I]))
3028/** @internal
3030 Very simple hash which has proven to be collision-free for
3031 several dozen keywords in a live scripting engine.
3032
3033 This hash is used to generate ids for limited keyword lists such
3034 that we can verify, via assert(), that the hash iscollision-free
3035 for the full input set.
3036
3037 Aside from the current implementation, these variations of
3038 fsl_xfcard_hash_step have worked out in prior testing:
3039
3040 - ((H << 1) + 100*I + I*CHAR - I* (fsl_xfcard_LowestIdChar - 1))
3041 - ((H << 1) + 45*I + CHAR - fsl_xfcard_LowestIdChar - 1)
3043 Design note: this takes an unsigned string because its argument is
3044 invariably from fsl__xfer::line::aToken.
3045*/
3046fsl_xfcard_hash_t fsl_xfcard_hash( unsigned const char * word );
3047
3048/** Non-unsigned-qualified C-string convenience form of fsl_xfcard_hash(). */
3049#define fsl_xfcard_hashS(WORD) fsl_xfcard_hash((unsigned const char *)WORD)
3050
3051/** @internal
3052
3053 Compile-time hashers for words of length 1..11.
3054*/
3055#define fsl_xfcard_hash_1(W) fsl_xfcard_hash_step(0,0,W)
3056#define fsl_xfcard_hash_2(W) fsl_xfcard_hash_step(fsl_xfcard_hash_1(W),1,W)
3057#define fsl_xfcard_hash_3(W) fsl_xfcard_hash_step(fsl_xfcard_hash_2(W),2,W)
3058#define fsl_xfcard_hash_4(W) fsl_xfcard_hash_step(fsl_xfcard_hash_3(W),3,W)
3059#define fsl_xfcard_hash_5(W) fsl_xfcard_hash_step(fsl_xfcard_hash_4(W),4,W)
3060#define fsl_xfcard_hash_6(W) fsl_xfcard_hash_step(fsl_xfcard_hash_5(W),5,W)
3061#define fsl_xfcard_hash_7(W) fsl_xfcard_hash_step(fsl_xfcard_hash_6(W),6,W)
3062#define fsl_xfcard_hash_8(W) fsl_xfcard_hash_step(fsl_xfcard_hash_7(W),7,W)
3063#define fsl_xfcard_hash_9(W) fsl_xfcard_hash_step(fsl_xfcard_hash_8(W),8,W)
3064#define fsl_xfcard_hash_10(W) fsl_xfcard_hash_step(fsl_xfcard_hash_9(W),9,W)
3065#define fsl_xfcard_hash_11(W) fsl_xfcard_hash_step(fsl_xfcard_hash_10(W),10,W)
3066#define fsl_xfcard_hash_N(N,W) fsl_xfcard_hash_ ## N(W)
3067
3068/** @internal
3069
3070 Objects for mapping known sync cards to their fsl_xfcard_e and
3071 hash of their name.
3072*/
3073struct fsl_xfcard {
3074 /** Card type ID. */
3075 const fsl_xfcard_e type;
3076 /** The protocol-level name of this card, e.g. "file" or "cfile". */
3077 char const * const name;
3078 /** A hash unique (in the context of fsl_xfcard) to this->name. */
3079 const fsl_xfcard_hash_t hash;
3080};
3081typedef struct fsl_xfcard fsl_xfcard;
3082
3083/** @internal
3084
3085 Searches for a sync card with the given name. Returns a
3086 static/const instance of one on success, else NULL. This is a
3087 binary search ordered on the card names' hashes, so is fairly fast:
3088 hash z, binary search on that hash, and one fsl_strcmp() on a
3089 match. The hash algo bails early if z is not shaped like a card
3090 name.
3091
3092 Design note: this takes an unsigned string because its argument is
3093 invariably from fsl__xfer::line::aToken.
3094*/
3095fsl_xfcard const *fsl__xfcard_search(unsigned char const *z);
3096/** Non-unsigned-qualified C-string convenience form of fsl__xfcard_search(). */
3097#define fsl__xfcard_searchNU(WORD) fsl__xfcard_search((unsigned const char *)(WORD))
3098
3099/** @internal
3100
3101 An fgets() workalike which uses an unbuffered file descriptor for
3102 reading.
3103
3104 Scans the input 1 byte at a time for a '\n', appending each read
3105 character to pOut, including the '\n' and a trailing NUL, up to a
3106 maximum of nOut-1 (to account for the NUL). If it hits EOF before
3107 finding a \n, that is not treated as an error, and downstream code
3108 may need to special-case that.
3109
3110 On success it returns 0, sets *ppOut to pOut, and *pnOut to the
3111 number of bytes filled out in pOut. On error, returns FSL_RC_IO on
3112 read error or FSL_RC_RANGE if no newline is found before nOut bytes
3113 are read.
3114
3115 If called when fdIn is at EOF, it will return 0 but set *pnOut to
3116 0.
3117
3118 On error it will return either FSL_RC_RANGE (if it finds now
3119 newline before nOut bytes) or propagate an error from the read()
3120 call, in the form of another non-0 fsl_rc_e value.
3121*/
3122int fsl__fdgets(int fdIn, unsigned char * pOut, fsl_size_t nOut,
3123 char **ppOut, fsl_size_t * pnOut);
3124
3125/** @internal
3126
3127 fsl_file_tempname() proxy which uses fsl_temp_dirs_get() to get the
3128 target dir. zBaseName may be NULL but library routines are strongly
3129 enouraged to use a of "libfossil-PURPOSE", where PURPOSE is a
3130 descrtive identifier, e.g. "PopenRequest" or "popen-request".
3131*/
3132int fsl__tmpfile( fsl_buffer * tgt, char const * zBaseName );
3133
3134/**
3135 If FSL_PLATFORM_IS_UNIX then this returns the result of chmod(2)
3136 for the given file name, converted from errno using
3137 fsl_errno_to_rc(). It uses permissions 0600.
3139 On other platforms this is a no-op and returns 0.
3140*/
3141int fsl__tmpchmod( char const * z );
3142
3143// Potential TODO
3144//int fsl__tmpfile_open( char const * zBaseName, FILE **fOut );
3145
3146/** @internal
3147
3148 Searches the OS path zPath for a binary named zBinName. If found,
3149 it puts a library-allocated copy of the resolved name to *zOut
3150 (which the caller must eventually pass to fsl_free()) then returns
3151 0.
3152
3153 If zPath is NULL, getenv("PATH") is used.
3154
3155 On error, *zOut is not modified and non-0 is returned:
3156
3157 - FSL_RC_NOT_FOUND if no match is found. This will also be returned
3158 if both zPath and $PATH are NULL.
3159
3160 - FSL_RC_OOM on allocation error.
3161
3162 On Windows platforms it will extend the search to include a ".exe"
3163 extension.
3164*/
3165int fsl__find_bin( char const *zPath, char const *zBinName, char **zOut );
3166
3167/**
3168 If d->P.used then this makes d->P.list[0] a delta from d->rid, else
3169 this is a no-op. Returns non-0 if fetching the parent RID or
3170 deltification fail. Returns 0 if there's nothing to do or if what
3171 needs doing gets done.
3172*/
3174
3175/**
3176 Imports content to f's opened repository's BLOB table using a
3177 client-provided input source. f must have an opened repository
3178 db. inFunc is the source of the data and inState is the first
3179 argument passed to inFunc(). If inFunc() succeeds in fetching all
3180 data (i.e. if it always returns 0 when called by this function)
3181 then that data is inserted into the blob table _if_ no existing
3182 record with the same hash is already in the table. If such a record
3183 exists, it is assumed that the content is identical and this
3184 function has no side-effects vis-a-vis the db in that case.
3185
3186 If rid is not NULL then the BLOB.RID record value (possibly of an
3187 older record!) is stored in *rid. If uuid is not NULL then the
3188 BLOB.UUID record value is stored in *uuid and the caller takes
3189 ownership of those bytes, which must eventually be passed to
3190 fsl_free() to release them.
3191
3192 rid and uuid are only modified on success and only if they are
3193 not NULL.
3194
3195 Returns 0 on success, non-0 on error. For errors other than basic
3196 argument validation and OOM conditions, f's error state is
3197 updated with a description of the problem. Returns FSL_RC_MISUSE
3198 if either f or inFunc are NULL. Whether or not inState may be
3199 NULL depends on inFunc's concrete implementation.
3200
3201 Be aware that BLOB.RID values can (but do not necessarily) change
3202 in the life of a repod db (via a reconstruct, a full re-clone, or
3203 similar, or simply when referring to different clones of the same
3204 repo). Thus clients should always store the full UUID, as opposed
3205 to the RID, for later reference. RIDs should, in general, be
3206 treated as session-transient values. That said, for purposes of
3207 linking tables in the db, the RID is used exclusively (clients are
3208 free to link their own extension tables using UUIDs, but doing so
3209 has a performance penalty comared to RIDs). For long-term storage
3210 of external links, and to guaranty that the data be usable with
3211 other copies of the same repo, the UUID is required.
3212
3213 Note that Fossil may deltify, compress, or otherwise modify
3214 content on its way into the blob table, and it may even modify
3215 content long after its insertion (e.g. to make it a delta against
3216 a newer version). Thus clients should normally never try
3217 to read back the blob directly from the database, but should
3218 instead read it using fsl_content_get().
3220 That said: this routine has no way of associating and older version
3221 (if any) of the same content with this newly-imported version, and
3222 therefore cannot delta-compress the older version.
3223
3224 Maintenance reminder: this is basically just a glorified form of
3225 the internal fsl__content_put(). Interestingly, fsl__content_put()
3226 always sets content to public (by default - the f object may
3227 override that later). It is not yet clear whether this routine
3228 needs to have a flag to set the blob private or not. Generally
3229 speaking, privacy is applied to fossil artifacts, as opposed to
3230 content blobs.
3232 @see fsl__repo_import_buffer()
3233*/
3235 void * inState, fsl_id_t * rid,
3236 fsl_uuid_str * uuid );
3237
3238/**
3239 A convenience form of fsl__repo_import_blob(), equivalent to:
3240
3241 ```
3242 fsl__repo_import_blob(f, fsl_input_f_buffer, bIn, rid, uuid )
3243 ```
3245 except that (A) bIn is const in this call and non-const in the
3246 other form (due to cursor traversal requirements) and (B) it
3247 returns FSL_RC_MISUSE if bIn is NULL.
3248*/
3249int fsl__repo_import_buffer( fsl_cx * f, fsl_buffer const * bIn,
3250 fsl_id_t * rid, fsl_uuid_str * uuid );
3251
3253#define E(NAME,IGNORED) fsl__cx_stmt_e_ ## NAME,
3255#undef E
3256};
3257
3258/**
3259 Returns the given cached statement object, preparing it if needed.
3260 If preparation fails then NULL is returned and f->error will
3261 hold the details.
3262
3263 If this returns non-NULL then the caller is obligated to pass the
3264 same q object to fsl__cx_stmt_yield().
3265*/
3266fsl_stmt * fsl__cx_stmt(fsl_cx * f, enum fsl__cx_stmt_e which);
3267
3268/**
3269 Must be passed all statement pointers obtained via fsl__cx_stmt().
3270 It MUST NOT be passed any statement from elsewhere except that
3271 q==NULL is permitted to simplify its usage. This resets the
3272 statement and clears any bindings.
3273
3274 Callers must treat q as if this function finalizes it, i.e. they
3275 must not derefence any members or pass it to another API after
3276 this. It can only be legally used again after fetching it from
3277 fsl__cx_stmt().
3278*/
3279void fsl__cx_stmt_yield(fsl_cx * f, fsl_stmt * q);
3280
3281/**
3282 Clears various internal caches and resets various
3283 internally-cached values related to repository and checkout
3284 dbs. Its argument must be true if we're clearing caches as a
3285 result of a transaction commit, else false.
3286*/
3287void fsl__cx_caches_reset(fsl_cx * f, bool isTxnCommit);
3288
3289/**
3290 May clear or reset cached data. This is intended to be called as
3291 part of a transaction commit/rollback hook and be passed true for a
3292 commit and false for a rollback.
3293*/
3294void fsl__cx_reset_for_txn(fsl_cx * f, bool isCommit);
3295
3296/**
3297 Clears only caches which are relevant to content lookup.
3300
3301/**
3302 Clears the contents of f->cache.mcache.
3303*/
3306/**
3307 An experiment.
3309 Runs BODY ( a {...} block) in the context of a fsl_cx savepoint.
3310 The body is expected to assign int-type RcVar to 0 on success and
3311 false on error. If RcVar is 0 when this is invoked, BODY is not
3312 run. If BODY succeeds, the savepoint is saved if KeepSPOnSuccess
3313 is true, else it is silently discarded. If RollbackTopOnError is
3314 true then any outer savepoint is put into a persistent rollback
3315 state, else any outer savepoint is unaffected. If BODY succeeds but
3316 the commit/rollback fails, RcVar is set to that failure code.
3317*/
3318#define fsl__cx_txn(FslCx, RcVar, RollbackTopOnError, KeepSPOnSuccess, BODY) { \
3319 RcVar = fsl_cx_txn_begin(FslCx); \
3320 if( 0==RcVar ){ \
3321 BODY \
3322 } \
3323 int const RcVar ## __ = \
3324 fsl_cx_txn_end_v2((FslCx), (0==RcVar) && (KeepSPOnSuccess), \
3325 ((RollbackTopOnError) && (0!=RcVar))); \
3326 if( !RcVar ) RcVar = RcVar ## __; \
3327 }
3329/**
3330 fsl__cx_txn() proxy for use with local savepoints which should not
3331 trigger a global savepoint rollback on error.
3333#define fsl__cx_txn_local(FslCx, RcVar, KeepSPOnSuccess, BODY) \
3334 fsl__cx_txn(FslCx, RcVar, 0, KeepSPOnSuccess, BODY)
3335
3336/**
3337 fsl__cx_txn() proxy for use with local savepoints which should
3338 trigger a global savepoint rollback on error.
3339*/
3340#define fsl__cx_txn_global(FslCx, RcVar, KeepSPOnSuccess, BODY) \
3341 fsl__cx_txn(FslCx, RcVar, 1, KeepSPOnSuccess, BODY)
3342
3343void fsl__id_bag_dump(fsl_id_bag const * src, FILE *to/*NULL==stdout*/,
3344 char const *zHeader);
3345
3346/* fsl__ptl details are in cache.c */
3347int fsl__ptl_init(fsl__ptl * c, uint16_t prealloc);
3349bool fsl__ptl_has(fsl__ptl const * c, fsl__ptl_e where, fsl_id_t rid);
3350int fsl__ptl_insert(fsl__ptl * c, fsl__ptl_e where, fsl_id_t rid);
3351bool fsl__ptl_remove(fsl__ptl const * c, fsl__ptl_e where, fsl_id_t rid);
3352
3353/**
3354 Can fail with OOM if isCommit and f->cache.ptl.level>0.
3355*/
3356int fsl__cx_ptl_pop(fsl_cx * f, bool isCommit);
3357int fsl__cx_ptl_push(fsl_cx * f);
3358/**
3359 Returns the given bag for the current transaction level. Never
3360 returns NULL unless "which" is invalid, in which case it prefers to
3361 fail fatally.
3362*/
3364/**
3365 Removes rid from the given PTL list.
3366*/
3367bool fsl__cx_ptl_remove(fsl_cx * f, fsl__ptl_e where, fsl_id_t rid);
3368#define fsl__cx_ptl_has(F,W,R) fsl__ptl_has(&(F)->cache.ptl, W, R)
3369#define fsl__cx_ptl_insert(F,W,R) fsl__ptl_insert(&(F)->cache.ptl, W, R)
3370
3371/**
3372 Sets *rid to f->db.ckout.rid, fetching the latter if
3373 needed. Returns non-0 if fetching fails.
3374*/
3375int fsl__ckout_rid(fsl_cx * f, fsl_id_t *rid);
3376
3377#if !defined(NDEBUG)
3378/**
3379 A place to put a breakpoint to help trace down errors. Pass it the
3380 rc of a just-failed operation and set a breakpoint in the if(rc)
3381 block of this function in fsl.c.
3382*/
3383void fsl__bprc(int rc);
3384#else
3385#define fsl__bprc(X) (void)0
3386#endif
3387
3388#if defined(__cplusplus)
3389} /*extern "C"*/
3390#endif
3391#endif
3392/* ORG_FOSSIL_SCM_FSL_INTERNAL_H_INCLUDED */
int32_t fsl_id_t
fsl_id_t is a signed integer type used to store database record IDs.
Definition config.h:271
uint64_t fsl_size_t
fsl_size_t is an unsigned integer type used to denote absolute ranges and lengths.
Definition config.h:192
int64_t fsl_time_t
The type used to represent type values.
Definition config.h:296
uint32_t fsl_flag32_t
A 32-bit unsigned int type.
Definition config.h:154
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...
Definition config.h:143
uint64_t fsl_uint_t
The unsigned counterpart of fsl_int_t.
Definition config.h:147
fsl_dbrole_e
This enum defines type ID tags with which the API tags fsl_db instances so that the library can figur...
Definition core.h:156
fsl_fileperm_e
File permissions flags supported by fossil manifests.
Definition core.h:511
#define E(N, V, H)
Definition core.h:497
fsl_satype_e
An enumeration of the types of structural artifacts used by Fossil.
Definition core.h:1676
fsl_buffer * fsl__cx_content_buffer(fsl_cx *f)
int fsl__repo_fingerprint_search(fsl_cx *f, fsl_id_t rcvid, char **zOut)
int fsl__ckout_rm_empty_dirs_for_file(fsl_cx *f, char const *zAbsPath)
const fsl__mcache fsl__mcache_empty
int fsl__vfile_to_ckout(fsl_cx *f, fsl_id_t vfileId, int *wasWritten)
int fsl__ckout_clear_merge_state(fsl_cx *f, bool fullWipe)
int fsl__rid_delete(fsl_cx *f, fsl_dbrole_e dbRole, char const *zTable, fsl_id_t rid)
Expects zTable to name a table with an rid field.
fsl_db * fsl__cx_db_for_role(fsl_cx *f, fsl_dbrole_e r)
void fsl__cx_reset_for_txn(fsl_cx *f, bool isCommit)
May clear or reset cached data.
int fsl__cx_ptl_push(fsl_cx *f)
void fsl__bprc(int rc)
A place to put a breakpoint to help trace down errors.
int fsl__pq_insert(fsl__pq *p, fsl_id_t e, double v, void *pData)
int fsl__leaf_do_pending_checks(fsl_cx *f)
int fsl__cx_StaticAssertScratchpadSizes[((sizeof(fsl__cx_empty.scratchpads.buf)/sizeof(fsl__cx_empty.scratchpads.buf[0]))==(sizeof(fsl__cx_empty.scratchpads.used)/sizeof(fsl__cx_empty.scratchpads.used[0]))) ? 1 :-1]
Ensure that fsl_cx::scratchpads::buf/used have the same array size.
Definition internal.h:1058
int fsl__popen2(const char *zCmd, int *pfdIn, FILE **ppOut, int *pChildPid)
void fsl__bccache_clear(fsl__bccache *c)
int fsl__unsent_rid_add(fsl_cx *f, fsl_id_t rid)
Inserts the given rid into the repo.unsent table.
int fsl__bccache_check_available(fsl_cx *f, fsl_id_t rid)
bool fsl__ptl_has(fsl__ptl const *c, fsl__ptl_e where, fsl_id_t rid)
void fsl__bccache_reuse(fsl__bccache *c)
int fsl__tag_propagate(fsl_cx *f, fsl_tagtype_e tagType, fsl_id_t pid, fsl_id_t tagid, fsl_id_t origId, const char *zValue, double mtime)
int fsl__fdgets(int fdIn, unsigned char *pOut, fsl_size_t nOut, char **ppOut, fsl_size_t *pnOut)
int fsl__ckout_version_write(fsl_cx *f, fsl_id_t vid, fsl_uuid_cstr uuid)
int fsl__crosslink_begin(fsl_cx *f)
int fsl__repo_import_buffer(fsl_cx *f, fsl_buffer const *bIn, fsl_id_t *rid, fsl_uuid_str *uuid)
A convenience form of fsl__repo_import_blob(), equivalent to:
int fsl__ckout_symlink_create(fsl_cx *f, char const *zTgtFile, char const *zLinkFile)
int fsl__is_locally_modified(fsl_cx *f, const char *zFilename, fsl_size_t fileSize, const char *zOrigHash, fsl_int_t zOrigHashLen, fsl_fileperm_e origPerm, int *isModified)
void fsl__ptl_clear(fsl__ptl *c)
int fsl__call_xlink_listeners(fsl_deck *d)
void fsl__cx_stmt_yield(fsl_cx *f, fsl_stmt *q)
Must be passed all statement pointers obtained via fsl__cx_stmt().
void fsl__cx_content_buffer_yield(fsl_cx *f)
unsigned char * fsl__tokenizer_next(fsl__tokenizer *pIn, fsl_size_t *pLen)
int fsl__deck_crosslink_one(fsl_deck *d)
int fsl__repo_filename_fnid2(fsl_cx *f, char const *filename, fsl_id_t *rv, bool createNew)
int fsl__search_doc_touch(fsl_cx *f, fsl_satype_e saType, fsl_id_t rid, const char *docName)
int fsl__tag_propagate_all(fsl_cx *f, fsl_id_t pid)
int fsl__diff_all(fsl__diff_cx *p)
void fsl__mutex_leave(void)
void fsl__cx_scratchpad_yield(fsl_cx *f, fsl_buffer *b)
int fsl__cx_see_key(fsl_cx *f, const char *zDbFile, fsl_buffer *pOut, int *keyType)
int fsl__tmpfile(fsl_buffer *tgt, char const *zBaseName)
int fsl__phantom_rid_add(fsl_cx *f, fsl_id_t rid)
Inserts the given rid into the repo.phantom table.
const fsl_cx fsl__cx_empty
void fsl__dump_triples(fsl__diff_cx const *p, char const *zFile, int ln)
void fsl__pq_clear(fsl__pq *p)
void fsl__card_J_list_free(fsl_list *li, bool alsoListMem)
unsigned int fsl__ckout_rm_empty_dirs(fsl_cx *f, fsl_buffer const *tgtDir)
#define fsl__ptl_line_map(E)
Expands to a list of the names of all fsl_id_bag members of the fsl__ptl_line struct by invoking macr...
Definition internal.h:306
int fsl__tag_insert(fsl_cx *f, fsl_tagtype_e tagtype, char const *zTag, char const *zValue, fsl_id_t srcId, double mtime, fsl_id_t rid, fsl_id_t *outRid)
int fsl__ckout_rid(fsl_cx *f, fsl_id_t *rid)
Sets *rid to f->db.ckout.rid, fetching the latter if needed.
char * fsl__config_inop_rhs(int iMask)
int fsl__leaf_eventually_check(fsl_cx *f, fsl_id_t rid)
int fsl__repo_verify_before_commit(fsl_cx *f, fsl_id_t rid)
int fsl__symlink_copy(char const *zFrom, char const *zTo, bool realLink)
int fsl__cx_ticket_create_table(fsl_cx *f)
bool fsl__mutex_held(void)
bool fsl__cx_ptl_remove(fsl_cx *f, fsl__ptl_e where, fsl_id_t rid)
Removes rid from the given PTL list.
int fsl__shunned_remove(fsl_cx *f)
@ fsl__xfer_max_tokens
Max number of expected tokens in fsl__xfer::line.
Definition internal.h:2704
int fsl__content_put_ex(fsl_cx *f, fsl_buffer const *pBlob, fsl_uuid_cstr zUuid, fsl_id_t srcId, fsl_size_t uncompSize, bool isPrivate, fsl_id_t *outRid)
int fsl__foci_register(fsl_cx *f, fsl_db *db)
fsl_xfcard_hash_t fsl_xfcard_hash(unsigned const char *word)
const fsl__tokenizer fsl__tokenizer_empty
fsl_xfcard const * fsl__xfcard_search(unsigned char const *z)
int fsl__private_rid_add(fsl_cx *f, fsl_id_t rid)
Inserts the given rid into the repo.private table.
void fsl__cx_mcache_clear(fsl_cx *f)
Clears the contents of f->cache.mcache.
int fsl__db_repo_verify_schema(fsl_db *db)
char * fsl__file_without_drive_letter(char *zFile)
int fsl__db_errcode(fsl_db *db, int sqliteCode)
const fsl__diff_cx fsl__diff_cx_empty
int fsl__ticket_rebuild(fsl_cx *f, char const *zTktId)
int fsl__repo_shun_artifacts(fsl_cx *f)
int fsl__ptl_insert(fsl__ptl *c, fsl__ptl_e where, fsl_id_t rid)
int fsl__delta_replace(fsl_cx *f, fsl_id_t rid, fsl_id_t srcid)
Replaces the repo.delta entry with the given rid.
bool fsl__ptl_remove(fsl__ptl const *c, fsl__ptl_e where, fsl_id_t rid)
void fsl__repo_verify_cancel(fsl_cx *f)
fsl__localmod_e
Definition internal.h:2128
@ FSL__LOCALMOD_CONTENT
File size or hash (i.e.
Definition internal.h:2138
@ FSL__LOCALMOD_LINK
The file type was switched between symlink and normal file.
Definition internal.h:2144
@ FSL__LOCALMOD_NOTFOUND
File was not found in the local checkout.
Definition internal.h:2148
@ FSL__LOCALMOD_PERM
Permissions changed.
Definition internal.h:2134
@ FSL__LOCALMOD_NONE
Sentinel value.
Definition internal.h:2130
bool fsl__is_reserved_fn_windows(const char *zPath, fsl_int_t nameLen)
int fsl__content_deltify(fsl_cx *f, fsl_id_t rid, fsl_id_t srcid, bool force)
int fsl__cx_attach_role(fsl_cx *f, const char *zDbName, fsl_dbrole_e r, bool createIfNotExists)
fsl_id_t fsl__uuid_to_rid2(fsl_cx *f, fsl_uuid_cstr uuid, fsl__phantom_e mode)
fsl_stmt * fsl__cx_stmt(fsl_cx *f, enum fsl__cx_stmt_e which)
Returns the given cached statement object, preparing it if needed.
void fsl__db_clear_strings(fsl_db *db, bool alsoBuffers)
fsl__cx_stmt_e
Definition internal.h:3217
int fsl__repo_import_blob(fsl_cx *f, fsl_input_f inFunc, void *inState, fsl_id_t *rid, fsl_uuid_str *uuid)
Imports content to f's opened repository's BLOB table using a client-provided input source.
int fsl__pclose2(int fdIn, FILE *pOut, int childPid)
void fsl__cx_content_caches_clear(fsl_cx *f)
Clears only caches which are relevant to content lookup.
int fsl__phantom_new(fsl_cx *f, fsl_uuid_cstr uuid, bool isPrivate, fsl_id_t *newId)
void fsl__cx_caches_reset(fsl_cx *f, bool isTxnCommit)
Clears various internal caches and resets various internally-cached values related to repository and ...
int fsl__repo_record_filename(fsl_cx *f)
int fsl__crosslink_end(fsl_cx *f, int resultCode)
int fsl__delta_delete(fsl_cx *f, fsl_id_t rid)
Replaces the repo.delta entry with the given rid.
void fsl__deck_clean_cards(fsl_deck *d, char const *letters)
fsl_id_t fsl__pq_extract(fsl__pq *p, void **pp)
int fsl__ckout_version_fetch(fsl_cx *f)
#define fsl__cx_cache_stmt_map(E)
Definition internal.h:894
int fsl__deck_crosslink(fsl_deck *d)
bool fsl__bccache_expire_oldest(fsl__bccache *c)
int fsl__ckout_safe_file_check(fsl_cx *f, char const *zFilename)
int fsl__cx_ticket_load_fields(fsl_cx *f, bool forceReload)
int fsl__find_filename_changes(fsl_cx *f, fsl_id_t iFrom, fsl_id_t iTo, bool revOK, uint32_t *pnChng, fsl_id_t **aiChng)
int fsl__tmpchmod(char const *z)
If FSL_PLATFORM_IS_UNIX then this returns the result of chmod(2) for the given file name,...
fsl_card_J_flags
Definition internal.h:1606
@ FSL_CARD_J_TICKET
Indicates that the field is used by the ticket table.
Definition internal.h:1614
@ FSL_CARD_J_BOTH
Indicates that the field is used by both the ticket and ticketchng tables.
Definition internal.h:1623
@ FSL_CARD_J_CHNG
Indicates that the field is used by the ticketchng table.
Definition internal.h:1618
@ FSL_CARD_J_INVALID
Sentinel value.
Definition internal.h:1610
int fsl__cx_init_db(fsl_cx *f, fsl_db *db)
#define STMT(MEMBER, IGNORED)
Definition internal.h:946
int fsl__bccache_insert(fsl__bccache *c, fsl_id_t rid, fsl_buffer *pBlob)
const fsl__xfer fsl__xfer_empty
Empty-initialized fsl__xfer instance, intended for copy initialization.
int fsl__repo_verify_at_commit(fsl_cx *f)
fsl__ptl_e
Enum entries corresponding to fsl__ptl_line members.
Definition internal.h:344
@ fsl__ptl_e_dummy
Sentinel value needed in slot 0.
Definition internal.h:346
int fsl__cx_ptl_pop(fsl_cx *f, bool isCommit)
Can fail with OOM if isCommit and f->cache.ptl.level>0.
fsl_buffer * fsl__cx_scratchpad(fsl_cx *f)
fsl_id_bag * fsl__cx_ptl_bag(fsl_cx *f, fsl__ptl_e which)
Returns the given bag for the current transaction level.
int fsl__unclustered_rid_add(fsl_cx *f, fsl_id_t rid)
Inserts the given rid into the repo.unclustered table.
int fsl__ptl_init(fsl__ptl *c, uint16_t prealloc)
const fsl__pq fsl__pq_empty
fsl_card_F * fsl__deck_F_seek(fsl_deck *d, const char *zName)
#define E(X)
Definition internal.h:318
fsl__phantom_e
Definition internal.h:1454
@ FSL_PHANTOM_PRIVATE
Indicates to fsl__uuid_to_rid2() that a private phantom artifact should be created if no artifact is ...
Definition internal.h:1469
@ FSL_PHANTOM_PUBLIC
Indicates to fsl__uuid_to_rid2() that a public phantom artifact should be created if no artifact is f...
Definition internal.h:1464
@ FSL_PHANTOM_NONE
Indicates to fsl__uuid_to_rid2() that no phantom artifact should be created.
Definition internal.h:1459
void fsl__mutex_enter(void)
void fsl__diff_optimize(fsl__diff_cx *p)
int fsl__mcache_StaticAssertArraySizes[((sizeof(fsl__mcache_empty.aAge)/sizeof(fsl__mcache_empty.aAge[0]))==(sizeof(fsl__mcache_empty.decks)/sizeof(fsl__mcache_empty.decks[0]))) ? 1 :-1]
This will fail to compile if the arrays fsl__mcache::aAge and fsl__mcache::decks have different sizes...
Definition internal.h:300
int fsl__db_cached_clear_role(fsl_db *db, fsl_flag32_t role)
int fsl__ckout_install_schema(fsl_cx *f, bool dropIfExists)
void fsl__cx_ckout_clear(fsl_cx *f)
void fsl__id_bag_dump(fsl_id_bag const *src, FILE *to, char const *zHeader)
void fsl__fatal(int code, char const *fmt,...)
int fsl__deck_deltify_parent(fsl_deck *d)
If d->P.used then this makes d->P.list[0] a delta from d->rid, else this is a no-op.
int fsl__content_put(fsl_cx *f, fsl_buffer const *pBlob, fsl_id_t *newRid)
int fsl__qsort_cmp_J_cards(void const *lhs, void const *rhs)
int fsl__content_undeltify(fsl_cx *f, fsl_id_t rid)
int fsl__find_bin(char const *zPath, char const *zBinName, char **zOut)
int fsl__private_rid_delete(fsl_cx *f, fsl_id_t rid)
Deletes the given rid from the repo.private table.
void fsl__diff_cx_clean(fsl__diff_cx *cx)
char * fsl__db_setting_inop_rhs(void)
int fsl__cx_update_seen_delta_deck(fsl_cx *f)
uint32_t fsl_xfcard_hash_t
Definition internal.h:2947
repo.h declares APIs specifically dealing with repository-db-side state, as opposed to specifically c...
fsl_tagtype_e
Artifact tag types used by the Fossil framework.
Definition repo.h:107
fsl_buffer content
Content of the artifact.
Definition internal.h:129
fsl_uint_t age
Age.
Definition internal.h:125
fsl_id_t rid
RID of the cached record.
Definition internal.h:121
fsl_uint_t nextAge
Next cache counter age.
Definition internal.h:187
unsigned misses
Definition internal.h:212
struct fsl__bccache::@135011273363202315345003011053312261121034167134 metrics
Metrics solely for internal use in looking for optimizations.
fsl__bccache_line * list
List of cached content, ordered by age.
Definition internal.h:199
unsigned szLimit
Limit on the (approx.) amount of memory (in bytes) which can be taken up by the cached buffers at one...
Definition internal.h:166
unsigned changeMarker
Gets incremented on each insert for purposes of invalidating this cache.
Definition internal.h:194
unsigned szTotal
Total amount of buffer memory (in bytes) used by cached content.
Definition internal.h:160
uint16_t used
Number of entries "used" in this->list.
Definition internal.h:170
uint16_t capacity
Number of allocated slots in this->list.
Definition internal.h:183
fsl_id_bag inCache
RIDs of all artifacts currently in the this->list cache.
Definition internal.h:204
unsigned hits
Definition internal.h:211
uint16_t usedLimit
Approximate upper limit on the number of entries in this->list.
Definition internal.h:179
int(* cmpLine)(const fsl_dline *const, const fsl_dline *const)
Predicate for comparing LHS/RHS lines for equivalence.
Definition internal.h:2359
int nEdit
Number of integers (3x num of triples) in aEdit[].
Definition internal.h:2347
int nTo
Number of lines in aTo[].
Definition internal.h:2357
fsl_dline * aFrom
File content for the left side of the diff.
Definition internal.h:2351
int nFrom
Number of lines in aFrom[].
Definition internal.h:2353
fsl_dline * aTo
File content for the right side of the diff.
Definition internal.h:2355
int * aEdit
aEdit describes the raw diff.
Definition internal.h:2345
int nEditAlloc
Number of elements allocated for aEdit[].
Definition internal.h:2349
fsl_deck decks[4]
Stores bitwise copies of decks.
Definition internal.h:267
unsigned hits
Counts the number of cache hits.
Definition internal.h:250
unsigned misses
Counts the number of cache misses.
Definition internal.h:252
fsl_uint_t aAge[4]
The virtual age of each deck in the cache.
Definition internal.h:255
fsl_uint_t nextAge
Next age value.
Definition internal.h:248
Definition internal.h:51
double priority
Priority of this element.
Definition internal.h:57
void * data
Raw data associated with this entry.
Definition internal.h:55
fsl_id_t id
RID of the entry.
Definition internal.h:53
fsl__pq_entry * list
The queue.
Definition internal.h:76
uint16_t capacity
Number of items allocated in this->list.
Definition internal.h:72
uint16_t used
Number of items used in this->list.
Definition internal.h:74
A cache of fsl_cx state which applies per transaction level.
Definition internal.h:317
This object manages a stack of fsl__ptl_line objects for a fsl_cx.
Definition internal.h:357
uint16_t level
0-based level.
Definition internal.h:363
int validateRidLevel
The transaction level in which the first RIDs (in this transaction stack) were added.
Definition internal.h:370
int rc
Persistent error code.
Definition internal.h:359
fsl__ptl_line * line
Current line in this->stack.
Definition internal.h:374
fsl_buffer mem
Memory for this->stack.
Definition internal.h:376
fsl__ptl_line * stack
Memory living in this->mem.
Definition internal.h:372
uint16_t allocated
Number of levels currently allocated.
Definition internal.h:361
unsigned char * z
First char of the next token.
Definition internal.h:2668
unsigned char * zEnd
One-past-the-end of the input.
Definition internal.h:2672
bool atEol
True if z points to the start of a new line.
Definition internal.h:2676
bool syncPrivate
True to enable syncing private content.
Definition internal.h:2802
fsl_sc chz
When using compressed responses, we need a layer of buffer to do the decompression.
Definition internal.h:2865
int rc
Almost all APIs which deal with this class (A) become no-ops if this is non-0, returning this value i...
Definition internal.h:2743
fsl_buffer cardPayload
Card payloads.
Definition internal.h:2783
char const * zAltPCode
Definition internal.h:2800
struct fsl__xfer::@106013134107234007264164355323121067061170035070 buf
Memory buffers.
bool nextIsPrivate
If true, next "file" received is a private artifact.
Definition internal.h:2804
int clockSkewSeen
Seconds of offset from localhost.
Definition internal.h:2812
int httpCode
Definition internal.h:2884
unsigned configRcvMask
Definition internal.h:2798
char const * name
User name memory owned by fsl__xfer::url.
Definition internal.h:2842
fsl_size_t nBytes
Number of bytes submitted for the request body.
Definition internal.h:2879
fsl_sha1_cx sha1
Hash of all request payload content, for generating the sync login card.
Definition internal.h:2874
int protocolVersion
Definition internal.h:2832
fsl_buffer bRaw
A raw, untokenized copy of b.
Definition internal.h:2756
fsl_cx * f
This object's fossil context.
Definition internal.h:2722
struct fsl__xfer::@213277222214172032306271371067326072022273034014 remote
Info about the remote.
short projCodeMatch
Tells us whether the remote project-code matches this one.
Definition internal.h:2829
fsl_size_t seqNo
Definition internal.h:2833
char const * password
Password memory owned by fsl__xfer::url.
Definition internal.h:2846
int manifestDate
Definition internal.h:2809
unsigned char * aToken[fsl__xfer_max_tokens]
Holds pointers to the individual tokens of b.
Definition internal.h:2761
fsl_stmt gimmeInsert
Definition internal.h:2791
struct fsl__xfer::@254005110157216005234214245024012031337222344012 request
fsl_stmt remoteUnkUuid
Definition internal.h:2793
fsl_buffer uresp
When using compressed responses, this is where it will store the uncompressed response.
Definition internal.h:2777
int releaseVersion
Definition internal.h:2808
struct fsl__xfer::@052356161311116115313350223176365365100245236047 line
One line of sync protocol input, which we tokenize via fsl__xfer_readln() for ease of processing.
int httpVersion
Definition internal.h:2883
fsl_sc * ch
The underlying communication channel.
Definition internal.h:2727
char * passwordToFree
Password memory owned by this object.
Definition internal.h:2851
struct fsl__xfer::@335205311072101202001330246203343006010326070331 q
Prepared statements.
fsl_buffer scratch
Generic scratchpad buffer.
Definition internal.h:2781
struct fsl__xfer::@123014107133202344251234372016036320270302156002 user
Info about the user which is relevant for sync.
fsl_uperm perm
Permissions calculated for the current user from sync login info.
Definition internal.h:2857
struct fsl__xfer::@331035010067370376046064066104352104050150153142 clone
struct fsl__xfer::@061243306230124057304262021256341342124057174064 response
fsl_buffer loginCard
Definition internal.h:2875
fsl_stmt igotHasRid
Definition internal.h:2790
fsl_stmt igotInsert
Definition internal.h:2789
struct fsl__xfer::@100355014156122125342103015172167034116165030312 flag
Various flags.
fsl_buffer b
Holds the current input line.
Definition internal.h:2752
uint8_t nToken
The number of tokens in use in aToken.
Definition internal.h:2767
int manifestTime
Definition internal.h:2810
fsl_xfer_metrics n
Various counters.
Definition internal.h:2867
unsigned configSendMask
Definition internal.h:2799
fsl_buffer hash
Hashing and UUID-fetching buffer.
Definition internal.h:2779
struct fsl__xfer::@155057320143012371237373355124062315143161126301 clientVersion
fsl_buffer emit
fsl_xfer_emit() and friends
Definition internal.h:2785
fsl_xfer_config * config
The configuration object for a given xfer trip.
Definition internal.h:2734
fsl_size_t aTokLen[fsl__xfer_max_tokens]
Holds the strlen() of each token in aTokens.
Definition internal.h:2765
A general-purpose buffer class, analog to Fossil's Blob class, but it is not called fsl_blob to avoid...
Definition util.h:684
F-cards each represent one file entry in a Manifest Artifact (i.e., a checkin version).
Definition repo.h:2200
A fsl_confirm_callback_f and its callback state, packaged into a neat little struct for easy copy/rep...
Definition util.h:6128
A part of the configuration used by fsl_cx_init() and friends.
Definition core.h:817
The main Fossil "context" type.
Definition internal.h:400
fsl_size_t nCommit
Definition internal.h:540
fsl_uuid_str uuid
The UUID of the current checkout.
Definition internal.h:496
fsl_buffer fileContent
A place for temporarily holding file content.
Definition internal.h:804
bool hasChngRid
Gets set to true (at some point) if the client has the ticketchng.rid db field.
Definition internal.h:1002
volatile int interrupted
Error flag which is intended to be set via signal handlers or a UI thread to tell this context to can...
Definition internal.h:669
fsl_deck mf
The deck used for incrementally building certain parts of a checkin.
Definition internal.h:558
struct fsl_cx::@020007115146216147330072070376055307053057350026::@005264160241016147273066030235165362255023103043 gconfig
Holds info directly related to a global config database.
fsl_id_t mtimeManifest
Infrastructure for fsl_mtime_of_manifest_file().
Definition internal.h:835
char * titleColumn
The name of the ticket-table field which refers to a ticket's title.
Definition internal.h:1008
fsl_id_bag selectedIds
Holds a list of "selected files" in the form of vfile.id values.
Definition internal.h:552
fsl_size_t nPeakBufSize
The maximum buffer capacity the content buffer had at relenquish-time.
Definition internal.h:1033
fsl_size_t nRollback
Definition internal.h:541
fsl_list ignore
Holds the "ignore-glob" globs.
Definition internal.h:869
fsl_buffer emit
A scratchpad specific to fsl__cx_emit() and friends.
Definition internal.h:647
char * dir
The directory part of an opened checkout db.
Definition internal.h:481
bool hasCTime
Gets set to true (at some point) if the client has the ticket.tkt_ctime db field.
Definition internal.h:990
int peakTxnLevel
Definition internal.h:538
char * mainBranch
The 'main-branch' repo config setting, defaulting to trunk.
Definition internal.h:520
short next
A cursor hint to try to speed up fsl__cx_scratchpad() by about half a nanosecond, making it O(1) inst...
Definition internal.h:643
fsl_size_t nCached
Number of times the internal content cache was used.
Definition internal.h:1022
short manifestSetting
Cache for the manifest config setting, as used by fsl_ckout_manifest_setting(), with the caveat that ...
Definition internal.h:778
struct fsl_cx::@020007115146216147330072070376055307053057350026::@163032253113021157001163004114365127333115365334 repo
Holds info directly related to a repo database.
bool isCrosslinking
True if fsl__crosslink_begin() has been called but fsl__crosslink_end() is still pending.
Definition internal.h:699
char * user
The default user name, for operations which need one.
Definition internal.h:517
fsl_buffer buf[8]
Strictly-internal temporary buffers we intend to reuse many times, mostly for filename canonicalizati...
Definition internal.h:633
fsl_flag32_t flags
Flags, some (or one) of which is runtime-configurable by the client (see fsl_cx_flags_e).
Definition internal.h:660
double mtime
Julian mtime of the checkout version, as reported by the [event] table.
Definition internal.h:501
fsl_db * dbMain
A pointer to the "main" db handle.
Definition internal.h:447
bool hasChng
Gets set to true (at some point) if the client has the ticketchng db table.
Definition internal.h:996
struct fsl_cx::@340103301036114033226306247146313264106064016232::@332143205074315256147100340201300235145204062251 stmt
Very-frequently-used SQL statements.
short caseInsensitive
Specifies whether SOME repository-level file-name comparisons/searches will work case-insensitively.
Definition internal.h:725
fsl_outputer output
Output channel used by fsl_output() and friends.
Definition internal.h:581
fsl__bccache blobContent
fsl_content_get() cache.
Definition internal.h:816
fsl_error error
Holds error state.
Definition internal.h:602
bool hasTicket
Gets set to true (at some point) if the client has the ticket db table.
Definition internal.h:984
fsl__ptl ptl
Per-transaction-level cache.
Definition internal.h:821
bool markPrivate
Whether or not a running commit process should be marked as private.
Definition internal.h:693
bool used[8]
Flags telling us which of this->buf is currenly in use.
Definition internal.h:637
struct fsl_cx::@060164061232151122333265333312342343114057105074 metrics
struct fsl_cx::@000334361201274132133024055052300077015112305352 scratchpads
Reuseable scratchpads for low-level file canonicalization buffering and whatnot.
fsl_size_t nTotalUsed
Total of the number of "used" bytes of the content cache each time it was relinquished.
Definition internal.h:1027
fsl_buffer format
A scratchpad specific to fsl_cx_format() and friends.
Definition internal.h:652
short searchIndexExists
Records whether this repository has an FTS search index.
Definition internal.h:770
bool ignoreDephantomizations
If true, skip "dephantomization" of phantom blobs.
Definition internal.h:686
struct fsl_cx::@323334113275166327162035266202157107324004347306 ckin
State for incrementally preparing a checkin operation.
fsl_id_t rid
The rid of the current checkout.
Definition internal.h:491
char * projectCode
The "project-code" config option.
Definition internal.h:841
fsl_size_t nBegin
Definition internal.h:539
fsl_id_bag markAvailableCache
An internal cache for fsl__content_mark_availble().
Definition internal.h:828
fsl_db db
Holds the filename of the current checkout db and possibly related state.
Definition internal.h:470
fsl_state clientState
Can be used to tie client-specific data to the context.
Definition internal.h:591
bool xlinkClustersOnly
Flag indicating that only cluster control artifacts should be processed by manifest crosslinking.
Definition internal.h:706
fsl_confirmer confirmer
Confirmation callback.
Definition internal.h:565
void const * allocStamp
Marker which tells us whether fsl_cx_finalize() needs to fsl_free() this instance or not.
Definition internal.h:453
fsl_size_t dirLen
Optimization: fsl_strlen() of dir.
Definition internal.h:486
struct fsl_cx::@060164061232151122333265333312342343114057105074::@061005011364057346137312302005301211130061344163 content
fsl_cx_config cxConfig
A bitwise copy of the config object passed to fsl_cx_init() (or some default).
Definition internal.h:459
fsl_fstat fstat
Internal optimization to avoid duplicate fsl_stat() calls across two functions in some cases.
Definition internal.h:847
char ** tempDirs
Holds a list of temp-dir names.
Definition internal.h:956
char * statusColumn
The name of the ticket-table field which refers to a ticket's status.
Definition internal.h:1014
fsl_xlinker_list xlinkers
List of callbacks for deck crosslinking purposes.
Definition internal.h:674
bool isSyncing
True when a sync is active, to prevent recursive attempts to sync.
Definition internal.h:718
fsl_list crnl
Holds the "crnl-glob" globs.
Definition internal.h:877
short allowSymlinks
Cached copy of the allow-symlinks config option, because it is (hypothetically) needed on many stat()...
Definition internal.h:745
short seenDeltaManifest
Indicates whether or not this repo has ever seen a delta manifest.
Definition internal.h:764
struct fsl_cx::@340103301036114033226306247146313264106064016232 cache
A place for caching generic things.
fsl_id_t rcvId
Record ID of rcvfrom entry during commits.
Definition internal.h:791
fsl__mcache mcache
Parsed-deck cache.
Definition internal.h:852
struct fsl_cx::@372345303007371026067315155322300072123137201133 ticket
Ticket-related information.
struct fsl_cx::@340103301036114033226306247146313264106064016232::@215000367172005003015217375313213241010174201332 globs
Holds various glob lists.
bool inFinalVerify
Is used to tell the content-save internals that a "finalverification" (a.k.a.
Definition internal.h:712
fsl_list customFields
Holds a list of (fsl_card_J*) records representing custom ticket table fields available in the db.
Definition internal.h:978
struct fsl_cx::@020007115146216147330072070376055307053057350026::@050063315273370257341365117161360367105046341152 ckout
Holds info directly related to a checkout database.
fsl_list binary
Holds the "binary-glob" globs.
Definition internal.h:873
fsl_size_t nCappedMaxSize
The number of times the content cache buffer was trimmed below the built-in maximum size.
Definition internal.h:1039
fsl_buffer deltaContent
Reusable buffer for creating and fetching deltas via fsl_content_get() and fsl__content_deltify().
Definition internal.h:811
Db handle wrapper class.
Definition db.h:313
A "deck" stores (predictably enough) a collection of "cards." Cards are constructs embedded within Fo...
Definition repo.h:319
Information about each line of a file being diffed.
Definition util.h:4023
A container for storing generic error state.
Definition util.h:781
A simple wrapper around the stat(2) structure resp.
Definition util.h:3321
A container type for lists of db record IDs.
Definition util.h:5694
Generic list container type.
Definition util.h:156
An interface which encapsulates data for managing an output destination, primarily intended for use w...
Definition util.h:337
The fsl_sc class encapsulates a streamable (as opposed to random-access) I/O channel intended solely ...
Definition sync.h:312
Holds state for SHA1 calculations.
Definition hash.h:251
Generic state-with-finalizer holder.
Definition util.h:238
Represents a prepared statement handle.
Definition db.h:555
Models user permissions precisely as fossil(1) does.
Definition repo.h:4367
const fsl_xfcard_hash_t hash
A hash unique (in the context of fsl_xfcard) to this->name.
Definition internal.h:3044
char const *const name
The protocol-level name of this card, e.g.
Definition internal.h:3042
const fsl_xfcard_e type
Card type ID.
Definition internal.h:3040
Various configuration pieces for libfossil sync transfer subsystem.
Definition sync.h:1554
Metrics for use with the library's "xfer" (sync) subsystem.
Definition sync.h:1340
A list of fsl_xlinker instances.
Definition repo.h:1755
sync.h declares APIs dealing with fossil repository synchronization.
fsl_xfcard_e
Definition sync.h:1317
char * fsl_uuid_str
fsl_uuid_str and fsl_uuid_cstr are "for documentation andreadability purposes" typedefs used to denot...
Definition util.h:72
int(* fsl_input_f)(void *state, void *dest, fsl_size_t *n)
Generic interface for streaming in data.
Definition util.h:318
char const * fsl_uuid_cstr
The const counterpart of fsl_uuid_str.
Definition util.h:80