xynth_.h

00001 /***************************************************************************
00002     begin                : Thu Jan 30 2003
00003     copyright            : (C) 2003 - 2006 by Alper Akcan
00004     email                : distchx@yahoo.com
00005  ***************************************************************************/
00006 
00007 /***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU Lesser General Public License as        *
00011  *   published by the Free Software Foundation; either version 2.1 of the  *
00012  *   License, or (at your option) any later version.                       *
00013  *                                                                         *
00014  ***************************************************************************/
00015 
00016 #ifndef SXYNTH__H
00017 #define SXYNTH__H
00018 
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022 
00023 #include <stdio.h>
00024 #include <errno.h>
00025 #include <stdlib.h>
00026 #include <unistd.h>
00027 #include <string.h>
00028 #include <stdarg.h>
00029 #include <ctype.h>
00030 #include "xynth.h"
00031 
00032 #define S_SERVER_DIR            "/tmp/.Xynth"
00033 #define S_SERVER_SOC_NAME       "/tmp/.Xynth/UDS-0"
00034 
00035 #define S_SERVER_SOC_PORT       9000
00036 #define S_SERVER_SOC_ADDR       "127.0.0.1"
00037 #define S_SERVER_SOC_ALLOW      INADDR_LOOPBACK
00038 
00039 #define S_SERVER_SOC_PIPE       "Emulated Sockets (PIPE)"
00040 
00041 #define S_CLIENTS_MAX    125
00042 #define S_MATRIX_MRBOX   252
00043 #define S_MATRIX_SWMOUSE 253
00044 #define S_MATRIX_DELETED 254
00045 #define S_MATRIX_FREE    255
00046 
00047 #define S_FNAME_MAX      255
00048 #define S_TITLE_MAX      255
00049 
00050 #define DFAT    1
00051 #define DSYS    2
00052 #define DSER    4
00053 #define DCLI    8
00054 
00055 #define MOUSE_MASK      (MOUSE_EVENT|MOUSE_OVER|MOUSE_RELEASED|MOUSE_PRESSED|MOUSE_CLICKED|MOUSE_HINT|MOUSE_HINT2)
00056 #define MOUSE_MASL      (MOUSE_WHEELXBUTTON_U|MOUSE_WHEELXBUTTON_D|MOUSE_WHEELYBUTTON_U|MOUSE_WHEELYBUTTON_D)
00057 #define KEYBD_MASK      (KEYBD_EVENT|KEYBD_RELEASED|KEYBD_PRESSED)
00058 #define KEYBD_MASL      (KEYCODE_CPLCKF|KEYCODE_NMLCKF)
00059 
00060 #define MIN(a, b)       ((a) < (b) ? (a) : (b))
00061 #define MAX(a, b)       ((a) > (b) ? (a) : (b))
00062 
00063 #if defined(DEBUG)
00064         #define debugf(a, b...) s_debug_debugf(a, __FILE__, __LINE__, (char *) __FUNCTION__, b);
00065 #else
00066         #define debugf(a, b...) {\
00067                 if ((a) & DFAT) {\
00068                         s_debug_debugf(a, __FILE__, __LINE__, (char *) __FUNCTION__, b);\
00069                 }\
00070         }
00071 #endif
00072 
00073 #if defined(PLATFORM_LINUX)
00074         #include <sys/time.h>
00075 #elif defined(PLATFORM_GP2X)
00076         #include <sys/time.h>
00077 #elif defined(PLATFORM_PSPDEV)
00078         #include <sys/time.h>
00079         unsigned int sleep (unsigned int sec);
00080         unsigned int usleep (unsigned long msec);
00081 #elif defined(PLATFORM_MINGW)
00082         unsigned int sleep (unsigned int sec);
00083         unsigned int usleep (unsigned long msec);
00084 #endif
00085 
00086 #if defined(SOCKET_BSD)
00087         #include <sys/types.h>
00088         #include <sys/socket.h>
00089         #include <sys/un.h>
00090         #include <netinet/in.h>
00091         #include <arpa/inet.h>
00092         typedef struct sockaddr s_sockaddr_t;
00093 #elif defined(SOCKET_PIPE)
00094         #define AF_PIPE         0x0001
00095         #define SOCK_STREAM     0x0001
00096         #define socklen_t       unsigned int
00097         struct s_sockaddr_s {
00098                 short sa_family;
00099                 char sa_addr[40];
00100         };
00101         typedef struct s_sockaddr_s s_sockaddr_t;
00102 #else
00103         #error "Select one of the connection methods!"
00104 #endif
00105 
00106 #if defined(HAVE_POLL)
00107         #include <sys/poll.h>
00108 #else
00109         #define POLLIN          0x0001
00110         #define POLLPRI         0x0002
00111         #define POLLOUT         0x0004
00112         #define POLLERR         0x0008
00113         #define POLLHUP         0x0010
00114         #define POLLNVAL        0x0020
00115         struct pollfd {
00116                 int fd;
00117                 short events;
00118                 short revents;
00119         };
00120         typedef unsigned int nfds_t;
00121 #endif
00122 
00123 /* pipe_api.c */
00124 int s_pipe_api_init (void);
00125 int s_pipe_api_uninit (void);
00126 int s_pipe_api_pipe (int filedes[2]);
00127 int s_pipe_api_poll (struct pollfd *ufds, nfds_t nfds, int timeout);
00128 int s_pipe_api_write (int fd, void *buf, int count);
00129 int s_pipe_api_read (int fd, void *buf, int count);
00130 int s_pipe_api_close (int fd);
00131 
00132 /* socket_api.c */
00133 int s_socket_api_init (void);
00134 int s_socket_api_uninit (void);
00135 int s_socket_api_poll (struct pollfd *ufds, nfds_t nfds, int timeout);
00136 int s_socket_api_recv (int s, void *read_buf, int total_size);
00137 int s_socket_api_send (int s, void *write_buf, int total_size);
00138 int s_socket_api_socket (int domain, int type, int protocol);
00139 int s_socket_api_bind (int sockfd, const s_sockaddr_t *my_addr, socklen_t addrlen);
00140 int s_socket_api_listen (int s, int backlog);
00141 int s_socket_api_accept (int s, s_sockaddr_t *addr, socklen_t *addrlen);
00142 int s_socket_api_connect (int sockfd, const s_sockaddr_t *serv_addr, socklen_t addrlen);
00143 int s_socket_api_close (int fd);
00144 
00145 typedef struct s_soc_data_display_s {
00146          /* 336 bytes */
00147         int bytesperpixel;
00148         int bitsperpixel;
00149         int colors;
00150         int blueoffset;
00151         int greenoffset;
00152         int redoffset;
00153         int bluelength;
00154         int greenlength;
00155         int redlength;
00156         unsigned int linear_buf;
00157         unsigned int matrix;
00158         unsigned int linear_mem_size;
00159         unsigned int linear_mem_base;
00160         int linear_buf_width;
00161         int linear_buf_pitch;
00162         int linear_buf_height;
00163         int shm_mid;
00164         int id;
00165         int shm_sid;
00166         int need_expose;
00167         char device[S_FNAME_MAX];
00168 } s_soc_data_display_t;
00169 
00170 typedef struct s_soc_data_expose_s {
00171         /* 64 bytes */
00172         int pri;
00173         s_rect_t buf;
00174         s_rect_t win;
00175         s_rect_t changed;
00176         int linear_buf_width;
00177         int linear_buf_pitch;
00178         int linear_buf_height;
00179 } s_soc_data_expose_t;
00180 
00181 typedef struct s_soc_data_event_s {
00182         /* 880 bytes */
00183         S_EVENT type;
00184         s_mouse_t mouse;
00185         s_keybd_t keybd;
00186 } s_soc_data_event_t;
00187 
00188 typedef struct s_soc_data_configure_s {
00189         /* 288 bytes */
00190         S_WINDOW form;
00191         s_rect_t rnew;
00192         int resizeable;
00193         int alwaysontop;
00194         S_MOUSE_CURSOR cursor;
00195         char title[S_TITLE_MAX];
00196 } s_soc_data_configure_t;
00197 
00198 typedef struct s_soc_data_stream_s {
00199         /* 28 bytes */
00200         int bitspp;
00201         s_rect_t rect;
00202         unsigned int blen;
00203         char *buf;
00204 } s_soc_data_stream_t;
00205 
00206 typedef struct s_soc_data_desktop_s {
00207         /* 33004 bytes */
00208         int count;
00209         struct {
00210                 int id;
00211                 int pri;
00212                 char title[S_TITLE_MAX];
00213         } client[S_CLIENTS_MAX];
00214 } s_soc_data_desktop_t;
00215 
00216 typedef struct s_soc_data_show_s {
00217         /* 8 bytes */
00218         int id;
00219         int show;
00220 } s_soc_data_show_t;
00221 
00222 #ifdef __cplusplus
00223 }
00224 #endif
00225 
00226 #endif /* SXYNTH__H */

Generated on Wed Dec 27 17:53:06 2006 for xynth-0.8.40 by  doxygen 1.4.7