| | @@ -31,10 +31,11 @@ |
| 31 | 31 | #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */ |
| 32 | 32 | #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */ |
| 33 | 33 | #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH commands re-added? */ |
| 34 | 34 | #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */ |
| 35 | 35 | #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */ |
| 36 | +#define TH_INIT_HOOK (TH_INIT_NEED_CONFIG|TH_INIT_FORCE_SETUP) |
| 36 | 37 | #endif |
| 37 | 38 | |
| 38 | 39 | /* |
| 39 | 40 | ** These are the "well-known" TH1 error messages that occur when no hook is |
| 40 | 41 | ** registered to be called prior to executing a command or processing a web |
| | @@ -1201,11 +1202,11 @@ |
| 1201 | 1202 | int Th_CommandHook( |
| 1202 | 1203 | const char *zName, |
| 1203 | 1204 | char cmdFlags |
| 1204 | 1205 | ){ |
| 1205 | 1206 | int rc = TH_OK; |
| 1206 | | - Th_FossilInit(1, 1); |
| 1207 | + Th_FossilInit(TH_INIT_HOOK); |
| 1207 | 1208 | Th_Store("cmd_name", zName); |
| 1208 | 1209 | Th_StoreInt("cmd_flags", cmdFlags); |
| 1209 | 1210 | rc = Th_Eval(g.interp, 0, "command_hook", -1); |
| 1210 | 1211 | if( rc==TH_ERROR ){ |
| 1211 | 1212 | int nResult = 0; |
| | @@ -1225,11 +1226,11 @@ |
| 1225 | 1226 | ** (i.e. "command_hook") explicitly forbids this by successfully returning |
| 1226 | 1227 | ** TH_BREAK or TH_CONTINUE. |
| 1227 | 1228 | */ |
| 1228 | 1229 | if( g.thTrace ){ |
| 1229 | 1230 | Th_Trace("[command_hook {%h}] => %h<br />\n", zName, |
| 1230 | | - Th_ReturnCodeName(rc)); |
| 1231 | + Th_ReturnCodeName(rc, 0)); |
| 1231 | 1232 | } |
| 1232 | 1233 | return (rc != TH_ERROR) ? rc : TH_OK; |
| 1233 | 1234 | } |
| 1234 | 1235 | |
| 1235 | 1236 | /* |
| | @@ -1242,17 +1243,17 @@ |
| 1242 | 1243 | int Th_CommandNotify( |
| 1243 | 1244 | const char *zName, |
| 1244 | 1245 | char cmdFlags |
| 1245 | 1246 | ){ |
| 1246 | 1247 | int rc; |
| 1247 | | - Th_FossilInit(1, 1); |
| 1248 | + Th_FossilInit(TH_INIT_HOOK); |
| 1248 | 1249 | Th_Store("cmd_name", zName); |
| 1249 | 1250 | Th_StoreInt("cmd_flags", cmdFlags); |
| 1250 | 1251 | rc = Th_Eval(g.interp, 0, "command_notify", -1); |
| 1251 | 1252 | if( g.thTrace ){ |
| 1252 | 1253 | Th_Trace("[command_notify {%h}] => %h<br />\n", zName, |
| 1253 | | - Th_ReturnCodeName(rc)); |
| 1254 | + Th_ReturnCodeName(rc, 0)); |
| 1254 | 1255 | } |
| 1255 | 1256 | return rc; |
| 1256 | 1257 | } |
| 1257 | 1258 | |
| 1258 | 1259 | /* |
| | @@ -1264,11 +1265,11 @@ |
| 1264 | 1265 | int Th_WebpageHook( |
| 1265 | 1266 | const char *zName, |
| 1266 | 1267 | char cmdFlags |
| 1267 | 1268 | ){ |
| 1268 | 1269 | int rc = TH_OK; |
| 1269 | | - Th_FossilInit(1, 1); |
| 1270 | + Th_FossilInit(TH_INIT_HOOK); |
| 1270 | 1271 | Th_Store("web_name", zName); |
| 1271 | 1272 | Th_StoreInt("web_flags", cmdFlags); |
| 1272 | 1273 | rc = Th_Eval(g.interp, 0, "webpage_hook", -1); |
| 1273 | 1274 | if( rc==TH_ERROR ){ |
| 1274 | 1275 | int nResult = 0; |
| | @@ -1288,11 +1289,11 @@ |
| 1288 | 1289 | ** command (i.e. "webpage_hook") explicitly forbids this by successfully |
| 1289 | 1290 | ** returning TH_BREAK or TH_CONTINUE. |
| 1290 | 1291 | */ |
| 1291 | 1292 | if( g.thTrace ){ |
| 1292 | 1293 | Th_Trace("[webpage_hook {%h}] => %h<br />\n", zName, |
| 1293 | | - Th_ReturnCodeName(rc)); |
| 1294 | + Th_ReturnCodeName(rc, 0)); |
| 1294 | 1295 | } |
| 1295 | 1296 | return (rc != TH_ERROR) ? rc : TH_OK; |
| 1296 | 1297 | } |
| 1297 | 1298 | |
| 1298 | 1299 | /* |
| | @@ -1305,17 +1306,17 @@ |
| 1305 | 1306 | int Th_WebpageNotify( |
| 1306 | 1307 | const char *zName, |
| 1307 | 1308 | char cmdFlags |
| 1308 | 1309 | ){ |
| 1309 | 1310 | int rc; |
| 1310 | | - Th_FossilInit(1, 1); |
| 1311 | + Th_FossilInit(TH_INIT_HOOK); |
| 1311 | 1312 | Th_Store("web_name", zName); |
| 1312 | 1313 | Th_StoreInt("web_flags", cmdFlags); |
| 1313 | 1314 | rc = Th_Eval(g.interp, 0, "webpage_notify", -1); |
| 1314 | 1315 | if( g.thTrace ){ |
| 1315 | 1316 | Th_Trace("[webpage_notify {%h}] => %h<br />\n", zName, |
| 1316 | | - Th_ReturnCodeName(rc)); |
| 1317 | + Th_ReturnCodeName(rc, 0)); |
| 1317 | 1318 | } |
| 1318 | 1319 | return rc; |
| 1319 | 1320 | } |
| 1320 | 1321 | |
| 1321 | 1322 | /* |
| | @@ -1441,10 +1442,10 @@ |
| 1441 | 1442 | }else{ |
| 1442 | 1443 | fossil_fatal("Unknown TH1 hook %s\n", g.argv[2]); |
| 1443 | 1444 | } |
| 1444 | 1445 | zResult = (char*)Th_GetResult(g.interp, &nResult); |
| 1445 | 1446 | sendText("RESULT (", -1, 0); |
| 1446 | | - sendText(Th_ReturnCodeName(rc), -1, 0); |
| 1447 | + sendText(Th_ReturnCodeName(rc, 0), -1, 0); |
| 1447 | 1448 | sendText("): ", -1, 0); |
| 1448 | 1449 | sendText(zResult, nResult, 0); |
| 1449 | 1450 | sendText("\n", -1, 0); |
| 1450 | 1451 | } |
| 1451 | 1452 | |