Exemplo n.º 1
0
        public void Duplicate()
        {
            AprPool p = AprPool.Create();
            Assert.IsFalse(p.IsNull,"#A01");

            AprString s = new AprString();
            Assert.IsTrue(s.IsNull,"#A02");

            s = AprString.Duplicate(p,"This is a test of string duplication");
            Assert.IsFalse(s.IsNull,"#A03");
            Assert.AreEqual("This is a test of string duplication",s.ToString(),"#A04");

            AprString s2 = AprString.Duplicate(p,s);
            Assert.IsFalse(s2.IsNull,"#A05");
            Assert.AreEqual("This is a test of string duplication",s2.ToString(),"#A06");

            s2 = AprString.Duplicate(p,s,14);
            Assert.IsFalse(s2.IsNull,"#A07");
            Assert.AreEqual("This is a test",s2.ToString(),"#A08");

            s = AprString.Duplicate(p,"This is a test of string duplication",14);
            Assert.IsFalse(s.IsNull,"#A09");
            Assert.AreEqual("This is a test",s.ToString(),"#A10");

               	p.Destroy();
            Assert.IsTrue(p.IsNull,"#A11");
        }
Exemplo n.º 2
0
        public void Set(string key, string value)
        {
            AprString aprKey   = new AprString(key, Pool);
            AprString aprValue = new AprString(value, Pool);

            Set((IntPtr)aprKey, -1, (IntPtr)aprValue);
        }
Exemplo n.º 3
0
        public SvnError GetCommitLogCallback(out AprString logMessage, out SvnPath tmpFile,
							 		   	  	 AprArray commitItems, IntPtr baton,
									      	 AprPool pool)
        {
            if (!commitItems.IsNull)
            {
                foreach (SvnClientCommitItem item in commitItems)
                {
                    Console.WriteLine("C1: {1} ({2}) r{3}",
                        item.Path, item.Kind, item.Revision);
                    Console.WriteLine("C2: {1} -> {2}",
                        item.Url,
                        item.CopyFromUrl);
                }
                Console.WriteLine();
            }

            Console.Write("Enter log message: ");
            logMessage = new AprString(Console.ReadLine(), pool);
            tmpFile = new SvnPath(pool);

            return(SvnError.NoError);
        }
Exemplo n.º 4
0
        public IntPtr GetParameter(Param param)
        {
            CheckPtr();
            if( mParamName == null )
            {
                mParamName = new IntPtr[ParamName.Length];
                for(int i=0; i<ParamName.Length; i++)
                    mParamName[i] = IntPtr.Zero;
            }

               		if( mParamName[(int)param] == IntPtr.Zero )
               			mParamName[(int)param] = new AprString(ParamName[(int)param],mPool);

            IntPtr ptr;
            Debug.Write(String.Format("svn_auth_get_parameter({0},{1:X})...",this,mParamName[(int)param].ToInt32()));
            ptr = Svn.svn_auth_get_parameter(mAuthBaton, mParamName[(int)param]);
            Debug.WriteLine(String.Format("Done({0:X})",ptr.ToInt32()));
            return(ptr);
        }
