|
|
1.1 ! root 1: /* smblib.h */ ! 2: ! 3: /* Synchronet message base (SMB) library function prototypes */ ! 4: ! 5: /* $Id: smblib.h,v 1.61 2004/12/29 10:13:08 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 2004 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: #ifndef __FLAT__ ! 48: #define __FLAT__ /* only supporting 32-bit targets now */ ! 49: #endif ! 50: ! 51: #ifdef _WIN32 ! 52: #ifdef __BORLANDC__ ! 53: #define SMBCALL __stdcall ! 54: #else ! 55: #define SMBCALL ! 56: #endif ! 57: #if defined(SMB_IMPORTS) || defined(SMB_EXPORTS) ! 58: #if defined(SMB_IMPORTS) ! 59: #define SMBEXPORT __declspec( dllimport ) ! 60: #else ! 61: #define SMBEXPORT __declspec( dllexport ) ! 62: #endif ! 63: #else /* self-contained executable */ ! 64: #define SMBEXPORT ! 65: #endif ! 66: #elif defined __unix__ ! 67: #define SMBCALL ! 68: #define SMBEXPORT ! 69: #else ! 70: #define SMBCALL ! 71: #define SMBEXPORT ! 72: #endif ! 73: ! 74: #include "smbdefs.h" ! 75: ! 76: #define SMB_STACK_LEN 4 /* Max msg bases in smb_stack() */ ! 77: #define SMB_STACK_POP 0 /* Pop a msg base off of smb_stack()*/ ! 78: #define SMB_STACK_PUSH 1 /* Push a msg base onto smb_stack() */ ! 79: #define SMB_STACK_XCHNG 2 /* Exchange msg base w/last pushed */ ! 80: ! 81: #define SMB_ALL_REFS 0 /* Free all references to data */ ! 82: ! 83: #define GETMSGTXT_TAILS (1<<0) /* Get message tail(s) */ ! 84: #define GETMSGTXT_NO_BODY (1<<1) /* Don't retrieve message body */ ! 85: #define GETMSGTXT_NO_HFIELDS (1<<2) /* Don't include text header fields */ ! 86: #define GETMSGTXT_BODY_ONLY GETMSGTXT_NO_HFIELDS ! 87: #define GETMSGTXT_TAIL_ONLY (GETMSGTXT_TAILS|GETMSGTXT_NO_BODY|GETMSGTXT_NO_HFIELDS) ! 88: #define GETMSGTXT_ALL GETMSGTXT_TAILS ! 89: ! 90: #define SMB_IS_OPEN(smb) ((smb)->shd_fp!=NULL) ! 91: ! 92: /* Legacy API functions */ ! 93: #define smb_incmsg(smb,msg) smb_incmsg_dfields(smb,msg,1) ! 94: #define smb_incdat smb_incmsgdat ! 95: #define smb_open_da(smb) smb_open_fp(smb,&(smb)->sda_fp,SH_DENYRW) ! 96: #define smb_close_da(smb) smb_close_fp(&(smb)->sda_fp) ! 97: #define smb_open_ha(smb) smb_open_fp(smb,&(smb)->sha_fp,SH_DENYRW) ! 98: #define smb_close_ha(smb) smb_close_fp(&(smb)->sha_fp) ! 99: #define smb_open_hash(smb) smb_open_fp(smb,&(smb)->hash_fp,SH_DENYRW) ! 100: #define smb_close_hash(smb) smb_close_fp(&(smb)->hash_fp) ! 101: ! 102: #ifdef __cplusplus ! 103: extern "C" { ! 104: #endif ! 105: ! 106: SMBEXPORT int SMBCALL smb_ver(void); ! 107: SMBEXPORT char* SMBCALL smb_lib_ver(void); ! 108: SMBEXPORT int SMBCALL smb_open(smb_t* smb); ! 109: SMBEXPORT void SMBCALL smb_close(smb_t* smb); ! 110: SMBEXPORT int SMBCALL smb_create(smb_t* smb); ! 111: SMBEXPORT int SMBCALL smb_stack(smb_t* smb, int op); ! 112: SMBEXPORT int SMBCALL smb_trunchdr(smb_t* smb); ! 113: SMBEXPORT int SMBCALL smb_lock(smb_t* smb); ! 114: SMBEXPORT int SMBCALL smb_unlock(smb_t* smb); ! 115: SMBEXPORT BOOL SMBCALL smb_islocked(smb_t* smb); ! 116: SMBEXPORT int SMBCALL smb_locksmbhdr(smb_t* smb); ! 117: SMBEXPORT int SMBCALL smb_getstatus(smb_t* smb); ! 118: SMBEXPORT int SMBCALL smb_putstatus(smb_t* smb); ! 119: SMBEXPORT int SMBCALL smb_unlocksmbhdr(smb_t* smb); ! 120: SMBEXPORT int SMBCALL smb_getmsgidx(smb_t* smb, smbmsg_t* msg); ! 121: SMBEXPORT int SMBCALL smb_getfirstidx(smb_t* smb, idxrec_t *idx); ! 122: SMBEXPORT int SMBCALL smb_getlastidx(smb_t* smb, idxrec_t *idx); ! 123: SMBEXPORT ulong SMBCALL smb_getmsghdrlen(smbmsg_t* msg); ! 124: SMBEXPORT ulong SMBCALL smb_getmsgdatlen(smbmsg_t* msg); ! 125: SMBEXPORT ulong SMBCALL smb_getmsgtxtlen(smbmsg_t* msg); ! 126: SMBEXPORT int SMBCALL smb_lockmsghdr(smb_t* smb, smbmsg_t* msg); ! 127: SMBEXPORT int SMBCALL smb_getmsghdr(smb_t* smb, smbmsg_t* msg); ! 128: SMBEXPORT int SMBCALL smb_unlockmsghdr(smb_t* smb, smbmsg_t* msg); ! 129: SMBEXPORT int SMBCALL smb_addcrc(smb_t* smb, ulong crc); ! 130: ! 131: SMBEXPORT int SMBCALL smb_hfield(smbmsg_t* msg, ushort type, size_t length, void* data); ! 132: SMBEXPORT int SMBCALL smb_hfield_str(smbmsg_t* msg, ushort type, const char* str); ! 133: SMBEXPORT int SMBCALL smb_hfield_append(smbmsg_t* msg, ushort type, size_t length, void* data); ! 134: SMBEXPORT int SMBCALL smb_hfield_append_str(smbmsg_t* msg, ushort type, const char* data); ! 135: SMBEXPORT int SMBCALL smb_hfield_addlist(smbmsg_t* msg, hfield_t** hfield_list, void** hfield_dat); ! 136: SMBEXPORT int SMBCALL smb_hfield_netaddr(smbmsg_t* msg, ushort type, const char* str, ushort* nettype); ! 137: #define smb_hfield_bin(msg, type, data) smb_hfield(msg, type, sizeof(data), &(data)) ! 138: ! 139: SMBEXPORT int SMBCALL smb_dfield(smbmsg_t* msg, ushort type, ulong length); ! 140: SMBEXPORT void* SMBCALL smb_get_hfield(smbmsg_t* msg, ushort type, hfield_t* hfield); ! 141: SMBEXPORT int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage); ! 142: SMBEXPORT int SMBCALL smb_putmsg(smb_t* smb, smbmsg_t* msg); ! 143: SMBEXPORT int SMBCALL smb_putmsgidx(smb_t* smb, smbmsg_t* msg); ! 144: SMBEXPORT int SMBCALL smb_putmsghdr(smb_t* smb, smbmsg_t* msg); ! 145: SMBEXPORT void SMBCALL smb_freemsgmem(smbmsg_t* msg); ! 146: SMBEXPORT void SMBCALL smb_freemsghdrmem(smbmsg_t* msg); ! 147: SMBEXPORT ulong SMBCALL smb_hdrblocks(ulong length); ! 148: SMBEXPORT ulong SMBCALL smb_datblocks(ulong length); ! 149: SMBEXPORT int SMBCALL smb_copymsgmem(smb_t* smb, smbmsg_t* destmsg, smbmsg_t* srcmsg); ! 150: SMBEXPORT int SMBCALL smb_tzutc(short timezone); ! 151: SMBEXPORT int SMBCALL smb_updatethread(smb_t* smb, smbmsg_t* remsg, ulong newmsgnum); ! 152: SMBEXPORT BOOL SMBCALL smb_valid_hdr_offset(smb_t* smb, ulong offset); ! 153: ! 154: /* smbadd.c */ ! 155: SMBEXPORT int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes ! 156: ,ushort xlat, const uchar* body, const uchar* tail); ! 157: ! 158: /* smballoc.c */ ! 159: SMBEXPORT long SMBCALL smb_allochdr(smb_t* smb, ulong length); ! 160: SMBEXPORT long SMBCALL smb_fallochdr(smb_t* smb, ulong length); ! 161: SMBEXPORT long SMBCALL smb_hallochdr(smb_t* smb); ! 162: SMBEXPORT long SMBCALL smb_allocdat(smb_t* smb, ulong length, ushort refs); ! 163: SMBEXPORT long SMBCALL smb_fallocdat(smb_t* smb, ulong length, ushort refs); ! 164: SMBEXPORT long SMBCALL smb_hallocdat(smb_t* smb); ! 165: SMBEXPORT int SMBCALL smb_incmsg_dfields(smb_t* smb, smbmsg_t* msg, ushort refs); ! 166: SMBEXPORT int SMBCALL smb_incmsgdat(smb_t* smb, ulong offset, ulong length, ushort refs); ! 167: SMBEXPORT int SMBCALL smb_freemsg(smb_t* smb, smbmsg_t* msg); ! 168: SMBEXPORT int SMBCALL smb_freemsg_dfields(smb_t* smb, smbmsg_t* msg, ushort refs); ! 169: SMBEXPORT int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, ushort refs); ! 170: SMBEXPORT int SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length); ! 171: SMBEXPORT void SMBCALL smb_freemsgtxt(char* buf); ! 172: ! 173: /* smbhash.c */ ! 174: SMBEXPORT int SMBCALL smb_findhash(smb_t* smb, hash_t** compare_list, hash_t* found ! 175: ,long source_mask, BOOL mark); ! 176: SMBEXPORT int SMBCALL smb_hashmsg(smb_t* smb, smbmsg_t* msg, const uchar* text, BOOL update); ! 177: SMBEXPORT hash_t* SMBCALL smb_hash(ulong msgnum, ulong time, unsigned source ! 178: ,unsigned flags, const void* data, size_t length); ! 179: SMBEXPORT hash_t* SMBCALL smb_hashstr(ulong msgnum, ulong time, unsigned source ! 180: ,unsigned flags, const char* str); ! 181: ! 182: SMBEXPORT hash_t** SMBCALL smb_msghashes(smbmsg_t* msg, const uchar* text); ! 183: SMBEXPORT int SMBCALL smb_addhashes(smb_t* smb, hash_t** hash_list, BOOL skip_marked); ! 184: SMBEXPORT ushort SMBCALL smb_name_crc(const char* name); ! 185: SMBEXPORT ushort SMBCALL smb_subject_crc(const char *subj); ! 186: SMBEXPORT int SMBCALL smb_init_idx(smb_t* smb, smbmsg_t* msg); ! 187: ! 188: /* Fast look-up functions (using hashes) */ ! 189: SMBEXPORT int SMBCALL smb_getmsgidx_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source ! 190: ,unsigned flags, const void* data, size_t length); ! 191: SMBEXPORT int SMBCALL smb_getmsghdr_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source ! 192: ,unsigned flags, const void* data, size_t length); ! 193: ! 194: /* 0-length specifies ASCIIZ data (length calculated automatically) */ ! 195: #define smb_getmsgidx_by_hashstr(smb, msg, source, flags, data) \ ! 196: smb_getmsgidx_by_hash(smb, msg, source, flags, data, 0) ! 197: #define smb_getmsghdr_by_hashstr(smb, msg, source, flags, data) \ ! 198: smb_getmsghdr_by_hash(smb, msg, source, flags, data, 0) ! 199: ! 200: /* Fast Message-ID based look-up macros (using hashes) */ ! 201: #define smb_getmsgidx_by_msgid(smb, msg, id) \ ! 202: smb_getmsgidx_by_hashstr(smb, msg, SMB_HASH_SOURCE_MSG_ID, SMB_HASH_MASK, id) ! 203: #define smb_getmsgidx_by_ftnid(smb, msg, id) \ ! 204: smb_getmsgidx_by_hashstr(smb, msg, SMB_HASH_SOURCE_FTN_ID, SMB_HASH_MASK, id) ! 205: #define smb_getmsghdr_by_msgid(smb, msg, id) \ ! 206: smb_getmsghdr_by_hashstr(smb, msg, SMB_HASH_SOURCE_MSG_ID, SMB_HASH_MASK, id) ! 207: #define smb_getmsghdr_by_ftnid(smb, msg, id) \ ! 208: smb_getmsghdr_by_hashstr(smb, msg, SMB_HASH_SOURCE_FTN_ID, SMB_HASH_MASK, id) ! 209: ! 210: /* smbstr.c */ ! 211: SMBEXPORT char* SMBCALL smb_hfieldtype(ushort type); ! 212: SMBEXPORT ushort SMBCALL smb_hfieldtypelookup(const char*); ! 213: SMBEXPORT char* SMBCALL smb_dfieldtype(ushort type); ! 214: SMBEXPORT char* SMBCALL smb_faddrtoa(fidoaddr_t* addr, char* outstr); ! 215: SMBEXPORT char* SMBCALL smb_netaddr(net_t* net); ! 216: SMBEXPORT ushort SMBCALL smb_netaddr_type(const char* str); ! 217: SMBEXPORT char* SMBCALL smb_zonestr(short zone, char* outstr); ! 218: SMBEXPORT char* SMBCALL smb_hashsource(smbmsg_t* msg, int source); ! 219: SMBEXPORT char* SMBCALL smb_hashsourcetype(uchar type); ! 220: SMBEXPORT fidoaddr_t SMBCALL smb_atofaddr(const fidoaddr_t* sys_addr, const char *str); ! 221: ! 222: /* smbdump.c */ ! 223: SMBEXPORT void SMBCALL smb_dump_msghdr(FILE* fp, smbmsg_t* msg); ! 224: ! 225: /* smbtxt.c */ ! 226: SMBEXPORT char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode); ! 227: ! 228: /* smbfile.c */ ! 229: SMBEXPORT int SMBCALL smb_feof(FILE* fp); ! 230: SMBEXPORT int SMBCALL smb_ferror(FILE* fp); ! 231: SMBEXPORT int SMBCALL smb_fflush(FILE* fp); ! 232: SMBEXPORT int SMBCALL smb_fgetc(FILE* fp); ! 233: SMBEXPORT int SMBCALL smb_fputc(int ch, FILE* fp); ! 234: SMBEXPORT int SMBCALL smb_fseek(FILE* fp, long offset, int whence); ! 235: SMBEXPORT long SMBCALL smb_ftell(FILE* fp); ! 236: SMBEXPORT size_t SMBCALL smb_fread(smb_t*, void* buf, size_t bytes, FILE* fp); ! 237: SMBEXPORT size_t SMBCALL smb_fwrite(smb_t*, const void* buf, size_t bytes, FILE* fp); ! 238: SMBEXPORT long SMBCALL smb_fgetlength(FILE* fp); ! 239: SMBEXPORT int SMBCALL smb_fsetlength(FILE* fp, long length); ! 240: SMBEXPORT void SMBCALL smb_rewind(FILE* fp); ! 241: SMBEXPORT void SMBCALL smb_clearerr(FILE* fp); ! 242: SMBEXPORT int SMBCALL smb_open_fp(smb_t* smb, FILE**, int share); ! 243: SMBEXPORT void SMBCALL smb_close_fp(FILE**); ! 244: ! 245: #ifdef __cplusplus ! 246: } ! 247: #endif ! 248: ! 249: #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.