Fossil SCM

Added tools/skintxt2config.c.

stephan 2021-02-06 16:26 trunk
Commit 35db28eb51a4d9a9ca87e1c190cbd3a6bb77efa38285e6533cc8f92e6227a5bb
1 file changed +120
--- a/tools/skintxt2config.c
+++ b/tools/skintxt2config.c
@@ -0,0 +1,120 @@
1
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
+/* vim: set ts=2 et sw=2 tw=80: */
3
+/*
4
+** Copyright (c) 2021 Stephan Beal (https://wanderinghorse.net/home/stephan/)
5
+**
6
+** This program is free software; you can redistribute it and/or
7
+** modify it under the terms of the Simplified BSD License (also
8
+** known as the "2-Clause License" or "FreeBSD License".)
9
+**
10
+** This program is distributed in the hope that it will be useful,
11
+** but without any warranty; without even the implied warranty of
12
+** merchantability or fitness for a particular purpose.
13
+**
14
+*******************************************************************************
15
+**
16
+** This application reads in Fossil SCM skin configuration files and emits
17
+** them in a form suitable for importing directly into a fossil database
18
+** using the (fossil config import) command.
19
+**
20
+** As input it requires one or more skin configuration files (css.txt,
21
+** header.txt, footer.txt, details.txt, js.txt) and all output goes to
22
+** stdout unless redirected using the -o FILENAME flag.
23
+**
24
+** Run it with no arguments or one of (help, --help, -?) for help text.
25
+*/
26
+#include <stdio.h>
27
+#include <stdlib.h>
28
+#<string.h>
29
+#include <errno.h>
30
+#include <time.h>
31
+#include <stdarg.h>
32
+
33
+static struct App_ {
34
+ const char * argv0;
35
+ time_t now;
36
+ FILE * ostr;
37
+} App = {
38
+0, 0, 0
39
+};
40
+
41
+static enum { F_CSS = 1, F_HEADER = 2, width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
42
+/* vim: set ts=2 et sw=2 tw=80: */
43
+/*
44
+** Copyright (c) 2021 Stephan Beal (https://wanderinghorse.net/home/stephan/)
45
+**
46
+** This program is free software; you can redistribute it and/or
47
+** modify it under the terms of the Simplified BSD License (also
48
+** known as the "2-Clause License" or "FreeBSD License".)
49
+**
50
+** This program is distributed in the hope that it will be useful,
51
+** but without any warranty; without even the implied warranty of
52
+** merchantability or fitness for a particular purpose.
53
+**
54
+*******************************************************************************
55
+**
56
+** This application reads in Fossil SCM skin configuration files and emits
57
+** them in a form suitable for importing directly into a fossil database
58
+** using the (fossil config import) command.
59
+**
60
+** As input it requires one or more skin configuration files (css.txt,
61
+** header.txt, footer.txt, details.txt, js.txt) and all output goes to
62
+** stdout unless redirected using the -o FILENAME flag.
63
+**
64
+** Run it with no arguments or one of (help, --help, -?) for help text.
65
+*/
66
+#include <stdio.h>
67
+#include <stdlib.h>
68
+#<string.h>
69
+#include <errno.h>
70
+#include <time.h>
71
+#include <stdarg.h>
72
+
73
+static struct App_ {
74
+ const char * argv0;
75
+ time_t now;
76
+ FILE * ostr;
77
+} App = {
78
+0, 0, 0
79
+};
80
+
81
+static void err(const char *zFmt, ...){
82
+ va gs, zFmt);
83
+ fputs("ERROR: ",stderr);
84
+ vfprintf(stderr, zFmt, vargs);
85
+ fputc('\n', stderr);
86
+ va_end(vargs);
87
+}
88
+
89
+static void app_usage(int isErr){
90
+ FILE * const ios = isErr ? stderr : stdout;
91
+ fprintf(ios, "Usage: %s ?OPTIONS? input-filename...\n\n",
92
+ App.argv0);
93
+ fprintf(ios, "Each filename must be one file which is conventionally "
94
+ "part of a Fossil SCM skin set:\n"
95
+ " css.txt, header.txt, footer.txt, details.txt, js.txt\n");
96
+ fprintf(ios, "\nOptions:\n");
97
+ fprintf(ios, "\n\t-o FILENAME = send output to the given file. "
98
+ "'-' means stdout (the default).\n");
99
+ fputc('\n', ios);
100
+}
101
+
102
+/*
103
+** Reads file zFilename, stores its contents in *zContent, and sets the
104
+** length of its contents to *nContent.
105
+**
106
+** Returns 0 on success. On error, *zContent and *nContent are not
107
+** modified and it may emit a message describing the problem.
108
+*/
109
+int read_file(char const *zFilename, unsigned char ** zContent,
110
+ int * nContent){
111
+ long fpos;
112
+ int rc = 0;
113
+ unsigned char * zMem = 0;
114
+ FILE * f = fopen(zFilename, "rb");
115
+ if(!f){
116
+ err("Cannot open file %s. Errno=%d", zFilename, errno);
117
+ return errno;
118
+ }
119
+/* -*- Margv[i])){
120
+ fprintf(stderr %s\n3M@1Qx,1KNjRY;1
--- a/tools/skintxt2config.c
+++ b/tools/skintxt2config.c
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/tools/skintxt2config.c
+++ b/tools/skintxt2config.c
@@ -0,0 +1,120 @@
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /*
4 ** Copyright (c) 2021 Stephan Beal (https://wanderinghorse.net/home/stephan/)
5 **
6 ** This program is free software; you can redistribute it and/or
7 ** modify it under the terms of the Simplified BSD License (also
8 ** known as the "2-Clause License" or "FreeBSD License".)
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but without any warranty; without even the implied warranty of
12 ** merchantability or fitness for a particular purpose.
13 **
14 *******************************************************************************
15 **
16 ** This application reads in Fossil SCM skin configuration files and emits
17 ** them in a form suitable for importing directly into a fossil database
18 ** using the (fossil config import) command.
19 **
20 ** As input it requires one or more skin configuration files (css.txt,
21 ** header.txt, footer.txt, details.txt, js.txt) and all output goes to
22 ** stdout unless redirected using the -o FILENAME flag.
23 **
24 ** Run it with no arguments or one of (help, --help, -?) for help text.
25 */
26 #include <stdio.h>
27 #include <stdlib.h>
28 #<string.h>
29 #include <errno.h>
30 #include <time.h>
31 #include <stdarg.h>
32
33 static struct App_ {
34 const char * argv0;
35 time_t now;
36 FILE * ostr;
37 } App = {
38 0, 0, 0
39 };
40
41 static enum { F_CSS = 1, F_HEADER = 2, width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
42 /* vim: set ts=2 et sw=2 tw=80: */
43 /*
44 ** Copyright (c) 2021 Stephan Beal (https://wanderinghorse.net/home/stephan/)
45 **
46 ** This program is free software; you can redistribute it and/or
47 ** modify it under the terms of the Simplified BSD License (also
48 ** known as the "2-Clause License" or "FreeBSD License".)
49 **
50 ** This program is distributed in the hope that it will be useful,
51 ** but without any warranty; without even the implied warranty of
52 ** merchantability or fitness for a particular purpose.
53 **
54 *******************************************************************************
55 **
56 ** This application reads in Fossil SCM skin configuration files and emits
57 ** them in a form suitable for importing directly into a fossil database
58 ** using the (fossil config import) command.
59 **
60 ** As input it requires one or more skin configuration files (css.txt,
61 ** header.txt, footer.txt, details.txt, js.txt) and all output goes to
62 ** stdout unless redirected using the -o FILENAME flag.
63 **
64 ** Run it with no arguments or one of (help, --help, -?) for help text.
65 */
66 #include <stdio.h>
67 #include <stdlib.h>
68 #<string.h>
69 #include <errno.h>
70 #include <time.h>
71 #include <stdarg.h>
72
73 static struct App_ {
74 const char * argv0;
75 time_t now;
76 FILE * ostr;
77 } App = {
78 0, 0, 0
79 };
80
81 static void err(const char *zFmt, ...){
82 va gs, zFmt);
83 fputs("ERROR: ",stderr);
84 vfprintf(stderr, zFmt, vargs);
85 fputc('\n', stderr);
86 va_end(vargs);
87 }
88
89 static void app_usage(int isErr){
90 FILE * const ios = isErr ? stderr : stdout;
91 fprintf(ios, "Usage: %s ?OPTIONS? input-filename...\n\n",
92 App.argv0);
93 fprintf(ios, "Each filename must be one file which is conventionally "
94 "part of a Fossil SCM skin set:\n"
95 " css.txt, header.txt, footer.txt, details.txt, js.txt\n");
96 fprintf(ios, "\nOptions:\n");
97 fprintf(ios, "\n\t-o FILENAME = send output to the given file. "
98 "'-' means stdout (the default).\n");
99 fputc('\n', ios);
100 }
101
102 /*
103 ** Reads file zFilename, stores its contents in *zContent, and sets the
104 ** length of its contents to *nContent.
105 **
106 ** Returns 0 on success. On error, *zContent and *nContent are not
107 ** modified and it may emit a message describing the problem.
108 */
109 int read_file(char const *zFilename, unsigned char ** zContent,
110 int * nContent){
111 long fpos;
112 int rc = 0;
113 unsigned char * zMem = 0;
114 FILE * f = fopen(zFilename, "rb");
115 if(!f){
116 err("Cannot open file %s. Errno=%d", zFilename, errno);
117 return errno;
118 }
119 /* -*- Margv[i])){
120 fprintf(stderr %s\n3M@1Qx,1KNjRY;1

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button