Exemplo n.º 5
0
        public SvnError SslServerTrustAuth(out SvnAuthCredSslServerTrust cred, 
						       			   IntPtr baton, AprString realm, 
										   SvnAuthCredSslServerTrust.CertFailures failures, 
										   SvnAuthSslServerCertInfo certInfo, 
										   bool maySave, IntPtr pool)
        {
            Console.WriteLine("Ssl Server Trust Prompt:");
            Console.WriteLine("------------------------");
            Console.WriteLine("");

            Console.WriteLine("Error validating server certificate for '{0}':", realm);
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.UnknownCA) > 0)
                Console.WriteLine(" - The certificate is not issued by a trusted authority");
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.CNMismatch) > 0)
                Console.WriteLine(" - The certificate hostname does not match");
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.NotYetValid) > 0)
                Console.WriteLine(" - The certificate is not yet valid");
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.Expired) > 0)
                Console.WriteLine(" - The certificate has expired");
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.Other) > 0)
                Console.WriteLine(" - The certificate has an unknown error");

            Console.WriteLine("Certificate informations:");
            Console.WriteLine("\tHostName:    " + certInfo.Hostname);
            Console.WriteLine("\tIssuer:      " + certInfo.IssuerDName);
            Console.WriteLine("\tValid From:  " + certInfo.ValidFrom);
            Console.WriteLine("\tValid Until: " + certInfo.ValidUntil);
            Console.WriteLine("\tFingerprint: " + certInfo.Fingerprint);

            cred = SvnAuthCredSslServerTrust.Alloc(pool);
            bool valid = false;
            while (!valid)
            {
                if (maySave)
                    Console.WriteLine("(R)eject, accept (t)emporarily or accept (p)ermanently? ");
                else
                    Console.WriteLine("(R)eject or accept (t)emporarily? ");

                string line = Console.ReadLine();
                if (line.Length > 0)
                {
                    char choice = line.ToLower()[0];
                    if (choice == 'r')
                    {
                        cred.AcceptedFailures = 0;
                        cred.MaySave=false;
                        valid = true;
                    }
                    else if (choice == 't')
                    {
                        cred.AcceptedFailures = failures;
                        cred.MaySave=false;
                        valid = true;
                    }
                    else if (choice == 'p')
                    {
                        cred.AcceptedFailures = failures;
                        cred.MaySave=true;
                        valid = true;
                    }
                }
            }
            return(SvnError.NoError);
        }
