Modified: 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/mutex-guide/index.en.mdtext
URL: 
http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/mutex-guide/index.en.mdtext?rev=1164283&r1=1164282&r2=1164283&view=diff
==============================================================================
--- 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/mutex-guide/index.en.mdtext
 (original)
+++ 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/mutex-guide/index.en.mdtext
 Thu Sep  1 21:34:29 2011
@@ -96,15 +96,15 @@ by other continuations or processes. Her
 For example:
 
                 ::::c
-               TSMutex mutexp;
-               mutexp = TSMutexCreate ();
+        TSMutex mutexp;
+        mutexp = TSMutexCreate ();
 
 2.  When you create the continuation, specify this mutex as the continuation's 
mutex.   
 For example:
 
                 :::c
                 TSCont contp;
-               contp = TSContCreate (handler, mutexp);
+        contp = TSContCreate (handler, mutexp);
 
 
 If any other functions want to access `contp`'s data, then it is up to them 
@@ -137,15 +137,15 @@ called `txn_contp`.
            ::::c
            void TSPluginInit(int argc, const char *argv[]) 
            { 
-               /* Plugin continuation */ 
-               TSCont contp; 
-               if ((contp = TSContCreate (plugin_cont_handler, NULL)) == 
TS_ERROR_PTR) { 
-                       LOG_ERROR("TSContCreate"); 
-               } else { 
-                       if (TSHttpHookAdd (TS_HTTP_TXN_START_HOOK, contp) == 
TS_ERROR) { 
-                               LOG_ERROR("TSHttpHookAdd"); 
-                       } 
-               } 
+               /* Plugin continuation */ 
+               TSCont contp; 
+               if ((contp = TSContCreate (plugin_cont_handler, NULL)) == 
TS_ERROR_PTR) { 
+                   LOG_ERROR("TSContCreate"); 
+               } else { 
+                   if (TSHttpHookAdd (TS_HTTP_TXN_START_HOOK, contp) == 
TS_ERROR) { 
+                       LOG_ERROR("TSHttpHookAdd"); 
+                   } 
+               } 
            }
 
 In the plugin continuation handler, create the new continuation `txn_contp` 
@@ -154,31 +154,31 @@ and then register it to be called back a
            ::::c
            static int plugin_cont_handler(TSCont contp, TSEvent event, void 
*edata) 
            { 
-               TSHttpTxn txnp = (TSHttpTxn)edata; 
-               TSCont txn_contp; 
+               TSHttpTxn txnp = (TSHttpTxn)edata; 
+               TSCont txn_contp; 
 
-               switch (event) { 
-                       case TS_EVENT_HTTP_TXN_START: 
-                               /* Create the HTTP txn continuation */ 
-                               txn_contp = TSContCreate(txn_cont_handler, 
NULL); 
-
-                               /* Register txn_contp to be called back when 
txnp reaches TS_HTTP_TXN_CLOSE_HOOK */ 
-                               if (TSHttpTxnHookAdd (txnp, 
TS_HTTP_TXN_CLOSE_HOOK, txn_contp) == TS_ERROR) { 
-                                       LOG_ERROR("TSHttpTxnHookAdd"); 
-                               } 
-
-                               break; 
-
-                       default: 
-                               TSAssert(!"Unexpected Event"); 
-                               break; 
-               } 
-
-               if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == 
TS_ERROR) { 
-                       LOG_ERROR("TSHttpTxnReenable"); 
-               } 
+               switch (event) { 
+                   case TS_EVENT_HTTP_TXN_START: 
+                       /* Create the HTTP txn continuation */ 
+                       txn_contp = TSContCreate(txn_cont_handler, NULL); 
+
+                       /* Register txn_contp to be called back when txnp 
reaches TS_HTTP_TXN_CLOSE_HOOK */ 
+                       if (TSHttpTxnHookAdd (txnp, TS_HTTP_TXN_CLOSE_HOOK, 
txn_contp) == TS_ERROR) { 
+                           LOG_ERROR("TSHttpTxnHookAdd"); 
+                       } 
+
+                       break; 
+
+                   default: 
+                       TSAssert(!"Unexpected Event"); 
+                       break; 
+               } 
+
+               if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == 
TS_ERROR) { 
+                   LOG_ERROR("TSHttpTxnReenable"); 
+               } 
 
-               return 0; 
+               return 0; 
            }
 
 
@@ -188,23 +188,23 @@ is closed. If you forget to do this, the
            ::::c
            static int txn_cont_handler(TSCont txn_contp, TSEvent event, void 
*edata) 
            { 
-               TSHttpTxn txnp; 
-               switch (event) { 
-                       case TS_EVENT_HTTP_TXN_CLOSE: 
-                               txnp = (TSHttpTxn) edata; 
-                               TSContDestroy(txn_contp); 
-                               break; 
-
-                       default: 
-                               TSAssert(!"Unexpected Event"); 
-                               break; 
-               } 
-
-               if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == 
TS_ERROR) { 
-                       LOG_ERROR("TSHttpTxnReenable"); 
-               } 
+               TSHttpTxn txnp; 
+               switch (event) { 
+                   case TS_EVENT_HTTP_TXN_CLOSE: 
+                       txnp = (TSHttpTxn) edata; 
+                       TSContDestroy(txn_contp); 
+                       break; 
+
+                   default: 
+                       TSAssert(!"Unexpected Event"); 
+                       break; 
+               } 
+
+               if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == 
TS_ERROR) { 
+                   LOG_ERROR("TSHttpTxnReenable"); 
+               } 
 
