From: <cli...@li...> - 2007-01-23 20:03:29
|
Send clisp-cvs mailing list submissions to cli...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/clisp-cvs or, via email, send a message with subject or body 'help' to cli...@li... You can reach the person managing the list at cli...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of clisp-cvs digest..." CLISP CVS commits for today Today's Topics: 1. clisp/src NEWS,1.367,1.368 ChangeLog,1.5494,1.5495 (Sam Steingold) 2. clisp/modules/fastcgi fastcgi.lisp, 1.11, 1.12 fastcgi_wrappers.c, 1.4, 1.5 (John Hinsdale) 3. clisp/src ChangeLog,1.5495,1.5496 (John Hinsdale) ---------------------------------------------------------------------- Message: 1 Date: Tue, 23 Jan 2007 03:36:47 +0000 From: Sam Steingold <sd...@us...> Subject: clisp/src NEWS,1.367,1.368 ChangeLog,1.5494,1.5495 To: cli...@li... Message-ID: <E1H...@ma...> Update of /cvsroot/clisp/clisp/src In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27144/src Modified Files: NEWS ChangeLog Log Message: New-CLX supports stumpwm Index: NEWS =================================================================== RCS file: /cvsroot/clisp/clisp/src/NEWS,v retrieving revision 1.367 retrieving revision 1.368 diff -u -d -r1.367 -r1.368 --- NEWS 11 Jan 2007 00:25:06 -0000 1.367 +++ NEWS 23 Jan 2007 03:36:44 -0000 1.368 @@ -12,6 +12,9 @@ * Module libsvm has been upgraded to the upstream version 2.83. See <http://clisp.cons.org/impnotes/libsvm.html> for details. +* NEW-CLX module now supports Sumpwm <http://www.nongnu.org/stumpwm/>. + Thanks to Shawn Betts <sa...@vc...>. + * EXT:ARGLIST now works on macros too. See <http://clisp.cons.org/impnotes/flow-dict.html#arglist> for details. Index: ChangeLog =================================================================== RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v retrieving revision 1.5494 retrieving revision 1.5495 diff -u -d -r1.5494 -r1.5495 --- ChangeLog 14 Jan 2007 15:41:33 -0000 1.5494 +++ ChangeLog 23 Jan 2007 03:36:44 -0000 1.5495 @@ -1,3 +1,22 @@ +2007-01-22 Shawn Betts <sa...@vc...> + Sam Steingold <sd...@gn...> + + New-CLX supports stumpwm + * modules/clx/new-clx/clx.f (SET-SELECTION-OWNER): fix argument order + (encode_event): set the event type; fix STACK handling + :EVENT-WINDOW is sometimes just a synonym for :WINDOW, sometimes + not; correctly map :EVENT-WINDOW to the corresponding XEvent slot + (:REPARENT-NOTIFY): add :OVERRIDE-REDIRECT-P + (ungrab_X): fix STACK handling + (xlib_error_handler): pass :ASYNCHRONOUS up + (XLIB:MAPPING-NOTIFY): implemented + (travel_queque): used to peek the event and called the event + handler which meant calling PROCESS-EVENTS inside that event + handler got the same event (this doesn't happen in mit-clx or + portable-clx). So travel_queque now just calls XNextEvent() + * modules/clx/new-clx/clx.lisp (SET-SELECTION-OWNER): export + implement error conditions (copied from mit-clx) + 2007-01-01 Sam Steingold <sd...@gn...> * spvw_debug.d (TheLfloat_) [DEBUG_SPVW]: added ------------------------------ Message: 2 Date: Tue, 23 Jan 2007 16:54:32 +0000 From: John Hinsdale <hi...@us...> Subject: clisp/modules/fastcgi fastcgi.lisp, 1.11, 1.12 fastcgi_wrappers.c, 1.4, 1.5 To: cli...@li... Message-ID: <E1H...@ma...> Update of /cvsroot/clisp/clisp/modules/fastcgi In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv24753/modules/fastcgi Modified Files: fastcgi.lisp fastcgi_wrappers.c Log Message: Allow binary file uploads via FastCGI Index: fastcgi.lisp =================================================================== RCS file: /cvsroot/clisp/clisp/modules/fastcgi/fastcgi.lisp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- fastcgi.lisp 14 Nov 2006 02:33:59 -0000 1.11 +++ fastcgi.lisp 23 Jan 2007 16:54:30 -0000 1.12 @@ -96,7 +96,7 @@ (do ((result "") (eof nil)) (eof result) - (let ((buf (fcgi_read_stdin))) + (let ((buf (byte-array-to-string (hex-to-byte-array (fcgi_read_stdin))))) (if (= 0 (length buf)) (setf eof t) (setf result (ext:string-concat result buf)))))) @@ -115,6 +115,38 @@ ; ---------------- Internal functions +;; HEX-VALUE -- Get integer value of single upper-case hex digit +(defun hex-value (h) + (cond ((and (char>= h #\A) (char<= h #\F)) + (+ 10 (- (char-code h) (char-code #\A)))) + ((and (char>= h #\a) (char<= h #\f)) + (+ 10 (- (char-code h) (char-code #\a)))) + ((and (char>= h #\0) (char<= h #\9)) + (- (char-code h) (char-code #\0))) + (t (error "Invalid hex digit")))) + +;; HEX-BYTE-VALUE -- Get byte value of pair of hex digits +(defun hex-byte-value (hh) + (+ (* 16 (hex-value (elt hh 0))) + (hex-value (elt hh 1)))) + +;; HEX-TO-BYTE-ARRAY -- Convert hex string to byte array +(defun hex-to-byte-array (h) + (let* ((size (/ (length h) 2)) + (result (make-array size :element-type '(unsigned-byte 8)))) + (loop + for i from 0 to (1- size) do + (let ((offset (* 2 i))) + (setf (elt result i) + (coerce (hex-byte-value (subseq h offset (+ 2 offset))) + '(unsigned-byte 8))))) + result)) + +;; BYTE-ARRAY-TO-STRING -- Convert byte array to string +(defun byte-array-to-string (b) + (coerce (map 'array #'(lambda (c) (code-char c)) b) + 'string)) + ; CAT ; Concatenate strings (defun cat (&rest args) Index: fastcgi_wrappers.c =================================================================== RCS file: /cvsroot/clisp/clisp/modules/fastcgi/fastcgi_wrappers.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- fastcgi_wrappers.c 12 Oct 2006 09:26:11 -0000 1.4 +++ fastcgi_wrappers.c 23 Jan 2007 16:54:30 -0000 1.5 @@ -44,6 +44,7 @@ /* Local functions */ static char * read_stdio(FILE *); static int write_stdio(FILE *, char *, int); +static void hexify (unsigned char *, int) ; /* Externally visible functions */ @@ -102,30 +103,25 @@ } -/* Read some bytes from stdin. Return a null-terminated string. This +/* Read some bytes from stdin. Return a null-terminated hex string. This does NOT necessarily read up to end of file, but rather will read until its buffer is full. Therefore, if you want to slurp in the entire contents of STDIN (which you usually do) you have to call this repeatedly. - Furthermore, the result is returned to CLISP as a null-terminated - string, so that occurrences of NUL (binary 0) characters in the - data will cause Lisp to get a short string. In web forms, however, - such data will usually be encoded. - */ char * fcgi_read_stdin() { return read_stdio(stdin); } static char * read_stdio(FILE * f) { - static char buf[TEMPBUFSIZE + 1]; + static unsigned char buf[2 * TEMPBUFSIZE + 1]; size_t nact = 0; if ( ! feof(f) ) nact = fread(buf, 1, TEMPBUFSIZE, f); if ( ferror(f) ) nact = 0; - buf[nact] = '\0'; + hexify(buf, nact); return buf; } @@ -155,3 +151,21 @@ void fcgi_finish_wrapper() { FCGI_Finish(); } + +/* Convert a binary buffer to null-terminated hex in place. Actual + allocation of buf must be twice N plus 1. Work from the end to the + start so we don't stomp on ourselves. */ +/* Convert int to hex */ +#define itoh(n)(((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')) +static void hexify (unsigned char * buf, int n) +{ + int i; + for ( i = n-1; i >= 0; i-- ) { + unsigned char c = buf[i]; + buf[2*i] = itoh(c / 16); + buf[2*i + 1] = itoh(c & 0xF); + } + + /* Null terminate */ + buf[2*n] = '\0'; +} ------------------------------ Message: 3 Date: Tue, 23 Jan 2007 16:54:32 +0000 From: John Hinsdale <hi...@us...> Subject: clisp/src ChangeLog,1.5495,1.5496 To: cli...@li... Message-ID: <E1H...@ma...> Update of /cvsroot/clisp/clisp/src In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv24753/src Modified Files: ChangeLog Log Message: Allow binary file uploads via FastCGI Index: ChangeLog =================================================================== RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v retrieving revision 1.5495 retrieving revision 1.5496 diff -u -d -r1.5495 -r1.5496 --- ChangeLog 23 Jan 2007 03:36:44 -0000 1.5495 +++ ChangeLog 23 Jan 2007 16:54:28 -0000 1.5496 @@ -1,3 +1,9 @@ +2007-01-22 John Hinsdale <hi...@al...> + + Allow binary file uploads via FastCGI + * modules/fastcgi/fastcgi.lisp, fastcgi_wrappers.c: handle binary + data via STDIN on POST request. Reported by Mik...@gm... + 2007-01-22 Shawn Betts <sa...@vc...> Sam Steingold <sd...@gn...> ------------------------------ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ------------------------------ _______________________________________________ clisp-cvs mailing list cli...@li... https://lists.sourceforge.net/lists/listinfo/clisp-cvs End of clisp-cvs Digest, Vol 9, Issue 9 *************************************** |
From: Sam S. <sd...@gn...> - 2007-01-23 20:39:08
|
> +;; BYTE-ARRAY-TO-STRING -- Convert byte array to string > +(defun byte-array-to-string (b) > + (coerce (map 'array #'(lambda (c) (code-char c)) b) > + 'string)) I don't think this is right. first of all, this: (defun byte-array-to-string (b) (map 'string #'code-char b)) is faster and clearer. second, this whole hexify hack feels yuky. there should be a better way (Jorg?). if FFI does not cut it, maybe switching to modprep would be a good idea? Sam |