From: ueno Date: Mon, 23 Oct 2006 08:18:03 +0000 (+0000) Subject: * mixi.el (mixi-curl-retrieve): New function. X-Git-Tag: cache-file-branchpoint~53 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4abb2b1114fc6ec3ed2ff3f9853478253c37b059;p=elisp%2Fmixi.git * mixi.el (mixi-curl-retrieve): New function. --- diff --git a/ChangeLog b/ChangeLog index cd7c92a..71c3a97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-10-23 Daiki Ueno + + * mixi.el (mixi-curl-retrieve): New function. + 2006-10-23 OHASHI Akira * mixi.el (mixi-get-matched-items): Don't convert string to number. diff --git a/mixi.el b/mixi.el index 4a35c67..4027a73 100644 --- a/mixi.el +++ b/mixi.el @@ -126,6 +126,16 @@ (function :format "Other function: %v\n" :size 0)) :group 'mixi) +(defcustom mixi-curl-program "curl" + "*The program name of `curl'." + :type 'file + :group 'mixi) + +(defcustom mixi-curl-cookie-file (expand-file-name "~/.mixi-cookies.txt") + "*The location of cookie file created by `curl'." + :type 'file + :group 'mixi) + (defcustom mixi-default-email nil "*Default E-mail address that is used to login automatically." :type '(choice (string :tag "E-mail address") @@ -237,6 +247,39 @@ Increase this value when unexpected error frequently occurs." (let ((ret (buffer-substring-no-properties (point-min) (point-max)))) (mixi-retrieve-1 ret url post-data)))))) +(defun mixi-curl-retrieve (url &optional post-data) + "Retrieve the URL and return getted strings." + (with-temp-buffer + (let ((orig-mode (default-file-modes)) + process ret) + (unwind-protect + (progn + (set-default-file-modes 448) + (setq process + (apply #'start-process "curl" (current-buffer) + mixi-curl-program + (append (if post-data '("-d" "@-")) + (list "-i" "-L" "-s" + "-b" mixi-curl-cookie-file + "-c" mixi-curl-cookie-file + (concat mixi-url url))))) + (set-process-sentinel process #'ignore)) + (set-default-file-modes orig-mode)) + (when post-data + (process-send-string process (concat post-data "\n")) + (process-send-eof process)) + (while (eq (process-status process) 'run) + (accept-process-output process 1)) + (goto-char (point-min)) + (while (looking-at "HTTP/[0-9]+\\.[0-9]+ [13][0-9][0-9]") + (delete-region (point) (re-search-forward "\r?\n\r?\n"))) + (unless (looking-at "HTTP/[0-9]+\\.[0-9]+ 200") + (error (mixi-message "Cannot retrieve"))) + (delete-region (point) (re-search-forward "\r?\n\r?\n")) + (setq ret (decode-coding-string (buffer-substring (point) (point-max)) + mixi-coding-system)) + (mixi-retrieve-1 ret url post-data)))) + (defconst mixi-my-id-regexp "