-               return 0; 
+               return 0; 
            }
 
 
@@ -215,9 +215,9 @@ means that you'll create your own data s
 the state of the HTTP transaction:
 
            ::::c
-          typedef struct { 
-                int state; 
-            } ContData;
+       typedef struct { 
+             int state; 
+         } ContData;
 
 You need to allocate the memory and initialize this structure for each HTTP 
 `txnp`. You can do that in the plugin continuation handler when it is called 
@@ -226,39 +226,39 @@ back with `TS_EVENT_HTTP_TXN_START`
            ::::c
            static int plugin_cont_handler(TSCont contp, TSEvent event, void 
*edata) 
            { 
-               TSHttpTxn txnp = (TSHttpTxn)edata; 
-               TSCont txn_contp; 
-               ContData *contData; 
-
-               switch (event) { 
-                       case TS_EVENT_HTTP_TXN_START: 
-                               /* Create the HTTP txn continuation */ 
-                               txn_contp = TSContCreate(txn_cont_handler, 
NULL); 
-
-                               /* Allocate and initialize the txn_contp data 
*/ 
-                               contData = (ContData*) 
TSmalloc(sizeof(ContData)); 
-                               contData->state = 0; 
-                               if (TSContDataSet(txn_contp, contData) == 
TS_ERROR) { 
-                                       LOG_ERROR("TSContDataSet"); 
-                               } 
-
-                               /* Register txn_contp to be called back when 
txnp reaches TS_HTTP_TXN_CLOSE_HOOK */ 
-                               if (TSHttpTxnHookAdd (txnp, 
TS_HTTP_TXN_CLOSE_HOOK, txn_contp) == TS_ERROR) { 
-                                       LOG_ERROR("TSHttpTxnHookAdd"); 
-                               } 
-
-                               break; 
-
-                       default: 
-                               TSAssert(!"Unexpected Event"); 
-                               break; 
-               } 
-
-               if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == 
TS_ERROR) { 
-                       LOG_ERROR("TSHttpTxnReenable"); 
-               } 
+               TSHttpTxn txnp = (TSHttpTxn)edata; 
+               TSCont txn_contp; 
+               ContData *contData; 
+
+               switch (event) { 
+                   case TS_EVENT_HTTP_TXN_START: 
+                       /* Create the HTTP txn continuation */ 
+                       txn_contp = TSContCreate(txn_cont_handler, NULL); 
+
+                       /* Allocate and initialize the txn_contp data */ 
+                       contData = (ContData*) TSmalloc(sizeof(ContData)); 
+                       contData->state = 0; 
+                       if (TSContDataSet(txn_contp, contData) == TS_ERROR) { 
+                           LOG_ERROR("TSContDataSet"); 
+                       } 
+
+                       /* Register txn_contp to be called back when txnp 
reaches TS_HTTP_TXN_CLOSE_HOOK */ 
+                       if (TSHttpTxnHookAdd (txnp, TS_HTTP_TXN_CLOSE_HOOK, 
txn_contp) == TS_ERROR) { 
+                           LOG_ERROR("TSHttpTxnHookAdd"); 
+                       } 
+
+                       break; 
+
+                   default: 
+                       TSAssert(!"Unexpected Event"); 
+                       break; 
+               } 
+
+               if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == 
TS_ERROR) { 
+                   LOG_ERROR("TSHttpTxnReenable"); 
+               } 
 
-               return 0; 
+               return 0; 
            }
 
 For accessing this data from anywhere, use TSContDataGet:
@@ -269,7 +269,7 @@ For accessing this data from anywhere, u
 
            contData = TSContDataGet(txn_contp); 
            if (contData == TS_ERROR_PTR) { 
-               LOG_ERROR("TSContDataGet"); 
+               LOG_ERROR("TSContDataGet"); 
            } 
            contData->state = 1;
 
@@ -278,30 +278,30 @@ Remember to free this memory before dest
            ::::c
            static int txn_cont_handler(TSCont txn_contp, TSEvent event, void 
*edata) 
            { 
-               TSHttpTxn txnp; 
-               ContData *contData; 
-               switch (event) { 
-                       case TS_EVENT_HTTP_TXN_CLOSE: 
-                               txnp = (TSHttpTxn) edata; 
-                               contData = TSContDataGet(txn_contp); 
-                               if (contData == TS_ERROR_PTR) { 
-                                       LOG_ERROR("TSContDataGet"); 
-                               } else { 
-                                       TSfree(contData); 
-                               } 
-                               TSContDestroy(txn_contp); 
-                               break; 
-
-                       default: 
-                               TSAssert(!"Unexpected Event"); 
-                               break; 
-               } 
-
-               if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == 
TS_ERROR) { 
-                       LOG_ERROR("TSHttpTxnReenable"); 
-               } 
+               TSHttpTxn txnp; 
+               ContData *contData; 
+               switch (event) { 
+                   case TS_EVENT_HTTP_TXN_CLOSE: 
+                       txnp = (TSHttpTxn) edata; 
+                       contData = TSContDataGet(txn_contp); 
+                       if (contData == TS_ERROR_PTR) { 
+                           LOG_ERROR("TSContDataGet"); 
+                       } else { 
+                           TSfree(contData); 
+                       } 
+                       TSContDestroy(txn_contp); 
+                       break; 
+
+                   default: 
+                       TSAssert(!"Unexpected Event"); 
+                       break; 
+               } 
+
+               if (TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE) == 
TS_ERROR) { 
+                   LOG_ERROR("TSHttpTxnReenable"); 
+               } 
 
