scotty.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 2006-2008 Leszek Godlewski
00004 
00005 This file is part of libscotty source code.
00006 
00007 libscotty is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU Lesser General Public License
00009 as published by the Free Software Foundation; either version 2.1 of the
00010 License, or (at your option) any later version.
00011 
00012 libscotty source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with libscotty; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 
00075 #ifndef _SCT_SCOTTY_H
00076 #define _SCT_SCOTTY_H
00077 
00078 #ifdef __cplusplus
00079 extern "C" {
00080 #endif // __cplusplus
00081 
00082 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
00083     #ifdef WIN32
00084         #define __EXPORT__ __declspec(dllexport)
00085     #elif (__GNUC__ >= 3)
00086         #define __EXPORT__ __attribute__((visibility("default")))
00087     #else
00088         #define __EXPORT__
00089     #endif
00090 #endif  // DOXYGEN_SHOULD_IGNORE_THIS
00091 
00092 #include <stddef.h> // for size_t
00093 
00102 #define SCT_VERSION_MAJOR           0
00103 
00111 #define SCT_VERSION_MINOR           1
00112 
00120 #define SCT_VERSION_PATCH           1
00121 
00131 #define SCT_VERSION(x)              { \
00132                                         (x)->major = SCT_VERSION_MAJOR; \
00133                                         (x)->minor = SCT_VERSION_MINOR; \
00134                                         (x)->patch = SCT_VERSION_PATCH; \
00135                                     }
00136 
00142 #define SCT_MAX_PROMPT              64      // max length of the command prompt
00143 
00148 #define SCT_CMDLINE_BUFFER_SIZE     1024    // max chars in a command line
00149 
00155 #define SCT_PRINTF_BUFFER_SIZE      32768   // SCT_Printf buffer size
00156 
00157 // error codes
00163 #define SCTE_NO_ERROR                   0
00164 
00171 #define SCTE_ERROR_CREATING_WINDOW      1   // curses initialization failed
00172 
00177 #define SCTE_INVALID_WINDOW_ID          2   // invalid window ID supplied to SCT_GetWindowHandle
00178 
00184 #define SCTE_MEMORY_ALLOCATION_FAILED   3   // a gMem.Alloc call returned NULL
00185 
00192 typedef enum {
00193     SCT_SCREEN,
00194     SCT_OUTPUT,
00195     SCT_INPUT
00196 } SCT_window_t;
00197 
00206 typedef struct SCT_allocator_s {
00207     void    (*Init)(void);
00208     void    (*Close)(void);
00209     void    *(*Alloc)(size_t size);
00210     void    (*Free)(void *ptr);
00211 } SCT_allocator_t;
00212 
00222 typedef struct SCT_version_s {
00223     int     major;
00224     int     minor;
00225     int     patch;
00226 } SCT_version_t;
00227 
00238 __EXPORT__ int      SCT_Init(void);
00239 
00247 __EXPORT__ int      SCT_IsInit(void);
00248 
00264 __EXPORT__ void     SCT_GetLinkedVersion(SCT_version_t *ver);
00265 
00280 __EXPORT__ int      SCT_SetAllocator(SCT_allocator_t *alloc);
00281 
00293 __EXPORT__ void     SCT_SetCommandHandlerFunction(void (*cmdEvFunc)(const char *cmd));
00294 
00305 __EXPORT__ int      SCT_SetHistorySize(unsigned int size);
00306 
00312 __EXPORT__ void     SCT_ClearHistory(void);
00313 
00324 __EXPORT__ void     *SCT_GetWindowHandle(SCT_window_t window);
00325 
00336 __EXPORT__ int      SCT_GetError(void);
00337 
00351 __EXPORT__ int      SCT_AddCompletionEntry(const char *str);
00352 
00360 __EXPORT__ int      SCT_RemoveCompletionEntry(const char *str);
00361 
00374 __EXPORT__ void     SCT_SetPrompt(const char *prompt);
00375 
00385 __EXPORT__ void     SCT_Echo(const char *str);
00386 
00399 __EXPORT__ void     SCT_Printf(const char *fmt, ...);
00400 
00405 __EXPORT__ void     SCT_ClearScreen(void);
00406 
00423 __EXPORT__ int      SCT_Input(void);
00424 
00430 __EXPORT__ int      SCT_Close(void);
00431 
00432 #ifdef __cplusplus
00433 }
00434 #endif // __cplusplus
00435 
00436 #endif // SCOTTY_H

Generated on Mon Jan 21 09:33:28 2008 for libscotty by  doxygen 1.5.4