File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / mpd / src / util.h
Revision 1.1.1.4 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:39:23 2021 UTC (3 years, 4 months ago) by misho
Branches: mpd, MAIN
CVS tags: v5_9p16, v5_9, HEAD
mpd 5.9

    1: 
    2: /*
    3:  * util.h
    4:  *
    5:  * Written by Archie Cobbs <archie@freebsd.org>
    6:  * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
    7:  * See ``COPYRIGHT.whistle''
    8:  */
    9: 
   10: #ifndef _UTIL_H_
   11: #define _UTIL_H_
   12: 
   13: #include "ip.h"
   14: #include <net/ethernet.h>
   15: #include <net/if_dl.h>
   16: #include <stdio.h>
   17: #include <osreldate.h>
   18:  /*-
   19:   * The following macro is used to update an
   20:   * internet checksum.  "acc" is a 32-bit
   21:   * accumulation of all the changes to the
   22:   * checksum (adding in old 16-bit words and
   23:   * subtracting out new words), and "cksum"
   24:   * is the checksum value to be updated.
   25:   */
   26: #define ADJUST_CHECKSUM(acc, cksum) { \
   27:     acc += cksum; \
   28:     if (acc < 0) { \
   29:       acc = -acc; \
   30:       acc = (acc >> 16) + (acc & 0xffff); \
   31:       acc += acc >> 16; \
   32:       cksum = (u_short) ~acc; \
   33:     } else { \
   34:       acc = (acc >> 16) + (acc & 0xffff); \
   35:       acc += acc >> 16; \
   36:       cksum = (u_short) acc; \
   37:     } \
   38:   }
   39: 
   40: #define MAX_U_INT32		0xffffffffU
   41: 
   42: #define IFCONF_BUFFSIZE		16384
   43: #define IFCONF_BUFFMAXSIZE	1048576
   44: 
   45: struct configfile {
   46: 	char   *label;
   47: 	off_t	seek;
   48: 	int	linenum;
   49: 	struct configfile *next;
   50: };
   51: 
   52: struct configfiles {
   53: 	char   *filename;
   54: 	struct configfile *sections;
   55: 	struct configfiles *next;
   56: };
   57: 
   58: /*
   59:  * FUNCTIONS
   60:  */
   61: 
   62: extern FILE *OpenConfFile(const char *name, struct configfile **cf);
   63: extern int SeekToLabel(FILE *fp, const char *label, int *lineNum, struct configfile *cf);
   64: extern char *ReadFullLine(FILE *fp, int *lineNum, char *result, int resultlen);
   65: extern int ReadFile(const char *filename, const char *target, int (*func) (Context ctx, int ac, const char *const av[], const char *file, int line), Context ctx);
   66: extern int ParseLine(char *line, char *vec[], int max_args, int copy);
   67: extern void FreeArgs(int ac, char *av[]);
   68: 
   69: extern int TcpGetListenPort(struct u_addr *addr, in_port_t port, int block);
   70: extern int TcpAcceptConnection(int sock, struct sockaddr_storage *addr, int block);
   71: extern int GetInetSocket(int type, struct u_addr *addr, in_port_t port, int block, char *ebuf, size_t len);
   72: 
   73: #ifdef PHYSTYPE_MODEM
   74: extern int OpenSerialDevice(const char *label, const char *path, int baudrate);
   75: extern int ExclusiveOpenDevice(const char *label, const char *path);
   76: extern void ExclusiveCloseDevice(const char *label, int fd, const char *path);
   77: 
   78: #endif
   79: 
   80: extern int PIDCheck(const char *lockfile, int killem);
   81: 
   82: extern void LengthenArray(void *arrayp, size_t esize, int *alenp, const char *type);
   83: 
   84: extern int ExecCmd(int log, const char *label, const char *fmt,...)__printflike(3, 4);
   85: extern int ExecCmdNosh(int log, const char *label, const char *fmt,...)__printflike(3, 4);
   86: 
   87: extern void ShowMesg(int log, const char *pref, const char *buf, int len);
   88: extern char *Bin2Hex(const unsigned char *bin, size_t len);
   89: extern u_char *Hex2Bin(char *hexstr);
   90: 
   91: #ifndef USE_NG_PRED1
   92: extern u_short Crc16(u_short fcs, u_char *cp, int len);
   93: 
   94: #endif
   95: 
   96: extern u_long GenerateMagic(void);
   97: 
   98: extern int GetAnyIpAddress(struct u_addr *ipaddr, const char *ifname);
   99: extern int GetEther(struct u_addr *addr, struct sockaddr_dl *hwaddr);
  100: extern int GetPeerEther(struct u_addr *addr, struct sockaddr_dl *hwaddr);
  101: extern void ppp_util_ascify(char *buf, size_t max, const char *bytes, size_t len);
  102: extern int IfaceSetFlag(const char *ifname, int value);
  103: 
  104: #ifndef	HAVE_NTOA_R
  105: extern char *ether_ntoa_r(const struct ether_addr *n, char *a);
  106: 
  107: #endif
  108: 
  109: 
  110: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>