Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.96 KB | None | 0 0
  1. diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
  2. index 5e44982..77af3e8 100644
  3. --- a/proxy/InkAPI.cc
  4. +++ b/proxy/InkAPI.cc
  5. @@ -4016,25 +4016,25 @@ TSConfigDataGet(TSConfig configp)
  6. // Management
  7. //
  8. ////////////////////////////////////////////////////////////////////
  9. -int
  10. +TSReturnCode
  11. TSMgmtIntGet(const char *var_name, TSMgmtInt *result)
  12. {
  13. - return RecGetRecordInt((char *) var_name, (RecInt *) result) == REC_ERR_OKAY ? 1 : 0;
  14. + return RecGetRecordInt((char *) var_name, (RecInt *) result) == REC_ERR_OKAY ? TS_SUCCESS : TS_ERROR;
  15. }
  16.  
  17. -int
  18. +TSReturnCode
  19. TSMgmtCounterGet(const char *var_name, TSMgmtCounter *result)
  20. {
  21. - return RecGetRecordCounter((char *) var_name, (RecCounter *) result) == REC_ERR_OKAY ? 1 : 0;
  22. + return RecGetRecordCounter((char *) var_name, (RecCounter *) result) == REC_ERR_OKAY ? TS_SUCCESS : TS_ERROR;
  23. }
  24.  
  25. -int
  26. +TSReturnCode
  27. TSMgmtFloatGet(const char *var_name, TSMgmtFloat *result)
  28. {
  29. - return RecGetRecordFloat((char *) var_name, (RecFloat *) result) == REC_ERR_OKAY ? 1 : 0;
  30. + return RecGetRecordFloat((char *) var_name, (RecFloat *) result) == REC_ERR_OKAY ? TS_SUCCESS : TS_ERROR;
  31. }
  32.  
  33. -int
  34. +TSReturnCode
  35. TSMgmtStringGet(const char *var_name, TSMgmtString *result)
  36. {
  37. RecString tmp = 0;
  38. @@ -4042,9 +4042,10 @@ TSMgmtStringGet(const char *var_name, TSMgmtString *result)
  39.  
  40. if (tmp) {
  41. *result = tmp;
  42. - return 1;
  43. + return TS_SUCCESS;
  44. }
  45. - return 0;
  46. +
  47. + return TS_ERROR;
  48. }
  49.  
  50. ////////////////////////////////////////////////////////////////////
  51. @@ -4332,7 +4333,7 @@ TSHttpTxnHookAdd(TSHttpTxn txnp, TSHttpHookID id, TSCont contp)
  52.  
  53. // Private api function for gzip plugin.
  54. // This function should only appear in TsapiPrivate.h
  55. -int
  56. +TSReturnCode
  57. TSHttpTxnHookRegisteredFor(TSHttpTxn txnp, TSHttpHookID id, TSEventFunc funcp)
  58. {
  59. HttpSM *sm = (HttpSM *) txnp;
  60. @@ -4340,12 +4341,12 @@ TSHttpTxnHookRegisteredFor(TSHttpTxn txnp, TSHttpHookID id, TSEventFunc funcp)
  61.  
  62. while (hook != NULL) {
  63. if (hook->m_cont && hook->m_cont->m_event_func == funcp) {
  64. - return 1;
  65. + return TS_SUCCESS;
  66. }
  67. hook = hook->m_link.next;
  68. }
  69.  
  70. - return 0;
  71. + return TS_ERROR;
  72. }
  73.  
  74. TSHttpSsn
  75. @@ -5393,7 +5394,7 @@ TSHttpTxnSetHttpRetBody(TSHttpTxn txnp, const char *body_msg, int plain_msg_flag
  76. }
  77.  
  78. /* control channel for HTTP */
  79. -int
  80. +TSReturnCode
  81. TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data)
  82. {
  83. sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
  84. @@ -5403,9 +5404,8 @@ TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data)
  85. switch (cntl) {
  86. case TS_HTTP_CNTL_GET_LOGGING_MODE:
  87. {
  88. - if (data == NULL) {
  89. - return 0;
  90. - }
  91. + if (data == NULL)
  92. + return TS_ERROR;
  93.  
  94. intptr_t *rptr = (intptr_t *) data;
  95.  
  96. @@ -5415,23 +5415,22 @@ TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data)
  97. *rptr = (intptr_t) TS_HTTP_CNTL_OFF;
  98. }
  99.  
  100. - return 1;
  101. + return TS_SUCCESS;
  102. }
  103.  
  104. case TS_HTTP_CNTL_SET_LOGGING_MODE:
  105. if (data != TS_HTTP_CNTL_ON && data != TS_HTTP_CNTL_OFF) {
  106. - return 0;
  107. + return TS_ERROR;
  108. } else {
  109. sm->t_state.api_info.logging_enabled = (bool) data;
  110. - return 1;
  111. + return TS_SUCCESS;
  112. }
  113. break;
  114.  
  115. case TS_HTTP_CNTL_GET_INTERCEPT_RETRY_MODE:
  116. {
  117. - if (data == NULL) {
  118. - return 0;
  119. - }
  120. + if (data == NULL)
  121. + return TS_ERROR;
  122.  
  123. intptr_t *rptr = (intptr_t *) data;
  124.  
  125. @@ -5441,21 +5440,21 @@ TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data)
  126. *rptr = (intptr_t) TS_HTTP_CNTL_OFF;
  127. }
  128.  
  129. - return 1;
  130. + return TS_SUCCESS;
  131. }
  132.  
  133. case TS_HTTP_CNTL_SET_INTERCEPT_RETRY_MODE:
  134. if (data != TS_HTTP_CNTL_ON && data != TS_HTTP_CNTL_OFF) {
  135. - return 0;
  136. + return TS_ERROR;
  137. } else {
  138. sm->t_state.api_info.retry_intercept_failures = (bool) data;
  139. - return 1;
  140. + return TS_SUCCESS;
  141. }
  142. default:
  143. - return 0;
  144. + return TS_ERROR;
  145. }
  146.  
  147. - return 0;
  148. + return TS_ERROR;
  149. }
  150.  
  151. /* This is kinda horky, we have to use TSServerState instead of
  152. @@ -6647,27 +6646,27 @@ TSIPLookupMatch(TSIPLookup iplu, uint32_t addr, void **data)
  153. return (my_iplu ? my_iplu->Match((ip_addr_t) addr, data) : 0);
  154. }
  155.  
  156. -int
  157. +TSReturnCode
  158. TSIPLookupMatchFirst(TSIPLookup iplu, uint32_t addr, TSIPLookupState iplus, void **data)
  159. {
  160. IpLookup *my_iplu = (IpLookup *) iplu;
  161. IpLookupState *my_iplus = (IpLookupState *) iplus;
  162. if (my_iplu && my_iplus && my_iplu->MatchFirst(addr, my_iplus, data))
  163. - return 1;
  164. + return TS_SUCCESS;
  165.  
  166. - return 0;
  167. + return TS_ERROR;
  168. }
  169.  
  170. -int
  171. +TSReturnCode
  172. TSIPLookupMatchNext(TSIPLookup iplu, TSIPLookupState iplus, void **data)
  173. {
  174. IpLookup *my_iplu = (IpLookup *) iplu;
  175. IpLookupState *my_iplus = (IpLookupState *) iplus;
  176.  
  177. if (my_iplu && my_iplus && my_iplu->MatchNext(my_iplus, data))
  178. - return 1;
  179. + return TS_SUCCESS;
  180.  
  181. - return 0;
  182. + return TS_ERROR;
  183. }
  184.  
  185. void
  186. @@ -6744,7 +6743,7 @@ TSMgmtConfigIntSet(const char *var_name, TSMgmtInt value)
  187. char *buffer;
  188.  
  189. // is this a valid integer?
  190. - if (!TSMgmtIntGet(var_name, &result))
  191. + if (TSMgmtIntGet(var_name, &result) != TS_SUCCESS)
  192. return TS_ERROR;
  193.  
  194. // construct a buffer
  195. @@ -6991,7 +6990,7 @@ TSFetchUrl(const char* headers, int request_len, unsigned int ip, int port , TSC
  196. fetch_sm->httpConnect();
  197. }
  198.  
  199. -int
  200. +TSReturnCode
  201. TSHttpIsInternalRequest(TSHttpTxn txnp)
  202. {
  203. sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
  204. @@ -7001,9 +7000,9 @@ TSHttpIsInternalRequest(TSHttpTxn txnp)
  205. NetVConnection *vc = cs->get_netvc();
  206.  
  207. if (!cs || !vc)
  208. - return 0;
  209. + return TS_ERROR;
  210.  
  211. - return vc->get_is_internal_request() ? 1 : 0;
  212. + return vc->get_is_internal_request() ? TS_SUCCESS : TS_ERROR;
  213. }
  214.  
  215.  
  216. diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
  217. index f777b53..7ecdee0 100644
  218. --- a/proxy/InkAPITest.cc
  219. +++ b/proxy/InkAPITest.cc
  220. @@ -2252,7 +2252,7 @@ checkHttpTxnClientIncomingPortGet(SocketTest * test, void *data)
  221. return TS_EVENT_CONTINUE;
  222. }
  223.  
  224. - if (TSMgmtIntGet("proxy.config.http.server_port", &port_from_config_file) == 0) {
  225. + if (TSMgmtIntGet("proxy.config.http.server_port", &port_from_config_file) != TS_SUCCESS) {
  226. port_from_config_file = 8080;
  227. }
  228.  
  229. @@ -5545,15 +5545,13 @@ REGRESSION_TEST(SDK_API_TSMgmtGet) (RegressionTest * test, int atype, int *pstat
  230.  
  231. *pstatus = REGRESSION_TEST_INPROGRESS;
  232.  
  233. - int retVal;
  234. int err = 0;
  235. TSMgmtCounter cvalue = 0;
  236. TSMgmtFloat fvalue = 0.0;
  237. TSMgmtInt ivalue = -1;
  238. TSMgmtString svalue = NULL;
  239.  
  240. - retVal = TSMgmtCounterGet(CONFIG_PARAM_COUNTER_NAME, &cvalue);
  241. - if (retVal == 0) {
  242. + if (TS_SUCCESS != TSMgmtCounterGet(CONFIG_PARAM_COUNTER_NAME, &cvalue)) {
  243. SDK_RPRINT(test, "TSMgmtCounterGet", "TestCase1.1", TC_FAIL, "can not get value of param %s", CONFIG_PARAM_COUNTER_NAME);
  244. err = 1;
  245. } else if (cvalue != CONFIG_PARAM_COUNTER_VALUE) {
  246. @@ -5565,24 +5563,21 @@ REGRESSION_TEST(SDK_API_TSMgmtGet) (RegressionTest * test, int atype, int *pstat
  247. SDK_RPRINT(test, "TSMgmtCounterGet", "TestCase1.1", TC_PASS, "ok");
  248. }
  249.  
  250. - retVal = TSMgmtFloatGet(CONFIG_PARAM_FLOAT_NAME, &fvalue);
  251. - if ((retVal == 0) || (fvalue != CONFIG_PARAM_FLOAT_VALUE)) {
  252. + if ((TS_SUCCESS != TSMgmtFloatGet(CONFIG_PARAM_FLOAT_NAME, &fvalue)) || (fvalue != CONFIG_PARAM_FLOAT_VALUE)) {
  253. SDK_RPRINT(test, "TSMgmtFloatGet", "TestCase2", TC_FAIL, "can not get value of param %s", CONFIG_PARAM_FLOAT_NAME);
  254. err = 1;
  255. } else {
  256. SDK_RPRINT(test, "TSMgmtFloatGet", "TestCase1.2", TC_PASS, "ok");
  257. }
  258.  
  259. - retVal = TSMgmtIntGet(CONFIG_PARAM_INT_NAME, &ivalue);
  260. - if ((retVal == 0) || (ivalue != CONFIG_PARAM_INT_VALUE)) {
  261. + if ((TSMgmtIntGet(CONFIG_PARAM_INT_NAME, &ivalue) != TS_SUCCESS) || (ivalue != CONFIG_PARAM_INT_VALUE)) {
  262. SDK_RPRINT(test, "TSMgmtIntGet", "TestCase1.3", TC_FAIL, "can not get value of param %s", CONFIG_PARAM_INT_NAME);
  263. err = 1;
  264. } else {
  265. SDK_RPRINT(test, "TSMgmtIntGet", "TestCase1.3", TC_PASS, "ok");
  266. }
  267.  
  268. - retVal = TSMgmtStringGet(CONFIG_PARAM_STRING_NAME, &svalue);
  269. - if (retVal == 0) {
  270. + if (TS_SUCCESS != TSMgmtStringGet(CONFIG_PARAM_STRING_NAME, &svalue)) {
  271. SDK_RPRINT(test, "TSMgmtStringGet", "TestCase1.4", TC_FAIL, "can not get value of param %s", CONFIG_PARAM_STRING_NAME);
  272. err = 1;
  273. } else if (strcmp(svalue, CONFIG_PARAM_STRING_VALUE) != 0) {
  274. diff --git a/proxy/InkAPITestTool.cc b/proxy/InkAPITestTool.cc
  275. index dfed535..754fa4b 100644
  276. --- a/proxy/InkAPITestTool.cc
  277. +++ b/proxy/InkAPITestTool.cc
  278. @@ -431,7 +431,7 @@ synclient_txn_create(void)
  279. TSMgmtInt proxy_port;
  280.  
  281. ClientTxn *txn = (ClientTxn *) TSmalloc(sizeof(ClientTxn));
  282. - if (!TSMgmtIntGet(PROXY_CONFIG_NAME_HTTP_PORT, &proxy_port)) {
  283. + if (TSMgmtIntGet(PROXY_CONFIG_NAME_HTTP_PORT, &proxy_port) != TS_SUCCESS) {
  284. proxy_port = PROXY_HTTP_DEFAULT_PORT;
  285. }
  286. txn->connect_port = (int) proxy_port;
  287. diff --git a/proxy/api/ts/experimental.h b/proxy/api/ts/experimental.h
  288. index 6259d04..41e8c60 100644
  289. --- a/proxy/api/ts/experimental.h
  290. +++ b/proxy/api/ts/experimental.h
  291. @@ -51,7 +51,7 @@ extern "C"
  292.  
  293. /* Do not edit these apis, used internally */
  294. tsapi int TSMimeHdrFieldEqual(TSMBuffer bufp, TSMLoc hdr_obj, TSMLoc field1, TSMLoc field2);
  295. - tsapi int TSHttpTxnHookRegisteredFor(TSHttpTxn txnp, TSHttpHookID id, TSEventFunc funcp);
  296. + tsapi TSReturnCode TSHttpTxnHookRegisteredFor(TSHttpTxn txnp, TSHttpHookID id, TSEventFunc funcp);
  297.  
  298. /* IP Lookup */
  299. typedef void *TSIPLookup;
  300. @@ -61,8 +61,8 @@ extern "C"
  301. tsapi void TSIPLookupPrint(TSIPLookup iplu, TSIPLookupPrintFunc pf);
  302. tsapi void TSIPLookupNewEntry(TSIPLookup iplu, uint32_t addr1, uint32_t addr2, void *data);
  303. tsapi int TSIPLookupMatch(TSIPLookup iplu, uint32_t addr, void **data);
  304. - tsapi int TSIPLookupMatchFirst(TSIPLookup iplu, uint32_t addr, TSIPLookupState iplus, void **data);
  305. - tsapi int TSIPLookupMatchNext(TSIPLookup iplu, TSIPLookupState iplus, void **data);
  306. + tsapi TSReturnCode TSIPLookupMatchFirst(TSIPLookup iplu, uint32_t addr, TSIPLookupState iplus, void **data);
  307. + tsapi TSReturnCode TSIPLookupMatchNext(TSIPLookup iplu, TSIPLookupState iplus, void **data);
  308.  
  309. /* for Media-IXT mms over http */
  310. typedef enum
  311. @@ -80,7 +80,7 @@ extern "C"
  312. TSHttpTxnCntl(.., TS_HTTP_CNTL_GET_LOGGING_MODE, &onoff);
  313. if (onoff == TS_HTTP_CNTL_ON) ....
  314. */
  315. - tsapi int TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data);
  316. + tsapi TSReturnCode TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data);
  317.  
  318.  
  319. /* Protocols APIs */
  320. diff --git a/proxy/api/ts/ts.h.in b/proxy/api/ts/ts.h.in
  321. index 9d1e269..9a5fb50 100644
  322. --- a/proxy/api/ts/ts.h.in
  323. +++ b/proxy/api/ts/ts.h.in
  324. @@ -2018,10 +2018,10 @@ extern "C"
  325.  
  326. /* --------------------------------------------------------------------------
  327. Management */
  328. - tsapi int TSMgmtIntGet(const char *var_name, TSMgmtInt *result);
  329. - tsapi int TSMgmtCounterGet(const char *var_name, TSMgmtCounter *result);
  330. - tsapi int TSMgmtFloatGet(const char *var_name, TSMgmtFloat *result);
  331. - tsapi int TSMgmtStringGet(const char *var_name, TSMgmtString *result);
  332. + tsapi TSReturnCode TSMgmtIntGet(const char *var_name, TSMgmtInt *result);
  333. + tsapi TSReturnCode TSMgmtCounterGet(const char *var_name, TSMgmtCounter *result);
  334. + tsapi TSReturnCode TSMgmtFloatGet(const char *var_name, TSMgmtFloat *result);
  335. + tsapi TSReturnCode TSMgmtStringGet(const char *var_name, TSMgmtString *result);
  336.  
  337. /* --------------------------------------------------------------------------
  338. Continuations */
  339. @@ -2267,7 +2267,7 @@ extern "C"
  340. tsapi void TSFetchPages(TSFetchUrlParams_t *params);
  341.  
  342. /* Check if HTTP State machine is internal or not */
  343. - tsapi int TSHttpIsInternalRequest(TSHttpTxn txnp);
  344. + tsapi TSReturnCode TSHttpIsInternalRequest(TSHttpTxn txnp);
  345.  
  346. /* --------------------------------------------------------------------------
  347. HTTP alternate selection */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement