spf2 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/ext/spf2/spf2.c +47 -75
  3. data/lib/spf2/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmQ3ZGM0ZTY5ZDQ2MjUzOGQwMjNjZGRkZjNkYzBjODBkZWZhNDY5MA==
4
+ MWQ2ZTFmZTdkYzRmMGZmNzdlODVmODFlMWQ1YTdiMzdhYTRmZjZhZg==
5
5
  data.tar.gz: !binary |-
6
- NWYyMDIwNjYzMTZjNTI2OTkzYjFkN2MzOGFlZGNiMWZlM2QwZjMzNw==
6
+ ZTFhNTFjZjJmYzc1Y2ZjYWQ0MjE0OTI3NzFjMGY1Y2IzZjE5OWI3MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2VmODRhZTZlOTZlMzFjZDg4OGU1MDU0MTA2MjgyMThlOGFlNTdhNGVlZjRk
10
- NDJmODYyNThmY2QwMzQ0NjE1ZjZjZTA1NmYzNDIzMDg1ZWViZDVkNTc3YzE4
11
- ZWNmODVhYTk0OGY4NjU2ZmI0MThmMDliNWJiODVlM2UzNzBkMTA=
9
+ YjgwZWYyNGI1M2I4NDc3YjgyZWJlNmU5ZDUyMDBmNTk1OGYzMzU3NjZjY2M4
10
+ NTQ0YWIxN2UzNjIwZDQ3ZTA1NTYwN2E3NGEwYTg3YjczMTFkZjBjZGE2Mzhk
11
+ YjNhNzVlMTE3NDEyNmM4MzM4MjA4MGQ1MTc4N2YzODZmZDZlMDY=
12
12
  data.tar.gz: !binary |-
13
- MTNhNmY0YTU3MTdmZWY5MjgzNjlkODIzODdiODA5OWE2YTUwNWZhZDdjMzEx
14
- MmVlZDNhZTMxYTlhYWYzNzIzOGUyNGZmYzFmODIxMmRjYzRmZjc3YzIwMGZj
15
- OGIwNDk0NTE5N2U0NDQwMDU4NDIxNzA0N2MzZTY4NjIwOWNmZGE=
13
+ YWZkODE0MDdlMDkzNWY2YTkzOTg3NzU1YmNjZTVlZTIxNjFjZjdkNjM5MDcz
14
+ NWY3NWY4NjQwNDYwZjA1OTlkNWEyOGYxOGIyOGJiNDY3NWViMTExMTY4NmVm
15
+ NTRkYTE4NTdjNDllYjk0YjdiZTkxOTNkODMyM2ZmZWFlM2M4OTY=
data/ext/spf2/spf2.c CHANGED
@@ -2,105 +2,78 @@
2
2
  #include <netinet/in.h>
3
3
  #include <spf2/spf.h>
4
4
  #include <spf2/spf_server.h>
5
- /*
6
- SPF_server_t *spf_server = SPF_server_new(SPF_DNS_CACHE, 0);
7
- Create a request, and set the relevant fields in it. Each setter method returns an SPF_errcode_t, which will inform you of error conditions, such as out-of-memory or invalid argument.
8
5
 
9
- SPF_request_t *spf_request = SPF_request_new(spf_server);
10
- SPF_request_set_ipv4_str(spf_request, "123.45.6.7");
11
- SPF_request_set_env_from(spf_request, "clientdomain.com");
12
- Now that we have built a query, we may execute it. It will use the SPF_server_t which was passed to the query constructor. As usual, the SPF_request_query_mailfrom method returns an error code, although much richer errors are returned inside the SPF_response_t - see spf_response.h for more details of that API.
6
+ static VALUE spf2_set_debug(VALUE self, VALUE bDebug)
7
+ {
8
+ SPF_server_t *spf_server;
13
9
 
14
- SPF_response_t *spf_response = NULL;
15
- SPF_request_query_mailfrom(spf_request, &spf_response);
16
- printf("Result is %s\n",
17
- SPF_strresult(SPF_response_result(spf_response)));
18
- When we have finished with the response, we must free it and the request.
19
-
20
- SPF_response_free(spf_response);
21
- SPF_request_free(spf_request);
22
- We can execute many requests in parallel threads on the same server, but before the program exits, we must free the server.
23
-
24
- SPF_server_free(spf_server);
25
- */
26
-
27
- /*
28
- */
29
-
30
-
31
-
32
- static VALUE
33
- spf2_set_debug(VALUE self, VALUE bDebug){
34
- SPF_server_t *spf_server ;
35
-
36
10
  Data_Get_Struct(self, SPF_server_t, spf_server);
37
- spf_server->debug = RTEST(bDebug);
11
+ spf_server->debug = RTEST(bDebug);
38
12
 
39
13
 
40
14
  return self;
41
15
  }
42
16
 
