in_ntoa.c

来自「* A ncurses user interface. * Network 」· C语言 代码 · 共 58 行

C
58 行
字号
/*  This file is part of sniffer, a packet capture utility and  network moniter  The author can be contacted at <mistral@stev.org>  the lastest version is avilable from   http://stev.org  This program is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or  (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#include "config.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <pthread.h>#include "log.h"#include "in_ntoa.h"/* when using this do not forget to free off the ram it malloc's */char *in_ntoa(unsigned long in) {	char *buff;	char *p;	p = (char *) &in;	buff = malloc(18);	if (!buff) {		log_errno("malloc");		return NULL;	}	sprintf(buff, "%d.%d.%d.%d", 		(p[0] & 255),		(p[1] & 255),		(p[2] & 255),		(p[3] & 255));	return buff;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?