Fossil SCM

Added (hasfeature json|ssl|tcl) function to TH1 to determine whether the given compile-time option is enabled.

stephan 2012-07-13 18:40 trunk
Commit 2be3a876fdf5c8b05e644eaa761dd5ef601993b9
1 file changed +50
--- src/th_main.c
+++ src/th_main.c
@@ -214,10 +214,59 @@
214214
Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc);
215215
}
216216
Th_SetResultInt(interp, rc);
217217
return TH_OK;
218218
}
219
+
220
+/*
221
+** TH command: hasfeature STRING
222
+**
223
+** Return true if the user has the given compile-time feature.
224
+** The set of features includes:
225
+**
226
+** "json" = FOSSIL_ENABLE_JSON
227
+** "tcl" = FOSSIL_ENABLE_TCL
228
+** "ssl" = FOSSIL_ENABLE_SSL
229
+*/
230
+static int hasfeatureCmd(
231
+ Th_Interp *interp,
232
+ void *p,
233
+ int argc,
234
+ const char **argv,
235
+ int *argl
236
+){
237
+ int rc = 0;
238
+ char const * zArg;
239
+ if( argc!=2 ){
240
+ return Th_WrongNumArgs(interp, "hasfeature STRING");
241
+ }
242
+ zArg = (char const*)argv[1];
243
+ if(NULL==zArg){
244
+ /* placeholder for following ifdefs... */
245
+ }
246
+#if defined(FOSSIL_ENABLE_JSON)
247
+ else if( 0 == fossil_strnicmp( zArg, "json", 4 ) ){
248
+ rc = 1;
249
+ }
250
+#endif
251
+#if defined(FOSSIL_ENABLE_SSL)
252
+ else if( 0 == fossil_strnicmp( zArg, "ssl", 3 ) ){
253
+ rc = 1;
254
+ }
255
+#endif
256
+#if defined(FOSSIL_ENABLE_TCL)
257
+ else if( 0 == fossil_strnicmp( zArg, "tcl", 3 ) ){
258
+ rc = 1;
259
+ }
260
+#endif
261
+ if( g.thTrace ){
262
+ Th_Trace("[hasfeature %#h] => %d<br />\n", argl[1], zArg, rc);
263
+ }
264
+ Th_SetResultInt(interp, rc);
265
+ return TH_OK;
266
+}
267
+
219268
220269
/*
221270
** TH command: anycap STRING
222271
**
223272
** Return true if the user has any one of the capabilities listed in STRING.
@@ -382,10 +431,11 @@
382431
{"anycap", anycapCmd, 0},
383432
{"combobox", comboboxCmd, 0},
384433
{"enable_output", enableOutputCmd, 0},
385434
{"linecount", linecntCmd, 0},
386435
{"hascap", hascapCmd, 0},
436
+ {"hasfeature", hasfeatureCmd, 0},
387437
{"htmlize", htmlizeCmd, 0},
388438
{"date", dateCmd, 0},
389439
{"html", putsCmd, 0},
390440
{"puts", putsCmd, (void*)1},
391441
{"wiki", wikiCmd, 0},
392442
--- src/th_main.c
+++ src/th_main.c
@@ -214,10 +214,59 @@
214 Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc);
215 }
216 Th_SetResultInt(interp, rc);
217 return TH_OK;
218 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
220 /*
221 ** TH command: anycap STRING
222 **
223 ** Return true if the user has any one of the capabilities listed in STRING.
@@ -382,10 +431,11 @@
382 {"anycap", anycapCmd, 0},
383 {"combobox", comboboxCmd, 0},
384 {"enable_output", enableOutputCmd, 0},
385 {"linecount", linecntCmd, 0},
386 {"hascap", hascapCmd, 0},
 
387 {"htmlize", htmlizeCmd, 0},
388 {"date", dateCmd, 0},
389 {"html", putsCmd, 0},
390 {"puts", putsCmd, (void*)1},
391 {"wiki", wikiCmd, 0},
392
--- src/th_main.c
+++ src/th_main.c
@@ -214,10 +214,59 @@
214 Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc);
215 }
216 Th_SetResultInt(interp, rc);
217 return TH_OK;
218 }
219
220 /*
221 ** TH command: hasfeature STRING
222 **
223 ** Return true if the user has the given compile-time feature.
224 ** The set of features includes:
225 **
226 ** "json" = FOSSIL_ENABLE_JSON
227 ** "tcl" = FOSSIL_ENABLE_TCL
228 ** "ssl" = FOSSIL_ENABLE_SSL
229 */
230 static int hasfeatureCmd(
231 Th_Interp *interp,
232 void *p,
233 int argc,
234 const char **argv,
235 int *argl
236 ){
237 int rc = 0;
238 char const * zArg;
239 if( argc!=2 ){
240 return Th_WrongNumArgs(interp, "hasfeature STRING");
241 }
242 zArg = (char const*)argv[1];
243 if(NULL==zArg){
244 /* placeholder for following ifdefs... */
245 }
246 #if defined(FOSSIL_ENABLE_JSON)
247 else if( 0 == fossil_strnicmp( zArg, "json", 4 ) ){
248 rc = 1;
249 }
250 #endif
251 #if defined(FOSSIL_ENABLE_SSL)
252 else if( 0 == fossil_strnicmp( zArg, "ssl", 3 ) ){
253 rc = 1;
254 }
255 #endif
256 #if defined(FOSSIL_ENABLE_TCL)
257 else if( 0 == fossil_strnicmp( zArg, "tcl", 3 ) ){
258 rc = 1;
259 }
260 #endif
261 if( g.thTrace ){
262 Th_Trace("[hasfeature %#h] => %d<br />\n", argl[1], zArg, rc);
263 }
264 Th_SetResultInt(interp, rc);
265 return TH_OK;
266 }
267
268
269 /*
270 ** TH command: anycap STRING
271 **
272 ** Return true if the user has any one of the capabilities listed in STRING.
@@ -382,10 +431,11 @@
431 {"anycap", anycapCmd, 0},
432 {"combobox", comboboxCmd, 0},
433 {"enable_output", enableOutputCmd, 0},
434 {"linecount", linecntCmd, 0},
435 {"hascap", hascapCmd, 0},
436 {"hasfeature", hasfeatureCmd, 0},
437 {"htmlize", htmlizeCmd, 0},
438 {"date", dateCmd, 0},
439 {"html", putsCmd, 0},
440 {"puts", putsCmd, (void*)1},
441 {"wiki", wikiCmd, 0},
442

Keyboard Shortcuts

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