Annotation of sbbs/src/smblib/smblib.h, revision 1.1.1.2

1.1       root        1: /* smblib.h */
                      2: 
                      3: /* Synchronet message base (SMB) library function prototypes */
                      4: 
1.1.1.2 ! root        5: /* $Id: smblib.h,v 1.69 2011/07/21 10:49:43 rswindell Exp $ */
1.1       root        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:  *                                                                                                                                                     *
1.1.1.2 ! root       11:  * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html         *
1.1       root       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);
1.1.1.2 ! root      125: SMBEXPORT int          SMBCALL smb_addcrc(smb_t* smb, uint32_t crc);
1.1       root      126: 
1.1.1.2 ! root      127: SMBEXPORT int          SMBCALL smb_hfield_add(smbmsg_t* msg, ushort type, size_t length, void* data, BOOL insert);
        !           128: SMBEXPORT int          SMBCALL smb_hfield_add_str(smbmsg_t* msg, ushort type, const char* str, BOOL insert);
        !           129: SMBEXPORT int          SMBCALL smb_hfield_replace(smbmsg_t* msg, ushort type, size_t length, void* data);
        !           130: SMBEXPORT int          SMBCALL smb_hfield_replace_str(smbmsg_t* msg, ushort type, const char* str);
1.1       root      131: SMBEXPORT int          SMBCALL smb_hfield_append(smbmsg_t* msg, ushort type, size_t length, void* data);
                    132: SMBEXPORT int          SMBCALL smb_hfield_append_str(smbmsg_t* msg, ushort type, const char* data);
1.1.1.2 ! root      133: SMBEXPORT int          SMBCALL smb_hfield_add_list(smbmsg_t* msg, hfield_t** hfield_list, void** hfield_dat, BOOL insert);
        !           134: SMBEXPORT int          SMBCALL smb_hfield_add_netaddr(smbmsg_t* msg, ushort type, const char* str, ushort* nettype, BOOL insert);
        !           135: /* Convenience macro: */
        !           136: #define smb_hfield_bin(msg, type, data) smb_hfield_add(msg, type, sizeof(data), &(data), /* insert: */FALSE)
        !           137: /* Backward compatibility macros: */
        !           138: #define smb_hfield(msg,type,len,data)  smb_hfield_add(msg, type, len, data, /* insert: */FALSE)
        !           139: #define smb_hfield_str(msg, type, str) smb_hfield_add_str(msg, type, str, /* insert: */FALSE)
        !           140: #define smb_hfield_netaddr(msg, type, str, nettype) smb_hfield_add_netaddr(msg, type, str, nettype, /* insert: */FALSE)
1.1       root      141: 
                    142: SMBEXPORT int          SMBCALL smb_dfield(smbmsg_t* msg, ushort type, ulong length);
                    143: SMBEXPORT void*                SMBCALL smb_get_hfield(smbmsg_t* msg, ushort type, hfield_t* hfield);
                    144: SMBEXPORT int          SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage);
                    145: SMBEXPORT int          SMBCALL smb_putmsg(smb_t* smb, smbmsg_t* msg);
                    146: SMBEXPORT int          SMBCALL smb_putmsgidx(smb_t* smb, smbmsg_t* msg);
                    147: SMBEXPORT int          SMBCALL smb_putmsghdr(smb_t* smb, smbmsg_t* msg);
                    148: SMBEXPORT void         SMBCALL smb_freemsgmem(smbmsg_t* msg);
                    149: SMBEXPORT void         SMBCALL smb_freemsghdrmem(smbmsg_t* msg);
                    150: SMBEXPORT ulong                SMBCALL smb_hdrblocks(ulong length);
                    151: SMBEXPORT ulong                SMBCALL smb_datblocks(ulong length);
                    152: SMBEXPORT int          SMBCALL smb_copymsgmem(smb_t* smb, smbmsg_t* destmsg, smbmsg_t* srcmsg);
                    153: SMBEXPORT int          SMBCALL smb_tzutc(short timezone);
                    154: SMBEXPORT int          SMBCALL smb_updatethread(smb_t* smb, smbmsg_t* remsg, ulong newmsgnum);
                    155: SMBEXPORT int          SMBCALL smb_updatemsg(smb_t* smb, smbmsg_t* msg);
                    156: SMBEXPORT BOOL         SMBCALL smb_valid_hdr_offset(smb_t* smb, ulong offset);
                    157: SMBEXPORT int          SMBCALL smb_init_idx(smb_t* smb, smbmsg_t* msg);
                    158: 
                    159: /* smbadd.c */
                    160: SMBEXPORT int          SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes
