home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libnet / mkcertld.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.1 KB  |  132 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. #include "mkutils.h" 
  19. #include "mkgeturl.h"
  20. #include "net.h"
  21. #include "secnav.h"
  22. #include "ldap.h"
  23. #include "certldap.h"
  24. #include "mkcertld.h"
  25.  
  26. PRIVATE int32
  27. net_CertLdapLoad(ActiveEntry *ce)
  28. {
  29.     int err = 0;
  30.     CertLdapConnData *connData;
  31.     
  32.     connData = SECNAV_CertLdapLoad(ce->URL_s);
  33.     ce->con_data = connData;
  34.     if ( connData == NULL ) {
  35.     err = -1;
  36.     }
  37.     
  38.     if ( err ) {
  39.     ce->status = err;
  40.     } else {
  41.  
  42. #ifdef NSPR20_DISABLED /* need to convert to PRFileDesc */
  43.     ce->socket = connData->fd;
  44. #endif
  45.     XP_ASSERT(0);
  46.  
  47. #ifdef XP_UNIX
  48.     NET_SetConnectSelect(ce->window_id, ce->socket);
  49.     NET_TotalNumberOfOpenConnections++;
  50. #else
  51.     NET_SetCallNetlibAllTheTime(ce->window_id, "mkcertld");
  52. #endif
  53.     }
  54.     
  55.     return(err);
  56. }
  57.  
  58. PRIVATE int32
  59. net_ProcessCertLdap(ActiveEntry *ce)
  60. {
  61.     int err;
  62.     CertLdapConnData *connData;
  63.     
  64.     connData = (CertLdapConnData *)ce->con_data;
  65.  
  66. #ifdef XP_UNIX
  67.     NET_ClearConnectSelect(ce->window_id, connData->fd);
  68.     NET_SetReadSelect(ce->window_id, connData->fd);
  69. #endif
  70.  
  71.     err = SECNAV_CertLdapProcess(connData);
  72.     
  73.     if ( err ) {
  74.     if ( err == 1 ) {
  75.         /* done */
  76.         ce->status = 0;
  77.         err = -1;
  78.     } else {
  79.         ce->status = err;
  80.     }
  81. #ifdef XP_UNIX
  82.     NET_ClearReadSelect(ce->window_id, connData->fd);
  83.     NET_TotalNumberOfOpenConnections--;
  84. #else
  85.         NET_ClearCallNetlibAllTheTime(ce->window_id, "mkcertld");
  86. #endif
  87.  
  88.     }
  89.  
  90.     return(err);
  91. }
  92.  
  93. PRIVATE int32
  94. net_InterruptCertLdap(ActiveEntry *ce)
  95. {
  96.     int err;
  97.     CertLdapConnData *connData;
  98.     
  99.     connData = (CertLdapConnData *)ce->con_data;
  100.  
  101.     err = SECNAV_CertLdapInterrupt(connData);
  102.     ce->status = MK_INTERRUPTED;
  103.  
  104. #ifdef XP_UNIX
  105.     NET_ClearReadSelect(ce->window_id, connData->fd);
  106.     NET_TotalNumberOfOpenConnections--;
  107. #else
  108.     NET_ClearCallNetlibAllTheTime(ce->window_id, "mkcertld");
  109. #endif
  110.  
  111.     return(err);
  112. }
  113.  
  114. PRIVATE void
  115. net_CleanupCertLdap(void)
  116. {
  117. }
  118.  
  119. MODULE_PRIVATE void
  120. NET_InitCertLdapProtocol(void)
  121. {
  122.         static NET_ProtoImpl certldap_proto_impl;
  123.  
  124.         certldap_proto_impl.init = net_CertLdapLoad;
  125.         certldap_proto_impl.process = net_ProcessCertLdap;
  126.         certldap_proto_impl.interrupt = net_InterruptCertLdap;
  127.         certldap_proto_impl.cleanup = net_CleanupCertLdap;
  128.  
  129.         NET_RegisterProtocolImplementation(&certldap_proto_impl, INTERNAL_CERTLDAP_TYPE_URL);
  130. }
  131.  
  132.