
/* cmd.h	- header file for commands
   distributed as part of _ s u l a _


    Author: Tano Fotang, 1997

    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.
    see the file COPYING for mor einfo.

*/

#ifndef _glirc_cmds_h
#define _glirc_cmds_h


/*---------------------------------------------------------------------*/
char	cmdchar;	/* command char , default '/' */
char	*ml_nl;		/* to place before newlines in multiline msges. defaullt:\t*/

/* command types*/
#define  CMD_IN		( 1<<0 )
/*#define  CMD_SYS	( 1<<1 )*/ /* obsolete */
#define  CMD_FD		( 1<<2 )

#define  CMD_NORMAL	( 1<<3 )
#define  CMD_CTCP	( 1<<4 )
#define	MAXCMDLEN	30 	/* max sula cmd length; doesent seem 2b used anywhere..*/


typedef struct TCmd{
	char	*name;
	char	*help;
	int	type;		
	union	{
		void	(*in)(void *);	/*IN_NORMAL */
		int		sp;
	} cmd;
	int	bf; 
	struct TCmd *left;
	struct TCmd *right;
} Cmd;

typedef Cmd	*pCmd;
Cmd		*cmdTree;
int		no_of_cmds;

typedef struct TCmdStruct{
	Winstruct *win;
	char	*args;		/* cmd arguments*/
}CmdStruct;
#define SERV_CMD	(1<<0)
#define CLI_CMD		(1<<1)
typedef struct TCmdOnCon{
	int	type;	/* SERV_CMD:sendto_server, CLI_CMD:process cmd*/
	char	*cmd;
	char	*server;
	u_short	port;
	struct TCmdOnCon *next;
} CmdOnCon;	/* do cmd upon connecting */
CmdOnCon	*cmdonconStart, *cmdonconEnd;


extern void add_cmdoncon(int type, char *cmd, char *serv, u_short port);
extern Cmd *find_cmd(char *name, int type);
extern int remove_cmd(char *name,int type);
extern int insert_cmd(pCmd *pp, Cmd *c, int flag);
extern int insert_bookmark(pBookmark *, Bookmark *, int *);
extern int del_bookmark(pBookmark *, Bookmark *);
extern int save_bookmarks(const char *, Bookmark *);
extern int load_bookmarks(const char *, Bookmark **);

extern int write_to_sp(int sp, const char *buf);
extern void send_blocktxt(int, const char *,int);
extern int new_process_cmd (const char *, int);
extern int remove_sp(int fd);


extern void unquote_str(char **);
extern void quote_str(char **);
extern int load_ctcp_cmds(void);

void print_cmd_tree(Cmd *p , int pos);
void list_cmds(Cmd *p);
extern int show_std_help(const char *,const char *, FD_chanwin *);

extern  int on_channel(const Server *, const char *); 
extern void jjoin(Winstruct *win);
void ClearWinChanList(Winstruct *win);

extern void set(int argc, char **argv, Winstruct *win);


#endif
