⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rvmegacoobjects.c

📁 h.248协议源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************
Filename:    rvmegacoobjects.c
Description: megaco objects
*******************************************************************************
                Copyright (c) 2000 RADVision Inc.
*******************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision Inc.
No part of this publication may be reproduced in any form whatsoever without
written prior approval by RADVision Inc.

RADVision Inc. reserves the right to revise this publication and make changes
without obligation to notify any person of such revisions or changes.
******************************************************************************/
#include "rvmegacoobjects.h"
#include "rvtime.h"
#include "rvdefalloc.h"
#include "rvalgo.h"
#include "rvstr.h"
#include <ctype.h>

static RvBool rvMegacoPackageItemLess(const RvMegacoPackageItem *a, const RvMegacoPackageItem *b);
static RvMegacoCommand *rvMegacoCommandConstruct(RvMegacoCommand *x, RvMegacoCommandType type, const RvMegacoTerminationId *id, RvAlloc *alloc);
static RvMegacoCommand *rvMegacoCommandConstructCopy(RvMegacoCommand *d, const RvMegacoCommand *s, RvAlloc *alloc);
void rvMegacoCommandDestruct(RvMegacoCommand *x);
static RvMegacoCommand *rvMegacoCommandCopy(RvMegacoCommand *d, const RvMegacoCommand *s);

#define rvNeverEqual(a, b) ((a)==(b))

#define RvMegacoPackageItemConstructCopy rvMegacoPackageItemConstructCopy
#define RvMegacoPackageItemDestruct rvMegacoPackageItemDestruct
#define RvMegacoPackageItemEqual rvMegacoPackageItemEqual
#define RvMegacoPackageItemLess rvMegacoPackageItemLess
#define RvMegacoParameterValueConstructCopy rvMegacoParameterValueConstructCopy
#define RvMegacoParameterValueDestruct rvMegacoParameterValueDestruct
#define RvMegacoDigitPositionConstructCopy rvMegacoDigitPositionConstructCopy
#define RvMegacoDigitPositionDestruct rvMegacoDigitPositionDestruct
#define RvMegacoDigitPositionEqual rvNeverEqual
#define RvMegacoDigitStringConstructCopy rvMegacoDigitStringConstructCopy
#define RvMegacoDigitStringDestruct rvMegacoDigitStringDestruct
#define RvMegacoDigitStringEqual rvNeverEqual
#define RvMegacoSignalConstructCopy rvMegacoSignalConstructCopy
#define RvMegacoSignalDestruct rvMegacoSignalDestruct
#define RvMegacoSignalEqual rvNeverEqual
#define RvMegacoSignalListConstructCopy rvMegacoSignalListConstructCopy
#define RvMegacoSignalListDestruct rvMegacoSignalListDestruct
#define RvMegacoSignalListEqual rvNeverEqual
#define RvMegacoObservedEventConstructCopy rvMegacoObservedEventConstructCopy
#define RvMegacoObservedEventDestruct rvMegacoObservedEventDestruct
#define RvMegacoObservedEventEqual rvNeverEqual
#define RvMegacoRequestedEventConstructCopy rvMegacoRequestedEventConstructCopy
#define RvMegacoRequestedEventDestruct rvMegacoRequestedEventDestruct
#define RvMegacoRequestedEventEqual rvNeverEqual
#define RvMegacoStreamDescriptorConstructCopy rvMegacoStreamDescriptorConstructCopy
#define RvMegacoStreamDescriptorDestruct rvMegacoStreamDescriptorDestruct
#define RvMegacoStreamDescriptorEqual rvNeverEqual
#define RvMegacoTerminationIdConstructCopy rvMegacoTerminationIdConstructCopy
#define RvMegacoTerminationIdDestruct rvMegacoTerminationIdDestruct
#define RvMegacoTerminationIdEqual rvMegacoTerminationIdEqual
#define RvMegacoEventConstructCopy rvMegacoEventConstructCopy
#define RvMegacoEventDestruct rvMegacoEventDestruct
#define RvMegacoEventEqual rvNeverEqual
#define RvStringAndIntConstructCopy rvStringAndIntConstructCopy
#define RvStringAndIntDestruct rvStringAndIntDestruct
#define RvStringAndIntEqual rvStringAndIntEqual
#define RvMegacoCommandConstructCopy rvMegacoCommandConstructCopy
#define RvMegacoCommandDestruct rvMegacoCommandDestruct
#define RvMegacoCommandEqual rvNeverEqual
#define RvMegacoActionConstructCopy rvMegacoActionConstructCopy
#define RvMegacoActionDestruct rvMegacoActionDestruct
#define RvMegacoActionEqual rvNeverEqual
#define RvMegacoCommandReplyConstructCopy rvMegacoCommandReplyConstructCopy
#define RvMegacoCommandReplyDestruct rvMegacoCommandReplyDestruct
#define RvMegacoCommandReplyEqual rvNeverEqual
#define RvMegacoActionReplyConstructCopy rvMegacoActionReplyConstructCopy
#define RvMegacoActionReplyDestruct rvMegacoActionReplyDestruct
#define RvMegacoActionReplyEqual rvNeverEqual
#define RvMegacoTransactionIdConstructCopy RvUintConstructCopy
#define RvMegacoTransactionIdDestruct RvUintDestruct
#define RvMegacoTransactionIdCopy RvUintCopy
#define RvMegacoTransactionIdEqual RvUintEqual
#define RvMegacoTransactionIdGetAllocator RvUintGetAllocator
#define RvMegacoTransactionIdSwap RvUintSwap
#define RvMegacoTransactionIdPairConstructCopy rvPairConstructCopy(RvMegacoTransactionId, RvMegacoTransactionId)
#define RvMegacoTransactionIdPairDestruct rvPairDestruct(RvMegacoTransactionId, RvMegacoTransactionId)
#define RvMegacoTransactionIdPairEqual rvPairEqual(RvMegacoTransactionId, RvMegacoTransactionId)

