File indexing completed on 2024-04-28 15:35:16
0001 /*************************************************************************** 0002 * Copyright (C) 2004 by Tomas Mecir * 0003 * kmuddy@kmuddy.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU Library General Public License as * 0007 * published by the Free Software Foundation; either version 2 of the * 0008 * License, or (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU Library General Public License for more details. * 0014 ***************************************************************************/ 0015 0016 #ifndef _LIBMXP_H 0017 #define _LIBMXP_H 0018 0019 0020 #ifdef __cplusplus 0021 extern "C" { 0022 #endif 0023 0024 enum attribs { 0025 Bold = 0x01, 0026 Italic = 0x02, 0027 Underline = 0x04, 0028 Strikeout = 0x08 0029 }; 0030 0031 typedef struct { 0032 unsigned char r, g, b; 0033 } RGB; 0034 0035 typedef struct { 0036 int type; //result type 0037 void *data; //result data, contents depend on result type 0038 } mxpResult; 0039 0040 /** PUBLIC API for the library */ 0041 0042 typedef void * MXPHANDLER; 0043 0044 /** create a new MXP handler */ 0045 MXPHANDLER mxpCreateHandler (); 0046 /** destroy a previously created MXP handler */ 0047 void mxpDestroyHandler (MXPHANDLER handler); 0048 0049 /** process some text with the handler */ 0050 void mxpProcessText (MXPHANDLER handler, const char *text); 0051 /** fetch next result of the processing */ 0052 mxpResult *mxpNextResult (MXPHANDLER handler); 0053 /** are there any more results to fetch? */ 0054 char mxpHasResults (MXPHANDLER handler); 0055 0056 /** switch to OPEN mode - use this immediately after creating this object, in case that 0057 you don't want to be in LOCKED mode by default (where MXP is only used if some line tag 0058 is received) */ 0059 void mxpSwitchToOpen (MXPHANDLER handler); 0060 0061 /** set default text attributes */ 0062 void mxpSetDefaultText (MXPHANDLER handler, const char *font, int size, char _bold, 0063 char _italic, char _underline, char _strikeout, RGB fg, RGB bg); 0064 /** set attributes of header 1-6 (for tags <h1>-<h6> */ 0065 void mxpSetHeaderParams (MXPHANDLER handler, int which, const char *font, int size, char _bold, 0066 char _italic, char _underline, char _strikeout, RGB fg, RGB bg); 0067 /** set default color for gauges */ 0068 void mxpSetDefaultGaugeColor (MXPHANDLER handler, RGB color); 0069 /** set used non-proportional font */ 0070 void mxpSetNonProportFont (MXPHANDLER handler, const char *font); 0071 /** set client name and version reported to the MUD */ 0072 void mxpSetClient (MXPHANDLER handler, const char *name, const char *version); 0073 /* screen, window and font size, used by FRAME and IMAGE tags */ 0074 void mxpSetScreenProps (MXPHANDLER handler, int sx, int sy, int wx, int wy, int fx, int fy); 0075 0076 void mxpSupportsLink (MXPHANDLER handler, char supports); 0077 void mxpSupportsGauge (MXPHANDLER handler, char supports); 0078 void mxpSupportsStatus (MXPHANDLER handler, char supports); 0079 void mxpSupportsSound (MXPHANDLER handler, char supports); 0080 void mxpSupportsFrame (MXPHANDLER handler, char supports); 0081 void mxpSupportsImage (MXPHANDLER handler, char supports); 0082 void mxpSupportsRelocate (MXPHANDLER handler, char supports); 0083 0084 0085 /** 0086 MXP result types: 0087 TODO: write the result type documentation. 0088 */ 0089 0090 //for type 3 0091 struct flagStruct { 0092 char begin; 0093 char *name; 0094 }; 0095 0096 //for type 4 0097 struct varStruct { 0098 char *name, *value; 0099 char erase; 0100 }; 0101 0102 #define USE_BOLD 0x01 0103 #define USE_ITALICS 0x02 0104 #define USE_UNDERLINE 0x04 0105 #define USE_STRIKEOUT 0x08 0106 #define USE_FG 0x10 0107 #define USE_BG 0x20 0108 #define USE_FONT 0x40 0109 #define USE_SIZE 0x80 0110 #define USE_ALL 0xFF 0111 0112 //for type 5 0113 struct formatStruct { 0114 unsigned char usemask; //8-bit; which params should be applied 0115 unsigned char attributes; 0116 RGB fg, bg; 0117 char *font; //if NULL and it should be applied => default font should be set 0118 int size; 0119 }; 0120 0121 //for type 6 0122 struct linkStruct { 0123 char *name, *url, *text, *hint; 0124 }; 0125 0126 //for type 7 0127 struct sendStruct { 0128 char *name, *command, *text, *hint; 0129 char toprompt, ismenu; 0130 }; 0131 0132 //for type 11; also see MSP protocol 0133 struct soundStruct { 0134 char isSOUND; //1 if SOUND, 0 if MUSIC 0135 char *fname, *url; //(fName and U params) 0136 int vol; //volume (V param) 0137 int repeats; //-1 for infinite (L param) 0138 int priority; //0-100; SOUND only (P param) 0139 char continuemusic; //continue without restarting if rerequested? MUSIC only (C param) 0140 char *type; //sound/music type (T param) 0141 }; 0142 0143 //for type 12 0144 struct windowStruct { 0145 char *name, *title; 0146 int left, top, width, height; 0147 char scrolling, floating; 0148 }; 0149 0150 //align type for internal windows and images (type Middle is only valid for images) 0151 enum alignType { 0152 Left = 1, 0153 Right, 0154 Bottom, 0155 Top, 0156 Middle 0157 }; 0158 0159 //for type 13 0160 struct internalWindowStruct { 0161 char *name, *title; 0162 enum alignType align; 0163 char scrolling; 0164 }; 0165 0166 //for type 16 0167 struct moveStruct { 0168 int x, y; 0169 }; 0170 0171 //for type 18 0172 struct relocateStruct { 0173 char *server; 0174 int port; 0175 }; 0176 0177 //for type 20 0178 struct imageStruct { 0179 char *fname, *url, *type; 0180 int height, width, hspace, vspace; 0181 enum alignType align; 0182 }; 0183 0184 //for type 22 0185 struct gaugeStruct { 0186 char *variable, *maxvariable, *caption; 0187 RGB color; 0188 }; 0189 0190 //for type 23 0191 struct statStruct { 0192 char *variable, *maxvariable, *caption; 0193 }; 0194 0195 0196 #ifdef __cplusplus 0197 //end of extern "C" 0198 }; 0199 #endif 0200 0201 #endif //_LIBMXP_H