libUPnP
1.6.17
|
00001 #ifndef UPNP_H 00002 #define UPNP_H 00003 00004 /******************************************************************************* 00005 * 00006 * Copyright (c) 2000-2003 Intel Corporation 00007 * All rights reserved. 00008 * Copyright (C) 2011-2012 France Telecom All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * * Neither name of Intel Corporation nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 00026 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00027 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00028 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00030 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 ******************************************************************************/ 00035 00044 #include "ixml.h" 00045 #include "upnpconfig.h" 00046 #include "UpnpGlobal.h" 00047 #include "UpnpInet.h" 00048 #include "UpnpString.h" 00049 00050 /* 00051 * \todo Document the exact reason of these include files and solve this 00052 * include mess in an include file like UpnpTime.h 00053 */ 00054 #ifdef WIN32 00055 #include <time.h> 00056 #ifdef UPNP_USE_MSVCPP 00057 #include <sys/types.h> /* needed for off_t */ 00058 #endif 00059 #elif (defined(BSD) && BSD >= 199306) 00060 #include <time.h> 00061 #else 00062 /* Other systems ??? */ 00063 #endif 00064 00065 #define LINE_SIZE (size_t)180 00066 #define NAME_SIZE (size_t)256 00067 #define MNFT_NAME_SIZE 64 00068 #define MODL_NAME_SIZE 32 00069 #define SERL_NUMR_SIZE 64 00070 #define MODL_DESC_SIZE 64 00071 #define UPNP_INFINITE -1 00072 #define UPNP_USING_CHUNKED -3 00073 #define UPNP_UNTIL_CLOSE -4 00074 00094 #define UPNP_E_SUCCESS 0 00095 00099 #define UPNP_E_INVALID_HANDLE -100 00100 00107 #define UPNP_E_INVALID_PARAM -101 00108 00114 #define UPNP_E_OUTOF_HANDLE -102 00115 00116 #define UPNP_E_OUTOF_CONTEXT -103 00117 00123 #define UPNP_E_OUTOF_MEMORY -104 00124 00131 #define UPNP_E_INIT -105 00132 00133 #define UPNP_E_BUFFER_TOO_SMALL -106 00134 00140 #define UPNP_E_INVALID_DESC -107 00141 00149 #define UPNP_E_INVALID_URL -108 00150 00151 #define UPNP_E_INVALID_SID -109 00152 00153 #define UPNP_E_INVALID_DEVICE -110 00154 00161 #define UPNP_E_INVALID_SERVICE -111 00162 00169 #define UPNP_E_BAD_RESPONSE -113 00170 00171 #define UPNP_E_BAD_REQUEST -114 00172 00179 #define UPNP_E_INVALID_ACTION -115 00180 00186 #define UPNP_E_FINISH -116 00187 00193 #define UPNP_E_INIT_FAILED -117 00194 00200 #define UPNP_E_URL_TOO_BIG -118 00201 00211 #define UPNP_E_BAD_HTTPMSG -119 00212 00219 #define UPNP_E_ALREADY_REGISTERED -120 00220 00225 #define UPNP_E_INVALID_INTERFACE -121 00226 00234 #define UPNP_E_NETWORK_ERROR -200 00235 00244 #define UPNP_E_SOCKET_WRITE -201 00245 00254 #define UPNP_E_SOCKET_READ -202 00255 00264 #define UPNP_E_SOCKET_BIND -203 00265 00274 #define UPNP_E_SOCKET_CONNECT -204 00275 00284 #define UPNP_E_OUTOF_SOCKET -205 00285 00292 #define UPNP_E_LISTEN -206 00293 00300 #define UPNP_E_TIMEDOUT -207 00301 00308 #define UPNP_E_SOCKET_ERROR -208 00309 00310 #define UPNP_E_FILE_WRITE_ERROR -209 00311 00316 #define UPNP_E_CANCELED -210 00317 00318 #define UPNP_E_EVENT_PROTOCOL -300 00319 00323 #define UPNP_E_SUBSCRIBE_UNACCEPTED -301 00324 00328 #define UPNP_E_UNSUBSCRIBE_UNACCEPTED -302 00329 00333 #define UPNP_E_NOTIFY_UNACCEPTED -303 00334 00341 #define UPNP_E_INVALID_ARGUMENT -501 00342 00347 #define UPNP_E_FILE_NOT_FOUND -502 00348 00352 #define UPNP_E_FILE_READ_ERROR -503 00353 00358 #define UPNP_E_EXT_NOT_XML -504 00359 00360 #define UPNP_E_NO_WEB_SERVER -505 00361 #define UPNP_E_OUTOF_BOUNDS -506 00362 00367 #define UPNP_E_NOT_FOUND -507 00368 00373 #define UPNP_E_INTERNAL_ERROR -911 00374 00375 /* SOAP-related error codes */ 00376 #define UPNP_SOAP_E_INVALID_ACTION 401 00377 #define UPNP_SOAP_E_INVALID_ARGS 402 00378 #define UPNP_SOAP_E_OUT_OF_SYNC 403 00379 #define UPNP_SOAP_E_INVALID_VAR 404 00380 #define UPNP_SOAP_E_ACTION_FAILED 501 00381 00382 /* @} ErrorCodes */ 00383 00384 #if UPNP_VERSION >= 10800 00385 /* 00386 * Opaque data structures. The following includes are data structures that 00387 * must be externally visible. Since version 1.8.0, only an opaque typedef 00388 * is visible from the outside world. Any operation on these data types 00389 * must be done using the appropriate interface functions. 00390 * 00391 * This policy has the great advantage that it is now possible to change 00392 * the internal implementation of these data structures without breaking 00393 * the API. 00394 */ 00395 #include "ActionComplete.h" 00396 #include "ActionRequest.h" 00397 #include "Discovery.h" 00398 #include "Event.h" 00399 #include "EventSubscribe.h" 00400 #include "FileInfo.h" 00401 #include "StateVarComplete.h" 00402 #include "StateVarRequest.h" 00403 #include "SubscriptionRequest.h" 00404 #endif /* UPNP_VERSION >= 10800 */ 00405 00412 enum UpnpOpenFileMode 00413 { 00414 UPNP_READ, 00415 UPNP_WRITE 00416 }; 00417 00425 typedef int UpnpClient_Handle; 00426 00435 typedef int UpnpDevice_Handle; 00436 00444 enum Upnp_EventType_e { 00445 /* 00446 * Control callbacks 00447 */ 00448 00453 UPNP_CONTROL_ACTION_REQUEST, 00454 00458 UPNP_CONTROL_ACTION_COMPLETE, 00459 00464 UPNP_CONTROL_GET_VAR_REQUEST, 00465 00469 UPNP_CONTROL_GET_VAR_COMPLETE, 00470 00471 /* 00472 * Discovery callbacks 00473 */ 00474 00479 UPNP_DISCOVERY_ADVERTISEMENT_ALIVE, 00480 00485 UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE, 00486 00491 UPNP_DISCOVERY_SEARCH_RESULT, 00492 00496 UPNP_DISCOVERY_SEARCH_TIMEOUT, 00497 00498 /* 00499 * Eventing callbacks 00500 */ 00501 00511 UPNP_EVENT_SUBSCRIPTION_REQUEST, 00512 00516 UPNP_EVENT_RECEIVED, 00517 00521 UPNP_EVENT_RENEWAL_COMPLETE, 00522 00526 UPNP_EVENT_SUBSCRIBE_COMPLETE, 00527 00531 UPNP_EVENT_UNSUBSCRIBE_COMPLETE, 00532 00537 UPNP_EVENT_AUTORENEWAL_FAILED, 00538 00543 UPNP_EVENT_SUBSCRIPTION_EXPIRED 00544 }; 00545 00546 typedef enum Upnp_EventType_e Upnp_EventType; 00547 00555 typedef char Upnp_SID[44]; 00556 00565 enum Upnp_SType_e { 00567 UPNP_S_ALL, 00568 00570 UPNP_S_ROOT, 00571 00573 UPNP_S_DEVICE, 00574 00577 UPNP_S_SERVICE 00578 }; 00579 00580 typedef enum Upnp_SType_e Upnp_SType; 00581 00588 enum Upnp_DescType_e { 00590 UPNPREG_URL_DESC, 00591 00594 UPNPREG_FILENAME_DESC, 00595 00598 UPNPREG_BUF_DESC 00599 }; 00600 00601 typedef enum Upnp_DescType_e Upnp_DescType; 00602 00603 #if UPNP_VERSION < 10800 00604 00606 struct Upnp_Action_Request 00607 { 00609 int ErrCode; 00610 00612 int Socket; 00613 00615 char ErrStr[LINE_SIZE]; 00616 00618 char ActionName[NAME_SIZE]; 00619 00621 char DevUDN[NAME_SIZE]; 00622 00624 char ServiceID[NAME_SIZE]; 00625 00627 IXML_Document *ActionRequest; 00628 00630 IXML_Document *ActionResult; 00631 00633 struct sockaddr_storage CtrlPtIPAddr; 00634 00637 IXML_Document *SoapHeader; 00638 }; 00639 00640 struct Upnp_Action_Complete 00641 { 00643 int ErrCode; 00644 00646 UpnpString *CtrlUrl; 00647 00649 IXML_Document *ActionRequest; 00650 00652 IXML_Document *ActionResult; 00653 00654 }; 00655 00659 struct Upnp_State_Var_Request 00660 { 00662 int ErrCode; 00663 00665 int Socket; 00666 00668 char ErrStr[LINE_SIZE]; 00669 00671 char DevUDN[NAME_SIZE]; 00672 00674 char ServiceID[NAME_SIZE]; 00675 00677 char StateVarName[NAME_SIZE]; 00678 00680 struct sockaddr_storage CtrlPtIPAddr; 00681 00684 DOMString CurrentVal; 00685 }; 00686 00690 struct Upnp_State_Var_Complete 00691 { 00693 int ErrCode; 00694 00696 UpnpString *CtrlUrl; 00697 00699 char StateVarName[NAME_SIZE]; 00700 00702 DOMString CurrentVal; 00703 }; 00704 00707 struct Upnp_Event 00708 { 00710 Upnp_SID Sid; 00711 00713 int EventKey; 00714 00716 IXML_Document *ChangedVariables; 00717 00718 }; 00719 00720 /* 00721 * This typedef is required by Doc++ to parse the last entry of the 00722 * Upnp_Discovery structure correctly. 00723 */ 00724 00725 00727 struct Upnp_Discovery 00728 { 00730 int ErrCode; 00731 00733 int Expires; 00734 00736 char DeviceId[LINE_SIZE]; 00737 00739 char DeviceType[LINE_SIZE]; 00740 00742 char ServiceType[LINE_SIZE]; 00743 00745 char ServiceVer[LINE_SIZE]; 00746 00748 char Location[LINE_SIZE]; 00749 00751 char Os[LINE_SIZE]; 00752 00754 char Date[LINE_SIZE]; 00755 00757 char Ext[LINE_SIZE]; 00758 00760 struct sockaddr_storage DestAddr; 00761 }; 00762 00766 struct Upnp_Event_Subscribe { 00767 00774 Upnp_SID Sid; 00775 00777 int ErrCode; 00778 00780 UpnpString *PublisherUrl; 00781 00783 int TimeOut; 00784 00785 }; 00786 00790 struct Upnp_Subscription_Request 00791 { 00793 char *ServiceId; 00794 00796 char *UDN; 00797 00799 Upnp_SID Sid; 00800 00801 }; 00802 00803 struct File_Info 00804 { 00808 off_t file_length; 00809 00812 time_t last_modified; 00813 00816 int is_directory; 00817 00820 int is_readable; 00821 00825 DOMString content_type; 00826 }; 00827 #endif /* UPNP_VERSION < 10800 */ 00828 00854 typedef int (*Upnp_FunPtr)( 00856 Upnp_EventType EventType, 00858 void *Event, 00860 void *Cookie); 00861 00862 /* @} Constants and Types */ 00863 00864 #ifdef __cplusplus 00865 extern "C" { 00866 #endif /* __cplusplus */ 00867 00907 EXPORT_SPEC int UpnpInit( 00910 const char *HostIP, 00913 unsigned short DestPort); 00914 00947 #ifdef UPNP_ENABLE_IPV6 00948 EXPORT_SPEC int UpnpInit2( 00952 const char *IfName, 00955 unsigned short DestPort); 00956 #endif 00957 00977 EXPORT_SPEC int UpnpFinish(void); 00978 00990 EXPORT_SPEC unsigned short UpnpGetServerPort(void); 00991 01003 #ifdef UPNP_ENABLE_IPV6 01004 EXPORT_SPEC unsigned short UpnpGetServerPort6(void); 01005 #endif 01006 01017 EXPORT_SPEC char *UpnpGetServerIpAddress(void); 01018 01030 #ifdef UPNP_ENABLE_IPV6 01031 EXPORT_SPEC char *UpnpGetServerIp6Address(void); 01032 01033 EXPORT_SPEC char *UpnpGetServerUlaGuaIp6Address(void); 01034 #endif 01035 01071 EXPORT_SPEC int UpnpRegisterRootDevice( 01074 const char *DescUrl, 01076 Upnp_FunPtr Callback, 01078 const void *Cookie, 01080 UpnpDevice_Handle *Hnd); 01081 01150 EXPORT_SPEC int UpnpRegisterRootDevice2( 01152 Upnp_DescType descriptionType, 01155 const char* description, 01158 size_t bufferLen, 01161 int config_baseURL, 01163 Upnp_FunPtr Fun, 01166 const void* Cookie, 01168 UpnpDevice_Handle* Hnd); 01169 01205 EXPORT_SPEC int UpnpRegisterRootDevice3( 01208 const char *DescUrl, 01210 Upnp_FunPtr Callback, 01212 const void *Cookie, 01214 UpnpDevice_Handle *Hnd, 01217 int AddressFamily); 01218 01255 EXPORT_SPEC int UpnpRegisterRootDevice4( 01258 const char *DescUrl, 01260 Upnp_FunPtr Callback, 01262 const void *Cookie, 01264 UpnpDevice_Handle *Hnd, 01267 int AddressFamily, 01270 const char *LowerDescUrl); 01271 01288 EXPORT_SPEC int UpnpUnRegisterRootDevice( 01290 UpnpDevice_Handle Hnd); 01291 01311 EXPORT_SPEC int UpnpUnRegisterRootDeviceLowPower( 01313 UpnpDevice_Handle Hnd, 01315 int PowerState, 01317 int SleepPeriod, 01319 int RegistrationState); 01320 01339 EXPORT_SPEC int UpnpRegisterClient( 01341 Upnp_FunPtr Callback, 01343 const void *Cookie, 01345 UpnpClient_Handle *Hnd); 01346 01363 EXPORT_SPEC int UpnpUnRegisterClient( 01365 UpnpClient_Handle Hnd); 01366 01373 EXPORT_SPEC int UpnpSetContentLength( 01376 UpnpClient_Handle Hnd, 01378 size_t contentLength); 01379 01396 EXPORT_SPEC int UpnpSetMaxContentLength( 01399 size_t contentLength); 01400 01401 /* @} Initialization and Registration */ 01402 01403 /****************************************************************************** 01404 ****************************************************************************** 01405 * * 01406 * D I S C O V E R Y * 01407 * * 01408 ****************************************************************************** 01409 ******************************************************************************/ 01410 01440 EXPORT_SPEC int UpnpSearchAsync( 01442 UpnpClient_Handle Hnd, 01447 int Mx, 01450 const char *TTarget_constarget_const, 01452 const void *Cookie_const); 01453 01469 EXPORT_SPEC int UpnpSendAdvertisement( 01471 UpnpDevice_Handle Hnd, 01473 int Exp); 01474 01493 EXPORT_SPEC int UpnpSendAdvertisementLowPower( 01495 UpnpDevice_Handle Hnd, 01497 int Exp, 01499 int PowerState, 01501 int SleepPeriod, 01503 int RegistrationState); 01504 01505 /* @} Discovery */ 01506 01507 /****************************************************************************** 01508 ****************************************************************************** 01509 * * 01510 * C O N T R O L * 01511 * * 01512 ****************************************************************************** 01513 ******************************************************************************/ 01514 01546 EXPORT_SPEC int UpnpGetServiceVarStatus( 01548 UpnpClient_Handle Hnd, 01550 const char *ActionURL, 01552 const char *VarName, 01556 DOMString *StVarVal); 01557 01575 EXPORT_SPEC int UpnpGetServiceVarStatusAsync( 01577 UpnpClient_Handle Hnd, 01579 const char *ActionURL, 01581 const char *VarName, 01584 Upnp_FunPtr Fun, 01586 const void *Cookie); 01587 01611 EXPORT_SPEC int UpnpSendAction( 01613 UpnpClient_Handle Hnd, 01615 const char *ActionURL, 01617 const char *ServiceType, 01619 const char *DevUDN, 01621 IXML_Document *Action, 01624 IXML_Document **RespNode); 01625 01649 EXPORT_SPEC int UpnpSendActionEx( 01651 UpnpClient_Handle Hnd, 01653 const char *ActionURL, 01655 const char *ServiceType, 01657 const char *DevUDN, 01660 IXML_Document *Header, 01662 IXML_Document *Action, 01665 IXML_Document **RespNode); 01666 01688 EXPORT_SPEC int UpnpSendActionAsync( 01690 UpnpClient_Handle Hnd, 01692 const char *ActionURL, 01694 const char *ServiceType, 01696 const char *DevUDN, 01698 IXML_Document *Action, 01701 Upnp_FunPtr Fun, 01704 const void *Cookie); 01705 01727 EXPORT_SPEC int UpnpSendActionExAsync( 01729 UpnpClient_Handle Hnd, 01731 const char *ActionURL, 01733 const char *ServiceType, 01735 const char *DevUDN, 01738 IXML_Document *Header, 01740 IXML_Document *Action, 01743 Upnp_FunPtr Fun, 01746 const void *Cookie); 01747 01750 /****************************************************************************** 01751 ****************************************************************************** 01752 * * 01753 * E V E N T I N G * 01754 * * 01755 ****************************************************************************** 01756 ******************************************************************************/ 01757 01789 EXPORT_SPEC int UpnpAcceptSubscription( 01791 UpnpDevice_Handle Hnd, 01793 const char *DevID, 01795 const char *ServID, 01797 const char **VarName, 01799 const char **NewVal, 01801 int cVariables, 01803 const Upnp_SID SubsId); 01804 01827 EXPORT_SPEC int UpnpAcceptSubscriptionExt( 01829 UpnpDevice_Handle Hnd, 01831 const char *DevID, 01833 const char *ServID, 01837 IXML_Document *PropSet, 01839 Upnp_SID SubsId); 01840 01862 EXPORT_SPEC int UpnpNotify( 01864 UpnpDevice_Handle, 01866 const char *DevID, 01868 const char *ServID, 01870 const char **VarName, 01872 const char **NewVal, 01874 int cVariables); 01875 01897 EXPORT_SPEC int UpnpNotifyExt( 01899 UpnpDevice_Handle, 01901 const char *DevID, 01903 const char *ServID, 01907 IXML_Document *PropSet); 01908 01937 EXPORT_SPEC int UpnpRenewSubscription( 01939 UpnpClient_Handle Hnd, 01942 int *TimeOut, 01944 const Upnp_SID SubsId); 01945 01993 EXPORT_SPEC int UpnpRenewSubscriptionAsync( 01995 UpnpClient_Handle Hnd, 01998 int TimeOut, 02000 Upnp_SID SubsId, 02003 Upnp_FunPtr Fun, 02005 const void *Cookie); 02006 02020 EXPORT_SPEC int UpnpSetMaxSubscriptions( 02023 UpnpDevice_Handle Hnd, 02025 int MaxSubscriptions); 02026 02041 EXPORT_SPEC int UpnpSetMaxSubscriptionTimeOut( 02044 UpnpDevice_Handle Hnd, 02046 int MaxSubscriptionTimeOut); 02047 02077 EXPORT_SPEC int UpnpSubscribe( 02079 UpnpClient_Handle Hnd, 02081 const char *PublisherUrl, 02085 int *TimeOut, 02087 Upnp_SID SubsId); 02088 02137 EXPORT_SPEC int UpnpSubscribeAsync( 02139 UpnpClient_Handle Hnd, 02141 const char *PublisherUrl, 02144 int TimeOut, 02146 Upnp_FunPtr Fun, 02148 const void *Cookie); 02149 02179 EXPORT_SPEC int UpnpUnSubscribe( 02181 UpnpClient_Handle Hnd, 02183 const Upnp_SID SubsId); 02184 02231 EXPORT_SPEC int UpnpUnSubscribeAsync( 02233 UpnpClient_Handle Hnd, 02235 Upnp_SID SubsId, 02238 Upnp_FunPtr Fun, 02240 const void *Cookie); 02241 02245 /****************************************************************************** 02246 ****************************************************************************** 02247 * * 02248 * C L I E N T - A P I * 02249 * * 02250 ****************************************************************************** 02251 ******************************************************************************/ 02252 02285 EXPORT_SPEC int UpnpDownloadUrlItem( 02287 const char *url, 02289 char **outBuf, 02292 char *contentType); 02293 02322 EXPORT_SPEC int UpnpOpenHttpGet( 02324 const char *url, 02326 void **handle, 02328 char **contentType, 02330 int *contentLength, 02332 int *httpStatus, 02336 int timeout); 02337 02366 EXPORT_SPEC int UpnpOpenHttpGetProxy( 02368 const char *url, 02370 const char *proxy_str, 02372 void **handle, 02374 char **contentType, 02376 int *contentLength, 02378 int *httpStatus, 02382 int timeout); 02383 02414 EXPORT_SPEC int UpnpOpenHttpGetEx( 02416 const char *url, 02418 void **handle, 02420 char **contentType, 02422 int *contentLength, 02424 int *httpStatus, 02426 int lowRange, 02428 int highRange, 02432 int timeout); 02433 02451 EXPORT_SPEC int UpnpReadHttpGet( 02453 void *handle, 02455 char *buf, 02457 size_t *size, 02461 int timeout); 02462 02471 EXPORT_SPEC int UpnpHttpGetProgress( 02473 void *handle, 02475 size_t *length, 02477 size_t *total); 02478 02486 EXPORT_SPEC int UpnpCancelHttpGet( 02489 void *handle); 02490 02499 EXPORT_SPEC int UpnpCloseHttpGet( 02502 void *handle); 02503 02529 EXPORT_SPEC int UpnpOpenHttpPost( 02531 const char *url, 02534 void **handle, 02536 const char *contentType, 02538 int contentLength, 02541 int timeout); 02542 02556 EXPORT_SPEC int UpnpWriteHttpPost( 02559 void *handle, 02561 char *buf, 02563 size_t *size, 02566 int timeout); 02567 02581 EXPORT_SPEC int UpnpCloseHttpPost( 02584 void *handle, 02586 int *httpStatus, 02589 int timeout); 02590 02618 EXPORT_SPEC int UpnpDownloadXmlDoc( 02620 const char *url, 02622 IXML_Document **xmlDoc); 02623 02626 /****************************************************************************** 02627 ****************************************************************************** 02628 * * 02629 * W E B S E R V E R A P I * 02630 * * 02631 ****************************************************************************** 02632 ******************************************************************************/ 02633 02656 EXPORT_SPEC int UpnpSetWebServerRootDir( 02658 const char *rootDir); 02659 02663 typedef void *UpnpWebFileHandle; 02664 02668 typedef int (*VDCallback_GetInfo)( 02670 const char *filename, 02672 #if UPNP_VERSION < 10800 02673 struct File_Info *info 02674 #else 02675 UpnpFileInfo *info 02676 #endif /* UPNP_VERSION < 10800 */ 02677 ); 02678 02687 EXPORT_SPEC int UpnpVirtualDir_set_GetInfoCallback(VDCallback_GetInfo callback); 02688 02692 typedef UpnpWebFileHandle (*VDCallback_Open)( 02694 const char *filename, 02697 enum UpnpOpenFileMode Mode); 02698 02707 EXPORT_SPEC int UpnpVirtualDir_set_OpenCallback(VDCallback_Open callback); 02708 02712 typedef int (*VDCallback_Read)( 02714 UpnpWebFileHandle fileHnd, 02716 char *buf, 02718 size_t buflen); 02719 02728 EXPORT_SPEC int UpnpVirtualDir_set_ReadCallback(VDCallback_Read callback); 02729 02733 typedef int (*VDCallback_Write)( 02735 UpnpWebFileHandle fileHnd, 02737 char *buf, 02739 size_t buflen); 02740 02749 EXPORT_SPEC int UpnpVirtualDir_set_WriteCallback(VDCallback_Write callback); 02750 02754 typedef int (*VDCallback_Seek) ( 02756 UpnpWebFileHandle fileHnd, 02760 off_t offset, 02765 int origin); 02766 02775 EXPORT_SPEC int UpnpVirtualDir_set_SeekCallback(VDCallback_Seek callback); 02776 02780 typedef int (*VDCallback_Close)( 02782 UpnpWebFileHandle fileHnd); 02783 02792 EXPORT_SPEC int UpnpVirtualDir_set_CloseCallback(VDCallback_Close callback); 02793 02799 struct UpnpVirtualDirCallbacks 02800 { 02801 VDCallback_GetInfo get_info; 02802 VDCallback_Open open; 02803 VDCallback_Read read; 02804 VDCallback_Write write; 02805 VDCallback_Seek seek; 02806 VDCallback_Close close; 02807 }; 02808 02816 EXPORT_SPEC int UpnpEnableWebserver( 02818 int enable); 02819 02827 EXPORT_SPEC int UpnpIsWebserverEnabled(void); 02828 02836 EXPORT_SPEC int UpnpSetVirtualDirCallbacks( 02838 struct UpnpVirtualDirCallbacks *callbacks ); 02839 02854 EXPORT_SPEC int UpnpAddVirtualDir( 02856 const char *dirName); 02857 02865 EXPORT_SPEC int UpnpRemoveVirtualDir( 02867 const char *dirName); 02868 02872 EXPORT_SPEC void UpnpRemoveAllVirtualDirs(void); 02873 02874 /* @} Web Server API */ 02875 02876 #ifdef __cplusplus 02877 } 02878 #endif /* __cplusplus */ 02879 02880 /* @} UPnPAPI UPnP API */ 02881 02882 #endif /* UPNP_H */