You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2010/11/30 02:43:06 UTC

svn commit: r1040383 [3/38] - in /trafficserver/traffic/branches/wccp: ./ build/ contrib/ contrib/perl/AdminClient/lib/Apache/TS/ example/ example/add-header/ example/app-template/ example/append-transform/ example/basic-auth/ example/blacklist-0/ exam...

Modified: trafficserver/traffic/branches/wccp/example/gzip-transform/gunzip.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/gzip-transform/gunzip.c?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/gzip-transform/gunzip.c (original)
+++ trafficserver/traffic/branches/wccp/example/gzip-transform/gunzip.c Tue Nov 30 01:42:55 2010
@@ -38,10 +38,10 @@
 
 typedef struct
 {
-  INKHttpTxn txn;
-  INKVIO output_vio;
-  INKIOBuffer output_buffer;
-  INKIOBufferReader output_reader;
+  TSHttpTxn txn;
+  TSVIO output_vio;
+  TSIOBuffer output_buffer;
+  TSIOBufferReader output_reader;
   int output_length;
   z_stream zstrm;
   uLong crc;
@@ -63,7 +63,7 @@ load_dictionary(char *dict, uLong * adle
 
   fp = fopen(preload_file, "r");
   if (!fp) {
-    INKError("gunzip-transform: ERROR: Unable to open dict file %s\n", preload_file);
+    TSError("gunzip-transform: ERROR: Unable to open dict file %s\n", preload_file);
     exit(0);
   }
 
@@ -84,14 +84,14 @@ load_dictionary(char *dict, uLong * adle
 static voidpf
 gzip_alloc(voidpf opaque, uInt items, uInt size)
 {
-  return (voidpf) INKmalloc(items * size);
+  return (voidpf) TSmalloc(items * size);
 }
 
 
 static void
 gzip_free(voidpf opaque, voidpf address)
 {
-  INKfree(address);
+  TSfree(address);
 }
 
 
@@ -100,7 +100,7 @@ gzip_data_alloc()
 {
   GzipData *data;
 
-  data = (GzipData *) INKmalloc(sizeof(GzipData));
+  data = (GzipData *) TSmalloc(sizeof(GzipData));
   data->output_vio = NULL;
   data->output_buffer = NULL;
   data->output_reader = NULL;
@@ -134,45 +134,45 @@ gzip_data_destroy(GzipData * data)
   if (data) {
     err = inflateEnd(&data->zstrm);
     if (err != Z_OK) {
-      INKError("gunzip-transform: ERROR: inflateEnd (%d)!", err);
+      TSError("gunzip-transform: ERROR: inflateEnd (%d)!", err);
     }
 
     if (data->output_buffer) {
-      INKIOBufferDestroy(data->output_buffer);
+      TSIOBufferDestroy(data->output_buffer);
     }
-    INKfree(data);
+    TSfree(data);
   }
 }
 
 
 static void
-gzip_transform_init(INKCont contp, GzipData * data)
+gzip_transform_init(TSCont contp, GzipData * data)
 {
-  INKVConn output_conn;
+  TSVConn output_conn;
 
   data->state = 1;
 
   /* Get the output connection where we'll write data to. */
-  output_conn = INKTransformOutputVConnGet(contp);
+  output_conn = TSTransformOutputVConnGet(contp);
 
-  data->output_buffer = INKIOBufferCreate();
-  data->output_reader = INKIOBufferReaderAlloc(data->output_buffer);
-  data->output_vio = INKVConnWrite(output_conn, contp, data->output_reader, INT_MAX);
+  data->output_buffer = TSIOBufferCreate();
+  data->output_reader = TSIOBufferReaderAlloc(data->output_buffer);
+  data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT_MAX);
 }
 
 
 static void
-gzip_transform_one(GzipData * data, INKIOBufferReader input_reader, int amount)
+gzip_transform_one(GzipData * data, TSIOBufferReader input_reader, int amount)
 {
-  INKIOBufferBlock blkp;
+  TSIOBufferBlock blkp;
   const char *ibuf;
   char *obuf;
-  int ilength, olength;
+  int64 ilength, olength;
   int err = Z_OK;
 
   while (amount > 0) {
-    blkp = INKIOBufferReaderStart(input_reader);
-    ibuf = INKIOBufferBlockReadStart(blkp, input_reader, &ilength);
+    blkp = TSIOBufferReaderStart(input_reader);
+    ibuf = TSIOBufferBlockReadStart(blkp, input_reader, &ilength);
 
     if (ilength > amount) {
       ilength = amount;
@@ -185,15 +185,15 @@ gzip_transform_one(GzipData * data, INKI
       err = inflateInit(&data->zstrm);
       data->flag = 0;
       if (err != Z_OK) {
-        INKError("gunzip-transform: ERROR: inflateInit (%d)!", err);
+        TSError("gunzip-transform: ERROR: inflateInit (%d)!", err);
         exit(1);
       }
     }
 
     while (data->zstrm.avail_in > 0 && err != Z_STREAM_END) {
-      blkp = INKIOBufferStart(data->output_buffer);
+      blkp = TSIOBufferStart(data->output_buffer);
 
-      obuf = INKIOBufferBlockWriteStart(blkp, &olength);
+      obuf = TSIOBufferBlockWriteStart(blkp, &olength);
 
       data->zstrm.next_out = (unsigned char *) obuf;
       data->zstrm.avail_out = olength;
@@ -205,18 +205,18 @@ gzip_transform_one(GzipData * data, INKI
 */
       if (err == Z_NEED_DICT) {
         assert(preload);
-        INKDebug("gunzip-transform", "Transform needs dictionary");
+        TSDebug("gunzip-transform", "Transform needs dictionary");
         /* TODO assert encoding dict is same as the decoding one, else send an error page */
         /* Dont send the user binary junk! */
 
         err = inflateSetDictionary(&data->zstrm, (Bytef *) dictionary, strlen(dictionary));
         if (err != Z_OK) {
-          INKError("gunzip-transform: ERROR: inflateSetDictionary (%d)!", err);
+          TSError("gunzip-transform: ERROR: inflateSetDictionary (%d)!", err);
         }
       }
 
       if (olength > data->zstrm.avail_out) {
-        INKIOBufferProduce(data->output_buffer, olength - data->zstrm.avail_out);
+        TSIOBufferProduce(data->output_buffer, olength - data->zstrm.avail_out);
         data->output_length += (olength - data->zstrm.avail_out);
       }
 
@@ -224,7 +224,7 @@ gzip_transform_one(GzipData * data, INKI
 
     /* TODO compute crc */
 
-    INKIOBufferReaderConsume(input_reader, ilength);
+    TSIOBufferReaderConsume(input_reader, ilength);
     amount -= ilength;
   }
 }
@@ -234,17 +234,17 @@ static void
 gzip_transform_finish(GzipData * data)
 {
   if (data->state == 1) {
-    INKIOBufferBlock blkp;
+    TSIOBufferBlock blkp;
     char *obuf;
-    int olength;
+    int64 olength;
     int err;
 
     data->state = 2;
 
     for (;;) {
-      blkp = INKIOBufferStart(data->output_buffer);
+      blkp = TSIOBufferStart(data->output_buffer);
 
-      obuf = INKIOBufferBlockWriteStart(blkp, &olength);
+      obuf = TSIOBufferBlockWriteStart(blkp, &olength);
       data->zstrm.next_out = (unsigned char *) obuf;
       data->zstrm.avail_out = olength;
 
@@ -252,7 +252,7 @@ gzip_transform_finish(GzipData * data)
       err = inflate(&data->zstrm, Z_FINISH);
 
       if (olength > data->zstrm.avail_out) {
-        INKIOBufferProduce(data->output_buffer, olength - data->zstrm.avail_out);
+        TSIOBufferProduce(data->output_buffer, olength - data->zstrm.avail_out);
         data->output_length += (olength - data->zstrm.avail_out);
       }
 
@@ -264,7 +264,7 @@ gzip_transform_finish(GzipData * data)
     }
 
     if (data->output_length != (data->zstrm.total_out)) {
-      INKError("gunzip-transform: ERROR: output lengths don't match (%d, %ld)", data->output_length,
+      TSError("gunzip-transform: ERROR: output lengths don't match (%d, %ld)", data->output_length,
                data->zstrm.total_out);
     }
 
@@ -274,9 +274,9 @@ gzip_transform_finish(GzipData * data)
 
 
 static void
-gzip_transform_do(INKCont contp)
+gzip_transform_do(TSCont contp)
 {
-  INKVIO write_vio;
+  TSVIO write_vio;
   GzipData *data;
   int towrite;
   int avail;
@@ -286,7 +286,7 @@ gzip_transform_do(INKCont contp)
      structure contains the output vio and output buffer. If the
      private data structure pointer is NULL, then we'll create it
      and initialize its internals. */
-  data = INKContDataGet(contp);
+  data = TSContDataGet(contp);
   if (data->state == 0) {
     gzip_transform_init(contp, data);
   }
@@ -295,7 +295,7 @@ gzip_transform_do(INKCont contp)
      ourself. This vio contains the buffer that we are to read from
      as well as the continuation we are to call when the buffer is
      empty. */
-  write_vio = INKVConnWriteVIOGet(contp);
+  write_vio = TSVConnWriteVIOGet(contp);
 
   length = data->output_length;
 
@@ -306,52 +306,52 @@ gzip_transform_do(INKCont contp)
      transformation that means we're done. In a more complex
      transformation we might have to finish writing the transformed
      data to our output connection. */
-  if (!INKVIOBufferGet(write_vio)) {
+  if (!TSVIOBufferGet(write_vio)) {
 
     gzip_transform_finish(data);
 
-    INKVIONBytesSet(data->output_vio, data->output_length);
+    TSVIONBytesSet(data->output_vio, data->output_length);
 
-    INKVIOReenable(data->output_vio);
+    TSVIOReenable(data->output_vio);
     return;
   }
 
   /* Determine how much data we have left to read. For this gzip
      transform plugin this is also the amount of data we have left
      to write to the output connection. */
-  towrite = INKVIONTodoGet(write_vio);
+  towrite = TSVIONTodoGet(write_vio);
   if (towrite > 0) {
     /* The amount of data left to read needs to be truncated by
        the amount of data actually in the read buffer. */
-    avail = INKIOBufferReaderAvail(INKVIOReaderGet(write_vio));
+    avail = TSIOBufferReaderAvail(TSVIOReaderGet(write_vio));
     if (towrite > avail) {
       towrite = avail;
     }
 
     if (towrite > 0) {
-      gzip_transform_one(data, INKVIOReaderGet(write_vio), towrite);
+      gzip_transform_one(data, TSVIOReaderGet(write_vio), towrite);
 
       /* Modify the write vio to reflect how much data we've
          completed. */
-      INKVIONDoneSet(write_vio, INKVIONDoneGet(write_vio) + towrite);
+      TSVIONDoneSet(write_vio, TSVIONDoneGet(write_vio) + towrite);
     }
   }
 
   /* Now we check the write vio to see if there is data left to
      read. */
-  if (INKVIONTodoGet(write_vio) > 0) {
+  if (TSVIONTodoGet(write_vio) > 0) {
     if (towrite > 0) {
       /* If we output some data then we reenable the output
          connection by reenabling the output vio. This will wakeup
          the output connection and allow it to consume data from the
          output buffer. */
       if (data->output_length > length) {
-        INKVIOReenable(data->output_vio);
+        TSVIOReenable(data->output_vio);
       }
 
       /* Call back the write vio continuation to let it know that we
          are ready for more data. */
-      INKContCall(INKVIOContGet(write_vio), INK_EVENT_VCONN_WRITE_READY, write_vio);
+      TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_READY, write_vio);
     }
   } else {
     /* If there is no data left to read, then we modify the output
@@ -361,53 +361,53 @@ gzip_transform_do(INKCont contp)
        that it can consume the data we just gave it. */
     gzip_transform_finish(data);
 
-    INKVIONBytesSet(data->output_vio, data->output_length);
+    TSVIONBytesSet(data->output_vio, data->output_length);
 
     if (data->output_length > length) {
-      INKVIOReenable(data->output_vio);
+      TSVIOReenable(data->output_vio);
     }
 
     /* Call back the write vio continuation to let it know that we
        have completed the write operation. */
-    INKContCall(INKVIOContGet(write_vio), INK_EVENT_VCONN_WRITE_COMPLETE, write_vio);
+    TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_COMPLETE, write_vio);
   }
 }
 
 
 static int
-gzip_transform(INKCont contp, INKEvent event, void *edata)
+gzip_transform(TSCont contp, TSEvent event, void *edata)
 {
   /* Check to see if the transformation has been closed by a call to
-     INKVConnClose. */
-  if (INKVConnClosedGet(contp)) {
-    gzip_data_destroy(INKContDataGet(contp));
-    INKContDestroy(contp);
+     TSVConnClose. */
+  if (TSVConnClosedGet(contp)) {
+    gzip_data_destroy(TSContDataGet(contp));
+    TSContDestroy(contp);
     return 0;
   } else {
     switch (event) {
-    case INK_EVENT_ERROR:
+    case TS_EVENT_ERROR:
       {
-        INKVIO write_vio;
+        TSVIO write_vio;
 
         /* Get the write vio for the write operation that was
            performed on ourself. This vio contains the continuation of
            our parent transformation. */
-        write_vio = INKVConnWriteVIOGet(contp);
+        write_vio = TSVConnWriteVIOGet(contp);
 
         /* Call back the write vio continuation to let it know that we
            have completed the write operation. */
-        INKContCall(INKVIOContGet(write_vio), INK_EVENT_ERROR, write_vio);
+        TSContCall(TSVIOContGet(write_vio), TS_EVENT_ERROR, write_vio);
       }
       break;
-    case INK_EVENT_VCONN_WRITE_COMPLETE:
-    case INK_EVENT_VCONN_EOS:
+    case TS_EVENT_VCONN_WRITE_COMPLETE:
+    case TS_EVENT_VCONN_EOS:
       /* When our output connection says that it has finished
          reading all the data we've written to it then we should
          shutdown the write portion of its connection to
          indicate that we don't want to hear about it anymore. */
-      INKVConnShutdown(INKTransformOutputVConnGet(contp), 0, 1);
+      TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
       break;
-    case INK_EVENT_VCONN_WRITE_READY:
+    case TS_EVENT_VCONN_WRITE_READY:
     default:
       /* If we get a WRITE_READY event or any other type of
          event (sent, perhaps, because we were reenabled) then
@@ -421,112 +421,112 @@ gzip_transform(INKCont contp, INKEvent e
 }
 
 static int
-gzip_transformable(INKHttpTxn txnp, int server)
+gzip_transformable(TSHttpTxn txnp, int server)
 {
-  INKMBuffer bufp;
-  INKMLoc hdr_loc;
-  INKMLoc field_loc;
+  TSMBuffer bufp;
+  TSMLoc hdr_loc;
+  TSMLoc field_loc;
   const char *value;
 
   if (server) {
-    INKHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
+    TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
   } else {
-    INKHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc);
+    TSHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc);
   }
 
   /* We only want to do gunzip(inflate) on documents that have a
      content-encoding "deflate". */
 
-  field_loc = INKMimeHdrFieldFind(bufp, hdr_loc, "Content-Encoding", -1);
+  field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, "Content-Encoding", -1);
   if (!field_loc) {
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return -4;
   }
 
-  if (INKMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &value, NULL) == INK_ERROR) {
-    INKHandleMLocRelease(bufp, hdr_loc, field_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+  if (TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &value, NULL) == TS_ERROR) {
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return -5;
   }
 
   if (value && (strncasecmp(value, "deflate", sizeof("deflate") - 1) == 0)) {
-    INKHandleMLocRelease(bufp, hdr_loc, field_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return 0;
   } else {
-    INKHandleMLocRelease(bufp, hdr_loc, field_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return -5;
   }
 }
 
 
 static void
-gzip_transform_add(INKHttpTxn txnp, int flag)
+gzip_transform_add(TSHttpTxn txnp, int flag)
 {
-  INKVConn connp;
+  TSVConn connp;
   GzipData *data;
 
   data = gzip_data_alloc();
   data->txn = txnp;
 
-  connp = INKTransformCreate(gzip_transform, txnp);
-  INKContDataSet(connp, data);
-  INKHttpTxnHookAdd(txnp, INK_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
+  connp = TSTransformCreate(gzip_transform, txnp);
+  TSContDataSet(connp, data);
+  TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
 }
 
 
 static int
-transform_plugin(INKCont contp, INKEvent event, void *edata)
+transform_plugin(TSCont contp, TSEvent event, void *edata)
 {
-  INKHttpTxn txnp = (INKHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn) edata;
   int reason;
 
   switch (event) {
-  case INK_EVENT_HTTP_READ_REQUEST_HDR:
+  case TS_EVENT_HTTP_READ_REQUEST_HDR:
     {
-      INKMBuffer bufp;
-      INKMLoc hdr_loc;
-      INKMLoc ae_loc;           /* for the accept encoding mime field */
-
-      INKHttpTxnClientReqGet(txnp, &bufp, &hdr_loc);
-      ae_loc = INKMimeHdrFieldCreate(bufp, hdr_loc);
-      INKMimeHdrFieldNameSet(bufp, hdr_loc, ae_loc, "Accept-Encoding", -1);
-      INKMimeHdrFieldValueAppend(bufp, hdr_loc, ae_loc, -1, "deflate", -1);
-      INKMimeHdrFieldAppend(bufp, hdr_loc, ae_loc);
-      INKHandleMLocRelease(bufp, hdr_loc, ae_loc);
-      INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+      TSMBuffer bufp;
+      TSMLoc hdr_loc;
+      TSMLoc ae_loc;           /* for the accept encoding mime field */
+
+      TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc);
+      ae_loc = TSMimeHdrFieldCreate(bufp, hdr_loc);
+      TSMimeHdrFieldNameSet(bufp, hdr_loc, ae_loc, "Accept-Encoding", -1);
+      TSMimeHdrFieldValueAppend(bufp, hdr_loc, ae_loc, -1, "deflate", -1);
+      TSMimeHdrFieldAppend(bufp, hdr_loc, ae_loc);
+      TSHandleMLocRelease(bufp, hdr_loc, ae_loc);
+      TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
 
-      INKDebug("gunzip-transform", "Changed request header to accept deflate encoding");
-      INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+      TSDebug("gunzip-transform", "Changed request header to accept deflate encoding");
+      TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
       break;
     }
-  case INK_EVENT_HTTP_READ_RESPONSE_HDR:
+  case TS_EVENT_HTTP_READ_RESPONSE_HDR:
     reason = gzip_transformable(txnp, 1);
     if (reason >= 0) {
-      INKMBuffer bufp;
-      INKMLoc hdr_loc;
-      INKMLoc field_loc;
-
-      INKHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
-      field_loc = INKMimeHdrFieldFind(bufp, hdr_loc, "Content-Encoding", -1);
-      INKMimeHdrFieldDestroy(bufp, hdr_loc, field_loc);
-      INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+      TSMBuffer bufp;
+      TSMLoc hdr_loc;
+      TSMLoc field_loc;
+
+      TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
+      field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, "Content-Encoding", -1);
+      TSMimeHdrFieldDestroy(bufp, hdr_loc, field_loc);
+      TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
 
-      INKDebug("gunzip-transform", "server content transformable");
+      TSDebug("gunzip-transform", "server content transformable");
       gzip_transform_add(txnp, 1);
     } else {
-      INKDebug("gunzip-transform", "server content NOT transformable [%d]", reason);
+      TSDebug("gunzip-transform", "server content NOT transformable [%d]", reason);
     }
 
-    INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
     break;
 
-  case INK_EVENT_HTTP_READ_CACHE_HDR:
+  case TS_EVENT_HTTP_READ_CACHE_HDR:
 
-    INKDebug("gunzip-transform", "Cached data");
+    TSDebug("gunzip-transform", "Cached data");
 
-    INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
     break;
 
   default:
@@ -538,7 +538,7 @@ transform_plugin(INKCont contp, INKEvent
 
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
   if (argc == 2) {
     strcpy(preload_file, argv[1]);
@@ -546,7 +546,7 @@ INKPluginInit(int argc, const char *argv
     load_dictionary(dictionary, &dictId);
   }
 
-  INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, INKContCreate(transform_plugin, NULL));
-  INKHttpHookAdd(INK_HTTP_READ_RESPONSE_HDR_HOOK, INKContCreate(transform_plugin, NULL));
-  INKHttpHookAdd(INK_HTTP_READ_CACHE_HDR_HOOK, INKContCreate(transform_plugin, NULL));
+  TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(transform_plugin, NULL));
+  TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(transform_plugin, NULL));
+  TSHttpHookAdd(TS_HTTP_READ_CACHE_HDR_HOOK, TSContCreate(transform_plugin, NULL));
 }

Modified: trafficserver/traffic/branches/wccp/example/gzip-transform/gzip.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/gzip-transform/gzip.c?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/gzip-transform/gzip.c (original)
+++ trafficserver/traffic/branches/wccp/example/gzip-transform/gzip.c Tue Nov 30 01:42:55 2010
@@ -38,10 +38,10 @@
 
 typedef struct
 {
-  INKHttpTxn txn;
-  INKVIO output_vio;
-  INKIOBuffer output_buffer;
-  INKIOBufferReader output_reader;
+  TSHttpTxn txn;
+  TSVIO output_vio;
+  TSIOBuffer output_buffer;
+  TSIOBufferReader output_reader;
   int output_length;
   z_stream zstrm;
   uLong crc;
@@ -62,7 +62,7 @@ load_dictionary(char *dict, uLong * adle
 
   fp = fopen(preload_file, "r");
   if (!fp) {
-    INKError("gzip-transform: ERROR: Unable to open dict file %s\n", preload_file);
+    TSError("gzip-transform: ERROR: Unable to open dict file %s\n", preload_file);
     exit(0);
   }
 
@@ -85,14 +85,14 @@ load_dictionary(char *dict, uLong * adle
 static voidpf
 gzip_alloc(voidpf opaque, uInt items, uInt size)
 {
-  return (voidpf) INKmalloc(items * size);
+  return (voidpf) TSmalloc(items * size);
 }
 
 
 static void
 gzip_free(voidpf opaque, voidpf address)
 {
-  INKfree(address);
+  TSfree(address);
 }
 
 
@@ -102,7 +102,7 @@ gzip_data_alloc()
   GzipData *data;
   int err;
 
-  data = (GzipData *) INKmalloc(sizeof(GzipData));
+  data = (GzipData *) TSmalloc(sizeof(GzipData));
   data->output_vio = NULL;
   data->output_buffer = NULL;
   data->output_reader = NULL;
@@ -124,7 +124,7 @@ gzip_data_alloc()
   err = deflateInit(&data->zstrm, Z_BEST_COMPRESSION);
 
   if (err != Z_OK) {
-    INKError("gzip-transform: ERROR: deflateInit (%d)!", err);
+    TSError("gzip-transform: ERROR: deflateInit (%d)!", err);
     exit(1);
   }
 
@@ -132,7 +132,7 @@ gzip_data_alloc()
     assert(&data->zstrm);
     err = deflateSetDictionary(&data->zstrm, (const Bytef *) dictionary, strlen(dictionary));
     if (err != Z_OK) {
-      INKError("gzip-transform: ERROR: deflateSetDictionary (%d)!", err);
+      TSError("gzip-transform: ERROR: deflateSetDictionary (%d)!", err);
     }
   }
 
@@ -148,60 +148,60 @@ gzip_data_destroy(GzipData * data)
   if (data) {
     err = deflateEnd(&data->zstrm);
     if (err != Z_OK) {
-      INKError("gzip-transform: ERROR: deflateEnd (%d)!", err);
+      TSError("gzip-transform: ERROR: deflateEnd (%d)!", err);
     }
 
     if (data->output_buffer) {
-      INKIOBufferDestroy(data->output_buffer);
+      TSIOBufferDestroy(data->output_buffer);
     }
-    INKfree(data);
+    TSfree(data);
   }
 }
 
 
 static void
-gzip_transform_init(INKCont contp, GzipData * data)
+gzip_transform_init(TSCont contp, GzipData * data)
 {
-  INKVConn output_conn;
-  INKMBuffer bufp;
-  INKMLoc hdr_loc;
-  INKMLoc ce_loc;               /* for the content encoding mime field */
+  TSVConn output_conn;
+  TSMBuffer bufp;
+  TSMLoc hdr_loc;
+  TSMLoc ce_loc;               /* for the content encoding mime field */
 
   data->state = 1;
 
   /*
    * Mark the output data as having gzip content encoding
    */
-  INKHttpTxnTransformRespGet(data->txn, &bufp, &hdr_loc);
-  ce_loc = INKMimeHdrFieldCreate(bufp, hdr_loc);
-  INKMimeHdrFieldNameSet(bufp, hdr_loc, ce_loc, "Content-Encoding", -1);
-  INKMimeHdrFieldValueStringInsert(bufp, hdr_loc, ce_loc, -1, "deflate", -1);
-  INKMimeHdrFieldAppend(bufp, hdr_loc, ce_loc);
-  INKHandleMLocRelease(bufp, hdr_loc, ce_loc);
-  INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+  TSHttpTxnTransformRespGet(data->txn, &bufp, &hdr_loc);
+  ce_loc = TSMimeHdrFieldCreate(bufp, hdr_loc);
+  TSMimeHdrFieldNameSet(bufp, hdr_loc, ce_loc, "Content-Encoding", -1);
+  TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, ce_loc, -1, "deflate", -1);
+  TSMimeHdrFieldAppend(bufp, hdr_loc, ce_loc);
+  TSHandleMLocRelease(bufp, hdr_loc, ce_loc);
+  TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
 
 
   /* Get the output connection where we'll write data to. */
-  output_conn = INKTransformOutputVConnGet(contp);
+  output_conn = TSTransformOutputVConnGet(contp);
 
-  data->output_buffer = INKIOBufferCreate();
-  data->output_reader = INKIOBufferReaderAlloc(data->output_buffer);
-  data->output_vio = INKVConnWrite(output_conn, contp, data->output_reader, INT_MAX);
+  data->output_buffer = TSIOBufferCreate();
+  data->output_reader = TSIOBufferReaderAlloc(data->output_buffer);
+  data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT_MAX);
 }
 
 
 static void
-gzip_transform_one(GzipData * data, INKIOBufferReader input_reader, int amount)
+gzip_transform_one(GzipData * data, TSIOBufferReader input_reader, int amount)
 {
-  INKIOBufferBlock blkp;
+  TSIOBufferBlock blkp;
   const char *ibuf;
   char *obuf;
-  int ilength, olength;
+  int64 ilength, olength;
   int err;
 
   while (amount > 0) {
-    blkp = INKIOBufferReaderStart(input_reader);
-    ibuf = INKIOBufferBlockReadStart(blkp, input_reader, &ilength);
+    blkp = TSIOBufferReaderStart(input_reader);
+    ibuf = TSIOBufferBlockReadStart(blkp, input_reader, &ilength);
 
     if (ilength > amount) {
       ilength = amount;
@@ -211,9 +211,9 @@ gzip_transform_one(GzipData * data, INKI
     data->zstrm.avail_in = ilength;
 
     while (data->zstrm.avail_in > 0) {
-      blkp = INKIOBufferStart(data->output_buffer);
+      blkp = TSIOBufferStart(data->output_buffer);
 
-      obuf = INKIOBufferBlockWriteStart(blkp, &olength);
+      obuf = TSIOBufferBlockWriteStart(blkp, &olength);
 
       data->zstrm.next_out = (unsigned char *) obuf;
       data->zstrm.avail_out = olength;
@@ -222,13 +222,13 @@ gzip_transform_one(GzipData * data, INKI
       err = deflate(&data->zstrm, Z_NO_FLUSH);
 
       if (olength > data->zstrm.avail_out) {
-        INKIOBufferProduce(data->output_buffer, olength - data->zstrm.avail_out);
+        TSIOBufferProduce(data->output_buffer, olength - data->zstrm.avail_out);
         data->output_length += (olength - data->zstrm.avail_out);
       }
 
       if (data->zstrm.avail_out > 0) {
         if (data->zstrm.avail_in != 0) {
-          INKError("gzip-transform: ERROR: avail_in is (%d): should be 0", data->zstrm.avail_in);
+          TSError("gzip-transform: ERROR: avail_in is (%d): should be 0", data->zstrm.avail_in);
         }
       }
     }
@@ -236,7 +236,7 @@ gzip_transform_one(GzipData * data, INKI
     /* compute CRC for error checking at client */
     data->crc = crc32(data->crc, (unsigned char *) ibuf, ilength);
 
-    INKIOBufferReaderConsume(input_reader, ilength);
+    TSIOBufferReaderConsume(input_reader, ilength);
     amount -= ilength;
   }
 }
@@ -246,17 +246,17 @@ static void
 gzip_transform_finish(GzipData * data)
 {
   if (data->state == 1) {
-    INKIOBufferBlock blkp;
+    TSIOBufferBlock blkp;
     char *obuf;
-    int olength;
+    int64 olength;
     int err;
 
     data->state = 2;
 
     for (;;) {
-      blkp = INKIOBufferStart(data->output_buffer);
+      blkp = TSIOBufferStart(data->output_buffer);
 
-      obuf = INKIOBufferBlockWriteStart(blkp, &olength);
+      obuf = TSIOBufferBlockWriteStart(blkp, &olength);
       data->zstrm.next_out = (unsigned char *) obuf;
       data->zstrm.avail_out = olength;
 
@@ -264,7 +264,7 @@ gzip_transform_finish(GzipData * data)
       err = deflate(&data->zstrm, Z_FINISH);
 
       if (olength > data->zstrm.avail_out) {
-        INKIOBufferProduce(data->output_buffer, olength - data->zstrm.avail_out);
+        TSIOBufferProduce(data->output_buffer, olength - data->zstrm.avail_out);
         data->output_length += (olength - data->zstrm.avail_out);
       }
 
@@ -273,20 +273,20 @@ gzip_transform_finish(GzipData * data)
       }
       /* done! */
       if (err != Z_STREAM_END) {
-        INKDebug("gzip-transform", "deflate should report Z_STREAM_END\n");
+        TSDebug("gzip-transform", "deflate should report Z_STREAM_END\n");
       }
       break;
     }
 
     if (data->output_length != (data->zstrm.total_out)) {
-      INKError("gzip-transform: ERROR: output lengths don't match (%d, %ld)", data->output_length,
+      TSError("gzip-transform: ERROR: output lengths don't match (%d, %ld)", data->output_length,
                data->zstrm.total_out);
     }
 
     /* compute/append crc to end of stream */
 
     /*
-       blkp = INKIOBufferStart (data->output_buffer);
+       blkp = TSIOBufferStart (data->output_buffer);
 
        tmp = data->crc;
        buf[0] = tmp & 0xff; tmp >>= 8;
@@ -304,7 +304,7 @@ gzip_transform_finish(GzipData * data)
        length = 8;
 
        while (length > 0) {
-       obuf = INKIOBufferBlockWriteStart (blkp, &olength);
+       obuf = TSIOBufferBlockWriteStart (blkp, &olength);
        if (olength > length) {
        olength = length;
        }
@@ -313,7 +313,7 @@ gzip_transform_finish(GzipData * data)
        p += olength;
        length -= olength;
 
-       INKIOBufferProduce (data->output_buffer, olength);
+       TSIOBufferProduce (data->output_buffer, olength);
        }
 
        data->output_length += 8;
@@ -323,9 +323,9 @@ gzip_transform_finish(GzipData * data)
 
 
 static void
-gzip_transform_do(INKCont contp)
+gzip_transform_do(TSCont contp)
 {
-  INKVIO write_vio;
+  TSVIO write_vio;
   GzipData *data;
   int towrite;
   int avail;
@@ -335,7 +335,7 @@ gzip_transform_do(INKCont contp)
      structure contains the output vio and output buffer. If the
      private data structure pointer is NULL, then we'll create it
      and initialize its internals. */
-  data = INKContDataGet(contp);
+  data = TSContDataGet(contp);
   if (data->state == 0) {
     gzip_transform_init(contp, data);
   }
@@ -344,7 +344,7 @@ gzip_transform_do(INKCont contp)
      ourself. This vio contains the buffer that we are to read from
      as well as the continuation we are to call when the buffer is
      empty. */
-  write_vio = INKVConnWriteVIOGet(contp);
+  write_vio = TSVConnWriteVIOGet(contp);
 
   length = data->output_length;
 
@@ -355,14 +355,14 @@ gzip_transform_do(INKCont contp)
      transformation that means we're done. In a more complex
      transformation we might have to finish writing the transformed
      data to our output connection. */
-  if (!INKVIOBufferGet(write_vio)) {
+  if (!TSVIOBufferGet(write_vio)) {
     gzip_transform_finish(data);
 
-    INKVIONBytesSet(data->output_vio, data->output_length);
-    INKDebug("gzip-transform", "Compressed size %d (bytes)", data->output_length);
+    TSVIONBytesSet(data->output_vio, data->output_length);
+    TSDebug("gzip-transform", "Compressed size %d (bytes)", data->output_length);
 
     if (data->output_length > length) {
-      INKVIOReenable(data->output_vio);
+      TSVIOReenable(data->output_vio);
     }
     return;
   }
@@ -370,39 +370,39 @@ gzip_transform_do(INKCont contp)
   /* Determine how much data we have left to read. For this gzip
      transform plugin this is also the amount of data we have left
      to write to the output connection. */
-  towrite = INKVIONTodoGet(write_vio);
+  towrite = TSVIONTodoGet(write_vio);
   if (towrite > 0) {
     /* The amount of data left to read needs to be truncated by
        the amount of data actually in the read buffer. */
-    avail = INKIOBufferReaderAvail(INKVIOReaderGet(write_vio));
+    avail = TSIOBufferReaderAvail(TSVIOReaderGet(write_vio));
     if (towrite > avail) {
       towrite = avail;
     }
 
     if (towrite > 0) {
-      gzip_transform_one(data, INKVIOReaderGet(write_vio), towrite);
+      gzip_transform_one(data, TSVIOReaderGet(write_vio), towrite);
 
       /* Modify the write vio to reflect how much data we've
          completed. */
-      INKVIONDoneSet(write_vio, INKVIONDoneGet(write_vio) + towrite);
+      TSVIONDoneSet(write_vio, TSVIONDoneGet(write_vio) + towrite);
     }
   }
 
   /* Now we check the write vio to see if there is data left to
      read. */
-  if (INKVIONTodoGet(write_vio) > 0) {
+  if (TSVIONTodoGet(write_vio) > 0) {
     if (towrite > 0) {
       /* If we output some data then we reenable the output
          connection by reenabling the output vio. This will wakeup
          the output connection and allow it to consume data from the
          output buffer. */
       if (data->output_length > length) {
-        INKVIOReenable(data->output_vio);
+        TSVIOReenable(data->output_vio);
       }
 
       /* Call back the write vio continuation to let it know that we
          are ready for more data. */
-      INKContCall(INKVIOContGet(write_vio), INK_EVENT_VCONN_WRITE_READY, write_vio);
+      TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_READY, write_vio);
     }
   } else {
     /* If there is no data left to read, then we modify the output
@@ -412,53 +412,53 @@ gzip_transform_do(INKCont contp)
        that it can consume the data we just gave it. */
     gzip_transform_finish(data);
 
-    INKVIONBytesSet(data->output_vio, data->output_length);
-    INKDebug("gzip-transform", "Compressed size %d (bytes)", data->output_length);
+    TSVIONBytesSet(data->output_vio, data->output_length);
+    TSDebug("gzip-transform", "Compressed size %d (bytes)", data->output_length);
 
     if (data->output_length > length) {
-      INKVIOReenable(data->output_vio);
+      TSVIOReenable(data->output_vio);
     }
 
     /* Call back the write vio continuation to let it know that we
        have completed the write operation. */
-    INKContCall(INKVIOContGet(write_vio), INK_EVENT_VCONN_WRITE_COMPLETE, write_vio);
+    TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_COMPLETE, write_vio);
   }
 }
 
 
 static int
-gzip_transform(INKCont contp, INKEvent event, void *edata)
+gzip_transform(TSCont contp, TSEvent event, void *edata)
 {
   /* Check to see if the transformation has been closed by a call to
-     INKVConnClose. */
-  if (INKVConnClosedGet(contp)) {
-    gzip_data_destroy(INKContDataGet(contp));
-    INKContDestroy(contp);
+     TSVConnClose. */
+  if (TSVConnClosedGet(contp)) {
+    gzip_data_destroy(TSContDataGet(contp));
+    TSContDestroy(contp);
     return 0;
   } else {
     switch (event) {
-    case INK_EVENT_ERROR:
+    case TS_EVENT_ERROR:
       {
-        INKVIO write_vio;
+        TSVIO write_vio;
 
         /* Get the write vio for the write operation that was
            performed on ourself. This vio contains the continuation of
            our parent transformation. */
-        write_vio = INKVConnWriteVIOGet(contp);
+        write_vio = TSVConnWriteVIOGet(contp);
 
         /* Call back the write vio continuation to let it know that we
            have completed the write operation. */
-        INKContCall(INKVIOContGet(write_vio), INK_EVENT_ERROR, write_vio);
+        TSContCall(TSVIOContGet(write_vio), TS_EVENT_ERROR, write_vio);
       }
       break;
-    case INK_EVENT_VCONN_WRITE_COMPLETE:
+    case TS_EVENT_VCONN_WRITE_COMPLETE:
       /* When our output connection says that it has finished
          reading all the data we've written to it then we should
          shutdown the write portion of its connection to
          indicate that we don't want to hear about it anymore. */
-      INKVConnShutdown(INKTransformOutputVConnGet(contp), 0, 1);
+      TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
       break;
-    case INK_EVENT_VCONN_WRITE_READY:
+    case TS_EVENT_VCONN_WRITE_READY:
     default:
       /* If we get a WRITE_READY event or any other type of
          event (sent, perhaps, because we were reenabled) then
@@ -473,30 +473,30 @@ gzip_transform(INKCont contp, INKEvent e
 
 
 static int
-gzip_transformable(INKHttpTxn txnp, int server)
+gzip_transformable(TSHttpTxn txnp, int server)
 {
   /* Server response header */
-  INKMBuffer bufp;
-  INKMLoc hdr_loc;
-  INKMLoc field_loc;
+  TSMBuffer bufp;
+  TSMLoc hdr_loc;
+  TSMLoc field_loc;
 
   /* Client request header */
-  INKMBuffer cbuf;
-  INKMLoc chdr;
-  INKMLoc cfield;
+  TSMBuffer cbuf;
+  TSMLoc chdr;
+  TSMLoc cfield;
 
   const char *value;
   int nvalues;
   int i, deflate_flag;
 
-  INKHttpTxnClientReqGet(txnp, &cbuf, &chdr);
+  TSHttpTxnClientReqGet(txnp, &cbuf, &chdr);
 
   /* check if client accepts "deflate" */
 
-  cfield = INKMimeHdrFieldFind(cbuf, chdr, INK_MIME_FIELD_ACCEPT_ENCODING, -1);
+  cfield = TSMimeHdrFieldFind(cbuf, chdr, TS_MIME_FIELD_ACCEPT_ENCODING, -1);
   if (cfield) {
-    nvalues = INKMimeHdrFieldValuesCount(cbuf, chdr, cfield);
-    INKMimeHdrFieldValueStringGet(cbuf, chdr, cfield, 0, &value, NULL);
+    nvalues = TSMimeHdrFieldValuesCount(cbuf, chdr, cfield);
+    TSMimeHdrFieldValueStringGet(cbuf, chdr, cfield, 0, &value, NULL);
     deflate_flag = 0;
     i = 0;
     while (nvalues > 0) {
@@ -505,112 +505,112 @@ gzip_transformable(INKHttpTxn txnp, int 
         break;
       }
       i++;
-      INKMimeHdrFieldValueStringGet(cbuf, chdr, cfield, i, &value, NULL);
+      TSMimeHdrFieldValueStringGet(cbuf, chdr, cfield, i, &value, NULL);
       nvalues--;
     }
     if (!deflate_flag) {
       return -7;
     }
-    INKHandleMLocRelease(cbuf, chdr, cfield);
-    INKHandleMLocRelease(cbuf, INK_NULL_MLOC, chdr);
+    TSHandleMLocRelease(cbuf, chdr, cfield);
+    TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
   } else {
-    INKHandleMLocRelease(cbuf, chdr, cfield);
-    INKHandleMLocRelease(cbuf, INK_NULL_MLOC, chdr);
+    TSHandleMLocRelease(cbuf, chdr, cfield);
+    TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
     return -6;
   }
 
   if (server) {
-    INKHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
+    TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
   } else {
-    INKHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc);
+    TSHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc);
   }
 
   /* If there already exists a content encoding then we don't want
      to do anything. */
-  field_loc = INKMimeHdrFieldFind(bufp, hdr_loc, INK_MIME_FIELD_CONTENT_ENCODING, -1);
+  field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_ENCODING, -1);
   if (field_loc) {
-    INKHandleMLocRelease(bufp, hdr_loc, field_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return -3;
   }
-  INKHandleMLocRelease(bufp, hdr_loc, field_loc);
+  TSHandleMLocRelease(bufp, hdr_loc, field_loc);
 
   /* We only want to do gzip compression on documents that have a
      content type of "text/" or "application/x-javascript". */
 
-  field_loc = INKMimeHdrFieldFind(bufp, hdr_loc, INK_MIME_FIELD_CONTENT_TYPE, -1);
+  field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_TYPE, -1);
   if (!field_loc) {
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return -4;
   }
 
-  if (INKMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &value, NULL) == INK_ERROR) {
-    INKHandleMLocRelease(bufp, hdr_loc, field_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+  if (TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &value, NULL) == TS_ERROR) {
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return -5;
   }
 
   if (value && (strncasecmp(value, "text/", sizeof("text/") - 1) == 0)) {
-    INKHandleMLocRelease(bufp, hdr_loc, field_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return 0;
   } else if (value && (strncasecmp(value, "application/x-javascript", (sizeof("application/x-javascript") - 1)) == 0)) {
-    INKHandleMLocRelease(bufp, hdr_loc, field_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return 0;
   } else {
-    INKHandleMLocRelease(bufp, hdr_loc, field_loc);
-    INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc);
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return -5;
   }
 }
 
 
 static void
-gzip_transform_add(INKHttpTxn txnp, int server)
+gzip_transform_add(TSHttpTxn txnp, int server)
 {
-  INKVConn connp;
+  TSVConn connp;
   GzipData *data;
 
-  connp = INKTransformCreate(gzip_transform, txnp);
+  connp = TSTransformCreate(gzip_transform, txnp);
 
   data = gzip_data_alloc();
   data->txn = txnp;
-  INKContDataSet(connp, data);
+  TSContDataSet(connp, data);
 
-  INKHttpTxnHookAdd(txnp, INK_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
+  TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
 }
 
 
 static int
-transform_plugin(INKCont contp, INKEvent event, void *edata)
+transform_plugin(TSCont contp, TSEvent event, void *edata)
 {
-  INKHttpTxn txnp = (INKHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn) edata;
   int reason;
 
   switch (event) {
-  case INK_EVENT_HTTP_READ_RESPONSE_HDR:
+  case TS_EVENT_HTTP_READ_RESPONSE_HDR:
     reason = gzip_transformable(txnp, 1);
     if (reason >= 0) {
-      INKDebug("gzip-transform", "server content transformable");
+      TSDebug("gzip-transform", "server content transformable");
       gzip_transform_add(txnp, 1);
     } else {
-      INKDebug("gzip-transform", "server content NOT transformable [%d]", reason);
+      TSDebug("gzip-transform", "server content NOT transformable [%d]", reason);
     }
 
-    INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
     break;
 
-  case INK_EVENT_HTTP_READ_CACHE_HDR:
+  case TS_EVENT_HTTP_READ_CACHE_HDR:
 
     reason = gzip_transformable(txnp, 0);
     if (reason >= 0) {
-      INKDebug("gzip-transform", "cached content transformable");
+      TSDebug("gzip-transform", "cached content transformable");
       gzip_transform_add(txnp, 1);
     } else {
-      INKDebug("gzip-transform", "cached data:  forwarding unchanged (%d)", reason);
+      TSDebug("gzip-transform", "cached data:  forwarding unchanged (%d)", reason);
     }
-    INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
     break;
 
   default:
@@ -622,7 +622,7 @@ transform_plugin(INKCont contp, INKEvent
 
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
   dictId = adler32(0L, Z_NULL, 0);
   if (argc == 2) {
@@ -631,7 +631,7 @@ INKPluginInit(int argc, const char *argv
     load_dictionary(dictionary, &dictId);
   }
 
-  INKHttpHookAdd(INK_HTTP_READ_RESPONSE_HDR_HOOK, INKContCreate(transform_plugin, NULL));
-  INKHttpHookAdd(INK_HTTP_READ_CACHE_HDR_HOOK, INKContCreate(transform_plugin, NULL));
+  TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(transform_plugin, NULL));
+  TSHttpHookAdd(TS_HTTP_READ_CACHE_HDR_HOOK, TSContCreate(transform_plugin, NULL));
 }
 

Propchange: trafficserver/traffic/branches/wccp/example/hello/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 30 01:42:55 2010
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.deps

Modified: trafficserver/traffic/branches/wccp/example/hello/hello.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/hello/hello.c?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/hello/hello.c (original)
+++ trafficserver/traffic/branches/wccp/example/hello/hello.c Tue Nov 30 01:42:55 2010
@@ -39,7 +39,7 @@ int
 check_ts_version()
 {
 
-  const char *ts_version = INKTrafficServerVersionGet();
+  const char *ts_version = TSTrafficServerVersionGet();
   int result = 0;
 
   if (ts_version) {
@@ -61,22 +61,22 @@ check_ts_version()
 }
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
-  INKPluginRegistrationInfo info;
+  TSPluginRegistrationInfo info;
 
   info.plugin_name = "hello-world";
   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;
   }
 
-  INKDebug("debug-hello", "Hello World!\n");
+  TSDebug("debug-hello", "Hello World!\n");
 }

Propchange: trafficserver/traffic/branches/wccp/example/include_other/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 30 01:42:55 2010
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.deps

Modified: trafficserver/traffic/branches/wccp/example/include_other/macro.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/include_other/macro.h?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/include_other/macro.h (original)
+++ trafficserver/traffic/branches/wccp/example/include_other/macro.h Tue Nov 30 01:42:55 2010
@@ -28,16 +28,16 @@
 
 #define LOG_AUTO_ERROR(API_NAME, COMMENT) \
 { \
-    INKDebug(PLUGIN_NAME, "%s %s [%s: line %d] (%s)", API_NAME, "AUTO_FAIL", \
+    TSDebug(PLUGIN_NAME, "%s %s [%s: line %d] (%s)", API_NAME, "AUTO_FAIL", \
             FUNCTION_NAME, __LINE__, COMMENT); \
 }
 #define LOG_API_ERROR(API_NAME) { \
-    INKDebug(DEBUG_TAG, "%s: %s %s [%s] File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
+    TSDebug(DEBUG_TAG, "%s: %s %s [%s] File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
 	     FUNCTION_NAME, __FILE__, __LINE__); \
 }
 
 #define LOG_API_ERROR_COMMENT(API_NAME, COMMENT) { \
-    INKDebug(DEBUG_TAG, "%s: %s %s [%s] File %s, line number %d (%s)", PLUGIN_NAME, API_NAME, "APIFAIL", \
+    TSDebug(DEBUG_TAG, "%s: %s %s [%s] File %s, line number %d (%s)", PLUGIN_NAME, API_NAME, "APIFAIL", \
 	     FUNCTION_NAME, __FILE__, __LINE__, COMMENT); \
 }
 
@@ -54,22 +54,22 @@
 #define LOG_ERROR_AND_REENABLE(API_NAME) \
 { \
     LOG_API_ERROR(API_NAME); \
-    INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE); \
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); \
 }
 
 /* added by nkale for internal plugins */
 #define LOG_NEG_ERROR(API_NAME) { \
-    INKDebug(NEG_ERROR_TAG, "%s: %s %s %s File %s, line number %d",PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
+    TSDebug(NEG_ERROR_TAG, "%s: %s %s %s File %s, line number %d",PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
              FUNCTION_NAME, __FILE__, __LINE__); \
 }
 
 /* Release macros */
-#define VALID_PTR(X) ((X != NULL) && (X != INK_ERROR_PTR))
+#define VALID_PTR(X) ((X != NULL) && (X != TS_ERROR_PTR))
 
 #define FREE(X) \
 { \
     if (VALID_PTR(X)) { \
-        INKfree((void *)X); \
+        TSfree((void *)X); \
         X = NULL; \
     } \
 } \
@@ -77,10 +77,10 @@
 #define HANDLE_RELEASE(P_BUFFER, P_PARENT, P_MLOC) \
 { \
     if (VALID_PTR(P_MLOC)) { \
-        if (INKHandleMLocRelease(P_BUFFER, P_PARENT, P_MLOC) == INK_ERROR) { \
-            LOG_API_ERROR("INKHandleMLocRelease"); \
+        if (TSHandleMLocRelease(P_BUFFER, P_PARENT, P_MLOC) == TS_ERROR) { \
+            LOG_API_ERROR("TSHandleMLocRelease"); \
         } else { \
-            P_MLOC = (INKMLoc)NULL; \
+            P_MLOC = (TSMLoc)NULL; \
         } \
     } \
 }\
@@ -88,8 +88,8 @@
 #define STR_RELEASE(P_BUFFER, P_PARENT, P_STR) \
 { \
     if (VALID_PTR(P_STR)) { \
-        if (INKHandleStringRelease(P_BUFFER, P_PARENT, P_STR) == INK_ERROR) { \
-            LOG_API_ERROR("INKHandleStringRelease"); \
+        if (TSHandleStringRelease(P_BUFFER, P_PARENT, P_STR) == TS_ERROR) { \
+            LOG_API_ERROR("TSHandleStringRelease"); \
         } else  { \
             P_STR = NULL; \
         } \
@@ -99,24 +99,24 @@
 #define URL_DESTROY(P_BUFFER, P_MLOC) \
 { \
     if (VALID_PTR(P_MLOC)) {\
-        INKUrlDestroy (P_BUFFER, P_MLOC); \
+        TSUrlDestroy (P_BUFFER, P_MLOC); \
     } else { \
-        P_MLOC = (INKMLoc)NULL; \
+        P_MLOC = (TSMLoc)NULL; \
     } \
 }\
 
 #define HDR_DESTROY(P_BUFFER, P_MLOC) \
 { \
     if (VALID_PTR(P_MLOC)) \
-        if (INKHttpHdrDestroy (P_BUFFER, P_MLOC) == INK_ERROR) \
-            LOG_API_ERROR("INKHttpHdrDestroy"); \
+        if (TSHttpHdrDestroy (P_BUFFER, P_MLOC) == TS_ERROR) \
+            LOG_API_ERROR("TSHttpHdrDestroy"); \
 }\
 
 #define BUFFER_DESTROY(P_BUFFER) \
 { \
     if (VALID_PTR(P_BUFFER)) \
-        if (INKMBufferDestroy (P_BUFFER) == INK_ERROR) \
-            LOG_API_ERROR("INKMBufferDestroy"); \
+        if (TSMBufferDestroy (P_BUFFER) == TS_ERROR) \
+            LOG_API_ERROR("TSMBufferDestroy"); \
 }\
 
 #endif

Propchange: trafficserver/traffic/branches/wccp/example/null-transform/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 30 01:42:55 2010
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.deps

Modified: trafficserver/traffic/branches/wccp/example/null-transform/null-transform.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/null-transform/null-transform.c?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/null-transform/null-transform.c (original)
+++ trafficserver/traffic/branches/wccp/example/null-transform/null-transform.c Tue Nov 30 01:42:55 2010
@@ -38,9 +38,9 @@
 
 typedef struct
 {
-  INKVIO output_vio;
-  INKIOBuffer output_buffer;
-  INKIOBufferReader output_reader;
+  TSVIO output_vio;
+  TSIOBuffer output_buffer;
+  TSIOBufferReader output_reader;
 } MyData;
 
 static MyData *
@@ -48,7 +48,7 @@ my_data_alloc()
 {
   MyData *data;
 
-  data = (MyData *) INKmalloc(sizeof(MyData));
+  data = (MyData *) TSmalloc(sizeof(MyData));
   data->output_vio = NULL;
   data->output_buffer = NULL;
   data->output_reader = NULL;
@@ -61,25 +61,26 @@ my_data_destroy(MyData * data)
 {
   if (data) {
     if (data->output_buffer) {
-      INKAssert(INKIOBufferDestroy(data->output_buffer) == INK_SUCCESS);
+      TSAssert(TSIOBufferDestroy(data->output_buffer) == TS_SUCCESS);
     }
-    INKfree(data);
+    TSfree(data);
   }
 }
 
 static void
-handle_transform(INKCont contp)
+handle_transform(TSCont contp)
 {
-  INKVConn output_conn;
-  INKIOBuffer buf_test;
-  INKVIO input_vio;
+  TSVConn output_conn;
+  TSIOBuffer buf_test;
+  TSVIO input_vio;
   MyData *data;
-  int towrite;
-  int avail;
+  int64 towrite;
+  int64 avail;
 
+  TSDebug("null-transform", "Entering handle_transform()");
   /* Get the output (downstream) vconnection where we'll write data to. */
 
-  output_conn = INKTransformOutputVConnGet(contp);
+  output_conn = TSTransformOutputVConnGet(contp);
 
   /* Get the write VIO for the write operation that was performed on
    * ourself. This VIO contains the buffer that we are to read from
@@ -87,9 +88,9 @@ handle_transform(INKCont contp)
    * empty. This is the input VIO (the write VIO for the upstream
    * vconnection).
    */
-  input_vio = INKVConnWriteVIOGet(contp);
-  if (input_vio == INK_ERROR_PTR) {
-    INKError("[null-transform] Unable to fetching input VIO\n");
+  input_vio = TSVConnWriteVIOGet(contp);
+  if (input_vio == TS_ERROR_PTR) {
+    TSError("[null-transform] Unable to fetching input VIO\n");
     goto Lerror;
   }
 
@@ -98,14 +99,15 @@ handle_transform(INKCont contp)
    * private data structure pointer is NULL, then we'll create it
    * and initialize its internals.
    */
-  data = INKContDataGet(contp);
+  data = TSContDataGet(contp);
   if (!data) {
     data = my_data_alloc();
-    data->output_buffer = INKIOBufferCreate();
-    data->output_reader = INKIOBufferReaderAlloc(data->output_buffer);
-    data->output_vio = INKVConnWrite(output_conn, contp, data->output_reader, INKVIONBytesGet(input_vio));
-    if (INKContDataSet(contp, data) == INK_ERROR) {
-      INKError("[null-transform] unable to set continuation " "data!\n");
+    data->output_buffer = TSIOBufferCreate();
+    data->output_reader = TSIOBufferReaderAlloc(data->output_buffer);
+    TSDebug("null-transform", "\tWriting %d bytes on VConn", TSVIONBytesGet(input_vio));
+    data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, TSVIONBytesGet(input_vio));
+    if (TSContDataSet(contp, data) == TS_ERROR) {
+      TSError("[null-transform] unable to set continuation " "data!\n");
       goto Lerror;
     }
   }
@@ -118,21 +120,21 @@ handle_transform(INKCont contp)
    * transformation we might have to finish writing the transformed
    * data to our output connection.
    */
-  buf_test = INKVIOBufferGet(input_vio);
+  buf_test = TSVIOBufferGet(input_vio);
 
   if (buf_test) {
-    if (buf_test == INK_ERROR_PTR) {
-      INKError("[null-transform] error fetching buffer\n");
+    if (buf_test == TS_ERROR_PTR) {
+      TSError("[null-transform] error fetching buffer\n");
       goto Lerror;
     }
   } else {
-    if (INKVIONBytesSet(data->output_vio, INKVIONDoneGet(input_vio)) == INK_ERROR) {
-      INKError("[null-transform] error seting output VIO nbytes\n");
+    if (TSVIONBytesSet(data->output_vio, TSVIONDoneGet(input_vio)) == TS_ERROR) {
+      TSError("[null-transform] error seting output VIO nbytes\n");
       goto Lerror;
     }
 
-    if (INKVIOReenable(data->output_vio) == INK_ERROR) {
-      INKError("[null-transform] error reenabling output VIO\n");
+    if (TSVIOReenable(data->output_vio) == TS_ERROR) {
+      TSError("[null-transform] error reenabling output VIO\n");
       goto Lerror;
     }
 
@@ -143,64 +145,65 @@ handle_transform(INKCont contp)
    * transform plugin this is also the amount of data we have left
    * to write to the output connection.
    */
-  towrite = INKVIONTodoGet(input_vio);
+  towrite = TSVIONTodoGet(input_vio);
+  TSDebug("null-transform", "\ttoWrite is %lld", towrite);
 
   if (towrite > 0) {
     /* The amount of data left to read needs to be truncated by
      * the amount of data actually in the read buffer.
      */
-    avail = INKIOBufferReaderAvail(INKVIOReaderGet(input_vio));
+    avail = TSIOBufferReaderAvail(TSVIOReaderGet(input_vio));
+    TSDebug("null-transform", "\tavail is %lld", avail);
     if (towrite > avail) {
       towrite = avail;
     }
 
     if (towrite > 0) {
       /* Copy the data from the read buffer to the output buffer. */
-      if (INKIOBufferCopy(INKVIOBufferGet(data->output_vio), INKVIOReaderGet(input_vio), towrite, 0) == INK_ERROR) {
-        INKError("[null-plugin] unable to copy IO buffers\n");
+      if (TSIOBufferCopy(TSVIOBufferGet(data->output_vio), TSVIOReaderGet(input_vio), towrite, 0) == TS_ERROR) {
+        TSError("[null-plugin] unable to copy IO buffers\n");
         goto Lerror;
       }
 
       /* Tell the read buffer that we have read the data and are no
        * longer interested in it.
        */
-      if (INKIOBufferReaderConsume(INKVIOReaderGet(input_vio), towrite)
-          == INK_ERROR) {
-        INKError("[null-plugin] unable to update VIO reader\n");
+      if (TSIOBufferReaderConsume(TSVIOReaderGet(input_vio), towrite) == TS_ERROR) {
+        TSError("[null-plugin] unable to update VIO reader\n");
         goto Lerror;
       }
 
       /* Modify the input VIO to reflect how much data we've
        * completed.
        */
-      if (INKVIONDoneSet(input_vio, INKVIONDoneGet(input_vio) + towrite) == INK_ERROR) {
-        INKError("[null-plugin] unable to update VIO\n");
+      if (TSVIONDoneSet(input_vio, TSVIONDoneGet(input_vio) + towrite) == TS_ERROR) {
+        TSError("[null-plugin] unable to update VIO\n");
         goto Lerror;
       }
     }
-  } else if (towrite == INK_ERROR) {
-    INKError("[null-plugin] error fetching VIO to-do amount\n");
+  } else if (towrite == TS_ERROR) {
+    TSError("[null-plugin] error fetching VIO to-do amount\n");
     goto Lerror;
   }
 
   /* Now we check the input VIO to see if there is data left to
    * read.
    */
-  if (INKVIONTodoGet(input_vio) > 0) {
+  if (TSVIONTodoGet(input_vio) > 0) {
     if (towrite > 0) {
       /* If there is data left to read, then we reenable the output
        * connection by reenabling the output VIO. This will wake up
        * the output connection and allow it to consume data from the
        * output buffer.
        */
-      if (INKVIOReenable(data->output_vio) == INK_ERROR) {
-        INKError("[null-plugin] error reenabling transaction\n");
+      if (TSVIOReenable(data->output_vio) == TS_ERROR) {
+        TSError("[null-plugin] error reenabling transaction\n");
         goto Lerror;
       }
       /* Call back the input VIO continuation to let it know that we
        * are ready for more data.
        */
-      INKContCall(INKVIOContGet(input_vio), INK_EVENT_VCONN_WRITE_READY, input_vio);
+      TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_READY, input_vio);
     }
   } else {
     /* If there is no data left to read, then we modify the output
@@ -209,16 +212,16 @@ handle_transform(INKCont contp)
      * is done reading. We then reenable the output connection so
      * that it can consume the data we just gave it.
      */
-    INKVIONBytesSet(data->output_vio, INKVIONDoneGet(input_vio));
-    if (INKVIOReenable(data->output_vio) == INK_ERROR) {
-      INKError("[null-plugin] error reenabling transaction\n");
+    TSVIONBytesSet(data->output_vio, TSVIONDoneGet(input_vio));
+    if (TSVIOReenable(data->output_vio) == TS_ERROR) {
+      TSError("[null-plugin] error reenabling transaction\n");
       goto Lerror;
     }
 
     /* Call back the input VIO continuation to let it know that we
      * have completed the write operation.
      */
-    INKContCall(INKVIOContGet(input_vio), INK_EVENT_VCONN_WRITE_COMPLETE, input_vio);
+    TSContCall(TSVIOContGet(input_vio), TS_EVENT_VCONN_WRITE_COMPLETE, input_vio);
   }
 
 
@@ -227,43 +230,50 @@ Lerror:
 }
 
 static int
-null_transform(INKCont contp, INKEvent event, void *edata)
+null_transform(TSCont contp, TSEvent event, void *edata)
 {
   /* Check to see if the transformation has been closed by a call to
-   * INKVConnClose.
+   * TSVConnClose.
    */
-  if (INKVConnClosedGet(contp)) {
-    my_data_destroy(INKContDataGet(contp));
-    INKAssert(INKContDestroy(contp) == INK_SUCCESS);
+  TSDebug("null-transform", "Entering null_transform()");
+
+  if (TSVConnClosedGet(contp)) {
+    TSDebug("null-transform", "\tVConn is closed");
+    my_data_destroy(TSContDataGet(contp));
+    TSAssert(TSContDestroy(contp) == TS_SUCCESS);
     return 0;
   } else {
     switch (event) {
-    case INK_EVENT_ERROR:
+    case TS_EVENT_ERROR:
       {
-        INKVIO input_vio;
+        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 = INKVConnWriteVIOGet(contp);
+        input_vio = TSVConnWriteVIOGet(contp);
 
         /* Call back the write VIO continuation to let it know that we
          * have completed the write operation.
          */
-        INKContCall(INKVIOContGet(input_vio), INK_EVENT_ERROR, input_vio);
+        TSContCall(TSVIOContGet(input_vio), TS_EVENT_ERROR, input_vio);
       }
       break;
-    case INK_EVENT_VCONN_WRITE_COMPLETE:
+    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
        * reading all the data we've written to it then we should
        * shutdown the write portion of its connection to
        * indicate that we don't want to hear about it anymore.
        */
-      INKAssert(INKVConnShutdown(INKTransformOutputVConnGet(contp), 0, 1) != INK_ERROR);
+      TSAssert(TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1) != TS_ERROR);
       break;
-    case INK_EVENT_VCONN_WRITE_READY:
+    case TS_EVENT_VCONN_WRITE_READY:
+      TSDebug("null-transform", "\tEvent is TS_EVENT_VCONN_WRITE_READY");
     default:
+      TSDebug("null-transform", "\t(event is %d)", event);
       /* If we get a WRITE_READY event or any other type of
        * event (sent, perhaps, because we were reenabled) then
        * we'll attempt to transform more data.
@@ -277,54 +287,58 @@ null_transform(INKCont contp, INKEvent e
 }
 
 static int
-transformable(INKHttpTxn txnp)
+transformable(TSHttpTxn txnp)
 {
   /*
    *  We are only interested in transforming "200 OK" responses.
    */
 
-  INKMBuffer bufp;
-  INKMLoc hdr_loc;
-  INKHttpStatus resp_status;
+  TSMBuffer bufp;
+  TSMLoc hdr_loc;
+  TSHttpStatus resp_status;
   int retv;
 
-  INKHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
-  resp_status = INKHttpHdrStatusGet(bufp, hdr_loc);
-  retv = (resp_status == INK_HTTP_STATUS_OK);
+  TSDebug("null-transform", "Entering transformable()");
+
+  TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
+  resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
+  retv = (resp_status == TS_HTTP_STATUS_OK);
 
-  if (INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc) == INK_ERROR) {
-    INKError("[null-transform] Error releasing MLOC while checking " "header status\n");
+  if (TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc) == TS_ERROR) {
+    TSError("[null-transform] Error releasing MLOC while checking " "header status\n");
   }
 
+  TSDebug("null-transform", "Exiting transformable with return %d", retv);
   return retv;
 }
 
 static void
-transform_add(INKHttpTxn txnp)
+transform_add(TSHttpTxn txnp)
 {
-  INKVConn connp;
-
-  connp = INKTransformCreate(null_transform, txnp);
+  TSVConn connp;
 
-  if (INKHttpTxnHookAdd(txnp, INK_HTTP_RESPONSE_TRANSFORM_HOOK, connp)
-      == INK_ERROR) {
-    INKError("[null-plugin] Unable to attach plugin to transaction\n");
+  TSDebug("null-transform", "Entering transform_add()");
+  connp = TSTransformCreate(null_transform, txnp);
+  if (TSHttpTxnHookAdd(txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp) == TS_ERROR) {
+    TSError("[null-plugin] Unable to attach plugin to transaction\n");
   }
 }
 
 static int
-transform_plugin(INKCont contp, INKEvent event, void *edata)
+transform_plugin(TSCont contp, TSEvent event, void *edata)
 {
-  INKHttpTxn txnp = (INKHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn) edata;
 
+  TSDebug("null-transform", "Entering transform_plugin()");
   switch (event) {
-  case INK_EVENT_HTTP_READ_RESPONSE_HDR:
+  case TS_EVENT_HTTP_READ_RESPONSE_HDR:
+    TSDebug("null-transform", "\tEvent is TS_EVENT_HTTP_READ_RESPONSE_HDR");
     if (transformable(txnp)) {
       transform_add(txnp);
     }
 
-    if (INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE) == INK_ERROR) {
-      INKError("[null-plugin] Alert! unable to continue " "the HTTP transaction\n");
+    if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == TS_ERROR) {
+      TSError("[null-plugin] Alert! unable to continue " "the HTTP transaction\n");
       return -1;
     }
     return 0;
@@ -339,7 +353,7 @@ int
 check_ts_version()
 {
 
-  const char *ts_version = INKTrafficServerVersionGet();
+  const char *ts_version = TSTrafficServerVersionGet();
   int result = 0;
 
   if (ts_version) {
@@ -362,31 +376,31 @@ check_ts_version()
 }
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
-  INKPluginRegistrationInfo info;
+  TSPluginRegistrationInfo info;
 
   info.plugin_name = "null-transform";
   info.vendor_name = "MyCompany";
   info.support_email = "ts-api-support@MyCompany.com";
 
-  if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) {
-    INKError("[null-transform] Plugin registration failed.\n");
+  if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+    TSError("[null-transform] Plugin registration failed.\n");
     goto Lerror;
   }
 
   if (!check_ts_version()) {
-    INKError("[null-transform] Plugin requires Traffic Server 2.0 " "or later\n");
+    TSError("[null-transform] Plugin requires Traffic Server 2.0 " "or later\n");
     goto Lerror;
   }
 
-  if (INKHttpHookAdd(INK_HTTP_READ_RESPONSE_HDR_HOOK, INKContCreate(transform_plugin, NULL)) == INK_ERROR) {
-    INKError("[null-transform] Unable to set READ_RESPONSE_HDR_HOOK\n");
+  if (TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(transform_plugin, NULL)) == TS_ERROR) {
+    TSError("[null-transform] Unable to set READ_RESPONSE_HDR_HOOK\n");
     goto Lerror;
   }
 
   return;
 
 Lerror:
-  INKError("[null-tranform] Unable to initialize plugin (disabled).\n");
+  TSError("[null-tranform] Unable to initialize plugin (disabled).\n");
 }

Modified: trafficserver/traffic/branches/wccp/example/null-transform/readme.txt
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/null-transform/readme.txt?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/null-transform/readme.txt (original)
+++ trafficserver/traffic/branches/wccp/example/null-transform/readme.txt Tue Nov 30 01:42:55 2010
@@ -4,7 +4,7 @@ on response content. 
 The plugin is called each time Traffic Server reads an HTTP 
 response header.
 
-  --  The INKPluginInit function has a global hook
+  --  The TSPluginInit function has a global hook
       set up for the READ RESPONSE HDR event.
 
 This plugin follows the default behavior for transforms: 
@@ -21,7 +21,7 @@ transformation, and adds it to the respo
 hook. 
 
   -- This is done in "transform_add" using 
-     INKTransformCreate and INKHttpTxnHookAdd.
+     TSTransformCreate and TSHttpTxnHookAdd.
 
   -- The handler function for the transformation is
      null_transform.
@@ -50,18 +50,18 @@ destroys itself if it finds out the tran
 closed). Then null_transform has a switch statement that 
 handles the following events: 
 
-  -- INK_EVENT_ERROR: if there is an error, null_transform
+  -- TS_EVENT_ERROR: if there is an error, null_transform
      lets the downstream vconnection know that the write
      operation is terminated (the downstream vconnection
      should not expect any more data). 
 
-  -- INK_EVENT_VCONN_WRITE_COMPLETE: the downstream vconnection
+  -- TS_EVENT_VCONN_WRITE_COMPLETE: the downstream vconnection
      has read all the data written to it. null_transform 
      shuts down the write portion of the downstream vconnection,
      meaning that the transformation does not want any more 
      WRITE events from the downstream vconnection. 
 
-  -- INK_EVENT_VCONN_WRITE_READY: null_transform calls 
+  -- TS_EVENT_VCONN_WRITE_READY: null_transform calls 
      handle_transform to transform data.
 
   -- All other events: call handle_transform. 
@@ -71,38 +71,38 @@ takes the role of the "vconnection user"
 Guide).  
 
 handle_transform needs to initiate the transformation by a call
-to INKVConnWrite on the output vconnection. To do this, handle_transform
+to TSVConnWrite on the output vconnection. To do this, handle_transform
 has to:
 
- -- get the output vconnection using INKTransformOutputVConnGet
+ -- get the output vconnection using TSTransformOutputVConnGet
 
- -- get the input vio using INKVConnWriteVIOGet (the input vio
+ -- get the input vio using TSVConnWriteVIOGet (the input vio
     contains the total number of bytes to be written, and keeps
     track of the number of bytes that the upstream vconnection
     has written to the input buffer. When the transformation has
     consumed data from the input buffer, it has to modify the 
     input vio.)
 
-After calling INKVConnWrite, the transformation can expect to 
+After calling TSVConnWrite, the transformation can expect to 
 receive WRITE_READY and WRITE_COMPLETE events from the downstream
 vconnection. 
 
 If there is data to read, handle_transform copies it over using
-INKIOBufferCopy. When done with the buffer, it calls
-INKIOBufferReaderConsume. If there is more data to read (than one
+TSIOBufferCopy. When done with the buffer, it calls
+TSIOBufferReaderConsume. If there is more data to read (than one
 buffer's worth), two things happen:
 
  -- handle_transform wakes up the downstream vconnection using
-    INKVIOReenable
+    TSVIOReenable
 
  -- handle_transform wakes up the upstream vconnection, asking it
-    for more data, by using INKContCall and sending it a 
+    for more data, by using TSContCall and sending it a 
     WRITE_READY event
 
 If there is no more data to read, handle_transform informs the 
-downstream vconnection using INKVIONBytesSet and INKVIOReenable.
+downstream vconnection using TSVIONBytesSet and TSVIOReenable.
 Then handle_transform sends the upstream vconnection the
-WRITE_COMPLETE event using INKContCall. 
+WRITE_COMPLETE event using TSContCall. 
 
 This is how the transformation receives the WRITE_COMPLETE event:
 when the downstream vconnection learns through the downstream

Propchange: trafficserver/traffic/branches/wccp/example/output-header/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 30 01:42:55 2010
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.deps

Modified: trafficserver/traffic/branches/wccp/example/output-header/output-header.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/output-header/output-header.c?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/output-header/output-header.c (original)
+++ trafficserver/traffic/branches/wccp/example/output-header/output-header.c Tue Nov 30 01:42:55 2010
@@ -23,7 +23,7 @@
 
 /* output_hdr.c: a plugin prints out the client request header
  *                 fields to stdout
- * A sample internal plugin to use the HdrPrint functions and the INKIOBuffers
+ * A sample internal plugin to use the HdrPrint functions and the TSIOBuffers
  * that the functions untilize.
  *
  * The plugin simply prints all the incoming request headers
@@ -48,97 +48,97 @@
 #define DEBUG_TAG "output-header"
 
 static void
-handle_dns(INKHttpTxn txnp, INKCont contp)
+handle_dns(TSHttpTxn txnp, TSCont contp)
 {
-  INKMBuffer bufp;
-  INKMLoc hdr_loc;
+  TSMBuffer bufp;
+  TSMLoc hdr_loc;
 
-  INKIOBuffer output_buffer;
-  INKIOBufferReader reader;
+  TSIOBuffer output_buffer;
+  TSIOBufferReader reader;
   int total_avail;
 
-  INKIOBufferBlock block;
+  TSIOBufferBlock block;
   const char *block_start;
-  int block_avail;
+  int64 block_avail;
 
   char *output_string;
-  int output_len;
+  int64 output_len;
 
-  if (!INKHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
-    INKDebug(DEBUG_TAG, "couldn't retrieve client request header");
-    INKError("couldn't retrieve client request header\n");
+  if (!TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc)) {
+    TSDebug(DEBUG_TAG, "couldn't retrieve client request header");
+    TSError("couldn't retrieve client request header\n");
     goto done;
   }
 
-  output_buffer = INKIOBufferCreate();
+  output_buffer = TSIOBufferCreate();
 
-  /* INKIOBufferCreate may return an error pointer */
-  if ((void *) output_buffer == INK_ERROR_PTR) {
-    INKDebug(DEBUG_TAG, "couldn't allocate IOBuffer");
-    INKError("couldn't allocate IOBuffer\n");
+  /* TSIOBufferCreate may return an error pointer */
+  if ((void *) output_buffer == TS_ERROR_PTR) {
+    TSDebug(DEBUG_TAG, "couldn't allocate IOBuffer");
+    TSError("couldn't allocate IOBuffer\n");
     goto done;
   }
 
-  reader = INKIOBufferReaderAlloc(output_buffer);
+  reader = TSIOBufferReaderAlloc(output_buffer);
 
-  /* INKIOBufferReaderAlloc may return an error pointer */
-  if ((void *) reader == INK_ERROR_PTR) {
-    INKDebug(DEBUG_TAG, "couldn't allocate IOBufferReader");
-    INKError("couldn't allocate IOBufferReader\n");
+  /* TSIOBufferReaderAlloc may return an error pointer */
+  if ((void *) reader == TS_ERROR_PTR) {
+    TSDebug(DEBUG_TAG, "couldn't allocate IOBufferReader");
+    TSError("couldn't allocate IOBufferReader\n");
     goto done;
   }
 
   /* This will print  just MIMEFields and not
      the http request line */
-  INKDebug(DEBUG_TAG, "Printing the hdrs ... ");
-  if (INKMimeHdrPrint(bufp, hdr_loc, output_buffer) == INK_ERROR) {
-    INKDebug(DEBUG_TAG, "non-fatal: error printing mime-hdrs");
-    INKError("non-fatal: error printing mime-hdrs\n");
+  TSDebug(DEBUG_TAG, "Printing the hdrs ... ");
+  if (TSMimeHdrPrint(bufp, hdr_loc, output_buffer) == TS_ERROR) {
+    TSDebug(DEBUG_TAG, "non-fatal: error printing mime-hdrs");
+    TSError("non-fatal: error printing mime-hdrs\n");
   }
 
-  if (INKHandleMLocRelease(bufp, INK_NULL_MLOC, hdr_loc) == INK_ERROR) {
-    INKDebug(DEBUG_TAG, "non-fatal: error releasing MLoc");
-    INKError("non-fatal: error releasing MLoc\n");
+  if (TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc) == TS_ERROR) {
+    TSDebug(DEBUG_TAG, "non-fatal: error releasing MLoc");
+    TSError("non-fatal: error releasing MLoc\n");
   }
 
   /* Find out how the big the complete header is by
      seeing the total bytes in the buffer.  We need to
      look at the buffer rather than the first block to
      see the size of the entire header */
-  total_avail = INKIOBufferReaderAvail(reader);
+  total_avail = TSIOBufferReaderAvail(reader);
 
-  /* INKIOBufferReaderAvail may send an INK_ERROR */
-  if ((INKReturnCode) total_avail == INK_ERROR) {
-    INKDebug(DEBUG_TAG, "couldn't get available byte-count from IO-read-buffer");
-    INKError("couldn't get available byte-count from IO-read-buffer\n");
+  /* TSIOBufferReaderAvail may send an TS_ERROR */
+  if ((TSReturnCode) total_avail == TS_ERROR) {
+    TSDebug(DEBUG_TAG, "couldn't get available byte-count from IO-read-buffer");
+    TSError("couldn't get available byte-count from IO-read-buffer\n");
     goto done;
   }
 
   /* Allocate the string with an extra byte for the string
      terminator */
-  output_string = (char *) INKmalloc(total_avail + 1);
+  output_string = (char *) TSmalloc(total_avail + 1);
   output_len = 0;
 
   /* We need to loop over all the buffer blocks to make
      sure we get the complete header since the header can
      be in multiple blocks */
-  block = INKIOBufferReaderStart(reader);
+  block = TSIOBufferReaderStart(reader);
 
-  /* INKIOBufferReaderStart may return an error pointer */
-  if (block == INK_ERROR_PTR) {
-    INKDebug(DEBUG_TAG, "couldn't get from IOBufferBlock");
-    INKError("couldn't get from IOBufferBlock\n");
+  /* TSIOBufferReaderStart may return an error pointer */
+  if (block == TS_ERROR_PTR) {
+    TSDebug(DEBUG_TAG, "couldn't get from IOBufferBlock");
+    TSError("couldn't get from IOBufferBlock\n");
     goto done;
   }
 
   while (block) {
 
-    block_start = INKIOBufferBlockReadStart(block, reader, &block_avail);
+    block_start = TSIOBufferBlockReadStart(block, reader, &block_avail);
 
-    /* INKIOBufferBlockReadStart may return an error pointer */
-    if (block_start == INK_ERROR_PTR) {
-      INKDebug(DEBUG_TAG, "couldn't read from IOBuffer");
-      INKError("couldn't read from IOBuffer\n");
+    /* TSIOBufferBlockReadStart may return an error pointer */
+    if (block_start == TS_ERROR_PTR) {
+      TSDebug(DEBUG_TAG, "couldn't read from IOBuffer");
+      TSError("couldn't read from IOBuffer\n");
       goto done;
     }
 
@@ -155,19 +155,19 @@ handle_dns(INKHttpTxn txnp, INKCont cont
     output_len += block_avail;
 
     /* Consume the data so that we get to the next block */
-    if (INKIOBufferReaderConsume(reader, block_avail) == INK_ERROR) {
-      INKDebug(DEBUG_TAG, "error consuming data from the ReaderBlock");
-      INKError("error consuming data from the ReaderBlock\n");
+    if (TSIOBufferReaderConsume(reader, block_avail) == TS_ERROR) {
+      TSDebug(DEBUG_TAG, "error consuming data from the ReaderBlock");
+      TSError("error consuming data from the ReaderBlock\n");
     }
 
     /* Get the next block now that we've consumed the
        data off the last block */
-    block = INKIOBufferReaderStart(reader);
+    block = TSIOBufferReaderStart(reader);
 
-    /* INKIOBufferReaderStart may return an error pointer */
-    if (block == INK_ERROR_PTR) {
-      INKDebug(DEBUG_TAG, "couldn't get from IOBufferBlock");
-      INKError("couldn't get from IOBufferBlock\n");
+    /* TSIOBufferReaderStart may return an error pointer */
+    if (block == TS_ERROR_PTR) {
+      TSDebug(DEBUG_TAG, "couldn't get from IOBufferBlock");
+      TSError("couldn't get from IOBufferBlock\n");
       goto done;
     }
   }
@@ -176,34 +176,34 @@ handle_dns(INKHttpTxn txnp, INKCont cont
   output_string[output_len] = '\0';
   output_len++;
 
-  /* Free up the INKIOBuffer that we used to print out the header */
-  if (INKIOBufferReaderFree(reader) != INK_SUCCESS) {
-    INKDebug(DEBUG_TAG, "non-fatal: error releasing IOBufferReader");
-    INKError("non-fatal: error releasing IOBufferReader\n");
+  /* Free up the TSIOBuffer that we used to print out the header */
+  if (TSIOBufferReaderFree(reader) != TS_SUCCESS) {
+    TSDebug(DEBUG_TAG, "non-fatal: error releasing IOBufferReader");
+    TSError("non-fatal: error releasing IOBufferReader\n");
   }
 
-  if (INKIOBufferDestroy(output_buffer) != INK_SUCCESS) {
-    INKDebug(DEBUG_TAG, "non-fatal: error destroying IOBuffer");
-    INKError("non-fatal: error destroying IOBuffer\n");
+  if (TSIOBufferDestroy(output_buffer) != TS_SUCCESS) {
+    TSDebug(DEBUG_TAG, "non-fatal: error destroying IOBuffer");
+    TSError("non-fatal: error destroying IOBuffer\n");
   }
 
   /* Although I'd never do this a production plugin, printf
      the header so that we can see it's all there */
-  INKDebug("debug-output-header", "%s", output_string);
+  TSDebug("debug-output-header", "%s", output_string);
 
-  INKfree(output_string);
+  TSfree(output_string);
 
 done:
-  INKHttpTxnReenable(txnp, INK_EVENT_HTTP_CONTINUE);
+  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
 }
 
 static int
-hdr_plugin(INKCont contp, INKEvent event, void *edata)
+hdr_plugin(TSCont contp, TSEvent event, void *edata)
 {
-  INKHttpTxn txnp = (INKHttpTxn) edata;
+  TSHttpTxn txnp = (TSHttpTxn) edata;
 
   switch (event) {
-  case INK_EVENT_HTTP_OS_DNS:
+  case TS_EVENT_HTTP_OS_DNS:
     handle_dns(txnp, contp);
     return 0;
   default:
@@ -217,7 +217,7 @@ int
 check_ts_version()
 {
 
-  const char *ts_version = INKTrafficServerVersionGet();
+  const char *ts_version = TSTrafficServerVersionGet();
   int result = 0;
 
   if (ts_version) {
@@ -239,28 +239,28 @@ check_ts_version()
 }
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
-  INKPluginRegistrationInfo info;
+  TSPluginRegistrationInfo info;
 
   info.plugin_name = "output-header";
   info.vendor_name = "MyCompany";
   info.support_email = "ts-api-support@MyCompany.com";
 
-  if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) {
-    INKError("[PluginInit] Plugin registration failed.\n");
+  if (!TSPluginRegister(TS_SDK_VERSION_2_0, &info)) {
+    TSError("[PluginInit] Plugin registration failed.\n");
     goto error;
   }
 
   if (!check_ts_version()) {
-    INKError("[PluginInit] Plugin requires Traffic Server 2.0 or later\n");
+    TSError("[PluginInit] Plugin requires Traffic Server 2.0 or later\n");
     goto error;
   }
 
 
-  INKHttpHookAdd(INK_HTTP_OS_DNS_HOOK, INKContCreate(hdr_plugin, NULL));
+  TSHttpHookAdd(TS_HTTP_OS_DNS_HOOK, TSContCreate(hdr_plugin, NULL));
 
 error:
-  INKError("[PluginInit] Plugin not initialized");
+  TSError("[PluginInit] Plugin not initialized");
 }
 

Modified: trafficserver/traffic/branches/wccp/example/output-header/readme
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/output-header/readme?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/output-header/readme (original)
+++ trafficserver/traffic/branches/wccp/example/output-header/readme Tue Nov 30 01:42:55 2010
@@ -1,4 +1,4 @@
-A sample internal plugin to use the HdrPrint functions and the INKIOBuffers 
+A sample internal plugin to use the HdrPrint functions and the TSIOBuffers 
 that the functions untilize.  
 
 The plugin simply prints all the incoming request headers

Propchange: trafficserver/traffic/branches/wccp/example/prefetch/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 30 01:42:55 2010
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.deps

Modified: trafficserver/traffic/branches/wccp/example/prefetch/prefetch-plugin-eg1.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/example/prefetch/prefetch-plugin-eg1.c?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/example/prefetch/prefetch-plugin-eg1.c (original)
+++ trafficserver/traffic/branches/wccp/example/prefetch/prefetch-plugin-eg1.c Tue Nov 30 01:42:55 2010
@@ -30,33 +30,33 @@
 #include <stdio.h>
 #include <string.h>
 #include <ts/ts.h>
-#include <ts/ts_private.h>
+#include <ts/experimental.h>
 
 /* We will register the following two hooks */
 
-int my_preparse_hook(int hook, INKPrefetchInfo * info);
-int my_embedded_url_hook(int hook, INKPrefetchInfo * info);
+int my_preparse_hook(int hook, TSPrefetchInfo * info);
+int my_embedded_url_hook(int hook, TSPrefetchInfo * info);
 
 void
-INKPluginInit(int argc, const char *argv[])
+TSPluginInit(int argc, const char *argv[])
 {
-  INKPluginRegistrationInfo info;
+  TSPluginRegistrationInfo info;
 
   info.plugin_name = "prefetch_plugin_eg1";
   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");
   }
 
   /* register our hooks */
-  INKPrefetchHookSet(INK_PREFETCH_PRE_PARSE_HOOK, &my_preparse_hook);
-  INKPrefetchHookSet(INK_PREFETCH_EMBEDDED_URL_HOOK, &my_embedded_url_hook);
+  TSPrefetchHookSet(TS_PREFETCH_PRE_PARSE_HOOK, &my_preparse_hook);
+  TSPrefetchHookSet(TS_PREFETCH_EMBEDDED_URL_HOOK, &my_embedded_url_hook);
 }
 
 int
-my_preparse_hook(int hook, INKPrefetchInfo * info)
+my_preparse_hook(int hook, TSPrefetchInfo * info)
 {
   unsigned char *ip = (unsigned char *) &info->client_ip;
 
@@ -64,11 +64,11 @@ my_preparse_hook(int hook, INKPrefetchIn
 
 
   /* we will let TS parse the page */
-  return INK_PREFETCH_CONTINUE;
+  return TS_PREFETCH_CONTINUE;
 }
 
 int
-my_embedded_url_hook(int hook, INKPrefetchInfo * info)
+my_embedded_url_hook(int hook, TSPrefetchInfo * info)
 {
 
   unsigned char *ip = (unsigned char *) &info->client_ip;
@@ -80,11 +80,11 @@ my_embedded_url_hook(int hook, INKPrefet
      We will select UDP for sending url and TCP for sending object
    */
 
-  info->url_proto = INK_PREFETCH_PROTO_UDP;
-  info->url_response_proto = INK_PREFETCH_PROTO_TCP;
+  info->url_proto = TS_PREFETCH_PROTO_UDP;
+  info->url_response_proto = TS_PREFETCH_PROTO_TCP;
 
-  /* we can return INK_PREFETCH_DISCONTINUE if we dont want TS to prefetch
+  /* we can return TS_PREFETCH_DISCONTINUE if we dont want TS to prefetch
      this url */
 
-  return INK_PREFETCH_CONTINUE;
+  return TS_PREFETCH_CONTINUE;
 }