Beispiel #1
0
/*================================================================
*   ixmlElement_getAttributeNodeNS
*       Retrieves an attr node by local name and namespace URI.
*       External function.
*
*   Parameter:
*       namespaceURI: the namespace of the attribute to retrieve.
*       localName: the local name of the attribute to retrieve.
*
*   Return Value:
*       The attr node with the specified attribute local name and
*       namespace URI or null if there is no such attribute.
*
*=================================================================*/
IXML_Attr *
ixmlElement_getAttributeNodeNS( IN IXML_Element * element,
                                IN DOMString namespaceURI,
                                IN DOMString localName )
{

    IXML_Node *attrNode;

    if( ( element == NULL ) || ( namespaceURI == NULL )
        || ( localName == NULL ) ) {
        return NULL;
    }

    attrNode = element->n.firstAttr;
    while( attrNode != NULL ) {
        if( rtp_strcmp( attrNode->localName, localName ) == 0 && rtp_strcmp( attrNode->namespaceURI, namespaceURI ) == 0 ) {    // found it
            break;
        } else {
            attrNode = attrNode->nextSibling;
        }
    }

    return ( IXML_Attr * ) attrNode;

}
Beispiel #2
0
/*================================================================
*   ixmlElement_removeAttributeNS
*       Removes an attribute by local name and namespace URI. The replacing
*       attribute has the same namespace URI and local name, as well as
*       the original prefix.
*       External function.
*
*   Parameters:
*       namespaceURI: the namespace URI of the attribute to remove.
*       localName: the local name of the atribute to remove.
*
*   Return Value:
*       IXML_SUCCESS or failure.
*
*=================================================================*/
int
ixmlElement_removeAttributeNS( IN IXML_Element * element,
                               IN DOMString namespaceURI,
                               IN DOMString localName )
{
    IXML_Node *attrNode;

    if( ( element == NULL ) || ( namespaceURI == NULL )
        || ( localName == NULL ) ) {
        return IXML_INVALID_PARAMETER;
    }

    attrNode = element->n.firstAttr;
    while( attrNode != NULL ) {
        if( rtp_strcmp( attrNode->localName, localName ) == 0 &&
            rtp_strcmp( attrNode->namespaceURI, namespaceURI ) == 0 ) {
            break;              //found it
        } else {
            attrNode = attrNode->nextSibling;
        }
    }

    if( attrNode != NULL ) {    // has the attribute
        if( attrNode->nodeValue != NULL ) {
            IXML_FREE( attrNode->nodeValue );
            attrNode->nodeValue = NULL;
        }
    }

    return IXML_SUCCESS;

}
Beispiel #3
0
/*================================================================
*   ixmlElement_hasAttributeNS
*       Returns true when attribute with a given local name and namespace
*       URI is specified on this element, false otherwise.
*       External function.
*
*   Parameters:
*       namespaceURI: the namespace URI of the attribute to look for.
*       localName: the local name of the attribute to look for.
*
*   Return Value:
*       true if an attribute with the given local name and namespace URI
*       is specified, false otherwise.
*
*=================================================================*/
IXML_BOOL
ixmlElement_hasAttributeNS( IN IXML_Element * element,
                            IN DOMString namespaceURI,
                            IN DOMString localName )
{

    IXML_Node *attrNode;

    if( ( element == NULL ) || ( namespaceURI == NULL )
        || ( localName == NULL ) ) {
        return FALSE;
    }

    attrNode = element->n.firstAttr;
    while( attrNode != NULL ) {
        if( rtp_strcmp( attrNode->localName, localName ) == 0 &&
            rtp_strcmp( attrNode->namespaceURI, namespaceURI ) == 0 ) {
            return TRUE;
        } else {
            attrNode = attrNode->nextSibling;
        }
    }

    return FALSE;
}
Beispiel #4
0
/*----------------------------------------------------------------------*
                            rtp_thread_spawn
 *----------------------------------------------------------------------*/
