Debian Codegraph @

COSMIC/Sprtskt.c

raw
1 /* Sprtskt.c:
2 * Authors: Charles E. Campbell, Jr.
3 * Terry McRoberts
4 * Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
5 * Permission is hereby granted to use and distribute this code,
6 * with or without modifications, provided that this copyright
7 * notice is copied with it. Like anything else that's free,
8 * Sprtskt.c is provided *as is* and comes with no warranty
9 * of any kind, either expressed or implied. By using this
10 * software, you agree that in no event will the copyright
11 * holder be liable for any damages resulting from the use
12 * of this software.
13 * Date: Aug 22, 2005
14 */
15 #include <stdio.h>
16 #include "sockets.h"
17
18 /* ------------------------------------------------------------------------
19 * Local Definitions:
20 */
21 #define BUFSIZE 128
22
23 /* ------------------------------------------------------------------------ */
24
25 /* Sprtskt: this function prints out a socket description */
26 #ifdef __PROTOTYPE__
27 char *Sprtskt(Socket *skt)
28 #else
29 char *Sprtskt(skt)
30 Socket *skt;
31 #endif
32 {
33 static char buf1[BUFSIZE];
34 static char buf2[BUFSIZE];
35 static char *b= buf1;
36
37 if(!skt) return "null socket";
38
39 /* toggles between the two static buffers */
40 if(b == buf1) b= buf2;
41 else b= buf1;
42
43 sprintf(b,"#%d:p%d:%s:%s@%s",
44 skt->skt,
45 skt->port,
46 (skt->type == PM_SERVER)? "server" :
47 (skt->type == PM_CLIENT)? "client" :
48 (skt->type == PM_ACCEPT)? "accept" : "???",
49 skt->sktname? skt->sktname : "null-sktname",
50 skt->hostname? skt->hostname : "null-host");
51
52 return b;
53 }
54
55 /* ---------------------------------------------------------------------
56 * vim: ts=4
57 */