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 2010/11/16 21:22:08 UTC

svn commit: r1035782 [4/29] - in /trafficserver/traffic/trunk: example/add-header/ example/append-transform/ example/basic-auth/ example/blacklist-0/ example/blacklist-1/ example/bnull-transform/ example/cache_plugin/ example/cache_scan/ example/file-1...

Modified: trafficserver/traffic/trunk/example/protocol/TxnSM.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/protocol/TxnSM.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/protocol/TxnSM.c (original)
+++ trafficserver/traffic/trunk/example/protocol/TxnSM.c Tue Nov 16 20:22:02 2010
@@ -23,87 +23,87 @@
 
 #include "TxnSM.h"
 
-extern INKTextLogObject protocol_plugin_log;
+extern TSTextLogObject protocol_plugin_log;
 
 /* Fix me: currently, tunnelling server_response from OS to both cache and
    client doesn't work for client_vc. So write data first to cache and then
    write cached data to client. */
 
 /* static functions */
-int main_handler(INKCont contp, INKEvent event, void *data);
+int main_handler(TSCont contp, TSEvent event, void *data);
 
 /* functions for clients */
-int state_start(INKCont contp, INKEvent event, void *data);
-int state_interface_with_client(INKCont contp, INKEvent event, INKVIO vio);
-int state_read_request_from_client(INKCont contp, INKEvent event, INKVIO vio);
-int state_send_response_to_client(INKCont contp, INKEvent event, INKVIO vio);
+int state_start(TSCont contp, TSEvent event, void *data);
+int state_interface_with_client(TSCont contp, TSEvent event, TSVIO vio);
+int state_read_request_from_client(TSCont contp, TSEvent event, TSVIO vio);
+int state_send_response_to_client(TSCont contp, TSEvent event, TSVIO vio);
 
 /* functions for cache operation */
-int state_handle_cache_lookup(INKCont contp, INKEvent event, INKVConn vc);
-int state_handle_cache_read_response(INKCont contp, INKEvent event, INKVIO vio);
-int state_handle_cache_prepare_for_write(INKCont contp, INKEvent event, INKVConn vc);
-int state_write_to_cache(INKCont contp, INKEvent event, INKVIO vio);
+int state_handle_cache_lookup(TSCont contp, TSEvent event, TSVConn vc);
+int state_handle_cache_read_response(TSCont contp, TSEvent event, TSVIO vio);
+int state_handle_cache_prepare_for_write(TSCont contp, TSEvent event, TSVConn vc);
+int state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio);
 
 /* functions for servers */
-int state_build_and_send_request(INKCont contp, INKEvent event, void *data);
-int state_dns_lookup(INKCont contp, INKEvent event, INKHostLookupResult host_info);
-int state_connect_to_server(INKCont contp, INKEvent event, INKVConn vc);
-int state_interface_with_server(INKCont contp, INKEvent event, INKVIO vio);
-int state_send_request_to_server(INKCont contp, INKEvent event, INKVIO vio);
-int state_read_response_from_server(INKCont contp, INKEvent event, INKVIO vio);
+int state_build_and_send_request(TSCont contp, TSEvent event, void *data);
+int state_dns_lookup(TSCont contp, TSEvent event, TSHostLookupResult host_info);
+int state_connect_to_server(TSCont contp, TSEvent event, TSVConn vc);
+int state_interface_with_server(TSCont contp, TSEvent event, TSVIO vio);
+int state_send_request_to_server(TSCont contp, TSEvent event, TSVIO vio);
+int state_read_response_from_server(TSCont contp, TSEvent event, TSVIO vio);
 
 /* misc functions */
-int state_done(INKCont contp, INKEvent event, INKVIO vio);
+int state_done(TSCont contp, TSEvent event, TSVIO vio);
 
-int send_response_to_client(INKCont contp);
-int prepare_to_die(INKCont contp);
+int send_response_to_client(TSCont contp);
+int prepare_to_die(TSCont contp);
 
-char *get_info_from_buffer(INKIOBufferReader the_reader);
+char *get_info_from_buffer(TSIOBufferReader the_reader);
 int is_request_end(char *buf);
 int parse_request(char *request, char *server_name, char *file_name);
-INKCacheKey CacheKeyCreate(char *file_name);
+TSCacheKey CacheKeyCreate(char *file_name);
 
 /* Continuation handler is a function pointer, this function
    is to assign the continuation handler to a specific function. */
 int
-main_handler(INKCont contp, INKEvent event, void *data)
+main_handler(TSCont contp, TSEvent event, void *data)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
   TxnSMHandler q_current_handler = txn_sm->q_current_handler;
 
-  INKDebug("protocol", "main_handler (contp %X event %d)", contp, event);
+  TSDebug("protocol", "main_handler (contp %X event %d)", contp, event);
 
   /* handle common cases errors */
