libscipaper 1.0.x
types.h
1/*
2 * types.h
3 * Copyright (C) Carl Philipp Klemm 2022 <carl@uvos.xyz>
4 *
5 * types.h is free software: you can redistribute it and/or modify it
6 * under the terms of the lesser GNU General Public License as published by the
7 * Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * types.h is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the lesser GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20#include <time.h>
21#include <stdbool.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
46
50typedef enum {
53 SCI_CAP_GET_PDF = (1<<2),
55
62
66typedef struct _VersionFixed {
67 unsigned int major;
68 unsigned int minor;
69 unsigned int patch;
71
75typedef struct _BackendInfo {
76 const char *const name;
79
84typedef struct _FillReqest {
85 bool doi:1;
86 bool url:1;
87 bool year:1;
88 bool publisher:1;
89 bool volume:1;
90 bool pages:1;
91 bool author:1;
92 bool title:1;
93 bool journal:1;
94 bool issn:1;
95 bool keywords:1;
96 bool downloadUrl:1;
97 bool abstract:1;
99
103typedef struct _DocumentMeta {
104 //To be filled by user for query or by backend as a result
105 char* doi;
106 char* url;
107 unsigned long year;
108 char* publisher;
109 char* volume;
110 char* pages;
111 char* author;
112 char* title;
113 char* journal;
114 char* issn;
115 char* keywords;
117 char* abstract;
124 //To be filled by backend
126 void (*backend_data_free_fn)(void*);
127 void* (*backend_data_copy_fn)(void*);
129 //Filled by libscipaper core
132
138
145
151
158
165
173char* document_meta_get_json(const DocumentMeta* meta, const char* fullText, size_t* length);
174
181
188
194char* document_meta_load_full_text_from_json_file(const char* jsonFileName);
195
203char* document_meta_get_biblatex(const DocumentMeta* meta, size_t* length, const char* type);
204
212bool document_meta_save(const char* fileName, const DocumentMeta* meta, const char* fullText);
213
218void document_meta_free_list(DocumentMeta** meta, size_t length);
219
228
234typedef struct _RequestReturn {
236 size_t count;
237 size_t maxCount;
238 size_t page;
239 size_t totalCount;
241
248RequestReturn* request_return_new(size_t count, size_t maxCount);
249
255
259typedef struct _PdfData
260{
261 unsigned char* data;
262 size_t length;
264} PdfData;
265
271
274#ifdef __cplusplus
275}
276#endif
void document_meta_free(DocumentMeta *meta)
Frees a document meta struct.
char * document_meta_get_biblatex(const DocumentMeta *meta, size_t *length, const char *type)
Get string containing biblatex entry of the supplied DoucmentMeta.
void pdf_data_free(PdfData *data)
Frees a PdfData struct.
loglevel_t
Severity of loglevels.
Definition types.h:37
char * document_meta_get_string(const DocumentMeta *meta)
Creates a human readable string describing a DocumentMeta.
capability_flags_t
Flags that describe what a backend can do.
Definition types.h:50
void request_return_free(RequestReturn *reqRet)
Frees a RequestReturn struct.
bool document_meta_save(const char *fileName, const DocumentMeta *meta, const char *fullText)
Saves a DocumentMeta to disk.
void document_meta_free_list(DocumentMeta **meta, size_t length)
Frees a list/array of document metas.
bool document_meta_is_equal(const DocumentMeta *a, const DocumentMeta *b)
Compares to document metas and returns if they are equal.
RequestReturn * request_return_new(size_t count, size_t maxCount)
Allocates a empty RequestReturn struct.
DocumentMeta * document_meta_copy(const DocumentMeta *meta)
Dose a deep copy of a DocumentMeta struct.
char * document_meta_load_full_text_from_json_file(const char *jsonFileName)
create a DocumentMeta from json file saved by document_meta_save()
DocumentMeta * document_meta_load_from_json_file(const char *jsonFileName)
create a DocumentMeta from json file saved by document_meta_save()
DocumentMeta * document_meta_new(void)
Mallocs a DocumentMeta struct and initializes it.
char * document_meta_get_json(const DocumentMeta *meta, const char *fullText, size_t *length)
Get string containing json data of the supplied DoucmentMeta.
DocumentMeta * document_meta_load_from_json(char *jsonFile)
create a DocumentMeta from json data saved by document_meta_get_json()
void document_meta_combine(DocumentMeta *target, const DocumentMeta *source)
Adds the fields set in source but not in target to target.
char * capability_flags_get_str(capability_flags_t capabilities)
returns the capabilities flags as a human readable string.
@ LL_INFO
Informational message.
Definition types.h:43
@ LL_DEBUG
Useful when debugging.
Definition types.h:44
@ LL_DEFAULT
Default log level.
Definition types.h:42
@ LL_NONE
No logging at all.
Definition types.h:38
@ LL_WARN
Warning.
Definition types.h:41
@ LL_ERR
Error.
Definition types.h:40
@ LL_CRIT
Critical error.
Definition types.h:39
@ SCI_CAP_GET_TEXT
Backend can get full text of documents.
Definition types.h:52
@ SCI_CAP_GET_PDF
Backend can get pdfs of documents.
Definition types.h:53
@ SCI_CAP_FILL
Backend can fill DocumentMeta structs.
Definition types.h:51
Backend information struct.
Definition types.h:75
const char *const name
Name of the plugin.
Definition types.h:76
capability_flags_t capabilities
Flags that describe what a backend can do.
Definition types.h:77
This struct contains the metadata of a paper, must be created via document_meta_new() and freed via d...
Definition types.h:103
bool compleatedLookup
Entry lookup completed.
Definition types.h:130
int backendId
The id of the backend that found the document, or the id that shall be tried to find the document.
Definition types.h:122
char * url
The URL of the paper in the journal.
Definition types.h:106
char * author
The author(s) of the paper.
Definition types.h:111
char * abstract
abstract of the document
Definition types.h:117
char * keywords
Keywords given by the author of the paper for the paper.
Definition types.h:115
bool hasFullText
a hint that document has full text available
Definition types.h:120
void * backendData
Backend specific data, not to be used by clients.
Definition types.h:125
char * issn
The journal issn in which the paper was published.
Definition types.h:114
char * journal
The journal in which the paper was published.
Definition types.h:113
char * downloadUrl
URL where the full text of the document can be found.
Definition types.h:116
char * doi
The DOI of the paper.
Definition types.h:105
char * searchText
freeform text to search for in backends
Definition types.h:119
unsigned long year
Publication year of the paper.
Definition types.h:107
char * publisher
Publisher of the paper.
Definition types.h:108
char * volume
Journal volume where the paper appeared.
Definition types.h:109
char * pages
Page(s) where the paper is to be found in the volume.
Definition types.h:110
char * title
The title of the paper.
Definition types.h:112
This bitfield tells libscipaper what fields you require to have filled.
Definition types.h:84
bool issn
The journal issn in which the paper was published.
Definition types.h:94
bool author
The author(s) of the paper.
Definition types.h:91
bool year
Publication year of the paper.
Definition types.h:87
bool volume
Journal volume where the paper appeared.
Definition types.h:89
bool abstract
abstract of the document
Definition types.h:97
bool keywords
Keywords given by the author of the paper for the paper.
Definition types.h:95
bool url
The URL of the paper in the journal.
Definition types.h:86
bool doi
The DOI of the paper.
Definition types.h:85
bool title
The title of the paper.
Definition types.h:92
bool journal
The journal in which the paper was published.
Definition types.h:93
bool pages
Page(s) where the paper is to be found in the volume.
Definition types.h:90
bool downloadUrl
URL where the full text of the document can be found.
Definition types.h:96
bool publisher
Publisher of the paper.
Definition types.h:88
This struct contains the raw data of a PDF document.
Definition types.h:260
unsigned char * data
Raw data.
Definition types.h:261
DocumentMeta * meta
Meta data of the document that the PDF belongs to.
Definition types.h:263
size_t length
Length of data.
Definition types.h:262
This struct is details the result of a metadata search.
Definition types.h:234
DocumentMeta ** documents
A array of document meta structs detailing the search results.
Definition types.h:235
size_t page
The page that was requested.
Definition types.h:238
size_t count
The length of the DocumentMeta array.
Definition types.h:236
size_t maxCount
The maximum number of search results to be presented, as requested by the interface user.
Definition types.h:237
size_t totalCount
The total number of search results found by the backend, 0 if this information is not supported by th...
Definition types.h:239
This struct contains the version of libscipaper in use.
Definition types.h:66