1.1.1.2 ! root      161:                                                ,uint16_t xlat, const uchar* body, const uchar* tail);
1.1       root      162: 
                    163: /* smballoc.c */
                    164: SMBEXPORT long         SMBCALL smb_allochdr(smb_t* smb, ulong length);
                    165: SMBEXPORT long         SMBCALL smb_fallochdr(smb_t* smb, ulong length);
                    166: SMBEXPORT long         SMBCALL smb_hallochdr(smb_t* smb);
1.1.1.2 ! root      167: SMBEXPORT long         SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t int16_trefs);
        !           168: SMBEXPORT long         SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs);
1.1       root      169: SMBEXPORT long         SMBCALL smb_hallocdat(smb_t* smb);
1.1.1.2 ! root      170: SMBEXPORT int          SMBCALL smb_incmsg_dfields(smb_t* smb, smbmsg_t* msg, uint16_t refs);
        !           171: SMBEXPORT int          SMBCALL smb_incmsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs);
1.1       root      172: SMBEXPORT int          SMBCALL smb_freemsg(smb_t* smb, smbmsg_t* msg);
1.1.1.2 ! root      173: SMBEXPORT int          SMBCALL smb_freemsg_dfields(smb_t* smb, smbmsg_t* msg, uint16_t refs);
        !           174: SMBEXPORT int          SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs);
1.1       root      175: SMBEXPORT int          SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length);
                    176: SMBEXPORT void         SMBCALL smb_freemsgtxt(char* buf);
                    177: 
                    178: /* smbhash.c */
                    179: SMBEXPORT int          SMBCALL smb_findhash(smb_t* smb, hash_t** compare_list, hash_t* found
                    180:                                                                                 ,long source_mask, BOOL mark);
                    181: SMBEXPORT int          SMBCALL smb_hashmsg(smb_t* smb, smbmsg_t* msg, const uchar* text, BOOL update);
                    182: SMBEXPORT hash_t*      SMBCALL smb_hash(ulong msgnum, ulong time, unsigned source
                    183:                                                                ,unsigned flags, const void* data, size_t length);
                    184: SMBEXPORT hash_t*      SMBCALL smb_hashstr(ulong msgnum, ulong time, unsigned source
                    185:                                                                ,unsigned flags, const char* str);
                    186: 
1.1.1.2 ! root      187: SMBEXPORT hash_t**     SMBCALL smb_msghashes(smbmsg_t* msg, const uchar* text, long source_mask);
1.1       root      188: SMBEXPORT int          SMBCALL smb_addhashes(smb_t* smb, hash_t** hash_list, BOOL skip_marked);
1.1.1.2 ! root      189: SMBEXPORT uint16_t     SMBCALL smb_name_crc(const char* name);
        !           190: SMBEXPORT uint16_t     SMBCALL smb_subject_crc(const char *subj);
        !           191: SMBEXPORT void         SMBCALL smb_freehashes(hash_t**);