int rtp_thread_spawn (RTP_HANDLE         * newThread,
                      RTP_ENTRY_POINT_FN   entryPoint,
                      const char         * name,
                      int                  stackSizeIndex,
                      int                  priorityIndex,
                      void               * userData)
{
    PIFACE pi;
    int * index = (int *) userData;
    
    if ((rtp_strcmp(name, "ip interpret") == 0) && !IPTaskInitialized[*index])
    {
        IPTaskInitialized[*index] = 1;

        IPTaskContinuation[*index].InitializeCallback((HAL_CALLBACK_FPN) entryPoint, userData);
    }
    
    else if ((rtp_strcmp(name, "timer comp") == 0) && !TimerTaskCompInitialized)
    {
        TimerTaskCompInitialized = 1;
        
        TimerTaskCompletion.InitializeForUserMode((HAL_CALLBACK_FPN) entryPoint, userData);
            
        TimerTaskCompletion.EnqueueDelta(cfg_protocol_data.timer_freq * 1000);
    }       
    
    else if ((rtp_strcmp(name, "timer cont") == 0) && !TimerTaskContInitialized)
    {      
        TimerTaskContInitialized = 1;

        TimerTaskContinuation.InitializeCallback((HAL_CALLBACK_FPN) entryPoint,userData);    
    } 
    
    else if ((rtp_strcmp(name, "interrupt task") == 0) && !InterruptTaskContInitialized[*index])
    {
        pi = (PIFACE) &ifaces[*index];
        if (!pi)
        {
            return -1;
        }

        InterruptTaskContInitialized[*index] = 1;
        
        InterruptTaskContinuation[*index].InitializeCallback((HAL_CALLBACK_FPN) entryPoint,pi);
    }
    
    else if ((rtp_strcmp(name, "dhcp") == 0) && !DHCPTaskInitialized)
    {
        DHCPTaskInitialized = 1;
        
        DHCPTaskContinuation.InitializeCallback((HAL_CALLBACK_FPN) entryPoint,userData);
    }
    
    return (0);    
}
static RTPMemBlockHeader *DbInsertByFile(RTPMemBlockHeader *InList,RTPMemBlockHeader *pRecord)
{
RTPMemBlockHeader *List=InList;
RTPMemBlockHeader *Prev=0;
	pRecord->next = 0;
	if (!List)
		return pRecord;
	while (List)
	{
		int cmpval = rtp_strcmp(pRecord->file,List->file);
		if (cmpval < 0 || cmpval==0 && pRecord->line < List->line)
		{
			pRecord->next = List;
			if (Prev)
				Prev->next = pRecord;
			if (List == InList)
				return pRecord;
			else
				return InList;
		}
		Prev = List;
		List=List->next;
	}
	Prev->next=pRecord;
	return InList;
}
Beispiel #6
0
/*----------------------------------------------------------------------*
                            rtp_thread_kill
 *----------------------------------------------------------------------*/