-               return 0; 
+               return 0; 
            }
 
 
@@ -338,30 +338,30 @@ In the example below, it's not necessary
 created in `txn_handler`:
 
         ::::c
-       static void
-       txn_handler (TSHttpTxn txnp, TSCont contp) {
-               TSCont newCont;
-               ....
-                       newCont = TSContCreate (newCont_handler, NULL);
-               //It's not necessary to create a new mutex for newCont.
+    static void
+    txn_handler (TSHttpTxn txnp, TSCont contp) {
+        TSCont newCont;
+        ....
+            newCont = TSContCreate (newCont_handler, NULL);
+        //It's not necessary to create a new mutex for newCont.
 
-               ...
+        ...
 
-                       TSHttpTxnReenable (txnp, TS_EVENT_HTTP_CONTINUE);
-       }
+            TSHttpTxnReenable (txnp, TS_EVENT_HTTP_CONTINUE);
+    }
 
         static int
         test_plugin (TSCont contp, TSEvent event, void *edata) {
-               TSHttpTxn txnp = (TSHttpTxn) edata;
+            TSHttpTxn txnp = (TSHttpTxn) edata;
 
-               switch (event) {
-                       case TS_EVENT_HTTP_READ_REQUEST_HDR:
-                               txn_handler (txnp, contp);
-                               return 0;
-                       default:
-                               break;
-               }
-               return 0;
+            switch (event) {
+                case TS_EVENT_HTTP_READ_REQUEST_HDR:
+                    txn_handler (txnp, contp);
+                    return 0;
+                default:
+                    break;
+            }
+            return 0;
         }
 
 The mutex functions are listed below:

Modified: 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/new-protocol-plugins/index.en.mdtext
URL: 
http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/new-protocol-plugins/index.en.mdtext?rev=1164283&r1=1164282&r2=1164283&view=diff
==============================================================================
--- 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/new-protocol-plugins/index.en.mdtext
 (original)
+++ 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/new-protocol-plugins/index.en.mdtext
 Thu Sep  1 21:34:29 2011
@@ -31,7 +31,7 @@ The sample protocol enables a client to 
 requests to a specific Traffic Server port (specified in `plugin.config`);
 each request has the following structure:
 