Exemplo n.º 6
0
        public void NotifyCallback(IntPtr baton, SvnPath Path,  
	        	 	 	           SvnWcNotify.Action action, Svn.NodeKind kind,
	        			 		   AprString mimeType, SvnWcNotify.State contentState,
	        			 		   SvnWcNotify.State propState, int revNum)
        {
            switch(action)
            {
                case SvnWcNotify.Action.Add:
                    if (!mimeType.IsNull && !mimeType.ToString().StartsWith("text/"))
                        Console.WriteLine("A  (bin)  {0}", Path);
                    else
                        Console.WriteLine("A         {0}", Path);
                    mChanged = true;
                    break;

                case SvnWcNotify.Action.BlameRevision:
                    break;

                case SvnWcNotify.Action.CommitAdded:
                    if (!mimeType.IsNull && !mimeType.ToString().StartsWith("text/"))
                        Console.WriteLine("Adding  (bin)  {0}", Path);
                    else
                        Console.WriteLine("Adding         {0}", Path);
                    break;

                case SvnWcNotify.Action.CommitDeleted:
                        Console.WriteLine("Deleting       {0}", Path);
                    break;

                case SvnWcNotify.Action.CommitModified:
                    Console.WriteLine("Sending        {0}", Path);
                    break;

                case SvnWcNotify.Action.CommitReplaced:
                        Console.WriteLine("Replacing      {0}", Path);
                    break;

                case SvnWcNotify.Action.Copy:
                    break;

                case SvnWcNotify.Action.Delete:
                    Console.WriteLine("D         {0}", Path);
                    mChanged = true;
                    break;

                case SvnWcNotify.Action.FailedRevert:
                    Console.WriteLine("Failed to revert '{0}' -- try updating instead.", Path);
                    break;

                case SvnWcNotify.Action.PostfixTxdelta:
                    if( !mTxDelta )
                    {
                        Console.Write("Transmitting file data ");
                        mTxDelta = true;
                    }
                    Console.Write(".");
                    break;

                case SvnWcNotify.Action.Resolved:
                    Console.WriteLine("Resolved conflicted state of '{0}'", Path);
                    break;

                case SvnWcNotify.Action.Restore:
                    Console.WriteLine("Restored '{0}'", Path);
                    break;

                case SvnWcNotify.Action.Revert:
                    Console.WriteLine("Reverted '{0}'", Path);
                    break;

                case SvnWcNotify.Action.Skip:
                    if (contentState == SvnWcNotify.State.Missing)
                        Console.WriteLine("Skipped missing target: '{0}'", Path);
              				else
                        Console.WriteLine("Skipped '{0}'", Path);
                    break;

                case SvnWcNotify.Action.StatusCompleted:
                    if( revNum >= 0 )
                        Console.WriteLine("Status against revision: {0}", revNum);
                    break;

                case SvnWcNotify.Action.StatusExternal:
                    Console.WriteLine("\nPerforming status on external item at '{0}'", Path);
                    break;

                case SvnWcNotify.Action.UpdateAdd:
                    Console.WriteLine("A {0}", Path);
                    mChanged = true;
                    break;

                case SvnWcNotify.Action.UpdateCompleted:
                    if( revNum >= 0 )
              		{
                        if( mSubCmd.LongName == "export" )
                            Console.WriteLine("Exported {0}revision {1}.",
                                                (mInExternal) ? "external at " : "",
                                                revNum);
                        else if( mSubCmd.LongName == "checkout" )
                            Console.WriteLine("Checked out {0}revision {1}.",
                                                (mInExternal) ? "external at " : "",
                                                revNum);
                        else
                        {
                            if( mChanged )
                      			Console.WriteLine("Updated {0}to revision {1}.",
                                                    (mInExternal) ? "external at " : "",
                                                    revNum);
                            else
                      			Console.WriteLine("{0}t revision {1}.",
                                                    (mInExternal) ? "External a" : "A",
                                                    revNum);
                        }
                    }
                    else  /* no revision */
                    {
                        if( mSubCmd.LongName == "export" )
                  			Console.WriteLine("{0}xport complete.",
                                                (mInExternal) ? "External e" : "E");
                        else if( mSubCmd.LongName == "checkout" )
                  			Console.WriteLine("{0}heckout complete.\n",
                                                (mInExternal) ? "External c" : "C");
                        else
                  			Console.WriteLine("{0}pdate complete.\n",
                                                (mInExternal) ? "External u" : "U");
                    }
                    if( mInExternal )
                        Console.WriteLine();
                    mInExternal = false;
                    mChanged = false;
                    break;

                case SvnWcNotify.Action.UpdateDelete:
                    Console.WriteLine("D {0}", Path);
                    mChanged = true;
                    break;

                case SvnWcNotify.Action.UpdateExternal:
                    Console.WriteLine("\nFetching external item into '{0}'", Path);
                    mInExternal = true;
                    break;

                case SvnWcNotify.Action.UpdateUpdate:
                    string s1 = " ";
                    string s2 = " ";
                    if (! ((kind == Svn.NodeKind.Dir)
               				&& ((propState == SvnWcNotify.State.Inapplicable)
                   			 || (propState == SvnWcNotify.State.Unknown)
                             || (propState == SvnWcNotify.State.Unchanged))))
                    {
                        mChanged = true;
                        if (kind == Svn.NodeKind.File)
                        {
                            if (contentState == SvnWcNotify.State.Conflicted)
                                s1 = "C";
                            else if (contentState == SvnWcNotify.State.Merged)
                                s1 = "G";
                            else if (contentState == SvnWcNotify.State.Changed)
                                s1 = "U";
              			}

                        if (propState == SvnWcNotify.State.Conflicted)
                            s2 = "C";
                        else if (propState == SvnWcNotify.State.Merged)
                            s2 = "G";
                        else if (propState == SvnWcNotify.State.Changed)
                            s2 = "U";

                        if (! ((contentState == SvnWcNotify.State.Unchanged
                                || contentState == SvnWcNotify.State.Unknown)
                            && (propState == SvnWcNotify.State.Unchanged
                                || propState == SvnWcNotify.State.Unknown)))
                            Console.WriteLine("{0}{1} {2}", s1, s2, Path);
                    }
              			break;
            }
        }
