00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef TQSLLIB_H
00012 #define TQSLLIB_H
00013
00014 #ifdef HAVE_CONFIG_H
00015 #include "sysconfig.h"
00016 #endif
00017
00018 #ifdef __WIN32__
00019 #ifdef TQSLLIB_DEF
00020 #define DLLEXPORT __declspec(dllexport)
00021 #else
00022 #define DLLEXPORT __declspec(dllimport)
00023 #endif
00024 #else
00025 #define DLLEXPORT
00026 #endif
00027
00028 #include "adif.h"
00029 #include "cabrillo.h"
00030
00035
00036 #define TQSL_MAX_PATH_LEN 256
00037 #define TQSL_PASSWORD_MAX 80
00038 #define TQSL_NAME_ELEMENT_MAX 256
00039 #define TQSL_CALLSIGN_MAX 13
00040 #define TQSL_CRQ_NAME_MAX 60
00041 #define TQSL_CRQ_ADDR_MAX 80
00042 #define TQSL_CRQ_CITY_MAX 80
00043 #define TQSL_CRQ_STATE_MAX 80
00044 #define TQSL_CRQ_POSTAL_MAX 20
00045 #define TQSL_CRQ_COUNTRY_MAX 80
00046 #define TQSL_CRQ_EMAIL_MAX 180
00047 #define TQSL_BAND_MAX 6
00048 #define TQSL_MODE_MAX 16
00049 #define TQSL_FREQ_MAX 20
00050 #define TQSL_SATNAME_MAX 6
00051 #define TQSL_PROPMODE_MAX 6
00052
00053 #define TQSL_CERT_CB_USER 0
00054 #define TQSL_CERT_CB_CA 1
00055 #define TQSL_CERT_CB_ROOT 2
00056 #define TQSL_CERT_CB_PKEY 3
00057 #define TQSL_CERT_CB_CONFIG 4
00058 #define TQSL_CERT_CB_CERT_TYPE(x) ((x) & 0xf)
00059 #define TQSL_CERT_CB_MILESTONE 0
00060 #define TQSL_CERT_CB_RESULT 0x10
00061 #define TQSL_CERT_CB_CALL_TYPE(x) ((x) & TQSL_CERT_CB_RESULT)
00062 #define TQSL_CERT_CB_PROMPT 0
00063 #define TQSL_CERT_CB_DUPLICATE 0x100
00064 #define TQSL_CERT_CB_ERROR 0x200
00065 #define TQSL_CERT_CB_LOADED 0x300
00066 #define TQSL_CERT_CB_RESULT_TYPE(x) ((x) & 0x0f00)
00067
00068 typedef void * tQSL_Cert;
00069 typedef void * tQSL_Location;
00070
00072 typedef struct {
00073 int year;
00074 int month;
00075 int day;
00076 } tQSL_Date;
00077
00079 typedef struct {
00080 int hour;
00081 int minute;
00082 int second;
00083 } tQSL_Time;
00084
00086 typedef struct tqsl_provider_st {
00087 char organizationName[TQSL_NAME_ELEMENT_MAX+1];
00088 char organizationalUnitName[TQSL_NAME_ELEMENT_MAX+1];
00089 char emailAddress[TQSL_NAME_ELEMENT_MAX+1];
00090 char url[TQSL_NAME_ELEMENT_MAX+1];
00091 } TQSL_PROVIDER;
00092
00094 typedef struct tqsl_cert_req_st {
00095 char providerName[TQSL_NAME_ELEMENT_MAX+1];
00096 char providerUnit[TQSL_NAME_ELEMENT_MAX+1];
00097 char callSign[TQSL_CALLSIGN_MAX+1];
00098 char name[TQSL_CRQ_NAME_MAX+1];
00099 char address1[TQSL_CRQ_ADDR_MAX+1];
00100 char address2[TQSL_CRQ_ADDR_MAX+1];
00101 char city[TQSL_CRQ_CITY_MAX+1];
00102 char state[TQSL_CRQ_STATE_MAX+1];
00103 char postalCode[TQSL_CRQ_POSTAL_MAX+1];
00104 char country[TQSL_CRQ_COUNTRY_MAX+1];
00105 char emailAddress[TQSL_CRQ_EMAIL_MAX+1];
00106 int dxccEntity;
00107 tQSL_Date qsoNotBefore;
00108 tQSL_Date qsoNotAfter;
00109 char password[TQSL_PASSWORD_MAX+1];
00110 tQSL_Cert signer;
00111 char renew;
00112 } TQSL_CERT_REQ;
00113
00115 typedef struct {
00116 char callsign[TQSL_CALLSIGN_MAX+1];
00117 char band[TQSL_BAND_MAX+1];
00118 char mode[TQSL_MODE_MAX+1];
00119 tQSL_Date date;
00120 tQSL_Time time;
00121 char freq[TQSL_FREQ_MAX+1];
00122 char rxfreq[TQSL_FREQ_MAX+1];
00123 char rxband[TQSL_BAND_MAX+1];
00124 char propmode[TQSL_PROPMODE_MAX+1];
00125 char satname[TQSL_SATNAME_MAX+1];
00126 } TQSL_QSO_RECORD;
00127
00129 extern const char *tQSL_BaseDir;
00130
00131 #ifdef __cplusplus
00132 extern "C" {
00133 #endif
00134
00139
00140
00142 DLLEXPORT extern int tQSL_Error;
00144 DLLEXPORT extern TQSL_ADIF_GET_FIELD_ERROR tQSL_ADIF_Error;
00146 DLLEXPORT extern TQSL_CABRILLO_ERROR_TYPE tQSL_Cabrillo_Error;
00148 DLLEXPORT extern char tQSL_ErrorFile[256];
00150 DLLEXPORT extern char tQSL_CustomError[256];
00151
00156 int tqsl_init();
00157
00167 int tqsl_setDirectory(const char *dir);
00168
00172 const char *tqsl_getErrorString();
00173
00178 const char *tqsl_getErrorString_v(int err);
00179
00187 int tqsl_encodeBase64(const unsigned char *data, int datalen, char *output, int outputlen);
00188
00197 int tqsl_decodeBase64(const char *input, unsigned char *data, int *datalen);
00198
00205 int tqsl_initDate(tQSL_Date *date, const char *str);
00206
00213 int tqsl_initTime(tQSL_Time *time, const char *str);
00214
00224 int tqsl_compareDates(const tQSL_Date *a, const tQSL_Date *b);
00225
00230 char *tqsl_convertDateToText(const tQSL_Date *date, char *buf, int bufsiz);
00231
00236 int tqsl_isDateValid(const tQSL_Date *d);
00237
00242 int tqsl_isDateNull(const tQSL_Date *d);
00243
00248 int tqsl_isTimeValid(const tQSL_Time *t);
00249
00254 char *tqsl_convertTimeToText(const tQSL_Time *time, char *buf, int bufsiz);
00255
00258 int tqsl_getVersion(int *major, int *minor);
00259
00262 int tqsl_getConfigVersion(int *major, int *minor);
00263
00292 #define TQSL_SELECT_CERT_WITHKEYS 1
00293 #define TQSL_SELECT_CERT_EXPIRED 2
00294 #define TQSL_SELECT_CERT_SUPERCEDED 4
00295
00321 int tqsl_selectCertificates(tQSL_Cert **certlist, int *ncerts,
00322 const char *callsign, int dxcc, const tQSL_Date *date, const TQSL_PROVIDER *issuer, int flag);
00323
00326 int tqsl_getCertificateKeyOnly(tQSL_Cert cert, int *keyonly);
00327
00330 int tqsl_getCertificateEncoded(tQSL_Cert cert, char *buf, int bufsiz);
00331
00334 int tqsl_getCertificateSerial(tQSL_Cert cert, long *serial);
00335
00345 int tqsl_getCertificateIssuer(tQSL_Cert cert, char *buf, int bufsiz);
00346
00356 int tqsl_getCertificateIssuerOrganization(tQSL_Cert cert, char *buf, int bufsiz);
00366 int tqsl_getCertificateIssuerOrganizationalUnit(tQSL_Cert cert, char *buf, int bufsiz);
00376 int tqsl_getCertificateCallSign(tQSL_Cert cert, char *buf, int bufsiz);
00386 int tqsl_getCertificateAROName(tQSL_Cert cert, char *buf, int bufsiz);
00387
00397 int tqsl_getCertificateEmailAddress(tQSL_Cert cert, char *buf, int bufsiz);
00398
00407 int tqsl_getCertificateQSONotBeforeDate(tQSL_Cert cert, tQSL_Date *date);
00408
00417 int tqsl_getCertificateQSONotAfterDate(tQSL_Cert cert, tQSL_Date *date);
00418
00427 int tqsl_getCertificateNotBeforeDate(tQSL_Cert cert, tQSL_Date *date);
00428
00437 int tqsl_getCertificateNotAfterDate(tQSL_Cert cert, tQSL_Date *date);
00438
00447 int tqsl_getCertificateDXCCEntity(tQSL_Cert cert, int *dxcc);
00448
00459 int tqsl_getCertificateRequestAddress1(tQSL_Cert cert, char *str, int bufsiz);
00460
00471 int tqsl_getCertificateRequestAddress2(tQSL_Cert cert, char *str, int bufsiz);
00472
00483 int tqsl_getCertificateRequestCity(tQSL_Cert cert, char *str, int bufsiz);
00484
00495 int tqsl_getCertificateRequestState(tQSL_Cert cert, char *str, int bufsiz);
00496
00507 int tqsl_getCertificateRequestPostalCode(tQSL_Cert cert, char *str, int bufsiz);
00508
00519 int tqsl_getCertificateRequestCountry(tQSL_Cert cert, char *str, int bufsiz);
00520
00521 #define TQSL_PK_TYPE_ERR 0
00522 #define TQSL_PK_TYPE_NONE 1
00523 #define TQSL_PK_TYPE_UNENC 2
00524 #define TQSL_PK_TYPE_ENC 3
00525
00540 int tqsl_getCertificatePrivateKeyType(tQSL_Cert cert);
00541
00542
00546 void tqsl_freeCertificate(tQSL_Cert cert);
00547
00548
00549
00567 int tqsl_importTQSLFile(const char *file, int(*cb)(int type, const char *message, void *userdata), void *user);
00568
00571 int tqsl_getNumProviders(int *n);
00572
00577 int tqsl_getProvider(int idx, TQSL_PROVIDER *provider);
00578
00591 int tqsl_createCertRequest(const char *filename, TQSL_CERT_REQ *req,
00592 int(*pwcb)(char *pwbuf, int pwsize, void *userdata), void *user);
00593
00601 int tqsl_exportPKCS12File(tQSL_Cert cert, const char *filename, const char *p12password);
00602
00605 int tqsl_importPKCS12File(const char *filename, const char *p12password, const char *password,
00606 int (*pwcb)(char *buf, int bufsiz, void *userdata), int(*cb)(int type , const char *message, void *userdata), void *user);
00607
00610 int tqsl_deleteCertificate(tQSL_Cert cert);
00611
00634 int tqsl_beginSigning(tQSL_Cert cert, char *password, int(*pwcb)(char *pwbuf, int pwsize, void *userdata), void *user);
00635
00640 int tqsl_checkSigningStatus(tQSL_Cert cert);
00641
00646 int tqsl_getMaxSignatureSize(tQSL_Cert cert, int *sigsize);
00647
00653 int tqsl_signDataBlock(tQSL_Cert cert, const unsigned char *data, int datalen, unsigned char *sig, int *siglen);
00654
00659 int tqsl_verifyDataBlock(tQSL_Cert cert, const unsigned char *data, int datalen, unsigned char *sig, int siglen);
00660
00668 int tqsl_signQSORecord(tQSL_Cert cert, tQSL_Location loc, TQSL_QSO_RECORD *rec, unsigned char *sig, int *siglen);
00669
00674 int tqsl_endSigning(tQSL_Cert cert);
00675
00777
00778
00779 #define TQSL_LOCATION_FIELD_TEXT 1
00780 #define TQSL_LOCATION_FIELD_DDLIST 2
00781 #define TQSL_LOCATION_FIELD_LIST 3
00782
00783
00784 #define TQSL_LOCATION_FIELD_CHAR 1
00785 #define TQSL_LOCATION_FIELD_INT 2
00786
00788 int tqsl_initStationLocationCapture(tQSL_Location *locp);
00789
00794 int tqsl_endStationLocationCapture(tQSL_Location *locp);
00795
00797 int tqsl_updateStationLocationCapture(tQSL_Location loc);
00798
00799
00800
00802 int tqsl_getStationLocationCapturePage(tQSL_Location loc, int *page);
00803
00808 int tqsl_setStationLocationCapturePage(tQSL_Location loc, int page);
00809
00811 int tqsl_nextStationLocationCapture(tQSL_Location loc);
00812
00814 int tqsl_prevStationLocationCapture(tQSL_Location loc);
00815
00817 int tqsl_hasNextStationLocationCapture(tQSL_Location loc, int *rval);
00818
00820 int tqsl_hasPrevStationLocationCapture(tQSL_Location loc, int *rval);
00821
00828 int tqsl_saveStationLocationCapture(tQSL_Location loc, int overwrite);
00829
00831 int tqsl_getStationLocationCaptureName(tQSL_Location loc, char *namebuf, int bufsiz);
00832
00834 int tqsl_setStationLocationCaptureName(tQSL_Location loc, const char *name);
00835
00837 int tqsl_getNumStationLocations(tQSL_Location loc, int *nloc);
00838
00840 int tqsl_getStationLocationName(tQSL_Location loc, int idx, char *buf, int bufsiz);
00841
00843 int tqsl_getStationLocationCallSign(tQSL_Location loc, int idx, char *buf, int bufsiz);
00844
00849 int tqsl_getStationLocation(tQSL_Location *loc, const char *name);
00850
00852 int tqsl_deleteStationLocation(const char *name);
00853
00855 int tqsl_getNumLocationField(tQSL_Location loc, int *numf);
00856
00858 int tqsl_getLocationFieldDataLabelSize(tQSL_Location loc, int field_num, int *rval);
00859
00861 int tqsl_getLocationFieldDataLabel(tQSL_Location loc, int field_num, char *buf, int bufsiz);
00862
00864 int tqsl_getLocationFieldDataGABBISize(tQSL_Location loc, int field_num, int *rval);
00865
00867 int tqsl_getLocationFieldDataGABBI(tQSL_Location loc, int field_num, char *buf, int bufsiz);
00868
00874 int tqsl_getLocationFieldInputType(tQSL_Location loc, int field_num, int *type);
00875
00880 int tqsl_getLocationFieldDataType(tQSL_Location loc, int field_num, int *type);
00881
00883 int tqsl_getLocationFieldDataLength(tQSL_Location loc, int field_num, int *rval);
00884
00891 int tqsl_getLocationFieldCharData(tQSL_Location loc, int field_num, char *buf, int bufsiz);
00892
00898 int tqsl_getLocationFieldIntData(tQSL_Location loc, int field_num, int *dat);
00899
00904 int tqsl_getLocationFieldIndex(tQSL_Location loc, int field_num, int *dat);
00905
00907 int tqsl_getNumLocationFieldListItems(tQSL_Location loc, int field_num, int *rval);
00908
00910 int tqsl_getLocationFieldListItem(tQSL_Location loc, int field_num, int item_idx, char *buf, int bufsiz);
00911
00913 int tqsl_setLocationFieldCharData(tQSL_Location loc, int field_num, const char *buf);
00914
00917 int tqsl_setLocationFieldIntData(tQSL_Location loc, int field_num, int dat);
00918
00923 int tqsl_setLocationFieldIndex(tQSL_Location loc, int field_num, int dat);
00924
00929 int tqsl_getLocationFieldChanged(tQSL_Location loc, int field_num, int *changed);
00930
00932 int tqsl_getLocationCallSign(tQSL_Location loc, char *buf, int bufsiz);
00933
00935 int tqsl_getLocationDXCCEntity(tQSL_Location loc, int *dxcc);
00936
00939 int tqsl_getNumDXCCEntity(int *number);
00940
00943 int tqsl_getDXCCEntity(int index, int *number, const char **name);
00944
00947 int tqsl_getDXCCEntityName(int number, const char **name);
00948
00950 int tqsl_getNumBand(int *number);
00951
00961 int tqsl_getBand(int index, const char **name, const char **spectrum, int *low, int *high);
00962
00964 int tqsl_getNumMode(int *number);
00965
00973 int tqsl_getMode(int index, const char **mode, const char **group);
00974
00976 int tqsl_getNumPropagationMode(int *number);
00977
00985 int tqsl_getPropagationMode(int index, const char **name, const char **descrip);
00986
00988 int tqsl_getNumSatellite(int *number);
00989
00999 int tqsl_getSatellite(int index, const char **name, const char **descrip,
01000 tQSL_Date *start, tQSL_Date *end);
01001
01004 int tqsl_clearCabrilloMap();
01005
01016 int tqsl_setCabrilloMapEntry(const char *contest, int field, int contest_type);
01017
01029 int tqsl_getCabrilloMapEntry(const char *contest, int *fieldnum, int *contest_type);
01030
01033 int tqsl_clearADIFModes();
01034
01037 int tqsl_setADIFMode(const char *adif_item, const char *mode);
01038
01041 int tqsl_getADIFMode(const char *adif_item, char *mode, int nmode);
01042
01052 const char *tqsl_getGABBItCERT(tQSL_Cert cert, int uid);
01053
01064 const char *tqsl_getGABBItSTATION(tQSL_Location loc, int uid, int certuid);
01065
01078 const char *tqsl_getGABBItCONTACT(tQSL_Cert cert, tQSL_Location loc, TQSL_QSO_RECORD *qso,
01079 int stationuid);
01080
01083 #ifdef __cplusplus
01084 }
01085 #endif
01086
01087
01088 #define TQSL_MAX_PW_LENGTH 32
01089
01090 #endif