tqsllib.h
Go to the documentation of this file.
/***************************************************************************
tqsllib.h - description
-------------------
begin : Mon May 20 2002
copyright : (C) 2002 by ARRL
author : Jon Bloom
email : jbloom@arrl.org
revision : $Id: tqsllib.h,v 1.14 2013/03/01 13:26:44 k1mu Exp $
***************************************************************************/
#ifndef TQSLLIB_H
#define TQSLLIB_H
#if defined(_WIN32) && !defined(TQSL_NODLL)
#ifdef TQSLLIB_DEF
#define DLLEXPORT __declspec(dllexport)
#define DLLEXPORTDATA __declspec(dllexport)
#define CALLCONVENTION __stdcall
#else
#define DLLEXPORT __declspec(dllimport)
#define DLLEXPORTDATA __declspec(dllimport)
#define CALLCONVENTION __stdcall
#endif
#else
#define DLLEXPORT
#define DLLEXPORTDATA
#define CALLCONVENTION
#endif
#include "adif.h"
#include "cabrillo.h"
/* Sizes */
#define TQSL_MAX_PATH_LEN 256
#define TQSL_PASSWORD_MAX 80
#define TQSL_NAME_ELEMENT_MAX 256
#define TQSL_CALLSIGN_MAX 13
#define TQSL_CRQ_NAME_MAX 60
#define TQSL_CRQ_ADDR_MAX 80
#define TQSL_CRQ_CITY_MAX 80
#define TQSL_CRQ_STATE_MAX 80
#define TQSL_CRQ_POSTAL_MAX 20
#define TQSL_CRQ_COUNTRY_MAX 80
#define TQSL_CRQ_EMAIL_MAX 180
#define TQSL_BAND_MAX 6
#define TQSL_MODE_MAX 16
#define TQSL_FREQ_MAX 20
#define TQSL_SATNAME_MAX 20
#define TQSL_PROPMODE_MAX 20
#define TQSL_CERT_CB_USER 0
#define TQSL_CERT_CB_CA 1
#define TQSL_CERT_CB_ROOT 2
#define TQSL_CERT_CB_PKEY 3
#define TQSL_CERT_CB_CONFIG 4
#define TQSL_CERT_CB_CERT_TYPE(x) ((x) & 0xf)
#define TQSL_CERT_CB_MILESTONE 0
#define TQSL_CERT_CB_RESULT 0x10
#define TQSL_CERT_CB_CALL_TYPE(x) ((x) & TQSL_CERT_CB_RESULT)
#define TQSL_CERT_CB_PROMPT 0
#define TQSL_CERT_CB_DUPLICATE 0x100
#define TQSL_CERT_CB_ERROR 0x200
#define TQSL_CERT_CB_LOADED 0x300
#define TQSL_CERT_CB_RESULT_TYPE(x) ((x) & 0x0f00)
typedef void * tQSL_Cert;
typedef void * tQSL_Location;
typedef char * tQSL_StationDataEnc;
typedef struct {
int year;
int month;
int day;
} tQSL_Date;
typedef struct {
int hour;
int minute;
int second;
} tQSL_Time;
typedef struct tqsl_provider_st {
char organizationName[TQSL_NAME_ELEMENT_MAX+1];
char organizationalUnitName[TQSL_NAME_ELEMENT_MAX+1];
char emailAddress[TQSL_NAME_ELEMENT_MAX+1];
char url[TQSL_NAME_ELEMENT_MAX+1];
} TQSL_PROVIDER;
typedef struct tqsl_cert_req_st {
char providerName[TQSL_NAME_ELEMENT_MAX+1];
char providerUnit[TQSL_NAME_ELEMENT_MAX+1];
char callSign[TQSL_CALLSIGN_MAX+1];
char name[TQSL_CRQ_NAME_MAX+1];
char address1[TQSL_CRQ_ADDR_MAX+1];
char address2[TQSL_CRQ_ADDR_MAX+1];
char city[TQSL_CRQ_CITY_MAX+1];
char state[TQSL_CRQ_STATE_MAX+1];
char postalCode[TQSL_CRQ_POSTAL_MAX+1];
char country[TQSL_CRQ_COUNTRY_MAX+1];
char emailAddress[TQSL_CRQ_EMAIL_MAX+1];
int dxccEntity;
tQSL_Date qsoNotBefore;
tQSL_Date qsoNotAfter;
char password[TQSL_PASSWORD_MAX+1];
tQSL_Cert signer;
char renew;
} TQSL_CERT_REQ;
typedef struct {
char callsign[TQSL_CALLSIGN_MAX+1];
char band[TQSL_BAND_MAX+1];
char mode[TQSL_MODE_MAX+1];
tQSL_Date date;
tQSL_Time time;
char freq[TQSL_FREQ_MAX+1];
char rxfreq[TQSL_FREQ_MAX+1];
char rxband[TQSL_BAND_MAX+1];
char propmode[TQSL_PROPMODE_MAX+1];
char satname[TQSL_SATNAME_MAX+1];
} TQSL_QSO_RECORD;
DLLEXPORTDATA extern const char *tQSL_BaseDir;
#ifdef __cplusplus
extern "C" {
#endif
DLLEXPORTDATA extern int tQSL_Error;
DLLEXPORTDATA extern TQSL_ADIF_GET_FIELD_ERROR tQSL_ADIF_Error;
DLLEXPORTDATA extern TQSL_CABRILLO_ERROR_TYPE tQSL_Cabrillo_Error;
DLLEXPORTDATA extern char tQSL_ErrorFile[256];
DLLEXPORTDATA extern char tQSL_CustomError[256];
DLLEXPORTDATA extern int tQSL_Errno;
DLLEXPORTDATA extern char tQSL_ImportCall[256];
DLLEXPORT int CALLCONVENTION tqsl_init();
DLLEXPORT int CALLCONVENTION tqsl_setDirectory(const char *dir);
DLLEXPORT const char* CALLCONVENTION tqsl_getErrorString();
DLLEXPORT const char* CALLCONVENTION tqsl_getErrorString_v(int err);
DLLEXPORT int CALLCONVENTION tqsl_encodeBase64(const unsigned char *data, int datalen, char *output, int outputlen);
DLLEXPORT int CALLCONVENTION tqsl_decodeBase64(const char *input, unsigned char *data, int *datalen);
DLLEXPORT int CALLCONVENTION tqsl_initDate(tQSL_Date *date, const char *str);
DLLEXPORT int CALLCONVENTION tqsl_initTime(tQSL_Time *time, const char *str);
DLLEXPORT int CALLCONVENTION tqsl_compareDates(const tQSL_Date *a, const tQSL_Date *b);
DLLEXPORT int CALLCONVENTION tqsl_subtractDates(const tQSL_Date *a, const tQSL_Date *b, int *diff);
DLLEXPORT char* CALLCONVENTION tqsl_convertDateToText(const tQSL_Date *date, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_isDateValid(const tQSL_Date *d);
DLLEXPORT int CALLCONVENTION tqsl_isDateNull(const tQSL_Date *d);
DLLEXPORT int CALLCONVENTION tqsl_isTimeValid(const tQSL_Time *t);
DLLEXPORT char* CALLCONVENTION tqsl_convertTimeToText(const tQSL_Time *time, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getVersion(int *major, int *minor);
DLLEXPORT int CALLCONVENTION tqsl_getConfigVersion(int *major, int *minor);
#define TQSL_SELECT_CERT_WITHKEYS 1
#define TQSL_SELECT_CERT_EXPIRED 2
#define TQSL_SELECT_CERT_SUPERCEDED 4
DLLEXPORT int CALLCONVENTION tqsl_selectCertificates(tQSL_Cert **certlist, int *ncerts,
const char *callsign, int dxcc, const tQSL_Date *date, const TQSL_PROVIDER *issuer, int flag);
DLLEXPORT int CALLCONVENTION tqsl_selectCACertificates(tQSL_Cert **certlist, int *ncerts, const char *type);
DLLEXPORT int CALLCONVENTION tqsl_getSelectedCertificate(tQSL_Cert *cert, const tQSL_Cert **certlist,
int idx);
DLLEXPORT int CALLCONVENTION tqsl_isCertificateExpired(tQSL_Cert cert, int *status);
DLLEXPORT int CALLCONVENTION tqsl_isCertificateSuperceded(tQSL_Cert cert, int *status);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateKeyOnly(tQSL_Cert cert, int *keyonly);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateEncoded(tQSL_Cert cert, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getKeyEncoded(tQSL_Cert cert, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_importKeyPairEncoded(const char *callsign, const char *type, const char *keybuf, const char *certbuf);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateSerial(tQSL_Cert cert, long *serial);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateSerialExt(tQSL_Cert cert, char *serial, int serialsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateSerialLength(tQSL_Cert cert);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateIssuer(tQSL_Cert cert, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateIssuerOrganization(tQSL_Cert cert, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateIssuerOrganizationalUnit(tQSL_Cert cert, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateCallSign(tQSL_Cert cert, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateAROName(tQSL_Cert cert, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateEmailAddress(tQSL_Cert cert, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateQSONotBeforeDate(tQSL_Cert cert, tQSL_Date *date);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateQSONotAfterDate(tQSL_Cert cert, tQSL_Date *date);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateNotBeforeDate(tQSL_Cert cert, tQSL_Date *date);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateNotAfterDate(tQSL_Cert cert, tQSL_Date *date);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateDXCCEntity(tQSL_Cert cert, int *dxcc);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateRequestAddress1(tQSL_Cert cert, char *str, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateRequestAddress2(tQSL_Cert cert, char *str, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateRequestCity(tQSL_Cert cert, char *str, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateRequestState(tQSL_Cert cert, char *str, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateRequestPostalCode(tQSL_Cert cert, char *str, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getCertificateRequestCountry(tQSL_Cert cert, char *str, int bufsiz);
#define TQSL_PK_TYPE_ERR 0
#define TQSL_PK_TYPE_NONE 1
#define TQSL_PK_TYPE_UNENC 2
#define TQSL_PK_TYPE_ENC 3
DLLEXPORT int CALLCONVENTION tqsl_getCertificatePrivateKeyType(tQSL_Cert cert);
DLLEXPORT void CALLCONVENTION tqsl_freeCertificate(tQSL_Cert cert);
#define TQSL_CERT_STATUS_UNK 0
#define TQSL_CERT_STATUS_SUP 1
#define TQSL_CERT_STATUS_EXP 2
#define TQSL_CERT_STATUS_OK 3
#define TQSL_CERT_STATUS_INV 4
DLLEXPORT int CALLCONVENTION tqsl_getCertificateStatus(long serial);
DLLEXPORT int CALLCONVENTION tqsl_setCertificateStatus(long serial, const char *status);
/* int tqsl_checkCertificate(tQSL_Cert); */
DLLEXPORT int CALLCONVENTION tqsl_importTQSLFile(const char *file, int(*cb)(int type, const char *message, void *userdata), void *user);
DLLEXPORT int CALLCONVENTION tqsl_getSerialFromTQSLFile(const char *file, long *serial);
DLLEXPORT int CALLCONVENTION tqsl_getNumProviders(int *n);
DLLEXPORT int CALLCONVENTION tqsl_getProvider(int idx, TQSL_PROVIDER *provider);
DLLEXPORT int CALLCONVENTION tqsl_createCertRequest(const char *filename, TQSL_CERT_REQ *req,
int(*pwcb)(char *pwbuf, int pwsize, void *userdata), void *user);
DLLEXPORT int CALLCONVENTION tqsl_exportPKCS12File(tQSL_Cert cert, const char *filename, const char *p12password);
DLLEXPORT int CALLCONVENTION tqsl_exportPKCS12Base64(tQSL_Cert cert, char *base64, int b64len, const char *p12password);
DLLEXPORT int CALLCONVENTION tqsl_importPKCS12File(const char *filename, const char *p12password, const char *password,
int (*pwcb)(char *buf, int bufsiz, void *userdata), int(*cb)(int type , const char *message, void *userdata), void *user);
DLLEXPORT int CALLCONVENTION tqsl_importPKCS12Base64(const char *base64, const char *p12password, const char *password,
int (*pwcb)(char *buf, int bufsiz, void *userdata), int(*cb)(int type , const char *message, void *userdata), void *user);
DLLEXPORT int CALLCONVENTION tqsl_deleteCertificate(tQSL_Cert cert);
DLLEXPORT int CALLCONVENTION tqsl_beginSigning(tQSL_Cert cert, char *password, int(*pwcb)(char *pwbuf, int pwsize, void *userdata), void *user);
DLLEXPORT int CALLCONVENTION tqsl_checkSigningStatus(tQSL_Cert cert);
DLLEXPORT int CALLCONVENTION tqsl_getMaxSignatureSize(tQSL_Cert cert, int *sigsize);
DLLEXPORT int CALLCONVENTION tqsl_signDataBlock(tQSL_Cert cert, const unsigned char *data, int datalen, unsigned char *sig, int *siglen);
DLLEXPORT int CALLCONVENTION tqsl_verifyDataBlock(tQSL_Cert cert, const unsigned char *data, int datalen, unsigned char *sig, int siglen);
DLLEXPORT int CALLCONVENTION tqsl_signQSORecord(tQSL_Cert cert, tQSL_Location loc, TQSL_QSO_RECORD *rec, unsigned char *sig, int *siglen);
DLLEXPORT int CALLCONVENTION tqsl_endSigning(tQSL_Cert cert);
/* Location field input types */
#define TQSL_LOCATION_FIELD_TEXT 1
#define TQSL_LOCATION_FIELD_DDLIST 2
#define TQSL_LOCATION_FIELD_LIST 3
#define TQSL_LOCATION_FIELD_BADZONE 4
/* Location field data types */
#define TQSL_LOCATION_FIELD_CHAR 1
#define TQSL_LOCATION_FIELD_INT 2
DLLEXPORT int CALLCONVENTION tqsl_initStationLocationCapture(tQSL_Location *locp);
DLLEXPORT int CALLCONVENTION tqsl_endStationLocationCapture(tQSL_Location *locp);
DLLEXPORT int CALLCONVENTION tqsl_updateStationLocationCapture(tQSL_Location loc);
DLLEXPORT int CALLCONVENTION tqsl_getNumStationLocationCapturePages(tQSL_Location loc, int *npages);
DLLEXPORT int CALLCONVENTION tqsl_getStationLocationCapturePage(tQSL_Location loc, int *page);
DLLEXPORT int CALLCONVENTION tqsl_setStationLocationCapturePage(tQSL_Location loc, int page);
DLLEXPORT int CALLCONVENTION tqsl_setStationLocationCertFlags(tQSL_Location loc, int flags);
DLLEXPORT int CALLCONVENTION tqsl_nextStationLocationCapture(tQSL_Location loc);
DLLEXPORT int CALLCONVENTION tqsl_prevStationLocationCapture(tQSL_Location loc);
DLLEXPORT int CALLCONVENTION tqsl_hasNextStationLocationCapture(tQSL_Location loc, int *rval);
DLLEXPORT int CALLCONVENTION tqsl_hasPrevStationLocationCapture(tQSL_Location loc, int *rval);
DLLEXPORT int CALLCONVENTION tqsl_saveStationLocationCapture(tQSL_Location loc, int overwrite);
DLLEXPORT int CALLCONVENTION tqsl_getStationLocationCaptureName(tQSL_Location loc, char *namebuf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_setStationLocationCaptureName(tQSL_Location loc, const char *name);
DLLEXPORT int CALLCONVENTION tqsl_getNumStationLocations(tQSL_Location loc, int *nloc);
DLLEXPORT int CALLCONVENTION tqsl_getStationLocationName(tQSL_Location loc, int idx, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getStationLocationCallSign(tQSL_Location loc, int idx, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getStationLocationField(tQSL_Location locp, const char *name, char *namebuf, int bufsize);
DLLEXPORT int CALLCONVENTION tqsl_getStationLocation(tQSL_Location *loc, const char *name);
DLLEXPORT int CALLCONVENTION tqsl_getStationLocationErrors(tQSL_Location loc, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getStationDataEnc(tQSL_StationDataEnc *sdata);
DLLEXPORT int CALLCONVENTION tqsl_freeStationDataEnc(tQSL_StationDataEnc sdata);
DLLEXPORT int CALLCONVENTION tqsl_mergeStationLocations(const char *locdata);
DLLEXPORT int CALLCONVENTION tqsl_deleteStationLocation(const char *name);
DLLEXPORT int CALLCONVENTION tqsl_getNumLocationField(tQSL_Location loc, int *numf);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldDataLabelSize(tQSL_Location loc, int field_num, int *rval);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldDataLabel(tQSL_Location loc, int field_num, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldDataGABBISize(tQSL_Location loc, int field_num, int *rval);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldDataGABBI(tQSL_Location loc, int field_num, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldInputType(tQSL_Location loc, int field_num, int *type);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldDataType(tQSL_Location loc, int field_num, int *type);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldFlags(tQSL_Location loc, int field_num, int *flags);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldDataLength(tQSL_Location loc, int field_num, int *rval);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldCharData(tQSL_Location loc, int field_num, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldIntData(tQSL_Location loc, int field_num, int *dat);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldIndex(tQSL_Location loc, int field_num, int *dat);
DLLEXPORT int CALLCONVENTION tqsl_getNumLocationFieldListItems(tQSL_Location loc, int field_num, int *rval);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldListItem(tQSL_Location loc, int field_num, int item_idx, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_setLocationFieldCharData(tQSL_Location loc, int field_num, const char *buf);
DLLEXPORT int CALLCONVENTION tqsl_setLocationFieldIntData(tQSL_Location loc, int field_num, int dat);
DLLEXPORT int CALLCONVENTION tqsl_setLocationFieldIndex(tQSL_Location loc, int field_num, int dat);
DLLEXPORT int CALLCONVENTION tqsl_getLocationFieldChanged(tQSL_Location loc, int field_num, int *changed);
DLLEXPORT int CALLCONVENTION tqsl_getLocationCallSign(tQSL_Location loc, char *buf, int bufsiz);
DLLEXPORT int CALLCONVENTION tqsl_getLocationDXCCEntity(tQSL_Location loc, int *dxcc);
DLLEXPORT int CALLCONVENTION tqsl_getNumDXCCEntity(int *number);
DLLEXPORT int CALLCONVENTION tqsl_getDXCCEntity(int index, int *number, const char **name);
DLLEXPORT int CALLCONVENTION tqsl_getDXCCEntityName(int number, const char **name);
DLLEXPORT int CALLCONVENTION tqsl_getDXCCZoneMap(int number, const char **zonemap);
DLLEXPORT int CALLCONVENTION tqsl_getNumBand(int *number);
DLLEXPORT int CALLCONVENTION tqsl_getBand(int index, const char **name, const char **spectrum, int *low, int *high);
DLLEXPORT int CALLCONVENTION tqsl_getNumMode(int *number);
DLLEXPORT int CALLCONVENTION tqsl_getMode(int index, const char **mode, const char **group);
DLLEXPORT int CALLCONVENTION tqsl_getNumPropagationMode(int *number);
DLLEXPORT int CALLCONVENTION tqsl_getPropagationMode(int index, const char **name, const char **descrip);
DLLEXPORT int CALLCONVENTION tqsl_getNumSatellite(int *number);
DLLEXPORT int CALLCONVENTION tqsl_getSatellite(int index, const char **name, const char **descrip,
tQSL_Date *start, tQSL_Date *end);
DLLEXPORT int CALLCONVENTION tqsl_clearCabrilloMap();
DLLEXPORT int CALLCONVENTION tqsl_setCabrilloMapEntry(const char *contest, int field, int contest_type);
DLLEXPORT int CALLCONVENTION tqsl_getCabrilloMapEntry(const char *contest, int *fieldnum, int *contest_type);
DLLEXPORT int CALLCONVENTION tqsl_clearADIFModes();
DLLEXPORT int CALLCONVENTION tqsl_setADIFMode(const char *adif_item, const char *mode);
DLLEXPORT int CALLCONVENTION tqsl_getADIFMode(const char *adif_item, char *mode, int nmode);
DLLEXPORT const char* CALLCONVENTION tqsl_getGABBItCERT(tQSL_Cert cert, int uid);
DLLEXPORT const char* CALLCONVENTION tqsl_getGABBItSTATION(tQSL_Location loc, int uid, int certuid);
DLLEXPORT const char* CALLCONVENTION tqsl_getGABBItCONTACT(tQSL_Cert cert, tQSL_Location loc, TQSL_QSO_RECORD *qso,
int stationuid);
DLLEXPORT const char* CALLCONVENTION tqsl_getGABBItCONTACTData(tQSL_Cert cert, tQSL_Location loc, TQSL_QSO_RECORD *qso,
int stationuid, char *signdata, int sdlen);
#ifdef __cplusplus
}
#endif
/* Useful defines */
#define TQSL_MAX_PW_LENGTH 32
#endif /* TQSLLIB_H */