Exemplo n.º 7
0
 public override string ToString()
 {
     if( IsNull )
         return("[svn_data:NULL]");
     else
     {
         int len = new AprString(mString).Length;
         if(len == 0)
             return("");
         byte[] str = new byte[len];
         Marshal.Copy(mString,str,0,len);
         return(Encoder.GetString(str));
     }
 }
Exemplo n.º 8
0
 public string GetAsString(AprString key)
 {
     return(GetAsString((IntPtr)key, -1));
 }
Exemplo n.º 9
0
 public void Set(AprString key, IntPtr value)
 {
     Set((IntPtr)key, -1, value);
 }
Exemplo n.º 10
0
 public void Set(string key, IntPtr value)
 {
     AprString aprKey = new AprString(key, Pool);
     Set((IntPtr)aprKey, -1, value);
 }
Exemplo n.º 11
0
 public void Set(string key, string value)
 {
     AprString aprKey = new AprString(key, Pool);
     AprString aprValue = new AprString(value, Pool);
     Set((IntPtr)aprKey, -1, (IntPtr)aprValue);
 }
Exemplo n.º 12
0
 public string GetAsString(AprString key)
 {
     return(GetAsString((IntPtr)key,-1));
 }
Exemplo n.º 13
0
 public string GetAsString(string key)
 {
     AprString aprKey = new AprString(key, Pool);
     return(GetAsString((IntPtr)aprKey,-1));
 }
Exemplo n.º 14
0
 public IntPtr Get(AprString key)
 {
     return(Get((IntPtr)key,-1));
 }
Exemplo n.º 15
0
 public IntPtr Get(string key)
 {
     AprString aprKey = new AprString(key, Pool);
     return(Get((IntPtr)aprKey,-1));
 }
Exemplo n.º 16
0
 public static SvnString Create(AprString str, uint size, AprPool pool)
 {
     return(new SvnString(str,size,pool));
 }
Exemplo n.º 17
0
 public void Set(AprString key, IntPtr value)
 {
     Set((IntPtr)key, -1, value);
 }
Exemplo n.º 18
0
 public SvnString(AprString str, int size, AprPool pool)
 {
     mString = (svn_string_t *) (Svn.svn_string_ncreate(str, unchecked((uint)size),
                                                        pool)).ToPointer();
 }
Exemplo n.º 19
0
 public IntPtr Get(AprString key)
 {
     return(Get((IntPtr)key, -1));
 }
Exemplo n.º 20
0
 public SvnString(AprString str, uint size, AprPool pool)
 {
     mString = (svn_string_t *) (Svn.svn_string_ncreate(str, size, pool)).ToPointer();
 }
Exemplo n.º 21
0
 public SvnStringBuf(AprString str, AprPool pool)
 {
     mStringBuf = (svn_stringbuf_t *) (Svn.svn_stringbuf_create(str, pool)).ToPointer();
 }
Exemplo n.º 22
0
 public static AprString Duplicate(AprPool pool, AprString str)
 {
     return(new AprString(str, pool));
 }
Exemplo n.º 23
0
 public SvnUrl(AprString str, AprPool pool)
 {
     mUrl = Svn.svn_path_uri_encode(new SvnPath(str,pool), pool);
 }
Exemplo n.º 24
0
 public static AprString Duplicate(AprPool pool, AprString str, uint size)
 {
     return(new AprString(str, size, pool));
 }
