/* * The vocabulary shared by every part of cgit. It pulls in the git headers * the renderers are written against, declares the record types they pass * around, and declares the single global ctx holding the parsed request, the * effective configuration and the repository being served. Anything that * belongs to one module is declared in that module's own header instead. */ #ifndef CGIT_H #define CGIT_H // git-compat-util.h sets the feature test macros that git's own headers and // the system headers are then compiled against, so it has to come first. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Every page cgit renders is UTF-8, so commit text in another encoding is // converted on the way in. #define PAGE_ENCODING "UTF-8" #define SECONDS_PER_MINUTE 60 #define SECONDS_PER_HOUR (SECONDS_PER_MINUTE * 60) #define SECONDS_PER_DAY (SECONDS_PER_HOUR * 24) #define SECONDS_PER_WEEK (SECONDS_PER_DAY * 7) #define SECONDS_PER_YEAR (SECONDS_PER_DAY * 365) // A double, because a twelfth of a year is not a whole number of seconds. #define SECONDS_PER_MONTH (SECONDS_PER_YEAR / 12.0) // The number of context lines git itself defaults to. #define DEFAULT_DIFF_CONTEXT 3 // A tab in rendered source runs on to the next multiple of this, which is the // width a browser picks on its own since the stylesheet sets no tab-size. #define TAB_WIDTH 8 typedef enum { DIFF_UNIFIED, DIFF_SSDIFF, DIFF_STATONLY } diff_type; // Filters are only ever held by pointer here, so their layout stays private // to filter.h. struct cgit_filter; struct cgit_repo { char *url; char *name; char *path; char *desc; char *head_content; char *owner; char *defbranch; char *module_link; struct string_list readme; char *section; char *clone_url; char *logo; char *logo_link; char *snapshot_prefix; int snapshots; int enable_blame; int enable_commit_graph; int enable_follow_links; int enable_gitmodules_links; int enable_log_filecount; int enable_log_linecount; int enable_mailmap; int enable_remote_branches; int enable_subject_links; int enable_commit_trailers; int enable_html_serving; int max_stats; int branch_sort; int commit_sort; time_t mtime; struct cgit_filter *about_filter; struct cgit_filter *commit_filter; struct cgit_filter *source_filter; struct cgit_filter *email_filter; struct cgit_filter *trailer_filter; struct string_list submodules; int hide; int ignore; }; struct cgit_repolist { int length; int count; struct cgit_repo *repos; }; struct commitinfo { struct commit *commit; char *author; char *author_email; // git's own width for a commit timestamp, which is wider than a long // on a 32 bit host and on Windows. timestamp_t author_date; int author_tz; char *committer; char *committer_email; timestamp_t committer_date; int committer_tz; char *subject; char *msg; char *msg_encoding; }; struct taginfo { char *tagger; char *tagger_email; timestamp_t tagger_date; int tagger_tz; char *msg; }; struct refinfo { const char *refname; struct object *object; union { struct taginfo *tag; struct commitinfo *commit; }; }; struct reflist { struct refinfo **refs; int alloc; int count; }; struct cgit_query { int has_symref; int has_oid; int has_difftype; char *raw; char *repo; char *page; char *search; char *grep; char *head; char *oid; char *oid2; char *path; char *url; char *period; int ofs; int nohead; char *sort; int showmsg; diff_type difftype; int show_all; int context; int ignorews; int follow; char *vpath; }; struct cgit_config { char *agefile; char *cache_root; char *clone_prefix; char *clone_url; char *favicon; char *footer; char *head_include; char *header; char *logo; char *logo_link; char *mimetype_file; char *module_link; char *project_list; struct string_list readme; struct string_list css; char *robots; char *root_title; char *root_desc; char *root_readme; char *script_name; char *section; char *repository_sort; // Always ends with a slash. char *virtual_root; char *strict_export; struct date_mode date_mode; int cache_size; int cache_dynamic_ttl; int cache_index_ttl; int cache_scan_ttl; int cache_static_ttl; int cache_summary_ttl; int cache_about_ttl; int cache_snapshot_ttl; int case_sensitive_sort; int embedded; int trust_scan_config; int enable_follow_links; int enable_gitmodules_links; int enable_header; int enable_http_clone; int enable_index_links; int enable_index_owner; int enable_blame; int enable_commit_graph; int enable_log_filecount; int enable_log_linecount; int enable_mailmap; int enable_plain_email; int enable_relative_dates; int enable_remote_branches; int enable_subject_links; int enable_commit_trailers; int enable_html_serving; int enable_tree_linenumbers; int enable_tree_group_dirs; int enable_git_config; int enable_cache_list; int local_time; int max_atom_items; int max_repo_count; int max_commit_count; int max_patch_count; int max_diff_files; int max_diff_lines; int max_msg_len; int max_ref_count; int max_repodesc_len; int max_blob_size; int max_stats; int renamelimit; int remove_suffix; int scan_hidden_path; int section_from_path; int snapshots; int section_sort; int summary_branches; int summary_log; int summary_tags; diff_type difftype; int branch_sort; int commit_sort; struct string_list mimetypes; struct string_list js; struct cgit_filter *about_filter; struct cgit_filter *commit_filter; struct cgit_filter *source_filter; struct cgit_filter *email_filter; struct cgit_filter *trailer_filter; struct cgit_filter *auth_filter; }; struct cgit_page { size_t size; const char *mimetype; const char *charset; const char *filename; const char *title; int status; const char *statusmsg; int untrusted; // Set once the status line is out, when an error can only join the body. int headers_sent; }; struct cgit_environment { const char *cgit_config; const char *http_host; const char *https; const char *no_http; const char *path_info; const char *query_string; const char *request_method; const char *script_name; const char *server_name; const char *server_port; const char *http_cookie; const char *http_referer; // A byte count, so size_t rather than a fixed width type that would // wrap at four gigabytes on the way in. size_t content_length; int authenticated; }; struct cgit_context { struct cgit_environment env; struct cgit_query qry; struct cgit_config cfg; struct cgit_repo *repo; struct cgit_page page; // Set when the repository holds no commits, so the page header can drop // the tabs that cannot render anything. int empty_repo; }; extern const char *cgit_version; extern struct cgit_repolist cgit_repolist; extern struct cgit_context ctx; extern void cgit_repo_config(struct cgit_repo *repo, const char *name, const char *value); #endif // CGIT_H