Ejemplo n.º 1
0
 public void Free(AprMemNode memnode)
 {
     CheckPtr();
     Debug.Write(String.Format("apr_allocator_free({0:X},{1:X})...", mAllocator.ToInt32(), (Int32)((IntPtr)memnode)));
     Apr.apr_allocator_free(mAllocator, memnode);
     Debug.WriteLine("Done");
 }
Ejemplo n.º 2
0
        public AprArray Append(AprPool pool, AprArray array)
        {
            IntPtr ptr;
            Type   arrType;

            CheckPtr();
            if (mEltsType != null && array.mEltsType != null && mEltsType != array.mEltsType)
            {
                throw new AprInvalidOperationException("Array type mismatch.");
            }

            if (mEltsType == null && array.mEltsType != null)
            {
                arrType = array.mEltsType;
            }
            arrType = mEltsType;

            Debug.Write(String.Format("apr_array_append({0},{1},{2})...", pool, array, this));
            ptr = Apr.apr_array_append(pool, (IntPtr)mArray, array);
            if (ptr == IntPtr.Zero)
            {
                throw new AprException("apr_array_append: Can't append an apr_array_header_t");
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(new AprArray(ptr, arrType));
        }
Ejemplo n.º 3
0
 public void Clear()
 {
     CheckPtr();
     Debug.Write(String.Format("apr_pool_clear({0:X})...", this));
     Apr.apr_pool_clear(mPool);
     Debug.WriteLine("Done");
 }
Ejemplo n.º 4
0
        public static AprFile Open(Std stream, AprPool pool)
        {
            IntPtr ptr = IntPtr.Zero;
            int    res = 0;

            switch (stream)
            {
            case Std.In:
                Debug.Write(String.Format("apr_file_open_stdin({0})...", pool));
                res = Apr.apr_file_open_stdin(out ptr, pool);
                break;

            case Std.Out:
                Debug.Write(String.Format("apr_file_open_stdout({0})...", pool));
                res = Apr.apr_file_open_stdout(out ptr, pool);
                break;

            case Std.Err:
                Debug.Write(String.Format("apr_file_open_stderr({0})...", pool));
                res = Apr.apr_file_open_stderr(out ptr, pool);
                break;
            }
            if (res != 0)
            {
                throw new AprException(res);
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 5
0
 public void This(out IntPtr key, out int size, out IntPtr value)
 {
     CheckPtr();
     Debug.Write(String.Format("apr_hash_this({0})...", this));
     Apr.apr_hash_this(mHashIndex, out key, out size, out value);
     Debug.WriteLine(String.Format("Done({0:X},{1},{2:X})", key.ToInt32(), size, value.ToInt32()));
 }
Ejemplo n.º 6
0
        public static string StrError(int apr_status)
        {
            StringBuilder buf = new StringBuilder(1024);

            Apr.apr_strerror(apr_status, buf, (uint)buf.Capacity);
            return(buf.ToString());
        }
Ejemplo n.º 7
0
 public void Destroy()
 {
     CheckPtr();
     Debug.Write(String.Format("apr_pool_destroy({0:X})...", this));
     Apr.apr_pool_destroy(mPool);
     Debug.WriteLine("Done");
     ClearPtr();
 }
Ejemplo n.º 8
0
 public void Destroy()
 {
     CheckPtr();
     Debug.Write(String.Format("apr_allocator_destroy({0:X})...", (Int32)mAllocator));
     Apr.apr_allocator_destroy(mAllocator);
     Debug.WriteLine("Done");
     ClearPtr();
 }
Ejemplo n.º 9
0
        public static AprHashIndex First(AprPool pool, AprHash h)
        {
            IntPtr ptr;

            Debug.Write(String.Format("apr_hash_first({0},{1})...", pool, h));
            ptr = Apr.apr_hash_first(pool, h);
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 10
0
        public void Next()
        {
            IntPtr ptr;

            CheckPtr();
            Debug.Write(String.Format("apr_hash_next({0})...", this));
            ptr = Apr.apr_hash_next(mHashIndex);
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));
            mHashIndex = ptr;
        }
Ejemplo n.º 11
0
        public bool IsEmpty()
        {
            bool isEmpty;

            CheckPtr();
            Debug.Write(String.Format("apr_is_empty_array({0})...", this));
            isEmpty = Apr.apr_is_empty_array(new IntPtr(mArray));
            Debug.WriteLine(String.Format("Done({0:X})", isEmpty));
            return(isEmpty);
        }
Ejemplo n.º 12
0
        public static string CTime(long value)
        {
            StringBuilder buf = new StringBuilder(APR_CTIME_LEN);
            int           res = Apr.apr_ctime(buf, value);

            if (res != 0)
            {
                throw new AprException(res);
            }
            return(buf.ToString());
        }
Ejemplo n.º 13
0
        public static string Rfc822Date(long value)
        {
            StringBuilder buf = new StringBuilder(APR_RFC822_DATE_LEN);
            int           res = Apr.apr_rfc822_date(buf, value);

            if (res != 0)
            {
                throw new AprException(res);
            }
            return(buf.ToString());
        }
Ejemplo n.º 14
0
        public IntPtr Pop()
        {
            IntPtr ptr;

            CheckPtr();
            Debug.Write(String.Format("apr_array_pop({0})...", this));
            ptr = Apr.apr_array_pop(new IntPtr(mArray));
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 15
0
        public void SetTimeTZ(long value, int tz)
        {
            Debug.Write(String.Format("apr_time_exp_tz({0:X},{1},{2})...", (new IntPtr(mTimeExp)).ToInt32(), value, tz));
            int res = Apr.apr_time_exp_tz(new IntPtr(mTimeExp), value, tz);

            if (res != 0)
            {
                throw new AprException(res);
            }
            Debug.WriteLine("Done");
        }
Ejemplo n.º 16
0
        public IntPtr Get(IntPtr key, int size)
        {
            IntPtr ptr;

            CheckPtr();
            Debug.Write(String.Format("apr_hash_get({0},{1:X},{2})...", this, key.ToInt32(), size));
            ptr = Apr.apr_hash_get(mHash, key, size);
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 17
0
        public void Close()
        {
            CheckPtr();
            Debug.Write(String.Format("apr_file_close({0})...", this));
            int res = Apr.apr_file_close(mFile);

            if (res != 0)
            {
                throw new AprException(res);
            }
            mFile = IntPtr.Zero;
        }
Ejemplo n.º 18
0
        public void Unlock()
        {
            CheckPtr();
            Debug.Write(String.Format("apr_thread_mutex_unlock({0:X})...", ((Int32)mThreadMutex)));
            int res = Apr.apr_thread_mutex_unlock(mThreadMutex);

            if (res != 0)
            {
                throw new AprException(res);
            }
            Debug.WriteLine("Done");
        }
Ejemplo n.º 19
0
        public static AprHash Make(AprPool pool)
        {
            IntPtr ptr;

            Debug.Write(String.Format("apr_hash_make({0})...", pool));
            ptr = Apr.apr_hash_make(pool);
            if (ptr == IntPtr.Zero)
            {
                throw new AprException("apr_hash_make: Can't create an apr_hash_t");
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 20
0
        public static AprArray Make(AprPool pool, int nElts, int eltSize)
        {
            IntPtr ptr;

            Debug.Write(String.Format("apr_array_make({0},{1},{2})...", pool, nElts, eltSize));
            ptr = Apr.apr_array_make(pool, nElts, eltSize);
            if (ptr == IntPtr.Zero)
            {
                throw new AprException("apr_array_make: Can't create an apr_array_header_t");
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 21
0
        public AprHash Overlay(AprPool pool, AprHash h)
        {
            IntPtr ptr;

            CheckPtr();
            Debug.Write(String.Format("apr_hash_overlay({0},{1},{2})...", pool, h, this));
            ptr = Apr.apr_hash_overlay(pool, h, mHash);
            if (ptr == IntPtr.Zero)
            {
                throw new AprException("apr_hash_overlay: Can't overlay an apr_hash_t");
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 22
0
        public static AprAllocator Create()
        {
            IntPtr ptr;

            Debug.Write("apr_allocator_create...");
            int res = Apr.apr_allocator_create(out ptr);

            if (res != 0)
            {
                throw new AprException(res);
            }
            Debug.WriteLine(String.Format("Done({0:X})", (Int32)ptr));

            return((AprAllocator)ptr);
        }
Ejemplo n.º 23
0
        public static AprFile Open(string fname, Flags flag, Perms perm, AprPool pool)
        {
            IntPtr ptr;

            Debug.Write(String.Format("apr_file_open({0},{1},{2},{3})...", fname, flag, perm, pool));
            int res = Apr.apr_file_open(out ptr, fname, (int)flag, (int)perm, pool);

            if (res != 0)
            {
                throw new AprException(res);
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 24
0
        public AprArray CopyHdr(AprPool pool)
        {
            IntPtr ptr;

            CheckPtr();
            Debug.Write(String.Format("apr_array_copy_hdr({0},{1})...", pool, this));
            ptr = Apr.apr_array_copy_hdr(pool, new IntPtr(mArray));
            if (ptr == IntPtr.Zero)
            {
                throw new AprException("apr_array_copy_hdr: Can't copy an apr_array_header_t");
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(new AprArray(ptr, mEltsType));
        }
Ejemplo n.º 25
0
        public string ToString(string format, int size)
        {
            StringBuilder str = new StringBuilder(size);
            uint          len;

            Debug.Write(String.Format("apr_strftime({0:X},{1})...", (new IntPtr(mTimeExp)).ToInt32(), format));
            int res = Apr.apr_strftime(str, out len, (uint)str.Capacity, format, new IntPtr(mTimeExp));

            if (res != 0)
            {
                throw new AprException(res);
            }
            Debug.WriteLine("Done");
            return(str.ToString());
        }
Ejemplo n.º 26
0
        public IntPtr Push()
        {
            IntPtr ptr;

            CheckPtr();
            Debug.Write(String.Format("apr_array_push({0})...", this));
            ptr = Apr.apr_array_push(new IntPtr(mArray));
            if (ptr == IntPtr.Zero)
            {
                throw new AprException("apr_array_push: Can't push an element");
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 27
0
        public static AprPool Create(AprPool pool, AprAllocator allocator)
        {
            IntPtr ptr;

            Debug.Write(String.Format("apr_pool_create_ex({0},{1})...", pool, allocator));
            int res = Apr.apr_pool_create_ex(out ptr, pool,
                                             IntPtr.Zero, allocator);

            if (res != 0)
            {
                throw new AprException(res);
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return(ptr);
        }
Ejemplo n.º 28
0
        public static AprThreadMutex Create(AprThreadMutexFlags flags,
                                            AprPool pool)
        {
            IntPtr ptr;

            Debug.Write(String.Format("apr_thread_mutex_create({0},{1})...", flags, pool));
            int res = Apr.apr_thread_mutex_create(out ptr, (uint)flags, pool);

            if (res != 0)
            {
                throw new AprException(res);
            }
            Debug.WriteLine(String.Format("Done({0:X})", ((Int32)ptr)));

            return((AprThreadMutex)ptr);
        }
Ejemplo n.º 29
0
        public void Cat(AprArray array)
        {
            CheckPtr();
            if (mEltsType != null && array.mEltsType != null && mEltsType != array.mEltsType)
            {
                throw new AprInvalidOperationException("Array types mismatch.");
            }

            if (mEltsType == null && array.mEltsType != null)
            {
                mEltsType = array.mEltsType;
            }

            Debug.WriteLine(String.Format("apr_array_cat({0},{1})", this, array));
            Apr.apr_array_cat((IntPtr)mArray, array);
        }
Ejemplo n.º 30
0
        public bool TryLock()
        {
            CheckPtr();
            Debug.Write(String.Format("apr_thread_mutex_trylock({0:X})...", ((Int32)mThreadMutex)));
            int res = Apr.apr_thread_mutex_trylock(mThreadMutex);

            if (res != 0)
            {
                if (res == 70025)
                {
                    Debug.WriteLine(String.Format("Fail({0})", res));
                    return(false);
                }
                throw new AprException(res);
            }
            Debug.WriteLine(String.Format("Done({0})", res));
            return(true);
        }