commit: 9e49193874e0345f42604fef28a80dfa221df4b5
parent: 1c20fa156896313da2aca9bc68a5765fe0798e08
author: Chris Noxz <chris@noxz.tech>
date: Sun, 1 Dec 2019 22:04:03 +0100
Temporary implementation of 'other' type
1 file changed, 36 insertions(+)
diff --git a/tapas.c b/tapas.c
@@ -35,6 +35,8 @@
#define STR_HE ".ds APA_HE "
#define STR_AN ".ds APA_AN "
#define STR_IN ".ds APA_IN "
+#define STR_FR ".ds APA_FR "
+#define STR_RE ".ds APA_RE "
#define STR_MS ".ds APA_MS "
typedef struct {
@@ -77,6 +79,8 @@ struct Settings {
char heading[BUF_SIZE];
char and[BUF_SIZE];
char in[BUF_SIZE];
+ char from[BUF_SIZE];
+ char retrieved[BUF_SIZE];
char ms[BUF_SIZE];
};
struct Settings settings;
@@ -94,6 +98,7 @@ static void setattr(char, char*);
static void printref(int);
static void findreplace(char*, const char*, const char*);
static void wordsym();
+static void format_other();
static void format_article();
static void format_book();
static void format_article_in_book();
@@ -197,6 +202,7 @@ printref(int type)
{
wordsym();
switch (type) {
+ case 0: format_other(); break;
case 1: format_article(); break;
case 2: format_book(); break;
case 3: format_article_in_book(); break;
@@ -241,6 +247,30 @@ wordsym()
findreplace(state.ref->editor, " and ", str_and);
}
+void /* TODO :: Check type of other, website etc. */
+format_other()
+{
+ if (!state.ref->author
+ || !state.ref->publication_date
+ || !state.ref->additions /* access date */
+ || !state.ref->site_name
+ || !state.ref->url)
+ return;
+ switch (settings.macroset) {
+ case ms_ms:
+ fprintf(stdout,
+ ".XP\n%s (%s). \n.I \"%s\" \".\"\n%s %s, %s %s\n",
+ state.ref->author,
+ state.ref->publication_date,
+ state.ref->site_name,
+ settings.retrieved,
+ state.ref->additions,
+ settings.from,
+ state.ref->url
+ ); break;
+ }
+}
+
void
format_article()
{
@@ -327,6 +357,10 @@ loadstr(char *line)
trim(settings.and);
else if (readstr(line, STR_IN, settings.in, BUF_SIZE))
trim(settings.in);
+ else if (readstr(line, STR_FR, settings.from, BUF_SIZE))
+ trim(settings.from);
+ else if (readstr(line, STR_RE, settings.retrieved, BUF_SIZE))
+ trim(settings.retrieved);
else if (readstr(line, STR_MS, settings.ms, BUF_SIZE))
trim(settings.ms);
else
@@ -362,6 +396,8 @@ main(int arc, char *argv[])
strcpy(settings.heading, "References");
strcpy(settings.and, "&");
strcpy(settings.in, "In");
+ strcpy(settings.from, "from");
+ strcpy(settings.retrieved, "Retrieved");
strcpy(settings.ms, "");
/* default state */