private static ErrorCode TryParseCore(string str, out CallIdHeader header) { osip_call_id_t *native = null; var strPtr = Marshal.StringToHGlobalAnsi(str); try { ErrorCode errorCode = NativeMethods.osip_call_id_init(&native); if (!errorCode.EnsureSuccess()) { header = null; return(errorCode); } errorCode = NativeMethods.osip_call_id_parse(native, strPtr); if (!errorCode.EnsureSuccess()) { header = null; return(errorCode); } header = FromNative(native); return(errorCode); } finally { NativeMethods.osip_call_id_free(native); Marshal.FreeHGlobal(strPtr); } }
internal static CallIdHeader FromNative(osip_call_id_t *native) { var header = new CallIdHeader { Number = Marshal.PtrToStringAnsi(native->number), Host = Marshal.PtrToStringAnsi(native->host) }; return(header); }
public CallIdHeader DeepClone() { osip_call_id_t *native = ToNative(); try { return(FromNative(native)); } finally { NativeMethods.osip_call_id_free(native); } }
public override string ToString() { IntPtr ptr = IntPtr.Zero; osip_call_id_t *native = ToNative(); try { NativeMethods.osip_call_id_to_str(native, &ptr).ThrowOnError(); return(Marshal.PtrToStringAnsi(ptr)); } finally { NativeMethods.osip_call_id_free(native); Marshal.FreeHGlobal(ptr); } }
public static extern ErrorCode osip_call_id_clone(osip_call_id_t *header, osip_call_id_t **dest);
public static extern ErrorCode osip_call_id_to_str(osip_call_id_t *header, IntPtr *dest);
public static extern ErrorCode osip_call_id_parse(osip_call_id_t *header, IntPtr hvalue);
public static extern void osip_call_id_free(osip_call_id_t *header);