⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genutils.c,v

📁 这是P2P流媒体方案-NICE的实现源码
💻 C,V
字号:
head	1.1;access;symbols;locks; strict;comment	@ * @;1.1date	2002.07.02.19.29.15;	author rbraud;	state Exp;branches;next	;desc@@1.1log@Initial revision@text@/* * \answer genutils for ODYSSEY * *-------------- * $Revision: 1.1 $ *-------------- * $Log: genutils.c,v $ * Revision 1.1  2002/01/26 17:59:45  suman * Initial revision * * Revision 1.4  2001/05/29 20:27:05  msanders * changes for December 2000 demo * * Revision 1.3  1999/05/20 22:29:52  merugu * Utils src cleaned... * * Revision 1.2  1999/05/20 00:14:54  msanders * removed static hosts and mac addresses, now use arp for dns2eth * resolution * * Revision 1.1.1.1  1999/04/14 04:37:05  merugu * Importing Odyssey * * Revision 1.1.1.1  1999/04/14 04:11:45  merugu * Importing Odyssey * * Revision 1.1.1.1  1999/04/05 22:15:44  merugu * Importing Odyssey Source * * Revision 1.1  1999/01/30  01:58:24  merugu * Initial revision * * Revision 1.2  1998/11/08 21:25:34  bobby * General Utilities * * Revision 1.1  1998/11/07 17:32:02  bobby * Initial revision * * Revision 1.3  1998/10/28 23:12:09  merugu * *** empty log message *** * */#include <sys/time.h>#include <stdio.h>#include <unistd.h>#ifdef IRIX64_6#include </usr/local/lib/gcc-lib/mips-sgi-irix5.3/2.7.2.2/include/stdarg.h>/* if this is not ugly i dont know what is! */#else#include <stdarg.h>#endif#include <sys/types.h>#include <math.h>#include <limits.h>#include <string.h> #include <stdlib.h>#include <signal.h>#include <sys/stat.h>#include <fcntl.h>#include "general.h"#define ALWAYS TRUE/* * conditional printer -- print iff * c is true  */void c_printf (boolean c, ...){  va_list ap;  char *f;  if (!c)    return;  va_start(ap, c);  f = va_arg (ap, char *);  vprintf (f, ap);  fflush(stdout);  va_end (ap);}/* * conditional warning * print warning string iff * condition c is true */ void c_warning (boolean c, ...){  /*   * conditional printer -- print iff   * c is true    */  va_list ap;  char *f;  if (!c)    return;  printf ("Warning: ");  va_start(ap, c);  f = va_arg (ap, char *);  vprintf (f, ap);  fflush(stdout);  va_end (ap);}/* * panic/quit with s as banner */void panic (char *s){  c_printf (ALWAYS, "===================== panic in <%s>\n", s);  select (0, 0, 0, 0, 0x0);  exit(-1);}/* internal function * usage: * panic_if (c) * will panic iff c is true */void panic_if_cond (int a, char *f, int l, char *fn){  if (a){    c_printf (ALWAYS, "Panic:: <%s.%d::%s>\n", f, l, fn);    exit(-1);  }}/* * allocate a buffer of size equal to the file * of name "fname" in the char **s * read fname into s * return: length of fname */long alloc_read (char **s, char *fname){  int fd = -1;  struct stat sbuf;  char *fin;  char cc[1024];    fd = open(fname, O_RDONLY);  if (fd < 0){    sprintf (cc, "alloc-read: open %s", fname);    panic (cc);  }  fstat (fd, &sbuf);    fin = (char *) getmem (sbuf.st_size+1);  if (!fin) {    panic ("alloc-read: getmem failure\n");  }  if (fd) {    read (fd, fin, sbuf.st_size);    close (fd);  }  fin[sbuf.st_size]=0x0;  *s = fin;  return sbuf.st_size;} @

⌨️ 快捷键说明

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