AmendHub

Download

jcs

/

amend

/

repo.h

 

(View History)

jcs   settings: Update TETabWidth after saving, no need for a warning Latest amendment: 78 on 2022-06-15

1 /*
2 * Copyright (c) 2021 joshua stein <jcs@jcs.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef __REPO_H__
18 #define __REPO_H__
19
20 #include <time.h>
21 #include "bile.h"
22
23 #define AMEND_CREATOR 'AMND'
24
25 #define REPO_TYPE 'AMRP'
26
27 #define REPO_FILE_RTYPE 'AFIL'
28 #define REPO_COMMIT_RTYPE 'CMMT'
29 #define REPO_DIFF_RTYPE 'DIFF'
30 #define REPO_TEXT_RTYPE 'TEXT'
31 #define REPO_VERS_RTYPE 'RVER'
32
33 #define DIFF_FILE_TYPE 'TEXT'
34
35 #define REPO_DIFF_TOO_BIG "\r[ Diff too large to view, %lu bytes not shown ]"
36
37 #define REPO_CUR_VERS 3
38
39 struct repo_file {
40 short id;
41 char filename[256];
42 OSType type;
43 OSType creator;
44 unsigned long ctime;
45 unsigned long mtime;
46 unsigned char flags;
47 #define REPO_FILE_DELETED (1 << 0)
48 };
49
50 struct repo_file_attrs {
51 char type[4];
52 char creator[4];
53 unsigned long ctime;
54 unsigned long mtime;
55 };
56
57 struct diffed_file {
58 struct repo_file *file;
59 short flags;
60 #define DIFFED_FILE_TEXT (1 << 0)
61 #define DIFFED_FILE_METADATA (1 << 1)
62 };
63
64 struct repo_commit {
65 short id;
66 time_t date;
67 char author[32];
68 short nfiles;
69 short *file_ids;
70 short adds;
71 short subs;
72 short log_len;
73 Handle log;
74 };
75
76 struct repo {
77 struct bile *bile;
78 short nfiles;
79 struct repo_file **files;
80 short next_file_id;
81 short ncommits;
82 struct repo_commit **commits;
83 short next_commit_id;
84 };
85
86 struct repo *repo_open(AppFile *file);
87 struct repo *repo_create(void);
88 void repo_close(struct repo *repo);
89 struct repo_commit *repo_parse_commit(unsigned long id, unsigned char *data,
90 size_t size);
91 struct repo_file * repo_parse_file(unsigned long id, unsigned char *data,
92 size_t size);
93 struct repo_file *repo_file_with_id(struct repo *repo, short id);
94 void repo_show_diff_text(struct repo *repo, struct repo_commit *commit,
95 TEHandle te);
96 struct repo_file *repo_add_file(struct repo *repo);
97 void repo_file_mark_for_deletion(struct repo *repo, struct repo_file *file);
98 short repo_diff_file(struct repo *repo, struct repo_file *file);
99 short repo_file_changed(struct repo *repo, struct repo_file *file);
100 short repo_checkout_file(struct repo *repo, struct repo_file *file,
101 short vrefnum, Str255 filename);
102 void repo_export_patch(struct repo *repo, struct repo_commit *commit,
103 short vrefnum, Str255 filename);
104 void repo_commit(struct repo *repo, struct diffed_file *diffed_files,
105 short nfiles, short adds, short subs, char *author, Handle log,
106 short loglen, Handle diff, unsigned long difflen);
107 void repo_backup(struct repo *repo);
108
109 #endif