Changeset 31
- Timestamp:
- 06/25/04 02:08:28
- Files:
-
- trunk/SubversionSharp/dev/src/SubversionSharp.prjx (modified) (1 diff)
- trunk/SubversionSharp/dev/src/Svn.cs (modified) (5 diffs)
- trunk/SubversionSharp/dev/src/SvnAuthBaton.cs (modified) (4 diffs)
- trunk/SubversionSharp/dev/src/SvnAuthCred.cs (modified) (5 diffs)
- trunk/SubversionSharp/dev/src/SvnAuthProvider.cs (modified) (13 diffs)
- trunk/SubversionSharp/dev/src/SvnAuthSslServerCertInfo.cs (modified) (6 diffs)
- trunk/SubversionSharp/dev/src/SvnClient.cs (added)
- trunk/SubversionSharp/dev/src/SvnClientCommitInfo.cs (added)
- trunk/SubversionSharp/dev/src/SvnClientCommitItem.cs (added)
- trunk/SubversionSharp/dev/src/SvnClientContext.cs (modified) (5 diffs)
- trunk/SubversionSharp/dev/src/SvnConfig.cs (modified) (2 diffs)
- trunk/SubversionSharp/dev/src/SvnDelegate.cs (added)
- trunk/SubversionSharp/dev/src/SvnError.cs (modified) (2 diffs)
- trunk/SubversionSharp/dev/src/SvnNullReferenceException.cs (modified) (2 diffs)
- trunk/SubversionSharp/dev/src/SvnOptRevision.cs (added)
- trunk/SubversionSharp/dev/src/SvnWcNotify.cs (added)
- trunk/SubversionSharp/test/src/Main.cs (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SubversionSharp/dev/src/SubversionSharp.prjx
r21 r31 12 12 <File name="./SvnAuthSslServerCertInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 13 13 <File name="./SvnAuthBaton.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 14 <File name="./SvnWcNotify.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 15 <File name="./SvnDelegate.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 16 <File name="./SvnClient.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 17 <File name="./SvnOptRevision.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 18 <File name="./SvnClientCommitInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 19 <File name="./SvnClientCommitItem.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 14 20 </Contents> 15 21 <References> trunk/SubversionSharp/dev/src/Svn.cs
r21 r31 18 18 19 19 ///<summary>Embeds all Svn external calls</summary> 20 public class Svn20 public sealed class Svn 21 21 { 22 22 // no instance constructor ! 23 23 private Svn() { } 24 25 public enum NodeKind 26 { 27 None, 28 File, 29 Dir, 30 Unknown 31 } 32 33 34 internal delegate IntPtr svn_cancel_func_t(IntPtr baton); 35 public delegate SvnError CancelFunc(IntPtr baton); 24 36 25 37 #region Wrapper around APR Pool … … 66 78 #endregion 67 79 68 #region ClientContext80 #region SvnClientContext 69 81 [DllImport("svn_client-1")] static extern 70 82 internal IntPtr svn_client_create_context(out IntPtr ctx, IntPtr pool); 71 #endregion 72 73 #region Config 83 84 internal delegate void svn_wc_notify_func_t(IntPtr baton, IntPtr path, 85 int action, int kind, 86 IntPtr mime_type, int content_state, 87 int prop_state, uint revision); 88 #endregion 89 90 #region SvnConfig 74 91 [DllImport("svn_client-1")] static extern 75 92 internal IntPtr svn_config_ensure(IntPtr config_dir, IntPtr pool); … … 83 100 #endregion 84 101 85 #region AuthProvider86 publicdelegate IntPtr svn_auth_simple_prompt_func_t(out IntPtr cred, IntPtr baton,87 88 int may_save, IntPtr pool);89 90 publicdelegate IntPtr svn_auth_username_prompt_func_t(out IntPtr cred, IntPtr baton,91 IntPtr realm, int may_save,92 IntPtr pool);102 #region SvnAuthProvider 103 internal delegate IntPtr svn_auth_simple_prompt_func_t(out IntPtr cred, IntPtr baton, 104 IntPtr realm, IntPtr username, 105 int may_save, IntPtr pool); 106 107 internal delegate IntPtr svn_auth_username_prompt_func_t(out IntPtr cred, IntPtr baton, 108 IntPtr realm, int may_save, 109 IntPtr pool); 93 110 94 [CLSCompliant(false)]95 publicdelegate IntPtr svn_auth_ssl_server_trust_prompt_func_t(out IntPtr cred, IntPtr baton,96 IntPtr realm, uint failures,97 IntPtr cert_info,98 int may_save, IntPtr pool);99 100 publicdelegate IntPtr svn_auth_ssl_client_cert_prompt_func_t(out IntPtr cred, IntPtr baton,101 IntPtr realm, int may_save,102 IntPtr pool);103 104 publicdelegate IntPtr svn_auth_ssl_client_cert_pw_prompt_func_t(out IntPtr cred,105 IntPtr baton,106 IntPtr realm, int may_save,107 IntPtr pool);111 //[CLSCompliant(false)] 112 internal delegate IntPtr svn_auth_ssl_server_trust_prompt_func_t(out IntPtr cred, IntPtr baton, 113 IntPtr realm, uint failures, 114 IntPtr cert_info, 115 int may_save, IntPtr pool); 116 117 internal delegate IntPtr svn_auth_ssl_client_cert_prompt_func_t(out IntPtr cred, IntPtr baton, 118 IntPtr realm, int may_save, 119 IntPtr pool); 120 121 internal delegate IntPtr svn_auth_ssl_client_cert_pw_prompt_func_t(out IntPtr cred, 122 IntPtr baton, 123 IntPtr realm, int may_save, 124 IntPtr pool); 108 125 109 126 [DllImport("svn_client-1")] static extern … … 144 161 #endregion 145 162 146 #region AuthBaton163 #region SvnAuthBaton 147 164 [DllImport("svn_client-1")] static extern 148 165 internal void svn_auth_open(out IntPtr auth_baton, IntPtr providers, IntPtr pool); … … 154 171 internal IntPtr svn_auth_get_parameter(IntPtr auth_baton, IntPtr name); 155 172 #endregion 173 174 #region SvnClient 175 internal delegate IntPtr svn_client_get_commit_log_t(out IntPtr log_message, 176 out IntPtr tmp_file, 177 IntPtr commit_items, IntPtr baton, 178 IntPtr pool); 179 180 [DllImport("svn_client-1", CharSet=CharSet.Ansi)] static extern 181 internal IntPtr svn_client_checkout(out int result_rev, string URL, 182 string path, IntPtr revision, int recurse, 183 IntPtr ctx, IntPtr pool); 184 185 [DllImport("svn_client-1", CharSet=CharSet.Ansi)] static extern 186 internal IntPtr svn_client_update (out int result_rev, string path, 187 IntPtr revision, int recurse, 188 IntPtr ctx, IntPtr pool); 189 190 [DllImport("svn_client-1", CharSet=CharSet.Ansi)] static extern 191 internal IntPtr svn_client_switch(out int result_rev, string path, string url, 192 IntPtr revision, int recurse, 193 IntPtr ctx, IntPtr pool); 194 195 [DllImport("svn_client-1", CharSet=CharSet.Ansi)] static extern 196 internal IntPtr svn_client_add(string path, int recursive, 197 IntPtr ctx, IntPtr pool); 198 #endregion 156 199 } 157 200 } trunk/SubversionSharp/dev/src/SvnAuthBaton.cs
r26 r31 77 77 mAuthProviders.Add(authObj.mAuthProvider); 78 78 } 79 Debug.Write(String.Format("svn_auth_open({0},{1})...",authArray,pool)); 79 80 Svn.svn_auth_open(out mAuthBaton, authArray, pool); 81 Debug.WriteLine(String.Format("Done({0:X})",mAuthBaton.ToInt32())); 80 82 mParamName = null; 81 83 mPool = pool; … … 118 120 119 121 #region Wrapper methods 120 public SvnAuthBaton Open(ArrayList authProviders, AprPool pool)122 public static SvnAuthBaton Open(ArrayList authProviders, AprPool pool) 121 123 { 122 124 return(new SvnAuthBaton(authProviders,pool)); … … 136 138 mParamName[(int)param] = new AprString(mPool, ParamName[(int)param]); 137 139 140 Debug.WriteLine(String.Format("svn_auth_set_parameter({0},{1:X},{2:X})",this,mParamName[(int)param].ToInt32(),value.ToInt32())); 138 141 Svn.svn_auth_set_parameter(mAuthBaton, mParamName[(int)param], value); 139 142 } … … 151 154 if( mParamName[(int)param] == IntPtr.Zero ) 152 155 mParamName[(int)param] = new AprString(mPool, ParamName[(int)param]); 153 154 return(Svn.svn_auth_get_parameter(mAuthBaton, mParamName[(int)param])); 156 157 IntPtr ptr; 158 Debug.Write(String.Format("svn_auth_get_parameter({0},{1:X})...",this,mParamName[(int)param].ToInt32())); 159 ptr = Svn.svn_auth_get_parameter(mAuthBaton, mParamName[(int)param]); 160 Debug.WriteLine(String.Format("Done({0:X})",ptr.ToInt32())); 161 return(ptr); 155 162 } 156 163 #endregion trunk/SubversionSharp/dev/src/SvnAuthCred.cs
r27 r31 87 87 get 88 88 { 89 CheckPtr(); 89 90 return(new AprString(mCred->username)); 90 91 } 91 92 set 92 93 { 94 CheckPtr(); 93 95 mCred->username = value; 94 96 } … … 99 101 get 100 102 { 103 CheckPtr(); 101 104 return(mCred->password); 102 105 } 103 106 set 104 107 { 108 CheckPtr(); 105 109 mCred->password = value; 106 110 } … … 111 115 get 112 116 { 117 CheckPtr(); 113 118 return(mCred->may_save != 0); 114 119 } 115 120 set 116 121 { 122 CheckPtr(); 117 123 mCred->may_save = (value) ? 1 : 0; 118 124 } … … 216 222 public unsafe struct SvnAuthCredSslServerTrust 217 223 { 224 [Flags] 225 public enum CertFailures 226 { 227 NotYetValid = 0x00000001, 228 Expired = 0x00000002, 229 CNMismatch = 0x00000004, 230 UnknownCA = 0x00000008, 231 Other = 0x40000000 232 } 233 218 234 private svn_auth_cred_ssl_server_trust_t *mCred; 219 235 … … 292 308 } 293 309 294 public int AcceptedFailure 295 { 296 get 297 { 298 return(unchecked((int)mCred->accepted_failures)); 299 } 300 set 301 { 302 mCred->accepted_failures = unchecked((uint)value); 303 } 304 } 305 306 [CLSCompliant(false)] 307 public uint NativeAcceptedFailure 308 { 309 get 310 { 311 return(mCred->accepted_failures); 312 } 313 set 314 { 315 mCred->accepted_failures = value; 310 public CertFailures AcceptedFailures 311 { 312 get 313 { 314 return((CertFailures)mCred->accepted_failures); 315 } 316 set 317 { 318 mCred->accepted_failures = (uint)value; 316 319 } 317 320 } trunk/SubversionSharp/dev/src/SvnAuthProvider.cs
r21 r31 18 18 { 19 19 private IntPtr mAuthProviderObject; 20 internal Svn AuthProvidermAuthProvider;20 internal SvnDelegate mAuthProvider; 21 21 22 22 #region Generic embedding functions of an IntPtr … … 27 27 } 28 28 29 private SvnAuthProviderObject(IntPtr ptr, Svn AuthProviderauthProvider)29 private SvnAuthProviderObject(IntPtr ptr, SvnDelegate authProvider) 30 30 { 31 31 mAuthProviderObject = ptr; … … 79 79 public delegate SvnError SslServerTrustPrompt(out SvnAuthCredSslServerTrust cred, 80 80 IntPtr baton, AprString realm, 81 intfailures,81 SvnAuthCredSslServerTrust.CertFailures failures, 82 82 SvnAuthSslServerCertInfo certInfo, 83 83 bool maySave, IntPtr pool); … … 98 98 { 99 99 IntPtr authObj; 100 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 100 SvnDelegate auth = new SvnDelegate(promptFunc); 101 Debug.Write(String.Format("svn_client_get_simple_prompt_provider([callback:{0}],{1:X},{2},{3})...",promptFunc.Method.Name,promptBaton.ToInt32(),retryLimit,pool)); 101 102 Svn.svn_client_get_simple_prompt_provider(out authObj, 102 103 (Svn.svn_auth_simple_prompt_func_t) auth.Wrapper, 103 104 promptBaton, retryLimit, pool); 105 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 104 106 return(new SvnAuthProviderObject(authObj,auth)); 105 107 } … … 110 112 { 111 113 IntPtr authObj; 112 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 114 SvnDelegate auth = new SvnDelegate(promptFunc); 115 Debug.Write(String.Format("svn_client_get_username_prompt_provider([callback:{0}],{1:X},{2},{3})...",promptFunc.Method.Name,promptBaton.ToInt32(),retryLimit,pool)); 113 116 Svn.svn_client_get_username_prompt_provider(out authObj, 114 117 (Svn.svn_auth_username_prompt_func_t) auth.Wrapper, 115 118 promptBaton, retryLimit, pool); 119 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 116 120 return(new SvnAuthProviderObject(authObj,auth)); 117 121 } … … 120 124 { 121 125 IntPtr authObj; 126 Debug.Write(String.Format("svn_client_get_simple_provider({0:X})",pool)); 122 127 Svn.svn_client_get_simple_provider(out authObj, pool); 128 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 123 129 return(new SvnAuthProviderObject(authObj)); 124 130 } … … 127 133 { 128 134 IntPtr authObj; 135 Debug.Write(String.Format("svn_client_get_username_provider({0:X})",pool)); 129 136 Svn.svn_client_get_username_provider(out authObj, pool); 137 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 130 138 return(new SvnAuthProviderObject(authObj)); 131 139 } … … 134 142 { 135 143 IntPtr authObj; 144 Debug.Write(String.Format("svn_client_get_ssl_server_trust_file_provider({0:X})",pool)); 136 145 Svn.svn_client_get_ssl_server_trust_file_provider(out authObj, pool); 146 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 137 147 return(new SvnAuthProviderObject(authObj)); 138 148 } … … 141 151 { 142 152 IntPtr authObj; 153 Debug.Write(String.Format("svn_client_get_ssl_client_cert_file_provider({0:X})",pool)); 143 154 Svn.svn_client_get_ssl_client_cert_file_provider(out authObj, pool); 155 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 144 156 return(new SvnAuthProviderObject(authObj)); 145 157 } … … 148 160 { 149 161 IntPtr authObj; 162 Debug.Write(String.Format("svn_client_get_ssl_client_cert_pw_file_provider({0:X})",pool)); 150 163 Svn.svn_client_get_ssl_client_cert_pw_file_provider(out authObj, pool); 164 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 151 165 return(new SvnAuthProviderObject(authObj)); 152 166 } … … 157 171 { 158 172 IntPtr authObj; 159 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 173 SvnDelegate auth = new SvnDelegate(promptFunc); 174 Debug.Write(String.Format("svn_client_get_ssl_server_trust_prompt_provider([callback:{0}],{1:X},{2})...",promptFunc.Method.Name,promptBaton.ToInt32(),pool)); 160 175 Svn.svn_client_get_ssl_server_trust_prompt_provider(out authObj, 161 176 (Svn.svn_auth_ssl_server_trust_prompt_func_t) auth.Wrapper, 162 177 promptBaton, pool); 178 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 163 179 return(new SvnAuthProviderObject(authObj,auth)); 164 180 } … … 169 185 { 170 186 IntPtr authObj; 171 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 187 SvnDelegate auth = new SvnDelegate(promptFunc); 188 Debug.Write(String.Format("svn_client_get_ssl_client_cert_prompt_provider([callback:{0}],{1},{2},{3})...",auth.Wrapper,promptBaton,retryLimit,pool)); 172 189 Svn.svn_client_get_ssl_client_cert_prompt_provider(out authObj, 173 190 (Svn.svn_auth_ssl_client_cert_prompt_func_t) auth.Wrapper, 174 191 promptBaton, retryLimit, pool); 192 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 175 193 return(new SvnAuthProviderObject(authObj,auth)); 176 194 } … … 181 199 { 182 200 IntPtr authObj; 183 SvnAuthProvider auth = new SvnAuthProvider(promptFunc); 201 SvnDelegate auth = new SvnDelegate(promptFunc); 202 Debug.Write(String.Format("svn_client_get_ssl_client_cert_pw_prompt_provider([callback:{0}],{1:X},{2},{3})...",promptFunc.Method.Name,promptBaton.ToInt32(),retryLimit,pool)); 184 203 Svn.svn_client_get_ssl_client_cert_pw_prompt_provider(out authObj, 185 204 (Svn.svn_auth_ssl_client_cert_pw_prompt_func_t) auth.Wrapper, 186 205 promptBaton, retryLimit, pool); 206 Debug.WriteLine(String.Format("Done({0:X})",authObj.ToInt32())); 187 207 return(new SvnAuthProviderObject(authObj,auth)); 188 208 } 189 209 #endregion 190 210 } 191 192 internal class SvnAuthProvider193 {194 object mFunc;195 object mWrapperFunc;196 197 public SvnAuthProvider(SvnAuthProviderObject.SimplePrompt func)198 {199 mFunc = func;200 mWrapperFunc = new Svn.svn_auth_simple_prompt_func_t(SvnAuthSimplePrompt);201 }202 203 public SvnAuthProvider(SvnAuthProviderObject.UsernamePrompt func)204 {205 mFunc = func;206 mWrapperFunc = new Svn.svn_auth_username_prompt_func_t(SvnAuthUsernamePrompt);207 }208 209 public SvnAuthProvider(SvnAuthProviderObject.SslServerTrustPrompt func)210 {211 mFunc = func;212 mWrapperFunc = new Svn.svn_auth_ssl_server_trust_prompt_func_t(SvnAuthSslServerTrustPrompt);213 }214 215 public SvnAuthProvider(SvnAuthProviderObject.SslClientCertPrompt func)216 {217 mFunc = func;218 mWrapperFunc = new Svn.svn_auth_ssl_client_cert_prompt_func_t(SvnAuthSslClientCertPrompt);219 }220 221 public SvnAuthProvider(SvnAuthProviderObject.SslClientCertPwPrompt func)222 {223 mFunc = func;224 mWrapperFunc = new Svn.svn_auth_ssl_client_cert_pw_prompt_func_t(SvnAuthSslClientCertPwPrompt);225 }226 227 public object Wrapper228 {229 get230 {231 return(mWrapperFunc);232 }233 }234 235 private IntPtr SvnAuthSimplePrompt(out IntPtr cred, IntPtr baton,236 IntPtr realm, IntPtr username,237 int may_save, IntPtr pool)238 {239 cred = IntPtr.Zero;240 SvnError err = SvnError.NoError;241 SvnAuthProviderObject.SimplePrompt func =242 mFunc as SvnAuthProviderObject.SimplePrompt;243 if( func == null ) {244 err = SvnError.Create(215000,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function");245 return(err);246 }247 try {248 SvnAuthCredSimple credSimple;249 err = func(out credSimple, baton,250 new AprString(realm), new AprString(username),251 (may_save != 0), new AprPool(pool));252 cred = credSimple;253 }254 catch( SvnException e ) {255 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message);256 }257 catch( Exception e ) {258 err = SvnError.Create(215000, SvnError.NoError, e.Message);259 }260 return(err);261 }262 263 private IntPtr SvnAuthUsernamePrompt(out IntPtr cred, IntPtr baton,264 IntPtr realm, int may_save,265 IntPtr pool)266 {267 cred = IntPtr.Zero;268 SvnError err = SvnError.NoError;269 SvnAuthProviderObject.UsernamePrompt func =270 mFunc as SvnAuthProviderObject.UsernamePrompt;271 if( func == null ) {272 err = SvnError.Create(215000,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function");273 return(err);274 }275 try {276 SvnAuthCredUsername credUsername;277 err = func(out credUsername, baton,278 new AprString(realm),279 (may_save != 0), new AprPool(pool));280 cred = credUsername;281 }282 catch( SvnException e ) {283 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message);284 }285 catch( Exception e ) {286 err = SvnError.Create(215000, SvnError.NoError, e.Message);287 }288 return(err);289 }290 291 //[CLSCompliant(false)]292 private IntPtr SvnAuthSslServerTrustPrompt(out IntPtr cred, IntPtr baton,293 IntPtr realm, uint failures,294 IntPtr cert_info,295 int may_save, IntPtr pool)296 {297 cred = IntPtr.Zero;298 SvnError err = SvnError.NoError;299 SvnAuthProviderObject.SslServerTrustPrompt func =300 mFunc as SvnAuthProviderObject.SslServerTrustPrompt;301 if( func == null ) {302 err = SvnError.Create(0,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function");303 return(err);304 }305 try {306 SvnAuthCredSslServerTrust credSslServerTrust;307 err = func(out credSslServerTrust, baton,308 new AprString(realm), unchecked((int)failures),309 new SvnAuthSslServerCertInfo(cert_info),310 (may_save != 0), new AprPool(pool));311 cred = credSslServerTrust;312 }313 catch( SvnException e ) {314 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message);315 }316 catch( Exception e ) {317 err = SvnError.Create(215000, SvnError.NoError, e.Message);318 }319 return(err);320 }321 322 private IntPtr SvnAuthSslClientCertPrompt(out IntPtr cred, IntPtr baton,323 IntPtr realm, int may_save,324 IntPtr pool)325 {326 cred = IntPtr.Zero;327 SvnError err = SvnError.NoError;328 SvnAuthProviderObject.SslClientCertPrompt func =329 mFunc as SvnAuthProviderObject.SslClientCertPrompt;330 if( func == null ) {331 err = SvnError.Create(215000,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function");332 return(err);333 }334 try {335 SvnAuthCredSslClientCert credSslClientCert;336 err = func(out credSslClientCert, baton,337 new AprString(realm),338 (may_save != 0), new AprPool(pool));339 cred = credSslClientCert;340 }341 catch( SvnException e ) {342 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message);343 }344 catch( Exception e ) {345 err = SvnError.Create(215000, SvnError.NoError, e.Message);346 }347 return(err);348 }349 350 private IntPtr SvnAuthSslClientCertPwPrompt(out IntPtr cred,351 IntPtr baton,352 IntPtr realm, int may_save,353 IntPtr pool)354 {355 cred = IntPtr.Zero;356 SvnError err = SvnError.NoError;357 SvnAuthProviderObject.SslClientCertPwPrompt func =358 mFunc as SvnAuthProviderObject.SslClientCertPwPrompt;359 if( func == null ) {360 err = SvnError.Create(215000,SvnError.NoError,"SvnNullReferenceException: null reference pointer to callback function");361 return(err);362 }363 try {364 SvnAuthCredSslClientCertPw credSslClientCertPw;365 err = func(out credSslClientCertPw, baton,366 new AprString(realm),367 (may_save != 0), new AprPool(pool));368 cred = credSslClientCertPw;369 }370 catch( SvnException e ) {371 err = SvnError.Create(e.AprErr, SvnError.NoError, e.Message);372 }373 catch( Exception e ) {374 err = SvnError.Create(215000, SvnError.NoError, e.Message);375 }376 return(err);377 }378 }379 211 } trunk/SubversionSharp/dev/src/SvnAuthSslServerCertInfo.cs
r27 r31 83 83 get 84 84 { 85 CheckPtr(); 85 86 return(mSslServerCertInfo->hostname); 86 87 } … … 90 91 get 91 92 { 93 CheckPtr(); 92 94 return(mSslServerCertInfo->fingerprint); 93 95 } … … 97 99 get 98 100 { 101 CheckPtr(); 99 102 return(mSslServerCertInfo->valid_from); 100 103 } … … 104 107 get 105 108 { 109 CheckPtr(); 106 110 return(mSslServerCertInfo->valid_until); 107 111 } … … 111 115 get 112 116 { 117 CheckPtr(); 113 118 return(mSslServerCertInfo->issuer_dname); 114 119 } … … 118 123 get 119 124 { 125 CheckPtr(); 120 126 return(mSslServerCertInfo->ascii_cert); 121 127 } trunk/SubversionSharp/dev/src/SvnClientContext.cs
r27 r31 17 17 { 18 18 19 public unsafe structSvnClientContext19 public unsafe class SvnClientContext 20 20 { 21 21 private svn_client_ctx_t *mClientContext; 22 private SvnAuthBaton mAuthBaton; 23 private SvnDelegate mNotifyFunc; 24 private SvnDelegate mLogMsgFunc; 25 private SvnDelegate mCancelFunc; 26 private GCHandle mHandle; 22 27 23 28 [StructLayout( LayoutKind.Sequential )] … … 26 31 public IntPtr auth_baton; 27 32 public IntPtr notify_func; 28 public void *notify_baton;33 public IntPtr notify_baton; 29 34 public IntPtr log_msg_func; 30 public void *log_msg_baton;35 public IntPtr log_msg_baton; 31 36 public IntPtr config; 32 37 public IntPtr cancel_func; 33 public void *cancel_baton;38 public IntPtr cancel_baton; 34 39 } 35 40 … … 38 43 { 39 44 mClientContext = ptr; 45 mAuthBaton = new SvnAuthBaton(); 46 mNotifyFunc = SvnDelegate.NullFunc; 47 mLogMsgFunc = SvnDelegate.NullFunc; 48 mCancelFunc = SvnDelegate.NullFunc; 49 mHandle = new GCHandle(); 40 50 } 41 51 … … 43 53 { 44 54 mClientContext = (svn_client_ctx_t *) ptr.ToPointer(); 55 mAuthBaton = new SvnAuthBaton(); 56 mNotifyFunc = SvnDelegate.NullFunc; 57 mLogMsgFunc = SvnDelegate.NullFunc; 58 mCancelFunc = SvnDelegate.NullFunc; 59 mHandle = new GCHandle(); 45 60 } 46 61 … … 96 111 97 112 #region Wrapper Properties 113 public SvnAuthBaton AuthBaton 114 { 115 get 116 { 117 CheckPtr(); 118 return(mAuthBaton); 119 } 120 set 121 { 122 CheckPtr(); 123 mAuthBaton = value; 124 mClientContext->auth_baton = mAuthBaton; 125 } 126 } 127 128 public SvnDelegate NotifyFunc 129 { 130 get 131 { 132 CheckPtr(); 133 return(mNotifyFunc); 134 } 135 set 136 { 137 CheckPtr(); 138 mNotifyFunc = value; 139 mClientContext->notify_func = mNotifyFunc.WrapperPtr; 140 //fixed(IntPtr *ptr = &(mClientContext->notify_func)) 141 // mNotifyFunc.MarshalWrapperToPtr(new IntPtr(ptr)); 142 } 143 } 144 145 public IntPtr NotifyBaton 146 { 147 get 148 { 149 CheckPtr(); 150 return(mClientContext->notify_baton); 151 152 } 153 set 154 { 155 CheckPtr(); 156 mClientContext->notify_baton = value; 157 } 158 } 159 160 public SvnDelegate LogMsgFunc 161 { 162 get 163 { 164 CheckPtr(); 165 return(mLogMsgFunc); 166 } 167 set 168 { 169 CheckPtr(); 170 mLogMsgFunc = value; 171 mClientContext->log_msg_func = mLogMsgFunc.WrapperPtr; 172 //fixed(IntPtr *ptr = &(mClientContext->log_msg_func)) 173 // mLogMsgFunc.MarshalWrapperToPtr(new IntPtr(ptr)); 174 } 175 } 176 177 public IntPtr LogMsgBaton 178 { 179 get 180 { 181 CheckPtr(); 182 return(mClientContext->log_msg_baton); 183 184 } 185 set 186 { 187 CheckPtr(); 188 mClientContext->log_msg_baton = value; 189 } 190 } 191 98 192 public AprHash Config 99 193 { 100 194 get 101 195 { 196 CheckPtr(); 102 197 return(mClientContext->config); 103 198 } 104 199 set 105 200 { 201 CheckPtr(); 106 202 mClientContext->config = value; 107 203 } 108 204 } 109 #endregion 205 206 public SvnDelegate CancelFunc 207 { 208 get 209 { 210 CheckPtr(); 211 return(mCancelFunc); 212 } 213 set 214 { 215 CheckPtr(); 216 mCancelFunc = value; 217 mClientContext->cancel_func = mCancelFunc.WrapperPtr; 218 //fixed(IntPtr *ptr = &(mClientContext->cancel_func)) 219 // mCancelFunc.MarshalWrapperToPtr(new IntPtr(ptr)); 220 } 221 } 222 223 public IntPtr CancelBaton 224 { 225 get 226 { 227 CheckPtr(); 228 return(mClientContext->cancel_baton); 229 230 } 231 set 232 { 233 CheckPtr(); 234 mClientContext->cancel_baton = value; 235 } 236 } 237 #endregion 110 238 } 111 239 } trunk/SubversionSharp/dev/src/SvnConfig.cs
r8 r31 77 77 public static void Ensure(AprPool pool) 78 78 { 79 Debug.WriteLine(String.Format("svn_config_ensure( {0},{1})",IntPtr.Zero,pool));79 Debug.WriteLine(String.Format("svn_config_ensure(NULL,{0})",pool)); 80 80 SvnError err = Svn.svn_config_ensure(IntPtr.Zero, pool); 81 81 if(!err.IsNoError) … … 102 102 { 103 103 IntPtr h; 104 Debug.WriteLine(String.Format("svn_config_get_config( {0},{1})",IntPtr.Zero,pool));104 Debug.WriteLine(String.Format("svn_config_get_config(NULL,{0})",pool)); 105 105 SvnError err = Svn.svn_config_get_config(out h, IntPtr.Zero, pool); 106 106 if(!err.IsNoError) trunk/SubversionSharp/dev/src/SvnError.cs
r27 r31 42 42 } 43 43 44 public static SvnError NoError ;44 public static SvnError NoError = new SvnError(IntPtr.Zero); 45 45 46 46 public bool IsNoError … … 65 65 public static implicit operator IntPtr(SvnError error) 66 66 { 67 return new IntPtr(error.mError); 67 if( error.IsNoError ) 68 return IntPtr.Zero; 69 else 70 return new IntPtr(error.mError); 68 71 } 69 72 trunk/SubversionSharp/dev/src/SvnNullReferenceException.cs
r18 r31 42 42 : base ( error ) 43 43 { 44 error.Clear(); 44 45 } 45 46 … … 47 48 : base ( error, innerException ) 48 49 { 50 error.Clear(); 49 51 } 50 52 trunk/SubversionSharp/test/src/Main.cs
r21 r31 3 3 using System.Diagnostics; 4 4 using System.Collections; 5 using System.Runtime.InteropServices; 5 6 using Softec.AprSharp; 6 7 using Softec.SubversionSharp; … … 17 18 ctx.Config = SvnConfig.GetConfig(pool); 18 19 19 ArrayList authObj = new ArrayList();20 authObj .Add(SvnAuthProviderObject.GetSimpleProvider(pool));21 authObj .Add(SvnAuthProviderObject.GetUsernameProvider(pool));22 authObj .Add(SvnAuthProviderObject.GetSslServerTrustFileProvider(pool));23 authObj .Add(SvnAuthProviderObject.GetSslClientCertFileProvider(pool));24 authObj .Add(SvnAuthProviderObject.GetSslClientCertPwFileProvider(pool));25 authObj .Add(SvnAuthProviderObject.GetPromptProvider(20 ArrayList authObjs = new ArrayList(); 21 authObjs.Add(SvnAuthProviderObject.GetSimpleProvider(pool)); 22 authObjs.Add(SvnAuthProviderObject.GetUsernameProvider(pool)); 23 authObjs.Add(SvnAuthProviderObject.GetSslServerTrustFileProvider(pool)); 24 authObjs.Add(SvnAuthProviderObject.GetSslClientCertFileProvider(pool)); 25 authObjs.Add(SvnAuthProviderObject.GetSslClientCertPwFileProvider(pool)); 26 authObjs.Add(SvnAuthProviderObject.GetPromptProvider( 26 27 new SvnAuthProviderObject.SimplePrompt(SimpleAuth), 27 28 IntPtr.Zero, 2, pool)); 28 authObj .Add(SvnAuthProviderObject.GetPromptProvider(29 authObjs.Add(SvnAuthProviderObject.GetPromptProvider( 29 30 new SvnAuthProviderObject.UsernamePrompt(UsernameAuth), 30 31 IntPtr.Zero, 2, pool)); 32 authObjs.Add(SvnAuthProviderObject.GetPromptProvider( 33 new SvnAuthProviderObject.SslServerTrustPrompt(SslServerTrustAuth), 34 IntPtr.Zero, pool)); 35 ctx.AuthBaton = SvnAuthBaton.Open(authObjs,pool); 36 ctx.NotifyFunc = new SvnDelegate(new SvnWcNotify.Func(NotifyCallback)); 37 ctx.LogMsgFunc = new SvnDelegate(new SvnClient.GetCommitLog(GetCommitLogCallback)); 38 ctx.CancelFunc = new SvnDelegate(new Svn.CancelFunc(CancelCallback)); 31 39 32 40 GCHandle h; 41 SvnOptRevision revision = SvnOptRevision.Alloc(out h); 42 try 43 { 44 revision.Number = 100; 45 SvnClient.SvnClientCheckout("https://www.softec.st/svn/test", 46 "/home/denisg/dev/lib/SubversionSharp/test/bin/Debug/test", 47 revision, true, ctx, pool); 48 49 revision.Kind = SvnOptRevision.RevisionKind.Head; 50 SvnClient.SvnClientUpdate("/home/denisg/dev/lib/SubversionSharp/test/bin/Debug/test", 51 revision, true, ctx, pool); 52 } 53 finally 54 { 55 h.Free(); 56 } 33 57 pool.Destroy(); 58 } 59 60 public static void NotifyCallback(IntPtr baton, AprString Path, 61 SvnWcNotify.Action action, Svn.NodeKind kind, 62 AprString mimeType, SvnWcNotify.State contentState, 63 SvnWcNotify.State propState, int revNum) 64 { 65 } 66 67 public static SvnError GetCommitLogCallback(out AprString logMessage, out AprString tmpFile, 68 AprArray commitItems, IntPtr baton, 69 AprPool pool) 70 { 71 if (!commitItems.IsNull) 72 { 73 foreach (SvnClientCommitItem item in gclea.CommitItems) 74 { 75 Console.WriteLine("C{0}: {1} ({2}) r{3}", 76 ++mCommitCounter, 77 item.Path, item.Kind, item.Revision); 78 Console.WriteLine("C{0}: {1} -> {2}", 79 mCommitCounter, 80 item.URL, 81 item.CopyFromUrl); 82 } 83 Console.WriteLine(); 84 } 85 86 Console.Write("Enter log message: "); 87 logMessage = new AprString(pool, Console.ReadLine()); 88 tmpFile = new AprString(); 89 90 return(SvnError.NoError); 91 } 92 93 94 public static SvnError CancelCallback(IntPtr baton) 95 { 96 return(SvnError.NoError); 34 97 } 35 98 … … 44 107 45 108 bool valid = false; 46 string line ;109 string line = ""; 47 110 48 111 while(!valid) … … 83 146 84 147 bool valid = false; 85 string line ;148 string line = ""; 86 149 87 150 while(!valid) … … 102 165 return(SvnError.NoError); 103 166 } 167 168 public static SvnError SslServerTrustAuth(out SvnAuthCredSslServerTrust cred, 169 IntPtr baton, AprString realm, 170 SvnAuthCredSslServerTrust.CertFailures failures, 171 SvnAuthSslServerCertInfo certInfo, 172 bool maySave, IntPtr pool) 173 { 174 Console.WriteLine("Ssl Server Trust Prompt:"); 175 Console.WriteLine("------------------------"); 176 Console.WriteLine(""); 177 178 Console.WriteLine("Error validating server certificate for '{0}':", realm); 179 if ((failures & SvnAuthCredSslServerTrust.CertFailures.UnknownCA) > 0) 180 Console.WriteLine(" - The certificate is not issued by a trusted authority"); 181 if ((failures & SvnAuthCredSslServerTrust.CertFailures.CNMismatch) > 0) 182 Console.WriteLine(" - The certificate hostname does not match"); 183 if ((failures & SvnAuthCredSslServerTrust.CertFailures.NotYetValid) > 0) 184 Console.WriteLine(" - The certificate is not yet valid"); 185 if ((failures & SvnAuthCredSslServerTrust.CertFailures.Expired) > 0) 186 Console.WriteLine(" - The certificate has expired"); 187 if ((failures & SvnAuthCredSslServerTrust.CertFailures.Other) > 0) 188 Console.WriteLine(" - The certificate has an unknown error"); 189 190 Console.WriteLine("Certificate informations:"); 191 Console.WriteLine("\tHostName: " + certInfo.Hostname); 192 Console.WriteLine("\tIssuer: " + certInfo.IssuerDName); 193 Console.WriteLine("\tValid From: " + certInfo.ValidFrom); 194 Console.WriteLine("\tValid Until: " + certInfo.ValidUntil); 195 Console.WriteLine("\tFingerprint: " + certInfo.Fingerprint); 196 197 cred = SvnAuthCredSslServerTrust.Alloc(pool); 198 bool valid = false; 199 while (!valid) 200 { 201 if (maySave) 202 Console.WriteLine("(R)eject, accept (t)emporarily or accept (p)ermanently? "); 203 else 204 Console.WriteLine("(R)eject or accept (t)emporarily? "); 205 206 string line = Console.ReadLine(); 207 if (line.Length > 0) 208 { 209 char choice = line.ToLower()[0]; 210 if (choice == 'r') 211 { 212 cred.AcceptedFailures = 0; 213 cred.MaySave=false; 214 valid = true; 215 } 216 else if (choice == 't') 217 { 218 cred.AcceptedFailures = failures; 219 cred.MaySave=false; 220 valid = true; 221 } 222 else if (choice == 'p') 223 { 224 cred.AcceptedFailures = failures; 225 cred.MaySave=true; 226 valid = true; 227 } 228 } 229 } 230 return(SvnError.NoError); 231 } 104 232 }