rvDefineMap(RvMegacoPackageItem, RvMegacoParameterValue)
rvDefineVector(RvMegacoDigitPosition)
rvDefineVector(RvMegacoDigitString)
rvDefineVector(RvMegacoSignal)
rvDefineVector(RvMegacoSignalList)
rvDefineVector(RvMegacoObservedEvent)
rvDefineVector(RvMegacoRequestedEvent)
rvDefineVector(RvMegacoStreamDescriptor)
rvDefineVector(RvMegacoTerminationId)
rvDefineVector(RvMegacoEvent)
rvDefineVector(RvStringAndInt)
rvDefineVector(RvMegacoCommand)
rvDefineVector(RvMegacoAction)
rvDefineVector(RvMegacoCommandReply)
rvDefineVector(RvMegacoActionReply)
rvDefineVector(RvUint)
rvDefinePair(RvMegacoTransactionId, RvMegacoTransactionId)
rvDefineList(RvMegacoTransactionIdPair)


/*$
{function:
	{name: rvTimeStampConstruct}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a time stamp object.}
	}
	{proto: RvTimeStamp *rvTimeStampConstruct(RvTimeStamp *x, unsigned int year, unsigned int month, unsigned int day,
		unsigned int hour, unsigned int minute, unsigned int hundredthsOfSeconds);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
		{param: {n:year} {d:The year.}}
		{param: {n:month} {d:The month.}}
		{param: {n:day} {d:The day.}}
		{param: {n:hour} {d:The hour.}}
		{param: {n:minute} {d:The minute.}}
		{param: {n:hundredthsOfSeconds} {d:The hundredths of seconds.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvTimeStamp *rvTimeStampConstruct(RvTimeStamp *x, unsigned int year, unsigned int month, unsigned int day, 
		unsigned int hour, unsigned int minute, unsigned int hundredthsOfSeconds)
{
	x->year = year;
	x->month = month;
	x->day = day;
	x->hour = hour;
	x->minute = minute;
	x->hsec = hundredthsOfSeconds;
	return x;
}


/*$
{function:
	{name: rvTimeStampConstructCurrentTime}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a time stamp object equal to the current time.}
	}
	{proto: RvTimeStamp *rvTimeStampConstructCurrentTime(RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvTimeStamp *rvTimeStampConstructCurrentTime(RvTimeStamp *x)
{
	RvTm tm;
	RvTimespec timespec;
	
	rvTimeUTC(rvTimeGetEpochTime(&timespec), &tm);
	x->year = tm.tm_year + 1900;
	x->month = tm.tm_mon + 1;
	x->day = tm.tm_mday;
	x->hour = tm.tm_hour;
	x->minute = tm.tm_min;
	x->hsec = tm.tm_sec * 100 + rvTimespecNsecs(&timespec) / 10000000;

	return x;
}


/*$
{function:
	{name: rvTimeStampConstructBlank}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs a blank time stamp object.}
	}
	{proto: RvTimeStamp *rvTimeStampConstructBlank(RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvTimeStamp *rvTimeStampConstructBlank(RvTimeStamp *x)
{
	x->year = 0;
	return x;
}


/*$
{function:
	{name: rvTimeStampEqual}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Compares two time stamp objects for equality.}
	}
	{proto: RvBool rvTimeStampEqual(const RvTimeStamp *a, const RvTimeStamp *b);}
	{params:
		{param: {n:a} {d:The first time stamp object.}}
		{param: {n:b} {d:The second time stamp object.}}
	}
	{returns: rvTrue if the objects are equal, rvFalse if not.}
}
$*/
RvBool rvTimeStampEqual(const RvTimeStamp *a, const RvTimeStamp *b)
{
	return a->hsec == b->hsec &&
		a->minute == b->minute &&
		a->hour == b->hour &&
		a->day == b->day &&
		a->month == b->month &&
		a->year == b->year;
}


