AmendHub

Download

jcs

/

subtext

/

folder.h

 

(View History)

jcs   folder: constify fields Latest amendment: 276 on 2022-11-11

1 /*
2 * Copyright (c) 2022 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 __FOLDER_H__
18 #define __FOLDER_H__
19
20 #include <stddef.h>
21 #include <stdio.h>
22 #include "db.h"
23 #include "sha1.h"
24
25 struct folder {
26 unsigned long id;
27 #define FOLDER_NAME_LENGTH 32
28 char name[FOLDER_NAME_LENGTH];
29 #define FOLDER_DESCR_LENGTH 100
30 char description[FOLDER_DESCR_LENGTH];
31 bool restricted_posting;
32 bool restricted_viewing;
33 unsigned long last_upload_at;
34 unsigned long file_count;
35 char path[FILENAME_MAX];
36
37 struct bile *bile;
38 };
39
40 extern const struct struct_field folder_fields[];
41 extern const size_t nfolder_fields;
42 extern const struct bile_object_field folder_object_fields[];
43 extern const size_t nfolder_object_fields;
44
45 struct folder_file {
46 unsigned long id;
47 time_t time;
48 unsigned long uploader_user_id;
49 #define FOLDER_FILE_FILENAME_LENGTH 31
50 char filename[FOLDER_FILE_FILENAME_LENGTH];
51 #define FOLDER_FILE_DESCR_LENGTH 50
52 char description[FOLDER_FILE_DESCR_LENGTH];
53 size_t size;
54 char sha1_checksum[SHA1_DIGEST_STRING_LENGTH + 1]; /* 42 */
55 size_t notes_size;
56 char *notes;
57 };
58 extern const struct bile_object_field folder_file_object_fields[];
59 extern const size_t nfolder_file_object_fields;
60
61 void folder_list(struct session *s);
62
63 #endif