Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libcs/csntoa.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1990-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Glenn Fowler
23
* AT&T Research
24
*
25
* return the string representation of addr
26
*/
27
28
#include "cslib.h"
29
30
char*
31
csntoa(register Cs_t* state, unsigned long addr)
32
{
33
register unsigned char* p;
34
int32_t a;
35
36
a = addr;
37
p = (unsigned char*)&a;
38
if ((!addr || p[0] == 127 && p[1] == 0 && p[2] == 0 && p[3] <= 1) && !state->ntoa[sizeof(state->ntoa)-1])
39
{
40
state->ntoa[sizeof(state->ntoa)-1] = 1;
41
addr = csaddr(state, NiL);
42
state->ntoa[sizeof(state->ntoa)-1] = 0;
43
}
44
sfsprintf(state->ntoa, sizeof(state->ntoa), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
45
messagef((state->id, NiL, -8, "ntoa(%s) call", state->ntoa));
46
return state->ntoa;
47
}
48
49
char*
50
_cs_ntoa(unsigned long addr)
51
{
52
return csntoa(&cs, addr);
53
}
54
55