|
|
1.1 root 1: /* msg_id.c */
2:
3: /* Synchronet Message-ID generation routines */
4:
5: /* $Id: msg_id.c,v 1.2 2004/10/21 07:34:33 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 program is free software; you can redistribute it and/or *
14: * modify it under the terms of the GNU 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 General Public License for more details: gpl.txt or *
18: * http://www.fsf.org/copyleft/gpl.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: #include "sbbs.h"
39:
40: static ulong msgid_serialno(smbmsg_t* msg)
41: {
42: return (msg->idx.time-1000000000) + msg->idx.number;
43: }
44:
45: /****************************************************************************/
46: /* Returns a FidoNet (FTS-9) message-ID */
47: /****************************************************************************/
48: char* DLLCALL ftn_msgid(sub_t *sub, smbmsg_t* msg)
49: {
50: static char msgid[256];
51:
52: if(msg->ftn_msgid!=NULL && *msg->ftn_msgid!=0)
53: return(msg->ftn_msgid);
54:
55: snprintf(msgid,sizeof(msgid)
56: ,"%lu.%s@%s %08lx"
57: ,msg->idx.number
58: ,sub->code
59: ,smb_faddrtoa(&sub->faddr,NULL)
60: ,msgid_serialno(msg)
61: );
62:
63: return(msgid);
64: }
65:
66: /****************************************************************************/
67: /* Return a general purpose (RFC-822) message-ID */
68: /****************************************************************************/
69: char* DLLCALL get_msgid(scfg_t* cfg, uint subnum, smbmsg_t* msg)
70: {
71: static char msgid[256];
72:
73: if(msg->id!=NULL && *msg->id!=0)
74: return(msg->id);
75:
76: if(subnum>=cfg->total_subs)
77: snprintf(msgid,sizeof(msgid)
78: ,"<%08lX.%lu@%s>"
79: ,msg->idx.time
80: ,msg->idx.number
81: ,cfg->sys_inetaddr);
82: else
83: snprintf(msgid,sizeof(msgid)
84: ,"<%08lX.%lu.%s@%s>"
85: ,msg->idx.time
86: ,msg->idx.number
87: ,cfg->sub[subnum]->code
88: ,cfg->sys_inetaddr);
89:
90: return(msgid);
91: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.