|
|
1.1 ! root 1: /* smblib.h */ ! 2: ! 3: /* Synchronet message base (SMB) library function prototypes */ ! 4: ! 5: /* $Id: smblib.h,v 1.63 2005/10/02 23:28:57 rswindell Exp $ */ ! 6: ! 7: /**************************************************************************** ! 8: * @format.tab-size 4 (Plain Text/Source Code File Header) * ! 9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * ! 10: * * ! 11: * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * ! 12: * * ! 13: * This library is free software; you can redistribute it and/or * ! 14: * modify it under the terms of the GNU Lesser General Public License * ! 15: * as published by the Free Software Foundation; either version 2 * ! 16: * of the License, or (at your option) any later version. * ! 17: * See the GNU Lesser General Public License for more details: lgpl.txt or * ! 18: * http://www.fsf.org/copyleft/lesser.html * ! 19: * * ! 20: * Anonymous FTP access to the most recent released source is available at * ! 21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * ! 22: * * ! 23: * Anonymous CVS access to the development source and modification history * ! 24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: * ! 25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login * ! 26: * (just hit return, no password is necessary) * ! 27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src * ! 28: * * ! 29: * For Synchronet coding style and modification guidelines, see * ! 30: * http://www.synchro.net/source.html * ! 31: * * ! 32: * You are encouraged to submit any modifications (preferably in Unix diff * ! 33: * format) via e-mail to [email protected] * ! 34: * * ! 35: * Note: If this box doesn't appear square, then you need to fix your tabs. * ! 36: ****************************************************************************/ ! 37: ! 38: #ifndef _SMBLIB_H ! 39: #define _SMBLIB_H ! 40: ! 41: #include "lzh.h" ! 42: ! 43: #ifdef SMBEXPORT ! 44: #undef SMBEXPORT ! 45: #endif ! 46: ! 47: #ifdef _WIN32 ! 48: #ifdef __BORLANDC__ ! 49: #define SMBCALL __stdcall ! 50: #else ! 51: #define SMBCALL ! 52: #endif ! 53: #if defined(SMB_IMPORTS) || defined(SMB_EXPORTS) ! 54: #if defined(SMB_IMPORTS) ! 55: #define SMBEXPORT __declspec( dllimport ) ! 56: #else ! 57: #define SMBEXPORT __declspec( dllexport ) ! 58: #endif ! 59: #else /* self-contained executable */ ! 60: #define SMBEXPORT ! 61: #endif ! 62: #elif defined __unix__ ! 63: #define SMBCALL ! 64: #define SMBEXPORT ! 65: #else ! 66: #define SMBCALL ! 67: #define SMBEXPORT ! 68: #endif ! 69: ! 70: #include "smbdefs.h" ! 71: ! 72: #define SMB_STACK_LEN 4 /* Max msg bases in smb_stack() */ ! 73: #define SMB_STACK_POP 0 /* Pop a msg base off of smb_stack()*/ ! 74: #define SMB_STACK_PUSH 1 /* Push a msg base onto smb_stack() */ ! 75: #define SMB_STACK_XCHNG 2 /* Exchange msg base w/last pushed */ ! 76: ! 77: #define SMB_ALL_REFS 0 /* Free all references to data */ ! 78: ! 79: #define GETMSGTXT_TAILS (1<<0) /* Get message tail(s) */ ! 80: #define GETMSGTXT_NO_BODY (1<<1) /* Don't retrieve message body */ ! 81: #define GETMSGTXT_NO_HFIELDS (1<<2) /* Don't include text header fields */ ! 82: #define GETMSGTXT_BODY_ONLY GETMSGTXT_NO_HFIELDS ! 83: #define GETMSGTXT_TAIL_ONLY (GETMSGTXT_TAILS|GETMSGTXT_NO_BODY|GETMSGTXT_NO_HFIELDS) ! 84: #define GETMSGTXT_ALL GETMSGTXT_TAILS ! 85: ! 86: #define SMB_IS_OPEN(smb) ((smb)->shd_fp!=NULL) ! 87: ! 88: /* Legacy API functions */ ! 89: #define smb_incmsg(smb,msg) smb_incmsg_dfields(smb,msg,1) ! 90: #define smb_incdat smb_incmsgdat ! 91: #define smb_open_da(smb) smb_open_fp(smb,&(smb)->sda_fp,SH_DENYRW) ! 92: #define smb_close_da(smb) smb_close_fp(&(smb)->sda_fp) ! 93: #define smb_open_ha(smb) smb_open_fp(smb,&(smb)->sha_fp,SH_DENYRW) ! 94: #define smb_close_ha(smb) smb_close_fp(&(smb)->sha_fp) ! 95: #define smb_open_hash(smb) smb_open_fp(smb,&(smb)->hash_fp,SH_DENYRW) ! 96: #define smb_close_hash(smb) smb_close_fp(&(smb)->hash_fp) ! 97: ! 98: #ifdef __cplusplus ! 99: extern "C" { ! 100: #endif ! 101: ! 102: SMBEXPORT int SMBCALL smb_ver(void); ! 103: SMBEXPORT char* SMBCALL smb_lib_ver(void); ! 104: SMBEXPORT int SMBCALL smb_open(smb_t* smb); ! 105: SMBEXPORT void SMBCALL smb_close(smb_t* smb); ! 106: SMBEXPORT int SMBCALL smb_create(smb_t* smb); ! 107: SMBEXPORT int SMBCALL smb_stack(smb_t* smb, int op); ! 108: SMBEXPORT int SMBCALL smb_trunchdr(smb_t* smb); ! 109: SMBEXPORT int SMBCALL smb_lock(smb_t* smb); ! 110: SMBEXPORT int SMBCALL smb_unlock(smb_t* smb); ! 111: SMBEXPORT BOOL SMBCALL smb_islocked(smb_t* smb); ! 112: SMBEXPORT int SMBCALL smb_locksmbhdr(smb_t* smb); ! 113: SMBEXPORT int SMBCALL smb_getstatus(smb_t* smb); ! 114: SMBEXPORT int SMBCALL smb_putstatus(smb_t* smb); ! 115: SMBEXPORT int SMBCALL smb_unlocksmbhdr(smb_t* smb); ! 116: SMBEXPORT int SMBCALL smb_getmsgidx(smb_t* smb, smbmsg_t* msg); ! 117: SMBEXPORT int SMBCALL smb_getfirstidx(smb_t* smb, idxrec_t *idx); ! 118: SMBEXPORT int SMBCALL smb_getlastidx(smb_t* smb, idxrec_t *idx); ! 119: SMBEXPORT ulong SMBCALL smb_getmsghdrlen(smbmsg_t* msg); ! 120: SMBEXPORT ulong SMBCALL smb_getmsgdatlen(smbmsg_t* msg); ! 121: SMBEXPORT ulong SMBCALL smb_getmsgtxtlen(smbmsg_t* msg); ! 122: SMBEXPORT int SMBCALL smb_lockmsghdr(smb_t* smb, smbmsg_t* msg); ! 123: SMBEXPORT int SMBCALL smb_getmsghdr(smb_t* smb, smbmsg_t* msg); ! 124: SMBEXPORT int SMBCALL smb_unlockmsghdr(smb_t* smb, smbmsg_t* msg); ! 125: SMBEXPORT int SMBCALL smb_addcrc(smb_t* smb, ulong crc); ! 126: ! 127: SMBEXPORT int SMBCALL smb_hfield(smbmsg_t* msg, ushort type, size_t length, void* data); ! 128: SMBEXPORT int SMBCALL smb_hfield_str(smbmsg_t* msg, ushort type, const char* str); ! 129: SMBEXPORT int SMBCALL smb_hfield_append(smbmsg_t* msg, ushort type, size_t length, void* data); ! 130: SMBEXPORT int SMBCALL smb_hfield_append_str(smbmsg_t* msg, ushort type, const char* data); ! 131: SMBEXPORT int SMBCALL smb_hfield_addlist(smbmsg_t* msg, hfield_t** hfield_list, void** hfield_dat); ! 132: SMBEXPORT int SMBCALL smb_hfield_netaddr(smbmsg_t* msg, ushort type, const char* str, ushort* nettype); ! 133: #define smb_hfield_bin(msg, type, data) smb_hfield(msg, type, sizeof(data), &(data)) ! 134: ! 135: SMBEXPORT int SMBCALL smb_dfield(smbmsg_t* msg, ushort type, ulong length); ! 136: SMBEXPORT void* SMBCALL smb_get_hfield(smbmsg_t* msg, ushort type, hfield_t* hfield); ! 137: SMBEXPORT int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage); ! 138: SMBEXPORT int SMBCALL smb_putmsg(smb_t* smb, smbmsg_t* msg); ! 139: SMBEXPORT int SMBCALL smb_putmsgidx(smb_t* smb, smbmsg_t* msg); ! 140: SMBEXPORT int SMBCALL smb_putmsghdr(smb_t* smb, smbmsg_t* msg); ! 141: SMBEXPORT void SMBCALL smb_freemsgmem(smbmsg_t* msg); ! 142: SMBEXPORT void SMBCALL smb_freemsghdrmem(smbmsg_t* msg); ! 143: SMBEXPORT ulong SMBCALL smb_hdrblocks(ulong length); ! 144: SMBEXPORT ulong SMBCALL smb_datblocks(ulong length); ! 145: SMBEXPORT int SMBCALL smb_copymsgmem(smb_t* smb, smbmsg_t* destmsg, smbmsg_t* srcmsg); ! 146: SMBEXPORT int SMBCALL smb_tzutc(short timezone); ! 147: SMBEXPORT int SMBCALL smb_updatethread(smb_t* smb, smbmsg_t* remsg, ulong newmsgnum); ! 148: SMBEXPORT int SMBCALL smb_updatemsg(smb_t* smb, smbmsg_t* msg); ! 149: SMBEXPORT BOOL SMBCALL smb_valid_hdr_offset(smb_t* smb, ulong offset); ! 150: SMBEXPORT int SMBCALL smb_init_idx(smb_t* smb, smbmsg_t* msg); ! 151: ! 152: /* smbadd.c */ ! 153: SMBEXPORT int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes ! 154: ,ushort xlat, const uchar* body, const uchar* tail); ! 155: ! 156: /* smballoc.c */ ! 157: SMBEXPORT long SMBCALL smb_allochdr(smb_t* smb, ulong length); ! 158: SMBEXPORT long SMBCALL smb_fallochdr(smb_t* smb, ulong length); ! 159: SMBEXPORT long SMBCALL smb_hallochdr(smb_t* smb); ! 160: SMBEXPORT long SMBCALL smb_allocdat(smb_t* smb, ulong length, ushort refs); ! 161: SMBEXPORT long SMBCALL smb_fallocdat(smb_t* smb, ulong length, ushort refs); ! 162: SMBEXPORT long SMBCALL smb_hallocdat(smb_t* smb); ! 163: SMBEXPORT int SMBCALL smb_incmsg_dfields(smb_t* smb, smbmsg_t* msg, ushort refs); ! 164: SMBEXPORT int SMBCALL smb_incmsgdat(smb_t* smb, ulong offset, ulong length, ushort refs); ! 165: SMBEXPORT int SMBCALL smb_freemsg(smb_t* smb, smbmsg_t* msg); ! 166: SMBEXPORT int SMBCALL smb_freemsg_dfields(smb_t* smb, smbmsg_t* msg, ushort refs); ! 167: SMBEXPORT int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, ushort refs); ! 168: SMBEXPORT int SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length); ! 169: SMBEXPORT void SMBCALL smb_freemsgtxt(char* buf); ! 170: ! 171: /* smbhash.c */ ! 172: SMBEXPORT int SMBCALL smb_findhash(smb_t* smb, hash_t** compare_list, hash_t* found ! 173: ,long source_mask, BOOL mark); ! 174: SMBEXPORT int SMBCALL smb_hashmsg(smb_t* smb, smbmsg_t* msg, const uchar* text, BOOL update); ! 175: SMBEXPORT hash_t* SMBCALL smb_hash(ulong msgnum, ulong time, unsigned source ! 176: ,unsigned flags, const void* data, size_t length); ! 177: SMBEXPORT hash_t* SMBCALL smb_hashstr(ulong msgnum, ulong time, unsigned source ! 178: ,unsigned flags, const char* str); ! 179: ! 180: SMBEXPORT hash_t** SMBCALL smb_msghashes(smbmsg_t* msg, const uchar* text); ! 181: SMBEXPORT int SMBCALL smb_addhashes(smb_t* smb, hash_t** hash_list, BOOL skip_marked); ! 182: SMBEXPORT ushort SMBCALL smb_name_crc(const char* name); ! 183: SMBEXPORT ushort SMBCALL smb_subject_crc(const char *subj); ! 184: ! 185: /* Fast look-up functions (using hashes) */ ! 186: SMBEXPORT int SMBCALL smb_getmsgidx_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source ! 187: ,unsigned flags, const void* data, size_t length); ! 188: SMBEXPORT int SMBCALL smb_getmsghdr_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source ! 189: ,unsigned flags, const void* data, size_t length); ! 190: ! 191: /* 0-length specifies ASCIIZ data (length calculated automatically) */ ! 192: #define smb_getmsgidx_by_hashstr(smb, msg, source, flags, data) \ ! 193: smb_getmsgidx_by_hash(smb, msg, source, flags, data, 0) ! 194: #define smb_getmsghdr_by_hashstr(smb, msg, source, flags, data) \ ! 195: smb_getmsghdr_by_hash(smb, msg, source, flags, data, 0) ! 196: ! 197: /* Fast Message-ID based look-up macros (using hashes) */ ! 198: #define smb_getmsgidx_by_msgid(smb, msg, id) \ ! 199: smb_getmsgidx_by_hashstr(smb, msg, SMB_HASH_SOURCE_MSG_ID, SMB_HASH_MASK, id) ! 200: #define smb_getmsgidx_by_ftnid(smb, msg, id) \ ! 201: smb_getmsgidx_by_hashstr(smb, msg, SMB_HASH_SOURCE_FTN_ID, SMB_HASH_MASK, id) ! 202: #define smb_getmsghdr_by_msgid(smb, msg, id) \ ! 203: smb_getmsghdr_by_hashstr(smb, msg, SMB_HASH_SOURCE_MSG_ID, SMB_HASH_MASK, id) ! 204: #define smb_getmsghdr_by_ftnid(smb, msg, id) \ ! 205: smb_getmsghdr_by_hashstr(smb, msg, SMB_HASH_SOURCE_FTN_ID, SMB_HASH_MASK, id) ! 206: ! 207: /* smbstr.c */ ! 208: SMBEXPORT char* SMBCALL smb_hfieldtype(ushort type); ! 209: SMBEXPORT ushort SMBCALL smb_hfieldtypelookup(const char*); ! 210: SMBEXPORT char* SMBCALL smb_dfieldtype(ushort type); ! 211: SMBEXPORT char* SMBCALL smb_faddrtoa(fidoaddr_t* addr, char* outstr); ! 212: SMBEXPORT char* SMBCALL smb_netaddr(net_t* net); ! 213: SMBEXPORT ushort SMBCALL smb_netaddr_type(const char* str); ! 214: SMBEXPORT char* SMBCALL smb_zonestr(short zone, char* outstr); ! 215: SMBEXPORT char* SMBCALL smb_hashsource(smbmsg_t* msg, int source); ! 216: SMBEXPORT char* SMBCALL smb_hashsourcetype(uchar type); ! 217: SMBEXPORT fidoaddr_t SMBCALL smb_atofaddr(const fidoaddr_t* sys_addr, const char *str); ! 218: ! 219: /* smbdump.c */ ! 220: SMBEXPORT void SMBCALL smb_dump_msghdr(FILE* fp, smbmsg_t* msg); ! 221: ! 222: /* smbtxt.c */ ! 223: SMBEXPORT char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode); ! 224: ! 225: /* smbfile.c */ ! 226: SMBEXPORT int SMBCALL smb_feof(FILE* fp); ! 227: SMBEXPORT int SMBCALL smb_ferror(FILE* fp); ! 228: SMBEXPORT int SMBCALL smb_fflush(FILE* fp); ! 229: SMBEXPORT int SMBCALL smb_fgetc(FILE* fp); ! 230: SMBEXPORT int SMBCALL smb_fputc(int ch, FILE* fp); ! 231: SMBEXPORT int SMBCALL smb_fseek(FILE* fp, long offset, int whence); ! 232: SMBEXPORT long SMBCALL smb_ftell(FILE* fp); ! 233: SMBEXPORT size_t SMBCALL smb_fread(smb_t*, void* buf, size_t bytes, FILE* fp); ! 234: SMBEXPORT size_t SMBCALL smb_fwrite(smb_t*, const void* buf, size_t bytes, FILE* fp); ! 235: SMBEXPORT long SMBCALL smb_fgetlength(FILE* fp); ! 236: SMBEXPORT int SMBCALL smb_fsetlength(FILE* fp, long length); ! 237: SMBEXPORT void SMBCALL smb_rewind(FILE* fp); ! 238: SMBEXPORT void SMBCALL smb_clearerr(FILE* fp); ! 239: SMBEXPORT int SMBCALL smb_open_fp(smb_t* smb, FILE**, int share); ! 240: SMBEXPORT void SMBCALL smb_close_fp(FILE**); ! 241: ! 242: #ifdef __cplusplus ! 243: } ! 244: #endif ! 245: ! 246: #endif /* Don't add anything after this #endif statement */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.