-  if (event == INK_EVENT_ERROR) {
+  if (event == TS_EVENT_ERROR) {
     return prepare_to_die(contp);
   }
 
   if (q_current_handler != &state_interface_with_server) {
-    if (event == INK_EVENT_VCONN_EOS) {
+    if (event == TS_EVENT_VCONN_EOS) {
       return prepare_to_die(contp);
     }
   }
 
-  INKDebug("protocol", "current_handler (%p)", q_current_handler);
+  TSDebug("protocol", "current_handler (%p)", q_current_handler);
 
   return (*q_current_handler) (contp, event, data);
 }
 
 /* Create the Txn data structure and the continuation for the Txn. */
-INKCont
-TxnSMCreate(INKMutex pmutex, INKVConn client_vc, int server_port)
+TSCont
+TxnSMCreate(TSMutex pmutex, TSVConn client_vc, int server_port)
 {
-  INKCont contp;
+  TSCont contp;
   TxnSM *txn_sm;
 
-  txn_sm = (TxnSM *) INKmalloc(sizeof(TxnSM));
+  txn_sm = (TxnSM *) TSmalloc(sizeof(TxnSM));
 
   txn_sm->q_mutex = pmutex;
   txn_sm->q_pending_action = NULL;
 
   /* Txn will use this server port to connect to the origin server. */
   txn_sm->q_server_port = server_port;
-  /* The client_vc is returned by INKNetAccept, refer to Protocol.c. */
+  /* The client_vc is returned by TSNetAccept, refer to Protocol.c. */
   txn_sm->q_client_vc = client_vc;
   /* The server_vc will be created if Txn connects to the origin server. */
   txn_sm->q_server_vc = NULL;
@@ -122,7 +122,7 @@ TxnSMCreate(INKMutex pmutex, INKVConn cl
   txn_sm->q_server_request_buffer_reader = NULL;
 
   /* Char buffers to store client request and server response. */
-  txn_sm->q_client_request = (char *) INKmalloc(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;
@@ -132,8 +132,8 @@ TxnSMCreate(INKMutex pmutex, INKVConn cl
   txn_sm->q_cache_read_buffer = NULL;
   txn_sm->q_cache_read_buffer_reader = NULL;
 
-  txn_sm->q_server_name = (char *) INKmalloc(sizeof(char) * (MAX_SERVER_NAME_LENGTH + 1));
-  txn_sm->q_file_name = (char *) INKmalloc(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;
@@ -141,23 +141,23 @@ TxnSMCreate(INKMutex pmutex, INKVConn cl
   /* Set the current handler to be state_start. */
   set_handler(txn_sm->q_current_handler, &state_start);
 
-  contp = INKContCreate(main_handler, txn_sm->q_mutex);
-  INKContDataSet(contp, txn_sm);
+  contp = TSContCreate(main_handler, txn_sm->q_mutex);
+  TSContDataSet(contp, txn_sm);
   return contp;
 }
 
 /* This function starts to read incoming client request data from client_vc */
 int
-state_start(INKCont contp, INKEvent event, void *data)
+state_start(TSCont contp, TSEvent event, void *data)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
   if (!txn_sm->q_client_vc) {
     return prepare_to_die(contp);
   }
 
-  txn_sm->q_client_request_buffer = INKIOBufferCreate();
-  txn_sm->q_client_request_buffer_reader = INKIOBufferReaderAlloc(txn_sm->q_client_request_buffer);
+  txn_sm->q_client_request_buffer = TSIOBufferCreate();
+  txn_sm->q_client_request_buffer_reader = TSIOBufferReaderAlloc(txn_sm->q_client_request_buffer);
 
   if (!txn_sm->q_client_request_buffer || !txn_sm->q_client_request_buffer_reader) {
     return prepare_to_die(contp);
@@ -166,28 +166,28 @@ state_start(INKCont contp, INKEvent even
   /* Now the IOBuffer and IOBufferReader is ready, the data from
      client_vc can be read into the IOBuffer. Since we don't know
      the size of the client request, set the expecting size to be
-     INT_MAX, so that we will always get INK_EVENT_VCONN_READ_READY
-     event, but never INK_EVENT_VCONN_READ_COMPLETE event. */
+     INT_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, &state_interface_with_client);
-  txn_sm->q_client_read_vio = INKVConnRead(txn_sm->q_client_vc, (INKCont) contp,
+  txn_sm->q_client_read_vio = TSVConnRead(txn_sm->q_client_vc, (TSCont) contp,
                                            txn_sm->q_client_request_buffer, INT_MAX);
 
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* This function is to call proper functions according to the
    VIO argument. If it's read_vio, which means reading request from
    client_vc, call state_read_request_from_client. If it's write_vio,
    which means sending response to client_vc, call
-   state_send_response_to_client. If the event is INK_EVENT_VCONN_EOS,
+   state_send_response_to_client. If the event is TS_EVENT_VCONN_EOS,
    which means the client closed socket and thus implies the client
    drop all jobs between TxnSM and the client, so go to die. */
 int
-state_interface_with_client(INKCont contp, INKEvent event, INKVIO vio)
+state_interface_with_client(TSCont contp, TSEvent event, TSVIO vio)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_interface_with_client");
+  TSDebug("protocol", "enter state_interface_with_client");
 
   txn_sm->q_pending_action = NULL;
 
@@ -201,90 +201,90 @@ state_interface_with_client(INKCont cont
 /* Data is read from client_vc, if all data for the request is in,
    parse it and do cache lookup. */
 int
-state_read_request_from_client(INKCont contp, INKEvent event, INKVIO vio)
+state_read_request_from_client(TSCont contp, TSEvent event, TSVIO vio)
 {
   int bytes_read, parse_result;
   char *temp_buf;
 
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_read_request_from_client");
+  TSDebug("protocol", "enter state_read_request_from_client");
 
   switch (event) {
-  case INK_EVENT_VCONN_READ_READY:
-    bytes_read = INKIOBufferReaderAvail(txn_sm->q_client_request_buffer_reader);
+  case TS_EVENT_VCONN_READ_READY:
+    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);
       strcat(txn_sm->q_client_request, temp_buf);
-      INKfree(temp_buf);
+      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 *) INKmalloc(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);
-        INKfree(temp_buf);
+        TSfree(temp_buf);
 
         if (parse_result != 1)
           return prepare_to_die(contp);
 
         /* Start to do cache lookup */
-        INKDebug("protocol", "Key material: file name is %d, %s*****", txn_sm->q_file_name, txn_sm->q_file_name);
-        txn_sm->q_key = (INKCacheKey) CacheKeyCreate(txn_sm->q_file_name);
+        TSDebug("protocol", "Key material: file name is %d, %s*****", txn_sm->q_file_name, txn_sm->q_file_name);
+        txn_sm->q_key = (TSCacheKey) CacheKeyCreate(txn_sm->q_file_name);
 
         set_handler(txn_sm->q_current_handler, &state_handle_cache_lookup);
-        txn_sm->q_pending_action = INKCacheRead(contp, txn_sm->q_key);
+        txn_sm->q_pending_action = TSCacheRead(contp, txn_sm->q_key);
 
-        return INK_SUCCESS;
+        return TS_SUCCESS;
       }
     }
 
     /* The request is not fully read, reenable the read_vio. */
-    INKVIOReenable(txn_sm->q_client_read_vio);
+    TSVIOReenable(txn_sm->q_client_read_vio);
     break;
 
   default:                     /* Shouldn't get here, prepare to die. */
     return prepare_to_die(contp);
 
   }
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* This function handle the cache lookup result. If MISS, try to
    open cache write_vc for writing. Otherwise, use the vc returned
    by the cache to read the data from the cache. */
 int
-state_handle_cache_lookup(INKCont contp, INKEvent event, INKVConn vc)
+state_handle_cache_lookup(TSCont contp, TSEvent event, TSVConn vc)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
   int64 response_size;
   int ret_val;
 
-  INKDebug("protocol", "enter state_handle_cache_lookup");
+  TSDebug("protocol", "enter state_handle_cache_lookup");
 
   switch (event) {
-  case INK_EVENT_CACHE_OPEN_READ:
-    INKDebug("protocol", "cache hit!!!");
+  case TS_EVENT_CACHE_OPEN_READ:
+    TSDebug("protocol", "cache hit!!!");
     /* Cache hit. */
 
     /* Write log */
-    ret_val = INKTextLogObjectWrite(protocol_plugin_log, "%s %s %d \n", txn_sm->q_file_name, txn_sm->q_server_name, 1);
-    if (ret_val != INK_SUCCESS)
-      INKError("fail to write into log");
+    ret_val = TSTextLogObjectWrite(protocol_plugin_log, "%s %s %d \n", txn_sm->q_file_name, txn_sm->q_server_name, 1);
+    if (ret_val != TS_SUCCESS)
+      TSError("fail to write into log");
 
     txn_sm->q_cache_vc = vc;
     txn_sm->q_pending_action = NULL;
 
     /* Get the size of the cached doc. */
-    INKVConnCacheObjectSizeGet(txn_sm->q_cache_vc, &response_size);
+    TSVConnCacheObjectSizeGet(txn_sm->q_cache_vc, &response_size);
 
     /* Allocate IOBuffer to store data from the cache. */
-    txn_sm->q_client_response_buffer = INKIOBufferCreate();
-    txn_sm->q_client_response_buffer_reader = INKIOBufferReaderAlloc(txn_sm->q_client_response_buffer);
-    txn_sm->q_cache_read_buffer = INKIOBufferCreate();
-    txn_sm->q_cache_read_buffer_reader = INKIOBufferReaderAlloc(txn_sm->q_cache_read_buffer);
+    txn_sm->q_client_response_buffer = TSIOBufferCreate();
+    txn_sm->q_client_response_buffer_reader = TSIOBufferReaderAlloc(txn_sm->q_client_response_buffer);
+    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 ||
@@ -294,21 +294,21 @@ state_handle_cache_lookup(INKCont contp,
 
     /* Read doc from the cache. */
     set_handler(txn_sm->q_current_handler, &state_handle_cache_read_response);
-    txn_sm->q_cache_read_vio = INKVConnRead(txn_sm->q_cache_vc, contp, txn_sm->q_cache_read_buffer, response_size);
+    txn_sm->q_cache_read_vio = TSVConnRead(txn_sm->q_cache_vc, contp, txn_sm->q_cache_read_buffer, response_size);
 
     break;
 
-  case INK_EVENT_CACHE_OPEN_READ_FAILED:
+  case TS_EVENT_CACHE_OPEN_READ_FAILED:
     /* Cache miss or error, open cache write_vc. */
-    INKDebug("protocol", "cache miss or error!!!");
+    TSDebug("protocol", "cache miss or error!!!");
     /* Write log */
-    ret_val = INKTextLogObjectWrite(protocol_plugin_log, "%s %s %d \n", txn_sm->q_file_name, txn_sm->q_server_name, 0);
+    ret_val = TSTextLogObjectWrite(protocol_plugin_log, "%s %s %d \n", txn_sm->q_file_name, txn_sm->q_server_name, 0);
 
-    if (ret_val != INK_SUCCESS)
-      INKError("fail to write into log");
+    if (ret_val != TS_SUCCESS)
+      TSError("fail to write into log");
 
     set_handler(txn_sm->q_current_handler, &state_handle_cache_prepare_for_write);
-    txn_sm->q_pending_action = INKCacheWrite(contp, txn_sm->q_key);
+    txn_sm->q_pending_action = TSCacheWrite(contp, txn_sm->q_key);
     break;
 
   default:
@@ -316,7 +316,7 @@ state_handle_cache_lookup(INKCont contp,
     return prepare_to_die(contp);
   }
 
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 static void
@@ -325,18 +325,18 @@ 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
      server response buffer */
-  int rdr_avail = INKIOBufferReaderAvail(txn_sm->q_cache_read_buffer_reader);
+  int rdr_avail = TSIOBufferReaderAvail(txn_sm->q_cache_read_buffer_reader);
 
-  INKDebug("protocol", "entering buffer_cache_data");
-  INKDebug("protocol", "loading %d bytes to buffer reader", rdr_avail);
+  TSDebug("protocol", "entering buffer_cache_data");
+  TSDebug("protocol", "loading %d bytes to buffer reader", rdr_avail);
 
-  INKAssert(rdr_avail > 0);
+  TSAssert(rdr_avail > 0);
 
-  INKIOBufferCopy(txn_sm->q_client_response_buffer,     /* (cache response buffer) */
+  TSIOBufferCopy(txn_sm->q_client_response_buffer,     /* (cache response buffer) */
                   txn_sm->q_cache_read_buffer_reader,   /* (transient buffer)      */
                   rdr_avail, 0);
 
-  INKIOBufferReaderConsume(txn_sm->q_cache_read_buffer_reader, rdr_avail);
+  TSIOBufferReaderConsume(txn_sm->q_cache_read_buffer_reader, rdr_avail);
 }
 
 /* If the document is fully read out of the cache, close the
@@ -345,37 +345,37 @@ load_buffer_cache_data(TxnSM * txn_sm)
    occurs, close the read_vc, open write_vc for writing the doc
    into the cache.*/
 int
-state_handle_cache_read_response(INKCont contp, INKEvent event, INKVIO vio)
+state_handle_cache_read_response(TSCont contp, TSEvent event, TSVIO vio)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_handle_cache_read_response");
+  TSDebug("protocol", "enter state_handle_cache_read_response");
 
   txn_sm->q_pending_action = NULL;
 
   switch (event) {
-  case INK_EVENT_VCONN_READ_COMPLETE:
+  case TS_EVENT_VCONN_READ_COMPLETE:
     load_buffer_cache_data(txn_sm);
-    INKVConnClose(txn_sm->q_cache_vc);
+    TSVConnClose(txn_sm->q_cache_vc);
     txn_sm->q_cache_vc = NULL;
     txn_sm->q_cache_read_vio = NULL;
     txn_sm->q_cache_write_vio = NULL;
-    INKIOBufferReaderFree(txn_sm->q_cache_read_buffer_reader);
-    INKIOBufferDestroy(txn_sm->q_cache_read_buffer);
+    TSIOBufferReaderFree(txn_sm->q_cache_read_buffer_reader);
+    TSIOBufferDestroy(txn_sm->q_cache_read_buffer);
     txn_sm->q_cache_read_buffer_reader = NULL;
     txn_sm->q_cache_read_buffer = NULL;
     return send_response_to_client(contp);
 
-  case INK_EVENT_VCONN_READ_READY:
+  case TS_EVENT_VCONN_READ_READY:
     load_buffer_cache_data(txn_sm);
 
-    INKVIOReenable(txn_sm->q_cache_read_vio);
+    TSVIOReenable(txn_sm->q_cache_read_vio);
     break;
 
   default:
     /* Error */
     if (txn_sm->q_cache_vc) {
-      INKVConnClose(txn_sm->q_cache_vc);
+      TSVConnClose(txn_sm->q_cache_vc);
       txn_sm->q_cache_vc = NULL;
       txn_sm->q_cache_read_vio = NULL;
       txn_sm->q_cache_write_vio = NULL;
@@ -384,32 +384,32 @@ state_handle_cache_read_response(INKCont
     /* Open the write_vc, after getting doc from the origin server,
        write the doc into the cache. */
     set_handler(txn_sm->q_current_handler, &state_handle_cache_prepare_for_write);
-    INKAssert(txn_sm->q_pending_action == NULL);
-    txn_sm->q_pending_action = INKCacheWrite(contp, txn_sm->q_key);
+    TSAssert(txn_sm->q_pending_action == NULL);
+    txn_sm->q_pending_action = TSCacheWrite(contp, txn_sm->q_key);
     break;
 
   }
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* The cache processor call us back with the vc to use for writing
    data into the cache.
    In case of error, abort txn. */
 int
-state_handle_cache_prepare_for_write(INKCont contp, INKEvent event, INKVConn vc)
+state_handle_cache_prepare_for_write(TSCont contp, TSEvent event, TSVConn vc)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_handle_cache_prepare_for_write");
+  TSDebug("protocol", "enter state_handle_cache_prepare_for_write");
 
   txn_sm->q_pending_action = NULL;
 
   switch (event) {
-  case INK_EVENT_CACHE_OPEN_WRITE:
+  case TS_EVENT_CACHE_OPEN_WRITE:
     txn_sm->q_cache_vc = vc;
     break;
   default:
-    INKError("can't open cache write_vc, aborting txn");
+    TSError("can't open cache write_vc, aborting txn");
     txn_sm->q_cache_vc = NULL;
     return prepare_to_die(contp);
     break;
@@ -420,19 +420,19 @@ state_handle_cache_prepare_for_write(INK
 /* Cache miss or error case. Start the process to send the request
    the origin server. */
 int
-state_build_and_send_request(INKCont contp, INKEvent event, void *data)
+state_build_and_send_request(TSCont contp, TSEvent event, void *data)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_build_and_send_request");
+  TSDebug("protocol", "enter state_build_and_send_request");
 
   txn_sm->q_pending_action = NULL;
 
-  txn_sm->q_server_request_buffer = INKIOBufferCreate();
-  txn_sm->q_server_request_buffer_reader = INKIOBufferReaderAlloc(txn_sm->q_server_request_buffer);
+  txn_sm->q_server_request_buffer = TSIOBufferCreate();
+  txn_sm->q_server_request_buffer_reader = TSIOBufferReaderAlloc(txn_sm->q_server_request_buffer);
 
-  txn_sm->q_server_response_buffer = INKIOBufferCreate();
-  txn_sm->q_cache_response_buffer_reader = INKIOBufferReaderAlloc(txn_sm->q_server_response_buffer);
+  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 ||
@@ -441,58 +441,58 @@ state_build_and_send_request(INKCont con
   }
 
   /* Marshal request */
-  INKIOBufferWrite(txn_sm->q_server_request_buffer, txn_sm->q_client_request, strlen(txn_sm->q_client_request));
+  TSIOBufferWrite(txn_sm->q_server_request_buffer, txn_sm->q_client_request, strlen(txn_sm->q_client_request));
 
   /* First thing to do is to get the server IP from the server host name. */
   set_handler(txn_sm->q_current_handler, &state_dns_lookup);
-  INKAssert(txn_sm->q_pending_action == NULL);
-  txn_sm->q_pending_action = INKHostLookup(contp, txn_sm->q_server_name, strlen(txn_sm->q_server_name));
+  TSAssert(txn_sm->q_pending_action == NULL);
+  txn_sm->q_pending_action = TSHostLookup(contp, txn_sm->q_server_name, strlen(txn_sm->q_server_name));
 
-  INKAssert(txn_sm->q_pending_action);
-  INKDebug("protocol", "initiating host lookup");
+  TSAssert(txn_sm->q_pending_action);
+  TSDebug("protocol", "initiating host lookup");
 
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* If Host lookup is successfully, connect to that IP. */
 int
-state_dns_lookup(INKCont contp, INKEvent event, INKHostLookupResult host_info)
+state_dns_lookup(TSCont contp, TSEvent event, TSHostLookupResult host_info)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_dns_lookup");
+  TSDebug("protocol", "enter state_dns_lookup");
 
   /* Can't find the server IP. */
-  if (event != INK_EVENT_HOST_LOOKUP || !host_info) {
+  if (event != TS_EVENT_HOST_LOOKUP || !host_info) {
     return prepare_to_die(contp);
   }
   txn_sm->q_pending_action = NULL;
 
-  /* Get the server IP from data structure INKHostLookupResult. */
-  INKHostLookupResultIPGet(host_info, &(txn_sm->q_server_ip));
+  /* Get the server IP from data structure TSHostLookupResult. */
+  TSHostLookupResultIPGet(host_info, &(txn_sm->q_server_ip));
 
   /* Connect to the server using its IP. */
   set_handler(txn_sm->q_current_handler, &state_connect_to_server);
-  INKAssert(txn_sm->q_pending_action == NULL);
-  txn_sm->q_pending_action = INKNetConnect(contp, txn_sm->q_server_ip, txn_sm->q_server_port);
+  TSAssert(txn_sm->q_pending_action == NULL);
+  txn_sm->q_pending_action = TSNetConnect(contp, txn_sm->q_server_ip, txn_sm->q_server_port);
 
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* Net Processor calls back, if succeeded, the net_vc is returned.
-   Note here, even if the event is INK_EVENT_NET_CONNECT, it doesn't
-   mean the net connection is set up because INKNetConnect is non-blocking.
+   Note here, even if the event is TS_EVENT_NET_CONNECT, it doesn't
+   mean the net connection is set up because TSNetConnect is non-blocking.
    Do VConnWrite to the net_vc, if fails, that means there is no net
    connection. */
 int
-state_connect_to_server(INKCont contp, INKEvent event, INKVConn vc)
+state_connect_to_server(TSCont contp, TSEvent event, TSVConn vc)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_connect_to_server");
+  TSDebug("protocol", "enter state_connect_to_server");
 
-  /* INKNetConnect failed. */
-  if (event != INK_EVENT_NET_CONNECT) {
+  /* TSNetConnect failed. */
+  if (event != TS_EVENT_NET_CONNECT) {
     return prepare_to_die(contp);
   }
   txn_sm->q_pending_action = NULL;
@@ -503,67 +503,67 @@ state_connect_to_server(INKCont contp, I
   set_handler(txn_sm->q_current_handler, &state_send_request_to_server);
 
   /* Actively write the request to the net_vc. */
-  txn_sm->q_server_write_vio = INKVConnWrite(txn_sm->q_server_vc, contp,
+  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 INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* Net Processor calls back, if write complete, wait for the response
    coming in, otherwise, reenable the write_vio. */
 int
-state_send_request_to_server(INKCont contp, INKEvent event, INKVIO vio)
+state_send_request_to_server(TSCont contp, TSEvent event, TSVIO vio)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_send_request_to_server");
+  TSDebug("protocol", "enter state_send_request_to_server");
 
   switch (event) {
-  case INK_EVENT_VCONN_WRITE_READY:
-    INKVIOReenable(vio);
+  case TS_EVENT_VCONN_WRITE_READY:
+    TSVIOReenable(vio);
     break;
-  case INK_EVENT_VCONN_WRITE_COMPLETE:
+  case TS_EVENT_VCONN_WRITE_COMPLETE:
     vio = NULL;
 
     /* Waiting for the incoming response. */
     set_handler(txn_sm->q_current_handler, &state_interface_with_server);
-    txn_sm->q_server_read_vio = INKVConnRead(txn_sm->q_server_vc, contp, txn_sm->q_server_response_buffer, INT_MAX);
+    txn_sm->q_server_read_vio = TSVConnRead(txn_sm->q_server_vc, contp, txn_sm->q_server_response_buffer, INT_MAX);
     break;
 
-    /* it could be failure of INKNetConnect */
+    /* it could be failure of TSNetConnect */
   default:
     return prepare_to_die(contp);
   }
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* Call correct handler according to the vio type. */
 int
-state_interface_with_server(INKCont contp, INKEvent event, INKVIO vio)
+state_interface_with_server(TSCont contp, TSEvent event, TSVIO vio)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_interface_with_server");
+  TSDebug("protocol", "enter state_interface_with_server");
 
   txn_sm->q_pending_action = NULL;
 
   switch (event) {
     /* This is returned from cache_vc. */
-  case INK_EVENT_VCONN_WRITE_READY:
-  case INK_EVENT_VCONN_WRITE_COMPLETE:
+  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. */
-  case INK_EVENT_VCONN_READ_READY:
+  case TS_EVENT_VCONN_READ_READY:
     /* Actually, we shouldn't get READ_COMPLETE because we set bytes
        count to be INT_MAX. */
-  case INK_EVENT_VCONN_READ_COMPLETE:
+  case TS_EVENT_VCONN_READ_COMPLETE:
     return state_read_response_from_server(contp, event, vio);
 
     /* all data of the response come in. */
-  case INK_EVENT_VCONN_EOS:
-    INKDebug("protocol", "get server eos");
+  case TS_EVENT_VCONN_EOS:
+    TSDebug("protocol", "get server eos");
     /* There is no more use of server_vc, close it. */
     if (txn_sm->q_server_vc) {
-      INKVConnClose(txn_sm->q_server_vc);
+      TSVConnClose(txn_sm->q_server_vc);
       txn_sm->q_server_vc = NULL;
     }
     txn_sm->q_server_read_vio = NULL;
@@ -573,7 +573,7 @@ state_interface_with_server(INKCont cont
     if (txn_sm->q_server_response_length == 0) {
       /* This is the bad response. Close client_vc. */
       if (txn_sm->q_client_vc) {
-        INKVConnClose(txn_sm->q_client_vc);
+        TSVConnClose(txn_sm->q_client_vc);
         txn_sm->q_client_vc = NULL;
       }
       txn_sm->q_client_read_vio = NULL;
@@ -581,7 +581,7 @@ state_interface_with_server(INKCont cont
 
       /* Close cache_vc as well. */
       if (txn_sm->q_cache_vc) {
-        INKVConnClose(txn_sm->q_cache_vc);
+        TSVConnClose(txn_sm->q_cache_vc);
         txn_sm->q_cache_vc = NULL;
       }
       txn_sm->q_cache_write_vio = NULL;
@@ -590,56 +590,56 @@ state_interface_with_server(INKCont cont
 
     if (txn_sm->q_cache_response_length >= txn_sm->q_server_response_length) {
       /* Write is complete, close the cache_vc. */
-      INKVConnClose(txn_sm->q_cache_vc);
+      TSVConnClose(txn_sm->q_cache_vc);
       txn_sm->q_cache_vc = NULL;
       txn_sm->q_cache_write_vio = NULL;
-      INKIOBufferReaderFree(txn_sm->q_cache_response_buffer_reader);
+      TSIOBufferReaderFree(txn_sm->q_cache_response_buffer_reader);
 
       /* Open cache_vc to read data and send to client. */
       set_handler(txn_sm->q_current_handler, &state_handle_cache_lookup);
-      txn_sm->q_pending_action = INKCacheRead(contp, txn_sm->q_key);
+      txn_sm->q_pending_action = TSCacheRead(contp, txn_sm->q_key);
     } else {                    /* not done with writing into cache */
 
-      INKDebug("protocol", "cache_response_length is %d, server response length is %d", txn_sm->q_cache_response_length,
+      TSDebug("protocol", "cache_response_length is %d, server response length is %d", txn_sm->q_cache_response_length,
                txn_sm->q_server_response_length);
-      INKVIOReenable(txn_sm->q_cache_write_vio);
+      TSVIOReenable(txn_sm->q_cache_write_vio);
     }
 
   default:
     break;
   }
 
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* The response comes in. If the origin server finishes writing, it
    will close the socket, so the event returned from the net_vc is
-   INK_EVENT_VCONN_EOS. By this event, TxnSM knows all data of the
+   TS_EVENT_VCONN_EOS. By this event, TxnSM knows all data of the
    response arrives and so parse it, save a copy in the cache and
    send the doc to the client. If reading is not done, reenable the
    read_vio. */
 int
-state_read_response_from_server(INKCont contp, INKEvent event, INKVIO vio)
+state_read_response_from_server(TSCont contp, TSEvent event, TSVIO vio)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
   int bytes_read = 0;
 
-  INKDebug("protocol", "enter state_read_response_from_server");
+  TSDebug("protocol", "enter state_read_response_from_server");
 
-  bytes_read = INKIOBufferReaderAvail(txn_sm->q_cache_response_buffer_reader);
+  bytes_read = TSIOBufferReaderAvail(txn_sm->q_cache_response_buffer_reader);
 
   if ((bytes_read > 0) && (txn_sm->q_cache_vc)) {
-    /* If this is the first write, do INKVConnWrite, otherwise, simply
+    /* 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 = INKVConnWrite(txn_sm->q_cache_vc,
+      txn_sm->q_cache_write_vio = TSVConnWrite(txn_sm->q_cache_vc,
                                                 contp, txn_sm->q_cache_response_buffer_reader, bytes_read);
     } else {
-      INKAssert(txn_sm->q_server_response_length > 0);
-      INKVIOReenable(txn_sm->q_cache_write_vio);
+      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 = INKVConnWrite (txn_sm->q_cache_vc,
+	    txn_sm->q_cache_write_vio = TSVConnWrite (txn_sm->q_cache_vc,
 						       contp,
 						       txn_sm->q_cache_response_buffer_reader,
 						       bytes_read);
@@ -648,59 +648,59 @@ state_read_response_from_server(INKCont 
   }
 
   txn_sm->q_server_response_length += bytes_read;
-  INKDebug("protocol", "bytes read is %d, total response length is %d", bytes_read, txn_sm->q_server_response_length);
+  TSDebug("protocol", "bytes read is %d, total response length is %d", bytes_read, txn_sm->q_server_response_length);
 
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* If the whole doc has been written into the cache, send the response
    to the client, otherwise, reenable the read_vio. */
 int
-state_write_to_cache(INKCont contp, INKEvent event, INKVIO vio)
+state_write_to_cache(TSCont contp, TSEvent event, TSVIO vio)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_write_to_cache");
+  TSDebug("protocol", "enter state_write_to_cache");
 
   switch (event) {
-  case INK_EVENT_VCONN_WRITE_READY:
-    INKVIOReenable(txn_sm->q_cache_write_vio);
-    return INK_SUCCESS;
-
-  case INK_EVENT_VCONN_WRITE_COMPLETE:
-    INKDebug("protocol", "nbytes %d, ndone %d", INKVIONBytesGet(vio), INKVIONDoneGet(vio));
-    /* Since the first write is through INKVConnWrite, which aleady consume
+  case TS_EVENT_VCONN_WRITE_READY:
+    TSVIOReenable(txn_sm->q_cache_write_vio);
+    return TS_SUCCESS;
+
+  case TS_EVENT_VCONN_WRITE_COMPLETE:
+    TSDebug("protocol", "nbytes %d, ndone %d", TSVIONBytesGet(vio), TSVIONDoneGet(vio));
+    /* Since the first write is through TSVConnWrite, which aleady consume
        the data in cache_buffer_reader, don't consume it again. */
     if (txn_sm->q_cache_response_length > 0 && txn_sm->q_block_bytes_read > 0)
-      INKIOBufferReaderConsume(txn_sm->q_cache_response_buffer_reader, txn_sm->q_block_bytes_read);
+      TSIOBufferReaderConsume(txn_sm->q_cache_response_buffer_reader, txn_sm->q_block_bytes_read);
 
-    txn_sm->q_cache_response_length += INKVIONBytesGet(vio);
+    txn_sm->q_cache_response_length += TSVIONBytesGet(vio);
 
     /* If not all data have been read in, we have to reenable the read_vio */
     if (txn_sm->q_server_vc != NULL) {
-      INKDebug("protocol", "reenable server_read_vio");
-      INKVIOReenable(txn_sm->q_server_read_vio);
-      return INK_SUCCESS;
+      TSDebug("protocol", "reenable server_read_vio");
+      TSVIOReenable(txn_sm->q_server_read_vio);
+      return TS_SUCCESS;
     }
 
     if (txn_sm->q_cache_response_length >= txn_sm->q_server_response_length) {
       /* Write is complete, close the cache_vc. */
-      INKDebug("protocol", "close cache_vc, cache_response_length is %d, server_response_lenght is %d",
+      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);
-      INKVConnClose(txn_sm->q_cache_vc);
+      TSVConnClose(txn_sm->q_cache_vc);
       txn_sm->q_cache_vc = NULL;
       txn_sm->q_cache_write_vio = NULL;
-      INKIOBufferReaderFree(txn_sm->q_cache_response_buffer_reader);
+      TSIOBufferReaderFree(txn_sm->q_cache_response_buffer_reader);
 
       /* Open cache_vc to read data and send to client. */
       set_handler(txn_sm->q_current_handler, &state_handle_cache_lookup);
-      txn_sm->q_pending_action = INKCacheRead(contp, txn_sm->q_key);
+      txn_sm->q_pending_action = TSCacheRead(contp, txn_sm->q_key);
     } else {                    /* not done with writing into cache */
 
-      INKDebug("protocol", "reenable cache_write_vio");
-      INKVIOReenable(txn_sm->q_cache_write_vio);
+      TSDebug("protocol", "reenable cache_write_vio");
+      TSVIOReenable(txn_sm->q_cache_write_vio);
     }
-    return INK_SUCCESS;
+    return TS_SUCCESS;
   default:
     break;
   }
@@ -713,25 +713,25 @@ state_write_to_cache(INKCont contp, INKE
    which means this txn is done, close the client_vc. Otherwise,
    reenable the write_vio. */
 int
-state_send_response_to_client(INKCont contp, INKEvent event, INKVIO vio)
+state_send_response_to_client(TSCont contp, TSEvent event, TSVIO vio)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_send_response_to_client");
+  TSDebug("protocol", "enter state_send_response_to_client");
 
   switch (event) {
-  case INK_EVENT_VCONN_WRITE_READY:
-    INKDebug("protocol", " . wr ready");
-    INKDebug("protocol", "write_ready: nbytes %d, ndone %d", INKVIONBytesGet(vio), INKVIONDoneGet(vio));
-    INKVIOReenable(txn_sm->q_client_write_vio);
+  case TS_EVENT_VCONN_WRITE_READY:
+    TSDebug("protocol", " . wr ready");
+    TSDebug("protocol", "write_ready: nbytes %d, ndone %d", TSVIONBytesGet(vio), TSVIONDoneGet(vio));
+    TSVIOReenable(txn_sm->q_client_write_vio);
     break;
 
-  case INK_EVENT_VCONN_WRITE_COMPLETE:
-    INKDebug("protocol", " . wr complete");
-    INKDebug("protocol", "write_complete: nbytes %d, ndone %d", INKVIONBytesGet(vio), INKVIONDoneGet(vio));
+  case TS_EVENT_VCONN_WRITE_COMPLETE:
+    TSDebug("protocol", " . wr complete");
+    TSDebug("protocol", "write_complete: nbytes %d, ndone %d", TSVIONBytesGet(vio), TSVIONDoneGet(vio));
     /* Finished sending all data to client, close client_vc. */
     if (txn_sm->q_client_vc) {
-      INKVConnClose(txn_sm->q_client_vc);
+      TSVConnClose(txn_sm->q_client_vc);
       txn_sm->q_client_vc = NULL;
     }
     txn_sm->q_client_read_vio = NULL;
@@ -740,41 +740,41 @@ state_send_response_to_client(INKCont co
     return state_done(contp, 0, NULL);
 
   default:
-    INKDebug("protocol", " . default handler");
+    TSDebug("protocol", " . default handler");
     return prepare_to_die(contp);
 
   }
 
-  INKDebug("protocol", "leaving send_response_to_client");
+  TSDebug("protocol", "leaving send_response_to_client");
 
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 
 /* There is something wrong, abort client, server and cache vc
    if they exist. */
 int
-prepare_to_die(INKCont contp)
+prepare_to_die(TSCont contp)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter prepare_to_die");
+  TSDebug("protocol", "enter prepare_to_die");
   if (txn_sm->q_client_vc) {
-    INKVConnAbort(txn_sm->q_client_vc, 1);
+    TSVConnAbort(txn_sm->q_client_vc, 1);
     txn_sm->q_client_vc = NULL;
   }
   txn_sm->q_client_read_vio = NULL;
   txn_sm->q_client_write_vio = NULL;
 
   if (txn_sm->q_server_vc) {
-    INKVConnAbort(txn_sm->q_server_vc, 1);
+    TSVConnAbort(txn_sm->q_server_vc, 1);
     txn_sm->q_server_vc = NULL;
   }
   txn_sm->q_server_read_vio = NULL;
   txn_sm->q_server_write_vio = NULL;
 
   if (txn_sm->q_cache_vc) {
-    INKVConnAbort(txn_sm->q_cache_vc, 1);
+    TSVConnAbort(txn_sm->q_cache_vc, 1);
     txn_sm->q_cache_vc = NULL;
   }
   txn_sm->q_cache_read_vio = NULL;
@@ -784,17 +784,17 @@ prepare_to_die(INKCont contp)
 }
 
 int
-state_done(INKCont contp, INKEvent event, INKVIO vio)
+state_done(TSCont contp, TSEvent event, TSVIO vio)
 {
-  TxnSM *txn_sm = (TxnSM *) INKContDataGet(contp);
+  TxnSM *txn_sm = (TxnSM *) TSContDataGet(contp);
 
-  INKDebug("protocol", "enter state_done");
+  TSDebug("protocol", "enter state_done");
 
-  if (txn_sm->q_pending_action && !INKActionDone(txn_sm->q_pending_action)) {
-    INKDebug("protocol", "cancelling pending action %p", txn_sm->q_pending_action);
-    INKActionCancel(txn_sm->q_pending_action);
+  if (txn_sm->q_pending_action && !TSActionDone(txn_sm->q_pending_action)) {
+    TSDebug("protocol", "cancelling pending action %p", txn_sm->q_pending_action);
+    TSActionCancel(txn_sm->q_pending_action);
   } else if (txn_sm->q_pending_action) {
-    INKDebug("protocol", "action is done %p", txn_sm->q_pending_action);
+    TSDebug("protocol", "action is done %p", txn_sm->q_pending_action);
   }
 
   txn_sm->q_pending_action = NULL;
@@ -802,121 +802,121 @@ state_done(INKCont contp, INKEvent event
 
   if (txn_sm->q_client_request_buffer) {
     if (txn_sm->q_client_request_buffer_reader)
-      INKIOBufferReaderFree(txn_sm->q_client_request_buffer_reader);
-    INKIOBufferDestroy(txn_sm->q_client_request_buffer);
+      TSIOBufferReaderFree(txn_sm->q_client_request_buffer_reader);
+    TSIOBufferDestroy(txn_sm->q_client_request_buffer);
     txn_sm->q_client_request_buffer = NULL;
     txn_sm->q_client_request_buffer_reader = NULL;
   }
 
   if (txn_sm->q_client_response_buffer) {
     if (txn_sm->q_client_response_buffer_reader)
-      INKIOBufferReaderFree(txn_sm->q_client_response_buffer_reader);
+      TSIOBufferReaderFree(txn_sm->q_client_response_buffer_reader);
 
-    INKIOBufferDestroy(txn_sm->q_client_response_buffer);
+    TSIOBufferDestroy(txn_sm->q_client_response_buffer);
     txn_sm->q_client_response_buffer = NULL;
     txn_sm->q_client_response_buffer_reader = NULL;
   }
 
   if (txn_sm->q_cache_read_buffer) {
     if (txn_sm->q_cache_read_buffer_reader)
-      INKIOBufferReaderFree(txn_sm->q_cache_read_buffer_reader);
-    INKIOBufferDestroy(txn_sm->q_cache_read_buffer);
+      TSIOBufferReaderFree(txn_sm->q_cache_read_buffer_reader);
+    TSIOBufferDestroy(txn_sm->q_cache_read_buffer);
     txn_sm->q_cache_read_buffer = NULL;
     txn_sm->q_cache_read_buffer_reader = NULL;
   }
 
   if (txn_sm->q_server_request_buffer) {
     if (txn_sm->q_server_request_buffer_reader)
-      INKIOBufferReaderFree(txn_sm->q_server_request_buffer_reader);
-    INKIOBufferDestroy(txn_sm->q_server_request_buffer);
+      TSIOBufferReaderFree(txn_sm->q_server_request_buffer_reader);
+    TSIOBufferDestroy(txn_sm->q_server_request_buffer);
     txn_sm->q_server_request_buffer = NULL;
     txn_sm->q_server_request_buffer_reader = NULL;
   }
 
   if (txn_sm->q_server_response_buffer) {
-    INKIOBufferDestroy(txn_sm->q_server_response_buffer);
+    TSIOBufferDestroy(txn_sm->q_server_response_buffer);
     txn_sm->q_server_response_buffer = NULL;
   }
 
   if (txn_sm->q_server_name) {
-    INKfree(txn_sm->q_server_name);
+    TSfree(txn_sm->q_server_name);
     txn_sm->q_server_name = NULL;
   }
 
   if (txn_sm->q_file_name) {
-    INKfree(txn_sm->q_file_name);
+    TSfree(txn_sm->q_file_name);
     txn_sm->q_file_name = NULL;
   }
 
   if (txn_sm->q_key)
-    INKCacheKeyDestroy(txn_sm->q_key);
+    TSCacheKeyDestroy(txn_sm->q_key);
 
   if (txn_sm->q_client_request) {
-    INKfree(txn_sm->q_client_request);
+    TSfree(txn_sm->q_client_request);
     txn_sm->q_client_request = NULL;
   }
 
   if (txn_sm->q_server_response) {
-    INKfree(txn_sm->q_server_response);
+    TSfree(txn_sm->q_server_response);
     txn_sm->q_server_response = NULL;
   }
 
   if (txn_sm) {
     txn_sm->q_magic = TXN_SM_DEAD;
-    INKfree(txn_sm);
+    TSfree(txn_sm);
   }
-  INKContDestroy(contp);
-  return INK_EVENT_NONE;
+  TSContDestroy(contp);
+  return TS_EVENT_NONE;
 }
 
 /* Write the data into the client_vc. */
 int
-send_response_to_client(INKCont contp)
+send_response_to_client(TSCont contp)
 {
   TxnSM *txn_sm;
   int response_len;
 
-  INKDebug("protocol", "enter send_response_to_client");
+  TSDebug("protocol", "enter send_response_to_client");
 
-  txn_sm = (TxnSM *) INKContDataGet(contp);
-  response_len = INKIOBufferReaderAvail(txn_sm->q_client_response_buffer_reader);
+  txn_sm = (TxnSM *) TSContDataGet(contp);
+  response_len = TSIOBufferReaderAvail(txn_sm->q_client_response_buffer_reader);
 
-  INKDebug("protocol", " . resp_len is %d, response_len");
+  TSDebug("protocol", " . resp_len is %d, response_len");
 
   set_handler(txn_sm->q_current_handler, &state_interface_with_client);
-  txn_sm->q_client_write_vio = INKVConnWrite(txn_sm->q_client_vc, (INKCont) contp,
+  txn_sm->q_client_write_vio = TSVConnWrite(txn_sm->q_client_vc, (TSCont) contp,
                                              txn_sm->q_client_response_buffer_reader, response_len);
-  return INK_SUCCESS;
+  return TS_SUCCESS;
 }
 
 /* Read data out through the_reader and save it in a char buffer. */
 char *
-get_info_from_buffer(INKIOBufferReader the_reader)
+get_info_from_buffer(TSIOBufferReader the_reader)
 {
   char *info;
   char *info_start;
 
   int64 read_avail, read_done;
-  INKIOBufferBlock blk;
+  TSIOBufferBlock blk;
   char *buf;
 
   if (!the_reader)
     return NULL;
 
-  read_avail = INKIOBufferReaderAvail(the_reader);
+  read_avail = TSIOBufferReaderAvail(the_reader);
 
-  info = (char *) INKmalloc(sizeof(char) * read_avail);
+  info = (char *) TSmalloc(sizeof(char) * read_avail);
   if (info == NULL)
     return NULL;
   info_start = info;
 
   /* Read the data out of the reader */
   while (read_avail > 0) {
-    blk = INKIOBufferReaderStart(the_reader);
-    buf = (char *) INKIOBufferBlockReadStart(blk, the_reader, &read_done);
+    blk = TSIOBufferReaderStart(the_reader);
+    buf = (char *) TSIOBufferBlockReadStart(blk, the_reader, &read_done);
     memcpy(info, buf, read_done);
     if (read_done > 0) {
-      INKIOBufferReaderConsume(the_reader, read_done);
+      TSIOBufferReaderConsume(the_reader, read_done);
       read_avail -= read_done;
       info += read_done;
     }
@@ -956,20 +956,20 @@ parse_request(char *request, char *serve
 
 /* Create 128-bit cache key based on the input string, in this case,
    the file_name of the requested doc. */
-INKCacheKey
+TSCacheKey
 CacheKeyCreate(char *file_name)
 {
-  INKCacheKey key;
-  INKReturnCode return_code;
+  TSCacheKey key;
+  TSReturnCode return_code;
 
-  /* INKCacheKeyCreate is to allocate memory space for the key */
-  return_code = INKCacheKeyCreate(&key);
-  if (return_code != INK_SUCCESS) {
-    INKError("Can't create cache key");
-    return (INKCacheKey) INK_ERROR_PTR;
+  /* TSCacheKeyCreate is to allocate memory space for the key */
+  return_code = TSCacheKeyCreate(&key);
+  if (return_code != TS_SUCCESS) {
+    TSError("Can't create cache key");
+    return (TSCacheKey) TS_ERROR_PTR;
   }
 
-  /* INKCacheKeyDigestSet is to compute INKCackeKey from the input string */
-  INKCacheKeyDigestSet(key, (unsigned char *) file_name, strlen(file_name));
+  /* TSCacheKeyDigestSet is to compute TSCackeKey from the input string */
+  TSCacheKeyDigestSet(key, (unsigned char *) file_name, strlen(file_name));
   return key;
 }

Modified: trafficserver/traffic/trunk/example/protocol/TxnSM.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/protocol/TxnSM.h?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/protocol/TxnSM.h (original)
+++ trafficserver/traffic/trunk/example/protocol/TxnSM.h Tue Nov 16 20:22:02 2010
@@ -26,9 +26,9 @@
 
 #include "Protocol.h"
 
-typedef int (*TxnSMHandler) (INKCont contp, INKEvent event, void *data);
+typedef int (*TxnSMHandler) (TSCont contp, TSEvent event, void *data);
 
-INKCont TxnSMCreate(INKMutex pmutex, INKVConn client_vc, int server_port);
+TSCont TxnSMCreate(TSMutex pmutex, TSVConn client_vc, int server_port);
 
 #define TXN_SM_ALIVE 0xAAAA0123
 #define TXN_SM_DEAD  0xFEE1DEAD
@@ -39,12 +39,12 @@ typedef struct _TxnSM
 {
   unsigned int q_magic;
 
-  INKMutex q_mutex;
-  INKAction q_pending_action;
+  TSMutex q_mutex;
+  TSAction q_pending_action;
   TxnSMHandler q_current_handler;
 
-  INKVConn q_client_vc;
-  INKVConn q_server_vc;
+  TSVConn q_client_vc;
+  TSVConn q_server_vc;
 
   char *q_client_request;
   char *q_server_response;
@@ -56,29 +56,29 @@ typedef struct _TxnSM
   uint32 q_server_ip;
   int q_server_port;
 
-  INKVIO q_client_read_vio;
-  INKVIO q_client_write_vio;
-  INKIOBuffer q_client_request_buffer;
-  INKIOBuffer q_client_response_buffer;
-  INKIOBufferReader q_client_request_buffer_reader;
-  INKIOBufferReader q_client_response_buffer_reader;
-
-  INKVIO q_server_read_vio;
-  INKVIO q_server_write_vio;
-  INKIOBuffer q_server_request_buffer;
-  INKIOBuffer q_server_response_buffer;
-  INKIOBufferReader q_server_request_buffer_reader;
+  TSVIO q_client_read_vio;
+  TSVIO q_client_write_vio;
+  TSIOBuffer q_client_request_buffer;
+  TSIOBuffer q_client_response_buffer;
+  TSIOBufferReader q_client_request_buffer_reader;
+  TSIOBufferReader q_client_response_buffer_reader;
+
+  TSVIO q_server_read_vio;
+  TSVIO q_server_write_vio;
+  TSIOBuffer q_server_request_buffer;
+  TSIOBuffer q_server_response_buffer;
+  TSIOBufferReader q_server_request_buffer_reader;
   int q_server_response_length;
   int q_block_bytes_read;
   int q_cache_response_length;
 
   /* Cache related */
-  INKVConn q_cache_vc;
-  INKIOBufferReader q_cache_response_buffer_reader;
-  INKVIO q_cache_read_vio;
-  INKVIO q_cache_write_vio;
-  INKIOBuffer q_cache_read_buffer;
-  INKIOBufferReader q_cache_read_buffer_reader;
+  TSVConn q_cache_vc;
+  TSIOBufferReader q_cache_response_buffer_reader;
+  TSVIO q_cache_read_vio;
+  TSVIO q_cache_write_vio;
+  TSIOBuffer q_cache_read_buffer;
+  TSIOBufferReader q_cache_read_buffer_reader;
 
 } TxnSM;
 

Modified: trafficserver/traffic/trunk/example/query_remap/query_remap.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/query_remap/query_remap.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/query_remap/query_remap.c (original)
+++ trafficserver/traffic/trunk/example/query_remap/query_remap.c Tue Nov 16 20:22:02 2010
@@ -43,7 +43,7 @@ typedef struct _query_remap_info {
 int tsremap_init(TSRemapInterface *api_info,char *errbuf,int errbuf_size)
 {
   /* Called at TS startup. Nothing needed for this plugin */
-  INKDebug(PLUGIN_NAME , "remap plugin initialized");
+  TSDebug(PLUGIN_NAME , "remap plugin initialized");
   return 0;
 }
 
@@ -52,10 +52,10 @@ int tsremap_new_instance(int argc,char *
 {
   /* Called for each remap rule using this plugin. The parameters are parsed here */
   int i;
-  INKDebug(PLUGIN_NAME, "new instance fromURL: %s toURL: %s", argv[0], argv[1]);
+  TSDebug(PLUGIN_NAME, "new instance fromURL: %s toURL: %s", argv[0], argv[1]);
 
   if (argc < 4) {
-    INKError("Missing parameters for " PLUGIN_NAME);
+    TSError("Missing parameters for " PLUGIN_NAME);
     return -1;
   }
 
@@ -66,23 +66,23 @@ int tsremap_new_instance(int argc,char *
        2: query param to hash
        3,4,... : server hostnames
   */
-  query_remap_info *qri = (query_remap_info*) INKmalloc(sizeof(query_remap_info));
+  query_remap_info *qri = (query_remap_info*) TSmalloc(sizeof(query_remap_info));
 
-  qri->param_name = INKstrdup(argv[2]);
+  qri->param_name = TSstrdup(argv[2]);
   qri->param_len = strlen(qri->param_name);
   qri->num_hosts = argc - 3;
-  qri->hosts = (char**) INKmalloc(qri->num_hosts*sizeof(char*));
+  qri->hosts = (char**) TSmalloc(qri->num_hosts*sizeof(char*));
 
-  INKDebug(PLUGIN_NAME, " - Hash using query parameter [%s] with %d 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] = INKstrdup(argv[i+3]);
-    INKDebug(PLUGIN_NAME, " - Host %d: %s", i, qri->hosts[i]);
+    qri->hosts[i] = TSstrdup(argv[i+3]);
+    TSDebug(PLUGIN_NAME, " - Host %d: %s", i, qri->hosts[i]);
   }
 
   *ih = (ihandle)qri;
-  INKDebug(PLUGIN_NAME, "created instance %p", *ih);
+  TSDebug(PLUGIN_NAME, "created instance %p", *ih);
   return 0;
 }
 
@@ -90,19 +90,19 @@ void tsremap_delete_instance(ihandle ih)
 {
   /* Release instance memory allocated in tsremap_new_instance */
   int i;
-  INKDebug(PLUGIN_NAME, "deleting instance %p", ih);
+  TSDebug(PLUGIN_NAME, "deleting instance %p", ih);
 
   if (ih) {
     query_remap_info *qri = (query_remap_info*)ih;
     if (qri->param_name)
-      INKfree(qri->param_name);
+      TSfree(qri->param_name);
     if (qri->hosts) {
       for (i=0; i < qri->num_hosts; ++i) {
-        INKfree(qri->hosts[i]);
+        TSfree(qri->hosts[i]);
       }
-      INKfree(qri->hosts);
+      TSfree(qri->hosts);
     }
-    INKfree(qri);
+    TSfree(qri);
   }
 }
 
@@ -113,18 +113,18 @@ int tsremap_remap(ihandle ih, rhandle rh
   query_remap_info *qri = (query_remap_info*)ih;
 
   if (!qri) {
-    INKError(PLUGIN_NAME "NULL ihandle");
+    TSError(PLUGIN_NAME "NULL ihandle");
     return 0;
   }
 
-  INKDebug(PLUGIN_NAME, "tsremap_remap request: %.*s", rri->orig_url_size, rri->orig_url);
+  TSDebug(PLUGIN_NAME, "tsremap_remap request: %.*s", rri->orig_url_size, rri->orig_url);
 
   if (rri && rri->request_query && rri->request_query_size > 0) {
     char *q, *key;
     char *s = NULL;
 
     /* make a copy of the query, as it is read only */
-    q = (char*) INKmalloc(rri->request_query_size+1);
+    q = (char*) TSmalloc(rri->request_query_size+1);
     strncpy(q, rri->request_query, rri->request_query_size);
     q[rri->request_query_size] = '\0';
 
@@ -137,13 +137,13 @@ int tsremap_remap(ihandle ih, rhandle rh
         /* the param key matched the configured param_name
            hash the param value to pick a host */
         hostidx = hash_fnv32(val, strlen(val)) % (uint32_t)qri->num_hosts;
-        INKDebug(PLUGIN_NAME, "modifying host based on %s", key);
+        TSDebug(PLUGIN_NAME, "modifying host based on %s", key);
         break;
       }
       key = strtok_r(NULL, "&", &s);
     }
 
-    INKfree(q);
+    TSfree(q);
 
     if (hostidx >= 0) {
       rri->new_host_size = strlen(qri->hosts[hostidx]);
@@ -151,7 +151,7 @@ int tsremap_remap(ihandle ih, rhandle rh
         /* copy the chosen host into rri */
         memcpy(rri->new_host, qri->hosts[hostidx], rri->new_host_size);
 
-        INKDebug(PLUGIN_NAME, "host changed from [%.*s] to [%.*s]",
+        TSDebug(PLUGIN_NAME, "host changed from [%.*s] to [%.*s]",
                  rri->request_host_size, rri->request_host,
                  rri->new_host_size, rri->new_host);
         return 1; /* host has been modified */
@@ -160,7 +160,7 @@ int tsremap_remap(ihandle ih, rhandle rh
   }
 
   /* the request was not modified, TS will use the toURL from the remap rule */
-  INKDebug(PLUGIN_NAME, "request not modified");
+  TSDebug(PLUGIN_NAME, "request not modified");
   return 0;
 }
 

Modified: trafficserver/traffic/trunk/example/redirect-1/redirect-1.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/redirect-1/redirect-1.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/redirect-1/redirect-1.c (original)
+++ trafficserver/traffic/trunk/example/redirect-1/redirect-1.c Tue Nov 16 20:22:02 2010
@@ -80,7 +80,7 @@ static INKStat requests_redirects;
 static INKStat requests_unchanged;
 
 
-void update_redirected_method_stats(INKMBuffer bufp, INKMLoc hdr_loc);
+void update_redirected_method_stats(TSMBuffer bufp, TSMLoc hdr_loc);
 
 static char *url_redirect;
 static char *uri_redirect;
@@ -88,10 +88,10 @@ static char *block_ip;
 
 
 static void
-handle_client_lookup(INKHttpTxn txnp, INKCont contp)
+handle_client_lookup(TSHttpTxn txnp, TSCont contp)
 {
-  INKMBuffer bufp;
-  INKMLoc hdr_loc, url_loc;
+  TSMBuffer bufp;
+  TSMLoc hdr_loc, url_loc;
   int host_length;
 
 #if !defined (_WIN32)
@@ -138,33 +138,33 @@ handle_client_lookup(INKHttpTxn txnp, IN
 
 
 #if !defined (_WIN32)
-  clientip = (in_addr_t) INKHttpTxnClientIPGet(txnp);
+  clientip = (in_addr_t) TSHttpTxnClientIPGet(txnp);
 #else
-  clientip = INKHttpTxnClientIPGet(txnp);
+  clientip = TSHttpTxnClientIPGet(txnp);
 #endif
 
 
   tempstruct.s_addr = clientip;
   clientstring = inet_ntoa(tempstruct);
-  INKDebug("redirect", "clientip is %s and block_ip is %s", clientstring, block_ip);
+  TSDebug("redirect", "clientip is %s and block_ip is %s", clientstring, block_ip);
 
-  if (!INKHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
-    INKError("couldn't retrieve client request header\n");
+  if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+    TSError("couldn't retrieve client request header\n");
     goto done;
   }
 
-  url_loc = INKHttpHdrUrlGet(bufp, hdr_loc);
+  url_loc = TSHttpHdrUrlGet(bufp, hdr_loc);
   if (!url_loc) {
-    INKError("couldn't retrieve request url\n");
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSError("couldn't retrieve request url\n");
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     goto done;
   }
 
-  host = INKUrlHostGet(bufp, url_loc, &host_length);
+  host = TSUrlHostGet(bufp, url_loc, &host_length);
   if (!host) {
-    INKError("couldn't retrieve request hostname\n");
-    INKHandleMLocRelease(bufp, hdr_loc, url_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSError("couldn't retrieve request hostname\n");
+    TSHandleMLocRelease(bufp, hdr_loc, url_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     goto done;
   }
 
@@ -172,21 +172,21 @@ handle_client_lookup(INKHttpTxn txnp, IN
    *   Check to see if the client is already headed to the redirect site.
    */
   if (strncmp(host, url_redirect, host_length) == 0) {
-    INKHandleStringRelease(bufp, url_loc, host);
-    INKHandleMLocRelease(bufp, hdr_loc, url_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleStringRelease(bufp, url_loc, host);
+    TSHandleMLocRelease(bufp, hdr_loc, url_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     goto done;
   }
 
   if (ip_deny == clientip) {
 
-    INKHttpTxnHookAdd(txnp, INK_HTTP_SEND_RESPONSE_HDR_HOOK, contp);
-    INKHandleStringRelease(bufp, url_loc, host);
+    TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, contp);
+    TSHandleStringRelease(bufp, url_loc, host);
 
     update_redirected_method_stats(bufp, hdr_loc);
 
-    INKHandleMLocRelease(bufp, hdr_loc, url_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, hdr_loc, url_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
 
     /*
      *   Increment the local redirect stat and do global update:
@@ -195,7 +195,7 @@ handle_client_lookup(INKHttpTxn txnp, IN
     INKStatsCoupledUpdate(local_request_outcomes);
     INKStatCoupledLocalCopyDestroy(local_request_outcomes);
 
-    INKHttpTxnReenable(txnp, INK_EVENT_HTTP_ERROR);
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_ERROR);
     return;
   }
 
@@ -207,64 +207,64 @@ done:
   INKStatsCoupledUpdate(local_request_outcomes);
   INKStatCoupledLocalCopyDestroy(local_request_outcomes);
 
-  INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
 }
 
 
 
 static void
-handle_response(INKHttpTxn txnp)
+handle_response(TSHttpTxn txnp)
 {
-  INKMBuffer bufp;
-  INKMLoc hdr_loc, newfield_loc;
+  TSMBuffer bufp;
+  TSMLoc hdr_loc, newfield_loc;
   char *errormsg_body = "All requests from this IP address are redirected.\n";
   char *tmp_body;
 
-  if (!INKHttpTxnClientRespGet(txnp, &bufp, &hdr_loc)) {
-    INKError("couldn't retrieve client response header\n");
+  if (!TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc)) {
+    TSError("couldn't retrieve client response header\n");
     goto done;
   }
 
-  INKHttpHdrStatusSet(bufp, hdr_loc, INK_HTTP_STATUS_MOVED_PERMANENTLY);
-  INKHttpHdrReasonSet(bufp, hdr_loc,
-                      INKHttpHdrReasonLookup(INK_HTTP_STATUS_MOVED_PERMANENTLY),
-                      strlen(INKHttpHdrReasonLookup(INK_HTTP_STATUS_MOVED_PERMANENTLY)));
-
-  newfield_loc = INKMimeHdrFieldCreate(bufp, hdr_loc);
-  INKMimeHdrFieldNameSet(bufp, hdr_loc, newfield_loc, INK_MIME_FIELD_LOCATION, INK_MIME_LEN_LOCATION);
-  INKMimeHdrFieldValueStringInsert(bufp, hdr_loc, newfield_loc, -1, uri_redirect, strlen(uri_redirect));
-  INKMimeHdrFieldAppend(bufp, hdr_loc, newfield_loc);
+  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)));
+
+  newfield_loc = TSMimeHdrFieldCreate(bufp, hdr_loc);
+  TSMimeHdrFieldNameSet(bufp, hdr_loc, newfield_loc, TS_MIME_FIELD_LOCATION, TS_MIME_LEN_LOCATION);
+  TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, newfield_loc, -1, uri_redirect, strlen(uri_redirect));
+  TSMimeHdrFieldAppend(bufp, hdr_loc, newfield_loc);
 
 
   /*
-   *  Note that we can't directly use errormsg_body, as INKHttpTxnErrorBodySet()
-   *  will try to free the passed buffer with INKfree().
+   *  Note that we can't directly use errormsg_body, as TSHttpTxnErrorBodySet()
+   *  will try to free the passed buffer with TSfree().
    */
-  tmp_body = INKstrdup(errormsg_body);
-  INKHttpTxnErrorBodySet(txnp, tmp_body, strlen(tmp_body), NULL);
-  INKHandleMLocRelease(bufp, hdr_loc, newfield_loc);
-  INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+  tmp_body = TSstrdup(errormsg_body);
+  TSHttpTxnErrorBodySet(txnp, tmp_body, strlen(tmp_body), NULL);
+  TSHandleMLocRelease(bufp, hdr_loc, newfield_loc);
+  TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
 
 
 done:
-  INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
 }
 
 
 
 static int
-redirect_plugin(INKCont contp, INKEvent event, void *edata)
+redirect_plugin(TSCont contp, TSEvent event, void *edata)
 {
 
-  INKHttpTxn txnp = (INKHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn) edata;
 
   switch (event) {
-  case INK_EVENT_HTTP_READ_REQUEST_HDR:
+  case TS_EVENT_HTTP_READ_REQUEST_HDR:
 
     handle_client_lookup(txnp, contp);
     return 0;
 
-  case INK_EVENT_HTTP_SEND_RESPONSE_HDR:
+  case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
 
     handle_response(txnp);
     return 0;
@@ -309,50 +309,50 @@ init_stats(void)
 /*
  *	This function is only called for redirected requests.  It illustrates
  *	several different ways of updating INT64 stats.  Some may consider
- *	the particular use of INKDecrementStat() shown below somewhat contrived.
+ *	the particular use of TSDecrementStat() shown below somewhat contrived.
  */
 void
-update_redirected_method_stats(INKMBuffer bufp, INKMLoc hdr_loc)
+update_redirected_method_stats(TSMBuffer bufp, TSMLoc hdr_loc)
 {
   const char *txn_method;
   int length;
   int64 tempint;
 
-  txn_method = INKHttpHdrMethodGet(bufp, hdr_loc, &length);
+  txn_method = TSHttpHdrMethodGet(bufp, hdr_loc, &length);
 
   if (NULL != txn_method) {
-    if (0 == strncmp(txn_method, INK_HTTP_METHOD_CONNECT, length))
+    if (0 == strncmp(txn_method, TS_HTTP_METHOD_CONNECT, length))
       INKStatIncrement(method_count_redirected_connect);
-    else if (0 == strncmp(txn_method, INK_HTTP_METHOD_DELETE, length))
+    else if (0 == strncmp(txn_method, TS_HTTP_METHOD_DELETE, length))
       INKStatIncrement(method_count_redirected_delete);
-    else if (0 == strncmp(txn_method, INK_HTTP_METHOD_GET, length))
+    else if (0 == strncmp(txn_method, TS_HTTP_METHOD_GET, length))
       INKStatIncrement(method_count_redirected_get);
 
-    else if (0 == strncmp(txn_method, INK_HTTP_METHOD_HEAD, length))
+    else if (0 == strncmp(txn_method, TS_HTTP_METHOD_HEAD, length))
       INKStatFloatAddTo(method_count_redirected_head, 1);
-    else if (0 == strncmp(txn_method, INK_HTTP_METHOD_ICP_QUERY, length))
+    else if (0 == strncmp(txn_method, TS_HTTP_METHOD_ICP_QUERY, length))
       INKStatFloatAddTo(method_count_redirected_icp_query, 1);
 
-    else if (0 == strncmp(txn_method, INK_HTTP_METHOD_OPTIONS, length)) {
+    else if (0 == strncmp(txn_method, TS_HTTP_METHOD_OPTIONS, length)) {
       INKStatIntGet(method_count_redirected_options, &tempint);
       tempint++;
       INKStatIntSet(method_count_redirected_options, tempint);
-    } else if (0 == strncmp(txn_method, INK_HTTP_METHOD_POST, length)) {
+    } else if (0 == strncmp(txn_method, TS_HTTP_METHOD_POST, length)) {
       INKStatDecrement(method_count_redirected_post);
       INKStatIncrement(method_count_redirected_post);
       INKStatIncrement(method_count_redirected_post);
     }
 
-    else if (0 == strncmp(txn_method, INK_HTTP_METHOD_PURGE, length))
+    else if (0 == strncmp(txn_method, TS_HTTP_METHOD_PURGE, length))
       INKStatIncrement(method_count_redirected_purge);
-    else if (0 == strncmp(txn_method, INK_HTTP_METHOD_PUT, length))
+    else if (0 == strncmp(txn_method, TS_HTTP_METHOD_PUT, length))
       INKStatIncrement(method_count_redirected_put);
-    else if (0 == strncmp(txn_method, INK_HTTP_METHOD_TRACE, length))
+    else if (0 == strncmp(txn_method, TS_HTTP_METHOD_TRACE, length))
       INKStatIncrement(method_count_redirected_trace);
     else
       INKStatIncrement(method_count_redirected_unknown);
   }
-  INKHandleStringRelease(bufp, hdr_loc, txn_method);
+  TSHandleStringRelease(bufp, hdr_loc, txn_method);
 
 }
 
@@ -360,7 +360,7 @@ int
 check_ts_version()
 {
 
-  const char *ts_version = INKTrafficServerVersionGet();
+  const char *ts_version = TSTrafficServerVersionGet();
   int result = 0;
 
   if (ts_version) {
@@ -383,52 +383,52 @@ check_ts_version()
 }
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
   const char prefix[] = "http://";
   int uri_len;
-  INKPluginRegistrationInfo info;
+  TSPluginRegistrationInfo info;
 
   info.plugin_name = "redirect-1";
   info.vendor_name = "MyCompany";
   info.support_email = "ts-api-support@MyCompany.com";
 
-  if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) {
-    INKError("Plugin registration failed.\n");
+  if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+    TSError("Plugin registration failed.\n");
   }
 
   if (!check_ts_version()) {
-    INKError("Plugin requires Traffic Server 2.0 or later\n");
+    TSError("Plugin requires Traffic Server 2.0 or later\n");
     return;
   }
 
   if (argc == 3) {
-    block_ip = INKstrdup(argv[1]);
+    block_ip = TSstrdup(argv[1]);
 
     /*
      *   The Location header must contain an absolute URI:
      */
 
-    url_redirect = INKstrdup(argv[2]);
+    url_redirect = TSstrdup(argv[2]);
     uri_len = strlen(prefix) + strlen(url_redirect) + 1;
-    uri_redirect = INKmalloc(uri_len);
+    uri_redirect = TSmalloc(uri_len);
     strcpy(uri_redirect, prefix);
     strcat(uri_redirect, url_redirect);
 
   } else {
-    INKError("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;
   }
 
   ip_deny = inet_addr(block_ip);
 
-  INKDebug("redirect_init", "initializing stats...");
+  TSDebug("redirect_init", "initializing stats...");
   init_stats();
-  INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, INKContCreate(redirect_plugin, NULL));
+  TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(redirect_plugin, NULL));
 
-  INKDebug("redirect_init", "block_ip is %s, url_redirect is %s, and uri_redirect is %s",
+  TSDebug("redirect_init", "block_ip is %s, url_redirect is %s, and uri_redirect is %s",
            block_ip, url_redirect, uri_redirect);
-  INKDebug("redirect_init", "ip_deny is %ld\n", ip_deny);
+  TSDebug("redirect_init", "ip_deny is %ld\n", ip_deny);
 
   /*
    *  Demonstrate another tracing function.  This can be used to
@@ -436,8 +436,8 @@ INKPluginInit(int argc, const char *argv
    *  be done in debug mode.
    */
 
-  if (INKIsDebugTagSet("redirect_demo"))
-    INKDebug("redirect_init", "The redirect_demo tag is set");
+  if (TSIsDebugTagSet("redirect_demo"))
+    TSDebug("redirect_init", "The redirect_demo tag is set");
   else
-    INKDebug("redirect_init", "The redirect_demo tag is not set");
+    TSDebug("redirect_init", "The redirect_demo tag is not set");
 }

Modified: trafficserver/traffic/trunk/example/remap/remap.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/remap/remap.cc?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/remap/remap.cc (original)
+++ trafficserver/traffic/trunk/example/remap/remap.cc Tue Nov 16 20:22:02 2010
@@ -174,17 +174,17 @@ my_print_ascii_string(const char *str, i
 }
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
-  INKPluginRegistrationInfo info;
+  TSPluginRegistrationInfo info;
   info.plugin_name = (char*)"remap_plugin";
   info.vendor_name = (char*)"Apache";
   info.support_email = (char*)"";
 
-  if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) {
-    INKError("Plugin registration failed. \n");
+  if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+    TSError("Plugin registration failed. \n");
   }
-  INKDebug("debug-remap", "INKPluginInit: Remap plugin started\n");
+  TSDebug("debug-remap", "TSPluginInit: Remap plugin started\n");
 }
 
 // Plugin initialization code. Called immediately after dlopen() Only once!
@@ -288,9 +288,9 @@ int
 tsremap_remap(ihandle ih, rhandle rh, TSRemapRequestInfo * rri)
 {
   char *p;
-  INKMBuffer cbuf;
-  INKMLoc chdr;
-  INKMLoc cfield;
+  TSMBuffer cbuf;
+  TSMLoc chdr;
+  TSMLoc cfield;
   int retcode = 0;              // TS must perform actual remapping
   unsigned long _processing_counter = ++processing_counter;     // one more function call (in real life use mutex to protect this counter)
 
@@ -326,29 +326,29 @@ tsremap_remap(ihandle ih, rhandle rh, TS
 
 
   // InkAPI usage case
-  if (INKHttpTxnClientReqGet((INKHttpTxn) rh, &cbuf, &chdr)) {
+  if (TSHttpTxnClientReqGet((TSHttpTxn) rh, &cbuf, &chdr)) {
     const char *value;
-    if ((cfield = INKMimeHdrFieldFind(cbuf, chdr, INK_MIME_FIELD_DATE, -1)) != NULL) {
+    if ((cfield = TSMimeHdrFieldFind(cbuf, chdr, TS_MIME_FIELD_DATE, -1)) != NULL) {
       fprintf(stderr, "We have \"Date\" header in request\n");
-      if (INKMimeHdrFieldValueStringGet(cbuf, chdr, cfield, 0, &value, NULL) != INK_ERROR) {
+      if (TSMimeHdrFieldValueStringGet(cbuf, chdr, cfield, 0, &value, NULL) != TS_ERROR) {
         fprintf(stderr, "Header value: %s\n", value);
       }
     }
-    if ((cfield = INKMimeHdrFieldFind(cbuf, chdr, "MyHeader", sizeof("MyHeader") - 1)) != NULL) {
+    if ((cfield = TSMimeHdrFieldFind(cbuf, chdr, "MyHeader", sizeof("MyHeader") - 1)) != NULL) {
       fprintf(stderr, "We have \"MyHeader\" header in request\n");
-      if (INKMimeHdrFieldValueStringGet(cbuf, chdr, cfield, 0, &value, NULL) != INK_ERROR) {
+      if (TSMimeHdrFieldValueStringGet(cbuf, chdr, cfield, 0, &value, NULL) != TS_ERROR) {
         fprintf(stderr, "Header value: %s\n", value);
       }
     }
-    INKHandleMLocRelease(cbuf, chdr, cfield);
-    INKHandleMLocRelease(cbuf, INK_NULL_MLOC, chdr);
+    TSHandleMLocRelease(cbuf, chdr, cfield);
+    TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
   }
   // How to store plugin private arguments inside Traffic Server request processing block.
-  // note: You can store up to INKHttpTxnGetMaxArgCnt() variables.
-  if (INKHttpTxnGetMaxArgCnt() > 0) {
+  // note: You can store up to TSHttpTxnGetMaxArgCnt() variables.
+  if (TSHttpTxnGetMaxArgCnt() > 0) {
     fprintf(stderr,
             "[tsremap_remap] Save processing counter %lu inside request processing block\n", _processing_counter);
-    INKHttpTxnSetArg((INKHttpTxn) rh, 1, (void *) _processing_counter); // save counter
+    TSHttpTxnSetArg((TSHttpTxn) rh, 1, (void *) _processing_counter); // save counter
   }
   // How to cancel request processing and return error message to the client
   // We wiil do it each other request
@@ -356,10 +356,10 @@ tsremap_remap(ihandle ih, rhandle rh, TS
     char tmp[256];
     static int my_local_counter = 0;
     snprintf(tmp, sizeof(tmp) - 1,
-             "This is very small example of INK API usage!\nIteration %d!\nHTTP return code %d\n",
-             my_local_counter, INK_HTTP_STATUS_CONTINUE + my_local_counter);
-    INKHttpTxnSetHttpRetStatus((INKHttpTxn) rh, (INKHttpStatus) ((int) INK_HTTP_STATUS_CONTINUE + my_local_counter));   //INK_HTTP_STATUS_SERVICE_UNAVAILABLE); //INK_HTTP_STATUS_NOT_ACCEPTABLE);
-    INKHttpTxnSetHttpRetBody((INKHttpTxn) rh, (const char *) tmp, true);
+             "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));   //TS_HTTP_STATUS_SERVICE_UNAVAILABLE); //TS_HTTP_STATUS_NOT_ACCEPTABLE);
+    TSHttpTxnSetHttpRetBody((TSHttpTxn) rh, (const char *) tmp, true);
     my_local_counter++;
   }
   // hardcoded case for remapping
@@ -388,7 +388,7 @@ void
 tsremap_os_response(ihandle ih, rhandle rh, int os_response_type)
 {
   int request_id;
-  INKHttpTxnGetArg((INKHttpTxn) rh, 1, (void **) &request_id);  // read counter (we store it in tsremap_remap function call)
+  TSHttpTxnGetArg((TSHttpTxn) rh, 1, (void **) &request_id);  // read counter (we store it in tsremap_remap function call)
   fprintf(stderr, "[tsremap_os_response] Read processing counter %d from request processing block\n", request_id);
   fprintf(stderr, "[tsremap_os_response] OS response status: %d\n", os_response_type);
 }

Modified: trafficserver/traffic/trunk/example/replace-header/replace-header.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/replace-header/replace-header.c?rev=1035782&r1=1035781&r2=1035782&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/replace-header/replace-header.c (original)
+++ trafficserver/traffic/trunk/example/replace-header/replace-header.c Tue Nov 16 20:22:02 2010
@@ -36,51 +36,51 @@
 #include <ts/ts.h>
 
 static void
-replace_header(INKHttpTxn txnp, INKCont contp)
+replace_header(TSHttpTxn txnp, TSCont contp)
 {
-  INKMBuffer resp_bufp;
-  INKMLoc resp_loc;
-  INKMLoc field_loc;
+  TSMBuffer resp_bufp;
+  TSMLoc resp_loc;
+  TSMLoc field_loc;
 
-  if (!INKHttpTxnServerRespGet(txnp, &resp_bufp, &resp_loc)) {
-    INKError("couldn't retrieve server response header.\n");
+  if (!TSHttpTxnServerRespGet(txnp, &resp_bufp, &resp_loc)) {
+    TSError("couldn't retrieve server response header.\n");
     goto done;
   }
 
-  field_loc = INKMimeHdrFieldFind(resp_bufp, resp_loc, INK_MIME_FIELD_ACCEPT_RANGES, INK_MIME_LEN_ACCEPT_RANGES);
+  field_loc = TSMimeHdrFieldFind(resp_bufp, resp_loc, TS_MIME_FIELD_ACCEPT_RANGES, TS_MIME_LEN_ACCEPT_RANGES);
   if (field_loc == 0) {
     /* field was not found */
 
     /* create a new field in the header */
-    field_loc = INKMimeHdrFieldCreate(resp_bufp, resp_loc);
+    field_loc = TSMimeHdrFieldCreate(resp_bufp, resp_loc);
     /* set its name */
-    INKMimeHdrFieldNameSet(resp_bufp, resp_loc, field_loc, INK_MIME_FIELD_ACCEPT_RANGES, INK_MIME_LEN_ACCEPT_RANGES);
+    TSMimeHdrFieldNameSet(resp_bufp, resp_loc, field_loc, TS_MIME_FIELD_ACCEPT_RANGES, TS_MIME_LEN_ACCEPT_RANGES);
     /* set its value */
-    INKMimeHdrFieldValueAppend(resp_bufp, resp_loc, field_loc, -1, "none", 4);
+    TSMimeHdrFieldValueAppend(resp_bufp, resp_loc, field_loc, -1, "none", 4);
     /* insert it into the header */
-    INKMimeHdrFieldAppend(resp_bufp, resp_loc, field_loc);
-    INKHandleMLocRelease(resp_bufp, resp_loc, field_loc);
-    INKHandleMLocRelease(resp_bufp, INK_NULL_MLOC, resp_loc);
+    TSMimeHdrFieldAppend(resp_bufp, resp_loc, field_loc);
+    TSHandleMLocRelease(resp_bufp, resp_loc, field_loc);
+    TSHandleMLocRelease(resp_bufp, TS_NULL_MLOC, resp_loc);
   } else {
     /* clear the field */
-    INKMimeHdrFieldValuesClear(resp_bufp, resp_loc, field_loc);
+    TSMimeHdrFieldValuesClear(resp_bufp, resp_loc, field_loc);
     /* set the value to "none" */
-    INKMimeHdrFieldValueStringInsert(resp_bufp, resp_loc, field_loc, -1, "none", 4);
-    INKHandleMLocRelease(resp_bufp, resp_loc, field_loc);
-    INKHandleMLocRelease(resp_bufp, INK_NULL_MLOC, resp_loc);
+    TSMimeHdrFieldValueStringInsert(resp_bufp, resp_loc, field_loc, -1, "none", 4);
+    TSHandleMLocRelease(resp_bufp, resp_loc, field_loc);
+    TSHandleMLocRelease(resp_bufp, TS_NULL_MLOC, resp_loc);
   }
 
 done:
-  INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
 }
 
 static int
-replace_header_plugin(INKCont contp, INKEvent event, void *edata)
+replace_header_plugin(TSCont contp, TSEvent event, void *edata)
 {
-  INKHttpTxn txnp = (INKHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn) edata;
 
   switch (event) {
-  case INK_EVENT_HTTP_READ_RESPONSE_HDR:
+  case TS_EVENT_HTTP_READ_RESPONSE_HDR:
     replace_header(txnp, contp);
     return 0;
   default:
@@ -93,7 +93,7 @@ int
 check_ts_version()
 {
 
-  const char *ts_version = INKTrafficServerVersionGet();
+  const char *ts_version = TSTrafficServerVersionGet();
   int result = 0;
 
   if (ts_version) {
@@ -116,22 +116,22 @@ check_ts_version()
 }
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
-  INKPluginRegistrationInfo info;
+  TSPluginRegistrationInfo info;
 
   info.plugin_name = "replace-header";
   info.vendor_name = "MyCompany";
   info.support_email = "ts-api-support@MyCompany.com";
 
-  if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) {
-    INKError("Plugin registration failed. \n");
+  if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+    TSError("Plugin registration failed. \n");
   }
 
   if (!check_ts_version()) {
-    INKError("Plugin requires Traffic Server 2.0 or later\n");
+    TSError("Plugin requires Traffic Server 2.0 or later\n");
     return;
   }
 
-  INKHttpHookAdd(INK_HTTP_READ_RESPONSE_HDR_HOOK, INKContCreate(replace_header_plugin, NULL));
+  TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(replace_header_plugin, NULL));
 }