summaryrefslogtreecommitdiff
path: root/support/texlab/crates/bibutils_sys/src/reftypes.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-12-03 03:01:24 +0000
committerNorbert Preining <norbert@preining.info>2019-12-03 03:01:24 +0000
commitb8d4bb76703bcb15578e2b23c5d256532180b894 (patch)
treebedd1df7a00521a2bd986b3c0289d6556a59e39b /support/texlab/crates/bibutils_sys/src/reftypes.c
parent02e4625a78a5029e8b5dc2a4ec70193b232f497e (diff)
CTAN sync 201912030301
Diffstat (limited to 'support/texlab/crates/bibutils_sys/src/reftypes.c')
-rw-r--r--support/texlab/crates/bibutils_sys/src/reftypes.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/support/texlab/crates/bibutils_sys/src/reftypes.c b/support/texlab/crates/bibutils_sys/src/reftypes.c
new file mode 100644
index 0000000000..0826c252cd
--- /dev/null
+++ b/support/texlab/crates/bibutils_sys/src/reftypes.c
@@ -0,0 +1,72 @@
+/*
+ * reftypes.c
+ *
+ * Copyright (c) Chris Putnam 2003-2019
+ *
+ * Source code released under the GPL version 2
+ *
+ */
+#include <stdio.h>
+#include <string.h>
+#include "is_ws.h"
+#include "fields.h"
+#include "reftypes.h"
+#include "msvc_fix.h"
+
+int
+get_reftype( const char *p, long refnum, char *progname, variants *all, int nall, char *tag, int *is_default, int chattiness )
+{
+ int i;
+
+ p = skip_ws( p );
+
+ *is_default = 0;
+
+ for ( i=0; i<nall; ++i ) {
+ if ( !strncasecmp( all[i].type, p, strlen(all[i].type) ) )
+ return i;
+ }
+
+ *is_default = 1;
+
+ if ( chattiness==REFTYPE_CHATTY ) {
+ if ( progname ) fprintf( stderr, "%s: ", progname );
+ fprintf( stderr, "Did not recognize type '%s' of refnum %ld (%s).\n"
+ "\tDefaulting to %s.\n", p, refnum, tag, all[0].type );
+ }
+
+ return 0;
+}
+
+int
+process_findoldtag( const char *oldtag, int reftype, variants all[], int nall )
+{
+ variants *v;
+ int i;
+
+ v = &(all[reftype]);
+ for ( i=0; i<v->ntags; ++i ) {
+ if ( !strcasecmp( (v->tags[i]).oldstr, oldtag ) )
+ return i;
+ }
+ return -1;
+}
+
+/* translate_oldtag()
+ */
+int
+translate_oldtag( const char *oldtag, int reftype, variants all[], int nall,
+ int *processingtype, int *level, char **newtag )
+{
+ int n;
+
+ n = process_findoldtag( oldtag, reftype, all, nall );
+ if ( n!=-1 ) {
+ *processingtype = ((all[reftype]).tags[n]).processingtype;
+ *level = ((all[reftype]).tags[n]).level;
+ *newtag = ((all[reftype]).tags[n]).newstr;
+ return 1;
+ }
+
+ return 0;
+}