• About TV's server
  • New in version 3.20
  • New in version 3.10
  • About the source code
  • About protocols/plugins
  • TV's server API
  • Protocol Initialisation
  • Protocol binding
  • Protocol Listening and handling
  • Protocol data storage
  • Control panel
  • Multi column list
  • Time and date
  • Http protocol functions
  • Unimplemented and/or replaced functions
  • GetSignatureProtocol function

    [This function is replaced by paramter pSign of function SetProtocolInformation and has never been implemented]
    The GetSignatureProtocol function should return the first few bytes of a protocol returned by a client.

    Syntax

    int __stdcall GetSignatureProtocol(
    __in ProtocolSession *psess,
    __out ProtocolSignature buf[],
    __inout int* len
    );

    Parameters

    psess [in]buf [out]len [inout]

    Return value

    If no error occurs the function returns True (one). If the function fails it will return False (zero).

    Remarks

    This function is should be exported to enable the feature to put more protocols on one connection. This, however, is only supported if the protocol specifies that the client is the first one to respond if a new connection is established. If the protocol does not support this feature this function does not have to be exported, the function can aslo return false if exported.

    Example

    This is an example of a HTTP protocol that supports the commands GET, POST and HEAD.
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "tvsserver_base.h"
    #include "tvs_redefine_api_names.h"
    
    #define AMMOUNT_OF_SUPPPORTED_COMMANDS 3
    
    char* supportedCommands[AMMOUNT_OF_SUPPPORTED_COMMANDS] = {"GET", "POST", "HEAD"};
    
    int GetSignatureProtocol(ProtocolSession psess, char* buf, int *len) {
    	int lengthArray;
    
    	if(!strcmp(psess->protocolName, "HTTP")) {
    		createProtocolSignatureFromArray(supportedCommands, AMMOUNT_OF_SUPPPORTED_COMMANDS, 0, &lengthArray);
    
    		if(buf==0) {
    			if(len==0)
    				return 0;
    			*len=lengthArray;
    			return 1;
    		}
    		
    		if(*len<lengthArray)
    			return 0;
    
    		return createProtocolSignatureFromArray(supportedCommands, AMMOUNT_OF_SUPPPORTED_COMMANDS, buf, len);
    	}
    	
    	return 0;
    }
    
    int createProtocolSignatureFromArray(char* p_array[], int ammountItems, char* buf, int* len) {
    	int bufSize;
    	int i;
    	char* retBuf;
    
    	retBuf = buf;
    
    	if(len==0)
    		return 0;
    
    	//Calculate the size of every integer that will contain the size of the command (that last one is zero)
    	bufSize = (ammountItems + 1) * sizeof(int);
    
    	for(i=0; i<ammountItems; i++) {
    		bufSize += strlen(p_array[i]);
    	}
    
    	//If the buffer is to small, return the needed size
    	if(buf==0 || *len < bufSize) {
    		*len = bufSize;
    		return 0;
    	}
    
    	//Copy every item with there size to the array
    	for(i=0; i<ammountItems; i++) {
    		*(int*)retBuf = strlen(p_array[i]);
    		retBuf += sizeof(int);
    		strcpy(retBuf, p_array[i]);
    		retBuf += strlen(retBuf);
    	}
    
    	*(int*)retBuf = 0;
    
    	return 1;
    }
    

    Requirements

    Should be exported by Processor plugin.
    Minimum supported API 1.00
    Header tvsserver_base.h