

(defun generate-ip-list ()
  (interactive)
  (save-excursion
    (let ((liste nil)
	  (count 1)
	  )
      (beginning-of-buffer)
      (while (search-forward-regexp "case\\s +\\(IP_[a-zA-Z_0-9]+\\)\\s *:" nil t)
	(setq liste (cons (match-string 1) 
			  liste))
	)
      (setq liste (reverse liste))
      (find-file "otalk.h")
      (beginning-of-buffer)
      (search-forward-regexp "/\\* LISTE IP_ \\*/")
      (beginning-of-line)
      (next-line 1)
      (save-excursion
	(delete-matching-lines "^#define\\s +IP_[a-zA-Z_0-9]+\\s +[0-9]+"))
      (while liste
	(insert-string "#define " 
		       (format "%-27s" (car liste))
		       (format "%-2d" count)
		       "\n")
	(setq count (+ 1 count))
	(setq liste (cdr liste))))))