43
- static VALUE
44
- spf2_query(VALUE self, VALUE ipfrom, VALUE domain) {
17
+ static VALUE spf2_query(VALUE self, VALUE ipfrom, VALUE domain)
18
+ {
45
19
 
46
- SPF_server_t *spf_server = NULL ;
47
- SPF_response_t *spf_response = NULL;
48
- SPF_request_t *spf_request = NULL;
20
+ SPF_server_t *spf_server = NULL;
21
+ SPF_response_t *spf_response = NULL;
22
+ SPF_request_t *spf_request = NULL;
49
23
 
50
- VALUE ret , str_result , str_reason, str_error;
24
+ VALUE ret, str_result, str_reason, str_error;
51
25
 
52
- Data_Get_Struct(self, SPF_server_t, spf_server);
26
+ Data_Get_Struct(self, SPF_server_t, spf_server);
27
+
28
+ spf_request = SPF_request_new(spf_server);
53
29
 
54
- spf_request = SPF_request_new(spf_server);
30
+ SPF_request_set_ipv4_str(spf_request, StringValueCStr(ipfrom));
31
+ SPF_request_set_env_from(spf_request, StringValueCStr(domain));
32
+ SPF_request_query_mailfrom(spf_request, &spf_response);
55
33
 
56
- SPF_request_set_ipv4_str(spf_request,StringValueCStr(ipfrom));
57
- SPF_request_set_env_from(spf_request,StringValueCStr(domain));
58
- SPF_request_query_mailfrom(spf_request, &spf_response);
34
+ str_result =
35
+ rb_str_new2(SPF_strresult(SPF_response_result(spf_response)));
36
+ str_reason =
37
+ rb_str_new2(SPF_strreason(SPF_response_reason(spf_response)));
38
+ str_error =
39
+ rb_str_new2(SPF_strerror(SPF_response_errcode(spf_response)));
40
+ ret = rb_ary_new2(4);
41
+ rb_ary_push(ret, str_result);
42
+ rb_ary_push(ret, str_reason);
43
+ rb_ary_push(ret, str_error);
59
44
 
60
- str_result = rb_str_new2(SPF_strresult(SPF_response_result(spf_response)));
61
- str_reason = rb_str_new2(SPF_strreason(SPF_response_reason(spf_response)));
62
- str_error = rb_str_new2(SPF_strerror(SPF_response_errcode(spf_response)));
63
- ret = rb_ary_new2(4);
64
- rb_ary_push(ret, str_result);
65
- rb_ary_push(ret, str_reason);
66
- rb_ary_push(ret, str_error);
67
45
 
68
-
69
- SPF_response_free(spf_response);
70
- SPF_request_free(spf_request);
71
- return ret;
46
+ SPF_response_free(spf_response);
47
+ SPF_request_free(spf_request);
48
+ return ret;
72
49
  }
73
50
 
74
51
 
75
- static void spf2_free(void * p){
76
- SPF_server_free(p);
52
+ static void spf2_free(void *p)
53
+ {
54
+ SPF_server_free(p);
77
55
  }
78
56
 
79
- static VALUE
80
- spf2_init(VALUE self, VALUE bDebug) {
81
- spf2_set_debug(self, bDebug);
82
- return self;
57
+ static VALUE spf2_init(VALUE self, VALUE bDebug)
58
+ {
59
+ spf2_set_debug(self, bDebug);
60
+ return self;
83
61
  }
84
62
 
85
63
 
86
64
 
87
- /*
88
- * This defines the C functions as extensions.
89
- *
90
- * The name of the Init_ function is important. What follows Init_ must match
91
- * the file name (including case) so ruby knows what method to call to define
92
- * the extensions.
93
- */
94
- static VALUE spf2_alloc(VALUE klass){
95
- SPF_server_t *spf_server = NULL;
96
- VALUE obj;
97
- spf_server = SPF_server_new(SPF_DNS_CACHE,0);
98
- obj = Data_Wrap_Struct(klass, 0, spf2_free, spf_server);
99
- return obj;
100
-
65
+ static VALUE spf2_alloc(VALUE klass)
66
+ {
67
+ SPF_server_t *spf_server = NULL;
68
+ VALUE obj;
69
+ spf_server = SPF_server_new(SPF_DNS_CACHE, 0);
70
+ obj = Data_Wrap_Struct(klass, 0, spf2_free, spf_server);
71
+ return obj;
72
+
101
73
  }
102
- void
103
- Init_spf2(void) {
74
+
75
+ void Init_spf2(void)
76
+ {
104
77
  VALUE cSpf2;
105
78
 
106
79
  cSpf2 = rb_const_get(rb_cObject, rb_intern("Spf2"));
@@ -110,4 +83,3 @@ Init_spf2(void) {
110
83
  rb_define_method(cSpf2, "debug=", spf2_set_debug, 1);
111
84
  rb_define_method(cSpf2, "query", spf2_query, 2);
112
85
  }
113
-
data/lib/spf2/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Spf2
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spf2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romeu Fonseca