56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
//----------------------------------------------------------------------------
|
||
//
|
||
// Copyright (C) 2004 Intel Corporation
|
||
//
|
||
// File: SoapUtils.cpp
|
||
//
|
||
// Contents: Sample code for an Intel<65> AMT Network client.
|
||
//
|
||
// Notes: This file contains the function implementations
|
||
// used throughout the code of the all SOAP sample applications.
|
||
//
|
||
//----------------------------------------------------------------------------
|
||
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include "SoapCommonDefinitions.h"
|
||
|
||
/*
|
||
* Changes the service name at the URI
|
||
* Arguments:
|
||
* uri - null-terminated string which holds the whole URI as supplied
|
||
* at the command line
|
||
* newService - string which represents the new service name
|
||
* newUri - pre-allocated string which will hold the new service URI
|
||
*/
|
||
bool ChangeService(const char *uri, const char *newService, char *newUri)
|
||
{
|
||
if (NULL == newUri)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
const char *tmp = strrchr(uri,'/');
|
||
if(tmp == NULL)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
int n = tmp - uri + 1;
|
||
|
||
if (strncpy_s(newUri, 2048, uri, n)) {
|
||
return false;
|
||
}
|
||
newUri[strnlen_s(uri, 2048) - strnlen_s(tmp, 2048) + 1] = '\0';
|
||
|
||
//copy newService to end of string instead '\0'
|
||
if (strcpy_s(&(newUri[n]), 2048, newService)) {
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
|