1.1       root      192: 
                    193: /* Fast look-up functions (using hashes) */
                    194: SMBEXPORT int          SMBCALL smb_getmsgidx_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source
                    195:                                                                 ,unsigned flags, const void* data, size_t length);
                    196: SMBEXPORT int          SMBCALL smb_getmsghdr_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source
                    197:                                                                 ,unsigned flags, const void* data, size_t length);
                    198: 
                    199: /* 0-length specifies ASCIIZ data (length calculated automatically) */
                    200: #define smb_getmsgidx_by_hashstr(smb, msg, source, flags, data) \
                    201:                smb_getmsgidx_by_hash(smb, msg, source, flags, data, 0)
                    202: #define smb_getmsghdr_by_hashstr(smb, msg, source, flags, data) \
                    203:                smb_getmsghdr_by_hash(smb, msg, source, flags, data, 0)
                    204: 
                    205: /* Fast Message-ID based look-up macros (using hashes) */
                    206: #define smb_getmsgidx_by_msgid(smb, msg, id) \
                    207:                smb_getmsgidx_by_hashstr(smb, msg, SMB_HASH_SOURCE_MSG_ID, SMB_HASH_MASK, id)
                    208: #define smb_getmsgidx_by_ftnid(smb, msg, id) \
                    209:                smb_getmsgidx_by_hashstr(smb, msg, SMB_HASH_SOURCE_FTN_ID, SMB_HASH_MASK, id)
                    210: #define smb_getmsghdr_by_msgid(smb, msg, id) \
                    211:                smb_getmsghdr_by_hashstr(smb, msg, SMB_HASH_SOURCE_MSG_ID, SMB_HASH_MASK, id)
                    212: #define smb_getmsghdr_by_ftnid(smb, msg, id) \
                    213:                smb_getmsghdr_by_hashstr(smb, msg, SMB_HASH_SOURCE_FTN_ID, SMB_HASH_MASK, id)
                    214: 
                    215: /* smbstr.c */
                    216: SMBEXPORT char*                SMBCALL smb_hfieldtype(ushort type);
                    217: SMBEXPORT ushort       SMBCALL smb_hfieldtypelookup(const char*);
                    218: SMBEXPORT char*                SMBCALL smb_dfieldtype(ushort type);
                    219: SMBEXPORT char*                SMBCALL smb_faddrtoa(fidoaddr_t* addr, char* outstr);
                    220: SMBEXPORT char*                SMBCALL smb_netaddr(net_t* net);
1.1.1.2 ! root      221: SMBEXPORT char*                SMBCALL smb_netaddrstr(net_t* net, char* fidoaddr_buf);
1.1       root      222: SMBEXPORT ushort       SMBCALL smb_netaddr_type(const char* str);
                    223: SMBEXPORT char*                SMBCALL smb_zonestr(short zone, char* outstr);
                    224: SMBEXPORT char*                SMBCALL smb_hashsource(smbmsg_t* msg, int source);
                    225: SMBEXPORT char*                SMBCALL smb_hashsourcetype(uchar type);
                    226: SMBEXPORT fidoaddr_t SMBCALL smb_atofaddr(const fidoaddr_t* sys_addr, const char *str);
                    227: 
                    228: /* smbdump.c */
                    229: SMBEXPORT void         SMBCALL smb_dump_msghdr(FILE* fp, smbmsg_t* msg);
                    230: 
                    231: /* smbtxt.c */
                    232: SMBEXPORT char*                SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode);
                    233: 
                    234: /* smbfile.c */
                    235: SMBEXPORT int          SMBCALL smb_feof(FILE* fp);
                    236: SMBEXPORT int          SMBCALL smb_ferror(FILE* fp);
                    237: SMBEXPORT int          SMBCALL smb_fflush(FILE* fp);
                    238: SMBEXPORT int          SMBCALL smb_fgetc(FILE* fp);
                    239: SMBEXPORT int          SMBCALL smb_fputc(int ch, FILE* fp);
                    240: SMBEXPORT int          SMBCALL smb_fseek(FILE* fp, long offset, int whence);
                    241: SMBEXPORT long         SMBCALL smb_ftell(FILE* fp);
                    242: SMBEXPORT size_t       SMBCALL smb_fread(smb_t*, void* buf, size_t bytes, FILE* fp);
                    243: SMBEXPORT size_t       SMBCALL smb_fwrite(smb_t*, const void* buf, size_t bytes, FILE* fp);
                    244: SMBEXPORT long         SMBCALL smb_fgetlength(FILE* fp);
                    245: SMBEXPORT int          SMBCALL smb_fsetlength(FILE* fp, long length);
                    246: SMBEXPORT void         SMBCALL smb_rewind(FILE* fp);
                    247: SMBEXPORT void         SMBCALL smb_clearerr(FILE* fp);
                    248: SMBEXPORT int          SMBCALL smb_open_fp(smb_t* smb, FILE**, int share);
                    249: SMBEXPORT void         SMBCALL smb_close_fp(FILE**);
                    250:                                        
                    251: #ifdef __cplusplus
                    252: }
                    253: #endif
                    254: 
                    255: #endif /* Don't add anything after this #endif statement */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.