Menu

[r1401]: / advanced / src / xmlrpc_server_abyss.c  Maximize  Restore  History

Download this file

1528 lines (1131 with data), 47.5 kB

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
/* Copyright information is at the end of the file */
#include "xmlrpc_config.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#ifdef _WIN32
# include <io.h>
#else
# include <signal.h>
# include <sys/wait.h>
# include <grp.h>
#endif
#include "bool.h"
#include "int.h"
#include "mallocvar.h"
#include "xmlrpc-c/abyss.h"
#include "xmlrpc-c/base.h"
#include "xmlrpc-c/server.h"
#include "xmlrpc-c/base_int.h"
#include "xmlrpc-c/string_int.h"
#include "xmlrpc-c/server_abyss.h"
/*=========================================================================
** die_if_fault_occurred
**=========================================================================
** If certain kinds of out-of-memory errors occur during server setup,
** we want to quit and print an error.
*/
static void die_if_fault_occurred(xmlrpc_env *env) {
if (env->fault_occurred) {
fprintf(stderr, "Unexpected XML-RPC fault: %s (%d)\n",
env->fault_string, env->fault_code);
exit(1);
}
}
static void
initAbyss(xmlrpc_env * const envP) {
const char * error;
AbyssInit(&error);
if (error) {
xmlrpc_faultf(envP, "Failed to initialize the Abyss library. %s",
error);
xmlrpc_strfree(error);
}
}
static void
termAbyss(void) {
AbyssTerm();
}
static unsigned int globallyInitialized = 0;
/* Initialization count */
void
xmlrpc_server_abyss_global_init(xmlrpc_env * const envP) {
/* Note that this is specified as not thread safe; user calls it at
the beginning of his program, when it is only one thread.
*/
XMLRPC_ASSERT_ENV_OK(envP);
if (globallyInitialized == 0)
initAbyss(envP);
++globallyInitialized;
}
void
xmlrpc_server_abyss_global_term(void) {
/* Note that this is specified as not thread safe; user calls it at
the end of his program, when it is only one thread.
*/
XMLRPC_ASSERT(globallyInitialized > 0);
--globallyInitialized;
if (globallyInitialized == 0)
termAbyss();
}
static void
validateGlobalInit(xmlrpc_env * const envP) {
if (!globallyInitialized)
xmlrpc_faultf(envP, "libxmlrpc_server_abyss has not been globally "
"initialized. See xmlrpc_server_abyss_init()");
}
static void
addAuthCookie(xmlrpc_env * const envP,
TSession * const abyssSessionP,
const char * const authCookie) {
const char * cookieResponse;
xmlrpc_asprintf(&cookieResponse, "auth=%s", authCookie);
if (cookieResponse == xmlrpc_strsol)
xmlrpc_faultf(envP, "Insufficient memory to generate cookie "
"response header.");
else {
ResponseAddField(abyssSessionP, "Set-Cookie", cookieResponse);
xmlrpc_strfree(cookieResponse);
}
}
static void
sendXmlData(xmlrpc_env * const envP,
TSession * const abyssSessionP,
const char * const body,
size_t const len,
bool const chunked) {
/*----------------------------------------------------------------------------
Generate an HTTP response containing body 'body' of length 'len'
characters.
This is meant to run in the context of an Abyss URI handler for
Abyss session 'abyssSessionP'.
-----------------------------------------------------------------------------*/
const char * http_cookie = NULL;
/* This used to set http_cookie to getenv("HTTP_COOKIE"), but
that doesn't make any sense -- environment variables are not
appropriate for this. So for now, cookie code is disabled.
- Bryan 2004.10.03.
*/
/* Various bugs before Xmlrpc-c 1.05 caused the response to be not
chunked in the most basic case, but chunked if the client explicitly
requested keepalive. I think it's better not to chunk, because
it's simpler, so I removed this in 1.05. I don't know what the
purpose of chunking would be, and an original comment suggests
the author wasn't sure chunking was a good idea.
In 1.06 we added the user option to chunk.
*/
if (chunked)
ResponseChunked(abyssSessionP);
ResponseStatus(abyssSessionP, 200);
if (http_cookie)
/* There's an auth cookie, so pass it back in the response. */
addAuthCookie(envP, abyssSessionP, http_cookie);
if ((size_t)(uint32_t)len != len)
xmlrpc_faultf(envP, "XML-RPC method generated a response too "
"large for Abyss to send");
else {
uint32_t const abyssLen = (uint32_t)len;
ResponseContentType(abyssSessionP, "text/xml; charset=\"utf-8\"");
ResponseContentLength(abyssSessionP, abyssLen);
ResponseWriteStart(abyssSessionP);
ResponseWriteBody(abyssSessionP, body, abyssLen);
ResponseWriteEnd(abyssSessionP);
}
}
static void
sendError(TSession * const abyssSessionP,
unsigned int const status,
const char * const explanation) {
/*----------------------------------------------------------------------------
Send an error response back to the client.
-----------------------------------------------------------------------------*/
ResponseStatus(abyssSessionP, (uint16_t) status);
ResponseError2(abyssSessionP, explanation);
}
static void
traceChunkRead(TSession * const abyssSessionP) {
fprintf(stderr, "XML-RPC handler got a chunk of %u bytes\n",
(unsigned int)SessionReadDataAvail(abyssSessionP));
}
static void
refillBufferFromConnection(xmlrpc_env * const envP,
TSession * const abyssSessionP,
const char * const trace) {
/*----------------------------------------------------------------------------
Get the next chunk of data from the connection into the buffer.
-----------------------------------------------------------------------------*/
bool succeeded;
succeeded = SessionRefillBuffer(abyssSessionP);
if (!succeeded)
xmlrpc_env_set_fault_formatted(
envP, XMLRPC_TIMEOUT_ERROR, "Timed out waiting for "
"client to send its POST data");
else {
if (trace)
traceChunkRead(abyssSessionP);
}
}
static void
getBody(xmlrpc_env * const envP,
TSession * const abyssSessionP,
size_t const contentSize,
const char * const trace,
xmlrpc_mem_block ** const bodyP) {
/*----------------------------------------------------------------------------
Get the entire body, which is of size 'contentSize' bytes, from the
Abyss session and return it as the new memblock *bodyP.
The first chunk of the body may already be in Abyss's buffer. We
retrieve that before reading more.
-----------------------------------------------------------------------------*/
xmlrpc_mem_block * body;
if (trace)
fprintf(stderr, "XML-RPC handler processing body. "
"Content Size = %u bytes\n", (unsigned)contentSize);
body = xmlrpc_mem_block_new(envP, 0);
if (!envP->fault_occurred) {
size_t bytesRead;
const char * chunkPtr;
size_t chunkLen;
bytesRead = 0;
while (!envP->fault_occurred && bytesRead < contentSize) {
SessionGetReadData(abyssSessionP, contentSize - bytesRead,
&chunkPtr, &chunkLen);
bytesRead += chunkLen;
assert(bytesRead <= contentSize);
XMLRPC_MEMBLOCK_APPEND(char, envP, body, chunkPtr, chunkLen);
if (bytesRead < contentSize)
refillBufferFromConnection(envP, abyssSessionP, trace);
}
if (envP->fault_occurred)
xmlrpc_mem_block_free(body);
else
*bodyP = body;
}
}
static void
storeCookies(TSession * const httpRequestP,
const char ** const errorP) {
/*----------------------------------------------------------------------------
Get the cookie settings from the HTTP headers and remember them for
use in responses.
-----------------------------------------------------------------------------*/
const char * const cookie = RequestHeaderValue(httpRequestP, "cookie");
if (cookie) {
/*
Setting the value in an environment variable doesn't make
any sense. So for now, cookie code is disabled.
-Bryan 04.10.03.
setenv("HTTP_COOKIE", cookie, 1);
*/
}
/* TODO: parse HTTP_COOKIE to find auth pair, if there is one */
*errorP = NULL;
}
static void
validateContentType(TSession * const httpRequestP,
const char ** const errorP) {
/*----------------------------------------------------------------------------
If the client didn't specify a content-type of "text/xml", fail.
We can't allow the client to default this header, because some
firewall software may rely on all XML-RPC requests using the POST
method and a content-type of "text/xml".x
-----------------------------------------------------------------------------*/
const char * const content_type =
RequestHeaderValue(httpRequestP, "content-type");
if (content_type == NULL)
xmlrpc_asprintf(errorP,
"You did not supply a content-type HTTP header");
else {
const char * const sempos = strchr(content_type, ';');
unsigned int baselen;
/* Length of the base portion of the content type, e.g.
"text/xml" int "text/xml;charset=utf-8"
*/
if (sempos)
baselen = sempos - content_type;
else
baselen = strlen(content_type);
if (!xmlrpc_strneq(content_type, "text/xml", baselen))
xmlrpc_asprintf(errorP, "Your content-type HTTP header value '%s' "
"does not have a base type of 'text/xml'",
content_type);
else
*errorP = NULL;
}
}
static void
processContentLength(TSession * const httpRequestP,
size_t * const inputLenP,
bool * const missingP,
const char ** const errorP) {
/*----------------------------------------------------------------------------
Make sure the content length is present and non-zero. This is
technically required by XML-RPC, but we only enforce it because we
don't want to figure out how to safely handle HTTP < 1.1 requests
without it.
-----------------------------------------------------------------------------*/
const char * const content_length =
RequestHeaderValue(httpRequestP, "content-length");
if (content_length == NULL) {
*missingP = TRUE;
*errorP = NULL;
} else {
*missingP = FALSE;
if (content_length[0] == '\0')
xmlrpc_asprintf(errorP, "The value in your content-length "
"HTTP header value is a null string");
else {
unsigned long contentLengthValue;
char * tail;
contentLengthValue = strtoul(content_length, &tail, 10);
if (*tail != '\0')
xmlrpc_asprintf(errorP, "There's non-numeric crap in "
"the value of your content-length "
"HTTP header: '%s'", tail);
else if (contentLengthValue < 1)
xmlrpc_asprintf(errorP, "According to your content-length "
"HTTP header, your request is empty (zero "
"length)");
else if ((unsigned long)(size_t)contentLengthValue
!= contentLengthValue)
xmlrpc_asprintf(errorP, "According to your content-length "
"HTTP header, your request is too big to "
"process; we can't even do arithmetic on its "
"size: %s bytes", content_length);
else {
*errorP = NULL;
*inputLenP = (size_t)contentLengthValue;
}
}
}
}
static void
traceHandlerCalled(TSession * const abyssSessionP) {
const char * methodDesc;
const TRequestInfo * requestInfoP;
fprintf(stderr, "xmlrpc_server_abyss URI path handler called.\n");
SessionGetRequestInfo(abyssSessionP, &requestInfoP);
fprintf(stderr, "URI = '%s'\n", requestInfoP->uri);
switch (requestInfoP->method) {
case m_unknown: methodDesc = "unknown"; break;
case m_get: methodDesc = "get"; break;
case m_put: methodDesc = "put"; break;
case m_head: methodDesc = "head"; break;
case m_post: methodDesc = "post"; break;
case m_delete: methodDesc = "delete"; break;
case m_trace: methodDesc = "trace"; break;
case m_options: methodDesc = "m_options"; break;
default: methodDesc = "?";
}
fprintf(stderr, "HTTP method = '%s'\n", methodDesc);
if (requestInfoP->query)
fprintf(stderr, "query (component of URL)='%s'\n",
requestInfoP->query);
else
fprintf(stderr, "URL has no query component\n");
}
static void
processCall(TSession * const abyssSessionP,
size_t const contentSize,
xmlrpc_registry * const registryP,
bool const wantChunk,
const char * const trace) {
/*----------------------------------------------------------------------------
Handle an RPC request. This is an HTTP request that has the proper form
to be an XML-RPC call.
The text of the call is available through the Abyss session
'abyssSessionP'.
Its content length is 'contentSize' bytes.
-----------------------------------------------------------------------------*/
xmlrpc_env env;
if (trace)
fprintf(stderr,
"xmlrpc_server_abyss URI path handler processing RPC.\n");
xmlrpc_env_init(&env);
if (contentSize > xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID))
xmlrpc_env_set_fault_formatted(
&env, XMLRPC_LIMIT_EXCEEDED_ERROR,
"XML-RPC request too large (%d bytes)", contentSize);
else {
xmlrpc_mem_block * body;
/* Read XML data off the wire. */
getBody(&env, abyssSessionP, contentSize, trace, &body);
if (!env.fault_occurred) {
xmlrpc_mem_block * output;
/* Process the RPC. */
xmlrpc_registry_process_call2(
&env, registryP,
XMLRPC_MEMBLOCK_CONTENTS(char, body),
XMLRPC_MEMBLOCK_SIZE(char, body),
abyssSessionP,
&output);
if (!env.fault_occurred) {
/* Send out the result. */
sendXmlData(&env, abyssSessionP,
XMLRPC_MEMBLOCK_CONTENTS(char, output),
XMLRPC_MEMBLOCK_SIZE(char, output),
wantChunk);
XMLRPC_MEMBLOCK_FREE(char, output);
}
XMLRPC_MEMBLOCK_FREE(char, body);
}
}
if (env.fault_occurred) {
uint16_t httpResponseStatus;
if (env.fault_code == XMLRPC_TIMEOUT_ERROR)
httpResponseStatus = 408; /* Request Timeout */
else
httpResponseStatus = 500; /* Internal Server Error */
sendError(abyssSessionP, httpResponseStatus, env.fault_string);
}
xmlrpc_env_clean(&env);
}
/****************************************************************************
Abyss handlers (to be registered with and called by Abyss)
****************************************************************************/
static const char * trace_abyss;
struct uriHandlerXmlrpc {
/*----------------------------------------------------------------------------
This is the part of an Abyss HTTP request handler (aka URI handler)
that is specific to the Xmlrpc-c handler.
-----------------------------------------------------------------------------*/
xmlrpc_registry * registryP;
const char * uriPath; /* malloc'ed */
bool chunkResponse;
/* The handler should chunk its response whenever possible */
};
static void
termUriHandler(void * const arg) {
struct uriHandlerXmlrpc * const uriHandlerXmlrpcP = arg;
xmlrpc_strfree(uriHandlerXmlrpcP->uriPath);
free(uriHandlerXmlrpcP);
}
static void
handleXmlrpcReq(URIHandler2 * const this,
TSession * const abyssSessionP,
abyss_bool * const handledP) {
/*----------------------------------------------------------------------------
Our job is to look at this HTTP request that the Abyss server is
trying to process and see if we can handle it. If it's an XML-RPC
call for this XML-RPC server, we handle it. If it's not, we refuse
it and Abyss can try some other handler.
Our return code is TRUE to mean we handled it; FALSE to mean we didn't.
Note that failing the request counts as handling it, and not handling
it does not mean we failed it.
This is an Abyss HTTP Request handler -- type URIHandler2.
-----------------------------------------------------------------------------*/
struct uriHandlerXmlrpc * const uriHandlerXmlrpcP = this->userdata;
const TRequestInfo * requestInfoP;
if (trace_abyss)
traceHandlerCalled(abyssSessionP);
SessionGetRequestInfo(abyssSessionP, &requestInfoP);
/* Note that requestInfoP->uri is not the whole URI. It is just
the "file name" part of it.
*/
if (strcmp(requestInfoP->uri, uriHandlerXmlrpcP->uriPath) != 0)
/* It's for the path (e.g. "/RPC2") that we're supposed to
handle.
*/
*handledP = FALSE;
else {
*handledP = TRUE;
if (requestInfoP->method != m_post)
sendError(abyssSessionP, 405,
"POST is the only HTTP method this server understands");
/* 405 = Method Not Allowed */
else {
const char * error;
storeCookies(abyssSessionP, &error);
if (error) {
sendError(abyssSessionP, 400, error);
xmlrpc_strfree(error);
} else {
const char * error;
validateContentType(abyssSessionP, &error);
if (error) {
sendError(abyssSessionP, 400, error);
/* 400 = Bad Request */
xmlrpc_strfree(error);
} else {
const char * error;
bool missing;
size_t contentSize;
processContentLength(abyssSessionP,
&contentSize, &missing, &error);
if (error) {
sendError(abyssSessionP, 400, error);
xmlrpc_strfree(error);
} else {
if (missing)
sendError(abyssSessionP, 411, "You must send a "
"content-length HTTP header in an "
"XML-RPC call.");
else
processCall(abyssSessionP, contentSize,
uriHandlerXmlrpcP->registryP,
uriHandlerXmlrpcP->chunkResponse,
trace_abyss);
}
}
}
}
}
if (trace_abyss)
fprintf(stderr, "xmlrpc_server_abyss URI path handler returning.\n");
}
/*=========================================================================
** xmlrpc_server_abyss_default_handler
**=========================================================================
** This handler returns a 404 Not Found for all requests. See the header
** for more documentation.
*/
static xmlrpc_bool
xmlrpc_server_abyss_default_handler(TSession * const sessionP) {
const TRequestInfo * requestInfoP;
const char * explanation;
if (trace_abyss)
fprintf(stderr, "xmlrpc_server_abyss default handler called.\n");
SessionGetRequestInfo(sessionP, &requestInfoP);
xmlrpc_asprintf(
&explanation,
"This XML-RPC For C/C++ Abyss XML-RPC server "
"responds to only one URI path. "
"I don't know what URI path that is, "
"but it's not the one you requested: '%s'. (Typically, it's "
"'/RPC2')", requestInfoP->uri);
sendError(sessionP, 404, explanation);
xmlrpc_strfree(explanation);
return TRUE;
}
static void
setHandler(xmlrpc_env * const envP,
TServer * const srvP,
const char * const uriPath,
xmlrpc_registry * const registryP,
bool const chunkResponse) {
struct uriHandlerXmlrpc * uriHandlerXmlrpcP;
URIHandler2 uriHandler;
abyss_bool success;
trace_abyss = getenv("XMLRPC_TRACE_ABYSS");
MALLOCVAR_NOFAIL(uriHandlerXmlrpcP);
uriHandlerXmlrpcP->registryP = registryP;
uriHandlerXmlrpcP->uriPath = strdup(uriPath);
uriHandlerXmlrpcP->chunkResponse = chunkResponse;
uriHandler.handleReq2 = handleXmlrpcReq;
uriHandler.handleReq1 = NULL;
uriHandler.userdata = uriHandlerXmlrpcP;
uriHandler.init = NULL;
uriHandler.term = &termUriHandler;
ServerAddHandler2(srvP, &uriHandler, &success);
if (!success)
xmlrpc_faultf(envP, "Abyss failed to register the Xmlrpc-c request "
"handler. ServerAddHandler2() failed.");
if (envP->fault_occurred)
free(uriHandlerXmlrpcP);
}
void
xmlrpc_server_abyss_set_handler(xmlrpc_env * const envP,
TServer * const srvP,
const char * const uriPath,
xmlrpc_registry * const registryP) {
setHandler(envP, srvP, uriPath, registryP, false);
}
static void
setHandlers(TServer * const srvP,
const char * const uriPath,
xmlrpc_registry * const registryP,
bool const chunkResponse) {
xmlrpc_env env;
xmlrpc_env_init(&env);
trace_abyss = getenv("XMLRPC_TRACE_ABYSS");
setHandler(&env, srvP, uriPath, registryP, chunkResponse);
if (env.fault_occurred)
abort();
ServerDefaultHandler(srvP, xmlrpc_server_abyss_default_handler);
xmlrpc_env_clean(&env);
}
void
xmlrpc_server_abyss_set_handlers2(TServer * const srvP,
const char * const uriPath,
xmlrpc_registry * const registryP) {
setHandlers(srvP, uriPath, registryP, false);
}
void
xmlrpc_server_abyss_set_handlers(TServer * const srvP,
xmlrpc_registry * const registryP) {
setHandlers(srvP, "/RPC2", registryP, false);
}
/*============================================================================
createServer()
============================================================================*/
static void
setAdditionalServerParms(const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize,
TServer * const serverP) {
/* The following ought to be parameters on ServerCreate(), but it
looks like plugging them straight into the TServer structure is
the only way to set them.
*/
if (parmSize >= XMLRPC_APSIZE(keepalive_timeout) &&
parmsP->keepalive_timeout > 0)
ServerSetKeepaliveTimeout(serverP, parmsP->keepalive_timeout);
if (parmSize >= XMLRPC_APSIZE(keepalive_max_conn) &&
parmsP->keepalive_max_conn > 0)
ServerSetKeepaliveMaxConn(serverP, parmsP->keepalive_max_conn);
if (parmSize >= XMLRPC_APSIZE(timeout) &&
parmsP->timeout > 0)
ServerSetTimeout(serverP, parmsP->timeout);
if (parmSize >= XMLRPC_APSIZE(dont_advertise))
ServerSetAdvertise(serverP, !parmsP->dont_advertise);
}
static void
extractServerCreateParms(
xmlrpc_env * const envP,
const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize,
bool * const socketBoundP,
unsigned int * const portNumberP,
TOsSocket * const socketFdP,
const char ** const logFileNameP) {
if (parmSize >= XMLRPC_APSIZE(socket_bound))
*socketBoundP = parmsP->socket_bound;
else
*socketBoundP = FALSE;
if (*socketBoundP) {
if (parmSize < XMLRPC_APSIZE(socket_handle))
xmlrpc_faultf(envP, "socket_bound is true, but server parameter "
"structure does not contain socket_handle (it's too "
"short)");
else
*socketFdP = parmsP->socket_handle;
} else {
if (parmSize >= XMLRPC_APSIZE(port_number))
*portNumberP = parmsP->port_number;
else
*portNumberP = 8080;
if (*portNumberP > 0xffff)
xmlrpc_faultf(envP,
"TCP port number %u exceeds the maximum possible "
"TCP port number (65535)",
*portNumberP);
}
if (!envP->fault_occurred) {
if (parmSize >= XMLRPC_APSIZE(log_file_name) &&
parmsP->log_file_name)
*logFileNameP = strdup(parmsP->log_file_name);
else
*logFileNameP = NULL;
}
}
static void
chanSwitchCreateOsSocket(TOsSocket const socketFd,
TChanSwitch ** const chanSwitchPP,
const char ** const errorP) {
#ifdef WIN32
ChanSwitchWinCreateWinsock(socketFd, chanSwitchPP, errorP);
#else
ChanSwitchUnixCreateFd(socketFd, chanSwitchPP, errorP);
#endif
}
static void
createServerBoundSocket(xmlrpc_env * const envP,
TOsSocket const socketFd,
const char * const logFileName,
TServer * const serverP,
TChanSwitch ** const chanSwitchPP) {
TChanSwitch * chanSwitchP;
const char * error;
chanSwitchCreateOsSocket(socketFd, &chanSwitchP, &error);
if (error) {
xmlrpc_faultf(envP, "Unable to create Abyss socket out of "
"file descriptor %d. %s", socketFd, error);
xmlrpc_strfree(error);
} else {
ServerCreateSwitch(serverP, chanSwitchP, &error);
if (error) {
xmlrpc_faultf(envP, "Abyss failed to create server. %s", error);
xmlrpc_strfree(error);
} else {
*chanSwitchPP = chanSwitchP;
ServerSetName(serverP, "XmlRpcServer");
if (logFileName)
ServerSetLogFileName(serverP, logFileName);
}
if (envP->fault_occurred)
ChanSwitchDestroy(chanSwitchP);
}
}
static void
createServerBare(xmlrpc_env * const envP,
const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize,
TServer * const serverP,
TChanSwitch ** const chanSwitchPP) {
/*----------------------------------------------------------------------------
Create a bare server. It will need further setup before it is ready
to use.
-----------------------------------------------------------------------------*/
bool socketBound;
unsigned int portNumber;
TOsSocket socketFd;
const char * logFileName;
extractServerCreateParms(envP, parmsP, parmSize,
&socketBound, &portNumber, &socketFd,
&logFileName);
if (!envP->fault_occurred) {
if (socketBound)
createServerBoundSocket(envP, socketFd, logFileName,
serverP, chanSwitchPP);
else {
ServerCreate(serverP, "XmlRpcServer", portNumber, DEFAULT_DOCS,
logFileName);
*chanSwitchPP = NULL;
}
if (logFileName)
xmlrpc_strfree(logFileName);
}
}
static bool
chunkResponseParm(const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize) {
return
parmSize >= XMLRPC_APSIZE(chunk_response) &&
parmsP->chunk_response;
}
static const char *
uriPathParm(const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize) {
const char * uriPath;
if (parmSize >= XMLRPC_APSIZE(uri_path) && parmsP->uri_path)
uriPath = parmsP->uri_path;
else
uriPath = "/RPC2";
return uriPath;
}
static void
createServer(xmlrpc_env * const envP,
const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize,
TServer * const abyssServerP,
TChanSwitch ** const chanSwitchPP) {
createServerBare(envP, parmsP, parmSize, abyssServerP, chanSwitchPP);
if (!envP->fault_occurred) {
setAdditionalServerParms(parmsP, parmSize, abyssServerP);
setHandlers(abyssServerP, uriPathParm(parmsP, parmSize),
parmsP->registryP,
chunkResponseParm(parmsP, parmSize));
ServerInit(abyssServerP);
}
}
static bool
enableShutdownParm(const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize) {
return
parmSize >= XMLRPC_APSIZE(enable_shutdown) &&
parmsP->enable_shutdown;
}
static xmlrpc_server_shutdown_fn shutdownAbyss;
static void
shutdownAbyss(xmlrpc_env * const envP,
void * const context,
const char * const comment ATTR_UNUSED,
void * const callInfo ATTR_UNUSED) {
/*----------------------------------------------------------------------------
Tell Abyss to wrap up whatever it's doing and shut down.
This is a server shutdown function to be registered in the method
registry, for use by the 'system.shutdown' system method.
After we return, Abyss will finish up the system.shutdown and any
other connections that are in progress, then the call to
ServerRun() etc. will return. But Abyss may be stuck waiting for
something, such as the next HTTP connection. In that case, until it
gets what it's waiting for, it won't even know it's supposed t shut
down. In particular, a caller of system.shutdown may have to execute
one more RPC in order for the shutdown to happen.
-----------------------------------------------------------------------------*/
TServer * const serverP = context;
xmlrpc_env_init(envP);
ServerTerminate(serverP);
}
/*=============================================================================
xmlrpc_server_abyss object methods
=============================================================================*/
struct xmlrpc_server_abyss {
TServer abyssServer;
TChanSwitch * chanSwitchP;
};
void
xmlrpc_server_abyss_create(xmlrpc_env * const envP,
const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize,
xmlrpc_server_abyss_t ** const serverPP) {
xmlrpc_server_abyss_t * serverP;
XMLRPC_ASSERT_ENV_OK(envP);
validateGlobalInit(envP);
if (!envP->fault_occurred) {
if (parmSize < XMLRPC_APSIZE(registryP))
xmlrpc_faultf(envP,
"You must specify members at least up through "
"'registryP' in the server parameters argument. "
"That would mean the parameter size would be >= %lu "
"but you specified a size of %u",
XMLRPC_APSIZE(registryP), parmSize);
else {
MALLOCVAR(serverP);
if (serverP == NULL)
xmlrpc_faultf(envP, "Unable to allocate memory for "
"server descriptor.");
else {
createServer(envP, parmsP, parmSize,
&serverP->abyssServer, &serverP->chanSwitchP);
if (!envP->fault_occurred) {
if (enableShutdownParm(parmsP, parmSize))
xmlrpc_registry_set_shutdown(
parmsP->registryP, &shutdownAbyss,
&serverP->abyssServer);
if (envP->fault_occurred)
free(serverP);
else
*serverPP = serverP;
}
}
}
}
}
void
xmlrpc_server_abyss_destroy(xmlrpc_server_abyss_t * const serverP) {
XMLRPC_ASSERT(globallyInitialized);
ServerFree(&serverP->abyssServer);
if (serverP->chanSwitchP)
ChanSwitchDestroy(serverP->chanSwitchP);
free(serverP);
}
void
xmlrpc_server_abyss_use_sigchld(xmlrpc_server_abyss_t * const serverP) {
ServerUseSigchld(&serverP->abyssServer);
}
void
xmlrpc_server_abyss_run_server(xmlrpc_env * const envP ATTR_UNUSED,
xmlrpc_server_abyss_t * const serverP) {
ServerRun(&serverP->abyssServer);
}
void
xmlrpc_server_abyss_terminate(
xmlrpc_env * const envP ATTR_UNUSED,
xmlrpc_server_abyss_t * const serverP) {
ServerTerminate(&serverP->abyssServer);
}
void
xmlrpc_server_abyss_reset_terminate(
xmlrpc_env * const envP ATTR_UNUSED,
xmlrpc_server_abyss_t * const serverP) {
ServerResetTerminate(&serverP->abyssServer);
}
static void
sigchld(int const signalClass ATTR_UNUSED) {
/*----------------------------------------------------------------------------
This is a signal handler for a SIGCHLD signal (which informs us that
one of our child processes has terminated).
The only child processes we have are those that belong to the Abyss
server (and then only if the Abyss server was configured to use
forking as a threading mechanism), so we respond by passing the
signal on to the Abyss server.
-----------------------------------------------------------------------------*/
#ifndef WIN32
bool childrenLeft;
bool error;
assert(signalClass == SIGCHLD);
error = false;
childrenLeft = true; /* initial assumption */
/* Reap defunct children until there aren't any more. */
while (childrenLeft && !error) {
int status;
pid_t pid;
pid = waitpid((pid_t) -1, &status, WNOHANG);
if (pid == 0)
childrenLeft = false;
else if (pid < 0) {
/* because of ptrace */
if (errno != EINTR)
error = true;
} else
ServerHandleSigchld(pid);
}
#endif /* WIN32 */
}
struct xmlrpc_server_abyss_sig {
/* A description of the state of the process' signal handlers before
functions in this library messed with them; useful for restoring
them later.
*/
#ifndef WIN32
struct sigaction pipe;
struct sigaction chld;
#else
int dummy;
#endif
};
static void
setupSignalHandlers(xmlrpc_server_abyss_sig * const oldHandlersP) {
#ifndef WIN32
struct sigaction mysigaction;
sigemptyset(&mysigaction.sa_mask);
mysigaction.sa_flags = 0;
/* This signal indicates connection closed in the middle */
mysigaction.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &mysigaction, &oldHandlersP->pipe);
/* This signal indicates a child process (request handler) has died */
mysigaction.sa_handler = sigchld;
sigaction(SIGCHLD, &mysigaction, &oldHandlersP->chld);
#endif
}
static void
restoreSignalHandlers(const xmlrpc_server_abyss_sig * const oldHandlersP) {
#ifndef WIN32
sigaction(SIGPIPE, &oldHandlersP->pipe, NULL);
sigaction(SIGCHLD, &oldHandlersP->chld, NULL);
#endif
}
void
xmlrpc_server_abyss_setup_sig(
xmlrpc_env * const envP,
xmlrpc_server_abyss_t * const serverP,
xmlrpc_server_abyss_sig ** const oldHandlersPP) {
xmlrpc_server_abyss_sig * oldHandlersP;
XMLRPC_ASSERT_ENV_OK(envP);
validateGlobalInit(envP);
if (!envP->fault_occurred) {
MALLOCVAR(oldHandlersP);
if (oldHandlersP == NULL)
xmlrpc_faultf(envP, "Unable to allocate memory to save signal "
"handling state.");
else {
setupSignalHandlers(oldHandlersP);
xmlrpc_server_abyss_use_sigchld(serverP);
}
if (oldHandlersPP)
*oldHandlersPP = oldHandlersP;
else
free(oldHandlersP);
}
}
void
xmlrpc_server_abyss_restore_sig(
const xmlrpc_server_abyss_sig * const oldHandlersP) {
restoreSignalHandlers(oldHandlersP);
}
static void
runServerDaemon(TServer * const serverP,
runfirstFn const runfirst,
void * const runfirstArg) {
xmlrpc_server_abyss_sig oldHandlers;
setupSignalHandlers(&oldHandlers);
ServerUseSigchld(serverP);
ServerDaemonize(serverP);
/* We run the user supplied runfirst after forking, but before accepting
connections (helpful when running with threads)
*/
if (runfirst)
runfirst(runfirstArg);
ServerRun(serverP);
restoreSignalHandlers(&oldHandlers);
}
static void
oldHighLevelAbyssRun(xmlrpc_env * const envP ATTR_UNUSED,
const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize) {
/*----------------------------------------------------------------------------
This is the old deprecated interface, where the caller of the
xmlrpc_server_abyss API supplies an Abyss configuration file and
we use it to daemonize (fork into the background, chdir, set uid, etc.)
and run the Abyss server.
The new preferred interface, implemented by normalLevelAbyssRun(),
instead lets Caller set up the process environment himself and pass
Abyss parameters in memory. That's a more conventional and
flexible API.
-----------------------------------------------------------------------------*/
TServer server;
runfirstFn runfirst;
void * runfirstArg;
ServerCreate(&server, "XmlRpcServer", 8080, DEFAULT_DOCS, NULL);
assert(parmSize >= XMLRPC_APSIZE(config_file_name));
ConfReadServerFile(parmsP->config_file_name, &server);
assert(parmSize >= XMLRPC_APSIZE(registryP));
setHandlers(&server, "/RPC2", parmsP->registryP, false);
ServerInit(&server);
if (parmSize >= XMLRPC_APSIZE(runfirst_arg)) {
runfirst = parmsP->runfirst;
runfirstArg = parmsP->runfirst_arg;
} else {
runfirst = NULL;
runfirstArg = NULL;
}
runServerDaemon(&server, runfirst, runfirstArg);
ServerFree(&server);
}
static void
normalLevelAbyssRun(xmlrpc_env * const envP,
const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize) {
xmlrpc_server_abyss_t * serverP;
xmlrpc_server_abyss_create(envP, parmsP, parmSize, &serverP);
if (!envP->fault_occurred) {
xmlrpc_server_abyss_sig * oldHandlersP;
xmlrpc_server_abyss_setup_sig(envP, serverP, &oldHandlersP);
if (!envP->fault_occurred) {
xmlrpc_server_abyss_run_server(envP, serverP);
xmlrpc_server_abyss_restore_sig(oldHandlersP);
free(oldHandlersP);
}
xmlrpc_server_abyss_destroy(serverP);
}
}
void
xmlrpc_server_abyss(xmlrpc_env * const envP,
const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize) {
/*----------------------------------------------------------------------------
Note that this is not re-entrant and not thread-safe, due to the
global library initialization. If you want to run a server inside
a thread of a multi-threaded program, use
xmlrpc_server_abyss_create() instead. As required by that
subroutine, your program will contain a call to
xmlrpc_server_abyss_init() early in your program, when it is only
one thread.
-----------------------------------------------------------------------------*/
XMLRPC_ASSERT_ENV_OK(envP);
xmlrpc_server_abyss_global_init(envP);
if (!envP->fault_occurred) {
if (parmSize < XMLRPC_APSIZE(registryP))
xmlrpc_faultf(envP,
"You must specify members at least up through "
"'registryP' in the server parameters argument. "
"That would mean the parameter size would be >= %lu "
"but you specified a size of %u",
XMLRPC_APSIZE(registryP), parmSize);
else {
if (parmsP->config_file_name)
oldHighLevelAbyssRun(envP, parmsP, parmSize);
else
normalLevelAbyssRun(envP, parmsP, parmSize);
}
xmlrpc_server_abyss_global_term();
}
}
/*=========================================================================
XML-RPC Server Method Registry
This is an old deprecated form of the server facilities that uses
global variables.
=========================================================================*/
/* These global variables must be treated as read-only after the
server has started.
*/
static TServer globalSrv;
/* When you use the old interface (xmlrpc_server_abyss_init(), etc.),
this is the Abyss server to which they refer. Obviously, there can be
only one Abyss server per program using this interface.
*/
static xmlrpc_registry * builtin_registryP;
void
xmlrpc_server_abyss_init_registry(void) {
/* This used to just create the registry and Caller would be
responsible for adding the handlers that use it.
But that isn't very modular -- the handlers and registry go
together; there's no sense in using the built-in registry and
not the built-in handlers because if you're custom building
something, you can just make your own regular registry. So now
we tie them together, and we don't export our handlers.
*/
xmlrpc_env env;
xmlrpc_env_init(&env);
builtin_registryP = xmlrpc_registry_new(&env);
die_if_fault_occurred(&env);
xmlrpc_env_clean(&env);
setHandlers(&globalSrv, "/RPC2", builtin_registryP, false);
}
xmlrpc_registry *
xmlrpc_server_abyss_registry(void) {
/* This is highly deprecated. If you want to mess with a registry,
make your own with xmlrpc_registry_new() -- don't mess with the
internal one.
*/
return builtin_registryP;
}
/* A quick & easy shorthand for adding a method. */
void
xmlrpc_server_abyss_add_method(char * const method_name,
xmlrpc_method const method,
void * const user_data) {
xmlrpc_env env;
xmlrpc_env_init(&env);
xmlrpc_registry_add_method(&env, builtin_registryP, NULL, method_name,
method, user_data);
die_if_fault_occurred(&env);
xmlrpc_env_clean(&env);
}
void
xmlrpc_server_abyss_add_method_w_doc(char * const method_name,
xmlrpc_method const method,
void * const user_data,
char * const signature,
char * const help) {
xmlrpc_env env;
xmlrpc_env_init(&env);
xmlrpc_registry_add_method_w_doc(
&env, builtin_registryP, NULL, method_name,
method, user_data, signature, help);
die_if_fault_occurred(&env);
xmlrpc_env_clean(&env);
}
void
xmlrpc_server_abyss_init(int const flags ATTR_UNUSED,
const char * const config_file) {
ServerCreate(&globalSrv, "XmlRpcServer", 8080, DEFAULT_DOCS, NULL);
ConfReadServerFile(config_file, &globalSrv);
xmlrpc_server_abyss_init_registry();
/* Installs /RPC2 handler and default handler that use the
built-in registry.
*/
ServerInit(&globalSrv);
}
void
xmlrpc_server_abyss_run_first(runfirstFn const runfirst,
void * const runfirstArg) {
runServerDaemon(&globalSrv, runfirst, runfirstArg);
}
void
xmlrpc_server_abyss_run(void) {
runServerDaemon(&globalSrv, NULL, NULL);
}
/*
** Copyright (C) 2001 by First Peer, Inc. All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** There is more copyright information in the bottom half of this file.
** Please see it for more details.
*/
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.