wok rev 11212
Add from wok-undigest: sdcc fbvnc novnc
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Nov 03 16:33:16 2011 +0100 (2011-11-03) |
parents | e414ce8e07d7 |
children | d9c2cb21341a |
files | fbvnc/receipt fbvnc/stuff/fbvnc.u novnc/receipt sdcc/receipt |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/fbvnc/receipt Thu Nov 03 16:33:16 2011 +0100 1.3 @@ -0,0 +1,32 @@ 1.4 +# SliTaz package receipt. 1.5 + 1.6 +PACKAGE="fbvnc" 1.7 +VERSION="20110416" 1.8 +CATEGORY="network" 1.9 +SHORT_DESC="VNC client in frame buffer." 1.10 +MAINTAINER="pascal.bellard@slitaz.org" 1.11 +WEB_SITE="http://repo.or.cz/w/fbvnc.git" 1.12 +_TARBALL="$PACKAGE-$VERSION.tar.gz" 1.13 + 1.14 +# Rules to configure and make the package. 1.15 +compile_rules() 1.16 +{ 1.17 + [ -s $SOURCES_REPOSITORY/$_TARBALL ] || 1.18 + wget -O $SOURCES_REPOSITORY/$_TARBALL \ 1.19 + $WEB_SITE/snapshot/e42bc02b14b3331e7c7f45c6b42179d0af99ed7b.tar.gz 1.20 + mkdir -p $src 1.21 + cd $src 1.22 + tar xzf $SOURCES_REPOSITORY/$_TARBALL 1.23 + mkdir $DESTDIR 1.24 + cd fbvnc 1.25 + patch -p0 < $stuff/fbvnc.u && 1.26 + make && cp fbvnc $DESTDIR 1.27 +} 1.28 + 1.29 + 1.30 +# Rules to gen a SliTaz package suitable for Tazpkg. 1.31 +genpkg_rules() 1.32 +{ 1.33 + mkdir -p $fs/usr/bin 1.34 + cp $_pkg/fbvnc $fs/usr/bin 1.35 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/fbvnc/stuff/fbvnc.u Thu Nov 03 16:33:16 2011 +0100 2.3 @@ -0,0 +1,612 @@ 2.4 +--- draw.h 2.5 ++++ draw.h 2.6 +@@ -15,5 +15,11 @@ 2.7 + void fb_cmap(void); 2.8 + 2.9 + /* helper functions */ 2.10 ++struct rgb_conv { 2.11 ++ int rshl, gshl; 2.12 ++ int rskp, gskp, bskp; 2.13 ++ int rmax, gmax, bmax; 2.14 ++}; 2.15 ++void fill_rgb_conv(int mode, struct rgb_conv *s); 2.16 + void fb_set(int r, int c, void *mem, int len); 2.17 + unsigned fb_val(int r, int g, int b); 2.18 +--- draw.c 2.19 ++++ draw.c 2.20 +@@ -10,14 +10,13 @@ 2.21 + 2.22 + #define MIN(a, b) ((a) < (b) ? (a) : (b)) 2.23 + #define MAX(a, b) ((a) > (b) ? (a) : (b)) 2.24 +-#define NLEVELS (1 << 8) 2.25 ++#define NLEVELS (1 << 16) 2.26 + 2.27 + static int fd; 2.28 + static void *fb; 2.29 + static struct fb_var_screeninfo vinfo; 2.30 + static struct fb_fix_screeninfo finfo; 2.31 +-static int bpp; 2.32 +-static int nr, ng, nb; 2.33 ++static int bytes_per_pixel; 2.34 + 2.35 + static int fb_len(void) 2.36 + { 2.37 +@@ -28,10 +27,12 @@ 2.38 + { 2.39 + static unsigned short red[NLEVELS], green[NLEVELS], blue[NLEVELS]; 2.40 + struct fb_cmap cmap; 2.41 ++ 2.42 + if (finfo.visual == FB_VISUAL_TRUECOLOR) 2.43 + return; 2.44 ++ 2.45 + cmap.start = 0; 2.46 +- cmap.len = MAX(nr, MAX(ng, nb)); 2.47 ++ cmap.len = NLEVELS; 2.48 + cmap.red = red; 2.49 + cmap.green = green; 2.50 + cmap.blue = blue; 2.51 +@@ -41,24 +42,39 @@ 2.52 + 2.53 + void fb_cmap(void) 2.54 + { 2.55 +- unsigned short red[NLEVELS], green[NLEVELS], blue[NLEVELS]; 2.56 ++ struct fb_bitfield *color[3] = { 2.57 ++ &vinfo.blue, &vinfo.green, &vinfo.red 2.58 ++ }; 2.59 ++ int eye_sensibility[3] = { 2, 0, 1 }; // higher=red, blue, lower=green 2.60 + struct fb_cmap cmap; 2.61 +- int i; 2.62 ++ unsigned short map[3][NLEVELS]; 2.63 ++ int i, j, n, offset; 2.64 ++ 2.65 + if (finfo.visual == FB_VISUAL_TRUECOLOR) 2.66 + return; 2.67 + 2.68 +- for (i = 0; i < nr; i++) 2.69 +- red[i] = (65535 / (nr - 1)) * i; 2.70 +- for (i = 0; i < ng; i++) 2.71 +- green[i] = (65535 / (ng - 1)) * i; 2.72 +- for (i = 0; i < nb; i++) 2.73 +- blue[i] = (65535 / (nb - 1)) * i; 2.74 +- 2.75 ++ for (i = 0, n = vinfo.bits_per_pixel; i < 3; i++) { 2.76 ++ n -= color[eye_sensibility[i]]->length = n / (3 - i); 2.77 ++ } 2.78 ++ n = (1 << vinfo.bits_per_pixel); 2.79 ++ if (n > NLEVELS) 2.80 ++ n = NLEVELS; 2.81 ++ for (i = offset = 0; i < 3; i++) { 2.82 ++ int length = color[i]->length; 2.83 ++ color[i]->offset = offset; 2.84 ++ for (j = 0; j < n; j++) { 2.85 ++ int k = (j >> offset) << (16 - length); 2.86 ++ if (k == (0xFFFF << (16 - length))) 2.87 ++ k = 0xFFFF; 2.88 ++ map[i][j] = k; 2.89 ++ } 2.90 ++ offset += length; 2.91 ++ } 2.92 + cmap.start = 0; 2.93 +- cmap.len = MAX(nr, MAX(ng, nb)); 2.94 +- cmap.red = red; 2.95 +- cmap.green = green; 2.96 +- cmap.blue = blue; 2.97 ++ cmap.len = n; 2.98 ++ cmap.red = map[2]; 2.99 ++ cmap.green = map[1]; 2.100 ++ cmap.blue = map[0]; 2.101 + cmap.transp = NULL; 2.102 + 2.103 + ioctl(fd, FBIOPUTCMAP, &cmap); 2.104 +@@ -66,25 +82,26 @@ 2.105 + 2.106 + unsigned fb_mode(void) 2.107 + { 2.108 +- return (bpp << 16) | (vinfo.red.length << 8) | 2.109 ++ return (bytes_per_pixel << 16) | (vinfo.red.length << 8) | 2.110 + (vinfo.green.length << 4) | (vinfo.blue.length); 2.111 + } 2.112 + 2.113 + int fb_init(void) 2.114 + { 2.115 ++ int err = 1; 2.116 + fd = open(FBDEV_PATH, O_RDWR); 2.117 + if (fd == -1) 2.118 + goto failed; 2.119 ++ err++; 2.120 + if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1) 2.121 + goto failed; 2.122 ++ err++; 2.123 + if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) 2.124 + goto failed; 2.125 + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); 2.126 +- bpp = (vinfo.bits_per_pixel + 7) >> 3; 2.127 +- nr = 1 << vinfo.red.length; 2.128 +- ng = 1 << vinfo.blue.length; 2.129 +- nb = 1 << vinfo.green.length; 2.130 ++ bytes_per_pixel = (vinfo.bits_per_pixel + 7) >> 3; 2.131 + fb = mmap(NULL, fb_len(), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 2.132 ++ err++; 2.133 + if (fb == MAP_FAILED) 2.134 + goto failed; 2.135 + fb_cmap_save(1); 2.136 +@@ -93,7 +110,7 @@ 2.137 + failed: 2.138 + perror("fb_init()"); 2.139 + close(fd); 2.140 +- return 1; 2.141 ++ return err; 2.142 + } 2.143 + 2.144 + void fb_free(void) 2.145 +@@ -120,19 +137,30 @@ 2.146 + 2.147 + void fb_set(int r, int c, void *mem, int len) 2.148 + { 2.149 +- memcpy(fb_mem(r) + (c + vinfo.xoffset) * bpp, mem, len * bpp); 2.150 ++ memcpy(fb_mem(r) + (c + vinfo.xoffset) * bytes_per_pixel, 2.151 ++ mem, len * bytes_per_pixel); 2.152 + } 2.153 + 2.154 ++void fill_rgb_conv(int mode, struct rgb_conv *s) 2.155 ++{ 2.156 ++ int bits; 2.157 ++ 2.158 ++ bits = mode & 0xF; mode >>= 4; 2.159 ++ s->rshl = s->gshl = bits; 2.160 ++ s->bskp = 8 - bits; s->bmax = (1 << bits) -1; 2.161 ++ bits = mode & 0xF; mode >>= 4; 2.162 ++ s->rshl += bits; 2.163 ++ s->gskp = 8 - bits; s->gmax = (1 << bits) -1; 2.164 ++ bits = mode & 0xF; 2.165 ++ s->rskp = 8 - bits; s->rmax = (1 << bits) -1; 2.166 ++} 2.167 ++ 2.168 + unsigned fb_val(int r, int g, int b) 2.169 + { 2.170 +- switch (fb_mode() & 0x0fff) { 2.171 +- default: 2.172 +- fprintf(stderr, "fb_val: unknown fb_mode()\n"); 2.173 +- case 0x0888: 2.174 +- return (r << 16) | (g << 8) | b; 2.175 +- case 0x0565: 2.176 +- return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); 2.177 +- case 0x0233: 2.178 +- return ((r >> 6) << 6) | ((g >> 5) << 3) | (b >> 5); 2.179 +- } 2.180 ++ static struct rgb_conv c; 2.181 ++ 2.182 ++ if (c.rshl == 0) 2.183 ++ fill_rgb_conv(fb_mode(), &c); 2.184 ++ return ((r >> c.rskp) << c.rshl) | ((g >> c.gskp) << c.gshl) 2.185 ++ | (b >> c.bskp); 2.186 + } 2.187 +--- fbvnc.c 2.188 ++++ fbvnc.c 2.189 +@@ -36,13 +36,15 @@ 2.190 + 2.191 + #define VNC_PORT "5900" 2.192 + 2.193 +-#define MAXRES (1 << 21) 2.194 +-#define MIN(a, b) ((a) < (b) ? (a) : (b)) 2.195 ++#define MAXRES (1 << 12) 2.196 + 2.197 + static int cols, rows; 2.198 ++static int srv_cols, srv_rows; 2.199 ++static int or, oc; 2.200 + static int mr, mc; /* mouse position */ 2.201 + 2.202 + static char buf[MAXRES]; 2.203 ++#define MAXPIX (MAXRES/sizeof(fbval_t)) 2.204 + 2.205 + static int vnc_connect(char *addr, char *port) 2.206 + { 2.207 +@@ -61,22 +63,26 @@ 2.208 + 2.209 + if (connect(fd, addrinfo->ai_addr, addrinfo->ai_addrlen) == -1) { 2.210 + close(fd); 2.211 +- freeaddrinfo(addrinfo); 2.212 +- return -1; 2.213 ++ fd = -2; 2.214 + } 2.215 + freeaddrinfo(addrinfo); 2.216 + return fd; 2.217 + } 2.218 + 2.219 ++static int bpp, vnc_mode; 2.220 ++static struct rgb_conv format; 2.221 + static int vnc_init(int fd) 2.222 + { 2.223 +- char vncver[] = "RFB 003.003\n"; 2.224 ++ static int vncfmt[] = { 0x40888, 0x20565, 0x10233, 0 }; 2.225 ++ char vncver[12]; 2.226 ++ int i; 2.227 ++ 2.228 + struct vnc_client_init clientinit; 2.229 + struct vnc_server_init serverinit; 2.230 + struct vnc_client_pixelfmt pixfmt_cmd; 2.231 + int connstat = VNC_CONN_FAILED; 2.232 + 2.233 +- write(fd, vncver, 12); 2.234 ++ write(fd, "RFB 003.003\n", 12); 2.235 + read(fd, vncver, 12); 2.236 + 2.237 + read(fd, &connstat, sizeof(connstat)); 2.238 +@@ -88,68 +94,78 @@ 2.239 + write(fd, &clientinit, sizeof(clientinit)); 2.240 + read(fd, &serverinit, sizeof(serverinit)); 2.241 + 2.242 +- if (fb_init()) 2.243 +- return -1; 2.244 +- if (FBM_BPP(fb_mode()) != sizeof(fbval_t)) { 2.245 +- fprintf(stderr, "fbvnc: fbval_t doesn't match fb depth\n"); 2.246 +- exit(1); 2.247 +- } 2.248 +- cols = MIN(ntohs(serverinit.w), fb_cols()); 2.249 +- rows = MIN(ntohs(serverinit.h), fb_rows()); 2.250 ++ i = fb_init(); 2.251 ++ if (i) 2.252 ++ return -1 - i; 2.253 ++ srv_cols = ntohs(serverinit.w); 2.254 ++ srv_rows = ntohs(serverinit.h); 2.255 ++ cols = MIN(srv_cols, fb_cols()); 2.256 ++ rows = MIN(srv_rows, fb_rows()); 2.257 + mr = rows / 2; 2.258 + mc = cols / 2; 2.259 ++ or = oc = 0; 2.260 + 2.261 + read(fd, buf, ntohl(serverinit.len)); 2.262 + pixfmt_cmd.type = VNC_CLIENT_PIXFMT; 2.263 +- pixfmt_cmd.format.bpp = 8; 2.264 +- pixfmt_cmd.format.depth = 8; 2.265 + pixfmt_cmd.format.bigendian = 0; 2.266 + pixfmt_cmd.format.truecolor = 1; 2.267 + 2.268 +- pixfmt_cmd.format.rmax = htons(3); 2.269 +- pixfmt_cmd.format.gmax = htons(7); 2.270 +- pixfmt_cmd.format.bmax = htons(7); 2.271 +- pixfmt_cmd.format.rshl = 0; 2.272 +- pixfmt_cmd.format.gshl = 2; 2.273 +- pixfmt_cmd.format.bshl = 5; 2.274 ++ if (bpp < 1) 2.275 ++ bpp = FBM_BPP(fb_mode()); 2.276 ++ if (bpp >= 3) 2.277 ++ bpp = 4; 2.278 ++ for (i = 0; bpp <= FBM_BPP(vncfmt[i]); i++) 2.279 ++ vnc_mode = vncfmt[i]; 2.280 ++ bpp = FBM_BPP(vnc_mode); 2.281 ++ pixfmt_cmd.format.bpp = 2.282 ++ pixfmt_cmd.format.depth = bpp << 3; 2.283 + 2.284 ++ fill_rgb_conv(FBM_COLORS(vnc_mode), &format); 2.285 ++ pixfmt_cmd.format.rmax = htons(format.rmax); 2.286 ++ pixfmt_cmd.format.gmax = htons(format.gmax); 2.287 ++ pixfmt_cmd.format.bmax = htons(format.bmax); 2.288 ++ pixfmt_cmd.format.rshl = format.rshl; 2.289 ++ pixfmt_cmd.format.gshl = format.gshl; 2.290 ++ pixfmt_cmd.format.bshl = 0; 2.291 + write(fd, &pixfmt_cmd, sizeof(pixfmt_cmd)); 2.292 + return fd; 2.293 + } 2.294 + 2.295 +-static int vnc_free(void) 2.296 ++static void vnc_free(void) 2.297 + { 2.298 + fb_free(); 2.299 +- return 0; 2.300 + } 2.301 + 2.302 +-static int vnc_refresh(int fd, int inc) 2.303 ++static void vnc_refresh(int fd, int inc) 2.304 + { 2.305 + struct vnc_client_fbup fbup_req; 2.306 + fbup_req.type = VNC_CLIENT_FBUP; 2.307 + fbup_req.inc = inc; 2.308 +- fbup_req.x = htons(0); 2.309 +- fbup_req.y = htons(0); 2.310 +- fbup_req.w = htons(cols); 2.311 +- fbup_req.h = htons(rows); 2.312 ++ fbup_req.x = htons(oc); 2.313 ++ fbup_req.y = htons(or); 2.314 ++ fbup_req.w = htons(oc + cols); 2.315 ++ fbup_req.h = htons(or + rows); 2.316 + write(fd, &fbup_req, sizeof(fbup_req)); 2.317 +- return 0; 2.318 + } 2.319 + 2.320 +-static void drawfb(char *s, int x, int y, int w, int h) 2.321 ++static void drawfb(char *s, int x, int y, int w) 2.322 + { 2.323 +- fbval_t slice[1 << 14]; 2.324 +- int i, j; 2.325 +- for (i = 0; i < h; i++) { 2.326 +- for (j = 0; j < w; j++) { 2.327 +- int c = *(unsigned char *) &s[i * w + j]; 2.328 +- int r = (c & 0x3) << 6; 2.329 +- int g = ((c >> 2) & 0x7) << 5; 2.330 +- int b = ((c >> 5) & 0x7) << 5; 2.331 +- slice[j] = FB_VAL(r, g, b); 2.332 ++ int mode = fb_mode(); 2.333 ++ if (mode != vnc_mode) { 2.334 ++ fbval_t slice[MAXRES]; 2.335 ++ unsigned char *byte = (unsigned char *) slice; 2.336 ++ int j; 2.337 ++ int fb_bpp = FBM_BPP(mode); 2.338 ++ for (j = 0; j < w; j++, byte += fb_bpp, s += bpp) { 2.339 ++ fbval_t c = * (fbval_t *) s; 2.340 ++ int r = ((c >> format.rshl) & format.rmax) << format.rskp; 2.341 ++ int g = ((c >> format.gshl) & format.gmax) << format.gskp; 2.342 ++ int b = (c & format.bmax) << format.bskp; 2.343 ++ * (fbval_t *) byte = FB_VAL(r, g, b); 2.344 + } 2.345 +- fb_set(y + i, x, slice, w); 2.346 ++ s = (void *) slice; 2.347 + } 2.348 ++ fb_set(y, x, s, w); 2.349 + } 2.350 + 2.351 + static void xread(int fd, void *buf, int len) 2.352 +@@ -159,54 +175,84 @@ 2.353 + while (nr < len && (n = read(fd, buf + nr, len - nr)) > 0) 2.354 + nr += n; 2.355 + if (nr < len) { 2.356 +- printf("partial vnc read!\n"); 2.357 +- exit(1); 2.358 ++ fprintf(stderr,"partial vnc read!\n"); 2.359 ++ exit(99); 2.360 + } 2.361 + } 2.362 + 2.363 ++static void skip(int fd, int len) 2.364 ++{ 2.365 ++ int n; 2.366 ++ while (len > 0 && (n = read(fd, buf, MIN(len, sizeof(buf)))) > 0) 2.367 ++ len -= n; 2.368 ++} 2.369 ++ 2.370 + static int vnc_event(int fd) 2.371 + { 2.372 + struct vnc_rect uprect; 2.373 +- char msg[1 << 12]; 2.374 +- struct vnc_server_fbup *fbup = (void *) msg; 2.375 +- struct vnc_server_cuttext *cuttext = (void *) msg; 2.376 +- struct vnc_server_colormap *colormap = (void *) msg; 2.377 +- int j; 2.378 +- int n; 2.379 ++ union { 2.380 ++ struct vnc_server_fbup fbup; 2.381 ++ struct vnc_server_cuttext cuttext; 2.382 ++ struct vnc_server_colormap colormap; 2.383 ++ } msg; 2.384 ++ int j, n; 2.385 + 2.386 +- if (read(fd, msg, 1) != 1) 2.387 ++ if (read(fd, &msg.fbup.type, 1) != 1) 2.388 + return -1; 2.389 +- switch (msg[0]) { 2.390 ++ switch (msg.fbup.type) { 2.391 + case VNC_SERVER_FBUP: 2.392 +- xread(fd, msg + 1, sizeof(*fbup) - 1); 2.393 +- n = ntohs(fbup->n); 2.394 ++ xread(fd, &msg.fbup.pad, sizeof(msg.fbup) - 1); 2.395 ++ n = ntohs(msg.fbup.n); 2.396 + for (j = 0; j < n; j++) { 2.397 +- int x, y, w, h; 2.398 ++ int x, y, w, h, l, i; 2.399 + xread(fd, &uprect, sizeof(uprect)); 2.400 ++ if (uprect.enc != 0) { 2.401 ++ fprintf(stderr,"Encoding not RAW: %d\n", 2.402 ++ ntohl(uprect.enc)); 2.403 ++ return -1; 2.404 ++ } 2.405 + x = ntohs(uprect.x); 2.406 + y = ntohs(uprect.y); 2.407 + w = ntohs(uprect.w); 2.408 + h = ntohs(uprect.h); 2.409 +- if (x >= cols || x + w > cols) 2.410 +- return -1; 2.411 +- if (y >= rows || y + h > rows) 2.412 +- return -1; 2.413 +- xread(fd, buf, w * h); 2.414 +- drawfb(buf, x, y, w, h); 2.415 ++ x -= oc; 2.416 ++ y -= or; 2.417 ++ i = 0; 2.418 ++ l = MIN(w, cols - x); 2.419 ++ if (x < 0) { 2.420 ++ l = MIN(w + x, cols); 2.421 ++ i = MIN(w, -x); 2.422 ++ x = 0; 2.423 ++ } 2.424 ++ if (l < 0) 2.425 ++ l = 0; 2.426 ++ for (; h--; y++) { 2.427 ++ int n = l; 2.428 ++ int xj = x; 2.429 ++ skip(fd, i * bpp); 2.430 ++ while (n > 0) { 2.431 ++ int j = MIN(n, MAXPIX); 2.432 ++ xread(fd, buf, j * bpp); 2.433 ++ if (y >= 0 && y < rows) 2.434 ++ drawfb(buf, xj, y, j); 2.435 ++ xj += j; n -= j; 2.436 ++ } 2.437 ++ skip(fd, (w - l - i) * bpp); 2.438 ++ } 2.439 + } 2.440 + break; 2.441 + case VNC_SERVER_BELL: 2.442 + break; 2.443 + case VNC_SERVER_CUTTEXT: 2.444 +- xread(fd, msg + 1, sizeof(*cuttext) - 1); 2.445 +- xread(fd, buf, ntohl(cuttext->len)); 2.446 ++ xread(fd, &msg.cuttext.pad1, sizeof(msg.cuttext) - 1); 2.447 ++ skip(fd, ntohl(msg.cuttext.len)); 2.448 + break; 2.449 + case VNC_SERVER_COLORMAP: 2.450 +- xread(fd, msg + 1, sizeof(*colormap) - 1); 2.451 +- xread(fd, buf, ntohs(colormap->n) * 3 * 2); 2.452 ++ xread(fd, &msg.colormap.pad, sizeof(msg.colormap) - 1); 2.453 ++ skip(fd, ntohs(msg.colormap.n) * 3 * 2); 2.454 + break; 2.455 + default: 2.456 +- fprintf(stderr, "unknown vnc msg: %d\n", msg[0]); 2.457 ++ fprintf(stderr, "unknown vnc msg: %d\n", msg.fbup.type); 2.458 + return -1; 2.459 + } 2.460 + return 0; 2.461 +@@ -217,12 +263,31 @@ 2.462 + char ie[3]; 2.463 + struct vnc_client_ratevent me = {VNC_CLIENT_RATEVENT}; 2.464 + int mask = 0; 2.465 ++ int refresh = 2; 2.466 + if (read(ratfd, &ie, sizeof(ie)) != 3) 2.467 + return -1; 2.468 + mc += ie[1]; 2.469 + mr -= ie[2]; 2.470 +- mc = MAX(0, MIN(cols - 1, mc)); 2.471 +- mr = MAX(0, MIN(rows - 1, mr)); 2.472 ++ if (mc < oc) { 2.473 ++ if ((oc -= cols / 5) < 0) 2.474 ++ oc = 0; 2.475 ++ } 2.476 ++ else if (mc >= oc + cols && oc + cols < srv_cols) { 2.477 ++ if ((oc += cols / 5) > srv_cols - cols) 2.478 ++ oc = srv_cols - cols; 2.479 ++ } 2.480 ++ else refresh--; 2.481 ++ if (mr < or) { 2.482 ++ if ((or -= rows / 5) < 0) 2.483 ++ or = 0; 2.484 ++ } 2.485 ++ else if (mr >= or + rows && or + rows < srv_rows) { 2.486 ++ if ((or += rows / 5) > srv_rows - rows) 2.487 ++ or = srv_rows - rows; 2.488 ++ } 2.489 ++ else refresh--; 2.490 ++ mc = MAX(oc, MIN(oc + cols - 1, mc)); 2.491 ++ mr = MAX(or, MIN(or + rows - 1, mr)); 2.492 + if (ie[0] & 0x01) 2.493 + mask |= VNC_BUTTON1_MASK; 2.494 + if (ie[0] & 0x04) 2.495 +@@ -233,6 +298,8 @@ 2.496 + me.x = htons(mc); 2.497 + me.mask = mask; 2.498 + write(fd, &me, sizeof(me)); 2.499 ++ if (refresh) 2.500 ++ vnc_refresh(fd, 0); 2.501 + return 0; 2.502 + } 2.503 + 2.504 +@@ -292,12 +359,11 @@ 2.505 + k = 0xff0d; 2.506 + break; 2.507 + case 0x0c: /* ^L: redraw */ 2.508 +- if (vnc_refresh(fd, 0)) 2.509 +- return -1; 2.510 ++ vnc_refresh(fd, 0); 2.511 + default: 2.512 + k = (unsigned char) key[i]; 2.513 + } 2.514 +- if (k >= 'A' && k <= 'Z' || strchr(":\"<>?{}|+_()*&^%$#@!~", k)) 2.515 ++ if ((k >= 'A' && k <= 'Z') || strchr(":\"<>?{}|+_()*&^%$#@!~", k)) 2.516 + mod[nmod++] = 0xffe1; 2.517 + if (k >= 1 && k <= 26) { 2.518 + k = 'a' + k - 1; 2.519 +@@ -339,40 +405,42 @@ 2.520 + write(STDIN_FILENO, show, strlen(show)); 2.521 + } 2.522 + 2.523 +-static void mainloop(int vnc_fd, int kbd_fd, int rat_fd) 2.524 ++static int mainloop(int vnc_fd, int kbd_fd, int rat_fd) 2.525 + { 2.526 + struct pollfd ufds[3]; 2.527 + int pending = 0; 2.528 + int err; 2.529 + ufds[0].fd = kbd_fd; 2.530 +- ufds[0].events = POLLIN; 2.531 + ufds[1].fd = vnc_fd; 2.532 +- ufds[1].events = POLLIN; 2.533 + ufds[2].fd = rat_fd; 2.534 ++ ufds[0].events = 2.535 ++ ufds[1].events = 2.536 + ufds[2].events = POLLIN; 2.537 +- if (vnc_refresh(vnc_fd, 0)) 2.538 +- return; 2.539 ++ vnc_refresh(vnc_fd, 0); 2.540 + while (1) { 2.541 + err = poll(ufds, 3, 500); 2.542 + if (err == -1 && errno != EINTR) 2.543 + break; 2.544 + if (!err) 2.545 + continue; 2.546 ++ err = -2; 2.547 + if (ufds[0].revents & POLLIN) 2.548 + if (kbd_event(vnc_fd, kbd_fd) == -1) 2.549 + break; 2.550 ++ err--; 2.551 + if (ufds[1].revents & POLLIN) { 2.552 + if (vnc_event(vnc_fd) == -1) 2.553 + break; 2.554 + pending = 0; 2.555 + } 2.556 ++ err--; 2.557 + if (ufds[2].revents & POLLIN) 2.558 + if (rat_event(vnc_fd, rat_fd) == -1) 2.559 + break; 2.560 + if (!pending++) 2.561 +- if (vnc_refresh(vnc_fd, 1)) 2.562 +- break; 2.563 ++ vnc_refresh(vnc_fd, 1); 2.564 + } 2.565 ++ return err; 2.566 + } 2.567 + 2.568 + int main(int argc, char * argv[]) 2.569 +@@ -380,27 +448,38 @@ 2.570 + char *port = VNC_PORT; 2.571 + char *host = "127.0.0.1"; 2.572 + struct termios ti; 2.573 +- int vnc_fd, rat_fd; 2.574 ++ int vnc_fd, rat_fd, status; 2.575 ++ 2.576 ++ if (argc < 2) { 2.577 ++ fprintf(stderr, "Usage : fbvnc [-bpp bits] server [port]\n"); 2.578 ++ return 0; 2.579 ++ } 2.580 ++ if (*argv[1] == '-' && argc >= 3) { 2.581 ++ argc -= 2; argv += 2; 2.582 ++ bpp = atoi(argv[0]) >> 3; 2.583 ++ } 2.584 + if (argc >= 2) 2.585 + host = argv[1]; 2.586 + if (argc >= 3) 2.587 + port = argv[2]; 2.588 +- if ((vnc_fd = vnc_connect(host, port)) == -1) { 2.589 +- fprintf(stderr, "could not connect!\n"); 2.590 ++ if ((vnc_fd = vnc_connect(host, port)) < 0) { 2.591 ++ fprintf(stderr, "could not connect! %s %s : %d\n", 2.592 ++ host,port,vnc_fd); 2.593 + return 1; 2.594 + } 2.595 +- if (vnc_init(vnc_fd) == -1) { 2.596 +- fprintf(stderr, "vnc init failed!\n"); 2.597 +- return 1; 2.598 ++ status = vnc_init(vnc_fd); 2.599 ++ if (status < 0) { 2.600 ++ fprintf(stderr, "vnc init failed! %d\n", status); 2.601 ++ return 2; 2.602 + } 2.603 + term_setup(&ti); 2.604 + rat_fd = open("/dev/input/mice", O_RDONLY); 2.605 + 2.606 +- mainloop(vnc_fd, 0, rat_fd); 2.607 ++ status = mainloop(vnc_fd, 0, rat_fd); 2.608 + 2.609 + term_cleanup(&ti); 2.610 + vnc_free(); 2.611 + close(vnc_fd); 2.612 + close(rat_fd); 2.613 +- return 0; 2.614 ++ return 2 - status; 2.615 + }
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/novnc/receipt Thu Nov 03 16:33:16 2011 +0100 3.3 @@ -0,0 +1,52 @@ 3.4 +# SliTaz package receipt. 3.5 + 3.6 +PACKAGE="novnc" 3.7 +VERSION="20110901" 3.8 +CATEGORY="network" 3.9 +SHORT_DESC="VNC client in javascript." 3.10 +MAINTAINER="pascal.bellard@slitaz.org" 3.11 +WEB_SITE="http://github.com/kanaka/noVNC" 3.12 +_TARBALL="$PACKAGE-$VERSION.tgz" 3.13 + 3.14 +DEPENDS="python python-numpy" 3.15 +BUILD_DEPENDS="wget python python-pil openssl" 3.16 +SUGGESTED="pyopenssl openssl" 3.17 + 3.18 +# Rules to configure and make the package. 3.19 +compile_rules() 3.20 +{ 3.21 + [ -s $SOURCES_REPOSITORY/$_TARBALL ] || 3.22 + wget -O $SOURCES_REPOSITORY/$_TARBALL \ 3.23 + $WEB_SITE/tarball/7b10dc8a485079fdc34847140fb0c993265e3a1e 3.24 + mkdir -p $src 3.25 + cd $src 3.26 + tar xzf $SOURCES_REPOSITORY/$_TARBALL 3.27 + mkdir -p $DESTDIR 3.28 + cd kanaka* 3.29 + sed -i 's/bash/sh/;s/ps -p \([^ ]*\)/ps | grep "^ *\1 "/' utils/launch.sh 3.30 + IMAGE=/usr/share/images/slitaz-background.jpg 3.31 + [ -s $IMAGE ] && utils/img2js.py $IMAGE noVNC_logo > include/logo.js 3.32 + cp -a *.html images/favicon.ico utils include $DESTDIR 3.33 +} 3.34 + 3.35 +# Rules to gen a SliTaz package suitable for Tazpkg. 3.36 +genpkg_rules() 3.37 +{ 3.38 + mkdir -p $fs/usr/share/novnc 3.39 + cp -a $_pkg/* $fs/usr/share/novnc 3.40 +} 3.41 + 3.42 +port_install() 3.43 +{ 3.44 + which openssl > /dev/null && 3.45 + openssl req -new -x509 -keyout $1/usr/share/novnc/self.pem \ 3.46 + -out $1/usr/share/novnc/self.pem -days 3650 -nodes <<EOT 3.47 +$(. /etc/locale.conf ; echo ${LANG#*_}) 3.48 +$(cat /etc/TZ) 3.49 + 3.50 +$(cat /etc/hostname) 3.51 + 3.52 + 3.53 + 3.54 +EOT 3.55 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/sdcc/receipt Thu Nov 03 16:33:16 2011 +0100 4.3 @@ -0,0 +1,33 @@ 4.4 +# SliTaz package receipt. 4.5 + 4.6 +PACKAGE="sdcc" 4.7 +VERSION="2.9.0" 4.8 +CATEGORY="development" 4.9 +SHORT_DESC="Retargettable C compiler for 8051, Z80 and 68HC08." 4.10 +MAINTAINER="pascal.bellard@slitaz.org" 4.11 +TARBALL="$PACKAGE-src-$VERSION.tar.bz2" 4.12 +WEB_SITE="http://sdcc.sourceforge.net/" 4.13 +WGET_URL="$SF_MIRROR/$PACKAGE/$PACKAGE/$VERSION/$TARBALL" 4.14 +TAGS="cross compiler" 4.15 + 4.16 +# Rules to configure and make the package. 4.17 +compile_rules() 4.18 +{ 4.19 + mv $PACKAGE $src 2> /dev/null 4.20 + cd $src 4.21 + sed -i 's/all %/%/' device/lib/pic/Makefile.in 4.22 + find -name getline.h | xargs sed -i \ 4.23 + 's/char.*getline/#define getline sdcc_getline\nchar *sdcc_getline/' 4.24 + ./configure --prefix=/usr --infodir=/usr/share/info \ 4.25 + --mandir=/usr/share/man \ 4.26 + $CONFIGURE_ARGS && 4.27 + make && 4.28 + make DESTDIR=$PWD/_pkg install 4.29 +} 4.30 + 4.31 +# Rules to gen a SliTaz package suitable for Tazpkg. 4.32 +genpkg_rules() 4.33 +{ 4.34 + cp -a $_pkg/usr $fs 4.35 +} 4.36 +