bouncestudio 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +2 -0
- data/Manifest.txt +13 -0
- data/README.txt +100 -0
- data/Rakefile +54 -0
- data/ext/Makefile +139 -0
- data/ext/bounce_studio.c +239 -0
- data/ext/extconf.rb +3 -0
- data/lib/bouncestudio.rb +2 -0
- data/lib/bouncestudio/version.rb +9 -0
- data/setup.rb +1585 -0
- data/test/bouncestudio_test.rb +99 -0
- data/test/raw_message.txt +50 -0
- data/test/test_helper.rb +9 -0
- metadata +58 -0
data/CHANGELOG.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
README for bouncestudio
|
2
|
+
=======================
|
3
|
+
|
4
|
+
== DESCRIPTION
|
5
|
+
|
6
|
+
The bouncestudio ruby extension wraps the Bounce Studio C API
|
7
|
+
from Boogie Tools, Inc. This allows a simple method of determining
|
8
|
+
if a given raw email message is a hard bounce, an "over quota"
|
9
|
+
bounce, etc.
|
10
|
+
|
11
|
+
== SYNOPSIS
|
12
|
+
|
13
|
+
# Rubygems magic
|
14
|
+
require 'rubygems'
|
15
|
+
require 'bouncestudio'
|
16
|
+
|
17
|
+
# First, set your license. If you don't have a BounceStudio license
|
18
|
+
# from BoogieTools, you can still test out the software. It'll just be
|
19
|
+
# too slow for production use. Go to http://www.boogietools.com/ to learn
|
20
|
+
# more. Using an environment variable is recommended to keep your license
|
21
|
+
# code out of your source.
|
22
|
+
BS_LICENSE = ENV["BS_LICENSE"] || ""
|
23
|
+
|
24
|
+
# Create the BounceStudio worker
|
25
|
+
bs = BoogieTools::BounceStudio.new(BS_LICENSE)
|
26
|
+
|
27
|
+
# Get your message, from a file, with Net::POP, etc
|
28
|
+
raw_message = "Subject: I love you"
|
29
|
+
|
30
|
+
# Issue the check.
|
31
|
+
result = bs.check(raw_message)
|
32
|
+
|
33
|
+
# If you're not licensed, this is where you'll get a delay and
|
34
|
+
# the following message:
|
35
|
+
#
|
36
|
+
# Thank you for trying the BounceStudio API.
|
37
|
+
# To register, please visit http://www.boogietools.com.
|
38
|
+
|
39
|
+
|
40
|
+
# Do whatever you want based on the following result codes.
|
41
|
+
|
42
|
+
# Type Description
|
43
|
+
# 0 NON BOUNCE
|
44
|
+
# 10 HARD BOUNCE
|
45
|
+
# 20 SOFT BOUNCE - General
|
46
|
+
# 21 SOFT BOUNCE - Dns Failure
|
47
|
+
# 22 SOFT BOUNCE - Mailbox Full
|
48
|
+
# 23 SOFT BOUNCE - Message Size Too Large
|
49
|
+
# 30 BOUNCE WITH NO EMAIL ADDRESS
|
50
|
+
# 40 GENERAL BOUNCE
|
51
|
+
# 50 MAIL BLOCK - General
|
52
|
+
# 51 MAIL BLOCK - Known Spammer
|
53
|
+
# 52 MAIL BLOCK - Spam Detected
|
54
|
+
# 53 MAIL BLOCK - Attachment Detected
|
55
|
+
# 54 MAIL BLOCK - Relay Denied
|
56
|
+
# 60 AUTO REPLY
|
57
|
+
# 70 TRANSIENT BOUNCE
|
58
|
+
# 80 SUBSCRIBE REQUEST
|
59
|
+
# 90 UNSUBSCRIBE REQUEST
|
60
|
+
# 100 CHALLENGE RESPONSE
|
61
|
+
|
62
|
+
|
63
|
+
== REQUIREMENTS
|
64
|
+
|
65
|
+
Besides Ruby and Rubygems, you'll of course need the BounceStudio
|
66
|
+
library. It is available for Linux or Windows. This wrapper has only
|
67
|
+
been tested with the Linux version.
|
68
|
+
|
69
|
+
== INSTALL
|
70
|
+
|
71
|
+
Using Rubygems:
|
72
|
+
|
73
|
+
* sudo gem install bouncestudio
|
74
|
+
|
75
|
+
== LICENSE
|
76
|
+
|
77
|
+
(The MIT License)
|
78
|
+
|
79
|
+
Copyright (c) 2007 BoogieTools, Inc.
|
80
|
+
|
81
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
82
|
+
a copy of this software and associated documentation files (the
|
83
|
+
"Software"), to deal in the Software without restriction, including
|
84
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
85
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
86
|
+
permit persons to whom the Software is furnished to do so, subject to
|
87
|
+
the following conditions:
|
88
|
+
|
89
|
+
The above copyright notice and this permission notice shall be
|
90
|
+
included in all copies or substantial portions of the Software.
|
91
|
+
|
92
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
93
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
94
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
95
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
96
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
97
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
98
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
99
|
+
|
100
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'hoe'
|
11
|
+
include FileUtils
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib', 'bouncestudio', 'version')
|
13
|
+
|
14
|
+
AUTHOR = "Joshua Warchol" # can also be an array of Authors
|
15
|
+
EMAIL = "joshua@zaadz.com"
|
16
|
+
DESCRIPTION = "A Ruby API wrapping the BounceStudio library from Boogie Tools"
|
17
|
+
GEM_NAME = "bouncestudio" # what ppl will type to install your gem
|
18
|
+
RUBYFORGE_PROJECT = "bouncestudio" # The unix name for your project
|
19
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
20
|
+
|
21
|
+
|
22
|
+
NAME = "bouncestudio"
|
23
|
+
REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
24
|
+
VERS = ENV['VERSION'] || (Bouncestudio::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
25
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
26
|
+
RDOC_OPTS = ['--quiet', '--title', "bouncestudio documentation",
|
27
|
+
"--opname", "index.html",
|
28
|
+
"--line-numbers",
|
29
|
+
"--main", "README",
|
30
|
+
"--inline-source"]
|
31
|
+
|
32
|
+
class Hoe
|
33
|
+
def extra_deps
|
34
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generate all the Rake tasks
|
39
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
40
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
41
|
+
p.author = AUTHOR
|
42
|
+
p.description = DESCRIPTION
|
43
|
+
p.email = EMAIL
|
44
|
+
p.summary = DESCRIPTION
|
45
|
+
p.url = HOMEPATH
|
46
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
47
|
+
p.test_globs = ["test/**/*_test.rb"]
|
48
|
+
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
|
49
|
+
|
50
|
+
# == Optional
|
51
|
+
#p.changes - A description of the release's latest changes.
|
52
|
+
#p.extra_deps - An array of rubygem dependencies.
|
53
|
+
p.spec_extras = {:extensions => ["ext/extconf.rb"]}
|
54
|
+
end
|
data/ext/Makefile
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
#### Start of system configuration section. ####
|
5
|
+
|
6
|
+
srcdir = .
|
7
|
+
topdir = /usr/lib/ruby/1.8/i486-linux
|
8
|
+
hdrdir = $(topdir)
|
9
|
+
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
10
|
+
prefix = $(DESTDIR)/usr
|
11
|
+
exec_prefix = $(prefix)
|
12
|
+
sitedir = $(DESTDIR)/usr/local/lib/site_ruby
|
13
|
+
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
14
|
+
archdir = $(rubylibdir)/$(arch)
|
15
|
+
sbindir = $(exec_prefix)/sbin
|
16
|
+
datadir = $(prefix)/share
|
17
|
+
includedir = $(prefix)/include
|
18
|
+
infodir = $(prefix)/info
|
19
|
+
sysconfdir = $(DESTDIR)/etc
|
20
|
+
mandir = $(datadir)/man
|
21
|
+
libdir = $(exec_prefix)/lib
|
22
|
+
sharedstatedir = $(prefix)/com
|
23
|
+
oldincludedir = $(DESTDIR)/usr/include
|
24
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
25
|
+
bindir = $(exec_prefix)/bin
|
26
|
+
localstatedir = $(DESTDIR)/var
|
27
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
28
|
+
libexecdir = $(exec_prefix)/libexec
|
29
|
+
|
30
|
+
CC = gcc
|
31
|
+
LIBRUBY = $(LIBRUBY_SO)
|
32
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
33
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
34
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
35
|
+
|
36
|
+
CFLAGS = -fPIC -Wall -g -O2 -fPIC
|
37
|
+
CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
|
38
|
+
CXXFLAGS = $(CFLAGS)
|
39
|
+
DLDFLAGS =
|
40
|
+
LDSHARED = $(CC) -shared
|
41
|
+
AR = ar
|
42
|
+
EXEEXT =
|
43
|
+
|
44
|
+
RUBY_INSTALL_NAME = ruby1.8
|
45
|
+
RUBY_SO_NAME = ruby1.8
|
46
|
+
arch = i486-linux
|
47
|
+
sitearch = i486-linux
|
48
|
+
ruby_version = 1.8
|
49
|
+
ruby = /usr/bin/ruby1.8
|
50
|
+
RUBY = $(ruby)
|
51
|
+
RM = rm -f
|
52
|
+
MAKEDIRS = mkdir -p
|
53
|
+
INSTALL = /usr/bin/install -c
|
54
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
55
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
56
|
+
COPY = cp
|
57
|
+
|
58
|
+
#### End of system configuration section. ####
|
59
|
+
|
60
|
+
preload =
|
61
|
+
|
62
|
+
libpath = $(libdir)
|
63
|
+
LIBPATH = -L"$(libdir)"
|
64
|
+
DEFFILE =
|
65
|
+
|
66
|
+
CLEANFILES =
|
67
|
+
DISTCLEANFILES =
|
68
|
+
|
69
|
+
extout =
|
70
|
+
extout_prefix =
|
71
|
+
target_prefix =
|
72
|
+
LOCAL_LIBS =
|
73
|
+
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lcrypt -lm -lc -lBounceStudio
|
74
|
+
SRCS = bounce_studio.c
|
75
|
+
OBJS = bounce_studio.o
|
76
|
+
TARGET = bounce_studio
|
77
|
+
DLLIB = $(TARGET).so
|
78
|
+
STATIC_LIB =
|
79
|
+
|
80
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
81
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
82
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
83
|
+
|
84
|
+
TARGET_SO = $(DLLIB)
|
85
|
+
CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
|
86
|
+
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
87
|
+
|
88
|
+
all: $(DLLIB)
|
89
|
+
static: $(STATIC_LIB)
|
90
|
+
|
91
|
+
clean:
|
92
|
+
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
93
|
+
|
94
|
+
distclean: clean
|
95
|
+
@-$(RM) Makefile extconf.h conftest.* mkmf.log
|
96
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
97
|
+
|
98
|
+
realclean: distclean
|
99
|
+
install: install-so install-rb
|
100
|
+
|
101
|
+
install-so: $(RUBYARCHDIR)
|
102
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
103
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
104
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
105
|
+
install-rb: pre-install-rb install-rb-default
|
106
|
+
install-rb-default: pre-install-rb-default
|
107
|
+
pre-install-rb: Makefile
|
108
|
+
pre-install-rb-default: Makefile
|
109
|
+
$(RUBYARCHDIR):
|
110
|
+
$(MAKEDIRS) $@
|
111
|
+
|
112
|
+
site-install: site-install-so site-install-rb
|
113
|
+
site-install-so: install-so
|
114
|
+
site-install-rb: install-rb
|
115
|
+
|
116
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
117
|
+
|
118
|
+
.cc.o:
|
119
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
120
|
+
|
121
|
+
.cxx.o:
|
122
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
123
|
+
|
124
|
+
.cpp.o:
|
125
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
126
|
+
|
127
|
+
.C.o:
|
128
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
129
|
+
|
130
|
+
.c.o:
|
131
|
+
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
132
|
+
|
133
|
+
$(DLLIB): $(OBJS)
|
134
|
+
@-$(RM) $@
|
135
|
+
$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $@ $(OBJS) $(LOCAL_LIBS) $(LIBS)
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
$(OBJS): ruby.h defines.h
|
data/ext/bounce_studio.c
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
#include "ruby.h"
|
2
|
+
#include "BounceStudio.h"
|
3
|
+
|
4
|
+
/*
|
5
|
+
Type Description
|
6
|
+
0 NON BOUNCE
|
7
|
+
10 HARD BOUNCE
|
8
|
+
20 SOFT BOUNCE - General
|
9
|
+
21 SOFT BOUNCE - Dns Failure
|
10
|
+
22 SOFT BOUNCE - Mailbox Full
|
11
|
+
23 SOFT BOUNCE - Message Size Too Large
|
12
|
+
30 BOUNCE WITH NO EMAIL ADDRESS
|
13
|
+
40 GENERAL BOUNCE
|
14
|
+
50 MAIL BLOCK - General
|
15
|
+
51 MAIL BLOCK - Known Spammer
|
16
|
+
52 MAIL BLOCK - Spam Detected
|
17
|
+
53 MAIL BLOCK - Attachment Detected
|
18
|
+
54 MAIL BLOCK - Relay Denied
|
19
|
+
60 AUTO REPLY
|
20
|
+
70 TRANSIENT BOUNCE
|
21
|
+
80 SUBSCRIBE REQUEST
|
22
|
+
90 UNSUBSCRIBE REQUEST
|
23
|
+
100 CHALLENGE RESPONSE
|
24
|
+
*/
|
25
|
+
|
26
|
+
/*
|
27
|
+
* BounceStudio.new()
|
28
|
+
*/
|
29
|
+
static char *license;
|
30
|
+
static int bs_initialized;
|
31
|
+
|
32
|
+
static VALUE rb_bs_init(VALUE self, VALUE lic_string) {
|
33
|
+
if( bs_initialized != 1 ) {
|
34
|
+
bsBounceStudio_init();
|
35
|
+
bs_initialized = 1;
|
36
|
+
}
|
37
|
+
license = StringValuePtr(lic_string);
|
38
|
+
return Qtrue;
|
39
|
+
}
|
40
|
+
|
41
|
+
/*
|
42
|
+
* BounceStudio#check(raw)
|
43
|
+
* wraps C bsBounceCheck()
|
44
|
+
*/
|
45
|
+
static VALUE rb_bs_check(VALUE self, VALUE raw) {
|
46
|
+
int BounceCode;
|
47
|
+
char *RawMessage, *EmailAddress;
|
48
|
+
|
49
|
+
RawMessage = StringValuePtr(raw);
|
50
|
+
|
51
|
+
BounceCode = bsBounceCheck(RawMessage, &EmailAddress, "", license);
|
52
|
+
|
53
|
+
return INT2NUM(BounceCode);
|
54
|
+
}
|
55
|
+
|
56
|
+
/*
|
57
|
+
* BounceStudio#get_body(raw)
|
58
|
+
* wraps C bsGetBody()
|
59
|
+
*/
|
60
|
+
static VALUE rb_bs_body(VALUE self, VALUE raw) {
|
61
|
+
char *RawMessage;
|
62
|
+
char *ReturnValue = NULL;
|
63
|
+
|
64
|
+
RawMessage = StringValuePtr(raw);
|
65
|
+
bsGetBody(RawMessage, &ReturnValue);
|
66
|
+
|
67
|
+
return rb_str_new2(ReturnValue);
|
68
|
+
}
|
69
|
+
|
70
|
+
/*
|
71
|
+
* BounceStudio#from_address(raw)
|
72
|
+
* wraps C bsGetFromAddress()
|
73
|
+
*/
|
74
|
+
static VALUE rb_bs_from_address(VALUE self, VALUE raw) {
|
75
|
+
char *RawMessage;
|
76
|
+
char *ReturnValue = NULL;
|
77
|
+
|
78
|
+
RawMessage = StringValuePtr(raw);
|
79
|
+
bsGetFromAddress(RawMessage, &ReturnValue);
|
80
|
+
|
81
|
+
return rb_str_new2(ReturnValue);
|
82
|
+
}
|
83
|
+
|
84
|
+
/*
|
85
|
+
* BounceStudio#from_friendly_name(raw)
|
86
|
+
* wraps C bsGetFromFriendlyName()
|
87
|
+
*/
|
88
|
+
static VALUE rb_bs_from_friendly_name(VALUE self, VALUE raw) {
|
89
|
+
char *RawMessage;
|
90
|
+
char *ReturnValue = NULL;
|
91
|
+
|
92
|
+
RawMessage = StringValuePtr(raw);
|
93
|
+
bsGetFromFriendlyName(RawMessage, &ReturnValue);
|
94
|
+
|
95
|
+
return rb_str_new2(ReturnValue);
|
96
|
+
}
|
97
|
+
|
98
|
+
/*
|
99
|
+
* BounceStudio#header(raw)
|
100
|
+
* wraps C bsGetHeader()
|
101
|
+
*/
|
102
|
+
static VALUE rb_bs_header(VALUE self, VALUE raw) {
|
103
|
+
char *RawMessage;
|
104
|
+
char *ReturnValue = NULL;
|
105
|
+
|
106
|
+
RawMessage = StringValuePtr(raw);
|
107
|
+
bsGetHeader(RawMessage, &ReturnValue);
|
108
|
+
|
109
|
+
return rb_str_new2(ReturnValue);
|
110
|
+
}
|
111
|
+
|
112
|
+
/*
|
113
|
+
* BounceStudio#reply_to_address(raw)
|
114
|
+
* wraps C bsGetReplyToAddress()
|
115
|
+
*/
|
116
|
+
static VALUE rb_bs_reply_to_address(VALUE self, VALUE raw) {
|
117
|
+
char *RawMessage;
|
118
|
+
char *ReturnValue = NULL;
|
119
|
+
|
120
|
+
RawMessage = StringValuePtr(raw);
|
121
|
+
bsGetReplyToAddress(RawMessage, &ReturnValue);
|
122
|
+
|
123
|
+
return rb_str_new2(ReturnValue);
|
124
|
+
}
|
125
|
+
|
126
|
+
/*
|
127
|
+
* BounceStudio#reply_to_friendly_name(raw)
|
128
|
+
* wraps C bsGetReplyToFriendlyName()
|
129
|
+
*/
|
130
|
+
static VALUE rb_bs_reply_to_friendly_name(VALUE self, VALUE raw) {
|
131
|
+
char *RawMessage;
|
132
|
+
char *ReturnValue = NULL;
|
133
|
+
|
134
|
+
RawMessage = StringValuePtr(raw);
|
135
|
+
bsGetReplyToFriendlyName(RawMessage, &ReturnValue);
|
136
|
+
|
137
|
+
return rb_str_new2(ReturnValue);
|
138
|
+
}
|
139
|
+
|
140
|
+
/*
|
141
|
+
* BounceStudio#subject(raw)
|
142
|
+
* wraps C bsGetSubject()
|
143
|
+
*/
|
144
|
+
static VALUE rb_bs_subject(VALUE self, VALUE raw) {
|
145
|
+
char *RawMessage;
|
146
|
+
char *ReturnValue = NULL;
|
147
|
+
|
148
|
+
RawMessage = StringValuePtr(raw);
|
149
|
+
bsGetSubject(RawMessage, &ReturnValue);
|
150
|
+
|
151
|
+
return rb_str_new2(ReturnValue);
|
152
|
+
}
|
153
|
+
|
154
|
+
/*
|
155
|
+
* BounceStudio#to_address(raw)
|
156
|
+
* wraps C bsGetToAddress()
|
157
|
+
*/
|
158
|
+
static VALUE rb_bs_to_address(VALUE self, VALUE raw) {
|
159
|
+
char *RawMessage;
|
160
|
+
char *ReturnValue = NULL;
|
161
|
+
|
162
|
+
RawMessage = StringValuePtr(raw);
|
163
|
+
bsGetToAddress(RawMessage, &ReturnValue);
|
164
|
+
|
165
|
+
return rb_str_new2(ReturnValue);
|
166
|
+
}
|
167
|
+
|
168
|
+
/*
|
169
|
+
* BounceStudio#to_friendly_name(raw)
|
170
|
+
* wraps C bsGetToFriendlyName()
|
171
|
+
*/
|
172
|
+
static VALUE rb_bs_to_friendly_name(VALUE self, VALUE raw) {
|
173
|
+
char *RawMessage;
|
174
|
+
char *ReturnValue = NULL;
|
175
|
+
|
176
|
+
RawMessage = StringValuePtr(raw);
|
177
|
+
bsGetToFriendlyName(RawMessage, &ReturnValue);
|
178
|
+
|
179
|
+
return rb_str_new2(ReturnValue);
|
180
|
+
}
|
181
|
+
|
182
|
+
/*
|
183
|
+
* BounceStudio#custom_header(raw)
|
184
|
+
* wraps C bsGetCustomHeader()
|
185
|
+
*/
|
186
|
+
static VALUE rb_bs_custom_header(VALUE self, VALUE raw, VALUE header) {
|
187
|
+
char *RawMessage;
|
188
|
+
char *Header;
|
189
|
+
char *ReturnValue = NULL;
|
190
|
+
|
191
|
+
RawMessage = StringValuePtr(raw);
|
192
|
+
Header = StringValuePtr(header);
|
193
|
+
bsGetCustomHeader(RawMessage, &ReturnValue, Header);
|
194
|
+
|
195
|
+
return rb_str_new2(ReturnValue);
|
196
|
+
}
|
197
|
+
|
198
|
+
/*
|
199
|
+
* BounceStudio#orig_custom_header(raw)
|
200
|
+
* wraps C bsGetOrigCustomHeader()
|
201
|
+
*/
|
202
|
+
static VALUE rb_bs_orig_custom_header(VALUE self, VALUE raw, VALUE header) {
|
203
|
+
char *RawMessage;
|
204
|
+
char *Header;
|
205
|
+
char *ReturnValue = NULL;
|
206
|
+
|
207
|
+
RawMessage = StringValuePtr(raw);
|
208
|
+
Header = StringValuePtr(header);
|
209
|
+
bsGetOrigCustomHeader(RawMessage, &ReturnValue, Header);
|
210
|
+
|
211
|
+
return rb_str_new2(ReturnValue);
|
212
|
+
}
|
213
|
+
|
214
|
+
/*
|
215
|
+
* Extention initializer
|
216
|
+
*/
|
217
|
+
void Init_bounce_studio() {
|
218
|
+
VALUE boogie_tools_mod =
|
219
|
+
rb_define_module("BoogieTools");
|
220
|
+
|
221
|
+
VALUE bs_class =
|
222
|
+
rb_define_class_under(boogie_tools_mod,
|
223
|
+
"BounceStudio", rb_cObject);
|
224
|
+
|
225
|
+
rb_define_method(bs_class, "initialize", rb_bs_init, 1);
|
226
|
+
rb_define_method(bs_class, "check", rb_bs_check, 1);
|
227
|
+
rb_define_method(bs_class, "body", rb_bs_body, 1);
|
228
|
+
rb_define_method(bs_class, "from_address", rb_bs_from_address, 1);
|
229
|
+
rb_define_method(bs_class, "from_friendly_name", rb_bs_from_friendly_name, 1);
|
230
|
+
rb_define_method(bs_class, "header", rb_bs_header, 1);
|
231
|
+
rb_define_method(bs_class, "reply_to_address", rb_bs_reply_to_address, 1);
|
232
|
+
rb_define_method(bs_class, "reply_to_friendly_name", rb_bs_reply_to_friendly_name, 1);
|
233
|
+
rb_define_method(bs_class, "subject", rb_bs_subject, 1);
|
234
|
+
rb_define_method(bs_class, "to_address", rb_bs_to_address, 1);
|
235
|
+
rb_define_method(bs_class, "to_friendly_name", rb_bs_to_friendly_name, 1);
|
236
|
+
rb_define_method(bs_class, "custom_header", rb_bs_custom_header, 2);
|
237
|
+
rb_define_method(bs_class, "orig_custom_header", rb_bs_orig_custom_header, 2);
|
238
|
+
}
|
239
|
+
|