-       server_name file_name
+    server_name file_name
 
 Using the Protocol plugin, Traffic Server can accept these requests, parse
 them, and act as a proxy cache (i.e., request the file from the origin server

Modified: 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/plugin-configurations/index.en.mdtext
URL: 
http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/plugin-configurations/index.en.mdtext?rev=1164283&r1=1164282&r2=1164283&view=diff
==============================================================================
--- 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/plugin-configurations/index.en.mdtext
 (original)
+++ 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/plugin-configurations/index.en.mdtext
 Thu Sep  1 21:34:29 2011
@@ -52,50 +52,50 @@ for all global data updates.
 Here's how the interface works:
 
         ::::c
-       /* Assume that you have previously defined a plugin configuration
-        * data structure named ConfigData, along with its constructor
-        * plugin_config_allocator () and its destructor 
-        * plugin_config_destructor (ConfigData *data)
-        */
-       ConfigData *plugin_config;
-       
-       /* You will need to assign plugin_config a unique identifier of type
-        * unsigned int. It is important to initialize this identifier to zero
-        * (see the documentation of the  function). 
-        */
-       static unsigned int   my_id = 0;
-       
-       /* You will need an TSConfig pointer to access a snapshot of the 
-        * current plugin_config. 
-        */
-       TSConfig config_ptr;
-       
-       /* Initialize plugin_config. */
-       plugin_config = plugin_config_allocator();
-       
-       /* Assign plugin_config an identifier using TSConfigSet. */
-       my_id = TSConfigSet (my_id, plugin_config, plugin_config_destructor);
-       
-       /* Get a snapshot of the current configuration using TSConfigGet. */
-       config_ptr = TSConfigGet (my_id);
-       
-       /* With an TSConfig pointer to the current configuration, you can 
-        * retrieve the configuration's current data using TSConfigDataGet. 
-        */
-       plugin_config = (ConfigData*) TSConfigDataGet (config_ptr);
-       
-       /* Do something with plugin_config here. */
-       
-       /* When you are done with retrieving or modifying the plugin data, you
-        * release the pointers to the data with a call to TSConfigRelease.
-        */
-       TSConfigRelease (my_id, config_ptr);
-       
-       /* Any time you want to modify plugin_config, you must repeat these
-        * steps, starting with 
-        * my_id = TSConfigSet (my_id,plugin_config, plugin_config_destructor);
-        * and continuing up to TSConfigRelease. 
-        */
+    /* Assume that you have previously defined a plugin configuration
+     * data structure named ConfigData, along with its constructor
+     * plugin_config_allocator () and its destructor 
+     * plugin_config_destructor (ConfigData *data)
+     */
+    ConfigData *plugin_config;
+    
+    /* You will need to assign plugin_config a unique identifier of type
+     * unsigned int. It is important to initialize this identifier to zero
+     * (see the documentation of the  function). 
+     */
+    static unsigned int   my_id = 0;
+    
+    /* You will need an TSConfig pointer to access a snapshot of the 
+     * current plugin_config. 
+     */
+    TSConfig config_ptr;
+    
+    /* Initialize plugin_config. */
+    plugin_config = plugin_config_allocator();
+    
+    /* Assign plugin_config an identifier using TSConfigSet. */
+    my_id = TSConfigSet (my_id, plugin_config, plugin_config_destructor);
+    
+    /* Get a snapshot of the current configuration using TSConfigGet. */
+    config_ptr = TSConfigGet (my_id);
+    
+    /* With an TSConfig pointer to the current configuration, you can 
+     * retrieve the configuration's current data using TSConfigDataGet. 
+     */
+    plugin_config = (ConfigData*) TSConfigDataGet (config_ptr);
+    
+    /* Do something with plugin_config here. */
+    
+    /* When you are done with retrieving or modifying the plugin data, you
+     * release the pointers to the data with a call to TSConfigRelease.
+     */
+    TSConfigRelease (my_id, config_ptr);
+    
+    /* Any time you want to modify plugin_config, you must repeat these
+     * steps, starting with 
+     * my_id = TSConfigSet (my_id,plugin_config, plugin_config_destructor);
+     * and continuing up to TSConfigRelease. 
+     */
 
 The configuration functions are:
 

Modified: 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/remap-plugin/example-query-remap.en.mdtext
URL: 
http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/remap-plugin/example-query-remap.en.mdtext?rev=1164283&r1=1164282&r2=1164283&view=diff
==============================================================================
--- 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/remap-plugin/example-query-remap.en.mdtext
 (original)
+++ 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/remap-plugin/example-query-remap.en.mdtext
 Thu Sep  1 21:34:29 2011
@@ -53,31 +53,31 @@ that can be used to pass per-instance da
 will be passed to the `tsremap_remap` function when it is triggered for a 
request.
 
 
-       :::c
-       typedef struct _query_remap_info {
-         char *param_name;
-         size_t param_len;
-         char **hosts;
-         int num_hosts;
-       } query_remap_info;
-               
-               
-       int tsremap_new_instance(int argc,char *argv[],ihandle *ih,char 
*errbuf,int errbuf_size)
-       {
-         int i;
-               
-         if (argc param_name = strdup(argv[2]);
-         qri->param_len = strlen(qri->param_name);
-         qri->num_hosts = argc - 3;
-         qri->hosts = (char**) TSmalloc(qri->num_hosts*sizeof(char*));
-               
-         for (i=0; i num_hosts; ++i) {
-           qri->hosts[i] = strdup(argv[i+3]);
-         }
-               
-         *ih = (ihandle)qri;
-         return 0;
-       }
+    :::c
+    typedef struct _query_remap_info {
+      char *param_name;
+      size_t param_len;
+      char **hosts;
+      int num_hosts;
+    } query_remap_info;
+        
+        
+    int tsremap_new_instance(int argc,char *argv[],ihandle *ih,char 
*errbuf,int errbuf_size)
+    {
+      int i;
+        
+      if (argc param_name = strdup(argv[2]);
+      qri->param_len = strlen(qri->param_name);
+      qri->num_hosts = argc - 3;
+      qri->hosts = (char**) TSmalloc(qri->num_hosts*sizeof(char*));
+        
+      for (i=0; i num_hosts; ++i) {
+        qri->hosts[i] = strdup(argv[i+3]);
+      }
+        
+      *ih = (ihandle)qri;
+      return 0;
+    }
 
 
 Another way remap plugins may want handle more complex configuration is to
@@ -95,51 +95,51 @@ and output members for the remap operati
 and checks the `request_query` for the configured query parameter. If the 
parameter
 is found, the plugin sets a `new_host` to modify the request host:
 
-       :::c
-       int tsremap_remap(ihandle ih, rhandle rh, TSRemapRequestInfo *rri)
-       {
-         int hostidx = -1;
-         query_remap_info *qri = (query_remap_info*)ih;
-               
-         if (!qri) {
-           TSError("NULL ihandle");
-           return 0;
-         }
-               
-         if (rri && rri->request_query && rri->request_query_size > 0) {
-           char *q, *s, *key;
-               
-           //make a copy of the query, as it is read only
-           q = (char*) TSmalloc(rri->request_query_size+1);
-           strncpy(q, rri->request_query, rri->request_query_size);
-           q[rri->request_query_size] = '\0';
-               
-           s = q;
-           //parse query parameters
-           for (key = strsep(&s, "&"); key != NULL; key = strsep(&s, "&")) {
-             char *val = strchr(key, '=');
-             if (val && (size_t)(val-key) == qri->param_len &&
-                 !strncmp(key, qri->param_name, qri->param_len)) {
-               ++val;
-               //the param key matched the configured param_name
-               //hash the param value to pick a host
-               hostidx = hash_fnv32(val, strlen(val)) % 
(u_int32_t)qri->num_hosts;
-               break;
-             }
-           }
-               
-           TSfree(q);
-               
-           if (hostidx >= 0) {
-             rri->new_host_size = strlen(qri->hosts[hostidx]);
-             if (rri->new_host_size new_host, qri->hosts[hostidx], 
rri->new_host_size);
-               return 1; //host has been modified
-             }
-           }
-         }
-               
-         //the request was not modified, TS will use the toURL from the remap 
rule
-         return 0;
-       }
+    :::c
+    int tsremap_remap(ihandle ih, rhandle rh, TSRemapRequestInfo *rri)
+    {
+      int hostidx = -1;
+      query_remap_info *qri = (query_remap_info*)ih;
+        
+      if (!qri) {
+        TSError("NULL ihandle");
+        return 0;
+      }
+          
+      if (rri && rri->request_query && rri->request_query_size > 0) {
+        char *q, *s, *key;
+            
+        //make a copy of the query, as it is read only
+        q = (char*) TSmalloc(rri->request_query_size+1);
+        strncpy(q, rri->request_query, rri->request_query_size);
+        q[rri->request_query_size] = '\0';
+            
+        s = q;
+        //parse query parameters
+        for (key = strsep(&s, "&"); key != NULL; key = strsep(&s, "&")) {
+          char *val = strchr(key, '=');
+          if (val && (size_t)(val-key) == qri->param_len &&
+              !strncmp(key, qri->param_name, qri->param_len)) {
+            ++val;
+            //the param key matched the configured param_name
+            //hash the param value to pick a host
+            hostidx = hash_fnv32(val, strlen(val)) % (u_int32_t)qri->num_hosts;
+            break;
+          }
+        }
+            
+        TSfree(q);
+            
+        if (hostidx >= 0) {
+          rri->new_host_size = strlen(qri->hosts[hostidx]);
+          if (rri->new_host_size new_host, qri->hosts[hostidx], 
rri->new_host_size);
+            return 1; //host has been modified
+          }
+        }
+      }
+        
+      //the request was not modified, TS will use the toURL from the remap rule
+      return 0;
+    }
 
 

Modified: 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/sample-source-code/index.en.mdtext
URL: 
http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/sample-source-code/index.en.mdtext?rev=1164283&r1=1164282&r2=1164283&view=diff
==============================================================================
--- 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/sample-source-code/index.en.mdtext
 (original)
+++ 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/sample-source-code/index.en.mdtext
 Thu Sep  1 21:34:29 2011
@@ -42,268 +42,268 @@ This plugin illustrates:
 * How to use the plugin configuration management interface
 
         :::::c
-       /* blacklist-1.c:  An example program that denies client access         
        
-        *                 to blacklisted sites. This plugin illustrates
-        *                 how to use configuration information from the  
-        *                 blacklist.txt configuration file. 
-        *
-        * Usage:    
-        * (Solaris) : blacklist-1.so 
-        *
-        *
-        */
-       
-       #include <stdio.h>
-       #include <string.h>
-       #include <ts/ts.h>
-       
-       #define MAX_NSITES 500
-       
-       static char* sites[MAX_NSITES];
-       static int nsites;
-       static TSMutex sites_mutex;
-       static TSTextLogObject log;
-       
-       static void
-       handle_dns (TSHttpTxn txnp, TSCont contp)
-       {
-           TSMBuffer bufp;
-           TSMLoc hdr_loc;
-           TSMLoc url_loc;
-           const char *host;
-           int i;
-           int host_length;
-           
-           if (!TSHttpTxnClientReqGet (txnp, &bufp, &hdr_loc)) {
-               TSError ("couldn't retrieve client request header\n");
-               goto done;
-           }
-           
-           url_loc = TSHttpHdrUrlGet (bufp, hdr_loc);
-           if (!url_loc) {
-               TSError ("couldn't retrieve request url\n");
-               TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
-               goto done;
-           }
-           
-           host = TSUrlHostGet (bufp, url_loc, &host_length);
-           if (!host) {
-               TSError ("couldn't retrieve request hostname\n");
-               TSHandleMLocRelease (bufp, hdr_loc, url_loc);
-               TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
-               goto done;
-           }
-       
-           TSMutexLock(sites_mutex);
-       
-           for (i = 0; i < nsites; i++) {
-               if (strncmp (host, sites[i], host_length) == 0) {
-              if (log) {
-             TSTextLogObjectWrite(log, "blacklisting site: %s", sites[i]);
-              } else {
-             printf ("blacklisting site: %s\n", sites[i]);
-              }
-                   TSHttpTxnHookAdd (txnp,
-                       TS_HTTP_SEND_RESPONSE_HDR_HOOK,
-                       contp);
-                   TSHandleMLocRelease (bufp, hdr_loc, url_loc);
-                   TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
-                   TSHttpTxnReenable (txnp, TS_EVENT_HTTP_ERROR);
-              TSMutexUnlock(sites_mutex);
-                   return;
-               }
-           }
-       
-           TSMutexUnlock(sites_mutex);
-           TSHandleMLocRelease (bufp, hdr_loc, url_loc);
-           TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
-       
-        done:
-           TSHttpTxnReenable (txnp, TS_EVENT_HTTP_CONTINUE);
-       }
-       
-       static void
-       handle_response (TSHttpTxn txnp)
-       {
-           TSMBuffer bufp;
-           TSMLoc hdr_loc;
-           TSMLoc url_loc;
-           char *url_str;
-           char *buf;
-           int url_length;
-        
-           if (!TSHttpTxnClientRespGet (txnp, &bufp, &hdr_loc)) {
-               TSError ("couldn't retrieve client response header\n");
-               goto done;
-           }
-           
-           TSHttpHdrStatusSet (bufp, hdr_loc, TS_HTTP_STATUS_FORBIDDEN);
-           TSHttpHdrReasonSet (bufp, hdr_loc,
-               TSHttpHdrReasonLookup (TS_HTTP_STATUS_FORBIDDEN), 
-               strlen (TSHttpHdrReasonLookup (TS_HTTP_STATUS_FORBIDDEN)) );
-           
-           if (!TSHttpTxnClientReqGet (txnp, &bufp, &hdr_loc)) {
-               TSError ("couldn't retrieve client request header\n");
-               TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
-               goto done;
-           }
-           
-           url_loc = TSHttpHdrUrlGet (bufp, hdr_loc);
-           if (!url_loc) {
-               TSError ("couldn't retrieve request url\n");
-               TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
-               goto done;
-           }
-           
-           buf = (char *)TSmalloc (4096);
-           
-           url_str = TSUrlStringGet (bufp, url_loc, &url_length);
-           sprintf (buf, "You are forbidden from accessing \"%s\"\n", url_str);
-           TSfree (url_str);
-           TSHandleMLocRelease (bufp, hdr_loc, url_loc);
-           TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
-         
-           TSHttpTxnErrorBodySet (txnp, buf, strlen (buf), NULL);
-       
-        done:
-           TSHttpTxnReenable (txnp, TS_EVENT_HTTP_CONTINUE);
-       }
-       
-       static void
-       read_blacklist (void)
-       {
-           char blacklist_file[1024];
-           TSFile file;
-       
-           sprintf (blacklist_file, "%s/blacklist.txt", TSPluginDirGet());
-           file = TSfopen(blacklist_file, "r");
-       
-           TSMutexLock (sites_mutex);
-           nsites = 0;
-       
-           if (file != NULL) {
-          char buffer[1024];
-       
-          while (TSfgets (file, buffer, sizeof(buffer)-1) != NULL &&
-                 nsites < MAX_NSITES) {
-              char* eol;
-              if ((eol = strstr(buffer, "\r\n")) != NULL) {
-             /* To handle newlines on Windows */
-             *eol = '\0';
-              } else if ((eol = strchr(buffer, '\n')) != NULL) {
-             *eol = '\0';
-              } else {
-             /* Not a valid line, skip it */
-             continue;
-              }
-              if (sites[nsites] != NULL) {
-             TSfree (sites[nsites]);
-              }
-              sites[nsites] = TSstrdup (buffer);
-              nsites++;
-          }
-       
-          TSfclose (file);
-           } else {
-          TSError ("unable to open %s\n", blacklist_file);
-          TSError ("all sites will be allowed\n", blacklist_file);
-           }
-          
-           TSMutexUnlock (sites_mutex);
-       
-       }
-       
-       static int
-       blacklist_plugin (TSCont contp, TSEvent event, void *edata)
-       {
-           TSHttpTxn txnp = (TSHttpTxn) edata;
-           
-           switch (event) {
-           case TS_EVENT_HTTP_OS_DNS: 
-               handle_dns (txnp, contp);
-               return 0;
-           case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
-               handle_response (txnp);
-               return 0;
-           case TS_EVENT_MGMT_UPDATE:
-          read_blacklist ();
-          return 0;
-           default:
-               break;
-           }
-           return 0;
-       }
-       
-       int
-       check_ts_version() 
-       {
-       
-          const char *ts_version = TSTrafficServerVersionGet();
-          int result = 0;
-       
-          if (ts_version) {
-              int major_ts_version = 0;
-              int minor_ts_version = 0;
-              int patch_ts_version = 0;
-       
-              if (sscanf(ts_version, "%d.%d.%d", &major_ts_version,
-               &minor_ts_version, &patch_ts_version) != 3) {
-             return 0;
-              }
-       
-              /* Need at least TS 2.0 */
-              if (major_ts_version >= 2) {
-             result = 1;
-              } 
-                
-          }
-       
-          return result;
-       }
-       
-       void
-       TSPluginInit (int argc, const char *argv[])
-       {
-           int i;
-           TSCont contp;
-           TSPluginRegistrationInfo info;
-           int error;
-         
-           info.plugin_name = "blacklist-1";
-           info.vendor_name = "DsCompany";
-           info.support_email = "[email protected]";
-       
-           if (!TSPluginRegister (TS_SDK_VERSION_2_0 , &info)) {
-               TSError ("Plugin registration failed.\n"); 
-           }
-       
-           if (!check_ts_version()) {
-          TSError ("Plugin requires Traffic Server 2.0 or later\n");
-          return;
-           }
-       
-           /* create an TSTextLogObject to log blacklisted requests to */
-           log = TSTextLogObjectCreate("blacklist", TS_LOG_MODE_ADD_TIMESTAMP,
-                    NULL, &error);
-           if (!log) {
-          printf("Blacklist plugin: error %d while creating log\n", error);
-           }
-       
-           sites_mutex = TSMutexCreate ();
-       
-           nsites = 0;
-           for (i = 0; i < MAX_NSITES; i++) {
-          sites[i] = NULL;
-           }
-       
-           read_blacklist ();
-       
-           contp = TSContCreate (blacklist_plugin, NULL);
-               
-           TSHttpHookAdd (TS_HTTP_OS_DNS_HOOK, contp);
-       
-           TSMgmtUpdateRegister (contp, "Super Blacklist Plugin", 
"blacklist.cgi");
-       }
+    /* blacklist-1.c:  An example program that denies client access            
     
+     *                 to blacklisted sites. This plugin illustrates
+     *                 how to use configuration information from the  
+     *                 blacklist.txt configuration file. 
+     *
+     * Usage:    
+     * (Solaris) : blacklist-1.so 
+     *
+     *
+     */
+    
+    #include <stdio.h>
+    #include <string.h>
+    #include <ts/ts.h>
+    
+    #define MAX_NSITES 500
+    
+    static char* sites[MAX_NSITES];
+    static int nsites;
+    static TSMutex sites_mutex;
+    static TSTextLogObject log;
+    
+    static void
+    handle_dns (TSHttpTxn txnp, TSCont contp)
+    {
+        TSMBuffer bufp;
+        TSMLoc hdr_loc;
+        TSMLoc url_loc;
+        const char *host;
+        int i;
+        int host_length;
+        
+        if (!TSHttpTxnClientReqGet (txnp, &bufp, &hdr_loc)) {
+            TSError ("couldn't retrieve client request header\n");
+            goto done;
+        }
+        
+        url_loc = TSHttpHdrUrlGet (bufp, hdr_loc);
+        if (!url_loc) {
+            TSError ("couldn't retrieve request url\n");
+            TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
+            goto done;
+        }
+        
+        host = TSUrlHostGet (bufp, url_loc, &host_length);
+        if (!host) {
+            TSError ("couldn't retrieve request hostname\n");
+            TSHandleMLocRelease (bufp, hdr_loc, url_loc);
+            TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
+            goto done;
+        }
+    
+        TSMutexLock(sites_mutex);
+    
+        for (i = 0; i < nsites; i++) {
+            if (strncmp (host, sites[i], host_length) == 0) {
+           if (log) {
+          TSTextLogObjectWrite(log, "blacklisting site: %s", sites[i]);
+           } else {
+          printf ("blacklisting site: %s\n", sites[i]);
+           }
+                TSHttpTxnHookAdd (txnp,
+                    TS_HTTP_SEND_RESPONSE_HDR_HOOK,
+                    contp);
+                TSHandleMLocRelease (bufp, hdr_loc, url_loc);
+                TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
+                TSHttpTxnReenable (txnp, TS_EVENT_HTTP_ERROR);
+           TSMutexUnlock(sites_mutex);
+                return;
+            }
+        }
+    
+        TSMutexUnlock(sites_mutex);
+        TSHandleMLocRelease (bufp, hdr_loc, url_loc);
+        TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
+    
+     done:
+        TSHttpTxnReenable (txnp, TS_EVENT_HTTP_CONTINUE);
+    }
+    
+    static void
+    handle_response (TSHttpTxn txnp)
+    {
+        TSMBuffer bufp;
+        TSMLoc hdr_loc;
+        TSMLoc url_loc;
+        char *url_str;
+        char *buf;
+        int url_length;
+     
+        if (!TSHttpTxnClientRespGet (txnp, &bufp, &hdr_loc)) {
+            TSError ("couldn't retrieve client response header\n");
+            goto done;
+        }
+        
+        TSHttpHdrStatusSet (bufp, hdr_loc, TS_HTTP_STATUS_FORBIDDEN);
+        TSHttpHdrReasonSet (bufp, hdr_loc,
+            TSHttpHdrReasonLookup (TS_HTTP_STATUS_FORBIDDEN), 
+            strlen (TSHttpHdrReasonLookup (TS_HTTP_STATUS_FORBIDDEN)) );
+        
+        if (!TSHttpTxnClientReqGet (txnp, &bufp, &hdr_loc)) {
+            TSError ("couldn't retrieve client request header\n");
+            TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
+            goto done;
+        }
+        
+        url_loc = TSHttpHdrUrlGet (bufp, hdr_loc);
+        if (!url_loc) {
+            TSError ("couldn't retrieve request url\n");
+            TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
+            goto done;
+        }
+        
+        buf = (char *)TSmalloc (4096);
+        
+        url_str = TSUrlStringGet (bufp, url_loc, &url_length);
+        sprintf (buf, "You are forbidden from accessing \"%s\"\n", url_str);
+        TSfree (url_str);
+        TSHandleMLocRelease (bufp, hdr_loc, url_loc);
+        TSHandleMLocRelease (bufp, TS_NULL_MLOC, hdr_loc);
+      
+        TSHttpTxnErrorBodySet (txnp, buf, strlen (buf), NULL);
+    
+     done:
+        TSHttpTxnReenable (txnp, TS_EVENT_HTTP_CONTINUE);
+    }
+    
+    static void
+    read_blacklist (void)
+    {
+        char blacklist_file[1024];
+        TSFile file;
+    
+        sprintf (blacklist_file, "%s/blacklist.txt", TSPluginDirGet());
+        file = TSfopen(blacklist_file, "r");
+    
+        TSMutexLock (sites_mutex);
+        nsites = 0;
+    
+        if (file != NULL) {
+       char buffer[1024];
+    
+       while (TSfgets (file, buffer, sizeof(buffer)-1) != NULL &&
+              nsites < MAX_NSITES) {
+           char* eol;
+           if ((eol = strstr(buffer, "\r\n")) != NULL) {
+          /* To handle newlines on Windows */
+          *eol = '\0';
+           } else if ((eol = strchr(buffer, '\n')) != NULL) {
+          *eol = '\0';
+           } else {
+          /* Not a valid line, skip it */
+          continue;
+           }
+           if (sites[nsites] != NULL) {
+          TSfree (sites[nsites]);
+           }
+           sites[nsites] = TSstrdup (buffer);
+           nsites++;
+       }
+    
+       TSfclose (file);
+        } else {
+       TSError ("unable to open %s\n", blacklist_file);
+       TSError ("all sites will be allowed\n", blacklist_file);
+        }
+       
+        TSMutexUnlock (sites_mutex);
+    
+    }
+    
+    static int
+    blacklist_plugin (TSCont contp, TSEvent event, void *edata)
+    {
+        TSHttpTxn txnp = (TSHttpTxn) edata;
+        
+        switch (event) {
+        case TS_EVENT_HTTP_OS_DNS: 
+            handle_dns (txnp, contp);
+            return 0;
+        case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
+            handle_response (txnp);
+            return 0;
+        case TS_EVENT_MGMT_UPDATE:
+       read_blacklist ();
+       return 0;
+        default:
+            break;
+        }
+        return 0;
+    }
+    
+    int
+    check_ts_version() 
+    {
+    
+       const char *ts_version = TSTrafficServerVersionGet();
+       int result = 0;
+    
+       if (ts_version) {
+           int major_ts_version = 0;
+           int minor_ts_version = 0;
+           int patch_ts_version = 0;
+    
+           if (sscanf(ts_version, "%d.%d.%d", &major_ts_version,
+            &minor_ts_version, &patch_ts_version) != 3) {
+          return 0;
+           }
+    
+           /* Need at least TS 2.0 */
+           if (major_ts_version >= 2) {
+          result = 1;
+           } 
+             
+       }
+    
+       return result;
+    }
+    
+    void
+    TSPluginInit (int argc, const char *argv[])
+    {
+        int i;
+        TSCont contp;
+        TSPluginRegistrationInfo info;
+        int error;
+      
+        info.plugin_name = "blacklist-1";
+        info.vendor_name = "DsCompany";
+        info.support_email = "[email protected]";
+    
+        if (!TSPluginRegister (TS_SDK_VERSION_2_0 , &info)) {
+            TSError ("Plugin registration failed.\n"); 
+        }
+    
+        if (!check_ts_version()) {
+       TSError ("Plugin requires Traffic Server 2.0 or later\n");
+       return;
+        }
+    
+        /* create an TSTextLogObject to log blacklisted requests to */
+        log = TSTextLogObjectCreate("blacklist", TS_LOG_MODE_ADD_TIMESTAMP,
+                 NULL, &error);
+        if (!log) {
+       printf("Blacklist plugin: error %d while creating log\n", error);
+        }
+    
+        sites_mutex = TSMutexCreate ();
+    
+        nsites = 0;
+        for (i = 0; i < MAX_NSITES; i++) {
+       sites[i] = NULL;
+        }
+    
+        read_blacklist ();
+    
+        contp = TSContCreate (blacklist_plugin, NULL);
+            
+        TSHttpHookAdd (TS_HTTP_OS_DNS_HOOK, contp);
+    
+        TSMgmtUpdateRegister (contp, "Super Blacklist Plugin", 
"blacklist.cgi");
+    }
 
 
 

Modified: 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/troubleshooting-tips/unable-to-debug-tags.en.mdtext
URL: 
http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/troubleshooting-tips/unable-to-debug-tags.en.mdtext?rev=1164283&r1=1164282&r2=1164283&view=diff
==============================================================================
--- 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/troubleshooting-tips/unable-to-debug-tags.en.mdtext
 (original)
+++ 
trafficserver/site/branches/ats-cms/content/docs/trunk/sdk/troubleshooting-tips/unable-to-debug-tags.en.mdtext
 Thu Sep  1 21:34:29 2011
@@ -31,7 +31,7 @@ Run Traffic Server with the `-Ttag` opti
 
        :::text
        traffic_server -T"my-plugin"
-       
+    
 
 Set the following variables in `records.config` (in the Traffic Server 
`config` 
 directory):


Reply via email to