int rtp_thread_kill (RTP_HANDLE         * newThread,
                      RTP_ENTRY_POINT_FN   entryPoint,
                      const char         * name,
                      int                  stackSizeIndex,
                      int                  priorityIndex,
                      void               * userData)
{
    int * index = (int *) userData;
    
    if ((rtp_strcmp(name, "ip interpret") == 0) && IPTaskInitialized[*index])
    {
        IPTaskInitialized[*index] = 0;

        IPTaskContinuation[*index].Abort();
    }
    
    else if ((rtp_strcmp(name, "timer comp") == 0) && TimerTaskCompInitialized)
    {
        TimerTaskCompInitialized = 0;
        
        TimerTaskCompletion.Abort();
    }       
    
    else if ((rtp_strcmp(name, "timer cont") == 0) && TimerTaskContInitialized)
    {      
        TimerTaskContInitialized = 0;

        TimerTaskContinuation.Abort();
    } 
    
    else if ((rtp_strcmp(name, "interrupt task") == 0) && InterruptTaskContInitialized[*index])
    {
        InterruptTaskContInitialized[*index] = 0;
        
        InterruptTaskContinuation[*index].Abort();
    }
    
    else if ((rtp_strcmp(name, "dhcp") == 0) && DHCPTaskInitialized)
    {
        DHCPTaskInitialized = 0;
        
        DHCPTaskContinuation.Abort();
    }
    
    return (0);    
}
Beispiel #7
0
static int in_user(char * userName, char *userPass, char *userPerm)
{
    rtp_term_promptstring (userName, 0);
    if (userName[0])
    {
        rtp_printf("Password  : "******"rw");
            rtp_printf("Select access rights , 'r'ead or 'rw' read-write  : ");
            rtp_term_promptstring (userPerm, 0);
            if (rtp_strcmp(userPerm, "rw") == 0)
                break;
            else if (rtp_strcmp(userPerm, "r") == 0)
                break;
        }
        return(1);
    }
    return(0);
}
// Find the file and accumulator record for this entry and update the size count
static void DbAddToByFileSummary(RTPMemBlockHeader *Rval,RTPMemBlockHeader *MemBlockToSum)
{
	RTPMemBlockHeader *MemBlock=Rval;
	while(MemBlock)
	{
		if(rtp_strcmp(MemBlock->file, MemBlockToSum->file)==0)
		{
			MemBlock->size += MemBlockToSum->size;
			MemBlock->seq += 1; // The seq field counts occurrences in a summary report
			return;
		}
		MemBlock=MemBlock->next;
	}
}
Beispiel #9
0
/*================================================================
*   ixmlDocument_getElementById
*       Returns the element whose ID is given by tagName. If no such
*       element exists, returns null.
*       External function.
*   Parameter:
*       tagName: the tag name for an element.
*   Return Values:
*       The matching element.
*
*=================================================================*/
IXML_Element *
ixmlDocument_getElementById( IN IXML_Document * doc,
                             IN DOMString tagName )
{
    IXML_Element *rtElement = NULL;
    IXML_Node *nodeptr = ( IXML_Node * ) doc;
    const char *name;

    if( ( nodeptr == NULL ) || ( tagName == NULL ) ) {
        return rtElement;
    }

    if( ixmlNode_getNodeType( nodeptr ) == eELEMENT_NODE ) {
        name = ixmlNode_getNodeName( nodeptr );
        if( name == NULL ) {
            return rtElement;
        }

        if( rtp_strcmp( tagName, name ) == 0 ) {
            rtElement = ( IXML_Element * ) nodeptr;
            return rtElement;
        } else {
            rtElement = ixmlDocument_getElementById( ( IXML_Document * )
                                                     ixmlNode_getFirstChild
                                                     ( nodeptr ),
                                                     tagName );
            if( rtElement == NULL ) {
                rtElement = ixmlDocument_getElementById( ( IXML_Document
                                                           * )
                                                         ixmlNode_getNextSibling
                                                         ( nodeptr ),
                                                         tagName );
            }
        }
    } else {
        rtElement = ixmlDocument_getElementById( ( IXML_Document * )
                                                 ixmlNode_getFirstChild
                                                 ( nodeptr ), tagName );
        if( rtElement == NULL ) {
            rtElement = ixmlDocument_getElementById( ( IXML_Document * )
                                                     ixmlNode_getNextSibling
                                                     ( nodeptr ),
                                                     tagName );
        }
    }

    return rtElement;
}
Beispiel #10
0
/** @memo   Check if an item is already contained in an item contained in a list or menu object.

    @doc    Checks if the string exactly matches a string that was passed in the item argument
    to one of the forms of rtp_gui_list_add_item(). The item argument is the text that is displayed
    when the list is displayed. This function may be used to identify and discard
    duplicate information like the device identifier information in rebroadcasts of SSDP advertisements.

    @precondition rtp_gui_list_init must be called first.

    @return 1 if the an exact match for item is already in the list. 0 otherwise.
*/
int rtp_gui_list_check_duplicate_item(
void *vplist, /** Handle returned from rtp_gui_list_init() */
char  *item   /** String to check for a match */)
{
	struct rtp_gui_list *plist;
	struct rtp_gui_list_item *pitem;

	plist = (struct rtp_gui_list *) vplist;
	pitem = plist->itemlist;
	while (pitem)
	{
		if (pitem->item && (rtp_strcmp(item, pitem->item) == 0))
			return(1);
		pitem = pitem->pnext;
	}
	return(0);
}
// Add the record to the list of memory records if it resides in a file and line that is not yet accounted for.
static int DbAddAppendIfNewLine(RTPMemBlockHeader *BlockListCategories,RTPMemBlockHeader *MemBlockToAdd)
{
	RTPMemBlockHeader *MemBlock=BlockListCategories;
	while(MemBlock)
	{
		if(rtp_strcmp(MemBlock->file, MemBlockToAdd->file)==0 && MemBlock->line == MemBlockToAdd->line)
			return 0;
		if (MemBlock->nextSort)
			MemBlock=MemBlock->nextSort;
		else
		{
			MemBlock->nextSort=MemBlockToAdd;
			MemBlockToAdd->nextSort=0;
			MemBlock = 0;
		}
	}
	return 1;
}
// ===
// Add a record to the list of records segregated by line.
static RTPMemBlockHeader *DbEnsureLineOnList(RTPMemBlockHeader *BlockList,RTPMemBlockHeader *MemBlockToAdd)
{
	RTPMemBlockHeader *MemBlock=BlockList;
	while(MemBlock)
	{
		if(rtp_strcmp(MemBlock->file, MemBlockToAdd->file)==0 && MemBlock->line == MemBlockToAdd->line)
			return MemBlock;
		if (MemBlock->nextSort)
			MemBlock=MemBlock->nextSort;
		else
		{
			MemBlock->nextSort=MemBlockToAdd;
			MemBlockToAdd->nextSort=0;
			MemBlock = 0;
		}
	}
	return MemBlockToAdd;
}
/*---------------------------------------------------------------------------*/
int  HTTP_ServerRemoveAuthRealm   (HTTPServerContext *server,
                                   const HTTP_CHAR *realmName)
{
HTTPServerAuthRealm *realm;

	realm = (HTTPServerAuthRealm *) server->realmList.next;
	while (realm != (HTTPServerAuthRealm *) &server->realmList)
	{
		if (!rtp_strcmp(realmName, realm->realmName))
		{
			/* found it */
			DLLIST_REMOVE(&realm->node);
			_HTTP_FreeServerAuthRealm(realm);
			return (0);
		}
		realm = (HTTPServerAuthRealm *) realm->node.next;
	}

	return (-1);
}
Beispiel #14
0
/*================================================================
*   ixmlElement_getAttribute
*       Retrievea an attribute value by name.
*       External function.
*   Parameters:
*       name: the name of the attribute to retrieve.
*   Return Values:
*       attribute value as a string, or the empty string if that attribute
*       does not have a specified value.
*
*=================================================================*/
DOMString
ixmlElement_getAttribute( IN IXML_Element * element,
                          IN DOMString name )
{
    IXML_Node *attrNode;

    if( ( element == NULL ) || ( name == NULL ) ) {
        return NULL;
    }

    attrNode = element->n.firstAttr;
    while( attrNode != NULL ) {
        if( rtp_strcmp( attrNode->nodeName, name ) == 0 ) { // found it
            return attrNode->nodeValue;
        } else {
            attrNode = attrNode->nextSibling;
        }
    }

    return NULL;
}
/*---------------------------------------------------------------------------*/
int  HTTP_ServerAddAuthRealm      (HTTPServerContext *server,
                                   const HTTP_CHAR *realmName,
                                   HTTPAuthRealmPath *pathList,
                                   HTTP_INT16 numPaths,
                                   HTTPAuthRealmUser *userList,
                                   HTTP_INT16 numUsers,
                                   HTTPAuthScheme scheme)
{
HTTPServerAuthRealm *realm;

	/* first try to find an existing realm with the same name */
	realm = (HTTPServerAuthRealm *) server->realmList.next;
	while (realm != (HTTPServerAuthRealm *) &server->realmList)
	{
		if (!rtp_strcmp(realmName, realm->realmName))
		{
			/* already exists; first need to remove it */
			return (-1);
		}
		realm = (HTTPServerAuthRealm *) realm->node.next;
	}

	realm = _HTTP_AllocServerAuthRealm();
	if (realm)
	{
		DLLIST_INSERT_BEFORE(&server->realmList, &realm->node);
		DLLIST_INIT(&realm->activeNonceList);
		realm->pathList = pathList;
		realm->userList = userList;
		realm->scheme   = scheme;
		realm->numPaths = numPaths;
		realm->numUsers = numUsers;
		rtp_strncpy(realm->realmName, realmName, HTTP_SERVER_NAME_LEN-1);
		return (0);
	}

	return (-1);
}
Beispiel #16
0
/*================================================================
*   ixmlElement_getAttributeNode
*       Retrieve an attribute node by name.
*       External function.
*   Parameters:
*       name: the name(nodeName) of the attribute to retrieve.
*   Return Value:
*       The attr node with the specified name (nodeName) or NULL if
*       there is no such attribute.
*
*=================================================================*/
IXML_Attr *
ixmlElement_getAttributeNode( IN IXML_Element * element,
                              IN char *name )
{

    IXML_Node *attrNode;

    if( ( element == NULL ) || ( name == NULL ) ) {
        return NULL;
    }

    attrNode = element->n.firstAttr;
    while( attrNode != NULL ) {
        if( rtp_strcmp( attrNode->nodeName, name ) == 0 ) { // found it
            break;
        } else {
            attrNode = attrNode->nextSibling;
        }
    }

    return ( IXML_Attr * ) attrNode;

}
/*---------------------------------------------------------------------------*/
int  _HTTP_ServerRemovePath       (HTTPServerContext *server,
                                   const HTTP_CHAR *path)
{
HTTPServerPath *serverPath;

	serverPath = (HTTPServerPath *) server->pathList.next;
	while (serverPath != (HTTPServerPath *) &server->pathList)
	{
		if (!rtp_strcmp(path, serverPath->path))
		{
			/* found it */
			if (serverPath->dfn)
			{
				serverPath->dfn(serverPath->userData);
			}
			DLLIST_REMOVE(&serverPath->node);
			_HTTP_FreeServerPath(serverPath);
			return (0);
		}
		serverPath = (HTTPServerPath *) serverPath->node.next;
	}

	return (-1);
}
Beispiel #18
0
/*================================================================
*   ixmlElement_setAttribute
*       Adds a new attribute.  If an attribute with that name is already
*       present in the element, its value is changed to be that of the value
*       parameter. If not, a new attribute is inserted into the element.
*
*       External function.
*   Parameters:
*       name: the name of the attribute to create or alter.
*       value: value to set in string form
*   Return Values:
*       IXML_SUCCESS or failure code.
*
*=================================================================*/
int
ixmlElement_setAttribute( IN IXML_Element * element,
                          IN char *name,
                          IN char *value )
{
    IXML_Node *attrNode;
    IXML_Attr *newAttrNode;
    short errCode = IXML_SUCCESS;

    if( ( element == NULL ) || ( name == NULL ) || ( value == NULL ) ) {
        errCode = IXML_INVALID_PARAMETER;
        goto ErrorHandler;
    }

    if( Parser_isValidXmlName( name ) == FALSE ) {
        errCode = IXML_INVALID_CHARACTER_ERR;
        goto ErrorHandler;
    }

    attrNode = element->n.firstAttr;
    while( attrNode != NULL ) {
        if( rtp_strcmp( attrNode->nodeName, name ) == 0 ) {
            break;              //found it
        } else {
            attrNode = attrNode->nextSibling;
        }
    }

    if( attrNode == NULL ) {    // add a new attribute
        errCode =
            ixmlDocument_createAttributeEx( ( IXML_Document * ) element->n.
                                            ownerDocument, name,
                                            &newAttrNode );
        if( errCode != IXML_SUCCESS ) {
            goto ErrorHandler;
        }

        attrNode = ( IXML_Node * ) newAttrNode;

        attrNode->nodeValue = IXML_STRDUP( value );
        if( attrNode->nodeValue == NULL ) {
            ixmlAttr_free( newAttrNode );
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
        }

        errCode =
            ixmlElement_setAttributeNode( element, newAttrNode, NULL );
        if( errCode != IXML_SUCCESS ) {
            ixmlAttr_free( newAttrNode );
            goto ErrorHandler;
        }

    } else {
        if( attrNode->nodeValue != NULL ) { // attribute name has a value already
            IXML_FREE( attrNode->nodeValue );
        }

        attrNode->nodeValue = IXML_STRDUP( value );
        if( attrNode->nodeValue == NULL ) {
            errCode = IXML_INSUFFICIENT_MEMORY;
        }
    }

  ErrorHandler:
    return errCode;
}
Beispiel #19
0
// ---------------------------------------------------- 
// ENTRY POINT
// ---------------------------------------------------- 
int smbservermain(void)
{
    char c;
    int go;
    int  have_printer;
    byte security_mode;
    RTP_THREAD new_thread;
#ifndef RTSMB_RTIP
    int spinState = 0;
    char spinner[4] = {'\\', '-', '/', '|'};
#endif

    // ------------------------------------------------ 
#if (INCLUDE_RTIP)
    rtp_memcpy(my_ip_srv_address, my_ip_address, IP_ALEN);
    rtp_memcpy(ip_srv_mask_address, ip_mask_address, IP_ALEN);
#endif

    // ------------------------------------------------ 
    rtp_printf("\n\nRun Alt Port Numbers(Y/y) or Well-Known(N/n)");
    while (!kbhit ())
    {       
    }
    c = getch ();
    if (c == 'Y' || c == 'y')
    {
        rtsmb_init_port_alt ();
    }
    
    if (c == 'N' || c == 'n')
    {
        rtsmb_init_port_well_know ();
    }

    // ------------------------------------------------ 
    if (!rtp_file_mkdir (SHARE_PATH))
    {
        rtp_printf("WARNING: mkdir of SHARE_PATH failed %s\n", SHARE_PATH, 0);
    }

    rtp_printf("\nsmbservermain - enter\n");
    go = 1;
    /* Start ertfs on windows*/
    //pc_ertfs_init ();

    /* initialize server */
    rtsmb_srv_init (my_ip_srv_address, ip_srv_mask_address, 
                    NETWORK_NAME , NETWORK_GROUP);
    rtp_printf ("Initialized rtsmb\n");

#ifdef USE_CONFIG_FILE
    rtsmb_srv_read_config ("smb_config.txt");
#else

    rtp_printf("Note: The demo does not actually print data, it just captures print data to a temporary file.\n");

    {
    char printerName[32];
    char driverName[32];
    char tempPath[32];
    char prnFile[32];

        rtp_strcpy(printerName, "SmbPrinter");
        rtp_strcpy(driverName, "HP LaserJet 1100");
        rtp_strcpy(tempPath, TEMP_PATH);
        rtp_strcpy(prnFile, "SmbPrintData.prn");

        have_printer = in_printer(printerName,driverName, tempPath, prnFile);
        if (have_printer)
        {
            rtsmb_srv_share_add_printer (printerName, driverName, 1, (PSMBFILEAPI)0, tempPath, 0, (PFCHAR)0, prnFile);
        }
    }
    security_mode = in_loginmode();

    //rtsmb_srv_share_add_tree (SHARE_NAME, DESCRIPTION,  NULL, SHARE_PATH, SHARE_FLAGS_8_3, SECURITY_READWRITE, NULL);
    //rtsmb_srv_share_add_tree (SHARE_NAME, DESCRIPTION, (PSMBFILEAPI)0, SHARE_PATH, SHARE_FLAGS_CREATE, SECURITY_READWRITE, (PFCHAR)0);

    rtsmb_srv_share_add_ipc ((PFCHAR)0);

    rtsmb_srv_set_mode (security_mode);  /* AUTH_USER_MODE or AUTH_SHARE_MODE */

    rtsmb_srv_register_group ("rw_access");
    rtsmb_srv_register_group ("rd_access");

    {
    char shareName[32];
    char sharePath[32];
    char shareDesc[32];
    char sharePass[32];
    char secCode[32];

        rtp_strcpy(shareName, SHARE_NAME);
        rtp_strcpy(shareDesc, "Rtsmbshare");
        rtp_strcpy(sharePath, SHARE_PATH);
        rtp_strcpy(sharePass, "");
        rtp_strcpy(secCode,"2");

        if (in_share(security_mode, shareName, sharePath, shareDesc, sharePass, secCode))
        {
        byte security_mode; /* Defult is 2  SECURITY_READWRITE */
        char *psharePass;
            if (sharePass[0])
                psharePass = &sharePass[0];
            else
                psharePass = 0;
            security_mode = (byte)(secCode[0] -'0');
            rtsmb_srv_share_add_tree (shareName, shareDesc, (PSMBFILEAPI)0, sharePath, SHARE_FLAGS_CREATE, security_mode, (PFCHAR)psharePass);
            rtsmb_srv_set_group_permissions ("rw_access", shareName, SECURITY_READWRITE);
            rtsmb_srv_set_group_permissions ("rd_access", shareName, SECURITY_READ);
        }
    }

    //  rtsmb_srv_set_group_permissions ("rw_access", SHARE_NAME, SECURITY_READWRITE);
    rtsmb_srv_set_group_permissions ("rw_access", "IPC$", SECURITY_READWRITE);
    rtsmb_srv_set_group_permissions ("rd_access", "IPC$", SECURITY_READWRITE);

    //rtsmb_srv_register_group ("ro_access");
    //rtsmb_srv_set_group_permissions ("ro_access", SHARE_NAME, SECURITY_READ);
    //rtsmb_srv_set_group_permissions ("ro_access", "IPC$", SECURITY_READWRITE);

    //rtsmb_srv_register_group ("wo_access");
    //rtsmb_srv_set_group_permissions ("wo_access", SHARE_NAME, SECURITY_WRITE);
    //rtsmb_srv_set_group_permissions ("wo_access", "IPC$", SECURITY_READWRITE);

    /* No access */
    //rtsmb_srv_register_group ("nonebs");
    //rtsmb_srv_set_group_permissions ("nonebs", SHARE_NAME, SECURITY_NONE);
    //rtsmb_srv_set_group_permissions ("nonebs", "IPC$", SECURITY_NONE);

    //rtsmb_srv_register_user (SMB_GUESTNAME, (PFCHAR)0);
    //rtsmb_srv_register_user (SMB_GUESTNAME, "ebs");
    //rtsmb_srv_add_user_to_group (SMB_GUESTNAME, "rw_access");

    if (security_mode == AUTH_USER_MODE)
    {
    char userName[32];
    char userPass[32];
    char userPerm[32];

        if (in_guestaccount())
            rtsmb_srv_register_user (SMB_GUESTNAME, (PFCHAR)0);

        rtp_strcpy(userName, "user");
        rtp_strcpy(userPass, "password");
        rtp_printf("Add users, enter a blank user to stop : ");
        while (in_user(userName, userPass, userPerm))
        {
            rtsmb_srv_register_user (userName, userPass);
            if (rtp_strcmp(userPerm, "rw") == 0)
                    {rtsmb_srv_add_user_to_group (userName, "rw_access");break;}
            else if (rtp_strcmp(userPerm, "r") == 0)
                {rtsmb_srv_add_user_to_group (userName, "rd_access");break;}
        }
    }

#endif //USE_CONFIG_FILE

#if (1)
    if (rtp_thread_spawn (
                &new_thread,
                (RTP_ENTRY_POINT_FN) rtsmb_main,
                (const char *) "RTIP_SMB_SRV",
                STACKSIZE_HUGE_INDEX,
                TASKPRIO_NORMAL_INDEX,
                (void *) 0
            ) < 0)
        {
            rtp_term_puts("spawn of SMB task failed");
            return(-1);
        }
        rtp_term_puts("spawn of SMB task WORKED");

        while (1)
        {
#ifndef RTSMB_RTIP
            spinState += 1;
            spinState = spinState%4;
            rtp_printf("\b%c",spinner[spinState]);

#endif
            rtsmb_srv_cycle (1000);
        }

#else
    //Main Loop
    while(go)
    {
        rtsmb_main ();
        if(rtp_term_kbhit())
        {
//          switch (getch())
            switch (rtp_term_getch())
            {
            case 'q':   go = 0;
                        break;
            default:    break;
            }
        }
    }

    //Shutdown
    rtp_printf("main: shutting down\n");

    rtsmb_srv_shutdown ();
    rtp_net_exit ();
#endif
    return(0);
}//main
Beispiel #20
0
int UPnP_DeviceSSDPCallback (
		SSDPServerContext* ctx, /** the SSDP context */
		SSDPServerRequest* serverRequest, /** address of buffer holding ssdp request
                                    information */
		void* cookie            /** cookie holds pointer to device run time
                                    information */
	)
{
	UPnPRootDevice* rootDevice;
    UPnPDevice*     device;
    UPnPService*    service;
    DLListNode*     listNode;
	char*           descLocation;
	SSDPSearch*     search = &serverRequest->data.search;
	UPnPDeviceRuntime* rt = (UPnPDeviceRuntime*) cookie;

	rootDevice = (UPnPRootDevice*) rt->rootDeviceList.next;

	/* search through rootDevice list for a match to search->target */
    while (rootDevice != (UPnPRootDevice *) &rt->rootDeviceList)
    {
		descLocation = _getLocation(search->clientAddr.ipAddr, search->clientAddr.port,
			                        search->clientAddr.type, rootDevice);

   		if (descLocation)
   		{
			if (rtp_strcmp(search->target, "ssdp:all") == 0)
			{
			    //responds for all embedded and root devices
		        listNode = rootDevice->deviceList.next;
		        while (listNode != &rootDevice->deviceList)
		        {
		            device = (UPnPDevice *)listNode;
		  	        if (SSDP_QueueSearchResponse(ctx, search, descLocation,
		   	            device->UDN, TIMEOUTSEC) == -1)
		   	        {
		   	        	break;
		   	        }
		            listNode = listNode->next;
		        }
		    }

		    if (rtp_strcmp(search->target, "upnp:rootdevice") == 0)
			{
		        if (SSDP_QueueSearchResponse(ctx, search, descLocation,
		            rootDevice->device.UDN, TIMEOUTSEC) == -1)
		        {
					_freeLocation(rootDevice, descLocation);
		        	break;
		        }
		    }
		    // Check the available services for search target
			listNode = rootDevice->serviceList.next;
		    while (listNode != &rootDevice->serviceList)
		    {
		        service =  (UPnPService *)listNode;
		        if (rtp_strcmp(search->target, service->serviceType) == 0)
			    {
			        if (SSDP_QueueSearchResponse(ctx, search, descLocation,
			            service->device->UDN, TIMEOUTSEC) == -1)
			        {
						break;
			        }
		        }
		        listNode = listNode->next;
		    }

		    /* Check the available devices for search target */
		    listNode = rootDevice->deviceList.next;

		    while (listNode != &rootDevice->deviceList)
		    {
		        device = (UPnPDevice *) listNode;

		        if (rtp_strcmp(search->target, device->deviceType) == 0)
			    {
			        if (SSDP_QueueSearchResponse(ctx, search, descLocation,
			            device->UDN, TIMEOUTSEC) == -1)
			        {
						break;
			        }
		        }

//rtp_printf("HEREHERE UPnP_DeviceSSDPCallback trying device->UDN |%s|\n", device->UDN);
		        if(rtp_strcmp(search->target, device->UDN) == 0)
			    {
			        if (SSDP_QueueSearchResponse(ctx, search, descLocation,
			            device->UDN, TIMEOUTSEC) == -1)
			        {
						break;
			        }
		        }

		        listNode = listNode->next;
		    }

			_freeLocation(rootDevice, descLocation);
		}

		rootDevice = (UPnPRootDevice *) rootDevice->device.node.next;
	}

    return(0);
}
Beispiel #21
0
/*================================================================
*   ixmlElement_setAttributeNodeNS
*       Adds a new attribute. If an attribute with that local name and
*       that namespace URI is already present in the element, it is replaced
*       by the new one.
*       External function.
*
*   Parameter:
*       newAttr: the attr node to add to the attribute list.
*
*   Return Value:
*       If the newAttr attribute replaces an existing attribute with the
*       same local name and namespace, the replaced attr node is returned,
*       otherwise null is returned.
*
*=================================================================*/
int
ixmlElement_setAttributeNodeNS( IN IXML_Element * element,
                                IN IXML_Attr * newAttr,
                                OUT IXML_Attr ** rtAttr )
{
    IXML_Node *attrNode;
    IXML_Node *node;
    IXML_Node *prevAttr = NULL,
     *nextAttr = NULL;
    IXML_Node *preSib,
     *nextSib;

    if( ( element == NULL ) || ( newAttr == NULL ) ) {
        return IXML_INVALID_PARAMETER;
    }

    if( newAttr->n.ownerDocument != element->n.ownerDocument ) {
        return IXML_WRONG_DOCUMENT_ERR;
    }

    if( ( newAttr->ownerElement != NULL )
        && ( newAttr->ownerElement != element ) ) {
        return IXML_INUSE_ATTRIBUTE_ERR;
    }

    newAttr->ownerElement = element;
    node = ( IXML_Node * ) newAttr;

    attrNode = element->n.firstAttr;
    while( attrNode != NULL ) {
        if( rtp_strcmp( attrNode->localName, node->localName ) == 0 &&
            rtp_strcmp( attrNode->namespaceURI, node->namespaceURI ) == 0 ) {
            break;              //found it
        } else {
            attrNode = attrNode->nextSibling;
        }
    }

    if( attrNode != NULL )      // already present, will replace by newAttr
    {
        preSib = attrNode->prevSibling;
        nextSib = attrNode->nextSibling;

        if( preSib != NULL ) {
            preSib->nextSibling = node;
        }

        if( nextSib != NULL ) {
            nextSib->prevSibling = node;
        }

        if( element->n.firstAttr == attrNode ) {
            element->n.firstAttr = node;
        }

        *rtAttr = ( IXML_Attr * ) attrNode;

    } else                      // add this attribute
    {
        if( element->n.firstAttr != NULL )  // element has attribute already
        {
            prevAttr = element->n.firstAttr;
            nextAttr = prevAttr->nextSibling;
            while( nextAttr != NULL ) {
                prevAttr = nextAttr;
                nextAttr = prevAttr->nextSibling;
            }
            prevAttr->nextSibling = node;
        } else                  // this is the first attribute node
        {
            element->n.firstAttr = node;
            node->prevSibling = NULL;
            node->nextSibling = NULL;
        }

        if( rtAttr != NULL ) {
            *rtAttr = NULL;
        }
    }

    return IXML_SUCCESS;
}
Beispiel #22
0
/*================================================================
*   ixmlElement_setAttributeNS
*       Adds a new attribute. If an attribute with the same local name
*       and namespace URI is already present on the element, its prefix
*       is changed to be the prefix part of the qualifiedName, and its
*       value is changed to be the value parameter.  This value is a
*       simple string.
*       External function.
*
*   Parameter:
*       namespaceURI: the namespace of the attribute to create or alter.
*       qualifiedName: the qualified name of the attribute to create or alter.
*       value: the value to set in string form.
*
*   Return Value:
*       IXML_SUCCESS or failure
*
*=================================================================*/
int
ixmlElement_setAttributeNS( IN IXML_Element * element,
                            IN DOMString namespaceURI,
                            IN DOMString qualifiedName,
                            IN DOMString value )
{
    IXML_Node *attrNode = NULL;
    IXML_Node newAttrNode;
    IXML_Attr *newAttr;
    int rc;

    if( ( element == NULL ) || ( namespaceURI == NULL ) ||
        ( qualifiedName == NULL ) || ( value == NULL ) ) {
        return IXML_INVALID_PARAMETER;
    }

    if( Parser_isValidXmlName( qualifiedName ) == FALSE ) {
        return IXML_INVALID_CHARACTER_ERR;
    }

    ixmlNode_init( &newAttrNode );

    newAttrNode.nodeName = IXML_STRDUP( qualifiedName );
    if( newAttrNode.nodeName == NULL ) {
        return IXML_INSUFFICIENT_MEMORY;
    }

    rc = Parser_setNodePrefixAndLocalName( &newAttrNode );
    if( rc != IXML_SUCCESS ) {
        Parser_freeNodeContent( &newAttrNode );
        return rc;
    }
    // see DOM 2 spec page 59
    if( ( newAttrNode.prefix != NULL && namespaceURI == NULL ) ||
        ( rtp_strcmp( newAttrNode.prefix, "xml" ) == 0 &&
          rtp_strcmp( namespaceURI,
                  "http://www.w3.org/XML/1998/namespace" ) != 0 )
        || ( rtp_strcmp( qualifiedName, "xmlns" ) == 0
             && rtp_strcmp( namespaceURI,
                        "http://www.w3.org/2000/xmlns/" ) != 0 ) ) {
        Parser_freeNodeContent( &newAttrNode );
        return IXML_NAMESPACE_ERR;
    }

    attrNode = element->n.firstAttr;
    while( attrNode != NULL ) {
        if( rtp_strcmp( attrNode->localName, newAttrNode.localName ) == 0 &&
            rtp_strcmp( attrNode->namespaceURI, namespaceURI ) == 0 ) {
            break;              //found it
        } else {
            attrNode = attrNode->nextSibling;
        }
    }

    if( attrNode != NULL ) {
        if( attrNode->prefix != NULL ) {
            IXML_FREE( attrNode->prefix );   // remove the old prefix
        }
        // replace it with the new prefix
        attrNode->prefix = IXML_STRDUP( newAttrNode.prefix );
        if( attrNode->prefix == NULL ) {
            Parser_freeNodeContent( &newAttrNode );
            return IXML_INSUFFICIENT_MEMORY;
        }

        if( attrNode->nodeValue != NULL ) {
            IXML_FREE( attrNode->nodeValue );
        }

        attrNode->nodeValue = IXML_STRDUP( value );
        if( attrNode->nodeValue == NULL ) {
            IXML_FREE( attrNode->prefix );
            Parser_freeNodeContent( &newAttrNode );
            return IXML_INSUFFICIENT_MEMORY;
        }

    } else {
        // add a new attribute
        rc = ixmlDocument_createAttributeNSEx( ( IXML_Document * )
                                               element->n.ownerDocument,
                                               namespaceURI, qualifiedName,
                                               &newAttr );
        if( rc != IXML_SUCCESS ) {
            return rc;
        }

        newAttr->n.nodeValue = IXML_STRDUP( value );
        if( newAttr->n.nodeValue == NULL ) {
            ixmlAttr_free( newAttr );
            return IXML_INSUFFICIENT_MEMORY;
        }

        if( ixmlElement_setAttributeNodeNS( element, newAttr, NULL ) !=
            IXML_SUCCESS ) {
            ixmlAttr_free( newAttr );
            return IXML_FAILED;
        }

    }

    Parser_freeNodeContent( &newAttrNode );
    return IXML_SUCCESS;
}