| 1 |
// project created on 4/28/04 at 9:26 a |
|---|
| 2 |
using System; |
|---|
| 3 |
using Softec.AprSharp; |
|---|
| 4 |
using System.Diagnostics; |
|---|
| 5 |
using System.Runtime.InteropServices; |
|---|
| 6 |
|
|---|
| 7 |
public class MainClass |
|---|
| 8 |
{ |
|---|
| 9 |
public static void Main(string[] args) |
|---|
| 10 |
{ |
|---|
| 11 |
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); |
|---|
| 12 |
Console.WriteLine("Hello World!"); |
|---|
| 13 |
|
|---|
| 14 |
AprAllocator a = AprAllocator.Create(); |
|---|
| 15 |
AprPool p = AprPool.Create(a); |
|---|
| 16 |
Debug.WriteLine("apr_pool_allocator_get("+p+")=" + p.Allocator); |
|---|
| 17 |
Debug.WriteLine("apr_allocator_owner_get("+a+")=" + a.Owner); |
|---|
| 18 |
a.Owner = p; |
|---|
| 19 |
Debug.WriteLine("apr_allocator_owner_get("+a+")=" + a.Owner); |
|---|
| 20 |
AprPool.Create(p).Destroy(); |
|---|
| 21 |
AprPool.Create(p,a).Destroy(); |
|---|
| 22 |
AprThreadMutex l=AprThreadMutex.Create(p); |
|---|
| 23 |
Debug.WriteLine("apr_thread_mutex_pool_get("+l+")=" + l.Pool); |
|---|
| 24 |
l.Lock(); |
|---|
| 25 |
Debug.WriteLine("apr_thread_mutex_trylock("+l+")=" + l.TryLock()); |
|---|
| 26 |
l.Unlock(); |
|---|
| 27 |
Debug.WriteLine("apr_thread_mutex_trylock("+l+")=" + l.TryLock()); |
|---|
| 28 |
l.Unlock(); |
|---|
| 29 |
Debug.WriteLine("apr_allocator_mutex_get("+a+")=" + a.Mutex); |
|---|
| 30 |
a.Mutex=l; |
|---|
| 31 |
Debug.WriteLine("apr_allocator_mutex_get("+a+")=" + a.Mutex); |
|---|
| 32 |
a.Free(a.Alloc(128)); |
|---|
| 33 |
|
|---|
| 34 |
GCHandle mt; |
|---|
| 35 |
AprTimeExp t = AprTimeExp.ManagedAlloc(out mt); |
|---|
| 36 |
long now = AprTimeExp.Now(); |
|---|
| 37 |
Debug.WriteLine("apr_time_now()="+now); |
|---|
| 38 |
t.Time = now; |
|---|
| 39 |
Debug.WriteLine("apr_rfc822_date=" + AprTimeExp.Rfc822Date(now)); |
|---|
| 40 |
Debug.WriteLine("apr_ctime=" + AprTimeExp.CTime(now)); |
|---|
| 41 |
Debug.WriteLine("apr_time_exp_____get=" + t.Time + DumpAprTimeExp(t)); |
|---|
| 42 |
Debug.WriteLine("apr_time_exp_gmt_get=" + t.GmtTime + DumpAprTimeExp(t)); |
|---|
| 43 |
Debug.WriteLine("apr_strftime=" + t.ToString("%Y%m%d%H%M%S")); |
|---|
| 44 |
t.Time = t.Time; |
|---|
| 45 |
Debug.WriteLine("apr_time_exp_____get=" + t.Time + DumpAprTimeExp(t)); |
|---|
| 46 |
Debug.WriteLine("apr_time_exp_gmt_get=" + t.GmtTime + DumpAprTimeExp(t)); |
|---|
| 47 |
Debug.WriteLine("apr_strftime=" + t.ToString("%Y%m%d%H%M%S")); |
|---|
| 48 |
t.GmtTime = now; |
|---|
| 49 |
Debug.WriteLine("apr_time_exp_____get=" + t.Time + DumpAprTimeExp(t)); |
|---|
| 50 |
Debug.WriteLine("apr_time_exp_gmt_get=" + t.GmtTime + DumpAprTimeExp(t)); |
|---|
| 51 |
Debug.WriteLine("apr_strftime=" + t.ToString("%Y%m%d%H%M%S")); |
|---|
| 52 |
t.GmtTime = t.GmtTime; |
|---|
| 53 |
Debug.WriteLine("apr_time_exp_____get=" + t.Time + DumpAprTimeExp(t)); |
|---|
| 54 |
Debug.WriteLine("apr_time_exp_gmt_get=" + t.GmtTime + DumpAprTimeExp(t)); |
|---|
| 55 |
Debug.WriteLine("apr_strftime=" + t.ToString("%Y%m%d%H%M%S")); |
|---|
| 56 |
t.SetTimeTZ(now, 7200); |
|---|
| 57 |
Debug.WriteLine("apr_time_exp_____get=" + t.Time + DumpAprTimeExp(t)); |
|---|
| 58 |
Debug.WriteLine("apr_time_exp_gmt_get=" + t.GmtTime + DumpAprTimeExp(t)); |
|---|
| 59 |
Debug.WriteLine("apr_strftime=" + t.ToString("%Y%m%d%H%M%S")); |
|---|
| 60 |
mt.Free(); |
|---|
| 61 |
p.Destroy(); |
|---|
| 62 |
|
|---|
| 63 |
/* |
|---|
| 64 |
a = AprAllocator.Create(); |
|---|
| 65 |
AprMemNode m = a.Alloc(16384); |
|---|
| 66 |
PrintMemNode("m", m, true); |
|---|
| 67 |
AprMemNode m1 = a.Alloc(32767); |
|---|
| 68 |
PrintMemNode("m", m, true); |
|---|
| 69 |
PrintMemNode("m1", m1, true); |
|---|
| 70 |
a.Free(m1); |
|---|
| 71 |
PrintMemNode("m", m, true); |
|---|
| 72 |
a.Destroy(); |
|---|
| 73 |
*/ |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
public unsafe static void PrintMemNode(string name, AprMemNode m, bool r) |
|---|
| 77 |
{ |
|---|
| 78 |
if (name != null) Debug.WriteLine("Dump "+name+"="+m.ToString()); |
|---|
| 79 |
Debug.Indent(); |
|---|
| 80 |
Debug.WriteLine("m.Next=" + m.Next.ToString()); |
|---|
| 81 |
if (!m.Next.IsNull() && r) PrintMemNode(name, m.Next, false); |
|---|
| 82 |
Debug.WriteLine("m.NativeRef=" + ((Int32)(m.NativeRef)).ToString("X")); |
|---|
| 83 |
//Debug.WriteLine("m.Ref=" + m.Ref.ToString()); |
|---|
| 84 |
//if (!m.Ref.IsNull() && r) PrintMemNode(name, m.Ref, false); |
|---|
| 85 |
Debug.WriteLine("m.Index=" + m.Index); |
|---|
| 86 |
Debug.WriteLine("m.FreeIndex=" + m.FreeIndex); |
|---|
| 87 |
Debug.WriteLine("m.FirstAvail=" + ((Int32)(m.FirstAvail)).ToString("X")); |
|---|
| 88 |
Debug.WriteLine("m.EndP=" + ((Int32)(m.EndP)).ToString("X")); |
|---|
| 89 |
Debug.Unindent(); |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
public static string DumpAprTimeExp(AprTimeExp t) |
|---|
| 93 |
{ |
|---|
| 94 |
return("{"+t.Day+"/"+t.Month+"/"+t.Year+" "+t.Hours+":"+t.Minutes+":"+t.Seconds+"."+t.MicroSeconds+" off"+t.TimeZone+" W"+t.WeekDay+" Y"+t.YearDay+"}"); |
|---|
| 95 |
} |
|---|
| 96 |
} |
|---|