/*$
{function:
	{name: rvTimeStampGetYear}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the year of the time stamp object.}
	}
	{proto: unsigned int rvTimeStampGetYear(const RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: The year.}
}
$*/
unsigned int rvTimeStampGetYear(const RvTimeStamp *x)
{
	return x->year;
}


/*$
{function:
	{name: rvTimeStampGetMonth}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the month of the time stamp object.}
	}
	{proto: unsigned int rvTimeStampGetMonth(const RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: The month.}
}
$*/
unsigned int rvTimeStampGetMonth(const RvTimeStamp *x)
{
	return x->month;
}


/*$
{function:
	{name: rvTimeStampGetDay}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the day of the time stamp object.}
	}
	{proto: unsigned int rvTimeStampGetDay(const RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: The day.}
}
$*/
unsigned int rvTimeStampGetDay(const RvTimeStamp *x)
{
	return x->day;
}


/*$
{function:
	{name: rvTimeStampGetHour}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the hour of the time stamp object.}
	}
	{proto: unsigned int rvTimeStampGetHour(const RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: The hour.}
}
$*/
unsigned int rvTimeStampGetHour(const RvTimeStamp *x)
{
	return x->hour;
}


/*$
{function:
	{name: rvTimeStampGetMinute}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the minute of the time stamp object.}
	}
	{proto: unsigned int rvTimeStampGetMinute(const RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: The minute.}
}
$*/
unsigned int rvTimeStampGetMinute(const RvTimeStamp *x)
{
	return x->minute;
}


/*$
{function:
	{name: rvTimeStampGetSeconds}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the seconds of the time stamp object.}
	}
	{proto: double rvTimeStampGetSeconds(const RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: The seconds.}
}
$*/
double rvTimeStampGetSeconds(const RvTimeStamp *x)
{
	return x->hsec * 0.01;
}


/*$
{function:
	{name: rvTimeStampGetHsecs}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Gets the hundredths of seconds of the time stamp object.}
	}
	{proto: unsigned int rvTimeStampGetHsecs(const RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: The hundredths of seconds.}
}
$*/
unsigned int rvTimeStampGetHsecs(const RvTimeStamp *x)
{
	return x->hsec;
}


/*$
{function:
	{name: rvTimeStampIsSet}
	{class: RvTimeStamp}
	{include: rvmegacoobjects.h}
	{description:
		{p: Checks whether the time stamp object is set.}
	}
	{proto: RvBool rvTimeStampIsSet(const RvTimeStamp *x);}
	{params:
		{param: {n:x} {d:The time stamp object.}}
	}
	{returns: rvTrue if the object is set, rvFalse if not.}
}
$*/
RvBool rvTimeStampIsSet(const RvTimeStamp *x)
{
	return x->year != 0;
}


/*$
{function:
	{name: rvMegacoEntityAddressConstruct}
	{class: RvMegacoEntityAddress}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs an entity address object from an IP address or domain name.}
	}
	{proto: RvMegacoEntityAddress *rvMegacoEntityAddressConstruct(RvMegacoEntityAddress *x, const char *dnsOrIp, RvInetPort port);}
	{params:
		{param: {n:x} {d:The entity address object.}}
		{param: {n:dnsOrIp} {d:The address.}}
		{param: {n:port} {d:The port number.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoEntityAddress *rvMegacoEntityAddressConstruct(RvMegacoEntityAddress *x, const char *dnsOrIp, RvInetPort port)
{
	return rvMegacoEntityAddressConstructA(x, dnsOrIp, port, &rvDefaultAlloc);
}


/*$
{function:
	{name: rvMegacoEntityAddressConstructA}
	{class: RvMegacoEntityAddress}
	{include: rvmegacoobjects.h}
	{description:
		{p: Constructs an entity address object from an IP address or domain name.}
	}
	{proto: RvMegacoEntityAddress *rvMegacoEntityAddressConstructA(RvMegacoEntityAddress *x, const char *dnsOrIp, RvInetPort port, RvAlloc *alloc);}
	{params:
		{param: {n:x} {d:The entity address object.}}
		{param: {n:dnsOrIp} {d:The address.}}
		{param: {n:port} {d:The port number.}}
		{param: {n:alloc} {d:The allocator to use.}}
	}
	{returns: A pointer to the constructed object, or NULL if construction failed.}
}
$*/
RvMegacoEntityAddress *rvMegacoEntityAddressConstructA(RvMegacoEntityAddress *x, const char *dnsOrIp, RvInetPort port, RvAlloc *alloc)
{
	rvStringConstruct(&x->address, dnsOrIp, alloc);
	x->port = port;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -