You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/03/23 21:33:21 UTC
[48/52] [partial] trafficserver git commit: TS-3419 Fix some enum's
such that clang-format can handle it the way we want. Basically this means
having a trailing ,
on short enum's. TS-3419 Run clang-format over most of the source
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/cache-scan/cache-scan.cc
----------------------------------------------------------------------
diff --git a/example/cache-scan/cache-scan.cc b/example/cache-scan/cache-scan.cc
index 4a5e500..ee1f04d 100644
--- a/example/cache-scan/cache-scan.cc
+++ b/example/cache-scan/cache-scan.cc
@@ -36,8 +36,7 @@
static TSCont global_contp;
-struct cache_scan_state_t
-{
+struct cache_scan_state_t {
TSVConn net_vc;
TSVConn cache_vc;
TSVIO read_vio;
@@ -66,12 +65,12 @@ static int
handle_scan(TSCont contp, TSEvent event, void *edata)
{
TSCacheHttpInfo cache_infop;
- cache_scan_state *cstate = (cache_scan_state *) TSContDataGet(contp);
+ cache_scan_state *cstate = (cache_scan_state *)TSContDataGet(contp);
if (event == TS_EVENT_CACHE_REMOVE) {
cstate->done = 1;
const char error[] = "Cache remove operation succeeded";
- cstate->cache_vc = (TSVConn) edata;
+ cstate->cache_vc = (TSVConn)edata;
cstate->write_vio = TSVConnWrite(cstate->net_vc, contp, cstate->resp_reader, INT64_MAX);
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, error, sizeof(error) - 1);
TSVIONBytesSet(cstate->write_vio, cstate->total_bytes);
@@ -84,7 +83,7 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
const char error[] = "Cache remove operation failed error=";
char rc[12];
snprintf(rc, 12, "%p", edata);
- cstate->cache_vc = (TSVConn) edata;
+ cstate->cache_vc = (TSVConn)edata;
cstate->write_vio = TSVConnWrite(cstate->net_vc, contp, cstate->resp_reader, INT64_MAX);
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, error, sizeof(error) - 1);
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, rc, strlen(rc));
@@ -94,15 +93,15 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
return 0;
}
- //first scan event, save vc and start write
+ // first scan event, save vc and start write
if (event == TS_EVENT_CACHE_SCAN) {
- cstate->cache_vc = (TSVConn) edata;
+ cstate->cache_vc = (TSVConn)edata;
cstate->write_vio = TSVConnWrite(cstate->net_vc, contp, cstate->resp_reader, INT64_MAX);
return TS_EVENT_CONTINUE;
}
- //just stop scanning if blocked or failed
- if (event == TS_EVENT_CACHE_SCAN_FAILED ||
- event == TS_EVENT_CACHE_SCAN_OPERATION_BLOCKED || event == TS_EVENT_CACHE_SCAN_OPERATION_FAILED) {
+ // just stop scanning if blocked or failed
+ if (event == TS_EVENT_CACHE_SCAN_FAILED || event == TS_EVENT_CACHE_SCAN_OPERATION_BLOCKED ||
+ event == TS_EVENT_CACHE_SCAN_OPERATION_FAILED) {
cstate->done = 1;
if (cstate->resp_buffer) {
const char error[] = "Cache scan operation blocked or failed";
@@ -115,12 +114,12 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
return TS_CACHE_SCAN_RESULT_DONE;
}
- //grab header and print url to outgoing vio
+ // grab header and print url to outgoing vio
if (event == TS_EVENT_CACHE_SCAN_OBJECT) {
if (cstate->done) {
return TS_CACHE_SCAN_RESULT_DONE;
}
- cache_infop = (TSCacheHttpInfo) edata;
+ cache_infop = (TSCacheHttpInfo)edata;
TSMBuffer req_bufp, resp_bufp;
TSMLoc req_hdr_loc, resp_hdr_loc;
@@ -142,7 +141,7 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_hdr_loc);
- //print the response headers
+ // print the response headers
TSCacheHttpInfoRespGet(cache_infop, &resp_bufp, &resp_hdr_loc);
cstate->total_bytes += TSMimeHdrLengthGet(resp_bufp, resp_hdr_loc);
TSMimeHdrPrint(resp_bufp, resp_hdr_loc, cstate->resp_buffer);
@@ -158,15 +157,14 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
cstate->total_items++;
return TS_CACHE_SCAN_RESULT_CONTINUE;
}
- //CACHE_SCAN_DONE: ready to close the vc on the next write reenable
+ // CACHE_SCAN_DONE: ready to close the vc on the next write reenable
if (event == TS_EVENT_CACHE_SCAN_DONE) {
cstate->done = 1;
char s[512];
- int s_len = snprintf(s, sizeof(s),
- "</pre></p>\n<p>%d total objects in cache</p>\n"
- "<form method=\"GET\" action=\"/show-cache\">"
- "Enter URL to delete: <input type=\"text\" size=\"40\" name=\"remove_url\">"
- "<input type=\"submit\" value=\"Delete URL\">",
+ int s_len = snprintf(s, sizeof(s), "</pre></p>\n<p>%d total objects in cache</p>\n"
+ "<form method=\"GET\" action=\"/show-cache\">"
+ "Enter URL to delete: <input type=\"text\" size=\"40\" name=\"remove_url\">"
+ "<input type=\"submit\" value=\"Delete URL\">",
cstate->total_items);
cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, s, s_len);
TSVIONBytesSet(cstate->write_vio, cstate->total_bytes);
@@ -185,11 +183,11 @@ handle_scan(TSCont contp, TSEvent event, void *edata)
static int
handle_accept(TSCont contp, TSEvent event, TSVConn vc)
{
- cache_scan_state *cstate = (cache_scan_state *) TSContDataGet(contp);
+ cache_scan_state *cstate = (cache_scan_state *)TSContDataGet(contp);
if (event == TS_EVENT_NET_ACCEPT) {
if (cstate) {
- //setup vc, buffers
+ // setup vc, buffers
cstate->net_vc = vc;
cstate->req_buffer = TSIOBufferCreate();
@@ -202,7 +200,7 @@ handle_accept(TSCont contp, TSEvent event, TSVConn vc)
TSContDestroy(contp);
}
} else {
- //net_accept failed
+ // net_accept failed
if (cstate) {
TSfree(cstate);
}
@@ -216,9 +214,8 @@ handle_accept(TSCont contp, TSEvent event, TSVConn vc)
static void
cleanup(TSCont contp)
{
-
- //shutdown vc and free memory
- cache_scan_state *cstate = (cache_scan_state *) TSContDataGet(contp);
+ // shutdown vc and free memory
+ cache_scan_state *cstate = (cache_scan_state *)TSContDataGet(contp);
if (cstate) {
// cancel any pending cache scan actions, since we will be destroying the
@@ -256,44 +253,42 @@ cleanup(TSCont contp)
static int
handle_io(TSCont contp, TSEvent event, void * /* edata ATS_UNUSED */)
{
- cache_scan_state *cstate = (cache_scan_state *) TSContDataGet(contp);
+ cache_scan_state *cstate = (cache_scan_state *)TSContDataGet(contp);
switch (event) {
case TS_EVENT_VCONN_READ_READY:
- case TS_EVENT_VCONN_READ_COMPLETE:
- {
- //we don't care about the request, so just shut down the read vc
- TSVConnShutdown(cstate->net_vc, 1, 0);
- //setup the response headers so we are ready to write body
- char hdrs[] = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n";
- cstate->total_bytes = TSIOBufferWrite(cstate->resp_buffer, hdrs, sizeof(hdrs) - 1);
-
- if (cstate->key_to_delete) {
- TSAction actionp = TSCacheRemove(contp, cstate->key_to_delete);
- if (!TSActionDone(actionp)) {
- cstate->pending_action = actionp;
- }
- } else {
- char head[] = "<h3>Cache Contents:</h3>\n<p><pre>\n";
- cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, head, sizeof(head) - 1);
- //start scan
- TSAction actionp = TSCacheScan(contp, 0, 512000);
- if (!TSActionDone(actionp)) {
- cstate->pending_action = actionp;
- }
- }
+ case TS_EVENT_VCONN_READ_COMPLETE: {
+ // we don't care about the request, so just shut down the read vc
+ TSVConnShutdown(cstate->net_vc, 1, 0);
+ // setup the response headers so we are ready to write body
+ char hdrs[] = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n";
+ cstate->total_bytes = TSIOBufferWrite(cstate->resp_buffer, hdrs, sizeof(hdrs) - 1);
- return 0;
- }
- case TS_EVENT_VCONN_WRITE_READY:
- {
- TSDebug("cache_iter", "ndone: %" PRId64 " total_bytes: % " PRId64, TSVIONDoneGet(cstate->write_vio), cstate->total_bytes);
- cstate->write_pending = 0;
- // the cache scan handler should call vio reenable when there is
- // available data
- //TSVIOReenable(cstate->write_vio);
- return 0;
+ if (cstate->key_to_delete) {
+ TSAction actionp = TSCacheRemove(contp, cstate->key_to_delete);
+ if (!TSActionDone(actionp)) {
+ cstate->pending_action = actionp;
+ }
+ } else {
+ char head[] = "<h3>Cache Contents:</h3>\n<p><pre>\n";
+ cstate->total_bytes += TSIOBufferWrite(cstate->resp_buffer, head, sizeof(head) - 1);
+ // start scan
+ TSAction actionp = TSCacheScan(contp, 0, 512000);
+ if (!TSActionDone(actionp)) {
+ cstate->pending_action = actionp;
+ }
}
+
+ return 0;
+ }
+ case TS_EVENT_VCONN_WRITE_READY: {
+ TSDebug("cache_iter", "ndone: %" PRId64 " total_bytes: % " PRId64, TSVIONDoneGet(cstate->write_vio), cstate->total_bytes);
+ cstate->write_pending = 0;
+ // the cache scan handler should call vio reenable when there is
+ // available data
+ // TSVIOReenable(cstate->write_vio);
+ return 0;
+ }
case TS_EVENT_VCONN_WRITE_COMPLETE:
TSDebug("cache_iter", "write complete");
case TS_EVENT_VCONN_EOS:
@@ -316,7 +311,7 @@ cache_intercept(TSCont contp, TSEvent event, void *edata)
switch (event) {
case TS_EVENT_NET_ACCEPT:
case TS_EVENT_NET_ACCEPT_FAILED:
- return handle_accept(contp, event, (TSVConn) edata);
+ return handle_accept(contp, event, (TSVConn)edata);
case TS_EVENT_VCONN_READ_READY:
case TS_EVENT_VCONN_READ_COMPLETE:
case TS_EVENT_VCONN_WRITE_READY:
@@ -359,7 +354,7 @@ unescapifyStr(char *buffer)
if (*read == '%' && *(read + 1) != '\0' && *(read + 2) != '\0') {
subStr[0] = *(++read);
subStr[1] = *(++read);
- *write = (char)strtol(subStr, (char **) NULL, 16);
+ *write = (char)strtol(subStr, (char **)NULL, 16);
read++;
write++;
} else if (*read == '+') {
@@ -381,7 +376,6 @@ unescapifyStr(char *buffer)
static int
setup_request(TSCont contp, TSHttpTxn txnp)
{
-
TSMBuffer bufp;
TSMLoc hdr_loc;
TSMLoc url_loc;
@@ -419,14 +413,13 @@ setup_request(TSCont contp, TSHttpTxn txnp)
if (path_len == 10 && !strncmp(path, "show-cache", 10)) {
scan_contp = TSContCreate(cache_intercept, TSMutexCreate());
TSHttpTxnIntercept(scan_contp, txnp);
- cstate = (cache_scan_state *) TSmalloc(sizeof(cache_scan_state));
+ cstate = (cache_scan_state *)TSmalloc(sizeof(cache_scan_state));
memset(cstate, 0, sizeof(cache_scan_state));
cstate->http_txnp = txnp;
if (query && query_len > 11) {
-
char querybuf[2048];
- query_len = (unsigned) query_len > sizeof(querybuf) - 1 ? sizeof(querybuf) - 1 : query_len;
+ query_len = (unsigned)query_len > sizeof(querybuf) - 1 ? sizeof(querybuf) - 1 : query_len;
char *start = querybuf, *end = querybuf + query_len;
size_t del_url_len;
memcpy(querybuf, query, query_len);
@@ -446,7 +439,7 @@ setup_request(TSCont contp, TSHttpTxn txnp)
TSMLoc urlLoc;
TSUrlCreate(urlBuf, &urlLoc);
- if (TSUrlParse(urlBuf, urlLoc, (const char **) &start, end) != TS_PARSE_DONE ||
+ if (TSUrlParse(urlBuf, urlLoc, (const char **)&start, end) != TS_PARSE_DONE ||
TSCacheKeyDigestFromUrlSet(cstate->key_to_delete, urlLoc) != TS_SUCCESS) {
TSError("CacheKeyDigestFromUrlSet failed");
TSCacheKeyDestroy(cstate->key_to_delete);
@@ -478,17 +471,17 @@ cache_print_plugin(TSCont contp, TSEvent event, void *edata)
{
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR:
- return setup_request(contp, (TSHttpTxn) edata);
+ return setup_request(contp, (TSHttpTxn)edata);
default:
break;
}
- TSHttpTxnReenable((TSHttpTxn) edata, TS_EVENT_HTTP_CONTINUE);
+ TSHttpTxnReenable((TSHttpTxn)edata, TS_EVENT_HTTP_CONTINUE);
return TS_SUCCESS;
}
//----------------------------------------------------------------------------
void
-TSPluginInit(int /* argc ATS_UNUSED */, const char */* argv ATS_UNUSED */[])
+TSPluginInit(int /* argc ATS_UNUSED */, const char * /* argv ATS_UNUSED */ [])
{
global_contp = TSContCreate(cache_print_plugin, TSMutexCreate());
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, global_contp);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/file-1/file-1.c
----------------------------------------------------------------------
diff --git a/example/file-1/file-1.c b/example/file-1/file-1.c
index 23d67d7..f61df8b 100644
--- a/example/file-1/file-1.c
+++ b/example/file-1/file-1.c
@@ -65,4 +65,3 @@ TSPluginInit(int argc, const char *argv[])
TSfclose(filep);
}
}
-
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/intercept/intercept.cc
----------------------------------------------------------------------
diff --git a/example/intercept/intercept.cc b/example/intercept/intercept.cc
index c56a01d..6248957 100644
--- a/example/intercept/intercept.cc
+++ b/example/intercept/intercept.cc
@@ -54,30 +54,30 @@
#define VERROR(fmt, ...) TSError("[%s] %s: " fmt, PLUGIN, __FUNCTION__, ##__VA_ARGS__)
#endif
-#define VIODEBUG(vio, fmt, ...) VDEBUG("vio=%p vio.cont=%p, vio.cont.data=%p, vio.vc=%p " fmt, \
- (vio), TSVIOContGet(vio), TSContDataGet(TSVIOContGet(vio)), TSVIOVConnGet(vio), ##__VA_ARGS__)
+#define VIODEBUG(vio, fmt, ...) \
+ VDEBUG("vio=%p vio.cont=%p, vio.cont.data=%p, vio.vc=%p " fmt, (vio), TSVIOContGet(vio), TSContDataGet(TSVIOContGet(vio)), \
+ TSVIOVConnGet(vio), ##__VA_ARGS__)
static TSCont TxnHook;
static TSCont InterceptHook;
-static int InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata);
-static int InterceptTxnHook(TSCont contp, TSEvent event, void * edata);
+static int InterceptInterceptionHook(TSCont contp, TSEvent event, void *edata);
+static int InterceptTxnHook(TSCont contp, TSEvent event, void *edata);
// We are going to stream data between Traffic Server and an
// external server. This structure represents the state of a
// streaming I/O request. Is is directional (ie. either a read or
// a write). We need two of these for each TSVConn; one to push
// data into the TSVConn and one to pull data out.
-struct InterceptIOChannel
-{
- TSVIO vio;
- TSIOBuffer iobuf;
- TSIOBufferReader reader;
+struct InterceptIOChannel {
+ TSVIO vio;
+ TSIOBuffer iobuf;
+ TSIOBufferReader reader;
- InterceptIOChannel() : vio(NULL), iobuf(NULL), reader(NULL) {
- }
+ InterceptIOChannel() : vio(NULL), iobuf(NULL), reader(NULL) {}
- ~InterceptIOChannel() {
+ ~InterceptIOChannel()
+ {
if (this->reader) {
TSIOBufferReaderFree(this->reader);
}
@@ -87,7 +87,9 @@ struct InterceptIOChannel
}
}
- void read(TSVConn vc, TSCont contp) {
+ void
+ read(TSVConn vc, TSCont contp)
+ {
TSReleaseAssert(this->vio == NULL);
TSReleaseAssert((this->iobuf = TSIOBufferCreate()));
TSReleaseAssert((this->reader = TSIOBufferReaderAlloc(this->iobuf)));
@@ -95,25 +97,27 @@ struct InterceptIOChannel
this->vio = TSVConnRead(vc, contp, this->iobuf, INT64_MAX);
}
- void write(TSVConn vc, TSCont contp) {
+ void
+ write(TSVConn vc, TSCont contp)
+ {
TSReleaseAssert(this->vio == NULL);
TSReleaseAssert((this->iobuf = TSIOBufferCreate()));
TSReleaseAssert((this->reader = TSIOBufferReaderAlloc(this->iobuf)));
this->vio = TSVConnWrite(vc, contp, this->reader, INT64_MAX);
}
-
};
// A simple encapsulation of the IO state of a TSVConn. We need the TSVConn itself, and the
// IO metadata for the read side and the write side.
-struct InterceptIO
-{
- TSVConn vc;
- InterceptIOChannel readio;
- InterceptIOChannel writeio;
-
- void close() {
+struct InterceptIO {
+ TSVConn vc;
+ InterceptIOChannel readio;
+ InterceptIOChannel writeio;
+
+ void
+ close()
+ {
if (this->vc) {
TSVConnClose(this->vc);
}
@@ -126,30 +130,27 @@ struct InterceptIO
// Server is the client, and the origin server on whose behalf we
// are intercepting is the server. Hence the "client" and
// "server" nomenclature here.
-struct InterceptState
-{
- TSHttpTxn txn; // The transaction on whose behalf we are intercepting.
+struct InterceptState {
+ TSHttpTxn txn; // The transaction on whose behalf we are intercepting.
- InterceptIO client; // Server intercept VC state.
- InterceptIO server; // Intercept origin VC state.
+ InterceptIO client; // Server intercept VC state.
+ InterceptIO server; // Intercept origin VC state.
- InterceptState() : txn(NULL) {
- }
+ InterceptState() : txn(NULL) {}
- ~InterceptState() {
- }
+ ~InterceptState() {}
};
// Return the InterceptIO control block that owns the given VC.
static InterceptIO *
-InterceptGetThisSide(InterceptState * istate, TSVConn vc)
+InterceptGetThisSide(InterceptState *istate, TSVConn vc)
{
return (istate->client.vc == vc) ? &istate->client : &istate->server;
}
// Return the InterceptIO control block that doesn't own the given VC.
static InterceptIO *
-InterceptGetOtherSide(InterceptState * istate, TSVConn vc)
+InterceptGetOtherSide(InterceptState *istate, TSVConn vc)
{
return (istate->client.vc == vc) ? &istate->server : &istate->client;
}
@@ -157,27 +158,24 @@ InterceptGetOtherSide(InterceptState * istate, TSVConn vc)
// Evaluates to a human-readable name for a TSVConn in the
// intercept proxy state.
static const char *
-InterceptProxySide(const InterceptState * istate, const InterceptIO * io)
+InterceptProxySide(const InterceptState *istate, const InterceptIO *io)
{
- return (io == &istate->client) ? "<client>"
- : (io == &istate->server) ? "<server>"
- : "<unknown>";
+ return (io == &istate->client) ? "<client>" : (io == &istate->server) ? "<server>" : "<unknown>";
}
static const char *
-InterceptProxySideVC(const InterceptState * istate, TSVConn vc)
+InterceptProxySideVC(const InterceptState *istate, TSVConn vc)
{
- return (istate->client.vc && vc == istate->client.vc) ? "<client>"
- : (istate->server.vc && vc == istate->server.vc) ? "<server>"
- : "<unknown>";
+ return (istate->client.vc && vc == istate->client.vc) ? "<client>" : (istate->server.vc && vc == istate->server.vc) ? "<server>" :
+ "<unknown>";
}
static bool
-InterceptAttemptDestroy(InterceptState * istate, TSCont contp)
+InterceptAttemptDestroy(InterceptState *istate, TSCont contp)
{
if (istate->server.vc == NULL && istate->client.vc == NULL) {
VDEBUG("destroying server intercept state istate=%p contp=%p", istate, contp);
- TSContDataSet(contp, NULL); // Force a crash if we get additional events.
+ TSContDataSet(contp, NULL); // Force a crash if we get additional events.
TSContDestroy(contp);
delete istate;
return true;
@@ -188,24 +186,24 @@ InterceptAttemptDestroy(InterceptState * istate, TSCont contp)
union socket_type {
struct sockaddr_storage storage;
- struct sockaddr sa;
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
};
union argument_type {
- void * ptr;
- intptr_t ecode;
- TSVConn vc;
- TSVIO vio;
- TSHttpTxn txn;
- InterceptState * istate;
-
- argument_type(void * _p) : ptr(_p) {}
+ void *ptr;
+ intptr_t ecode;
+ TSVConn vc;
+ TSVIO vio;
+ TSHttpTxn txn;
+ InterceptState *istate;
+
+ argument_type(void *_p) : ptr(_p) {}
};
static TSCont
-InterceptContCreate(TSEventFunc hook, TSMutex mutexp, void * data)
+InterceptContCreate(TSEventFunc hook, TSMutex mutexp, void *data)
{
TSCont contp;
@@ -231,17 +229,17 @@ InterceptShouldInterceptRequest(TSHttpTxn txn)
// should transfer any data we find from one side of the transfer
// to the other.
static int64_t
-InterceptTransferData(InterceptIO * from, InterceptIO * to)
+InterceptTransferData(InterceptIO *from, InterceptIO *to)
{
- TSIOBufferBlock block;
- int64_t consumed = 0;
+ TSIOBufferBlock block;
+ int64_t consumed = 0;
// Walk the list of buffer blocks in from the read VIO.
for (block = TSIOBufferReaderStart(from->readio.reader); block; block = TSIOBufferBlockNext(block)) {
int64_t remain = 0;
- const char * ptr;
+ const char *ptr;
- VDEBUG("attempting to transfer %" PRId64 " available bytes", TSIOBufferBlockReadAvail(block, from->readio.reader));
+ VDEBUG("attempting to transfer %" PRId64 " available bytes", TSIOBufferBlockReadAvail(block, from->readio.reader));
// Take the data from each buffer block, and write it into
// the buffer of the write VIO.
@@ -271,7 +269,7 @@ InterceptTransferData(InterceptIO * from, InterceptIO * to)
// starts with TS_EVENT_NET_ACCEPT, and then continues with
// TSVConn events.
static int
-InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
+InterceptInterceptionHook(TSCont contp, TSEvent event, void *edata)
{
argument_type arg(edata);
@@ -282,10 +280,10 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
// Set up the server intercept. We have the original
// TSHttpTxn from the continuation. We need to connect to the
// real origin and get ready to shuffle data around.
- char buf[INET_ADDRSTRLEN];
+ char buf[INET_ADDRSTRLEN];
socket_type addr;
- argument_type cdata(TSContDataGet(contp));
- InterceptState * istate = new InterceptState();
+ argument_type cdata(TSContDataGet(contp));
+ InterceptState *istate = new InterceptState();
int fd = -1;
// This event is delivered by the continuation that we
@@ -297,8 +295,8 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
// 127.0.0.1:$PORT.
memset(&addr, 0, sizeof(addr));
addr.sin.sin_family = AF_INET;
- addr.sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); // XXX config option
- addr.sin.sin_port = htons(PORT); // XXX config option
+ addr.sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); // XXX config option
+ addr.sin.sin_port = htons(PORT); // XXX config option
// Normally, we would use TSNetConnect to connect to a secondary service, but to demonstrate
// the use of TSVConnFdCreate, we do a blocking connect inline. This it not recommended for
@@ -319,8 +317,8 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
return TS_EVENT_NONE;
}
- VDEBUG("binding client vc=%p to %s:%u",
- istate->client.vc, inet_ntop(AF_INET, &addr.sin.sin_addr, buf, sizeof(buf)), (unsigned)ntohs(addr.sin.sin_port));
+ VDEBUG("binding client vc=%p to %s:%u", istate->client.vc, inet_ntop(AF_INET, &addr.sin.sin_addr, buf, sizeof(buf)),
+ (unsigned)ntohs(addr.sin.sin_port));
istate->txn = cdata.txn;
istate->client.vc = arg.vc;
@@ -373,14 +371,15 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
case TS_EVENT_VCONN_READ_READY: {
argument_type cdata = TSContDataGet(contp);
- TSVConn vc = TSVIOVConnGet(arg.vio);
- InterceptIO * from = InterceptGetThisSide(cdata.istate, vc);
- InterceptIO * to = InterceptGetOtherSide(cdata.istate, vc);;
- int64_t nbytes;
+ TSVConn vc = TSVIOVConnGet(arg.vio);
+ InterceptIO *from = InterceptGetThisSide(cdata.istate, vc);
+ InterceptIO *to = InterceptGetOtherSide(cdata.istate, vc);
+ ;
+ int64_t nbytes;
VIODEBUG(arg.vio, "ndone=%" PRId64 " ntodo=%" PRId64, TSVIONDoneGet(arg.vio), TSVIONTodoGet(arg.vio));
- VDEBUG("reading vio=%p vc=%p, istate=%p is bound to client vc=%p and server vc=%p",
- arg.vio, TSVIOVConnGet(arg.vio), cdata.istate, cdata.istate->client.vc, cdata.istate->server.vc);
+ VDEBUG("reading vio=%p vc=%p, istate=%p is bound to client vc=%p and server vc=%p", arg.vio, TSVIOVConnGet(arg.vio),
+ cdata.istate, cdata.istate->client.vc, cdata.istate->server.vc);
if (to->vc == NULL) {
VDEBUG("closing %s vc=%p", InterceptProxySide(cdata.istate, from), from->vc);
@@ -396,8 +395,8 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
return TS_EVENT_NONE;
}
- VDEBUG("reading from %s (vc=%p), writing to %s (vc=%p)",
- InterceptProxySide(cdata.istate, from), from->vc, InterceptProxySide(cdata.istate, to), to->vc);
+ VDEBUG("reading from %s (vc=%p), writing to %s (vc=%p)", InterceptProxySide(cdata.istate, from), from->vc,
+ InterceptProxySide(cdata.istate, to), to->vc);
nbytes = InterceptTransferData(from, to);
@@ -406,7 +405,7 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
TSVIO writeio = to->writeio.vio;
VIODEBUG(writeio, "WRITE VIO ndone=%" PRId64 " ntodo=%" PRId64, TSVIONDoneGet(writeio), TSVIONTodoGet(writeio));
TSVIOReenable(from->readio.vio); // Re-enable the read side.
- TSVIOReenable(to->writeio.vio); // Reenable the write side.
+ TSVIOReenable(to->writeio.vio); // Reenable the write side.
}
return TS_EVENT_NONE;
@@ -419,15 +418,16 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
// The exception is where one side of the proxied connection
// has been closed. Then we want to close the other side.
argument_type cdata = TSContDataGet(contp);
- TSVConn vc = TSVIOVConnGet(arg.vio);
- InterceptIO * to = InterceptGetThisSide(cdata.istate, vc);
- InterceptIO * from = InterceptGetOtherSide(cdata.istate, vc);;
+ TSVConn vc = TSVIOVConnGet(arg.vio);
+ InterceptIO *to = InterceptGetThisSide(cdata.istate, vc);
+ InterceptIO *from = InterceptGetOtherSide(cdata.istate, vc);
+ ;
// If the other side is closed, close this side too, but only if there
// we have drained the write buffer.
if (from->vc == NULL) {
- VDEBUG("closing %s vc=%p with %" PRId64 " bytes to left",
- InterceptProxySide(cdata.istate, to), to->vc, TSIOBufferReaderAvail(to->writeio.reader));
+ VDEBUG("closing %s vc=%p with %" PRId64 " bytes to left", InterceptProxySide(cdata.istate, to), to->vc,
+ TSIOBufferReaderAvail(to->writeio.reader));
if (TSIOBufferReaderAvail(to->writeio.reader) == 0) {
to->close();
}
@@ -447,26 +447,27 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
// to receiving EOS from the intercepted origin server, and
// when handling errors.
- TSVConn vc = TSVIOVConnGet(arg.vio);
+ TSVConn vc = TSVIOVConnGet(arg.vio);
argument_type cdata = TSContDataGet(contp);
- InterceptIO * from = InterceptGetThisSide(cdata.istate, vc);
- InterceptIO * to = InterceptGetOtherSide(cdata.istate, vc);;
+ InterceptIO *from = InterceptGetThisSide(cdata.istate, vc);
+ InterceptIO *to = InterceptGetOtherSide(cdata.istate, vc);
+ ;
VIODEBUG(arg.vio, "received EOS or ERROR from %s side", InterceptProxySideVC(cdata.istate, vc));
// Close the side that we received the EOS event from.
if (from) {
- VDEBUG("%s writeio has %" PRId64 " bytes left",
- InterceptProxySide(cdata.istate, from), TSIOBufferReaderAvail(from->writeio.reader));
+ VDEBUG("%s writeio has %" PRId64 " bytes left", InterceptProxySide(cdata.istate, from),
+ TSIOBufferReaderAvail(from->writeio.reader));
from->close();
}
// Should we also close the other side? Well, that depends on whether the reader
// has drained the data. If we close too early they will see a truncated read.
if (to) {
- VDEBUG("%s writeio has %" PRId64 " bytes left",
- InterceptProxySide(cdata.istate, to), TSIOBufferReaderAvail(to->writeio.reader));
+ VDEBUG("%s writeio has %" PRId64 " bytes left", InterceptProxySide(cdata.istate, to),
+ TSIOBufferReaderAvail(to->writeio.reader));
if (TSIOBufferReaderAvail(to->writeio.reader) == 0) {
to->close();
}
@@ -500,14 +501,14 @@ InterceptInterceptionHook(TSCont contp, TSEvent event, void * edata)
// Handle events that occur on the TSHttpTxn.
static int
-InterceptTxnHook(TSCont contp, TSEvent event, void * edata)
+InterceptTxnHook(TSCont contp, TSEvent event, void *edata)
{
argument_type arg(edata);
VDEBUG("contp=%p, event=%s (%d), edata=%p", contp, TSHttpEventNameLookup(event), event, arg.ptr);
switch (event) {
- case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE: {
+ case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE: {
if (InterceptShouldInterceptRequest(arg.txn)) {
TSCont c = InterceptContCreate(InterceptInterceptionHook, TSMutexCreate(), arg.txn);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/lifecycle-plugin/lifecycle-plugin.c
----------------------------------------------------------------------
diff --git a/example/lifecycle-plugin/lifecycle-plugin.c b/example/lifecycle-plugin/lifecycle-plugin.c
index 1b16a1c..5f1ed3e 100644
--- a/example/lifecycle-plugin/lifecycle-plugin.c
+++ b/example/lifecycle-plugin/lifecycle-plugin.c
@@ -30,9 +30,10 @@
#include <ts/ts.h>
int
-CallbackHandler(TSCont this, TSEvent id, void* no_data) {
- (void) this;
- (void) no_data;
+CallbackHandler(TSCont this, TSEvent id, void *no_data)
+{
+ (void)this;
+ (void)no_data;
switch (id) {
case TS_EVENT_LIFECYCLE_PORTS_INITIALIZED:
TSDebug("lifecycle-plugin", "Proxy ports initialized");
@@ -67,9 +68,7 @@ CheckVersion()
/* Need at least TS 3.3.5 */
if (major_ts_version > 3 ||
- (major_ts_version == 3 &&
- (minor_ts_version > 3 ||
- (minor_ts_version == 3 && patch_ts_version >= 5)))) {
+ (major_ts_version == 3 && (minor_ts_version > 3 || (minor_ts_version == 3 && patch_ts_version >= 5)))) {
result = 1;
}
}
@@ -95,7 +94,8 @@ TSPluginInit(int argc, const char *argv[])
}
if (!CheckVersion()) {
- TSError("[lifecycle-plugin] Plugin requires Traffic Server 3.3.5 " "or later\n");
+ TSError("[lifecycle-plugin] Plugin requires Traffic Server 3.3.5 "
+ "or later\n");
goto Lerror;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/null-transform/null-transform.c
----------------------------------------------------------------------
diff --git a/example/null-transform/null-transform.c b/example/null-transform/null-transform.c
index 2c23dea..d5b94d4 100644
--- a/example/null-transform/null-transform.c
+++ b/example/null-transform/null-transform.c
@@ -38,8 +38,7 @@
#include "ts/ts.h"
#include "ink_defs.h"
-typedef struct
-{
+typedef struct {
TSVIO output_vio;
TSIOBuffer output_buffer;
TSIOBufferReader output_reader;
@@ -50,7 +49,7 @@ my_data_alloc()
{
MyData *data;
- data = (MyData *) TSmalloc(sizeof(MyData));
+ data = (MyData *)TSmalloc(sizeof(MyData));
data->output_vio = NULL;
data->output_buffer = NULL;
data->output_reader = NULL;
@@ -59,7 +58,7 @@ my_data_alloc()
}
static void
-my_data_destroy(MyData * data)
+my_data_destroy(MyData *data)
{
if (data) {
if (data->output_buffer)
@@ -102,7 +101,7 @@ handle_transform(TSCont contp)
data->output_buffer = TSIOBufferCreate();
data->output_reader = TSIOBufferReaderAlloc(data->output_buffer);
TSDebug("null-transform", "\tWriting %" PRId64 " bytes on VConn", TSVIONBytesGet(input_vio));
- //data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT32_MAX);
+ // data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT32_MAX);
data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT64_MAX);
// data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, TSVIONBytesGet(input_vio));
TSContDataSet(contp, data);
@@ -206,23 +205,21 @@ null_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
return 0;
} else {
switch (event) {
- case TS_EVENT_ERROR:
- {
- TSVIO input_vio;
-
- TSDebug("null-transform", "\tEvent is TS_EVENT_ERROR");
- /* Get the write VIO for the write operation that was
- * performed on ourself. This VIO contains the continuation of
- * our parent transformation. This is the input VIO.
- */
- input_vio = TSVConnWriteVIOGet(contp);
-
- /* Call back the write VIO continuation to let it know that we
- * have completed the write operation.
- */
- TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
- }
- break;
+ case TS_EVENT_ERROR: {
+ TSVIO input_vio;
+
+ TSDebug("null-transform", "\tEvent is TS_EVENT_ERROR");
+ /* Get the write VIO for the write operation that was
+ * performed on ourself. This VIO contains the continuation of
+ * our parent transformation. This is the input VIO.
+ */
+ input_vio = TSVConnWriteVIOGet(contp);
+
+ /* Call back the write VIO continuation to let it know that we
+ * have completed the write operation.
+ */
+ TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
+ } break;
case TS_EVENT_VCONN_WRITE_COMPLETE:
TSDebug("null-transform", "\tEvent is TS_EVENT_VCONN_WRITE_COMPLETE");
/* When our output connection says that it has finished
@@ -267,7 +264,8 @@ transformable(TSHttpTxn txnp)
retv = (resp_status == TS_HTTP_STATUS_OK);
if (TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc) == TS_ERROR) {
- TSError("[null-transform] Error releasing MLOC while checking " "header status\n");
+ TSError("[null-transform] Error releasing MLOC while checking "
+ "header status\n");
}
TSDebug("null-transform", "Exiting transformable with return %d", retv);
@@ -287,7 +285,7 @@ transform_add(TSHttpTxn txnp)
static int
transform_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
{
- TSHttpTxn txnp = (TSHttpTxn) edata;
+ TSHttpTxn txnp = (TSHttpTxn)edata;
TSDebug("null-transform", "Entering transform_plugin()");
switch (event) {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/output-header/output-header.c
----------------------------------------------------------------------
diff --git a/example/output-header/output-header.c b/example/output-header/output-header.c
index 34a7b81..56ca24e 100644
--- a/example/output-header/output-header.c
+++ b/example/output-header/output-header.c
@@ -84,7 +84,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp ATS_UNUSED)
/* Allocate the string with an extra byte for the string
terminator */
- output_string = (char *) TSmalloc(total_avail + 1);
+ output_string = (char *)TSmalloc(total_avail + 1);
output_len = 0;
/* We need to loop over all the buffer blocks to make
@@ -135,7 +135,7 @@ done:
static int
hdr_plugin(TSCont contp, TSEvent event, void *edata)
{
- TSHttpTxn txnp = (TSHttpTxn) edata;
+ TSHttpTxn txnp = (TSHttpTxn)edata;
switch (event) {
case TS_EVENT_HTTP_OS_DNS:
@@ -167,4 +167,3 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
error:
TSError("[PluginInit] Plugin not initialized");
}
-
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/prefetch/prefetch-plugin-eg1.c
----------------------------------------------------------------------
diff --git a/example/prefetch/prefetch-plugin-eg1.c b/example/prefetch/prefetch-plugin-eg1.c
index 72013dc..61d7a21 100644
--- a/example/prefetch/prefetch-plugin-eg1.c
+++ b/example/prefetch/prefetch-plugin-eg1.c
@@ -33,9 +33,9 @@
#include <ts/experimental.h>
TSPrefetchReturnCode
-my_preparse_hook(TSPrefetchHookID hook, TSPrefetchInfo * info)
+my_preparse_hook(TSPrefetchHookID hook, TSPrefetchInfo *info)
{
- unsigned char *ip = (unsigned char *) &info->client_ip;
+ unsigned char *ip = (unsigned char *)&info->client_ip;
printf("preparse hook (%d): request from child %u.%u.%u.%u\n", hook, ip[0], ip[1], ip[2], ip[3]);
@@ -45,13 +45,12 @@ my_preparse_hook(TSPrefetchHookID hook, TSPrefetchInfo * info)
}
TSPrefetchReturnCode
-my_embedded_url_hook(TSPrefetchHookID hook, TSPrefetchInfo * info)
+my_embedded_url_hook(TSPrefetchHookID hook, TSPrefetchInfo *info)
{
+ unsigned char *ip = (unsigned char *)&info->client_ip;
- unsigned char *ip = (unsigned char *) &info->client_ip;
-
- printf("url hook (%d): url: %s %s child: %u.%u.%u.%u\n",
- hook, info->embedded_url, (info->present_in_cache) ? "(present in cache)" : "", ip[0], ip[1], ip[2], ip[3]);
+ printf("url hook (%d): url: %s %s child: %u.%u.%u.%u\n", hook, info->embedded_url,
+ (info->present_in_cache) ? "(present in cache)" : "", ip[0], ip[1], ip[2], ip[3]);
/*
We will select UDP for sending url and TCP for sending object
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/prefetch/test-hns-plugin.c
----------------------------------------------------------------------
diff --git a/example/prefetch/test-hns-plugin.c b/example/prefetch/test-hns-plugin.c
index e1da4c9..7d33b44 100644
--- a/example/prefetch/test-hns-plugin.c
+++ b/example/prefetch/test-hns-plugin.c
@@ -78,7 +78,7 @@ static TSMutex file_write_mutex;
TSPrefetchReturnCode
-embedded_object_hook(TSPrefetchHookID hook, TSPrefetchInfo * info)
+embedded_object_hook(TSPrefetchHookID hook, TSPrefetchInfo *info)
{
TSIOBufferBlock block;
const char *block_start;
@@ -88,8 +88,8 @@ embedded_object_hook(TSPrefetchHookID hook, TSPrefetchInfo * info)
printf("(%s) >>> TS_PREFETCH_EMBEDDED_OBJECT_HOOK (%d)\n", TAG, hook);
- printf("(%s) \tobject size for: %s is %lld\n",
- TAG, info->embedded_url, (long long)TSIOBufferReaderAvail(info->object_buf_reader));
+ printf("(%s) \tobject size for: %s is %lld\n", TAG, info->embedded_url,
+ (long long)TSIOBufferReaderAvail(info->object_buf_reader));
/* Get the embedded objects here */
total_avail = TSIOBufferReaderAvail(info->object_buf_reader);
@@ -120,20 +120,18 @@ embedded_object_hook(TSPrefetchHookID hook, TSPrefetchInfo * info)
}
TSPrefetchReturnCode
-embedded_url_hook(TSPrefetchHookID hook, TSPrefetchInfo* info)
+embedded_url_hook(TSPrefetchHookID hook, TSPrefetchInfo *info)
{
-
- unsigned char *ip = (unsigned char *) &info->client_ip;
+ unsigned char *ip = (unsigned char *)&info->client_ip;
printf("(%s) >>> TS_PREFETCH_EMBEDDED_URL_HOOK (%d)\n", TAG, hook);
- printf("(%s) \tURL: %s %s Child IP: %u.%u.%u.%u\n",
- TAG, info->embedded_url, (info->present_in_cache) ? "(present in cache)" : "", ip[0], ip[1], ip[2], ip[3]);
+ printf("(%s) \tURL: %s %s Child IP: %u.%u.%u.%u\n", TAG, info->embedded_url, (info->present_in_cache) ? "(present in cache)" : "",
+ ip[0], ip[1], ip[2], ip[3]);
/* We will select UDP for sending url and TCP for sending object */
if (embedded_object)
- info->object_buf_status = (embedded_object == 1)
- ? TS_PREFETCH_OBJ_BUF_NEEDED : TS_PREFETCH_OBJ_BUF_NEEDED_N_TRANSMITTED;
+ info->object_buf_status = (embedded_object == 1) ? TS_PREFETCH_OBJ_BUF_NEEDED : TS_PREFETCH_OBJ_BUF_NEEDED_N_TRANSMITTED;
if (url_proto)
info->url_response_proto = TS_PREFETCH_PROTO_TCP;
else
@@ -156,9 +154,9 @@ embedded_url_hook(TSPrefetchHookID hook, TSPrefetchInfo* info)
TSPrefetchReturnCode
-pre_parse_hook(TSPrefetchHookID hook, TSPrefetchInfo* info)
+pre_parse_hook(TSPrefetchHookID hook, TSPrefetchInfo *info)
{
- unsigned char *ip = (unsigned char *) &info->client_ip;
+ unsigned char *ip = (unsigned char *)&info->client_ip;
printf("(%s) >>> TS_PREFETCH_PRE_PARSE_HOOK (%d)\n", TAG, hook);
@@ -177,14 +175,13 @@ pre_parse_hook(TSPrefetchHookID hook, TSPrefetchInfo* info)
}
-
void
TSPluginInit(int argc, const char *argv[])
{
int c, arg;
extern char *optarg;
TSPluginRegistrationInfo plugin_info;
- char file_name[512] = { 0 };
+ char file_name[512] = {0};
plugin_info.plugin_name = "test-prefetch";
plugin_info.vendor_name = "MyCompany";
plugin_info.support_email = "ts-api-support@MyCompany.com";
@@ -194,7 +191,7 @@ TSPluginInit(int argc, const char *argv[])
return;
}
- while ((c = getopt(argc, (char *const *) argv, "p:u:i:o:d:")) != EOF) {
+ while ((c = getopt(argc, (char *const *)argv, "p:u:i:o:d:")) != EOF) {
switch (c) {
case 'p':
case 'u':
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/protocol/Protocol.c
----------------------------------------------------------------------
diff --git a/example/protocol/Protocol.c b/example/protocol/Protocol.c
index d065c9d..0151c68 100644
--- a/example/protocol/Protocol.c
+++ b/example/protocol/Protocol.c
@@ -50,8 +50,8 @@ accept_handler(TSCont contp, TSEvent event, void *edata)
case TS_EVENT_NET_ACCEPT:
/* Create a new mutex for the TxnSM, which is going
to handle the incoming request. */
- pmutex = (TSMutex) TSMutexCreate();
- txn_sm = (TSCont) TxnSMCreate(pmutex, (TSVConn) edata, server_port);
+ pmutex = (TSMutex)TSMutexCreate();
+ txn_sm = (TSCont)TxnSMCreate(pmutex, (TSVConn)edata, server_port);
/* This is no reason for not grabbing the lock.
So skip the routine which handle LockTry failure case. */
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/protocol/Protocol.h
----------------------------------------------------------------------
diff --git a/example/protocol/Protocol.h b/example/protocol/Protocol.h
index aeddd0d..d45efbc 100644
--- a/example/protocol/Protocol.h
+++ b/example/protocol/Protocol.h
@@ -41,7 +41,10 @@
/* MAX_SERVER_NAME_LENGTH + MAX_FILE_NAME_LENGTH + strlen("\n\n") */
#define MAX_REQUEST_LENGTH 2050
-#define set_handler(_d, _s) {_d = _s;}
+#define set_handler(_d, _s) \
+ { \
+ _d = _s; \
+ }
#endif /* PROTOCOL_H */
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/protocol/TxnSM.c
----------------------------------------------------------------------
diff --git a/example/protocol/TxnSM.c b/example/protocol/TxnSM.c
index 98eafaf..d9c2b29 100644
--- a/example/protocol/TxnSM.c
+++ b/example/protocol/TxnSM.c
@@ -72,7 +72,7 @@ TSCacheKey CacheKeyCreate(char *file_name);
int
main_handler(TSCont contp, TSEvent event, void *data)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TxnSMHandler q_current_handler = txn_sm->q_current_handler;
TSDebug("protocol", "main_handler (contp %p event %d)", contp, event);
@@ -90,7 +90,7 @@ main_handler(TSCont contp, TSEvent event, void *data)
TSDebug("protocol", "current_handler (%p)", q_current_handler);
- return (*q_current_handler) (contp, event, data);
+ return (*q_current_handler)(contp, event, data);
}
/* Create the Txn data structure and the continuation for the Txn. */
@@ -100,7 +100,7 @@ TxnSMCreate(TSMutex pmutex, TSVConn client_vc, int server_port)
TSCont contp;
TxnSM *txn_sm;
- txn_sm = (TxnSM *) TSmalloc(sizeof(TxnSM));
+ txn_sm = (TxnSM *)TSmalloc(sizeof(TxnSM));
txn_sm->q_mutex = pmutex;
txn_sm->q_pending_action = NULL;
@@ -126,7 +126,7 @@ TxnSMCreate(TSMutex pmutex, TSVConn client_vc, int server_port)
txn_sm->q_server_request_buffer_reader = NULL;
/* Char buffers to store client request and server response. */
- txn_sm->q_client_request = (char *) TSmalloc(sizeof(char) * (MAX_REQUEST_LENGTH + 1));
+ txn_sm->q_client_request = (char *)TSmalloc(sizeof(char) * (MAX_REQUEST_LENGTH + 1));
memset(txn_sm->q_client_request, '\0', (sizeof(char) * (MAX_REQUEST_LENGTH + 1)));
txn_sm->q_server_response = NULL;
txn_sm->q_server_response_length = 0;
@@ -136,8 +136,8 @@ TxnSMCreate(TSMutex pmutex, TSVConn client_vc, int server_port)
txn_sm->q_cache_read_buffer = NULL;
txn_sm->q_cache_read_buffer_reader = NULL;
- txn_sm->q_server_name = (char *) TSmalloc(sizeof(char) * (MAX_SERVER_NAME_LENGTH + 1));
- txn_sm->q_file_name = (char *) TSmalloc(sizeof(char) * (MAX_FILE_NAME_LENGTH + 1));
+ txn_sm->q_server_name = (char *)TSmalloc(sizeof(char) * (MAX_SERVER_NAME_LENGTH + 1));
+ txn_sm->q_file_name = (char *)TSmalloc(sizeof(char) * (MAX_FILE_NAME_LENGTH + 1));
txn_sm->q_key = NULL;
txn_sm->q_magic = TXN_SM_ALIVE;
@@ -154,7 +154,7 @@ TxnSMCreate(TSMutex pmutex, TSVConn client_vc, int server_port)
int
state_start(TSCont contp, TSEvent event ATS_UNUSED, void *data ATS_UNUSED)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
if (!txn_sm->q_client_vc) {
return prepare_to_die(contp);
@@ -173,7 +173,7 @@ state_start(TSCont contp, TSEvent event ATS_UNUSED, void *data ATS_UNUSED)
INT64_MAX, so that we will always get TS_EVENT_VCONN_READ_READY
event, but never TS_EVENT_VCONN_READ_COMPLETE event. */
set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_interface_with_client);
- txn_sm->q_client_read_vio = TSVConnRead(txn_sm->q_client_vc, (TSCont) contp, txn_sm->q_client_request_buffer, INT64_MAX);
+ txn_sm->q_client_read_vio = TSVConnRead(txn_sm->q_client_vc, (TSCont)contp, txn_sm->q_client_request_buffer, INT64_MAX);
return TS_SUCCESS;
}
@@ -188,7 +188,7 @@ state_start(TSCont contp, TSEvent event ATS_UNUSED, void *data ATS_UNUSED)
int
state_interface_with_client(TSCont contp, TSEvent event, TSVIO vio)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_interface_with_client");
@@ -209,7 +209,7 @@ state_read_request_from_client(TSCont contp, TSEvent event, TSVIO vio ATS_UNUSED
int bytes_read, parse_result;
char *temp_buf;
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_read_request_from_client");
@@ -218,13 +218,13 @@ state_read_request_from_client(TSCont contp, TSEvent event, TSVIO vio ATS_UNUSED
bytes_read = TSIOBufferReaderAvail(txn_sm->q_client_request_buffer_reader);
if (bytes_read > 0) {
- temp_buf = (char *) get_info_from_buffer(txn_sm->q_client_request_buffer_reader);
+ temp_buf = (char *)get_info_from_buffer(txn_sm->q_client_request_buffer_reader);
TSstrlcat(txn_sm->q_client_request, temp_buf, MAX_REQUEST_LENGTH + 1);
TSfree(temp_buf);
/* Check if the request is fully read, if so, do cache lookup. */
if (strstr(txn_sm->q_client_request, "\r\n\r\n") != NULL) {
- temp_buf = (char *) TSmalloc(sizeof(char) * (strlen(txn_sm->q_client_request) + 1));
+ temp_buf = (char *)TSmalloc(sizeof(char) * (strlen(txn_sm->q_client_request) + 1));
memcpy(temp_buf, txn_sm->q_client_request, strlen(txn_sm->q_client_request));
temp_buf[strlen(txn_sm->q_client_request)] = '\0';
parse_result = parse_request(temp_buf, txn_sm->q_server_name, txn_sm->q_file_name);
@@ -248,9 +248,8 @@ state_read_request_from_client(TSCont contp, TSEvent event, TSVIO vio ATS_UNUSED
TSVIOReenable(txn_sm->q_client_read_vio);
break;
- default: /* Shouldn't get here, prepare to die. */
+ default: /* Shouldn't get here, prepare to die. */
return prepare_to_die(contp);
-
}
return TS_SUCCESS;
}
@@ -261,7 +260,7 @@ state_read_request_from_client(TSCont contp, TSEvent event, TSVIO vio ATS_UNUSED
int
state_handle_cache_lookup(TSCont contp, TSEvent event, TSVConn vc)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
int64_t response_size;
int ret_val;
@@ -289,9 +288,8 @@ state_handle_cache_lookup(TSCont contp, TSEvent event, TSVConn vc)
txn_sm->q_cache_read_buffer = TSIOBufferCreate();
txn_sm->q_cache_read_buffer_reader = TSIOBufferReaderAlloc(txn_sm->q_cache_read_buffer);
- if (!txn_sm->q_client_response_buffer ||
- !txn_sm->q_client_response_buffer_reader ||
- !txn_sm->q_cache_read_buffer || !txn_sm->q_cache_read_buffer_reader) {
+ if (!txn_sm->q_client_response_buffer || !txn_sm->q_client_response_buffer_reader || !txn_sm->q_cache_read_buffer ||
+ !txn_sm->q_cache_read_buffer_reader) {
return prepare_to_die(contp);
}
@@ -323,7 +321,7 @@ state_handle_cache_lookup(TSCont contp, TSEvent event, TSVConn vc)
}
static void
-load_buffer_cache_data(TxnSM * txn_sm)
+load_buffer_cache_data(TxnSM *txn_sm)
{
/* transfer the data from the cache buffer (which must
fully be consumed on a VCONN_READY event, to the
@@ -335,9 +333,9 @@ load_buffer_cache_data(TxnSM * txn_sm)
TSAssert(rdr_avail > 0);
- TSIOBufferCopy(txn_sm->q_client_response_buffer, /* (cache response buffer) */
- txn_sm->q_cache_read_buffer_reader, /* (transient buffer) */
- rdr_avail, 0);
+ TSIOBufferCopy(txn_sm->q_client_response_buffer, /* (cache response buffer) */
+ txn_sm->q_cache_read_buffer_reader, /* (transient buffer) */
+ rdr_avail, 0);
TSIOBufferReaderConsume(txn_sm->q_cache_read_buffer_reader, rdr_avail);
}
@@ -350,7 +348,7 @@ load_buffer_cache_data(TxnSM * txn_sm)
int
state_handle_cache_read_response(TSCont contp, TSEvent event, TSVIO vio ATS_UNUSED)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_handle_cache_read_response");
@@ -390,7 +388,6 @@ state_handle_cache_read_response(TSCont contp, TSEvent event, TSVIO vio ATS_UNUS
TSAssert(txn_sm->q_pending_action == NULL);
txn_sm->q_pending_action = TSCacheWrite(contp, txn_sm->q_key);
break;
-
}
return TS_SUCCESS;
}
@@ -401,7 +398,7 @@ state_handle_cache_read_response(TSCont contp, TSEvent event, TSVIO vio ATS_UNUS
int
state_handle_cache_prepare_for_write(TSCont contp, TSEvent event, TSVConn vc)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_handle_cache_prepare_for_write");
@@ -425,7 +422,7 @@ state_handle_cache_prepare_for_write(TSCont contp, TSEvent event, TSVConn vc)
int
state_build_and_send_request(TSCont contp, TSEvent event ATS_UNUSED, void *data ATS_UNUSED)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_build_and_send_request");
@@ -437,9 +434,8 @@ state_build_and_send_request(TSCont contp, TSEvent event ATS_UNUSED, void *data
txn_sm->q_server_response_buffer = TSIOBufferCreate();
txn_sm->q_cache_response_buffer_reader = TSIOBufferReaderAlloc(txn_sm->q_server_response_buffer);
- if (!txn_sm->q_server_request_buffer ||
- !txn_sm->q_server_request_buffer_reader ||
- !txn_sm->q_server_response_buffer || !txn_sm->q_cache_response_buffer_reader) {
+ if (!txn_sm->q_server_request_buffer || !txn_sm->q_server_request_buffer_reader || !txn_sm->q_server_response_buffer ||
+ !txn_sm->q_cache_response_buffer_reader) {
return prepare_to_die(contp);
}
@@ -461,8 +457,8 @@ state_build_and_send_request(TSCont contp, TSEvent event ATS_UNUSED, void *data
int
state_dns_lookup(TSCont contp, TSEvent event, TSHostLookupResult host_info)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
- struct sockaddr const* q_server_addr;
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
+ struct sockaddr const *q_server_addr;
struct sockaddr_in ip_addr;
TSDebug("protocol", "enter state_dns_lookup");
@@ -483,7 +479,7 @@ state_dns_lookup(TSCont contp, TSEvent event, TSHostLookupResult host_info)
memcpy(&ip_addr, q_server_addr, sizeof(ip_addr));
ip_addr.sin_port = txn_sm->q_server_port;
- txn_sm->q_pending_action = TSNetConnect(contp, (struct sockaddr const*)&ip_addr);
+ txn_sm->q_pending_action = TSNetConnect(contp, (struct sockaddr const *)&ip_addr);
return TS_SUCCESS;
}
@@ -496,7 +492,7 @@ state_dns_lookup(TSCont contp, TSEvent event, TSHostLookupResult host_info)
int
state_connect_to_server(TSCont contp, TSEvent event, TSVConn vc)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_connect_to_server");
@@ -512,8 +508,8 @@ state_connect_to_server(TSCont contp, TSEvent event, TSVConn vc)
set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_send_request_to_server);
/* Actively write the request to the net_vc. */
- txn_sm->q_server_write_vio = TSVConnWrite(txn_sm->q_server_vc, contp,
- txn_sm->q_server_request_buffer_reader, strlen(txn_sm->q_client_request));
+ txn_sm->q_server_write_vio =
+ TSVConnWrite(txn_sm->q_server_vc, contp, txn_sm->q_server_request_buffer_reader, strlen(txn_sm->q_client_request));
return TS_SUCCESS;
}
@@ -522,7 +518,7 @@ state_connect_to_server(TSCont contp, TSEvent event, TSVConn vc)
int
state_send_request_to_server(TSCont contp, TSEvent event, TSVIO vio)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_send_request_to_server");
@@ -538,7 +534,7 @@ state_send_request_to_server(TSCont contp, TSEvent event, TSVIO vio)
txn_sm->q_server_read_vio = TSVConnRead(txn_sm->q_server_vc, contp, txn_sm->q_server_response_buffer, INT64_MAX);
break;
- /* it could be failure of TSNetConnect */
+ /* it could be failure of TSNetConnect */
default:
return prepare_to_die(contp);
}
@@ -549,25 +545,25 @@ state_send_request_to_server(TSCont contp, TSEvent event, TSVIO vio)
int
state_interface_with_server(TSCont contp, TSEvent event, TSVIO vio)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_interface_with_server");
txn_sm->q_pending_action = NULL;
switch (event) {
- /* This is returned from cache_vc. */
+ /* This is returned from cache_vc. */
case TS_EVENT_VCONN_WRITE_READY:
case TS_EVENT_VCONN_WRITE_COMPLETE:
return state_write_to_cache(contp, event, vio);
- /* Otherwise, handle events from server. */
+ /* Otherwise, handle events from server. */
case TS_EVENT_VCONN_READ_READY:
- /* Actually, we shouldn't get READ_COMPLETE because we set bytes
- count to be INT64_MAX. */
+ /* Actually, we shouldn't get READ_COMPLETE because we set bytes
+ count to be INT64_MAX. */
case TS_EVENT_VCONN_READ_COMPLETE:
return state_read_response_from_server(contp, event, vio);
- /* all data of the response come in. */
+ /* all data of the response come in. */
case TS_EVENT_VCONN_EOS:
TSDebug("protocol", "get server eos");
/* There is no more use of server_vc, close it. */
@@ -607,10 +603,10 @@ state_interface_with_server(TSCont contp, TSEvent event, TSVIO vio)
/* Open cache_vc to read data and send to client. */
set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_handle_cache_lookup);
txn_sm->q_pending_action = TSCacheRead(contp, txn_sm->q_key);
- } else { /* not done with writing into cache */
+ } else { /* not done with writing into cache */
TSDebug("protocol", "cache_response_length is %d, server response length is %d", txn_sm->q_cache_response_length,
- txn_sm->q_server_response_length);
+ txn_sm->q_server_response_length);
TSVIOReenable(txn_sm->q_cache_write_vio);
}
@@ -630,7 +626,7 @@ state_interface_with_server(TSCont contp, TSEvent event, TSVIO vio)
int
state_read_response_from_server(TSCont contp, TSEvent event ATS_UNUSED, TSVIO vio ATS_UNUSED)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
int bytes_read = 0;
TSDebug("protocol", "enter state_read_response_from_server");
@@ -641,18 +637,17 @@ state_read_response_from_server(TSCont contp, TSEvent event ATS_UNUSED, TSVIO vi
/* If this is the first write, do TSVConnWrite, otherwise, simply
reenable q_cache_write_vio. */
if (txn_sm->q_server_response_length == 0) {
- txn_sm->q_cache_write_vio = TSVConnWrite(txn_sm->q_cache_vc,
- contp, txn_sm->q_cache_response_buffer_reader, bytes_read);
+ txn_sm->q_cache_write_vio = TSVConnWrite(txn_sm->q_cache_vc, contp, txn_sm->q_cache_response_buffer_reader, bytes_read);
} else {
TSAssert(txn_sm->q_server_response_length > 0);
TSVIOReenable(txn_sm->q_cache_write_vio);
txn_sm->q_block_bytes_read = bytes_read;
-/*
- txn_sm->q_cache_write_vio = TSVConnWrite (txn_sm->q_cache_vc,
- contp,
- txn_sm->q_cache_response_buffer_reader,
- bytes_read);
- */
+ /*
+ txn_sm->q_cache_write_vio = TSVConnWrite (txn_sm->q_cache_vc,
+ contp,
+ txn_sm->q_cache_response_buffer_reader,
+ bytes_read);
+ */
}
}
@@ -667,7 +662,7 @@ state_read_response_from_server(TSCont contp, TSEvent event ATS_UNUSED, TSVIO vi
int
state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_write_to_cache");
@@ -695,7 +690,7 @@ state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio)
if (txn_sm->q_cache_response_length >= txn_sm->q_server_response_length) {
/* Write is complete, close the cache_vc. */
TSDebug("protocol", "close cache_vc, cache_response_length is %d, server_response_lenght is %d",
- txn_sm->q_cache_response_length, txn_sm->q_server_response_length);
+ txn_sm->q_cache_response_length, txn_sm->q_server_response_length);
TSVConnClose(txn_sm->q_cache_vc);
txn_sm->q_cache_vc = NULL;
txn_sm->q_cache_write_vio = NULL;
@@ -704,7 +699,7 @@ state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio)
/* Open cache_vc to read data and send to client. */
set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_handle_cache_lookup);
txn_sm->q_pending_action = TSCacheRead(contp, txn_sm->q_key);
- } else { /* not done with writing into cache */
+ } else { /* not done with writing into cache */
TSDebug("protocol", "re-enable cache_write_vio");
TSVIOReenable(txn_sm->q_cache_write_vio);
@@ -724,14 +719,14 @@ state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio)
int
state_send_response_to_client(TSCont contp, TSEvent event, TSVIO vio)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_send_response_to_client");
switch (event) {
case TS_EVENT_VCONN_WRITE_READY:
TSDebug("protocol", " . wr ready");
- TSDebug("protocol", "write_ready: nbytes %" PRId64", ndone %" PRId64, TSVIONBytesGet(vio), TSVIONDoneGet(vio));
+ TSDebug("protocol", "write_ready: nbytes %" PRId64 ", ndone %" PRId64, TSVIONBytesGet(vio), TSVIONDoneGet(vio));
TSVIOReenable(txn_sm->q_client_write_vio);
break;
@@ -751,7 +746,6 @@ state_send_response_to_client(TSCont contp, TSEvent event, TSVIO vio)
default:
TSDebug("protocol", " . default handler");
return prepare_to_die(contp);
-
}
TSDebug("protocol", "leaving send_response_to_client");
@@ -765,7 +759,7 @@ state_send_response_to_client(TSCont contp, TSEvent event, TSVIO vio)
int
prepare_to_die(TSCont contp)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter prepare_to_die");
if (txn_sm->q_client_vc) {
@@ -795,7 +789,7 @@ prepare_to_die(TSCont contp)
int
state_done(TSCont contp, TSEvent event ATS_UNUSED, TSVIO vio ATS_UNUSED)
{
- TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
+ TxnSM *txn_sm = (TxnSM *)TSContDataGet(contp);
TSDebug("protocol", "enter state_done");
@@ -887,14 +881,14 @@ send_response_to_client(TSCont contp)
TSDebug("protocol", "enter send_response_to_client");
- txn_sm = (TxnSM *) TSContDataGet(contp);
+ txn_sm = (TxnSM *)TSContDataGet(contp);
response_len = TSIOBufferReaderAvail(txn_sm->q_client_response_buffer_reader);
TSDebug("protocol", " . resp_len is %d", response_len);
set_handler(txn_sm->q_current_handler, (TxnSMHandler)&state_interface_with_client);
- txn_sm->q_client_write_vio = TSVConnWrite(txn_sm->q_client_vc, (TSCont) contp,
- txn_sm->q_client_response_buffer_reader, response_len);
+ txn_sm->q_client_write_vio =
+ TSVConnWrite(txn_sm->q_client_vc, (TSCont)contp, txn_sm->q_client_response_buffer_reader, response_len);
return TS_SUCCESS;
}
@@ -914,7 +908,7 @@ get_info_from_buffer(TSIOBufferReader the_reader)
read_avail = TSIOBufferReaderAvail(the_reader);
- info = (char *) TSmalloc(sizeof(char) * read_avail);
+ info = (char *)TSmalloc(sizeof(char) * read_avail);
if (info == NULL)
return NULL;
info_start = info;
@@ -922,7 +916,7 @@ get_info_from_buffer(TSIOBufferReader the_reader)
/* Read the data out of the reader */
while (read_avail > 0) {
blk = TSIOBufferReaderStart(the_reader);
- buf = (char *) TSIOBufferBlockReadStart(blk, the_reader, &read_done);
+ buf = (char *)TSIOBufferBlockReadStart(blk, the_reader, &read_done);
memcpy(info, buf, read_done);
if (read_done > 0) {
TSIOBufferReaderConsume(the_reader, read_done);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/protocol/TxnSM.h
----------------------------------------------------------------------
diff --git a/example/protocol/TxnSM.h b/example/protocol/TxnSM.h
index 2876f5a..cf6d657 100644
--- a/example/protocol/TxnSM.h
+++ b/example/protocol/TxnSM.h
@@ -26,17 +26,16 @@
#include "Protocol.h"
-typedef int (*TxnSMHandler) (TSCont contp, TSEvent event, void *data);
+typedef int (*TxnSMHandler)(TSCont contp, TSEvent event, void *data);
TSCont TxnSMCreate(TSMutex pmutex, TSVConn client_vc, int server_port);
#define TXN_SM_ALIVE 0xAAAA0123
-#define TXN_SM_DEAD 0xFEE1DEAD
-#define TXN_SM_ZERO 0x00001111
+#define TXN_SM_DEAD 0xFEE1DEAD
+#define TXN_SM_ZERO 0x00001111
/* The Txn State Machine */
-typedef struct _TxnSM
-{
+typedef struct _TxnSM {
unsigned int q_magic;
TSMutex q_mutex;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/query-remap/query-remap.c
----------------------------------------------------------------------
diff --git a/example/query-remap/query-remap.c b/example/query-remap/query-remap.c
index 8eabd3f..6f5b0c8 100644
--- a/example/query-remap/query-remap.c
+++ b/example/query-remap/query-remap.c
@@ -43,11 +43,10 @@ typedef struct _query_remap_info {
int
-TSRemapInit(TSRemapInterface *api_info ATS_UNUSED, char *errbuf ATS_UNUSED,
- int errbuf_size ATS_UNUSED)
+TSRemapInit(TSRemapInterface *api_info ATS_UNUSED, char *errbuf ATS_UNUSED, int errbuf_size ATS_UNUSED)
{
/* Called at TS startup. Nothing needed for this plugin */
- TSDebug(PLUGIN_NAME , "remap plugin initialized");
+ TSDebug(PLUGIN_NAME, "remap plugin initialized");
return 0;
}
@@ -71,39 +70,38 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf ATS_UNUSED, i
2: query param to hash
3,4,... : server hostnames
*/
- query_remap_info *qri = (query_remap_info*) TSmalloc(sizeof(query_remap_info));
+ query_remap_info *qri = (query_remap_info *)TSmalloc(sizeof(query_remap_info));
qri->param_name = TSstrdup(argv[2]);
qri->param_len = strlen(qri->param_name);
qri->num_hosts = argc - 3;
- qri->hosts = (char**) TSmalloc(qri->num_hosts*sizeof(char*));
+ qri->hosts = (char **)TSmalloc(qri->num_hosts * sizeof(char *));
- TSDebug(PLUGIN_NAME, " - Hash using query parameter [%s] with %d hosts",
- qri->param_name, qri->num_hosts);
+ TSDebug(PLUGIN_NAME, " - Hash using query parameter [%s] with %d hosts", qri->param_name, qri->num_hosts);
- for (i=0; i < qri->num_hosts; ++i) {
- qri->hosts[i] = TSstrdup(argv[i+3]);
+ for (i = 0; i < qri->num_hosts; ++i) {
+ qri->hosts[i] = TSstrdup(argv[i + 3]);
TSDebug(PLUGIN_NAME, " - Host %d: %s", i, qri->hosts[i]);
}
- *ih = (void*)qri;
+ *ih = (void *)qri;
TSDebug(PLUGIN_NAME, "created instance %p", *ih);
return 0;
}
void
-TSRemapDeleteInstance(void* ih)
+TSRemapDeleteInstance(void *ih)
{
/* Release instance memory allocated in TSRemapNewInstance */
int i;
TSDebug(PLUGIN_NAME, "deleting instance %p", ih);
if (ih) {
- query_remap_info *qri = (query_remap_info*)ih;
+ query_remap_info *qri = (query_remap_info *)ih;
if (qri->param_name)
TSfree(qri->param_name);
if (qri->hosts) {
- for (i=0; i < qri->num_hosts; ++i) {
+ for (i = 0; i < qri->num_hosts; ++i) {
TSfree(qri->hosts[i]);
}
TSfree(qri->hosts);
@@ -114,10 +112,10 @@ TSRemapDeleteInstance(void* ih)
TSRemapStatus
-TSRemapDoRemap(void* ih, TSHttpTxn rh ATS_UNUSED, TSRemapRequestInfo *rri)
+TSRemapDoRemap(void *ih, TSHttpTxn rh ATS_UNUSED, TSRemapRequestInfo *rri)
{
int hostidx = -1;
- query_remap_info *qri = (query_remap_info*)ih;
+ query_remap_info *qri = (query_remap_info *)ih;
if (!qri || !rri) {
TSError(PLUGIN_NAME "NULL private data or RRI");
@@ -125,20 +123,19 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh ATS_UNUSED, TSRemapRequestInfo *rri)
}
int req_query_len;
- const char* req_query = TSUrlHttpQueryGet(rri->requestBufp, rri->requestUrl, &req_query_len);
+ const char *req_query = TSUrlHttpQueryGet(rri->requestBufp, rri->requestUrl, &req_query_len);
if (req_query && req_query_len > 0) {
char *q, *key;
char *s = NULL;
/* make a copy of the query, as it is read only */
- q = (char*) TSstrndup(req_query, req_query_len+1);
+ q = (char *)TSstrndup(req_query, req_query_len + 1);
/* parse query parameters */
for (key = strtok_r(q, "&", &s); key != NULL;) {
char *val = strchr(key, '=');
- if (val && (size_t)(val-key) == qri->param_len &&
- !strncmp(key, qri->param_name, qri->param_len)) {
+ if (val && (size_t)(val - key) == qri->param_len && !strncmp(key, qri->param_name, qri->param_len)) {
++val;
/* the param key matched the configured param_name
hash the param value to pick a host */
@@ -154,7 +151,7 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh ATS_UNUSED, TSRemapRequestInfo *rri)
if (hostidx >= 0) {
int req_host_len;
/* TODO: Perhaps use TSIsDebugTagSet() before calling TSUrlHostGet()... */
- const char* req_host = TSUrlHostGet(rri->requestBufp, rri->requestUrl, &req_host_len);
+ const char *req_host = TSUrlHostGet(rri->requestBufp, rri->requestUrl, &req_host_len);
if (TSUrlHostSet(rri->requestBufp, rri->requestUrl, qri->hosts[hostidx], strlen(qri->hosts[hostidx])) != TS_SUCCESS) {
TSDebug(PLUGIN_NAME, "Failed to modify the Host in request URL");
@@ -179,10 +176,9 @@ hash_fnv32(char *buf, size_t len)
uint32_t hval = (uint32_t)0x811c9dc5; /* FNV1_32_INIT */
for (; len > 0; --len) {
- hval *= (uint32_t)0x01000193; /* FNV_32_PRIME */
+ hval *= (uint32_t)0x01000193; /* FNV_32_PRIME */
hval ^= (uint32_t)*buf++;
}
return hval;
}
-
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/redirect-1/redirect-1.c
----------------------------------------------------------------------
diff --git a/example/redirect-1/redirect-1.c b/example/redirect-1/redirect-1.c
index 613235a..06865f2 100644
--- a/example/redirect-1/redirect-1.c
+++ b/example/redirect-1/redirect-1.c
@@ -35,9 +35,9 @@
#include <stdio.h>
#include <string.h>
-# include <unistd.h>
-# include <netinet/in.h>
-# include <arpa/inet.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
#include <ts/ts.h>
@@ -107,10 +107,8 @@ handle_client_lookup(TSHttpTxn txnp, TSCont contp)
* Create the local copies of the global coupled stats:
*/
local_requests_all = INKStatCoupledLocalAdd(local_request_outcomes, "requests.all.local", INKSTAT_TYPE_FLOAT);
- local_requests_redirects = INKStatCoupledLocalAdd(local_request_outcomes,
- "requests.redirects.local", INKSTAT_TYPE_INT64);
- local_requests_unchanged = INKStatCoupledLocalAdd(local_request_outcomes,
- "requests.unchanged.local", INKSTAT_TYPE_INT64);
+ local_requests_redirects = INKStatCoupledLocalAdd(local_request_outcomes, "requests.redirects.local", INKSTAT_TYPE_INT64);
+ local_requests_unchanged = INKStatCoupledLocalAdd(local_request_outcomes, "requests.unchanged.local", INKSTAT_TYPE_INT64);
/*
@@ -122,7 +120,7 @@ handle_client_lookup(TSHttpTxn txnp, TSCont contp)
INKStatFloatAddTo(local_requests_all, 1.0);
if (TSIsDebugTagSet("redirect")) {
- struct sockaddr const* addr = TSHttpTxnClientAddrGet(txnp);
+ struct sockaddr const *addr = TSHttpTxnClientAddrGet(txnp);
if (addr) {
socklen_t addr_size = 0;
@@ -200,7 +198,6 @@ done:
}
-
static void
handle_response(TSHttpTxn txnp)
{
@@ -215,9 +212,8 @@ handle_response(TSHttpTxn txnp)
}
TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_MOVED_PERMANENTLY);
- TSHttpHdrReasonSet(bufp, hdr_loc,
- TSHttpHdrReasonLookup(TS_HTTP_STATUS_MOVED_PERMANENTLY),
- strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_MOVED_PERMANENTLY)));
+ TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_MOVED_PERMANENTLY),
+ strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_MOVED_PERMANENTLY)));
TSMimeHdrFieldCreate(bufp, hdr_loc, &newfield_loc); /* Probably should check for errors ... */
TSMimeHdrFieldNameSet(bufp, hdr_loc, newfield_loc, TS_MIME_FIELD_LOCATION, TS_MIME_LEN_LOCATION);
@@ -239,12 +235,10 @@ done:
}
-
static int
redirect_plugin(TSCont contp, TSEvent event, void *edata)
{
-
- TSHttpTxn txnp = (TSHttpTxn) edata;
+ TSHttpTxn txnp = (TSHttpTxn)edata;
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR:
@@ -265,7 +259,6 @@ redirect_plugin(TSCont contp, TSEvent event, void *edata)
}
-
/*
* Global statistics functions:
*/
@@ -291,7 +284,6 @@ init_stats(void)
requests_all = INKStatCoupledGlobalAdd(request_outcomes, "requests.all", INKSTAT_TYPE_FLOAT);
requests_redirects = INKStatCoupledGlobalAdd(request_outcomes, "requests.redirects", INKSTAT_TYPE_INT64);
requests_unchanged = INKStatCoupledGlobalAdd(request_outcomes, "requests.unchanged", INKSTAT_TYPE_INT64);
-
}
/*
@@ -371,7 +363,8 @@ TSPluginInit(int argc, const char *argv[])
TSstrlcat(uri_redirect, url_redirect, uri_len);
} else {
- TSError("Incorrect syntax in plugin.conf: correct usage is" "redirect-1.so ip_deny url_redirect");
+ TSError("Incorrect syntax in plugin.conf: correct usage is"
+ "redirect-1.so ip_deny url_redirect");
return;
}
@@ -381,8 +374,7 @@ TSPluginInit(int argc, const char *argv[])
init_stats();
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(redirect_plugin, NULL));
- TSDebug("redirect_init", "block_ip is %s, url_redirect is %s, and uri_redirect is %s",
- block_ip, url_redirect, uri_redirect);
+ TSDebug("redirect_init", "block_ip is %s, url_redirect is %s, and uri_redirect is %s", block_ip, url_redirect, uri_redirect);
// ToDo: Should figure out how to print IPs which are IPv4 / v6.
// TSDebug("redirect_init", "ip_deny is %ld\n", ip_deny);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/remap/remap.cc
----------------------------------------------------------------------
diff --git a/example/remap/remap.cc b/example/remap/remap.cc
index 2dbe82a..f8311d7 100644
--- a/example/remap/remap.cc
+++ b/example/remap/remap.cc
@@ -57,22 +57,19 @@ public:
remap_entry *next;
int argc;
char **argv;
- remap_entry(int _argc, char *_argv[]);
- ~remap_entry();
+ remap_entry(int _argc, char *_argv[]);
+ ~remap_entry();
static void add_to_list(remap_entry *re);
static void remove_from_list(remap_entry *re);
};
-static int plugin_init_counter = 0; /* remap plugin initialization counter */
-static pthread_mutex_t remap_plugin_global_mutex; /* remap plugin global mutex */
-remap_entry *
- remap_entry::active_list = 0;
-pthread_mutex_t
- remap_entry::mutex; /* remap_entry class mutex */
+static int plugin_init_counter = 0; /* remap plugin initialization counter */
+static pthread_mutex_t remap_plugin_global_mutex; /* remap plugin global mutex */
+remap_entry *remap_entry::active_list = 0;
+pthread_mutex_t remap_entry::mutex; /* remap_entry class mutex */
/* ----------------------- remap_entry::remap_entry ------------------------ */
-remap_entry::remap_entry(int _argc, char *_argv[]):
- next(NULL), argc(0), argv(NULL)
+remap_entry::remap_entry(int _argc, char *_argv[]) : next(NULL), argc(0), argv(NULL)
{
int i;
@@ -133,20 +130,20 @@ store_my_error_message(TSReturnCode retcode, char *err_msg_buf, int buf_size, co
va_list ap;
va_start(ap, fmt);
err_msg_buf[0] = 0;
- (void) vsnprintf(err_msg_buf, buf_size - 1, fmt, ap);
+ (void)vsnprintf(err_msg_buf, buf_size - 1, fmt, ap);
err_msg_buf[buf_size - 1] = 0;
va_end(ap);
}
- return retcode; /* error code here */
+ return retcode; /* error code here */
}
void
TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
{
TSPluginRegistrationInfo info;
- info.plugin_name = (char*)"remap_plugin";
- info.vendor_name = (char*)"Apache";
- info.support_email = (char*)"";
+ info.plugin_name = (char *)"remap_plugin";
+ info.vendor_name = (char *)"Apache";
+ info.support_email = (char *)"";
if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
TSError("Plugin registration failed. \n");
@@ -169,20 +166,20 @@ TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
if (unlikely(api_info->size < sizeof(TSRemapInterface))) {
return store_my_error_message(TS_ERROR, errbuf, errbuf_size,
"[TSRemapInit] - Incorrect size of TSRemapInterface structure %d. Should be at least %d bytes",
- (int) api_info->size, (int) sizeof(TSRemapInterface));
+ (int)api_info->size, (int)sizeof(TSRemapInterface));
}
if (unlikely(api_info->tsremap_version < TSREMAP_VERSION)) {
- return store_my_error_message(TS_ERROR, errbuf, errbuf_size,
- "[TSRemapInit] - Incorrect API version %d.%d",
+ return store_my_error_message(TS_ERROR, errbuf, errbuf_size, "[TSRemapInit] - Incorrect API version %d.%d",
(api_info->tsremap_version >> 16), (api_info->tsremap_version & 0xffff));
}
- if (pthread_mutex_init(&remap_plugin_global_mutex, 0) || pthread_mutex_init(&remap_entry::mutex, 0)) { /* pthread_mutex_init - always returns 0. :) - impossible error */
+ if (pthread_mutex_init(&remap_plugin_global_mutex, 0) ||
+ pthread_mutex_init(&remap_entry::mutex, 0)) { /* pthread_mutex_init - always returns 0. :) - impossible error */
return store_my_error_message(TS_ERROR, errbuf, errbuf_size, "[TSRemapInit] - Mutex initialization error");
}
plugin_init_counter++;
}
- return TS_SUCCESS; /* success */
+ return TS_SUCCESS; /* success */
}
// Plugin shutdown
@@ -208,8 +205,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
fprintf(stderr, "Remap Plugin: TSRemapNewInstance()\n");
if (argc < 2) {
- return store_my_error_message(TS_ERROR, errbuf, errbuf_size,
- "[TSRemapNewInstance] - Incorrect number of arguments - %d", argc);
+ return store_my_error_message(TS_ERROR, errbuf, errbuf_size, "[TSRemapNewInstance] - Incorrect number of arguments - %d", argc);
}
if (!argv || !ih) {
return store_my_error_message(TS_ERROR, errbuf, errbuf_size, "[TSRemapNewInstance] - Invalid argument(s)");
@@ -227,16 +223,16 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
remap_entry::add_to_list(ri);
- *ih = (void*) ri;
+ *ih = (void *)ri;
return TS_SUCCESS;
}
/* ---------------------- TSRemapDeleteInstance -------------------------- */
void
-TSRemapDeleteInstance(void* ih)
+TSRemapDeleteInstance(void *ih)
{
- remap_entry *ri = (remap_entry *) ih;
+ remap_entry *ri = (remap_entry *)ih;
fprintf(stderr, "Remap Plugin: TSRemapDeleteInstance()\n");
@@ -245,24 +241,25 @@ TSRemapDeleteInstance(void* ih)
delete ri;
}
-static volatile unsigned long processing_counter = 0; // sequential counter
+static volatile unsigned long processing_counter = 0; // sequential counter
static int arg_index = 0;
/* -------------------------- TSRemapDoRemap -------------------------------- */
TSRemapStatus
-TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
{
- const char* temp;
- const char* temp2;
+ const char *temp;
+ const char *temp2;
int len, len2, port;
TSMLoc cfield;
- unsigned long _processing_counter = ++processing_counter; // one more function call (in real life use mutex to protect this counter)
+ unsigned long _processing_counter =
+ ++processing_counter; // one more function call (in real life use mutex to protect this counter)
- remap_entry *ri = (remap_entry *) ih;
+ remap_entry *ri = (remap_entry *)ih;
fprintf(stderr, "Remap Plugin: TSRemapDoRemap()\n");
if (!ri || !rri)
- return TSREMAP_NO_REMAP; /* TS must remap this request */
+ return TSREMAP_NO_REMAP; /* TS must remap this request */
fprintf(stderr, "[TSRemapDoRemap] From: \"%s\" To: \"%s\"\n", ri->argv[0], ri->argv[1]);
@@ -305,19 +302,18 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
// How to store plugin private arguments inside Traffic Server request processing block.
if (TSHttpArgIndexReserve("remap_example", "Example remap plugin", &arg_index) == TS_SUCCESS) {
fprintf(stderr, "[TSRemapDoRemap] Save processing counter %lu inside request processing block\n", _processing_counter);
- TSHttpTxnArgSet((TSHttpTxn) rh, arg_index, (void *) _processing_counter); // save counter
+ TSHttpTxnArgSet((TSHttpTxn)rh, arg_index, (void *)_processing_counter); // save counter
}
// How to cancel request processing and return error message to the client
// We wiil do it each other request
if (_processing_counter & 1) {
- char* tmp = (char*)TSmalloc(256);
+ char *tmp = (char *)TSmalloc(256);
static int my_local_counter = 0;
- size_t len = snprintf(tmp, 255,
- "This is very small example of TS API usage!\nIteration %d!\nHTTP return code %d\n",
+ size_t len = snprintf(tmp, 255, "This is very small example of TS API usage!\nIteration %d!\nHTTP return code %d\n",
my_local_counter, TS_HTTP_STATUS_CONTINUE + my_local_counter);
- TSHttpTxnSetHttpRetStatus((TSHttpTxn) rh, (TSHttpStatus) ((int) TS_HTTP_STATUS_CONTINUE + my_local_counter));
- TSHttpTxnErrorBodySet((TSHttpTxn) rh, tmp, len, NULL); // Defaults to text/html
+ TSHttpTxnSetHttpRetStatus((TSHttpTxn)rh, (TSHttpStatus)((int)TS_HTTP_STATUS_CONTINUE + my_local_counter));
+ TSHttpTxnErrorBodySet((TSHttpTxn)rh, tmp, len, NULL); // Defaults to text/html
my_local_counter++;
}
// hardcoded case for remapping
@@ -352,13 +348,13 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
/* ----------------------- TSRemapOSResponse ----------------------------- */
void
-TSRemapOSResponse(void* ih ATS_UNUSED, TSHttpTxn rh, int os_response_type)
+TSRemapOSResponse(void *ih ATS_UNUSED, TSHttpTxn rh, int os_response_type)
{
int request_id = -1;
- void *data = TSHttpTxnArgGet((TSHttpTxn) rh, arg_index); // read counter (we store it in TSRemapDoRemap function call)
+ void *data = TSHttpTxnArgGet((TSHttpTxn)rh, arg_index); // read counter (we store it in TSRemapDoRemap function call)
if (data)
- request_id = *((int*)data);
+ request_id = *((int *)data);
fprintf(stderr, "[TSRemapOSResponse] Read processing counter %d from request processing block\n", request_id);
fprintf(stderr, "[TSRemapOSResponse] OS response status: %d\n", os_response_type);
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/remap_header_add/remap_header_add.cc
----------------------------------------------------------------------
diff --git a/example/remap_header_add/remap_header_add.cc b/example/remap_header_add/remap_header_add.cc
index 324fd3f..503089e 100644
--- a/example/remap_header_add/remap_header_add.cc
+++ b/example/remap_header_add/remap_header_add.cc
@@ -34,18 +34,17 @@
#include "ts/ts.h"
#include "ts/remap.h"
-struct remap_line
-{
+struct remap_line {
int argc;
char **argv; // store the originals
- int nvc; // the number of name value pairs, should be argc - 2.
+ int nvc; // the number of name value pairs, should be argc - 2.
char **name; // at load we will parse out the name and values.
char **val;
};
#define TAG "headeradd_remap"
-#define NOWARN_UNUSED __attribute__ ((unused))
+#define NOWARN_UNUSED __attribute__((unused))
#define EXTERN extern "C"
@@ -62,7 +61,7 @@ ParseArgIntoNv(const char *arg, char **n, char **v)
}
size_t name_len = colon_pos - arg;
- *n = (char *) TSmalloc(name_len + 1);
+ *n = (char *)TSmalloc(name_len + 1);
memcpy(*n, arg, colon_pos - arg);
(*n)[name_len] = '\0';
@@ -70,11 +69,11 @@ ParseArgIntoNv(const char *arg, char **n, char **v)
// check to see if the value is quoted.
if (val_len > 1 && colon_pos[1] == '"' && colon_pos[val_len] == '"') {
- colon_pos++; // advance past the first quote
+ colon_pos++; // advance past the first quote
val_len -= 2; // don't include the trailing quote
}
- *v = (char *) TSmalloc(val_len + 1);
+ *v = (char *)TSmalloc(val_len + 1);
memcpy(*v, colon_pos + 1, val_len);
(*v)[val_len] = '\0';
@@ -90,7 +89,7 @@ TSRemapInit(NOWARN_UNUSED TSRemapInterface *api_info, NOWARN_UNUSED char *errbuf
TSReturnCode
-TSRemapNewInstance(int argc, char* argv[], void** ih, NOWARN_UNUSED char* errbuf, NOWARN_UNUSED int errbuf_size)
+TSRemapNewInstance(int argc, char *argv[], void **ih, NOWARN_UNUSED char *errbuf, NOWARN_UNUSED int errbuf_size)
{
remap_line *rl = NULL;
@@ -103,35 +102,34 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, NOWARN_UNUSED char* errbuf
// print all arguments for this particular remapping
- rl = (remap_line*) TSmalloc(sizeof(remap_line));
+ rl = (remap_line *)TSmalloc(sizeof(remap_line));
rl->argc = argc;
rl->argv = argv;
rl->nvc = argc - 2; // the first two are the remap from and to
if (rl->nvc) {
- rl->name = (char**) TSmalloc(sizeof(char *) * rl->nvc);
- rl->val = (char**) TSmalloc(sizeof(char *) * rl->nvc);
+ rl->name = (char **)TSmalloc(sizeof(char *) * rl->nvc);
+ rl->val = (char **)TSmalloc(sizeof(char *) * rl->nvc);
}
TSDebug(TAG, "NewInstance:");
for (int i = 2; i < argc; i++) {
- ParseArgIntoNv(argv[i], &rl->name[i-2], &rl->val[i-2]);
+ ParseArgIntoNv(argv[i], &rl->name[i - 2], &rl->val[i - 2]);
}
- *ih = (void *) rl;
+ *ih = (void *)rl;
return TS_SUCCESS;
}
void
-TSRemapDeleteInstance(void* ih)
+TSRemapDeleteInstance(void *ih)
{
TSDebug(TAG, "deleting instance %p", ih);
if (ih) {
- remap_line *rl = (remap_line*)ih;
- for (int i = 0; i < rl->nvc; ++i)
- {
+ remap_line *rl = (remap_line *)ih;
+ for (int i = 0; i < rl->nvc; ++i) {
TSfree(rl->name[i]);
TSfree(rl->val[i]);
}
@@ -144,9 +142,9 @@ TSRemapDeleteInstance(void* ih)
TSRemapStatus
-TSRemapDoRemap(void* ih, NOWARN_UNUSED TSHttpTxn txn, NOWARN_UNUSED TSRemapRequestInfo *rri)
+TSRemapDoRemap(void *ih, NOWARN_UNUSED TSHttpTxn txn, NOWARN_UNUSED TSRemapRequestInfo *rri)
{
- remap_line *rl = (remap_line *) ih;
+ remap_line *rl = (remap_line *)ih;
if (!rl || !rri) {
TSError(TAG ": rl or rri is null.");
@@ -167,9 +165,9 @@ TSRemapDoRemap(void* ih, NOWARN_UNUSED TSHttpTxn txn, NOWARN_UNUSED TSRemapReque
TSMLoc field_loc;
if (TSMimeHdrFieldCreate(req_bufp, req_loc, &field_loc) == TS_SUCCESS) {
- TSMimeHdrFieldNameSet(req_bufp, req_loc, field_loc, rl->name[i], strlen(rl->name[i]));
- TSMimeHdrFieldAppend(req_bufp, req_loc, field_loc);
- TSMimeHdrFieldValueStringInsert(req_bufp, req_loc, field_loc, 0, rl->val[i], strlen(rl->val[i]));
+ TSMimeHdrFieldNameSet(req_bufp, req_loc, field_loc, rl->name[i], strlen(rl->name[i]));
+ TSMimeHdrFieldAppend(req_bufp, req_loc, field_loc);
+ TSMimeHdrFieldValueStringInsert(req_bufp, req_loc, field_loc, 0, rl->val[i], strlen(rl->val[i]));
} else {
TSError(TAG ": Failure on TSMimeHdrFieldCreate");
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/example/replace-header/replace-header.c
----------------------------------------------------------------------
diff --git a/example/replace-header/replace-header.c b/example/replace-header/replace-header.c
index d4bc31b..75ca390 100644
--- a/example/replace-header/replace-header.c
+++ b/example/replace-header/replace-header.c
@@ -81,7 +81,7 @@ done:
static int
replace_header_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
{
- TSHttpTxn txnp = (TSHttpTxn) edata;
+ TSHttpTxn txnp = (TSHttpTxn)edata;
switch (event) {
case TS_EVENT_HTTP_READ_RESPONSE_HDR: