Annotation of embedaddon/mpd/src/console.h, revision 1.1
1.1 ! misho 1:
! 2: /*
! 3: * console.h
! 4: *
! 5: * Written by Archie Cobbs <archie@freebsd.org>
! 6: * Copyright (c) 1998-1999 Whistle Communications, Inc. All rights reserved.
! 7: * See ``COPYRIGHT.whistle''
! 8: */
! 9:
! 10: #ifndef _CONSOLE_H_
! 11: #define _CONSOLE_H_
! 12:
! 13: #include "ppp.h"
! 14:
! 15: /*
! 16: * DEFINITIONS
! 17: */
! 18:
! 19: #define MAX_CONSOLE_ARGS 50
! 20: #define MAX_CONSOLE_LINE 400
! 21: #define MAX_CONSOLE_HIST 10
! 22:
! 23: #define Printf(fmt, args...) do { \
! 24: if (ctx->cs) \
! 25: ctx->cs->write(ctx->cs, fmt, ## args); \
! 26: } while (0)
! 27:
! 28: #define Error(fmt, args...) do { \
! 29: snprintf(ctx->errmsg, sizeof(ctx->errmsg), \
! 30: fmt, ## args); \
! 31: return(CMD_ERR_OTHER); \
! 32: } while (0)
! 33:
! 34: /* Configuration options */
! 35: enum {
! 36: CONSOLE_LOGGING /* enable logging */
! 37: };
! 38:
! 39: struct console {
! 40: int fd; /* listener */
! 41: struct u_addr addr;
! 42: in_port_t port;
! 43: SLIST_HEAD(, console_session) sessions; /* active sessions */
! 44: EventRef event; /* connect-event */
! 45: pthread_rwlock_t lock;
! 46: };
! 47:
! 48: typedef struct console *Console;
! 49:
! 50: struct console_session;
! 51:
! 52: typedef struct console_session *ConsoleSession;
! 53:
! 54: struct context {
! 55: Bund bund;
! 56: Link lnk;
! 57: Rep rep;
! 58: ConsoleSession cs;
! 59: int depth; /* Number recursive 'load' calls */
! 60: char errmsg[256]; /* Error message of the last command */
! 61: int priv;
! 62: };
! 63:
! 64: struct console_user {
! 65: char username[32];
! 66: char password[32];
! 67: int priv;
! 68: };
! 69:
! 70: typedef struct console_user *ConsoleUser;
! 71:
! 72: struct console_session {
! 73: Console console;
! 74: struct optinfo options; /* Configured options */
! 75: int fd; /* connection fd */
! 76: void *cookie; /* device dependent cookie */
! 77: EventRef readEvent;
! 78: struct context context;
! 79: struct console_user user;
! 80: struct u_addr peer_addr;
! 81: in_port_t peer_port;
! 82: void (*prompt)(struct console_session *);
! 83: void (*write)(struct console_session *, const char *fmt, ...);
! 84: void (*writev)(struct console_session *, const char *fmt, va_list vl);
! 85: void (*close)(struct console_session *);
! 86: u_char state;
! 87: u_char telnet;
! 88: u_char escaped;
! 89: u_char exit;
! 90: int cmd_len;
! 91: char cmd[MAX_CONSOLE_LINE];
! 92: int currhist;
! 93: char history[MAX_CONSOLE_HIST][MAX_CONSOLE_LINE]; /* last command */
! 94: SLIST_ENTRY(console_session) next;
! 95: };
! 96:
! 97: /*
! 98: * VARIABLES
! 99: */
! 100:
! 101: extern const struct cmdtab ConsoleSetCmds[];
! 102: extern struct ghash *gUsers; /* allowed users */
! 103: extern pthread_rwlock_t gUsersLock;
! 104:
! 105:
! 106: /*
! 107: * FUNCTIONS
! 108: */
! 109:
! 110: extern int ConsoleInit(Console c);
! 111: extern int ConsoleOpen(Console c);
! 112: extern int ConsoleClose(Console c);
! 113: extern int ConsoleStat(Context ctx, int ac, char *av[], void *arg);
! 114: extern Context StdConsoleConnect(Console c);
! 115: extern void ConsoleShutdown(Console c);
! 116:
! 117: extern int UserCommand(Context ctx, int ac, char *av[], void *arg);
! 118: extern int UserStat(Context ctx, int ac, char *av[], void *arg);
! 119:
! 120: #endif
! 121:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>