/[winpt]/trunk/PTD/wptDNSKeys.cpp
ViewVC logotype

Diff of /trunk/PTD/wptDNSKeys.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 255 by twoaday, Fri Jul 28 11:11:09 2006 UTC revision 256 by twoaday, Sat Aug 5 10:31:06 2006 UTC
# Line 21  Line 21 
21  #include <windows.h>  #include <windows.h>
22  #include <windns.h>  #include <windns.h>
23    
24    #include "wptDNSKeys.h"
25    
26    
27  /* typedef for the function signature. */  /* typedef for the function signature. */
28  typedef DNS_STATUS (*dns_query_fnc) (LPSTR, WORD, DWORD, PIP4_ARRAY,  typedef DNS_STATUS (*dns_query_fnc) (LPSTR, WORD, DWORD, PIP4_ARRAY,
29                                      PDNS_RECORD*, PVOID *);                                      PDNS_RECORD*, PVOID *);
30    
31    typedef void (*dns_record_list_free_fnc) (PDNS_RECORD, DNS_FREE_TYPE);
32    
33  /* function pointer. */  /* function pointer. */
34  static dns_query_fnc dns_query = NULL;  static dns_query_fnc dns_query = NULL;
35    static dns_record_list_free_fnc dns_record_free = NULL;
36    
37  /* hinstance handle to the DLL. */  /* hinstance handle to the DLL. */
38  static HINSTANCE dns_api = NULL;  static HINSTANCE dns_api = NULL;
# Line 35  static HINSTANCE dns_api = NULL; Line 41  static HINSTANCE dns_api = NULL;
41  static int dns_failed = 0;  static int dns_failed = 0;
42    
43    
 /*  
 DNS_STATUS WINAPI DnsQuery (  
   LPSTR lpstrName, WORD wType,  
   DWORD fOptions, PIP4_ARRAY aipServers,  
   PDNS_RECORD *ppQueryResultsSet,  
   PVOID *pReserved  
 );  
 */  
   
 struct pka_info_s {  
     int ver;  
     char *fpr;  
     char *uri;  
 };  
 typedef struct pka_info_s *pka_info_t;  
   
44    
45  /* Initialize the DNS sub system. We do this via dynamic loading  /* Initialize the DNS sub system. We do this via dynamic loading
46     because older NT/9X systems do not have this API. */     because older NT/9X systems do not have this API. */
# Line 71  dns_init (void) Line 61  dns_init (void)
61          dns_failed = 1;          dns_failed = 1;
62          return -1;          return -1;
63      }      }
64        dns_record_free = (dns_record_list_free_fnc)GetProcAddress (dns_api, "DnsRecordListFree");
65        if (!dns_record_free) {
66            dns_failed = 1;
67            return -1;
68        }
69      return 0;      return 0;
70  }  }
71    
72    
73  /* Cleanup static structs. */  /* Cleanup static structs. */
74  void  void
75  dns_cleanup (void)  dns_cleanup (void)
# Line 81  dns_cleanup (void) Line 77  dns_cleanup (void)
77      if (dns_api)      if (dns_api)
78          FreeLibrary (dns_api);          FreeLibrary (dns_api);
79      dns_api = NULL;      dns_api = NULL;
80        dns_failed = 0;
81  }  }
82    
83    
 /* Release the memory of the @pka structure. */  
 void  
 dns_free_pka_record (pka_info_t pka)  
 {  
     if (pka->fpr)  
         free (pka->fpr);  
     if (pka->uri)  
         free (pka->uri);  
     free (pka);  
 }  
   
84    
85    
86  /* build a DNS name for the PKA lookup. */  /* build a DNS name for the PKA lookup. */
# Line 165  parse_pka_data (const char *data) Line 151  parse_pka_data (const char *data)
151    
152  /* Retrieve a PKA record from the DNS.  /* Retrieve a PKA record from the DNS.
153     @userid is used to extract the email address. */     @userid is used to extract the email address. */
154  int  extern "C" int
155  dns_get_pka_record (const char *userid, pka_info_t *r_pka)  dns_get_pka_record (const char *userid, pka_info_t *r_pka)
156  {  {
157      char *addr;      char *addr;
# Line 185  dns_get_pka_record (const char *userid, Line 171  dns_get_pka_record (const char *userid,
171      }      }
172      *r_pka = parse_pka_data (rec->Data.Txt.pStringArray[0]);      *r_pka = parse_pka_data (rec->Data.Txt.pStringArray[0]);
173    
174      //DnsRecordListFree (rec, DnsFreeRecordList);      dns_record_free (rec, DnsFreeRecordList);
175      free (addr);      free (addr);
176      return 0;      return 0;
177  }  }
178    
179    
180    /* Release the memory of the @pka structure. */
181    extern "C" void
182    dns_free_pka_record (pka_info_t pka)
183    {
184        if (pka->fpr)
185            free (pka->fpr);
186        if (pka->uri)
187            free (pka->uri);
188        free (pka);
189    }

Legend:
Removed from v.255  
changed lines
  Added in v.256

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26