Geo-Address-Mail-Standardizer-USPS-AMS
view release on metacpan or search on metacpan
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <zip4.h>
#include <z4dpv.h>
// convenience macros for a few cases:
//
// - newSVpvs only works for literals
// - might set undef via NULL pointer
#define newSVpvn_nolen(s) newSVpvn(s, strlen(s))
#define newSVpvn_nolen_undef(s) newSVpvn(s, s ? strlen(s) : 0)
MODULE = Geo::Address::Mail::Standardizer::USPS::AMS PACKAGE = Geo::Address::Mail::Standardizer::USPS::AMS PREFIX = ams_
void ams_init(SV * self)
PPCODE:
Z4OPEN_PARM z4cfg;
int status;
char * statedir;
char * datadir;
char * path_comm;
char * path_dpv;
char * path_elot;
char * path_lacslink;
char * path_suitelink;
// get paths to the database and the security key file
// as provided by the appropriate moose attributes
PUSHMARK(SP);
XPUSHs(self);
PUTBACK;
call_method("datadir", 0);
datadir = strdup(SvPV_nolen(ST(0)));
POPs;
PUSHMARK(SP);
XPUSHs(self);
PUTBACK;
call_method("statedir", 0);
statedir = strdup(SvPV_nolen(ST(0)));
POPs;
// construct all of the common paths
path_comm = malloc(strlen(datadir) + 16);
path_dpv = malloc(strlen(datadir) + 16);
path_elot = malloc(strlen(datadir) + 16);
path_lacslink = malloc(strlen(datadir) + 16);
path_suitelink = malloc(strlen(datadir) + 16);
sprintf(path_comm, "%s/comm", datadir);
sprintf(path_dpv, "%s/dpv", datadir);
sprintf(path_elot, "%s/elot", datadir);
sprintf(path_lacslink, "%s/lacslink", datadir);
sprintf(path_suitelink, "%s/suitelink", datadir);
// zero out the config structure as indicated by the
// documentation
memset(&z4cfg, 0, sizeof(Z4OPEN_PARM));
z4cfg.systemflag = 'Y';
z4cfg.abrstflag = 'N';
z4cfg.elotflag = 'N';
z4cfg.ewsflag = 'N';
z4cfg.dpvflag = 'Y';
z4cfg.llkflag = 'Y';
z4cfg.stelnkflag = 'N';
z4cfg.config.system = statedir;
z4cfg.config.address1 = path_comm;
z4cfg.config.addrindex = path_comm;
( run in 0.743 second using v1.01-cache-2.11-cpan-5511b514fd6 )