• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

remap.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef __TS_REMAP_H__
00025 #define __TS_REMAP_H__
00026 
00027 #ifndef tsapi
00028 #define tsapi
00029 #endif
00030 
00031 #ifdef __cplusplus
00032 extern "C"
00033 {
00034 #endif                          /* __cplusplus */
00035 
00036 #define TSREMAP_VMAJOR   3      /* major version number */
00037 #define TSREMAP_VMINOR   0      /* minor version number */
00038 #define TSREMAP_VERSION ((TSREMAP_VMAJOR << 16)|TSREMAP_VMINOR)
00039 
00040   typedef struct _tsremap_api_info
00041   {
00042     unsigned long size;         /* in: sizeof(struct _tsremap_api_info) */
00043     unsigned long tsremap_version;      /* in: TS supported version ((major << 16) | minor) */
00044   } TSRemapInterface;
00045 
00046 
00047   typedef struct _tm_remap_request_info
00048   {
00049     /* Important: You should *not* release these buf pointers or TSMLocs from your plugin! */
00050 
00051     /* these URL mloc's are read only, use normal ts/ts.h APIs for accesing  */
00052     TSMLoc mapFromUrl;
00053     TSMLoc mapToUrl;
00054 
00055     /* the request URL mloc and buffer pointers are read-write. You can read and modify the
00056      requestUrl using normal ts/ts.h APIs, which is how you change the destination URL. */
00057     TSMLoc requestUrl;
00058 
00059     /* requestBufp and requestHdrp are the equivalent of calling TSHttpTxnClientReqGet(). */
00060     TSMBuffer requestBufp;
00061     TSMLoc requestHdrp;
00062 
00063     /* 0 - don't redirect, 1 - use the (new)request URL as a redirect */
00064     int redirect;
00065   } TSRemapRequestInfo;
00066 
00067 
00068   /* This is the type returned by the TSRemapDoRemap() callback */
00069   typedef enum
00070   {
00071     TSREMAP_NO_REMAP = 0,       /* No remaping was done, continue with next in chain */
00072     TSREMAP_DID_REMAP = 1,      /* Remapping was done, continue with next in chain */
00073     TSREMAP_NO_REMAP_STOP = 2,  /* No remapping was done, and stop plugin chain evaluation */
00074     TSREMAP_DID_REMAP_STOP = 3, /* Remapping was done, but stop plugin chain evaluation */
00075 
00076     /* In the future, the following error codes can also be used:
00077        -400 to -499
00078        -500 to -599
00079        ....
00080        This would allow a plugin to generate an error page. Right now,
00081        setting the return code to any negative number is equivalent to TSREMAP_NO_REMAP */
00082     TSREMAP_ERROR = -1          /* Some error, that should generate an error page */
00083   } TSRemapStatus;
00084 
00085 
00086 
00087   /* ----------------------------------------------------------------------------------
00088      These are the entry points a plugin can implement. Note that TSRemapInit() and
00089      TSRemapDoRemap() are both required.
00090      ----------------------------------------------------------------------------------
00091   */
00092 
00093   /* Plugin initialization - called first.
00094      Mandatory interface function.
00095      Return: TS_SUCCESS
00096              TS_ERROR - error, errbuf can include error message from plugin
00097   */
00098   tsapi TSReturnCode TSRemapInit(TSRemapInterface* api_info, char* errbuf, int errbuf_size);
00099 
00100 
00101   /* Remap new request
00102      Mandatory interface function.
00103      Remap API plugin can/should use SDK API function calls inside this function!
00104      return: TSREMAP_NO_REMAP - No remaping was done, continue with next in chain
00105              TSREMAP_DID_REMAP - Remapping was done, continue with next in chain
00106              TSREMAP_NO_REMAP_STOP - No remapping was done, and stop plugin chain evaluation
00107              TSREMAP_DID_REMAP_STOP -  Remapping was done, but stop plugin chain evaluation
00108   */
00109   tsapi TSRemapStatus TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo* rri);
00110 
00111 
00112   /* Plugin shutdown, called when plugin is unloaded.
00113      Optional function. */
00114   tsapi void TSRemapDone(void);
00115 
00116 
00117   /* Plugin new instance. Create new plugin processing entry for unique remap record.
00118      First two arguments in argv vector are - fromURL and toURL from remap record.
00119      Please keep in mind that fromURL and toURL will be converted to canonical view.
00120      Return: TS_SUCESS
00121              TS_ERROR - instance creation error
00122   */
00123   tsapi TSReturnCode TSRemapNewInstance(int argc, char* argv[], void** ih, char* errbuf, int errbuf_size);
00124   tsapi void TSRemapDeleteInstance(void*);
00125 
00126 
00127   /* Check response code from Origin Server
00128      os_response_type -> TSServerState
00129      Remap API plugin can use InkAPI function calls inside TSRemapDoRemap()
00130      Return: none
00131   */
00132   tsapi void TSRemapOSResponse(void* ih, TSHttpTxn rh, int os_response_type);
00133 
00134 #ifdef __cplusplus
00135 }
00136 #endif                          /* __cplusplus */
00137 #endif                          /* #ifndef __TS_REMAP_H__ */

Generated by  doxygen 1.7.1