Exemplo n.º 25
0
        public SvnError SimpleAuth(out SvnAuthCredSimple cred, IntPtr baton, 
	        				   	   AprString realm, AprString username, 
	        				   	   bool maySave, AprPool pool)
        {
            Console.WriteLine("Simple Authentication");
            Console.WriteLine("---------------------");
            Console.WriteLine("Realm: {0}", realm);
            Console.WriteLine("");

            bool valid = false;
            string line = "";

            while(!valid)
            {
                if (!username.IsNull)
                    Console.Write("Enter Username ({0}): ", username);
                else
                    Console.Write("Enter Username: "******"Enter Password: ");
            cred.Password = new AprString(Console.ReadLine(), pool);
            cred.MaySave = maySave;
            return(SvnError.NoError);
        }
Exemplo n.º 26
0
 public AprString(AprString str, AprPool pool)
 {
     mString = Apr.apr_pstrdup(pool, str);
 }
Exemplo n.º 27
0
        public SvnError UsernameAuth(out SvnAuthCredUsername cred, IntPtr baton, 
									 AprString realm, bool maySave, AprPool pool)
        {
            Console.WriteLine("Username Authentication:");
            Console.WriteLine("------------------------");
            Console.WriteLine("Realm: {0}", realm);
            Console.WriteLine("");

            bool valid = false;
            string line = "";

            while(!valid)
            {
                Console.Write("Enter Username: ");

                line = Console.ReadLine();

                if (line.Trim().Length > 0)
                {
                    valid = true;
                }
            }

            cred = SvnAuthCredUsername.Alloc(pool);
            cred.Username = new AprString(line, pool);
            cred.MaySave = maySave;
            return(SvnError.NoError);
        }
Exemplo n.º 28
0
 public AprString(AprString str, int size, AprPool pool)
 {
     mString = Apr.apr_pstrndup(pool, str, unchecked((uint)size));
 }
Exemplo n.º 29
0
        public void ArrayOfAprString()
        {
            AprPool p = AprPool.Create();
            Assert.IsFalse(p.IsNull,"#F01");

            AprArray a = AprArray.Make(p,5,typeof(AprString));
            Assert.IsFalse(a.IsNull,"#F02");

            Marshal.WriteIntPtr(a.Push(),new AprString("1",p));
            Marshal.WriteIntPtr(a.Push(),new AprString("2",p));
            Marshal.WriteIntPtr(a.Push(),new AprString("3",p));
            Marshal.WriteIntPtr(a.Push(),new AprString("4",p));
            Marshal.WriteIntPtr(a.Push(),new AprString("5",p));

            AprString[] arr = new AprString[5];
            a.CopyTo(arr,0);

            AprArray b = AprArray.LazyMake(p,a);
            Assert.AreEqual(a.ToIntPtr(),b.ToIntPtr(),"#F19");

            AprPool sp = AprPool.Create(p);
            Assert.IsFalse(sp.IsNull,"#F01");
            b = AprArray.LazyMake(sp,a);
            Assert.IsFalse(a.ToIntPtr() == b.ToIntPtr(),"#F20");

            Assert.AreEqual("5",a.PopObject().ToString(),"#F03");
            Assert.AreEqual("4",a.PopObject().ToString(),"#F04");
            Assert.AreEqual("3",a.PopObject().ToString(),"#F05");
            Assert.AreEqual("2",a.PopObject().ToString(),"#F06");
            Assert.AreEqual("1",a.PopObject().ToString(),"#F07");

            Assert.AreEqual("5",b.PopObject().ToString(),"#F21");
            Assert.AreEqual("4",b.PopObject().ToString(),"#F22");
            Assert.AreEqual("3",b.PopObject().ToString(),"#F23");
            Assert.AreEqual("2",b.PopObject().ToString(),"#F24");
            Assert.AreEqual("1",b.PopObject().ToString(),"#F25");

            Assert.AreEqual("1",arr[0].ToString(),"#F08");
            Assert.AreEqual("2",arr[1].ToString(),"#F09");
            Assert.AreEqual("3",arr[2].ToString(),"#F10");
            Assert.AreEqual("4",arr[3].ToString(),"#F11");
            Assert.AreEqual("5",arr[4].ToString(),"#F12");

            a = AprArray.Make(p,arr);

            Assert.AreEqual("5",a.PopObject().ToString(),"#F13");
            Assert.AreEqual("4",a.PopObject().ToString(),"#F14");
            Assert.AreEqual("3",a.PopObject().ToString(),"#F15");
            Assert.AreEqual("2",a.PopObject().ToString(),"#F16");
            Assert.AreEqual("1",a.PopObject().ToString(),"#F17");

            a = AprArray.LazyMake(p,new string[] {"1","2","3","4","5"},typeof(AprString));
            Assert.AreEqual("5",a.PopObject().ToString(),"#F26");
            Assert.AreEqual("4",a.PopObject().ToString(),"#F27");
            Assert.AreEqual("3",a.PopObject().ToString(),"#F28");
            Assert.AreEqual("2",a.PopObject().ToString(),"#F29");
            Assert.AreEqual("1",a.PopObject().ToString(),"#F30");

               	p.Destroy();
            Assert.IsTrue(p.IsNull,"#F18");
        }
Exemplo n.º 30
0
 public AprString(AprString str, uint size, AprPool pool)
 {
     mString = Apr.apr_pstrndup(pool, str, size);
 }
Exemplo n.º 31
0
        public void SetParameter(Param param, IntPtr value)
        {
            CheckPtr();
            if( mParamName == null )
            {
                mParamName = new IntPtr[ParamName.Length];
                for(int i=0; i<ParamName.Length; i++)
                    mParamName[i] = IntPtr.Zero;
            }

               		if( mParamName[(int)param] == IntPtr.Zero )
               			mParamName[(int)param] = new AprString(ParamName[(int)param],mPool);

            Debug.WriteLine(String.Format("svn_auth_set_parameter({0},{1:X},{2:X})",this,mParamName[(int)param].ToInt32(),value.ToInt32()));
            Svn.svn_auth_set_parameter(mAuthBaton, mParamName[(int)param], value);
        }
Exemplo n.º 32
0
 public static AprString Duplicate(AprPool pool, AprString str)
 {
     return(new AprString(str, pool));
 }
Exemplo n.º 33
0
        public void Set(string key, IntPtr value)
        {
            AprString aprKey = new AprString(key, Pool);

            Set((IntPtr)aprKey, -1, value);
        }
Exemplo n.º 34
0
 public static AprString Duplicate(AprPool pool, AprString str, uint size)
 {
     return(new AprString(str, size, pool));
 }
Exemplo n.º 35
0
        public string GetAsString(string key)
        {
            AprString aprKey = new AprString(key, Pool);

            return(GetAsString((IntPtr)aprKey, -1));
        }
Exemplo n.º 36
0
 public AprString(AprString str, AprPool pool)
 {
     mString = Apr.apr_pstrdup(pool, str);
 }
Exemplo n.º 37
0
        public IntPtr Get(string key)
        {
            AprString aprKey = new AprString(key, Pool);

            return(Get((IntPtr)aprKey, -1));
        }
Exemplo n.º 38
0
 public AprString(AprString str, int size, AprPool pool)
 {
     mString = Apr.apr_pstrndup(pool, str, unchecked ((uint)size));
 }
Exemplo n.º 39
0
 public static SvnData Duplicate(AprPool pool, AprString str)
 {
     return(new SvnData(str, pool));
 }
Exemplo n.º 40
0
 public AprString(AprString str, uint size, AprPool pool)
 {
     mString = Apr.apr_pstrndup(pool, str, size);
 }
Exemplo n.º 41
0
 public SvnData(AprString str, AprPool pool)
 {
     SvnError err = Svn.svn_utf_cstring_to_utf8(out mString, str, pool);
     if(!err.IsNoError)
         throw new SvnException(err);
 }
Exemplo n.º 42
0
 public static SvnStringBuf Create(AprString str, AprPool pool)
 {
     return(new SvnStringBuf(str,pool));
 }