Author |
|
mfitzgerald Vetran
Joined: June 14 2006 Location: United States Posts: 142
|
Posted: July 13 2009 at 4:16pm | IP Logged
|
|
|
With the newer version of LS (6.0.0.16) there is now the ability to "query" the LSME for any expiration timestamp via function:
Code:
GetMediaEngineVersionInfo() |
|
|
The structure "TELPHONY_ENGINE_VERSION_INFO" stores this value in a char * (or according to the development document an ASCIIZ). Though I must admit, I am not familiar with ASCIIZ and google queries return little information on this. Was that a typo?
Regardless, I believe the basic gist is how can one convert the char * which is returned in that structure into a standard time_t (i.e. __int64).
I've located a few tutorials which deal with something like this, but none have proven viable/standard.
Code:
time_t stamp;
if (sizeof(time_t) == sizeof(long))
stamp = atoi(t);
else if (sizeof(time_t) == sizeof(long))
stamp = atol(t);
else if (sizeof(time_t) == sizeof(long long)) // not standard
stamp = atoll(t); // not viable
|
|
|
Maybe I'm just making this more difficult than it needs to be.
|
Back to Top |
|
|
mfitzgerald Vetran
Joined: June 14 2006 Location: United States Posts: 142
|
Posted: July 13 2009 at 4:40pm | IP Logged
|
|
|
FYI:
"t" above would be the char *.
And disregard the question regarding ASCIIZ.
Quote:
ASCIIZ refers to a method of terminating character strings using the ASCII character numbered zero (known as NULL or NUL). This is is the method used by C and C++, where the \0 special character is known as the NULL terminator. |
|
|
Guess I hadn't heard it termed in that manor.
|
Back to Top |
|
|
support Administrator
Joined: January 26 2005 Location: United States Posts: 1666
|
Posted: July 13 2009 at 6:42pm | IP Logged
|
|
|
Hi Fitz,
Wow… I must be showing my age when I use terms like ASCIIZ string. :-)
ASCIIZ just means a NULL (zero) terminated ASCII string – as you pointed out in your last post.
Using the pEngineeringReleaseTimeout pointer value:
This structure member is simply a pointer to a string.
If you are running a standard version of the VOIP media engine product, then the pEngineeringReleaseTimeout pointer will point to a zero length (empty) string.
If you are running an “engineering version” of the VOIP media engine product ()a time bombed version), then the pEngineeringReleaseTimeout pointer will point to an unsigned 32 bit time_t value that is represented as a numerical string.
You can convert this numerical string value to a time_t value (for example, using atol()) and then use the integer value type cast to a time_t value for use in any of the time_t format routines of the standard C library to obtain a “man readable” time out string.
If for any reason the compiled HTML Software Developer’s Reference (or the .NET manage code media engine docs) are not clear regarding how to use this new structure member, please make sure to post your thoughts. It is hard sometimes to make things clear... even though we try.
Here is a bit of C code that may help…
Code:
// Return to the caller the expire time of the media engine if it is a
// time bombed "engineering release".
//
BOOL GetEngineeringReleaseExpireTime(time_t *pExpireTime)
{
BOOL ret = FALSE;
BOOL status;
TELPHONY_ENGINE_VERSION_INFO VersionInfo;
status = GetMediaEngineVersionInfo(&VersionInfo);
if(!status)
{
// error obtaining the version info. should never happen.
//
// allow this proc to return zero.
//
*pExpireTime = 0;
}
else
{
// convert the time string value to a time_t value.
*pExpireTime = (time_t)atof(VersionInfo.pEngineeringReleaseTimeout);
// now you have the time_t expire value. you can now use any of the
// C standard library time format routines to convert this into a
// man readable display string or use the standar C library time()
// procedure to compare this converted value against the current
// system time.
//
// signal success.
ret = TRUE;
}
return(ret);
}
|
|
|
Please repost if I have missed something.
Thank you,
Randal
|
Back to Top |
|
|
mfitzgerald Vetran
Joined: June 14 2006 Location: United States Posts: 142
|
Posted: July 14 2009 at 8:56am | IP Logged
|
|
|
Thanks for the sample, I certainly was making this more complicated than necessary.
Two questions:
1)
Out of curiosity, why the decision to go with char * instead of time_t?
NOTE: time() returns time_t. According to the docs, time() is used to construct the char *.
2)
Can this function be called at anytime (i.e. before MicroCode)?
|
Back to Top |
|
|
support Administrator
Joined: January 26 2005 Location: United States Posts: 1666
|
Posted: July 15 2009 at 11:18am | IP Logged
|
|
|
Hello Fitz,
Item 1 - why the decision to go with char * instead of time_t:
Actually it has to do with using the media engine with languages other than C/C++ and .NET support for the media engine. A string representation for the expire timeout in a .NET or other language app is completely decoupled from any “time value typecast” that may be required when using this value in apps that are either .NET or some other language (Delphi for example).
Item 2 - Can this function be called at anytime (i.e. before MicroCode)?:
The sample code I posted (and the GetMediaEngineVersionInfo() API procedure) can be called anytime… even before the InitializeMediaEngine() and StartSipTelephony() API procs are called.
A note regarding the sample code I posted:
If the media engine is a non time bombed version (standard product), the GetEngineeringReleaseExpireTime() proc above will return TRUE and the value assigned to the pExpireTime pointer will be zero.
If the media engine is a time bombed version (engineering release), the GetEngineeringReleaseExpireTime() proc above will return TRUE and the value assigned to the pExpireTime pointer will be some value other than zero – the true expire time.
Randal
|
Back to Top |
|
|
mfitzgerald Vetran
Joined: June 14 2006 Location: United States Posts: 142
|
Posted: July 15 2009 at 11:28am | IP Logged
|
|
|
Thanks for your reply.
Because the function GetMediaEngineVersionInfo() returns BOOL, if it fails I intended to exit the application gracefully and thus the second question.
If we are going to exit anyway, then we wouldn't need to try to initialize LSME.
I've modified your example function quite a bit, now it also passes by ref a value calculating the number of days left till expiration, as well as the expiration time in time_t format.
All other aspects of the struct are logged for future debugging purposes.
One final question.
What happens if the LSME has expired? Before we initialize LSME, will the function still work, returning a date that has passed? If so, I'll need to modify my day count slightly and exit the application as there is no reason to continue if LS has already expired.
Thanks as always for your quick response.
|
Back to Top |
|
|
support Administrator
Joined: January 26 2005 Location: United States Posts: 1666
|
Posted: July 15 2009 at 11:49am | IP Logged
|
|
|
Hi Fitz,
From your previous post, I will assume your reference to the “GetMediaEngineVersionInfo() returns BOOL” was supposed to say “GetEngineeringReleaseExpireTime()returns BOOL”.
You >>>
… If we are going to exit anyway, then we wouldn't need to try to initialize LSME?
<<< Randal
Yes - correct.
You >>>
What happens if the LSME has expired?
<<< Randal
You can still call your version of the GetEngineeringReleaseExpireTime() as normal. You will still have access to the expire time via the GetMediaEngineVersionInfo() API procedure.
You >>>
Before we initialize LSME, will the function still work, returning a date that has passed?
<<< Randal
Yes.
Please repost if I have missed something.
Randal
|
Back to Top |
|
|