Add Debian source format file
[cl-fftw3.git] / wisdom.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          wisdowm.lisp
6 ;;;; Purpose:       Functions for handling FFTW wisdom
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  March 2009
9 ;;;;
10 ;;;; This file and CL-FFTW3 are Copyright (c) 2009-2011 by Kevin M. Rosenberg
11 ;;;;
12 ;;;; FFTW3 users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
16
17 (in-package #:fftw3)
18
19 (defun import-user-wisdom ()
20   (let ((file-contents (kmrcl:read-file-to-string *user-wisdom-file*)))
21     (when (and (stringp file-contents) (plusp (length file-contents)))
22       (fftw-import-wisdom-from-string file-contents))))
23
24 (defun export-user-wisdom ()
25   (let ((str+ptr (fftw-export-wisdom-to-string)))
26     (when (probe-file *user-wisdom-file*)
27       (delete-file *user-wisdom-file*))
28     (with-open-file (out *user-wisdom-file* :direction :output :if-exists :overwrite
29                          :if-does-not-exist :create)
30       (format out "~A" (first str+ptr)))
31     (free (second str+ptr))))
32
33