/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1990-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20/*21* Glenn Fowler22* AT&T Research23*24* return the string representation of addr25*/2627#include "cslib.h"2829char*30csntoa(register Cs_t* state, unsigned long addr)31{32register unsigned char* p;33int32_t a;3435a = addr;36p = (unsigned char*)&a;37if ((!addr || p[0] == 127 && p[1] == 0 && p[2] == 0 && p[3] <= 1) && !state->ntoa[sizeof(state->ntoa)-1])38{39state->ntoa[sizeof(state->ntoa)-1] = 1;40addr = csaddr(state, NiL);41state->ntoa[sizeof(state->ntoa)-1] = 0;42}43sfsprintf(state->ntoa, sizeof(state->ntoa), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);44messagef((state->id, NiL, -8, "ntoa(%s) call", state->ntoa));45return state->ntoa;46}4748char*49_cs_ntoa(unsigned long addr)50{51return csntoa(&cs, addr);52}535455