libfossil
fossil-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(NET_FOSSIL_SCM_FSL_INTERNAL_H_INCLUDED)
4 #define NET_FOSSIL_SCM_FSL_INTERNAL_H_INCLUDED
5 /*
6  Copyright (c) 2013 D. Richard Hipp
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the Simplified BSD License (also
10  known as the "2-Clause License" or "FreeBSD License".)
11 
12  This program is distributed in the hope that it will be l,
13  but without any warranty; without even the implied warranty of
14  merchantability or fitness for a particular purpose.
15 
16  Author contact information:
17  drh@hwaci.com
18  http://www.hwaci.com/drh/
19 
20  *****************************************************************************
21  This file declares library-level internal APIs which are shared
22  across the library.
23 */
24 
25 #include "fossil-scm/fossil-content.h" /* a fossil-xxx header MUST come first b/c of config macros */
26 #include "fossil-scm/fossil-hash.h"
28 
29 #if defined(__cplusplus)
30 extern "C" {
31 #endif
32 
33 typedef struct fsl_acache fsl_acache;
35 typedef struct fsl_pq fsl_pq;
36 typedef struct fsl_pq_e fsl_pq_e;
37 
38 /** @internal
39 
40  Queue entry type for the fsl_pq class.
41 */
42 struct fsl_pq_e {
43  /** RID of the entry. */
45  /** Raw data associated with this entry. */
46  void * p;
47  /** Priority of this element. */
49 };
50 /** @internal
51  Empty-initialized fsl_pq_e structure.
52 */
53 #define fsl_pq_e_empty_m {0,NULL,0.0}
54 
55 /** @internal
56 
57  A simple priority queue class. Instances _must_ be initialized
58  by copying fsl_pq_empty or fsl_pq_empty_m (depending on where
59  the instance lives).
60 */
61 struct fsl_pq {
62  /** Number of items allocated in this->list. */
64  /** Number of items used in this->list. */
66  /** The queue. It is kept sorted by entry->value. */
68 };
69 
70 /** @internal
71  Empty-initialized fsl_pq struct, intended for const-copy initialization.
72 */
73 #define fsl_pq_empty_m {0,0,NULL}
74 
75 /** @internal
76  Empty-initialized fsl_pq struct, intended for copy initialization.
77 */
78 extern const fsl_pq fsl_pq_empty;
79 
80 /** @internal
81 
82  Clears the contents of p, freeing any memory it owns, but not
83  freeing p. Results are undefined if !p.
84 */
85 void fsl_pq_clear(fsl_pq * p);
86 
87 /** @internal
88  Insert element e into the queue. Returns 0 on success,
89  FSL_RC_OOM on error. Results are undefined if !p or e
90  is invalid. pData may be NULL.
91 */
92 int fsl_pq_insert(fsl_pq *p, fsl_id_t e,
93  fsl_double_t v, void *pData);
94 
95 /** @internal
96 
97  Extracts (removes) the first element from the queue (the element
98  with the smallest value) and return its ID. Return 0 if the
99  queue is empty. If pp is not NULL then *pp is (on success)
100  assigned to the 'p' member of the extracted element.
101 */
102 fsl_id_t fsl_pq_extract(fsl_pq *p, void **pp);
103 
104 /** @internal
105 
106  Holds one "line" of a fsl_acache cache.
107 */
109  /**
110  RID of the cached record.
111  */
113  /**
114  Age. Newer is larger.
115  */
117  /**
118  Content of the artifact.
119  */
121 };
122 /** @internal
123 
124  Empty-initialized fsl_acache_line structure.
125 */
126 #define fsl_acache_line_empty_m { 0,0,fsl_buffer_empty_m }
127 
128 
129 /** @internal
130 
131  A cache for tracking the existence of artifacts while the
132  internal goings-on of control artifacts are going on.
133 
134  Currently the artifact cache is unused because it costs much
135  more than it gives us. Once the library supports certain
136  operations (like rebuild and sync) caching will become more
137  useful.
138 
139  Historically fossil caches artifacts as their blob content, but
140  libfossil will likely (at some point) to instead cache fsl_deck
141  instances, which contain all of the same data in pre-parsed form.
142  It cost more memory, though.
143 */
144 struct fsl_acache {
145  /**
146  Total amount of memory used by cached content.
147  */
149  /**
150  Number of entries "used" in this->list.
151  */
153  /**
154  Number of slots in this->list.
155  */
157  /**
158  Next cache counter age. Higher is newer.
159  */
161  /**
162  List of cached content, ordered by age.
163  */
165  /**
166  All artifacts currently in the cache.
167  */
169  /**
170  Cache of known-missing content.
171  */
173  /**
174  Cache of of known-existing content.
175  */
177 };
178 /** @internal
179 
180  Empty-initialized fsl_acache structure, intended
181  for const-copy initialization.
182 */
183 #define fsl_acache_empty_m { \
184  0/*szTotal*/,0/*used*/,0/*capacity*/, \
185  0/*nextAge*/,NULL/*list*/, \
186  fsl_id_bag_empty_m/*inCache*/, \
187  fsl_id_bag_empty_m/*missing*/, \
188  fsl_id_bag_empty_m/*available*/ \
189  }
190 /** @internal
191 
192  Empty-initialized fsl_acache structure, intended
193  for copy initialization.
194 */
195 extern const fsl_acache fsl_acache_empty;
196 
197 
198 /** @internal
199 
200  A type for holding a callback/state pair for manifest
201  crosslinking callbacks.
202 */
203 struct fsl_xlinker {
204  char const * name;
205  /** Callback function. */
207  /** State for this->f's last argument. */
208  void * state;
209 };
210 typedef struct fsl_xlinker fsl_xlinker;
211 
212 /** Empty-initialized fsl_xlinker struct, intended for const-copy
213  intialization. */
214 #define fsl_xlinker_empty_m {NULL,NULL,NULL}
215 
216 /** Empty-initialized fsl_xlinker struct, intended for copy intialization. */
217 extern const fsl_xlinker fsl_xlinker_empty;
218 
219 /** @internal
220 
221  An array of fsl_xlinker instances.
222 */
224  /** Number of used items in this->list. */
226  /** Number of slots allocated in this->list. */
228  /** Array of this->used elements. */
230 };
232 
233 /** Empty-initializes fsl_xlinker_list struct, intended for
234  const-copy intialization. */
235 #define fsl_xlinker_list_empty_m {0,0,NULL}
236 
237 /** Empty-initializes fsl_xlinker_list struct, intended for copy intialization. */
239 
240 /** @internal
241 
242  Searches f's crosslink callbacks for an entry with the given
243  name and returns that entry, or NULL if no match is found. The
244  returned object is owned by f.
245 */
246 fsl_xlinker * fsl_xlinker_by_name( fsl_cx * f, char const * name );
247 
248 /* The fsl_cx class is documented in main public header. */
249 struct fsl_cx {
250  /**
251  A pointer to the "main" db handle. Exactly which db IS the
252  main db is, because we have three DBs, not generally knowble.
253 
254  As of this writing (20141027) the following applies:
255 
256  dbMain always points to &this->dbMem (a ":memory:" db opened by
257  fsl_cx_init()), and the repo/ckout/config DBs get ATTACHed to
258  that one. Their separate handles (this->{repo,ckout,config}.db)
259  are used to store the name and file path to each one (even though
260  they have no real db handle associated with them).
261 
262  Internal code should rely as little as possible on the actual
263  arrangement of internal DB handles, and should use
264  fsl_cx_db_repo(), fsl_cx_db_checkout(), and fsl_cx_db_config() to
265  get a handle to the specific db they want. Currently they will
266  always return NULL or the same handle, but that design decision
267  might change at some point, so the public API treats them as
268  separate entities.
269  */
271 
272  /**
273  Marker which tells us whether fsl_cx_finalize() needs
274  to fsl_free() this instance or not.
275  */
276  void const * allocStamp;
277 
278  /**
279  A ":memory:" (or "") db to work around
280  open-vs-attach-vs-main-vs-real-name problems wrt to the
281  repo/ckout/config dbs. This db handle gets opened automatically
282  at startup and all others which a fsl_cx manages get ATTACHed to
283  it.
284  */
286 
287  /**
288  Holds info directly related to a checkout database.
289  */
290  struct {
291  /**
292  Handle to the currently opened checkout database IF the checkout
293  is the main db.
294  */
296  /**
297  Possibly not needed, but useful for doing absolute-to-relative
298  path conversions for checking file lists.
299 
300  The directory part of an opened checkout db. This is
301  currently only set by fsl_checkout_open_dir(). It contains a
302  trailing slash, largely because that simplifies porting
303  fossil(1) code.
304  */
305  char * dir;
306  /**
307  Optimization: fsl_strlen() of dir. Guaranteed to be set to
308  dir's length if dir is not NULL.
309  */
311  /**
312  The rid of the current checkout. May be 0 for an empty
313  repo/checkout. Must be negative if not yet known.
314  */
316 
317  /**
318  The UUID of the current checkout. Only set if this->rid
319  is positive.
320  */
322  } ckout;
323 
324  /**
325  Holds info directly related to a repo database.
326  */
327  struct {
328  /**
329  Handle to the currently opened repository database IF repo
330  is the main db.
331  */
332  fsl_db db;
333  /**
334  The default user name, for operations which need one.
335  See fsl_cx_user_set().
336  */
337  char * user;
338  } repo;
339 
340  /**
341  Holds info directly related to a global config database.
342  */
343  struct {
344  /**
345  Handle to the currently opened global config database IF config
346  is the main db.
347  */
348  fsl_db db;
349  } config;
350 
351 
352  /**
353  State for incrementally proparing a checkin operation.
354  */
355  struct {
356  /**
357  Tells us if vfile_selected has been created or not.
358  */
360 
361  /**
362  Holds a list of "selected files" in the form
363  of vfile.id values.
364  */
366 
367  /**
368  The deck used for incrementally building certain parts of a
369  checkin.
370  */
372  } ckin;
373 
374  /**
375  Output channel used by fsl_output() and friends.
376  */
378 
379  /**
380  Can be used to tie client-specific data to the context. Its
381  finalizer is called when fsl_cx_finalize() cleans up.
382  */
384 
385  /**
386  Holds error state. As a general rule, this information is
387  updated only by routines which need to return more info than a
388  simple integer error code. This is primarily db-related
389  routines, where we add the db-driver-provided error state
390  here. It is not used by "simple" routines for which an integer
391  code always suffices. APIs which set this should denote it
392  with a comment like "updates the context's error state on
393  error."
394  */
396  /**
397  Optimization: reusable scratchpad for
398  creating/encoding/decoding strings.
399  */
401 
402  /**
403  A scratchpad specifically for dealing with filename-related,
404  non-recursive caching.
405  */
407 
408  /**
409  A place for holding file content. We use this in places where
410  we have to loop over files and read their entire contents. The
411  loop and the reading might be happening in different functions,
412  though.
413  */
415 
416  /**
417  A copy of the config object passed to fsl_cx_init() (or some
418  default).
419  */
421 
422  /**
423  Flags, some (or one) of which is runtime-configurable by the
424  client (see fsl_cx_flag_t). We can get rid of this and add the
425  flags to the cache member along with the rest of them.
426  */
427  int flags;
428 
429  /**
430  List of callbacks for deck crosslinking purposes.
431  */
433 
434  /**
435  A place for caching generic things.
436  */
437  struct {
438  /**
439  Cached copy of the allow-symlinks config option, because it
440  is needed on each stat() call. Negative value=="not yet
441  determined", 0==no, positive==yes. The negative value means
442  we need to check the repo config resp. the global config to
443  see if this is on. We can probably default this to true,
444  though i don't think(?) fossil(1) does so(?).
445  */
447 
448  /**
449  If true, SOME repository-level file-name
450  comparisons/searches will work case-insensitively.
451  */
453 
454  /**
455  Porting artifact. Not yet used.
456  */
458 
459  /**
460  Record ID of rcvfrom entry during commits.
461  */
463 
464  /**
465  Bool flag: whether or not a running commit process should be
466  marked as private.
467  */
469 
470  /**
471  Analog to v1's content.c:ignoreDephantomizations flag.
472  */
474 
475  /**
476  True if fsl_mf_crosslink_begin() has been called but
477  fsl_mf_crosslink_end() is still pending.
478  */
480 
481  /**
482  Flag indicating that only cluster control artifacts
483  should be processed by manifest crosslinking.
484  */
486 
487  /**
488  Used to tell the content-save internals that a "final
489  verification" (a.k.a. verify-before-commit) is underway.
490  */
492 
493  /**
494  Indicates whether or not this repo has ever seen a manifest.
495  negative==undetermined, 0==no, positive==yes.
496  */
498 
499  /**
500  TODO: a cache of most recently loaded/freed manifests,
501  analog to v1's manifest.c:manifestCache array. Won't need
502  this until we get to a point where we can rebuild or similar
503  intensive operations.
504  */
505  struct {
506  /**
507  Head of the cache list. All insertions/removals happen at
508  the head.
509  */
511  /**
512  TODO: maximum number of entries in the mf linked list.
513  */
515  /**
516  Current number of entries in the mf linked list.
517  */
519  } mf;
520 
521  /**
522  Artifact cache used during processing of manifests.
523  */
525  /**
526  Used during manifest parsing.
527  */
529  /**
530  Used during the processing of manifests to keep track of
531  "leaf checks" which need to be done downstream.
532  */
534 
535  /**
536  Holds the RID of every record awaiting verification
537  during the verify-at-commit checks.
538  */
540 
541  /**
542  Infrastructure for fsl_mtime_of_manifest_file(). It
543  remembers the previous RID so that it knows when it has to
544  invalidate/rebuild its ancestry cache.
545  */
547 
548  /**
549  The "project-code" config option.
550  */
551  char * projectCode;
552 
553  /**
554  Holds various glob lists.
555  */
556  struct {
557  /**
558  Holds the "ignore-glob" globs.
559  */
561  /**
562  Holds the "binary-glob" globs.
563  */
565  /**
566  Holds the "crnl-glob" globs.
567  */
569  } globs;
570  } cache;
571 
572  /**
573  Ticket-related information.
574  */
575  struct {
576  /**
577  Holds a list of (fsl_card_J*) records representing custom
578  ticket table fields available in the db.
579 
580  Each entry's flags member denote (using fsl_card_J_flags)
581  whether that field is used by the ticket or ticketchng
582  tables.
583 
584  TODO, eventually: add a separate type for these entries. We
585  use fsl_card_J because the infrastructure is there and they
586  provide what we need, but fsl_card_J::flags only exists for
587  this list. A custom type would be smaller than fsl_card_J
588  (only two members) but adding it requires adding some
589  infrastructure which isn't worth the effort at the moment.
590  */
592 
593  /**
594  Gets set to true (at some point) if the client has the
595  ticket db table.
596  */
598  /**
599  Gets set to true (at some point) if the client has the
600  ticket.tkt_ctime db field.
601  */
602  int hasCTime;
603 
604  /**
605  Gets set to true (at some point) if the client has the
606  ticketchnk db table.
607  */
608  int hasChng;
609  /**
610  Gets set to true (at some point) if the client has the
611  ticketchng.rid db field.
612  */
614  } ticket;
615 
616  /*
617  Note: no state related to server/user/etc. That is higher-level
618  stuff. We might need to allow the user to set a default user
619  name to avoid that he has to explicitly set it on all of the
620  various Control Artifact-generation bits which need it.
621  */
622 };
623 
624 /** @internal
625 
626  Initialized-with-defaults fsl_cx struct.
627 */
628 #define fsl_cx_empty_m { \
629  NULL /*dbMain*/, \
630  NULL/*allocStamp*/, \
631  fsl_db_empty_m /* dbMem */, \
632  {/*ckout*/ \
633  fsl_db_empty_m /*db*/, \
634  NULL /*dir*/, 0/*dirLen*/, \
635  -1/*rid*/, NULL/*uuid*/ \
636  }, \
637  {/*repo*/ fsl_db_empty_m /*db*/, \
638  0/*user*/ \
639  }, \
640  {/*config*/ fsl_db_empty_m /*db*/ }, \
641  {/*ckin*/ \
642  0/*hasSetupVfile*/, \
643  fsl_id_bag_empty_m/*selectedIds*/, \
644  fsl_deck_empty_m/*mf*/ \
645  }, \
646  fsl_outputer_FILE_m /*output*/, \
647  fsl_state_empty_m /*clientState*/, \
648  fsl_error_empty_m /*error*/, \
649  fsl_buffer_empty_m /*scratch*/, \
650  fsl_buffer_empty_m /*fsScratch*/, \
651  fsl_buffer_empty_m /*fileContent*/, \
652  fsl_cx_config_empty_m /*cxConfig*/, \
653  FSL_CX_F_DEFAULTS/*flags*/, \
654  fsl_xlinker_list_empty_m/*xlinkers*/, \
655  {/*cache*/ \
656  -1/*allowSymlinks*/, \
657  0/*caseInsensitive*/, \
658  0/*ignoreDephantomizations*/, \
659  0/*rcvId*/, \
660  0/*markPrivate*/, \
661  0/*deferCrosslink*/, \
662  0/*isCrosslinking*/, \
663  0/*xlinkClustersOnly*/, \
664  0/*inFinalVerify*/, \
665  -1/*seenManifest*/, \
666  {/*mf*/ NULL/*head*/,5/*max*/,0/*size*/}, \
667  fsl_acache_empty_m/*arty*/, \
668  fsl_id_bag_empty_m/*mfSeen*/, \
669  fsl_id_bag_empty_m/*leafCheck*/, \
670  fsl_id_bag_empty_m/*toVerify*/, \
671  0/*mtimeManifest*/, \
672  NULL/*projectCode*/, \
673  {/*globs*/ \
674  fsl_list_empty_m/*ignore*/, \
675  fsl_list_empty_m/*binary*/, \
676  fsl_list_empty_m/*crnl*/ \
677  } \
678  }, \
679  {/*ticket*/ \
680  fsl_list_empty_m/*customFields*/, \
681  0/*hasTicket*/, \
682  0/*hasCTime*/, \
683  0/*hasChng*/, \
684  0/*hasCngRid*/ \
685  } \
686  }
687 
688 /** @internal
689  Initialized-with-defaults fsl_cx instance.
690 */
691 extern const fsl_cx fsl_cx_empty;
692 /*
693  TODO:
694 
695  int fsl_buffer_append_getenv( fsl_buffer * b, char const * env )
696 
697  Fetches the given env var and appends it to b. Returns FSL_RC_NOT_FOUND
698  if the env var is not set. The primary use for this would be to simplify
699  the Windows implementation of fsl_find_home_dir().
700 */
701 
702 
703 /** @internal
704 
705  Searches for a repo.tag entry given name in the given context's
706  repository db. If found, it returns the record's id. If no
707  record is found and create is true (non-0) then a tag is created
708  and its entry id is returned. Returns 0 if it finds no entry, a
709  negative value on error. On db-level error, f's error state is
710  updated.
711 */
712 FSL_EXPORT fsl_id_t fsl_tag_id( fsl_cx * f, char const * tag, char create );
713 
714 /** @internal
715 
716  Expires the single oldest entry in c. Returns true (non-0) if it
717  removes an item, else 0.
718 */
720 
721 /** @internal
722 
723  Add an entry to the content cache.
724 
725  This routines transfers the contents of pBlob over to c,
726  regardless of success or failure. The cache will deallocate
727  memory when it has finished with it.
728 
729  Returns 0 on success, FSL_RC_OOM on allocation error. Has undefined
730  behaviour if !c, rid is not semantically valid, !pBlob (or pBlob
731  has no content???).
732 */
733 int fsl_acache_insert(fsl_acache * c, fsl_id_t rid, fsl_buffer *pBlob);
734 
735 /** @internal
736 
737  Frees all memory held by c, and clears out c's state, but does
738  not free c. Results are undefined if !c.
739 */
740 void fsl_acache_clear(fsl_acache * c);
741 
742 /** @internal
743 
744  Checks f->cache.arty to see if rid is available in the
745  repository opened by f.
746 
747  Returns 0 if the content for the given rid is available in the
748  repo or the cache. Returns FSL_RC_NOT_FOUND if it is not in the
749  repo nor the cache. Returns some other non-0 code for "real
750  errors," e.g. FSL_RC_OOM if a cache allocation fails. This
751  operation may update the cache's contents.
752 
753  If this function detects a loop in artifact lineage, it fails an
754  assert() in debug builds and returns FSL_RC_CONSISTENCY in
755  non-debug builds. That doesn't happen in real life, though.
756 */
758 
759 /** @internal
760 
761  This is THE ONLY routine which adds content to the blob table.
762 
763  This writes the given buffer content into the repository
764  database's blob tabe. It Returns the record ID via outRid (if it
765  is not NULL). If the content is already in the database (as
766  determined by a lookup of its SHA1 hash against blob.uuid), this
767  routine fetches the RID (via *outRid) but has no side effects in
768  the repo.
769 
770  If srcId is >0 then pBlob must contain delta content from
771  the srcId record. srcId might be a phantom.
772 
773  pBlob is normally uncompressed text, but if uncompSize>0 then
774  the pBlob value is assumed to be compressed (via fsl_buffer_compress()
775  or equivalent) and uncompSize is
776  its uncompressed size. If uncompSize>0 then zUuid must be valid
777  and refer to the hash of the _uncompressed_ data (which is why
778  this routine does not calculate it for the client).
779 
780  Sidebar: we "could" use fsl_buffer_is_compressed() and friends
781  to determine if pBlob is compressed and get its decompressed
782  size, then remove the uncompSize parameter, but that would
783  require that this function decompress the content to calculate
784  the hash. Since the caller likely just compressed it, that seems
785  like a huge waste.
786 
787  zUuid is the UUID of the artifact, if it is not NULL. When
788  srcId is specified then zUuid must always be specified. If
789  srcId is zero, and zUuid is zero then the correct zUuid is
790  computed from pBlob. If zUuid is not NULL then this function
791  asserts (in debug builds) that fsl_is_uuid() returns true for
792  zUuid.
793 
794  If isPrivate is true, the blob is created as a private record.
795 
796  If the record already exists but is a phantom, the pBlob content
797  is inserted and the phatom becomes a real record.
798 
799  The original content of pBlob is not disturbed. The caller continues
800  to be responsible for pBlob. This routine does *not* take over
801  responsibility for freeing pBlob.
802 
803  If outRid is not NULL then on success *outRid is assigned to the
804  RID of the underlying blob record.
805 
806  Returns 0 on success and there are too many potential error cases
807  to name - this function is a massive beast.
808 
809  Potential TODO: we don't really need the uncompSize param - we
810  can deduce it, if needed, based on pBlob's content. We cannot,
811  however, know the UUID of the decompressed content unless the
812  client passes it in to us.
813 
814 
815  @see fsl_content_put()
816 */
817 FSL_EXPORT int fsl_content_put_ex( fsl_cx * f, fsl_buffer const * pBlob,
818  fsl_uuid_cstr zUuid, fsl_id_t srcId,
819  fsl_size_t uncompSize, char isPrivate,
820  fsl_id_t * outRid);
821 /** @internal
822 
823  Equivalent to fsl_content_put_ex(f,pBlob,NULL,0,0,0,newRid).
824 
825  This must only be used for saving raw (non-delta) content.
826 
827  @see fsl_content_put_ex()
828 */
829 int fsl_content_put( fsl_cx * f, fsl_buffer const * pBlob,
830  fsl_id_t * newRid);
831 
832 
833 /** @internal
834 
835  If the given blob ID refers to deltified repo content, this routine
836  undeltifies it and replaces its content with its expanded
837  form.
838 
839  Returns 0 on success, FSL_RC_MISUSE if !f, FSL_RC_NOT_A_REPO if
840  f has no opened repository, FSL_RC_RANGE if rid is not positive,
841  and any number of other potential errors during the db and
842  content operations. This function treats already unexpanded
843  content as success.
844 
845  @see fsl_content_deltify()
846 */
848 
849 
850 /** @internal
851 
852  The converse of fsl_content_undeltify(), this replaces the storage
853  of the given blob record so that it is a delta of srcid.
854 
855  If rid is already a delta from some other place then no
856  conversion occurs and this is a no-op unless force is true.
857 
858  It never generates a delta that carries a private artifact into
859  a public artifact. Otherwise, when we go to send the public
860  artifact on a sync operation, the other end of the sync will
861  never be able to receive the source of the delta. It is OK to
862  delta private->private, public->private, and public->public.
863  Just no private->public delta. For such cases this function
864  returns 0, as opposed to FSL_RC_ACCESS or some similar code, and
865  leaves the content untouched.
866 
867  If srcid is a delta that depends on rid, then srcid is
868  converted to undelta'd text.
869 
870  If either rid or srcid contain less than some "small,
871  unspecified number" of bytes (currently 50), or if the resulting
872  delta does not achieve a compression of at least 25%, the rid is
873  left untouched.
874 
875  Returns 0 if a delta is successfully made or none needs to be
876  made, non-0 on error.
877 
878  @see fsl_content_undeltify()
879 */
880 int fsl_content_deltify(fsl_cx * f, fsl_id_t rid,
881  fsl_id_t srcid, char force);
882 
883 
884 /** @internal
885 
886  Creates a new phantom blob with the given UUID and return its
887  artifact ID via *newId. Returns 0 on success, FSL_RC_MISUSE if
888  !f or !uuid, FSL_RC_RANGE if fsl_is_uuid(uuid) returns false,
889  FSL_RC_NOT_A_REPO if f has no repository opened, FSL_RC_ACCESS
890  if the given uuid has been shunned, and about 20 other potential
891  error codes from the underlying db calls. If isPrivate is true
892  _or_ f has been flagged as being in "private mode" then the new
893  content is flagged as private. newId may be NULL, but if it is
894  then the caller will have to find the record id himself by using
895  the UUID (see fsl_uuid_to_rid()).
896 */
897 int fsl_content_new( fsl_cx * f, fsl_uuid_cstr uuid, char isPrivate,
898  fsl_id_t * newId );
899 
900 
901 
902 /** @internal
903 
904  Recompute/rebuild the entire repo.leaf table.
905 
906  This can be expensive (in time) for a really large repository.
907  So it is only done for things like a full rebuild.
908 
909  Returns 0 on success. Error may indicate that f is not a repo.
910  On error f's error state may be updated.
911 */
913 
914 /** @internal
915 
916  Check to see if checkin "rid" is a leaf and either add it to the LEAF
917  table if it is, or remove it if it is not.
918 
919  Returns 0 on success, FSL_RC_MISUSE if !f or f has no repo db
920  opened, FSL_RC_RANGE if pid is <=0. Other errors
921  (e.g. FSL_RC_DB) may indicate that db is not a repo. On error
922  db's error state may be updated.
923 */
924 int fsl_repo_leaf_check(fsl_cx * f, fsl_id_t pid);
925 
926 /** @internal
927 
928  Schedules a leaf check for "rid" and its parents. Returns 0 on
929  success.
930 */
932 
933 /** @internal
934 
935  Perform all pending leaf checks. Returns 0 on success or if it
936  has nothing to do.
937 */
939 
940 /** @internal
941 
942  UNTESTED - the bits which use this are not yet ported.
943 
944  This initializes some temporary db state for the crosslinking
945  of tickets.
946 
947  Returns 0 on success. If it returns 0, the caller must
948  eventually call fsl_mf_crosslink_end(), otherwise he must not
949  call fsl_mf_crosslink_end().
950 
951  This function starts a db transaction if one is not already
952  active. fsl_mf_crosslink_end() will end it.
953 */
955 
956 /** @internal
957 
958  UNTESTED - the bits which use this are not yet ported.
959 
960  Must not be called unless fsl_mf_crosslink_begin() has been
961  called.
962 
963  Returns 0 on success. On error it initiates (or propagates) a
964  rollback for the current transaction.
965 
966 */
968 
969 
970 /** @internal
971 
972  Inserts a tag into f's repo db. It does not create the related
973  control artifact - use fsl_tag_add_artifact() for that.
974 
975  rid is the artifact to which the tag is being applied.
976 
977  srcId is the artifact that contains the tag. It is often, but
978  not always, the same as rid. This is often the RID of the
979  manifest containing tags added as part of the commit, in which
980  case rid==srcId. A Control Artifact which tags a different
981  artifact will have rid!=srcId.
982 
983  mtime is the Julian timestamp for the tag. Defaults to the
984  current time if mtime <= 0.0.
985 
986  If outRid is not NULL then on success *outRid is assigned the
987  record ID of the generated tag (the tag.tagid db field).
988 
989  If a more recent (compared to mtime) entry already exists for
990  this tag/rid combination then its tag.tagid is returned via
991  *outRid (if outRid is not NULL) and no new entry is created.
992 
993  Returns 0 on success, and has a huge number of potential error
994  codes.
995 */
996 int fsl_tag_insert( fsl_cx * f,
997  fsl_tag_type tagtype,
998  char const * zTag,
999  char const * zValue,
1000  fsl_id_t srcId,
1001  fsl_double_t mtime,
1002  fsl_id_t rid,
1003  fsl_id_t *outRid );
1004 /** @internal
1005 
1006  Propagate all propagatable tags in pid to the children of pid.
1007 */
1008 int fsl_tag_propagate_all(fsl_cx * f, fsl_id_t pid);
1009 
1010 /** @internal
1011 
1012  Propagates a tag through the various internal pipelines.
1013 
1014  pid is the artifact id to whose children the tag should be
1015  propagated.
1016 
1017  tagid is the id of the tag to propagate (the tag.tagid db value).
1018 
1019  tagType is the type of tag to propagate. Must be either FSL_TAGTYPE_CANCEL
1020  or FSL_TAGTYPE_PROPAGATING.
1021 
1022  origId is the artifact id of the origin tag if tagType ==
1023  FSL_TAGTYPE_PROPAGATING, otherwise it is ignored.
1024 
1025  zValue is the optional value for the tag. May be NULL.
1026 
1027  mtime is the Julian timestamp for the tag. Must be a valid time
1028  (no defaults here).
1029 
1030  This function is unforgiving of invalid values/ranges, and may assert
1031  in debug mode if passed invalid ids (values<=0), a NULL f, or if f has
1032  no opened repo.
1033 */
1034 int fsl_tag_propagate(fsl_cx *f,
1035  fsl_tag_type tagType,
1036  fsl_id_t pid,
1037  fsl_id_t tagid,
1038  fsl_id_t origId,
1039  const char *zValue,
1040  fsl_double_t mtime );
1041 
1042 /** @internal
1043 
1044  Remove the PGP signature from a raw artifact, if there is one.
1045 
1046  Expects *pz to point to *pn bytes of string memory which might
1047  or might not be prefixed by a PGP signature. If the string is
1048  enveloped in a signature, then upon returning *pz will point to
1049  the first byte after the end of the PGP header and *pn will
1050  contain the length of the content up to, but not including, the
1051  PGP footer.
1052 
1053  If *pz does not look like a PGP header then this is a no-op.
1054 
1055  Neither pointer may be NULL and *pz must point to *pn bytes of
1056  valid memory.
1057 */
1058 void fsl_remove_pgp_signature(unsigned char const **pz, fsl_size_t *pn);
1059 
1060 /** @internal
1061 
1062  Clears the "seen" cache used by manifest parsing. Should be
1063  called by routines which initialize parsing, but not until their
1064  work has finished all parsing (so that recursive parsing can
1065  use it).
1066 */
1067 void fsl_cx_clear_mf_seen(fsl_cx * f);
1068 
1069 /** @internal
1070 
1071  Generates an fsl_appendf()-formatted message to stderr and
1072  fatally aborts the application by calling exit(). This is only
1073  (ONLY!) intended for us as a placeholder for certain test cases
1074  and is neither thread-safe nor reantrant.
1075 
1076  fmt may be empty or NULL, in which case only the code and its
1077  fsl_rc_cstr() representation are output.
1078 
1079  This function does not return.
1080 */
1081 FSL_EXPORT void fsl_fatal( int code, char const * fmt, ... )
1082 #ifdef __GNUC__
1083  __attribute__ ((noreturn))
1084 #endif
1085  ;
1086 
1087 /** @internal
1088 
1089  Translate a normalized, repo-relative filename into a
1090  filename-id (fnid). Create a new fnid if none previously exists
1091  and createNew is true. On success returns 0 and sets *rv to the
1092  filename.fnid record value. If createNew is false and no match
1093  is found, 0 is returned but *rv will be set to 0. Returns non-0
1094  on error. Results are undefined if any parameter is NULL.
1095 
1096 
1097  In debug builds, this function asserts that no pointer arguments
1098  are NULL and that f has an opened repository.
1099 */
1100 FSL_EXPORT int fsl_repo_filename_fnid2( fsl_cx * f, char const * filename, fsl_id_t * rv, char createNew );
1101 
1102 
1103 /** @internal
1104 
1105  Functionally similar to fsl_repo_filename_fnid2(), but fetches
1106  a vfile.id value. vid is the vfile.vid to filter on. If vid is
1107  <=0 then f->ckout.rid is used. It only matches on
1108  vfile.pathname, not vfile.origname, and requires an exact match
1109  because it is expected that the input filename will typically
1110  come from fsl_card_F entries.
1111 
1112  On success returns 0 and sets *rv to the vfile.id or to 0 if no
1113  entry is found. On error, returns non-0 and it should be taken
1114  seriously.
1115 
1116  In debug builds, this function asserts that no pointer arguments
1117  are NULL and that f has an opened checkout.
1118 */
1119 FSL_EXPORT int fsl_checkout_filename_vfile_id( fsl_cx * f, char const * fn, fsl_id_t vid,
1120  fsl_id_t * rv );
1121 
1122 
1123 /** @internal
1124 
1125  Clears all fsl_buffer members of db but leaves the rest
1126  intact. If alsoErrorState is true then the error state is also
1127  cleared, else it is kept as well.
1128 */
1129 void fsl_db_clear_strings(fsl_db * db, char alsoErrorState );
1130 
1131 /** @internal
1132 
1133  Returns 0 if db appears to have a current repository schema, 1
1134  if it appears to have an out of date schema, and -1 if it
1135  appears to not be a repository. Results are undefined if db is
1136  NULL or not opened.
1137 */
1139 
1140 
1141 /** @internal
1142 
1143  Flags for APIs which add phantom blobs to the repository. The
1144  values in this enum derive from fossil(1) code and should not be
1145  changed without careful forethought and (afterwards) testing. A
1146  phantom blob is a blob about whose existence we know but for
1147  which we have no content. This normally happens during sync
1148  or rebuild operations.
1149 */
1151 /**
1152  Indicates to fsl_uuid_to_rid2() that no phantom artifact
1153  should be created.
1154 */
1156 /**
1157  Indicates to fsl_uuid_to_rid2() that a public phantom
1158  artifact should be created if no artifact is found.
1159 */
1161 /**
1162  Indicates to fsl_uuid_to_rid2() that a private phantom
1163  artifact should be created if no artifact is found.
1164 */
1166 };
1168 
1169 /** @internal
1170 
1171  Works like fsl_uuid_to_rid(), with these differences:
1172 
1173  - uuid is expected to be a complete UUID, not a prefix.
1174 
1175  - If it finds no entry and the mode argument specifies so then
1176  it will add either a public or private phantom entry and return
1177  its new rid. If mode is FSL_PHANTOM_NONE then this this behaves
1178  just like fsl_uuid_to_rid().
1179 
1180  Returns a positive value on success, 0 if it finds no entry and
1181  mode==FSL_PHANTOM_NONE, and a negative value on error (e.g. if
1182  fsl_is_uuid(uuid) returns false). Errors which happen after
1183  argument validation will "most likely" update f's error state
1184  with details.
1185 */
1187  fsl_phantom_t mode );
1188 
1189 /** @internal
1190 
1191  Schedules the given rid to be verified at the next commit. This
1192  is used by routines which add artifact records to the blob
1193  table.
1194 
1195  The only error case, assuming the arguments are valid, is an
1196  allocation error while appending rid to the internal to-verify
1197  queue.
1198 
1199  @see fsl_repo_verify_at_commit()
1200  @see fsl_repo_verify_cancel()
1201 */
1203 
1204 /** @internal
1205 
1206  Clears f's verify-at-commit list of RIDs.
1207 
1208  @see fsl_repo_verify_at_commit()
1209  @see fsl_repo_verify_before_commit()
1210 */
1211 void fsl_repo_verify_cancel( fsl_cx * f );
1212 
1213 /** @internal
1214 
1215  Processes all pending verify-at-commit entries and clears the
1216  to-verify list. Returns 0 on success. On error f's error state
1217  will likely be updated.
1218 
1219  ONLY call this from fsl_db_transaction_end() or its delegate (if
1220  refactored).
1221 
1222  Verification calls fsl_content_get() to "unpack" content added
1223  in the current transaction. If fetching the content (which
1224  applies any deltas it may need to) fails or a checksum does not
1225  match then this routine fails and returns non-0. Any error f's
1226  error state will be updated.
1227 
1228  @see fsl_repo_verify_cancel()
1229  @see fsl_repo_verify_before_commit()
1230 */
1232 
1233 /** @internal
1234 
1235  Removes all entries from the repo's blob table which are listed
1236  in the shun table. Returns 0 on success. This operation is
1237  wrapped in a transaction. Delta contant which depend on
1238  to-be-shunned content are replaced with their undeltad forms.
1239 
1240  Returns 0 on success.
1241 */
1243 
1244 /** @internal.
1245 
1246  Return a pointer to a string that contains the RHS of an SQL IN
1247  operator which will select config.name values that are part of
1248  the configuration that matches iMatch (a bitmask of
1249  fsl_configset_t values). Ownership of the returned string is
1250  passed to the caller, who must eventually pass it to
1251  fsl_free(). Returns NULL on allocation error.
1252 */
1253 char *fsl_config_inop_rhs(int iMask);
1254 
1255 /** @internal
1256 
1257  Return a pointer to a string that contains the RHS of an IN
1258  operator that will select config.name values that are in the
1259  list of control settings. Ownership of the returned string is
1260  passed to the caller, who must eventually pass it to
1261  fsl_free(). Returns NULL on allocation error.
1262 */
1263 char *fsl_db_setting_inop_rhs();
1264 
1265 /**
1266  Hard-coded range of values of the vfile.chnged db field.
1267 */
1275 };
1276 
1277 /** @internal
1278 
1279  Populates f's checkout vfile table with all files from the given
1280  Manifest RID. If vfile already contains entries for that
1281  manifest, it assumes they are loaded and does not insert them
1282  (returning 0 unless cleanup (see below) fails). If manifestRid
1283  is 0 or less then the current checkout's RID is used.
1284 
1285  The clearOthers flag is a compatibility flag for fossil(1). The
1286  vfile model allows an arbitrary number of checkin versions to be
1287  installed in it at once, but several of fossil(1)'s commands do
1288  not account for that, and assume only one version is loaded at a
1289  time.
1290 
1291  Returns 0 on success, any number of codes on any number of errors.
1292 
1293  f must not be NULL and must have opened checkout and repository
1294  databases. In debug builds it will assert that that is so.
1295 
1296 */
1297 int fsl_vfile_load_from_rid(fsl_cx * f, fsl_id_t manifestRid, char clearOthers);
1298 
1299 /**
1300  @internal
1301 
1302  A bitmask of flags for fsl_vfile_changes_scan().
1303 */
1305 /**
1306  The empty flags set.
1307 */
1309 
1310 /**
1311  Non-file FS objects throw an error. Not yet implemented.
1312 */
1314 /**
1315  Verify file content using sha1sum, regardless of whether or not
1316  file timestamps differ.
1317 */
1319 /**
1320  For unchanged or changed-by-merge files, set the mtime to last
1321  check-out time, as determined by fsl_mtime_of_manifest_file().
1322 */
1324 /**
1325  Indicates that when populating the vfile table, it should be
1326  cleared of entries for other checkins. This is primarily for
1327  compatibility with fossil(1), which generally assumes only a
1328  single checkin's worth of state is in vfile and can get confused
1329  if that is not the case.
1330 */
1332 };
1333 
1334 
1335 /** @internal
1336 
1337  This function populates (if needed) the vfile table of f's
1338  checkout db for the given checkin version ID then compares files
1339  listed in it against files in the checkout directory, updating
1340  vfile's status for the current checkout version id as its goes.
1341  If vid is negative then the current checkout's RID is used in
1342  its place (note that 0 is the RID of an initial empty
1343  repository!). cksigFlags must be a bitmask of fsl_ckout_sig_t
1344  values.
1345 
1346  Returns 0 on success, non-0 on error.
1347 
1348  BUG: this does not properly catch one particular corner-case
1349  change, where a file has been replaced by a same-named non-file.
1350 */
1351 FSL_EXPORT int fsl_vfile_changes_scan(fsl_cx * f, fsl_id_t vid, int cksigFlags);
1352 
1353 /** @internal
1354 
1355  Creates the ticket and ticketchng tables in f's repository db,
1356  DROPPING them if they already exist. The schema comes from
1357  fsl_cx_schema_ticket().
1358 
1359  Returns 0 on success.
1360 */
1362 
1363 /** @internal
1364 
1365  li is assumed to be empty or contain (fsl_card_J*)
1366  instances. If alsoListMem is true then any memory owned
1367  by li is also freed. li itself is not freed.
1368 
1369  Results are undefined if li is NULL.
1370 */
1371 void fsl_card_J_list_free( fsl_list * li, char alsoListMem );
1372 
1373 /** @internal
1374 
1375  Values for fsl_card_J::flags.
1376 */
1378 /**
1379  Sentinel value.
1380 */
1382 /**
1383  Indicates that the field is used by the ticket table.
1384 */
1386 /**
1387  Indicates that the field is used by the ticketchng table.
1388 */
1390 /**
1391  Indicates that the field is used by both the ticket and
1392  ticketchng tables.
1393 */
1395 };
1396 
1397 /** @internal
1398 
1399  Loads all custom/customizable ticket fields from f's repo's
1400  ticket table info f. If f has already loaded the list and
1401  forceReload is false, this is a no-op.
1402 
1403  Returns 0 on success.
1404 
1405  @see fsl_cx::ticket::customFields
1406 */
1407 FSL_EXPORT int fsl_cx_ticket_load_fields(fsl_cx * f, char forceReload);
1408 
1409 /** @internal
1410 
1411  A comparison routine for qsort(3) which compares fsl_card_J
1412  instances in a lexical manner based on their names. The order is
1413  important for card ordering in generated manifests.
1414 
1415  This routine expects to get passed (fsl_card_J**) (namely from
1416  fsl_list entries), and will not work on an array of J-cards.
1417 */
1418 int fsl_qsort_cmp_J_cards( void const * lhs, void const * rhs );
1419 
1420 /** @internal
1421 
1422  The internal version of fsl_deck_parse(). See that function
1423  for details regarding everything but the 3rd argument.
1424 
1425  If you happen to know the _correct_ RID for the deck being
1426  parsed, pass it as the rid argument, else pass 0. A negative
1427  value will result in a FSL_RC_RANGE error. This value is (or
1428  will be) only used as an optimization in other places and only
1429  if d->f is not NULL. Passing a positive value has no effect on
1430  how the content is parsed or on the result - it only affects
1431  internal details/optimizations.
1432 
1433 */
1434 int fsl_deck_parse2(fsl_deck * d, fsl_buffer * src, fsl_id_t rid);
1435 
1436 /** @internal
1437 
1438  This function updates the repo and/or global config databases
1439  with links between the dbs intended for various fossil-level
1440  bookkeeping and housecleaning. These links are not essential to
1441  fossil's functionality but assist in certain "global"
1442  operations.
1443 
1444  If no checkout is opened but a repo is, the global config (if
1445  opened) is updated to know about the opened repo db.
1446 
1447  If a checkout is opened, global config (if opened) and the
1448  repo are updated to point to the checked-out db.
1449 */
1451 
1452 /** @internal
1453 
1454  Updates f->ckout.uuid and f->ckout.rid to reflect the current
1455  checkout state. If no checkout is opened, the uuid is
1456  freed/NULLed and the rid is set to 0. Returns 0 on success. If
1457  it returns an error, the f->ckout state is left in a potentially
1458  inconsistent state, and it should not be relied upon
1459  until/unless the error is resolved.
1460 */
1462 
1463 /** @internal
1464 
1465  On Windows platforms (only), if fsl_isalpha(*zFile)
1466  and ':' == zFile[1] then this returns zFile+2,
1467  otherwise it returns zFile.
1468 */
1469 char * fsl_file_without_drive_letter(char * zFile);
1470 
1471 /** @internal
1472 
1473  This is identical to the public-API member fsl_deck_F_search(),
1474  except that it returns a non-const F-card.
1475 
1476  Locate a file named zName in d->F.list. Return a pointer to the
1477  appropriate fsl_mf_card object. Return NULL if not found.
1478 
1479  If d->f is set (as it is when loading decks via
1480  fsl_deck_load_rid() and friends), this routine works even if p is
1481  a delta-manifest. The pointer returned might be to the baseline
1482  and d->B.baseline is loaded on demand if needed.
1483 
1484  If the returned card's uuid member is NULL, it means that the file
1485  was removed in the checkin represented by d.
1486 
1487  If !d, zName is NULL or empty, or FSL_CATYPE_CHECKIN!=d->type, it
1488  asserts in debug builds and returns NULL in non-debug builds.
1489 
1490  We assume that filenames are in sorted order and use a binary
1491  search. As an optimization, to support the most common use case,
1492  searches through a deck update d->F.cursor to the last position a
1493  search was found. Because searches are normally done in lexical
1494  order (because of architectural reasons), this is normally an O(1)
1495  operation. It degrades to O(N) if out-of-lexical-order searches
1496  are performed.
1497 */
1498 fsl_card_F * fsl_deck_F_seek(fsl_deck * const d, const char *zName);
1499 
1500 /** @internal
1501 
1502  Part of the fsl_cx::fileContent optimization. This sets
1503  f->fileContent.used to 0 and if its capacity is over a certain
1504  (unspecified, unconfigurable) size then it is trimmed to that
1505  size.
1506 */
1508 
1509 /** @internal
1510 
1511  Expects f to have an opened checkout and zName to be the name of
1512  an entry in the vfile table. This function does not do any path
1513  resolution on zName. On success it returns 0 and assigned *vfid
1514  to the vfile.id value of the matching file. If no match is
1515  found, 0 is returned and *vfile is set to 0.
1516 
1517  This search honors the context-level case-insensitivity setting
1518  (see fsl_cx_case_sensitive_set()).
1519 */
1520 int fsl_filename_to_vfile_id( fsl_cx * f, char const * zName,
1521  fsl_id_t * vfid );
1522 
1523 /** @internal
1524 
1525  Searches the vfile table where vfile.vid=vid for a name which
1526  matches zName or a subdirectory named zName. For each entry it
1527  finds, it adds the vfile.id to dest. If zName is NULL or empty
1528  then all files in vfile with the given vid are selected.
1529 
1530  This search honors the context-level case-insensitivity setting
1531  (see fsl_cx_case_sensitive_set()).
1532 
1533  Returns 0 on success. Not finding anything is not treated as an
1534  error, though we could arguably return FSL_RC_NOT_FOUND for the
1535  cases which use this function.
1536 */
1538  fsl_id_bag * dest, char const * zName);
1539 
1540 #if defined(__cplusplus)
1541 } /*extern "C"*/
1542 #endif
1543 #endif
1544 /* NET_FOSSIL_SCM_FSL_INTERNAL_H_INCLUDED */
fsl_id_t id
RID of the entry.
fsl_uint_t fsl_size_t
fsl_size_t is an unsigned integer type used to denote absolute ranges and lengths.
void * state
State for this->f's last argument.
const fsl_acache fsl_acache_empty
fsl_phantom_t
int fsl_repo_verify_before_commit(fsl_cx *f, fsl_id_t rid)
Generic state-with-finalizer holder.
Definition: fossil-util.h:232
const fsl_cx fsl_cx_empty
fsl_outputer output
Output channel used by fsl_output() and friends.
char * fsl_file_without_drive_letter(char *zFile)
The main Fossil "context" type.
A part of the configuration used by fsl_cx_init() and friends.
Definition: fossil-core.h:506
char ignoreDephantomizations
Porting artifact.
int fsl_repo_record_filename(fsl_cx *f)
FSL_EXPORT int fsl_cx_ticket_load_fields(fsl_cx *f, char forceReload)
int seenManifest
Indicates whether or not this repo has ever seen a manifest.
fsl_uint32_t limit
TODO: maximum number of entries in the mf linked list.
Sentinel value.
int fsl_repo_leaf_do_pending_checks(fsl_cx *f)
fsl_buffer scratch
Optimization: reusable scratchpad for creating/encoding/decoding strings.
int fsl_cx_ticket_create_table(fsl_cx *f)
Indicates to fsl_uuid_to_rid2() that no phantom artifact should be created.
void fsl_pq_clear(fsl_pq *p)
fsl_id_bag toVerify
Holds the RID of every record awaiting verification during the verify-at-commit checks.
int fsl_vfile_load_from_rid(fsl_cx *f, fsl_id_t manifestRid, char clearOthers)
Indicates that when populating the vfile table, it should be cleared of entries for other checkins...
struct fsl_cx::@10::@13 globs
Holds various glob lists.
The empty flags set.
fsl_card_F * fsl_deck_F_seek(fsl_deck *const d, const char *zName)
An interface which encapsulates data for managing an output destination, primarily intended for use w...
Definition: fossil-util.h:325
struct fsl_cx::@10 cache
A place for caching generic things.
FSL_EXPORT int fsl_repo_leaves_rebuild(fsl_cx *f)
A container for storing generic error state.
Definition: fossil-util.h:692
fsl_pq_e * list
The queue.
int hasTicket
Gets set to true (at some point) if the client has the ticket db table.
fsl_vfile_change_t
Hard-coded range of values of the vfile.chnged db field.
fsl_size_t used
Number of entries "used" in this->list.
int hasChng
Gets set to true (at some point) if the client has the ticketchnk db table.
fsl_id_bag available
Cache of of known-existing content.
Verify file content using sha1sum, regardless of whether or not file timestamps differ.
char markPrivate
Bool flag: whether or not a running commit process should be marked as private.
fsl_deck * head
Head of the cache list.
Db handle wrapper class.
Definition: fossil-db.h:105
#define FSL_EXPORT
Definition: fossil-config.h:19
struct fsl_cx::@7 repo
Holds info directly related to a repo database.
fsl_xlinker * fsl_xlinker_by_name(fsl_cx *f, char const *name)
char const * fsl_uuid_cstr
The const counterpart of fsl_uuid_str.
Definition: fossil-util.h:92
FSL_EXPORT int fsl_checkout_filename_vfile_id(fsl_cx *f, char const *fn, fsl_id_t vid, fsl_id_t *rv)
void fsl_card_J_list_free(fsl_list *li, char alsoListMem)
char * fsl_config_inop_rhs(int iMask)
int fsl_acache_insert(fsl_acache *c, fsl_id_t rid, fsl_buffer *pBlob)
fsl_deck_xlink_f f
Callback function.
fsl_buffer content
Content of the artifact.
Generic list container type.
Definition: fossil-util.h:150
fsl_id_t rid
The rid of the current checkout.
fsl_error error
Holds error state.
fsl_acache arty
Artifact cache used during processing of manifests.
fsl_id_t fsl_pq_extract(fsl_pq *p, void **pp)
Indicates to fsl_uuid_to_rid2() that a private phantom artifact should be created if no artifact is f...
fsl_size_t capacity
Number of slots in this->list.
char xlinkClustersOnly
Flag indicating that only cluster control artifacts should be processed by manifest crosslinking...
fsl_ckout_sig_t
int flags
Flags, some (or one) of which is runtime-configurable by the client (see fsl_cx_flag_t).
Indicates that the field is used by the ticketchng table.
fsl_id_t fsl_uuid_to_rid2(fsl_cx *f, fsl_uuid_cstr uuid, fsl_phantom_t mode)
int fsl_repo_leaf_check(fsl_cx *f, fsl_id_t pid)
int fsl_content_new(fsl_cx *f, fsl_uuid_cstr uuid, char isPrivate, fsl_id_t *newId)
int fsl_tag_propagate(fsl_cx *f, fsl_tag_type tagType, fsl_id_t pid, fsl_id_t tagid, fsl_id_t origId, const char *zValue, fsl_double_t mtime)
char * fsl_db_setting_inop_rhs()
int fsl_mf_crosslink_begin(fsl_cx *f)
fsl_double_t value
Priority of this element.
fsl_list binary
Holds the "binary-glob" globs.
fsl_buffer fileContent
A place for holding file content.
void fsl_db_clear_strings(fsl_db *db, char alsoErrorState)
fsl_size_t dirLen
Optimization: fsl_strlen() of dir.
fsl_size_t capacity
Number of items allocated in this->list.
char const * name
fsl_int_t nextAge
Next cache counter age.
char * dir
Possibly not needed, but useful for doing absolute-to-relative path conversions for checking file lis...
int fsl_repo_shun_artifacts(fsl_cx *f)
char * projectCode
The "project-code" config option.
char * fsl_uuid_str
fsl_uuid_str and fsl_uuid_cstr are "for documentation and readability purposes" typedefs used to deno...
Definition: fossil-util.h:85
For unchanged or changed-by-merge files, set the mtime to last check-out time, as determined by fsl_m...
fsl_int32_t fsl_id_t
fsl_id_t is a signed integer type used to store database record IDs.
int(* fsl_deck_xlink_f)(fsl_cx *f, fsl_deck const *d, void *state)
A callback interface for manifest crosslinking, so that we can farm out the updating of the event tab...
Indicates that the field is used by the ticket table.
struct fsl_cx::@11 ticket
Ticket-related information.
fsl_id_t mtimeManifest
Infrastructure for fsl_mtime_of_manifest_file().
fsl_uuid_str uuid
The UUID of the current checkout.
int fsl_tag_insert(fsl_cx *f, fsl_tag_type tagtype, char const *zTag, char const *zValue, fsl_id_t srcId, fsl_double_t mtime, fsl_id_t rid, fsl_id_t *outRid)
FSL_EXPORT fsl_id_t fsl_tag_id(fsl_cx *f, char const *tag, char create)
int fsl_db_repo_verify_schema(fsl_db *db)
char fsl_acache_expire_oldest(fsl_acache *c)
Indicates that the field is used by both the ticket and ticketchng tables.
fsl_xlinker * list
Array of this->used elements.
fsl_card_J_flags
int fsl_content_put(fsl_cx *f, fsl_buffer const *pBlob, fsl_id_t *newRid)
int fsl_repo_leaf_eventually_check(fsl_cx *f, fsl_id_t rid)
char * user
The default user name, for operations which need one.
int fsl_filename_to_vfile_ids(fsl_cx *f, fsl_id_t vid, fsl_id_bag *dest, char const *zName)
A general-purpose buffer class, analog to Fossil v1's Blob class, but it is not called fsl_blob to av...
Definition: fossil-util.h:632
int fsl_acache_check_available(fsl_cx *f, fsl_id_t rid)
int hasCTime
Gets set to true (at some point) if the client has the ticket.tkt_ctime db field. ...
fsl_xlinker_list xlinkers
List of callbacks for deck crosslinking purposes.
fsl_size_t used
Number of used items in this->list.
fsl_size_t used
Number of items used in this->list.
int fsl_mf_crosslink_end(fsl_cx *f)
int fsl_tag_propagate_all(fsl_cx *f, fsl_id_t pid)
fsl_int_t szTotal
Total amount of memory used by cached content.
Indicates to fsl_uuid_to_rid2() that a public phantom artifact should be created if no artifact is fo...
Represents one file entry in a Manifest/Control Artifact (i.e., a checkin version).
fsl_acache_line * list
List of cached content, ordered by age.
struct fsl_cx::@6 ckout
Holds info directly related to a checkout database.
unsigned int fsl_uint32_t
Definition: fossil-config.h:82
A container type for lists of db record IDs.
Definition: fossil-util.h:3986
fsl_int_t age
Age.
fsl_db db
Handle to the currently opened checkout database IF the checkout is the main db.
fsl_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...
fsl_id_bag leafCheck
Used during the processing of manifests to keep track of "leaf checks" which need to be done downstre...
int fsl_content_deltify(fsl_cx *f, fsl_id_t rid, fsl_id_t srcid, char force)
fsl_size_t capacity
Number of slots allocated in this->list.
double fsl_double_t
fsl_double_t is the double type used by the library.
Non-file FS objects throw an error.
fsl_deck mf
The deck used for incrementally building certain parts of a checkin.
fsl_tag_type
Artifact tag types used by the Fossil framework.
A "deck" stores (predictably enough) a collection of "cards." Cards are constructs embedded within Fo...
char caseInsensitive
If true, SOME repository-level file-name comparisons/searches will work case-insensitively.
int fsl_repo_verify_at_commit(fsl_cx *f)
fsl_cx_config cxConfig
A copy of the config object passed to fsl_cx_init() (or some default).
void const * allocStamp
Marker which tells us whether fsl_cx_finalize() needs to fsl_free() this instance or not...
fsl_uint32_t size
Current number of entries in the mf linked list.
const fsl_xlinker_list fsl_xlinker_list_empty
Empty-initializes fsl_xlinker_list struct, intended for copy intialization.
void fsl_acache_clear(fsl_acache *c)
fsl_state clientState
Can be used to tie client-specific data to the context.
char deferCrosslink
Analog to v1's content.c:ignoreDephantomizations flag.
fsl_id_bag selectedIds
Holds a list of "selected files" in the form of vfile.id values.
void fsl_remove_pgp_signature(unsigned char const **pz, fsl_size_t *pn)
void fsl_cx_yield_file_buffer(fsl_cx *f)
int fsl_content_undeltify(fsl_cx *f, fsl_id_t rid)
int hasChngRid
Gets set to true (at some point) if the client has the ticketchng.rid db field.
fsl_list crnl
Holds the "crnl-glob" globs.
FSL_EXPORT int fsl_repo_filename_fnid2(fsl_cx *f, char const *filename, fsl_id_t *rv, char createNew)
fsl_db * dbMain
A pointer to the "main" db handle.
int fsl_deck_parse2(fsl_deck *d, fsl_buffer *src, fsl_id_t rid)
fsl_list customFields
Holds a list of (fsl_card_J*) records representing custom ticket table fields available in the db...
fsl_id_bag mfSeen
Used during manifest parsing.
fsl_list ignore
Holds the "ignore-glob" globs.
fsl_id_t rcvId
Record ID of rcvfrom entry during commits.
int hasSetupVfile
Tells us if vfile_selected has been created or not.
const fsl_xlinker fsl_xlinker_empty
Empty-initialized fsl_xlinker struct, intended for copy intialization.
fsl_db dbMem
A ":memory:" (or "") db to work around open-vs-attach-vs-main-vs-real-name problems wrt to the repo/c...
struct fsl_cx::@8 config
Holds info directly related to a global config database.
int fsl_qsort_cmp_J_cards(void const *lhs, void const *rhs)
void fsl_repo_verify_cancel(fsl_cx *f)
int fsl_cx_update_checkout_uuid(fsl_cx *f)
fsl_id_bag missing
Cache of known-missing content.
fsl_id_t rid
RID of the cached record.
FSL_EXPORT int fsl_content_put_ex(fsl_cx *f, fsl_buffer const *pBlob, fsl_uuid_cstr zUuid, fsl_id_t srcId, fsl_size_t uncompSize, char isPrivate, fsl_id_t *outRid)
fsl_buffer fsScratch
A scratchpad specifically for dealing with filename-related, non-recursive caching.
FSL_EXPORT int fsl_vfile_changes_scan(fsl_cx *f, fsl_id_t vid, int cksigFlags)
char inFinalVerify
Used to tell the content-save internals that a "final verification" (a.k.a.
int fsl_pq_insert(fsl_pq *p, fsl_id_t e, fsl_double_t v, void *pData)
char isCrosslinking
True if fsl_mf_crosslink_begin() has been called but fsl_mf_crosslink_end() is still pending...
int fsl_filename_to_vfile_id(fsl_cx *f, char const *zName, fsl_id_t *vfid)
const fsl_pq fsl_pq_empty
fsl_id_bag inCache
All artifacts currently in the cache.
struct fsl_cx::@9 ckin
State for incrementally proparing a checkin operation.
FSL_EXPORT void fsl_fatal(int code, char const *fmt,...)
int allowSymlinks
Cached copy of the allow-symlinks config option, because it is needed on each stat() call...
void fsl_cx_clear_mf_seen(fsl_cx *f)
void * p
Raw data associated with this entry.