httpclk.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:4k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. /*
  36.  * This is generated code, do not modify. Look in httpclk.pm to
  37.  * make modifications
  38.  */
  39. #ifndef PMC_PREDEFINED_TYPES
  40. #define PMC_PREDEFINED_TYPES
  41. typedef char* pmc_string;
  42. struct buffer {
  43.  INT16 len;
  44.  INT8* data;
  45. };
  46. #endif/*PMC_PREDEFINED_TYPES*/
  47. #ifndef _HTTPCLK_H_
  48. #define _HTTPCLK_H_
  49. enum HTTPOpcodes
  50. {
  51.     HTTP_RV_RESPONSE = 'r',
  52.     HTTP_RESPONSE = 'H',
  53.     HTTP_OPTION_RESPONSE = 'O',
  54.     HTTP_OPT_RESPONSE_END = 'e',
  55.     HTTP_POSTDONE = 'h', /*pna_http_post_done*/
  56.     HTTP_DONE = 'D'  /*pna_http_done*/
  57. };
  58. enum HTTPOptionOpcodes
  59. {
  60.     HTTP_OPTION_SHORT_PADDING = 1
  61. };
  62. class CloakedHTTPResponse
  63. {
  64. public:
  65.     UINT8* pack(UINT8* buf, UINT32 &len);
  66.     UINT8* unpack(UINT8* buf, UINT32 len);
  67.     const UINT32 static_size() {return 4;}
  68.     UINT8 opcode;
  69.     UINT8 length;
  70.     UINT8 status;
  71.     UINT8 padding;
  72. };
  73. inline UINT8*
  74. CloakedHTTPResponse::pack(UINT8* buf, UINT32 &len)
  75. {
  76.     UINT8* off = buf;
  77.     opcode = HTTP_RESPONSE;
  78.     *off++ = opcode;
  79.     length = 2;
  80.     *off++ = length;
  81.     *off++ = status;
  82.     padding = 0;
  83.     *off++ = padding;
  84.     len = off-buf;
  85.     return off;
  86. }
  87. inline UINT8*
  88. CloakedHTTPResponse::unpack(UINT8* buf, UINT32 len)
  89. {
  90.     if (len <= 0)
  91. return 0;
  92.     UINT8* off = buf;
  93.     opcode = *off++;
  94.     length = *off++;
  95.     status = *off++;
  96.     padding = *off++;
  97.     return off;
  98. }
  99. class CloakedHTTPRVResponse
  100. {
  101. public:
  102.     UINT8* pack(UINT8* buf, UINT32 &len);
  103.     UINT8* unpack(UINT8* buf, UINT32 len);
  104.     const UINT32 static_size() {return 4;}
  105.     UINT8 opcode;
  106.     UINT16 length;
  107.     UINT8 status;
  108. };
  109. inline UINT8*
  110. CloakedHTTPRVResponse::pack(UINT8* buf, UINT32 &len)
  111. {
  112.     UINT8* off = buf;
  113.     opcode = HTTP_RV_RESPONSE;
  114.     *off++ = opcode;
  115.     length = 1;
  116.     {*off++ = (UINT8) (length>>8); *off++ = (UINT8) (length);}
  117.     *off++ = status;
  118.     len = off-buf;
  119.     return off;
  120. }
  121. inline UINT8*
  122. CloakedHTTPRVResponse::unpack(UINT8* buf, UINT32 len)
  123. {
  124.     if (len <= 0)
  125. return 0;
  126.     UINT8* off = buf;
  127.     opcode = *off++;
  128.     {length = *off++<<8; length |= *off++;}
  129.     status = *off++;
  130.     return off;
  131. }
  132. #endif /* _HTTPCLK_H_ */