repo
string | commit
string | message
string | diff
string |
---|---|---|---|
methodmissing/vio
|
cf68c502b6ecc50eeef7be73e1de59a1604c54ec
|
Implement IO.readv
|
diff --git a/ext/vio/Makefile b/ext/vio/Makefile
index 7a7517f..e47763a 100644
--- a/ext/vio/Makefile
+++ b/ext/vio/Makefile
@@ -1,186 +1,157 @@
SHELL = /bin/sh
#### Start of system configuration section. ####
srcdir = .
-topdir = /opt/local/ruby19/include/ruby-1.9.1
-hdrdir = /opt/local/ruby19/include/ruby-1.9.1
-arch_hdrdir = /opt/local/ruby19/include/ruby-1.9.1/$(arch)
-VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
-prefix = $(DESTDIR)/opt/local/ruby19
-rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+topdir = /opt/local/lib/ruby/1.8/i686-darwin9.5.1
+hdrdir = $(topdir)
+VPATH = $(srcdir):$(topdir):$(hdrdir)
exec_prefix = $(prefix)
-vendorhdrdir = $(rubyhdrdir)/vendor_ruby
-sitehdrdir = $(rubyhdrdir)/site_ruby
-rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
-vendordir = $(rubylibprefix)/vendor_ruby
-sitedir = $(rubylibprefix)/site_ruby
-ridir = $(datarootdir)/$(RI_BASE_NAME)
+prefix = $(DESTDIR)/opt/local
+sharedstatedir = $(prefix)/com
mandir = $(datarootdir)/man
-localedir = $(datarootdir)/locale
-libdir = $(exec_prefix)/lib
psdir = $(docdir)
-pdfdir = $(docdir)
-dvidir = $(docdir)
-htmldir = $(docdir)
-infodir = $(datarootdir)/info
-docdir = $(datarootdir)/doc/$(PACKAGE)
oldincludedir = $(DESTDIR)/usr/include
+localedir = $(datarootdir)/locale
+bindir = $(exec_prefix)/bin
+libexecdir = $(exec_prefix)/libexec
+sitedir = $(libdir)/ruby/site_ruby
+htmldir = $(docdir)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
includedir = $(prefix)/include
-localstatedir = $(prefix)/var
-sharedstatedir = $(prefix)/com
+infodir = $(datarootdir)/info
+vendorlibdir = $(vendordir)/$(ruby_version)
sysconfdir = $(prefix)/etc
-datadir = $(datarootdir)
-datarootdir = $(prefix)/share
-libexecdir = $(exec_prefix)/libexec
+libdir = $(exec_prefix)/lib
sbindir = $(exec_prefix)/sbin
-bindir = $(exec_prefix)/bin
-rubylibdir = $(rubylibprefix)/$(ruby_version)
+rubylibdir = $(libdir)/ruby/$(ruby_version)
+docdir = $(datarootdir)/doc/$(PACKAGE)
+dvidir = $(docdir)
+vendordir = $(libdir)/ruby/vendor_ruby
+datarootdir = $(prefix)/share
+pdfdir = $(docdir)
archdir = $(rubylibdir)/$(arch)
-sitelibdir = $(sitedir)/$(ruby_version)
sitearchdir = $(sitelibdir)/$(sitearch)
-vendorlibdir = $(vendordir)/$(ruby_version)
-vendorarchdir = $(vendorlibdir)/$(sitearch)
+datadir = $(datarootdir)
+localstatedir = $(prefix)/var
+sitelibdir = $(sitedir)/$(ruby_version)
CC = gcc
-CXX = g++
LIBRUBY = $(LIBRUBY_A)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
-LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
+LIBRUBYARG_SHARED =
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
-OUTFLAG = -o
-COUTFLAG = -o
RUBY_EXTCONF_H =
-cflags = $(optflags) $(debugflags) $(warnflags)
-optflags = -O3
-debugflags = -g
-warnflags = -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings
-CFLAGS = -fno-common $(cflags) -pipe
-INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
+CFLAGS = -fno-common -O2 -pipe -fno-common $(cflags)
+INCFLAGS = -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.5.1 -I.
DEFS =
-CPPFLAGS = -DHAVE_RB_THREAD_BLOCKING_REGION -DRUBY19 -pedantic -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
-CXXFLAGS = $(CFLAGS) $(cxxflags)
-ldflags = -L. -L/usr/local/lib
+CPPFLAGS = -DHAVE_RB_TRAP_IMMEDIATE -DRUBY18 -pedantic -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
+CXXFLAGS = $(CFLAGS)
+ldflags = -L.
dldflags =
archflag =
DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
-LDSHARED = $(CC) -dynamic -bundle -undefined suppress -flat_namespace
-LDSHAREDXX = $(CXX) -dynamic -bundle -undefined suppress -flat_namespace
+LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
AR = ar
EXEEXT =
-RUBY_BASE_NAME = ruby
RUBY_INSTALL_NAME = ruby
RUBY_SO_NAME = ruby
-arch = i386-darwin9.7.0
-sitearch = $(arch)
-ruby_version = 1.9.1
-ruby = /opt/local/ruby19/bin/ruby
+arch = i686-darwin9.5.1
+sitearch = i686-darwin9.5.1
+ruby_version = 1.8
+ruby = /opt/local/bin/ruby
RUBY = $(ruby)
RM = rm -f
-RM_RF = $(RUBY) -run -e rm -- -rf
-RMDIRS = $(RUBY) -run -e rmdir -- -p
MAKEDIRS = mkdir -p
INSTALL = /usr/bin/install -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp
#### End of system configuration section. ####
preload =
libpath = . $(libdir)
LIBPATH = -L. -L$(libdir)
DEFFILE =
CLEANFILES = mkmf.log
DISTCLEANFILES =
-DISTCLEANDIRS =
extout =
extout_prefix =
target_prefix =
LOCAL_LIBS =
-LIBS = -lpthread -ldl -lobjc
+LIBS = -ldl -lobjc
SRCS = vio.c
OBJS = vio.o
TARGET = vio
DLLIB = $(TARGET).bundle
EXTSTATIC =
STATIC_LIB =
BINDIR = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
-HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
-ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
TARGET_SO = $(DLLIB)
-CLEANLIBS = $(TARGET).bundle
-CLEANOBJS = *.o *.bak
-
-all: $(DLLIB)
-static: $(STATIC_LIB)
-.PHONY: all install static install-so install-rb
-.PHONY: clean clean-so clean-rb
-
-clean-rb-default::
-clean-rb::
-clean-so::
-clean: clean-so clean-rb-default clean-rb
+CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
+CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
+
+all: $(DLLIB)
+static: $(STATIC_LIB)
+
+clean:
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
-distclean-rb-default::
-distclean-rb::
-distclean-so::
-distclean: clean distclean-so distclean-rb-default distclean-rb
+distclean: clean
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
- @-$(RMDIRS) $(DISTCLEANDIRS)
-realclean: distclean
+realclean: distclean
install: install-so install-rb
install-so: $(RUBYARCHDIR)
install-so: $(RUBYARCHDIR)/$(DLLIB)
-$(RUBYARCHDIR)/$(DLLIB): $(RUBYARCHDIR) $(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
install-rb: pre-install-rb install-rb-default
install-rb-default: pre-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
$(RUBYARCHDIR):
$(MAKEDIRS) $@
site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
.cc.o:
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
.cxx.o:
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
.cpp.o:
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
.C.o:
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
.c.o:
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
-$(DLLIB): $(OBJS) Makefile
- @-$(RM) $(@)
+$(DLLIB): $(OBJS)
+ @-$(RM) $@
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
-$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
+$(OBJS): ruby.h defines.h
diff --git a/ext/vio/mkmf.log b/ext/vio/mkmf.log
index b9def1d..24e7aa7 100644
--- a/ext/vio/mkmf.log
+++ b/ext/vio/mkmf.log
@@ -1,63 +1,45 @@
-have_func: checking for rb_thread_blocking_region()... -------------------- yes
+have_func: checking for rb_thread_blocking_region()... -------------------- no
-"gcc -o conftest -I/opt/local/ruby19/include/ruby-1.9.1/i386-darwin9.7.0 -I/opt/local/ruby19/include/ruby-1.9.1/ruby/backward -I/opt/local/ruby19/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -pipe conftest.c -L. -L/opt/local/ruby19/lib -L. -L/usr/local/lib -lruby-static -lpthread -ldl -lobjc "
-/opt/local/ruby19/lib/ruby/1.9.1/mkmf.rb:300: warning: Insecure world writable dir /Users/lourens in PATH, mode 040753
+"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.5.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O2 -pipe -fno-common conftest.c -L. -L/opt/local/lib -L. -lruby-static -ldl -lobjc "
+/opt/local/lib/ruby/1.8/mkmf.rb:266: warning: Insecure world writable dir /Users/lourens in PATH, mode 040753
+conftest.c: In function âtâ:
+conftest.c:3: error: ârb_thread_blocking_regionâ undeclared (first use in this function)
+conftest.c:3: error: (Each undeclared identifier is reported only once
+conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
-1: #include "ruby.h"
-2:
-3: int main() {return 0;}
+1: /*top*/
+2: int main() { return 0; }
+3: int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return 0; }
/* end */
-"gcc -o conftest -I/opt/local/ruby19/include/ruby-1.9.1/i386-darwin9.7.0 -I/opt/local/ruby19/include/ruby-1.9.1/ruby/backward -I/opt/local/ruby19/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -pipe conftest.c -L. -L/opt/local/ruby19/lib -L. -L/usr/local/lib -lruby-static -lpthread -ldl -lobjc "
+"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.5.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O2 -pipe -fno-common conftest.c -L. -L/opt/local/lib -L. -lruby-static -ldl -lobjc "
+Undefined symbols:
+ "_rb_thread_blocking_region", referenced from:
+ _t in ccnCXhId.o
+ld: symbol(s) not found
+collect2: ld returned 1 exit status
checked program was:
/* begin */
-1: #include "ruby.h"
-2:
-3: /*top*/
-4: int main() {return 0;}
-5: int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return 0; }
+1: /*top*/
+2: int main() { return 0; }
+3: int t() { rb_thread_blocking_region(); return 0; }
/* end */
--------------------
-have_macro: checking for RUBY_UBF_IO in ruby.h... -------------------- yes
+have_var: checking for rb_trap_immediate in ruby.h,rubysig.h... -------------------- yes
-"gcc -I/opt/local/ruby19/include/ruby-1.9.1/i386-darwin9.7.0 -I/opt/local/ruby19/include/ruby-1.9.1/ruby/backward -I/opt/local/ruby19/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -pipe -c conftest.c"
+"gcc -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.5.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O2 -pipe -fno-common -c conftest.c"
checked program was:
/* begin */
-1: #include "ruby.h"
-2:
-3: #include <ruby.h>
+1: #include <ruby.h>
+2: #include <rubysig.h>
+3:
4: /*top*/
-5: #ifndef RUBY_UBF_IO
-6: # error
-7: >>>>>> RUBY_UBF_IO undefined <<<<<<
-8: #endif
-/* end */
-
---------------------
-
-have_var: checking for rb_trap_immediate in ruby.h,rubysig.h... -------------------- no
-
-"gcc -I/opt/local/ruby19/include/ruby-1.9.1/i386-darwin9.7.0 -I/opt/local/ruby19/include/ruby-1.9.1/ruby/backward -I/opt/local/ruby19/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -pipe -c conftest.c"
-In file included from conftest.c:4:
-/opt/local/ruby19/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
-conftest.c: In function âtâ:
-conftest.c:8: error: ârb_trap_immediateâ undeclared (first use in this function)
-conftest.c:8: error: (Each undeclared identifier is reported only once
-conftest.c:8: error: for each function it appears in.)
-checked program was:
-/* begin */
-1: #include "ruby.h"
-2:
-3: #include <ruby.h>
-4: #include <rubysig.h>
-5:
-6: /*top*/
-7: int main() {return 0;}
-8: int t() { const volatile void *volatile p; p = &(&rb_trap_immediate)[0]; return 0; }
+5: int main() { return 0; }
+6: int t() { const volatile void *volatile p; p = &(&rb_trap_immediate)[0]; return 0; }
/* end */
--------------------
diff --git a/ext/vio/vio.c b/ext/vio/vio.c
index a41baa5..584d5fa 100644
--- a/ext/vio/vio.c
+++ b/ext/vio/vio.c
@@ -1,42 +1,86 @@
#include "ruby.h"
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
#ifndef RSTRING_PTR
#define RSTRING_PTR(obj) RSTRING(obj)->ptr
#endif
#ifndef RSTRING_LEN
#define RSTRING_LEN(obj) RSTRING(obj)->len
#endif
#ifndef RARRAY_PTR
#define RARRAY_PTR(obj) RARRAY(obj)->ptr
#endif
#ifndef RARRAY_LEN
#define RARRAY_LEN(obj) RARRAY(obj)->len
#endif
#ifdef RUBY19
#include "ruby/io.h"
#define TRAP_BEG
#define TRAP_END
#else
#include "rubysig.h"
#include "rubyio.h"
#endif
static VALUE
vio_read(VALUE io, VALUE iov)
{
+ Check_Type(iov, T_ARRAY);
+ int fd;
+#ifdef RUBY19
+ rb_io_t *fptr;
+#else
+ OpenFile *fptr;
+#endif
+ if (RARRAY_LEN(iov) == 0) rb_raise(rb_eIOError, "No buffer offsets given");
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+#ifdef RUBY19
+ fd = fptr->fd;
+#else
+ fd = fileno(fptr->f);
+#endif
+ struct iovec iovs[IOV_MAX];
+ int i, size, bytes_read;
+ int expected = 0;
+ int cnt = RARRAY_LEN(iov);
+ VALUE results = rb_ary_new2(cnt);
+ for (i=0; i < cnt; i++) {
+ size = FIX2INT(RARRAY_PTR(iov)[i]);
+ expected = expected + size;
+ iovs[i].iov_len = size;
+ iovs[i].iov_base = malloc(size);
+ }
+ bytes_read = readv(fd,iovs,cnt);
+ if (bytes_read < expected) rb_raise(rb_eIOError, "Vectored I/O read failure!");
+ for (i=0; i < cnt; i++) {
+ rb_ary_push(results, rb_tainted_str_new((char *)iovs[i].iov_base, iovs[i].iov_len));
+ }
+ return results;
}
static VALUE
vio_write(VALUE io, VALUE iov)
{
+ Check_Type(iov, T_ARRAY);
+#ifdef RUBY19
+ rb_io_t *fptr;
+#else
+ OpenFile *fptr;
+#endif
+ GetOpenFile(io, fptr);
+ rb_io_check_writable(fptr);
+ return Qnil;
}
void Init_vio()
{
rb_define_method(rb_cIO, "readv", vio_read, 1);
rb_define_method(rb_cIO, "writev", vio_write, 1);
}
\ No newline at end of file
diff --git a/ext/vio/vio.o b/ext/vio/vio.o
index 4a14f4a..2f73eac 100644
Binary files a/ext/vio/vio.o and b/ext/vio/vio.o differ
diff --git a/test/fixtures/fix.txt b/test/fixtures/fix.txt
new file mode 100644
index 0000000..6536e4f
--- /dev/null
+++ b/test/fixtures/fix.txt
@@ -0,0 +1 @@
+8=FIX.4.49=4535=049=TW56=ISLD34=352=20000426-12:05:0610=220
\ No newline at end of file
diff --git a/test/fixtures/db.txt b/test/fixtures/writable.txt
similarity index 100%
rename from test/fixtures/db.txt
rename to test/fixtures/writable.txt
diff --git a/test/test_vio.rb b/test/test_vio.rb
index 154d3b4..1e71a51 100644
--- a/test/test_vio.rb
+++ b/test/test_vio.rb
@@ -1,13 +1,34 @@
$:.unshift "."
require File.dirname(__FILE__) + '/helper'
class TestVectoredIO < Test::Unit::TestCase
- def test_defines_readv_and_writev
- io = File.open(fixture('db.txt'))
- assert io.respond_to? :readv
- assert io.respond_to? :writev
+ def test_readv_arguments
+ io = File.open(fixture('fix.txt'))
+ assert_raises TypeError do
+ io.readv(nil)
+ end
+ assert_raises IOError do
+ io.readv []
+ end
+ io.readv [1]
io.close
end
+ def test_readv
+ io = File.open(fixture('fix.txt'))
+ expected = [ "8=FIX.4.4", "\x019=45", "\x0135=0", "\x0149=TW", "\x0156=ISLD",
+"\x0134=3\x0152=20000426-12:05:06", "\x0110=220" ]
+ assert_equal expected, io.readv([9, 5, 5, 6, 8, 26, 7])
+ io.close
+ end
+
+ def test_writev_arguments
+ io = File.open(fixture('writable.txt'), 'w')
+ assert_raises TypeError do
+ io.writev(nil)
+ end
+ io.writev []
+ io.close
+ end
end
\ No newline at end of file
|
methodmissing/vio
|
e5a1502627079275a7ae6b54033525c3080c6c22
|
gitignore
|
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d09f029
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+*.bundle
+Makefile
+mkmf.log
+.DS_Store
+*.o
+test/scratch/*.txt
\ No newline at end of file
|
methodmissing/vio
|
64d5d516384fff4607804756e8336c6fec0b5d71
|
Initial skeleton
|
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..1c2575f
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,69 @@
+#!/usr/bin/env rake
+require 'rake/testtask'
+require 'rake/clean'
+$:.unshift(File.expand_path('lib'))
+VIO_ROOT = 'ext/vio'
+
+desc 'Default: test'
+task :default => :test
+
+desc 'Run VIO tests.'
+Rake::TestTask.new(:test) do |t|
+ t.libs = [VIO_ROOT]
+ t.pattern = 'test/test_*.rb'
+ t.verbose = true
+end
+task :test => :build
+
+namespace :build do
+ file "#{VIO_ROOT}/vio.c"
+ file "#{VIO_ROOT}/extconf.rb"
+ file "#{VIO_ROOT}/Makefile" => %W(#{VIO_ROOT}/vio.c #{VIO_ROOT}/extconf.rb) do
+ Dir.chdir(VIO_ROOT) do
+ ruby 'extconf.rb'
+ end
+ end
+
+ desc "generate makefile"
+ task :makefile => %W(#{VIO_ROOT}/Makefile #{VIO_ROOT}/vio.c)
+
+ dlext = Config::CONFIG['DLEXT']
+ file "#{VIO_ROOT}/vio.#{dlext}" => %W(#{VIO_ROOT}/Makefile #{VIO_ROOT}/vio.c) do
+ Dir.chdir(VIO_ROOT) do
+ sh 'make' # TODO - is there a config for which make somewhere?
+ end
+ end
+
+ desc "compile vio extension"
+ task :compile => "#{VIO_ROOT}/vio.#{dlext}"
+
+ task :clean do
+ Dir.chdir(VIO_ROOT) do
+ sh 'make clean'
+ end if File.exists?("#{VIO_ROOT}/Makefile")
+ end
+
+ CLEAN.include("#{VIO_ROOT}/Makefile")
+ CLEAN.include("#{VIO_ROOT}/vio.#{dlext}")
+end
+
+task :clean => %w(build:clean)
+
+desc "compile"
+task :build => %w(build:compile)
+
+task :install do |t|
+ Dir.chdir(VIO_ROOT) do
+ sh 'sudo make install'
+ end
+end
+
+desc "clean build install"
+task :setup => %w(clean build install)
+
+desc "run benchmarks"
+task :bench do |t|
+ ruby "bench/read.rb"
+ ruby "bench/write.rb"
+end
+task :bench => :build
\ No newline at end of file
diff --git a/ext/vio/Makefile b/ext/vio/Makefile
new file mode 100644
index 0000000..7a7517f
--- /dev/null
+++ b/ext/vio/Makefile
@@ -0,0 +1,186 @@
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+topdir = /opt/local/ruby19/include/ruby-1.9.1
+hdrdir = /opt/local/ruby19/include/ruby-1.9.1
+arch_hdrdir = /opt/local/ruby19/include/ruby-1.9.1/$(arch)
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+prefix = $(DESTDIR)/opt/local/ruby19
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitedir = $(rubylibprefix)/site_ruby
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+archdir = $(rubylibdir)/$(arch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitearchdir = $(sitelibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_A)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
+OUTFLAG = -o
+COUTFLAG = -o
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3
+debugflags = -g
+warnflags = -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings
+CFLAGS = -fno-common $(cflags) -pipe
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DHAVE_RB_THREAD_BLOCKING_REGION -DRUBY19 -pedantic -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
+CXXFLAGS = $(CFLAGS) $(cxxflags)
+ldflags = -L. -L/usr/local/lib
+dldflags =
+archflag =
+DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
+LDSHARED = $(CC) -dynamic -bundle -undefined suppress -flat_namespace
+LDSHAREDXX = $(CXX) -dynamic -bundle -undefined suppress -flat_namespace
+AR = ar
+EXEEXT =
+
+RUBY_BASE_NAME = ruby
+RUBY_INSTALL_NAME = ruby
+RUBY_SO_NAME = ruby
+arch = i386-darwin9.7.0
+sitearch = $(arch)
+ruby_version = 1.9.1
+ruby = /opt/local/ruby19/bin/ruby
+RUBY = $(ruby)
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = $(RUBY) -run -e rmdir -- -p
+MAKEDIRS = mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(libdir)
+LIBPATH = -L. -L$(libdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout =
+extout_prefix =
+target_prefix =
+LOCAL_LIBS =
+LIBS = -lpthread -ldl -lobjc
+SRCS = vio.c
+OBJS = vio.o
+TARGET = vio
+DLLIB = $(TARGET).bundle
+EXTSTATIC =
+STATIC_LIB =
+
+BINDIR = $(bindir)
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR = $(sitelibdir)$(target_prefix)
+RUBYARCHDIR = $(sitearchdir)$(target_prefix)
+HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
+ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(DLLIB)
+CLEANLIBS = $(TARGET).bundle
+CLEANOBJS = *.o *.bak
+
+all: $(DLLIB)
+static: $(STATIC_LIB)
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-rb
+
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-rb-default clean-rb
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean: clean distclean-so distclean-rb-default distclean-rb
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ @-$(RMDIRS) $(DISTCLEANDIRS)
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(RUBYARCHDIR) $(DLLIB)
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+$(RUBYARCHDIR):
+ $(MAKEDIRS) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .cxx .cpp .C .o
+
+.cc.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.C.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.o:
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+$(DLLIB): $(OBJS) Makefile
+ @-$(RM) $(@)
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
+
+$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
diff --git a/ext/vio/extconf.rb b/ext/vio/extconf.rb
new file mode 100644
index 0000000..7b95e54
--- /dev/null
+++ b/ext/vio/extconf.rb
@@ -0,0 +1,13 @@
+require 'mkmf'
+
+def add_define(name)
+ $defs.push("-D#{name}")
+end
+
+dir_config('vio')
+add_define 'RUBY19' if have_func('rb_thread_blocking_region') and have_macro('RUBY_UBF_IO', 'ruby.h')
+add_define 'RUBY18' if have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h'])
+
+$defs.push("-pedantic")
+
+create_makefile('vio')
\ No newline at end of file
diff --git a/ext/vio/mkmf.log b/ext/vio/mkmf.log
new file mode 100644
index 0000000..b9def1d
--- /dev/null
+++ b/ext/vio/mkmf.log
@@ -0,0 +1,63 @@
+have_func: checking for rb_thread_blocking_region()... -------------------- yes
+
+"gcc -o conftest -I/opt/local/ruby19/include/ruby-1.9.1/i386-darwin9.7.0 -I/opt/local/ruby19/include/ruby-1.9.1/ruby/backward -I/opt/local/ruby19/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -pipe conftest.c -L. -L/opt/local/ruby19/lib -L. -L/usr/local/lib -lruby-static -lpthread -ldl -lobjc "
+/opt/local/ruby19/lib/ruby/1.9.1/mkmf.rb:300: warning: Insecure world writable dir /Users/lourens in PATH, mode 040753
+checked program was:
+/* begin */
+1: #include "ruby.h"
+2:
+3: int main() {return 0;}
+/* end */
+
+"gcc -o conftest -I/opt/local/ruby19/include/ruby-1.9.1/i386-darwin9.7.0 -I/opt/local/ruby19/include/ruby-1.9.1/ruby/backward -I/opt/local/ruby19/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -pipe conftest.c -L. -L/opt/local/ruby19/lib -L. -L/usr/local/lib -lruby-static -lpthread -ldl -lobjc "
+checked program was:
+/* begin */
+1: #include "ruby.h"
+2:
+3: /*top*/
+4: int main() {return 0;}
+5: int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return 0; }
+/* end */
+
+--------------------
+
+have_macro: checking for RUBY_UBF_IO in ruby.h... -------------------- yes
+
+"gcc -I/opt/local/ruby19/include/ruby-1.9.1/i386-darwin9.7.0 -I/opt/local/ruby19/include/ruby-1.9.1/ruby/backward -I/opt/local/ruby19/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -pipe -c conftest.c"
+checked program was:
+/* begin */
+1: #include "ruby.h"
+2:
+3: #include <ruby.h>
+4: /*top*/
+5: #ifndef RUBY_UBF_IO
+6: # error
+7: >>>>>> RUBY_UBF_IO undefined <<<<<<
+8: #endif
+/* end */
+
+--------------------
+
+have_var: checking for rb_trap_immediate in ruby.h,rubysig.h... -------------------- no
+
+"gcc -I/opt/local/ruby19/include/ruby-1.9.1/i386-darwin9.7.0 -I/opt/local/ruby19/include/ruby-1.9.1/ruby/backward -I/opt/local/ruby19/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -g -Wall -Wno-unused-parameter -Wno-parentheses -Wno-missing-field-initializers -Wshorten-64-to-32 -Wpointer-arith -Wwrite-strings -pipe -c conftest.c"
+In file included from conftest.c:4:
+/opt/local/ruby19/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
+conftest.c: In function âtâ:
+conftest.c:8: error: ârb_trap_immediateâ undeclared (first use in this function)
+conftest.c:8: error: (Each undeclared identifier is reported only once
+conftest.c:8: error: for each function it appears in.)
+checked program was:
+/* begin */
+1: #include "ruby.h"
+2:
+3: #include <ruby.h>
+4: #include <rubysig.h>
+5:
+6: /*top*/
+7: int main() {return 0;}
+8: int t() { const volatile void *volatile p; p = &(&rb_trap_immediate)[0]; return 0; }
+/* end */
+
+--------------------
+
diff --git a/ext/vio/vio.bundle b/ext/vio/vio.bundle
new file mode 100755
index 0000000..6fa0d59
Binary files /dev/null and b/ext/vio/vio.bundle differ
diff --git a/ext/vio/vio.c b/ext/vio/vio.c
new file mode 100644
index 0000000..a41baa5
--- /dev/null
+++ b/ext/vio/vio.c
@@ -0,0 +1,42 @@
+#include "ruby.h"
+
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(obj) RSTRING(obj)->ptr
+#endif
+
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(obj) RSTRING(obj)->len
+#endif
+
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(obj) RARRAY(obj)->ptr
+#endif
+
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(obj) RARRAY(obj)->len
+#endif
+
+#ifdef RUBY19
+ #include "ruby/io.h"
+ #define TRAP_BEG
+ #define TRAP_END
+#else
+ #include "rubysig.h"
+ #include "rubyio.h"
+#endif
+
+static VALUE
+vio_read(VALUE io, VALUE iov)
+{
+}
+
+static VALUE
+vio_write(VALUE io, VALUE iov)
+{
+}
+
+void Init_vio()
+{
+ rb_define_method(rb_cIO, "readv", vio_read, 1);
+ rb_define_method(rb_cIO, "writev", vio_write, 1);
+}
\ No newline at end of file
diff --git a/ext/vio/vio.o b/ext/vio/vio.o
new file mode 100644
index 0000000..4a14f4a
Binary files /dev/null and b/ext/vio/vio.o differ
diff --git a/test/fixtures/db.txt b/test/fixtures/db.txt
new file mode 100644
index 0000000..e69de29
diff --git a/test/helper.rb b/test/helper.rb
new file mode 100644
index 0000000..c6a05e2
--- /dev/null
+++ b/test/helper.rb
@@ -0,0 +1,13 @@
+require 'fileutils'
+require 'test/unit'
+require 'vio'
+
+FIXTURES = File.dirname(__FILE__) + "/fixtures"
+
+def fixtures(*files)
+ files.map{|f| File.join(FIXTURES,f) }
+end
+
+def fixture(file)
+ file =~ /\// ? file : fixtures(*file).first
+end
\ No newline at end of file
diff --git a/test/test_vio.rb b/test/test_vio.rb
new file mode 100644
index 0000000..154d3b4
--- /dev/null
+++ b/test/test_vio.rb
@@ -0,0 +1,13 @@
+$:.unshift "."
+require File.dirname(__FILE__) + '/helper'
+
+class TestVectoredIO < Test::Unit::TestCase
+
+ def test_defines_readv_and_writev
+ io = File.open(fixture('db.txt'))
+ assert io.respond_to? :readv
+ assert io.respond_to? :writev
+ io.close
+ end
+
+end
\ No newline at end of file
|
eschulte/blorgit_themes
|
da2bbdc1555472a515f9ea0a6ae9bf38d79de539
|
added worg style
|
diff --git a/worg/style.sass b/worg/style.sass
new file mode 100644
index 0000000..4bc00e6
--- /dev/null
+++ b/worg/style.sass
@@ -0,0 +1,95 @@
+// include the worg stylesheet
+@import worg.css
+
+#sidebar
+ :float right
+ :width 12em
+ :font-size 9pt
+ :color black
+ :background #FFF
+ :font-size 80%
+ :padding .5em
+ :margin 1em -2em 1em 1em
+ :float right
+ :display block
+ :max-width 50%
+ ul
+ :list-style none
+ :border 1px solid #CCC
+
+#titlebar
+ #title
+ float: left
+ #search
+ float: right
+ ul
+ list-style: none
+ #actions
+ float: right
+ ul
+ list-style: none
+ li
+ display: inline
+
+#title_separator
+ clear: both
+
+#comments
+ ul
+ list-style: none
+
+#comments
+ label
+ font-weight: bold
+
+#new_comment
+ label
+ display: block
+
+#content
+ :margin-right 12em
+
+// default org-mode styles
+.todo
+ :color red
+.done
+ :color green
+.tag
+ :background-color #add8e6
+ :font-weight normal
+.timestamp
+ :color #bebebe
+.timestamp-kwd
+ :color #5f9ea0
+p.verse
+ :margin-left 3%
+pre
+ :border 1pt solid #AEBDCC
+ :background-color #F3F5F7
+ :padding 5pt
+ :font-size 90%
+ :overflow auto
+table
+ :border-collapse collapse
+td, th
+ :vertical-align top
+dt
+ :font-weight bold
+div.figure
+ :padding .5em
+ p
+ :text-align center
+.linenr
+ :font-size smaller
+.code-highlighted
+ :background-color #ffff00
+.org-info-js_info-nagication
+ :border-style none
+#org-info-js_console-label
+ :font-size 10px
+ :font-weight bold
+ :white-space nowrap
+.org-info-js_search-highlight
+ :background-color #ffff00
+ :color #000000
+ :font-weight bold
diff --git a/worg/worg.css b/worg/worg.css
new file mode 100644
index 0000000..68d7af6
--- /dev/null
+++ b/worg/worg.css
@@ -0,0 +1,824 @@
+body {
+ margin: 10px 8% 10px 8%;
+ font-family: Verdana;
+ text-align: justify;
+ font-size: 10pt;
+ padding: 10px;
+ line-height: 1.2em;
+}
+
+#table-of-contents {
+ color: black;
+ background: #FFF;
+ font-size: 80%;
+ padding: .5em;
+ margin: 1em -2em 1em 1em;
+ float: right;
+ display: block;
+ border: 1px solid #CCC;
+ max-width: 50%;
+ overflow: auto;
+}
+
+#table-of-contents a {
+ color: #003333;
+}
+
+#table-of-contents a:hover {
+ color: #003333;
+ text-decoration: underline;
+}
+
+#table-of-contents li {
+ margin: .2em;
+}
+
+#table-of-contents h2 {
+ margin-top: .2em;
+ border: none;
+}
+
+h1 {
+ font-size: 12pt;
+}
+
+.title {
+ color: #990000;
+ padding-bottom: 7px;
+ margin-bottom: 20px;
+ border-bottom: 1px solid #222;
+}
+
+h2 {
+ font-size: 12pt;
+ padding-bottom: 4px;
+ margin-bottom: 5px;
+ border-bottom: 3px solid #DDD;
+}
+
+h3 {
+ font-size: 11pt;
+ color: #333333;
+}
+
+h4 {
+ font-size: 9pt;
+}
+
+a {
+ text-decoration: none;
+ color: #006666
+}
+
+a:visited {
+ text-decoration: none;
+ color: #336666
+}
+
+a:hover {
+ text-decoration: underline;
+ color: #003333
+}
+
+.todo {
+ color: #990000;
+}
+
+.done {
+ color: #006666;
+}
+
+.timestamp-kwd {
+ color: #444;
+}
+
+.tag {
+ color: #DDD;
+ font-size: 70%;
+ font-weight: 500;
+}
+
+li {
+ margin: .4em;
+}
+
+table {
+ border: none;
+}
+
+td {
+ border: none;
+ padding: .1em .7em .1em .3em;
+}
+
+th {
+ border: none;
+}
+
+code {
+ font-size: 100%;
+}
+
+img {
+ border: none;
+}
+
+.share img {
+ opacity: .4;
+ -moz-opacity: .4;
+ filter: alpha(opacity=40);
+}
+
+.share img:hover {
+ opacity: 1;
+ -moz-opacity: 1;
+ filter: alpha(opacity=100);
+}
+
+/* pre {border: 1px solid #555; */
+/* background: #EEE; */
+/* font-size: 9pt; */
+/* padding: 1em; */
+/* } */
+
+/* pre { */
+/* color: #e5e5e5; */
+/* background-color: #000000; */
+/* padding: 1.4em; */
+/* border: 2px solid grey; */
+/* } */
+
+pre {
+ color: black;
+ background-color: #eeeeee;
+ padding: 1.2em;
+ border: 1px solid #dddddd;
+}
+
+.builtin {
+ /* font-lock-builtin-face */
+ color: #f4a460;
+}
+.comment {
+ /* font-lock-comment-face */
+ color: #737373;
+}
+.comment-delimiter {
+ /* font-lock-comment-delimiter-face */
+ color: #666666;
+}
+.constant {
+ /* font-lock-constant-face */
+ color: #db7093;
+}
+.doc {
+ /* font-lock-doc-face */
+ color: #b3b3b3;
+}
+.function-name {
+ /* font-lock-function-name-face */
+ color: #5f9ea0;
+}
+.headline {
+ /* headline-face */
+ color: #ffffff;
+ background-color: #000000;
+ font-weight: bold;
+}
+.keyword {
+ /* font-lock-keyword-face */
+ color: #4682b4;
+}
+.negation-char {
+}
+.regexp-grouping-backslash {
+}
+.regexp-grouping-construct {
+}
+.string {
+ /* font-lock-string-face */
+ color: #fffacd;
+}
+.todo-comment {
+ /* todo-comment-face */
+ color: #ffffff;
+ background-color: #000000;
+ font-weight: bold;
+}
+.variable-name {
+ /* font-lock-variable-name-face */
+ color: #ff6a6a;
+}
+.warning {
+ /* font-lock-warning-face */
+ color: #ffffff;
+ background-color: #cd5c5c;
+ font-weight: bold;
+}
+pre.a {
+ color: inherit;
+ background-color: inherit;
+ font: inherit;
+ text-decoration: inherit;
+}
+pre.a:hover {
+ text-decoration: underline;
+}
+
+/* Styles for org-info.js */
+
+.org-info-js_info-navigation
+{
+ border-style:none;
+}
+
+#org-info-js_console-label
+{
+ font-size:10px;
+ font-weight:bold;
+ white-space:nowrap;
+}
+
+.org-info-js_search-highlight
+{
+ background-color:#ffff00;
+ color:#000000;
+ font-weight:bold;
+}
+
+#org-info-js-window
+{
+ border-bottom:1px solid black;
+ padding-bottom:10px;
+ margin-bottom:10px;
+}
+
+
+
+.org-info-search-highlight
+{
+ background-color:#adefef; /* same color as emacs default */
+ color:#000000;
+ font-weight:bold;
+}
+
+.org-bbdb-company {
+ /* bbdb-company */
+ font-style: italic;
+}
+.org-bbdb-field-name {
+}
+.org-bbdb-field-value {
+}
+.org-bbdb-name {
+ /* bbdb-name */
+ text-decoration: underline;
+}
+.org-bold {
+ /* bold */
+ font-weight: bold;
+}
+.org-bold-italic {
+ /* bold-italic */
+ font-weight: bold;
+ font-style: italic;
+}
+.org-border {
+ /* border */
+ background-color: #000000;
+}
+.org-buffer-menu-buffer {
+ /* buffer-menu-buffer */
+ font-weight: bold;
+}
+.org-builtin {
+ /* font-lock-builtin-face */
+ color: #da70d6;
+}
+.org-button {
+ /* button */
+ text-decoration: underline;
+}
+.org-c-nonbreakable-space {
+ /* c-nonbreakable-space-face */
+ background-color: #ff0000;
+ font-weight: bold;
+}
+.org-calendar-today {
+ /* calendar-today */
+ text-decoration: underline;
+}
+.org-comment {
+ /* font-lock-comment-face */
+ color: #b22222;
+}
+.org-comment-delimiter {
+ /* font-lock-comment-delimiter-face */
+ color: #b22222;
+}
+.org-constant {
+ /* font-lock-constant-face */
+ color: #5f9ea0;
+}
+.org-cursor {
+ /* cursor */
+ background-color: #000000;
+}
+.org-default {
+ /* default */
+ color: #000000;
+ background-color: #ffffff;
+}
+.org-diary {
+ /* diary */
+ color: #ff0000;
+}
+.org-doc {
+ /* font-lock-doc-face */
+ color: #bc8f8f;
+}
+.org-escape-glyph {
+ /* escape-glyph */
+ color: #a52a2a;
+}
+.org-file-name-shadow {
+ /* file-name-shadow */
+ color: #7f7f7f;
+}
+.org-fixed-pitch {
+}
+.org-fringe {
+ /* fringe */
+ background-color: #f2f2f2;
+}
+.org-function-name {
+ /* font-lock-function-name-face */
+ color: #0000ff;
+}
+.org-header-line {
+ /* header-line */
+ color: #333333;
+ background-color: #e5e5e5;
+}
+.org-help-argument-name {
+ /* help-argument-name */
+ font-style: italic;
+}
+.org-highlight {
+ /* highlight */
+ background-color: #b4eeb4;
+}
+.org-holiday {
+ /* holiday */
+ background-color: #ffc0cb;
+}
+.org-info-header-node {
+ /* info-header-node */
+ color: #a52a2a;
+ font-weight: bold;
+ font-style: italic;
+}
+.org-info-header-xref {
+ /* info-header-xref */
+ color: #0000ff;
+ text-decoration: underline;
+}
+.org-info-menu-header {
+ /* info-menu-header */
+ font-weight: bold;
+}
+.org-info-menu-star {
+ /* info-menu-star */
+ color: #ff0000;
+}
+.org-info-node {
+ /* info-node */
+ color: #a52a2a;
+ font-weight: bold;
+ font-style: italic;
+}
+.org-info-title-1 {
+ /* info-title-1 */
+ font-size: 172%;
+ font-weight: bold;
+}
+.org-info-title-2 {
+ /* info-title-2 */
+ font-size: 144%;
+ font-weight: bold;
+}
+.org-info-title-3 {
+ /* info-title-3 */
+ font-size: 120%;
+ font-weight: bold;
+}
+.org-info-title-4 {
+ /* info-title-4 */
+ font-weight: bold;
+}
+.org-info-xref {
+ /* info-xref */
+ color: #0000ff;
+ text-decoration: underline;
+}
+.org-isearch {
+ /* isearch */
+ color: #b0e2ff;
+ background-color: #cd00cd;
+}
+.org-italic {
+ /* italic */
+ font-style: italic;
+}
+.org-keyword {
+ /* font-lock-keyword-face */
+ color: #a020f0;
+}
+.org-lazy-highlight {
+ /* lazy-highlight */
+ background-color: #afeeee;
+}
+.org-link {
+ /* link */
+ color: #0000ff;
+ text-decoration: underline;
+}
+.org-link-visited {
+ /* link-visited */
+ color: #8b008b;
+ text-decoration: underline;
+}
+.org-match {
+ /* match */
+ background-color: #ffff00;
+}
+.org-menu {
+}
+.org-message-cited-text {
+ /* message-cited-text */
+ color: #ff0000;
+}
+.org-message-header-cc {
+ /* message-header-cc */
+ color: #191970;
+}
+.org-message-header-name {
+ /* message-header-name */
+ color: #6495ed;
+}
+.org-message-header-newsgroups {
+ /* message-header-newsgroups */
+ color: #00008b;
+ font-weight: bold;
+ font-style: italic;
+}
+.org-message-header-other {
+ /* message-header-other */
+ color: #4682b4;
+}
+.org-message-header-subject {
+ /* message-header-subject */
+ color: #000080;
+ font-weight: bold;
+}
+.org-message-header-to {
+ /* message-header-to */
+ color: #191970;
+ font-weight: bold;
+}
+.org-message-header-xheader {
+ /* message-header-xheader */
+ color: #0000ff;
+}
+.org-message-mml {
+ /* message-mml */
+ color: #228b22;
+}
+.org-message-separator {
+ /* message-separator */
+ color: #a52a2a;
+}
+.org-minibuffer-prompt {
+ /* minibuffer-prompt */
+ color: #0000cd;
+}
+.org-mm-uu-extract {
+ /* mm-uu-extract */
+ color: #006400;
+ background-color: #ffffe0;
+}
+.org-mode-line {
+ /* mode-line */
+ color: #000000;
+ background-color: #bfbfbf;
+}
+.org-mode-line-buffer-id {
+ /* mode-line-buffer-id */
+ font-weight: bold;
+}
+.org-mode-line-highlight {
+}
+.org-mode-line-inactive {
+ /* mode-line-inactive */
+ color: #333333;
+ background-color: #e5e5e5;
+}
+.org-mouse {
+ /* mouse */
+ background-color: #000000;
+}
+.org-negation-char {
+}
+.org-next-error {
+ /* next-error */
+ background-color: #eedc82;
+}
+.org-nobreak-space {
+ /* nobreak-space */
+ color: #a52a2a;
+ text-decoration: underline;
+}
+.org-org-agenda-date {
+ /* org-agenda-date */
+ color: #0000ff;
+}
+.org-org-agenda-date-weekend {
+ /* org-agenda-date-weekend */
+ color: #0000ff;
+ font-weight: bold;
+}
+.org-org-agenda-restriction-lock {
+ /* org-agenda-restriction-lock */
+ background-color: #ffff00;
+}
+.org-org-agenda-structure {
+ /* org-agenda-structure */
+ color: #0000ff;
+}
+.org-org-archived {
+ /* org-archived */
+ color: #7f7f7f;
+}
+.org-org-code {
+ /* org-code */
+ color: #7f7f7f;
+}
+.org-org-column {
+ /* org-column */
+ background-color: #e5e5e5;
+}
+.org-org-column-title {
+ /* org-column-title */
+ background-color: #e5e5e5;
+ font-weight: bold;
+ text-decoration: underline;
+}
+.org-org-date {
+ /* org-date */
+ color: #a020f0;
+ text-decoration: underline;
+}
+.org-org-done {
+ /* org-done */
+ color: #228b22;
+ font-weight: bold;
+}
+.org-org-drawer {
+ /* org-drawer */
+ color: #0000ff;
+}
+.org-org-ellipsis {
+ /* org-ellipsis */
+ color: #b8860b;
+ text-decoration: underline;
+}
+.org-org-formula {
+ /* org-formula */
+ color: #b22222;
+}
+.org-org-headline-done {
+ /* org-headline-done */
+ color: #bc8f8f;
+}
+.org-org-hide {
+ /* org-hide */
+ color: #e5e5e5;
+}
+.org-org-latex-and-export-specials {
+ /* org-latex-and-export-specials */
+ color: #8b4513;
+}
+.org-org-level-1 {
+ /* org-level-1 */
+ color: #0000ff;
+}
+.org-org-level-2 {
+ /* org-level-2 */
+ color: #b8860b;
+}
+.org-org-level-3 {
+ /* org-level-3 */
+ color: #a020f0;
+}
+.org-org-level-4 {
+ /* org-level-4 */
+ color: #b22222;
+}
+.org-org-level-5 {
+ /* org-level-5 */
+ color: #228b22;
+}
+.org-org-level-6 {
+ /* org-level-6 */
+ color: #5f9ea0;
+}
+.org-org-level-7 {
+ /* org-level-7 */
+ color: #da70d6;
+}
+.org-org-level-8 {
+ /* org-level-8 */
+ color: #bc8f8f;
+}
+.org-org-link {
+ /* org-link */
+ color: #a020f0;
+ text-decoration: underline;
+}
+.org-org-property-value {
+}
+.org-org-scheduled-previously {
+ /* org-scheduled-previously */
+ color: #b22222;
+}
+.org-org-scheduled-today {
+ /* org-scheduled-today */
+ color: #006400;
+}
+.org-org-sexp-date {
+ /* org-sexp-date */
+ color: #a020f0;
+}
+.org-org-special-keyword {
+ /* org-special-keyword */
+ color: #bc8f8f;
+}
+.org-org-table {
+ /* org-table */
+ color: #0000ff;
+}
+.org-org-tag {
+ /* org-tag */
+ font-weight: bold;
+}
+.org-org-target {
+ /* org-target */
+ text-decoration: underline;
+}
+.org-org-time-grid {
+ /* org-time-grid */
+ color: #b8860b;
+}
+.org-org-todo {
+ /* org-todo */
+ color: #ff0000;
+}
+.org-org-upcoming-deadline {
+ /* org-upcoming-deadline */
+ color: #b22222;
+}
+.org-org-verbatim {
+ /* org-verbatim */
+ color: #7f7f7f;
+ text-decoration: underline;
+}
+.org-org-warning {
+ /* org-warning */
+ color: #ff0000;
+ font-weight: bold;
+}
+.org-outline-1 {
+ /* outline-1 */
+ color: #0000ff;
+}
+.org-outline-2 {
+ /* outline-2 */
+ color: #b8860b;
+}
+.org-outline-3 {
+ /* outline-3 */
+ color: #a020f0;
+}
+.org-outline-4 {
+ /* outline-4 */
+ color: #b22222;
+}
+.org-outline-5 {
+ /* outline-5 */
+ color: #228b22;
+}
+.org-outline-6 {
+ /* outline-6 */
+ color: #5f9ea0;
+}
+.org-outline-7 {
+ /* outline-7 */
+ color: #da70d6;
+}
+.org-outline-8 {
+ /* outline-8 */
+ color: #bc8f8f;
+}
+.org-preprocessor {
+ /* font-lock-preprocessor-face */
+ color: #da70d6;
+}
+.org-query-replace {
+ /* query-replace */
+ color: #b0e2ff;
+ background-color: #cd00cd;
+}
+.org-regexp-grouping-backslash {
+ /* font-lock-regexp-grouping-backslash */
+ font-weight: bold;
+}
+.org-regexp-grouping-construct {
+ /* font-lock-regexp-grouping-construct */
+ font-weight: bold;
+}
+.org-region {
+ /* region */
+ background-color: #eedc82;
+}
+.org-rmail-highlight {
+}
+.org-scroll-bar {
+ /* scroll-bar */
+ background-color: #bfbfbf;
+}
+.org-secondary-selection {
+ /* secondary-selection */
+ background-color: #ffff00;
+}
+.org-shadow {
+ /* shadow */
+ color: #7f7f7f;
+}
+.org-show-paren-match {
+ /* show-paren-match */
+ background-color: #40e0d0;
+}
+.org-show-paren-mismatch {
+ /* show-paren-mismatch */
+ color: #ffffff;
+ background-color: #a020f0;
+}
+.org-string {
+ /* font-lock-string-face */
+ color: #bc8f8f;
+}
+.org-texinfo-heading {
+ /* texinfo-heading */
+ color: #0000ff;
+}
+.org-tool-bar {
+ /* tool-bar */
+ color: #000000;
+ background-color: #bfbfbf;
+}
+.org-tooltip {
+ /* tooltip */
+ color: #000000;
+ background-color: #ffffe0;
+}
+.org-trailing-whitespace {
+ /* trailing-whitespace */
+ background-color: #ff0000;
+}
+.org-type {
+ /* font-lock-type-face */
+ color: #228b22;
+}
+.org-underline {
+ /* underline */
+ text-decoration: underline;
+}
+.org-variable-name {
+ /* font-lock-variable-name-face */
+ color: #b8860b;
+}
+.org-variable-pitch {
+}
+.org-vertical-border {
+}
+.org-warning {
+ /* font-lock-warning-face */
+ color: #ff0000;
+ font-weight: bold;
+}
+.rss_box {}
+.rss_title, rss_title a {}
+.rss_items {}
+.rss_item a:link, .rss_item a:visited, .rss_item a:active {}
+.rss_item a:hover {}
+.rss_date {}
\ No newline at end of file
diff --git a/worg/worg.rake b/worg/worg.rake
new file mode 100644
index 0000000..f9bfc10
--- /dev/null
+++ b/worg/worg.rake
@@ -0,0 +1,12 @@
+require 'sass'
+
+$worg_dir = File.dirname(__FILE__)
+namespace :themes do
+ desc "a worg theme, same as default but plus the worg css"
+ task :worg do
+ File.open(File.join($blogs, $global_config[:config]['style']), 'w') do |file|
+ file.write(Sass::Engine.new(File.read(File.join(File.dirname(__FILE__), 'style.sass'))).render)
+ end
+ FileUtils.cp(File.join($worg_dir, 'worg.css'), $blogs)
+ end
+end
|
eschulte/blorgit_themes
|
ff8184f1626730f3fb0c3645edf0cd5f25c92466
|
requiring sass for all theme rake files
|
diff --git a/food/food.rake b/food/food.rake
index 187c9c9..7bc0c0b 100644
--- a/food/food.rake
+++ b/food/food.rake
@@ -1,10 +1,12 @@
+require 'sass'
+
$food_dir = File.dirname(__FILE__)
namespace :themes do
desc "a food theme for my recipes"
task :food do
File.open(File.join($blogs, $global_config[:config]['style']), 'w') do |file|
file.write(Sass::Engine.new(File.read(File.join(File.dirname(__FILE__), 'style.sass'))).render)
end
FileUtils.cp_r(File.join($food_dir, 'images'), $blogs)
end
end
diff --git a/org/org.rake b/org/org.rake
index 7a6c468..c31de28 100644
--- a/org/org.rake
+++ b/org/org.rake
@@ -1,10 +1,12 @@
+require 'sass'
+
$dir = File.dirname(__FILE__)
namespace :themes do
desc "an org-mode theme featuring the folding unicorn"
task :org do
File.open(File.join($blogs, $global_config[:config]['style']), 'w') do |file|
file.write(Sass::Engine.new(File.read(File.join(File.dirname(__FILE__), 'style.sass'))).render)
end
FileUtils.cp_r(File.join($dir, 'images'), $blogs)
end
end
|
eschulte/blorgit_themes
|
377a8dd30046dd6ee35e5e126a23c386e8a5d073
|
added default org-mode style to each theme
|
diff --git a/default/style.sass b/default/style.sass
index 0893e11..9b402fa 100644
--- a/default/style.sass
+++ b/default/style.sass
@@ -1,35 +1,80 @@
#sidebar
float: right
width: 12em
font-size: 9pt
ul
list-style: none
#titlebar
#title
float: left
#search
float: right
ul
list-style: none
#actions
float: right
ul
list-style: none
li
display: inline
#title_separator
clear: both
#comments
ul
list-style: none
#comments
label
font-weight: bold
#new_comment
label
display: block
+
+// default org-mode styles
+.todo
+ :color red
+.done
+ :color green
+.tag
+ :background-color #add8e6
+ :font-weight normal
+.timestamp
+ :color #bebebe
+.timestamp-kwd
+ :color #5f9ea0
+p.verse
+ :margin-left 3%
+pre
+ :border 1pt solid #AEBDCC
+ :background-color #F3F5F7
+ :padding 5pt
+ :font-size 90%
+ :overflow auto
+table
+ :border-collapse collapse
+td, th
+ :vertical-align top
+dt
+ :font-weight bold
+div.figure
+ :padding .5em
+ p
+ :text-align center
+.linenr
+ :font-size smaller
+.code-highlighted
+ :background-color #ffff00
+.org-info-js_info-nagication
+ :border-style none
+#org-info-js_console-label
+ :font-size 10px
+ :font-weight bold
+ :white-space nowrap
+.org-info-js_search-highlight
+ :background-color #ffff00
+ :color #000000
+ :font-weight bold
diff --git a/food/style.sass b/food/style.sass
index fe536e6..9691d41 100644
--- a/food/style.sass
+++ b/food/style.sass
@@ -1,123 +1,168 @@
body
background: #6d6d6d
#titlebar
#title_pre
background: url(/images/patton-extension-small-double.png) repeat-x 0px 0px transparent
margin: 0px
width: 98%
height: 182px
position: absolute
z-index: 0
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
#title
background: url(/images/patton-small.png) no-repeat
margin: 0px
position: absolute
width: 451px
height: 182px
z-index: 0
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
a
color: white
position: absolute
padding-top: 24px
padding-left: 98px
width: 182px
height: 158px
font-size: 36px
text-decoration: none
&:hover
text-decoration: underline
#search
position: absolute
right: 4%
z-index: 1
ul
list-style: none
#actions
position: absolute
right: 4%
top: 136px
z-index: 1
ul
list-style: none
li
display: inline
padding-left: .5em
padding-right: .5em
padding-top: .25em
padding-bottom: .25em
margin: .25em
background: #6d6d6d
border: 1px solid black
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
&:hover
background: white
a
color: #6d6d6d
a
color: white
text-decoration: none
#title_separator
clear: both
#insides
position: absolute
top: 200px
width: 98%
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
background: white
#sidebar
float: right
width: 12em
font-size: 9pt
margin: .5em
label
font-weight: bold
div
border: 2px solid #6d6d6d
padding: .5em
margin-top: 1em
background: #c9db8a
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
ul
list-style: circle
li
&:hover
list-style: disc
a
color: black
text-decoration: none
-# &:hover
-# background: #8daf13
#contents
padding: .5em
#comments
list-style: none
#comments ul
list-style: none
#comments label
font-weight: bold
#new_comment
label
display: block
&:hover
text-decoration: underline
+
+// default org-mode styles
+.todo
+ :color red
+.done
+ :color green
+.tag
+ :background-color #add8e6
+ :font-weight normal
+.timestamp
+ :color #bebebe
+.timestamp-kwd
+ :color #5f9ea0
+p.verse
+ :margin-left 3%
+pre
+ :border 1pt solid #AEBDCC
+ :background-color #F3F5F7
+ :padding 5pt
+ :font-size 90%
+ :overflow auto
+table
+ :border-collapse collapse
+td, th
+ :vertical-align top
+dt
+ :font-weight bold
+div.figure
+ :padding .5em
+ p
+ :text-align center
+.linenr
+ :font-size smaller
+.code-highlighted
+ :background-color #ffff00
+.org-info-js_info-nagication
+ :border-style none
+#org-info-js_console-label
+ :font-size 10px
+ :font-weight bold
+ :white-space nowrap
+.org-info-js_search-highlight
+ :background-color #ffff00
+ :color #000000
+ :font-weight bold
diff --git a/org/style.sass b/org/style.sass
index 62b92a0..2392dff 100644
--- a/org/style.sass
+++ b/org/style.sass
@@ -1,116 +1,161 @@
#titlebar
background: url(/images/folded-extension.png) repeat-x 0px 0px transparent
width: 98%
border-radius: 18px
border: 2px solid #6d6d6d
-moz-border-radius: 18px
-webkit-border-radius: 18px
clear: both
#title_pre
// thanks to Tim Burt for the folded unicorn
background: url(/images/folded-unicorn.png) no-repeat
float: left
width: 158px
height: 150px
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
font-size: 0px
#title
a
float: left
padding: 1em
text-decoration: none
font-size: 2em
color: white
&:hover
text-decoration: underline
#search
margin: .5em
float: right
ul
list-style: none
#actions
float: right
ul
list-style: none
li
display: inline
padding-left: .5em
padding-right: .5em
padding-top: .25em
padding-bottom: .25em
margin: .25em
background: #6d6d6d
border: 1px solid black
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
&:hover
background: white
a
color: #6d6d6d
a
color: white
text-decoration: none
#title_separator
clear: both
#insides
width: 98%
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
background: white
#outline-container-1
clear: left
#sidebar
float: right
width: 12em
font-size: 9pt
margin: .5em
label
font-weight: bold
div
border: 2px solid #6d6d6d
padding: .5em
margin-top: 1em
background: #1e0601
color: white
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
ul
list-style: circle
li
color: white
&:hover
list-style: disc
a
color: white
text-decoration: none
#contents
padding: .5em
#comments
list-style: none
#comments ul
list-style: none
#comments label
font-weight: bold
#new_comment
label
display: block
&:hover
text-decoration: underline
#creation_form
label
display: block
+
+// default org-mode styles
+.todo
+ :color red
+.done
+ :color green
+.tag
+ :background-color #add8e6
+ :font-weight normal
+.timestamp
+ :color #bebebe
+.timestamp-kwd
+ :color #5f9ea0
+p.verse
+ :margin-left 3%
+pre
+ :border 1pt solid #AEBDCC
+ :background-color #F3F5F7
+ :padding 5pt
+ :font-size 90%
+ :overflow auto
+table
+ :border-collapse collapse
+td, th
+ :vertical-align top
+dt
+ :font-weight bold
+div.figure
+ :padding .5em
+ p
+ :text-align center
+.linenr
+ :font-size smaller
+.code-highlighted
+ :background-color #ffff00
+.org-info-js_info-nagication
+ :border-style none
+#org-info-js_console-label
+ :font-size 10px
+ :font-weight bold
+ :white-space nowrap
+.org-info-js_search-highlight
+ :background-color #ffff00
+ :color #000000
+ :font-weight bold
|
eschulte/blorgit_themes
|
1887e0d8a3c3985c9c91e359e61a03bf62a12aec
|
CSS deployment no longer relies on the sass executable
|
diff --git a/default/default.rake b/default/default.rake
index c42d65c..2f96a80 100644
--- a/default/default.rake
+++ b/default/default.rake
@@ -1,6 +1,10 @@
+require 'sass'
+
namespace :themes do
desc "a default theme, should serve as a good starting point"
task :default do
- %x{sass #{File.join(File.dirname(__FILE__), 'style.sass')} #{File.join($blogs, $global_config[:config]['style'])}}
+ File.open(File.join($blogs, $global_config[:config]['style']), 'w') do |file|
+ file.write(Sass::Engine.new(File.read(File.join(File.dirname(__FILE__), 'style.sass'))).render)
+ end
end
end
diff --git a/food/food.rake b/food/food.rake
index daec32e..187c9c9 100644
--- a/food/food.rake
+++ b/food/food.rake
@@ -1,8 +1,10 @@
$food_dir = File.dirname(__FILE__)
namespace :themes do
desc "a food theme for my recipes"
task :food do
- %x{sass #{File.join($food_dir, 'style.sass')} #{File.join($blogs, $global_config[:config]['style'])}}
+ File.open(File.join($blogs, $global_config[:config]['style']), 'w') do |file|
+ file.write(Sass::Engine.new(File.read(File.join(File.dirname(__FILE__), 'style.sass'))).render)
+ end
FileUtils.cp_r(File.join($food_dir, 'images'), $blogs)
end
end
diff --git a/org/org.rake b/org/org.rake
index 6bad6a5..7a6c468 100644
--- a/org/org.rake
+++ b/org/org.rake
@@ -1,8 +1,10 @@
$dir = File.dirname(__FILE__)
namespace :themes do
desc "an org-mode theme featuring the folding unicorn"
task :org do
- %x{sass #{File.join($dir, 'style.sass')} #{File.join($blogs, $global_config[:config]['style'])}}
+ File.open(File.join($blogs, $global_config[:config]['style']), 'w') do |file|
+ file.write(Sass::Engine.new(File.read(File.join(File.dirname(__FILE__), 'style.sass'))).render)
+ end
FileUtils.cp_r(File.join($dir, 'images'), $blogs)
end
end
|
eschulte/blorgit_themes
|
9e24daf7e3de8b8839cef17e966604307f08838a
|
added unicorn favicon to org-mode theme
|
diff --git a/org/images/favicon.ico b/org/images/favicon.ico
new file mode 100644
index 0000000..43103cc
Binary files /dev/null and b/org/images/favicon.ico differ
|
eschulte/blorgit_themes
|
b9cec00c7b0fd74fc650efe8c1a5e6faf8ce0861
|
removed weird table css from org theme
|
diff --git a/org/style.sass b/org/style.sass
index 5f2cc8d..62b92a0 100644
--- a/org/style.sass
+++ b/org/style.sass
@@ -1,145 +1,116 @@
#titlebar
background: url(/images/folded-extension.png) repeat-x 0px 0px transparent
width: 98%
border-radius: 18px
border: 2px solid #6d6d6d
-moz-border-radius: 18px
-webkit-border-radius: 18px
clear: both
#title_pre
// thanks to Tim Burt for the folded unicorn
background: url(/images/folded-unicorn.png) no-repeat
float: left
width: 158px
height: 150px
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
font-size: 0px
#title
a
float: left
padding: 1em
text-decoration: none
font-size: 2em
color: white
&:hover
text-decoration: underline
#search
margin: .5em
float: right
ul
list-style: none
#actions
float: right
ul
list-style: none
li
display: inline
padding-left: .5em
padding-right: .5em
padding-top: .25em
padding-bottom: .25em
margin: .25em
background: #6d6d6d
border: 1px solid black
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
&:hover
background: white
a
color: #6d6d6d
a
color: white
text-decoration: none
#title_separator
clear: both
#insides
width: 98%
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
background: white
-#table-of-contents
- overflow: hidden
- padding: .5em
- border-radius: 8px
- -moz-border-radius: 8px
- -webkit-border-radius: 8px
- h2
- margin: 0
- ul
- list-style: none
- li
- background: #1e0601
- border-radius: 8px
- -moz-border-radius: 8px
- -webkit-border-radius: 8px
- margin: .25em
- padding: .5em
- float: left
- a
- color: white
- text-decoration: none
- &:hover
- text-decoration: underline
- ul
- li
- float: none
- margin: 0
- padding: 0
-
#outline-container-1
clear: left
#sidebar
float: right
width: 12em
font-size: 9pt
margin: .5em
label
font-weight: bold
div
border: 2px solid #6d6d6d
padding: .5em
margin-top: 1em
background: #1e0601
color: white
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
ul
list-style: circle
li
color: white
&:hover
list-style: disc
a
color: white
text-decoration: none
#contents
padding: .5em
#comments
list-style: none
#comments ul
list-style: none
#comments label
font-weight: bold
#new_comment
label
display: block
&:hover
text-decoration: underline
#creation_form
label
display: block
|
eschulte/blorgit_themes
|
26fdfd8dd5cf8b2e4288b2edb32744403f5570f0
|
switching to nutmeg favicon
|
diff --git a/food/images/favicon.ico b/food/images/favicon.ico
index e6b241d..9095a41 100644
Binary files a/food/images/favicon.ico and b/food/images/favicon.ico differ
|
eschulte/blorgit_themes
|
4218a34bf7b03557f3c4d0b4c2017fce5ff86c4a
|
added favicon for foods theme
|
diff --git a/food/images/favicon.ico b/food/images/favicon.ico
new file mode 100644
index 0000000..e6b241d
Binary files /dev/null and b/food/images/favicon.ico differ
|
eschulte/blorgit_themes
|
2fb394a106b5791bb7b73c11c365d0f58c2271c2
|
tweak to org style (body doesn't block on sidebar)
|
diff --git a/org/style.sass b/org/style.sass
index c1e8ea5..5f2cc8d 100644
--- a/org/style.sass
+++ b/org/style.sass
@@ -1,145 +1,145 @@
#titlebar
background: url(/images/folded-extension.png) repeat-x 0px 0px transparent
width: 98%
border-radius: 18px
border: 2px solid #6d6d6d
-moz-border-radius: 18px
-webkit-border-radius: 18px
clear: both
#title_pre
// thanks to Tim Burt for the folded unicorn
background: url(/images/folded-unicorn.png) no-repeat
float: left
width: 158px
height: 150px
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
font-size: 0px
#title
a
float: left
padding: 1em
text-decoration: none
font-size: 2em
color: white
&:hover
text-decoration: underline
#search
margin: .5em
float: right
ul
list-style: none
#actions
float: right
ul
list-style: none
li
display: inline
padding-left: .5em
padding-right: .5em
padding-top: .25em
padding-bottom: .25em
margin: .25em
background: #6d6d6d
border: 1px solid black
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
&:hover
background: white
a
color: #6d6d6d
a
color: white
text-decoration: none
#title_separator
clear: both
#insides
width: 98%
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
background: white
#table-of-contents
overflow: hidden
padding: .5em
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
h2
margin: 0
ul
list-style: none
li
background: #1e0601
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
margin: .25em
padding: .5em
float: left
a
color: white
text-decoration: none
&:hover
text-decoration: underline
ul
li
float: none
margin: 0
padding: 0
#outline-container-1
- clear: both
+ clear: left
#sidebar
float: right
width: 12em
font-size: 9pt
margin: .5em
label
font-weight: bold
div
border: 2px solid #6d6d6d
padding: .5em
margin-top: 1em
background: #1e0601
color: white
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
ul
list-style: circle
li
color: white
&:hover
list-style: disc
a
color: white
text-decoration: none
#contents
padding: .5em
#comments
list-style: none
#comments ul
list-style: none
#comments label
font-weight: bold
#new_comment
label
display: block
&:hover
text-decoration: underline
#creation_form
label
display: block
|
eschulte/blorgit_themes
|
4ee486b87cea0a19469ec87655fe73018476208e
|
adding TOC style to org theme
|
diff --git a/org/style.sass b/org/style.sass
index 35497cb..c1e8ea5 100644
--- a/org/style.sass
+++ b/org/style.sass
@@ -1,113 +1,145 @@
#titlebar
background: url(/images/folded-extension.png) repeat-x 0px 0px transparent
width: 98%
border-radius: 18px
border: 2px solid #6d6d6d
-moz-border-radius: 18px
-webkit-border-radius: 18px
clear: both
#title_pre
// thanks to Tim Burt for the folded unicorn
background: url(/images/folded-unicorn.png) no-repeat
float: left
width: 158px
height: 150px
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
font-size: 0px
#title
a
float: left
padding: 1em
text-decoration: none
font-size: 2em
color: white
&:hover
text-decoration: underline
#search
margin: .5em
float: right
ul
list-style: none
#actions
float: right
ul
list-style: none
li
display: inline
padding-left: .5em
padding-right: .5em
padding-top: .25em
padding-bottom: .25em
margin: .25em
background: #6d6d6d
border: 1px solid black
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
&:hover
background: white
a
color: #6d6d6d
a
color: white
text-decoration: none
#title_separator
clear: both
#insides
width: 98%
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
background: white
+#table-of-contents
+ overflow: hidden
+ padding: .5em
+ border-radius: 8px
+ -moz-border-radius: 8px
+ -webkit-border-radius: 8px
+ h2
+ margin: 0
+ ul
+ list-style: none
+ li
+ background: #1e0601
+ border-radius: 8px
+ -moz-border-radius: 8px
+ -webkit-border-radius: 8px
+ margin: .25em
+ padding: .5em
+ float: left
+ a
+ color: white
+ text-decoration: none
+ &:hover
+ text-decoration: underline
+ ul
+ li
+ float: none
+ margin: 0
+ padding: 0
+
+#outline-container-1
+ clear: both
+
#sidebar
float: right
width: 12em
font-size: 9pt
margin: .5em
label
font-weight: bold
div
border: 2px solid #6d6d6d
padding: .5em
margin-top: 1em
background: #1e0601
color: white
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
ul
list-style: circle
li
color: white
&:hover
list-style: disc
a
color: white
text-decoration: none
#contents
padding: .5em
#comments
list-style: none
#comments ul
list-style: none
#comments label
font-weight: bold
#new_comment
label
display: block
&:hover
text-decoration: underline
#creation_form
label
display: block
|
eschulte/blorgit_themes
|
0be391d3f15d46750134deb118aa5b5a34b7d225
|
added border to titlebar on org theme
|
diff --git a/org/style.sass b/org/style.sass
index 66fc732..35497cb 100644
--- a/org/style.sass
+++ b/org/style.sass
@@ -1,112 +1,113 @@
#titlebar
background: url(/images/folded-extension.png) repeat-x 0px 0px transparent
width: 98%
border-radius: 18px
+ border: 2px solid #6d6d6d
-moz-border-radius: 18px
-webkit-border-radius: 18px
clear: both
#title_pre
// thanks to Tim Burt for the folded unicorn
background: url(/images/folded-unicorn.png) no-repeat
float: left
width: 158px
height: 150px
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
font-size: 0px
#title
a
float: left
padding: 1em
text-decoration: none
font-size: 2em
color: white
&:hover
text-decoration: underline
#search
margin: .5em
float: right
ul
list-style: none
#actions
float: right
ul
list-style: none
li
display: inline
padding-left: .5em
padding-right: .5em
padding-top: .25em
padding-bottom: .25em
margin: .25em
background: #6d6d6d
border: 1px solid black
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
&:hover
background: white
a
color: #6d6d6d
a
color: white
text-decoration: none
#title_separator
clear: both
#insides
width: 98%
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
background: white
#sidebar
float: right
width: 12em
font-size: 9pt
margin: .5em
label
font-weight: bold
div
border: 2px solid #6d6d6d
padding: .5em
margin-top: 1em
background: #1e0601
color: white
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
ul
list-style: circle
li
color: white
&:hover
list-style: disc
a
color: white
text-decoration: none
#contents
padding: .5em
#comments
list-style: none
#comments ul
list-style: none
#comments label
font-weight: bold
#new_comment
label
display: block
&:hover
text-decoration: underline
#creation_form
label
display: block
|
eschulte/blorgit_themes
|
334708531f028db23a84178e0fbf5ebdda3bf752
|
now showing title in org-mode theme
|
diff --git a/org/style.sass b/org/style.sass
index 7bfaa91..66fc732 100644
--- a/org/style.sass
+++ b/org/style.sass
@@ -1,105 +1,112 @@
#titlebar
background: url(/images/folded-extension.png) repeat-x 0px 0px transparent
width: 98%
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
clear: both
+ #title_pre
+ // thanks to Tim Burt for the folded unicorn
+ background: url(/images/folded-unicorn.png) no-repeat
+ float: left
+ width: 158px
+ height: 150px
+ border-radius: 18px
+ -moz-border-radius: 18px
+ -webkit-border-radius: 18px
+ font-size: 0px
#title
a
- // thanks to Tim Burt for the folded unicorn
- background: url(/images/folded-unicorn.png) no-repeat
- margin: .5em
float: left
- width: 158px
- height: 150px
- border-radius: 18px
- -moz-border-radius: 18px
- -webkit-border-radius: 18px
- font-size: 0px
+ padding: 1em
+ text-decoration: none
+ font-size: 2em
+ color: white
+ &:hover
+ text-decoration: underline
#search
margin: .5em
float: right
ul
list-style: none
#actions
float: right
ul
list-style: none
li
display: inline
padding-left: .5em
padding-right: .5em
padding-top: .25em
padding-bottom: .25em
margin: .25em
background: #6d6d6d
border: 1px solid black
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
&:hover
background: white
a
color: #6d6d6d
a
color: white
text-decoration: none
#title_separator
clear: both
#insides
width: 98%
border-radius: 18px
-moz-border-radius: 18px
-webkit-border-radius: 18px
background: white
#sidebar
float: right
width: 12em
font-size: 9pt
margin: .5em
label
font-weight: bold
div
border: 2px solid #6d6d6d
padding: .5em
margin-top: 1em
background: #1e0601
color: white
border-radius: 8px
-moz-border-radius: 8px
-webkit-border-radius: 8px
ul
list-style: circle
li
color: white
&:hover
list-style: disc
a
color: white
text-decoration: none
#contents
padding: .5em
#comments
list-style: none
#comments ul
list-style: none
#comments label
font-weight: bold
#new_comment
label
display: block
&:hover
text-decoration: underline
#creation_form
label
display: block
|
eschulte/blorgit_themes
|
20b6c4b529407185fc71e8d873f7baf2a8f75f36
|
adding folded-unicorn org-mode theme
|
diff --git a/org/images/folded-unicorn.png b/org/images/folded-unicorn.png
new file mode 100644
index 0000000..1d2553c
Binary files /dev/null and b/org/images/folded-unicorn.png differ
diff --git a/org/org.rake b/org/org.rake
new file mode 100644
index 0000000..7b5ac90
--- /dev/null
+++ b/org/org.rake
@@ -0,0 +1,8 @@
+$dir = File.dirname(__FILE__)
+namespace :themes do
+ desc "an org-mode theme featuring the folding unicorn"
+ task :org do
+ %x{sass #{File.join($dir, 'style.sass')} #{File.join($blogs, $config['style'])}}
+ FileUtils.cp_r(File.join($dir, 'images'), $blogs)
+ end
+end
diff --git a/org/style.sass b/org/style.sass
new file mode 100644
index 0000000..69e2691
--- /dev/null
+++ b/org/style.sass
@@ -0,0 +1,101 @@
+#titlebar
+ background: #1e0601
+ border-radius: 18px
+ width: 98%
+ -moz-border-radius: 18px
+ -webkit-border-radius: 18px
+ clear: both
+ #title
+ a
+ // thanks to Tim Burt for the folded unicorn
+ background: url(/images/folded-unicorn.png) no-repeat
+ margin: .5em
+ float: left
+ width: 158px
+ height: 150px
+ border-radius: 18px
+ -moz-border-radius: 18px
+ -webkit-border-radius: 18px
+ font-size: 0px
+ #search
+ margin: .5em
+ float: right
+ ul
+ list-style: none
+ #actions
+ float: right
+ ul
+ list-style: none
+ li
+ display: inline
+ padding-left: .5em
+ padding-right: .5em
+ padding-top: .25em
+ padding-bottom: .25em
+ margin: .25em
+ background: #6d6d6d
+ border: 1px solid black
+ border-radius: 8px
+ -moz-border-radius: 8px
+ -webkit-border-radius: 8px
+ &:hover
+ background: white
+ a
+ color: #6d6d6d
+ a
+ color: white
+ text-decoration: none
+
+#title_separator
+ clear: both
+
+#insides
+ width: 98%
+ border-radius: 18px
+ -moz-border-radius: 18px
+ -webkit-border-radius: 18px
+ background: white
+
+#sidebar
+ float: right
+ width: 12em
+ font-size: 9pt
+ margin: .5em
+ label
+ font-weight: bold
+ div
+ border: 2px solid #6d6d6d
+ padding: .5em
+ margin-top: 1em
+ background: #1e0601
+ color: white
+ border-radius: 8px
+ -moz-border-radius: 8px
+ -webkit-border-radius: 8px
+ ul
+ list-style: circle
+ li
+ color: white
+ &:hover
+ list-style: disc
+ a
+ color: white
+ text-decoration: none
+
+#contents
+ padding: .5em
+
+#comments
+ list-style: none
+
+#comments ul
+ list-style: none
+
+#comments label
+ font-weight: bold
+
+#new_comment
+ label
+ display: block
+ &:hover
+ text-decoration: underline
|
eschulte/blorgit_themes
|
38cd180567fee752ac291a5737b413b2b7f87df9
|
adding food theme
|
diff --git a/food/food.rake b/food/food.rake
new file mode 100644
index 0000000..880ae7b
--- /dev/null
+++ b/food/food.rake
@@ -0,0 +1,8 @@
+$food_dir = File.dirname(__FILE__)
+namespace :themes do
+ desc "a food theme for my recipes"
+ task :food do
+ %x{sass #{File.join($food_dir, 'style.sass')} #{File.join($blogs, $config['style'])}}
+ FileUtils.cp_r(File.join($food_dir, 'images'), $blogs)
+ end
+end
diff --git a/food/images/patton-extension-small-double.png b/food/images/patton-extension-small-double.png
new file mode 100644
index 0000000..d87af02
Binary files /dev/null and b/food/images/patton-extension-small-double.png differ
diff --git a/food/images/patton-small.png b/food/images/patton-small.png
new file mode 100644
index 0000000..aa64c0f
Binary files /dev/null and b/food/images/patton-small.png differ
diff --git a/food/style.sass b/food/style.sass
new file mode 100644
index 0000000..fe536e6
--- /dev/null
+++ b/food/style.sass
@@ -0,0 +1,123 @@
+body
+ background: #6d6d6d
+
+#titlebar
+ #title_pre
+ background: url(/images/patton-extension-small-double.png) repeat-x 0px 0px transparent
+ margin: 0px
+ width: 98%
+ height: 182px
+ position: absolute
+ z-index: 0
+ border-radius: 18px
+ -moz-border-radius: 18px
+ -webkit-border-radius: 18px
+ #title
+ background: url(/images/patton-small.png) no-repeat
+ margin: 0px
+ position: absolute
+ width: 451px
+ height: 182px
+ z-index: 0
+ border-radius: 18px
+ -moz-border-radius: 18px
+ -webkit-border-radius: 18px
+ a
+ color: white
+ position: absolute
+ padding-top: 24px
+ padding-left: 98px
+ width: 182px
+ height: 158px
+ font-size: 36px
+ text-decoration: none
+ &:hover
+ text-decoration: underline
+ #search
+ position: absolute
+ right: 4%
+ z-index: 1
+ ul
+ list-style: none
+ #actions
+ position: absolute
+ right: 4%
+ top: 136px
+ z-index: 1
+ ul
+ list-style: none
+ li
+ display: inline
+ padding-left: .5em
+ padding-right: .5em
+ padding-top: .25em
+ padding-bottom: .25em
+ margin: .25em
+ background: #6d6d6d
+ border: 1px solid black
+ border-radius: 8px
+ -moz-border-radius: 8px
+ -webkit-border-radius: 8px
+ &:hover
+ background: white
+ a
+ color: #6d6d6d
+ a
+ color: white
+ text-decoration: none
+
+#title_separator
+ clear: both
+
+#insides
+ position: absolute
+ top: 200px
+ width: 98%
+ border-radius: 18px
+ -moz-border-radius: 18px
+ -webkit-border-radius: 18px
+ background: white
+
+#sidebar
+ float: right
+ width: 12em
+ font-size: 9pt
+ margin: .5em
+ label
+ font-weight: bold
+ div
+ border: 2px solid #6d6d6d
+ padding: .5em
+ margin-top: 1em
+ background: #c9db8a
+ border-radius: 8px
+ -moz-border-radius: 8px
+ -webkit-border-radius: 8px
+ ul
+ list-style: circle
+ li
+ &:hover
+ list-style: disc
+ a
+ color: black
+ text-decoration: none
+ -# &:hover
+ -# background: #8daf13
+
+#contents
+ padding: .5em
+
+#comments
+ list-style: none
+
+#comments ul
+ list-style: none
+
+#comments label
+ font-weight: bold
+
+#new_comment
+ label
+ display: block
+ &:hover
+ text-decoration: underline
|
eschulte/blorgit_themes
|
591162b286821dd6594d224d325a8995b2588af3
|
adding default theme
|
diff --git a/default/default.rake b/default/default.rake
new file mode 100644
index 0000000..085a1c7
--- /dev/null
+++ b/default/default.rake
@@ -0,0 +1,6 @@
+namespace :themes do
+ desc "a default theme, should serve as a good starting point"
+ task :default do
+ %x{sass #{File.join(File.dirname(__FILE__), 'style.sass')} #{File.join($blogs, $config['style'])}}
+ end
+end
diff --git a/default/style.sass b/default/style.sass
index 1d877c6..0893e11 100644
--- a/default/style.sass
+++ b/default/style.sass
@@ -1,28 +1,35 @@
#sidebar
float: right
width: 12em
font-size: 9pt
-
-#sidebar ul
- list-style: none
-
-#titlebar a
- float: left
+ ul
+ list-style: none
+
+#titlebar
+ #title
+ float: left
+ #search
+ float: right
+ ul
+ list-style: none
+ #actions
+ float: right
+ ul
+ list-style: none
+ li
+ display: inline
#title_separator
clear: both
-#titlebar #user
- float: right
-
#comments
- list-style: none
-
-#comments ul
- list-style: none
+ ul
+ list-style: none
-#comments label
- font-weight: bold
+#comments
+ label
+ font-weight: bold
-#new_comment label
- display: block
+#new_comment
+ label
+ display: block
|
eschulte/blorgit_themes
|
766fb643e3153eb78bb311e55039adad5264f5c9
|
added README
|
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..be51fa1
--- /dev/null
+++ b/README.markdown
@@ -0,0 +1 @@
+themes for [blorgit](http://github.com/eschulte/blorgit/tree/master)
|
mahu/pilse
|
315f50123563ef25dad013d9e299fe014c753277
|
fileparser
|
diff --git a/Raytracer1108/include/scene.hpp b/Raytracer1108/include/scene.hpp
new file mode 100644
index 0000000..94a58b2
--- /dev/null
+++ b/Raytracer1108/include/scene.hpp
@@ -0,0 +1,36 @@
+#ifndef __SCENE_PARSER__
+#define __SCENE_PARSER__
+
+#include "shape.hpp"
+#include "sphere.hpp"
+#include "box.hpp"
+#include "material.hpp"
+#include "camera.hpp"
+#include "light.hpp"
+
+
+#include<list>
+#include<string>
+#include<fstream>
+#include<sstream>
+
+class scene
+
+{
+ public:
+ scene(std::string const&);
+
+
+ public:
+ std::list<shape*> objects;
+ std::list<light> lights;
+ std::list<material> mats;
+ std::list<camera> cam;
+
+
+
+
+
+};
+
+#endif
diff --git a/Raytracer1108/src/scene.cpp b/Raytracer1108/src/scene.cpp
new file mode 100644
index 0000000..2735109
--- /dev/null
+++ b/Raytracer1108/src/scene.cpp
@@ -0,0 +1,184 @@
+#include "scene.hpp"
+#include<iostream>
+
+
+scene::scene(std::string const& s)
+
+{
+ std::ifstream infile;
+ std::string str;
+
+ infile.open(s.c_str(),std::ifstream::in);
+
+ while(infile.good())
+ {
+ std::getline(infile,str);
+ std::stringstream sstr(str);
+ std::string k;
+ double d;
+ sstr>>k;
+
+ if(k[0]=='#')
+ {std::cout<<"\nKommentar\n"<<std::endl;}
+ else{
+ if(k== "define")
+ {
+ sstr>>k;
+ if(k=="shape")
+ {
+ sstr>>k;
+ if(k=="box")
+ {
+ sstr>>k;
+ std::string bname =k;
+
+ math3d::point p1, p2;
+ material a;
+
+ sstr>>d;
+ p1[math3d::point::x]=d;
+ sstr>>d;
+ p1[math3d::point::y]=d;
+ sstr>>d;
+ p1[math3d::point::z]=d;
+
+ sstr>>d;
+ p2[math3d::point::x]=d;
+ sstr>>d;
+ p2[math3d::point::y]=d;
+ sstr>>d;
+ p2[math3d::point::z]=d;
+
+ sstr>>k;
+ std::string mat_name=k;
+
+ for(std::list<material>::iterator i=mats.begin();i!=mats.end();++i)
+ {
+ if((*i).name_ == k)
+ {
+ a=(*i);
+ }
+ }
+
+ shape *b = new box(p1,p2,bname,a);
+ objects.push_back(b);
+ }
+
+ else if(k=="sphere")
+ {
+ sstr>>k;
+ std::string sname=k;
+ math3d::point center;
+ material a;
+
+ sstr>>d;
+ center[math3d::point::x]=d;
+ sstr>>d;
+ center[math3d::point::y]=d;
+ sstr>>d;
+ center[math3d::point::z]=d;
+
+ sstr>>d;
+ double radius=d;
+
+ sstr>>k;
+ std::string mat_name=k;
+
+ for(std::list<material>::iterator i=mats.begin();i!=mats.end();++i)
+ {
+ if((*i).name_ == k)
+ {
+ a=(*i);
+ }
+ }
+
+ shape *s = new sphere(center,radius,sname,a);
+ objects.push_back(s);
+ }
+ }
+ else if(k=="light")
+ {
+ sstr>>k;
+ std::string lname=k;
+ math3d::point pos;
+
+ sstr>>d;
+ pos[math3d::point::x]=d;
+ sstr>>d;
+ pos[math3d::point::y]=d;
+ sstr>>d;
+ pos[math3d::point::z]=d;
+
+ rgb la, ld;
+
+ sstr>>d;
+ la[rgb::r]=d;
+ sstr>>d;
+ la[rgb::g]=d;
+ sstr>>d;
+ la[rgb::b]=d;
+
+
+ sstr>>d;
+ ld[rgb::r]=d;
+ sstr>>d;
+ ld[rgb::g]=d;
+ sstr>>d;
+ ld[rgb::b]=d;
+
+
+ light *s = new light(pos,lname,la,ld);
+
+ lights.push_back(*s);
+
+
+ }
+ }
+
+ else if(k=="camera")
+ {
+ sstr>>k;
+ std::string cname=k;
+
+ sstr>>d;
+ double fx=d;
+ sstr>>d;
+ double fy=d;
+
+ camera *c = new camera(cname,fx,fy);
+ cam.push_back(*c);
+ }
+
+ else if(k=="render")
+ {
+ sstr>>k;
+ std::string camname=k;
+ camera c;
+ for(std::list<camera>::iterator i=cam.begin();i!=cam.end();++i)
+ {
+ if((*i).name_==k)
+ {
+ c=(*i);
+ }
+ }
+ sstr>>k;
+ std::string filename=k;
+
+ sstr>>d;
+ int x_res=d;
+ sstr>>d;
+ int y_res=d;
+ }
+
+ }
+
+ }
+
+
+
+}
+
+
+
+
+
|
mahu/pilse
|
12e6342064e735d38c8ba665ccbd732d1e43c272
|
raytrac klasse
|
diff --git a/Raytracer1108/include/rtapplication.hpp b/Raytracer1108/include/rtapplication.hpp
new file mode 100644
index 0000000..2fc6797
--- /dev/null
+++ b/Raytracer1108/include/rtapplication.hpp
@@ -0,0 +1,39 @@
+#ifndef __RTAPPLICATION_HPP__
+#define __RTAPPLICATION_HPP__
+
+#include "light.hpp"
+#include "shape.hpp"
+#include "material.hpp"
+#include "camera.hpp"
+
+#include "glutwindow.hpp"
+#include "ppmwriter.hpp"
+#include "pixel.hpp"
+#include "vector.hpp"
+#include "rgb.hpp"
+
+#include <iostream>
+#include <cmath>
+#include <list>
+
+
+class rtApplication
+{
+ public :
+
+ rtApplication();
+ rtApplication(std::list<shape*> const&, camera const&, std::list<light> const&);
+ ~rtApplication();
+ void raytrace() const;
+
+ //private :
+
+ std::list<shape*> shapeList_;
+ camera cam_;
+ std::list<light> lightList_;
+};
+
+
+
+#endif /* __RTAPPLICATION_HPP__ */
+
diff --git a/Raytracer1108/src/rtapplication.cpp b/Raytracer1108/src/rtapplication.cpp
new file mode 100644
index 0000000..61ade63
--- /dev/null
+++ b/Raytracer1108/src/rtapplication.cpp
@@ -0,0 +1,74 @@
+#include "rtapplication.hpp"
+
+rtApplication::rtApplication() {}
+
+rtApplication::rtApplication(std::list<shape*> const& sl, camera const& cam, std::list<light> const& ll) :
+ shapeList_ (sl) ,
+ cam_(cam) ,
+ lightList_(ll) {}
+
+rtApplication::~rtApplication() {}
+
+void rtApplication::raytrace() const
+{
+ // get glutwindow instance
+ glutwindow& gw = glutwindow::instance();
+
+ // create a ppmwriter
+ ppmwriter pw(gw.width(), gw.height(), "./checkerboard.ppm");
+
+ // for all pixels of window
+ double height (gw.height());
+ double width (gw.width());
+ double z = height * 0.5 / std::tan(cam_.fovX_ * M_PI / 360);
+
+ for (int y = -int( height / 2); y < int((height+1) / 2); ++y)
+ {
+ for (int x = -int( width / 2); x < int((width+1) / 2); ++x)
+ {
+ // create pixel at x,y
+ pixel p(x, y);
+
+ // compute color for pixel
+ ray r(math3d::vector(0,0,0,0), math3d::vector(x, y, z));
+
+ double closestT = ~0;
+ shape* closestObj = 0;
+
+ for ( std::list<shape*>::const_iterator i = shapeList_.begin(); i != shapeList_.end(); ++i)
+ {
+ double newT = (**i).intersection(r);
+
+ if (newT < closestT)
+ {
+ closestT = newT;
+ closestObj = *i;
+ }
+
+ if (closestObj != 0)
+ p.color = closestObj->getMaterial().reflexionAmbient_;
+ else
+ p.color = rgb(0.3,0.3,0.8);
+ }
+
+ // write pixel to output window
+ gw.write(p);
+
+ // write pixel to image writer
+ pw.write(p);
+ }
+ }
+
+ // save final image
+ pw.save();
+}
+
+
+
+
+
+
+
+
+
+
|
mahu/pilse
|
910aa4bcdd20037899e8e4754aa2250aaba1feda
|
Stand 11.08, n bissl aufgeräumt
|
diff --git a/Raytracer1108/include/box.hpp b/Raytracer1108/include/box.hpp
new file mode 100644
index 0000000..4b9d249
--- /dev/null
+++ b/Raytracer1108/include/box.hpp
@@ -0,0 +1,42 @@
+#ifndef _BOX_HPP
+#define _BOX_HPP
+
+#include "shape.hpp"
+#include "matrix.hpp"
+#include "vector.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+#include "ray.hpp"
+#include "material.hpp"
+
+
+#include <cmath>
+
+
+class box : public shape
+{
+ public:
+ box();
+ box( math3d::point const&, math3d::point const&, std::string const&, material const&,
+ math3d::matrix const& matr = math3d::matrix::identity(),
+ math3d::matrix const& matrInv = math3d::matrix::identity() );
+ box(box const&);
+ ~box();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(math3d::point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn(std::ostream&) const;
+ /*virtual*/ box* clone() const;
+ double intersection(ray const&) const;
+
+
+
+ private:
+ math3d::point vertexLuh_;
+ math3d::point vertexRov_;
+};
+
+
+
+#endif /* _BOX_HPP */
diff --git a/Raytracer1108/include/camera.hpp b/Raytracer1108/include/camera.hpp
new file mode 100644
index 0000000..5194add
--- /dev/null
+++ b/Raytracer1108/include/camera.hpp
@@ -0,0 +1,37 @@
+#ifndef __CAMERA_HPP__
+#define __CAMERA_HPP__
+
+
+#include "matrix.hpp"
+#include "transform.hpp"
+#include "vector.hpp"
+
+
+#include <string>
+
+class camera
+{
+
+ public:
+
+ camera();
+ camera(std::string const&, double, double,
+ math3d::matrix const& matr = math3d::matrix::identity(),
+ math3d::matrix const& matrInv = math3d::matrix::identity() );
+ void translate(math3d::vector const&);
+ void scale(math3d::vector const&);
+ void rotate(math3d::vector const&, double);
+
+
+ private:
+
+ std::string name_;
+ double fovX_;
+ double fovY_;
+
+ math3d::matrix worldMatrix_;
+ math3d::matrix worldMatrixInvers_;
+};
+
+
+#endif /* __camera_HPP__ */
diff --git a/Raytracer1108/include/glutwindow.hpp b/Raytracer1108/include/glutwindow.hpp
new file mode 100644
index 0000000..f3b70e7
--- /dev/null
+++ b/Raytracer1108/include/glutwindow.hpp
@@ -0,0 +1,65 @@
+#ifndef BUW_GLUT_WINDOW_HPP
+#define BUW_GLUT_WINDOW_HPP
+
+// header, system
+#include <vector>
+#include <string>
+
+// header, project
+#include <rgb.hpp>
+#include <pixel.hpp>
+
+
+
+class glutwindow {
+public : // typedefs, enums
+ typedef std::vector<rgb> colorbuffer_t;
+
+ ~glutwindow();
+
+private : // do not copy glutwindow
+
+ glutwindow(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[]);
+
+ glutwindow(glutwindow const&);
+
+ glutwindow& operator=(glutwindow const&);
+
+public : // methods
+
+ static void init(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[]);
+ static glutwindow& instance();
+
+ void write(const pixel& p);
+ void update();
+ void run();
+
+ std::size_t width() const;
+ std::size_t height() const;
+ float const& buffer() const;
+
+private: // member
+
+ colorbuffer_t buffer_;
+
+ std::size_t width_;
+ std::size_t height_;
+
+ std::size_t posx_;
+ std::size_t posy_;
+
+ std::string name_;
+};
+
+// external glut callbacks
+void display();
+void reshape(int, int);
+void idle();
+
+#endif // BUW_GLUT_WINDOW_HPP
\ No newline at end of file
diff --git a/Raytracer1108/include/light.hpp b/Raytracer1108/include/light.hpp
new file mode 100644
index 0000000..a709080
--- /dev/null
+++ b/Raytracer1108/include/light.hpp
@@ -0,0 +1,28 @@
+#ifndef __LIGHT_HPP__
+#define __LIGHT_HPP__
+
+#include "vector.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+
+#include <iostream>
+#include <string>
+#include <cmath>
+
+struct light
+{
+ light();
+ light(math3d::point, std::string, rgb, rgb);
+
+
+ // Membervariablen
+
+ math3d::point location_;
+ std::string name_;
+ rgb lightAmbient_;
+ rgb lightDiffuse_;
+};
+
+
+#endif /* __light_HPP__ */
+
diff --git a/Raytracer1108/include/material.hpp b/Raytracer1108/include/material.hpp
new file mode 100644
index 0000000..f9a2820
--- /dev/null
+++ b/Raytracer1108/include/material.hpp
@@ -0,0 +1,31 @@
+#ifndef __MATERIAL_HPP__
+#define __MATERIAL_HPP__
+
+#include "vector.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+
+#include <iostream>
+#include <cmath>
+#include <string>
+
+struct material
+{
+
+ //Konstruktoren
+
+ material();
+ material(std::string, rgb, rgb, rgb, double);
+
+
+ //Membervariablen
+
+ std::string name_;
+ rgb reflexionAmbient_;
+ rgb reflexionDiffuse_;
+ rgb reflexionSpecular_;
+ double expReflexionSpecular_;
+};
+
+
+#endif /* __material_HPP__ */
diff --git a/Raytracer1108/include/matrix.hpp b/Raytracer1108/include/matrix.hpp
new file mode 100644
index 0000000..5a46c69
--- /dev/null
+++ b/Raytracer1108/include/matrix.hpp
@@ -0,0 +1,113 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : matrix.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_MATRIX_HPP)
+
+#define BUW_MATH3D_MATRIX_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+#include <vector.hpp>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point;
+
+ class matrix {
+
+ public:
+
+ enum cols { c0 = vector::x, c1 = vector::y, c2 = vector::z, c3 = vector::w };
+ enum rows { r0 = vector::x, r1 = vector::y, r2 = vector::z, r3 = vector::w };
+
+ // column major element ordering
+ enum component { aa = 0, ba = 4, ca = 8, da = 12,
+ ab = 1, bb = 5, cb = 9, db = 13,
+ ac = 2, bc = 6, cc = 10, dc = 14,
+ ad = 3, bd = 7, cd = 11, dd = 15 };
+
+ matrix();
+ matrix(matrix const&);
+ matrix(double const [16]);
+
+ ~matrix();
+
+ void swap(matrix&);
+
+ matrix& operator=(matrix const&);
+
+ double const& operator()(cols, rows) const;
+ double& operator()(cols, rows);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ matrix& operator*=(matrix const&);
+ matrix& operator*=(double);
+ matrix& operator/=(double);
+
+ double trace() const;
+
+ // to implement
+ double determinant() const;
+
+ bool invert();
+
+ bool is_invertible() const; // det(M) != 0
+
+ static matrix const& null(); // m[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
+ static matrix const& identity(); // m[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
+
+ private:
+
+ double data_[16];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ matrix operator-(matrix const&);
+
+ matrix operator*(matrix const&, matrix const&);
+ matrix operator*(matrix const&, double);
+ matrix operator*(double, matrix const&);
+ matrix operator/(matrix const&, double);
+
+ point operator*(matrix const&, point const&);
+ vector operator*(matrix const&, vector const&);
+
+ bool operator==(matrix const&, matrix const&);
+
+ matrix make_rotation_x(double);
+
+ double determinant(matrix const&);
+ double trace(matrix const&);
+ matrix inverse(matrix const&);
+ matrix transpose(matrix const&);
+
+ bool is_invertible(matrix const&);
+
+ std::ostream& operator<<(std::ostream&, matrix const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_MATRIX_HPP)
diff --git a/Raytracer1108/include/pixel.hpp b/Raytracer1108/include/pixel.hpp
new file mode 100644
index 0000000..171e414
--- /dev/null
+++ b/Raytracer1108/include/pixel.hpp
@@ -0,0 +1,30 @@
+#ifndef BUW_PIXEL_HPP
+#define BUW_PIXEL_HPP
+
+// header, system
+#include <iosfwd>
+
+// header, project
+#include <rgb.hpp>
+
+
+class pixel {
+public : // c'tor
+
+ pixel(std::size_t = 0, std::size_t = 0);
+ ~pixel();
+
+public : // methods
+
+ void print(std::ostream&) const;
+
+public : // member
+
+ std::size_t x;
+ std::size_t y;
+ rgb color;
+};
+
+std::ostream& operator<<(std::ostream&, const pixel&);
+
+#endif // BUW_PIXEL_HPP
diff --git a/Raytracer1108/include/point.hpp b/Raytracer1108/include/point.hpp
new file mode 100644
index 0000000..70c874a
--- /dev/null
+++ b/Raytracer1108/include/point.hpp
@@ -0,0 +1,75 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : point.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_POINT_HPP)
+
+#define BUW_MATH3D_POINT_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+#include <vector.hpp>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point {
+
+ public:
+
+ enum component { x = vector::x, y = vector::y, z = vector::z, w = vector::w };
+
+ point();
+ point(point const&);
+ point(double, double, double, double = 1.0); // x, y, z, w
+
+ ~point();
+
+ void swap(point&);
+
+ point& operator=(point const&);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ point& operator+=(vector const&);
+ point& operator-=(vector const&);
+
+ static point const& origin(); // p[0,0,0,1]
+
+ private:
+
+ double data_[4];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ point operator-(point const&);
+
+ point operator+(point const&, vector const&);
+ point operator-(point const&, vector const&);
+ bool operator==(point const&, point const&);
+
+ std::ostream& operator<<(std::ostream&, point const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_POINT_HPP)
diff --git a/Raytracer1108/include/ppmwriter.hpp b/Raytracer1108/include/ppmwriter.hpp
new file mode 100644
index 0000000..bc5aef2
--- /dev/null
+++ b/Raytracer1108/include/ppmwriter.hpp
@@ -0,0 +1,31 @@
+#ifndef BUW_PPMWRITER_HPP
+#define BUW_PPMWRITER_HPP
+
+// header, system
+#include <string>
+#include <vector>
+
+// header, project
+#include <pixel.hpp>
+
+
+class ppmwriter
+{
+public:
+ ppmwriter(std::size_t w, std::size_t h, std::string const& file);
+ ppmwriter(std::size_t w, std::size_t h);
+ ~ppmwriter();
+
+public:
+ void write(pixel const& p);
+ void save(std::string const& file);
+ void save();
+
+private:
+ std::string file_;
+ std::vector<unsigned int> data_;
+ size_t width_;
+ size_t height_;
+};
+
+#endif // BUW_PPMWRITER
diff --git a/Raytracer1108/include/ray.hpp b/Raytracer1108/include/ray.hpp
new file mode 100644
index 0000000..126552a
--- /dev/null
+++ b/Raytracer1108/include/ray.hpp
@@ -0,0 +1,26 @@
+#ifndef __RAY_HPP__
+#define __RAY_HPP__
+
+#include "vector.hpp"
+
+#include <iostream>
+#include <cmath>
+
+struct ray
+{
+
+ //Konstruktoren
+
+ ray();
+ ray(math3d::vector a, math3d::vector b);
+
+
+ //Membervariablen
+
+ math3d::vector origin_;
+ math3d::vector direction_;
+};
+
+
+#endif /* __RAY_HPP__ */
+
diff --git a/Raytracer1108/include/rgb.hpp b/Raytracer1108/include/rgb.hpp
new file mode 100644
index 0000000..af91357
--- /dev/null
+++ b/Raytracer1108/include/rgb.hpp
@@ -0,0 +1,38 @@
+#ifndef BUW_RGB_HPP
+#define BUW_RGB_HPP
+
+// header, system
+#include <iosfwd>
+
+
+class rgb {
+public : // enums, typedefs
+ enum component {r, g, b};
+ typedef float value_t;
+
+public : // c'tor
+ rgb();
+ rgb(rgb const&);
+ rgb(value_t r, value_t g, value_t b);
+
+ ~rgb();
+
+public : // methods
+ void swap(rgb&);
+ void print(std::ostream& os) const;
+
+ value_t& operator[](enum component);
+ const value_t& operator[](enum component) const;
+
+ rgb& operator= (const rgb&);
+ void operator+=(const rgb&);
+
+
+private: // members
+ value_t data_[3]; // rgb
+};
+
+rgb operator+(const rgb& a, const rgb& b);
+std::ostream& operator<<(std::ostream& os, rgb const&);
+
+#endif // BUW_RGB_HPP
diff --git a/Raytracer1108/include/shape.hpp b/Raytracer1108/include/shape.hpp
new file mode 100644
index 0000000..73bd910
--- /dev/null
+++ b/Raytracer1108/include/shape.hpp
@@ -0,0 +1,56 @@
+#ifndef _SHAPE_HPP
+#define _SHAPE_HPP
+
+#include "rgb.hpp"
+#include "point.hpp"
+#include "ray.hpp"
+#include "material.hpp"
+#include "matrix.hpp"
+#include "transform.hpp"
+
+#include <iostream>
+#include <string>
+
+class shape
+{
+ public:
+ shape();
+ shape(std::string const&, material const&,
+ math3d::matrix const& matr, // = math3d::matrix::identity(),
+ math3d::matrix const& matrInv ); // = math3d::matrix::identity() );
+ shape(shape const&);
+ virtual ~shape();
+
+ virtual double volume() const =0;
+ virtual bool isInside(math3d::point const&) const =0;
+ virtual double surface() const =0;
+ virtual shape* clone() const =0;
+ virtual double intersection(ray const&) const =0;
+ std::string getName() const;
+ material getMaterial() const;
+ virtual void printOn(std::ostream& = std::cout) const;
+ int ref();
+ int unRef();
+
+ void translate(math3d::vector const&);
+ void scale(math3d::vector const&);
+ void rotate(math3d::vector const&, double);
+
+
+ private:
+
+ std::string name_;
+ int refCount_;
+ material material_;
+ math3d::matrix worldMatrix_;
+ math3d::matrix worldMatrixInvers_;
+
+};
+
+std::ostream& operator<<(std::ostream&, shape const&);
+bool operator==(shape const& lhs, shape const& rhs);
+
+
+
+#endif /* _shape_HPP */
+
diff --git a/Raytracer1108/include/sphere.hpp b/Raytracer1108/include/sphere.hpp
new file mode 100644
index 0000000..28a1c3b
--- /dev/null
+++ b/Raytracer1108/include/sphere.hpp
@@ -0,0 +1,41 @@
+#ifndef _SPHERE_HPP
+#define _SPHERE_HPP
+
+#include "shape.hpp"
+#include "vector.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+#include "ray.hpp"
+#include "matrix.hpp"
+#include "material.hpp"
+
+#include <cmath>
+
+class sphere : public shape
+{
+ public:
+ sphere();
+ sphere(math3d::point const&, double, std::string const&, material const&,
+ math3d::matrix const& matr = math3d::matrix::identity(),
+ math3d::matrix const& matrInv = math3d::matrix::identity() );
+ sphere(sphere const&);
+ ~sphere();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(math3d::point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn( std::ostream&) const;
+ /*virtual*/ sphere* clone() const;
+ /*virtual*/ double intersection(ray const&) const;
+
+
+ private:
+ math3d::point center_;
+ double radius_;
+
+};
+
+
+
+#endif /* _sphere_HPP */
+
diff --git a/Raytracer1108/include/transform.hpp b/Raytracer1108/include/transform.hpp
new file mode 100644
index 0000000..6034bf2
--- /dev/null
+++ b/Raytracer1108/include/transform.hpp
@@ -0,0 +1,18 @@
+#ifndef __TRANSFORM_HPP__
+#define __TRANSFORM_HPP__
+
+#include "vector.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+#include "matrix.hpp"
+
+
+#include <cmath>
+#include <string>
+
+math3d::matrix translationmatrix(math3d::vector const&);
+math3d::matrix rotationmatrix(math3d::vector const&, double);
+math3d::matrix scalingmatrix(math3d::vector const&);
+
+
+#endif /* __transform_HPP__ */
diff --git a/Raytracer1108/include/transform.hpp~ b/Raytracer1108/include/transform.hpp~
new file mode 100644
index 0000000..1e4a355
--- /dev/null
+++ b/Raytracer1108/include/transform.hpp~
@@ -0,0 +1,18 @@
+#ifndef __TRANSFORM_HPP__
+#define __TRANSFORM_HPP__
+
+#include "vector.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+#include "matrix.hpp"
+
+#include <iostream>
+#include <cmath>
+#include <string>
+
+math3d::matrix translationmatrix(math3d::vector const&);
+math3d::matrix rotationmatrix(math3d::vector const&, double);
+math3d::matrix scalingmatrix(math3d::vector const&);
+
+
+#endif /* __transform_HPP__ */
diff --git a/Raytracer1108/include/vector.hpp b/Raytracer1108/include/vector.hpp
new file mode 100644
index 0000000..bcd985c
--- /dev/null
+++ b/Raytracer1108/include/vector.hpp
@@ -0,0 +1,100 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : vector.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_VECTOR_HPP)
+
+#define BUW_MATH3D_VECTOR_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+//#include <>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point;
+
+ class vector {
+
+ public:
+
+ enum component { x = 0, y = 1, z = 2, w = 3 };
+
+ vector();
+ vector(vector const&);
+ vector(point const&, point const&); // second - first
+ vector(double, double, double, double = 0.0); // x, y, z, w
+
+ ~vector();
+
+ void swap(vector&);
+
+ vector& operator=(vector const&);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ vector& operator+=(vector const&);
+ vector& operator-=(vector const&);
+ vector& operator*=(double);
+ vector& operator/=(double);
+
+
+ double length() const;
+ double length_square() const;
+
+ static vector const& null(); // v[0,0,0,0]
+ static vector const& unit_x(); // v[1,0,0,0]
+ static vector const& unit_y(); // v[0,1,0,0]
+ static vector const& unit_z(); // v[0,0,1,0]
+
+ vector& normalize();
+
+ private:
+
+ double data_[4];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ vector operator-(vector const&);
+
+ vector operator+(vector const&, vector const&);
+ vector operator-(point const&, point const&);
+ vector operator-(vector const&, vector const&);
+ vector operator*(vector const&, double);
+ vector operator*(double, vector const&);
+ vector operator/(vector const&, double);
+ bool operator==(vector const&, vector const&);
+
+ double length(vector const&);
+ double length_square(vector const&);
+ double dot(vector const&, vector const&);
+ vector cross(vector const&, vector const&);
+ vector normalize(vector const&);
+
+ std::ostream& operator<<(std::ostream&, vector const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_VECTOR_HPP)
+
diff --git a/Raytracer1108/src/Makefile b/Raytracer1108/src/Makefile
new file mode 100644
index 0000000..6473444
--- /dev/null
+++ b/Raytracer1108/src/Makefile
@@ -0,0 +1,25 @@
+FLAGS = -c
+COMPILER = g++
+BFLAGS = -I ../include
+
+default:
+ $(COMPILER) $(FLAGS) point.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) vector.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) shape.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) rgb.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) pixel.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) sphere.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) ray.cpp $(BFLAGS)
+ rm *.o
+
+intersect:
+ $(COMPILER) $(FLAGS) point.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) vector.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) shape.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) rgb.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) sphere.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) ray.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) intersecttest.cpp $(BFLAGS)
+ $(COMPILER) point.o vector.o shape.o rgb.o sphere.o ray.o intersecttest.o -o intersect
+ rm *.o
+
diff --git a/Raytracer1108/src/box.cpp b/Raytracer1108/src/box.cpp
new file mode 100644
index 0000000..1c29874
--- /dev/null
+++ b/Raytracer1108/src/box.cpp
@@ -0,0 +1,178 @@
+#include "box.hpp"
+
+//
+// Konstruktoren, Destruktor
+//
+box::box() {}
+
+box::box(math3d::point const& p1, math3d::point const& p2, std::string const& name, material const& mat, math3d::matrix const& matr, math3d::matrix const& matrInv) :
+ shape(name,mat, matr, matrInv) ,
+ vertexLuh_ (p1),
+ vertexRov_ (p2) {}
+
+box::box(box const& bx) :
+ shape(bx) ,
+ vertexLuh_(bx.vertexLuh_) ,
+ vertexRov_(bx.vertexRov_) {}
+
+box::~box() {}
+//
+
+
+//
+// volume - Berechnung boxvolumen
+//
+double box::volume() const
+{
+ return std::abs( (vertexLuh_[math3d::point::x]-vertexRov_[math3d::point::x]) *
+ (vertexLuh_[math3d::point::y]-vertexRov_[math3d::point::y]) *
+ (vertexLuh_[math3d::point::z]-vertexRov_[math3d::point::z]) );
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool box::isInside(math3d::point const& p) const
+{
+ return ( (p[math3d::point::x] >= vertexLuh_[math3d::point::x] && p[math3d::point::x] <= vertexRov_[math3d::point::x]) &&
+ (p[math3d::point::y] >= vertexLuh_[math3d::point::y] && p[math3d::point::y] <= vertexRov_[math3d::point::y]) &&
+ (p[math3d::point::z] >= vertexLuh_[math3d::point::z] && p[math3d::point::z] <= vertexRov_[math3d::point::z]) );
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double box::surface() const
+{
+ return ( std::abs(2* (vertexLuh_[math3d::point::x]-vertexRov_[math3d::point::x]) * (vertexLuh_[math3d::point::y]-vertexRov_[math3d::point::y]))
+ + std::abs(2* (vertexLuh_[math3d::point::x]-vertexRov_[math3d::point::x]) * (vertexLuh_[math3d::point::z]-vertexRov_[math3d::point::z]))
+ + std::abs(2* (vertexLuh_[math3d::point::z]-vertexRov_[math3d::point::z]) * (vertexLuh_[math3d::point::y]-vertexRov_[math3d::point::y])) );
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void box::printOn(std::ostream& stream) const
+{
+ stream << "\nBox: \n";
+ shape::printOn(stream);
+ stream << "Vertex Links unten hinten: " << vertexLuh_[math3d::point::x] << " "
+ << vertexLuh_[math3d::point::y] << " " << vertexLuh_[math3d::point::z] << "\n";
+ stream << "Vertex Rechts oben vorne: " << vertexRov_[math3d::point::x] << " "
+ << vertexRov_[math3d::point::y] << " " << vertexRov_[math3d::point::z] << "\n";
+ //stream << "Länge: " << x_ << " , Breite: " << z_ << " , Höhe: " << y_ << "\n";
+ stream << "Volumen: " << volume() << "\nOberfläche: " << surface() << "\n";
+}
+//
+
+
+//
+// clone
+//
+box* box::clone() const
+{
+ return new box(*this);
+}
+//
+
+
+//
+// intersection
+//
+double box::intersection(ray const& ray) const
+{
+
+// durch Null teilen???
+
+ double t = ~0;
+ double p_x, p_y, p_z;
+
+ //linke seite quader
+ double t_x_min = (vertexLuh_[math3d::point::x] - ray.origin_[math3d::vector::x]) / ray.direction_[math3d::vector::x];
+
+ if (t_x_min < t)
+ {
+ p_y = ray.origin_[math3d::vector::y] + t_x_min * ray.direction_[math3d::vector::y];
+ p_z = ray.origin_[math3d::vector::z] + t_x_min * ray.direction_[math3d::vector::z];
+
+ if( p_y >= vertexLuh_[math3d::point::y] && p_y <= vertexRov_[math3d::point::y] &&
+ p_z >= vertexLuh_[math3d::point::z] && p_z <= vertexRov_[math3d::point::z] )
+ t = t_x_min;
+ }
+
+ //untere seite quader
+ double t_y_min = (vertexLuh_[math3d::point::y] - ray.origin_[math3d::vector::y]) / ray.direction_[math3d::vector::y];
+
+ if (t_y_min < t)
+ {
+ p_x = ray.origin_[math3d::vector::x] + t_y_min * ray.direction_[math3d::vector::x];
+ p_z = ray.origin_[math3d::vector::z] + t_y_min * ray.direction_[math3d::vector::z];
+
+ if( p_x >= vertexLuh_[math3d::point::x] && p_x <= vertexRov_[math3d::point::x] &&
+ p_z >= vertexLuh_[math3d::point::z] && p_z <= vertexRov_[math3d::point::z] )
+ t = t_y_min;
+ }
+
+ //hintere seite quader
+ double t_z_min = (vertexLuh_[math3d::point::z] - ray.origin_[math3d::vector::z]) / ray.direction_[math3d::vector::z];
+
+ if (t_z_min < t)
+ {
+ p_x = ray.origin_[math3d::vector::x] + t_z_min * ray.direction_[math3d::vector::x];
+ p_y = ray.origin_[math3d::vector::y] + t_z_min * ray.direction_[math3d::vector::y];
+
+ if( p_x >= vertexLuh_[math3d::point::x] && p_x <= vertexRov_[math3d::point::x] &&
+ p_y >= vertexLuh_[math3d::point::y] && p_z <= vertexRov_[math3d::point::y] )
+ t = t_z_min;
+ }
+
+ //rechte seite quader
+ double t_x_max = (vertexRov_[math3d::point::x] - ray.origin_[math3d::vector::x]) / ray.direction_[math3d::vector::x];
+
+ if (t_x_max < t)
+ {
+ p_y = ray.origin_[math3d::vector::y] + t_x_max * ray.direction_[math3d::vector::y];
+ p_z = ray.origin_[math3d::vector::z] + t_x_max * ray.direction_[math3d::vector::z];
+
+ if( p_y >= vertexLuh_[math3d::point::y] && p_y <= vertexRov_[math3d::point::y] &&
+ p_z >= vertexLuh_[math3d::point::z] && p_z <= vertexRov_[math3d::point::z] )
+ t = t_x_max;
+ }
+
+ //obere seite quader
+ double t_y_max = (vertexRov_[math3d::point::y] - ray.origin_[math3d::vector::y]) / ray.direction_[math3d::vector::y];
+
+ if (t_y_max < t)
+ {
+ p_x = ray.origin_[math3d::vector::x] + t_y_max * ray.direction_[math3d::vector::x];
+ p_z = ray.origin_[math3d::vector::z] + t_y_max * ray.direction_[math3d::vector::z];
+
+ if( p_x >= vertexLuh_[math3d::point::x] && p_x <= vertexRov_[math3d::point::x] &&
+ p_z >= vertexLuh_[math3d::point::z] && p_z <= vertexRov_[math3d::point::z] )
+ t = t_y_max;
+ }
+
+ //vordere seite quader
+ double t_z_max = (vertexRov_[math3d::point::z] - ray.origin_[math3d::vector::z]) / ray.direction_[math3d::vector::z];
+
+ if (t_z_max < t)
+ {
+ p_x = ray.origin_[math3d::vector::x] + t_z_max * ray.direction_[math3d::vector::x];
+ p_y = ray.origin_[math3d::vector::y] + t_z_max * ray.direction_[math3d::vector::y];
+
+ if( p_x >= vertexLuh_[math3d::point::x] && p_x <= vertexRov_[math3d::point::x] &&
+ p_y >= vertexLuh_[math3d::point::y] && p_y <= vertexRov_[math3d::point::y] )
+ t = t_z_max;
+ }
+
+ return t;
+}
+
+
+
diff --git a/Raytracer1108/src/camera.cpp b/Raytracer1108/src/camera.cpp
new file mode 100644
index 0000000..3f8a4e7
--- /dev/null
+++ b/Raytracer1108/src/camera.cpp
@@ -0,0 +1,81 @@
+#include "camera.hpp"
+
+//
+// Konstruktoren
+//
+camera::camera() {}
+camera::camera(std::string const& n, double x, double y, math3d::matrix const& matr, math3d::matrix const& matrInv) :
+ name_(n) ,
+ fovX_(x),
+ fovY_(y),
+ worldMatrix_(matr),
+ worldMatrixInvers_(matrInv) {}
+//
+
+
+//
+// translate
+//
+void camera::translate(math3d::vector const& v)
+{
+/* matrix tmp;
+
+ tmp[math3d::matrix::da] = v[math3d::vector::x];
+ tmp[math3d::matrix::db] = v[math3d::vector::y];
+ tmp[math3d::matrix::dc] = v[math3d::vector::z];
+*/
+
+ worldMatrix_ *= translationmatrix(v);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
+
+//
+// scale
+//
+void camera::scale(math3d::vector const& v)
+{
+/* matrix tmp;
+
+ tmp[math3d::matrix::aa] = v[math3d::vector::x];
+ tmp[math3d::matrix::bb] = v[math3d::vector::y];
+ tmp[math3d::matrix::cc] = v[math3d::vector::z];
+*/
+
+ worldMatrix_ *= scalingmatrix(v);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
+
+//
+// rotate
+//
+void camera::rotate(math3d::vector const& v, double w)
+{
+/* matrix tmp;
+
+ double const cosW(std::cos(w));
+ double const sinW(std::sin(w));
+ double const x = v[math3d::vector::x];
+ double const y = v[math3d::vector::y];
+ double const z = v[math3d::vector::z];
+ double const tmp = 1 - cosW;
+
+ tmp[math3d::matrix::aa] = cosW + x * x * tmp;
+ tmp[math3d::matrix::ab] = x * y * tmp + y * sinW;
+ tmp[math3d::matrix::ac] = x * z * tmp - y * sinW;
+ tmp[math3d::matrix::ba] = x * y * tmp - z * sinW;
+ tmp[math3d::matrix::bb] = cosW + y * y * tmp;
+ tmp[math3d::matrix::bc] = y * z * tmp + x * sinW;
+ tmp[math3d::matrix::ca] = x * z * tmp + y * sinW;
+ tmp[math3d::matrix::cb] = y * z * tmp - x * sinW;
+ tmp[math3d::matrix::cc] = cosW + z * z * tmp;
+*/
+
+ worldMatrix_ *= rotationmatrix(v,w);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
diff --git a/Raytracer1108/src/camera.cpp~ b/Raytracer1108/src/camera.cpp~
new file mode 100644
index 0000000..ba9f578
--- /dev/null
+++ b/Raytracer1108/src/camera.cpp~
@@ -0,0 +1,81 @@
+#include "camera.hpp"
+
+//
+// Konstruktoren
+//
+camera::camera() {}
+camera::camera(std::string n, double x, double y, math3d::matrix const& matr, math3d::matrix const& matrInv) :
+ name_(n) ,
+ fovX_(x),
+ fovY_(y),
+ worldMatrix_(matr),
+ worldMatrixInvers_(matrInv) {}
+//
+
+
+//
+// translate
+//
+void camera::translate(math3d::vector const& v)
+{
+/* matrix tmp;
+
+ tmp[math3d::matrix::da] = v[math3d::vector::x];
+ tmp[math3d::matrix::db] = v[math3d::vector::y];
+ tmp[math3d::matrix::dc] = v[math3d::vector::z];
+*/
+
+ worldMatrix_ *= translationmatrix(v);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
+
+//
+// scale
+//
+void camera::scale(math3d::vector const& v)
+{
+/* matrix tmp;
+
+ tmp[math3d::matrix::aa] = v[math3d::vector::x];
+ tmp[math3d::matrix::bb] = v[math3d::vector::y];
+ tmp[math3d::matrix::cc] = v[math3d::vector::z];
+*/
+
+ worldMatrix_ *= scalingmatrix(v);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
+
+//
+// rotate
+//
+void camera::rotate(math3d::vector const& v, double w)
+{
+/* matrix tmp;
+
+ double const cosW(std::cos(w));
+ double const sinW(std::sin(w));
+ double const x = v[math3d::vector::x];
+ double const y = v[math3d::vector::y];
+ double const z = v[math3d::vector::z];
+ double const tmp = 1 - cosW;
+
+ tmp[math3d::matrix::aa] = cosW + x * x * tmp;
+ tmp[math3d::matrix::ab] = x * y * tmp + y * sinW;
+ tmp[math3d::matrix::ac] = x * z * tmp - y * sinW;
+ tmp[math3d::matrix::ba] = x * y * tmp - z * sinW;
+ tmp[math3d::matrix::bb] = cosW + y * y * tmp;
+ tmp[math3d::matrix::bc] = y * z * tmp + x * sinW;
+ tmp[math3d::matrix::ca] = x * z * tmp + y * sinW;
+ tmp[math3d::matrix::cb] = y * z * tmp - x * sinW;
+ tmp[math3d::matrix::cc] = cosW + z * z * tmp;
+*/
+
+ worldMatrix_ *= rotationmatrix(v,w);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
diff --git a/Raytracer1108/src/glutwindow.cpp b/Raytracer1108/src/glutwindow.cpp
new file mode 100644
index 0000000..dbcb064
--- /dev/null
+++ b/Raytracer1108/src/glutwindow.cpp
@@ -0,0 +1,153 @@
+// header i/f
+#include "glutwindow.hpp"
+
+// header, system
+#if WIN32
+ #include <time.h>
+ #include <windows.h>
+#else
+ #include <sys/time.h>
+#endif
+
+#ifdef __APPLE__
+ #include <GLUT/glut.h>
+#else
+ #include <GL/glut.h>
+#endif
+
+#include <iostream>
+#include <cassert>
+
+// header, project
+
+// globals
+glutwindow* g_glutwindow = 0;
+
+
+////////////////////////////////////////////////////////////////////////////////
+glutwindow::glutwindow(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[])
+ : width_(width),
+ height_(height),
+ posx_(posx),
+ posy_(posy),
+ name_(name)
+{
+ g_glutwindow = this;
+ buffer_.resize(width_ * height_);
+
+ glutInit(&argc,argv);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+
+ glutInitWindowPosition(int(posx_), int(posy_));
+ glutInitWindowSize(int(width_), int(height_));
+ glutCreateWindow(name_.c_str());
+
+ glutDisplayFunc(display);
+ glutReshapeFunc(reshape);
+ glutIdleFunc(idle);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+glutwindow::~glutwindow()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/*static*/ glutwindow&
+glutwindow::instance()
+{
+ assert(g_glutwindow);
+ return *g_glutwindow;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/*static*/ void
+glutwindow::init(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[])
+{
+ static glutwindow instance(width, height, posx, posy, name, argc, argv);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::run()
+{
+ glutMainLoop();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t
+glutwindow::width() const {
+ return width_;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t
+glutwindow::height() const {
+ return height_;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::write(const pixel& p)
+{
+ // flip pixels, because of opengl glDrawPixels
+ size_t buf_pos = (width_*p.y + (p.x));
+ if (buf_pos >= buffer_.size() || (int)buf_pos < 0) {
+ std::cerr << "Fatal Error glutwindow::write(pixel p) : pixel out of image : " << (int)p.x << "," << (int)p.y << std::endl;
+ } else {
+ buffer_[buf_pos] = p.color;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::update()
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glDrawPixels(width_, height_, GL_RGB, GL_FLOAT, &(buffer_.front()));
+ glutSwapBuffers();
+
+ // upate only with 25Hz
+#if WIN32
+ Sleep(20);
+#else
+ usleep(20000);
+#endif
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void display()
+{
+ glutwindow::instance().update();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void reshape(int w, int h)
+{
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void idle()
+{
+ glutPostRedisplay();
+}
diff --git a/Raytracer1108/src/light.cpp b/Raytracer1108/src/light.cpp
new file mode 100644
index 0000000..e2a6787
--- /dev/null
+++ b/Raytracer1108/src/light.cpp
@@ -0,0 +1,10 @@
+#include "light.hpp"
+
+light::light() {}
+
+light::light(math3d::point p, std::string n, rgb la, rgb ld) :
+ location_(p) ,
+ name_(n) ,
+ lightAmbient_(la) ,
+ lightDiffuse_(ld) {}
+
diff --git a/Raytracer1108/src/main.cpp b/Raytracer1108/src/main.cpp
new file mode 100644
index 0000000..a6df1a9
--- /dev/null
+++ b/Raytracer1108/src/main.cpp
@@ -0,0 +1,90 @@
+#include <glutwindow.hpp>
+#include <ppmwriter.hpp>
+#include <pixel.hpp>
+
+#include <iostream>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#ifdef __APPLE__
+ #include <GLUT/glut.h>
+#else
+ #include <GL/glut.h>
+#endif
+
+// this is a dummy raytrace application
+class rt_application
+{
+public :
+
+ //
+ void raytrace() const
+ {
+ // size of a tile in checkerboard
+ const std::size_t checkersize = 20;
+
+ // get glutwindow instance
+ glutwindow& gw = glutwindow::instance();
+
+ // create a ppmwriter
+ ppmwriter pw(gw.width(), gw.height(), "./checkerboard.ppm");
+
+ // for all pixels of window
+ for (std::size_t y = 0; y < gw.height(); ++y) {
+ for (std::size_t x = 0; x < gw.width(); ++x) {
+
+ // create pixel at x,y
+ pixel p(x, y);
+
+ // compute color for pixel
+ if ( ((x/checkersize)%2) != ((y/checkersize)%2)) {
+ p.color = rgb(1.0, 1.0, float(x)/gw.height());
+ } else {
+ p.color = rgb(1.0, 0.0, float(y)/gw.width());
+ }
+
+ // write pixel to output window
+ gw.write(p);
+
+ // write pixel to image writer
+ pw.write(p);
+ }
+ }
+
+ // save final image
+ pw.save();
+ }
+
+private : // attributes
+
+ // you may add a scene description here
+
+};
+
+
+
+
+
+int main(int argc, char* argv[])
+{
+ // set resolution and checkersize
+ const std::size_t width = 400;
+ const std::size_t height = 400;
+
+ // create output window
+ glutwindow::init(width, height, 100, 100, "CheckerBoard", argc, argv);
+
+ // create a ray tracing application
+ rt_application app;
+
+ // start computation in thread
+ boost::thread thr(boost::bind(&rt_application::raytrace, &app));
+
+ // start output on glutwindow
+ glutwindow::instance().run();
+
+ // wait on thread
+ thr.join();
+
+ return 0;
+}
diff --git a/Raytracer1108/src/material.cpp b/Raytracer1108/src/material.cpp
new file mode 100644
index 0000000..d4ffb4a
--- /dev/null
+++ b/Raytracer1108/src/material.cpp
@@ -0,0 +1,12 @@
+#include "material.hpp"
+
+material::material() {}
+
+material::material(std::string n, rgb ra, rgb rd, rgb rs, double ers) :
+ name_(n) ,
+ reflexionAmbient_(ra),
+ reflexionDiffuse_(rd),
+ reflexionSpecular_(rs),
+ expReflexionSpecular_(ers) {}
+
+
diff --git a/Raytracer1108/src/matrix.cpp b/Raytracer1108/src/matrix.cpp
new file mode 100644
index 0000000..d7209dd
--- /dev/null
+++ b/Raytracer1108/src/matrix.cpp
@@ -0,0 +1,488 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : matrix.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "matrix.hpp"
+
+// includes, system
+
+#include <algorithm> // std::copy, std::swap_ranges
+#include <cmath> // std::cos, std::sin
+#include <iomanip> // std::fixed, std::setprecision
+#include <ostream> // std::ostream
+#include <limits> // std::numeric_limits
+
+// includes, project
+#include <point.hpp>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ double const null_array16[16] = {
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+ };
+
+ double const ident_array16[16] = {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+ };
+
+ // functions, internal
+
+ double
+ det3_helper(double a1, double a2, double a3,
+ double b1, double b2, double b3,
+ double c1, double c2, double c3)
+ {
+ return ((a1 * b2 * c3) + (a2 * b3 * c1) + (a3 * b1 * c2) -
+ (a1 * b3 * c2) - (a2 * b1 * c3) - (a3 * b2 * c1));
+ }
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ matrix::matrix()
+ : data_()
+ {
+ std::copy(ident_array16, ident_array16+16, data_);
+ }
+
+ matrix::matrix(matrix const& rhs)
+ : data_()
+ {
+ std::copy(rhs.data_, rhs.data_+16, data_);
+ }
+
+ matrix::matrix(double const a[16])
+ : data_()
+ {
+ std::copy(a, a+16, data_);
+ }
+
+ matrix::~matrix()
+ {}
+
+ void
+ matrix::swap(matrix& rhs)
+ {
+ std::swap_ranges(data_, data_+16, rhs.data_);
+ }
+
+ matrix&
+ matrix::operator=(matrix const& rhs)
+ {
+ matrix tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ matrix::operator()(matrix::cols a, matrix::rows b) const
+ {
+ return data_[(b * 4) + a];
+ }
+
+ double&
+ matrix::operator()(matrix::cols a, matrix::rows b)
+ {
+ return data_[(b * 4) + a];
+ }
+
+ double const&
+ matrix::operator[](matrix::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ matrix::operator[](matrix::component idx)
+ {
+ return data_[idx];
+ }
+
+ matrix&
+ matrix::operator*=(matrix const& rhs)
+ {
+ matrix tmp;
+
+ tmp.data_[ 0] = (data_[ 0] * rhs.data_[ 0] +
+ data_[ 4] * rhs.data_[ 1] +
+ data_[ 8] * rhs.data_[ 2] +
+ data_[12] * rhs.data_[ 3]);
+ tmp.data_[ 1] = (data_[ 1] * rhs.data_[ 0] +
+ data_[ 5] * rhs.data_[ 1] +
+ data_[ 9] * rhs.data_[ 2] +
+ data_[13] * rhs.data_[ 3]);
+ tmp.data_[ 2] = (data_[ 2] * rhs.data_[ 0] +
+ data_[ 6] * rhs.data_[ 1] +
+ data_[10] * rhs.data_[ 2] +
+ data_[14] * rhs.data_[ 3]);
+ tmp.data_[ 3] = (data_[ 3] * rhs.data_[ 0] +
+ data_[ 7] * rhs.data_[ 1] +
+ data_[11] * rhs.data_[ 2] +
+ data_[15] * rhs.data_[ 3]);
+ tmp.data_[ 4] = (data_[ 0] * rhs.data_[ 4] +
+ data_[ 4] * rhs.data_[ 5] +
+ data_[ 8] * rhs.data_[ 6] +
+ data_[12] * rhs.data_[ 7]);
+ tmp.data_[ 5] = (data_[ 1] * rhs.data_[ 4] +
+ data_[ 5] * rhs.data_[ 5] +
+ data_[ 9] * rhs.data_[ 6] +
+ data_[13] * rhs.data_[ 7]);
+ tmp.data_[ 6] = (data_[ 2] * rhs.data_[ 4] +
+ data_[ 6] * rhs.data_[ 5] +
+ data_[10] * rhs.data_[ 6] +
+ data_[14] * rhs.data_[ 7]);
+ tmp.data_[ 7] = (data_[ 3] * rhs.data_[ 4] +
+ data_[ 7] * rhs.data_[ 5] +
+ data_[11] * rhs.data_[ 6] +
+ data_[15] * rhs.data_[ 7]);
+ tmp.data_[ 8] = (data_[ 0] * rhs.data_[ 8] +
+ data_[ 4] * rhs.data_[ 9] +
+ data_[ 8] * rhs.data_[10] +
+ data_[12] * rhs.data_[11]);
+ tmp.data_[ 9] = (data_[ 1] * rhs.data_[ 8] +
+ data_[ 5] * rhs.data_[ 9] +
+ data_[ 9] * rhs.data_[10] +
+ data_[13] * rhs.data_[11]);
+ tmp.data_[10] = (data_[ 2] * rhs.data_[ 8] +
+ data_[ 6] * rhs.data_[ 9] +
+ data_[10] * rhs.data_[10] +
+ data_[14] * rhs.data_[11]);
+ tmp.data_[11] = (data_[ 3] * rhs.data_[ 8] +
+ data_[ 7] * rhs.data_[ 9] +
+ data_[11] * rhs.data_[10] +
+ data_[15] * rhs.data_[11]);
+ tmp.data_[12] = (data_[ 0] * rhs.data_[12] +
+ data_[ 4] * rhs.data_[13] +
+ data_[ 8] * rhs.data_[14] +
+ data_[12] * rhs.data_[15]);
+ tmp.data_[13] = (data_[ 1] * rhs.data_[12] +
+ data_[ 5] * rhs.data_[13] +
+ data_[ 9] * rhs.data_[14] +
+ data_[13] * rhs.data_[15]);
+ tmp.data_[14] = (data_[ 2] * rhs.data_[12] +
+ data_[ 6] * rhs.data_[13] +
+ data_[10] * rhs.data_[14] +
+ data_[14] * rhs.data_[15]);
+ tmp.data_[15] = (data_[ 3] * rhs.data_[12] +
+ data_[ 7] * rhs.data_[13] +
+ data_[11] * rhs.data_[14] +
+ data_[15] * rhs.data_[15]);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ matrix&
+ matrix::operator*=(double rhs)
+ {
+ for (unsigned idx = 0; idx < 16; ++idx)
+ data_[idx] *= rhs;
+
+ return *this;
+ }
+
+ matrix&
+ matrix::operator/=(double rhs)
+ {
+ for (unsigned idx = 0; idx < 16; ++idx)
+ data_[idx] /= rhs;
+
+ return *this;
+ }
+
+ double
+ matrix::trace() const
+ {
+ return data_[0] + data_[5] + data_[10] + data_[15];
+ }
+
+ double
+ matrix::determinant() const
+ {
+ // to implement!
+ double det(0.0);
+
+ return det;
+ }
+
+ bool
+ matrix::invert()
+ {
+ bool result(false);
+ double const d(determinant());
+
+ if (0.0 != d) {
+ double const& a1(data_[ 0]);
+ double const& b1(data_[ 4]);
+ double const& c1(data_[ 8]);
+ double const& d1(data_[12]);
+ double const& a2(data_[ 1]);
+ double const& b2(data_[ 5]);
+ double const& c2(data_[ 9]);
+ double const& d2(data_[13]);
+ double const& a3(data_[ 2]);
+ double const& b3(data_[ 6]);
+ double const& c3(data_[10]);
+ double const& d3(data_[14]);
+ double const& a4(data_[ 3]);
+ double const& b4(data_[ 7]);
+ double const& c4(data_[11]);
+ double const& d4(data_[15]);
+
+ double const di(1.0 / d);
+
+ matrix tmp;
+
+ tmp.data_[ 0] = det3_helper(b2, b3, b4, c2, c3, c4, d2, d3, d4) * di;
+ tmp.data_[ 1] = -det3_helper(a2, a3, a4, c2, c3, c4, d2, d3, d4) * di;
+ tmp.data_[ 2] = det3_helper(a2, a3, a4, b2, b3, b4, d2, d3, d4) * di;
+ tmp.data_[ 3] = -det3_helper(a2, a3, a4, b2, b3, b4, c2, c3, c4) * di;
+ tmp.data_[ 4] = -det3_helper(b1, b3, b4, c1, c3, c4, d1, d3, d4) * di;
+ tmp.data_[ 5] = det3_helper(a1, a3, a4, c1, c3, c4, d1, d3, d4) * di;
+ tmp.data_[ 6] = -det3_helper(a1, a3, a4, b1, b3, b4, d1, d3, d4) * di;
+ tmp.data_[ 7] = det3_helper(a1, a3, a4, b1, b3, b4, c1, c3, c4) * di;
+ tmp.data_[ 8] = det3_helper(b1, b2, b4, c1, c2, c4, d1, d2, d4) * di;
+ tmp.data_[ 9] = -det3_helper(a1, a2, a4, c1, c2, c4, d1, d2, d4) * di;
+ tmp.data_[10] = det3_helper(a1, a2, a4, b1, b2, b4, d1, d2, d4) * di;
+ tmp.data_[11] = -det3_helper(a1, a2, a4, b1, b2, b4, c1, c2, c4) * di;
+ tmp.data_[12] = -det3_helper(b1, b2, b3, c1, c2, c3, d1, d2, d3) * di;
+ tmp.data_[13] = det3_helper(a1, a2, a3, c1, c2, c3, d1, d2, d3) * di;
+ tmp.data_[14] = -det3_helper(a1, a2, a3, b1, b2, b3, d1, d2, d3) * di;
+ tmp.data_[15] = det3_helper(a1, a2, a3, b1, b2, b3, c1, c2, c3) * di;
+
+ swap(tmp);
+
+ result = true;
+ }
+
+ return result;
+ }
+
+ bool
+ matrix::is_invertible() const
+ {
+ return 0 != determinant();
+ }
+
+ /* static */
+ matrix const&
+ matrix::null()
+ {
+ static matrix null_(null_array16);
+ return null_;
+ }
+
+ /* static */
+ matrix const&
+ matrix::identity()
+ {
+ static matrix identity_(ident_array16);
+ return identity_;
+ }
+
+ matrix
+ operator-(matrix const& rhs)
+ {
+ return matrix(rhs) *= -1.0;
+ }
+
+ matrix
+ operator*(matrix const& lhs, matrix const& rhs)
+ {
+ return matrix(lhs) *= rhs;
+ }
+
+ matrix
+ operator*(matrix const& lhs, double rhs)
+ {
+ return matrix(lhs) *= rhs;
+ }
+
+ matrix
+ operator*(double lhs, matrix const& rhs)
+ {
+ return matrix(rhs) *= lhs;
+ }
+
+ matrix
+ operator/(matrix const& lhs, double rhs)
+ {
+ return matrix(lhs) /= rhs;
+ }
+
+ point
+ operator*(matrix const& lhs, const point& rhs)
+ {
+ return point(lhs[matrix::aa] * rhs[point::x] +
+ lhs[matrix::ba] * rhs[point::y] +
+ lhs[matrix::ca] * rhs[point::z] +
+ lhs[matrix::da] * rhs[point::w],
+ lhs[matrix::ab] * rhs[point::x] +
+ lhs[matrix::bb] * rhs[point::y] +
+ lhs[matrix::cb] * rhs[point::z] +
+ lhs[matrix::db] * rhs[point::w],
+ lhs[matrix::ac] * rhs[point::x] +
+ lhs[matrix::bc] * rhs[point::y] +
+ lhs[matrix::cc] * rhs[point::z] +
+ lhs[matrix::dc] * rhs[point::w],
+ lhs[matrix::ad] * rhs[point::x] +
+ lhs[matrix::bd] * rhs[point::y] +
+ lhs[matrix::cd] * rhs[point::z] +
+ lhs[matrix::dd] * rhs[point::w]);
+ }
+
+ vector
+ operator*(matrix const& lhs, const vector& rhs)
+ {
+ return vector(lhs[matrix::aa] * rhs[vector::x] +
+ lhs[matrix::ba] * rhs[vector::y] +
+ lhs[matrix::ca] * rhs[vector::z] +
+ lhs[matrix::da] * rhs[vector::w],
+ lhs[matrix::ab] * rhs[vector::x] +
+ lhs[matrix::bb] * rhs[vector::y] +
+ lhs[matrix::cb] * rhs[vector::z] +
+ lhs[matrix::db] * rhs[vector::w],
+ lhs[matrix::ac] * rhs[vector::x] +
+ lhs[matrix::bc] * rhs[vector::y] +
+ lhs[matrix::cc] * rhs[vector::z] +
+ lhs[matrix::dc] * rhs[vector::w],
+ lhs[matrix::ad] * rhs[vector::x] +
+ lhs[matrix::bd] * rhs[vector::y] +
+ lhs[matrix::cd] * rhs[vector::z] +
+ lhs[matrix::dd] * rhs[vector::w]);
+ }
+
+ bool
+ operator==(matrix const& lhs, matrix const& rhs)
+ {
+ return (std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon());
+ }
+
+ matrix
+ make_rotation_x(double a)
+ {
+ double const cos_a(std::cos(a));
+ double const sin_a(std::sin(a));
+
+ matrix tmp;
+
+ tmp[matrix::bb] = cos_a;
+ tmp[matrix::cb] = sin_a;
+ tmp[matrix::bc] = -sin_a;
+ tmp[matrix::cc] = cos_a;
+
+ return tmp;
+ }
+
+ double
+ determinant(matrix const& a)
+ {
+ return a.determinant();
+ }
+
+ double
+ trace(matrix const& a)
+ {
+ return a.trace();
+ }
+
+ matrix
+ inverse(matrix const& a)
+ {
+ matrix tmp(a);
+
+ tmp.invert();
+
+ return tmp;
+ }
+
+ bool
+ is_invertible(matrix const& a)
+ {
+ return a.is_invertible();
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, matrix const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << std::fixed << std::setprecision(3)
+ << '['
+ << a[matrix::aa] << ','
+ << a[matrix::ab] << ','
+ << a[matrix::ac] << ','
+ << a[matrix::ad] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ba] << ','
+ << a[matrix::bb] << ','
+ << a[matrix::bc] << ','
+ << a[matrix::bd] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ca] << ','
+ << a[matrix::cb] << ','
+ << a[matrix::cc] << ','
+ << a[matrix::cd] << ','
+ << std::endl
+ << ' '
+ << a[matrix::da] << ','
+ << a[matrix::db] << ','
+ << a[matrix::dc] << ','
+ << a[matrix::dd]
+ << ']';
+ }
+
+ return os;
+ }
+
+} // namespace math3d {
diff --git a/Raytracer1108/src/pixel.cpp b/Raytracer1108/src/pixel.cpp
new file mode 100644
index 0000000..691ff5f
--- /dev/null
+++ b/Raytracer1108/src/pixel.cpp
@@ -0,0 +1,39 @@
+// header i/f
+#include "pixel.hpp"
+
+// header, system
+#include <ostream>
+
+
+pixel::pixel(std::size_t a, std::size_t b)
+ : x(a),
+ y(b),
+ color()
+{}
+
+
+///////////////////////////////////////////////////////////////////////////////
+pixel::~pixel()
+{}
+
+
+///////////////////////////////////////////////////////////////////////////////
+void
+pixel::print(std::ostream& os) const
+{
+ os << "pixel[" << (int)x << ',' << (int)y << "]("
+ << color[rgb::r] << ','
+ << color[rgb::g] << ','
+ << color[rgb::b] << ')';
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+std::ostream&
+operator<<(std::ostream& os, const pixel& a)
+{
+ std::ostream::sentry cerberus (os);
+ if (cerberus)
+ a.print(os);
+ return os;
+}
\ No newline at end of file
diff --git a/Raytracer1108/src/point.cpp b/Raytracer1108/src/point.cpp
new file mode 100644
index 0000000..361a0c2
--- /dev/null
+++ b/Raytracer1108/src/point.cpp
@@ -0,0 +1,173 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : point.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "point.hpp"
+
+// includes, system
+
+#include <algorithm> // std::swap_ranges
+#include <cmath> // std::abs
+#include <limits> // std::numeric_limits
+#include <ostream> // std::ostream
+
+// includes, project
+
+// #include <>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ // functions, internal
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ point::point()
+ {
+ data_[0] = data_[1] = data_[2] = 0.0; data_[3] = 1.0;
+ }
+
+ point::point(point const& a)
+ {
+ data_[0] = a.data_[0];
+ data_[1] = a.data_[1];
+ data_[2] = a.data_[2];
+ data_[3] = a.data_[3];
+ }
+
+ point::point(double a, double b, double c, double d)
+ {
+ data_[0] = a;
+ data_[1] = b;
+ data_[2] = c;
+ data_[3] = d;
+ }
+
+ point::~point()
+ {}
+
+ void
+ point::swap(point& rhs)
+ {
+ std::swap_ranges(data_, data_+4, rhs.data_);
+ }
+
+ point&
+ point::operator=(point const& rhs)
+ {
+ point tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ point::operator[](point::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ point::operator[](point::component idx)
+ {
+ return data_[idx];
+ }
+
+ point&
+ point::operator+=(vector const& rhs)
+ {
+ data_[point::x] += rhs[vector::x];
+ data_[point::y] += rhs[vector::y];
+ data_[point::z] += rhs[vector::z];
+ // data_[point::w] += rhs[vector::w];
+
+ return *this;
+ }
+
+ point&
+ point::operator-=(vector const& rhs)
+ {
+ data_[point::x] -= rhs[vector::x];
+ data_[point::y] -= rhs[vector::y];
+ data_[point::z] -= rhs[vector::z];
+ // data_[point::w] -= rhs[vector::w];
+
+ return *this;
+ }
+
+ /* static */ point const&
+ point::origin()
+ {
+ static point origin_(0.0, 0.0, 0.0);
+ return origin_;
+ }
+
+ point
+ operator-(point const& rhs)
+ {
+ return point(-rhs[point::x], -rhs[point::y], -rhs[point::z], rhs[point::w]);
+ }
+
+ point
+ operator+(point const& lhs, vector const& rhs)
+ {
+ return point(lhs) += rhs;
+ }
+
+ point
+ operator-(point const& lhs, vector const& rhs)
+ {
+ return point(lhs) -= rhs;
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, point const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << '['
+ << a[point::x] << ','
+ << a[point::y] << ','
+ << a[point::z] << ','
+ << a[point::w]
+ << ']';
+ }
+
+ return os;
+ }
+
+ bool
+ operator==(point const& lhs, point const& rhs)
+ {
+ return (std::fabs(rhs[point::x] - lhs[point::x]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[point::y] - lhs[point::y]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[point::z] - lhs[point::z]) < std::numeric_limits<double>::epsilon());
+ }
+
+
+} // namespace math3d {
diff --git a/Raytracer1108/src/ppmwriter.cpp b/Raytracer1108/src/ppmwriter.cpp
new file mode 100644
index 0000000..2b892bf
--- /dev/null
+++ b/Raytracer1108/src/ppmwriter.cpp
@@ -0,0 +1,81 @@
+// header i/f
+#include "ppmwriter.hpp"
+
+// header, system
+#include <iostream>
+#include <fstream>
+#include <cmath>
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::ppmwriter(std::size_t w, std::size_t h, std::string const& file)
+ : file_(file),
+ width_(w),
+ height_(h) {
+ data_.resize(w * h * (sizeof(rgb)/sizeof(rgb::value_t)));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::ppmwriter(std::size_t w, std::size_t h)
+ : file_("untitled.ppm"),
+ width_(w),
+ height_(h) {
+ data_.resize(w*h*(sizeof(rgb)/sizeof(rgb::value_t)));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::~ppmwriter()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::write(pixel const& p)
+{
+ size_t buf_pos = width_*p.y + p.x;
+ std::size_t pos = (sizeof(rgb)/sizeof(rgb::value_t)) * buf_pos;
+ if (pos + ((sizeof(rgb)/sizeof(rgb::value_t)) - 1) > data_.size() || (int)buf_pos < 0) {
+ std::cerr << "Fatal Error ppmwriter::write(pixel p) : Critical write position\n";
+ } else {
+ data_[pos] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::r], 255.0));
+ data_[pos+1] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::g], 255.0));
+ data_[pos+2] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::b], 255.0));
+ }
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::save(std::string const& file)
+{
+ file_ = file;
+ save();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::save()
+{
+ const std::size_t line_length = 18;
+
+ std::fstream file(file_.c_str(), std::ios::out);
+ file.clear();
+ file << "P3 "
+ << (unsigned int)width_ << " "
+ << (unsigned int)height_ << " "
+ << 255 << " \n";
+
+ std::size_t pos = 1;
+ for (std::vector<unsigned int>::iterator i = data_.begin();
+ i < data_.end();
+ ++i, ++pos)
+ {
+ file << (int)*i << " ";
+ if (pos > line_length) {
+ file << "\n";
+ pos=0;
+ }
+ }
+
+ file.close();
+}
\ No newline at end of file
diff --git a/Raytracer1108/src/ray.cpp b/Raytracer1108/src/ray.cpp
new file mode 100644
index 0000000..eb4fa19
--- /dev/null
+++ b/Raytracer1108/src/ray.cpp
@@ -0,0 +1,24 @@
+#include "ray.hpp"
+
+ray::ray() :
+ origin_(0,0,0,0),
+ direction_(0,0,1,0) {}
+
+ray::ray(math3d::vector o,math3d::vector d) :
+ origin_(o) ,
+ direction_(d) {]
+
+/*{
+ //Normalisieren des Richtungsvektors
+
+ double laenge_dir = std::sqrt(std::pow(direction_[math3d::vector::x],2) +
+ std::pow(direction_[math3d::vector::y],2) +
+ std::pow(direction_[math3d::vector::z],2) );
+
+ if(laenge_dir != 1)
+ {
+ direction_ = direction_/laenge_dir;
+ }
+}*/
+
+
diff --git a/Raytracer1108/src/rgb.cpp b/Raytracer1108/src/rgb.cpp
new file mode 100644
index 0000000..cd8b355
--- /dev/null
+++ b/Raytracer1108/src/rgb.cpp
@@ -0,0 +1,116 @@
+// header i/f
+#include "rgb.hpp"
+
+// header, system
+#include <iostream>
+
+// header, project
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb()
+{
+ data_[0] = 0;
+ data_[1] = 0;
+ data_[2] = 0;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb(rgb const& rhs)
+{
+ data_[0] = rhs.data_[0];
+ data_[1] = rhs.data_[1];
+ data_[2] = rhs.data_[2];
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb(float r, float g, float b)
+{
+ data_[0] = r;
+ data_[1] = g;
+ data_[2] = b;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::~rgb()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::swap(rgb& rhs)
+{
+ std::swap(data_[0], rhs.data_[0]);
+ std::swap(data_[1], rhs.data_[1]);
+ std::swap(data_[2], rhs.data_[2]);
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::print(std::ostream& os) const
+{
+ os << '(' << data_[0] << '|' << data_[1] << '|' << data_[2] << ')' << std::endl;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::value_t&
+rgb::operator[](enum rgb::component c)
+{
+ return data_[c];
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+const rgb::value_t&
+rgb::operator[](enum rgb::component c) const
+{
+ return data_[c];
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb&
+rgb::operator=(rgb const& rhs)
+{
+ rgb tmp(rhs);
+ swap(tmp);
+ return *this;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::operator+=(rgb const& a)
+{
+ data_[0]+=a.data_[0];
+ data_[1]+=a.data_[1];
+ data_[2]+=a.data_[2];
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb
+operator+(rgb const& a, rgb const& b)
+{
+ rgb result(a);
+ result += b;
+ return result;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::ostream&
+operator<<(std::ostream& os, rgb const& color)
+{
+ color.print(os);
+ return os;
+}
diff --git a/Raytracer1108/src/shape.cpp b/Raytracer1108/src/shape.cpp
new file mode 100644
index 0000000..d9674d3
--- /dev/null
+++ b/Raytracer1108/src/shape.cpp
@@ -0,0 +1,163 @@
+#include "shape.hpp"
+
+
+shape::shape() : refCount_(0) {}
+shape::shape(std::string const& s, material const& mat, math3d::matrix const& matr, math3d::matrix const& matrInv) :
+ name_(s) ,
+ refCount_(0),
+ material_(mat),
+ worldMatrix_(matr),
+ worldMatrixInvers_(matrInv) {}
+
+shape::shape(shape const& sh) :
+ name_(sh.name_),
+ refCount_(0),
+ material_(sh.material_),
+ worldMatrix_(sh.worldMatrix_),
+ worldMatrixInvers_(sh.worldMatrixInvers_) {}
+
+shape::~shape() {}
+
+
+//
+// getmaterial
+//
+material shape::getMaterial() const
+{
+ return material_;
+}
+//
+
+
+//
+// getname
+//
+std::string shape::getName() const
+{
+ return name_;
+}
+//
+
+
+//
+// printOn
+//
+void shape::printOn( std::ostream& stream) const
+{
+ stream << "Name: " << name_ << "\n";
+}
+//
+
+std::ostream& operator<<(std::ostream& stream, shape const& sh)
+{
+ sh.printOn(stream);
+ return stream;
+}
+
+bool operator==(shape const& lhs, shape const& rhs)
+{
+ return lhs.getName() == rhs.getName();
+}
+
+
+//
+// ref
+//
+int shape::ref()
+{
+ return ++refCount_;
+}
+//
+
+
+//
+// unRef
+//
+int shape::unRef()
+{
+ --refCount_;
+ if (refCount_ <= 0)
+ {
+ delete this;
+ return 0;
+ }
+ return refCount_;
+}
+//
+
+
+//
+// translate
+//
+void shape::translate(math3d::vector const& v)
+{
+/* matrix tmp;
+
+ tmp[math3d::matrix::da] = v[math3d::vector::x];
+ tmp[math3d::matrix::db] = v[math3d::vector::y];
+ tmp[math3d::matrix::dc] = v[math3d::vector::z];
+*/
+
+ worldMatrix_ *= translationmatrix(v);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
+
+//
+// scale
+//
+void shape::scale(math3d::vector const& v)
+{
+/* matrix tmp;
+
+ tmp[math3d::matrix::aa] = v[math3d::vector::x];
+ tmp[math3d::matrix::bb] = v[math3d::vector::y];
+ tmp[math3d::matrix::cc] = v[math3d::vector::z];
+*/
+
+ worldMatrix_ *= scalingmatrix(v);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
+
+//
+// rotate
+//
+void shape::rotate(math3d::vector const& v, double w)
+{
+/* matrix tmp;
+
+ double const cosW(std::cos(w));
+ double const sinW(std::sin(w));
+ double const x = v[math3d::vector::x];
+ double const y = v[math3d::vector::y];
+ double const z = v[math3d::vector::z];
+ double const tmp = 1 - cosW;
+
+ tmp[math3d::matrix::aa] = cosW + x * x * tmp;
+ tmp[math3d::matrix::ab] = x * y * tmp + y * sinW;
+ tmp[math3d::matrix::ac] = x * z * tmp - y * sinW;
+ tmp[math3d::matrix::ba] = x * y * tmp - z * sinW;
+ tmp[math3d::matrix::bb] = cosW + y * y * tmp;
+ tmp[math3d::matrix::bc] = y * z * tmp + x * sinW;
+ tmp[math3d::matrix::ca] = x * z * tmp + y * sinW;
+ tmp[math3d::matrix::cb] = y * z * tmp - x * sinW;
+ tmp[math3d::matrix::cc] = cosW + z * z * tmp;
+*/
+
+ worldMatrix_ *= rotationmatrix(v,w);
+ worldMatrixInvers_ = inverse(worldMatrix_);
+}
+//
+
+
+
+
+
+
+
+
+
+
diff --git a/Raytracer1108/src/sphere.cpp b/Raytracer1108/src/sphere.cpp
new file mode 100644
index 0000000..58ee42f
--- /dev/null
+++ b/Raytracer1108/src/sphere.cpp
@@ -0,0 +1,120 @@
+
+
+#include "sphere.hpp"
+
+//
+// Konstruktoren
+//
+sphere::sphere() {}
+
+sphere::sphere(math3d::point const& c, double r, std::string const& name, material const& mat, math3d::matrix const& matr, math3d::matrix const& matrInv) :
+ shape(name, mat, matr, matrInv) ,
+ center_(c) ,
+ radius_(r) {}
+
+sphere::sphere(sphere const& sp) :
+ shape(sp) ,
+ center_(sp.center_) ,
+ radius_(sp.radius_) {}
+
+sphere::~sphere() {}
+//
+
+
+//
+// volume - Berechnung Kugelvolumen
+//
+double sphere::volume() const
+{
+ return pow(radius_,3)*4/3*M_PI;
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool sphere::isInside(math3d::point const& p) const
+{
+ return ( (sqrt(pow(center_[math3d::point::x]-p[math3d::point::x],2) + pow(center_[math3d::point::y]-p[math3d::point::y],2) + pow(center_[math3d::point::z]-p[math3d::point::z],2))) <= radius_);
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double sphere::surface() const
+{
+ return 4* radius_ * radius_ * M_PI;
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void sphere::printOn(std::ostream& stream) const
+{
+ stream << "\nSphere:\n";
+ shape::printOn(stream);
+ stream << "Mittelpunkt: (" << center_[math3d::point::x] << "," << center_[math3d::point::y] << "," << center_[math3d::point::z] << ")\n";
+ stream << "Radius: " << radius_ << "\n";
+}
+//
+
+
+//
+// clone
+//
+sphere* sphere::clone() const
+{
+ return new sphere(*this);
+}
+//
+
+
+//
+// intersection
+//
+double sphere::intersection(ray const& ray) const
+{
+ //Strahl transformieren
+ //Multiplikation mit inverser Matrix der Sphere
+
+ //quadratische gl
+ double a = math3d::dot(ray.direction_, ray.direction_);
+ double b = 2 * (math3d::dot(ray.origin_ , ray.direction_));
+ double c = (math3d::dot(ray.origin_ , ray.origin_)) - (radius_*radius_);
+
+ double under_sqrt = (b * b) - 4 * c;
+
+ if(under_sqrt < 0)
+ {
+ return ~0;
+ }
+ else if (under_sqrt > 0)
+ {
+ double i_1 = 0.5 * (-b - sqrt(under_sqrt)) / a;
+ double i_2 = 0.5 * (-b + sqrt(under_sqrt)) / a;
+
+ if(i_1 >= i_2)
+ return i_1;
+ else
+ return i_2;
+ }
+ else
+ {
+ double i_1 = -(0.5 * b) / a;
+
+ return i_1;
+ }
+}
+//
+
+
+
+
+
+
+
diff --git a/Raytracer1108/src/transform.cpp b/Raytracer1108/src/transform.cpp
new file mode 100644
index 0000000..bbe4792
--- /dev/null
+++ b/Raytracer1108/src/transform.cpp
@@ -0,0 +1,65 @@
+#include "transform.hpp"
+
+//
+// translate
+//
+math3d::matrix translationmatrix(math3d::vector const& v)
+{
+ math3d::matrix tmp;
+
+ tmp[math3d::matrix::da] = v[math3d::vector::x];
+ tmp[math3d::matrix::db] = v[math3d::vector::y];
+ tmp[math3d::matrix::dc] = v[math3d::vector::z];
+
+ return tmp;
+};
+//
+
+
+//
+// rotate
+//
+math3d::matrix rotationmatrix(math3d::vector const& v, double w)
+{
+ math3d::matrix tmp;
+
+ double const cosW(std::cos(w));
+ double const sinW(std::sin(w));
+ double const x = v[math3d::vector::x];
+ double const y = v[math3d::vector::y];
+ double const z = v[math3d::vector::z];
+ double const einsMinusCosW = 1 - cosW;
+
+ tmp[math3d::matrix::aa] = cosW + x * x * einsMinusCosW;
+ tmp[math3d::matrix::ab] = x * y * einsMinusCosW + y * sinW;
+ tmp[math3d::matrix::ac] = x * z * einsMinusCosW - y * sinW;
+ tmp[math3d::matrix::ba] = x * y * einsMinusCosW - z * sinW;
+ tmp[math3d::matrix::bb] = cosW + y * y * einsMinusCosW;
+ tmp[math3d::matrix::bc] = y * z * einsMinusCosW + x * sinW;
+ tmp[math3d::matrix::ca] = x * z * einsMinusCosW + y * sinW;
+ tmp[math3d::matrix::cb] = y * z * einsMinusCosW - x * sinW;
+ tmp[math3d::matrix::cc] = cosW + z * z * einsMinusCosW;
+
+ return tmp;
+};
+//
+
+
+//
+// scale
+//
+math3d::matrix scalingmatrix(math3d::vector const& v)
+{
+ math3d::matrix tmp;
+
+ tmp[math3d::matrix::aa] = v[math3d::vector::x];
+ tmp[math3d::matrix::bb] = v[math3d::vector::y];
+ tmp[math3d::matrix::cc] = v[math3d::vector::z];
+
+ return tmp;
+};
+//
+
+
+
+
diff --git a/Raytracer1108/src/vector.cpp b/Raytracer1108/src/vector.cpp
new file mode 100644
index 0000000..7569d19
--- /dev/null
+++ b/Raytracer1108/src/vector.cpp
@@ -0,0 +1,253 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : vector.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "vector.hpp"
+
+// includes, system
+
+#include <algorithm> // std::swap_ranges
+#include <cmath> // std::sqrt
+#include <limits> // std::numeric_limits
+#include <ostream> // std::ostream
+
+// includes, project
+
+#include <point.hpp>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ // functions, internal
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ vector::vector()
+ {
+ data_[0] = data_[1] = data_[2] = data_[3] = 0.0;
+ }
+
+ vector::vector(vector const& a)
+ {
+ data_[0] = a.data_[0];
+ data_[1] = a.data_[1];
+ data_[2] = a.data_[2];
+ data_[3] = a.data_[3];
+ }
+
+ vector::vector(point const& a, point const& b)
+ {
+ data_[0] = b[point::x] - a[point::x];
+ data_[1] = b[point::y] - a[point::y];
+ data_[2] = b[point::z] - a[point::z];
+ data_[3] = 0.0;
+ }
+
+ vector::vector(double a, double b, double c, double d)
+ {
+ data_[0] = a;
+ data_[1] = b;
+ data_[2] = c;
+ data_[3] = d;
+ }
+
+ vector::~vector()
+ {}
+
+ void
+ vector::swap(vector& rhs)
+ {
+ std::swap_ranges(data_, data_+4, rhs.data_);
+ }
+
+ vector&
+ vector::operator=(vector const& rhs)
+ {
+ vector tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ vector::operator[](vector::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ vector::operator[](vector::component idx)
+ {
+ return data_[idx];
+ }
+
+ vector&
+ vector::operator+=(vector const& rhs)
+ {
+ data_[0] += rhs.data_[0];
+ data_[1] += rhs.data_[1];
+ data_[2] += rhs.data_[2];
+ // data_[3] += rhs.data_[3];
+
+ return *this;
+ }
+
+ vector&
+ vector::operator-=(vector const& rhs)
+ {
+ data_[0] -= rhs.data_[0];
+ data_[1] -= rhs.data_[1];
+ data_[2] -= rhs.data_[2];
+ // data_[3] -= rhs.data_[3];
+
+ return *this;
+ }
+
+ vector&
+ vector::operator*=(double rhs)
+ {
+ data_[0] *= rhs;
+ data_[1] *= rhs;
+ data_[2] *= rhs;
+ data_[3] *= rhs;
+
+ return *this;
+ }
+
+ vector&
+ vector::operator/=(double rhs)
+ {
+ data_[0] /= rhs;
+ data_[1] /= rhs;
+ data_[2] /= rhs;
+ data_[3] /= rhs;
+
+ return *this;
+ }
+
+ vector
+ operator-(vector const& rhs)
+ {
+ return vector(rhs) *= -1.0;
+ }
+
+ vector
+ operator+(vector const& lhs, vector const& rhs)
+ {
+ return vector(lhs) += rhs;
+ }
+
+ vector
+ operator-(point const& lhs, point const& rhs)
+ {
+ return vector(rhs, lhs);
+ }
+
+ vector
+ operator-(vector const& lhs, vector const& rhs)
+ {
+ return vector(lhs) -= rhs;
+ }
+
+ vector
+ operator*(vector const& lhs, double rhs)
+ {
+ return vector(lhs) *= rhs;
+ }
+
+ vector
+ operator*(double lhs, vector const& rhs)
+ {
+ return vector(rhs) *= lhs;
+ }
+
+ vector
+ operator/(vector const& lhs, double rhs)
+ {
+ return vector(lhs) /= rhs;
+ }
+
+ double operator*(vector const& lhs, vector const& rhs)
+ {
+ return (lhs[vector::x]*rhs[vector::x]+lhs[vector::y]*rhs[vector::y]+lhs[vector::z]+rhs[vector::z]);
+ }
+
+ /* static */ vector const&
+ vector::null()
+ {
+ static vector null_(0.0, 0.0, 0.0);
+ return null_;
+ }
+
+ /* static */ vector const&
+ vector::unit_x()
+ {
+ static vector unit_x_(1.0, 0.0, 0.0);
+ return unit_x_;
+ }
+
+ /* static */ vector const&
+ vector::unit_y()
+ {
+ static vector unit_y_(0.0, 1.0, 0.0);
+ return unit_y_;
+ }
+
+ /* static */ vector const&
+ vector::unit_z()
+ {
+ static vector unit_z_(0.0, 0.0, 1.0);
+ return unit_z_;
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, vector const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << '['
+ << a[vector::x] << ','
+ << a[vector::y] << ','
+ << a[vector::z] << ','
+ << a[vector::w]
+ << ']';
+ }
+
+ return os;
+ }
+
+ bool
+ operator==(vector const& lhs, vector const& rhs)
+ {
+ return (std::fabs(rhs[vector::x] - lhs[vector::x]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[vector::y] - lhs[vector::y]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[vector::z] - lhs[vector::z]) < std::numeric_limits<double>::epsilon());
+ }
+
+} // namespace math3d {
+
|
mahu/pilse
|
0d32f85c2f0c3daa24d497321b8a203b70023b44
|
Backup 11.8.2010
|
diff --git a/Backup/Raytracer/include/box.hpp b/Backup/Raytracer/include/box.hpp
new file mode 100644
index 0000000..ba2f489
--- /dev/null
+++ b/Backup/Raytracer/include/box.hpp
@@ -0,0 +1,37 @@
+#ifndef _BOX_HPP
+#define _BOX_HPP
+
+#include "shape.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+#include "ray.hpp"
+#include "material.hpp"
+#include <iostream>
+#include <cmath>
+
+
+class box : public shape
+{
+ public:
+ box();
+ box( math3d::point const&, math3d::point const&, std::string const&,rgb const&, material const&);
+ box(box const&);
+ ~box();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(math3d::point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn(std::ostream&) const;
+ /*virtual*/ box* clone() const;
+ double intersection(ray const&) const;
+
+
+
+ private:
+ math3d::point vertexLuv_;
+ math3d::point vertexRoh_;
+};
+
+
+
+#endif /* _BOX_HPP */
diff --git a/Backup/Raytracer/include/camera.hpp b/Backup/Raytracer/include/camera.hpp
new file mode 100644
index 0000000..d1c57b3
--- /dev/null
+++ b/Backup/Raytracer/include/camera.hpp
@@ -0,0 +1,25 @@
+#ifndef __CAMERA_HPP__
+#define __CAMERA_HPP__
+
+
+
+#include <string>
+
+struct camera
+{
+
+ //Konstruktoren
+
+ camera();
+ camera(std::string, double, double);
+
+
+ //Membervariablen
+
+ std::string name_;
+ double fovX_;
+ double fovY_;
+};
+
+
+#endif /* __camera_HPP__ */
diff --git a/Backup/Raytracer/include/glutwindow.hpp b/Backup/Raytracer/include/glutwindow.hpp
new file mode 100644
index 0000000..f3b70e7
--- /dev/null
+++ b/Backup/Raytracer/include/glutwindow.hpp
@@ -0,0 +1,65 @@
+#ifndef BUW_GLUT_WINDOW_HPP
+#define BUW_GLUT_WINDOW_HPP
+
+// header, system
+#include <vector>
+#include <string>
+
+// header, project
+#include <rgb.hpp>
+#include <pixel.hpp>
+
+
+
+class glutwindow {
+public : // typedefs, enums
+ typedef std::vector<rgb> colorbuffer_t;
+
+ ~glutwindow();
+
+private : // do not copy glutwindow
+
+ glutwindow(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[]);
+
+ glutwindow(glutwindow const&);
+
+ glutwindow& operator=(glutwindow const&);
+
+public : // methods
+
+ static void init(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[]);
+ static glutwindow& instance();
+
+ void write(const pixel& p);
+ void update();
+ void run();
+
+ std::size_t width() const;
+ std::size_t height() const;
+ float const& buffer() const;
+
+private: // member
+
+ colorbuffer_t buffer_;
+
+ std::size_t width_;
+ std::size_t height_;
+
+ std::size_t posx_;
+ std::size_t posy_;
+
+ std::string name_;
+};
+
+// external glut callbacks
+void display();
+void reshape(int, int);
+void idle();
+
+#endif // BUW_GLUT_WINDOW_HPP
\ No newline at end of file
diff --git a/Backup/Raytracer/include/material.hpp b/Backup/Raytracer/include/material.hpp
new file mode 100644
index 0000000..f9a2820
--- /dev/null
+++ b/Backup/Raytracer/include/material.hpp
@@ -0,0 +1,31 @@
+#ifndef __MATERIAL_HPP__
+#define __MATERIAL_HPP__
+
+#include "vector.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+
+#include <iostream>
+#include <cmath>
+#include <string>
+
+struct material
+{
+
+ //Konstruktoren
+
+ material();
+ material(std::string, rgb, rgb, rgb, double);
+
+
+ //Membervariablen
+
+ std::string name_;
+ rgb reflexionAmbient_;
+ rgb reflexionDiffuse_;
+ rgb reflexionSpecular_;
+ double expReflexionSpecular_;
+};
+
+
+#endif /* __material_HPP__ */
diff --git a/Backup/Raytracer/include/matrix.hpp b/Backup/Raytracer/include/matrix.hpp
new file mode 100644
index 0000000..2b432ec
--- /dev/null
+++ b/Backup/Raytracer/include/matrix.hpp
@@ -0,0 +1,121 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : matrix.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_MATRIX_HPP)
+
+#define BUW_MATH3D_MATRIX_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+#include <vector.hpp>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point;
+
+ class matrix {
+
+ public:
+
+ enum cols { c0 = vector::x, c1 = vector::y, c2 = vector::z, c3 = vector::w };
+ enum rows { r0 = vector::x, r1 = vector::y, r2 = vector::z, r3 = vector::w };
+
+ // column major element ordering
+ enum component { aa = 0, ba = 4, ca = 8, da = 12,
+ ab = 1, bb = 5, cb = 9, db = 13,
+ ac = 2, bc = 6, cc = 10, dc = 14,
+ ad = 3, bd = 7, cd = 11, dd = 15 };
+
+ matrix();
+ matrix(matrix const&);
+ matrix(double const [16]);
+
+ ~matrix();
+
+ void swap(matrix&);
+
+ matrix& operator=(matrix const&);
+
+ double const& operator()(cols, rows) const;
+ double& operator()(cols, rows);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ matrix& operator*=(matrix const&);
+ matrix& operator*=(double);
+ matrix& operator/=(double);
+
+ double determinant() const;
+ double trace() const;
+
+ bool invert();
+ void transpose();
+ void lr_decompose(matrix& l, matrix& r) const;
+
+ bool is_invertible() const; // det(M) != 0
+
+ static matrix const& null(); // m[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
+ static matrix const& identity(); // m[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
+
+ private:
+
+ double data_[16];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ matrix operator-(matrix const&);
+
+ matrix operator*(matrix const&, matrix const&);
+ matrix operator*(matrix const&, double);
+ matrix operator*(double, matrix const&);
+ matrix operator/(matrix const&, double);
+
+ point operator*(matrix const&, point const&);
+ vector operator*(matrix const&, vector const&);
+
+ bool operator==(matrix const&, matrix const&);
+
+ matrix make_translation(double, double, double);
+ matrix make_translation(vector const&);
+
+ matrix make_scale(double, double, double);
+ matrix make_scale(vector const&);
+
+ matrix make_rotation_x(double);
+ matrix make_rotation_y(double);
+ matrix make_rotation_z(double);
+
+ double determinant(matrix const&);
+ double trace(matrix const&);
+ matrix inverse(matrix const&);
+ matrix transpose(matrix const&);
+
+ bool is_invertible(matrix const&);
+
+ std::ostream& operator<<(std::ostream&, matrix const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_MATRIX_HPP)
diff --git a/Backup/Raytracer/include/pixel.hpp b/Backup/Raytracer/include/pixel.hpp
new file mode 100644
index 0000000..171e414
--- /dev/null
+++ b/Backup/Raytracer/include/pixel.hpp
@@ -0,0 +1,30 @@
+#ifndef BUW_PIXEL_HPP
+#define BUW_PIXEL_HPP
+
+// header, system
+#include <iosfwd>
+
+// header, project
+#include <rgb.hpp>
+
+
+class pixel {
+public : // c'tor
+
+ pixel(std::size_t = 0, std::size_t = 0);
+ ~pixel();
+
+public : // methods
+
+ void print(std::ostream&) const;
+
+public : // member
+
+ std::size_t x;
+ std::size_t y;
+ rgb color;
+};
+
+std::ostream& operator<<(std::ostream&, const pixel&);
+
+#endif // BUW_PIXEL_HPP
diff --git a/Backup/Raytracer/include/point.hpp b/Backup/Raytracer/include/point.hpp
new file mode 100644
index 0000000..a697a41
--- /dev/null
+++ b/Backup/Raytracer/include/point.hpp
@@ -0,0 +1,77 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : point.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_POINT_HPP)
+
+#define BUW_MATH3D_POINT_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+#include <vector.hpp>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point {
+
+ public:
+
+ enum component { x = vector::x, y = vector::y, z = vector::z, w = vector::w };
+
+ point();
+ point(point const&);
+ point(double, double, double, double = 1.0); // x, y, z, w
+
+ ~point();
+
+ void swap(point&);
+
+ point& operator=(point const&);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ point& operator+=(vector const&);
+ point& operator-=(vector const&);
+
+ static point const& origin(); // p[0,0,0,1]
+
+ private:
+
+ double data_[4];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ point operator-(point const&);
+
+ point operator+(point const&, vector const&);
+ point operator-(point const&, vector const&);
+ bool operator==(point const&, point const&);
+
+ double distance(point const&, point const&);
+
+ std::ostream& operator<<(std::ostream&, point const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_POINT_HPP)
diff --git a/Backup/Raytracer/include/ppmwriter.hpp b/Backup/Raytracer/include/ppmwriter.hpp
new file mode 100644
index 0000000..bc5aef2
--- /dev/null
+++ b/Backup/Raytracer/include/ppmwriter.hpp
@@ -0,0 +1,31 @@
+#ifndef BUW_PPMWRITER_HPP
+#define BUW_PPMWRITER_HPP
+
+// header, system
+#include <string>
+#include <vector>
+
+// header, project
+#include <pixel.hpp>
+
+
+class ppmwriter
+{
+public:
+ ppmwriter(std::size_t w, std::size_t h, std::string const& file);
+ ppmwriter(std::size_t w, std::size_t h);
+ ~ppmwriter();
+
+public:
+ void write(pixel const& p);
+ void save(std::string const& file);
+ void save();
+
+private:
+ std::string file_;
+ std::vector<unsigned int> data_;
+ size_t width_;
+ size_t height_;
+};
+
+#endif // BUW_PPMWRITER
diff --git a/Backup/Raytracer/include/ray.hpp b/Backup/Raytracer/include/ray.hpp
new file mode 100644
index 0000000..126552a
--- /dev/null
+++ b/Backup/Raytracer/include/ray.hpp
@@ -0,0 +1,26 @@
+#ifndef __RAY_HPP__
+#define __RAY_HPP__
+
+#include "vector.hpp"
+
+#include <iostream>
+#include <cmath>
+
+struct ray
+{
+
+ //Konstruktoren
+
+ ray();
+ ray(math3d::vector a, math3d::vector b);
+
+
+ //Membervariablen
+
+ math3d::vector origin_;
+ math3d::vector direction_;
+};
+
+
+#endif /* __RAY_HPP__ */
+
diff --git a/Backup/Raytracer/include/rgb.hpp b/Backup/Raytracer/include/rgb.hpp
new file mode 100644
index 0000000..af91357
--- /dev/null
+++ b/Backup/Raytracer/include/rgb.hpp
@@ -0,0 +1,38 @@
+#ifndef BUW_RGB_HPP
+#define BUW_RGB_HPP
+
+// header, system
+#include <iosfwd>
+
+
+class rgb {
+public : // enums, typedefs
+ enum component {r, g, b};
+ typedef float value_t;
+
+public : // c'tor
+ rgb();
+ rgb(rgb const&);
+ rgb(value_t r, value_t g, value_t b);
+
+ ~rgb();
+
+public : // methods
+ void swap(rgb&);
+ void print(std::ostream& os) const;
+
+ value_t& operator[](enum component);
+ const value_t& operator[](enum component) const;
+
+ rgb& operator= (const rgb&);
+ void operator+=(const rgb&);
+
+
+private: // members
+ value_t data_[3]; // rgb
+};
+
+rgb operator+(const rgb& a, const rgb& b);
+std::ostream& operator<<(std::ostream& os, rgb const&);
+
+#endif // BUW_RGB_HPP
diff --git a/Backup/Raytracer/include/shape.hpp b/Backup/Raytracer/include/shape.hpp
new file mode 100644
index 0000000..7dbed9d
--- /dev/null
+++ b/Backup/Raytracer/include/shape.hpp
@@ -0,0 +1,48 @@
+#ifndef _SHAPE_HPP
+#define _SHAPE_HPP
+
+#include "rgb.hpp"
+#include "point.hpp"
+#include "ray.hpp"
+#include "material.hpp"
+
+#include <iostream>
+#include <string>
+
+class shape
+{
+ public:
+ shape();
+ shape(std::string const&, rgb const&, material const&);
+ shape(shape const&);
+ virtual ~shape();
+
+ virtual double volume() const =0;
+ virtual bool isInside(math3d::point const&) const =0;
+ virtual double surface() const =0;
+ virtual shape* clone() const =0;
+ virtual double intersection(ray const&) const =0;
+ rgb getColor() const;
+ std::string getName() const;
+ material getMaterial() const;
+ virtual void printOn(std::ostream& = std::cout) const;
+ int ref();
+ int unRef();
+ // shape* operator=(shape*);
+
+ private:
+
+ rgb color_;
+ std::string name_;
+ int refCount_;
+ material material_;
+
+};
+
+std::ostream& operator<<(std::ostream&, shape const&);
+bool operator==(shape const& lhs, shape const& rhs);
+
+
+
+#endif /* _shape_HPP */
+
diff --git a/Backup/Raytracer/include/sphere.hpp b/Backup/Raytracer/include/sphere.hpp
new file mode 100644
index 0000000..2f2c95c
--- /dev/null
+++ b/Backup/Raytracer/include/sphere.hpp
@@ -0,0 +1,35 @@
+#ifndef _SPHERE_HPP
+#define _SPHERE_HPP
+
+#include "shape.hpp"
+#include "vector.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+#include "ray.hpp"
+
+class sphere : public shape
+{
+ public:
+ sphere();
+ sphere(math3d::point const&, double, std::string const&, rgb const&, material const& );
+ sphere(sphere const&);
+ ~sphere();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(math3d::point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn( std::ostream&) const;
+ /*virtual*/ sphere* clone() const;
+ /*virual*/ double intersection(ray const&) const;
+
+
+ private:
+ math3d::point center_;
+ double radius_;
+
+};
+
+
+
+#endif /* _sphere_HPP */
+
diff --git a/Backup/Raytracer/include/vector.hpp b/Backup/Raytracer/include/vector.hpp
new file mode 100644
index 0000000..bcd985c
--- /dev/null
+++ b/Backup/Raytracer/include/vector.hpp
@@ -0,0 +1,100 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : vector.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_VECTOR_HPP)
+
+#define BUW_MATH3D_VECTOR_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+//#include <>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point;
+
+ class vector {
+
+ public:
+
+ enum component { x = 0, y = 1, z = 2, w = 3 };
+
+ vector();
+ vector(vector const&);
+ vector(point const&, point const&); // second - first
+ vector(double, double, double, double = 0.0); // x, y, z, w
+
+ ~vector();
+
+ void swap(vector&);
+
+ vector& operator=(vector const&);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ vector& operator+=(vector const&);
+ vector& operator-=(vector const&);
+ vector& operator*=(double);
+ vector& operator/=(double);
+
+
+ double length() const;
+ double length_square() const;
+
+ static vector const& null(); // v[0,0,0,0]
+ static vector const& unit_x(); // v[1,0,0,0]
+ static vector const& unit_y(); // v[0,1,0,0]
+ static vector const& unit_z(); // v[0,0,1,0]
+
+ vector& normalize();
+
+ private:
+
+ double data_[4];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ vector operator-(vector const&);
+
+ vector operator+(vector const&, vector const&);
+ vector operator-(point const&, point const&);
+ vector operator-(vector const&, vector const&);
+ vector operator*(vector const&, double);
+ vector operator*(double, vector const&);
+ vector operator/(vector const&, double);
+ bool operator==(vector const&, vector const&);
+
+ double length(vector const&);
+ double length_square(vector const&);
+ double dot(vector const&, vector const&);
+ vector cross(vector const&, vector const&);
+ vector normalize(vector const&);
+
+ std::ostream& operator<<(std::ostream&, vector const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_VECTOR_HPP)
+
diff --git a/Backup/Raytracer/muhaha b/Backup/Raytracer/muhaha
new file mode 100644
index 0000000..cd4bf34
--- /dev/null
+++ b/Backup/Raytracer/muhaha
@@ -0,0 +1 @@
+fdegfeg
diff --git a/Backup/Raytracer/src/Makefile b/Backup/Raytracer/src/Makefile
new file mode 100644
index 0000000..0fc371f
--- /dev/null
+++ b/Backup/Raytracer/src/Makefile
@@ -0,0 +1,26 @@
+FLAGS = -c
+COMPILER = g++
+BFLAGS = -I ../include
+
+default:
+ $(COMPILER) $(FLAGS) point.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) vector.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) shape.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) rgb.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) pixel.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) sphere.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) ray.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) box.cpp $(BFLAGS)
+ rm *.o
+
+intersect:
+ $(COMPILER) $(FLAGS) point.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) vector.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) shape.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) rgb.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) sphere.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) ray.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) intersecttest.cpp $(BFLAGS)
+ $(COMPILER) point.o vector.o shape.o rgb.o sphere.o ray.o intersecttest.o -o intersect
+ rm *.o
+
diff --git a/Backup/Raytracer/src/box.cpp b/Backup/Raytracer/src/box.cpp
new file mode 100644
index 0000000..b856bac
--- /dev/null
+++ b/Backup/Raytracer/src/box.cpp
@@ -0,0 +1,157 @@
+#include "box.hpp"
+
+//
+// Konstruktoren, Destruktor
+//
+box::box():
+ shape("Box",rgb(),material()),
+ vertexLuv_(math3d::point(0,0,0,1)),
+ vertexRoh_(math3d::point(1,1,1,1))
+ {}
+
+box::box(math3d::point const& p1, math3d::point const& p2, std::string const& name,rgb const& col, material const& mat)
+ : shape(name,col,mat) , vertexLuv_ (p1), vertexRoh_ (p2)
+ {}
+
+box::box(box const& bx) : shape(bx) , vertexLuv_(bx.vertexLuv_) , vertexRoh_(bx.vertexRoh_) {}
+
+box::~box() { std::cout << "Destruktor Box\n"; }
+//
+
+
+//
+// volume - Berechnung boxvolumen
+//
+double box::volume() const
+{
+ return std::abs( (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) *
+ (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y]) *
+ (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]) );
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool box::isInside(math3d::point const& p) const
+{
+ return ( (p[math3d::point::x] >= vertexLuv_[math3d::point::x] && p[math3d::point::x] <= vertexRoh_[math3d::point::x]) &&
+ (p[math3d::point::y] >= vertexLuv_[math3d::point::y] && p[math3d::point::y] <= vertexRoh_[math3d::point::y]) &&
+ (p[math3d::point::z] >= vertexLuv_[math3d::point::z] && p[math3d::point::z] <= vertexRoh_[math3d::point::z]) );
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double box::surface() const
+{
+ return ( std::abs(2* (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) * (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y]))
+ + std::abs(2* (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) * (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]))
+ + std::abs(2* (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]) * (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y])) );
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void box::printOn(std::ostream& stream) const
+{
+ stream << "\nBox: \n";
+ shape::printOn(stream);
+ stream << "Vertex Links unten vorne: " << vertexLuv_[math3d::point::x] << " "
+ << vertexLuv_[math3d::point::y] << " " << vertexLuv_[math3d::point::z] << "\n";
+ stream << "Vertex Rechts oben hinten: " << vertexRoh_[math3d::point::x] << " "
+ << vertexRoh_[math3d::point::y] << " " << vertexRoh_[math3d::point::z] << "\n";
+ //stream << "Länge: " << x_ << " , Breite: " << z_ << " , Höhe: " << y_ << "\n";
+ stream << "Volumen: " << volume() << "\nOberfläche: " << surface() << "\n";
+}
+//
+
+
+//
+// clone
+//
+box* box::clone() const
+{
+ return new box(*this);
+}
+//
+
+double box::intersection(ray const& g) const
+{
+
+ double t_x_min= (vertexLuv_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
+
+ double t_x_min_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
+
+ double t_x_min_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
+
+ if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z]<=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
+ {
+ return t_x_min;
+ }
+
+ double t_y_min= (vertexLuv_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
+
+ double t_y_min_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
+
+ double t_y_min_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
+
+ if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z] <=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
+ {
+ return t_y_min;
+ }
+
+ double t_z_min= (vertexLuv_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
+
+ double t_z_min_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
+
+ double t_z_min_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
+
+ if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y] <=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
+ {
+ return t_z_min;
+ }
+
+ double t_x_max= (vertexRoh_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
+
+ double t_x_max_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
+
+ double t_x_max_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
+
+ if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z] <=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
+ {
+ return t_x_max;
+ }
+
+ double t_y_max= (vertexRoh_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
+
+ double t_y_max_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
+
+ double t_y_max_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
+
+ if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z]<=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
+ {
+ return t_y_max;
+ }
+
+ double t_z_max= (vertexRoh_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
+
+ double t_z_max_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
+
+ double t_z_max_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
+
+ if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y]<=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
+ {
+ return t_z_max;
+ }
+
+return ~0;
+
+}
+
+
diff --git a/Backup/Raytracer/src/camera.cpp b/Backup/Raytracer/src/camera.cpp
new file mode 100644
index 0000000..c539246
--- /dev/null
+++ b/Backup/Raytracer/src/camera.cpp
@@ -0,0 +1,7 @@
+#include "camera.hpp"
+
+camera::camera() {}
+
+camera::camera(std::string n, double x, double y) : name_(n) , fovX_(x), fovY_(y) {}
+
+
diff --git a/Backup/Raytracer/src/glutwindow.cpp b/Backup/Raytracer/src/glutwindow.cpp
new file mode 100644
index 0000000..dbcb064
--- /dev/null
+++ b/Backup/Raytracer/src/glutwindow.cpp
@@ -0,0 +1,153 @@
+// header i/f
+#include "glutwindow.hpp"
+
+// header, system
+#if WIN32
+ #include <time.h>
+ #include <windows.h>
+#else
+ #include <sys/time.h>
+#endif
+
+#ifdef __APPLE__
+ #include <GLUT/glut.h>
+#else
+ #include <GL/glut.h>
+#endif
+
+#include <iostream>
+#include <cassert>
+
+// header, project
+
+// globals
+glutwindow* g_glutwindow = 0;
+
+
+////////////////////////////////////////////////////////////////////////////////
+glutwindow::glutwindow(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[])
+ : width_(width),
+ height_(height),
+ posx_(posx),
+ posy_(posy),
+ name_(name)
+{
+ g_glutwindow = this;
+ buffer_.resize(width_ * height_);
+
+ glutInit(&argc,argv);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+
+ glutInitWindowPosition(int(posx_), int(posy_));
+ glutInitWindowSize(int(width_), int(height_));
+ glutCreateWindow(name_.c_str());
+
+ glutDisplayFunc(display);
+ glutReshapeFunc(reshape);
+ glutIdleFunc(idle);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+glutwindow::~glutwindow()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/*static*/ glutwindow&
+glutwindow::instance()
+{
+ assert(g_glutwindow);
+ return *g_glutwindow;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/*static*/ void
+glutwindow::init(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[])
+{
+ static glutwindow instance(width, height, posx, posy, name, argc, argv);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::run()
+{
+ glutMainLoop();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t
+glutwindow::width() const {
+ return width_;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t
+glutwindow::height() const {
+ return height_;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::write(const pixel& p)
+{
+ // flip pixels, because of opengl glDrawPixels
+ size_t buf_pos = (width_*p.y + (p.x));
+ if (buf_pos >= buffer_.size() || (int)buf_pos < 0) {
+ std::cerr << "Fatal Error glutwindow::write(pixel p) : pixel out of image : " << (int)p.x << "," << (int)p.y << std::endl;
+ } else {
+ buffer_[buf_pos] = p.color;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::update()
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glDrawPixels(width_, height_, GL_RGB, GL_FLOAT, &(buffer_.front()));
+ glutSwapBuffers();
+
+ // upate only with 25Hz
+#if WIN32
+ Sleep(20);
+#else
+ usleep(20000);
+#endif
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void display()
+{
+ glutwindow::instance().update();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void reshape(int w, int h)
+{
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void idle()
+{
+ glutPostRedisplay();
+}
diff --git a/Backup/Raytracer/src/intersect b/Backup/Raytracer/src/intersect
new file mode 100755
index 0000000..c1ef81b
Binary files /dev/null and b/Backup/Raytracer/src/intersect differ
diff --git a/Backup/Raytracer/src/intersecttest.cpp b/Backup/Raytracer/src/intersecttest.cpp
new file mode 100644
index 0000000..ff47db9
--- /dev/null
+++ b/Backup/Raytracer/src/intersecttest.cpp
@@ -0,0 +1,21 @@
+#include"sphere.hpp"
+#include"ray.hpp"
+#include"point.hpp"
+#include"iostream"
+
+int main()
+{
+
+math3d::vector a(-5,0,0,0);
+math3d::vector c(-4,0,0,0);
+math3d::point b(0,0,0,1);
+
+sphere s(b,1,"kugel",rgb(1,2,3));
+ray x(a,c);
+
+s.printOn(std::cout);
+std::cout<<s.intersection(x)<<std::endl;
+
+
+return 0;
+}
diff --git a/Backup/Raytracer/src/main.cpp b/Backup/Raytracer/src/main.cpp
new file mode 100644
index 0000000..a6df1a9
--- /dev/null
+++ b/Backup/Raytracer/src/main.cpp
@@ -0,0 +1,90 @@
+#include <glutwindow.hpp>
+#include <ppmwriter.hpp>
+#include <pixel.hpp>
+
+#include <iostream>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#ifdef __APPLE__
+ #include <GLUT/glut.h>
+#else
+ #include <GL/glut.h>
+#endif
+
+// this is a dummy raytrace application
+class rt_application
+{
+public :
+
+ //
+ void raytrace() const
+ {
+ // size of a tile in checkerboard
+ const std::size_t checkersize = 20;
+
+ // get glutwindow instance
+ glutwindow& gw = glutwindow::instance();
+
+ // create a ppmwriter
+ ppmwriter pw(gw.width(), gw.height(), "./checkerboard.ppm");
+
+ // for all pixels of window
+ for (std::size_t y = 0; y < gw.height(); ++y) {
+ for (std::size_t x = 0; x < gw.width(); ++x) {
+
+ // create pixel at x,y
+ pixel p(x, y);
+
+ // compute color for pixel
+ if ( ((x/checkersize)%2) != ((y/checkersize)%2)) {
+ p.color = rgb(1.0, 1.0, float(x)/gw.height());
+ } else {
+ p.color = rgb(1.0, 0.0, float(y)/gw.width());
+ }
+
+ // write pixel to output window
+ gw.write(p);
+
+ // write pixel to image writer
+ pw.write(p);
+ }
+ }
+
+ // save final image
+ pw.save();
+ }
+
+private : // attributes
+
+ // you may add a scene description here
+
+};
+
+
+
+
+
+int main(int argc, char* argv[])
+{
+ // set resolution and checkersize
+ const std::size_t width = 400;
+ const std::size_t height = 400;
+
+ // create output window
+ glutwindow::init(width, height, 100, 100, "CheckerBoard", argc, argv);
+
+ // create a ray tracing application
+ rt_application app;
+
+ // start computation in thread
+ boost::thread thr(boost::bind(&rt_application::raytrace, &app));
+
+ // start output on glutwindow
+ glutwindow::instance().run();
+
+ // wait on thread
+ thr.join();
+
+ return 0;
+}
diff --git a/Backup/Raytracer/src/material.cpp b/Backup/Raytracer/src/material.cpp
new file mode 100644
index 0000000..d4ffb4a
--- /dev/null
+++ b/Backup/Raytracer/src/material.cpp
@@ -0,0 +1,12 @@
+#include "material.hpp"
+
+material::material() {}
+
+material::material(std::string n, rgb ra, rgb rd, rgb rs, double ers) :
+ name_(n) ,
+ reflexionAmbient_(ra),
+ reflexionDiffuse_(rd),
+ reflexionSpecular_(rs),
+ expReflexionSpecular_(ers) {}
+
+
diff --git a/Backup/Raytracer/src/matrix.cpp b/Backup/Raytracer/src/matrix.cpp
new file mode 100644
index 0000000..2f97c0b
--- /dev/null
+++ b/Backup/Raytracer/src/matrix.cpp
@@ -0,0 +1,660 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : matrix.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "matrix.hpp"
+
+// includes, system
+
+#include <algorithm> // std::copy, std::swap_ranges
+#include <cmath> // std::cos, std::sin
+#include <iomanip> // std::fixed, std::setprecision
+#include <ostream> // std::ostream
+#include <limits> // std::numeric_limits
+
+// includes, project
+#include <point.hpp>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ double const null_array16[16] = {
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+ };
+
+ double const ident_array16[16] = {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+ };
+
+ // functions, internal
+
+ double
+ det3_helper(double a1, double a2, double a3,
+ double b1, double b2, double b3,
+ double c1, double c2, double c3)
+ {
+ return ((a1 * b2 * c3) + (a2 * b3 * c1) + (a3 * b1 * c2) -
+ (a1 * b3 * c2) - (a2 * b1 * c3) - (a3 * b2 * c1));
+ }
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ matrix::matrix()
+ {
+ std::copy(ident_array16, ident_array16+16, data_);
+ }
+
+ matrix::matrix(matrix const& rhs)
+ {
+ std::copy(rhs.data_, rhs.data_+16, data_);
+ }
+
+ matrix::matrix(double const a[16])
+ {
+ std::copy(a, a+16, data_);
+ }
+
+ matrix::~matrix()
+ {}
+
+ void
+ matrix::swap(matrix& rhs)
+ {
+ std::swap_ranges(data_, data_+16, rhs.data_);
+ }
+
+ matrix&
+ matrix::operator=(matrix const& rhs)
+ {
+ matrix tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ matrix::operator()(matrix::cols a, matrix::rows b) const
+ {
+ return data_[(b * 4) + a];
+ }
+
+ double&
+ matrix::operator()(matrix::cols a, matrix::rows b)
+ {
+ return data_[(b * 4) + a];
+ }
+
+ double const&
+ matrix::operator[](matrix::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ matrix::operator[](matrix::component idx)
+ {
+ return data_[idx];
+ }
+
+ matrix&
+ matrix::operator*=(matrix const& rhs)
+ {
+ matrix tmp;
+
+ tmp.data_[ 0] = (data_[ 0] * rhs.data_[ 0] +
+ data_[ 4] * rhs.data_[ 1] +
+ data_[ 8] * rhs.data_[ 2] +
+ data_[12] * rhs.data_[ 3]);
+ tmp.data_[ 1] = (data_[ 1] * rhs.data_[ 0] +
+ data_[ 5] * rhs.data_[ 1] +
+ data_[ 9] * rhs.data_[ 2] +
+ data_[13] * rhs.data_[ 3]);
+ tmp.data_[ 2] = (data_[ 2] * rhs.data_[ 0] +
+ data_[ 6] * rhs.data_[ 1] +
+ data_[10] * rhs.data_[ 2] +
+ data_[14] * rhs.data_[ 3]);
+ tmp.data_[ 3] = (data_[ 3] * rhs.data_[ 0] +
+ data_[ 7] * rhs.data_[ 1] +
+ data_[11] * rhs.data_[ 2] +
+ data_[15] * rhs.data_[ 3]);
+ tmp.data_[ 4] = (data_[ 0] * rhs.data_[ 4] +
+ data_[ 4] * rhs.data_[ 5] +
+ data_[ 8] * rhs.data_[ 6] +
+ data_[12] * rhs.data_[ 7]);
+ tmp.data_[ 5] = (data_[ 1] * rhs.data_[ 4] +
+ data_[ 5] * rhs.data_[ 5] +
+ data_[ 9] * rhs.data_[ 6] +
+ data_[13] * rhs.data_[ 7]);
+ tmp.data_[ 6] = (data_[ 2] * rhs.data_[ 4] +
+ data_[ 6] * rhs.data_[ 5] +
+ data_[10] * rhs.data_[ 6] +
+ data_[14] * rhs.data_[ 7]);
+ tmp.data_[ 7] = (data_[ 3] * rhs.data_[ 4] +
+ data_[ 7] * rhs.data_[ 5] +
+ data_[11] * rhs.data_[ 6] +
+ data_[15] * rhs.data_[ 7]);
+ tmp.data_[ 8] = (data_[ 0] * rhs.data_[ 8] +
+ data_[ 4] * rhs.data_[ 9] +
+ data_[ 8] * rhs.data_[10] +
+ data_[12] * rhs.data_[11]);
+ tmp.data_[ 9] = (data_[ 1] * rhs.data_[ 8] +
+ data_[ 5] * rhs.data_[ 9] +
+ data_[ 9] * rhs.data_[10] +
+ data_[13] * rhs.data_[11]);
+ tmp.data_[10] = (data_[ 2] * rhs.data_[ 8] +
+ data_[ 6] * rhs.data_[ 9] +
+ data_[10] * rhs.data_[10] +
+ data_[14] * rhs.data_[11]);
+ tmp.data_[11] = (data_[ 3] * rhs.data_[ 8] +
+ data_[ 7] * rhs.data_[ 9] +
+ data_[11] * rhs.data_[10] +
+ data_[15] * rhs.data_[11]);
+ tmp.data_[12] = (data_[ 0] * rhs.data_[12] +
+ data_[ 4] * rhs.data_[13] +
+ data_[ 8] * rhs.data_[14] +
+ data_[12] * rhs.data_[15]);
+ tmp.data_[13] = (data_[ 1] * rhs.data_[12] +
+ data_[ 5] * rhs.data_[13] +
+ data_[ 9] * rhs.data_[14] +
+ data_[13] * rhs.data_[15]);
+ tmp.data_[14] = (data_[ 2] * rhs.data_[12] +
+ data_[ 6] * rhs.data_[13] +
+ data_[10] * rhs.data_[14] +
+ data_[14] * rhs.data_[15]);
+ tmp.data_[15] = (data_[ 3] * rhs.data_[12] +
+ data_[ 7] * rhs.data_[13] +
+ data_[11] * rhs.data_[14] +
+ data_[15] * rhs.data_[15]);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ matrix&
+ matrix::operator*=(double rhs)
+ {
+ for (unsigned idx = 0; idx < 16; ++idx)
+ data_[idx] *= rhs;
+
+ return *this;
+ }
+
+ matrix&
+ matrix::operator/=(double rhs)
+ {
+ for (unsigned idx = 0; idx < 16; ++idx)
+ data_[idx] /= rhs;
+
+ return *this;
+ }
+
+ double
+ matrix::determinant() const
+ {
+ double const& a1(data_[ 0]);
+ double const& b1(data_[ 4]);
+ double const& c1(data_[ 8]);
+ double const& d1(data_[12]);
+
+ double const& a2(data_[ 1]);
+ double const& b2(data_[ 5]);
+ double const& c2(data_[ 9]);
+ double const& d2(data_[13]);
+
+ double const& a3(data_[ 2]);
+ double const& b3(data_[ 6]);
+ double const& c3(data_[10]);
+ double const& d3(data_[14]);
+
+ double const& a4(data_[ 3]);
+ double const& b4(data_[ 7]);
+ double const& c4(data_[11]);
+ double const& d4(data_[15]);
+
+ return (a1 * det3_helper(b2, b3, b4, c2, c3, c4, d2, d3, d4) -
+ b1 * det3_helper(a2, a3, a4, c2, c3, c4, d2, d3, d4) +
+ c1 * det3_helper(a2, a3, a4, b2, b3, b4, d2, d3, d4) -
+ d1 * det3_helper(a2, a3, a4, b2, b3, b4, c2, c3, c4));
+ }
+
+ double
+ matrix::trace() const
+ {
+ return data_[0] + data_[5] + data_[10] + data_[15];
+ }
+
+ bool
+ matrix::invert()
+ {
+ bool result(false);
+ double const d(determinant());
+
+ if (0.0 != d) {
+ double const& a1(data_[ 0]);
+ double const& b1(data_[ 4]);
+ double const& c1(data_[ 8]);
+ double const& d1(data_[12]);
+ double const& a2(data_[ 1]);
+ double const& b2(data_[ 5]);
+ double const& c2(data_[ 9]);
+ double const& d2(data_[13]);
+ double const& a3(data_[ 2]);
+ double const& b3(data_[ 6]);
+ double const& c3(data_[10]);
+ double const& d3(data_[14]);
+ double const& a4(data_[ 3]);
+ double const& b4(data_[ 7]);
+ double const& c4(data_[11]);
+ double const& d4(data_[15]);
+
+ double const di(1.0 / d);
+
+ matrix tmp;
+
+ tmp.data_[ 0] = det3_helper(b2, b3, b4, c2, c3, c4, d2, d3, d4) * di;
+ tmp.data_[ 1] = -det3_helper(a2, a3, a4, c2, c3, c4, d2, d3, d4) * di;
+ tmp.data_[ 2] = det3_helper(a2, a3, a4, b2, b3, b4, d2, d3, d4) * di;
+ tmp.data_[ 3] = -det3_helper(a2, a3, a4, b2, b3, b4, c2, c3, c4) * di;
+ tmp.data_[ 4] = -det3_helper(b1, b3, b4, c1, c3, c4, d1, d3, d4) * di;
+ tmp.data_[ 5] = det3_helper(a1, a3, a4, c1, c3, c4, d1, d3, d4) * di;
+ tmp.data_[ 6] = -det3_helper(a1, a3, a4, b1, b3, b4, d1, d3, d4) * di;
+ tmp.data_[ 7] = det3_helper(a1, a3, a4, b1, b3, b4, c1, c3, c4) * di;
+ tmp.data_[ 8] = det3_helper(b1, b2, b4, c1, c2, c4, d1, d2, d4) * di;
+ tmp.data_[ 9] = -det3_helper(a1, a2, a4, c1, c2, c4, d1, d2, d4) * di;
+ tmp.data_[10] = det3_helper(a1, a2, a4, b1, b2, b4, d1, d2, d4) * di;
+ tmp.data_[11] = -det3_helper(a1, a2, a4, b1, b2, b4, c1, c2, c4) * di;
+ tmp.data_[12] = -det3_helper(b1, b2, b3, c1, c2, c3, d1, d2, d3) * di;
+ tmp.data_[13] = det3_helper(a1, a2, a3, c1, c2, c3, d1, d2, d3) * di;
+ tmp.data_[14] = -det3_helper(a1, a2, a3, b1, b2, b3, d1, d2, d3) * di;
+ tmp.data_[15] = det3_helper(a1, a2, a3, b1, b2, b3, c1, c2, c3) * di;
+
+ swap(tmp);
+
+ result = true;
+ }
+
+ return result;
+ }
+
+ void
+ matrix::transpose()
+ {
+ matrix tmp(*this);
+
+ // data_[ 0] = tmp.data_[ 0];
+ data_[ 1] = tmp.data_[ 4];
+ data_[ 2] = tmp.data_[ 8];
+ data_[ 3] = tmp.data_[12];
+ data_[ 4] = tmp.data_[ 1];
+ // data_[ 5] = tmp.data_[ 5];
+ data_[ 6] = tmp.data_[ 9];
+ data_[ 7] = tmp.data_[13];
+ data_[ 8] = tmp.data_[ 2];
+ data_[ 9] = tmp.data_[ 6];
+ // data_[10] = tmp.data_[10];
+ data_[11] = tmp.data_[14];
+ data_[12] = tmp.data_[ 3];
+ data_[13] = tmp.data_[ 7];
+ data_[14] = tmp.data_[11];
+ // data_[15] = tmp.data_[15];
+ }
+
+
+ void
+ matrix::lr_decompose(matrix& l, matrix& r) const
+ {
+ // initialise matrices
+ r = *this;
+ l = matrix::identity();
+
+ // first row
+ double const q1 = r[ab] / r[aa];
+ double const q2 = r[ac] / r[aa];
+ double const q3 = r[ad] / r[aa];
+
+ r[ab] -= q1 * r[aa];
+ r[bb] -= q1 * r[ba];
+ r[cb] -= q1 * r[ca];
+ r[db] -= q1 * r[da];
+
+ r[ac] -= q2 * r[aa];
+ r[bc] -= q2 * r[ba];
+ r[cc] -= q2 * r[ca];
+ r[dc] -= q2 * r[da];
+
+ r[ad] -= q3 * r[aa];
+ r[bd] -= q3 * r[ba];
+ r[cd] -= q3 * r[ca];
+ r[dd] -= q3 * r[da];
+
+ l[ab] = q1;
+ l[ac] = q2;
+ l[ad] = q3;
+
+ // second row
+ double const q4 = r[bc] / r[bb];
+ double const q5 = r[bd] / r[bb];
+
+ r[bc] -= q4 * r[bb];
+ r[cc] -= q4 * r[cb];
+ r[dc] -= q4 * r[db];
+
+ r[bd] -= q5 * r[bc];
+ r[cd] -= q5 * r[cc];
+ r[dd] -= q5 * r[dc];
+
+ l[bc] = q4;
+ l[bd] = q5;
+
+ // third row
+ double q6 = r[cd] / r[cc];
+ r[cd] -= q6 * r[cc];
+ r[dd] -= q6 * r[dc];
+ l[cd] = q6;
+ }
+
+ bool
+ matrix::is_invertible() const
+ {
+ return 0 != determinant();
+ }
+
+ /* static */
+ matrix const&
+ matrix::null()
+ {
+ static matrix null_(null_array16);
+ return null_;
+ }
+
+ /* static */
+ matrix const&
+ matrix::identity()
+ {
+ static matrix identity_(ident_array16);
+ return identity_;
+ }
+
+ matrix
+ operator-(matrix const& rhs)
+ {
+ return matrix(rhs) *= -1.0;
+ }
+
+ matrix
+ operator*(matrix const& lhs, matrix const& rhs)
+ {
+ return matrix(lhs) *= rhs;
+ }
+
+ matrix
+ operator*(matrix const& lhs, double rhs)
+ {
+ return matrix(lhs) *= rhs;
+ }
+
+ matrix
+ operator*(double lhs, matrix const& rhs)
+ {
+ return matrix(rhs) *= lhs;
+ }
+
+ matrix
+ operator/(matrix const& lhs, double rhs)
+ {
+ return matrix(lhs) /= rhs;
+ }
+
+ point
+ operator*(matrix const& lhs, const point& rhs)
+ {
+ return point(lhs[matrix::aa] * rhs[point::x] +
+ lhs[matrix::ba] * rhs[point::y] +
+ lhs[matrix::ca] * rhs[point::z] +
+ lhs[matrix::da] * rhs[point::w],
+ lhs[matrix::ab] * rhs[point::x] +
+ lhs[matrix::bb] * rhs[point::y] +
+ lhs[matrix::cb] * rhs[point::z] +
+ lhs[matrix::db] * rhs[point::w],
+ lhs[matrix::ac] * rhs[point::x] +
+ lhs[matrix::bc] * rhs[point::y] +
+ lhs[matrix::cc] * rhs[point::z] +
+ lhs[matrix::dc] * rhs[point::w],
+ lhs[matrix::ad] * rhs[point::x] +
+ lhs[matrix::bd] * rhs[point::y] +
+ lhs[matrix::cd] * rhs[point::z] +
+ lhs[matrix::dd] * rhs[point::w]);
+ }
+
+ vector
+ operator*(matrix const& lhs, const vector& rhs)
+ {
+ return vector(lhs[matrix::aa] * rhs[vector::x] +
+ lhs[matrix::ba] * rhs[vector::y] +
+ lhs[matrix::ca] * rhs[vector::z] +
+ lhs[matrix::da] * rhs[vector::w],
+ lhs[matrix::ab] * rhs[vector::x] +
+ lhs[matrix::bb] * rhs[vector::y] +
+ lhs[matrix::cb] * rhs[vector::z] +
+ lhs[matrix::db] * rhs[vector::w],
+ lhs[matrix::ac] * rhs[vector::x] +
+ lhs[matrix::bc] * rhs[vector::y] +
+ lhs[matrix::cc] * rhs[vector::z] +
+ lhs[matrix::dc] * rhs[vector::w],
+ lhs[matrix::ad] * rhs[vector::x] +
+ lhs[matrix::bd] * rhs[vector::y] +
+ lhs[matrix::cd] * rhs[vector::z] +
+ lhs[matrix::dd] * rhs[vector::w]);
+ }
+
+ bool
+ operator==(matrix const& lhs, matrix const& rhs)
+ {
+ return (std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon());
+ }
+
+ matrix
+ make_translation(double a, double b, double c)
+ {
+ matrix tmp;
+
+ tmp[matrix::da] = a;
+ tmp[matrix::db] = b;
+ tmp[matrix::dc] = c;
+
+ return tmp;
+ }
+
+ matrix
+ make_translation(vector const& a)
+ {
+ return make_translation(a[vector::x], a[vector::y], a[vector::z]);
+ }
+
+ matrix
+ make_scale(double a, double b, double c)
+ {
+ matrix tmp;
+
+ tmp[matrix::aa] = a;
+ tmp[matrix::bb] = b;
+ tmp[matrix::cc] = c;
+
+ return tmp;
+ }
+
+ matrix
+ make_scale(vector const& a)
+ {
+ return make_scale(a[vector::x], a[vector::y], a[vector::z]);
+ }
+
+ matrix
+ make_rotation_x(double a)
+ {
+ double const cos_a(std::cos(a));
+ double const sin_a(std::sin(a));
+
+ matrix tmp;
+
+ tmp[matrix::bb] = cos_a;
+ tmp[matrix::cb] = sin_a;
+ tmp[matrix::bc] = -sin_a;
+ tmp[matrix::cc] = cos_a;
+
+ return tmp;
+ }
+
+ matrix
+ make_rotation_y(double a)
+ {
+ double const cos_a(std::cos(a));
+ double const sin_a(std::sin(a));
+
+ matrix tmp;
+
+ tmp[matrix::aa] = cos_a;
+ tmp[matrix::ca] = -sin_a;
+ tmp[matrix::ac] = sin_a;
+ tmp[matrix::cc] = cos_a;
+
+ return tmp;
+ }
+
+ matrix
+ make_rotation_z(double a)
+ {
+ double const cos_a(std::cos(a));
+ double const sin_a(std::sin(a));
+
+ matrix tmp;
+
+ tmp[matrix::aa] = cos_a;
+ tmp[matrix::ba] = sin_a;
+ tmp[matrix::ab] = -sin_a;
+ tmp[matrix::bb] = cos_a;
+
+ return tmp;
+ }
+
+ double
+ determinant(matrix const& a)
+ {
+ return a.determinant();
+ }
+
+ double
+ trace(matrix const& a)
+ {
+ return a.trace();
+ }
+
+ matrix
+ inverse(matrix const& a)
+ {
+ matrix tmp(a);
+
+ tmp.invert();
+
+ return tmp;
+ }
+
+ matrix
+ transpose(matrix const& a)
+ {
+ matrix tmp(a);
+
+ tmp.transpose();
+
+ return tmp;
+ }
+
+ bool
+ is_invertible(matrix const& a)
+ {
+ return a.is_invertible();
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, matrix const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << std::fixed << std::setprecision(3)
+ << '['
+ << a[matrix::aa] << ','
+ << a[matrix::ba] << ','
+ << a[matrix::ca] << ','
+ << a[matrix::da] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ab] << ','
+ << a[matrix::bb] << ','
+ << a[matrix::cb] << ','
+ << a[matrix::db] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ac] << ','
+ << a[matrix::bc] << ','
+ << a[matrix::cc] << ','
+ << a[matrix::dc] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ad] << ','
+ << a[matrix::bd] << ','
+ << a[matrix::cd] << ','
+ << a[matrix::dd]
+ << ']';
+ }
+
+ return os;
+ }
+
+} // namespace math3d {
diff --git a/Backup/Raytracer/src/pixel.cpp b/Backup/Raytracer/src/pixel.cpp
new file mode 100644
index 0000000..691ff5f
--- /dev/null
+++ b/Backup/Raytracer/src/pixel.cpp
@@ -0,0 +1,39 @@
+// header i/f
+#include "pixel.hpp"
+
+// header, system
+#include <ostream>
+
+
+pixel::pixel(std::size_t a, std::size_t b)
+ : x(a),
+ y(b),
+ color()
+{}
+
+
+///////////////////////////////////////////////////////////////////////////////
+pixel::~pixel()
+{}
+
+
+///////////////////////////////////////////////////////////////////////////////
+void
+pixel::print(std::ostream& os) const
+{
+ os << "pixel[" << (int)x << ',' << (int)y << "]("
+ << color[rgb::r] << ','
+ << color[rgb::g] << ','
+ << color[rgb::b] << ')';
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+std::ostream&
+operator<<(std::ostream& os, const pixel& a)
+{
+ std::ostream::sentry cerberus (os);
+ if (cerberus)
+ a.print(os);
+ return os;
+}
\ No newline at end of file
diff --git a/Backup/Raytracer/src/point.cpp b/Backup/Raytracer/src/point.cpp
new file mode 100644
index 0000000..1d32432
--- /dev/null
+++ b/Backup/Raytracer/src/point.cpp
@@ -0,0 +1,179 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : point.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "point.hpp"
+
+// includes, system
+
+#include <algorithm> // std::swap_ranges
+#include <cmath> // std::abs
+#include <limits> // std::numeric_limits
+#include <ostream> // std::ostream
+
+// includes, project
+
+// #include <>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ // functions, internal
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ point::point()
+ {
+ data_[0] = data_[1] = data_[2] = 0.0; data_[3] = 1.0;
+ }
+
+ point::point(point const& a)
+ {
+ data_[0] = a.data_[0];
+ data_[1] = a.data_[1];
+ data_[2] = a.data_[2];
+ data_[3] = a.data_[3];
+ }
+
+ point::point(double a, double b, double c, double d)
+ {
+ data_[0] = a;
+ data_[1] = b;
+ data_[2] = c;
+ data_[3] = d;
+ }
+
+ point::~point()
+ {}
+
+ void
+ point::swap(point& rhs)
+ {
+ std::swap_ranges(data_, data_+4, rhs.data_);
+ }
+
+ point&
+ point::operator=(point const& rhs)
+ {
+ point tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ point::operator[](point::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ point::operator[](point::component idx)
+ {
+ return data_[idx];
+ }
+
+ point&
+ point::operator+=(vector const& rhs)
+ {
+ data_[point::x] += rhs[vector::x];
+ data_[point::y] += rhs[vector::y];
+ data_[point::z] += rhs[vector::z];
+ // data_[point::w] += rhs[vector::w];
+
+ return *this;
+ }
+
+ point&
+ point::operator-=(vector const& rhs)
+ {
+ data_[point::x] -= rhs[vector::x];
+ data_[point::y] -= rhs[vector::y];
+ data_[point::z] -= rhs[vector::z];
+ // data_[point::w] -= rhs[vector::w];
+
+ return *this;
+ }
+
+ /* static */ point const&
+ point::origin()
+ {
+ static point origin_(0.0, 0.0, 0.0);
+ return origin_;
+ }
+
+ point
+ operator-(point const& rhs)
+ {
+ return point(-rhs[point::x], -rhs[point::y], -rhs[point::z], rhs[point::w]);
+ }
+
+ point
+ operator+(point const& lhs, vector const& rhs)
+ {
+ return point(lhs) += rhs;
+ }
+
+ point
+ operator-(point const& lhs, vector const& rhs)
+ {
+ return point(lhs) -= rhs;
+ }
+
+ double
+ distance(point const& a, point const& b)
+ {
+ return std::abs(length(vector(a, b)));
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, point const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << '['
+ << a[point::x] << ','
+ << a[point::y] << ','
+ << a[point::z] << ','
+ << a[point::w]
+ << ']';
+ }
+
+ return os;
+ }
+
+ bool
+ operator==(point const& lhs, point const& rhs)
+ {
+ return (std::fabs(rhs[point::x] - lhs[point::x]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[point::y] - lhs[point::y]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[point::z] - lhs[point::z]) < std::numeric_limits<double>::epsilon());
+ }
+
+
+} // namespace math3d {
diff --git a/Backup/Raytracer/src/ppmwriter.cpp b/Backup/Raytracer/src/ppmwriter.cpp
new file mode 100644
index 0000000..2b892bf
--- /dev/null
+++ b/Backup/Raytracer/src/ppmwriter.cpp
@@ -0,0 +1,81 @@
+// header i/f
+#include "ppmwriter.hpp"
+
+// header, system
+#include <iostream>
+#include <fstream>
+#include <cmath>
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::ppmwriter(std::size_t w, std::size_t h, std::string const& file)
+ : file_(file),
+ width_(w),
+ height_(h) {
+ data_.resize(w * h * (sizeof(rgb)/sizeof(rgb::value_t)));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::ppmwriter(std::size_t w, std::size_t h)
+ : file_("untitled.ppm"),
+ width_(w),
+ height_(h) {
+ data_.resize(w*h*(sizeof(rgb)/sizeof(rgb::value_t)));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::~ppmwriter()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::write(pixel const& p)
+{
+ size_t buf_pos = width_*p.y + p.x;
+ std::size_t pos = (sizeof(rgb)/sizeof(rgb::value_t)) * buf_pos;
+ if (pos + ((sizeof(rgb)/sizeof(rgb::value_t)) - 1) > data_.size() || (int)buf_pos < 0) {
+ std::cerr << "Fatal Error ppmwriter::write(pixel p) : Critical write position\n";
+ } else {
+ data_[pos] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::r], 255.0));
+ data_[pos+1] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::g], 255.0));
+ data_[pos+2] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::b], 255.0));
+ }
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::save(std::string const& file)
+{
+ file_ = file;
+ save();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::save()
+{
+ const std::size_t line_length = 18;
+
+ std::fstream file(file_.c_str(), std::ios::out);
+ file.clear();
+ file << "P3 "
+ << (unsigned int)width_ << " "
+ << (unsigned int)height_ << " "
+ << 255 << " \n";
+
+ std::size_t pos = 1;
+ for (std::vector<unsigned int>::iterator i = data_.begin();
+ i < data_.end();
+ ++i, ++pos)
+ {
+ file << (int)*i << " ";
+ if (pos > line_length) {
+ file << "\n";
+ pos=0;
+ }
+ }
+
+ file.close();
+}
\ No newline at end of file
diff --git a/Backup/Raytracer/src/ray.cpp b/Backup/Raytracer/src/ray.cpp
new file mode 100644
index 0000000..b28db43
--- /dev/null
+++ b/Backup/Raytracer/src/ray.cpp
@@ -0,0 +1,24 @@
+#include "ray.hpp"
+
+ray::ray() :
+ origin_(0,0,0,0),
+ direction_(0,0,1,0) {}
+
+ray::ray(math3d::vector o,math3d::vector d) :
+ origin_(o) ,
+ direction_(d) {}
+
+/*{
+ //Normalisieren des Richtungsvektors
+
+ double laenge_dir = std::sqrt(std::pow(direction_[math3d::vector::x],2) +
+ std::pow(direction_[math3d::vector::y],2) +
+ std::pow(direction_[math3d::vector::z],2) );
+
+ if(laenge_dir != 1)
+ {
+ direction_ = direction_/laenge_dir;
+ }
+}*/
+
+
diff --git a/Backup/Raytracer/src/rgb.cpp b/Backup/Raytracer/src/rgb.cpp
new file mode 100644
index 0000000..cd8b355
--- /dev/null
+++ b/Backup/Raytracer/src/rgb.cpp
@@ -0,0 +1,116 @@
+// header i/f
+#include "rgb.hpp"
+
+// header, system
+#include <iostream>
+
+// header, project
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb()
+{
+ data_[0] = 0;
+ data_[1] = 0;
+ data_[2] = 0;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb(rgb const& rhs)
+{
+ data_[0] = rhs.data_[0];
+ data_[1] = rhs.data_[1];
+ data_[2] = rhs.data_[2];
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb(float r, float g, float b)
+{
+ data_[0] = r;
+ data_[1] = g;
+ data_[2] = b;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::~rgb()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::swap(rgb& rhs)
+{
+ std::swap(data_[0], rhs.data_[0]);
+ std::swap(data_[1], rhs.data_[1]);
+ std::swap(data_[2], rhs.data_[2]);
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::print(std::ostream& os) const
+{
+ os << '(' << data_[0] << '|' << data_[1] << '|' << data_[2] << ')' << std::endl;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::value_t&
+rgb::operator[](enum rgb::component c)
+{
+ return data_[c];
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+const rgb::value_t&
+rgb::operator[](enum rgb::component c) const
+{
+ return data_[c];
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb&
+rgb::operator=(rgb const& rhs)
+{
+ rgb tmp(rhs);
+ swap(tmp);
+ return *this;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::operator+=(rgb const& a)
+{
+ data_[0]+=a.data_[0];
+ data_[1]+=a.data_[1];
+ data_[2]+=a.data_[2];
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb
+operator+(rgb const& a, rgb const& b)
+{
+ rgb result(a);
+ result += b;
+ return result;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::ostream&
+operator<<(std::ostream& os, rgb const& color)
+{
+ color.print(os);
+ return os;
+}
diff --git a/Backup/Raytracer/src/shape.cpp b/Backup/Raytracer/src/shape.cpp
new file mode 100644
index 0000000..37db1c1
--- /dev/null
+++ b/Backup/Raytracer/src/shape.cpp
@@ -0,0 +1,105 @@
+#include "shape.hpp"
+
+
+shape::shape() : refCount_(0) {}
+shape::shape(std::string const& s, rgb const& col, material const& mat) :
+ color_(col) ,
+ name_(s) ,
+ refCount_(0),
+ material_(mat) {}
+shape::shape(shape const& sh) :
+ color_(sh.color_) ,
+ name_(sh.name_),
+ refCount_(0),
+ material_(sh.material_) {}
+
+shape::~shape() {}
+
+
+//
+// getmaterial
+//
+material shape::getMaterial() const
+{
+ return material_;
+}
+//
+
+
+//
+// getcolor
+//
+rgb shape::getColor() const
+{
+ return color_;
+}
+
+
+//
+// getname
+//
+std::string shape::getName() const
+{
+ return name_;
+}
+//
+
+
+//
+// printOn
+//
+void shape::printOn( std::ostream& stream) const
+{
+ stream << "Name: " << name_ << ", Farbe: (" << color_[rgb::r] << "," << color_[rgb::g] << "," << color_[rgb::b] << ")\n";
+}
+//
+
+std::ostream& operator<<(std::ostream& stream, shape const& sh)
+{
+ sh.printOn(stream);
+ return stream;
+}
+
+bool operator==(shape const& lhs, shape const& rhs)
+{
+ return lhs.getName() == rhs.getName();
+}
+
+
+//
+// ref
+//
+int shape::ref()
+{
+ return ++refCount_;
+}
+//
+
+
+//
+// unRef
+//
+int shape::unRef()
+{
+ --refCount_;
+ if (refCount_ <= 0)
+ {
+ delete this;
+ return 0;
+ }
+ return refCount_;
+}
+//
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Backup/Raytracer/src/sphere.cpp b/Backup/Raytracer/src/sphere.cpp
new file mode 100644
index 0000000..6b58846
--- /dev/null
+++ b/Backup/Raytracer/src/sphere.cpp
@@ -0,0 +1,124 @@
+
+#include<cmath>
+#include "sphere.hpp"
+
+//
+// Konstruktoren
+//
+sphere::sphere() {}
+sphere::sphere(math3d::point const& c, double r, std::string const& name, rgb const& col, material const& mat) :
+ shape(name, col, mat) ,
+ center_(c) ,
+ radius_(r)
+ {}
+sphere::sphere(sphere const& sp) :
+ shape(sp) ,
+ center_(sp.center_) ,
+ radius_(sp.radius_) {}
+
+sphere::~sphere() {}
+//
+
+
+//
+// volume - Berechnung Kugelvolumen
+//
+double sphere::volume() const
+{
+ return pow(radius_,3)*4/3*M_PI;
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool sphere::isInside(math3d::point const& p) const
+{
+ return ( (sqrt(pow(center_[math3d::point::x]-p[math3d::point::x],2) + pow(center_[math3d::point::y]-p[math3d::point::y],2) + pow(center_[math3d::point::z]-p[math3d::point::z],2))) <= radius_);
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double sphere::surface() const
+{
+ return 4* radius_ * radius_ * M_PI;
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void sphere::printOn(std::ostream& stream) const
+{
+ stream << "\nSphere:\n";
+ shape::printOn(stream);
+ stream << "Mittelpunkt: (" << center_[math3d::point::x] << "," << center_[math3d::point::y] << "," << center_[math3d::point::z] << ")\n";
+ stream << "Radius: " << radius_ << "\n";
+}
+//
+
+
+//
+// clone
+//
+sphere* sphere::clone() const
+{
+ return new sphere(*this);
+}
+//
+
+
+
+
+//
+// intersection
+//
+double sphere::intersection(ray const& g) const
+
+{
+ //Strahl transformieren
+ //Multiplikation mit inverser Matrix der Sphere
+
+ //quadratische gl
+
+ double a = math3d::dot(g.direction_, g.direction_);
+ double b = 2 * (math3d::dot(g.origin_ , g.direction_));
+ double c = (math3d::dot(g.origin_ , g.origin_)) - (radius_*radius_);
+
+
+ double under_sqrt = (b * b) - 4 * c;
+
+ if(under_sqrt < 0)
+ {
+ return ~0;
+ }
+ else if (under_sqrt > 0)
+ {
+ double i_1 = 0.5 * (-b - sqrt(under_sqrt)) / a;
+ double i_2 = 0.5 * (-b + sqrt(under_sqrt)) / a;
+
+ if(i_1 >= i_2)
+ return i_1;
+ else
+ return i_2;
+ }
+ else
+ {
+ double i_1 = -(0.5 * b) / a;
+
+ return i_1;
+ }
+}
+//
+
+
+
+
+
+
+
diff --git a/Backup/Raytracer/src/test b/Backup/Raytracer/src/test
new file mode 100755
index 0000000..1132629
Binary files /dev/null and b/Backup/Raytracer/src/test differ
diff --git a/Backup/Raytracer/src/vector.cpp b/Backup/Raytracer/src/vector.cpp
new file mode 100644
index 0000000..61d09b2
--- /dev/null
+++ b/Backup/Raytracer/src/vector.cpp
@@ -0,0 +1,309 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : vector.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "vector.hpp"
+
+// includes, system
+
+#include <algorithm> // std::swap_ranges
+#include <cmath> // std::sqrt
+#include <limits> // std::numeric_limits
+#include <ostream> // std::ostream
+
+// includes, project
+
+#include <point.hpp>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ // functions, internal
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ vector::vector()
+ {
+ data_[0] = data_[1] = data_[2] = data_[3] = 0.0;
+ }
+
+ vector::vector(vector const& a)
+ {
+ data_[0] = a.data_[0];
+ data_[1] = a.data_[1];
+ data_[2] = a.data_[2];
+ data_[3] = a.data_[3];
+ }
+
+ vector::vector(point const& a, point const& b)
+ {
+ data_[0] = b[point::x] - a[point::x];
+ data_[1] = b[point::y] - a[point::y];
+ data_[2] = b[point::z] - a[point::z];
+ data_[3] = 0.0;
+ }
+
+ vector::vector(double a, double b, double c, double d)
+ {
+ data_[0] = a;
+ data_[1] = b;
+ data_[2] = c;
+ data_[3] = d;
+ }
+
+ vector::~vector()
+ {}
+
+ void
+ vector::swap(vector& rhs)
+ {
+ std::swap_ranges(data_, data_+4, rhs.data_);
+ }
+
+ vector&
+ vector::operator=(vector const& rhs)
+ {
+ vector tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ vector::operator[](vector::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ vector::operator[](vector::component idx)
+ {
+ return data_[idx];
+ }
+
+ vector&
+ vector::operator+=(vector const& rhs)
+ {
+ data_[0] += rhs.data_[0];
+ data_[1] += rhs.data_[1];
+ data_[2] += rhs.data_[2];
+ // data_[3] += rhs.data_[3];
+
+ return *this;
+ }
+
+ vector&
+ vector::operator-=(vector const& rhs)
+ {
+ data_[0] -= rhs.data_[0];
+ data_[1] -= rhs.data_[1];
+ data_[2] -= rhs.data_[2];
+ // data_[3] -= rhs.data_[3];
+
+ return *this;
+ }
+
+ vector&
+ vector::operator*=(double rhs)
+ {
+ data_[0] *= rhs;
+ data_[1] *= rhs;
+ data_[2] *= rhs;
+ data_[3] *= rhs;
+
+ return *this;
+ }
+
+ vector&
+ vector::operator/=(double rhs)
+ {
+ data_[0] /= rhs;
+ data_[1] /= rhs;
+ data_[2] /= rhs;
+ data_[3] /= rhs;
+
+ return *this;
+ }
+
+ double
+ vector::length() const
+ {
+ return std::sqrt(length_square());
+ }
+
+ double
+ vector::length_square() const
+ {
+ return dot(*this, *this);
+ }
+
+ vector&
+ vector::normalize()
+ {
+ vector tmp(*this);
+
+ tmp /= length();
+
+ swap(tmp);
+ return *this;
+ }
+
+ vector
+ operator-(vector const& rhs)
+ {
+ return vector(rhs) *= -1.0;
+ }
+
+ vector
+ operator+(vector const& lhs, vector const& rhs)
+ {
+ return vector(lhs) += rhs;
+ }
+
+ vector
+ operator-(point const& lhs, point const& rhs)
+ {
+ return vector(rhs, lhs);
+ }
+
+ vector
+ operator-(vector const& lhs, vector const& rhs)
+ {
+ return vector(lhs) -= rhs;
+ }
+
+ vector
+ operator*(vector const& lhs, double rhs)
+ {
+ return vector(lhs) *= rhs;
+ }
+
+ vector
+ operator*(double lhs, vector const& rhs)
+ {
+ return vector(rhs) *= lhs;
+ }
+
+ vector
+ operator/(vector const& lhs, double rhs)
+ {
+ return vector(lhs) /= rhs;
+ }
+
+ double
+ length(vector const& a)
+ {
+ return a.length();
+ }
+
+ double
+ length_square(vector const& a)
+ {
+ return a.length_square();
+ }
+
+ /* static */ vector const&
+ vector::null()
+ {
+ static vector null_(0.0, 0.0, 0.0);
+ return null_;
+ }
+
+ /* static */ vector const&
+ vector::unit_x()
+ {
+ static vector unit_x_(1.0, 0.0, 0.0);
+ return unit_x_;
+ }
+
+ /* static */ vector const&
+ vector::unit_y()
+ {
+ static vector unit_y_(0.0, 1.0, 0.0);
+ return unit_y_;
+ }
+
+ /* static */ vector const&
+ vector::unit_z()
+ {
+ static vector unit_z_(0.0, 0.0, 1.0);
+ return unit_z_;
+ }
+
+ double
+ dot(vector const& lhs, vector const& rhs)
+ {
+ return ((lhs[vector::x] * rhs[vector::x]) +
+ (lhs[vector::y] * rhs[vector::y]) +
+ (lhs[vector::z] * rhs[vector::z]));
+ }
+
+ vector
+ cross(vector const& lhs, vector const& rhs)
+ {
+ return vector(((lhs[vector::y] * rhs[vector::z]) - (lhs[vector::z] * rhs[vector::y])),
+ ((lhs[vector::z] * rhs[vector::x]) - (lhs[vector::x] * rhs[vector::z])),
+ ((lhs[vector::x] * rhs[vector::y]) - (lhs[vector::y] * rhs[vector::x])));
+ }
+
+ vector
+ normalize(vector const& a)
+ {
+ vector tmp(a);
+
+ tmp.normalize();
+
+ return tmp;
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, vector const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << '['
+ << a[vector::x] << ','
+ << a[vector::y] << ','
+ << a[vector::z] << ','
+ << a[vector::w]
+ << ']';
+ }
+
+ return os;
+ }
+
+ bool
+ operator==(vector const& lhs, vector const& rhs)
+ {
+ return (std::fabs(rhs[vector::x] - lhs[vector::x]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[vector::y] - lhs[vector::y]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[vector::z] - lhs[vector::z]) < std::numeric_limits<double>::epsilon());
+ }
+
+} // namespace math3d {
+
|
mahu/pilse
|
92e3735b8c85ac6446d538ed2db8ee5e587da76c
|
c'tor angepasst
|
diff --git a/Raytracer/include/box.hpp b/Raytracer/include/box.hpp
index 00faeaa..ba2f489 100644
--- a/Raytracer/include/box.hpp
+++ b/Raytracer/include/box.hpp
@@ -1,36 +1,37 @@
#ifndef _BOX_HPP
#define _BOX_HPP
#include "shape.hpp"
#include "point.hpp"
#include "rgb.hpp"
#include "ray.hpp"
+#include "material.hpp"
#include <iostream>
#include <cmath>
class box : public shape
{
public:
box();
- box( math3d::point const&, math3d::point const&, std::string const&, rgb const&);
+ box( math3d::point const&, math3d::point const&, std::string const&,rgb const&, material const&);
box(box const&);
~box();
/*virtual*/ double volume() const;
/*virtual*/ bool isInside(math3d::point const&) const;
/*virtual*/ double surface() const;
/*virtual*/ void printOn(std::ostream&) const;
/*virtual*/ box* clone() const;
- double intersection(ray) const;
+ double intersection(ray const&) const;
private:
math3d::point vertexLuv_;
math3d::point vertexRoh_;
};
#endif /* _BOX_HPP */
diff --git a/Raytracer/src/box.cpp b/Raytracer/src/box.cpp
index 15a1ab5..b856bac 100644
--- a/Raytracer/src/box.cpp
+++ b/Raytracer/src/box.cpp
@@ -1,153 +1,157 @@
#include "box.hpp"
//
// Konstruktoren, Destruktor
//
-box::box() { std::cout << "Konstruktor Box\n"; }
+box::box():
+ shape("Box",rgb(),material()),
+ vertexLuv_(math3d::point(0,0,0,1)),
+ vertexRoh_(math3d::point(1,1,1,1))
+ {}
-box::box(math3d::point const& p1, math3d::point const& p2, std::string const& name, rgb const& col)
- : shape(name,col) , vertexLuv_ (p1), vertexRoh_ (p2)
- { std::cout << "Konstruktor Box\n"; }
+box::box(math3d::point const& p1, math3d::point const& p2, std::string const& name,rgb const& col, material const& mat)
+ : shape(name,col,mat) , vertexLuv_ (p1), vertexRoh_ (p2)
+ {}
box::box(box const& bx) : shape(bx) , vertexLuv_(bx.vertexLuv_) , vertexRoh_(bx.vertexRoh_) {}
box::~box() { std::cout << "Destruktor Box\n"; }
//
//
// volume - Berechnung boxvolumen
//
double box::volume() const
{
return std::abs( (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) *
(vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y]) *
(vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]) );
}
//
//
// isInside - Kollision
//
bool box::isInside(math3d::point const& p) const
{
return ( (p[math3d::point::x] >= vertexLuv_[math3d::point::x] && p[math3d::point::x] <= vertexRoh_[math3d::point::x]) &&
(p[math3d::point::y] >= vertexLuv_[math3d::point::y] && p[math3d::point::y] <= vertexRoh_[math3d::point::y]) &&
(p[math3d::point::z] >= vertexLuv_[math3d::point::z] && p[math3d::point::z] <= vertexRoh_[math3d::point::z]) );
}
//
//
// surface - Berechnung Oberfläche
//
double box::surface() const
{
return ( std::abs(2* (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) * (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y]))
+ std::abs(2* (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) * (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]))
+ std::abs(2* (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]) * (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y])) );
}
//
//
// printOn - Ausgabe
//
void box::printOn(std::ostream& stream) const
{
stream << "\nBox: \n";
shape::printOn(stream);
stream << "Vertex Links unten vorne: " << vertexLuv_[math3d::point::x] << " "
<< vertexLuv_[math3d::point::y] << " " << vertexLuv_[math3d::point::z] << "\n";
stream << "Vertex Rechts oben hinten: " << vertexRoh_[math3d::point::x] << " "
<< vertexRoh_[math3d::point::y] << " " << vertexRoh_[math3d::point::z] << "\n";
//stream << "Länge: " << x_ << " , Breite: " << z_ << " , Höhe: " << y_ << "\n";
stream << "Volumen: " << volume() << "\nOberfläche: " << surface() << "\n";
}
//
//
// clone
//
box* box::clone() const
{
return new box(*this);
}
//
-double box::intersection(ray g) const
+double box::intersection(ray const& g) const
{
double t_x_min= (vertexLuv_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
double t_x_min_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
double t_x_min_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z]<=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
{
return t_x_min;
}
double t_y_min= (vertexLuv_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
double t_y_min_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
double t_y_min_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z] <=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
{
return t_y_min;
}
double t_z_min= (vertexLuv_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
double t_z_min_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
double t_z_min_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y] <=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
{
return t_z_min;
}
double t_x_max= (vertexRoh_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
double t_x_max_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
double t_x_max_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z] <=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
{
return t_x_max;
}
double t_y_max= (vertexRoh_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
double t_y_max_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
double t_y_max_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z]<=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
{
return t_y_max;
}
double t_z_max= (vertexRoh_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
double t_z_max_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
double t_z_max_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y]<=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
{
return t_z_max;
}
return ~0;
}
|
mahu/pilse
|
b2cf18a79100fc366cf1242ed31dedaa2d54fadf
|
eingerückt :)
|
diff --git a/Raytracer/src/box.cpp b/Raytracer/src/box.cpp
index 81443dc..15a1ab5 100644
--- a/Raytracer/src/box.cpp
+++ b/Raytracer/src/box.cpp
@@ -1,154 +1,153 @@
#include "box.hpp"
//
// Konstruktoren, Destruktor
//
box::box() { std::cout << "Konstruktor Box\n"; }
box::box(math3d::point const& p1, math3d::point const& p2, std::string const& name, rgb const& col)
: shape(name,col) , vertexLuv_ (p1), vertexRoh_ (p2)
{ std::cout << "Konstruktor Box\n"; }
box::box(box const& bx) : shape(bx) , vertexLuv_(bx.vertexLuv_) , vertexRoh_(bx.vertexRoh_) {}
box::~box() { std::cout << "Destruktor Box\n"; }
//
//
// volume - Berechnung boxvolumen
//
double box::volume() const
{
return std::abs( (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) *
(vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y]) *
(vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]) );
}
//
//
// isInside - Kollision
//
bool box::isInside(math3d::point const& p) const
{
return ( (p[math3d::point::x] >= vertexLuv_[math3d::point::x] && p[math3d::point::x] <= vertexRoh_[math3d::point::x]) &&
(p[math3d::point::y] >= vertexLuv_[math3d::point::y] && p[math3d::point::y] <= vertexRoh_[math3d::point::y]) &&
(p[math3d::point::z] >= vertexLuv_[math3d::point::z] && p[math3d::point::z] <= vertexRoh_[math3d::point::z]) );
}
//
//
// surface - Berechnung Oberfläche
//
double box::surface() const
{
return ( std::abs(2* (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) * (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y]))
+ std::abs(2* (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) * (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]))
+ std::abs(2* (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]) * (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y])) );
}
//
//
// printOn - Ausgabe
//
void box::printOn(std::ostream& stream) const
{
stream << "\nBox: \n";
shape::printOn(stream);
stream << "Vertex Links unten vorne: " << vertexLuv_[math3d::point::x] << " "
<< vertexLuv_[math3d::point::y] << " " << vertexLuv_[math3d::point::z] << "\n";
stream << "Vertex Rechts oben hinten: " << vertexRoh_[math3d::point::x] << " "
<< vertexRoh_[math3d::point::y] << " " << vertexRoh_[math3d::point::z] << "\n";
//stream << "Länge: " << x_ << " , Breite: " << z_ << " , Höhe: " << y_ << "\n";
stream << "Volumen: " << volume() << "\nOberfläche: " << surface() << "\n";
}
//
//
// clone
//
box* box::clone() const
{
return new box(*this);
}
//
double box::intersection(ray g) const
{
-double t_x_min= (vertexLuv_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
-
-double t_x_min_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
-
-double t_x_min_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
-
-if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z]<=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
-{
- return t_x_min;
-}
-
-double t_y_min= (vertexLuv_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
-
-double t_y_min_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
-
-double t_y_min_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
-
-if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z]<=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
-{
- return t_y_min;
-}
-
-double t_z_min= (vertexLuv_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
-
-double t_z_min_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
-
-double t_z_min_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
-
-if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y]<=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
-{
- return t_z_min;
-}
-
-double t_x_max= (vertexRoh_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
-
-double t_x_max_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
-
-double t_x_max_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
-
-if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z]<=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
-{
- return t_x_max;
-}
-double t_y_max= (vertexRoh_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
-
-double t_y_max_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
-
-double t_y_max_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
-
-if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z]<=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
-{
- return t_y_max;
-}
-
-double t_z_max= (vertexRoh_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
-
-double t_z_max_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
-
-double t_z_max_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
-
-if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y]<=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
-{
- return t_z_max;
-}
-
-
+ double t_x_min= (vertexLuv_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
+
+ double t_x_min_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
+
+ double t_x_min_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
+
+ if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z]<=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
+ {
+ return t_x_min;
+ }
+
+ double t_y_min= (vertexLuv_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
+
+ double t_y_min_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
+
+ double t_y_min_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
+
+ if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z] <=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
+ {
+ return t_y_min;
+ }
+
+ double t_z_min= (vertexLuv_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
+
+ double t_z_min_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
+
+ double t_z_min_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
+
+ if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y] <=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
+ {
+ return t_z_min;
+ }
+
+ double t_x_max= (vertexRoh_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
+
+ double t_x_max_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
+
+ double t_x_max_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
+
+ if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z] <=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
+ {
+ return t_x_max;
+ }
+
+ double t_y_max= (vertexRoh_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
+
+ double t_y_max_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
+
+ double t_y_max_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
+
+ if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z]<=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
+ {
+ return t_y_max;
+ }
+
+ double t_z_max= (vertexRoh_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
+
+ double t_z_max_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
+
+ double t_z_max_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
+
+ if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y]<=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
+ {
+ return t_z_max;
+ }
return ~0;
}
|
mahu/pilse
|
efd6b5b0511c3efeb891f4274a064131c4dc8f3f
|
doppeldeklaration von a entfernt
|
diff --git a/Raytracer/src/sphere.cpp b/Raytracer/src/sphere.cpp
index 0fb6b96..a1ade6a 100644
--- a/Raytracer/src/sphere.cpp
+++ b/Raytracer/src/sphere.cpp
@@ -1,107 +1,107 @@
#include<cmath>
#include "sphere.hpp"
//
// Konstruktoren
//
sphere::sphere() {}
sphere::sphere(math3d::point const& c, double r, std::string const& name, rgb const& col) : shape(name, col) , center_(c) , radius_(r)
{}
sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
sphere::~sphere() {}
//
//
// volume - Berechnung Kugelvolumen
//
double sphere::volume() const
{
return pow(radius_,3)*4/3*M_PI;
}
//
//
// isInside - Kollision
//
bool sphere::isInside(math3d::point const& p) const
{
return ( (sqrt(pow(center_[math3d::point::x]-p[math3d::point::x],2) + pow(center_[math3d::point::y]-p[math3d::point::y],2) + pow(center_[math3d::point::z]-p[math3d::point::z],2))) <= radius_);
}
//
//
// surface - Berechnung Oberfläche
//
double sphere::surface() const
{
return 4* radius_ * radius_ * M_PI;
}
//
//
// printOn - Ausgabe
//
void sphere::printOn(std::ostream& stream) const
{
stream << "\nSphere:\n";
shape::printOn(stream);
stream << "Mittelpunkt: (" << center_[math3d::point::x] << "," << center_[math3d::point::y] << "," << center_[math3d::point::z] << ")\n";
stream << "Radius: " << radius_ << "\n";
}
//
//
// clone
//
sphere* sphere::clone() const
{
return new sphere(*this);
}
-double sphere::intersection(ray const& a)
+double sphere::intersection(ray const& g)
{
//Strahl transformieren
//Multiplikation mit inverser Matrix der Sphere
//quadratische gl
- double a = math3d::dot(a.direction_, a.direction_)
- double b = 2 * (math3d::dot(a.origin_ , a.direction_));
- double c = (math3d::dot(a.origin_ , a.origin_)) - (radius_*radius_);
+ double a = math3d::dot(g.direction_, g.direction_);
+ double b = 2 * (math3d::dot(g.origin_ , g.direction_));
+ double c = (math3d::dot(g.origin_ , g.origin_)) - (radius_*radius_);
double under_sqrt = (b * b) - 4 * c;
if(under_sqrt < 0)
{
return ~0;
}
else if (under_sqrt > 0)
{
double i_1 = 0.5 * (-b - sqrt(under_sqrt)) / a;
double i_2 = 0.5 * (-b + sqrt(under_sqrt)) / a;
if(i_1 >= i_2)
return i_1;
else
return i_2;
}
else
{
double i_1 = -(0.5 * b) / a;
return i_1;
}
}
|
mahu/pilse
|
213d9013bcec994c240043374d04eec288c6f826
|
intersection
|
diff --git a/Raytracer/include/box.hpp b/Raytracer/include/box.hpp
new file mode 100644
index 0000000..00faeaa
--- /dev/null
+++ b/Raytracer/include/box.hpp
@@ -0,0 +1,36 @@
+#ifndef _BOX_HPP
+#define _BOX_HPP
+
+#include "shape.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+#include "ray.hpp"
+#include <iostream>
+#include <cmath>
+
+
+class box : public shape
+{
+ public:
+ box();
+ box( math3d::point const&, math3d::point const&, std::string const&, rgb const&);
+ box(box const&);
+ ~box();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(math3d::point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn(std::ostream&) const;
+ /*virtual*/ box* clone() const;
+ double intersection(ray) const;
+
+
+
+ private:
+ math3d::point vertexLuv_;
+ math3d::point vertexRoh_;
+};
+
+
+
+#endif /* _BOX_HPP */
diff --git a/Raytracer/src/box.cpp b/Raytracer/src/box.cpp
new file mode 100644
index 0000000..81443dc
--- /dev/null
+++ b/Raytracer/src/box.cpp
@@ -0,0 +1,154 @@
+#include "box.hpp"
+
+//
+// Konstruktoren, Destruktor
+//
+box::box() { std::cout << "Konstruktor Box\n"; }
+
+box::box(math3d::point const& p1, math3d::point const& p2, std::string const& name, rgb const& col)
+ : shape(name,col) , vertexLuv_ (p1), vertexRoh_ (p2)
+ { std::cout << "Konstruktor Box\n"; }
+
+box::box(box const& bx) : shape(bx) , vertexLuv_(bx.vertexLuv_) , vertexRoh_(bx.vertexRoh_) {}
+
+box::~box() { std::cout << "Destruktor Box\n"; }
+//
+
+
+//
+// volume - Berechnung boxvolumen
+//
+double box::volume() const
+{
+ return std::abs( (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) *
+ (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y]) *
+ (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]) );
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool box::isInside(math3d::point const& p) const
+{
+ return ( (p[math3d::point::x] >= vertexLuv_[math3d::point::x] && p[math3d::point::x] <= vertexRoh_[math3d::point::x]) &&
+ (p[math3d::point::y] >= vertexLuv_[math3d::point::y] && p[math3d::point::y] <= vertexRoh_[math3d::point::y]) &&
+ (p[math3d::point::z] >= vertexLuv_[math3d::point::z] && p[math3d::point::z] <= vertexRoh_[math3d::point::z]) );
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double box::surface() const
+{
+ return ( std::abs(2* (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) * (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y]))
+ + std::abs(2* (vertexLuv_[math3d::point::x]-vertexRoh_[math3d::point::x]) * (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]))
+ + std::abs(2* (vertexLuv_[math3d::point::z]-vertexRoh_[math3d::point::z]) * (vertexLuv_[math3d::point::y]-vertexRoh_[math3d::point::y])) );
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void box::printOn(std::ostream& stream) const
+{
+ stream << "\nBox: \n";
+ shape::printOn(stream);
+ stream << "Vertex Links unten vorne: " << vertexLuv_[math3d::point::x] << " "
+ << vertexLuv_[math3d::point::y] << " " << vertexLuv_[math3d::point::z] << "\n";
+ stream << "Vertex Rechts oben hinten: " << vertexRoh_[math3d::point::x] << " "
+ << vertexRoh_[math3d::point::y] << " " << vertexRoh_[math3d::point::z] << "\n";
+ //stream << "Länge: " << x_ << " , Breite: " << z_ << " , Höhe: " << y_ << "\n";
+ stream << "Volumen: " << volume() << "\nOberfläche: " << surface() << "\n";
+}
+//
+
+
+//
+// clone
+//
+box* box::clone() const
+{
+ return new box(*this);
+}
+//
+
+double box::intersection(ray g) const
+{
+
+double t_x_min= (vertexLuv_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
+
+double t_x_min_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
+
+double t_x_min_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
+
+if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z]<=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
+{
+ return t_x_min;
+}
+
+double t_y_min= (vertexLuv_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
+
+double t_y_min_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
+
+double t_y_min_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
+
+if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z]<=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
+{
+ return t_y_min;
+}
+
+double t_z_min= (vertexLuv_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
+
+double t_z_min_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
+
+double t_z_min_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
+
+if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y]<=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
+{
+ return t_z_min;
+}
+
+double t_x_max= (vertexRoh_[math3d::point::x]/g.direction_[math3d::vector::x])-g.origin_[math3d::vector::x];
+
+double t_x_max_y=g.origin_[math3d::vector::y]+t_x_min*g.direction_[math3d::vector::y];
+
+double t_x_max_z=g.origin_[math3d::vector::z]+t_x_min*g.direction_[math3d::vector::z];
+
+if(vertexLuv_[math3d::point::y]<=t_x_min_y && t_x_min_y<=vertexRoh_[math3d::point::y] && vertexLuv_[math3d::point::z]<=t_x_min_z && t_x_min_z<=vertexRoh_[math3d::point::z])
+{
+ return t_x_max;
+}
+double t_y_max= (vertexRoh_[math3d::point::y]/g.direction_[math3d::vector::y])-g.origin_[math3d::vector::y];
+
+double t_y_max_x=g.origin_[math3d::vector::x]+t_y_min*g.direction_[math3d::vector::x];
+
+double t_y_max_z=g.origin_[math3d::vector::z]+t_y_min*g.direction_[math3d::vector::z];
+
+if(vertexLuv_[math3d::point::x]<=t_y_min_x && t_y_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::z]<=t_y_min_z && t_y_min_z<=vertexRoh_[math3d::point::z])
+{
+ return t_y_max;
+}
+
+double t_z_max= (vertexRoh_[math3d::point::z]/g.direction_[math3d::vector::z])-g.origin_[math3d::vector::z];
+
+double t_z_max_x=g.origin_[math3d::vector::x]+t_z_min*g.direction_[math3d::vector::x];
+
+double t_z_max_y=g.origin_[math3d::vector::y]+t_z_min*g.direction_[math3d::vector::y];
+
+if(vertexLuv_[math3d::point::x]<=t_z_min_x && t_z_min_x<=vertexRoh_[math3d::point::x] && vertexLuv_[math3d::point::y]<=t_z_min_y && t_z_min_y<=vertexRoh_[math3d::point::y])
+{
+ return t_z_max;
+}
+
+
+
+return ~0;
+
+}
+
+
|
mahu/pilse
|
ae069bc394e291b2cc5850a83239e05909359f0b
|
ray, normalisieren auskommentiert
|
diff --git a/Raytracer/src/ray.cpp b/Raytracer/src/ray.cpp
index 9f21f26..eb4fa19 100644
--- a/Raytracer/src/ray.cpp
+++ b/Raytracer/src/ray.cpp
@@ -1,25 +1,24 @@
#include "ray.hpp"
-ray::ray():
+ray::ray() :
origin_(0,0,0,0),
- direction_(0,0,1,0)
-{}
+ direction_(0,0,1,0) {}
-ray::ray(math3d::vector o,math3d::vector d):
- origin_(o),
- direction_(d)
+ray::ray(math3d::vector o,math3d::vector d) :
+ origin_(o) ,
+ direction_(d) {]
-{
+/*{
//Normalisieren des Richtungsvektors
double laenge_dir = std::sqrt(std::pow(direction_[math3d::vector::x],2) +
std::pow(direction_[math3d::vector::y],2) +
std::pow(direction_[math3d::vector::z],2) );
if(laenge_dir != 1)
{
direction_ = direction_/laenge_dir;
}
-}
+}*/
|
mahu/pilse
|
cf4cd2ca034385bb39f795efffacdeb6a8c008b2
|
sphere intersect
|
diff --git a/Raytracer/src/sphere.cpp b/Raytracer/src/sphere.cpp
index 4d2e84c..0fb6b96 100644
--- a/Raytracer/src/sphere.cpp
+++ b/Raytracer/src/sphere.cpp
@@ -1,103 +1,107 @@
#include<cmath>
#include "sphere.hpp"
//
// Konstruktoren
//
sphere::sphere() {}
sphere::sphere(math3d::point const& c, double r, std::string const& name, rgb const& col) : shape(name, col) , center_(c) , radius_(r)
{}
sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
sphere::~sphere() {}
//
//
// volume - Berechnung Kugelvolumen
//
double sphere::volume() const
{
return pow(radius_,3)*4/3*M_PI;
}
//
//
// isInside - Kollision
//
bool sphere::isInside(math3d::point const& p) const
{
return ( (sqrt(pow(center_[math3d::point::x]-p[math3d::point::x],2) + pow(center_[math3d::point::y]-p[math3d::point::y],2) + pow(center_[math3d::point::z]-p[math3d::point::z],2))) <= radius_);
}
//
//
// surface - Berechnung Oberfläche
//
double sphere::surface() const
{
return 4* radius_ * radius_ * M_PI;
}
//
//
// printOn - Ausgabe
//
void sphere::printOn(std::ostream& stream) const
{
stream << "\nSphere:\n";
shape::printOn(stream);
stream << "Mittelpunkt: (" << center_[math3d::point::x] << "," << center_[math3d::point::y] << "," << center_[math3d::point::z] << ")\n";
stream << "Radius: " << radius_ << "\n";
}
//
//
// clone
//
sphere* sphere::clone() const
{
return new sphere(*this);
}
double sphere::intersection(ray const& a)
{
+ //Strahl transformieren
+ //Multiplikation mit inverser Matrix der Sphere
+
//quadratische gl
+ double a = math3d::dot(a.direction_, a.direction_)
double b = 2 * (math3d::dot(a.origin_ , a.direction_));
double c = (math3d::dot(a.origin_ , a.origin_)) - (radius_*radius_);
double under_sqrt = (b * b) - 4 * c;
if(under_sqrt < 0)
{
return ~0;
}
else if (under_sqrt > 0)
{
- double i_1 = 0.5 * (-b - sqrt(under_sqrt));
- double i_2 = 0.5 * (-b + sqrt(under_sqrt));
+ double i_1 = 0.5 * (-b - sqrt(under_sqrt)) / a;
+ double i_2 = 0.5 * (-b + sqrt(under_sqrt)) / a;
if(i_1 >= i_2)
return i_1;
else
return i_2;
}
else
{
- double i_1 = -(0.5 * b);
+ double i_1 = -(0.5 * b) / a;
return i_1;
}
}
|
mahu/pilse
|
0d3a2c5fdf7d902de2727ab8850563616d3c3e66
|
sphere intersect
|
diff --git a/Raytracer/src/sphere.cpp b/Raytracer/src/sphere.cpp
index df33f61..4d2e84c 100644
--- a/Raytracer/src/sphere.cpp
+++ b/Raytracer/src/sphere.cpp
@@ -1,99 +1,103 @@
#include<cmath>
#include "sphere.hpp"
//
// Konstruktoren
//
sphere::sphere() {}
sphere::sphere(math3d::point const& c, double r, std::string const& name, rgb const& col) : shape(name, col) , center_(c) , radius_(r)
{}
sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
sphere::~sphere() {}
//
//
// volume - Berechnung Kugelvolumen
//
double sphere::volume() const
{
return pow(radius_,3)*4/3*M_PI;
}
//
//
// isInside - Kollision
//
bool sphere::isInside(math3d::point const& p) const
{
return ( (sqrt(pow(center_[math3d::point::x]-p[math3d::point::x],2) + pow(center_[math3d::point::y]-p[math3d::point::y],2) + pow(center_[math3d::point::z]-p[math3d::point::z],2))) <= radius_);
}
//
//
// surface - Berechnung Oberfläche
//
double sphere::surface() const
{
return 4* radius_ * radius_ * M_PI;
}
//
//
// printOn - Ausgabe
//
void sphere::printOn(std::ostream& stream) const
{
stream << "\nSphere:\n";
shape::printOn(stream);
stream << "Mittelpunkt: (" << center_[math3d::point::x] << "," << center_[math3d::point::y] << "," << center_[math3d::point::z] << ")\n";
stream << "Radius: " << radius_ << "\n";
}
//
//
// clone
//
sphere* sphere::clone() const
{
return new sphere(*this);
}
double sphere::intersection(ray const& a)
{
- double under_sqrt=((a.origin_*a.origin_)/4)-(a.origin_*a.origin_-pow(radius_,2));
+ //quadratische gl
+ double b = 2 * (math3d::dot(a.origin_ , a.direction_));
+ double c = (math3d::dot(a.origin_ , a.origin_)) - (radius_*radius_);
- if(under_sqrt>0)
+ double under_sqrt = (b * b) - 4 * c;
+
+ if(under_sqrt < 0)
+ {
+ return ~0;
+ }
+ else if (under_sqrt > 0)
{
- double i_1=0.5*(2*(a.origin_*a.direction_))+sqrt(under_sqrt);
- double i_2=0.5*(2*(a.origin_*a.direction_))-sqrt(under_sqrt);
+ double i_1 = 0.5 * (-b - sqrt(under_sqrt));
+ double i_2 = 0.5 * (-b + sqrt(under_sqrt));
- if(i_1>=i_2)
+ if(i_1 >= i_2)
return i_1;
else
- return i_2;
-
-
+ return i_2;
}
- else if (under_sqrt==0)
+ else
{
- double i_1=0.5*(2*(a.origin_*a.direction_));
+ double i_1 = -(0.5 * b);
return i_1;
}
-
- return ~0;
}
|
mahu/pilse
|
6d37a3f15852506afef48ce9c1e1451c46503381
|
aktualisiert
|
diff --git a/Raytracer/src/Makefile b/Raytracer/src/Makefile
new file mode 100644
index 0000000..6473444
--- /dev/null
+++ b/Raytracer/src/Makefile
@@ -0,0 +1,25 @@
+FLAGS = -c
+COMPILER = g++
+BFLAGS = -I ../include
+
+default:
+ $(COMPILER) $(FLAGS) point.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) vector.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) shape.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) rgb.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) pixel.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) sphere.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) ray.cpp $(BFLAGS)
+ rm *.o
+
+intersect:
+ $(COMPILER) $(FLAGS) point.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) vector.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) shape.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) rgb.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) sphere.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) ray.cpp $(BFLAGS)
+ $(COMPILER) $(FLAGS) intersecttest.cpp $(BFLAGS)
+ $(COMPILER) point.o vector.o shape.o rgb.o sphere.o ray.o intersecttest.o -o intersect
+ rm *.o
+
diff --git a/Raytracer/src/intersect b/Raytracer/src/intersect
new file mode 100755
index 0000000..7b9d52f
Binary files /dev/null and b/Raytracer/src/intersect differ
diff --git a/Raytracer/src/intersecttest.cpp b/Raytracer/src/intersecttest.cpp
index e0088bd..ff47db9 100644
--- a/Raytracer/src/intersecttest.cpp
+++ b/Raytracer/src/intersecttest.cpp
@@ -1,21 +1,21 @@
#include"sphere.hpp"
#include"ray.hpp"
#include"point.hpp"
#include"iostream"
int main()
{
-math3d::vector a(0,0,0,0);
-math3d::vector c(3,0,0,0);
-math3d::point b(3,0,0,1);
+math3d::vector a(-5,0,0,0);
+math3d::vector c(-4,0,0,0);
+math3d::point b(0,0,0,1);
sphere s(b,1,"kugel",rgb(1,2,3));
ray x(a,c);
s.printOn(std::cout);
std::cout<<s.intersection(x)<<std::endl;
return 0;
}
diff --git a/Raytracer/src/shape.cpp b/Raytracer/src/shape.cpp
index 3b8147d..771d822 100644
--- a/Raytracer/src/shape.cpp
+++ b/Raytracer/src/shape.cpp
@@ -1,86 +1,86 @@
#include "shape.hpp"
-shape::shape() : refCount_(0) { std::cout << "Konstruktor Shape\n"; }
-shape::shape(std::string const& s, rgb const& col) : color_(col) , name_(s) , refCount_(0) { std::cout << "Konstruktor Shape\n"; }
-shape::shape(shape const& sh) : color_(sh.color_) , name_(sh.name_), refCount_(0) { std::cout << "konstruktor Shape\n"; }
-shape::~shape() { std::cout << "Destruktor Shape\n"; }
+shape::shape() : refCount_(0) {}
+shape::shape(std::string const& s, rgb const& col) : color_(col) , name_(s) , refCount_(0) {}
+shape::shape(shape const& sh) : color_(sh.color_) , name_(sh.name_), refCount_(0) {}
+shape::~shape() {}
//
// getcolor
//
rgb shape::getColor() const
{
return color_;
}
//
// getname
//
std::string shape::getName() const
{
return name_;
}
//
//
// printOn
//
void shape::printOn( std::ostream& stream) const
{
stream << "Name: " << name_ << ", Farbe: (" << color_[rgb::r] << "," << color_[rgb::g] << "," << color_[rgb::b] << ")\n";
}
//
std::ostream& operator<<(std::ostream& stream, shape const& sh)
{
sh.printOn(stream);
return stream;
}
bool operator==(shape const& lhs, shape const& rhs)
{
return lhs.getName() == rhs.getName();
}
//
// ref
//
int shape::ref()
{
return ++refCount_;
}
//
//
// unRef
//
int shape::unRef()
{
--refCount_;
if (refCount_ <= 0)
{
delete this;
return 0;
}
return refCount_;
}
//
diff --git a/Raytracer/src/sphere.cpp b/Raytracer/src/sphere.cpp
index 7f93627..df33f61 100644
--- a/Raytracer/src/sphere.cpp
+++ b/Raytracer/src/sphere.cpp
@@ -1,99 +1,99 @@
#include<cmath>
#include "sphere.hpp"
//
// Konstruktoren
//
sphere::sphere() {}
sphere::sphere(math3d::point const& c, double r, std::string const& name, rgb const& col) : shape(name, col) , center_(c) , radius_(r)
{}
sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
sphere::~sphere() {}
//
//
// volume - Berechnung Kugelvolumen
//
double sphere::volume() const
{
return pow(radius_,3)*4/3*M_PI;
}
//
//
// isInside - Kollision
//
bool sphere::isInside(math3d::point const& p) const
{
return ( (sqrt(pow(center_[math3d::point::x]-p[math3d::point::x],2) + pow(center_[math3d::point::y]-p[math3d::point::y],2) + pow(center_[math3d::point::z]-p[math3d::point::z],2))) <= radius_);
}
//
//
// surface - Berechnung Oberfläche
//
double sphere::surface() const
{
return 4* radius_ * radius_ * M_PI;
}
//
//
// printOn - Ausgabe
//
void sphere::printOn(std::ostream& stream) const
{
stream << "\nSphere:\n";
shape::printOn(stream);
stream << "Mittelpunkt: (" << center_[math3d::point::x] << "," << center_[math3d::point::y] << "," << center_[math3d::point::z] << ")\n";
stream << "Radius: " << radius_ << "\n";
}
//
//
// clone
//
sphere* sphere::clone() const
{
return new sphere(*this);
}
double sphere::intersection(ray const& a)
{
- double under_sqrt=(a.origin_*a.origin_)-4*(a.origin_*a.origin_-pow(radius_,2));
+ double under_sqrt=((a.origin_*a.origin_)/4)-(a.origin_*a.origin_-pow(radius_,2));
if(under_sqrt>0)
{
double i_1=0.5*(2*(a.origin_*a.direction_))+sqrt(under_sqrt);
double i_2=0.5*(2*(a.origin_*a.direction_))-sqrt(under_sqrt);
if(i_1>=i_2)
return i_1;
else
return i_2;
}
else if (under_sqrt==0)
{
double i_1=0.5*(2*(a.origin_*a.direction_));
return i_1;
}
return ~0;
}
diff --git a/Raytracer/src/test b/Raytracer/src/test
new file mode 100755
index 0000000..1132629
Binary files /dev/null and b/Raytracer/src/test differ
|
mahu/pilse
|
93d6043319085d7c26e52fb987495aea8aa52f64
|
neugit add Raytracer/src/sphere.cpp Raytracer/src/intersecttest.cpp Raytracer/include/sphere.hpp
|
diff --git a/Raytracer/src/intersecttest.cpp b/Raytracer/src/intersecttest.cpp
new file mode 100644
index 0000000..e0088bd
--- /dev/null
+++ b/Raytracer/src/intersecttest.cpp
@@ -0,0 +1,21 @@
+#include"sphere.hpp"
+#include"ray.hpp"
+#include"point.hpp"
+#include"iostream"
+
+int main()
+{
+
+math3d::vector a(0,0,0,0);
+math3d::vector c(3,0,0,0);
+math3d::point b(3,0,0,1);
+
+sphere s(b,1,"kugel",rgb(1,2,3));
+ray x(a,c);
+
+s.printOn(std::cout);
+std::cout<<s.intersection(x)<<std::endl;
+
+
+return 0;
+}
diff --git a/Raytracer/src/sphere.cpp b/Raytracer/src/sphere.cpp
index 54ac5e1..7f93627 100644
--- a/Raytracer/src/sphere.cpp
+++ b/Raytracer/src/sphere.cpp
@@ -1,97 +1,99 @@
#include<cmath>
#include "sphere.hpp"
//
// Konstruktoren
//
sphere::sphere() {}
sphere::sphere(math3d::point const& c, double r, std::string const& name, rgb const& col) : shape(name, col) , center_(c) , radius_(r)
{}
sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
sphere::~sphere() {}
//
//
// volume - Berechnung Kugelvolumen
//
double sphere::volume() const
{
return pow(radius_,3)*4/3*M_PI;
}
//
//
// isInside - Kollision
//
bool sphere::isInside(math3d::point const& p) const
{
return ( (sqrt(pow(center_[math3d::point::x]-p[math3d::point::x],2) + pow(center_[math3d::point::y]-p[math3d::point::y],2) + pow(center_[math3d::point::z]-p[math3d::point::z],2))) <= radius_);
}
//
//
// surface - Berechnung Oberfläche
//
double sphere::surface() const
{
return 4* radius_ * radius_ * M_PI;
}
//
//
// printOn - Ausgabe
//
void sphere::printOn(std::ostream& stream) const
{
stream << "\nSphere:\n";
shape::printOn(stream);
stream << "Mittelpunkt: (" << center_[math3d::point::x] << "," << center_[math3d::point::y] << "," << center_[math3d::point::z] << ")\n";
stream << "Radius: " << radius_ << "\n";
}
//
//
// clone
//
sphere* sphere::clone() const
{
return new sphere(*this);
}
double sphere::intersection(ray const& a)
{
- if(sqrt((a.origin_*a.origin_)-4*(a.origin_*a.origin_-pow(radius_,2)))>0)
+ double under_sqrt=(a.origin_*a.origin_)-4*(a.origin_*a.origin_-pow(radius_,2));
+
+ if(under_sqrt>0)
{
- double i_1=0.5*(-(2*(a.origin_*a.direction_))-sqrt((a.origin_*a.origin_)-4*(a.origin_*a.origin_-pow(radius_,2))));
- double i_2=0.5*(-(2*(a.origin_*a.direction_))+sqrt((a.origin_*a.origin_)-4*(a.origin_*a.origin_-pow(radius_,2))));
+ double i_1=0.5*(2*(a.origin_*a.direction_))+sqrt(under_sqrt);
+ double i_2=0.5*(2*(a.origin_*a.direction_))-sqrt(under_sqrt);
- if(i_1<=i_2)
+ if(i_1>=i_2)
return i_1;
else
return i_2;
}
- else if (sqrt((a.origin_*a.origin_)-4*(a.origin_*a.origin_-pow(radius_,2)))==0)
+ else if (under_sqrt==0)
{
- double i_1=0.5*(-(2*(a.origin_*a.direction_))+sqrt((a.origin_*a.origin_)-4*(a.origin_*a.origin_-pow(radius_,2))));
+ double i_1=0.5*(2*(a.origin_*a.direction_));
return i_1;
}
return ~0;
}
|
mahu/pilse
|
f4bc4b9c40a8be66fb2319ace798c2f986932c34
|
ray incl-guard
|
diff --git a/Raytracer/include/ray.hpp b/Raytracer/include/ray.hpp
index 7c539a3..6079d56 100644
--- a/Raytracer/include/ray.hpp
+++ b/Raytracer/include/ray.hpp
@@ -1,20 +1,28 @@
+
+#ifndef __RAY_HPP__
+#define __RAY_HPP__
+
#include "point.hpp"
#include "vector.hpp"
#include <iostream>
#include <cmath>
struct ray
{
//Konstruktoren
ray();
ray(math3d::point a, math3d::vector b);
//Membervariablen
math3d::point origin_;
math3d::vector direction_;
};
+
+
+#endif /* __RAY_HPP__ */
+
|
mahu/pilse
|
0864ba22be047f30c5f9f65450f3579319771ca9
|
Raytracer
|
diff --git a/include/shape.hpp b/include/shape.hpp
index 80192c4..d8bab1f 100644
--- a/include/shape.hpp
+++ b/include/shape.hpp
@@ -1,42 +1,42 @@
#ifndef _SHAPE_HPP
#define _SHAPE_HPP
#include <iostream>
#include <string>
-#include "color.hpp"
-#include "point3d.hpp"
+#include "rgb.hpp"
+#include "point.hpp"
class shape
{
public:
shape();
shape(std::string const&, rgb const&);
shape(shape const&);
virtual ~shape();
virtual double volume() const =0;
- virtual bool isInside(point3d const&) const =0;
+ virtual bool isInside(point const&) const =0;
virtual double surface() const =0;
virtual shape* clone() const =0;
// color getColor() const;
std::string getName() const;
virtual void printOn(std::ostream& = std::cout) const;
int ref();
int unRef();
// shape* operator=(shape*);
private:
rgb color_;
std::string name_;
int refCount_;
};
std::ostream& operator<<(std::ostream&, shape const&);
bool operator==(shape const& lhs, shape const& rhs);
#endif /* _shape_HPP */
diff --git a/include/sphere.hpp b/include/sphere.hpp
index e0fac23..fcfc659 100644
--- a/include/sphere.hpp
+++ b/include/sphere.hpp
@@ -1,34 +1,34 @@
#ifndef _SPHERE_HPP
#define _SPHERE_HPP
#include "shape.hpp"
-#include "point3d.hpp"
-#include "color.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
class sphere : public shape
{
public:
sphere();
sphere(point const&, double, std::string const&, rgb const&);
sphere(sphere const&);
~sphere();
/*virtual*/ double volume() const;
/*virtual*/ bool isInside(point const&) const;
/*virtual*/ double surface() const;
/*virtual*/ void printOn( std::ostream&) const;
/*virtual*/ sphere* clone() const;
// sphere* operator=(sphere*);
// sphere operator=(sphere);
private:
point center_;
double radius_;
};
#endif /* _sphere_HPP */
diff --git a/ray.cpp b/ray.cpp
index c6ee020..16ca364 100644
--- a/ray.cpp
+++ b/ray.cpp
@@ -1,14 +1,22 @@
ray::ray():
origin_(0,0,0,1),
- direction_(1,1,1,0)
+ direction_(0,0,1,0)
{}
ray::ray(point o,vector d):
origin_(o),
direction_(d)
+
+{
+ double laenge_dir = sqrt(pow(direction_[0],2)+pow(direction_[1],2)+pow(direction_[2],2));
- {}
+ if(laenge_dir!=1)
+ {
+ direction_ = direction_/laenge_dir;
+
+ }
+}
diff --git a/src/sphere.cpp b/src/sphere.cpp
index 08611dc..24ad37b 100644
--- a/src/sphere.cpp
+++ b/src/sphere.cpp
@@ -1,96 +1,96 @@
#include "sphere.hpp"
-sphere::sphere() { std::cout << "Konstruktor Sphere\n"; }
+sphere::sphere() {}
sphere::sphere(point const& c, double r, std::string const& name, rgb const& col) : shape(name, col) , center_(c) , radius_(r)
- { std::cout << "Konstruktor Sphere\n"; }
+ {}
sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
-sphere::~sphere() { std::cout << "Destruktor Sphere\n"; }
+sphere::~sphere() {}
//
// volume - Berechnung Kugelvolumen
//
double sphere::volume() const
{
return pow(radius_,3)*4/3*M_PI;
}
//
//
// isInside - Kollision
//
bool sphere::isInside(point const& p) const
{
( (sqrt(pow(center_[x]-p[x],2) + pow(center_[y]-p[y],2) + pow(center_[z]-p[z],2))) <= radius_)
// return true;
// else
// return false;
}
//
//
// surface - Berechnung Oberfläche
//
double sphere::surface() const
{
return 4* radius_ * radius_ * M_PI;
}
//
//
// printOn - Ausgabe
//
void sphere::printOn(std::ostream& stream) const
{
stream << "\nSphere:\n";
shape::printOn(stream);
stream << "Mittelpunkt: (" << center_[x] << "," << center_[y] << "," << center_[z] << ")\n";
stream << "Radius: " << radius_ << "\n";
}
//
//
// clone
//
sphere* sphere::clone() const
{
return new sphere(*this);
}
//
/*
//
// operator =
//
sphere* sphere::operator=(sphere* sp)
{
sp->ref();
std::cout << "\nhihu\n";
return sp;
}
//
sphere sphere::operator=(sphere sp)
{
sp.ref();
std::cout << "\nhihu\n";
return sp;
}*/
//
|
mahu/pilse
|
bc43ccb16002953c5fa418a60be1b66b0b4524c9
|
sphere bearbeitet
|
diff --git a/Raytracer/include/sphere.hpp b/Raytracer/include/sphere.hpp
index 5cc0fc2..3b49072 100644
--- a/Raytracer/include/sphere.hpp
+++ b/Raytracer/include/sphere.hpp
@@ -1,34 +1,32 @@
#ifndef _SPHERE_HPP
#define _SPHERE_HPP
#include "shape.hpp"
#include "point.hpp"
#include "rgb.hpp"
class sphere : public shape
{
public:
sphere();
sphere(math3d::point const&, double, std::string const&, rgb const&);
sphere(sphere const&);
~sphere();
/*virtual*/ double volume() const;
/*virtual*/ bool isInside(math3d::point const&) const;
/*virtual*/ double surface() const;
/*virtual*/ void printOn( std::ostream&) const;
/*virtual*/ sphere* clone() const;
- // sphere* operator=(sphere*);
- // sphere operator=(sphere);
private:
math3d::point center_;
- double radius_;
+ double radius_;
};
#endif /* _sphere_HPP */
diff --git a/Raytracer/src/sphere.cpp b/Raytracer/src/sphere.cpp
index d7592b5..9e478e2 100644
--- a/Raytracer/src/sphere.cpp
+++ b/Raytracer/src/sphere.cpp
@@ -1,93 +1,73 @@
#include<cmath>
#include "sphere.hpp"
-
+//
+// Konstruktoren
+//
sphere::sphere() {}
sphere::sphere(math3d::point const& c, double r, std::string const& name, rgb const& col) : shape(name, col) , center_(c) , radius_(r)
{}
sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
sphere::~sphere() {}
+//
+
//
// volume - Berechnung Kugelvolumen
//
double sphere::volume() const
{
return pow(radius_,3)*4/3*M_PI;
}
//
//
// isInside - Kollision
//
bool sphere::isInside(math3d::point const& p) const
{
return ( (sqrt(pow(center_[math3d::point::x]-p[math3d::point::x],2) + pow(center_[math3d::point::y]-p[math3d::point::y],2) + pow(center_[math3d::point::z]-p[math3d::point::z],2))) <= radius_);
}
//
//
// surface - Berechnung Oberfläche
//
double sphere::surface() const
{
return 4* radius_ * radius_ * M_PI;
}
//
//
// printOn - Ausgabe
//
void sphere::printOn(std::ostream& stream) const
{
stream << "\nSphere:\n";
shape::printOn(stream);
stream << "Mittelpunkt: (" << center_[math3d::point::x] << "," << center_[math3d::point::y] << "," << center_[math3d::point::z] << ")\n";
stream << "Radius: " << radius_ << "\n";
}
//
//
// clone
//
sphere* sphere::clone() const
{
return new sphere(*this);
}
//
-/*
-//
-// operator =
-//
-sphere* sphere::operator=(sphere* sp)
-{
- sp->ref();
-std::cout << "\nhihu\n";
- return sp;
-}
-//
-
-sphere sphere::operator=(sphere sp)
-{
- sp.ref();
-std::cout << "\nhihu\n";
- return sp;
-}*/
-//
-
-
-
-
-
|
mahu/pilse
|
6dc81959283e0ba7ea3fcaf11c2e05b50e45fdcc
|
ray-bearbeitet
|
diff --git a/Raytracer/include/ray.hpp b/Raytracer/include/ray.hpp
index dd61448..7c539a3 100644
--- a/Raytracer/include/ray.hpp
+++ b/Raytracer/include/ray.hpp
@@ -1,17 +1,20 @@
-#include<point.hpp>
-#include<vector.hpp>
+#include "point.hpp"
+#include "vector.hpp"
+
+#include <iostream>
+#include <cmath>
struct ray
{
//Konstruktoren
- ray();
- ray(point a, vector b);
+ ray();
+ ray(math3d::point a, math3d::vector b);
//Membervariablen
- point origin_;
- vector direction_;
+ math3d::point origin_;
+ math3d::vector direction_;
};
diff --git a/Raytracer/src/ray.cpp b/Raytracer/src/ray.cpp
index b038e37..bc32441 100644
--- a/Raytracer/src/ray.cpp
+++ b/Raytracer/src/ray.cpp
@@ -1,24 +1,25 @@
+#include "ray.hpp"
ray::ray():
- origin_(0,0,0,1),
- direction_(0,0,1,0)
+ origin_(0,0,0,1),
+ direction_(0,0,1,0)
+{}
- {}
-
-ray::ray(point o,vector d):
- origin_(o),
- direction_(d)
+ray::ray(math3d::point o,math3d::vector d):
+ origin_(o),
+ direction_(d)
{
//Normalisieren des Richtungsvektors
- double laenge_dir = sqrt(pow(direction_[0],2)+pow(direction_[1],2)+pow(direction_[2],2));
+ double laenge_dir = std::sqrt(std::pow(direction_[math3d::vector::x],2) +
+ std::pow(direction_[math3d::vector::y],2) +
+ std::pow(direction_[math3d::vector::z],2) );
- if(laenge_dir!=1)
+ if(laenge_dir != 1)
{
direction_ = direction_/laenge_dir;
-
}
}
|
mahu/pilse
|
46a306d880a2610fa4aab67d7f833d13305e7da4
|
Strahlen
|
diff --git a/Raytracer/src/ray.cpp b/Raytracer/src/ray.cpp
index c6ee020..b038e37 100644
--- a/Raytracer/src/ray.cpp
+++ b/Raytracer/src/ray.cpp
@@ -1,14 +1,24 @@
ray::ray():
origin_(0,0,0,1),
- direction_(1,1,1,0)
+ direction_(0,0,1,0)
{}
ray::ray(point o,vector d):
origin_(o),
direction_(d)
+
+{
+ //Normalisieren des Richtungsvektors
+
+ double laenge_dir = sqrt(pow(direction_[0],2)+pow(direction_[1],2)+pow(direction_[2],2));
- {}
+ if(laenge_dir!=1)
+ {
+ direction_ = direction_/laenge_dir;
+
+ }
+}
|
mahu/pilse
|
504634f0da38434a45fcf459fb991dd3540ec63d
|
Strahlen
|
diff --git a/Raytracer/include/ray.hpp b/Raytracer/include/ray.hpp
new file mode 100644
index 0000000..dd61448
--- /dev/null
+++ b/Raytracer/include/ray.hpp
@@ -0,0 +1,17 @@
+#include<point.hpp>
+#include<vector.hpp>
+
+struct ray
+{
+
+ //Konstruktoren
+
+ ray();
+ ray(point a, vector b);
+
+
+ //Membervariablen
+
+ point origin_;
+ vector direction_;
+};
diff --git a/Raytracer/src/ray.cpp b/Raytracer/src/ray.cpp
new file mode 100644
index 0000000..c6ee020
--- /dev/null
+++ b/Raytracer/src/ray.cpp
@@ -0,0 +1,14 @@
+
+ray::ray():
+ origin_(0,0,0,1),
+ direction_(1,1,1,0)
+
+ {}
+
+ray::ray(point o,vector d):
+ origin_(o),
+ direction_(d)
+
+ {}
+
+
|
mahu/pilse
|
7d06ded9f7b3802bf62c7894c86354b04f0ec69f
|
Strahlen
|
diff --git a/Raytracer/ray.cpp b/Raytracer/ray.cpp
new file mode 100644
index 0000000..c6ee020
--- /dev/null
+++ b/Raytracer/ray.cpp
@@ -0,0 +1,14 @@
+
+ray::ray():
+ origin_(0,0,0,1),
+ direction_(1,1,1,0)
+
+ {}
+
+ray::ray(point o,vector d):
+ origin_(o),
+ direction_(d)
+
+ {}
+
+
diff --git a/Raytracer/ray.hpp b/Raytracer/ray.hpp
new file mode 100644
index 0000000..dd61448
--- /dev/null
+++ b/Raytracer/ray.hpp
@@ -0,0 +1,17 @@
+#include<point.hpp>
+#include<vector.hpp>
+
+struct ray
+{
+
+ //Konstruktoren
+
+ ray();
+ ray(point a, vector b);
+
+
+ //Membervariablen
+
+ point origin_;
+ vector direction_;
+};
|
mahu/pilse
|
46b65ffd290e6f17c49a18f4beb907dd6bb36f5a
|
Strahlen
|
diff --git a/ray.cpp b/ray.cpp
new file mode 100644
index 0000000..c6ee020
--- /dev/null
+++ b/ray.cpp
@@ -0,0 +1,14 @@
+
+ray::ray():
+ origin_(0,0,0,1),
+ direction_(1,1,1,0)
+
+ {}
+
+ray::ray(point o,vector d):
+ origin_(o),
+ direction_(d)
+
+ {}
+
+
diff --git a/ray.hpp b/ray.hpp
new file mode 100644
index 0000000..dd61448
--- /dev/null
+++ b/ray.hpp
@@ -0,0 +1,17 @@
+#include<point.hpp>
+#include<vector.hpp>
+
+struct ray
+{
+
+ //Konstruktoren
+
+ ray();
+ ray(point a, vector b);
+
+
+ //Membervariablen
+
+ point origin_;
+ vector direction_;
+};
|
mahu/pilse
|
b81506b17d34ca8f97a14198d4c6eb6e7f1ed6ff
|
framework
|
diff --git a/Raytracer/muhaha b/Raytracer/muhaha
new file mode 100644
index 0000000..e69de29
|
mahu/pilse
|
87337370fb2f0ea5c3c3a7b37d4f29e6921d6342
|
framework
|
diff --git a/Raytracer/include/glutwindow.hpp b/Raytracer/include/glutwindow.hpp
new file mode 100644
index 0000000..f3b70e7
--- /dev/null
+++ b/Raytracer/include/glutwindow.hpp
@@ -0,0 +1,65 @@
+#ifndef BUW_GLUT_WINDOW_HPP
+#define BUW_GLUT_WINDOW_HPP
+
+// header, system
+#include <vector>
+#include <string>
+
+// header, project
+#include <rgb.hpp>
+#include <pixel.hpp>
+
+
+
+class glutwindow {
+public : // typedefs, enums
+ typedef std::vector<rgb> colorbuffer_t;
+
+ ~glutwindow();
+
+private : // do not copy glutwindow
+
+ glutwindow(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[]);
+
+ glutwindow(glutwindow const&);
+
+ glutwindow& operator=(glutwindow const&);
+
+public : // methods
+
+ static void init(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[]);
+ static glutwindow& instance();
+
+ void write(const pixel& p);
+ void update();
+ void run();
+
+ std::size_t width() const;
+ std::size_t height() const;
+ float const& buffer() const;
+
+private: // member
+
+ colorbuffer_t buffer_;
+
+ std::size_t width_;
+ std::size_t height_;
+
+ std::size_t posx_;
+ std::size_t posy_;
+
+ std::string name_;
+};
+
+// external glut callbacks
+void display();
+void reshape(int, int);
+void idle();
+
+#endif // BUW_GLUT_WINDOW_HPP
\ No newline at end of file
diff --git a/Raytracer/include/matrix.hpp b/Raytracer/include/matrix.hpp
new file mode 100644
index 0000000..5a46c69
--- /dev/null
+++ b/Raytracer/include/matrix.hpp
@@ -0,0 +1,113 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : matrix.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_MATRIX_HPP)
+
+#define BUW_MATH3D_MATRIX_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+#include <vector.hpp>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point;
+
+ class matrix {
+
+ public:
+
+ enum cols { c0 = vector::x, c1 = vector::y, c2 = vector::z, c3 = vector::w };
+ enum rows { r0 = vector::x, r1 = vector::y, r2 = vector::z, r3 = vector::w };
+
+ // column major element ordering
+ enum component { aa = 0, ba = 4, ca = 8, da = 12,
+ ab = 1, bb = 5, cb = 9, db = 13,
+ ac = 2, bc = 6, cc = 10, dc = 14,
+ ad = 3, bd = 7, cd = 11, dd = 15 };
+
+ matrix();
+ matrix(matrix const&);
+ matrix(double const [16]);
+
+ ~matrix();
+
+ void swap(matrix&);
+
+ matrix& operator=(matrix const&);
+
+ double const& operator()(cols, rows) const;
+ double& operator()(cols, rows);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ matrix& operator*=(matrix const&);
+ matrix& operator*=(double);
+ matrix& operator/=(double);
+
+ double trace() const;
+
+ // to implement
+ double determinant() const;
+
+ bool invert();
+
+ bool is_invertible() const; // det(M) != 0
+
+ static matrix const& null(); // m[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
+ static matrix const& identity(); // m[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
+
+ private:
+
+ double data_[16];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ matrix operator-(matrix const&);
+
+ matrix operator*(matrix const&, matrix const&);
+ matrix operator*(matrix const&, double);
+ matrix operator*(double, matrix const&);
+ matrix operator/(matrix const&, double);
+
+ point operator*(matrix const&, point const&);
+ vector operator*(matrix const&, vector const&);
+
+ bool operator==(matrix const&, matrix const&);
+
+ matrix make_rotation_x(double);
+
+ double determinant(matrix const&);
+ double trace(matrix const&);
+ matrix inverse(matrix const&);
+ matrix transpose(matrix const&);
+
+ bool is_invertible(matrix const&);
+
+ std::ostream& operator<<(std::ostream&, matrix const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_MATRIX_HPP)
diff --git a/Raytracer/include/pixel.hpp b/Raytracer/include/pixel.hpp
new file mode 100644
index 0000000..171e414
--- /dev/null
+++ b/Raytracer/include/pixel.hpp
@@ -0,0 +1,30 @@
+#ifndef BUW_PIXEL_HPP
+#define BUW_PIXEL_HPP
+
+// header, system
+#include <iosfwd>
+
+// header, project
+#include <rgb.hpp>
+
+
+class pixel {
+public : // c'tor
+
+ pixel(std::size_t = 0, std::size_t = 0);
+ ~pixel();
+
+public : // methods
+
+ void print(std::ostream&) const;
+
+public : // member
+
+ std::size_t x;
+ std::size_t y;
+ rgb color;
+};
+
+std::ostream& operator<<(std::ostream&, const pixel&);
+
+#endif // BUW_PIXEL_HPP
diff --git a/Raytracer/include/point.hpp b/Raytracer/include/point.hpp
new file mode 100644
index 0000000..70c874a
--- /dev/null
+++ b/Raytracer/include/point.hpp
@@ -0,0 +1,75 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : point.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_POINT_HPP)
+
+#define BUW_MATH3D_POINT_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+#include <vector.hpp>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point {
+
+ public:
+
+ enum component { x = vector::x, y = vector::y, z = vector::z, w = vector::w };
+
+ point();
+ point(point const&);
+ point(double, double, double, double = 1.0); // x, y, z, w
+
+ ~point();
+
+ void swap(point&);
+
+ point& operator=(point const&);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ point& operator+=(vector const&);
+ point& operator-=(vector const&);
+
+ static point const& origin(); // p[0,0,0,1]
+
+ private:
+
+ double data_[4];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ point operator-(point const&);
+
+ point operator+(point const&, vector const&);
+ point operator-(point const&, vector const&);
+ bool operator==(point const&, point const&);
+
+ std::ostream& operator<<(std::ostream&, point const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_POINT_HPP)
diff --git a/Raytracer/include/ppmwriter.hpp b/Raytracer/include/ppmwriter.hpp
new file mode 100644
index 0000000..bc5aef2
--- /dev/null
+++ b/Raytracer/include/ppmwriter.hpp
@@ -0,0 +1,31 @@
+#ifndef BUW_PPMWRITER_HPP
+#define BUW_PPMWRITER_HPP
+
+// header, system
+#include <string>
+#include <vector>
+
+// header, project
+#include <pixel.hpp>
+
+
+class ppmwriter
+{
+public:
+ ppmwriter(std::size_t w, std::size_t h, std::string const& file);
+ ppmwriter(std::size_t w, std::size_t h);
+ ~ppmwriter();
+
+public:
+ void write(pixel const& p);
+ void save(std::string const& file);
+ void save();
+
+private:
+ std::string file_;
+ std::vector<unsigned int> data_;
+ size_t width_;
+ size_t height_;
+};
+
+#endif // BUW_PPMWRITER
diff --git a/Raytracer/include/rgb.hpp b/Raytracer/include/rgb.hpp
new file mode 100644
index 0000000..af91357
--- /dev/null
+++ b/Raytracer/include/rgb.hpp
@@ -0,0 +1,38 @@
+#ifndef BUW_RGB_HPP
+#define BUW_RGB_HPP
+
+// header, system
+#include <iosfwd>
+
+
+class rgb {
+public : // enums, typedefs
+ enum component {r, g, b};
+ typedef float value_t;
+
+public : // c'tor
+ rgb();
+ rgb(rgb const&);
+ rgb(value_t r, value_t g, value_t b);
+
+ ~rgb();
+
+public : // methods
+ void swap(rgb&);
+ void print(std::ostream& os) const;
+
+ value_t& operator[](enum component);
+ const value_t& operator[](enum component) const;
+
+ rgb& operator= (const rgb&);
+ void operator+=(const rgb&);
+
+
+private: // members
+ value_t data_[3]; // rgb
+};
+
+rgb operator+(const rgb& a, const rgb& b);
+std::ostream& operator<<(std::ostream& os, rgb const&);
+
+#endif // BUW_RGB_HPP
diff --git a/Raytracer/include/vector.hpp b/Raytracer/include/vector.hpp
new file mode 100644
index 0000000..f323b08
--- /dev/null
+++ b/Raytracer/include/vector.hpp
@@ -0,0 +1,87 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : vector.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_VECTOR_HPP)
+
+#define BUW_MATH3D_VECTOR_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point;
+
+ class vector {
+
+ public:
+
+ enum component { x = 0, y = 1, z = 2, w = 3 };
+
+ vector();
+ vector(vector const&);
+ vector(point const&, point const&); // second - first
+ vector(double, double, double, double = 0.0); // x, y, z, w
+
+ ~vector();
+
+ void swap(vector&);
+
+ vector& operator=(vector const&);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ vector& operator+=(vector const&);
+ vector& operator-=(vector const&);
+ vector& operator*=(double);
+ vector& operator/=(double);
+
+ static vector const& null(); // v[0,0,0,0]
+ static vector const& unit_x(); // v[1,0,0,0]
+ static vector const& unit_y(); // v[0,1,0,0]
+ static vector const& unit_z(); // v[0,0,1,0]
+
+
+ private:
+
+ double data_[4];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+ vector operator-(vector const&);
+
+ vector operator+(vector const&, vector const&);
+ vector operator-(point const&, point const&);
+ vector operator-(vector const&, vector const&);
+ vector operator*(vector const&, double);
+ vector operator*(double, vector const&);
+ vector operator/(vector const&, double);
+ bool operator==(vector const&, vector const&);
+
+ std::ostream& operator<<(std::ostream&, vector const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_VECTOR_HPP)
+
diff --git a/Raytracer/src/glutwindow.cpp b/Raytracer/src/glutwindow.cpp
new file mode 100644
index 0000000..dbcb064
--- /dev/null
+++ b/Raytracer/src/glutwindow.cpp
@@ -0,0 +1,153 @@
+// header i/f
+#include "glutwindow.hpp"
+
+// header, system
+#if WIN32
+ #include <time.h>
+ #include <windows.h>
+#else
+ #include <sys/time.h>
+#endif
+
+#ifdef __APPLE__
+ #include <GLUT/glut.h>
+#else
+ #include <GL/glut.h>
+#endif
+
+#include <iostream>
+#include <cassert>
+
+// header, project
+
+// globals
+glutwindow* g_glutwindow = 0;
+
+
+////////////////////////////////////////////////////////////////////////////////
+glutwindow::glutwindow(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[])
+ : width_(width),
+ height_(height),
+ posx_(posx),
+ posy_(posy),
+ name_(name)
+{
+ g_glutwindow = this;
+ buffer_.resize(width_ * height_);
+
+ glutInit(&argc,argv);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+
+ glutInitWindowPosition(int(posx_), int(posy_));
+ glutInitWindowSize(int(width_), int(height_));
+ glutCreateWindow(name_.c_str());
+
+ glutDisplayFunc(display);
+ glutReshapeFunc(reshape);
+ glutIdleFunc(idle);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+glutwindow::~glutwindow()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/*static*/ glutwindow&
+glutwindow::instance()
+{
+ assert(g_glutwindow);
+ return *g_glutwindow;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/*static*/ void
+glutwindow::init(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[])
+{
+ static glutwindow instance(width, height, posx, posy, name, argc, argv);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::run()
+{
+ glutMainLoop();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t
+glutwindow::width() const {
+ return width_;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t
+glutwindow::height() const {
+ return height_;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::write(const pixel& p)
+{
+ // flip pixels, because of opengl glDrawPixels
+ size_t buf_pos = (width_*p.y + (p.x));
+ if (buf_pos >= buffer_.size() || (int)buf_pos < 0) {
+ std::cerr << "Fatal Error glutwindow::write(pixel p) : pixel out of image : " << (int)p.x << "," << (int)p.y << std::endl;
+ } else {
+ buffer_[buf_pos] = p.color;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::update()
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glDrawPixels(width_, height_, GL_RGB, GL_FLOAT, &(buffer_.front()));
+ glutSwapBuffers();
+
+ // upate only with 25Hz
+#if WIN32
+ Sleep(20);
+#else
+ usleep(20000);
+#endif
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void display()
+{
+ glutwindow::instance().update();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void reshape(int w, int h)
+{
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void idle()
+{
+ glutPostRedisplay();
+}
diff --git a/Raytracer/src/main.cpp b/Raytracer/src/main.cpp
new file mode 100644
index 0000000..a6df1a9
--- /dev/null
+++ b/Raytracer/src/main.cpp
@@ -0,0 +1,90 @@
+#include <glutwindow.hpp>
+#include <ppmwriter.hpp>
+#include <pixel.hpp>
+
+#include <iostream>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#ifdef __APPLE__
+ #include <GLUT/glut.h>
+#else
+ #include <GL/glut.h>
+#endif
+
+// this is a dummy raytrace application
+class rt_application
+{
+public :
+
+ //
+ void raytrace() const
+ {
+ // size of a tile in checkerboard
+ const std::size_t checkersize = 20;
+
+ // get glutwindow instance
+ glutwindow& gw = glutwindow::instance();
+
+ // create a ppmwriter
+ ppmwriter pw(gw.width(), gw.height(), "./checkerboard.ppm");
+
+ // for all pixels of window
+ for (std::size_t y = 0; y < gw.height(); ++y) {
+ for (std::size_t x = 0; x < gw.width(); ++x) {
+
+ // create pixel at x,y
+ pixel p(x, y);
+
+ // compute color for pixel
+ if ( ((x/checkersize)%2) != ((y/checkersize)%2)) {
+ p.color = rgb(1.0, 1.0, float(x)/gw.height());
+ } else {
+ p.color = rgb(1.0, 0.0, float(y)/gw.width());
+ }
+
+ // write pixel to output window
+ gw.write(p);
+
+ // write pixel to image writer
+ pw.write(p);
+ }
+ }
+
+ // save final image
+ pw.save();
+ }
+
+private : // attributes
+
+ // you may add a scene description here
+
+};
+
+
+
+
+
+int main(int argc, char* argv[])
+{
+ // set resolution and checkersize
+ const std::size_t width = 400;
+ const std::size_t height = 400;
+
+ // create output window
+ glutwindow::init(width, height, 100, 100, "CheckerBoard", argc, argv);
+
+ // create a ray tracing application
+ rt_application app;
+
+ // start computation in thread
+ boost::thread thr(boost::bind(&rt_application::raytrace, &app));
+
+ // start output on glutwindow
+ glutwindow::instance().run();
+
+ // wait on thread
+ thr.join();
+
+ return 0;
+}
diff --git a/Raytracer/src/matrix.cpp b/Raytracer/src/matrix.cpp
new file mode 100644
index 0000000..d7209dd
--- /dev/null
+++ b/Raytracer/src/matrix.cpp
@@ -0,0 +1,488 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : matrix.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "matrix.hpp"
+
+// includes, system
+
+#include <algorithm> // std::copy, std::swap_ranges
+#include <cmath> // std::cos, std::sin
+#include <iomanip> // std::fixed, std::setprecision
+#include <ostream> // std::ostream
+#include <limits> // std::numeric_limits
+
+// includes, project
+#include <point.hpp>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ double const null_array16[16] = {
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+ };
+
+ double const ident_array16[16] = {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+ };
+
+ // functions, internal
+
+ double
+ det3_helper(double a1, double a2, double a3,
+ double b1, double b2, double b3,
+ double c1, double c2, double c3)
+ {
+ return ((a1 * b2 * c3) + (a2 * b3 * c1) + (a3 * b1 * c2) -
+ (a1 * b3 * c2) - (a2 * b1 * c3) - (a3 * b2 * c1));
+ }
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ matrix::matrix()
+ : data_()
+ {
+ std::copy(ident_array16, ident_array16+16, data_);
+ }
+
+ matrix::matrix(matrix const& rhs)
+ : data_()
+ {
+ std::copy(rhs.data_, rhs.data_+16, data_);
+ }
+
+ matrix::matrix(double const a[16])
+ : data_()
+ {
+ std::copy(a, a+16, data_);
+ }
+
+ matrix::~matrix()
+ {}
+
+ void
+ matrix::swap(matrix& rhs)
+ {
+ std::swap_ranges(data_, data_+16, rhs.data_);
+ }
+
+ matrix&
+ matrix::operator=(matrix const& rhs)
+ {
+ matrix tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ matrix::operator()(matrix::cols a, matrix::rows b) const
+ {
+ return data_[(b * 4) + a];
+ }
+
+ double&
+ matrix::operator()(matrix::cols a, matrix::rows b)
+ {
+ return data_[(b * 4) + a];
+ }
+
+ double const&
+ matrix::operator[](matrix::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ matrix::operator[](matrix::component idx)
+ {
+ return data_[idx];
+ }
+
+ matrix&
+ matrix::operator*=(matrix const& rhs)
+ {
+ matrix tmp;
+
+ tmp.data_[ 0] = (data_[ 0] * rhs.data_[ 0] +
+ data_[ 4] * rhs.data_[ 1] +
+ data_[ 8] * rhs.data_[ 2] +
+ data_[12] * rhs.data_[ 3]);
+ tmp.data_[ 1] = (data_[ 1] * rhs.data_[ 0] +
+ data_[ 5] * rhs.data_[ 1] +
+ data_[ 9] * rhs.data_[ 2] +
+ data_[13] * rhs.data_[ 3]);
+ tmp.data_[ 2] = (data_[ 2] * rhs.data_[ 0] +
+ data_[ 6] * rhs.data_[ 1] +
+ data_[10] * rhs.data_[ 2] +
+ data_[14] * rhs.data_[ 3]);
+ tmp.data_[ 3] = (data_[ 3] * rhs.data_[ 0] +
+ data_[ 7] * rhs.data_[ 1] +
+ data_[11] * rhs.data_[ 2] +
+ data_[15] * rhs.data_[ 3]);
+ tmp.data_[ 4] = (data_[ 0] * rhs.data_[ 4] +
+ data_[ 4] * rhs.data_[ 5] +
+ data_[ 8] * rhs.data_[ 6] +
+ data_[12] * rhs.data_[ 7]);
+ tmp.data_[ 5] = (data_[ 1] * rhs.data_[ 4] +
+ data_[ 5] * rhs.data_[ 5] +
+ data_[ 9] * rhs.data_[ 6] +
+ data_[13] * rhs.data_[ 7]);
+ tmp.data_[ 6] = (data_[ 2] * rhs.data_[ 4] +
+ data_[ 6] * rhs.data_[ 5] +
+ data_[10] * rhs.data_[ 6] +
+ data_[14] * rhs.data_[ 7]);
+ tmp.data_[ 7] = (data_[ 3] * rhs.data_[ 4] +
+ data_[ 7] * rhs.data_[ 5] +
+ data_[11] * rhs.data_[ 6] +
+ data_[15] * rhs.data_[ 7]);
+ tmp.data_[ 8] = (data_[ 0] * rhs.data_[ 8] +
+ data_[ 4] * rhs.data_[ 9] +
+ data_[ 8] * rhs.data_[10] +
+ data_[12] * rhs.data_[11]);
+ tmp.data_[ 9] = (data_[ 1] * rhs.data_[ 8] +
+ data_[ 5] * rhs.data_[ 9] +
+ data_[ 9] * rhs.data_[10] +
+ data_[13] * rhs.data_[11]);
+ tmp.data_[10] = (data_[ 2] * rhs.data_[ 8] +
+ data_[ 6] * rhs.data_[ 9] +
+ data_[10] * rhs.data_[10] +
+ data_[14] * rhs.data_[11]);
+ tmp.data_[11] = (data_[ 3] * rhs.data_[ 8] +
+ data_[ 7] * rhs.data_[ 9] +
+ data_[11] * rhs.data_[10] +
+ data_[15] * rhs.data_[11]);
+ tmp.data_[12] = (data_[ 0] * rhs.data_[12] +
+ data_[ 4] * rhs.data_[13] +
+ data_[ 8] * rhs.data_[14] +
+ data_[12] * rhs.data_[15]);
+ tmp.data_[13] = (data_[ 1] * rhs.data_[12] +
+ data_[ 5] * rhs.data_[13] +
+ data_[ 9] * rhs.data_[14] +
+ data_[13] * rhs.data_[15]);
+ tmp.data_[14] = (data_[ 2] * rhs.data_[12] +
+ data_[ 6] * rhs.data_[13] +
+ data_[10] * rhs.data_[14] +
+ data_[14] * rhs.data_[15]);
+ tmp.data_[15] = (data_[ 3] * rhs.data_[12] +
+ data_[ 7] * rhs.data_[13] +
+ data_[11] * rhs.data_[14] +
+ data_[15] * rhs.data_[15]);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ matrix&
+ matrix::operator*=(double rhs)
+ {
+ for (unsigned idx = 0; idx < 16; ++idx)
+ data_[idx] *= rhs;
+
+ return *this;
+ }
+
+ matrix&
+ matrix::operator/=(double rhs)
+ {
+ for (unsigned idx = 0; idx < 16; ++idx)
+ data_[idx] /= rhs;
+
+ return *this;
+ }
+
+ double
+ matrix::trace() const
+ {
+ return data_[0] + data_[5] + data_[10] + data_[15];
+ }
+
+ double
+ matrix::determinant() const
+ {
+ // to implement!
+ double det(0.0);
+
+ return det;
+ }
+
+ bool
+ matrix::invert()
+ {
+ bool result(false);
+ double const d(determinant());
+
+ if (0.0 != d) {
+ double const& a1(data_[ 0]);
+ double const& b1(data_[ 4]);
+ double const& c1(data_[ 8]);
+ double const& d1(data_[12]);
+ double const& a2(data_[ 1]);
+ double const& b2(data_[ 5]);
+ double const& c2(data_[ 9]);
+ double const& d2(data_[13]);
+ double const& a3(data_[ 2]);
+ double const& b3(data_[ 6]);
+ double const& c3(data_[10]);
+ double const& d3(data_[14]);
+ double const& a4(data_[ 3]);
+ double const& b4(data_[ 7]);
+ double const& c4(data_[11]);
+ double const& d4(data_[15]);
+
+ double const di(1.0 / d);
+
+ matrix tmp;
+
+ tmp.data_[ 0] = det3_helper(b2, b3, b4, c2, c3, c4, d2, d3, d4) * di;
+ tmp.data_[ 1] = -det3_helper(a2, a3, a4, c2, c3, c4, d2, d3, d4) * di;
+ tmp.data_[ 2] = det3_helper(a2, a3, a4, b2, b3, b4, d2, d3, d4) * di;
+ tmp.data_[ 3] = -det3_helper(a2, a3, a4, b2, b3, b4, c2, c3, c4) * di;
+ tmp.data_[ 4] = -det3_helper(b1, b3, b4, c1, c3, c4, d1, d3, d4) * di;
+ tmp.data_[ 5] = det3_helper(a1, a3, a4, c1, c3, c4, d1, d3, d4) * di;
+ tmp.data_[ 6] = -det3_helper(a1, a3, a4, b1, b3, b4, d1, d3, d4) * di;
+ tmp.data_[ 7] = det3_helper(a1, a3, a4, b1, b3, b4, c1, c3, c4) * di;
+ tmp.data_[ 8] = det3_helper(b1, b2, b4, c1, c2, c4, d1, d2, d4) * di;
+ tmp.data_[ 9] = -det3_helper(a1, a2, a4, c1, c2, c4, d1, d2, d4) * di;
+ tmp.data_[10] = det3_helper(a1, a2, a4, b1, b2, b4, d1, d2, d4) * di;
+ tmp.data_[11] = -det3_helper(a1, a2, a4, b1, b2, b4, c1, c2, c4) * di;
+ tmp.data_[12] = -det3_helper(b1, b2, b3, c1, c2, c3, d1, d2, d3) * di;
+ tmp.data_[13] = det3_helper(a1, a2, a3, c1, c2, c3, d1, d2, d3) * di;
+ tmp.data_[14] = -det3_helper(a1, a2, a3, b1, b2, b3, d1, d2, d3) * di;
+ tmp.data_[15] = det3_helper(a1, a2, a3, b1, b2, b3, c1, c2, c3) * di;
+
+ swap(tmp);
+
+ result = true;
+ }
+
+ return result;
+ }
+
+ bool
+ matrix::is_invertible() const
+ {
+ return 0 != determinant();
+ }
+
+ /* static */
+ matrix const&
+ matrix::null()
+ {
+ static matrix null_(null_array16);
+ return null_;
+ }
+
+ /* static */
+ matrix const&
+ matrix::identity()
+ {
+ static matrix identity_(ident_array16);
+ return identity_;
+ }
+
+ matrix
+ operator-(matrix const& rhs)
+ {
+ return matrix(rhs) *= -1.0;
+ }
+
+ matrix
+ operator*(matrix const& lhs, matrix const& rhs)
+ {
+ return matrix(lhs) *= rhs;
+ }
+
+ matrix
+ operator*(matrix const& lhs, double rhs)
+ {
+ return matrix(lhs) *= rhs;
+ }
+
+ matrix
+ operator*(double lhs, matrix const& rhs)
+ {
+ return matrix(rhs) *= lhs;
+ }
+
+ matrix
+ operator/(matrix const& lhs, double rhs)
+ {
+ return matrix(lhs) /= rhs;
+ }
+
+ point
+ operator*(matrix const& lhs, const point& rhs)
+ {
+ return point(lhs[matrix::aa] * rhs[point::x] +
+ lhs[matrix::ba] * rhs[point::y] +
+ lhs[matrix::ca] * rhs[point::z] +
+ lhs[matrix::da] * rhs[point::w],
+ lhs[matrix::ab] * rhs[point::x] +
+ lhs[matrix::bb] * rhs[point::y] +
+ lhs[matrix::cb] * rhs[point::z] +
+ lhs[matrix::db] * rhs[point::w],
+ lhs[matrix::ac] * rhs[point::x] +
+ lhs[matrix::bc] * rhs[point::y] +
+ lhs[matrix::cc] * rhs[point::z] +
+ lhs[matrix::dc] * rhs[point::w],
+ lhs[matrix::ad] * rhs[point::x] +
+ lhs[matrix::bd] * rhs[point::y] +
+ lhs[matrix::cd] * rhs[point::z] +
+ lhs[matrix::dd] * rhs[point::w]);
+ }
+
+ vector
+ operator*(matrix const& lhs, const vector& rhs)
+ {
+ return vector(lhs[matrix::aa] * rhs[vector::x] +
+ lhs[matrix::ba] * rhs[vector::y] +
+ lhs[matrix::ca] * rhs[vector::z] +
+ lhs[matrix::da] * rhs[vector::w],
+ lhs[matrix::ab] * rhs[vector::x] +
+ lhs[matrix::bb] * rhs[vector::y] +
+ lhs[matrix::cb] * rhs[vector::z] +
+ lhs[matrix::db] * rhs[vector::w],
+ lhs[matrix::ac] * rhs[vector::x] +
+ lhs[matrix::bc] * rhs[vector::y] +
+ lhs[matrix::cc] * rhs[vector::z] +
+ lhs[matrix::dc] * rhs[vector::w],
+ lhs[matrix::ad] * rhs[vector::x] +
+ lhs[matrix::bd] * rhs[vector::y] +
+ lhs[matrix::cd] * rhs[vector::z] +
+ lhs[matrix::dd] * rhs[vector::w]);
+ }
+
+ bool
+ operator==(matrix const& lhs, matrix const& rhs)
+ {
+ return (std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon());
+ }
+
+ matrix
+ make_rotation_x(double a)
+ {
+ double const cos_a(std::cos(a));
+ double const sin_a(std::sin(a));
+
+ matrix tmp;
+
+ tmp[matrix::bb] = cos_a;
+ tmp[matrix::cb] = sin_a;
+ tmp[matrix::bc] = -sin_a;
+ tmp[matrix::cc] = cos_a;
+
+ return tmp;
+ }
+
+ double
+ determinant(matrix const& a)
+ {
+ return a.determinant();
+ }
+
+ double
+ trace(matrix const& a)
+ {
+ return a.trace();
+ }
+
+ matrix
+ inverse(matrix const& a)
+ {
+ matrix tmp(a);
+
+ tmp.invert();
+
+ return tmp;
+ }
+
+ bool
+ is_invertible(matrix const& a)
+ {
+ return a.is_invertible();
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, matrix const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << std::fixed << std::setprecision(3)
+ << '['
+ << a[matrix::aa] << ','
+ << a[matrix::ab] << ','
+ << a[matrix::ac] << ','
+ << a[matrix::ad] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ba] << ','
+ << a[matrix::bb] << ','
+ << a[matrix::bc] << ','
+ << a[matrix::bd] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ca] << ','
+ << a[matrix::cb] << ','
+ << a[matrix::cc] << ','
+ << a[matrix::cd] << ','
+ << std::endl
+ << ' '
+ << a[matrix::da] << ','
+ << a[matrix::db] << ','
+ << a[matrix::dc] << ','
+ << a[matrix::dd]
+ << ']';
+ }
+
+ return os;
+ }
+
+} // namespace math3d {
diff --git a/Raytracer/src/pixel.cpp b/Raytracer/src/pixel.cpp
new file mode 100644
index 0000000..691ff5f
--- /dev/null
+++ b/Raytracer/src/pixel.cpp
@@ -0,0 +1,39 @@
+// header i/f
+#include "pixel.hpp"
+
+// header, system
+#include <ostream>
+
+
+pixel::pixel(std::size_t a, std::size_t b)
+ : x(a),
+ y(b),
+ color()
+{}
+
+
+///////////////////////////////////////////////////////////////////////////////
+pixel::~pixel()
+{}
+
+
+///////////////////////////////////////////////////////////////////////////////
+void
+pixel::print(std::ostream& os) const
+{
+ os << "pixel[" << (int)x << ',' << (int)y << "]("
+ << color[rgb::r] << ','
+ << color[rgb::g] << ','
+ << color[rgb::b] << ')';
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+std::ostream&
+operator<<(std::ostream& os, const pixel& a)
+{
+ std::ostream::sentry cerberus (os);
+ if (cerberus)
+ a.print(os);
+ return os;
+}
\ No newline at end of file
diff --git a/Raytracer/src/point.cpp b/Raytracer/src/point.cpp
new file mode 100644
index 0000000..361a0c2
--- /dev/null
+++ b/Raytracer/src/point.cpp
@@ -0,0 +1,173 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : point.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "point.hpp"
+
+// includes, system
+
+#include <algorithm> // std::swap_ranges
+#include <cmath> // std::abs
+#include <limits> // std::numeric_limits
+#include <ostream> // std::ostream
+
+// includes, project
+
+// #include <>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ // functions, internal
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ point::point()
+ {
+ data_[0] = data_[1] = data_[2] = 0.0; data_[3] = 1.0;
+ }
+
+ point::point(point const& a)
+ {
+ data_[0] = a.data_[0];
+ data_[1] = a.data_[1];
+ data_[2] = a.data_[2];
+ data_[3] = a.data_[3];
+ }
+
+ point::point(double a, double b, double c, double d)
+ {
+ data_[0] = a;
+ data_[1] = b;
+ data_[2] = c;
+ data_[3] = d;
+ }
+
+ point::~point()
+ {}
+
+ void
+ point::swap(point& rhs)
+ {
+ std::swap_ranges(data_, data_+4, rhs.data_);
+ }
+
+ point&
+ point::operator=(point const& rhs)
+ {
+ point tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ point::operator[](point::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ point::operator[](point::component idx)
+ {
+ return data_[idx];
+ }
+
+ point&
+ point::operator+=(vector const& rhs)
+ {
+ data_[point::x] += rhs[vector::x];
+ data_[point::y] += rhs[vector::y];
+ data_[point::z] += rhs[vector::z];
+ // data_[point::w] += rhs[vector::w];
+
+ return *this;
+ }
+
+ point&
+ point::operator-=(vector const& rhs)
+ {
+ data_[point::x] -= rhs[vector::x];
+ data_[point::y] -= rhs[vector::y];
+ data_[point::z] -= rhs[vector::z];
+ // data_[point::w] -= rhs[vector::w];
+
+ return *this;
+ }
+
+ /* static */ point const&
+ point::origin()
+ {
+ static point origin_(0.0, 0.0, 0.0);
+ return origin_;
+ }
+
+ point
+ operator-(point const& rhs)
+ {
+ return point(-rhs[point::x], -rhs[point::y], -rhs[point::z], rhs[point::w]);
+ }
+
+ point
+ operator+(point const& lhs, vector const& rhs)
+ {
+ return point(lhs) += rhs;
+ }
+
+ point
+ operator-(point const& lhs, vector const& rhs)
+ {
+ return point(lhs) -= rhs;
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, point const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << '['
+ << a[point::x] << ','
+ << a[point::y] << ','
+ << a[point::z] << ','
+ << a[point::w]
+ << ']';
+ }
+
+ return os;
+ }
+
+ bool
+ operator==(point const& lhs, point const& rhs)
+ {
+ return (std::fabs(rhs[point::x] - lhs[point::x]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[point::y] - lhs[point::y]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[point::z] - lhs[point::z]) < std::numeric_limits<double>::epsilon());
+ }
+
+
+} // namespace math3d {
diff --git a/Raytracer/src/ppmwriter.cpp b/Raytracer/src/ppmwriter.cpp
new file mode 100644
index 0000000..2b892bf
--- /dev/null
+++ b/Raytracer/src/ppmwriter.cpp
@@ -0,0 +1,81 @@
+// header i/f
+#include "ppmwriter.hpp"
+
+// header, system
+#include <iostream>
+#include <fstream>
+#include <cmath>
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::ppmwriter(std::size_t w, std::size_t h, std::string const& file)
+ : file_(file),
+ width_(w),
+ height_(h) {
+ data_.resize(w * h * (sizeof(rgb)/sizeof(rgb::value_t)));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::ppmwriter(std::size_t w, std::size_t h)
+ : file_("untitled.ppm"),
+ width_(w),
+ height_(h) {
+ data_.resize(w*h*(sizeof(rgb)/sizeof(rgb::value_t)));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::~ppmwriter()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::write(pixel const& p)
+{
+ size_t buf_pos = width_*p.y + p.x;
+ std::size_t pos = (sizeof(rgb)/sizeof(rgb::value_t)) * buf_pos;
+ if (pos + ((sizeof(rgb)/sizeof(rgb::value_t)) - 1) > data_.size() || (int)buf_pos < 0) {
+ std::cerr << "Fatal Error ppmwriter::write(pixel p) : Critical write position\n";
+ } else {
+ data_[pos] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::r], 255.0));
+ data_[pos+1] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::g], 255.0));
+ data_[pos+2] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::b], 255.0));
+ }
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::save(std::string const& file)
+{
+ file_ = file;
+ save();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::save()
+{
+ const std::size_t line_length = 18;
+
+ std::fstream file(file_.c_str(), std::ios::out);
+ file.clear();
+ file << "P3 "
+ << (unsigned int)width_ << " "
+ << (unsigned int)height_ << " "
+ << 255 << " \n";
+
+ std::size_t pos = 1;
+ for (std::vector<unsigned int>::iterator i = data_.begin();
+ i < data_.end();
+ ++i, ++pos)
+ {
+ file << (int)*i << " ";
+ if (pos > line_length) {
+ file << "\n";
+ pos=0;
+ }
+ }
+
+ file.close();
+}
\ No newline at end of file
diff --git a/Raytracer/src/rgb.cpp b/Raytracer/src/rgb.cpp
new file mode 100644
index 0000000..cd8b355
--- /dev/null
+++ b/Raytracer/src/rgb.cpp
@@ -0,0 +1,116 @@
+// header i/f
+#include "rgb.hpp"
+
+// header, system
+#include <iostream>
+
+// header, project
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb()
+{
+ data_[0] = 0;
+ data_[1] = 0;
+ data_[2] = 0;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb(rgb const& rhs)
+{
+ data_[0] = rhs.data_[0];
+ data_[1] = rhs.data_[1];
+ data_[2] = rhs.data_[2];
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb(float r, float g, float b)
+{
+ data_[0] = r;
+ data_[1] = g;
+ data_[2] = b;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::~rgb()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::swap(rgb& rhs)
+{
+ std::swap(data_[0], rhs.data_[0]);
+ std::swap(data_[1], rhs.data_[1]);
+ std::swap(data_[2], rhs.data_[2]);
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::print(std::ostream& os) const
+{
+ os << '(' << data_[0] << '|' << data_[1] << '|' << data_[2] << ')' << std::endl;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::value_t&
+rgb::operator[](enum rgb::component c)
+{
+ return data_[c];
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+const rgb::value_t&
+rgb::operator[](enum rgb::component c) const
+{
+ return data_[c];
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb&
+rgb::operator=(rgb const& rhs)
+{
+ rgb tmp(rhs);
+ swap(tmp);
+ return *this;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::operator+=(rgb const& a)
+{
+ data_[0]+=a.data_[0];
+ data_[1]+=a.data_[1];
+ data_[2]+=a.data_[2];
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb
+operator+(rgb const& a, rgb const& b)
+{
+ rgb result(a);
+ result += b;
+ return result;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::ostream&
+operator<<(std::ostream& os, rgb const& color)
+{
+ color.print(os);
+ return os;
+}
diff --git a/Raytracer/src/vector.cpp b/Raytracer/src/vector.cpp
new file mode 100644
index 0000000..45d4ecd
--- /dev/null
+++ b/Raytracer/src/vector.cpp
@@ -0,0 +1,248 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : vector.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "vector.hpp"
+
+// includes, system
+
+#include <algorithm> // std::swap_ranges
+#include <cmath> // std::sqrt
+#include <limits> // std::numeric_limits
+#include <ostream> // std::ostream
+
+// includes, project
+
+#include <point.hpp>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ // functions, internal
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ vector::vector()
+ {
+ data_[0] = data_[1] = data_[2] = data_[3] = 0.0;
+ }
+
+ vector::vector(vector const& a)
+ {
+ data_[0] = a.data_[0];
+ data_[1] = a.data_[1];
+ data_[2] = a.data_[2];
+ data_[3] = a.data_[3];
+ }
+
+ vector::vector(point const& a, point const& b)
+ {
+ data_[0] = b[point::x] - a[point::x];
+ data_[1] = b[point::y] - a[point::y];
+ data_[2] = b[point::z] - a[point::z];
+ data_[3] = 0.0;
+ }
+
+ vector::vector(double a, double b, double c, double d)
+ {
+ data_[0] = a;
+ data_[1] = b;
+ data_[2] = c;
+ data_[3] = d;
+ }
+
+ vector::~vector()
+ {}
+
+ void
+ vector::swap(vector& rhs)
+ {
+ std::swap_ranges(data_, data_+4, rhs.data_);
+ }
+
+ vector&
+ vector::operator=(vector const& rhs)
+ {
+ vector tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ vector::operator[](vector::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ vector::operator[](vector::component idx)
+ {
+ return data_[idx];
+ }
+
+ vector&
+ vector::operator+=(vector const& rhs)
+ {
+ data_[0] += rhs.data_[0];
+ data_[1] += rhs.data_[1];
+ data_[2] += rhs.data_[2];
+ // data_[3] += rhs.data_[3];
+
+ return *this;
+ }
+
+ vector&
+ vector::operator-=(vector const& rhs)
+ {
+ data_[0] -= rhs.data_[0];
+ data_[1] -= rhs.data_[1];
+ data_[2] -= rhs.data_[2];
+ // data_[3] -= rhs.data_[3];
+
+ return *this;
+ }
+
+ vector&
+ vector::operator*=(double rhs)
+ {
+ data_[0] *= rhs;
+ data_[1] *= rhs;
+ data_[2] *= rhs;
+ data_[3] *= rhs;
+
+ return *this;
+ }
+
+ vector&
+ vector::operator/=(double rhs)
+ {
+ data_[0] /= rhs;
+ data_[1] /= rhs;
+ data_[2] /= rhs;
+ data_[3] /= rhs;
+
+ return *this;
+ }
+
+ vector
+ operator-(vector const& rhs)
+ {
+ return vector(rhs) *= -1.0;
+ }
+
+ vector
+ operator+(vector const& lhs, vector const& rhs)
+ {
+ return vector(lhs) += rhs;
+ }
+
+ vector
+ operator-(point const& lhs, point const& rhs)
+ {
+ return vector(rhs, lhs);
+ }
+
+ vector
+ operator-(vector const& lhs, vector const& rhs)
+ {
+ return vector(lhs) -= rhs;
+ }
+
+ vector
+ operator*(vector const& lhs, double rhs)
+ {
+ return vector(lhs) *= rhs;
+ }
+
+ vector
+ operator*(double lhs, vector const& rhs)
+ {
+ return vector(rhs) *= lhs;
+ }
+
+ vector
+ operator/(vector const& lhs, double rhs)
+ {
+ return vector(lhs) /= rhs;
+ }
+
+ /* static */ vector const&
+ vector::null()
+ {
+ static vector null_(0.0, 0.0, 0.0);
+ return null_;
+ }
+
+ /* static */ vector const&
+ vector::unit_x()
+ {
+ static vector unit_x_(1.0, 0.0, 0.0);
+ return unit_x_;
+ }
+
+ /* static */ vector const&
+ vector::unit_y()
+ {
+ static vector unit_y_(0.0, 1.0, 0.0);
+ return unit_y_;
+ }
+
+ /* static */ vector const&
+ vector::unit_z()
+ {
+ static vector unit_z_(0.0, 0.0, 1.0);
+ return unit_z_;
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, vector const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << '['
+ << a[vector::x] << ','
+ << a[vector::y] << ','
+ << a[vector::z] << ','
+ << a[vector::w]
+ << ']';
+ }
+
+ return os;
+ }
+
+ bool
+ operator==(vector const& lhs, vector const& rhs)
+ {
+ return (std::fabs(rhs[vector::x] - lhs[vector::x]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[vector::y] - lhs[vector::y]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[vector::z] - lhs[vector::z]) < std::numeric_limits<double>::epsilon());
+ }
+
+} // namespace math3d {
+
|
mahu/pilse
|
7e1da41e63c3228bc1c43321a9b849568ef76ae7
|
huuuuu
|
diff --git a/README~ b/README~
new file mode 100644
index 0000000..50b9dd2
--- /dev/null
+++ b/README~
@@ -0,0 +1 @@
+timbuktu
|
mahu/pilse
|
8cf5a63f99922999fd9c9ec2e2f48e8274b8cba2
|
hello world
|
diff --git a/README b/README
index 50b9dd2..4519826 100644
--- a/README
+++ b/README
@@ -1 +1,2 @@
timbuktu
+tambakta
|
mahu/pilse
|
eafe54a537d1ba523e5e7f6980b39d0abcba6b1d
|
Please enter the commit message for your changes. Lines starting
|
diff --git a/README b/README
index e69de29..50b9dd2 100644
--- a/README
+++ b/README
@@ -0,0 +1 @@
+timbuktu
|
mahu/pilse
|
91e0ff95555acaad8c2bf7986ba56c4558c27cc6
|
Please enter the commit message for your changes. Lines starting
|
diff --git a/include/box.hpp b/include/box.hpp
new file mode 100644
index 0000000..81bd9bf
--- /dev/null
+++ b/include/box.hpp
@@ -0,0 +1,33 @@
+#ifndef _BOX_HPP
+#define _BOX_HPP
+
+#include "shape.hpp"
+#include "point.hpp"
+#include "rgb.hpp"
+#include <iostream>
+#include <cmath>
+
+
+class box : public shape
+{
+ public:
+ box();
+ box( point const&, point const&, std::string const&, color const&);
+ box(box const&);
+ ~box();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn(std::ostream&) const;
+ /*virtual*/ box* clone() const;
+// box* operator=(box*);
+
+
+ private:
+ point vertex_[2];
+};
+
+
+
+#endif /* _BOX_HPP */
diff --git a/include/box.hpp~ b/include/box.hpp~
new file mode 100644
index 0000000..bacc70b
--- /dev/null
+++ b/include/box.hpp~
@@ -0,0 +1,33 @@
+#ifndef _BOX_HPP
+#define _BOX_HPP
+
+#include "shape.hpp"
+#include "point3d.hpp"
+#include "color.hpp"
+#include <iostream>
+#include <cmath>
+
+
+class box : public shape
+{
+ public:
+ box();
+ box( point const&, point const&, std::string const&, color const&);
+ box(box const&);
+ ~box();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn(std::ostream&) const;
+ /*virtual*/ box* clone() const;
+// box* operator=(box*);
+
+
+ private:
+ point vertex_[2];
+};
+
+
+
+#endif /* _BOX_HPP */
diff --git a/include/glutwindow.hpp b/include/glutwindow.hpp
new file mode 100644
index 0000000..f3b70e7
--- /dev/null
+++ b/include/glutwindow.hpp
@@ -0,0 +1,65 @@
+#ifndef BUW_GLUT_WINDOW_HPP
+#define BUW_GLUT_WINDOW_HPP
+
+// header, system
+#include <vector>
+#include <string>
+
+// header, project
+#include <rgb.hpp>
+#include <pixel.hpp>
+
+
+
+class glutwindow {
+public : // typedefs, enums
+ typedef std::vector<rgb> colorbuffer_t;
+
+ ~glutwindow();
+
+private : // do not copy glutwindow
+
+ glutwindow(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[]);
+
+ glutwindow(glutwindow const&);
+
+ glutwindow& operator=(glutwindow const&);
+
+public : // methods
+
+ static void init(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[]);
+ static glutwindow& instance();
+
+ void write(const pixel& p);
+ void update();
+ void run();
+
+ std::size_t width() const;
+ std::size_t height() const;
+ float const& buffer() const;
+
+private: // member
+
+ colorbuffer_t buffer_;
+
+ std::size_t width_;
+ std::size_t height_;
+
+ std::size_t posx_;
+ std::size_t posy_;
+
+ std::string name_;
+};
+
+// external glut callbacks
+void display();
+void reshape(int, int);
+void idle();
+
+#endif // BUW_GLUT_WINDOW_HPP
\ No newline at end of file
diff --git a/include/matrix.hpp b/include/matrix.hpp
new file mode 100644
index 0000000..2b432ec
--- /dev/null
+++ b/include/matrix.hpp
@@ -0,0 +1,121 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : matrix.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_MATRIX_HPP)
+
+#define BUW_MATH3D_MATRIX_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+#include <vector.hpp>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point;
+
+ class matrix {
+
+ public:
+
+ enum cols { c0 = vector::x, c1 = vector::y, c2 = vector::z, c3 = vector::w };
+ enum rows { r0 = vector::x, r1 = vector::y, r2 = vector::z, r3 = vector::w };
+
+ // column major element ordering
+ enum component { aa = 0, ba = 4, ca = 8, da = 12,
+ ab = 1, bb = 5, cb = 9, db = 13,
+ ac = 2, bc = 6, cc = 10, dc = 14,
+ ad = 3, bd = 7, cd = 11, dd = 15 };
+
+ matrix();
+ matrix(matrix const&);
+ matrix(double const [16]);
+
+ ~matrix();
+
+ void swap(matrix&);
+
+ matrix& operator=(matrix const&);
+
+ double const& operator()(cols, rows) const;
+ double& operator()(cols, rows);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ matrix& operator*=(matrix const&);
+ matrix& operator*=(double);
+ matrix& operator/=(double);
+
+ double determinant() const;
+ double trace() const;
+
+ bool invert();
+ void transpose();
+ void lr_decompose(matrix& l, matrix& r) const;
+
+ bool is_invertible() const; // det(M) != 0
+
+ static matrix const& null(); // m[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
+ static matrix const& identity(); // m[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
+
+ private:
+
+ double data_[16];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ matrix operator-(matrix const&);
+
+ matrix operator*(matrix const&, matrix const&);
+ matrix operator*(matrix const&, double);
+ matrix operator*(double, matrix const&);
+ matrix operator/(matrix const&, double);
+
+ point operator*(matrix const&, point const&);
+ vector operator*(matrix const&, vector const&);
+
+ bool operator==(matrix const&, matrix const&);
+
+ matrix make_translation(double, double, double);
+ matrix make_translation(vector const&);
+
+ matrix make_scale(double, double, double);
+ matrix make_scale(vector const&);
+
+ matrix make_rotation_x(double);
+ matrix make_rotation_y(double);
+ matrix make_rotation_z(double);
+
+ double determinant(matrix const&);
+ double trace(matrix const&);
+ matrix inverse(matrix const&);
+ matrix transpose(matrix const&);
+
+ bool is_invertible(matrix const&);
+
+ std::ostream& operator<<(std::ostream&, matrix const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_MATRIX_HPP)
diff --git a/include/pixel.hpp b/include/pixel.hpp
new file mode 100644
index 0000000..171e414
--- /dev/null
+++ b/include/pixel.hpp
@@ -0,0 +1,30 @@
+#ifndef BUW_PIXEL_HPP
+#define BUW_PIXEL_HPP
+
+// header, system
+#include <iosfwd>
+
+// header, project
+#include <rgb.hpp>
+
+
+class pixel {
+public : // c'tor
+
+ pixel(std::size_t = 0, std::size_t = 0);
+ ~pixel();
+
+public : // methods
+
+ void print(std::ostream&) const;
+
+public : // member
+
+ std::size_t x;
+ std::size_t y;
+ rgb color;
+};
+
+std::ostream& operator<<(std::ostream&, const pixel&);
+
+#endif // BUW_PIXEL_HPP
diff --git a/include/point.hpp b/include/point.hpp
new file mode 100644
index 0000000..a697a41
--- /dev/null
+++ b/include/point.hpp
@@ -0,0 +1,77 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : point.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_POINT_HPP)
+
+#define BUW_MATH3D_POINT_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+#include <vector.hpp>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point {
+
+ public:
+
+ enum component { x = vector::x, y = vector::y, z = vector::z, w = vector::w };
+
+ point();
+ point(point const&);
+ point(double, double, double, double = 1.0); // x, y, z, w
+
+ ~point();
+
+ void swap(point&);
+
+ point& operator=(point const&);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ point& operator+=(vector const&);
+ point& operator-=(vector const&);
+
+ static point const& origin(); // p[0,0,0,1]
+
+ private:
+
+ double data_[4];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ point operator-(point const&);
+
+ point operator+(point const&, vector const&);
+ point operator-(point const&, vector const&);
+ bool operator==(point const&, point const&);
+
+ double distance(point const&, point const&);
+
+ std::ostream& operator<<(std::ostream&, point const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_POINT_HPP)
diff --git a/include/ppmwriter.hpp b/include/ppmwriter.hpp
new file mode 100644
index 0000000..bc5aef2
--- /dev/null
+++ b/include/ppmwriter.hpp
@@ -0,0 +1,31 @@
+#ifndef BUW_PPMWRITER_HPP
+#define BUW_PPMWRITER_HPP
+
+// header, system
+#include <string>
+#include <vector>
+
+// header, project
+#include <pixel.hpp>
+
+
+class ppmwriter
+{
+public:
+ ppmwriter(std::size_t w, std::size_t h, std::string const& file);
+ ppmwriter(std::size_t w, std::size_t h);
+ ~ppmwriter();
+
+public:
+ void write(pixel const& p);
+ void save(std::string const& file);
+ void save();
+
+private:
+ std::string file_;
+ std::vector<unsigned int> data_;
+ size_t width_;
+ size_t height_;
+};
+
+#endif // BUW_PPMWRITER
diff --git a/include/rgb.hpp b/include/rgb.hpp
new file mode 100644
index 0000000..af91357
--- /dev/null
+++ b/include/rgb.hpp
@@ -0,0 +1,38 @@
+#ifndef BUW_RGB_HPP
+#define BUW_RGB_HPP
+
+// header, system
+#include <iosfwd>
+
+
+class rgb {
+public : // enums, typedefs
+ enum component {r, g, b};
+ typedef float value_t;
+
+public : // c'tor
+ rgb();
+ rgb(rgb const&);
+ rgb(value_t r, value_t g, value_t b);
+
+ ~rgb();
+
+public : // methods
+ void swap(rgb&);
+ void print(std::ostream& os) const;
+
+ value_t& operator[](enum component);
+ const value_t& operator[](enum component) const;
+
+ rgb& operator= (const rgb&);
+ void operator+=(const rgb&);
+
+
+private: // members
+ value_t data_[3]; // rgb
+};
+
+rgb operator+(const rgb& a, const rgb& b);
+std::ostream& operator<<(std::ostream& os, rgb const&);
+
+#endif // BUW_RGB_HPP
diff --git a/include/shape.hpp b/include/shape.hpp
new file mode 100644
index 0000000..80192c4
--- /dev/null
+++ b/include/shape.hpp
@@ -0,0 +1,42 @@
+#ifndef _SHAPE_HPP
+#define _SHAPE_HPP
+
+#include <iostream>
+#include <string>
+#include "color.hpp"
+#include "point3d.hpp"
+
+class shape
+{
+ public:
+ shape();
+ shape(std::string const&, rgb const&);
+ shape(shape const&);
+ virtual ~shape();
+
+ virtual double volume() const =0;
+ virtual bool isInside(point3d const&) const =0;
+ virtual double surface() const =0;
+ virtual shape* clone() const =0;
+// color getColor() const;
+ std::string getName() const;
+ virtual void printOn(std::ostream& = std::cout) const;
+ int ref();
+ int unRef();
+ // shape* operator=(shape*);
+
+ private:
+
+ rgb color_;
+ std::string name_;
+ int refCount_;
+
+};
+
+std::ostream& operator<<(std::ostream&, shape const&);
+bool operator==(shape const& lhs, shape const& rhs);
+
+
+
+#endif /* _shape_HPP */
+
diff --git a/include/shape.hpp~ b/include/shape.hpp~
new file mode 100644
index 0000000..7265882
--- /dev/null
+++ b/include/shape.hpp~
@@ -0,0 +1,42 @@
+#ifndef _SHAPE_HPP
+#define _SHAPE_HPP
+
+#include <iostream>
+#include <string>
+#include "color.hpp"
+#include "point3d.hpp"
+
+class shape
+{
+ public:
+ shape();
+ shape(std::string const&, color const&);
+ shape(shape const&);
+ virtual ~shape();
+
+ virtual double volume() const =0;
+ virtual bool isInside(point3d const&) const =0;
+ virtual double surface() const =0;
+ virtual shape* clone() const =0;
+ color getColor() const;
+ std::string getName() const;
+ virtual void printOn(std::ostream& = std::cout) const;
+ int ref();
+ int unRef();
+ // shape* operator=(shape*);
+
+ //private:
+
+ color color_;
+ std::string name_;
+ int refCount_;
+
+};
+
+std::ostream& operator<<(std::ostream&, shape const&);
+bool operator==(shape const& lhs, shape const& rhs);
+
+
+
+#endif /* _shape_HPP */
+
diff --git a/include/shapeContainer.hpp b/include/shapeContainer.hpp
new file mode 100644
index 0000000..f6e8a97
--- /dev/null
+++ b/include/shapeContainer.hpp
@@ -0,0 +1,41 @@
+#ifndef _SHAPECONTAINER_HPP
+#define _SHAPECONTAINER_HPP
+
+#include <iostream>
+#include <string>
+#include "color.hpp"
+#include "point3d.hpp"
+#include "shape.hpp"
+#include <list>
+#include <algorithm>
+#include <numeric>
+#include <functional>
+
+class shapeContainer
+{
+ public:
+ shapeContainer();
+ shapeContainer(shapeContainer const&);
+ ~shapeContainer();
+
+ void insertShapeObj(shape *);
+ void deleteShapeObj(color const&);
+ void deleteShapeObj(std::string const&);
+ void print(std::ostream& stream=std::cout) const;
+ shapeContainer cloneDeep() const;
+ shapeContainer cloneShallow() const;
+ shapeContainer & operator=(shapeContainer const&);
+
+
+ //private:
+
+ std::list<shape*> shapeCon_;
+
+
+};
+
+void printShapeName(shape const*);
+double getTotalVolume(double, shape const*);
+
+#endif /* _shapecontainer_HPP */
+
diff --git a/include/sphere.hpp b/include/sphere.hpp
new file mode 100644
index 0000000..e0fac23
--- /dev/null
+++ b/include/sphere.hpp
@@ -0,0 +1,34 @@
+#ifndef _SPHERE_HPP
+#define _SPHERE_HPP
+
+#include "shape.hpp"
+#include "point3d.hpp"
+#include "color.hpp"
+
+class sphere : public shape
+{
+ public:
+ sphere();
+ sphere(point const&, double, std::string const&, rgb const&);
+ sphere(sphere const&);
+ ~sphere();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn( std::ostream&) const;
+ /*virtual*/ sphere* clone() const;
+ // sphere* operator=(sphere*);
+ // sphere operator=(sphere);
+
+
+ private:
+ point center_;
+ double radius_;
+
+};
+
+
+
+#endif /* _sphere_HPP */
+
diff --git a/include/sphere.hpp~ b/include/sphere.hpp~
new file mode 100644
index 0000000..29b8107
--- /dev/null
+++ b/include/sphere.hpp~
@@ -0,0 +1,34 @@
+#ifndef _SPHERE_HPP
+#define _SPHERE_HPP
+
+#include "shape.hpp"
+#include "point3d.hpp"
+#include "color.hpp"
+
+class sphere : public shape
+{
+ public:
+ sphere();
+ sphere(point const&, double, std::string const&, color const&);
+ sphere(sphere const&);
+ ~sphere();
+
+ /*virtual*/ double volume() const;
+ /*virtual*/ bool isInside(point const&) const;
+ /*virtual*/ double surface() const;
+ /*virtual*/ void printOn( std::ostream&) const;
+ /*virtual*/ sphere* clone() const;
+ // sphere* operator=(sphere*);
+ // sphere operator=(sphere);
+
+
+ private:
+ point center_;
+ double radius_;
+
+};
+
+
+
+#endif /* _sphere_HPP */
+
diff --git a/include/vector.hpp b/include/vector.hpp
new file mode 100644
index 0000000..bcd985c
--- /dev/null
+++ b/include/vector.hpp
@@ -0,0 +1,100 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : vector.hpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+#if !defined(BUW_MATH3D_VECTOR_HPP)
+
+#define BUW_MATH3D_VECTOR_HPP
+
+// includes, system
+#include <iosfwd> // fwd. decl: std::ostream
+
+// includes, project
+//#include <>
+
+namespace math3d {
+
+ // types, exported (class, enum, struct, union, typedef)
+
+ class point;
+
+ class vector {
+
+ public:
+
+ enum component { x = 0, y = 1, z = 2, w = 3 };
+
+ vector();
+ vector(vector const&);
+ vector(point const&, point const&); // second - first
+ vector(double, double, double, double = 0.0); // x, y, z, w
+
+ ~vector();
+
+ void swap(vector&);
+
+ vector& operator=(vector const&);
+
+ double const& operator[](component) const;
+ double& operator[](component);
+
+ vector& operator+=(vector const&);
+ vector& operator-=(vector const&);
+ vector& operator*=(double);
+ vector& operator/=(double);
+
+
+ double length() const;
+ double length_square() const;
+
+ static vector const& null(); // v[0,0,0,0]
+ static vector const& unit_x(); // v[1,0,0,0]
+ static vector const& unit_y(); // v[0,1,0,0]
+ static vector const& unit_z(); // v[0,0,1,0]
+
+ vector& normalize();
+
+ private:
+
+ double data_[4];
+
+ };
+
+ // variables, exported (extern)
+
+ // functions, inlined (inline)
+
+ // functions, exported (extern)
+
+ vector operator-(vector const&);
+
+ vector operator+(vector const&, vector const&);
+ vector operator-(point const&, point const&);
+ vector operator-(vector const&, vector const&);
+ vector operator*(vector const&, double);
+ vector operator*(double, vector const&);
+ vector operator/(vector const&, double);
+ bool operator==(vector const&, vector const&);
+
+ double length(vector const&);
+ double length_square(vector const&);
+ double dot(vector const&, vector const&);
+ vector cross(vector const&, vector const&);
+ vector normalize(vector const&);
+
+ std::ostream& operator<<(std::ostream&, vector const&);
+
+} // namespace math3d {
+
+#endif // #if !defined(BUW_MATH3D_VECTOR_HPP)
+
diff --git a/src/box.cpp b/src/box.cpp
new file mode 100644
index 0000000..1bfc993
--- /dev/null
+++ b/src/box.cpp
@@ -0,0 +1,83 @@
+
+
+#include "box.hpp"
+
+
+box::box() { std::cout << "Konstruktor Box\n"; }
+box::box(point const& p1, point const& p2, std::string const& name, color const& col)
+ : shape(name,col) , vertex_[0](p1), vertex_[1](p2)
+ { std::cout << "Konstruktor Box\n"; }
+box::box(box const& bx) : shape(bx) , vertex_(bx.vertex_[0]) , vertex_[1](bx.vertex_[1]) {}
+box::~box() { std::cout << "Destruktor Box\n"; }
+
+//
+// volume - Berechnung boxvolumen
+//
+double box::volume() const
+{
+ return std::abs( (vertex_[0].data[x]-vertex_[1].data[x]) * (vertex_[0].data[y]-vertex_[1].data[y]) * (vertex_[0].data[z]-vertex_[1].data[z]) );
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool box::isInside(point const& p) const
+{
+ return ( (p[x] >= vertex_[0].data[x] && p[x] <= vertex_[1].data[x]) &&
+ (p[y] >= vertex_[0].data[y] && p[y] <= vertex_[1].data[y]) &&
+ (p[z] >= vertex_[0].data[z] && p[z] <= vertex_[1].data[z]) );
+ //return (p.getx() >= vertex_.getx() && p.getx() <= vertex_.getx()+x_) &&
+ // (p.gety() >= vertex_.gety() && p.gety() <= vertex_.gety()+y_) &&
+ // (p.getz() >= vertex_.getz() && p.getz() <= vertex_.getz()+z_);
+
+ /*if ( skalarpro( point3d(-1,0,0), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety(), p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(1,0,0), point3d(p.getx()-vertex_.getx()-x_, p.gety()-vertex_.gety(), p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(0,1,0), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety()-y_, p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(0,-1,0), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety(), p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(0,0,1), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety(), p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(0,0,-1), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety(), p.getz()-vertex_.getz()+z_)) >= 0 )
+ return false;
+ else
+ return true;*/
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double box::surface() const
+{
+ return ( std::abs(2 * (vertex_[0].data[x]-vertex_[1].data[x]) * (vertex_[0].data[y]-vertex_[1].data[y]))
+ + std::abs(2 * (vertex_[0].data[x]-vertex_[1].data[x]) * (vertex_[0].data[z]-vertex_[1].data[z]))
+ + std::abs(2 * (vertex_[0].data[z]-vertex_[1].data[z]) * (vertex_[0].data[y]-vertex_[1].data[y])) );
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void box::printOn(std::ostream& stream) const
+{
+ stream << "\nBox: \n";
+ shape::printOn(stream);
+ //stream << "Vertex: " << vertex_[x] << " " << vertex_[y] << " " << vertex_[z] << "\n";
+ //stream << "Länge: " << x_ << " , Breite: " << z_ << " , Höhe: " << y_ << "\n";
+ stream << "Volumen: " << volume() << "\nOberfläche: " << surface() << "\n";
+}
+//
+
+
+//
+// clone
+//
+box* box::clone() const
+{
+ return new box(*this);
+}
+//
+
+
diff --git a/src/box.cpp~ b/src/box.cpp~
new file mode 100644
index 0000000..f9defbe
--- /dev/null
+++ b/src/box.cpp~
@@ -0,0 +1,89 @@
+
+
+#include "box.hpp"
+
+
+box::box() { std::cout << "Konstruktor Box\n"; }
+box::box(point const& p1, point const& p2, std::string const& name, color const& col)
+ : shape(name,col) , vertex_[0](p1), vertex_[1](p2)
+ { std::cout << "Konstruktor Box\n"; }
+box::box(box const& bx) : shape(bx) , vertex_(bx.vertex_[0]) , vertex_[1](bx.vertex_[1]) {}
+box::~box() { std::cout << "Destruktor Box\n"; }
+
+//
+// volume - Berechnung boxvolumen
+//
+double box::volume() const
+{
+ return std::abs( (vertex_[0].data[0]-vertex_[1].data[0]) * (vertex_[0].data[1]-vertex_[1].data[1]) * (vertex_[0].data[2]-vertex_[1].data[2]) );
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool box::isInside(point3d const& p) const
+{
+ return (p.getx() >= vertex_.getx() && p.getx() <= vertex_.getx()+x_) &&
+ (p.gety() >= vertex_.gety() && p.gety() <= vertex_.gety()+y_) &&
+ (p.getz() >= vertex_.getz() && p.getz() <= vertex_.getz()+z_);
+
+ /*if ( skalarpro( point3d(-1,0,0), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety(), p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(1,0,0), point3d(p.getx()-vertex_.getx()-x_, p.gety()-vertex_.gety(), p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(0,1,0), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety()-y_, p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(0,-1,0), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety(), p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(0,0,1), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety(), p.getz()-vertex_.getz())) >= 0 &&
+ skalarpro( point3d(0,0,-1), point3d(p.getx()-vertex_.getx(), p.gety()-vertex_.gety(), p.getz()-vertex_.getz()+z_)) >= 0 )
+ return false;
+ else
+ return true;*/
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double box::surface() const
+{
+ return std::abs(2 * x_ * y_) + std::abs(2 * x_ * z_) + std::abs(2 * y_ * z_);
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void box::printOn(std::ostream& stream) const
+{
+ stream << "\nBox: \n";
+ shape::printOn(stream);
+ stream << "Vertex: " << vertex_[x] << " " << vertex_[y] << " " << vertex_[z] << "\n";
+ stream << "Länge: " << x_ << " , Breite: " << z_ << " , Höhe: " << y_ << "\n";
+ stream << "Volumen: " << volume() << "\nOberfläche: " << surface() << "\n";
+}
+//
+
+
+//
+// clone
+//
+box* box::clone() const
+{
+ return new box(*this);
+}
+//
+
+
+/*
+//
+// operator =
+//
+box* box::operator=(box* bx)
+{
+ bx->ref();
+
+ return bx;
+}
+//*/
diff --git a/src/glutwindow.cpp b/src/glutwindow.cpp
new file mode 100644
index 0000000..dbcb064
--- /dev/null
+++ b/src/glutwindow.cpp
@@ -0,0 +1,153 @@
+// header i/f
+#include "glutwindow.hpp"
+
+// header, system
+#if WIN32
+ #include <time.h>
+ #include <windows.h>
+#else
+ #include <sys/time.h>
+#endif
+
+#ifdef __APPLE__
+ #include <GLUT/glut.h>
+#else
+ #include <GL/glut.h>
+#endif
+
+#include <iostream>
+#include <cassert>
+
+// header, project
+
+// globals
+glutwindow* g_glutwindow = 0;
+
+
+////////////////////////////////////////////////////////////////////////////////
+glutwindow::glutwindow(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[])
+ : width_(width),
+ height_(height),
+ posx_(posx),
+ posy_(posy),
+ name_(name)
+{
+ g_glutwindow = this;
+ buffer_.resize(width_ * height_);
+
+ glutInit(&argc,argv);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+
+ glutInitWindowPosition(int(posx_), int(posy_));
+ glutInitWindowSize(int(width_), int(height_));
+ glutCreateWindow(name_.c_str());
+
+ glutDisplayFunc(display);
+ glutReshapeFunc(reshape);
+ glutIdleFunc(idle);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+glutwindow::~glutwindow()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/*static*/ glutwindow&
+glutwindow::instance()
+{
+ assert(g_glutwindow);
+ return *g_glutwindow;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/*static*/ void
+glutwindow::init(std::size_t width, std::size_t height,
+ std::size_t posx, std::size_t posy,
+ std::string const& name,
+ int argc, char* argv[])
+{
+ static glutwindow instance(width, height, posx, posy, name, argc, argv);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::run()
+{
+ glutMainLoop();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t
+glutwindow::width() const {
+ return width_;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t
+glutwindow::height() const {
+ return height_;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::write(const pixel& p)
+{
+ // flip pixels, because of opengl glDrawPixels
+ size_t buf_pos = (width_*p.y + (p.x));
+ if (buf_pos >= buffer_.size() || (int)buf_pos < 0) {
+ std::cerr << "Fatal Error glutwindow::write(pixel p) : pixel out of image : " << (int)p.x << "," << (int)p.y << std::endl;
+ } else {
+ buffer_[buf_pos] = p.color;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void
+glutwindow::update()
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glDrawPixels(width_, height_, GL_RGB, GL_FLOAT, &(buffer_.front()));
+ glutSwapBuffers();
+
+ // upate only with 25Hz
+#if WIN32
+ Sleep(20);
+#else
+ usleep(20000);
+#endif
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void display()
+{
+ glutwindow::instance().update();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void reshape(int w, int h)
+{
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void idle()
+{
+ glutPostRedisplay();
+}
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..a6df1a9
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,90 @@
+#include <glutwindow.hpp>
+#include <ppmwriter.hpp>
+#include <pixel.hpp>
+
+#include <iostream>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#ifdef __APPLE__
+ #include <GLUT/glut.h>
+#else
+ #include <GL/glut.h>
+#endif
+
+// this is a dummy raytrace application
+class rt_application
+{
+public :
+
+ //
+ void raytrace() const
+ {
+ // size of a tile in checkerboard
+ const std::size_t checkersize = 20;
+
+ // get glutwindow instance
+ glutwindow& gw = glutwindow::instance();
+
+ // create a ppmwriter
+ ppmwriter pw(gw.width(), gw.height(), "./checkerboard.ppm");
+
+ // for all pixels of window
+ for (std::size_t y = 0; y < gw.height(); ++y) {
+ for (std::size_t x = 0; x < gw.width(); ++x) {
+
+ // create pixel at x,y
+ pixel p(x, y);
+
+ // compute color for pixel
+ if ( ((x/checkersize)%2) != ((y/checkersize)%2)) {
+ p.color = rgb(1.0, 1.0, float(x)/gw.height());
+ } else {
+ p.color = rgb(1.0, 0.0, float(y)/gw.width());
+ }
+
+ // write pixel to output window
+ gw.write(p);
+
+ // write pixel to image writer
+ pw.write(p);
+ }
+ }
+
+ // save final image
+ pw.save();
+ }
+
+private : // attributes
+
+ // you may add a scene description here
+
+};
+
+
+
+
+
+int main(int argc, char* argv[])
+{
+ // set resolution and checkersize
+ const std::size_t width = 400;
+ const std::size_t height = 400;
+
+ // create output window
+ glutwindow::init(width, height, 100, 100, "CheckerBoard", argc, argv);
+
+ // create a ray tracing application
+ rt_application app;
+
+ // start computation in thread
+ boost::thread thr(boost::bind(&rt_application::raytrace, &app));
+
+ // start output on glutwindow
+ glutwindow::instance().run();
+
+ // wait on thread
+ thr.join();
+
+ return 0;
+}
diff --git a/src/matrix.cpp b/src/matrix.cpp
new file mode 100644
index 0000000..2f97c0b
--- /dev/null
+++ b/src/matrix.cpp
@@ -0,0 +1,660 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : matrix.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "matrix.hpp"
+
+// includes, system
+
+#include <algorithm> // std::copy, std::swap_ranges
+#include <cmath> // std::cos, std::sin
+#include <iomanip> // std::fixed, std::setprecision
+#include <ostream> // std::ostream
+#include <limits> // std::numeric_limits
+
+// includes, project
+#include <point.hpp>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ double const null_array16[16] = {
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0
+ };
+
+ double const ident_array16[16] = {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+ };
+
+ // functions, internal
+
+ double
+ det3_helper(double a1, double a2, double a3,
+ double b1, double b2, double b3,
+ double c1, double c2, double c3)
+ {
+ return ((a1 * b2 * c3) + (a2 * b3 * c1) + (a3 * b1 * c2) -
+ (a1 * b3 * c2) - (a2 * b1 * c3) - (a3 * b2 * c1));
+ }
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ matrix::matrix()
+ {
+ std::copy(ident_array16, ident_array16+16, data_);
+ }
+
+ matrix::matrix(matrix const& rhs)
+ {
+ std::copy(rhs.data_, rhs.data_+16, data_);
+ }
+
+ matrix::matrix(double const a[16])
+ {
+ std::copy(a, a+16, data_);
+ }
+
+ matrix::~matrix()
+ {}
+
+ void
+ matrix::swap(matrix& rhs)
+ {
+ std::swap_ranges(data_, data_+16, rhs.data_);
+ }
+
+ matrix&
+ matrix::operator=(matrix const& rhs)
+ {
+ matrix tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ matrix::operator()(matrix::cols a, matrix::rows b) const
+ {
+ return data_[(b * 4) + a];
+ }
+
+ double&
+ matrix::operator()(matrix::cols a, matrix::rows b)
+ {
+ return data_[(b * 4) + a];
+ }
+
+ double const&
+ matrix::operator[](matrix::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ matrix::operator[](matrix::component idx)
+ {
+ return data_[idx];
+ }
+
+ matrix&
+ matrix::operator*=(matrix const& rhs)
+ {
+ matrix tmp;
+
+ tmp.data_[ 0] = (data_[ 0] * rhs.data_[ 0] +
+ data_[ 4] * rhs.data_[ 1] +
+ data_[ 8] * rhs.data_[ 2] +
+ data_[12] * rhs.data_[ 3]);
+ tmp.data_[ 1] = (data_[ 1] * rhs.data_[ 0] +
+ data_[ 5] * rhs.data_[ 1] +
+ data_[ 9] * rhs.data_[ 2] +
+ data_[13] * rhs.data_[ 3]);
+ tmp.data_[ 2] = (data_[ 2] * rhs.data_[ 0] +
+ data_[ 6] * rhs.data_[ 1] +
+ data_[10] * rhs.data_[ 2] +
+ data_[14] * rhs.data_[ 3]);
+ tmp.data_[ 3] = (data_[ 3] * rhs.data_[ 0] +
+ data_[ 7] * rhs.data_[ 1] +
+ data_[11] * rhs.data_[ 2] +
+ data_[15] * rhs.data_[ 3]);
+ tmp.data_[ 4] = (data_[ 0] * rhs.data_[ 4] +
+ data_[ 4] * rhs.data_[ 5] +
+ data_[ 8] * rhs.data_[ 6] +
+ data_[12] * rhs.data_[ 7]);
+ tmp.data_[ 5] = (data_[ 1] * rhs.data_[ 4] +
+ data_[ 5] * rhs.data_[ 5] +
+ data_[ 9] * rhs.data_[ 6] +
+ data_[13] * rhs.data_[ 7]);
+ tmp.data_[ 6] = (data_[ 2] * rhs.data_[ 4] +
+ data_[ 6] * rhs.data_[ 5] +
+ data_[10] * rhs.data_[ 6] +
+ data_[14] * rhs.data_[ 7]);
+ tmp.data_[ 7] = (data_[ 3] * rhs.data_[ 4] +
+ data_[ 7] * rhs.data_[ 5] +
+ data_[11] * rhs.data_[ 6] +
+ data_[15] * rhs.data_[ 7]);
+ tmp.data_[ 8] = (data_[ 0] * rhs.data_[ 8] +
+ data_[ 4] * rhs.data_[ 9] +
+ data_[ 8] * rhs.data_[10] +
+ data_[12] * rhs.data_[11]);
+ tmp.data_[ 9] = (data_[ 1] * rhs.data_[ 8] +
+ data_[ 5] * rhs.data_[ 9] +
+ data_[ 9] * rhs.data_[10] +
+ data_[13] * rhs.data_[11]);
+ tmp.data_[10] = (data_[ 2] * rhs.data_[ 8] +
+ data_[ 6] * rhs.data_[ 9] +
+ data_[10] * rhs.data_[10] +
+ data_[14] * rhs.data_[11]);
+ tmp.data_[11] = (data_[ 3] * rhs.data_[ 8] +
+ data_[ 7] * rhs.data_[ 9] +
+ data_[11] * rhs.data_[10] +
+ data_[15] * rhs.data_[11]);
+ tmp.data_[12] = (data_[ 0] * rhs.data_[12] +
+ data_[ 4] * rhs.data_[13] +
+ data_[ 8] * rhs.data_[14] +
+ data_[12] * rhs.data_[15]);
+ tmp.data_[13] = (data_[ 1] * rhs.data_[12] +
+ data_[ 5] * rhs.data_[13] +
+ data_[ 9] * rhs.data_[14] +
+ data_[13] * rhs.data_[15]);
+ tmp.data_[14] = (data_[ 2] * rhs.data_[12] +
+ data_[ 6] * rhs.data_[13] +
+ data_[10] * rhs.data_[14] +
+ data_[14] * rhs.data_[15]);
+ tmp.data_[15] = (data_[ 3] * rhs.data_[12] +
+ data_[ 7] * rhs.data_[13] +
+ data_[11] * rhs.data_[14] +
+ data_[15] * rhs.data_[15]);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ matrix&
+ matrix::operator*=(double rhs)
+ {
+ for (unsigned idx = 0; idx < 16; ++idx)
+ data_[idx] *= rhs;
+
+ return *this;
+ }
+
+ matrix&
+ matrix::operator/=(double rhs)
+ {
+ for (unsigned idx = 0; idx < 16; ++idx)
+ data_[idx] /= rhs;
+
+ return *this;
+ }
+
+ double
+ matrix::determinant() const
+ {
+ double const& a1(data_[ 0]);
+ double const& b1(data_[ 4]);
+ double const& c1(data_[ 8]);
+ double const& d1(data_[12]);
+
+ double const& a2(data_[ 1]);
+ double const& b2(data_[ 5]);
+ double const& c2(data_[ 9]);
+ double const& d2(data_[13]);
+
+ double const& a3(data_[ 2]);
+ double const& b3(data_[ 6]);
+ double const& c3(data_[10]);
+ double const& d3(data_[14]);
+
+ double const& a4(data_[ 3]);
+ double const& b4(data_[ 7]);
+ double const& c4(data_[11]);
+ double const& d4(data_[15]);
+
+ return (a1 * det3_helper(b2, b3, b4, c2, c3, c4, d2, d3, d4) -
+ b1 * det3_helper(a2, a3, a4, c2, c3, c4, d2, d3, d4) +
+ c1 * det3_helper(a2, a3, a4, b2, b3, b4, d2, d3, d4) -
+ d1 * det3_helper(a2, a3, a4, b2, b3, b4, c2, c3, c4));
+ }
+
+ double
+ matrix::trace() const
+ {
+ return data_[0] + data_[5] + data_[10] + data_[15];
+ }
+
+ bool
+ matrix::invert()
+ {
+ bool result(false);
+ double const d(determinant());
+
+ if (0.0 != d) {
+ double const& a1(data_[ 0]);
+ double const& b1(data_[ 4]);
+ double const& c1(data_[ 8]);
+ double const& d1(data_[12]);
+ double const& a2(data_[ 1]);
+ double const& b2(data_[ 5]);
+ double const& c2(data_[ 9]);
+ double const& d2(data_[13]);
+ double const& a3(data_[ 2]);
+ double const& b3(data_[ 6]);
+ double const& c3(data_[10]);
+ double const& d3(data_[14]);
+ double const& a4(data_[ 3]);
+ double const& b4(data_[ 7]);
+ double const& c4(data_[11]);
+ double const& d4(data_[15]);
+
+ double const di(1.0 / d);
+
+ matrix tmp;
+
+ tmp.data_[ 0] = det3_helper(b2, b3, b4, c2, c3, c4, d2, d3, d4) * di;
+ tmp.data_[ 1] = -det3_helper(a2, a3, a4, c2, c3, c4, d2, d3, d4) * di;
+ tmp.data_[ 2] = det3_helper(a2, a3, a4, b2, b3, b4, d2, d3, d4) * di;
+ tmp.data_[ 3] = -det3_helper(a2, a3, a4, b2, b3, b4, c2, c3, c4) * di;
+ tmp.data_[ 4] = -det3_helper(b1, b3, b4, c1, c3, c4, d1, d3, d4) * di;
+ tmp.data_[ 5] = det3_helper(a1, a3, a4, c1, c3, c4, d1, d3, d4) * di;
+ tmp.data_[ 6] = -det3_helper(a1, a3, a4, b1, b3, b4, d1, d3, d4) * di;
+ tmp.data_[ 7] = det3_helper(a1, a3, a4, b1, b3, b4, c1, c3, c4) * di;
+ tmp.data_[ 8] = det3_helper(b1, b2, b4, c1, c2, c4, d1, d2, d4) * di;
+ tmp.data_[ 9] = -det3_helper(a1, a2, a4, c1, c2, c4, d1, d2, d4) * di;
+ tmp.data_[10] = det3_helper(a1, a2, a4, b1, b2, b4, d1, d2, d4) * di;
+ tmp.data_[11] = -det3_helper(a1, a2, a4, b1, b2, b4, c1, c2, c4) * di;
+ tmp.data_[12] = -det3_helper(b1, b2, b3, c1, c2, c3, d1, d2, d3) * di;
+ tmp.data_[13] = det3_helper(a1, a2, a3, c1, c2, c3, d1, d2, d3) * di;
+ tmp.data_[14] = -det3_helper(a1, a2, a3, b1, b2, b3, d1, d2, d3) * di;
+ tmp.data_[15] = det3_helper(a1, a2, a3, b1, b2, b3, c1, c2, c3) * di;
+
+ swap(tmp);
+
+ result = true;
+ }
+
+ return result;
+ }
+
+ void
+ matrix::transpose()
+ {
+ matrix tmp(*this);
+
+ // data_[ 0] = tmp.data_[ 0];
+ data_[ 1] = tmp.data_[ 4];
+ data_[ 2] = tmp.data_[ 8];
+ data_[ 3] = tmp.data_[12];
+ data_[ 4] = tmp.data_[ 1];
+ // data_[ 5] = tmp.data_[ 5];
+ data_[ 6] = tmp.data_[ 9];
+ data_[ 7] = tmp.data_[13];
+ data_[ 8] = tmp.data_[ 2];
+ data_[ 9] = tmp.data_[ 6];
+ // data_[10] = tmp.data_[10];
+ data_[11] = tmp.data_[14];
+ data_[12] = tmp.data_[ 3];
+ data_[13] = tmp.data_[ 7];
+ data_[14] = tmp.data_[11];
+ // data_[15] = tmp.data_[15];
+ }
+
+
+ void
+ matrix::lr_decompose(matrix& l, matrix& r) const
+ {
+ // initialise matrices
+ r = *this;
+ l = matrix::identity();
+
+ // first row
+ double const q1 = r[ab] / r[aa];
+ double const q2 = r[ac] / r[aa];
+ double const q3 = r[ad] / r[aa];
+
+ r[ab] -= q1 * r[aa];
+ r[bb] -= q1 * r[ba];
+ r[cb] -= q1 * r[ca];
+ r[db] -= q1 * r[da];
+
+ r[ac] -= q2 * r[aa];
+ r[bc] -= q2 * r[ba];
+ r[cc] -= q2 * r[ca];
+ r[dc] -= q2 * r[da];
+
+ r[ad] -= q3 * r[aa];
+ r[bd] -= q3 * r[ba];
+ r[cd] -= q3 * r[ca];
+ r[dd] -= q3 * r[da];
+
+ l[ab] = q1;
+ l[ac] = q2;
+ l[ad] = q3;
+
+ // second row
+ double const q4 = r[bc] / r[bb];
+ double const q5 = r[bd] / r[bb];
+
+ r[bc] -= q4 * r[bb];
+ r[cc] -= q4 * r[cb];
+ r[dc] -= q4 * r[db];
+
+ r[bd] -= q5 * r[bc];
+ r[cd] -= q5 * r[cc];
+ r[dd] -= q5 * r[dc];
+
+ l[bc] = q4;
+ l[bd] = q5;
+
+ // third row
+ double q6 = r[cd] / r[cc];
+ r[cd] -= q6 * r[cc];
+ r[dd] -= q6 * r[dc];
+ l[cd] = q6;
+ }
+
+ bool
+ matrix::is_invertible() const
+ {
+ return 0 != determinant();
+ }
+
+ /* static */
+ matrix const&
+ matrix::null()
+ {
+ static matrix null_(null_array16);
+ return null_;
+ }
+
+ /* static */
+ matrix const&
+ matrix::identity()
+ {
+ static matrix identity_(ident_array16);
+ return identity_;
+ }
+
+ matrix
+ operator-(matrix const& rhs)
+ {
+ return matrix(rhs) *= -1.0;
+ }
+
+ matrix
+ operator*(matrix const& lhs, matrix const& rhs)
+ {
+ return matrix(lhs) *= rhs;
+ }
+
+ matrix
+ operator*(matrix const& lhs, double rhs)
+ {
+ return matrix(lhs) *= rhs;
+ }
+
+ matrix
+ operator*(double lhs, matrix const& rhs)
+ {
+ return matrix(rhs) *= lhs;
+ }
+
+ matrix
+ operator/(matrix const& lhs, double rhs)
+ {
+ return matrix(lhs) /= rhs;
+ }
+
+ point
+ operator*(matrix const& lhs, const point& rhs)
+ {
+ return point(lhs[matrix::aa] * rhs[point::x] +
+ lhs[matrix::ba] * rhs[point::y] +
+ lhs[matrix::ca] * rhs[point::z] +
+ lhs[matrix::da] * rhs[point::w],
+ lhs[matrix::ab] * rhs[point::x] +
+ lhs[matrix::bb] * rhs[point::y] +
+ lhs[matrix::cb] * rhs[point::z] +
+ lhs[matrix::db] * rhs[point::w],
+ lhs[matrix::ac] * rhs[point::x] +
+ lhs[matrix::bc] * rhs[point::y] +
+ lhs[matrix::cc] * rhs[point::z] +
+ lhs[matrix::dc] * rhs[point::w],
+ lhs[matrix::ad] * rhs[point::x] +
+ lhs[matrix::bd] * rhs[point::y] +
+ lhs[matrix::cd] * rhs[point::z] +
+ lhs[matrix::dd] * rhs[point::w]);
+ }
+
+ vector
+ operator*(matrix const& lhs, const vector& rhs)
+ {
+ return vector(lhs[matrix::aa] * rhs[vector::x] +
+ lhs[matrix::ba] * rhs[vector::y] +
+ lhs[matrix::ca] * rhs[vector::z] +
+ lhs[matrix::da] * rhs[vector::w],
+ lhs[matrix::ab] * rhs[vector::x] +
+ lhs[matrix::bb] * rhs[vector::y] +
+ lhs[matrix::cb] * rhs[vector::z] +
+ lhs[matrix::db] * rhs[vector::w],
+ lhs[matrix::ac] * rhs[vector::x] +
+ lhs[matrix::bc] * rhs[vector::y] +
+ lhs[matrix::cc] * rhs[vector::z] +
+ lhs[matrix::dc] * rhs[vector::w],
+ lhs[matrix::ad] * rhs[vector::x] +
+ lhs[matrix::bd] * rhs[vector::y] +
+ lhs[matrix::cd] * rhs[vector::z] +
+ lhs[matrix::dd] * rhs[vector::w]);
+ }
+
+ bool
+ operator==(matrix const& lhs, matrix const& rhs)
+ {
+ return (std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::aa] - rhs[matrix::aa]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ba] - rhs[matrix::ba]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::ca] - rhs[matrix::ca]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(lhs[matrix::da] - rhs[matrix::da]) < std::numeric_limits<double>::epsilon());
+ }
+
+ matrix
+ make_translation(double a, double b, double c)
+ {
+ matrix tmp;
+
+ tmp[matrix::da] = a;
+ tmp[matrix::db] = b;
+ tmp[matrix::dc] = c;
+
+ return tmp;
+ }
+
+ matrix
+ make_translation(vector const& a)
+ {
+ return make_translation(a[vector::x], a[vector::y], a[vector::z]);
+ }
+
+ matrix
+ make_scale(double a, double b, double c)
+ {
+ matrix tmp;
+
+ tmp[matrix::aa] = a;
+ tmp[matrix::bb] = b;
+ tmp[matrix::cc] = c;
+
+ return tmp;
+ }
+
+ matrix
+ make_scale(vector const& a)
+ {
+ return make_scale(a[vector::x], a[vector::y], a[vector::z]);
+ }
+
+ matrix
+ make_rotation_x(double a)
+ {
+ double const cos_a(std::cos(a));
+ double const sin_a(std::sin(a));
+
+ matrix tmp;
+
+ tmp[matrix::bb] = cos_a;
+ tmp[matrix::cb] = sin_a;
+ tmp[matrix::bc] = -sin_a;
+ tmp[matrix::cc] = cos_a;
+
+ return tmp;
+ }
+
+ matrix
+ make_rotation_y(double a)
+ {
+ double const cos_a(std::cos(a));
+ double const sin_a(std::sin(a));
+
+ matrix tmp;
+
+ tmp[matrix::aa] = cos_a;
+ tmp[matrix::ca] = -sin_a;
+ tmp[matrix::ac] = sin_a;
+ tmp[matrix::cc] = cos_a;
+
+ return tmp;
+ }
+
+ matrix
+ make_rotation_z(double a)
+ {
+ double const cos_a(std::cos(a));
+ double const sin_a(std::sin(a));
+
+ matrix tmp;
+
+ tmp[matrix::aa] = cos_a;
+ tmp[matrix::ba] = sin_a;
+ tmp[matrix::ab] = -sin_a;
+ tmp[matrix::bb] = cos_a;
+
+ return tmp;
+ }
+
+ double
+ determinant(matrix const& a)
+ {
+ return a.determinant();
+ }
+
+ double
+ trace(matrix const& a)
+ {
+ return a.trace();
+ }
+
+ matrix
+ inverse(matrix const& a)
+ {
+ matrix tmp(a);
+
+ tmp.invert();
+
+ return tmp;
+ }
+
+ matrix
+ transpose(matrix const& a)
+ {
+ matrix tmp(a);
+
+ tmp.transpose();
+
+ return tmp;
+ }
+
+ bool
+ is_invertible(matrix const& a)
+ {
+ return a.is_invertible();
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, matrix const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << std::fixed << std::setprecision(3)
+ << '['
+ << a[matrix::aa] << ','
+ << a[matrix::ba] << ','
+ << a[matrix::ca] << ','
+ << a[matrix::da] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ab] << ','
+ << a[matrix::bb] << ','
+ << a[matrix::cb] << ','
+ << a[matrix::db] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ac] << ','
+ << a[matrix::bc] << ','
+ << a[matrix::cc] << ','
+ << a[matrix::dc] << ','
+ << std::endl
+ << ' '
+ << a[matrix::ad] << ','
+ << a[matrix::bd] << ','
+ << a[matrix::cd] << ','
+ << a[matrix::dd]
+ << ']';
+ }
+
+ return os;
+ }
+
+} // namespace math3d {
diff --git a/src/pixel.cpp b/src/pixel.cpp
new file mode 100644
index 0000000..691ff5f
--- /dev/null
+++ b/src/pixel.cpp
@@ -0,0 +1,39 @@
+// header i/f
+#include "pixel.hpp"
+
+// header, system
+#include <ostream>
+
+
+pixel::pixel(std::size_t a, std::size_t b)
+ : x(a),
+ y(b),
+ color()
+{}
+
+
+///////////////////////////////////////////////////////////////////////////////
+pixel::~pixel()
+{}
+
+
+///////////////////////////////////////////////////////////////////////////////
+void
+pixel::print(std::ostream& os) const
+{
+ os << "pixel[" << (int)x << ',' << (int)y << "]("
+ << color[rgb::r] << ','
+ << color[rgb::g] << ','
+ << color[rgb::b] << ')';
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+std::ostream&
+operator<<(std::ostream& os, const pixel& a)
+{
+ std::ostream::sentry cerberus (os);
+ if (cerberus)
+ a.print(os);
+ return os;
+}
\ No newline at end of file
diff --git a/src/point.cpp b/src/point.cpp
new file mode 100644
index 0000000..1d32432
--- /dev/null
+++ b/src/point.cpp
@@ -0,0 +1,179 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : point.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "point.hpp"
+
+// includes, system
+
+#include <algorithm> // std::swap_ranges
+#include <cmath> // std::abs
+#include <limits> // std::numeric_limits
+#include <ostream> // std::ostream
+
+// includes, project
+
+// #include <>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ // functions, internal
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ point::point()
+ {
+ data_[0] = data_[1] = data_[2] = 0.0; data_[3] = 1.0;
+ }
+
+ point::point(point const& a)
+ {
+ data_[0] = a.data_[0];
+ data_[1] = a.data_[1];
+ data_[2] = a.data_[2];
+ data_[3] = a.data_[3];
+ }
+
+ point::point(double a, double b, double c, double d)
+ {
+ data_[0] = a;
+ data_[1] = b;
+ data_[2] = c;
+ data_[3] = d;
+ }
+
+ point::~point()
+ {}
+
+ void
+ point::swap(point& rhs)
+ {
+ std::swap_ranges(data_, data_+4, rhs.data_);
+ }
+
+ point&
+ point::operator=(point const& rhs)
+ {
+ point tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ point::operator[](point::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ point::operator[](point::component idx)
+ {
+ return data_[idx];
+ }
+
+ point&
+ point::operator+=(vector const& rhs)
+ {
+ data_[point::x] += rhs[vector::x];
+ data_[point::y] += rhs[vector::y];
+ data_[point::z] += rhs[vector::z];
+ // data_[point::w] += rhs[vector::w];
+
+ return *this;
+ }
+
+ point&
+ point::operator-=(vector const& rhs)
+ {
+ data_[point::x] -= rhs[vector::x];
+ data_[point::y] -= rhs[vector::y];
+ data_[point::z] -= rhs[vector::z];
+ // data_[point::w] -= rhs[vector::w];
+
+ return *this;
+ }
+
+ /* static */ point const&
+ point::origin()
+ {
+ static point origin_(0.0, 0.0, 0.0);
+ return origin_;
+ }
+
+ point
+ operator-(point const& rhs)
+ {
+ return point(-rhs[point::x], -rhs[point::y], -rhs[point::z], rhs[point::w]);
+ }
+
+ point
+ operator+(point const& lhs, vector const& rhs)
+ {
+ return point(lhs) += rhs;
+ }
+
+ point
+ operator-(point const& lhs, vector const& rhs)
+ {
+ return point(lhs) -= rhs;
+ }
+
+ double
+ distance(point const& a, point const& b)
+ {
+ return std::abs(length(vector(a, b)));
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, point const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << '['
+ << a[point::x] << ','
+ << a[point::y] << ','
+ << a[point::z] << ','
+ << a[point::w]
+ << ']';
+ }
+
+ return os;
+ }
+
+ bool
+ operator==(point const& lhs, point const& rhs)
+ {
+ return (std::fabs(rhs[point::x] - lhs[point::x]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[point::y] - lhs[point::y]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[point::z] - lhs[point::z]) < std::numeric_limits<double>::epsilon());
+ }
+
+
+} // namespace math3d {
diff --git a/src/ppmwriter.cpp b/src/ppmwriter.cpp
new file mode 100644
index 0000000..2b892bf
--- /dev/null
+++ b/src/ppmwriter.cpp
@@ -0,0 +1,81 @@
+// header i/f
+#include "ppmwriter.hpp"
+
+// header, system
+#include <iostream>
+#include <fstream>
+#include <cmath>
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::ppmwriter(std::size_t w, std::size_t h, std::string const& file)
+ : file_(file),
+ width_(w),
+ height_(h) {
+ data_.resize(w * h * (sizeof(rgb)/sizeof(rgb::value_t)));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::ppmwriter(std::size_t w, std::size_t h)
+ : file_("untitled.ppm"),
+ width_(w),
+ height_(h) {
+ data_.resize(w*h*(sizeof(rgb)/sizeof(rgb::value_t)));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+ppmwriter::~ppmwriter()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::write(pixel const& p)
+{
+ size_t buf_pos = width_*p.y + p.x;
+ std::size_t pos = (sizeof(rgb)/sizeof(rgb::value_t)) * buf_pos;
+ if (pos + ((sizeof(rgb)/sizeof(rgb::value_t)) - 1) > data_.size() || (int)buf_pos < 0) {
+ std::cerr << "Fatal Error ppmwriter::write(pixel p) : Critical write position\n";
+ } else {
+ data_[pos] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::r], 255.0));
+ data_[pos+1] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::g], 255.0));
+ data_[pos+2] = (unsigned int)std::max(0.0, std::min(255.0 * p.color[rgb::b], 255.0));
+ }
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::save(std::string const& file)
+{
+ file_ = file;
+ save();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void ppmwriter::save()
+{
+ const std::size_t line_length = 18;
+
+ std::fstream file(file_.c_str(), std::ios::out);
+ file.clear();
+ file << "P3 "
+ << (unsigned int)width_ << " "
+ << (unsigned int)height_ << " "
+ << 255 << " \n";
+
+ std::size_t pos = 1;
+ for (std::vector<unsigned int>::iterator i = data_.begin();
+ i < data_.end();
+ ++i, ++pos)
+ {
+ file << (int)*i << " ";
+ if (pos > line_length) {
+ file << "\n";
+ pos=0;
+ }
+ }
+
+ file.close();
+}
\ No newline at end of file
diff --git a/src/rgb.cpp b/src/rgb.cpp
new file mode 100644
index 0000000..cd8b355
--- /dev/null
+++ b/src/rgb.cpp
@@ -0,0 +1,116 @@
+// header i/f
+#include "rgb.hpp"
+
+// header, system
+#include <iostream>
+
+// header, project
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb()
+{
+ data_[0] = 0;
+ data_[1] = 0;
+ data_[2] = 0;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb(rgb const& rhs)
+{
+ data_[0] = rhs.data_[0];
+ data_[1] = rhs.data_[1];
+ data_[2] = rhs.data_[2];
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::rgb(float r, float g, float b)
+{
+ data_[0] = r;
+ data_[1] = g;
+ data_[2] = b;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::~rgb()
+{}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::swap(rgb& rhs)
+{
+ std::swap(data_[0], rhs.data_[0]);
+ std::swap(data_[1], rhs.data_[1]);
+ std::swap(data_[2], rhs.data_[2]);
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::print(std::ostream& os) const
+{
+ os << '(' << data_[0] << '|' << data_[1] << '|' << data_[2] << ')' << std::endl;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb::value_t&
+rgb::operator[](enum rgb::component c)
+{
+ return data_[c];
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+const rgb::value_t&
+rgb::operator[](enum rgb::component c) const
+{
+ return data_[c];
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb&
+rgb::operator=(rgb const& rhs)
+{
+ rgb tmp(rhs);
+ swap(tmp);
+ return *this;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+void
+rgb::operator+=(rgb const& a)
+{
+ data_[0]+=a.data_[0];
+ data_[1]+=a.data_[1];
+ data_[2]+=a.data_[2];
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+rgb
+operator+(rgb const& a, rgb const& b)
+{
+ rgb result(a);
+ result += b;
+ return result;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+std::ostream&
+operator<<(std::ostream& os, rgb const& color)
+{
+ color.print(os);
+ return os;
+}
diff --git a/src/shape.cpp b/src/shape.cpp
new file mode 100644
index 0000000..af79913
--- /dev/null
+++ b/src/shape.cpp
@@ -0,0 +1,112 @@
+
+
+#include "shape.hpp"
+
+
+shape::shape() : refCount_(0) { std::cout << "Konstruktor Shape\n"; }
+shape::shape(std::string const& s, rgb const& col) : color_(col) , name_(s) , refCount_(0) { std::cout << "Konstruktor Shape\n"; }
+shape::shape(shape const& sh) : color_(sh.color_) , name_(sh.name_), refCount_(0) { std::cout << "konstruktor Shape\n"; }
+shape::~shape() { std::cout << "Destruktor Shape\n"; }
+
+
+//
+// getcolor
+//
+//color shape::getColor() const
+//{
+// return color_;
+//}
+//
+
+//
+// getname
+//
+std::string shape::getName() const
+{
+ return name_;
+}
+//
+
+
+//
+// printOn
+//
+void shape::printOn( std::ostream& stream) const
+{
+ stream << "Name: " << name_ << ", Farbe: (" << color_[r] << "," << color_[g] << "," << color_[b] << ")\n";
+}
+//
+
+std::ostream& operator<<(std::ostream& stream, shape const& sh)
+{
+ sh.printOn(stream);
+ return stream;
+}
+
+bool operator==(shape const& lhs, shape const& rhs)
+{
+ return lhs.getName() == rhs.getName();
+}
+
+
+//
+// ref
+//
+int shape::ref()
+{
+ return ++refCount_;
+}
+//
+
+
+//
+// unRef
+//
+int shape::unRef()
+{
+ --refCount_;
+ if (refCount_ <= 0)
+ {
+ delete this;
+ return 0;
+ }
+ return refCount_;
+}
+//
+
+
+//
+// getRef
+//
+//int shape::getRef()
+//{
+// return refCount_;
+//}
+//
+
+
+//
+// operator =
+//
+/*shape* shape::operator=(shape* sh)
+{
+
+std::cout << "\nhahO\n";
+ sh->ref();
+
+ return sh;
+}*/
+//
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/shape.cpp~ b/src/shape.cpp~
new file mode 100644
index 0000000..ac7bb6e
--- /dev/null
+++ b/src/shape.cpp~
@@ -0,0 +1,112 @@
+
+
+#include "shape.hpp"
+
+
+shape::shape() : refCount_(0) { std::cout << "Konstruktor Shape\n"; }
+shape::shape(std::string const& s, color const& col) : color_(col) , name_(s) , refCount_(0) { std::cout << "Konstruktor Shape\n"; }
+shape::shape(shape const& sh) : color_(sh.color_) , name_(sh.name_), refCount_(0) { std::cout << "konstruktor Shape\n"; }
+shape::~shape() { std::cout << "Destruktor Shape\n"; }
+
+
+//
+// getcolor
+//
+color shape::getColor() const
+{
+ return color_;
+}
+//
+
+//
+// getname
+//
+std::string shape::getName() const
+{
+ return name_;
+}
+//
+
+
+//
+// printOn
+//
+void shape::printOn( std::ostream& stream) const
+{
+ stream << "Name: " << name_ << ", Farbe: (" << color_.getcolorr() << "," << color_.getcolorg() << "," << color_.getcolorb() << ")\n";
+}
+//
+
+std::ostream& operator<<(std::ostream& stream, shape const& sh)
+{
+ sh.printOn(stream);
+ return stream;
+}
+
+bool operator==(shape const& lhs, shape const& rhs)
+{
+ return lhs.getName() == rhs.getName();
+}
+
+
+//
+// ref
+//
+int shape::ref()
+{
+ return ++refCount_;
+}
+//
+
+
+//
+// unRef
+//
+int shape::unRef()
+{
+ --refCount_;
+ if (refCount_ <= 0)
+ {
+ delete this;
+ return 0;
+ }
+ return refCount_;
+}
+//
+
+
+//
+// getRef
+//
+//int shape::getRef()
+//{
+// return refCount_;
+//}
+//
+
+
+//
+// operator =
+//
+/*shape* shape::operator=(shape* sh)
+{
+
+std::cout << "\nhahO\n";
+ sh->ref();
+
+ return sh;
+}*/
+//
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/shapeContainer.cpp b/src/shapeContainer.cpp
new file mode 100644
index 0000000..413d9ad
--- /dev/null
+++ b/src/shapeContainer.cpp
@@ -0,0 +1,155 @@
+
+
+#include "shapeContainer.hpp"
+
+
+shapeContainer::shapeContainer() { std::cout << "Konstruktor ShapeContainer\n"; }
+shapeContainer::shapeContainer(shapeContainer const& sC) : shapeCon_(sC.shapeCon_)
+{
+ for (std::list<shape*>::iterator i = shapeCon_.begin(); i != shapeCon_.end(); ++i )
+ {
+ (**i).ref();
+ }
+ std::cout << "Konstruktor ShapeContainer\n";
+}
+shapeContainer::~shapeContainer()
+{
+ for (std::list<shape*>::iterator i = shapeCon_.begin(); i != shapeCon_.end(); ++i )
+ {
+ (**i).unRef();
+
+ }
+ std::cout << "Destruktor ShapeContainer\n";
+}
+
+
+//
+// insertShapeObj
+//
+void shapeContainer::insertShapeObj (shape * sh)
+{
+ shapeCon_.push_back(sh);
+ sh->ref();
+}
+//
+
+
+//
+// deleteShapeObj
+//
+void shapeContainer::deleteShapeObj (std::string const& name)
+{
+ for (std::list<shape*>::iterator i = shapeCon_.begin(); i != shapeCon_.end(); ++i )
+ {
+ if ( (**i).getName() == name )
+ {
+ (**i).unRef();
+
+ i = shapeCon_.erase(i);
+ }
+ }
+}
+//
+void shapeContainer::deleteShapeObj (color const& clr)
+{
+ for (std::list<shape*>::iterator i = shapeCon_.begin(); i != shapeCon_.end(); ++i )
+ {
+ if ( (**i).getColor() == clr )
+ {
+ (**i).unRef();
+
+ i = shapeCon_.erase(i);
+ }
+ }
+}
+//
+
+
+//
+// print
+//
+void shapeContainer::print(std::ostream& stream ) const
+{
+ double tempVol=0;
+
+ /*for (std::list<shape*>::const_iterator i = shapeCon_.begin(); i != shapeCon_.end(); ++i )
+ {
+ stream << "Name : " << (**i).getName() << "\n";
+ tempVol += (**i).volume();
+ }
+ stream << "Gesamtvolumen: " << tempVol << std::endl;*/
+
+ std::for_each (shapeCon_.begin(), shapeCon_.end(), printShapeName);
+ stream << "Gesamtvolumen: " << std::accumulate (shapeCon_.begin(), shapeCon_.end(), tempVol, getTotalVolume) << std::endl;
+
+}
+// std::for_each Hilfsfunktion
+void printShapeName(shape const* sh)
+{
+ std::cout << "Name: " << sh->getName() << std::endl;
+}
+// std::accumulate Hilfsfunktion
+double getTotalVolume(double x, shape const* sh2)
+{
+ return x + sh2->volume();
+}
+//
+
+
+//
+// cloneDeep
+//
+shapeContainer shapeContainer::cloneDeep() const
+{
+ shapeContainer sC;
+
+ for (std::list<shape*>::const_iterator i = shapeCon_.begin(); i != shapeCon_.end(); ++i )
+ {
+ shape* sh = (**i).clone();
+ sC.insertShapeObj(sh);
+ }
+ return sC;
+}
+//
+
+
+//
+// cloneShallow
+//
+shapeContainer shapeContainer::cloneShallow() const
+{
+ return shapeContainer(*this);
+}
+//
+
+
+
+//
+// operator =
+//
+shapeContainer& shapeContainer::operator=(shapeContainer const& sC)
+{
+ if ( &sC == this )
+ return *this;
+
+ //for (std::list<shape*>::iterator i = shapeCon_.begin(); i != shapeCon_.end(); ++i )
+ //{
+ // if ( (**i).unRef() == 0 ) i = shapeCon_.erase(i);
+ //}
+
+ //for (std::list<shape*>::iterator i = sC.shapeCon_.begin(); i != sC.shapeCon_.end(); ++i )
+ //{
+ // (**i).ref();
+ //}
+ // return sC;
+
+ shapeContainer temp(sC);
+ std::swap(temp.shapeCon_,this->shapeCon_);
+ return *this;
+
+}
+//
+
+
+
+
diff --git a/src/sphere.cpp b/src/sphere.cpp
new file mode 100644
index 0000000..08611dc
--- /dev/null
+++ b/src/sphere.cpp
@@ -0,0 +1,96 @@
+
+
+#include "sphere.hpp"
+
+
+sphere::sphere() { std::cout << "Konstruktor Sphere\n"; }
+sphere::sphere(point const& c, double r, std::string const& name, rgb const& col) : shape(name, col) , center_(c) , radius_(r)
+ { std::cout << "Konstruktor Sphere\n"; }
+sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
+sphere::~sphere() { std::cout << "Destruktor Sphere\n"; }
+
+//
+// volume - Berechnung Kugelvolumen
+//
+double sphere::volume() const
+{
+ return pow(radius_,3)*4/3*M_PI;
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool sphere::isInside(point const& p) const
+{
+ ( (sqrt(pow(center_[x]-p[x],2) + pow(center_[y]-p[y],2) + pow(center_[z]-p[z],2))) <= radius_)
+// return true;
+// else
+// return false;
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double sphere::surface() const
+{
+ return 4* radius_ * radius_ * M_PI;
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void sphere::printOn(std::ostream& stream) const
+{
+ stream << "\nSphere:\n";
+ shape::printOn(stream);
+ stream << "Mittelpunkt: (" << center_[x] << "," << center_[y] << "," << center_[z] << ")\n";
+ stream << "Radius: " << radius_ << "\n";
+}
+//
+
+
+//
+// clone
+//
+sphere* sphere::clone() const
+{
+ return new sphere(*this);
+}
+//
+
+/*
+//
+// operator =
+//
+sphere* sphere::operator=(sphere* sp)
+{
+ sp->ref();
+std::cout << "\nhihu\n";
+ return sp;
+}
+//
+
+sphere sphere::operator=(sphere sp)
+{
+ sp.ref();
+std::cout << "\nhihu\n";
+ return sp;
+}*/
+//
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/sphere.cpp~ b/src/sphere.cpp~
new file mode 100644
index 0000000..3a66a3a
--- /dev/null
+++ b/src/sphere.cpp~
@@ -0,0 +1,96 @@
+
+
+#include "sphere.hpp"
+
+
+sphere::sphere() { std::cout << "Konstruktor Sphere\n"; }
+sphere::sphere(point const& c, double r, std::string const& name, color const& col) : shape(name, col) , center_(c) , radius_(r)
+ { std::cout << "Konstruktor Sphere\n"; }
+sphere::sphere(sphere const& sp) : shape(sp) , center_(sp.center_) , radius_(sp.radius_) {}
+sphere::~sphere() { std::cout << "Destruktor Sphere\n"; }
+
+//
+// volume - Berechnung Kugelvolumen
+//
+double sphere::volume() const
+{
+ return pow(radius_,3)*4/3*M_PI;
+}
+//
+
+
+//
+// isInside - Kollision
+//
+bool sphere::isInside(point const& p) const
+{
+ ( (sqrt(pow(center_[x]-p[x],2) + pow(center_[y]-p[y],2) + pow(center_[z]-p[z],2))) <= radius_)
+// return true;
+// else
+// return false;
+}
+//
+
+
+//
+// surface - Berechnung Oberfläche
+//
+double sphere::surface() const
+{
+ return 4* radius_ * radius_ * M_PI;
+}
+//
+
+
+//
+// printOn - Ausgabe
+//
+void sphere::printOn(std::ostream& stream) const
+{
+ stream << "\nSphere:\n";
+ shape::printOn(stream);
+ stream << "Mittelpunkt: (" << center_[x] << "," << center_[y] << "," << center_[z] << ")\n";
+ stream << "Radius: " << radius_ << "\n";
+}
+//
+
+
+//
+// clone
+//
+sphere* sphere::clone() const
+{
+ return new sphere(*this);
+}
+//
+
+/*
+//
+// operator =
+//
+sphere* sphere::operator=(sphere* sp)
+{
+ sp->ref();
+std::cout << "\nhihu\n";
+ return sp;
+}
+//
+
+sphere sphere::operator=(sphere sp)
+{
+ sp.ref();
+std::cout << "\nhihu\n";
+ return sp;
+}*/
+//
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/vector.cpp b/src/vector.cpp
new file mode 100644
index 0000000..61d09b2
--- /dev/null
+++ b/src/vector.cpp
@@ -0,0 +1,309 @@
+// -*- Mode:C++ -*-
+
+/**************************************************************************************************/
+/* */
+/* Copyright (C) 2008 Bauhaus University Weimar */
+/* */
+/**************************************************************************************************/
+/* */
+/* module : vector.cpp */
+/* project : lectures in programming && software engineering, winter 08/09 */
+/* description: */
+/* */
+/**************************************************************************************************/
+
+// include i/f header
+
+#include "vector.hpp"
+
+// includes, system
+
+#include <algorithm> // std::swap_ranges
+#include <cmath> // std::sqrt
+#include <limits> // std::numeric_limits
+#include <ostream> // std::ostream
+
+// includes, project
+
+#include <point.hpp>
+
+// internal unnamed namespace
+
+namespace {
+
+ // types, internal (class, enum, struct, union, typedef)
+
+ // variables, internal
+
+ // functions, internal
+
+} // namespace {
+
+namespace math3d {
+
+ // variables, exported
+
+ // functions, exported
+
+ vector::vector()
+ {
+ data_[0] = data_[1] = data_[2] = data_[3] = 0.0;
+ }
+
+ vector::vector(vector const& a)
+ {
+ data_[0] = a.data_[0];
+ data_[1] = a.data_[1];
+ data_[2] = a.data_[2];
+ data_[3] = a.data_[3];
+ }
+
+ vector::vector(point const& a, point const& b)
+ {
+ data_[0] = b[point::x] - a[point::x];
+ data_[1] = b[point::y] - a[point::y];
+ data_[2] = b[point::z] - a[point::z];
+ data_[3] = 0.0;
+ }
+
+ vector::vector(double a, double b, double c, double d)
+ {
+ data_[0] = a;
+ data_[1] = b;
+ data_[2] = c;
+ data_[3] = d;
+ }
+
+ vector::~vector()
+ {}
+
+ void
+ vector::swap(vector& rhs)
+ {
+ std::swap_ranges(data_, data_+4, rhs.data_);
+ }
+
+ vector&
+ vector::operator=(vector const& rhs)
+ {
+ vector tmp(rhs);
+
+ swap(tmp);
+
+ return *this;
+ }
+
+ double const&
+ vector::operator[](vector::component idx) const
+ {
+ return data_[idx];
+ }
+
+ double&
+ vector::operator[](vector::component idx)
+ {
+ return data_[idx];
+ }
+
+ vector&
+ vector::operator+=(vector const& rhs)
+ {
+ data_[0] += rhs.data_[0];
+ data_[1] += rhs.data_[1];
+ data_[2] += rhs.data_[2];
+ // data_[3] += rhs.data_[3];
+
+ return *this;
+ }
+
+ vector&
+ vector::operator-=(vector const& rhs)
+ {
+ data_[0] -= rhs.data_[0];
+ data_[1] -= rhs.data_[1];
+ data_[2] -= rhs.data_[2];
+ // data_[3] -= rhs.data_[3];
+
+ return *this;
+ }
+
+ vector&
+ vector::operator*=(double rhs)
+ {
+ data_[0] *= rhs;
+ data_[1] *= rhs;
+ data_[2] *= rhs;
+ data_[3] *= rhs;
+
+ return *this;
+ }
+
+ vector&
+ vector::operator/=(double rhs)
+ {
+ data_[0] /= rhs;
+ data_[1] /= rhs;
+ data_[2] /= rhs;
+ data_[3] /= rhs;
+
+ return *this;
+ }
+
+ double
+ vector::length() const
+ {
+ return std::sqrt(length_square());
+ }
+
+ double
+ vector::length_square() const
+ {
+ return dot(*this, *this);
+ }
+
+ vector&
+ vector::normalize()
+ {
+ vector tmp(*this);
+
+ tmp /= length();
+
+ swap(tmp);
+ return *this;
+ }
+
+ vector
+ operator-(vector const& rhs)
+ {
+ return vector(rhs) *= -1.0;
+ }
+
+ vector
+ operator+(vector const& lhs, vector const& rhs)
+ {
+ return vector(lhs) += rhs;
+ }
+
+ vector
+ operator-(point const& lhs, point const& rhs)
+ {
+ return vector(rhs, lhs);
+ }
+
+ vector
+ operator-(vector const& lhs, vector const& rhs)
+ {
+ return vector(lhs) -= rhs;
+ }
+
+ vector
+ operator*(vector const& lhs, double rhs)
+ {
+ return vector(lhs) *= rhs;
+ }
+
+ vector
+ operator*(double lhs, vector const& rhs)
+ {
+ return vector(rhs) *= lhs;
+ }
+
+ vector
+ operator/(vector const& lhs, double rhs)
+ {
+ return vector(lhs) /= rhs;
+ }
+
+ double
+ length(vector const& a)
+ {
+ return a.length();
+ }
+
+ double
+ length_square(vector const& a)
+ {
+ return a.length_square();
+ }
+
+ /* static */ vector const&
+ vector::null()
+ {
+ static vector null_(0.0, 0.0, 0.0);
+ return null_;
+ }
+
+ /* static */ vector const&
+ vector::unit_x()
+ {
+ static vector unit_x_(1.0, 0.0, 0.0);
+ return unit_x_;
+ }
+
+ /* static */ vector const&
+ vector::unit_y()
+ {
+ static vector unit_y_(0.0, 1.0, 0.0);
+ return unit_y_;
+ }
+
+ /* static */ vector const&
+ vector::unit_z()
+ {
+ static vector unit_z_(0.0, 0.0, 1.0);
+ return unit_z_;
+ }
+
+ double
+ dot(vector const& lhs, vector const& rhs)
+ {
+ return ((lhs[vector::x] * rhs[vector::x]) +
+ (lhs[vector::y] * rhs[vector::y]) +
+ (lhs[vector::z] * rhs[vector::z]));
+ }
+
+ vector
+ cross(vector const& lhs, vector const& rhs)
+ {
+ return vector(((lhs[vector::y] * rhs[vector::z]) - (lhs[vector::z] * rhs[vector::y])),
+ ((lhs[vector::z] * rhs[vector::x]) - (lhs[vector::x] * rhs[vector::z])),
+ ((lhs[vector::x] * rhs[vector::y]) - (lhs[vector::y] * rhs[vector::x])));
+ }
+
+ vector
+ normalize(vector const& a)
+ {
+ vector tmp(a);
+
+ tmp.normalize();
+
+ return tmp;
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os, vector const& a)
+ {
+ std::ostream::sentry const cerberus(os);
+
+ if (cerberus) {
+ os << '['
+ << a[vector::x] << ','
+ << a[vector::y] << ','
+ << a[vector::z] << ','
+ << a[vector::w]
+ << ']';
+ }
+
+ return os;
+ }
+
+ bool
+ operator==(vector const& lhs, vector const& rhs)
+ {
+ return (std::fabs(rhs[vector::x] - lhs[vector::x]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[vector::y] - lhs[vector::y]) < std::numeric_limits<double>::epsilon() &&
+ std::fabs(rhs[vector::z] - lhs[vector::z]) < std::numeric_limits<double>::epsilon());
+ }
+
+} // namespace math3d {
+
|
smejkalp/Bipartite
|
d198e6bd07d3134c5b9ce1b62b940549b78a9509
|
ptakoviny
|
diff --git a/src/Bipartite.cpp b/src/Bipartite.cpp
index dbbeb33..3d6ea9d 100644
--- a/src/Bipartite.cpp
+++ b/src/Bipartite.cpp
@@ -1,24 +1,24 @@
//============================================================================
// Name : Bipartite.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <stack>
#include "State.h"
using namespace std;
int main() {
State *firstState;
firstState = new State();
stack<State*> states;
-
+egw fgkwrkrhkwrgh
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
|
smejkalp/Bipartite
|
408ac15dd2e74a1bfc2b219879b1517532b1ec2b
|
Naivni implementace konstruktoru
|
diff --git a/Debug/Bipartite b/Debug/Bipartite
new file mode 100755
index 0000000..323d1af
Binary files /dev/null and b/Debug/Bipartite differ
diff --git a/Debug/src/Bipartite.o b/Debug/src/Bipartite.o
new file mode 100644
index 0000000..7c0d429
Binary files /dev/null and b/Debug/src/Bipartite.o differ
diff --git a/src/Bipartite.cpp b/src/Bipartite.cpp
index 82843ce..dbbeb33 100644
--- a/src/Bipartite.cpp
+++ b/src/Bipartite.cpp
@@ -1,23 +1,24 @@
//============================================================================
// Name : Bipartite.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <stack>
#include "State.h"
using namespace std;
int main() {
+ State *firstState;
-
+ firstState = new State();
stack<State*> states;
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
|
bpilkerton/php-crpapi
|
e027bc12ea9382a9952d95f190c7f9a4afc831d6
|
OCD tab2space
|
diff --git a/crpapi.php b/crpapi.php
index 763030d..29412d9 100644
--- a/crpapi.php
+++ b/crpapi.php
@@ -1,91 +1,91 @@
<?php
/**
* class php-crpapi
* Simple PHP client library for working with the Center for Responsive Politics' API.
* Information on CRP's API can be found at http://www.opensecrets.org/action/api_doc.php
* Information on using this class, including examples at http://github.com/bpilkerton/php-crpapi
* @author Ben Pilkerton <[email protected]>
* @version 0.2
*/
class crp_api {
- function __construct($method=NULL,$params=NULL) {
+ function __construct($method=NULL,$params=NULL) {
- $this->api_key = "";
- $this->base_url = "http://api.opensecrets.org/";
- $this->output = "json";
-
- //Allow output type to be overridden on object instantiation
- $this->output = isset($params['output']) ? $params['output']: $this->output;
- $this->method = $method;
- self::load_params($params);
-
- $this->file_hash = md5($method . "," . implode(",",$params));
- $this->cache_hash = "dataCache/" . $this->file_hash;
- $this->cache_time = 86400; #one day
-
- }
+ $this->api_key = "";
+ $this->base_url = "http://api.opensecrets.org/";
+ $this->output = "json";
+
+ //Allow output type to be overridden on object instantiation
+ $this->output = isset($params['output']) ? $params['output']: $this->output;
+ $this->method = $method;
+ self::load_params($params);
+
+ $this->file_hash = md5($method . "," . implode(",",$params));
+ $this->cache_hash = "dataCache/" . $this->file_hash;
+ $this->cache_time = 86400; #one day
+
+ }
- private function load_params($params) {
- $this->url = $this->base_url . "?method=" . $this->method .
- "&apikey=" . $this->api_key;
+ private function load_params($params) {
+ $this->url = $this->base_url . "?method=" . $this->method .
+ "&apikey=" . $this->api_key;
- foreach ($params as $key=>$val) {
- $this->url .= "&" . $key . "=" . $val;
- $this->$key = $val;
- }
+ foreach ($params as $key=>$val) {
+ $this->url .= "&" . $key . "=" . $val;
+ $this->$key = $val;
+ }
- return;
- }
-
- public function get_data($use_cache=true) {
-
- if ($use_cache and file_exists($this->cache_hash) and (time() - filectime($this->cache_hash) < $this->cache_time)) {
-
- $this->cache_hit = true;
- $file = fopen($this->cache_hash,"r");
- $this->data = stream_get_contents($file);
- $this->data = gzuncompress($this->data);
- $this->data = unserialize($this->data);
- fclose($file);
+ return;
+ }
+
+ public function get_data($use_cache=true) {
+
+ if ($use_cache and file_exists($this->cache_hash) and (time() - filectime($this->cache_hash) < $this->cache_time)) {
+
+ $this->cache_hit = true;
+ $file = fopen($this->cache_hash,"r");
+ $this->data = stream_get_contents($file);
+ $this->data = gzuncompress($this->data);
+ $this->data = unserialize($this->data);
+ fclose($file);
$this->response_headers = "No http request sent, using cache";
- } else {
- $this->cache_hit = false;
- $this->data = file_get_contents($this->url);
+ } else {
+ $this->cache_hit = false;
+ $this->data = file_get_contents($this->url);
$this->response_headers = $http_response_header;
- switch ($this->output) {
- case "json":
- $this->data = json_decode($this->data,true);
- break;
- case "xml":
- $this->data = simplexml_load_string($this->data);
- break;
- default:
- die("Unknown output type. Use 'json' or 'xml'");
- }
+ switch ($this->output) {
+ case "json":
+ $this->data = json_decode($this->data,true);
+ break;
+ case "xml":
+ $this->data = simplexml_load_string($this->data);
+ break;
+ default:
+ die("Unknown output type. Use 'json' or 'xml'");
+ }
- if ($use_cache) {
- $file = fopen($this->cache_hash,"w");
- $store = serialize($this->data);
- $store = gzcompress($store);
- fwrite($file,$store);
- fclose($file);
- }
- }
-
- return $this->data;
- }
-
- function get_cache_status() {
- return $this->cache_hit;
- }
+ if ($use_cache) {
+ $file = fopen($this->cache_hash,"w");
+ $store = serialize($this->data);
+ $store = gzcompress($store);
+ fwrite($file,$store);
+ fclose($file);
+ }
+ }
+
+ return $this->data;
+ }
+
+ function get_cache_status() {
+ return $this->cache_hit;
+ }
- function get_response_headers() {
- return $this->response_headers;
- }
+ function get_response_headers() {
+ return $this->response_headers;
+ }
}
?>
diff --git a/example.php b/example.php
index 66a2ede..19825a2 100644
--- a/example.php
+++ b/example.php
@@ -1,108 +1,108 @@
<?php
/**
*
* php-crpapi example usage
* @author Ben Pilkerton
*
*
* There are a few options which need to be defined in the constructor
* in crpapi.php. These include specifying your API key, default
* output type (json recommended, default) and cache lifetime
* (one day is default).
*
* Include the CRP API Library and create an object instance, specifying
* the parameters. In this example, we specify the output type. This
* could be ommitted and the default (defined in the constructor) will
* be used.
*
**/
require_once('crpapi.php');
/**
* Setup the class instance with our request parameters
**/
$crp = new crp_api("candIndustry", Array("cid"=>"N00002408","cycle"=>"2012","output"=>"json"));
/**
* These variables are exposed upon instantiation
**/
echo "<h2>Request data</h2>";
echo $crp->api_key . "<br />";
echo $crp->output . "<br />";
echo $crp->method . "<br />";
echo $crp->base_url . "<br />";
echo $crp->url . "<br />";
echo "<hr />";
/**
* Get the data. This example retrieves json data which is converted to
* an associative array. If using xml, a SimpleXML object will be returned.
* The getData method can optionally be passed a true/false value (true is
* default). If set to false, a local file cache will not be used.
**/
$data = $crp->get_data();
/**
* Show the cache status. By default, the library caches API query results in a
* gzipped, serialized form in a text file in the dataCache directory. If you do
* not desire file caching, call get_data(false) (see above). The cache life can
* be set by altering $this->cache_time value in crpapi.php. The default is
* one day.
**/
echo "<h2>Request Cache Status</h2>";
if ($crp->get_cache_status()) {
- echo "Cache Hit";
+ echo "Cache Hit";
} else {
- echo "Cache Miss";
+ echo "Cache Miss";
}
echo "<hr />";
/**
* Show response headers. If not using the cache or the cache is empty an http
* request is made to the service. You can view the HTTP response headers with
* something like this.
**/
if (!$crp->get_cache_status()) {
echo "<h2>HTTP Response Headers</h2>";
foreach ($crp->response_headers as $header) {
echo $header . "<br />";
}
echo "<hr />";
}
/**
* Iterate over the results
**/
echo "<h2>Parsed Results</h2>";
echo "<h3>Meta data</h3>";
foreach ($data['response']['industries']['@attributes'] as $key=>$val) {
- echo $key . " => " . $val . "<br />";
+ echo $key . " => " . $val . "<br />";
}
echo "<h3>Actual data</h3>";
echo "<table><tr><th>Industry</th><th>Indivs</th><th>PACs</th><th>Total</th></tr>";
foreach ($data['response']['industries']['industry'] as $ind) {
- foreach ($ind as $row) {
- echo "<tr><td>" . $row['industry_name'] . "</td><td>$" .
- $row['indivs'] . "</td><td>$" . $row['pacs'] . "</td><td>$" .
- $row['total'] . "</td></tr>";
- }
+ foreach ($ind as $row) {
+ echo "<tr><td>" . $row['industry_name'] . "</td><td>$" .
+ $row['indivs'] . "</td><td>$" . $row['pacs'] . "</td><td>$" .
+ $row['total'] . "</td></tr>";
+ }
}
echo "</table>";
?>
\ No newline at end of file
|
bpilkerton/php-crpapi
|
a2f18a754bbfa773213c6a3cf8bea8206da4d44f
|
removed key
|
diff --git a/crpapi.php b/crpapi.php
index 474a063..763030d 100644
--- a/crpapi.php
+++ b/crpapi.php
@@ -1,91 +1,91 @@
<?php
/**
* class php-crpapi
* Simple PHP client library for working with the Center for Responsive Politics' API.
* Information on CRP's API can be found at http://www.opensecrets.org/action/api_doc.php
* Information on using this class, including examples at http://github.com/bpilkerton/php-crpapi
* @author Ben Pilkerton <[email protected]>
* @version 0.2
*/
class crp_api {
function __construct($method=NULL,$params=NULL) {
- $this->api_key = "75ac04de8fc38139e66a5156bd18a828";
+ $this->api_key = "";
$this->base_url = "http://api.opensecrets.org/";
$this->output = "json";
//Allow output type to be overridden on object instantiation
$this->output = isset($params['output']) ? $params['output']: $this->output;
$this->method = $method;
self::load_params($params);
$this->file_hash = md5($method . "," . implode(",",$params));
$this->cache_hash = "dataCache/" . $this->file_hash;
$this->cache_time = 86400; #one day
}
private function load_params($params) {
$this->url = $this->base_url . "?method=" . $this->method .
"&apikey=" . $this->api_key;
foreach ($params as $key=>$val) {
$this->url .= "&" . $key . "=" . $val;
$this->$key = $val;
}
return;
}
public function get_data($use_cache=true) {
if ($use_cache and file_exists($this->cache_hash) and (time() - filectime($this->cache_hash) < $this->cache_time)) {
$this->cache_hit = true;
$file = fopen($this->cache_hash,"r");
$this->data = stream_get_contents($file);
$this->data = gzuncompress($this->data);
$this->data = unserialize($this->data);
fclose($file);
$this->response_headers = "No http request sent, using cache";
} else {
$this->cache_hit = false;
$this->data = file_get_contents($this->url);
$this->response_headers = $http_response_header;
switch ($this->output) {
case "json":
$this->data = json_decode($this->data,true);
break;
case "xml":
$this->data = simplexml_load_string($this->data);
break;
default:
die("Unknown output type. Use 'json' or 'xml'");
}
if ($use_cache) {
$file = fopen($this->cache_hash,"w");
$store = serialize($this->data);
$store = gzcompress($store);
fwrite($file,$store);
fclose($file);
}
}
return $this->data;
}
function get_cache_status() {
return $this->cache_hit;
}
function get_response_headers() {
return $this->response_headers;
}
}
?>
|
bpilkerton/php-crpapi
|
b5623cbc21a002173af4370a9a028533ef598996
|
added response header access and clean up
|
diff --git a/crpapi.php b/crpapi.php
index c35eed0..474a063 100644
--- a/crpapi.php
+++ b/crpapi.php
@@ -1,85 +1,91 @@
<?php
/**
* class php-crpapi
* Simple PHP client library for working with the Center for Responsive Politics' API.
* Information on CRP's API can be found at http://www.opensecrets.org/action/api_doc.php
* Information on using this class, including examples at http://github.com/bpilkerton/php-crpapi
* @author Ben Pilkerton <[email protected]>
* @version 0.2
*/
-class crpData {
+class crp_api {
function __construct($method=NULL,$params=NULL) {
- $this->apikey = "";
- $this->baseurl = "http://api.opensecrets.org/";
+ $this->api_key = "75ac04de8fc38139e66a5156bd18a828";
+ $this->base_url = "http://api.opensecrets.org/";
$this->output = "json";
//Allow output type to be overridden on object instantiation
$this->output = isset($params['output']) ? $params['output']: $this->output;
$this->method = $method;
- self::loadParams($params);
+ self::load_params($params);
- $this->fileHash = md5($method . "," . implode(",",$params));
- $this->cacheHash = "dataCache/" . $this->fileHash;
- $this->cacheTime = 86400; #one day
+ $this->file_hash = md5($method . "," . implode(",",$params));
+ $this->cache_hash = "dataCache/" . $this->file_hash;
+ $this->cache_time = 86400; #one day
}
- private function loadParams($params) {
- $this->url = $this->baseurl . "?method=" . $this->method .
- "&apikey=" . $this->apikey;
+ private function load_params($params) {
+ $this->url = $this->base_url . "?method=" . $this->method .
+ "&apikey=" . $this->api_key;
foreach ($params as $key=>$val) {
$this->url .= "&" . $key . "=" . $val;
$this->$key = $val;
}
return;
}
- public function getData($useCache=true) {
+ public function get_data($use_cache=true) {
- if ($useCache and file_exists($this->cacheHash) and (time() - filectime($this->cacheHash) < $this->cacheTime)) {
+ if ($use_cache and file_exists($this->cache_hash) and (time() - filectime($this->cache_hash) < $this->cache_time)) {
- $this->cacheHit = true;
- $file = fopen($this->cacheHash,"r");
+ $this->cache_hit = true;
+ $file = fopen($this->cache_hash,"r");
$this->data = stream_get_contents($file);
$this->data = gzuncompress($this->data);
$this->data = unserialize($this->data);
fclose($file);
+ $this->response_headers = "No http request sent, using cache";
} else {
- $this->cacheHit = false;
+ $this->cache_hit = false;
$this->data = file_get_contents($this->url);
-
+ $this->response_headers = $http_response_header;
+
switch ($this->output) {
case "json":
$this->data = json_decode($this->data,true);
break;
case "xml":
$this->data = simplexml_load_string($this->data);
break;
default:
die("Unknown output type. Use 'json' or 'xml'");
}
- if ($useCache) {
- $file = fopen($this->cacheHash,"w");
+ if ($use_cache) {
+ $file = fopen($this->cache_hash,"w");
$store = serialize($this->data);
$store = gzcompress($store);
fwrite($file,$store);
fclose($file);
}
}
return $this->data;
}
- function getCacheStatus() {
- return $this->cacheHit;
+ function get_cache_status() {
+ return $this->cache_hit;
}
+ function get_response_headers() {
+ return $this->response_headers;
+ }
+
}
?>
diff --git a/example.php b/example.php
index f7d9516..66a2ede 100644
--- a/example.php
+++ b/example.php
@@ -1,76 +1,108 @@
<?php
/**
*
* php-crpapi example usage
* @author Ben Pilkerton
*
*
* There are a few options which need to be defined in the constructor
* in crpapi.php. These include specifying your API key, default
* output type (json recommended, default) and cache lifetime
* (one day is default).
*
* Include the CRP API Library and create an object instance, specifying
* the parameters. In this example, we specify the output type. This
* could be ommitted and the default (defined in the constructor) will
* be used.
*
**/
require_once('crpapi.php');
-$crp = new crpData("candIndustry", Array("cid"=>"N00002408","cycle"=>"2010","output"=>"json"));
+/**
+ * Setup the class instance with our request parameters
+**/
+
+$crp = new crp_api("candIndustry", Array("cid"=>"N00002408","cycle"=>"2012","output"=>"json"));
/**
* These variables are exposed upon instantiation
**/
-echo $crp->apikey . "<br />";
+echo "<h2>Request data</h2>";
+
+echo $crp->api_key . "<br />";
echo $crp->output . "<br />";
echo $crp->method . "<br />";
-echo $crp->baseurl . "<br />";
+echo $crp->base_url . "<br />";
echo $crp->url . "<br />";
echo "<hr />";
/**
* Get the data. This example retrieves json data which is converted to
* an associative array. If using xml, a SimpleXML object will be returned.
* The getData method can optionally be passed a true/false value (true is
* default). If set to false, a local file cache will not be used.
**/
-$data = $crp->getData();
+$data = $crp->get_data();
+
+/**
+ * Show the cache status. By default, the library caches API query results in a
+ * gzipped, serialized form in a text file in the dataCache directory. If you do
+ * not desire file caching, call get_data(false) (see above). The cache life can
+ * be set by altering $this->cache_time value in crpapi.php. The default is
+ * one day.
+**/
+
+echo "<h2>Request Cache Status</h2>";
+
+if ($crp->get_cache_status()) {
+ echo "Cache Hit";
+} else {
+ echo "Cache Miss";
+}
+
+echo "<hr />";
+
+/**
+ * Show response headers. If not using the cache or the cache is empty an http
+ * request is made to the service. You can view the HTTP response headers with
+ * something like this.
+**/
+
+if (!$crp->get_cache_status()) {
+
+ echo "<h2>HTTP Response Headers</h2>";
+
+ foreach ($crp->response_headers as $header) {
+ echo $header . "<br />";
+ }
-//Metadata
+ echo "<hr />";
+}
+
+/**
+ * Iterate over the results
+**/
+
+echo "<h2>Parsed Results</h2>";
+
+echo "<h3>Meta data</h3>";
foreach ($data['response']['industries']['@attributes'] as $key=>$val) {
echo $key . " => " . $val . "<br />";
}
-//Table Data
+echo "<h3>Actual data</h3>";
echo "<table><tr><th>Industry</th><th>Indivs</th><th>PACs</th><th>Total</th></tr>";
foreach ($data['response']['industries']['industry'] as $ind) {
foreach ($ind as $row) {
echo "<tr><td>" . $row['industry_name'] . "</td><td>$" .
$row['indivs'] . "</td><td>$" . $row['pacs'] . "</td><td>$" .
$row['total'] . "</td></tr>";
}
}
echo "</table>";
-echo "<hr />";
-
-/**
- * Show the cache status. By default, the library caches API query results in a
- * gzipped, serialized form in a text file in the dataCache directory. If you do
- * not desire file caching, call getData(false) (see above). The cache life can
- * be set by altering $this->cacheTime value in crpapi.php. The default is
- * one day.
-**/
-
-if ($crp->getCacheStatus()) {
- echo "Cache Hit";
-} else {
- echo "Cache Miss";
-}
?>
\ No newline at end of file
|
bpilkerton/php-crpapi
|
f123b5c6788211c2119e8217a4794acd26b89044
|
Edit formating
|
diff --git a/example.php b/example.php
index de559d5..f7d9516 100644
--- a/example.php
+++ b/example.php
@@ -1,76 +1,76 @@
<?php
/**
*
* php-crpapi example usage
* @author Ben Pilkerton
*
*
* There are a few options which need to be defined in the constructor
* in crpapi.php. These include specifying your API key, default
* output type (json recommended, default) and cache lifetime
* (one day is default).
*
* Include the CRP API Library and create an object instance, specifying
* the parameters. In this example, we specify the output type. This
* could be ommitted and the default (defined in the constructor) will
* be used.
*
**/
require_once('crpapi.php');
$crp = new crpData("candIndustry", Array("cid"=>"N00002408","cycle"=>"2010","output"=>"json"));
/**
* These variables are exposed upon instantiation
**/
echo $crp->apikey . "<br />";
echo $crp->output . "<br />";
echo $crp->method . "<br />";
-echo $crp->baseurl . "<br />";
+echo $crp->baseurl . "<br />";
echo $crp->url . "<br />";
echo "<hr />";
/**
* Get the data. This example retrieves json data which is converted to
* an associative array. If using xml, a SimpleXML object will be returned.
* The getData method can optionally be passed a true/false value (true is
* default). If set to false, a local file cache will not be used.
**/
$data = $crp->getData();
//Metadata
foreach ($data['response']['industries']['@attributes'] as $key=>$val) {
echo $key . " => " . $val . "<br />";
}
//Table Data
echo "<table><tr><th>Industry</th><th>Indivs</th><th>PACs</th><th>Total</th></tr>";
foreach ($data['response']['industries']['industry'] as $ind) {
foreach ($ind as $row) {
echo "<tr><td>" . $row['industry_name'] . "</td><td>$" .
$row['indivs'] . "</td><td>$" . $row['pacs'] . "</td><td>$" .
$row['total'] . "</td></tr>";
}
}
echo "</table>";
echo "<hr />";
/**
* Show the cache status. By default, the library caches API query results in a
* gzipped, serialized form in a text file in the dataCache directory. If you do
* not desire file caching, call getData(false) (see above). The cache life can
* be set by altering $this->cacheTime value in crpapi.php. The default is
* one day.
**/
if ($crp->getCacheStatus()) {
echo "Cache Hit";
} else {
echo "Cache Miss";
}
?>
\ No newline at end of file
|
bpilkerton/php-crpapi
|
e0ea9c1fa5382ecd74c136d7cd91f915ceb16004
|
Added file cache mechanism. Improved example usage.
|
diff --git a/crpapi.php b/crpapi.php
index d69b993..c35eed0 100644
--- a/crpapi.php
+++ b/crpapi.php
@@ -1,53 +1,85 @@
<?php
/**
* class php-crpapi
- * Simple PHP client library for working with the Center for Responsive Politics' API
+ * Simple PHP client library for working with the Center for Responsive Politics' API.
* Information on CRP's API can be found at http://www.opensecrets.org/action/api_doc.php
* Information on using this class, including examples at http://github.com/bpilkerton/php-crpapi
* @author Ben Pilkerton <[email protected]>
- * @version 0.1
+ * @version 0.2
*/
class crpData {
function __construct($method=NULL,$params=NULL) {
+
$this->apikey = "";
$this->baseurl = "http://api.opensecrets.org/";
$this->output = "json";
//Allow output type to be overridden on object instantiation
$this->output = isset($params['output']) ? $params['output']: $this->output;
$this->method = $method;
self::loadParams($params);
+
+ $this->fileHash = md5($method . "," . implode(",",$params));
+ $this->cacheHash = "dataCache/" . $this->fileHash;
+ $this->cacheTime = 86400; #one day
+
}
private function loadParams($params) {
$this->url = $this->baseurl . "?method=" . $this->method .
"&apikey=" . $this->apikey;
-
+
foreach ($params as $key=>$val) {
$this->url .= "&" . $key . "=" . $val;
$this->$key = $val;
}
-
+
return;
}
- public function getData() {
+ public function getData($useCache=true) {
- $this->rawdata = file_get_contents($this->url);
+ if ($useCache and file_exists($this->cacheHash) and (time() - filectime($this->cacheHash) < $this->cacheTime)) {
- switch ($this->output) {
- case "json":
- $this->data = json_decode($this->rawdata);
- break;
- case "xml":
- $this->data = simplexml_load_string($this->rawdata);
- break;
+ $this->cacheHit = true;
+ $file = fopen($this->cacheHash,"r");
+ $this->data = stream_get_contents($file);
+ $this->data = gzuncompress($this->data);
+ $this->data = unserialize($this->data);
+ fclose($file);
+
+ } else {
+ $this->cacheHit = false;
+ $this->data = file_get_contents($this->url);
+
+ switch ($this->output) {
+ case "json":
+ $this->data = json_decode($this->data,true);
+ break;
+ case "xml":
+ $this->data = simplexml_load_string($this->data);
+ break;
+ default:
+ die("Unknown output type. Use 'json' or 'xml'");
+ }
+
+ if ($useCache) {
+ $file = fopen($this->cacheHash,"w");
+ $store = serialize($this->data);
+ $store = gzcompress($store);
+ fwrite($file,$store);
+ fclose($file);
+ }
}
-
+
return $this->data;
}
-}
+
+ function getCacheStatus() {
+ return $this->cacheHit;
+ }
+}
?>
diff --git a/dataCache/README b/dataCache/README
new file mode 100644
index 0000000..ca05512
--- /dev/null
+++ b/dataCache/README
@@ -0,0 +1 @@
+This directory is used to cache API data. Make sure your perms are setup.
diff --git a/example.php b/example.php
index 636fe07..de559d5 100644
--- a/example.php
+++ b/example.php
@@ -1,37 +1,76 @@
<?php
/**
*
* php-crpapi example usage
* @author Ben Pilkerton
*
+ *
+ * There are a few options which need to be defined in the constructor
+ * in crpapi.php. These include specifying your API key, default
+ * output type (json recommended, default) and cache lifetime
+ * (one day is default).
+ *
+ * Include the CRP API Library and create an object instance, specifying
+ * the parameters. In this example, we specify the output type. This
+ * could be ommitted and the default (defined in the constructor) will
+ * be used.
+ *
**/
require_once('crpapi.php');
-$crp = new crpData("candIndustry", Array("cid"=>"N00000019","cycle"=>"2006","output"=>"xml"));
+$crp = new crpData("candIndustry", Array("cid"=>"N00002408","cycle"=>"2010","output"=>"json"));
/**
* These variables are exposed upon instantiation
**/
echo $crp->apikey . "<br />";
echo $crp->output . "<br />";
echo $crp->method . "<br />";
+echo $crp->baseurl . "<br />";
echo $crp->url . "<br />";
+echo "<hr />";
/**
- * Get the data (either JSON std obj or SimpleXML Object)
+ * Get the data. This example retrieves json data which is converted to
+ * an associative array. If using xml, a SimpleXML object will be returned.
+ * The getData method can optionally be passed a true/false value (true is
+ * default). If set to false, a local file cache will not be used.
**/
-echo "<hr />";
-
$data = $crp->getData();
-print_r($data);
+
+//Metadata
+foreach ($data['response']['industries']['@attributes'] as $key=>$val) {
+ echo $key . " => " . $val . "<br />";
+}
+
+//Table Data
+echo "<table><tr><th>Industry</th><th>Indivs</th><th>PACs</th><th>Total</th></tr>";
+foreach ($data['response']['industries']['industry'] as $ind) {
+ foreach ($ind as $row) {
+ echo "<tr><td>" . $row['industry_name'] . "</td><td>$" .
+ $row['indivs'] . "</td><td>$" . $row['pacs'] . "</td><td>$" .
+ $row['total'] . "</td></tr>";
+ }
+}
+
+echo "</table>";
+echo "<hr />";
/**
- * Alternatively use the raw response after getData() is run
+ * Show the cache status. By default, the library caches API query results in a
+ * gzipped, serialized form in a text file in the dataCache directory. If you do
+ * not desire file caching, call getData(false) (see above). The cache life can
+ * be set by altering $this->cacheTime value in crpapi.php. The default is
+ * one day.
**/
-print_r($crp->rawdata);
+if ($crp->getCacheStatus()) {
+ echo "Cache Hit";
+} else {
+ echo "Cache Miss";
+}
?>
\ No newline at end of file
|
bpilkerton/php-crpapi
|
029a24b15901cc12fda82a7f35faefe6448a2054
|
cleaned up a bit
|
diff --git a/crpapi.php b/crpapi.php
index e9e31a6..d69b993 100644
--- a/crpapi.php
+++ b/crpapi.php
@@ -1,55 +1,53 @@
<?php
/**
* class php-crpapi
* Simple PHP client library for working with the Center for Responsive Politics' API
* Information on CRP's API can be found at http://www.opensecrets.org/action/api_doc.php
* Information on using this class, including examples at http://github.com/bpilkerton/php-crpapi
* @author Ben Pilkerton <[email protected]>
* @version 0.1
*/
class crpData {
function __construct($method=NULL,$params=NULL) {
$this->apikey = "";
$this->baseurl = "http://api.opensecrets.org/";
$this->output = "json";
//Allow output type to be overridden on object instantiation
$this->output = isset($params['output']) ? $params['output']: $this->output;
$this->method = $method;
self::loadParams($params);
}
private function loadParams($params) {
$this->url = $this->baseurl . "?method=" . $this->method .
"&apikey=" . $this->apikey;
foreach ($params as $key=>$val) {
$this->url .= "&" . $key . "=" . $val;
$this->$key = $val;
}
return;
}
public function getData() {
$this->rawdata = file_get_contents($this->url);
switch ($this->output) {
case "json":
$this->data = json_decode($this->rawdata);
break;
case "xml":
$this->data = simplexml_load_string($this->rawdata);
break;
}
return $this->data;
-
}
-
}
-?>
\ No newline at end of file
+?>
|
ILikeUnicorns/light-eating-robot
|
84fc72c45e5e4e8b14570eb1d5c8e47beea698b2
|
Week 7
|
diff --git a/dwengoRS232.c b/dwengoRS232.c
index 2f6e14c..61f8a20 100644
--- a/dwengoRS232.c
+++ b/dwengoRS232.c
@@ -1,30 +1,37 @@
#include "dwengoRS232.h"
#include <usart.h>
#include <capture.h>
#include <timers.h>
void initializeRS232(void)
{
//Configure Timer3
//OpenTimer3(TIMER_INT_OFF & T3_SOURCE_INT);
//Configure USART
+ //Fosc/(64*(spbrg+1)) => for 9600 = 77
OpenUSART(USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_BRGH_LOW &
USART_EIGHT_BIT &
USART_CONT_RX,
77);
}
void sendData(void)
{
//void putrs1USART ( const MEM_MODEL rom char *data);
putrsUSART((const rom char *)"HELLO WORLD OMG");
+
+ //After sending message, wait for confirmation from computer
+ while(!DataRdyUSART())
+ {
+
+ }
}
void closeRS232(void)
{
CloseUSART();
}
\ No newline at end of file
diff --git a/project.c b/project.c
index c567d0b..a5b2739 100644
--- a/project.c
+++ b/project.c
@@ -1,119 +1,117 @@
#include <p18f4550.h>
#include <delays.h>
#include <string.h>
#include <portb.h>
#include "dwengoConfig.h"
#include "dwengoBoard.h"
#include "dwengoLCD.h"
#include "dwengoMotor.h"
#include "dwengoDelay.h"
#include "dwengoSensors.h"
void YourHighPriorityISRCode();
void YourLowPriorityISRCode();
// interrupt handler routines DO NOT EDIT
#pragma code high_vector=0x08
void high_vector() {
_asm
goto YourHighPriorityISRCode
_endasm
}
#pragma code
#pragma code low_vector=0x18
void low_vector() {
_asm
goto YourLowPriorityISRCode
_endasm
}
#pragma code
// interrupt handler routines
#pragma interrupt YourHighPriorityISRCode
void YourHighPriorityISRCode()
{
//Interrupt to send Q table
printStringToLCD("HIGHPRI", 1, 0);
leftMotor(0);
rightMotor(0);
}
#pragma interrupt YourLowPriorityISRCode
void YourLowPriorityISRCode()
{
//Interrupt to stop motors
printStringToLCD("LOWPRI", 1, 0);
leftMotor(0);
rightMotor(0);
}
//Program values
int prevSensors[2];
int curSensors[2];
int diffSens0;
int diffSens1;
int thresshold=30;
char mode=0;
-char datasend = "tetn";
-
//Main
void main(void) {
initBoard();
backlightOn();
//Configure interrupts
//Interrupt on RB1 = SW_E
OpenRB1INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_HIGH);
//Interrupt on RB0 = SW_W
OpenRB0INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_LOW);
//Enable button input => not needed, see dwengoBoard.c->initBoard();
TRISB = 0xFF;
//Init motors
initializeMotors();
initializeSensors();
while (TRUE)
{
if(SW_N == 0)
{
mode = 0;
clearLCD();
printStringToLCD("Doing moves brah", 1, 0);
leftMotor(700);
rightMotor(700);
delay_s(4);
leftMotor(1000);
rightMotor(700);
delay_s(4);
leftMotor(700);
rightMotor(1000);
delay_s(4);
leftMotor(-700);
rightMotor(700);
delay_s(4);
}
else if(mode == 1)
{
//Light eating
}
else if(SW_S == 0)
{
//Start light eating
//mode = 1;
clearLCD();
printStringToLCD("Going to send string", 0, 0);
initializeRS232();
sendData();
}
else
{
//printStringToLCD("Cool story bro", 0, 0);
}
}
}
\ No newline at end of file
|
ILikeUnicorns/light-eating-robot
|
ac0245c4b2110c3780b38a9d6454f25f4a2c147b
|
Enabled interrupts.
|
diff --git a/project.c b/project.c
index 8c73ee4..c567d0b 100644
--- a/project.c
+++ b/project.c
@@ -1,119 +1,119 @@
#include <p18f4550.h>
#include <delays.h>
#include <string.h>
#include <portb.h>
#include "dwengoConfig.h"
#include "dwengoBoard.h"
#include "dwengoLCD.h"
#include "dwengoMotor.h"
#include "dwengoDelay.h"
#include "dwengoSensors.h"
void YourHighPriorityISRCode();
void YourLowPriorityISRCode();
// interrupt handler routines DO NOT EDIT
#pragma code high_vector=0x08
void high_vector() {
_asm
goto YourHighPriorityISRCode
_endasm
}
#pragma code
#pragma code low_vector=0x18
void low_vector() {
_asm
goto YourLowPriorityISRCode
_endasm
}
#pragma code
// interrupt handler routines
#pragma interrupt YourHighPriorityISRCode
void YourHighPriorityISRCode()
{
//Interrupt to send Q table
printStringToLCD("HIGHPRI", 1, 0);
leftMotor(0);
rightMotor(0);
}
#pragma interrupt YourLowPriorityISRCode
void YourLowPriorityISRCode()
{
//Interrupt to stop motors
printStringToLCD("LOWPRI", 1, 0);
leftMotor(0);
rightMotor(0);
}
//Program values
int prevSensors[2];
int curSensors[2];
int diffSens0;
int diffSens1;
int thresshold=30;
char mode=0;
char datasend = "tetn";
//Main
void main(void) {
initBoard();
backlightOn();
//Configure interrupts
//Interrupt on RB1 = SW_E
- //OpenRB1INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_HIGH);
+ OpenRB1INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_HIGH);
//Interrupt on RB0 = SW_W
- //OpenRB0INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_LOW);
+ OpenRB0INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_LOW);
//Enable button input => not needed, see dwengoBoard.c->initBoard();
TRISB = 0xFF;
//Init motors
initializeMotors();
initializeSensors();
while (TRUE)
{
if(SW_N == 0)
{
mode = 0;
clearLCD();
printStringToLCD("Doing moves brah", 1, 0);
leftMotor(700);
rightMotor(700);
delay_s(4);
leftMotor(1000);
rightMotor(700);
delay_s(4);
leftMotor(700);
rightMotor(1000);
delay_s(4);
leftMotor(-700);
rightMotor(700);
delay_s(4);
}
else if(mode == 1)
{
//Light eating
}
else if(SW_S == 0)
{
//Start light eating
//mode = 1;
clearLCD();
printStringToLCD("Going to send string", 0, 0);
initializeRS232();
sendData();
}
else
{
//printStringToLCD("Cool story bro", 0, 0);
}
}
}
\ No newline at end of file
|
ILikeUnicorns/light-eating-robot
|
1e50cdea5ef6ac67a01ed09fb48b8cfe5b268660
|
Start project, week 6.
|
diff --git a/QLearning.c b/QLearning.c
new file mode 100644
index 0000000..12c255a
--- /dev/null
+++ b/QLearning.c
@@ -0,0 +1,29 @@
+#include "QLearning.h"
+#include <stdlib.h>
+#include <stdio.h>
+#define MIN -3
+#define GOAL 2
+
+void initializeQLearning(void)
+{
+ //Make new table
+ int QTABLE_SIZE =3;
+// char** qding = (char**)malloc(sizeof(char*)*QTABLE_SIZE);
+// for(i = 0; i< QTABLE_SIZE; i++)
+// qt[i]= NULL;
+}
+
+void addNode(char s, char a, char r)
+{
+
+}
+
+void getTable(void)
+{
+
+}
+
+void getAction(char s)
+{
+
+}
\ No newline at end of file
diff --git a/QLearning.h b/QLearning.h
new file mode 100644
index 0000000..c0ec2ce
--- /dev/null
+++ b/QLearning.h
@@ -0,0 +1,21 @@
+#ifndef QLEARNING_H
+#define QLEARNING_H
+
+#pragma udata DATA
+int large_table[768];
+
+#pragma udata
+int *table_ptr = &large_table[0];
+
+struct qtnode{
+ int state;
+ int action;
+ int reward;
+};
+//typedef struct qtnode** qtable;
+
+void initializeQLearning(void);
+void addNode(char s, char a, char r);
+void getTable(void);
+void getAction(char s);
+#endif
\ No newline at end of file
diff --git a/dwengoBoard.c b/dwengoBoard.c
new file mode 100644
index 0000000..f8dfd18
--- /dev/null
+++ b/dwengoBoard.c
@@ -0,0 +1,25 @@
+#include "dwengoBoard.h"
+
+void initBoard(void) {
+
+ // if lcd display is connected (default)
+#ifndef NO_LCD
+ // init the lcd display
+ initLCD();
+ clearLCD();
+#endif
+
+ // set buttons as inputs
+ SW_C_DIR = INPUT;
+ SW_N_DIR = INPUT;
+ SW_S_DIR = INPUT;
+ SW_W_DIR = INPUT;
+ SW_E_DIR = INPUT;
+
+ // enable pull-up resistors of port B (buttons)
+ INTCON2bits.NOT_RBPU = 0;
+
+ // set led pins as output
+ LEDS_DIR = 0; // led pins as outputs
+ LEDS = 0; // switch leds off
+}
diff --git a/dwengoBoard.h b/dwengoBoard.h
new file mode 100644
index 0000000..19377bb
--- /dev/null
+++ b/dwengoBoard.h
@@ -0,0 +1,88 @@
+/*
+ * dwengoBoard.h
+ *
+ *
+ *
+ */
+
+#ifndef DWENGO_BOARD_H
+#define DWENGO_BOARD_H
+
+// Constants
+#define TRUE 1
+#define FALSE 0
+#define HIGH 1
+#define LOW 0
+#define PRESSED 0
+#define INPUT 1
+#define OUTPUT 0
+
+// Data types
+#define BYTE unsigned char
+
+// Pin assignments
+
+// leds
+#define LEDS PORTD
+#define LEDS_DIR TRISD
+#define LED0 PORTDbits.RD0
+#define LED1 PORTDbits.RD1
+#define LED2 PORTDbits.RD2
+#define LED3 PORTDbits.RD3
+#define LED4 PORTDbits.RD4
+#define LED5 PORTDbits.RD5
+#define LED6 PORTDbits.RD6
+#define LED7 PORTDbits.RD7
+
+// buttons
+#define SW_C PORTBbits.RB2
+#define SW_C_DIR TRISBbits.TRISB2
+#define SW_N PORTBbits.RB4
+#define SW_N_DIR TRISBbits.TRISB4
+#define SW_E PORTBbits.RB1
+#define SW_E_DIR TRISBbits.TRISB1
+#define SW_S PORTBbits.RB5
+#define SW_S_DIR TRISBbits.TRISB5
+#define SW_W PORTBbits.RB0
+#define SW_W_DIR TRISBbits.TRISB0
+
+// LCD display
+#define LCD_DATA PORTD
+#define LCD_DATA_DIR TRISD
+#define LCD_BACKLIGHT PORTCbits.RC0
+#define LCD_BACKLIGHT_DIR TRISCbits.TRISC0
+#define LCD_RW PORTEbits.RE1
+#define LCD_RW_DIR TRISEbits.TRISE1
+#define LCD_RS PORTEbits.RE0
+#define LCD_RS_DIR TRISEbits.TRISE0
+#define LCD_EN PORTEbits.RE2
+#define LCD_EN_DIR TRISEbits.TRISE2
+
+// servo connectors
+#define SERVO1 PORTBbits.RB5
+#define SERVO1_DIR TRISBbits.TRISB5
+#define SERVO2 PORTBbits.RB4
+#define SERVO2_DIR TRISBbits.TRISB4
+
+// motor driver
+#define MOTOR1_0 PORTCbits.RC2
+#define MOTOR1_0_DIR TRISCbits.TRISC2
+#define MOTOR1_1 PORTAbits.RA4
+#define MOTOR1_1_DIR TRISAbits.TRISA4
+#define MOTOR2_0 PORTCbits.RC1
+#define MOTOR2_0_DIR TRISCbits.TRISC1
+#define MOTOR2_1 PORTBbits.RB3
+#define MOTOR2_1_DIR TRISBbits.TRISB3
+
+// include libraries
+#include <p18f4550.h>
+#include "dwengoDelay.h"
+
+#ifndef NO_LCD
+#include "dwengoLCD.h"
+#endif
+
+// intialisation routine for the board
+void initBoard(void);
+
+#endif //DWENGO_BOARD_H
\ No newline at end of file
diff --git a/dwengoConfig.h b/dwengoConfig.h
new file mode 100644
index 0000000..05fe0c9
--- /dev/null
+++ b/dwengoConfig.h
@@ -0,0 +1,53 @@
+
+// CPU Clock: 48MHz
+#pragma config PLLDIV = 5 // Divide by 5 (20 MHz oscillator input)
+#pragma config FOSC = HSPLL_HS // HS oscillator, PLL enabled, HS used by USB
+#pragma config CPUDIV = OSC1_PLL2 // System Clock Postscaler Selection bits
+
+// USB: enabled
+#pragma config USBDIV = 2 // USB Clock: 48 Mhz
+#pragma config VREGEN = ON // USB Voltage Regulator: enabled
+
+// Brown-out Reset: disabled
+#pragma config BOR = OFF // Brown-out Reset enabled in hardware only (SBOREN is disabled)
+#pragma config BORV = 3 // Brown-out Reset Voltage bits
+
+// Watchdog Timer: disabled
+#pragma config WDT = OFF // Watchdog Timer Enable bit
+#pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits
+
+// Miscellaneous
+#pragma config IESO = OFF // Oscillator Switchover mode: disabled
+#pragma config FCMEN = OFF // Fail-Safe Clock Monitor: disabled
+#pragma config PWRT = OFF // Power-up Timer: disabled
+#pragma config MCLRE = ON // MCLR pin: enabled; RE3 input pin: disabled
+#pragma config LPT1OSC = OFF // Low-Power Timer1 Oscillator: disabled
+#pragma config PBADEN = OFF // PORB digital IO on powerup
+#pragma config CCP2MX = ON // CCP2 is multiplexed to RC1 (not RB3)
+#pragma config XINST = OFF // Extended Instruction Set: disabled
+#pragma config LVP = OFF // Low-voltage programming: disabled
+#pragma config STVREN = ON // Stack Full/Underflow Reset: enabled
+
+// Code Protection: disabled
+#pragma config CPB = OFF // Boot Block Code Protection bit
+#pragma config CPD = OFF // Data EEPROM Code Protection bit
+#pragma config CP0 = OFF // Code Protection bit Block 0
+#pragma config CP1 = OFF // Code Protection bit Block 1
+#pragma config CP2 = OFF // Code Protection bit Block 2
+#pragma config CP3 = OFF // Code Protection bit Block 3
+
+// Write Protection: disabled
+#pragma config WRTC = OFF // Configuration Register Write Protection bit
+#pragma config WRTB = OFF // Boot Block Write Protection bit
+#pragma config WRTD = OFF // Data EEPROM Write Protection bit
+#pragma config WRT0 = OFF // Write Protection bit Block 0
+#pragma config WRT1 = OFF // Write Protection bit Block 1
+#pragma config WRT2 = OFF // Write Protection bit Block 2
+#pragma config WRT3 = OFF // Write Protection bit Block 3
+
+// Table Read Protection: disabled
+#pragma config EBTRB = OFF // Boot Block Table Read Protection bit
+#pragma config EBTR0 = OFF // Table Read Protection bit Block 0
+#pragma config EBTR1 = OFF // Table Read Protection bit Block 1
+#pragma config EBTR2 = OFF // Table Read Protection bit Block 2
+#pragma config EBTR3 = OFF // Table Read Protection bit Block 3
diff --git a/dwengoDelay.c b/dwengoDelay.c
new file mode 100644
index 0000000..547a6b7
--- /dev/null
+++ b/dwengoDelay.c
@@ -0,0 +1,41 @@
+/**
+ * Delay
+ * part of Dwengo library
+ *
+ * Delay routines for the dwengo board.
+ *
+ * Version: 1.0.$Revision: 1556 $
+ * Date: $Date: 2009-12-19 01:34:57 +0100 (za, 19 dec 2009) $
+ * (c) Dwengo vzw - http://www.dwengo.org
+ */
+
+#include "dwengoDelay.h"
+
+void delay_100us(int n) {
+ int i;
+ if (n != 0) {
+ delay_us(95);
+ for (i = 1; i<n; i++) {
+ delay_us(98);
+ }
+ }
+}
+
+void delay_ms(int n){
+ int i;
+ if (n != 0) {
+ delay_us(94)
+ delay_100us(9);
+ for (i = 1; i<n; i++) {
+ delay_us(96)
+ delay_100us(9);
+ }
+ }
+}
+
+void delay_s(int n){
+ int i;
+ for (i=0; i<n; i++) {
+ delay_ms(1000);
+ }
+}
\ No newline at end of file
diff --git a/dwengoDelay.h b/dwengoDelay.h
new file mode 100644
index 0000000..68c0c76
--- /dev/null
+++ b/dwengoDelay.h
@@ -0,0 +1,41 @@
+/**
+ * Delay
+ * part of Dwengo library
+ *
+ * Delay routines for the dwengo board.
+ *
+ * Version: 1.0.$Revision: 1618 $
+ * Date: $Date: 2010-01-04 22:19:02 +0100 (ma, 04 jan 2010) $
+ * (c) Dwengo vzw - http://www.dwengo.org
+ */
+
+#ifndef DWENGO_DELAY_H
+#define DWENGO_DELAY_H
+
+#define delay_us(n) \
+{ char a=n; \
+ _asm \
+ MOVLW a \
+ MOVF PLUSW2, 1, 0 \
+ BZ 12 \
+ DECF PLUSW2, 1, 0 \
+loop: \
+ MOVLW a \
+ MOVF PLUSW2, 1, 0 \
+ BZ 8 \
+ NOP \
+ NOP \
+ NOP \
+ NOP \
+ NOP \
+ NOP \
+ DECF PLUSW2, 1, 0 \
+ BRA -11 \
+end: \
+ _endasm }
+
+void delay_100us(int n);
+void delay_ms(int n);
+void delay_s(int n);
+
+#endif // DWENGO_DELAY_H
\ No newline at end of file
diff --git a/dwengoLCD.c b/dwengoLCD.c
new file mode 100644
index 0000000..5a18abd
--- /dev/null
+++ b/dwengoLCD.c
@@ -0,0 +1,165 @@
+/**
+ * LCD Display
+ * part of Dwengo library
+ *
+ * Control of LCD display on the Dwengo board
+ *
+ * Version: 1.0.$Revision: 1669 $
+ * Date: $Date: 2010-01-17 21:42:59 +0100 (zo, 17 jan 2010) $
+ * (c) Dwengo vzw - http://www.dwengo.org
+ */
+
+#include "dwengoLCD.h"
+#include <stdlib.h>
+
+// Keeps track of current line number and character position.
+struct lcd_info_type lcd_info;
+
+void initLCD(void) {
+ LCD_BACKLIGHT_DIR = OUTPUT; // Set LCD backlight-pin as output
+ ADCON1 = 0x0A; // RE0-2 digital
+ delay_ms(5); // wait 5ms
+
+ LCD_DATA = 0;
+ LCD_DATA_DIR = 0xff;
+
+ LCD_RS_DIR = OUTPUT;
+ LCD_RW_DIR = OUTPUT;
+ LCD_EN_DIR = OUTPUT;
+
+ LCD_RS = 0;
+ LCD_RW = 0;
+ LCD_EN = 0;
+
+ delay_ms(15);
+
+ LCD_DATA_DIR = 0;
+
+ commandLCD(0b00110000);
+ commandLCD(0b00110000);
+ commandLCD(0b00110000);
+ commandLCD(0b00111000);
+ commandLCD(0b00000110);
+ commandLCD(0b00011000);
+ commandLCD(0b00001100);
+ lcd_info.line = lcd_info.pos = 0;
+}
+
+void clearLCD(void) {
+ commandLCD(0b00000001);
+ delay_ms(2);
+ setCursorLCD(0,0);
+}
+
+void commandLCD(const BYTE c) {
+ BYTE temp;
+
+ temp = LCD_DATA; // Save current data on datapins for LED's
+
+ // Write command to LCD
+ LCD_RW = 0;
+ LCD_RS = 0;
+
+ LCD_EN = 1; // Bring enable pin high
+ temp = LCD_DATA; // Save current data on datapins for LED's
+ LCD_DATA = c; // Write command data to data port
+ LCD_EN = 0; // data is clocked at the falling edge of enable pin
+ LCD_DATA = temp; // restore data on datapins
+ delay_us(45); // wait until display has processed the data
+}
+
+
+// set cursor at position p of line l
+void setCursorLCD(BYTE l, BYTE p) {
+ BYTE c;
+
+ // check if input is valid
+ if (l>LCD_LASTLINE) l = LCD_LASTLINE;
+ if (p>LCD_LASTPOS) p = LCD_LASTPOS;
+
+ lcd_info.line = l;
+ lcd_info.pos = p;
+
+ if (l == 1)
+ c = 0b11000000;
+ else
+ c = 0b10000000;
+
+ // position offset
+ p &= 0b00001111;
+ c |= p;
+
+ commandLCD(c);
+
+ delay_us(45); // wait until display has processed the command
+}
+
+
+void appendCharToLCD(const char c) {
+ unsigned temp = LCD_DATA; // Save current data on datapins for LED's
+ if (lcd_info.pos>LCD_LASTPOS)
+ if (lcd_info.line)
+ clearLCD();
+ else
+ setCursorLCD(1, 0);
+
+ // Write char to LCD
+ LCD_RW = 0;
+ LCD_RS = 1;
+
+ LCD_EN = 1; // Bring enable pin high
+ temp = LCD_DATA; // Save current data on datapins for LED's
+ LCD_DATA = c; // Write data to data port
+ LCD_EN = 0; // data is clocked at the falling edge of enable pin
+ LCD_DATA = temp; // restore data on datapins
+ delay_us(45); // wait until display has processed the data
+
+ lcd_info.pos++; // increment lcd cursor position
+}
+
+
+void printCharToLCD(const char c, BYTE l, BYTE p) {
+ BYTE temp;
+
+ // set cursor to selected position
+ setCursorLCD(l,p);
+
+ // append to this position
+ appendCharToLCD(c);
+}
+
+void appendStringToLCD_(const far rom char* message) {
+ while (*message) {
+ appendCharToLCD(*message++);
+ }
+}
+
+void printStringToLCD(char* message, BYTE l, BYTE p) {
+ // set cursor to selected position
+ setCursorLCD(l,p);
+
+ // append to this position
+ appendStringToLCD(message);
+}
+
+void appendStringToLCDcharptr(char* message) {
+ while(*message) {
+ appendCharToLCD(*message++);
+ }
+}
+
+void appendIntToLCD(int i) {
+ char buffer[7];
+ itoa(i,buffer);
+ buffer[6] = 0;
+ appendStringToLCDcharptr(buffer);
+}
+
+void printIntToLCD(int i, BYTE l, BYTE p) {
+ // set cursor to selected position
+ setCursorLCD(l,p);
+
+ // append to this position
+ appendIntToLCD(i);
+}
+
diff --git a/dwengoLCD.h b/dwengoLCD.h
new file mode 100644
index 0000000..d756f84
--- /dev/null
+++ b/dwengoLCD.h
@@ -0,0 +1,55 @@
+/**
+ * LCD Display
+ * part of Dwengo library
+ *
+ * Control of LCD display on the Dwengo board
+ *
+ * Version: 1.0.$Revision: 1567 $
+ * Date: $Date: 2009-12-21 21:38:03 +0100 (ma, 21 dec 2009) $
+ * (c) Dwengo vzw - http://www.dwengo.org
+ */
+
+#ifndef DWENGO_LCD_H
+#define DWENGO_LCD_H
+
+#include "dwengoBoard.h"
+#include "dwengoDelay.h"
+
+// Properties
+#define LCD_WIDTH 16
+#define LCD_HEIGHT 2
+#define LCD_LASTLINE (LCD_HEIGHT - 1)
+#define LCD_LASTPOS (LCD_WIDTH - 1)
+
+// Macro's
+#define backlightOn() (LCD_BACKLIGHT = 1)
+#define backlightOff() (LCD_BACKLIGHT = 0)
+
+#define appendStringToLCD(message) appendStringToLCD_((const far rom char*)(message))
+
+// Functions
+void initLCD(void);
+void clearLCD(void);
+
+void commandLCD(const BYTE c);
+void setCursorLCD(BYTE l, BYTE p);
+
+void appendCharToLCD(const char c);
+void printCharToLCD(const char c, BYTE l, BYTE p);
+
+void appendStringToLCD_(const far rom char* s);
+void printStringToLCD(char* s, BYTE l, BYTE p);
+
+void appendIntToLCD(int i);
+void printIntToLCD(int i, BYTE l, BYTE p);
+
+// Structures
+struct lcd_info_type {
+ unsigned char line;
+ unsigned char pos;
+};
+
+// Keeps track of current line number and character position.
+extern struct lcd_info_type lcd_info;
+
+#endif // DWENGO_LCD_H
diff --git a/dwengoMotor.c b/dwengoMotor.c
new file mode 100644
index 0000000..5d598a0
--- /dev/null
+++ b/dwengoMotor.c
@@ -0,0 +1,81 @@
+#include "dwengoMotor.h"
+#include "pwm.h"
+#include "timers.h"
+
+void initializeMotors(void)
+{
+ //Define RC1, RC2, RB3, RA4 as output
+ //RC1 == CCP1; RC2 == CCP2; generates PWM signals
+ TRISAbits.TRISA4 = 0;
+ TRISBbits.TRISB3 = 0;
+ TRISCbits.TRISC1 = 0;
+ TRISCbits.TRISC2 = 0;
+
+ //Timer enable
+ T2CON = 0b00000001;
+ //Timer enable
+ T2CONbits.TMR2ON = 1;
+ T2CONbits.T2OUTPS0 = 0;
+ T2CONbits.T2OUTPS1 = 0;
+ T2CONbits.T2OUTPS2 = 0;
+ T2CONbits.T2OUTPS3 = 0;
+
+ //PWM Period = [(PR2)+1]*4*Tosc (48Mhz)*(TMR2 Prescale value)
+ OpenPWM1(0xFF);
+ //PWM Period = [(PR2)+1]*4*Tosc (48Mhz)*(TMR2 Prescale value)
+ OpenPWM2(0xFF);
+
+ //Stop motors
+ SetDCPWM1(0);
+ SetDCPWM2(0);
+}
+
+void leftMotor(int speed)
+{
+ //Check if direction is changed; if so, delay to avoid overheating of the motor driver
+ if(DIR != (speed > 0))
+ {
+ delay_ms(50);
+ }
+
+ if(speed < 0)
+ {
+ //Negative speed
+ MOTOR1_1_DIR = 0;
+ SetDCPWM1(-speed); //0 is max speed in reverse
+ }
+ else
+ {
+ //Postive speed
+ MOTOR1_1_DIR = 1;
+ SetDCPWM1(1023-speed);
+ }
+ DIR = (speed > 0);
+ //T2_PS_1_4 & T2_POST_1_1
+ OpenTimer2(TIMER_INT_OFF & T2_PS_1_4 & T2_POST_1_1);
+}
+
+void rightMotor(int speed)
+{
+ //Check if direction is changed; if so, delay to avoid overheating of the motor driver
+ if(DIR != (speed > 0))
+ {
+ delay_ms(50);
+ }
+
+ if(speed < 0)
+ {
+ //Negative speed
+ MOTOR2_1_DIR = 1;
+ SetDCPWM2(1023 + speed);
+ }
+ else
+ {
+ //Positive speed
+ MOTOR2_1_DIR = 0;
+ SetDCPWM2(speed);
+ }
+
+ //T2_PS_1_4 & T2_POST_1_1
+ OpenTimer2(TIMER_INT_OFF & T2_PS_1_4 & T2_POST_1_1);
+}
\ No newline at end of file
diff --git a/dwengoMotor.h b/dwengoMotor.h
new file mode 100644
index 0000000..fb1a0e8
--- /dev/null
+++ b/dwengoMotor.h
@@ -0,0 +1,14 @@
+#ifndef DWENGO_MOTOR_H
+#define DWENGO_MOTOR_H
+
+#include "dwengoBoard.h"
+#include "dwengoDelay.h"
+
+//Vars
+static BYTE DIR;
+
+// Functions
+void initializeMotors(void);
+void leftMotor(int speed);
+void rightMotor(int speed);
+#endif
\ No newline at end of file
diff --git a/dwengoQLearning.c b/dwengoQLearning.c
new file mode 100644
index 0000000..8308667
--- /dev/null
+++ b/dwengoQLearning.c
@@ -0,0 +1,17 @@
+#include "dwengoQLearning.h"
+
+void initializeQLearning(void)
+{
+ //Make new table
+
+}
+
+void addNode(char s, char a, char r)
+{
+
+}
+
+void getTable(void)
+{
+
+}
\ No newline at end of file
diff --git a/dwengoQLearning.h b/dwengoQLearning.h
new file mode 100644
index 0000000..aebb3cd
--- /dev/null
+++ b/dwengoQLearning.h
@@ -0,0 +1,11 @@
+#ifndef DWENGO_QLEARNING_H
+#define DWENGO_QLEARNING_H
+
+#include "dwengoBoard.h"
+#include "dwengoDelay.h"
+
+void initializeQLearning(void);
+void addNode(char s, char a, char r);
+void getTable(void);
+
+#endif
\ No newline at end of file
diff --git a/dwengoRS232.c b/dwengoRS232.c
new file mode 100644
index 0000000..2f6e14c
--- /dev/null
+++ b/dwengoRS232.c
@@ -0,0 +1,30 @@
+#include "dwengoRS232.h"
+#include <usart.h>
+#include <capture.h>
+#include <timers.h>
+
+void initializeRS232(void)
+{
+ //Configure Timer3
+ //OpenTimer3(TIMER_INT_OFF & T3_SOURCE_INT);
+
+ //Configure USART
+ OpenUSART(USART_TX_INT_OFF &
+ USART_RX_INT_OFF &
+ USART_ASYNCH_MODE &
+ USART_BRGH_LOW &
+ USART_EIGHT_BIT &
+ USART_CONT_RX,
+ 77);
+}
+
+void sendData(void)
+{
+ //void putrs1USART ( const MEM_MODEL rom char *data);
+ putrsUSART((const rom char *)"HELLO WORLD OMG");
+}
+
+void closeRS232(void)
+{
+ CloseUSART();
+}
\ No newline at end of file
diff --git a/dwengoRS232.h b/dwengoRS232.h
new file mode 100644
index 0000000..5de2cb9
--- /dev/null
+++ b/dwengoRS232.h
@@ -0,0 +1,11 @@
+#ifndef DWENGO_RS232_H
+#define DWENGO_RS232_H
+
+#include "dwengoBoard.h"
+#include "dwengoDelay.h"
+
+void initializeRS232(void);
+void sendData(void);
+void closeRS232(void);
+
+#endif
\ No newline at end of file
diff --git a/dwengoSensors.c b/dwengoSensors.c
new file mode 100644
index 0000000..6be0b63
--- /dev/null
+++ b/dwengoSensors.c
@@ -0,0 +1,28 @@
+#include "dwengoSensors.h"
+#include "adc.h"
+
+void initializeSensors(void)
+{
+ //ANCON0bits.PCFG0=0;
+ OpenADC(ADC_FOSC_64 & ADC_RIGHT_JUST & ADC_6_TAD, ADC_CH0 & ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS, 0b1010);
+}
+
+int readSensor(BYTE sensor)
+{
+ int data;
+ switch(sensor)
+ {
+ case 0:
+ SetChanADC(ADC_CH0);
+ case 1:
+ SetChanADC(ADC_CH1);
+ }
+
+ //delay_us(125);
+ ConvertADC();
+
+ while (BusyADC());
+ data=ReadADC();
+
+ return data;
+}
\ No newline at end of file
diff --git a/dwengoSensors.h b/dwengoSensors.h
new file mode 100644
index 0000000..1ef9677
--- /dev/null
+++ b/dwengoSensors.h
@@ -0,0 +1,10 @@
+#ifndef DWENGO_SENSORS_H
+#define DWENGO_SENSORS_H
+
+#include "dwengoBoard.h"
+#include "dwengoDelay.h"
+
+// Functions
+void initializeSensors(void);
+int readSensor(BYTE sensor);
+#endif
\ No newline at end of file
diff --git a/project.c b/project.c
new file mode 100644
index 0000000..8c73ee4
--- /dev/null
+++ b/project.c
@@ -0,0 +1,119 @@
+#include <p18f4550.h>
+#include <delays.h>
+#include <string.h>
+#include <portb.h>
+#include "dwengoConfig.h"
+#include "dwengoBoard.h"
+#include "dwengoLCD.h"
+#include "dwengoMotor.h"
+#include "dwengoDelay.h"
+#include "dwengoSensors.h"
+
+void YourHighPriorityISRCode();
+void YourLowPriorityISRCode();
+
+// interrupt handler routines DO NOT EDIT
+#pragma code high_vector=0x08
+void high_vector() {
+ _asm
+ goto YourHighPriorityISRCode
+ _endasm
+}
+#pragma code
+
+#pragma code low_vector=0x18
+void low_vector() {
+ _asm
+ goto YourLowPriorityISRCode
+ _endasm
+}
+#pragma code
+
+// interrupt handler routines
+#pragma interrupt YourHighPriorityISRCode
+void YourHighPriorityISRCode()
+{
+ //Interrupt to send Q table
+ printStringToLCD("HIGHPRI", 1, 0);
+ leftMotor(0);
+ rightMotor(0);
+}
+
+#pragma interrupt YourLowPriorityISRCode
+void YourLowPriorityISRCode()
+{
+ //Interrupt to stop motors
+ printStringToLCD("LOWPRI", 1, 0);
+ leftMotor(0);
+ rightMotor(0);
+}
+
+//Program values
+int prevSensors[2];
+int curSensors[2];
+int diffSens0;
+int diffSens1;
+int thresshold=30;
+char mode=0;
+
+char datasend = "tetn";
+
+//Main
+void main(void) {
+ initBoard();
+ backlightOn();
+
+ //Configure interrupts
+ //Interrupt on RB1 = SW_E
+ //OpenRB1INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_HIGH);
+
+ //Interrupt on RB0 = SW_W
+ //OpenRB0INT(PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_OFF & PORTB_INT_PRIO_LOW);
+
+ //Enable button input => not needed, see dwengoBoard.c->initBoard();
+ TRISB = 0xFF;
+
+ //Init motors
+ initializeMotors();
+ initializeSensors();
+
+ while (TRUE)
+ {
+ if(SW_N == 0)
+ {
+ mode = 0;
+ clearLCD();
+ printStringToLCD("Doing moves brah", 1, 0);
+ leftMotor(700);
+ rightMotor(700);
+ delay_s(4);
+ leftMotor(1000);
+ rightMotor(700);
+ delay_s(4);
+ leftMotor(700);
+ rightMotor(1000);
+ delay_s(4);
+ leftMotor(-700);
+ rightMotor(700);
+ delay_s(4);
+ }
+ else if(mode == 1)
+ {
+ //Light eating
+
+ }
+ else if(SW_S == 0)
+ {
+ //Start light eating
+ //mode = 1;
+ clearLCD();
+ printStringToLCD("Going to send string", 0, 0);
+ initializeRS232();
+ sendData();
+ }
+ else
+ {
+ //printStringToLCD("Cool story bro", 0, 0);
+ }
+ }
+}
\ No newline at end of file
|
luciofm/luciofm.github.com
|
3784995e2d6063cf7b0bf06cdb5f5c5c8a59476d
|
Moved heu cv to here.
|
diff --git a/heu/hnangelo.pdf b/heu/hnangelo.pdf
new file mode 100644
index 0000000..c07501a
Binary files /dev/null and b/heu/hnangelo.pdf differ
|
luciofm/luciofm.github.com
|
b1523d56c720f1fe5e8c88fc594ac1767bf668f0
|
Added index.html
|
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..ba9056b
--- /dev/null
+++ b/index.html
@@ -0,0 +1 @@
+luciofm GitHub Page
|
luciofm/luciofm.github.com
|
68a2deb7dcb904b4b7bdc0590eda28826382c852
|
Place robots on right place.
|
diff --git a/robots.txt b/robots.txt
new file mode 100644
index 0000000..0e58931
--- /dev/null
+++ b/robots.txt
@@ -0,0 +1,5 @@
+User-agent: *
+Disallow: /heu
+Disallow: /LOs/heu
+Disallow: /heu/hnangelo.pdf
+Disallow: /LOs/heu/hnangelo.pdf
|
myfwhite/expenses
|
85903d3d1cd917c60a244005bca8ef8fe7305191
|
Fixed search and index
|
diff --git a/app/controllers/expenses_controller.rb b/app/controllers/expenses_controller.rb
old mode 100644
new mode 100755
index 5f781f9..003789f
--- a/app/controllers/expenses_controller.rb
+++ b/app/controllers/expenses_controller.rb
@@ -1,38 +1,50 @@
class ExpensesController < ApplicationController
before_filter :check_authentication
def show
@title = 'View Expense'
@expense = Expense.find(params[:id])
end
def download
@expense = Expense.find(params[:id])
send_data(@expense.file_data, @expense.send_data_details)
end
def new
@title = 'Add expense'
end
def create
@expense = Expense.new(params[:expense])
if @expense.save
flash[:notice] = "Thank you for your submission"
redirect_to :expenses
else
flash[:error] = "There was a problem with your submission"
+ redirect_to new_expense_path
end
end
def index
@title = 'Expenses'
- Expense.search({:user => current_user})
+ @expenses = Expense.search_by_current_user(current_user)
end
def search
@title = 'Search expenses'
+ @expense = Expense.find(:first)
+ end
+
+ def search_results
+ search_params = params[:expense].merge({:user => current_user})
+ if @expense = Expense.search_by_expense_number(search_params)
+ redirect_to expense_path(@expense)
+ else
+ flash[:notice] = "No expense matches your search parameters"
+ redirect_to search_expenses_path
+ end
end
end
diff --git a/app/models/expense.rb b/app/models/expense.rb
old mode 100644
new mode 100755
index b23b904..ec3e86e
--- a/app/models/expense.rb
+++ b/app/models/expense.rb
@@ -1,43 +1,63 @@
class Expense < ActiveRecord::Base
belongs_to :user
validates_presence_of :expense_number, :user, :filename
validates_associated :user
validates_numericality_of :expense_number
- def self.search(search_params)
- if search_params[:user]
- find_all_by_user_id(search_params[:user].id, :order => "created_at DESC")
+ def authorised_for?(current_user)
+ true if (current_user.is_admin? || user == current_user)
+ end
+
+ def self.search_by_current_user(user)
+ search_by_user(user,user)
+ end
+
+ # admin users can view any other users' expenses
+ # other users can only view their own expenses
+ def self.search_by_user(user,current_user)
+ if current_user.is_admin? || user = current_user
+ find_all_by_user_id(user.id, :order => "created_at DESC")
end
end
+ # given params with an expense_number and the current user
+ # return the expense with that expense number.
+ # if it doesn't exist, or the current_user is not authorised, then
+ # return nil
+ def self.search_by_expense_number(params)
+ return nil unless params[:expense_number]
+ expense = find_by_expense_number(params[:expense_number])
+ expense if expense && expense.authorised_for?(params[:user])
+ end
+
def display_type
@inline_types = ['application/pdf', 'text/plain', 'image/gif', 'image/jpeg', 'image/png']
@inline_types.each do |type|
return 'inline' if type == self.content_type
end
'downloaded'
end
def send_data_details
{:filename => this.filename, :type => this.content_type, :disposition => this.display_type}
end
def uploaded_file=(incoming_file)
self.filename = incoming_file.original_filename
self.content_type = incoming_file.content_type
self.file_data = incoming_file.read
end
def filename=(new_filename)
write_attribute("filename", sanitize_filename(new_filename))
end
private
def sanitize_filename(filename)
just_filename = File.basename(filename)
just_filename.gsub(/[^\w\.\-]/, '_')
end
end
diff --git a/app/views/expenses/index.haml b/app/views/expenses/index.haml
old mode 100644
new mode 100755
index b52100c..7c2c9bb
--- a/app/views/expenses/index.haml
+++ b/app/views/expenses/index.haml
@@ -1,10 +1,11 @@
%table
%tr
%th Expense number
%th Employee
%th File
- @expenses.each do |expense|
%tr
%td= expense.expense_number
%td= expense.user.username
- %td= link_to "#{expense.filename}", :action => 'download' , :id => expense
\ No newline at end of file
+ %td= link_to "#{expense.filename}", :action => 'download' , :id => expense
+
diff --git a/app/views/expenses/search.haml b/app/views/expenses/search.haml
old mode 100644
new mode 100755
index 3dd278d..9b025b2
--- a/app/views/expenses/search.haml
+++ b/app/views/expenses/search.haml
@@ -1,12 +1,7 @@
-- error_messages_for :expense
-- form_for :expenses, @expense do |f|
+- form_for :expense, @expense, :url => search_results_expenses_path, :html => {:method => "get"} do |f|
.field
= label(:expense_number, 'Expense number')
%br
= f.text_field 'expense_number'
- - if current_user.is_admin?
- = label(:username, 'Employee')
- %br
- = f.text_field 'username'
.actions
- = f.submit 'Search'
\ No newline at end of file
+ = f.submit 'Search'
diff --git a/app/views/expenses/show.haml b/app/views/expenses/show.haml
index 687a5a2..df204a0 100644
--- a/app/views/expenses/show.haml
+++ b/app/views/expenses/show.haml
@@ -1,7 +1,7 @@
%dl
%dt Expense number
- %dd= @expense.id
+ %dd= @expense.expense_number
%dt User
%dd= @expense.user.username
%dt Expense file
%dd= link_to "#{@expense.filename}", :action => 'download' , :id => @expense
\ No newline at end of file
diff --git a/log/development.log b/log/development.log
index bb685f7..ad6ffb4 100644
--- a/log/development.log
+++ b/log/development.log
@@ -14959,512 +14959,2954 @@ SyntaxError (/home/myfwhite/projects/expenses/app/models/expense.rb:43: syntax e
Rendered rescues/_trace (96.7ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 15:59:25) [POST]
Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
[4;36;1mUser Load (1.1ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
Redirected to http://localhost:3000/expenses
Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 15:59:25) [GET]
Parameters: {"action"=>"index", "controller"=>"expenses"}
[4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mExpense Load (281.0ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expenses/index
Rendered expenses/_options (0.4ms)
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 592ms (View: 9, DB: 282) | 200 OK [http://localhost/expenses]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 16:00:34) [POST]
Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
[4;35;1mUser Load (1.1ms)[0m [0mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
Redirected to http://localhost:3000/expenses
Completed in 15ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:00:34) [GET]
Parameters: {"action"=>"index", "controller"=>"expenses"}
[4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mExpense Load (288.2ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expenses/index
Rendered expenses/_options (0.5ms)
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 605ms (View: 21, DB: 289) | 200 OK [http://localhost/expenses]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:00:50) [GET]
Parameters: {"action"=>"index", "controller"=>"expenses"}
[4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mExpense Load (295.3ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expenses/index
Rendered expenses/_options (0.4ms)
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 606ms (View: 19, DB: 296) | 200 OK [http://localhost/expenses]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#new (for 127.0.0.1 at 2010-07-19 16:00:53) [GET]
Parameters: {"action"=>"new", "controller"=>"expenses"}
[4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/new
Rendered expenses/_options (0.4ms)
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 31ms (View: 18, DB: 1) | 200 OK [http://localhost/expenses/new]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#create (for 127.0.0.1 at 2010-07-19 16:01:02) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100719-29010-pkkisd-0>, "user_id"=>"1", "expense_number"=>"5464"}, "action"=>"create", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"expenses"}
[4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mSQL (0.1ms)[0m [0;1mBEGIN[0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mSQL (19.0ms)[0m [0;1mINSERT INTO "expenses" ("created_at", "content_type", "updated_at", "file_data", "user_id", "expense_number", "filename") VALUES('2010-07-19 06:01:02.316365', E'application/octet-stream', '2010-07-19 06:01:02.316365', E'# This viminfo file was generated by Vim 7.2.\\012# You may edit it if you are careful!\\012\\012# Value of ''encoding'' when this file was written\\012*encoding=utf-8\\012\\012\\012# hlsearch on (H) or off (h):\\012~h\\012# Last Search Pattern:\\012~Msle0~/\\\\<created\\\\>\\012\\012# Last Substitute String:\\012$\\012\\012# Command Line History (newest to oldest):\\012:wq\\012:q\\012:w\\012:e new.txt\\012:q!\\012:e ../layouts/application.html.erb\\012:e user_helper.rb\\012:b1\\012:e ../models/user.rb\\012:b3\\012:ls\\012:b2\\012:e goodbye.html.erb\\012:e hello.html.erb\\012:e ../views/say/goodbye.html.erb\\012:e ~/.vimrc\\012:e application_controller.rb\\012:e ../../controllers/say_controller.rb\\012:pwd\\012:e $VIMRUNTIME\\012:e $VIMRC\\012:e app/controllers/say_controller.rb\\012:bn\\012:e $GVIMRC\\012:e /home/myfwhite/.vim/gvimrc\\012:e /home/myfwhite/.vim/vimrc\\012:$VIMRC\\012:cd $HOME\\012:$HOME\\012:qall\\012::q\\012:e ~/Downloads/tutelogin/app/views/user/login.html.erb\\012\\012# Search String History (newest to oldest):\\012? \\\\<created\\\\>\\012?/flash\\012?/swap\\012?/swqp\\012?/host\\012?/cd \\012?/cucumber\\012?/--ver\\012?/pag\\012\\012# Expression History (newest to oldest):\\012\\012# Input Line History (newest to oldest):\\012\\012# Input Line History (newest to oldest):\\012\\012# Registers:\\012"0\\011LINE\\0110\\012\\011 ~ ~ ~\\012"1\\011LINE\\0110\\012\\011#\\012"2\\011LINE\\0110\\012\\011host all all 10.0.0.0 255.255.255.0 md5\\012"3\\011LINE\\0110\\012\\011# from https://help.ubuntu.com/community/PostgreSQL so that system and postgres users are separate\\012"4\\011LINE\\0110\\012\\011host all all ::1/128 md5\\012"5\\011LINE\\0110\\012\\011# IPv6 local connections:\\012"6\\011LINE\\0110\\012\\011host all all 127.0.0.1/32 md5\\012"7\\011LINE\\0110\\012\\011# IPv4 local connections:\\012"8\\011LINE\\0110\\012\\011local all all ident\\012"9\\011LINE\\0110\\012\\011# "local" is for Unix domain socket connections only\\012""-\\011CHAR\\0110\\012\\011#\\012\\012# File marks:\\012''0 3 45 ~/projects/c3freezer/db/migrate/20100719023923_add_username_uniqueness_index.rb\\012''1 80 0 /etc/postgresql/8.4/main/pg_hba.conf\\012''2 77 0 /etc/postgresql/8.4/main/pg_hba.conf\\012''3 83 0 /etc/postgresql/8.4/main/pg_hba.conf\\012''4 82 0 /etc/postgresql/8.4/main/pg_hba.conf\\012''5 84 46 /etc/postgresql/8.4/main/pg_hba.conf\\012''6 84 58 /etc/postgresql/8.4/main/pg_hba.conf\\012''7 22 23 ~/projects/c3freezer/config/environment.rb\\012''8 1 0 ~/projects/c3freezer/.gitignore\\012''9 3 0 ~/projects/c3freezer/.gitignore\\012\\012# Jumplist (newest first):\\012-'' 3 45 ~/projects/c3freezer/db/migrate/20100719023923_add_username_uniqueness_index.rb\\012-'' 1 0 ~/projects/c3freezer/db/migrate/20100719023923_add_username_uniqueness_index.rb\\012-'' 80 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 1 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 77 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 83 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 82 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 3 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 84 46 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 22 23 ~/projects/c3freezer/config/environment.rb\\012-'' 1 0 ~/projects/c3freezer/config/environment.rb\\012-'' 1 0 ~/projects/c3freezer/.gitignore\\012-'' 3 0 ~/projects/c3freezer/.gitignore\\012-'' 4 0 ~/projects/c3freezer/.gitignore\\012-'' 1 44 ~/projects/expenses/.git/COMMIT_EDITMSG\\012-'' 86 0 ~/Documents/new.txt\\012-'' 10 48 ~/Documents/routes.txt\\012-'' 4 0 ~/Documents/routes.txt\\012-'' 17 0 ~/Documents/routes.txt\\012-'' 6 1 ~/Documents/routes.txt\\012-'' 14 0 ~/Documents/routes.txt\\012-'' 15 0 ~/Documents/routes.txt\\012-'' 1 0 ~/Documents/routes.txt\\012-'' 3 2 ~/rails_tests/music_store/config/routes.rb\\012-'' 4 2 ~/rails_tests/music_store/config/routes.rb\\012-'' 1 0 ~/rails_tests/music_store/config/routes.rb\\012-'' 2 0 ~/rails_tests/music_store/config/routes.rb\\012-'' 1 0 ~/projects/expenses/README\\012-'' 4 0 ~/projects.old/expenses/config/routes.rb\\012-'' 1 0 ~/projects.old/expenses/config/routes.rb\\012-'' 9 5 ~/expensefiles/db/migrate/20100714232518_create_expense_files.rb\\012-'' 1 0 ~/expensefiles/db/migrate/20100714232518_create_expense_files.rb\\012-'' 4 15 ~/projects/expenses/db/migrate/20100714232518_create_expense_files.rb\\012-'' 1 0 ~/projects/expenses/db/migrate/20100714232518_create_expense_files.rb\\012-'' 1 6 ~/projects/upload_test/app/views/upload/uploadfile.haml\\012-'' 1 4 ~/projects/expenses/app/views/expenses/edit.haml\\012-'' 1 6 ~/projects/expenses/app/views/expenses/show.haml\\012-'' 1 4 ~/projects/expenses/app/views/expenses/new.haml\\012-'' 1 5 ~/projects/expenses/app/views/expenses/index.haml\\012-'' 4 0 ~/Downloads/tutelogin/app/views/layouts/_stylesheets.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/_stylesheets.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/public/stylesheets/custom.css\\012-'' 1 0 ~/Downloads/tutelogin/public/stylesheets/blueprint/screen.css\\012-'' 9 11 ~/Downloads/tutelogin/app/views/layouts/application.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/application.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/_footer.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/_f\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/_header.html.erb\\012-'' 1 6 ~/projects/expenses/app/views/layouts/_header.haml\\012-'' 1 0 ~/Downloads/tutelogin/app/views/user/login.html.erb\\012-'' 9 0 ~/Downloads/tutelogin/app/views/user\\012-'' 1 0 ~/Downloads/tutelogin/app/views/user\\012-'' 8 0 ~/Downloads/tutelogin/app/views/user\\012-'' 12 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 8 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 1 0 ~/Downloads/tutelogin/app/models/user.rb\\012-'' 1 0 ~/Downloads/tutelogin/app/helpers/user_helper.rb\\012-'' 1 0 ~/Downloads/tutelogin/app/helpers/application_helper.rb\\012-'' 9 0 ~/Downloads/tutelogin/app/controllers/user_controller.rb\\012-'' 1 0 ~/Downloads/tutelogin/app/controllers/user_controller.rb\\012-'' 1 0 ~/Downloads/tutelogin/app/controllers/application_controller.rb\\012-'' 1 0 ~/projects/expenses/config/environment.rb\\012-'' 1 0 ~/projects/expenses/public/stylesheets/scaffold.css\\012-'' 1 0 ~/Downloads/tutelogin/app/views/user/private.html.erb\\012-'' 18 0 ~/Downloads/tutelogin/app/views/user\\012-'' 11 0 ~/Downloads/tutelogin/app/views\\012-'' 1 0 ~/Downloads/tutelogin/app/views\\012-'' 19 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 44 0 ~/Downloads/tutelogin/config/routes.rb\\012-'' 1 0 ~/Downloads/tutelogin/config/routes.rb\\012-'' 11 37 ~/Downloads/tutelogin/app/views/layouts/application.html.erb\\012-'' 34 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 30 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 1 0 ~/projects/expenses/app/helpers/users_helper.rb\\012-'' 14 6 ~/projects/expenses/app/helpers/application_helper.rb\\012-'' 15 0 ~/projects/expenses/app/helpers/application_helper.rb\\012-'' 1 0 ~/projects/expenses/app/helpers/application_helper.rb\\012-'' 26 6 ~/projects/expenses/app/controllers/users_controller.rb\\012-'' 1 0 ~/projects/expenses/app/models/user.rb\\012-'' 28 3 ~/projects/expenses/app/controllers/users_controller.rb\\012-'' 1 0 ~/projects/expenses/app/controllers/users_controller.rb\\012-'' 5 12 ~/projects/expenses/db/migrate/20100713065213_create_users.rb\\012-'' 1 0 ~/projects/expenses/db/migrate/20100713065213_create_users.rb\\012-'' 1 0 ~/rails_tests/expenses/app/models/user.rb\\012-'' 17 16 ~/projects/expenses/config/database.yml\\012-'' 1 0 ~/projects/expenses/config/database.yml\\012-'' 4 15 ~/rails_tests/expenses/config/database.yml\\012-'' 1 0 ~/rails_tests/expenses/config/database.yml\\012-'' 1 0 ~/rails_tests/expenses/config/d\\012-'' 17 16 ~/rails_tests/expenses/config/database.yml\\012-'' 109 8 ~/.bashrc\\012-'' 1 0 ~/.bashrc\\012-'' 106 2 ~/.bashrc\\012-'' 105 1 ~/.bashrc\\012-'' 11 4 ~/rails_tests/e/app/views/say/hello.html.erb\\012-'' 1 0 ~/rails_tests/e/app/views/say/hello.html.erb\\012-'' 49 23 ~/Documents/Notes.txt\\012-'' 1 0 ~/Documents/Notes.txt\\012-'' 5 23 ~/rails_tests/e/app/controllers/say_controller.rb\\012\\012# History of marks within files (newest to oldest):\\012\\012> ~/projects/c3freezer/db/migrate/20100719023923_add_username_uniqueness_index.rb\\012\\011"\\0113\\01145\\012\\011^\\0113\\01146\\012\\011.\\0113\\01145\\012\\011+\\0113\\01145\\012\\012> /etc/postgresql/8.4/main/pg_hba.conf\\012\\011"\\01180\\0110\\012\\011^\\01183\\0111\\012\\011.\\01182\\0110\\012\\011+\\01184\\01197\\012\\011+\\01184\\0110\\012\\011+\\01184\\01151\\012\\011+\\01184\\01156\\012\\011+\\01184\\0110\\012\\011+\\01183\\0110\\012\\011+\\01176\\0110\\012\\011+\\01178\\0110\\012\\011+\\01180\\0110\\012\\011+\\01182\\0110\\012\\012> ~/projects/c3freezer/config/environment.rb\\012\\011"\\01122\\01123\\012\\011^\\01122\\01124\\012\\011.\\01122\\01123\\012\\011+\\01122\\01123\\012\\012> ~/projects/c3freezer/.gitignore\\012\\011"\\0111\\0110\\012\\011^\\0113\\01111\\012\\011.\\0113\\01110\\012\\011+\\0111\\0119\\012\\011+\\0112\\0114\\012\\011+\\0111\\0114\\012\\011+\\0114\\0110\\012\\011+\\0113\\01110\\012\\012> ~/projects/expenses/.git/COMMIT_EDITMSG\\012\\011"\\0111\\01144\\012\\011^\\0111\\01145\\012\\011.\\0111\\01144\\012\\011+\\0111\\01144\\012\\012> ~/Documents/routes.txt\\012\\011"\\01110\\01148\\012\\011^\\0118\\01149\\012\\011.\\01110\\0110\\012\\011+\\0111\\01138\\012\\011+\\0117\\01138\\012\\011+\\0119\\01138\\012\\011+\\01111\\01138\\012\\011+\\01113\\01138\\012\\011+\\01113\\01138\\012\\011+\\01114\\01138\\012\\011+\\01115\\01138\\012\\011+\\0111\\01121\\012\\011+\\0113\\0110\\012\\011+\\0112\\01142\\012\\011+\\0114\\01143\\012\\011+\\0116\\01138\\012\\011+\\0117\\01138\\012\\011+\\0119\\01138\\012\\011+\\01111\\01138\\012\\011+\\01113\\01138\\012\\011+\\01114\\01138\\012\\011+\\01115\\01146\\012\\011+\\01114\\01145\\012\\011+\\01113\\01143\\012\\011+\\01111\\01143\\012\\011+\\0119\\01142\\012\\011+\\0117\\01145\\012\\011+\\0116\\01144\\012\\011+\\0116\\01174\\012\\011+\\0113\\01132\\012\\011+\\0114\\01169\\012\\011+\\0117\\01173\\012\\011+\\0116\\01156\\012\\011+\\0117\\01166\\012\\011+\\01113\\01157\\012\\011+\\01115\\01157\\012\\011+\\01114\\01157\\012\\011+\\01111\\01170\\012\\011+\\0119\\01169\\012\\011+\\0116\\01166\\012\\011+\\0118\\0110\\012\\011+\\01110\\0110\\012\\011+\\01112\\0110\\012\\011+\\0114\\01171\\012\\011+\\01117\\0110\\012\\011+\\0115\\0110\\012\\011+\\01116\\0110\\012\\011+\\0118\\01148\\012\\011+\\01110\\0110\\012\\011+\\01112\\0110\\012\\011+\\01110\\0110\\012\\012> ~/Documents/new.txt\\012\\011"\\01186\\0110\\012\\011.\\0111\\0110\\012\\011+\\0111\\0110\\012\\012> ~/rails_tests/music_store/config/routes.rb\\012\\011"\\0113\\0112\\012\\011.\\0113\\0110\\012\\011+\\0114\\0110\\012\\011+\\0113\\0110\\012\\012> ~/projects/expenses/README\\012\\011"\\0111\\0110\\012\\011^\\0111\\01121\\012\\011.\\0111\\01120\\012\\011+\\0111\\01121\\012\\011+\\0111\\01120\\012\\012> ~/projects.old/expenses/config/routes.rb\\012\\011"\\0114\\0110\\012\\012> ~/Documents/Notes.txt\\012\\011"\\01149\\0114\\012\\011^\\01149\\01124\\012\\011.\\01149\\01123\\012\\011+\\0116\\0112\\012\\011+\\01111\\01117\\012\\011+\\0119\\01110\\012\\011+\\01111\\01118\\012\\011+\\01112\\01129\\012\\011+\\01150\\0110\\012\\011+\\01119\\0115\\012\\011+\\01119\\01128\\012\\011+\\01121\\01131\\012\\011+\\01122\\01110\\012\\011+\\01122\\0112\\012\\011+\\01121\\0110\\012\\011+\\01119\\0110\\012\\011+\\01122\\0110\\012\\011+\\01120\\0110\\012\\011+\\01122\\01122\\012\\011+\\01119\\01184\\012\\011+\\01123\\01117\\012\\011+\\01121\\01112\\012\\011+\\01122\\01122\\012\\011+\\01123\\01117\\012\\011+\\01122\\01110\\012\\011+\\01124\\01115\\012\\011+\\01125\\0111\\012\\011+\\01124\\01115\\012\\011+\\01125\\01117\\012\\011+\\01140\\0110\\012\\011+\\01150\\01113\\012\\011+\\01150\\01144\\012\\011+\\01150\\01110\\012\\011+\\01119\\01145\\012\\011+\\01119\\0110\\012\\011+\\01119\\0117\\012\\011+\\01119\\0110\\012\\011+\\01119\\0110\\012\\011+\\01119\\01148\\012\\011+\\01150\\0110\\012\\011+\\01150\\0110\\012\\011+\\01119\\0110\\012\\011+\\01119\\0116\\012\\011+\\01150\\0110\\012\\011+\\01150\\0117\\012\\011+\\01150\\0117\\012\\011+\\01128\\0119\\012\\011+\\01129\\0117\\012\\011+\\01130\\0118\\012\\011+\\01127\\01122\\012\\011+\\01131\\01129\\012\\011+\\01140\\01113\\012\\011+\\01119\\0110\\012\\011+\\01117\\0111\\012\\011+\\01119\\0110\\012\\011+\\01118\\011107\\012\\011+\\01122\\0110\\012\\011+\\01139\\0110\\012\\011+\\01150\\0110\\012\\011+\\01133\\0110\\012\\011+\\01132\\0110\\012\\011+\\01150\\0110\\012\\011+\\01149\\01123\\012\\012> ~/projects/expenses/config/database.yml\\012\\011"\\01117\\01116\\012\\011^\\01117\\01117\\012\\011.\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\012> ~/expensefiles/db/migrate/20100714232518_create_expense_files.rb\\012\\011"\\0119\\0115\\012\\011^\\0118\\01134\\012\\011.\\0119\\0110\\012\\011+\\0114\\01132\\012\\011+\\0115\\0110\\012\\011+\\0119\\0117\\012\\011+\\0114\\0110\\012\\011+\\0119\\0115\\012\\011+\\0115\\01129\\012\\011+\\0119\\0110\\012\\011+\\0116\\01132\\012\\011+\\0117\\01127\\012\\011+\\0118\\01133\\012\\011+\\0119\\0110\\012\\012> ~/projects/expenses/db/migrate/20100714232518_create_expense_files.rb\\012\\011"\\0114\\01115\\012\\011^\\0114\\01116\\012\\011.\\0114\\01115\\012\\011+\\0114\\01115\\012\\012> ~/projects/upload_test/app/views/upload/uploadfile.haml\\012\\011"\\0111\\0116\\012\\011^\\0111\\0117\\012\\011.\\0111\\0116\\012\\011+\\0111\\0116\\012\\012> ~/projects/expenses/app/views/expenses/edit.haml\\012\\011"\\0111\\0114\\012\\011^\\0111\\0115\\012\\011.\\0111\\0114\\012\\011+\\0111\\0114\\012\\012> ~/projects/expenses/app/views/expenses/show.haml\\012\\011"\\0111\\0116\\012\\011^\\0111\\0117\\012\\011.\\0111\\0116\\012\\011+\\0111\\0116\\012\\012> ~/projects/expenses/app/views/expenses/new.haml\\012\\011"\\0111\\0114\\012\\011^\\0111\\0115\\012\\011.\\0111\\0114\\012\\011+\\0111\\0114\\012\\012> ~/projects/expenses/app/views/expenses/index.haml\\012\\011"\\0111\\0115\\012\\011^\\0111\\0116\\012\\011.\\0111\\0115\\012\\011+\\0111\\0115\\012\\012> ~/Downloads/tutelogin/app/views/layouts/_stylesheets.html.erb\\012\\011"\\0114\\0110\\012\\012> ~/Downloads/tutelogin/public/stylesheets/custom.css\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/public/stylesheets/blueprint/screen.css\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/views/layouts/application.html.erb\\012\\011"\\0119\\01111\\012\\011^\\0111\\0111\\012\\012> ~/Downloads/tutelogin/app/views/layouts/_footer.html.erb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/views/layouts/_footer.haml\\012\\011"\\0111\\0118\\012\\011^\\0111\\0119\\012\\011.\\0111\\0118\\012\\011+\\0111\\0118\\012\\012> ~/Downloads/tutelogin/app/views/layouts/_f\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/views/layouts/_stylesheets.haml\\012\\011"\\0111\\0115\\012\\011^\\0111\\0116\\012\\011.\\0111\\0115\\012\\011+\\0111\\0115\\012\\012> ~/Downloads/tutelogin/app/views/layouts/_header.html.erb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/views/layouts/_header.haml\\012\\011"\\0111\\0116\\012\\011^\\0111\\0117\\012\\011.\\0111\\0116\\012\\011+\\0111\\0116\\012\\012> ~/Downloads/tutelogin/app/views/user/login.html.erb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/models/user.rb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/helpers/application_helper.rb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/helpers/user_helper.rb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/controllers/user_controller.rb\\012\\011"\\0119\\0110\\012\\012> ~/Downloads/tutelogin/app/controllers/application_controller.rb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/config/environment.rb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/config/environment.rb\\012\\011"\\0114\\01125\\012\\011^\\0114\\0111\\012\\011.\\0114\\01125\\012\\011+\\0114\\01125\\012\\012> ~/projects/expenses/public/stylesheets/scaffold.css\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/views/user/private.html.erb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/views/users/private.haml\\012\\011"\\0113\\01134\\012\\011^\\0113\\01168\\012\\011.\\0113\\01168\\012\\011+\\0111\\01152\\012\\011+\\0113\\01168\\012\\012> ~/projects/expenses/app/views/users/login.haml\\012\\011"\\01112\\0110\\012\\011^\\01110\\01110\\012\\011.\\01112\\0110\\012\\011+\\0112\\0118\\012\\011+\\0113\\0115\\012\\011+\\0113\\0110\\012\\011+\\0117\\0110\\012\\011+\\0113\\01142\\012\\011+\\0114\\0116\\012\\011+\\0117\\0110\\012\\011+\\0119\\0110\\012\\011+\\0116\\0117\\012\\011+\\01110\\0110\\012\\011+\\0118\\0116\\012\\011+\\01110\\01110\\012\\011+\\01112\\0110\\012\\012> ~/projects/expenses/app/views/layouts/application.haml\\012\\011"\\01115\\0114\\012\\011^\\01115\\0115\\012\\011.\\01115\\0114\\012\\011+\\0114\\0113\\012\\011+\\0115\\0115\\012\\011+\\01116\\0110\\012\\011+\\0114\\01113\\012\\011+\\0115\\0110\\012\\011+\\0117\\01129\\012\\011+\\0112\\01162\\012\\011+\\0117\\01134\\012\\011+\\0118\\0118\\012\\011+\\0116\\0110\\012\\011+\\0117\\0110\\012\\011+\\0118\\01140\\012\\011+\\0119\\01120\\012\\011+\\01111\\01140\\012\\011+\\01113\\01113\\012\\011+\\01113\\0110\\012\\011+\\01116\\0110\\012\\011+\\01113\\01115\\012\\011+\\01116\\0110\\012\\011+\\01113\\0110\\012\\011+\\01114\\0110\\012\\011+\\01115\\0110\\012\\011+\\01116\\0110\\012\\011+\\01115\\01133\\012\\011+\\0114\\0112\\012\\011+\\01115\\0114\\012\\012> ~/projects/expenses/config/routes.rb\\012\\011"\\0113\\0112\\012\\011.\\0113\\0110\\012\\011+\\01145\\0110\\012\\011+\\0113\\0110\\012\\011+\\0113\\0110\\012\\012> ~/Downloads/tutelogin/config/routes.rb\\012\\011"\\01144\\0110\\012\\012> ~/projects/expenses/app/views/layouts/application.html.erb\\012\\011"\\0111\\0111\\012\\011^\\0111\\0112\\012\\011.\\0111\\0111\\012\\011+\\0111\\0111\\012\\012> ~/projects/expenses/app/views/layouts/users.html.erb\\012\\011"\\01116\\0110\\012\\012> ~/projects/expenses/app/helpers/users_helper.rb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/helpers/application_helper.rb\\012\\011"\\01114\\0116\\012\\011^\\01114\\0117\\012\\011.\\01114\\0110\\012\\011+\\01115\\01114\\012\\011+\\0115\\0118\\012\\011+\\01115\\0110\\012\\011+\\0119\\01142\\012\\011+\\01115\\0110\\012\\011+\\0119\\01174\\012\\011+\\01110\\0110\\012\\011+\\01114\\0110\\012\\012> ~/projects/expenses/app/controllers/users_controller.rb\\012\\011"\\01126\\0116\\012\\011^\\01126\\0117\\012\\011.\\01126\\0110\\012\\011+\\01128\\0110\\012\\011+\\01128\\0114\\012\\011+\\01128\\0110\\012\\011+\\01111\\011118\\012\\011+\\01110\\01143\\012\\011+\\01128\\0110\\012\\011+\\01127\\0110\\012\\011+\\01113\\01120\\012\\011+\\01117\\01143\\012\\011+\\01114\\01142\\012\\011+\\01117\\01140\\012\\011+\\01119\\0110\\012\\011+\\01124\\01141\\012\\011+\\01126\\0110\\012\\012> ~/projects/expenses/app/models/user.rb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/db/migrate/20100713065213_create_users.rb\\012\\011"\\0115\\01112\\012\\012> ~/rails_tests/expenses/app/models/user.rb\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/expenses/config/database.yml\\012\\011"\\0114\\01115\\012\\011^\\01117\\01117\\012\\011.\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\012> ~/rails_tests/expenses/config/d\\012\\011"\\0111\\0110\\012\\012> ~/.bashrc\\012\\011"\\011109\\0118\\012\\011^\\011109\\01129\\012\\011.\\011109\\01129\\012\\011+\\011113\\0110\\012\\011+\\011102\\01156\\012\\011+\\011103\\01110\\012\\011+\\011102\\01129\\012\\011+\\011100\\0110\\012\\011+\\011101\\0110\\012\\011+\\011102\\01129\\012\\011+\\011109\\0119\\012\\011+\\011111\\01126\\012\\011+\\011102\\01135\\012\\011+\\011109\\0119\\012\\011+\\011107\\0110\\012\\011+\\011109\\01129\\012\\011i\\011102\\01138\\012\\012> ~/rails_tests/e/app/views/say/hello.html.erb\\012\\011"\\01111\\0114\\012\\011.\\01111\\0110\\012\\011+\\0111\\01126\\012\\011+\\0111\\0112\\012\\011+\\0111\\0116\\012\\011+\\0111\\0117\\012\\011+\\01112\\0117\\012\\011+\\0111\\0110\\012\\011+\\0117\\01118\\012\\011+\\0112\\0110\\012\\011+\\01112\\0110\\012\\011+\\0113\\0110\\012\\011+\\0116\\0110\\012\\011+\\01111\\0110\\012\\011+\\0117\\01127\\012\\011+\\01111\\0110\\012\\011+\\0118\\01123\\012\\011+\\0119\\0110\\012\\011+\\01111\\01136\\012\\011+\\01111\\01114\\012\\011+\\01111\\01111\\012\\011+\\01111\\0119\\012\\011+\\01111\\01139\\012\\011+\\01111\\0110\\012\\012> ~/rails_tests/e/app/controllers/say_controller.rb\\012\\011"\\0115\\01123\\012\\011^\\0114\\01130\\012\\011.\\0114\\01129\\012\\011+\\0116\\0112\\012\\011+\\0113\\0110\\012\\011+\\0112\\0110\\012\\011+\\01111\\0110\\012\\011+\\0115\\01123\\012\\011+\\01110\\0110\\012\\011+\\0118\\01114\\012\\011+\\0119\\0110\\012\\011+\\0117\\0110\\012\\011+\\0114\\01129\\012\\012> ~/rails_tests/e/app/views/say/goodbye.html.erb\\012\\011"\\0119\\01128\\012\\011^\\0119\\01129\\012\\011.\\01110\\0110\\012\\011+\\01112\\0117\\012\\011+\\0118\\0110\\012\\011+\\0117\\01134\\012\\011+\\0118\\01141\\012\\011+\\0118\\01114\\012\\011+\\0119\\01151\\012\\011+\\01110\\0110\\012\\012> ~/rails_tests/e/app/controllers/application_controller.rb\\012\\011"\\0111\\0110\\012\\012> ~/.vimrc\\012\\011"\\01163\\01114\\012\\012> ~/rails_tests/e/$VIMRC\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/e/config/database.yml\\012\\011"\\01117\\01116\\012\\011^\\01117\\01117\\012\\011.\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\012> ~/rails_tests/d/app/controllers/say_controller.rb\\012\\011"\\0111\\0110\\012\\011^\\0113\\0114\\012\\011.\\0113\\0114\\012\\011+\\0114\\0110\\012\\011+\\0112\\0113\\012\\011+\\0113\\0114\\012\\012> ~/rails_tests/d/config/routes.rb\\012\\011"\\01142\\0110\\012\\012> ~/$VIMRC\\012\\011"\\0111\\0110\\012\\011.\\0111\\0110\\012\\011+\\0111\\0110\\012\\012> ~/.vim/vimrc\\012\\011"\\0111\\0110\\012\\012> ~/.vim/gvimrc\\012\\011"\\0111\\0110\\012\\012> ~/$GVIMRC\\012\\011"\\0111\\0110\\012\\011.\\0111\\0110\\012\\011+\\0111\\0110\\012\\012> ~/rails_tests/d/app/views/say/hello.html.erb\\012\\011"\\0119\\0110\\012\\011^\\0119\\0110\\012\\011.\\0118\\0117\\012\\011+\\0111\\0116\\012\\011+\\0118\\0117\\012\\012> ~/rails_tests/d/config/database.yml\\012\\011"\\01117\\0110\\012\\011^\\01117\\01117\\012\\011.\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\012> /etc/postgresql/8.1/main/pg_hba.conf\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/b/config/database.yml\\012\\011"\\01113\\01115\\012\\011^\\01113\\01116\\012\\011.\\01113\\01115\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\011+\\01113\\01115\\012\\012> ~/Documents/peepcode-009-rails-i-4-mov/code/dotfiles/ptree.pl\\012\\011"\\0111\\0110\\012\\012> ~/Documents/peepcode-009-rails-i-4-mov/code/dotfiles/aliases.bash.sh\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/m/config/routes.rb\\012\\011"\\01143\\0110\\012\\012> ~/rails_tests/m/app/controllers/application_controller.rb\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/m/config/environments/development.rb\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/m/app/controllers/say_controller.rb\\012\\011"\\0113\\0112\\012\\011^\\0113\\0113\\012\\011.\\0113\\0112\\012\\011+\\0113\\0112\\012\\012> ~/pgadmin.log\\012\\011"\\0115\\0110\\012\\012> ~/rails_tests/test/config/database.yml\\012\\011"\\0114\\01111\\012\\012> ~/rails_tests/test/config/environment.rb\\012\\011"\\01141\\0110\\012\\012> ~/rails_tests/test/app/controllers/say_controller.rb\\012\\011"\\0113\\0112\\012\\011^\\0113\\0113\\012\\011.\\0113\\0112\\012\\011+\\0113\\0112\\012\\012> ~/rails_tests/work/config/database.yml\\012\\011"\\01110\\0110\\012\\011^\\0119\\01121\\012\\011.\\01110\\0110\\012\\011+\\0114\\01120\\012\\011+\\0115\\01116\\012\\011+\\0117\\01127\\012\\011+\\01110\\0110\\012\\011+\\01110\\0111\\012\\011+\\0119\\01120\\012\\011+\\01110\\0110\\012\\012> ~/rails_tests/work/app/views/say/hello.html.erb\\012\\011"\\0119\\0110\\012\\011^\\0119\\0110\\012\\011.\\0118\\0117\\012\\011+\\0118\\0117\\012\\012> ~/rails_tests/work/app/controllers/say_controller.rb\\012\\011"\\0114\\0112\\012\\011^\\0114\\0113\\012\\011.\\0114\\0112\\012\\011+\\0115\\0110\\012\\011+\\0114\\0112\\012\\012> ~/rails_tests/demo/app/controllers/say_controller.rb\\012\\011"\\0111\\0110\\012\\011^\\0113\\0117\\012\\011.\\0113\\0116\\012\\011+\\0113\\0116\\012\\012> ~/rails_tests/demo/app/views/say/hello.html.erb\\012\\011"\\0111\\0110\\012\\011^\\0118\\0117\\012\\011.\\0118\\0116\\012\\011+\\0118\\0116\\012\\012> ~/rails_tests/demo/config/routes.rb\\012\\011"\\01143\\0110\\012\\012> ~/rails_tests/abc/config/environment.rb\\012\\011"\\0114\\0110\\012\\011^\\0114\\0111\\012\\011.\\0114\\0110\\012\\011+\\0114\\0110\\012\\012> ~/.gemrc\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/demo/config/environment.rb\\012\\011"\\0114\\0110\\012\\011^\\0114\\0111\\012\\011.\\0114\\0110\\012\\011+\\0114\\0110\\012\\012> ~/rails_tests/demo/config/environments/development.rb\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/demo/config/boot.rb\\012\\011"\\01185\\0110\\012\\012> ~/.bash_history\\012\\011"\\011108\\0110\\012\\012> ~/rails_tests/demo/config/environment\\012\\011"\\0111\\0110\\012\\012> /etc/X11/xorg.conf\\012\\011"\\0115\\01118\\012\\011^\\0115\\01119\\012\\011.\\0115\\01118\\012\\011+\\0115\\01118\\012\\012> ~/Downloads/rubygems-1.3.7/README\\012\\011"\\01119\\0110\\012', 1, 5464, E'.viminfo') RETURNING "id"[0m
[4;35;1mSQL (16.8ms)[0m [0mCOMMIT[0m
Redirected to http://localhost:3000/expenses
Completed in 63ms (DB: 37) | 302 Found [http://localhost/expenses]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:01:02) [GET]
Parameters: {"action"=>"index", "controller"=>"expenses"}
[4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mExpense Load (282.9ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expenses/index
Rendered expenses/_options (0.4ms)
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 611ms (View: 17, DB: 284) | 200 OK [http://localhost/expenses]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:01:06) [GET]
Parameters: {"action"=>"search", "controller"=>"expenses"}
[4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/search
Rendered expenses/_options (0.4ms)
Rendered layouts/_header (0.1ms)
Rendered layouts/_footer (0.1ms)
Completed in 23ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:05:55) [GET]
Parameters: {"action"=>"search", "controller"=>"expenses"}
[4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/search
Rendered expenses/_options (0.4ms)
ActionView::TemplateError (undefined method `submit_tag' for #<ActionView::Helpers::FormBuilder:0xb66c7918>) on line #13 of app/views/expenses/search.haml:
10: %br
11: = f.text_field 'username'
12: .actions
13: = f.submit_tag "Search", :name => nil
app/views/expenses/search.haml:13
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:225:in `call'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:225
haml (3.0.13) lib/haml/helpers.rb:588:in `call'
haml (3.0.13) lib/haml/helpers.rb:588:in `haml_bind_proc'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:231:in `form_for'
app/views/expenses/search.haml:3:in `_run_haml_app47views47expenses47search46haml'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (108.6ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (internal_server_error)
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:06:03) [GET]
Parameters: {"action"=>"search", "controller"=>"expenses"}
[4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/search
Rendered expenses/_options (0.4ms)
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 23ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:08:30) [GET]
Parameters: {"action"=>"search", "controller"=>"expenses"}
[4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/search
Rendered expenses/_options (0.4ms)
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 24ms (View: 12, DB: 1) | 200 OK [http://localhost/expenses/search]
[4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-19 16:08:34) [POST]
Parameters: {"commit"=>"Search", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "expenses"=>{"username"=>"", "expense_number"=>"1111"}}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (22.5ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (method_not_allowed)
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:49:45) [GET]
Parameters: {"action"=>"search", "controller"=>"expenses"}
[4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/search
Rendered expenses/_options (0.4ms)
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 17ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing UsersController#login (for 127.0.0.1 at 2010-07-19 16:49:51) [GET]
Parameters: {"action"=>"login", "controller"=>"users"}
Rendering template within layouts/application
Rendering users/login
[4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendered expenses/_options (0.5ms)
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 16ms (View: 14, DB: 1) | 200 OK [http://localhost/]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing UsersController#login (for 127.0.0.1 at 2010-07-19 16:51:23) [GET]
Parameters: {"action"=>"login", "controller"=>"users"}
Rendering template within layouts/application
Rendering users/login
[4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendered expenses/_options (0.5ms)
Rendered layouts/_header (0.2ms)
Rendered expenses/_options (0.4ms)
Rendered layouts/_footer (0.1ms)
Completed in 24ms (View: 22, DB: 1) | 200 OK [http://localhost/]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing UsersController#login (for 127.0.0.1 at 2010-07-19 16:51:34) [GET]
Parameters: {"action"=>"login", "controller"=>"users"}
Rendering template within layouts/application
Rendering users/login
[4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendered layouts/_header (6.9ms)
Rendered expenses/_options (0.4ms)
Rendered layouts/_footer (0.1ms)
Completed in 86ms (View: 22, DB: 1) | 200 OK [http://localhost/]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:52:24) [GET]
Parameters: {"action"=>"index", "controller"=>"expenses"}
[4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
SyntaxError (/home/myfwhite/projects/expenses/app/models/expense.rb:15: syntax error, unexpected kEND
/home/myfwhite/projects/expenses/app/models/expense.rb:81: syntax error, unexpected $end, expecting kEND):
app/controllers/expenses_controller.rb:31:in `index'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (36.5ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#new (for 127.0.0.1 at 2010-07-19 16:52:33) [GET]
Parameters: {"action"=>"new", "controller"=>"expenses"}
[4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/new
ActionView::TemplateError (/home/myfwhite/projects/expenses/app/models/expense.rb:15: syntax error, unexpected kEND
/home/myfwhite/projects/expenses/app/models/expense.rb:81: syntax error, unexpected $end, expecting kEND) on line #2 of app/views/expenses/new.haml:
1: - error_messages_for :expense
2: - form_for Expense.new, :html =>{ :multipart => true } do |f|
3: = f.hidden_field :user_id, :value => current_user.id
4: .field
5: = label(:expense_number, "Expense number")
app/views/expenses/new.haml:2:in `_run_haml_app47views47expenses47new46haml'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (48.1ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#new (for 127.0.0.1 at 2010-07-19 16:52:59) [GET]
Parameters: {"action"=>"new", "controller"=>"expenses"}
[4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/new
Rendered layouts/_header (71.4ms)
Rendered expenses/_options (0.4ms)
Rendered layouts/_footer (0.1ms)
Completed in 97ms (View: 85, DB: 1) | 200 OK [http://localhost/expenses/new]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#new (for 127.0.0.1 at 2010-07-19 16:53:00) [GET]
Parameters: {"action"=>"new", "controller"=>"expenses"}
[4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/new
Rendered layouts/_header (0.2ms)
Rendered expenses/_options (0.4ms)
Rendered layouts/_footer (0.1ms)
Completed in 25ms (View: 13, DB: 1) | 200 OK [http://localhost/expenses/new]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:53:01) [GET]
Parameters: {"action"=>"search", "controller"=>"expenses"}
[4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/search
Rendered layouts/_header (0.2ms)
Rendered expenses/_options (0.3ms)
Rendered layouts/_footer (0.1ms)
Completed in 23ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:53:03) [GET]
Parameters: {"action"=>"index", "controller"=>"expenses"}
[4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendering template within layouts/application
Rendering expenses/index
ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each) on line #6 of app/views/expenses/index.haml:
3: %th Expense number
4: %th Employee
5: %th File
6: - @expenses.each do |expense|
7: %tr
8: %td= expense.expense_number
9: %td= expense.user.username
app/views/expenses/index.haml:6:in `_run_haml_app47views47expenses47index46haml'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (39.9ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:53:11) [GET]
Parameters: {"action"=>"index", "controller"=>"expenses"}
[4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mExpense Load (284.7ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expenses/index
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendered layouts/_header (0.2ms)
Rendered expenses/_options (0.3ms)
Rendered layouts/_footer (0.1ms)
Completed in 630ms (View: 18, DB: 286) | 200 OK [http://localhost/expenses]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 17:01:04) [GET]
Parameters: {"action"=>"index", "controller"=>"expenses"}
[4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
[4;35;1mExpense Load (284.7ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expenses/index
ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each) on line #6 of app/views/expenses/index.haml:
3: %th Expense number
4: %th Employee
5: %th File
6: - @expenses.each do |expense|
7: %tr
8: %td= expense.expense_number
9: %td= expense.user.username
app/views/expenses/index.haml:6:in `_run_haml_app47views47expenses47index46haml'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (40.6ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-20 09:10:48) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (8.6ms)
+Rendered expenses/_options (2.6ms)
+Rendered layouts/_footer (1.1ms)
+Completed in 63ms (View: 60, DB: 1) | 200 OK [http://localhost/]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 09:10:54) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (277.0ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.6ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 593ms (View: 21, DB: 278) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (1.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:11:02) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (276.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 594ms (View: 22, DB: 278) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#update (for 127.0.0.1 at 2010-07-20 09:11:06) [PUT]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"update", "_method"=>"put", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "id"=>"23", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'1111') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses/6
+Completed in 18ms (DB: 1) | 302 Found [http://localhost/expenses/23]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:11:06) [GET]
+ Parameters: {"action"=>"show", "id"=>"6", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 6) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;36;1mUser Load (0.3ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 28ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/6]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:11:09) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (280.1ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 600ms (View: 17, DB: 281) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#update (for 127.0.0.1 at 2010-07-20 09:11:13) [PUT]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"22222"}, "action"=>"update", "_method"=>"put", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "id"=>"23", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'22222') LIMIT 1[0m
+
+NoMethodError (You have a nil object when you didn't expect it!
+The error occurred while evaluating nil.authorised_for):
+ app/models/expense.rb:14:in `search'
+ app/controllers/expenses_controller.rb:20:in `update'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (32.9ms)
+Rendered rescues/_request_and_response (1.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:29:28) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 78ms (View: 62, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:32:03) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 30ms (View: 14, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.0ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:32:06) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 26ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:33:23) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 29ms (View: 14, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:33:39) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 30ms (View: 14, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:35:52) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (16.9ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 90ms (View: 74, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:37:12) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:37:13) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+NoMethodError (You have a nil object when you didn't expect it!
+The error occurred while evaluating nil.merge):
+ app/controllers/expenses_controller.rb:50:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (31.6ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:38:10) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:38:26) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+NoMethodError (You have a nil object when you didn't expect it!
+The error occurred while evaluating nil.merge):
+ app/controllers/expenses_controller.rb:50:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (30.4ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:39:45) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.7ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 95ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:39:49) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+NameError (uninitialized constant ExpensesController::RAILS_DEFAULT_DEBUGGER):
+ app/controllers/expenses_controller.rb:50:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (32.3ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:40:27) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+NameError (uninitialized constant ExpensesController::RAILS_DEFAULT_DEBUGGER):
+ app/controllers/expenses_controller.rb:50:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (31.7ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:41:20) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:41:21) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:41:27) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+
+NoMethodError (You have a nil object when you didn't expect it!
+The error occurred while evaluating nil.merge):
+ app/controllers/expenses_controller.rb:52:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (36.2ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:41:49) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+
+NoMethodError (undefined method `expense' for #<ExpensesController:0xb66c62d4>):
+ app/controllers/expenses_controller.rb:55:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (30.7ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:42:18) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+
+NoMethodError (undefined method `expense' for #<ExpensesController:0xb65cfb8c>):
+ app/controllers/expenses_controller.rb:56:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (31.8ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:44:27) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+
+NoMethodError (undefined method `expense' for #<ExpensesController:0xb64f75d4>):
+ app/controllers/expenses_controller.rb:56:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (33.8ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:45:01) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+Redirected to http://localhost:3000/expenses/5
+Completed in 19ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:45:01) [GET]
+ Parameters: {"action"=>"show", "id"=>"5", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/5]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:45:03) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:45:05) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+Redirected to http://localhost:3000/expenses/5
+Completed in 21ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:45:05) [GET]
+ Parameters: {"action"=>"show", "id"=>"5", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 22ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/5]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:45:06) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.5ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 85ms (View: 70, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:45:08) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+Redirected to http://localhost:3000/expenses/5
+Completed in 19ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:45:08) [GET]
+ Parameters: {"action"=>"show", "id"=>"5", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/5]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:45:28) [GET]
+ Parameters: {"action"=>"show", "id"=>"5", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 26ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/5]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:45:30) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 8, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 09:45:41) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+NoMethodError (undefined method `search' for #<Class:0xb65deb14>):
+ app/controllers/expenses_controller.rb:41:in `index'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (35.8ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 09:46:30) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.7ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+NoMethodError (undefined method `search' for #<Class:0xb680f2e4>):
+ app/controllers/expenses_controller.rb:41:in `index'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (34.7ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 09:46:45) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (293.1ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 573ms (View: 14, DB: 294) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 09:47:34) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+ArgumentError (wrong number of arguments (2 for 1)):
+ app/controllers/expenses_controller.rb:41:in `search_by_current_user'
+ app/controllers/expenses_controller.rb:41:in `index'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (32.2ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 09:47:53) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+ArgumentError (wrong number of arguments (2 for 1)):
+ app/controllers/expenses_controller.rb:41:in `search_by_current_user'
+ app/controllers/expenses_controller.rb:41:in `index'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (30.7ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 09:48:12) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (289.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 568ms (View: 15, DB: 290) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#logout (for 127.0.0.1 at 2010-07-20 09:48:31) [GET]
+ Parameters: {"action"=>"logout", "controller"=>"users"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Redirected to http://localhost:3000/login
+Completed in 14ms (DB: 1) | 302 Found [http://localhost/user/logout]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-20 09:48:31) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 7ms (View: 5, DB: 0) | 200 OK [http://localhost/login]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-20 09:48:35) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"/7CwsuGX6HlOHlK3lTEEfvKPE5zi0wTqB/vJkB5qEyI=", "controller"=>"users", "user"=>{"username"=>"test", "password"=>"[FILTERED]"}}
+ [4;35;1mUser Load (1.0ms)[0m [0mSELECT * FROM "users" WHERE (username = E'test' and password = E'test') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 09:48:35) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (4.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 2) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 32ms (View: 8, DB: 5) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:48:44) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 71ms (View: 56, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:48:48) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"1111", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"1111", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'1111') LIMIT 1[0m
+#<Expense id: 6, user_id: 2, expense_number: 1111, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:41", updated_at: "2010-07-15 01:31:41">
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+#<Expense id: 6, user_id: 2, expense_number: 1111, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:41", updated_at: "2010-07-15 01:31:41">
+Redirected to http://localhost:3000/expenses/6
+Completed in 20ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:48:48) [GET]
+ Parameters: {"action"=>"show", "id"=>"6", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 6) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/6]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:48:51) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:48:53) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.8ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+ [4;36;1mUser Load (0.3ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+Redirected to http://localhost:3000/expenses/5
+Completed in 20ms (DB: 2) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:48:53) [GET]
+ Parameters: {"action"=>"show", "id"=>"5", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mUser Load (0.2ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/5]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:49:03) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 8, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:49:08) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9874654132356"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9874654132356"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9874654132356", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"9874654132356", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.0ms)[0m [0mPGError: ERROR: value "9874654132356" is out of range for type integer
+LINE 1: ...M "expenses" WHERE ("expenses"."expense_number" = E'98746541...
+ ^
+: SELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9874654132356') LIMIT 1[0m
+
+ActiveRecord::StatementInvalid (PGError: ERROR: value "9874654132356" is out of range for type integer
+LINE 1: ...M "expenses" WHERE ("expenses"."expense_number" = E'98746541...
+ ^
+: SELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9874654132356') LIMIT 1):
+ app/models/expense.rb:25:in `search_by_expense_number'
+ app/controllers/expenses_controller.rb:54:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (43.0ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:49:15) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"98746541"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"98746541"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"98746541", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"98746541", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'98746541') LIMIT 1[0m
+nil
+
+NoMethodError (You have a nil object when you didn't expect it!
+The error occurred while evaluating nil.authorised_for):
+ app/models/expense.rb:27:in `search_by_expense_number'
+ app/controllers/expenses_controller.rb:54:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (34.4ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:49:58) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"98746541"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"98746541"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"98746541", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"98746541", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'98746541') LIMIT 1[0m
+nil
+nil
+
+NoMethodError (undefined method `search_url' for #<ExpensesController:0xb65e2ed0>):
+ app/controllers/expenses_controller.rb:59:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (32.7ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:50:29) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"98746541"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"98746541"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"98746541", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"98746541", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'98746541') LIMIT 1[0m
+nil
+nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 17ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=98746541&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:50:29) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.7ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 93ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:50:34) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+ [4;36;1mUser Load (0.2ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+Redirected to http://localhost:3000/expenses/5
+Completed in 22ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:50:34) [GET]
+ Parameters: {"action"=>"show", "id"=>"5", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mUser Load (0.3ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/5]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:50:36) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:50:39) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"1111", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"1111", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'1111') LIMIT 1[0m
+#<Expense id: 6, user_id: 2, expense_number: 1111, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:41", updated_at: "2010-07-15 01:31:41">
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+#<Expense id: 6, user_id: 2, expense_number: 1111, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:41", updated_at: "2010-07-15 01:31:41">
+Redirected to http://localhost:3000/expenses/6
+Completed in 20ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 09:50:39) [GET]
+ Parameters: {"action"=>"show", "id"=>"6", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 6) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/6]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:50:42) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 8, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:50:47) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"8974651"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"8974651"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"8974651", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"8974651", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'8974651') LIMIT 1[0m
+nil
+nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 79ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=8974651&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:50:47) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 28ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:52:21) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+starting search_results
+{"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (1.2ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+ [4;36;1mUser Load (0.2ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+#<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+
+ActionController::RoutingError (expense_url failed to generate from {:controller=>"expenses", :action=>"show", :id=>"#<Expense id: 5, user_id: 1, expense_number: 9999, filename: \"Notes.txt\", content_type: \"text/plain\", file_data: \"Rails\\n-----\\n- Active Record = ORM layer:\\nrequire 'a...\", created_at: \"2010-07-15 01:31:08\", updated_at: \"2010-07-15 01:31:08\">\n"}, expected: {:controller=>"expenses", :action=>"show"}, diff: {:id=>"#<Expense id: 5, user_id: 1, expense_number: 9999, filename: \"Notes.txt\", content_type: \"text/plain\", file_data: \"Rails\\n-----\\n- Active Record = ORM layer:\\nrequire 'a...\", created_at: \"2010-07-15 01:31:08\", updated_at: \"2010-07-15 01:31:08\">\n"}):
+ (eval):16:in `expense_path'
+ app/controllers/expenses_controller.rb:56:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (not_found)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:58:49) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.4ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:58:52) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+expense #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+authorised_for test?
+
+NameError (undefined local variable or method `params' for #<Expense:0xb6608dd8>):
+ app/models/expense.rb:10:in `authorised_for?'
+ app/models/expense.rb:30:in `search_by_expense_number'
+ app/controllers/expenses_controller.rb:52:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (31.8ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 09:59:58) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+expense #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+authorised_for test?
+ [4;35;1mUser Load (0.2ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+expense after found: nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 21ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 09:59:58) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.7ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 97ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:00:00) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 27ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:00:01) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+expense #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+authorised_for test?
+ [4;36;1mUser Load (0.2ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+expense after found: nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 19ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:00:01) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:00:06) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+expense #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+authorised_for test?
+ [4;35;1mUser Load (0.2ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+expense after found: nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 20ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:00:06) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mUser Load (0.4ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:02:03) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+expense #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+ [4;36;1mUser Load (0.2ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+authorised_for admin?
+
+expense after found: nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 19ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:03) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (2.7ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 90ms (View: 11, DB: 4) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:02:10) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"1111", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"1111", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'1111') LIMIT 1[0m
+expense #<Expense id: 6, user_id: 2, expense_number: 1111, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:41", updated_at: "2010-07-15 01:31:41">
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+authorised_for test?
+true
+expense after found: #<Expense id: 6, user_id: 2, expense_number: 1111, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:41", updated_at: "2010-07-15 01:31:41">
+Redirected to http://localhost:3000/expenses/6
+Completed in 20ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=1111&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 10:02:10) [GET]
+ Parameters: {"action"=>"show", "id"=>"6", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.3ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 6) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 23ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/6]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:12) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:02:16) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"674611"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"674611", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"674611", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'674611') LIMIT 1[0m
+expense nil
+expense after found: nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 18ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=674611&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:16) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 27ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:02:18) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+expense #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+ [4;35;1mUser Load (0.2ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+authorised_for admin?
+
+expense after found: nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 19ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:18) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (1.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 84ms (View: 69, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:02:22) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+{"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+starting search_by_expense_number
+params {"expense_number"=>"9999", "user"=>#<User id: 2, username: "test", password: "test", is_admin: false, created_at: "2010-07-15 00:31:23", updated_at: "2010-07-15 00:31:23">}
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+expense #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+ [4;36;1mUser Load (0.2ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+authorised_for admin?
+
+expense after found: nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 20ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:22) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 28ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#logout (for 127.0.0.1 at 2010-07-20 10:02:24) [GET]
+ Parameters: {"action"=>"logout", "controller"=>"users"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Redirected to http://localhost:3000/login
+Completed in 11ms (DB: 1) | 302 Found [http://localhost/user/logout]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-20 10:02:24) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (1.0ms)
+Completed in 8ms (View: 5, DB: 0) | 200 OK [http://localhost/login]
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-20 10:02:28) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"tK3JJUQBWE1MNCVc1buv3IouCezzJU26izgTRqpLYfU=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;36;1mUser Load (1.1ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 14ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 10:02:28) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (279.8ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 593ms (View: 16, DB: 280) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:31) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:02:33) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+{"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+starting search_by_expense_number
+params {"expense_number"=>"9999", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+expense #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+authorised_for admin?
+true
+expense after found: #<Expense id: 5, user_id: 1, expense_number: 9999, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:08", updated_at: "2010-07-15 01:31:08">
+Redirected to http://localhost:3000/expenses/5
+Completed in 19ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.0ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 10:02:33) [GET]
+ Parameters: {"action"=>"show", "id"=>"5", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/5]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:34) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:02:37) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+{"expense_number"=>"1111", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+starting search_by_expense_number
+params {"expense_number"=>"1111", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'1111') LIMIT 1[0m
+expense #<Expense id: 6, user_id: 2, expense_number: 1111, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:41", updated_at: "2010-07-15 01:31:41">
+ [4;36;1mUser Load (0.2ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+authorised_for test?
+true
+expense after found: #<Expense id: 6, user_id: 2, expense_number: 1111, filename: "Notes.txt", content_type: "text/plain", file_data: "Rails\n-----\n- Active Record = ORM layer:\nrequire 'a...", created_at: "2010-07-15 01:31:41", updated_at: "2010-07-15 01:31:41">
+Redirected to http://localhost:3000/expenses/6
+Completed in 22ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.0ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 10:02:37) [GET]
+ Parameters: {"action"=>"show", "id"=>"6", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 6) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mUser Load (0.3ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/6]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:39) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 27ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:02:44) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"468975"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+{"expense_number"=>"468975", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+starting search_by_expense_number
+params {"expense_number"=>"468975", "user"=>#<User id: 1, username: "admin", password: "admin", is_admin: true, created_at: "2010-07-15 00:30:50", updated_at: "2010-07-15 00:30:50">}
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'468975') LIMIT 1[0m
+expense nil
+expense after found: nil
+Redirected to http://localhost:3000/expenses/search
+Completed in 18ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=468975&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:02:44) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 26ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:18:36) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 8, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:18:52) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 87ms (View: 72, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:18:54) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses/5
+Completed in 20ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 10:18:54) [GET]
+ Parameters: {"action"=>"show", "id"=>"5", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 5) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/5]
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:18:56) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 6, DB: 2) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:19:00) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.4ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'1111') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses/6
+Completed in 17ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 10:19:00) [GET]
+ Parameters: {"action"=>"show", "id"=>"6", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 6) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;35;1mUser Load (0.3ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/6]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:19:02) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 7, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:19:05) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1000"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'1000') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses/search
+Completed in 17ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=1000&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:19:05) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.7ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (12.9ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 81ms (View: 7, DB: 14) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#new (for 127.0.0.1 at 2010-07-20 10:19:10) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/new
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 30ms (View: 18, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#create (for 127.0.0.1 at 2010-07-20 10:19:20) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100720-2918-1g7swmv-0>, "user_id"=>"1", "expense_number"=>"84651"}, "action"=>"create", "authenticity_token"=>"tK3JJUQBWE1MNCVc1buv3IouCezzJU26izgTRqpLYfU=", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mBEGIN[0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (0.6ms)[0m [0;1mINSERT INTO "expenses" ("created_at", "content_type", "updated_at", "file_data", "user_id", "expense_number", "filename") VALUES('2010-07-20 00:19:20.527203', E'application/octet-stream', '2010-07-20 00:19:20.527203', E'select * from users\\001;\\012select * fom users;\\012select * from users;\\012select * from users;\\012insert into users (username, password, is_admin) values ("admin", "admin","t");\\012INSERT INTO users (username, password, is_admin) VALUES ("admin", "admin", "t");\\012select * from expenses\\001;\\012delete * from expenses\\001;\\012delete from expenses where number = nil;\\012delete from expenses where number = null;\\012select * from expenses;\\012delete from expenses where number != 123;\\012delete from expenses ;\\012insert into expenses (''number'', ''filename'', ''user_id'') values (123, ''blah.png'', 1);\\012insert into expenses (number, filename, user_id) values (123, ''blah.png'', 1);\\012select * from expenses;\\012select * from expenses\\001;\\012select * from expenses;\\012select * from expenses\\001;\\012select * from users\\001;\\012', 1, 84651, E'.psql_history') RETURNING "id"[0m
+ [4;35;1mSQL (12.4ms)[0m [0mCOMMIT[0m
+Redirected to http://localhost:3000/expenses
+Completed in 39ms (DB: 14) | 302 Found [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 10:19:20) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (276.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 564ms (View: 16, DB: 277) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:19:27) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 7, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 10:19:30) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (284.6ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.5ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 590ms (View: 16, DB: 285) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.3ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:19:32) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.7ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 7, DB: 2) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:19:34) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"84651"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'84651') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses/24
+Completed in 18ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=84651&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 10:19:34) [GET]
+ Parameters: {"action"=>"show", "id"=>"24", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.4ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 24) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/24]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:19:37) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 6, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.0ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#new (for 127.0.0.1 at 2010-07-20 10:19:42) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/new
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 75ms (View: 13, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#create (for 127.0.0.1 at 2010-07-20 10:19:50) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100720-2918-zrmfkf-0>, "user_id"=>"1", "expense_number"=>"fasd"}, "action"=>"create", "authenticity_token"=>"tK3JJUQBWE1MNCVc1buv3IouCezzJU26izgTRqpLYfU=", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mBEGIN[0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mROLLBACK[0m
+
+ActionView::MissingTemplate (Missing template expenses/create.erb in view path app/views):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#create (for 127.0.0.1 at 2010-07-20 10:20:23) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100720-2918-11ktcnt-0>, "user_id"=>"1", "expense_number"=>"465a"}, "action"=>"create", "authenticity_token"=>"tK3JJUQBWE1MNCVc1buv3IouCezzJU26izgTRqpLYfU=", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mBEGIN[0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mROLLBACK[0m
+
+ActionView::MissingTemplate (Missing template expenses/create.erb in view path app/views):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#create (for 127.0.0.1 at 2010-07-20 10:21:23) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100720-2918-10np0os-0>, "user_id"=>"1", "expense_number"=>"465a"}, "action"=>"create", "authenticity_token"=>"tK3JJUQBWE1MNCVc1buv3IouCezzJU26izgTRqpLYfU=", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+HERE!!!!!!
+ [4;35;1mSQL (0.1ms)[0m [0mBEGIN[0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mROLLBACK[0m
+
+ActionView::MissingTemplate (Missing template expenses/create.erb in view path app/views):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:21:45) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.7ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 26ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:23:02) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 8, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#new (for 127.0.0.1 at 2010-07-20 10:23:04) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/new
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 12, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#create (for 127.0.0.1 at 2010-07-20 10:23:11) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100720-2918-16rrw0j-0>, "user_id"=>"1", "expense_number"=>"dasfsdf"}, "action"=>"create", "authenticity_token"=>"tK3JJUQBWE1MNCVc1buv3IouCezzJU26izgTRqpLYfU=", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+HERE!!!!!!
+ [4;36;1mSQL (0.1ms)[0m [0;1mBEGIN[0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mROLLBACK[0m
+Redirected to http://localhost:3000/expenses/new
+Completed in 22ms (DB: 1) | 302 Found [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#new (for 127.0.0.1 at 2010-07-20 10:23:11) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/new
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 13, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#logout (for 127.0.0.1 at 2010-07-20 10:23:27) [GET]
+ Parameters: {"action"=>"logout", "controller"=>"users"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Redirected to http://localhost:3000/login
+Completed in 15ms (DB: 1) | 302 Found [http://localhost/user/logout]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-20 10:23:28) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 6ms (View: 4, DB: 0) | 200 OK [http://localhost/login]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-20 10:23:32) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"vZsdRX2qqajmDQhz7QYl1gMyzTFzzGLsbQQPTZDE4Zg=", "controller"=>"users", "user"=>{"username"=>"test", "password"=>"[FILTERED]"}}
+ [4;35;1mUser Load (1.0ms)[0m [0mSELECT * FROM "users" WHERE (username = E'test' and password = E'test') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 10:23:32) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (4.8ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 2) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 30ms (View: 7, DB: 5) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:23:35) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 6, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:23:37) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"9999"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'9999') LIMIT 1[0m
+ [4;36;1mUser Load (0.2ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Redirected to http://localhost:3000/expenses/search
+Completed in 20ms (DB: 2) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=9999&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:23:38) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 79ms (View: 7, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:23:42) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'1111') LIMIT 1[0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Redirected to http://localhost:3000/expenses/6
+Completed in 18ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=1111&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 10:23:42) [GET]
+ Parameters: {"action"=>"show", "id"=>"6", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (0.5ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 6) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/6]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-20 10:23:44) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (4.6ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 2) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 32ms (View: 8, DB: 5) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.3ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:23:45) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 6, DB: 2) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:23:47) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"4444"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (2.0ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'4444') LIMIT 1[0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Redirected to http://localhost:3000/expenses/11
+Completed in 20ms (DB: 3) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=4444&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#show (for 127.0.0.1 at 2010-07-20 10:23:47) [GET]
+ Parameters: {"action"=>"show", "id"=>"11", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;35;1mExpense Load (2.3ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 11) [0m
+Rendering template within layouts/application
+Rendering expenses/show
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 5, DB: 3) | 200 OK [http://localhost/expenses/11]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:23:51) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 77ms (View: 7, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search_results (for 127.0.0.1 at 2010-07-20 10:23:54) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"87946513"}, "action"=>"search_results", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."expense_number" = E'87946513') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses/search
+Completed in 18ms (DB: 1) | 302 Found [http://localhost/expenses/search_results?expense%5Bexpense_number%5D=87946513&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-20 10:23:55) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (0.5ms)[0m [0;1mSELECT * FROM "expenses" LIMIT 1[0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 7, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#logout (for 127.0.0.1 at 2010-07-20 10:23:57) [GET]
+ Parameters: {"action"=>"logout", "controller"=>"users"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Redirected to http://localhost:3000/login
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/logout]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-20 10:23:58) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 7ms (View: 4, DB: 0) | 200 OK [http://localhost/login]
|
myfwhite/expenses
|
e6f5eb1a6747567a7815b049fe5a23bba32c259a
|
renamed controllers and views to plural, to make routes work. continued on search
|
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6ab2e97..92bc27f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,27 +1,31 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
- # filter_parameter_logging :password
+ filter_parameter_logging :password
+
+ helper_method :logged_in?, :current_user
+
+ def current_user
+ @current_user ||= ((session[:user_id] && User.find(session[:user_id])) || 0)
+ end
- helper_method :logged_in?
-
def logged_in?
- session[:user]
+ current_user != 0
end
def check_authentication
unless logged_in?
flash[:notice] = "You need to login to do that"
- redirect_to :controller => 'user', :notice => "You need to log in to do that"
+ redirect_to :controller => 'users', :notice => "You need to log in to do that"
end
end
def index
- redirect_to :controller => 'user'
+ redirect_to :controller => 'users'
end
end
diff --git a/app/controllers/expense_controller.rb b/app/controllers/expense_controller.rb
deleted file mode 100644
index 7e6665c..0000000
--- a/app/controllers/expense_controller.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-class ExpenseController < ApplicationController
-
- before_filter :check_authentication
-
- def show
- @title = 'View Expense'
- @expense = Expense.find(params[:id])
- end
-
- def download
- @expense = Expense.find(params[:id])
- send_data(@expense.file_data,
- :filename => @expense.filename,
- :type => @expense.content_type,
- :disposition => @expense.display_type)
- end
-
- def new
- @title = 'Add expense'
- end
-
- def create
- @expense = Expense.new(params[:expense])
- #@expense.uploaded_file = params[:file]
- @expense.user = session[:user]
- @expense.expense_number = params[:expense_number]
-
- if @expense.save
- flash[:notice] = "Thank you for your submission"
- redirect_to :expenses
- else
- flash[:error] = "There was a problem with your submission"
- end
- end
-
- def index
- @title = 'Expenses'
- @expenses = Expense.find(:all, :conditions => ['user_id = ?', session[:user][:id]], :order => "created_at DESC")
- end
-
- def search
- @title = 'Search'
- end
-
- def search_results
- @expense = Expense.new(params[:expense])
- @title = 'Search results'
-
- if @expense.expense_number.to_i < 1
- flash[:notice] = "Expense number cannot be blank"
- redirect_to :search_expenses
- else
- if @expense = Expense.find(:first, :conditions => ["expense_number = ?", expense_number])
- if session[:user].is_admin? || session[:user] == @expense.user
- redirect_to expense_url(@expense)
- else
- flash[:error] = "No expense file found for #{expense_number}"
- redirect_to :search_expenses
- end
- else
- flash[:notice] = "No expense file found for #{expense_number}"
- redirect_to :search_expenses
- end
- end
- end
-
-end
diff --git a/app/controllers/expenses_controller.rb b/app/controllers/expenses_controller.rb
new file mode 100644
index 0000000..5f781f9
--- /dev/null
+++ b/app/controllers/expenses_controller.rb
@@ -0,0 +1,38 @@
+class ExpensesController < ApplicationController
+
+ before_filter :check_authentication
+
+ def show
+ @title = 'View Expense'
+ @expense = Expense.find(params[:id])
+ end
+
+ def download
+ @expense = Expense.find(params[:id])
+ send_data(@expense.file_data, @expense.send_data_details)
+ end
+
+ def new
+ @title = 'Add expense'
+ end
+
+ def create
+ @expense = Expense.new(params[:expense])
+ if @expense.save
+ flash[:notice] = "Thank you for your submission"
+ redirect_to :expenses
+ else
+ flash[:error] = "There was a problem with your submission"
+ end
+ end
+
+ def index
+ @title = 'Expenses'
+ Expense.search({:user => current_user})
+ end
+
+ def search
+ @title = 'Search expenses'
+ end
+
+end
diff --git a/app/controllers/user_controller.rb b/app/controllers/users_controller.rb
similarity index 80%
rename from app/controllers/user_controller.rb
rename to app/controllers/users_controller.rb
index 1491d49..0c44673 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,32 +1,32 @@
-class UserController < ApplicationController
+class UsersController < ApplicationController
def index
redirect_to :action => 'login'
end
def login
@title = "Login"
end
def authenticate
@user = User.new(params[:user])
# TODO: Sort out hashing of password
valid_user = User.find(:first, :conditions => ["username = ? and password = ?", @user.username, @user.password])
if valid_user
- session[:user] = valid_user
- redirect_to :controller => 'expense'
+ session[:user_id] = valid_user
+ redirect_to :controller => 'expenses'
else
flash[:notice] = "Invalid User/Password"
redirect_to :login
end
end
def logout
if logged_in?
reset_session
redirect_to :login
end
end
end
diff --git a/app/helpers/expense_helper.rb b/app/helpers/expense_helper.rb
deleted file mode 100644
index ed7d123..0000000
--- a/app/helpers/expense_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module ExpenseHelper
-end
diff --git a/app/helpers/expenses_helper.rb b/app/helpers/expenses_helper.rb
new file mode 100644
index 0000000..1d50062
--- /dev/null
+++ b/app/helpers/expenses_helper.rb
@@ -0,0 +1,2 @@
+module ExpensesHelper
+end
diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb
deleted file mode 100644
index 0147c3f..0000000
--- a/app/helpers/user_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module UserHelper
-end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
new file mode 100644
index 0000000..2310a24
--- /dev/null
+++ b/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
diff --git a/app/models/expense.rb b/app/models/expense.rb
index e752b62..b23b904 100644
--- a/app/models/expense.rb
+++ b/app/models/expense.rb
@@ -1,33 +1,43 @@
class Expense < ActiveRecord::Base
belongs_to :user
validates_presence_of :expense_number, :user, :filename
validates_associated :user
- validates_numericality_of :expense_number, '>' => 1
+ validates_numericality_of :expense_number
+
+ def self.search(search_params)
+ if search_params[:user]
+ find_all_by_user_id(search_params[:user].id, :order => "created_at DESC")
+ end
+ end
def display_type
@inline_types = ['application/pdf', 'text/plain', 'image/gif', 'image/jpeg', 'image/png']
@inline_types.each do |type|
return 'inline' if type == self.content_type
end
'downloaded'
end
+ def send_data_details
+ {:filename => this.filename, :type => this.content_type, :disposition => this.display_type}
+ end
+
def uploaded_file=(incoming_file)
self.filename = incoming_file.original_filename
self.content_type = incoming_file.content_type
self.file_data = incoming_file.read
end
def filename=(new_filename)
write_attribute("filename", sanitize_filename(new_filename))
end
private
def sanitize_filename(filename)
just_filename = File.basename(filename)
just_filename.gsub(/[^\w\.\-]/, '_')
end
end
diff --git a/app/views/expense/search.haml b/app/views/expense/search.haml
deleted file mode 100644
index 9124f40..0000000
--- a/app/views/expense/search.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-= render 'expense/options'
-- error_messages_for :expense
-- form_for 'search_results', @expense, :html => {:method => :get} do |f|
- .field
- = label(:expense_number, "Expense number")
- %br
- = f.text_field "expense_number"
- .actions
- = f.submit "Search"
\ No newline at end of file
diff --git a/app/views/expense/_options.haml b/app/views/expenses/_options.haml
similarity index 100%
rename from app/views/expense/_options.haml
rename to app/views/expenses/_options.haml
diff --git a/app/views/expense/index.haml b/app/views/expenses/index.haml
similarity index 68%
rename from app/views/expense/index.haml
rename to app/views/expenses/index.haml
index 8f33f2e..b52100c 100644
--- a/app/views/expense/index.haml
+++ b/app/views/expenses/index.haml
@@ -1,9 +1,10 @@
-= render 'expense/options'
%table
%tr
%th Expense number
- %th Filename
+ %th Employee
+ %th File
- @expenses.each do |expense|
%tr
%td= expense.expense_number
+ %td= expense.user.username
%td= link_to "#{expense.filename}", :action => 'download' , :id => expense
\ No newline at end of file
diff --git a/app/views/expense/new.haml b/app/views/expenses/new.haml
similarity index 62%
rename from app/views/expense/new.haml
rename to app/views/expenses/new.haml
index c04d877..417631b 100644
--- a/app/views/expense/new.haml
+++ b/app/views/expenses/new.haml
@@ -1,13 +1,13 @@
-= render 'expense/options'
- error_messages_for :expense
-- form_for :expense, @expense do |f|
+- form_for Expense.new, :html =>{ :multipart => true } do |f|
+ = f.hidden_field :user_id, :value => current_user.id
.field
= label(:expense_number, "Expense number")
%br
= f.text_field 'expense_number'
.field
= label(:uploaded_file, "File")
%br
= f.file_field 'uploaded_file'
.actions
= f.submit 'Upload'
\ No newline at end of file
diff --git a/app/views/expenses/search.haml b/app/views/expenses/search.haml
new file mode 100644
index 0000000..3dd278d
--- /dev/null
+++ b/app/views/expenses/search.haml
@@ -0,0 +1,12 @@
+- error_messages_for :expense
+- form_for :expenses, @expense do |f|
+ .field
+ = label(:expense_number, 'Expense number')
+ %br
+ = f.text_field 'expense_number'
+ - if current_user.is_admin?
+ = label(:username, 'Employee')
+ %br
+ = f.text_field 'username'
+ .actions
+ = f.submit 'Search'
\ No newline at end of file
diff --git a/app/views/expense/show.haml b/app/views/expenses/show.haml
similarity index 80%
rename from app/views/expense/show.haml
rename to app/views/expenses/show.haml
index aadf3af..687a5a2 100644
--- a/app/views/expense/show.haml
+++ b/app/views/expenses/show.haml
@@ -1,8 +1,7 @@
-= render 'expense/options'
%dl
%dt Expense number
%dd= @expense.id
%dt User
%dd= @expense.user.username
%dt Expense file
%dd= link_to "#{@expense.filename}", :action => 'download' , :id => @expense
\ No newline at end of file
diff --git a/app/views/layouts/_footer.haml b/app/views/layouts/_footer.haml
index 827f26d..079b14a 100644
--- a/app/views/layouts/_footer.haml
+++ b/app/views/layouts/_footer.haml
@@ -1,3 +1,3 @@
-.footer
+#footer
%ul.navigation.round
%li © 2010 C3 Business Solutions
diff --git a/app/views/layouts/_header.haml b/app/views/layouts/_header.haml
index ea76d64..8e02e25 100644
--- a/app/views/layouts/_header.haml
+++ b/app/views/layouts/_header.haml
@@ -1,8 +1,8 @@
.round#header
%ul.navigation.round
-if logged_in?
- %li= session[:user].username
+ %li= current_user.username
%li= link_to "logout", "/user/logout"
- else
%li= link_to "login", "/user/login"
diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml
index 477047e..253a9f3 100644
--- a/app/views/layouts/application.haml
+++ b/app/views/layouts/application.haml
@@ -1,15 +1,17 @@
!!! Strict
%html{:lang => "en", "xml:lang" => "en", :xmlns => "http://www.w3.org/1999/xhtml"}
%head
%title= title
= stylesheet_link_tag 'blueprint/screen', :media => 'screen'
= stylesheet_link_tag 'custom', :media => 'screen'
%body
.container
= render 'layouts/header'
#content.round
%h2= heading
- flash.each do |key, value|
%div{:class => "flash #{key}"}= value
+ -if logged_in?
+ = render 'expenses/options'
= yield
= render 'layouts/footer'
\ No newline at end of file
diff --git a/app/views/user/login.haml b/app/views/users/login.haml
similarity index 85%
rename from app/views/user/login.haml
rename to app/views/users/login.haml
index 02696f7..2fdb382 100644
--- a/app/views/user/login.haml
+++ b/app/views/users/login.haml
@@ -1,13 +1,11 @@
--if logged_in?
- = render 'expense/options'
- form_for :user, @user, :url => {:action => :authenticate} do |f|
.field
= label(:username, "Username")
%br
= f.text_field "username"
.field
= label(:password, "Password")
%br
= f.password_field "password"
.actions
= f.submit "Login"
diff --git a/config/routes.rb b/config/routes.rb
index 95b8074..6d896b6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,14 +1,13 @@
ActionController::Routing::Routes.draw do |map|
map.resources :expenses,
- :controller => :expense,
:collection => {:search => :get, :search_results => :get},
:member => {:download => :get}
- map.connect '/user/:action', :controller => :user
- map.root :controller => 'user', :action => 'login'
- map.login 'login', :controller => :user, :action => 'login'
+ map.connect '/user/:action', :controller => :users
+ map.root :controller => 'users', :action => 'login'
+ map.login 'login', :controller => :users, :action => 'login'
#map.connect ':controller/:action/:id'
#map.connect ':controller/:action/:id.:format'
end
diff --git a/log/development.log b/log/development.log
index 2b117b0..bb685f7 100644
--- a/log/development.log
+++ b/log/development.log
@@ -13152,512 +13152,2319 @@ Completed in 29ms (View: 20, DB: 0) | 200 OK [http://localhost/expenses/search]
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:28:00) [POST]
Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (30.0ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:29:12) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.4ms)
Rendered layouts/_header (5.6ms)
Rendered layouts/_footer (0.1ms)
Completed in 18ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:29:14) [POST]
Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (47.1ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:29:33) [POST]
Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (35.4ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:29:37) [POST]
Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (30.2ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:29:50) [POST]
Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (28.1ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:17) [GET]
Rendering template within layouts/application
Rendering expense/search
ERROR: compiling _run_haml_app47views47expense47search46haml RAISED compile error
/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected '{', expecting kEND
form_for :search_results, @expense {method => :get} do |f|;
^
/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end
Function body: def _run_haml_app47views47expense47search46haml(local_assigns)
old_output_buffer = output_buffer;;begin;extend Haml::Helpers;_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, {:attr_wrapper=>"'", :format=>:xhtml, :escape_html=>false, :autoclose=>["meta", "img", "link", "br", "hr", "input", "area", "param", "col", "base"], :preserve=>["textarea", "pre", "code"], :ugly=>false, :encoding=>nil});_erbout = _hamlout.buffer;__in_erb_template = true;;_hamlout.push_text("#{_hamlout.format_script_false_false_false_false_false_true_false(( render 'expense/options'
));}\n", 0, false); error_messages_for :expense;
form_for :search_results, @expense {method => :get} do |f|;
_hamlout.push_text("<div class='field'>\n #{
_hamlout.adjust_tabs(1); _hamlout.format_script_false_false_false_false_false_true_false(( label(:expense_number, "Expense number")
));}\n <br />\n #{
_hamlout.format_script_false_false_false_false_false_true_false(( f.text_field "expense_number"
));}\n</div>\n<div class='actions'>\n #{
_hamlout.format_script_false_false_false_false_false_true_false(( f.submit "Search"
));}\n</div>\n", -1, false);end;_erbout;ensure;@haml_buffer = @haml_buffer.upper;end;
ensure
self.output_buffer = old_output_buffer
end
Backtrace: /home/myfwhite/projects/expenses/app/views/expense/search.haml:11:in `compile!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:61:in `compile'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:28:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/template.rb:199:in `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:260:in `render_without_haml'
/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:343:in `_render_with_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:257:in `render_without_haml'
/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1250:in `render_for_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:945:in `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1326:in `default_render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1332:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:617:in `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:146:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:606:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:391:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:386:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:87:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:121:in `_call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:130
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:93:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:114:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reloader.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:108:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log_tailer.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:50:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:14:in `run'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:111
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
./script/server:3
ActionView::TemplateError (compile error
/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected '{', expecting kEND
form_for :search_results, @expense {method => :get} do |f|;
^
/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end) on line #3 of app/views/expense/search.haml:
1: = render 'expense/options'
2: - error_messages_for :expense
3: - form_for :search_results, @expense {method => :get} do |f|
4: .field
5: = label(:expense_number, "Expense number")
6: %br
app/views/expense/search.haml:11:in `compile!'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (56.2ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (internal_server_error)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:24) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.7ms)
ActionView::TemplateError (wrong number of arguments (0 for 1)) on line #3 of app/views/expense/search.haml:
1: = render 'expense/options'
2: - error_messages_for :expense
3: - form_for :search_results, @expense, {method => :get} do |f|
4: .field
5: = label(:expense_number, "Expense number")
6: %br
app/views/expense/search.haml:3:in `method'
app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (49.7ms)
Rendered rescues/_request_and_response (0.5ms)
Rendering rescues/layout (internal_server_error)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:38) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.4ms)
ActionView::TemplateError (undefined local variable or method `html' for #<ActionView::Base:0xb6569364>) on line #3 of app/views/expense/search.haml:
1: = render 'expense/options'
2: - error_messages_for :expense
3: - form_for :search_results, @expense, html => {method => :get} do |f|
4: .field
5: = label(:expense_number, "Expense number")
6: %br
app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (49.0ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (internal_server_error)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:46) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.4ms)
ActionView::TemplateError (wrong number of arguments (0 for 1)) on line #3 of app/views/expense/search.haml:
1: = render 'expense/options'
2: - error_messages_for :expense
3: - form_for :search_results, @expense, :html => {method => :get} do |f|
4: .field
5: = label(:expense_number, "Expense number")
6: %br
app/views/expense/search.haml:3:in `method'
app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (52.3ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:55) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.5ms)
Rendered layouts/_header (5.5ms)
Rendered layouts/_footer (0.1ms)
Completed in 21ms (View: 15, DB: 0) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:59) [GET]
Parameters: {"search_results"=>{"expense_number"=>"111"}, "commit"=>"Search"}
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.4ms)
Rendered layouts/_header (5.1ms)
Rendered layouts/_footer (0.1ms)
Completed in 16ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=111&commit=Search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:02) [GET]
Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.4ms)
Rendered layouts/_header (8.2ms)
Rendered layouts/_footer (0.2ms)
Completed in 21ms (View: 14, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:15) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.4ms)
Rendered layouts/_header (6.0ms)
Rendered layouts/_footer (0.1ms)
Completed in 27ms (View: 12, DB: 0) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (4.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:18) [GET]
Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.4ms)
Rendered layouts/_header (7.8ms)
Rendered layouts/_footer (0.2ms)
Completed in 19ms (View: 12, DB: 4) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
[4;36;1mSQL (0.9ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:35) [GET]
Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.4ms)
Rendered layouts/_header (6.8ms)
Rendered layouts/_footer (0.1ms)
Completed in 25ms (View: 20, DB: 1) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:38) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.5ms)
Rendered layouts/_header (8.1ms)
Rendered layouts/_footer (0.2ms)
Completed in 28ms (View: 18, DB: 0) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:41) [GET]
Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.5ms)
Rendered layouts/_header (5.6ms)
Rendered layouts/_footer (0.1ms)
Completed in 17ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:52) [GET]
Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search"}
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.6ms)
Rendered layouts/_header (7.1ms)
Rendered layouts/_footer (0.1ms)
Completed in 19ms (View: 13, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=11110&commit=Search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:33:12) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.5ms)
Rendered layouts/_header (5.6ms)
Rendered layouts/_footer (0.1ms)
Completed in 16ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 17:33:14) [GET]
Rendering template within layouts/application
Rendering expense/new
Rendered expense/_options (0.5ms)
Rendered layouts/_header (5.8ms)
Rendered layouts/_footer (0.1ms)
Completed in 21ms (View: 15, DB: 0) | 200 OK [http://localhost/expenses/new]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#index (for 127.0.0.1 at 2010-07-16 17:33:17) [GET]
[4;36;1mExpense Load (5.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expense/index
Rendered expense/_options (0.5ms)
Rendered layouts/_header (1.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 30ms (View: 8, DB: 6) | 200 OK [http://localhost/expenses]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:33:18) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.5ms)
Rendered layouts/_header (5.5ms)
Rendered layouts/_footer (0.1ms)
Completed in 20ms (View: 14, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.7ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#login (for 127.0.0.1 at 2010-07-19 09:35:39) [GET]
+Rendering template within layouts/application
+Rendering user/login
+Rendered layouts/_header (1.7ms)
+Rendered layouts/_footer (1.1ms)
+Completed in 83ms (View: 80, DB: 1) | 200 OK [http://localhost/]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#authenticate (for 127.0.0.1 at 2010-07-19 09:35:49) [POST]
+ Parameters: {"commit"=>"Login", "authenticity_token"=>"ccZIcsmGdo83IIjasmbi3m3VmcAqKP3CtHem+C5Y8To=", "user"=>{"username"=>"admin", "password"=>"admin"}}
+ [4;36;1mUser Load (12.1ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 286ms (DB: 12) | 302 Found [http://localhost/user/authenticate]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:35:50) [GET]
+
+RuntimeError (Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id):
+ app/controllers/expense_controller.rb:38:in `index'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (82.4ms)
+Rendered rescues/_request_and_response (1.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.0ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:37:22) [GET]
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (1.9ms)
+
+ActionView::TemplateError (You have a nil object when you didn't expect it!
+You might have expected an instance of Array.
+The error occurred while evaluating nil.each) on line #6 of app/views/expense/index.haml:
+3: %tr
+4: %th Expense number
+5: %th Filename
+6: - @expenses.each do |expense|
+7: %tr
+8: %td= expense.expense_number
+9: %td= link_to "#{expense.filename}", :action => 'download' , :id => expense
+
+ app/views/expense/index.haml:6:in `_run_haml_app47views47expense47index46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (38.6ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:41:28) [GET]
+ [4;35;1mUser Load (27.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (655.1ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 1030ms (View: 9, DB: 683) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-19 09:41:46) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-19 09:41:58) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"pgadmin.log", "expense_number"=>"234"}, "authenticity_token"=>"ccZIcsmGdo83IIjasmbi3m3VmcAqKP3CtHem+C5Y8To="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (23.5ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-19 09:43:38) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"pgadmin.log", "expense_number"=>"234"}, "authenticity_token"=>"ccZIcsmGdo83IIjasmbi3m3VmcAqKP3CtHem+C5Y8To="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (81.3ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-19 09:43:54) [GET]
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 29ms (View: 18, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#create (for 127.0.0.1 at 2010-07-19 09:44:00) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100719-2624-itterv-0>, "expense_number"=>"213"}, "authenticity_token"=>"ccZIcsmGdo83IIjasmbi3m3VmcAqKP3CtHem+C5Y8To="}
+ [4;35;1mUser Load (1.2ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (0.2ms)[0m [0;1mBEGIN[0m
+ [4;35;1mSQL (0.1ms)[0m [0mROLLBACK[0m
+
+ActionView::MissingTemplate (Missing template expense/create.erb in view path app/views):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#create (for 127.0.0.1 at 2010-07-19 09:46:55) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100719-2624-1gcbdrp-0>, "expense_number"=>"213"}, "authenticity_token"=>"ccZIcsmGdo83IIjasmbi3m3VmcAqKP3CtHem+C5Y8To="}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mBEGIN[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mROLLBACK[0m
+
+ActionView::MissingTemplate (Missing template expense/create.erb in view path app/views):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-19 09:47:54) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.6ms)
+
+ActionView::TemplateError (undefined local variable or method `value' for #<ActionView::Base:0xb65cb2bc>) on line #4 of app/views/expense/new.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for Expense.new, :html =>{ :multipart => true } do |f|
+4: = f.hidden_field :user_id, value => current_user.id
+5: .field
+6: = label(:expense_number, "Expense number")
+7: %br
+
+ app/views/expense/new.haml:4
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:225:in `call'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:225
+ haml (3.0.13) lib/haml/helpers.rb:588:in `call'
+ haml (3.0.13) lib/haml/helpers.rb:588:in `haml_bind_proc'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:231:in `form_for'
+ app/views/expense/new.haml:3:in `_run_haml_app47views47expense47new46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (105.0ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#login (for 127.0.0.1 at 2010-07-19 09:48:07) [GET]
+Rendering template within layouts/application
+Rendering user/login
+ [4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered expense/_options (0.7ms)
+
+ActionView::TemplateError (You have a nil object when you didn't expect it!
+The error occurred while evaluating nil.username) on line #4 of app/views/layouts/_header.haml:
+1: .round#header
+2: %ul.navigation.round
+3: -if logged_in?
+4: %li= @current_user.username
+5: %li= link_to "logout", "/user/logout"
+6: - else
+7: %li= link_to "login", "/user/login"
+
+ app/views/layouts/_header.haml:4:in `_run_haml_app47views47layouts47_header46haml_locals_header_object'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:11:in `render'
+ haml (3.0.13) lib/haml/helpers.rb:90:in `non_haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:11:in `render'
+ app/views/layouts/application.haml:9:in `_run_haml_app47views47layouts47application46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (49.2ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#login (for 127.0.0.1 at 2010-07-19 09:48:52) [GET]
+Rendering template within layouts/application
+Rendering user/login
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (1.8ms)
+Rendered layouts/_footer (1.1ms)
+Completed in 27ms (View: 24, DB: 1) | 200 OK [http://localhost/]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:48:53) [GET]
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (272.9ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 590ms (View: 8, DB: 274) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-19 09:48:56) [GET]
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.5ms)
+
+ActionView::TemplateError (undefined local variable or method `value' for #<ActionView::Base:0xb67754f0>) on line #4 of app/views/expense/new.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for Expense.new, :html =>{ :multipart => true } do |f|
+4: = f.hidden_field :user_id, value => current_user.id
+5: .field
+6: = label(:expense_number, "Expense number")
+7: %br
+
+ app/views/expense/new.haml:4
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:225:in `call'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:225
+ haml (3.0.13) lib/haml/helpers.rb:588:in `call'
+ haml (3.0.13) lib/haml/helpers.rb:588:in `haml_bind_proc'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:231:in `form_for'
+ app/views/expense/new.haml:3:in `_run_haml_app47views47expense47new46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (44.6ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-19 09:49:12) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 82ms (View: 20, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#create (for 127.0.0.1 at 2010-07-19 09:49:22) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100719-2624-kr7ufa-0>, "user_id"=>"1", "expense_number"=>"9999"}, "authenticity_token"=>"ccZIcsmGdo83IIjasmbi3m3VmcAqKP3CtHem+C5Y8To="}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mBEGIN[0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (53.4ms)[0m [0mINSERT INTO "expenses" ("created_at", "content_type", "updated_at", "file_data", "user_id", "expense_number", "filename") VALUES('2010-07-18 23:49:22.430183', E'text/x-log', '2010-07-18 23:49:22.430183', E'2010-07-13 11:57:09 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\0122010-07-13 11:57:12 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\012\\0122010-07-13 11:57:14 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\012\\0122010-07-14 11:54:06 ERROR : ERROR: column "admin" does not exist\\012LINE 1: ...into users (username, password, is_admin) values ("admin", "...\\012 ^\\012', 1, 9999, E'pgadmin.log') RETURNING "id"[0m
+ [4;36;1mSQL (19.0ms)[0m [0;1mCOMMIT[0m
+Redirected to http://localhost:3000/expenses
+Completed in 158ms (DB: 73) | 302 Found [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:49:22) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (271.2ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 538ms (View: 8, DB: 272) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:49:26) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+
+ActionView::TemplateError (undefined method `submit' for #<ActionView::Base:0xb67709c8>) on line #9 of app/views/expense/search.haml:
+6: %br
+7: = text_field_tag "expense_number"
+8: .actions
+9: = submit "Search"
+
+ app/views/expense/search.haml:9
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:199:in `call'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:199
+ haml (3.0.13) lib/haml/helpers.rb:588:in `call'
+ haml (3.0.13) lib/haml/helpers.rb:588
+ haml (3.0.13) lib/haml/helpers.rb:343:in `call'
+ haml (3.0.13) lib/haml/helpers.rb:343:in `capture_haml'
+ haml (3.0.13) lib/haml/helpers.rb:566:in `with_haml_buffer'
+ haml (3.0.13) lib/haml/helpers.rb:339:in `capture_haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:88:in `capture'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:205:in `form_tag'
+ app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (45.9ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:51:03) [GET]
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+
+ActionView::TemplateError (Illegal nesting: nesting within plain text is illegal.) on line #9 of app/views/expense/search.haml:
+6: %br
+7: = text_field_tag 'expense_number'
+8: if current_user.is_admin?
+9: = label(:username, 'Employee')
+10: %br
+11: = text_field_tag 'username'
+12: .actions
+
+ app/views/expense/search.haml:9
+ haml (3.0.13) lib/haml/precompiler.rb:355:in `push_plain'
+ haml (3.0.13) lib/haml/precompiler.rb:279:in `process_line'
+ haml (3.0.13) lib/haml/precompiler.rb:178:in `precompile'
+ haml (3.0.13) lib/haml/engine.rb:121:in `initialize'
+ haml (3.0.13) lib/haml/template/plugin.rb:29:in `new'
+ haml (3.0.13) lib/haml/template/plugin.rb:29:in `compile'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (43.2ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:51:18) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+
+ActionView::TemplateError (undefined method `submit' for #<ActionView::Base:0xb6628b88>) on line #13 of app/views/expense/search.haml:
+10: %br
+11: = text_field_tag 'username'
+12: .actions
+13: = submit "Search"
+
+ app/views/expense/search.haml:13
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:199:in `call'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:199
+ haml (3.0.13) lib/haml/helpers.rb:588:in `call'
+ haml (3.0.13) lib/haml/helpers.rb:588
+ haml (3.0.13) lib/haml/helpers.rb:343:in `call'
+ haml (3.0.13) lib/haml/helpers.rb:343:in `capture_haml'
+ haml (3.0.13) lib/haml/helpers.rb:566:in `with_haml_buffer'
+ haml (3.0.13) lib/haml/helpers.rb:339:in `capture_haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:88:in `capture'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:205:in `form_tag'
+ app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (46.8ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:51:55) [GET]
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:53:11) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:53:28) [GET]
+ [4;36;1mUser Load (0.7ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+
+ActionView::TemplateError (Inconsistent indentation: 1 space was used for indentation, but the rest of the document was indented using 2 spaces.) on line #9 of app/views/expense/search.haml:
+6: %br
+7: = text_field_tag 'expense_number'
+8: = if current_user.is_admin?
+9: / = label(:username, 'Employee')
+10: / %br
+11: = text_field_tag 'username'
+12: .actions
+
+ app/views/expense/search.haml:9
+ haml (3.0.13) lib/haml/precompiler.rb:152:in `tabs'
+ haml (3.0.13) lib/haml/precompiler.rb:134:in `instance_eval'
+ haml (3.0.13) lib/haml/precompiler.rb:134:in `tabs'
+ haml (3.0.13) lib/haml/precompiler.rb:1040:in `block_opened?'
+ haml (3.0.13) lib/haml/precompiler.rb:388:in `push_script'
+ haml (3.0.13) lib/haml/precompiler.rb:224:in `process_line'
+ haml (3.0.13) lib/haml/precompiler.rb:178:in `precompile'
+ haml (3.0.13) lib/haml/engine.rb:121:in `initialize'
+ haml (3.0.13) lib/haml/template/plugin.rb:29:in `new'
+ haml (3.0.13) lib/haml/template/plugin.rb:29:in `compile'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (45.0ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:53:43) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:53:51) [GET]
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:54:09) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 87ms (View: 76, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (2.4ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:54:15) [GET]
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+
+ActionView::TemplateError (Illegal nesting: nesting within a tag that already has content is illegal.) on line #13 of app/views/expense/search.haml:
+10: %br
+11: = text_field_tag 'username'
+12: /.actions
+13: /= submit_tag "Search", :name => nil
+
+ app/views/expense/search.haml:13
+ haml (3.0.13) lib/haml/precompiler.rb:847:in `render_comment'
+ haml (3.0.13) lib/haml/precompiler.rb:215:in `process_line'
+ haml (3.0.13) lib/haml/precompiler.rb:178:in `precompile'
+ haml (3.0.13) lib/haml/engine.rb:121:in `initialize'
+ haml (3.0.13) lib/haml/template/plugin.rb:29:in `new'
+ haml (3.0.13) lib/haml/template/plugin.rb:29:in `compile'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (43.2ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:54:26) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 22ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:54:45) [GET]
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.1ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 9, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#logout (for 127.0.0.1 at 2010-07-19 09:54:52) [GET]
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Redirected to http://localhost:3000/login
+Completed in 11ms (DB: 1) | 302 Found [http://localhost/user/logout]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#login (for 127.0.0.1 at 2010-07-19 09:54:52) [GET]
+Rendering template within layouts/application
+Rendering user/login
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 7ms (View: 4, DB: 0) | 200 OK [http://localhost/login]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#authenticate (for 127.0.0.1 at 2010-07-19 09:54:57) [POST]
+ Parameters: {"commit"=>"Login", "authenticity_token"=>"nZXI95eo8Hmxk9VCEkRrhxFibu1bxsprl8S6xRjjn00=", "user"=>{"username"=>"test", "password"=>"test"}}
+ [4;36;1mUser Load (0.9ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'test' and password = E'test') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 78ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:54:57) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+ [4;36;1mExpense Load (4.6ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 29ms (View: 7, DB: 5) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:55:00) [GET]
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 16ms (View: 4, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#logout (for 127.0.0.1 at 2010-07-19 09:55:47) [GET]
+ Parameters: {"action"=>"logout", "controller"=>"user"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 2) [0m
+Redirected to http://localhost:3000/login
+Completed in 11ms (DB: 1) | 302 Found [http://localhost/user/logout]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#login (for 127.0.0.1 at 2010-07-19 09:55:47) [GET]
+ Parameters: {"action"=>"login", "controller"=>"user"}
+Rendering template within layouts/application
+Rendering user/login
+Rendered layouts/_header (0.1ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 6ms (View: 4, DB: 0) | 200 OK [http://localhost/login]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#authenticate (for 127.0.0.1 at 2010-07-19 09:56:26) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"wEbLpNCsCcUbBfRZl9ccxfniEVVsEZq/dWE0xMc+TXI=", "controller"=>"user", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;35;1mUser Load (1.0ms)[0m [0mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:56:26) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expense"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (283.7ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 585ms (View: 8, DB: 284) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#logout (for 127.0.0.1 at 2010-07-19 09:56:43) [GET]
+ Parameters: {"action"=>"logout", "controller"=>"user"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Redirected to http://localhost:3000/login
+Completed in 12ms (DB: 1) | 302 Found [http://localhost/user/logout]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.0ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#login (for 127.0.0.1 at 2010-07-19 09:56:43) [GET]
+ Parameters: {"action"=>"login", "controller"=>"user"}
+Rendering template within layouts/application
+Rendering user/login
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 7ms (View: 5, DB: 0) | 200 OK [http://localhost/login]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#authenticate (for 127.0.0.1 at 2010-07-19 09:56:59) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"user", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;35;1mUser Load (1.0ms)[0m [0mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:56:59) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expense"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (283.9ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 587ms (View: 9, DB: 284) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-19 09:58:11) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expense"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 26ms (View: 13, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#create (for 127.0.0.1 at 2010-07-19 09:58:20) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100719-2624-17pa82j-0>, "user_id"=>"1", "expense_number"=>"1"}, "action"=>"create", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"expense"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mBEGIN[0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (0.5ms)[0m [0;1mINSERT INTO "expenses" ("created_at", "content_type", "updated_at", "file_data", "user_id", "expense_number", "filename") VALUES('2010-07-18 23:58:20.605227', E'text/x-log', '2010-07-18 23:58:20.605227', E'2010-07-13 11:57:09 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\0122010-07-13 11:57:12 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\012\\0122010-07-13 11:57:14 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\012\\0122010-07-14 11:54:06 ERROR : ERROR: column "admin" does not exist\\012LINE 1: ...into users (username, password, is_admin) values ("admin", "...\\012 ^\\012', 1, 1, E'pgadmin.log') RETURNING "id"[0m
+ [4;35;1mSQL (9.6ms)[0m [0mCOMMIT[0m
+Redirected to http://localhost:3000/expenses
+Completed in 35ms (DB: 11) | 302 Found [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:58:20) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expense"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (279.5ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 591ms (View: 10, DB: 280) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#create (for 127.0.0.1 at 2010-07-19 09:58:21) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100719-2624-1fnx8vs-0>, "user_id"=>"1", "expense_number"=>"1"}, "action"=>"create", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"expense"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mBEGIN[0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.6ms)[0m [0mINSERT INTO "expenses" ("created_at", "content_type", "updated_at", "file_data", "user_id", "expense_number", "filename") VALUES('2010-07-18 23:58:21.278980', E'text/x-log', '2010-07-18 23:58:21.278980', E'2010-07-13 11:57:09 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\0122010-07-13 11:57:12 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\012\\0122010-07-13 11:57:14 ERROR : FATAL: terminating connection due to administrator command\\012server closed the connection unexpectedly\\012\\011This probably means the server terminated abnormally\\012\\011before or while processing the request.\\012\\0122010-07-14 11:54:06 ERROR : ERROR: column "admin" does not exist\\012LINE 1: ...into users (username, password, is_admin) values ("admin", "...\\012 ^\\012', 1, 1, E'pgadmin.log') RETURNING "id"[0m
+ [4;36;1mSQL (25.0ms)[0m [0;1mCOMMIT[0m
+Redirected to http://localhost:3000/expenses
+Completed in 51ms (DB: 26) | 302 Found [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:58:21) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expense"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (272.1ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 571ms (View: 9, DB: 273) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-19 09:58:23) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expense"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 12, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#create (for 127.0.0.1 at 2010-07-19 09:58:30) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100719-2624-atq3br-0>, "user_id"=>"1", "expense_number"=>"asdf"}, "action"=>"create", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"expense"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mBEGIN[0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mSQL (0.1ms)[0m [0mROLLBACK[0m
+
+ActionView::MissingTemplate (Missing template expense/create.erb in view path app/views):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-19 09:59:20) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expense"}
+ [4;36;1mUser Load (0.7ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 28ms (View: 13, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-19 09:59:26) [GET]
+ Parameters: {"action"=>"index", "username"=>"", "expense_number"=>"1111", "controller"=>"expense"}
+ [4;35;1mUser Load (0.4ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (269.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 570ms (View: 8, DB: 270) | 200 OK [http://localhost/expenses?expense_number=1111&username=]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#login (for 127.0.0.1 at 2010-07-19 15:50:53) [GET]
+ Parameters: {"action"=>"login", "controller"=>"user"}
+
+NameError (uninitialized constant UserController):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (27.4ms)
+Rendered rescues/_request_and_response (1.2ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.0ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-19 15:51:33) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+ActionView::TemplateError (Missing template expense/_options.erb in view path app/views) on line #2 of app/views/users/login.haml:
+1: -if logged_in?
+2: = render 'expense/options'
+3: - form_for :user, @user, :url => {:action => :authenticate} do |f|
+4: .field
+5: = label(:username, "Username")
+
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:11:in `render'
+ haml (3.0.13) lib/haml/helpers.rb:90:in `non_haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:11:in `render'
+ app/views/users/login.haml:2:in `_run_haml_app47views47users47login46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (51.4ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-19 15:52:01) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered expenses/_options (1.9ms)
+Rendered layouts/_header (1.7ms)
+Rendered layouts/_footer (1.0ms)
+Completed in 39ms (View: 36, DB: 1) | 200 OK [http://localhost/]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 15:52:11) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;36;1mUser Load (1.0ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-19 15:52:11) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expense"}
+
+NameError (uninitialized constant ExpenseController):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (94.8ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-19 15:53:41) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expense"}
+
+NameError (uninitialized constant ExpenseController):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (28.9ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 15:54:05) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;35;1mUser Load (1.0ms)[0m [0mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-19 15:54:05) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expense"}
+
+NameError (uninitialized constant ExpenseController):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (27.7ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-19 15:54:29) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expense"}
+
+NameError (uninitialized constant ExpenseController):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (25.5ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 15:54:40) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;36;1mUser Load (1.1ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+
+ActionController::RoutingError (No route matches {:controller=>"expenses", :action=>"index"}):
+ app/controllers/users_controller.rb:18:in `authenticate'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (not_found)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-19 15:57:53) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered expenses/_options (2.0ms)
+Rendered layouts/_header (1.7ms)
+Rendered layouts/_footer (1.1ms)
+Completed in 67ms (View: 64, DB: 1) | 200 OK [http://localhost/]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 15:57:58) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;35;1mUser Load (1.0ms)[0m [0mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+
+ActionController::RoutingError (No route matches {:controller=>"expenses", :action=>"index"}):
+ app/controllers/users_controller.rb:18:in `authenticate'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (not_found)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.3ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 15:58:17) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;36;1mUser Load (0.9ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 15:58:17) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/index
+Rendered expenses/_options (0.6ms)
+
+ActionView::TemplateError (You have a nil object when you didn't expect it!
+You might have expected an instance of Array.
+The error occurred while evaluating nil.each) on line #6 of app/views/expenses/index.haml:
+3: %tr
+4: %th Expense number
+5: %th Filename
+6: - @expenses.each do |expense|
+7: %tr
+8: %td= expense.expense_number
+9: %td= link_to "#{expense.filename}", :action => 'download' , :id => expense
+
+ app/views/expenses/index.haml:6:in `_run_haml_app47views47expenses47index46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (43.7ms)
+Rendered rescues/_request_and_response (1.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 15:59:00) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;36;1mUser Load (1.0ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 15:59:00) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+SyntaxError (/home/myfwhite/projects/expenses/app/models/expense.rb:43: syntax error, unexpected $end, expecting kEND):
+ app/controllers/expenses_controller.rb:38:in `index'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (96.7ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 15:59:25) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;36;1mUser Load (1.1ms)[0m [0;1mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 13ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 15:59:25) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (281.0ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 592ms (View: 9, DB: 282) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#authenticate (for 127.0.0.1 at 2010-07-19 16:00:34) [POST]
+ Parameters: {"commit"=>"Login", "action"=>"authenticate", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"users", "user"=>{"username"=>"admin", "password"=>"[FILTERED]"}}
+ [4;35;1mUser Load (1.1ms)[0m [0mSELECT * FROM "users" WHERE (username = E'admin' and password = E'admin') LIMIT 1[0m
+Redirected to http://localhost:3000/expenses
+Completed in 15ms (DB: 1) | 302 Found [http://localhost/user/authenticate]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:00:34) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (288.2ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+Rendered expenses/_options (0.5ms)
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 605ms (View: 21, DB: 289) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:00:50) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (295.3ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+Rendered expenses/_options (0.4ms)
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 606ms (View: 19, DB: 296) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#new (for 127.0.0.1 at 2010-07-19 16:00:53) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/new
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 31ms (View: 18, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#create (for 127.0.0.1 at 2010-07-19 16:01:02) [POST]
+ Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>#<File:/tmp/RackMultipart20100719-29010-pkkisd-0>, "user_id"=>"1", "expense_number"=>"5464"}, "action"=>"create", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mBEGIN[0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mSQL (19.0ms)[0m [0;1mINSERT INTO "expenses" ("created_at", "content_type", "updated_at", "file_data", "user_id", "expense_number", "filename") VALUES('2010-07-19 06:01:02.316365', E'application/octet-stream', '2010-07-19 06:01:02.316365', E'# This viminfo file was generated by Vim 7.2.\\012# You may edit it if you are careful!\\012\\012# Value of ''encoding'' when this file was written\\012*encoding=utf-8\\012\\012\\012# hlsearch on (H) or off (h):\\012~h\\012# Last Search Pattern:\\012~Msle0~/\\\\<created\\\\>\\012\\012# Last Substitute String:\\012$\\012\\012# Command Line History (newest to oldest):\\012:wq\\012:q\\012:w\\012:e new.txt\\012:q!\\012:e ../layouts/application.html.erb\\012:e user_helper.rb\\012:b1\\012:e ../models/user.rb\\012:b3\\012:ls\\012:b2\\012:e goodbye.html.erb\\012:e hello.html.erb\\012:e ../views/say/goodbye.html.erb\\012:e ~/.vimrc\\012:e application_controller.rb\\012:e ../../controllers/say_controller.rb\\012:pwd\\012:e $VIMRUNTIME\\012:e $VIMRC\\012:e app/controllers/say_controller.rb\\012:bn\\012:e $GVIMRC\\012:e /home/myfwhite/.vim/gvimrc\\012:e /home/myfwhite/.vim/vimrc\\012:$VIMRC\\012:cd $HOME\\012:$HOME\\012:qall\\012::q\\012:e ~/Downloads/tutelogin/app/views/user/login.html.erb\\012\\012# Search String History (newest to oldest):\\012? \\\\<created\\\\>\\012?/flash\\012?/swap\\012?/swqp\\012?/host\\012?/cd \\012?/cucumber\\012?/--ver\\012?/pag\\012\\012# Expression History (newest to oldest):\\012\\012# Input Line History (newest to oldest):\\012\\012# Input Line History (newest to oldest):\\012\\012# Registers:\\012"0\\011LINE\\0110\\012\\011 ~ ~ ~\\012"1\\011LINE\\0110\\012\\011#\\012"2\\011LINE\\0110\\012\\011host all all 10.0.0.0 255.255.255.0 md5\\012"3\\011LINE\\0110\\012\\011# from https://help.ubuntu.com/community/PostgreSQL so that system and postgres users are separate\\012"4\\011LINE\\0110\\012\\011host all all ::1/128 md5\\012"5\\011LINE\\0110\\012\\011# IPv6 local connections:\\012"6\\011LINE\\0110\\012\\011host all all 127.0.0.1/32 md5\\012"7\\011LINE\\0110\\012\\011# IPv4 local connections:\\012"8\\011LINE\\0110\\012\\011local all all ident\\012"9\\011LINE\\0110\\012\\011# "local" is for Unix domain socket connections only\\012""-\\011CHAR\\0110\\012\\011#\\012\\012# File marks:\\012''0 3 45 ~/projects/c3freezer/db/migrate/20100719023923_add_username_uniqueness_index.rb\\012''1 80 0 /etc/postgresql/8.4/main/pg_hba.conf\\012''2 77 0 /etc/postgresql/8.4/main/pg_hba.conf\\012''3 83 0 /etc/postgresql/8.4/main/pg_hba.conf\\012''4 82 0 /etc/postgresql/8.4/main/pg_hba.conf\\012''5 84 46 /etc/postgresql/8.4/main/pg_hba.conf\\012''6 84 58 /etc/postgresql/8.4/main/pg_hba.conf\\012''7 22 23 ~/projects/c3freezer/config/environment.rb\\012''8 1 0 ~/projects/c3freezer/.gitignore\\012''9 3 0 ~/projects/c3freezer/.gitignore\\012\\012# Jumplist (newest first):\\012-'' 3 45 ~/projects/c3freezer/db/migrate/20100719023923_add_username_uniqueness_index.rb\\012-'' 1 0 ~/projects/c3freezer/db/migrate/20100719023923_add_username_uniqueness_index.rb\\012-'' 80 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 1 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 77 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 83 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 82 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 3 0 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 84 46 /etc/postgresql/8.4/main/pg_hba.conf\\012-'' 22 23 ~/projects/c3freezer/config/environment.rb\\012-'' 1 0 ~/projects/c3freezer/config/environment.rb\\012-'' 1 0 ~/projects/c3freezer/.gitignore\\012-'' 3 0 ~/projects/c3freezer/.gitignore\\012-'' 4 0 ~/projects/c3freezer/.gitignore\\012-'' 1 44 ~/projects/expenses/.git/COMMIT_EDITMSG\\012-'' 86 0 ~/Documents/new.txt\\012-'' 10 48 ~/Documents/routes.txt\\012-'' 4 0 ~/Documents/routes.txt\\012-'' 17 0 ~/Documents/routes.txt\\012-'' 6 1 ~/Documents/routes.txt\\012-'' 14 0 ~/Documents/routes.txt\\012-'' 15 0 ~/Documents/routes.txt\\012-'' 1 0 ~/Documents/routes.txt\\012-'' 3 2 ~/rails_tests/music_store/config/routes.rb\\012-'' 4 2 ~/rails_tests/music_store/config/routes.rb\\012-'' 1 0 ~/rails_tests/music_store/config/routes.rb\\012-'' 2 0 ~/rails_tests/music_store/config/routes.rb\\012-'' 1 0 ~/projects/expenses/README\\012-'' 4 0 ~/projects.old/expenses/config/routes.rb\\012-'' 1 0 ~/projects.old/expenses/config/routes.rb\\012-'' 9 5 ~/expensefiles/db/migrate/20100714232518_create_expense_files.rb\\012-'' 1 0 ~/expensefiles/db/migrate/20100714232518_create_expense_files.rb\\012-'' 4 15 ~/projects/expenses/db/migrate/20100714232518_create_expense_files.rb\\012-'' 1 0 ~/projects/expenses/db/migrate/20100714232518_create_expense_files.rb\\012-'' 1 6 ~/projects/upload_test/app/views/upload/uploadfile.haml\\012-'' 1 4 ~/projects/expenses/app/views/expenses/edit.haml\\012-'' 1 6 ~/projects/expenses/app/views/expenses/show.haml\\012-'' 1 4 ~/projects/expenses/app/views/expenses/new.haml\\012-'' 1 5 ~/projects/expenses/app/views/expenses/index.haml\\012-'' 4 0 ~/Downloads/tutelogin/app/views/layouts/_stylesheets.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/_stylesheets.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/public/stylesheets/custom.css\\012-'' 1 0 ~/Downloads/tutelogin/public/stylesheets/blueprint/screen.css\\012-'' 9 11 ~/Downloads/tutelogin/app/views/layouts/application.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/application.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/_footer.html.erb\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/_f\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts/_header.html.erb\\012-'' 1 6 ~/projects/expenses/app/views/layouts/_header.haml\\012-'' 1 0 ~/Downloads/tutelogin/app/views/user/login.html.erb\\012-'' 9 0 ~/Downloads/tutelogin/app/views/user\\012-'' 1 0 ~/Downloads/tutelogin/app/views/user\\012-'' 8 0 ~/Downloads/tutelogin/app/views/user\\012-'' 12 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 8 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 1 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 1 0 ~/Downloads/tutelogin/app/models/user.rb\\012-'' 1 0 ~/Downloads/tutelogin/app/helpers/user_helper.rb\\012-'' 1 0 ~/Downloads/tutelogin/app/helpers/application_helper.rb\\012-'' 9 0 ~/Downloads/tutelogin/app/controllers/user_controller.rb\\012-'' 1 0 ~/Downloads/tutelogin/app/controllers/user_controller.rb\\012-'' 1 0 ~/Downloads/tutelogin/app/controllers/application_controller.rb\\012-'' 1 0 ~/projects/expenses/config/environment.rb\\012-'' 1 0 ~/projects/expenses/public/stylesheets/scaffold.css\\012-'' 1 0 ~/Downloads/tutelogin/app/views/user/private.html.erb\\012-'' 18 0 ~/Downloads/tutelogin/app/views/user\\012-'' 11 0 ~/Downloads/tutelogin/app/views\\012-'' 1 0 ~/Downloads/tutelogin/app/views\\012-'' 19 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 44 0 ~/Downloads/tutelogin/config/routes.rb\\012-'' 1 0 ~/Downloads/tutelogin/config/routes.rb\\012-'' 11 37 ~/Downloads/tutelogin/app/views/layouts/application.html.erb\\012-'' 34 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 30 0 ~/Downloads/tutelogin/app/views/layouts\\012-'' 1 0 ~/projects/expenses/app/helpers/users_helper.rb\\012-'' 14 6 ~/projects/expenses/app/helpers/application_helper.rb\\012-'' 15 0 ~/projects/expenses/app/helpers/application_helper.rb\\012-'' 1 0 ~/projects/expenses/app/helpers/application_helper.rb\\012-'' 26 6 ~/projects/expenses/app/controllers/users_controller.rb\\012-'' 1 0 ~/projects/expenses/app/models/user.rb\\012-'' 28 3 ~/projects/expenses/app/controllers/users_controller.rb\\012-'' 1 0 ~/projects/expenses/app/controllers/users_controller.rb\\012-'' 5 12 ~/projects/expenses/db/migrate/20100713065213_create_users.rb\\012-'' 1 0 ~/projects/expenses/db/migrate/20100713065213_create_users.rb\\012-'' 1 0 ~/rails_tests/expenses/app/models/user.rb\\012-'' 17 16 ~/projects/expenses/config/database.yml\\012-'' 1 0 ~/projects/expenses/config/database.yml\\012-'' 4 15 ~/rails_tests/expenses/config/database.yml\\012-'' 1 0 ~/rails_tests/expenses/config/database.yml\\012-'' 1 0 ~/rails_tests/expenses/config/d\\012-'' 17 16 ~/rails_tests/expenses/config/database.yml\\012-'' 109 8 ~/.bashrc\\012-'' 1 0 ~/.bashrc\\012-'' 106 2 ~/.bashrc\\012-'' 105 1 ~/.bashrc\\012-'' 11 4 ~/rails_tests/e/app/views/say/hello.html.erb\\012-'' 1 0 ~/rails_tests/e/app/views/say/hello.html.erb\\012-'' 49 23 ~/Documents/Notes.txt\\012-'' 1 0 ~/Documents/Notes.txt\\012-'' 5 23 ~/rails_tests/e/app/controllers/say_controller.rb\\012\\012# History of marks within files (newest to oldest):\\012\\012> ~/projects/c3freezer/db/migrate/20100719023923_add_username_uniqueness_index.rb\\012\\011"\\0113\\01145\\012\\011^\\0113\\01146\\012\\011.\\0113\\01145\\012\\011+\\0113\\01145\\012\\012> /etc/postgresql/8.4/main/pg_hba.conf\\012\\011"\\01180\\0110\\012\\011^\\01183\\0111\\012\\011.\\01182\\0110\\012\\011+\\01184\\01197\\012\\011+\\01184\\0110\\012\\011+\\01184\\01151\\012\\011+\\01184\\01156\\012\\011+\\01184\\0110\\012\\011+\\01183\\0110\\012\\011+\\01176\\0110\\012\\011+\\01178\\0110\\012\\011+\\01180\\0110\\012\\011+\\01182\\0110\\012\\012> ~/projects/c3freezer/config/environment.rb\\012\\011"\\01122\\01123\\012\\011^\\01122\\01124\\012\\011.\\01122\\01123\\012\\011+\\01122\\01123\\012\\012> ~/projects/c3freezer/.gitignore\\012\\011"\\0111\\0110\\012\\011^\\0113\\01111\\012\\011.\\0113\\01110\\012\\011+\\0111\\0119\\012\\011+\\0112\\0114\\012\\011+\\0111\\0114\\012\\011+\\0114\\0110\\012\\011+\\0113\\01110\\012\\012> ~/projects/expenses/.git/COMMIT_EDITMSG\\012\\011"\\0111\\01144\\012\\011^\\0111\\01145\\012\\011.\\0111\\01144\\012\\011+\\0111\\01144\\012\\012> ~/Documents/routes.txt\\012\\011"\\01110\\01148\\012\\011^\\0118\\01149\\012\\011.\\01110\\0110\\012\\011+\\0111\\01138\\012\\011+\\0117\\01138\\012\\011+\\0119\\01138\\012\\011+\\01111\\01138\\012\\011+\\01113\\01138\\012\\011+\\01113\\01138\\012\\011+\\01114\\01138\\012\\011+\\01115\\01138\\012\\011+\\0111\\01121\\012\\011+\\0113\\0110\\012\\011+\\0112\\01142\\012\\011+\\0114\\01143\\012\\011+\\0116\\01138\\012\\011+\\0117\\01138\\012\\011+\\0119\\01138\\012\\011+\\01111\\01138\\012\\011+\\01113\\01138\\012\\011+\\01114\\01138\\012\\011+\\01115\\01146\\012\\011+\\01114\\01145\\012\\011+\\01113\\01143\\012\\011+\\01111\\01143\\012\\011+\\0119\\01142\\012\\011+\\0117\\01145\\012\\011+\\0116\\01144\\012\\011+\\0116\\01174\\012\\011+\\0113\\01132\\012\\011+\\0114\\01169\\012\\011+\\0117\\01173\\012\\011+\\0116\\01156\\012\\011+\\0117\\01166\\012\\011+\\01113\\01157\\012\\011+\\01115\\01157\\012\\011+\\01114\\01157\\012\\011+\\01111\\01170\\012\\011+\\0119\\01169\\012\\011+\\0116\\01166\\012\\011+\\0118\\0110\\012\\011+\\01110\\0110\\012\\011+\\01112\\0110\\012\\011+\\0114\\01171\\012\\011+\\01117\\0110\\012\\011+\\0115\\0110\\012\\011+\\01116\\0110\\012\\011+\\0118\\01148\\012\\011+\\01110\\0110\\012\\011+\\01112\\0110\\012\\011+\\01110\\0110\\012\\012> ~/Documents/new.txt\\012\\011"\\01186\\0110\\012\\011.\\0111\\0110\\012\\011+\\0111\\0110\\012\\012> ~/rails_tests/music_store/config/routes.rb\\012\\011"\\0113\\0112\\012\\011.\\0113\\0110\\012\\011+\\0114\\0110\\012\\011+\\0113\\0110\\012\\012> ~/projects/expenses/README\\012\\011"\\0111\\0110\\012\\011^\\0111\\01121\\012\\011.\\0111\\01120\\012\\011+\\0111\\01121\\012\\011+\\0111\\01120\\012\\012> ~/projects.old/expenses/config/routes.rb\\012\\011"\\0114\\0110\\012\\012> ~/Documents/Notes.txt\\012\\011"\\01149\\0114\\012\\011^\\01149\\01124\\012\\011.\\01149\\01123\\012\\011+\\0116\\0112\\012\\011+\\01111\\01117\\012\\011+\\0119\\01110\\012\\011+\\01111\\01118\\012\\011+\\01112\\01129\\012\\011+\\01150\\0110\\012\\011+\\01119\\0115\\012\\011+\\01119\\01128\\012\\011+\\01121\\01131\\012\\011+\\01122\\01110\\012\\011+\\01122\\0112\\012\\011+\\01121\\0110\\012\\011+\\01119\\0110\\012\\011+\\01122\\0110\\012\\011+\\01120\\0110\\012\\011+\\01122\\01122\\012\\011+\\01119\\01184\\012\\011+\\01123\\01117\\012\\011+\\01121\\01112\\012\\011+\\01122\\01122\\012\\011+\\01123\\01117\\012\\011+\\01122\\01110\\012\\011+\\01124\\01115\\012\\011+\\01125\\0111\\012\\011+\\01124\\01115\\012\\011+\\01125\\01117\\012\\011+\\01140\\0110\\012\\011+\\01150\\01113\\012\\011+\\01150\\01144\\012\\011+\\01150\\01110\\012\\011+\\01119\\01145\\012\\011+\\01119\\0110\\012\\011+\\01119\\0117\\012\\011+\\01119\\0110\\012\\011+\\01119\\0110\\012\\011+\\01119\\01148\\012\\011+\\01150\\0110\\012\\011+\\01150\\0110\\012\\011+\\01119\\0110\\012\\011+\\01119\\0116\\012\\011+\\01150\\0110\\012\\011+\\01150\\0117\\012\\011+\\01150\\0117\\012\\011+\\01128\\0119\\012\\011+\\01129\\0117\\012\\011+\\01130\\0118\\012\\011+\\01127\\01122\\012\\011+\\01131\\01129\\012\\011+\\01140\\01113\\012\\011+\\01119\\0110\\012\\011+\\01117\\0111\\012\\011+\\01119\\0110\\012\\011+\\01118\\011107\\012\\011+\\01122\\0110\\012\\011+\\01139\\0110\\012\\011+\\01150\\0110\\012\\011+\\01133\\0110\\012\\011+\\01132\\0110\\012\\011+\\01150\\0110\\012\\011+\\01149\\01123\\012\\012> ~/projects/expenses/config/database.yml\\012\\011"\\01117\\01116\\012\\011^\\01117\\01117\\012\\011.\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\012> ~/expensefiles/db/migrate/20100714232518_create_expense_files.rb\\012\\011"\\0119\\0115\\012\\011^\\0118\\01134\\012\\011.\\0119\\0110\\012\\011+\\0114\\01132\\012\\011+\\0115\\0110\\012\\011+\\0119\\0117\\012\\011+\\0114\\0110\\012\\011+\\0119\\0115\\012\\011+\\0115\\01129\\012\\011+\\0119\\0110\\012\\011+\\0116\\01132\\012\\011+\\0117\\01127\\012\\011+\\0118\\01133\\012\\011+\\0119\\0110\\012\\012> ~/projects/expenses/db/migrate/20100714232518_create_expense_files.rb\\012\\011"\\0114\\01115\\012\\011^\\0114\\01116\\012\\011.\\0114\\01115\\012\\011+\\0114\\01115\\012\\012> ~/projects/upload_test/app/views/upload/uploadfile.haml\\012\\011"\\0111\\0116\\012\\011^\\0111\\0117\\012\\011.\\0111\\0116\\012\\011+\\0111\\0116\\012\\012> ~/projects/expenses/app/views/expenses/edit.haml\\012\\011"\\0111\\0114\\012\\011^\\0111\\0115\\012\\011.\\0111\\0114\\012\\011+\\0111\\0114\\012\\012> ~/projects/expenses/app/views/expenses/show.haml\\012\\011"\\0111\\0116\\012\\011^\\0111\\0117\\012\\011.\\0111\\0116\\012\\011+\\0111\\0116\\012\\012> ~/projects/expenses/app/views/expenses/new.haml\\012\\011"\\0111\\0114\\012\\011^\\0111\\0115\\012\\011.\\0111\\0114\\012\\011+\\0111\\0114\\012\\012> ~/projects/expenses/app/views/expenses/index.haml\\012\\011"\\0111\\0115\\012\\011^\\0111\\0116\\012\\011.\\0111\\0115\\012\\011+\\0111\\0115\\012\\012> ~/Downloads/tutelogin/app/views/layouts/_stylesheets.html.erb\\012\\011"\\0114\\0110\\012\\012> ~/Downloads/tutelogin/public/stylesheets/custom.css\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/public/stylesheets/blueprint/screen.css\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/views/layouts/application.html.erb\\012\\011"\\0119\\01111\\012\\011^\\0111\\0111\\012\\012> ~/Downloads/tutelogin/app/views/layouts/_footer.html.erb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/views/layouts/_footer.haml\\012\\011"\\0111\\0118\\012\\011^\\0111\\0119\\012\\011.\\0111\\0118\\012\\011+\\0111\\0118\\012\\012> ~/Downloads/tutelogin/app/views/layouts/_f\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/views/layouts/_stylesheets.haml\\012\\011"\\0111\\0115\\012\\011^\\0111\\0116\\012\\011.\\0111\\0115\\012\\011+\\0111\\0115\\012\\012> ~/Downloads/tutelogin/app/views/layouts/_header.html.erb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/views/layouts/_header.haml\\012\\011"\\0111\\0116\\012\\011^\\0111\\0117\\012\\011.\\0111\\0116\\012\\011+\\0111\\0116\\012\\012> ~/Downloads/tutelogin/app/views/user/login.html.erb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/models/user.rb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/helpers/application_helper.rb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/helpers/user_helper.rb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/controllers/user_controller.rb\\012\\011"\\0119\\0110\\012\\012> ~/Downloads/tutelogin/app/controllers/application_controller.rb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/config/environment.rb\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/config/environment.rb\\012\\011"\\0114\\01125\\012\\011^\\0114\\0111\\012\\011.\\0114\\01125\\012\\011+\\0114\\01125\\012\\012> ~/projects/expenses/public/stylesheets/scaffold.css\\012\\011"\\0111\\0110\\012\\012> ~/Downloads/tutelogin/app/views/user/private.html.erb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/views/users/private.haml\\012\\011"\\0113\\01134\\012\\011^\\0113\\01168\\012\\011.\\0113\\01168\\012\\011+\\0111\\01152\\012\\011+\\0113\\01168\\012\\012> ~/projects/expenses/app/views/users/login.haml\\012\\011"\\01112\\0110\\012\\011^\\01110\\01110\\012\\011.\\01112\\0110\\012\\011+\\0112\\0118\\012\\011+\\0113\\0115\\012\\011+\\0113\\0110\\012\\011+\\0117\\0110\\012\\011+\\0113\\01142\\012\\011+\\0114\\0116\\012\\011+\\0117\\0110\\012\\011+\\0119\\0110\\012\\011+\\0116\\0117\\012\\011+\\01110\\0110\\012\\011+\\0118\\0116\\012\\011+\\01110\\01110\\012\\011+\\01112\\0110\\012\\012> ~/projects/expenses/app/views/layouts/application.haml\\012\\011"\\01115\\0114\\012\\011^\\01115\\0115\\012\\011.\\01115\\0114\\012\\011+\\0114\\0113\\012\\011+\\0115\\0115\\012\\011+\\01116\\0110\\012\\011+\\0114\\01113\\012\\011+\\0115\\0110\\012\\011+\\0117\\01129\\012\\011+\\0112\\01162\\012\\011+\\0117\\01134\\012\\011+\\0118\\0118\\012\\011+\\0116\\0110\\012\\011+\\0117\\0110\\012\\011+\\0118\\01140\\012\\011+\\0119\\01120\\012\\011+\\01111\\01140\\012\\011+\\01113\\01113\\012\\011+\\01113\\0110\\012\\011+\\01116\\0110\\012\\011+\\01113\\01115\\012\\011+\\01116\\0110\\012\\011+\\01113\\0110\\012\\011+\\01114\\0110\\012\\011+\\01115\\0110\\012\\011+\\01116\\0110\\012\\011+\\01115\\01133\\012\\011+\\0114\\0112\\012\\011+\\01115\\0114\\012\\012> ~/projects/expenses/config/routes.rb\\012\\011"\\0113\\0112\\012\\011.\\0113\\0110\\012\\011+\\01145\\0110\\012\\011+\\0113\\0110\\012\\011+\\0113\\0110\\012\\012> ~/Downloads/tutelogin/config/routes.rb\\012\\011"\\01144\\0110\\012\\012> ~/projects/expenses/app/views/layouts/application.html.erb\\012\\011"\\0111\\0111\\012\\011^\\0111\\0112\\012\\011.\\0111\\0111\\012\\011+\\0111\\0111\\012\\012> ~/projects/expenses/app/views/layouts/users.html.erb\\012\\011"\\01116\\0110\\012\\012> ~/projects/expenses/app/helpers/users_helper.rb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/app/helpers/application_helper.rb\\012\\011"\\01114\\0116\\012\\011^\\01114\\0117\\012\\011.\\01114\\0110\\012\\011+\\01115\\01114\\012\\011+\\0115\\0118\\012\\011+\\01115\\0110\\012\\011+\\0119\\01142\\012\\011+\\01115\\0110\\012\\011+\\0119\\01174\\012\\011+\\01110\\0110\\012\\011+\\01114\\0110\\012\\012> ~/projects/expenses/app/controllers/users_controller.rb\\012\\011"\\01126\\0116\\012\\011^\\01126\\0117\\012\\011.\\01126\\0110\\012\\011+\\01128\\0110\\012\\011+\\01128\\0114\\012\\011+\\01128\\0110\\012\\011+\\01111\\011118\\012\\011+\\01110\\01143\\012\\011+\\01128\\0110\\012\\011+\\01127\\0110\\012\\011+\\01113\\01120\\012\\011+\\01117\\01143\\012\\011+\\01114\\01142\\012\\011+\\01117\\01140\\012\\011+\\01119\\0110\\012\\011+\\01124\\01141\\012\\011+\\01126\\0110\\012\\012> ~/projects/expenses/app/models/user.rb\\012\\011"\\0111\\0110\\012\\012> ~/projects/expenses/db/migrate/20100713065213_create_users.rb\\012\\011"\\0115\\01112\\012\\012> ~/rails_tests/expenses/app/models/user.rb\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/expenses/config/database.yml\\012\\011"\\0114\\01115\\012\\011^\\01117\\01117\\012\\011.\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\012> ~/rails_tests/expenses/config/d\\012\\011"\\0111\\0110\\012\\012> ~/.bashrc\\012\\011"\\011109\\0118\\012\\011^\\011109\\01129\\012\\011.\\011109\\01129\\012\\011+\\011113\\0110\\012\\011+\\011102\\01156\\012\\011+\\011103\\01110\\012\\011+\\011102\\01129\\012\\011+\\011100\\0110\\012\\011+\\011101\\0110\\012\\011+\\011102\\01129\\012\\011+\\011109\\0119\\012\\011+\\011111\\01126\\012\\011+\\011102\\01135\\012\\011+\\011109\\0119\\012\\011+\\011107\\0110\\012\\011+\\011109\\01129\\012\\011i\\011102\\01138\\012\\012> ~/rails_tests/e/app/views/say/hello.html.erb\\012\\011"\\01111\\0114\\012\\011.\\01111\\0110\\012\\011+\\0111\\01126\\012\\011+\\0111\\0112\\012\\011+\\0111\\0116\\012\\011+\\0111\\0117\\012\\011+\\01112\\0117\\012\\011+\\0111\\0110\\012\\011+\\0117\\01118\\012\\011+\\0112\\0110\\012\\011+\\01112\\0110\\012\\011+\\0113\\0110\\012\\011+\\0116\\0110\\012\\011+\\01111\\0110\\012\\011+\\0117\\01127\\012\\011+\\01111\\0110\\012\\011+\\0118\\01123\\012\\011+\\0119\\0110\\012\\011+\\01111\\01136\\012\\011+\\01111\\01114\\012\\011+\\01111\\01111\\012\\011+\\01111\\0119\\012\\011+\\01111\\01139\\012\\011+\\01111\\0110\\012\\012> ~/rails_tests/e/app/controllers/say_controller.rb\\012\\011"\\0115\\01123\\012\\011^\\0114\\01130\\012\\011.\\0114\\01129\\012\\011+\\0116\\0112\\012\\011+\\0113\\0110\\012\\011+\\0112\\0110\\012\\011+\\01111\\0110\\012\\011+\\0115\\01123\\012\\011+\\01110\\0110\\012\\011+\\0118\\01114\\012\\011+\\0119\\0110\\012\\011+\\0117\\0110\\012\\011+\\0114\\01129\\012\\012> ~/rails_tests/e/app/views/say/goodbye.html.erb\\012\\011"\\0119\\01128\\012\\011^\\0119\\01129\\012\\011.\\01110\\0110\\012\\011+\\01112\\0117\\012\\011+\\0118\\0110\\012\\011+\\0117\\01134\\012\\011+\\0118\\01141\\012\\011+\\0118\\01114\\012\\011+\\0119\\01151\\012\\011+\\01110\\0110\\012\\012> ~/rails_tests/e/app/controllers/application_controller.rb\\012\\011"\\0111\\0110\\012\\012> ~/.vimrc\\012\\011"\\01163\\01114\\012\\012> ~/rails_tests/e/$VIMRC\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/e/config/database.yml\\012\\011"\\01117\\01116\\012\\011^\\01117\\01117\\012\\011.\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\012> ~/rails_tests/d/app/controllers/say_controller.rb\\012\\011"\\0111\\0110\\012\\011^\\0113\\0114\\012\\011.\\0113\\0114\\012\\011+\\0114\\0110\\012\\011+\\0112\\0113\\012\\011+\\0113\\0114\\012\\012> ~/rails_tests/d/config/routes.rb\\012\\011"\\01142\\0110\\012\\012> ~/$VIMRC\\012\\011"\\0111\\0110\\012\\011.\\0111\\0110\\012\\011+\\0111\\0110\\012\\012> ~/.vim/vimrc\\012\\011"\\0111\\0110\\012\\012> ~/.vim/gvimrc\\012\\011"\\0111\\0110\\012\\012> ~/$GVIMRC\\012\\011"\\0111\\0110\\012\\011.\\0111\\0110\\012\\011+\\0111\\0110\\012\\012> ~/rails_tests/d/app/views/say/hello.html.erb\\012\\011"\\0119\\0110\\012\\011^\\0119\\0110\\012\\011.\\0118\\0117\\012\\011+\\0111\\0116\\012\\011+\\0118\\0117\\012\\012> ~/rails_tests/d/config/database.yml\\012\\011"\\01117\\0110\\012\\011^\\01117\\01117\\012\\011.\\01117\\01116\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\012> /etc/postgresql/8.1/main/pg_hba.conf\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/b/config/database.yml\\012\\011"\\01113\\01115\\012\\011^\\01113\\01116\\012\\011.\\01113\\01115\\012\\011+\\01116\\01116\\012\\011+\\01117\\01116\\012\\011+\\01113\\01115\\012\\012> ~/Documents/peepcode-009-rails-i-4-mov/code/dotfiles/ptree.pl\\012\\011"\\0111\\0110\\012\\012> ~/Documents/peepcode-009-rails-i-4-mov/code/dotfiles/aliases.bash.sh\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/m/config/routes.rb\\012\\011"\\01143\\0110\\012\\012> ~/rails_tests/m/app/controllers/application_controller.rb\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/m/config/environments/development.rb\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/m/app/controllers/say_controller.rb\\012\\011"\\0113\\0112\\012\\011^\\0113\\0113\\012\\011.\\0113\\0112\\012\\011+\\0113\\0112\\012\\012> ~/pgadmin.log\\012\\011"\\0115\\0110\\012\\012> ~/rails_tests/test/config/database.yml\\012\\011"\\0114\\01111\\012\\012> ~/rails_tests/test/config/environment.rb\\012\\011"\\01141\\0110\\012\\012> ~/rails_tests/test/app/controllers/say_controller.rb\\012\\011"\\0113\\0112\\012\\011^\\0113\\0113\\012\\011.\\0113\\0112\\012\\011+\\0113\\0112\\012\\012> ~/rails_tests/work/config/database.yml\\012\\011"\\01110\\0110\\012\\011^\\0119\\01121\\012\\011.\\01110\\0110\\012\\011+\\0114\\01120\\012\\011+\\0115\\01116\\012\\011+\\0117\\01127\\012\\011+\\01110\\0110\\012\\011+\\01110\\0111\\012\\011+\\0119\\01120\\012\\011+\\01110\\0110\\012\\012> ~/rails_tests/work/app/views/say/hello.html.erb\\012\\011"\\0119\\0110\\012\\011^\\0119\\0110\\012\\011.\\0118\\0117\\012\\011+\\0118\\0117\\012\\012> ~/rails_tests/work/app/controllers/say_controller.rb\\012\\011"\\0114\\0112\\012\\011^\\0114\\0113\\012\\011.\\0114\\0112\\012\\011+\\0115\\0110\\012\\011+\\0114\\0112\\012\\012> ~/rails_tests/demo/app/controllers/say_controller.rb\\012\\011"\\0111\\0110\\012\\011^\\0113\\0117\\012\\011.\\0113\\0116\\012\\011+\\0113\\0116\\012\\012> ~/rails_tests/demo/app/views/say/hello.html.erb\\012\\011"\\0111\\0110\\012\\011^\\0118\\0117\\012\\011.\\0118\\0116\\012\\011+\\0118\\0116\\012\\012> ~/rails_tests/demo/config/routes.rb\\012\\011"\\01143\\0110\\012\\012> ~/rails_tests/abc/config/environment.rb\\012\\011"\\0114\\0110\\012\\011^\\0114\\0111\\012\\011.\\0114\\0110\\012\\011+\\0114\\0110\\012\\012> ~/.gemrc\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/demo/config/environment.rb\\012\\011"\\0114\\0110\\012\\011^\\0114\\0111\\012\\011.\\0114\\0110\\012\\011+\\0114\\0110\\012\\012> ~/rails_tests/demo/config/environments/development.rb\\012\\011"\\0111\\0110\\012\\012> ~/rails_tests/demo/config/boot.rb\\012\\011"\\01185\\0110\\012\\012> ~/.bash_history\\012\\011"\\011108\\0110\\012\\012> ~/rails_tests/demo/config/environment\\012\\011"\\0111\\0110\\012\\012> /etc/X11/xorg.conf\\012\\011"\\0115\\01118\\012\\011^\\0115\\01119\\012\\011.\\0115\\01118\\012\\011+\\0115\\01118\\012\\012> ~/Downloads/rubygems-1.3.7/README\\012\\011"\\01119\\0110\\012', 1, 5464, E'.viminfo') RETURNING "id"[0m
+ [4;35;1mSQL (16.8ms)[0m [0mCOMMIT[0m
+Redirected to http://localhost:3000/expenses
+Completed in 63ms (DB: 37) | 302 Found [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:01:02) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (282.9ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+Rendered expenses/_options (0.4ms)
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 611ms (View: 17, DB: 284) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:01:06) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_header (0.1ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 10, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:05:55) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered expenses/_options (0.4ms)
+
+ActionView::TemplateError (undefined method `submit_tag' for #<ActionView::Helpers::FormBuilder:0xb66c7918>) on line #13 of app/views/expenses/search.haml:
+10: %br
+11: = f.text_field 'username'
+12: .actions
+13: = f.submit_tag "Search", :name => nil
+
+ app/views/expenses/search.haml:13
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:225:in `call'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:225
+ haml (3.0.13) lib/haml/helpers.rb:588:in `call'
+ haml (3.0.13) lib/haml/helpers.rb:588:in `haml_bind_proc'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:231:in `form_for'
+ app/views/expenses/search.haml:3:in `_run_haml_app47views47expenses47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (108.6ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:06:03) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:08:30) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 12, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-19 16:08:34) [POST]
+ Parameters: {"commit"=>"Search", "authenticity_token"=>"qUPKeKkHYE5JTICIJoe5WpgsKlntSASOIPUT4fH+zMo=", "expenses"=>{"username"=>"", "expense_number"=>"1111"}}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (22.5ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:49:45) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 17ms (View: 5, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-19 16:49:51) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered expenses/_options (0.5ms)
+Rendered layouts/_header (0.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 16ms (View: 14, DB: 1) | 200 OK [http://localhost/]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-19 16:51:23) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered expenses/_options (0.5ms)
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 22, DB: 1) | 200 OK [http://localhost/]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UsersController#login (for 127.0.0.1 at 2010-07-19 16:51:34) [GET]
+ Parameters: {"action"=>"login", "controller"=>"users"}
+Rendering template within layouts/application
+Rendering users/login
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (6.9ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 86ms (View: 22, DB: 1) | 200 OK [http://localhost/]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:52:24) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+
+SyntaxError (/home/myfwhite/projects/expenses/app/models/expense.rb:15: syntax error, unexpected kEND
+/home/myfwhite/projects/expenses/app/models/expense.rb:81: syntax error, unexpected $end, expecting kEND):
+ app/controllers/expenses_controller.rb:31:in `index'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (36.5ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#new (for 127.0.0.1 at 2010-07-19 16:52:33) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.4ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/new
+
+ActionView::TemplateError (/home/myfwhite/projects/expenses/app/models/expense.rb:15: syntax error, unexpected kEND
+/home/myfwhite/projects/expenses/app/models/expense.rb:81: syntax error, unexpected $end, expecting kEND) on line #2 of app/views/expenses/new.haml:
+1: - error_messages_for :expense
+2: - form_for Expense.new, :html =>{ :multipart => true } do |f|
+3: = f.hidden_field :user_id, :value => current_user.id
+4: .field
+5: = label(:expense_number, "Expense number")
+
+ app/views/expenses/new.haml:2:in `_run_haml_app47views47expenses47new46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (48.1ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#new (for 127.0.0.1 at 2010-07-19 16:52:59) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/new
+Rendered layouts/_header (71.4ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 97ms (View: 85, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#new (for 127.0.0.1 at 2010-07-19 16:53:00) [GET]
+ Parameters: {"action"=>"new", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/new
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.4ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 13, DB: 1) | 200 OK [http://localhost/expenses/new]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#search (for 127.0.0.1 at 2010-07-19 16:53:01) [GET]
+ Parameters: {"action"=>"search", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.5ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/search
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 23ms (View: 11, DB: 1) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:53:03) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.5ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendering template within layouts/application
+Rendering expenses/index
+
+ActionView::TemplateError (You have a nil object when you didn't expect it!
+You might have expected an instance of Array.
+The error occurred while evaluating nil.each) on line #6 of app/views/expenses/index.haml:
+3: %th Expense number
+4: %th Employee
+5: %th File
+6: - @expenses.each do |expense|
+7: %tr
+8: %td= expense.expense_number
+9: %td= expense.user.username
+
+ app/views/expenses/index.haml:6:in `_run_haml_app47views47expenses47index46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (39.9ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 16:53:11) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mExpense Load (284.7ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;36;1mCACHE (0.0ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mCACHE (0.0ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+Rendered layouts/_header (0.2ms)
+Rendered expenses/_options (0.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 630ms (View: 18, DB: 286) | 200 OK [http://localhost/expenses]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpensesController#index (for 127.0.0.1 at 2010-07-19 17:01:04) [GET]
+ Parameters: {"action"=>"index", "controller"=>"expenses"}
+ [4;36;1mUser Load (0.6ms)[0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
+ [4;35;1mExpense Load (284.7ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."user_id" = 1) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expenses/index
+
+ActionView::TemplateError (You have a nil object when you didn't expect it!
+You might have expected an instance of Array.
+The error occurred while evaluating nil.each) on line #6 of app/views/expenses/index.haml:
+3: %th Expense number
+4: %th Employee
+5: %th File
+6: - @expenses.each do |expense|
+7: %tr
+8: %td= expense.expense_number
+9: %td= expense.user.username
+
+ app/views/expenses/index.haml:6:in `_run_haml_app47views47expenses47index46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (40.6ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
|
myfwhite/expenses
|
df9ba5c3a7e8c659dfae189c91755da5d23ed192
|
Attempting to get search form to work
|
diff --git a/app/controllers/expense_controller.rb b/app/controllers/expense_controller.rb
index d28c852..7e6665c 100644
--- a/app/controllers/expense_controller.rb
+++ b/app/controllers/expense_controller.rb
@@ -1,67 +1,67 @@
class ExpenseController < ApplicationController
before_filter :check_authentication
def show
@title = 'View Expense'
@expense = Expense.find(params[:id])
end
def download
@expense = Expense.find(params[:id])
send_data(@expense.file_data,
:filename => @expense.filename,
:type => @expense.content_type,
:disposition => @expense.display_type)
end
def new
@title = 'Add expense'
end
def create
@expense = Expense.new(params[:expense])
#@expense.uploaded_file = params[:file]
@expense.user = session[:user]
@expense.expense_number = params[:expense_number]
if @expense.save
flash[:notice] = "Thank you for your submission"
redirect_to :expenses
else
flash[:error] = "There was a problem with your submission"
end
end
def index
@title = 'Expenses'
@expenses = Expense.find(:all, :conditions => ['user_id = ?', session[:user][:id]], :order => "created_at DESC")
end
def search
@title = 'Search'
end
def search_results
- expense_number = params[:search][:expense_number].to_i
+ @expense = Expense.new(params[:expense])
@title = 'Search results'
- if expense_number < 1
+ if @expense.expense_number.to_i < 1
flash[:notice] = "Expense number cannot be blank"
redirect_to :search_expenses
else
if @expense = Expense.find(:first, :conditions => ["expense_number = ?", expense_number])
if session[:user].is_admin? || session[:user] == @expense.user
redirect_to expense_url(@expense)
else
flash[:error] = "No expense file found for #{expense_number}"
redirect_to :search_expenses
end
else
flash[:notice] = "No expense file found for #{expense_number}"
redirect_to :search_expenses
end
end
end
end
diff --git a/app/views/expense/search.haml b/app/views/expense/search.haml
index fa406f1..9124f40 100644
--- a/app/views/expense/search.haml
+++ b/app/views/expense/search.haml
@@ -1,9 +1,9 @@
= render 'expense/options'
- error_messages_for :expense
-- form_for :expense, @expense, :url => 'search_results' do |f|
+- form_for 'search_results', @expense, :html => {:method => :get} do |f|
.field
= label(:expense_number, "Expense number")
%br
= f.text_field "expense_number"
.actions
= f.submit "Search"
\ No newline at end of file
diff --git a/log/development.log b/log/development.log
index c81ccda..2b117b0 100644
--- a/log/development.log
+++ b/log/development.log
@@ -11574,512 +11574,2090 @@ The error occurred while evaluating nil.stringify_keys) on line #3 of app/views/
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (54.8ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (internal_server_error)
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 16:38:00) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.5ms)
Rendered layouts/_header (5.7ms)
Rendered layouts/_footer (0.1ms)
Completed in 17ms (View: 11, DB: 0) | 200 OK [http://localhost/expenses/search]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing UserController#logout (for 127.0.0.1 at 2010-07-16 16:38:02) [GET]
Redirected to http://localhost:3000/login
Completed in 6ms (DB: 0) | 302 Found [http://localhost/user/logout]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing UserController#login (for 127.0.0.1 at 2010-07-16 16:38:02) [GET]
Rendering template within layouts/application
Rendering user/login
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 8ms (View: 6, DB: 0) | 200 OK [http://localhost/login]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing UserController#login (for 127.0.0.1 at 2010-07-16 16:38:04) [GET]
Rendering template within layouts/application
Rendering user/login
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 7ms (View: 5, DB: 0) | 200 OK [http://localhost/user/login]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing UserController#authenticate (for 127.0.0.1 at 2010-07-16 16:38:08) [POST]
Parameters: {"commit"=>"Login", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0=", "user"=>{"username"=>"test", "password"=>"test"}}
[4;35;1mUser Load (3.3ms)[0m [0mSELECT * FROM "users" WHERE (username = E'test' and password = E'test') LIMIT 1[0m
Redirected to http://localhost:3000/expenses
Completed in 29ms (DB: 3) | 302 Found [http://localhost/user/authenticate]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#index (for 127.0.0.1 at 2010-07-16 16:38:08) [GET]
[4;36;1mExpense Load (5.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expense/index
Rendered expense/_options (0.4ms)
Rendered layouts/_header (1.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 29ms (View: 8, DB: 6) | 200 OK [http://localhost/expenses]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#index (for 127.0.0.1 at 2010-07-16 16:38:10) [GET]
[4;35;1mExpense Load (5.3ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expense/index
Rendered expense/_options (0.5ms)
Rendered layouts/_header (1.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 35ms (View: 14, DB: 5) | 200 OK [http://localhost/expenses]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 16:38:14) [GET]
Rendering template within layouts/application
Rendering expense/new
Rendered expense/_options (0.5ms)
ActionView::TemplateError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.stringify_keys) on line #3 of app/views/expense/new.haml:
1: = render 'expense/options'
2: - error_messages_for :expense
3: - form_tag :create, @expense, :html => {:multipart => true} do |f|
4: .field
5: = label_tag(:expense_number, "Expense number")
6: %br
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:205:in `form_tag'
app/views/expense/new.haml:3:in `_run_haml_app47views47expense47new46haml'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (54.6ms)
Rendered rescues/_request_and_response (0.3ms)
Rendering rescues/layout (internal_server_error)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 16:40:25) [GET]
Rendering template within layouts/application
Rendering expense/new
Rendered expense/_options (0.4ms)
Rendered layouts/_header (5.5ms)
Rendered layouts/_footer (0.2ms)
Completed in 22ms (View: 16, DB: 0) | 200 OK [http://localhost/expenses/new]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:40:37) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"expense_number"=>"111", "file"=>"Notes.txt"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (24.9ms)
Rendered rescues/_request_and_response (0.7ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:40:46) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"expense_number"=>"111", "file"=>"Notes.txt"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (25.0ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:48:51) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"expense_number"=>"111", "file"=>"Notes.txt"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (193.8ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 16:48:56) [GET]
Rendering template within layouts/application
Rendering expense/new
Rendered expense/_options (0.6ms)
Rendered layouts/_header (5.9ms)
Rendered layouts/_footer (0.2ms)
Completed in 25ms (View: 18, DB: 0) | 200 OK [http://localhost/expenses/new]
[4;36;1mSQL (1.4ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:49:02) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"C3 Email configuration.pdf", "expense_number"=>"111"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (25.1ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:51:56) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"C3 Email configuration.pdf", "expense_number"=>"111"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (24.8ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:53:35) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"C3 Email configuration.pdf", "expense_number"=>"111"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (25.9ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing UserController#login (for 127.0.0.1 at 2010-07-16 16:53:40) [GET]
Rendering template within layouts/application
Rendering user/login
Rendered expense/_options (0.5ms)
Rendered layouts/_header (7.4ms)
Rendered layouts/_footer (0.1ms)
Completed in 20ms (View: 17, DB: 0) | 200 OK [http://localhost/]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#index (for 127.0.0.1 at 2010-07-16 16:53:42) [GET]
[4;36;1mExpense Load (6.9ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expense/index
Rendered expense/_options (2.0ms)
Rendered layouts/_header (1.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 37ms (View: 10, DB: 7) | 200 OK [http://localhost/expenses]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#download (for 127.0.0.1 at 2010-07-16 16:53:44) [GET]
Parameters: {"id"=>"15"}
[4;35;1mExpense Load (0.7ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 15) [0m
Sending data Notes.txt
Completed in 20ms (View: 1, DB: 1) | 200 OK [http://localhost/expenses/15/download]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 16:53:47) [GET]
Rendering template within layouts/application
Rendering expense/new
Rendered expense/_options (0.4ms)
Rendered layouts/_header (5.6ms)
Rendered layouts/_footer (0.1ms)
Completed in 21ms (View: 14, DB: 0) | 200 OK [http://localhost/expenses/new]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 16:53:48) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.5ms)
Rendered layouts/_header (5.7ms)
Rendered layouts/_footer (0.1ms)
Completed in 22ms (View: 16, DB: 0) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:53:50) [POST]
Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (33.9ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 16:53:53) [GET]
Rendering template within layouts/application
Rendering expense/new
Rendered expense/_options (0.4ms)
Rendered layouts/_header (5.7ms)
Rendered layouts/_footer (0.2ms)
Completed in 21ms (View: 15, DB: 0) | 200 OK [http://localhost/expenses/new]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:54:04) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"Git.pdf", "expense_number"=>"1asd"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (167.5ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 16:54:39) [GET]
Rendering template within layouts/application
Rendering expense/search
Rendered expense/_options (0.9ms)
Rendered layouts/_header (5.8ms)
Rendered layouts/_footer (0.1ms)
Completed in 21ms (View: 12, DB: 0) | 200 OK [http://localhost/expenses/search]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#index (for 127.0.0.1 at 2010-07-16 16:54:40) [GET]
[4;36;1mExpense Load (5.4ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
Rendering template within layouts/application
Rendering expense/index
Rendered expense/_options (0.5ms)
Rendered layouts/_header (1.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 30ms (View: 8, DB: 6) | 200 OK [http://localhost/expenses]
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#download (for 127.0.0.1 at 2010-07-16 16:54:42) [GET]
Parameters: {"id"=>"15"}
[4;35;1mExpense Load (0.6ms)[0m [0mSELECT * FROM "expenses" WHERE ("expenses"."id" = 15) [0m
Sending data Notes.txt
Completed in 20ms (View: 1, DB: 1) | 200 OK [http://localhost/expenses/15/download]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#show (for 127.0.0.1 at 2010-07-16 16:54:48) [GET]
Parameters: {"id"=>"19"}
[4;36;1mExpense Load (0.6ms)[0m [0;1mSELECT * FROM "expenses" WHERE ("expenses"."id" = 19) [0m
Rendering template within layouts/application
Rendering expense/show
Rendered expense/_options (0.5ms)
[4;35;1mUser Load (0.4ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m
Rendered layouts/_header (0.2ms)
Rendered layouts/_footer (0.1ms)
Completed in 24ms (View: 8, DB: 1) | 200 OK [http://localhost/expenses/19]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 16:55:45) [GET]
Rendering template within layouts/application
Rendering expense/new
Rendered expense/_options (0.4ms)
Rendered layouts/_header (5.7ms)
Rendered layouts/_footer (0.2ms)
Completed in 20ms (View: 11, DB: 0) | 200 OK [http://localhost/expenses/new]
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:55:47) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"", "expense_number"=>""}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (26.3ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:57:18) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"", "expense_number"=>""}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (25.0ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
[4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
[4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 16:57:26) [POST]
Parameters: {"commit"=>"Upload", "expense"=>{"uploaded_file"=>"old.txt", "expense_number"=>"54"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (24.8ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.4ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing UserController#login (for 127.0.0.1 at 2010-07-16 17:09:56) [GET]
+Rendering template within layouts/application
+Rendering user/login
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.6ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 17ms (View: 15, DB: 1) | 200 OK [http://localhost/]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-16 17:09:58) [GET]
+ [4;36;1mExpense Load (5.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (1.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 33ms (View: 9, DB: 6) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 17:10:00) [GET]
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.5ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 18ms (View: 12, DB: 0) | 200 OK [http://localhost/expenses/new]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:10:02) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.7ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 16ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:10:06) [POST]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"123"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (29.8ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search_results (for 127.0.0.1 at 2010-07-16 17:11:42) [GET]
+
+NoMethodError (You have a nil object when you didn't expect it!
+You might have expected an instance of ActiveRecord::Base.
+The error occurred while evaluating nil.[]):
+ app/controllers/expense_controller.rb:46:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (33.9ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:11:47) [POST]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"123"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (25.1ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:18:09) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+
+ActionView::TemplateError (undefined local variable or method `search_results_path' for #<ActionView::Base:0xb6431ab4>) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for search_results_path do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (57.5ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:18:20) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+
+ActionView::TemplateError (undefined local variable or method `search_results_expenses' for #<ActionView::Base:0xb6304510>) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for search_results_expenses do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (48.7ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:18:31) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.5ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 22ms (View: 16, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:18:39) [POST]
+ Parameters: {"search_results"=>{"expense_number"=>"111"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (25.6ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:18:47) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (140.2ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 154ms (View: 148, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:19:03) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+ERROR: compiling _run_haml_app47views47expense47search46haml RAISED compile error
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected ':', expecting kEND
+ form_for 'search_results' :method => :get do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end
+Function body: def _run_haml_app47views47expense47search46haml(local_assigns)
+ old_output_buffer = output_buffer;;begin;extend Haml::Helpers;_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, {:attr_wrapper=>"'", :format=>:xhtml, :escape_html=>false, :autoclose=>["meta", "img", "link", "br", "hr", "input", "area", "param", "col", "base"], :preserve=>["textarea", "pre", "code"], :ugly=>false, :encoding=>nil});_erbout = _hamlout.buffer;__in_erb_template = true;;_hamlout.push_text("#{_hamlout.format_script_false_false_false_false_false_true_false(( render 'expense/options'
+));}\n", 0, false); error_messages_for :expense;
+ form_for 'search_results' :method => :get do |f|;
+_hamlout.push_text("<div class='field'>\n #{
+_hamlout.adjust_tabs(1); _hamlout.format_script_false_false_false_false_false_true_false(( label(:expense_number, "Expense number")
+));}\n <br />\n #{
+_hamlout.format_script_false_false_false_false_false_true_false(( f.text_field "expense_number"
+));}\n</div>\n<div class='actions'>\n #{
+_hamlout.format_script_false_false_false_false_false_true_false(( f.submit "Search"
+));}\n</div>\n", -1, false);end;_erbout;ensure;@haml_buffer = @haml_buffer.upper;end;
+ ensure
+ self.output_buffer = old_output_buffer
+ end
+Backtrace: /home/myfwhite/projects/expenses/app/views/expense/search.haml:11:in `compile!'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:61:in `compile'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:28:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/template.rb:199:in `render_template'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:260:in `render_without_haml'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:343:in `_render_with_layout'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:257:in `render_without_haml'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1250:in `render_for_file'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:945:in `render_without_benchmark'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1326:in `default_render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1332:in `perform_action_without_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:617:in `call_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:146:in `perform_action'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `send'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `process_without_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:606:in `process'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:391:in `process'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:386:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:87:in `dispatch'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:121:in `_call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:130
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/sass/plugin/rack.rb:41:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:93:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:114:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reloader.rb:34:in `run'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:108:in `call'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log_tailer.rb:17:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:50:in `service'
+/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:14:in `run'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:111
+/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
+/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
+./script/server:3
+
+ActionView::TemplateError (compile error
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected ':', expecting kEND
+ form_for 'search_results' :method => :get do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for 'search_results' :method => :get do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:11:in `compile!'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (52.0ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:19:25) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+ERROR: compiling _run_haml_app47views47expense47search46haml RAISED compile error
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected ':', expecting kEND
+ form_for 'search_results' :url => {:method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected kDO, expecting kEND
+ form_for 'search_results' :url => {:method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end
+Function body: def _run_haml_app47views47expense47search46haml(local_assigns)
+ old_output_buffer = output_buffer;;begin;extend Haml::Helpers;_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, {:attr_wrapper=>"'", :format=>:xhtml, :escape_html=>false, :autoclose=>["meta", "img", "link", "br", "hr", "input", "area", "param", "col", "base"], :preserve=>["textarea", "pre", "code"], :ugly=>false, :encoding=>nil});_erbout = _hamlout.buffer;__in_erb_template = true;;_hamlout.push_text("#{_hamlout.format_script_false_false_false_false_false_true_false(( render 'expense/options'
+));}\n", 0, false); error_messages_for :expense;
+ form_for 'search_results' :url => {:method => :get} do |f|;
+_hamlout.push_text("<div class='field'>\n #{
+_hamlout.adjust_tabs(1); _hamlout.format_script_false_false_false_false_false_true_false(( label(:expense_number, "Expense number")
+));}\n <br />\n #{
+_hamlout.format_script_false_false_false_false_false_true_false(( f.text_field "expense_number"
+));}\n</div>\n<div class='actions'>\n #{
+_hamlout.format_script_false_false_false_false_false_true_false(( f.submit "Search"
+));}\n</div>\n", -1, false);end;_erbout;ensure;@haml_buffer = @haml_buffer.upper;end;
+ ensure
+ self.output_buffer = old_output_buffer
+ end
+Backtrace: /home/myfwhite/projects/expenses/app/views/expense/search.haml:11:in `compile!'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:61:in `compile'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:28:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/template.rb:199:in `render_template'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:260:in `render_without_haml'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:343:in `_render_with_layout'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:257:in `render_without_haml'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1250:in `render_for_file'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:945:in `render_without_benchmark'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1326:in `default_render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1332:in `perform_action_without_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:617:in `call_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:146:in `perform_action'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `send'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `process_without_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:606:in `process'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:391:in `process'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:386:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:87:in `dispatch'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:121:in `_call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:130
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/sass/plugin/rack.rb:41:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:93:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:114:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reloader.rb:34:in `run'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:108:in `call'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log_tailer.rb:17:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:50:in `service'
+/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:14:in `run'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:111
+/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
+/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
+./script/server:3
+
+ActionView::TemplateError (compile error
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected ':', expecting kEND
+ form_for 'search_results' :url => {:method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected kDO, expecting kEND
+ form_for 'search_results' :url => {:method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for 'search_results' :url => {:method => :get} do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:11:in `compile!'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (47.4ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:19:33) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+ERROR: compiling _run_haml_app47views47expense47search46haml RAISED compile error
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected ':', expecting kEND
+ form_for 'search_results' :html => {:method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected kDO, expecting kEND
+ form_for 'search_results' :html => {:method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end
+Function body: def _run_haml_app47views47expense47search46haml(local_assigns)
+ old_output_buffer = output_buffer;;begin;extend Haml::Helpers;_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, {:attr_wrapper=>"'", :format=>:xhtml, :escape_html=>false, :autoclose=>["meta", "img", "link", "br", "hr", "input", "area", "param", "col", "base"], :preserve=>["textarea", "pre", "code"], :ugly=>false, :encoding=>nil});_erbout = _hamlout.buffer;__in_erb_template = true;;_hamlout.push_text("#{_hamlout.format_script_false_false_false_false_false_true_false(( render 'expense/options'
+));}\n", 0, false); error_messages_for :expense;
+ form_for 'search_results' :html => {:method => :get} do |f|;
+_hamlout.push_text("<div class='field'>\n #{
+_hamlout.adjust_tabs(1); _hamlout.format_script_false_false_false_false_false_true_false(( label(:expense_number, "Expense number")
+));}\n <br />\n #{
+_hamlout.format_script_false_false_false_false_false_true_false(( f.text_field "expense_number"
+));}\n</div>\n<div class='actions'>\n #{
+_hamlout.format_script_false_false_false_false_false_true_false(( f.submit "Search"
+));}\n</div>\n", -1, false);end;_erbout;ensure;@haml_buffer = @haml_buffer.upper;end;
+ ensure
+ self.output_buffer = old_output_buffer
+ end
+Backtrace: /home/myfwhite/projects/expenses/app/views/expense/search.haml:11:in `compile!'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:61:in `compile'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:28:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/template.rb:199:in `render_template'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:260:in `render_without_haml'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:343:in `_render_with_layout'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:257:in `render_without_haml'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1250:in `render_for_file'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:945:in `render_without_benchmark'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1326:in `default_render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1332:in `perform_action_without_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:617:in `call_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:146:in `perform_action'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `send'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `process_without_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:606:in `process'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:391:in `process'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:386:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:87:in `dispatch'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:121:in `_call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:130
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/sass/plugin/rack.rb:41:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:93:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:114:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reloader.rb:34:in `run'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:108:in `call'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log_tailer.rb:17:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:50:in `service'
+/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:14:in `run'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:111
+/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
+/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
+./script/server:3
+
+ActionView::TemplateError (compile error
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected ':', expecting kEND
+ form_for 'search_results' :html => {:method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected kDO, expecting kEND
+ form_for 'search_results' :html => {:method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for 'search_results' :html => {:method => :get} do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:11:in `compile!'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (43.5ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:19:40) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.6ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 16, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:19:58) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.8ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 20ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:20:01) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.7ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 16ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:20:05) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.8ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 16ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:21:22) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.6ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 24ms (View: 15, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:21:26) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.5ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 17ms (View: 11, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:21:37) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.9ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 24ms (View: 17, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:21:41) [GET]
+ Parameters: {"commit"=>"Search", "search"=>{"expense_number"=>"1111"}}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.8ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 20ms (View: 14, DB: 0) | 200 OK [http://localhost/expenses/search?search%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:22:24) [GET]
+ Parameters: {"commit"=>"Search", "search"=>{"expense_number"=>"1111"}}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.6ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 22ms (View: 16, DB: 0) | 200 OK [http://localhost/expenses/search?search%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:22:27) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (6.7ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 18ms (View: 13, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:23:14) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+
+ActionView::TemplateError (undefined local variable or method `search_results_path' for #<ActionView::Base:0xb64cd1d0>) on line #4 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: /- form_for :expense search_results', :html => {:method => :get} do |f|
+4: - form_for @expense, search_results_path do |f|
+5: .field
+6: = label(:expense_number, "Expense number")
+7: %br
+
+ app/views/expense/search.haml:4:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (42.9ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:23:24) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.6ms)
+
+ActionView::TemplateError (Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id) on line #4 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: /- form_for :expense search_results', :html => {:method => :get} do |f|
+4: - form_for @expense, 'search_results' do |f|
+5: .field
+6: = label(:expense_number, "Expense number")
+7: %br
+
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:231:in `form_for'
+ app/views/expense/search.haml:4:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (55.7ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:23:35) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+
+ActionView::TemplateError (Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id) on line #4 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: /- form_for :expense search_results', :html => {:method => :get} do |f|
+4: - form_for @expense, 'search_results' do |f|
+5: .field
+6: = label(:expense_number, "Expense number")
+7: %br
+
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:231:in `form_for'
+ app/views/expense/search.haml:4:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (56.5ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;35;1mSQL (4.2ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.4ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-16 17:23:43) [GET]
+ [4;35;1mExpense Load (5.7ms)[0m [0mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (1.3ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 149ms (View: 9, DB: 10) | 200 OK [http://localhost/expenses/]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:23:45) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (3.3ms)
+
+ActionView::TemplateError (Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id) on line #4 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: /- form_for :expense search_results', :html => {:method => :get} do |f|
+4: - form_for @expense, 'search_results' do |f|
+5: .field
+6: = label(:expense_number, "Expense number")
+7: %br
+
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:231:in `form_for'
+ app/views/expense/search.haml:4:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (56.6ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:24:46) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.6ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 16, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:24:51) [POST]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (24.4ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:25:17) [POST]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}, "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (25.6ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:25:21) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (8.2ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 25ms (View: 19, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search_results (for 127.0.0.1 at 2010-07-16 17:25:25) [GET]
+ Parameters: {"commit"=>"Search", "expense"=>{"expense_number"=>"1111"}}
+
+NameError (undefined local variable or method `expense_number' for #<ExpenseController:0xb62f2bd0>):
+ app/controllers/expense_controller.rb:53:in `search_results'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (42.5ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:27:15) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+
+ActionView::TemplateError (Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id) on line #5 of app/views/expense/search.haml:
+2: - error_messages_for :expense
+3: /- form_for :expense search_results', do |f|
+4: /- form_for :expense, :url => {:action => 'search_results'}, :html => {:method => :get} do |f|
+5: - form_for [:search_results, @expense] do |f|
+6: .field
+7: = label(:expense_number, "Expense number")
+8: %br
+
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:231:in `form_for'
+ app/views/expense/search.haml:5:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (84.3ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:27:55) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (6.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 29ms (View: 20, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:28:00) [POST]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (30.0ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:29:12) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.6ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 18ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:29:14) [POST]
+ Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (47.1ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:29:33) [POST]
+ Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (35.4ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:29:37) [POST]
+ Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (30.2ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-07-16 17:29:50) [POST]
+ Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search", "authenticity_token"=>"XeqoHHpGlq+tsoOdO3IZO2FZmvQtuZApcmM3AqQ3yg0="}
+
+ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (28.1ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (method_not_allowed)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:17) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+ERROR: compiling _run_haml_app47views47expense47search46haml RAISED compile error
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected '{', expecting kEND
+ form_for :search_results, @expense {method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end
+Function body: def _run_haml_app47views47expense47search46haml(local_assigns)
+ old_output_buffer = output_buffer;;begin;extend Haml::Helpers;_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, {:attr_wrapper=>"'", :format=>:xhtml, :escape_html=>false, :autoclose=>["meta", "img", "link", "br", "hr", "input", "area", "param", "col", "base"], :preserve=>["textarea", "pre", "code"], :ugly=>false, :encoding=>nil});_erbout = _hamlout.buffer;__in_erb_template = true;;_hamlout.push_text("#{_hamlout.format_script_false_false_false_false_false_true_false(( render 'expense/options'
+));}\n", 0, false); error_messages_for :expense;
+ form_for :search_results, @expense {method => :get} do |f|;
+_hamlout.push_text("<div class='field'>\n #{
+_hamlout.adjust_tabs(1); _hamlout.format_script_false_false_false_false_false_true_false(( label(:expense_number, "Expense number")
+));}\n <br />\n #{
+_hamlout.format_script_false_false_false_false_false_true_false(( f.text_field "expense_number"
+));}\n</div>\n<div class='actions'>\n #{
+_hamlout.format_script_false_false_false_false_false_true_false(( f.submit "Search"
+));}\n</div>\n", -1, false);end;_erbout;ensure;@haml_buffer = @haml_buffer.upper;end;
+ ensure
+ self.output_buffer = old_output_buffer
+ end
+Backtrace: /home/myfwhite/projects/expenses/app/views/expense/search.haml:11:in `compile!'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:61:in `compile'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/renderable.rb:28:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/template.rb:199:in `render_template'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:260:in `render_without_haml'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:343:in `_render_with_layout'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/base.rb:257:in `render_without_haml'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/haml/helpers/action_view_mods.rb:13:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1250:in `render_for_file'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:945:in `render_without_benchmark'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:51:in `render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1326:in `default_render'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:1332:in `perform_action_without_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:617:in `call_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
+/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/flash.rb:146:in `perform_action'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `send'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `process_without_filters'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/filters.rb:606:in `process'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:391:in `process'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/base.rb:386:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:87:in `dispatch'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:121:in `_call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:130
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call'
+/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
+/usr/lib/ruby/gems/1.8/gems/haml-3.0.13/lib/sass/plugin/rack.rb:41:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:93:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:114:in `call'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reloader.rb:34:in `run'
+/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:108:in `call'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log_tailer.rb:17:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:50:in `service'
+/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:14:in `run'
+/usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:111
+/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
+/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
+./script/server:3
+
+ActionView::TemplateError (compile error
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:3: syntax error, unexpected '{', expecting kEND
+ form_for :search_results, @expense {method => :get} do |f|;
+ ^
+/home/myfwhite/projects/expenses/app/views/expense/search.haml:11: syntax error, unexpected kENSURE, expecting $end) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for :search_results, @expense {method => :get} do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:11:in `compile!'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (56.2ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:24) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.7ms)
+
+ActionView::TemplateError (wrong number of arguments (0 for 1)) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for :search_results, @expense, {method => :get} do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:3:in `method'
+ app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (49.7ms)
+Rendered rescues/_request_and_response (0.5ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:38) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+
+ActionView::TemplateError (undefined local variable or method `html' for #<ActionView::Base:0xb6569364>) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for :search_results, @expense, html => {method => :get} do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (49.0ms)
+Rendered rescues/_request_and_response (0.4ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:46) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+
+ActionView::TemplateError (wrong number of arguments (0 for 1)) on line #3 of app/views/expense/search.haml:
+1: = render 'expense/options'
+2: - error_messages_for :expense
+3: - form_for :search_results, @expense, :html => {method => :get} do |f|
+4: .field
+5: = label(:expense_number, "Expense number")
+6: %br
+
+ app/views/expense/search.haml:3:in `method'
+ app/views/expense/search.haml:3:in `_run_haml_app47views47expense47search46haml'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/haml/helpers/action_view_mods.rb:13:in `render'
+ haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (52.3ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:55) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.5ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 15, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:31:59) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (5.1ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 16ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=111&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:02) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (8.2ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 21ms (View: 14, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:15) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (6.0ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 27ms (View: 12, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (4.2ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:18) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (7.8ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 19ms (View: 12, DB: 4) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;36;1mSQL (0.9ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.2ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:35) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.4ms)
+Rendered layouts/_header (6.8ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 25ms (View: 20, DB: 1) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:38) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (8.1ms)
+Rendered layouts/_footer (0.2ms)
+Completed in 28ms (View: 18, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:41) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"1111"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.6ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 17ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=1111&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:32:52) [GET]
+ Parameters: {"search_results"=>{"expense_number"=>"11110"}, "commit"=>"Search"}
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.6ms)
+Rendered layouts/_header (7.1ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 19ms (View: 13, DB: 0) | 200 OK [http://localhost/expenses/search?search_results%5Bexpense_number%5D=11110&commit=Search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:33:12) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.6ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 16ms (View: 10, DB: 0) | 200 OK [http://localhost/expenses/search]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#new (for 127.0.0.1 at 2010-07-16 17:33:14) [GET]
+Rendering template within layouts/application
+Rendering expense/new
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.8ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 21ms (View: 15, DB: 0) | 200 OK [http://localhost/expenses/new]
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'panic'[0m
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#index (for 127.0.0.1 at 2010-07-16 17:33:17) [GET]
+ [4;36;1mExpense Load (5.5ms)[0m [0;1mSELECT * FROM "expenses" WHERE (user_id = 2) ORDER BY created_at DESC[0m
+Rendering template within layouts/application
+Rendering expense/index
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (1.2ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 30ms (View: 8, DB: 6) | 200 OK [http://localhost/expenses]
+ [4;35;1mSQL (0.1ms)[0m [0mSET client_min_messages TO 'panic'[0m
+ [4;36;1mSQL (0.1ms)[0m [0;1mSET client_min_messages TO 'notice'[0m
+
+
+Processing ExpenseController#search (for 127.0.0.1 at 2010-07-16 17:33:18) [GET]
+Rendering template within layouts/application
+Rendering expense/search
+Rendered expense/_options (0.5ms)
+Rendered layouts/_header (5.5ms)
+Rendered layouts/_footer (0.1ms)
+Completed in 20ms (View: 14, DB: 0) | 200 OK [http://localhost/expenses/search]
|
nocturnal/EShell
|
91f5f8f5ab97158181725fcbef4e8114221e5597
|
license
|
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..78b6073
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 200x, Insomniac Games, Inc.
+All rights reserved.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+Neither the name of the Insomniac Games, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+For Source files:
+
+<Library name>
+<Brief library description>
+Copyright (C) 200x Insomniac Games
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the Insomniac Open License
+as published by Insomniac Games.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even an implied warranty. See the
+Insomniac Open License for more details.
+
+You should have received a copy of the Insomniac Open License
+along with this code; if not, write to the Insomniac Games
+2255 N. Ontario St Suite 550, Burbank, CA 91504, or email
[email protected], or visit
+http://nocturnal.insomniacgames.com.
\ No newline at end of file
|
skalnik/MUSI-3610
|
ae8b0c3287ab1095efe91573b6f0e9d67b134ed5
|
Another day, moar notes
|
diff --git a/Notes/11-2.txt b/Notes/11-2.txt
new file mode 100644
index 0000000..56dbe84
--- /dev/null
+++ b/Notes/11-2.txt
@@ -0,0 +1,28 @@
+Handel
+* Produces Opera Serias
+* Famous for concertos
+* Concerto is a 3 movement form (slow fast slow)
+* Violin concerti & oboe concerti
+* Known for his Oratori, especially Messiah
+* When Opera collapses his turns to spirituality
+* Suffers a stroke, right arm temporarily paralyzed, can't write or perform
+* After this, he locks himself into room and writes Messiah
+* Hires a small choir Dublin. Not well receieved
+* Performs it in London for charity. Turns into instant hit
+* Watermusick is a suite of international dance pieces
+John Gay
+* Sweeps away Seria with Opera Comics
+* Lower class women are used commonly in these operas
+* Male is brought down due to his amoral lifestyle
+Antonio Vivaldi (1678-1741)
+* Born in Northern Italy
+* Operates in Venice
+* Ordained as a priest at 1703, however wasn't spiritaul and gets out of saying mass
+* Son of violinist & opera entrepreneur
+* Exoticism, Fiery Concertos. By doing this he brings the Concerto to it's height.
+* His stuff starts getting published throughout Europe
+* Teaches at an orphanage
+* Most famous are the Four Seasons concertos
+* First program music
+* Ritornello Principle - A major theme (or themes) that will return over and over again.
+* They become the structure of the piece.
|
skalnik/MUSI-3610
|
8b4ffdd04ebfa0f1b5d26d5fb1f0085d14051007
|
More notes
|
diff --git a/Notes/10-14.txt b/Notes/10-14.txt
new file mode 100644
index 0000000..2c547e5
--- /dev/null
+++ b/Notes/10-14.txt
@@ -0,0 +1,42 @@
+The Baroque Period 1600-1750
+
+The Baroque Ideal
+* The term 'baroque' literally refers to an ireegular pearl (one connotation; a flawed shape). The stylistic term was coined in 1750 in derogatory reference to a new, ornate architectural facade.
+* Other associations of the term "baroque":
+ * abnormal
+ * exaggerated
+ * grotesque
+ * flamboyant
+ * expressionistic
+* Baroque music is not all this way, but certain characteristics emerge
+Italy very influential in the Baroque
+* Florence: "invention" of Opera & theatrical innovation
+* Rome: Sacred Music
+* Venice & Naples: centers of Opera
+* French music (Jean-Baptiste Lully) a transplanted Florentine (Italian from Florance)
+* German music re-invented in the Italian style (Bach, Handel)
+* English music revived after Commonwealth (1642-1660) in the Italian style
+Baroque Environment Key Points
+* Era of religious wars, exploration, colonization
+* Rise of the middle clas (bourgeois) culture; expansion of performance opportunity beyond home & church to concert/opera houses & university (collegium musicum)
+* Age of Discovery. Kepler, Galileo, Newton, Copernicus, Descartes, Harvey
+* Age of Absolute Monarchies
+The Baroque Musical Ideal
+* Vs. Renaissance practice...
+* Monteverdi 1605 departs prima practica (dual priority words & music in a polyphonic environment) from Seconda practica (music serving the text)
+* "The end of all good music is to affect the soul"... from this philosophy the doctrine of the affections emerges
+* Gradual emergence of idiomatic (specific instrumental characterisitics) writing
+A Tale of Two Cities
+* Venice & Florence
+* Florentine Camerata (lit. salon; space for entertaining in a well-appointed home)
+* Venetian academia, opera, song
+* Experimentation, examination of new points of discourse (complex, even bizarre emotions/subjects)
+Forerunners
+* Ren Theatre emulating Greek tragedy (in which some lyric speech is sung)
+* Medieval liturgical drama
+* "Intermedi"; large scale musical productions with song poetry etc.
+* Pastorail poems of idyllic love
+* Madrigal cycles (story telling collections)
+A Florentine in Rome
+* Girolamo Mei 1519-1594 Florentine scholar working in Rome on Greek music history, reading original Greek plays, then wrote 4 books "De Modis": i.e. Of the (or Concerning) the Modes
+* Conclusion: Greeks achieved powerful expression through single voice and natural range of emotion of which it is capable
diff --git a/Notes/10-21.txt b/Notes/10-21.txt
new file mode 100644
index 0000000..0cbfba2
--- /dev/null
+++ b/Notes/10-21.txt
@@ -0,0 +1,34 @@
+Vincenzo Galilei 1520-1591
+* Galileo Galilei's father
+* Lutenist, Composer, Theorist
+* Tuscan; moves to Pisa, marries into a noble family, Galileo born in 1564
+* Vincenzo meets Gioseffo Zarlino in 1563, studies theory with him
+* Vincenzo makes physical (acoustical) discoveries
+Florentine Camerata (1580-1600)
+* Counts Giovanni Bardi, Gacopo Corsi, Ottavio Rinuccini, The Medicis, Jacopo Peri, Guilio Caccini, Glaudio Moteverdi
+* First Operas: Euridice, Dafne, Orfeo
+* Doctrine of the Affections (passions): content of a work should demonstrate a single affection
+* Representative Style outward expression of emotions
+* Stile Concitato (Agitated Style)
+Opera
+* Sung Throughout
+* Includes Dramatic Aaction, costumes etc.
+* Greco-Romon subject matter (story)
+* Monody (solo song): Recitative and Aria
+* Da Capo Aria A B (fine) Da Capo (D.C. sign)
+* Emergence of librettist (the person who writes the "book" (store & lyrics) of opera)
+* French lyric tragedy, English Masque and semi-opera contribute to Opera
+Instrumental Techniques arising from Opera
+* Continuous bass: always motion in left hand of kb, cello or bass instrument(s)
+* Figured bass notation, shorthand for harmonic progression to facilitate improvisation
+* Instruments complement affection (passion) through improvisation: supports liberties of singer and heightens affections
+* Simple harmonic accompaniment based on Major Minor tonalities
+Baroque Musical Energy
+* Equal Temperament (reinforcement of sound, larger ensembles and possibility of key changes)
+* Dissonance
+* Expansive melodic development
+* Vigorous rhythms aimed at public performance
+Monteverdi (1567-1643)
+* L'Orfeo 1607 Youtube Toccata & Tu Se Morta (Savall)
+* Il Combittimento di Tancredi e Clorinda (1624) from the text Gerusalmemme Liberata by Torquato Tasso
+* 'The Return of Ulysses' (1641) and 'The Coronation of Poppea' (1642)
|
skalnik/MUSI-3610
|
a3e597c5e0d72e46560a2d6ad63c90fb03fd0af4
|
More notes
|
diff --git a/Notes/10-7.txt b/Notes/10-7.txt
new file mode 100644
index 0000000..60619d8
--- /dev/null
+++ b/Notes/10-7.txt
@@ -0,0 +1,11 @@
+1. Word painting, imitation and monody are stylistic indicators of the early renaissance. T
+2. Northern (Netherlander) composers dominate European music in the late Renaissance.
+3. Early madrigal offered amateurs an opportunity to perform at home. T
+4. Monteverdi's great contributions include the Pope Marcellus Mass. F
+5. Continuous imitation first appears in the late Renaissance. F
+6. Renaissance intrumental music includes dance rhythms. T
+7. During the Renaissance, a rising merchant class arrange commissions in the arts for themselves and on behalf of the church. T
+8. Throughout the Renaissance, harmony is based upon church modes.
+9. The Council of Trent focused on entirely upon musical and artistic values. F
+10. In secular music, the Renaissance includes a progression from solo voice and lute songs to intricate polphony (madrigal). T
+11. Artistic dominance of the northern composers is demonstrated through the career of Monteverdi. F
diff --git a/Notes/9-30.txt b/Notes/9-30.txt
index e69de29..77484e2 100644
--- a/Notes/9-30.txt
+++ b/Notes/9-30.txt
@@ -0,0 +1,27 @@
+Secular Song - The Madrigal
+* Arising from a tradition of solo, 2 and 3 part song
+* Perhaps from the archaic Italian 'Matri' and 'Calle'
+* "Mother tongue" (i.e. sung/created in Italian)
+* A Madrigal is a 4 or 5 part vocal work for unaccompanied voice
+Lute
+* For small area
+Dulcian
+* Dulce - Sweetly
+* Similar to the basoon
+Pipes
+* Every country has a set of bag pipes
+Piffaro
+* Modern musicians that play these old instruments
+* All' arm! (All to arms)
+Madrigal
+* Secular composition
+* Subjects fit the ideal of world painting such as hunting, nature, great tales of war and adventure, nationalism in its infancy, love in all aspects (distant and intimate, in love and abandoned).
+* Double entendre often present
+Madrigal at its height
+* Italy (beautiful singing style and melody)
+* England (word painting and poetic mastery): Thomas Weelkes, William Byrd, John Farmer
+* Claudio Monteverdi (1567-1643)
+* The greatest of Italian Renaissance madrigal composers
+Thomas Weelkes
+* English
+* Madrigal Writer
|
skalnik/MUSI-3610
|
31fecfad621f611913bea5f812a512117696f7d0
|
Random fixes discovered while studying
|
diff --git a/Notes/8-31.txt b/Notes/8-31.txt
index f3da209..483278e 100644
--- a/Notes/8-31.txt
+++ b/Notes/8-31.txt
@@ -1,43 +1,43 @@
Music (from the Muses)
* Muses inspired creativity
The Muses
* Kalliope is the eldest of the muses: goddess of song (Kallioph, Kallipeia, Calliope) daughter of Zeus and Titan Goddess Mnemosyne (Goddess of memory & time)
* Kalliope's son is Orpheus; poet/singer/lyre master & greatest of human musicians.
* Dionysus overhears Orpheus singing priase to Helios (Sun God sometimes identified as Apollo), Jealous, DIonysus looses the Bakkhantes (women follwers of Dionysus maddened by wine/sensuality) to dismember Orpheus.
Apollo
* Son of Zeus
* God of light, truth, intellect, archery, medicine, music, poetry, and prophetic vision (the oracles).
* Master of the lyre and kithara (Persian ancestor of guitar)
"Artistic Polarity"
* Early implications of spiritual art/music; free will, life's choices, paths or stages ("the ages" of men & women: child, adolescent, maturity, old age).
* Dionysian: prioritize the emotional, the power of human feelings (the adolescent heart in the moment, passion, youth) and the forces of nature expressed in art.
* Apllonian: Artistic expression of intellect, form, balance, sophistication, the most elevated expression of the human mind (maturity, beauty, elegance)
Equal Temperament
* In Pythagorean or Just tuning systems, intervals are derived via ratio 4:3, 5:4, 6:5, etc.
-* In Equal Temperament, each half step interval is esuidistant, derived by geometric esquence (logorhythm)
+* In Equal Temperament, each half step interval is equidistant, derived by geometric esquence (logorhythm)
* For this course, implications; all 12 tones are equidistant; facilitates modulation, large ensembles.
More terms related to melody
* Range - the parameter of a melody (lowest/highest)
* Shape/Contour - graphic description (waves, arc, rising line)
* Conjunct/Disjunct - motion by small or large interval
* Phrase - A significant portion of a melody, described by natural points of tension or rest
Countermelody
* Melodies are not always in motion (sustained notes, points of rest etc.) and at these points, another significant melodic idea can grace the main idea
* Countermelody is a secondary figure; a melody that complements the main melody momentarily (it is not the main idea nor is it a background accompanying figure)
Rhythm
* Meter: rhythms organized into repeating patterns of accented and unaccented beats
* Meters are widely varied, but the most common meters in Western music are 2, 3, 4, 6, 9, 12 beats per measure
* Meter is indicated by time signature
Measures
* Measures or Bars
* Measure lines or bar lines are veritical markers that assist in fixing the strong accent points graphically
* Time signature
* Key signature
Time Signatures
* 2/4 2 beats per measure, quarter note gets one beat
* 3/2 3 beats per measure, half note gets the beat
* 4/4 4 beats per measure, quarter note gets the beat
* 5/8 5 beats per measure, eighth note gets the beat
Conducting patterns
* Don't feel like typing these and I already know 'em.
diff --git a/Notes/9-7.txt b/Notes/9-7.txt
index ac50e8a..6d64dea 100644
--- a/Notes/9-7.txt
+++ b/Notes/9-7.txt
@@ -1,68 +1,68 @@
Terms and Techniques of Composition and Counterpoint
* Retrograde - melodic fragment or motive stated backwards
* Inversion - Upside down
* Augmentation - expanded over more time
The Esthetics of Unity
* Repetition
* Contrast
* Variation
* Proto-music with these charactersitics leads to form
Basic Forms
* Binary AB
* Ternary ABA
* Rondo ABACA or ABACADA
Terms relating to form
* Theme - a melody or main idea
* Themeatic Development - expanding a theme's motives (small recognizable elements)
* Sequence - repetition of a motive or theme at a different pitch level
* Call and Response - leader and congregation (or ensemble) relationship
* Movement - a macroform of a longer work that stands alone - typically follows a specific form (each period has fomulaic associations)
Misc terms
* Ostinato figures - repetitive musical figures often underpinning a melody
* Dynamics - Indicate gradations of volume (degree of force employed in setting and sustaining a pitch)
* Duration - The length of time over which a note is maintained or sounded (ratios)
* Timbre (color) - dictated by the size, shape, materials of an instrument, combination of instruments, or qualities imparted by the player
Range
* Terms related to ranges are based upon the Latin and Italian terms for vocal range and function, with four main categories:
* Soprano
* Alto
* Tenor
* Bass
Families of Instruments (be able to place each in its family)
* Woodwinds
* Piccolo, flute, oboe, clarinet, bass clarinet, English horn, bassoon, constrabassoon
* Brass
* trumpet, French horn, trombone, bass trombone, tuba
* Strings
* violin, viola, cello, string bass
* Percussion
* snare drum, tambourine, field drum, bass drum, cymbals, triangle, timpani, xylophone, marimba, vibraphone, bells, chimes, etc.
Others
* Piano: fullname Pianoforte
* Guitar: Arabic/Persian roots, flat top, curved back
* Organ: secular outdoor instrument w/multiple operators, 10th century accepted into the church
-Ensemvles
+Ensembles
* Chorus/Chorale, Chamber Choir
* Orchestras: String, Chamber (30-50), Pit, Opera, Balllet, Symphony(80-)
* Concert Bands, Rcock Bands, Jazz Bands
Historical Periods
* Middle Ages (Medieval) 400-1450
* Renaissance 1450-1600
* Baroque 1600-1750
* Rococo 1725-1775
* Classical 1750-1825
* Romantic 1820-1900
* Post Romantic & Impressionist 1890-1915
* Modern (20th Century is Technically 1900-2000)
Middle Ages/Medieval 400-1450
* Marked by decline of Roman Empire (Vandals sack Rome in 476)
* End of period comes with fall of Constantinople to the Turks (1453)
* At the start of the Medieval period, remnants of Greek & Roman heritage are largely dormant, but will resurface at the end of the period
* Pope Gregory (590-604)
* Re-codifes the Ordinary part of the mass and liturgy
* The Orders - Rules that apply to every mass
* The Propers - Special functions of the mass
* Re-organizes the Schola Cantorum (School for Singing) & edits/standardizes plainchant (now called Gregorian Chant)
* Neumatic System
diff --git a/Notes/9-9.txt b/Notes/9-9.txt
index 0ccfacf..5602c33 100644
--- a/Notes/9-9.txt
+++ b/Notes/9-9.txt
@@ -1,27 +1,27 @@
Middle Ages (400-1450)
* The Propers - Special functions of the mass
* Re-organizes the Schola Cantorum (School for Singing) & edits/standardizes plainchant (now called Gregorian Chant)
* Neumatic System
* Church Modes
* Slow progression: Monophony to Polyphony
* Acoustical echo, boy singers lead to octave, then 5th and 4th
-* Following the stability of Charlemegne's (742-814) rule of the frankish empire, the Romanesque preiod 850-1150 sees the devlopment of notation, enhanced learning opportunities due to Charlemagne's belief in a literate public, a flourishing of intellectual pursuit even within the church in Paris
+* Following the stability of Charlemegne's (742-814) rule of the frankish empire, the Romanesque period 850-1150 sees the devlopment of notation, enhanced learning opportunities due to Charlemagne's belief in a literate public, a flourishing of intellectual pursuit even within the church in Paris
* Marian Movement (1000-1400)
* Hildegard of Bingen (1098-1179)
* Visions in 1141 lead to 1151 completion of "Sitas vias Domini" (Know the Ways of the Lord), which ends with morality play: "Ordo Virtutum" (Order of the Virtues)
* Notre Dame Cathedral, 12th, 13th centuries. Polophony, organum, isorhythmic motet
* Crusades (1096-1217) Five crusades, infusion of Eastern technologies and instrumentation
* The first true polyphonic composer we are aware of is Leonin (Leoninus 1135-1201), his student is Perotin; 2-4 voice polyphony
-* 1271 Morco Polo (Venetian) sets out for China
+* 1271 Marco Polo (Venetian) sets out for China
Marion Movement 1000-1400s
* Spiritual reverence for Mary, also refered to as "Age of Chivalry" of Arthurian legend (6th-7th Cent.)
* Hildegard von Bigen (1098-1179) Church Morality Play; "Ordo Virtutem" (Play of Virtues)
* Purity of Women reflected in art and music
* Bors rescues a maiden instead of Lionel, his brother (BROS BEFORE HOES DUDE!)
* Play of Virtues - First Church Morality play
* More difficult to sing in compared to Gregorian Chant
* Play of Virtues
* Alfonso el Sabio He Who Gladly Serves - Singular Female Voice
* Landini Behold Spring - Multiple Female Voices. Mostly Homophonic
|
skalnik/MUSI-3610
|
d95ef62a5b9f36f77dff9454cbab4c4a7b154810
|
Notes for 9/14
|
diff --git a/Notes/9-14.txt b/Notes/9-14.txt
new file mode 100644
index 0000000..048c57f
--- /dev/null
+++ b/Notes/9-14.txt
@@ -0,0 +1,29 @@
+The French Ars Nova (late 1300s-early 1400s)
+* Secular Music
+ * Jongleurs street/court performers, jugglers, theatrical entertainers
+ * Troubadours <Fr: trouve; work, discover, invent>
+ * The courtly composer, poet, often of noble birth or highly educated or odrained; traveling singer/story-telling entertainers accepted at court
+* Phillippe de Vitre 1291-1361 (not test material)
+* Guillaume de Machaut (1300-1377)
+Papal Power
+* "Certain disciples of the new school, much occupying themselves with the measured dividing of time, display their method in notes which are new to us ⦠with these notes of small value every composition is pestered. Moreoverâ¦sometimes even they stuff [the music] with upper parts made out of secular song. We now hasten therefore to banish these methodsâ¦and to put htem to flight more effectually that heretofore, far from the house of God." - Pope John XXII, 1317
+Instrumental Music, Late Medieval
+* Dance (secular)
+* Accompanying solo voice
+* Instruments "doubling" voices in church works
+* Rise of professional instrumentalists, capable of reading, improvisation, embellishment
+* Gradual displacement: Oral Tradition => Musical Literacy
+Instruments
+* Soft: Lute, recorder, harp, psaltery
+* Loud: shawn (primitive oboe), slide trumpet, sackbut, tabor and other assorted drums, pipe and reed organs
+
+
+
+
+Review
+* Cuts Responsible For: 19, 21, 22
+* Pages 1-49.
+* Terms: Melody, Pitch, Interval, Equal Temperament, Range, Shape, Conjunt, Disjunt, Phrase, Countermelody, Time Signature and Metrical patterns, Simple meters, syncopation, polyrhythm, retrograde, inversion, augmentation, diminution, harmony, chords, major & minor, consonance & disonance, tension & resolution, musical texture, terms of counterpoint,* Medievel 400-1450, Renaissance 1450-1600, Baroque 1600-1750, Classical 1750-1825.
+* Must know things about chant. Neumatic system, proper & ordinary, secular vs sacred, organum, motet, etc
+* Pope Gregory revamped the *already existing* Schola Cantorum
+
|
skalnik/MUSI-3610
|
00b4c1a45c450653c54ac70fbe6b8e98596e247a
|
Notes for 9/9
|
diff --git a/Notes/9-9.txt b/Notes/9-9.txt
new file mode 100644
index 0000000..0ccfacf
--- /dev/null
+++ b/Notes/9-9.txt
@@ -0,0 +1,27 @@
+Middle Ages (400-1450)
+* The Propers - Special functions of the mass
+* Re-organizes the Schola Cantorum (School for Singing) & edits/standardizes plainchant (now called Gregorian Chant)
+* Neumatic System
+* Church Modes
+* Slow progression: Monophony to Polyphony
+* Acoustical echo, boy singers lead to octave, then 5th and 4th
+* Following the stability of Charlemegne's (742-814) rule of the frankish empire, the Romanesque preiod 850-1150 sees the devlopment of notation, enhanced learning opportunities due to Charlemagne's belief in a literate public, a flourishing of intellectual pursuit even within the church in Paris
+* Marian Movement (1000-1400)
+* Hildegard of Bingen (1098-1179)
+* Visions in 1141 lead to 1151 completion of "Sitas vias Domini" (Know the Ways of the Lord), which ends with morality play: "Ordo Virtutum" (Order of the Virtues)
+* Notre Dame Cathedral, 12th, 13th centuries. Polophony, organum, isorhythmic motet
+* Crusades (1096-1217) Five crusades, infusion of Eastern technologies and instrumentation
+* The first true polyphonic composer we are aware of is Leonin (Leoninus 1135-1201), his student is Perotin; 2-4 voice polyphony
+* 1271 Morco Polo (Venetian) sets out for China
+Marion Movement 1000-1400s
+* Spiritual reverence for Mary, also refered to as "Age of Chivalry" of Arthurian legend (6th-7th Cent.)
+* Hildegard von Bigen (1098-1179) Church Morality Play; "Ordo Virtutem" (Play of Virtues)
+* Purity of Women reflected in art and music
+* Bors rescues a maiden instead of Lionel, his brother (BROS BEFORE HOES DUDE!)
+* Play of Virtues - First Church Morality play
+* More difficult to sing in compared to Gregorian Chant
+
+* Play of Virtues
+* Alfonso el Sabio He Who Gladly Serves - Singular Female Voice
+* Landini Behold Spring - Multiple Female Voices. Mostly Homophonic
+
|
skalnik/MUSI-3610
|
403fa3db1f816ed9fbb7d67fbfdf03eadfaecac8
|
Another day, moar notez
|
diff --git a/Notes/9-7.txt b/Notes/9-7.txt
new file mode 100644
index 0000000..ac50e8a
--- /dev/null
+++ b/Notes/9-7.txt
@@ -0,0 +1,68 @@
+Terms and Techniques of Composition and Counterpoint
+* Retrograde - melodic fragment or motive stated backwards
+* Inversion - Upside down
+* Augmentation - expanded over more time
+The Esthetics of Unity
+* Repetition
+* Contrast
+* Variation
+* Proto-music with these charactersitics leads to form
+Basic Forms
+* Binary AB
+* Ternary ABA
+* Rondo ABACA or ABACADA
+Terms relating to form
+* Theme - a melody or main idea
+* Themeatic Development - expanding a theme's motives (small recognizable elements)
+* Sequence - repetition of a motive or theme at a different pitch level
+* Call and Response - leader and congregation (or ensemble) relationship
+* Movement - a macroform of a longer work that stands alone - typically follows a specific form (each period has fomulaic associations)
+Misc terms
+* Ostinato figures - repetitive musical figures often underpinning a melody
+* Dynamics - Indicate gradations of volume (degree of force employed in setting and sustaining a pitch)
+* Duration - The length of time over which a note is maintained or sounded (ratios)
+* Timbre (color) - dictated by the size, shape, materials of an instrument, combination of instruments, or qualities imparted by the player
+Range
+* Terms related to ranges are based upon the Latin and Italian terms for vocal range and function, with four main categories:
+* Soprano
+* Alto
+* Tenor
+* Bass
+Families of Instruments (be able to place each in its family)
+* Woodwinds
+ * Piccolo, flute, oboe, clarinet, bass clarinet, English horn, bassoon, constrabassoon
+* Brass
+ * trumpet, French horn, trombone, bass trombone, tuba
+* Strings
+ * violin, viola, cello, string bass
+* Percussion
+ * snare drum, tambourine, field drum, bass drum, cymbals, triangle, timpani, xylophone, marimba, vibraphone, bells, chimes, etc.
+Others
+* Piano: fullname Pianoforte
+* Guitar: Arabic/Persian roots, flat top, curved back
+* Organ: secular outdoor instrument w/multiple operators, 10th century accepted into the church
+Ensemvles
+* Chorus/Chorale, Chamber Choir
+* Orchestras: String, Chamber (30-50), Pit, Opera, Balllet, Symphony(80-)
+* Concert Bands, Rcock Bands, Jazz Bands
+Historical Periods
+* Middle Ages (Medieval) 400-1450
+* Renaissance 1450-1600
+* Baroque 1600-1750
+* Rococo 1725-1775
+* Classical 1750-1825
+* Romantic 1820-1900
+* Post Romantic & Impressionist 1890-1915
+* Modern (20th Century is Technically 1900-2000)
+Middle Ages/Medieval 400-1450
+* Marked by decline of Roman Empire (Vandals sack Rome in 476)
+* End of period comes with fall of Constantinople to the Turks (1453)
+* At the start of the Medieval period, remnants of Greek & Roman heritage are largely dormant, but will resurface at the end of the period
+* Pope Gregory (590-604)
+* Re-codifes the Ordinary part of the mass and liturgy
+* The Orders - Rules that apply to every mass
+* The Propers - Special functions of the mass
+* Re-organizes the Schola Cantorum (School for Singing) & edits/standardizes plainchant (now called Gregorian Chant)
+* Neumatic System
+
+
|
skalnik/MUSI-3610
|
a992d19546208aa45e08e168d4156e1ebf0610d6
|
Added Syllabus & Concert Report Form
|
diff --git a/Concert Report Form.pdf b/Concert Report Form.pdf
new file mode 100644
index 0000000..24080b3
Binary files /dev/null and b/Concert Report Form.pdf differ
diff --git a/Syllabus.pdf b/Syllabus.pdf
new file mode 100644
index 0000000..b8f8d6b
Binary files /dev/null and b/Syllabus.pdf differ
|
skalnik/MUSI-3610
|
164ee39950ceb7db0fc327c9c60462e5740572a7
|
Another day, another set of notes.
|
diff --git a/Notes/8-31.txt b/Notes/8-31.txt
new file mode 100644
index 0000000..f3da209
--- /dev/null
+++ b/Notes/8-31.txt
@@ -0,0 +1,43 @@
+Music (from the Muses)
+* Muses inspired creativity
+The Muses
+* Kalliope is the eldest of the muses: goddess of song (Kallioph, Kallipeia, Calliope) daughter of Zeus and Titan Goddess Mnemosyne (Goddess of memory & time)
+* Kalliope's son is Orpheus; poet/singer/lyre master & greatest of human musicians.
+* Dionysus overhears Orpheus singing priase to Helios (Sun God sometimes identified as Apollo), Jealous, DIonysus looses the Bakkhantes (women follwers of Dionysus maddened by wine/sensuality) to dismember Orpheus.
+Apollo
+* Son of Zeus
+* God of light, truth, intellect, archery, medicine, music, poetry, and prophetic vision (the oracles).
+* Master of the lyre and kithara (Persian ancestor of guitar)
+"Artistic Polarity"
+* Early implications of spiritual art/music; free will, life's choices, paths or stages ("the ages" of men & women: child, adolescent, maturity, old age).
+* Dionysian: prioritize the emotional, the power of human feelings (the adolescent heart in the moment, passion, youth) and the forces of nature expressed in art.
+* Apllonian: Artistic expression of intellect, form, balance, sophistication, the most elevated expression of the human mind (maturity, beauty, elegance)
+
+Equal Temperament
+* In Pythagorean or Just tuning systems, intervals are derived via ratio 4:3, 5:4, 6:5, etc.
+* In Equal Temperament, each half step interval is esuidistant, derived by geometric esquence (logorhythm)
+* For this course, implications; all 12 tones are equidistant; facilitates modulation, large ensembles.
+More terms related to melody
+* Range - the parameter of a melody (lowest/highest)
+* Shape/Contour - graphic description (waves, arc, rising line)
+* Conjunct/Disjunct - motion by small or large interval
+* Phrase - A significant portion of a melody, described by natural points of tension or rest
+Countermelody
+* Melodies are not always in motion (sustained notes, points of rest etc.) and at these points, another significant melodic idea can grace the main idea
+* Countermelody is a secondary figure; a melody that complements the main melody momentarily (it is not the main idea nor is it a background accompanying figure)
+Rhythm
+* Meter: rhythms organized into repeating patterns of accented and unaccented beats
+* Meters are widely varied, but the most common meters in Western music are 2, 3, 4, 6, 9, 12 beats per measure
+* Meter is indicated by time signature
+Measures
+* Measures or Bars
+* Measure lines or bar lines are veritical markers that assist in fixing the strong accent points graphically
+* Time signature
+* Key signature
+Time Signatures
+* 2/4 2 beats per measure, quarter note gets one beat
+* 3/2 3 beats per measure, half note gets the beat
+* 4/4 4 beats per measure, quarter note gets the beat
+* 5/8 5 beats per measure, eighth note gets the beat
+Conducting patterns
+* Don't feel like typing these and I already know 'em.
|
skalnik/MUSI-3610
|
24fe8f288ca17d52320b8af7be178e31e48e194d
|
Added first day of notes
|
diff --git a/Notes/8-26.txt b/Notes/8-26.txt
new file mode 100644
index 0000000..177ed94
--- /dev/null
+++ b/Notes/8-26.txt
@@ -0,0 +1,45 @@
+Melody
+* Succession of pitches perceived as a whole
+* Variation and development
+* Singable and memorable
+* Melody is often the raison d'etre of a composition; all else follows from the melody
+* In longer works, melodies may be referred to as themes
+What is a Good Melody?
+* Ode to Joy
+* Semi-tones, very singable. Much like children's songs. Easy to sing for the most ignorant among us.
+* Home note is G, last note of the main phrase. Hard to identify, but if changed, very obvious.
+* Second phrase is the same thing, except to the last bar which is slightly different.
+* The third phrase is very different, a bit quicker. It circles the second degree of the scale (G) and ends on the 5th degree
+* Last phrase is the same as the first. It ties this back to the start, using the most memorable part of the entire piece.
+Pitch
+* A specific sound expressed by name and vibrations per second; vibration results in compression of air which we can sense.
+* 12 different pitches represented by 7 letters of the alphabet and use of modifiers; flats & sharps.
+* Pitch names repeat at multiples with sepcific number identifier (ex: 440, 880, 1760 = A4, A5, & A6).
+* C-C#-D-D#-E-F-F#-G-G#-A-A#-B-C1-C#1
+* Some orchestras now tune to 442, and some to even 445.
+* Movies will sometimes increase pitch of the score by almost a quarter tone to brighten the music.
+Interval
+* The distance between 2 pitches
+* Can be expressed specifically (but not in this course)
+* Expressed comparatively (narrow, medium, wide movement in a melody or interval) a goal for students in this course
+* Half steps and whole steps: basic material of modes and scales
+* Melodys have to use a mix of intervals, if they didn't it wouldn't be natural
+Western Roots (Don't need to know)
+* Pythagoras (6th century BC) and Ptolemy (ca. 83-161 AD) observed physical properties of cibrating bodies, such as; halving a string doubles the vps; we perceive (universally) the same "tone or pitch" one octave higher (2:1), 4ths and 5ths (3:2 and 4:32) also observed then other ratios extrapolated
+* Timothesus (ca. 480 BC) musicians epic poem survives of Salamis naval battle (follows Thermopylae), in which Greeks defeat the Persian navy
+* Aristoxenus, in 330 BC made the first (preserved) theoretical references
+* Greek Philosphers associated modes/scales with various emotions, mental states
+* Music associated with the highest sciences, perceived as a gift from the Gods, and used in worship in the Greek cults
+Dionysus
+* Dionysus depicted with satyr (lover?), graphes, panther (nature's unruled strength)
+ * Naturalistic life & philophy
+ * Birth of theatre (relating life lessons)
+ * Sensuality, love, orgiastic worship
+ * Associated with evocative, loud instruments: Aulos
+ * Satrs, nymphs, Pan (pan pipes)
+Aulos
+* Banded to the player's head for support in outdoor processions
+* Two reed instruments played by one player
+* Limited to a few notes
+Music (from the muses)
+* Muses inspired creativity
|
alios/lab
|
cb307ad4c0c3ada1b04bc2cb86ab8840f7f96475
|
implemented greate circle course
|
diff --git a/Geodetic.hs b/Geodetic.hs
index c0114c2..8deed40 100644
--- a/Geodetic.hs
+++ b/Geodetic.hs
@@ -1,246 +1,236 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
---{-# LANGUAGE TypeFamilies #-}
-module Geodatic where
-
-import qualified Prelude
+module Geodetic (
+ GeodeticModel (..),
+ ANS, ans, ans',
+ WGS84, wgs84, wgs84',
+ GRS80, grs80, grs80',
+ GeodeticCoordinate (..), refElipsoid, latitude, longitude, height,
+ ECEF (..), coordX, coordY, coordZ,
+ gcDist,
+ CourseDirection (..),
+ gcCourse,
+ dr
+ ) where
+
+import qualified Prelude ()
import Numeric.Units.Dimensional.TF.Prelude
import Control.Lens hiding (_1, _2, _3, (*~))
+import Data.Typeable
+import Data.Fixed
+
+data GeodeticCoordinate m t =
+ GeodeticCoordinate {
+ _refElipsoid :: !m,
+ _latitude :: !(PlaneAngle t),
+ _longitude :: !(PlaneAngle t),
+ _height :: !(Length t)
+ } deriving (Show, Eq, Typeable)
+makeLenses ''GeodeticCoordinate
-class GeodaticModel m where
+data ECEF t =
+ ECEF {
+ _coordX :: !(Length t),
+ _coordY :: !(Length t),
+ _coordZ :: !(Length t)
+ } deriving (Show, Eq, Typeable)
+makeLenses ''ECEF
+
+data CourseDirection = CourseEast | CourseWest
+ deriving (Show, Eq, Typeable)
+
+class (Eq m, Typeable m) => GeodeticModel m where
semiMajorAxis :: (Fractional t) => m -> Length t
recProcFlattening :: (Fractional t) => m -> Dimensionless t
flattening :: (Fractional t) => m -> Dimensionless t
flattening m = _1 / (recProcFlattening m)
semiMinorAxis :: (Fractional t) => m -> Length t
semiMinorAxis m = (semiMajorAxis m) * (_1 - flattening m)
fstEccentricity :: (Floating t, Fractional t) => m -> Dimensionless t
fstEccentricity m =
let f = flattening m
in (_2 * f) - (f ** _2)
sndEccentricity :: (Floating t, Fractional t) => m -> Dimensionless t
sndEccentricity m =
let f = flattening m
a = f * (_2 - f)
b = ((_1 - f) ** _2)
in a / b
-
-
-data GeodeticCoordinate m t =
- GeodeticCoordinate {
- _refElipsoid :: !m,
- _latitude :: !(PlaneAngle t),
- _longitude :: !(PlaneAngle t),
- _height :: !(Length t)
- } deriving (Show, Eq)
-makeLenses ''GeodeticCoordinate
-
-
-
-data ECEF t =
- ECEF {
- _coordX :: !(Length t),
- _coordY :: !(Length t),
- _coordZ :: !(Length t)
- } deriving (Show, Eq)
-makeLenses ''ECEF
-
-
-
-
-toEcef :: (Floating t, GeodaticModel m) => GeodeticCoordinate m t -> ECEF t
-toEcef c =
- let Ï = _longitude c
- λ = _latitude c
- h = _height c
+ toEcef :: (Floating t) => GeodeticCoordinate m t -> ECEF t
+ toEcef c =
+ let Ï = c ^. longitude
+ λ = c ^. latitude
+ h = c ^. height
e2 = fstEccentricity $ _refElipsoid c
x = sqrt (_1 - (e2 * ((sin Ï) ** _2)))
a = semiMajorAxis $ _refElipsoid c
normal = a / x
normalh = normal + h
rx = normalh * (cos Ï) * (cos λ)
ry = normalh * (cos Ï) * (sin λ)
rz = (((a * ( _1 - e2)) / x) + h) * (sin Ï)
in ECEF rx ry rz
-
-toGeodatic :: (GeodaticModel m, RealFloat t) =>
- m -> ECEF t -> GeodeticCoordinate m t
-toGeodatic m coord =
+ fromEcef :: (RealFloat t) => m -> ECEF t -> GeodeticCoordinate m t
+ fromEcef m coord =
let x = coord ^. coordX
y = coord ^. coordY
z = coord ^. coordZ
a = semiMajorAxis m
b = semiMinorAxis m
e2 = fstEccentricity m
e'2 = sndEccentricity m
r = sqrt ((x * x) + (y * y))
ee2 = (a * a) - (b * b)
f = (54 *~ one) * (b * b) * (z * z)
g = (r * r) + ((_1 - e2) * z * z) - (e2 * e2 * ee2)
c = (e2 * e2 * f * r * r ) / ( g * g * g )
s = cbrt (_1 + c + sqrt ((c*c) + (_2 * c)))
p = f / (_3 * ((s + (_1 / s) + _1) ** _2) * (g * g))
q = sqrt (_1 + (_2 * e2 * e2 * p))
r0a = ((_0 - _1) * (p * e2 * r)) / (_1 + q)
r0b = sqrt ((((_1 / _2) * a * a) * (_1 + (_1 / q)))-
((p * (_1 - e2) * z * z)/(q * (_1 + q))) -
((_1 / _2) * p * r * r))
r0 = r0a + r0b
ub = z * z
ua = (r - (e2 * r0)) * (r - (e2 * r0))
u = sqrt (ua + ub)
v = sqrt (ua + ((_1 - e2) * ub))
z0 = (b * b * z) / (a * v)
h = u * (_1 - ((b * b)/(a * v)))
Ï = atan ((z + (e'2 * z0)) / r)
λ = atan2 y x
in GeodeticCoordinate m λ Ï h
+ geodeticModel :: m
+ fromGeodetic :: (GeodeticModel a, Typeable t, RealFloat t) =>
+ GeodeticCoordinate a t -> GeodeticCoordinate m t
+ fromGeodetic = fromEcef geodeticModel . toEcef
+
+sm :: (Fractional t) => Length t
+sm = 1.852 *~ kilo meter
+
+
+-- | greate circle distance
+gcDist :: (GeodeticModel m, Floating t) => GeodeticCoordinate m t -> GeodeticCoordinate m t -> Length t
+gcDist c1 c2 = c1 `gcDist'` c2
+ where gcDist' (GeodeticCoordinate _ Ï1 λ1 _) (GeodeticCoordinate _ Ï2 λ2 _) =
+ let dλ = abs $ λ1 - λ2
+ a1 = (cos Ï1 * sin dλ)
+ a2 = (cos Ï2 * sin Ï1) - (sin Ï2 * cos Ï1 * cos dλ)
+ a = sqrt ((a1 * a1) + (a2 *a2))
+ b = (sin Ï2 * sin Ï1) + (cos Ï2 * cos Ï1 * cos dλ)
+ dÏ = atan (a / b)
+ r = 6371.01 *~ kilo meter
+ in r * dÏ
+
+-- | greate circle course
+gcCourse :: (Ord t, Real t, Floating t, GeodeticModel a) =>
+ CourseDirection -> GeodeticCoordinate a t -> GeodeticCoordinate a t -> PlaneAngle t
+gcCourse d a b =
+ let jb = b ^. longitude
+ dg = gcDist a b / (1 *~ meter)
+ ja = a ^. longitude
+ ar = ((sin jb) - (cos dg) * (sin ja)) / ((cos ja) * (sin dg))
+ d360 = (360 *~ degree)
+ c = case d of
+ CourseWest -> ar
+ CourseEast -> d360 - ar
+ in ((c /~ degree) `mod'` 360) *~ degree
+
+
+data ANS = ANS deriving (Show, Eq, Typeable)
+instance GeodeticModel ANS where
+ geodeticModel = ANS
+ semiMajorAxis _ = (6378160.0 *~ meter)
+ recProcFlattening _ = (298.25 *~ one)
-
-
-
-
-
-
-
-
-
+ans' :: (Floating t) => PlaneAngle t -> PlaneAngle t -> Length t -> GeodeticCoordinate ANS t
+ans' Ï Î» h = GeodeticCoordinate ANS Ï Î» h
+ans :: (Floating t) => t -> t -> t -> GeodeticCoordinate ANS t
+ans Ï Î» h = ans' (Ï *~ degree) (λ *~ degree) (h *~ meter)
-data ANS = ANS deriving (Show, Eq)
-instance GeodaticModel ANS where
- semiMajorAxis _ = (6378160.0 *~ meter)
- recProcFlattening _ = (298.25 *~ one)
-
-
-data WGS84 = WGS84 deriving (Show, Eq)
-instance GeodaticModel WGS84 where
+data WGS84 = WGS84 deriving (Show, Eq, Typeable)
+instance GeodeticModel WGS84 where
+ geodeticModel = WGS84
semiMajorAxis _ = (6378137.0 *~ meter)
recProcFlattening _ = (298.257223563 *~ one)
+wgs84' :: (Floating t) => PlaneAngle t -> PlaneAngle t -> Length t -> GeodeticCoordinate WGS84 t
wgs84' Ï Î» h = GeodeticCoordinate WGS84 Ï Î» h
-wgs84 Ï Î» h = wgs84'(Ï *~ degree) (λ *~ degree) (h *~ meter)
-
-ms = wgs84 51.969659 7.605286 0
-mse = toEcef ms
-ms2 = toGeodatic WGS84 mse
-
-hh = wgs84 53.543572 10.02502 74
+wgs84 :: (Floating t) => t -> t -> t -> GeodeticCoordinate WGS84 t
+wgs84 Ï Î» h = wgs84'(Ï *~ degree) (λ *~ degree) (h *~ meter)
-data GRS80 = GRS80 deriving (Show, Eq)
-instance GeodaticModel GRS80 where
+data GRS80 = GRS80 deriving (Show, Eq, Typeable)
+instance GeodeticModel GRS80 where
+ geodeticModel = GRS80
semiMajorAxis _ = (6378137.0 *~ meter)
recProcFlattening _ = (298.257222101 *~ one)
+grs80' :: (Floating t) => PlaneAngle t -> PlaneAngle t -> Length t -> GeodeticCoordinate GRS80 t
+grs80' Ï Î» h = GeodeticCoordinate GRS80 Ï Î» h
-{-
+grs80 :: (Floating t) => t -> t -> t -> GeodeticCoordinate GRS80 t
+grs80 Ï Î» h = grs80'(Ï *~ degree) (λ *~ degree) (h *~ meter)
-gcDist :: Coordinate a t -> Coordinate b t -> Length t
-gcDist a@(ECEFCoordinate _ _ _) b@(ECEFCoordinate _ _ _) =
- gcDist (toGeodatic WGS84 a) (toGeodatic WGS84 b)
-gcDist a@(GeodaticCoordinate m _ _ _) b@(ECEFCoordinate _ _ _) =
- gcDist a (toGeodatic m b)
-gcDist a@(ECEFCoordinate _ _ _) b@(GeodaticCoordinate m _ _ _) =
- gcDist (toGeodatic m a) b
-gcDist c1@(GeodaticCoordinate m1 Ï1 λ1 __) c2@(GeodaticCoordinate m2 Ï2 λ2 _)
- | (m1 /= m2) = gcDist c1 (toGeodatic m1 c2)
- | otherwise =
- let dλ = abs $ λ1 - λ2
- a1 = (cos Ï1 * sin dλ)
- a2 = (cos Ï2 * sin Ï1) - (sin Ï2 * cos Ï1 * cos dλ)
- a = sqrt ((a1 * a1) + (a2 *a2))
- b = (sin Ï2 * sin Ï1) + (cos Ï2 * cos Ï1 * cos dλ)
- dÏ = atan (a / b)
- r = 6371.01 *~ kilo meter
- in r * dÏ
+dr :: (Floating t) =>
+ GeodeticCoordinate m t -> Velocity t -> Time t -> PlaneAngle t -> PlaneAngle t --GeodeticCoordinate m t
+dr fix v t a =
+ let l = ((v * t) / sm)
+ in l
+t = dr ms (160 *~ (kilo meter / hour)) (30 *~ minute) (90 *~ degree)
--}
-{-
-ans' Ï Î» h= GeodaticCoordinate ANS Ï Î» h
-ans Ï Î» h = ans' (Ï *~ degree) (λ *~ degree) (h *~ meter)
-grs80' Ï Î» h = GeodaticCoordinate GRS80 Ï Î» h
-grs80 Ï Î» h = grs80' (Ï *~ degree) (λ *~ degree) (h *~ meter)
+msgrs :: GeodeticCoordinate GRS80 Double
+msgrs = fromGeodetic ms
+cmsny = gcCourse CourseWest ms ny
+cmshh = gcCourse CourseEast ms hh
-data Coordinate t where
- GeodaticCoordinate :: (Eq t, Show t, Num t, RealFloat t) =>
- GeodaticModelT ->
- PlaneAngle t->
- PlaneAngle t ->
- Length t ->
- Coordinate t
- ECEFCoordinate :: (Eq t, Show t, Num t, RealFloat t) =>Length t -> Length t -> Length t -> Coordinate t
-
+ms = wgs84 51.969659 7.605286 0
-instance Eq (Coordinate t) where
- (ECEFCoordinate x y z) == (ECEFCoordinate x' y' z') = (x == x') &&
- (y == y') &&
- (z == z')
- a@(GeodaticCoordinate m Ï Î» h) == b@(GeodaticCoordinate m' Ï' λ' h') =
- if (m == m') then (Ï == Ï') && (λ == λ') && (h == h) else
- toGeodatic m b == a
- a == b = toEcef a == toEcef b
+foo = wgs84 51.969659 23.605286 0
---instance Num (Coordinate t) where
-
+mse = toEcef ms
+ms2 = fromEcef WGS84 mse
-instance Show (Coordinate t) where
- show (GeodaticCoordinate m Ï Î» h) = show (m,Ï,λ,h)
- show (ECEFCoordinate x y z) = show (x,y,z)
-
+hh = wgs84 53.543572 10.02502 74
+hhg = grs80 53.543572 10.02502 74
+fa = gcDist ms hh
+fb = gcDist ms $ fromGeodetic hhg
+ny = wgs84 40.43 (-74) 0
-toGeodatic :: GeodaticModelT -> Coordinate t -> Coordinate t
-toGeodatic :: GeodaticModelT -> Coordinate t -> Coordinate t
-toGeodatic tm c@(GeodaticCoordinate m Ï Î» h) =
- if (tm == m) then c else toGeodatic tm (toEcef c)
-toGeodatic tm c@(ECEFCoordinate x y z) =
- let a = semiMajorAxis tm
- b = semiMinorAxis tm
- e2 = fstEccentricity tm
- e'2 = sndEccentricity tm
- r = sqrt ((x * x) + (y * y))
- ee2 = (a * a) - (b * b)
- f = (54 *~ one) * (b * b) * (z * z)
- g = (r * r) + ((_1 - e2) * z * z) - (e2 * e2 * ee2)
- c = (e2 * e2 * f * r * r ) / ( g * g * g )
- s = cbrt (_1 + c + sqrt ((c*c) + (_2 * c)))
- p = f / (_3 * ((s + (_1 / s) + _1) ** _2) * (g * g))
- q = sqrt (_1 + (_2 * e2 * e2 * p))
- r0a = ((_0 - _1) * (p * e2 * r)) / (_1 + q)
- r0b = sqrt ((((_1 / _2) * a * a) * (_1 + (_1 / q)))-
- ((p * (_1 - e2) * z * z)/(q * (_1 + q))) -
- ((_1 / _2) * p * r * r))
- r0 = r0a + r0b
- ub = z * z
- ua = (r - (e2 * r0)) * (r - (e2 * r0))
- u = sqrt (ua + ub)
- v = sqrt (ua + ((_1 - e2) * ub))
- z0 = (b * b * z) / (a * v)
- h = u * (_1 - ((b * b)/(a * v)))
- Ï = atan ((z + (e'2 * z0)) / r)
- λ = atan2 y x
- in GeodaticCoordinate tm Ï Î» h
+d1 = ms ^. latitude - ms2 ^.latitude
+d2 = ms ^. longitude - ms2 ^.longitude
+d3 = ms ^. height - ms2 ^.height
-
+xx = [ wgs84 x y 0 | x <- [0..359] , y <- [-90, 90] ]
+xxx = fmap (fromEcef WGS84 . toEcef) xx
+
+xxxx = zip xx xxx
+
+xd f =
+ let ds = map (\(a,b) -> a ^. f - b ^. f) xxxx
+ in (minimum ds, maximum ds)
+xd1 = xd latitude
+xd2 = xd longitude
+xd3 = xd height
-d1 = wgs84 36.12 (-86.67) 0
-d1a = ans 36.12 (-86.67) 0
-d2 = wgs84 33.94 (-118.40) 0
--}
|
alios/lab
|
2ef27f93eb6a338c52e1e9d821d6abc13d738c0a
|
refactoring
|
diff --git a/Geodatic.hs b/Geodatic.hs
index d2872dd..c0114c2 100644
--- a/Geodatic.hs
+++ b/Geodatic.hs
@@ -1,152 +1,246 @@
-{-# LANGUAGE GADTs, EmptyDataDecls, FlexibleInstances, Rank2Types, FlexibleContexts, TypeSynonymInstances, LiberalTypeSynonyms #-}
+{-# LANGUAGE TemplateHaskell #-}
+--{-# LANGUAGE TypeFamilies #-}
-module Geodatic ( GeodaticModelT(..)
- , ans, grs80, wgs84, ans', grs80', wgs84'
- , toEcef, toGeodatic ) where
+module Geodatic where
import qualified Prelude
-import Numeric.Units.Dimensional.Prelude
-
-data GeodaticModelT where
- ANS :: GeodaticModelT
- GRS80 :: GeodaticModelT
- WGS84 :: GeodaticModelT
- deriving (Eq, Show)
-
-instance GeodaticModel GeodaticModelT where
- semiMajorAxis ANS = (6378160.0 *~ meter)
- semiMajorAxis GRS80 = (6378137.0 *~ meter)
- semiMajorAxis WGS84 = (6378137.0 *~ meter)
- recProcFlattening ANS = (298.25 *~ one)
- recProcFlattening GRS80 = (298.257222101 *~ one)
- recProcFlattening WGS84 = (298.257223563 *~ one)
-
-class (Eq m, Show m) => GeodaticModel m where
+import Numeric.Units.Dimensional.TF.Prelude
+import Control.Lens hiding (_1, _2, _3, (*~))
+
+class GeodaticModel m where
semiMajorAxis :: (Fractional t) => m -> Length t
recProcFlattening :: (Fractional t) => m -> Dimensionless t
flattening :: (Fractional t) => m -> Dimensionless t
flattening m = _1 / (recProcFlattening m)
semiMinorAxis :: (Fractional t) => m -> Length t
semiMinorAxis m = (semiMajorAxis m) * (_1 - flattening m)
fstEccentricity :: (Floating t, Fractional t) => m -> Dimensionless t
fstEccentricity m =
let f = flattening m
in (_2 * f) - (f ** _2)
sndEccentricity :: (Floating t, Fractional t) => m -> Dimensionless t
sndEccentricity m =
let f = flattening m
a = f * (_2 - f)
b = ((_1 - f) ** _2)
in a / b
+
+
+data GeodeticCoordinate m t =
+ GeodeticCoordinate {
+ _refElipsoid :: !m,
+ _latitude :: !(PlaneAngle t),
+ _longitude :: !(PlaneAngle t),
+ _height :: !(Length t)
+ } deriving (Show, Eq)
+makeLenses ''GeodeticCoordinate
+
+
+
+data ECEF t =
+ ECEF {
+ _coordX :: !(Length t),
+ _coordY :: !(Length t),
+ _coordZ :: !(Length t)
+ } deriving (Show, Eq)
+makeLenses ''ECEF
+
+
+
+
+toEcef :: (Floating t, GeodaticModel m) => GeodeticCoordinate m t -> ECEF t
+toEcef c =
+ let Ï = _longitude c
+ λ = _latitude c
+ h = _height c
+ e2 = fstEccentricity $ _refElipsoid c
+ x = sqrt (_1 - (e2 * ((sin Ï) ** _2)))
+ a = semiMajorAxis $ _refElipsoid c
+ normal = a / x
+ normalh = normal + h
+ rx = normalh * (cos Ï) * (cos λ)
+ ry = normalh * (cos Ï) * (sin λ)
+ rz = (((a * ( _1 - e2)) / x) + h) * (sin Ï)
+ in ECEF rx ry rz
+
+toGeodatic :: (GeodaticModel m, RealFloat t) =>
+ m -> ECEF t -> GeodeticCoordinate m t
+toGeodatic m coord =
+ let x = coord ^. coordX
+ y = coord ^. coordY
+ z = coord ^. coordZ
+ a = semiMajorAxis m
+ b = semiMinorAxis m
+ e2 = fstEccentricity m
+ e'2 = sndEccentricity m
+ r = sqrt ((x * x) + (y * y))
+ ee2 = (a * a) - (b * b)
+ f = (54 *~ one) * (b * b) * (z * z)
+ g = (r * r) + ((_1 - e2) * z * z) - (e2 * e2 * ee2)
+ c = (e2 * e2 * f * r * r ) / ( g * g * g )
+ s = cbrt (_1 + c + sqrt ((c*c) + (_2 * c)))
+ p = f / (_3 * ((s + (_1 / s) + _1) ** _2) * (g * g))
+ q = sqrt (_1 + (_2 * e2 * e2 * p))
+ r0a = ((_0 - _1) * (p * e2 * r)) / (_1 + q)
+ r0b = sqrt ((((_1 / _2) * a * a) * (_1 + (_1 / q)))-
+ ((p * (_1 - e2) * z * z)/(q * (_1 + q))) -
+ ((_1 / _2) * p * r * r))
+ r0 = r0a + r0b
+ ub = z * z
+ ua = (r - (e2 * r0)) * (r - (e2 * r0))
+ u = sqrt (ua + ub)
+ v = sqrt (ua + ((_1 - e2) * ub))
+ z0 = (b * b * z) / (a * v)
+ h = u * (_1 - ((b * b)/(a * v)))
+ Ï = atan ((z + (e'2 * z0)) / r)
+ λ = atan2 y x
+ in GeodeticCoordinate m λ Ï h
+
+
+
+
+
+
+
+
+
+
+
+
+
+data ANS = ANS deriving (Show, Eq)
+instance GeodaticModel ANS where
+ semiMajorAxis _ = (6378160.0 *~ meter)
+ recProcFlattening _ = (298.25 *~ one)
+
+
+data WGS84 = WGS84 deriving (Show, Eq)
+instance GeodaticModel WGS84 where
+ semiMajorAxis _ = (6378137.0 *~ meter)
+ recProcFlattening _ = (298.257223563 *~ one)
+
+wgs84' Ï Î» h = GeodeticCoordinate WGS84 Ï Î» h
+wgs84 Ï Î» h = wgs84'(Ï *~ degree) (λ *~ degree) (h *~ meter)
+
+ms = wgs84 51.969659 7.605286 0
+mse = toEcef ms
+ms2 = toGeodatic WGS84 mse
+
+hh = wgs84 53.543572 10.02502 74
+
+
+data GRS80 = GRS80 deriving (Show, Eq)
+
+instance GeodaticModel GRS80 where
+ semiMajorAxis _ = (6378137.0 *~ meter)
+ recProcFlattening _ = (298.257222101 *~ one)
+
+
+{-
+
+gcDist :: Coordinate a t -> Coordinate b t -> Length t
+gcDist a@(ECEFCoordinate _ _ _) b@(ECEFCoordinate _ _ _) =
+ gcDist (toGeodatic WGS84 a) (toGeodatic WGS84 b)
+gcDist a@(GeodaticCoordinate m _ _ _) b@(ECEFCoordinate _ _ _) =
+ gcDist a (toGeodatic m b)
+gcDist a@(ECEFCoordinate _ _ _) b@(GeodaticCoordinate m _ _ _) =
+ gcDist (toGeodatic m a) b
+gcDist c1@(GeodaticCoordinate m1 Ï1 λ1 __) c2@(GeodaticCoordinate m2 Ï2 λ2 _)
+ | (m1 /= m2) = gcDist c1 (toGeodatic m1 c2)
+ | otherwise =
+ let dλ = abs $ λ1 - λ2
+ a1 = (cos Ï1 * sin dλ)
+ a2 = (cos Ï2 * sin Ï1) - (sin Ï2 * cos Ï1 * cos dλ)
+ a = sqrt ((a1 * a1) + (a2 *a2))
+ b = (sin Ï2 * sin Ï1) + (cos Ï2 * cos Ï1 * cos dλ)
+ dÏ = atan (a / b)
+ r = 6371.01 *~ kilo meter
+ in r * dÏ
+
+
+
+
+-}
+
+{-
+ans' Ï Î» h= GeodaticCoordinate ANS Ï Î» h
+ans Ï Î» h = ans' (Ï *~ degree) (λ *~ degree) (h *~ meter)
+
+grs80' Ï Î» h = GeodaticCoordinate GRS80 Ï Î» h
+grs80 Ï Î» h = grs80' (Ï *~ degree) (λ *~ degree) (h *~ meter)
+
+
+
+
data Coordinate t where
GeodaticCoordinate :: (Eq t, Show t, Num t, RealFloat t) =>
GeodaticModelT ->
PlaneAngle t->
PlaneAngle t ->
Length t ->
Coordinate t
ECEFCoordinate :: (Eq t, Show t, Num t, RealFloat t) =>Length t -> Length t -> Length t -> Coordinate t
-
instance Eq (Coordinate t) where
(ECEFCoordinate x y z) == (ECEFCoordinate x' y' z') = (x == x') &&
(y == y') &&
(z == z')
a@(GeodaticCoordinate m Ï Î» h) == b@(GeodaticCoordinate m' Ï' λ' h') =
if (m == m') then (Ï == Ï') && (λ == λ') && (h == h) else
toGeodatic m b == a
a == b = toEcef a == toEcef b
--instance Num (Coordinate t) where
instance Show (Coordinate t) where
show (GeodaticCoordinate m Ï Î» h) = show (m,Ï,λ,h)
show (ECEFCoordinate x y z) = show (x,y,z)
-ans' Ï Î» h= GeodaticCoordinate ANS Ï Î» h
-ans Ï Î» h = ans' (Ï *~ degree) (λ *~ degree) (h *~ meter)
-grs80' Ï Î» h = GeodaticCoordinate GRS80 Ï Î» h
-grs80 Ï Î» h = grs80' (Ï *~ degree) (λ *~ degree) (h *~ meter)
-
-wgs84' Ï Î» h = GeodaticCoordinate WGS84 Ï Î» h
-wgs84 Ï Î» h = wgs84'(Ï *~ degree) (λ *~ degree) (h *~ meter)
-
-toEcef :: Coordinate t -> Coordinate t
-toEcef c@(ECEFCoordinate _ _ _) = c
-toEcef (GeodaticCoordinate m Ï Î» h) =
- let e2 = fstEccentricity m
- x = sqrt (_1 - (e2 * ((sin Ï) ** _2)))
- a = semiMajorAxis m
- normal = a / x
- normalh = normal + h
- rx = normalh * (cos Ï) * (cos λ)
- ry = normalh * (cos Ï) * (sin λ)
- rz = (((a * ( _1 - e2)) / x) + h) * (sin Ï)
- in ECEFCoordinate rx ry rz
-
+toGeodatic :: GeodaticModelT -> Coordinate t -> Coordinate t
toGeodatic :: GeodaticModelT -> Coordinate t -> Coordinate t
toGeodatic tm c@(GeodaticCoordinate m Ï Î» h) =
if (tm == m) then c else toGeodatic tm (toEcef c)
toGeodatic tm c@(ECEFCoordinate x y z) =
let a = semiMajorAxis tm
b = semiMinorAxis tm
e2 = fstEccentricity tm
e'2 = sndEccentricity tm
r = sqrt ((x * x) + (y * y))
ee2 = (a * a) - (b * b)
f = (54 *~ one) * (b * b) * (z * z)
g = (r * r) + ((_1 - e2) * z * z) - (e2 * e2 * ee2)
c = (e2 * e2 * f * r * r ) / ( g * g * g )
s = cbrt (_1 + c + sqrt ((c*c) + (_2 * c)))
p = f / (_3 * ((s + (_1 / s) + _1) ** _2) * (g * g))
q = sqrt (_1 + (_2 * e2 * e2 * p))
r0a = ((_0 - _1) * (p * e2 * r)) / (_1 + q)
r0b = sqrt ((((_1 / _2) * a * a) * (_1 + (_1 / q)))-
((p * (_1 - e2) * z * z)/(q * (_1 + q))) -
((_1 / _2) * p * r * r))
r0 = r0a + r0b
ub = z * z
ua = (r - (e2 * r0)) * (r - (e2 * r0))
u = sqrt (ua + ub)
v = sqrt (ua + ((_1 - e2) * ub))
z0 = (b * b * z) / (a * v)
h = u * (_1 - ((b * b)/(a * v)))
Ï = atan ((z + (e'2 * z0)) / r)
λ = atan2 y x
in GeodaticCoordinate tm Ï Î» h
-gcDist :: Coordinate t -> Coordinate t -> Length t
-gcDist a@(ECEFCoordinate _ _ _) b@(ECEFCoordinate _ _ _) =
- gcDist (toGeodatic WGS84 a) (toGeodatic WGS84 b)
-gcDist a@(GeodaticCoordinate m _ _ _) b@(ECEFCoordinate _ _ _) =
- gcDist a (toGeodatic m b)
-gcDist a@(ECEFCoordinate _ _ _) b@(GeodaticCoordinate m _ _ _) =
- gcDist (toGeodatic m a) b
-gcDist c1@(GeodaticCoordinate m1 Ï1 λ1 __) c2@(GeodaticCoordinate m2 Ï2 λ2 _)
- | (m1 /= m2) = gcDist c1 (toGeodatic m1 c2)
- | otherwise =
- let dλ = abs $ λ1 - λ2
- a1 = (cos Ï1 * sin dλ)
- a2 = (cos Ï2 * sin Ï1) - (sin Ï2 * cos Ï1 * cos dλ)
- a = sqrt ((a1 * a1) + (a2 *a2))
- b = (sin Ï2 * sin Ï1) + (cos Ï2 * cos Ï1 * cos dλ)
- dÏ = atan (a / b)
- r = 6371.01 *~ kilo meter
- in r * dÏ
-ms = wgs84 51.969659 7.605286 0
-hh = wgs84 53.543572 10.02502 0
d1 = wgs84 36.12 (-86.67) 0
d1a = ans 36.12 (-86.67) 0
d2 = wgs84 33.94 (-118.40) 0
+-}
|
alios/lab
|
2de5bfc0dfee353160eb1d2a16b17e9a82b01635
|
added solskens ba script thing
|
diff --git a/solske_ba.hs b/solske_ba.hs
new file mode 100644
index 0000000..36692d7
--- /dev/null
+++ b/solske_ba.hs
@@ -0,0 +1,269 @@
+import Data.List
+import qualified Data.Map as M
+
+
+a = M.fromList $ m [
+ ("q8",0.216),
+ ("q6_d",0.202),
+ ("Branche",0.191),
+ ("g4",0.170),
+ ("q2_b",0.168),
+ ("g1",0.146),
+ ("Geschlecht",0.129),
+ ("g2",0.129),
+ ("q5",0.126),
+ ("q6_c",0.113),
+ ("q6_e",0.109),
+ ("q2_d",0.107),
+ ("g5",0.092),
+ ("q4c2",0.088),
+ ("q4c1",0.083),
+ ("q7_a",0.083),
+ ("q7_d",0.075),
+ ("q7_f",0.071),
+ ("q7_c",0.069),
+ ("q7_g",0.069),
+ ("q4c4",0.066),
+ ("q4c10",0.058)
+ ]
+
+b = M.fromList $ m [
+ ("q2_b",0.129),
+ ("g1",0.123),
+ ("q6_d",0.122),
+ ("q8",0.120),
+ ("s10",0.120),
+ ("g4",0.098),
+ ("q2_d",0.098),
+ ("q9",0.096),
+ ("q4c2",0.091),
+ ("g2",0.078),
+ ("Geschlecht",0.071),
+ ("g5",0.064),
+ ("q4c1",0.058),
+ ("q7_d",0.058),
+ ("q5",0.055)]
+
+
+c = M.fromList $ m [
+ ("q8",0.173),
+ ("Branche",0.170),
+ ("g1",0.167),
+ ("q4c1",0.158),
+ ("s10",0.154),
+ ("q7_c",0.143),
+ ("s6",0.124),
+ ("q9",0.115),
+ ("q7_d",0.113),
+ ("q6_c",0.112),
+ ("g5",0.103),
+ ("s5",0.102),
+ ("g4",0.089),
+ ("g2",0.078),
+ ("g3",0.075),
+ ("q4c8",0.072),
+ ("q7_a",0.069),
+ ("q2_f",0.068),
+ ("q7_f",0.068),
+ ("q4c2",0.064),
+ ("q4c3",0.064),
+ ("s4",0.059),
+ ("q2_a",0.057),
+ ("q2_e",0.052)]
+
+d = M.fromList $ m [
+ ("s8",0.328),
+ ("g4",0.308),
+ ("q6_d",0.252),
+ ("q12",0.249),
+ ("q4c1",0.216),
+ ("q6_c",0.195),
+ ("q8",0.191),
+ ("Familienst.",0.160),
+ ("g1",0.160),
+ ("g5",0.157),
+ ("q6_a",0.153),
+ ("Branche",0.153),
+ ("q7_c",0.150),
+ ("q6_e",0.146),
+ ("g2",0.141),
+ ("q2_a",0.133),
+ ("q4c3",0.129),
+ ("s5",0.120),
+ ("q4c10",0.110),
+ ("q4c4",0.099),
+ ("q9",0.095),
+ ("Geschlecht",0.093),
+ ("q7_d",0.093),
+ ("q7_a",0.088),
+ ("q2_d",0.083),
+ ("q4c11",0.083),
+ ("q5",0.082),
+ ("q4c8",0.081),
+ ("q2_b",0.075),
+ ("q13",0.074),
+ ("q7_f",0.071),
+ ("q7_g",0.065),
+ ("q2_c",0.062),
+ ("q7_e",0.055)]
+
+e = M.fromList $ m [
+ ("Familienst.",0.195),
+ ("g1",0.187),
+ ("g2",0.171),
+ ("g4",0.171),
+ ("Alter",0.165),
+ ("q8",0.158),
+ ("q6_d",0.154),
+ ("q6_c",0.151),
+ ("s5",0.143),
+ ("q4c1",0.143),
+ ("q6_e2",0.141),
+ ("q7_c",0.137),
+ ("Branche",0.134),
+ ("s6",0.119),
+ ("g5",0.115),
+ ("Geschlecht",0.105),
+ ("q7_e",0.092),
+ ("g3",0.086),
+ ("q2_e",0.086),
+ ("q7_g",0.083),
+ ("q4c4",0.082),
+ ("q7_d",0.071),
+ ("q4c8",0.069),
+ ("q4c3",0.066) ]
+
+f = M.fromList $ m [
+ ("g4",0.356),
+ ("s8",0.349),
+ ("g1",0.307),
+ ("q4c1",0.264),
+ ("q6_d",0.259),
+ ("g5",0.252),
+ ("g2",0.246),
+ ("q8",0.212),
+ ("q6_c",0.197),
+ ("g3",0.191),
+ ("q7_c",0.191),
+ ("q7_d",0.190),
+ ("Branche",0.154),
+ ("Alter",0.143),
+ ("s10",0.129),
+ ("q7_g",0.127),
+ ("q4c3",0.124),
+ ("q7_f",0.124),
+ ("s6",0.123),
+ ("q7_e",0.119),
+ ("q7_a",0.116),
+ ("Familienst.",0.112),
+ ("s5",0.112),
+ ("q10",0.112),
+ ("q9",0.099),
+ ("q4c4",0.096),
+ ("q2_c",0.091),
+ ("q7_b",0.091),
+ ("q2_d",0.079),
+ ("q5",0.076),
+ ("q4c10",0.072),
+ ("q2_e",0.057)]
+
+g = M.fromList $ m [
+ ("q6_c",0.387),
+ ("q6_d",0.362),
+ ("q4c1",0.324),
+ ("g4",0.300),
+ ("g1",0.263),
+ ("g2",0.256),
+ ("q8",0.255),
+ ("g5",0.232),
+ ("q7_c",0.226),
+ ("q6_a",0.218),
+ ("Alter",0.204),
+ ("q4c3",0.190),
+ ("Familienst.",0.188),
+ ("q7_d",0.181),
+ ("s5",0.180),
+ ("g3",0.170),
+ ("q4c4",0.170),
+ ("q2_b",0.163),
+ ("q2_a",0.151),
+ ("q7_g",0.146),
+ ("q7_a",0.139),
+ ("q7_f",0.137),
+ ("q2_d",0.136),
+ ("q2_c",0.133),
+ ("Geschlecht",0.129),
+ ("q7_e",0.124),
+ ("q5",0.123),
+ ("q4c10",0.122),
+ ("q4c2",0.120),
+ ("q4c9",0.109)]
+
+m :: [(String, Double) ] -> [(String, Double)]
+m xs = m' (fromInteger.toInteger $ vcount) xs
+m' _ [] = []
+m' c ((k,v):xs) = (k, v * c) : m' (c - 1) xs
+
+
+va = [a,b,c]
+vb = [d,e,f]
+vc = [g]
+
+alll = [a,b,c] ++ [d,e,f] ++ [g]
+
+un = foldl M.union M.empty alll
+
+
+allvars = map fst $ M.toList un
+{-
+allvars:
+["Alter","Branche","Familienst.","Geschlecht","g1","g2","g3","g4","g5","q10","q12","q13","q2_a","q2_b","q2_c","q2_d","q2_e","q2_f","q4c1","q4c10","q4c11","q4c2","q4c3","q4c4","q4c8","q4c9","q5","q6_a","q6_c","q6_d","q6_e","q6_e2","q7_a","q7_b","q7_c","q7_d","q7_e","q7_f","q7_g","q8","q9","s10","s4","s5","s6","s8"]
+-}
+
+vcount = length allvars
+{-
+vcount: 46
+-}
+
+findv xs k = case (M.lookup xs k) of
+ Nothing -> 0.0
+ Just v -> v
+
+findvmaps k = ((sum $ map (findv k) va) * fa) +
+ ((sum $ map (findv k) vb) * fb) +
+ ((sum $ map (findv k) vc) * fc)
+
+
+-- faktor gruppe 1 (q3_a-c)
+fa = 1.0
+-- faktor gruppe 2 (q3_d-f)
+fb = 1.5
+-- faktor für c
+fc = 2
+
+allvarvals = sortBy (\(_,a) (_,b) -> compare a b) [ (k, findvmaps k) | k <- allvars]
+
+{-
+
+Ergebniss von allvarvals:
+
+[("s4",1.4749999999999999),("q13",1.887),("q2_f",1.9720000000000002),("q7_b",2.5934999999999997),("q4c11",2.6145),("q4c9",3.706),("q10",3.864),("q2_e",6.0905),("q4c8",7.0245),("q6_e2",7.613999999999999),("q2_c",10.15),("q6_e",11.151),("q4c2",12.41),("q4c10",12.434000000000001),("q9",15.201),("q7_e",15.24),("q5",15.866000000000001),("q2_a",16.008499999999998),("s6",16.0165),("q12",16.0605),("s10",17.7),("q7_f",17.911),("q2_d",19.064999999999998),("q7_a",19.431),("q7_g",20.4765),("Geschlecht",21.762),("q4c4",22.1475),("q6_a",24.394000000000002),("q2_b",24.469),("g3",27.2815),("q4c3",28.626),("Alter",32.161500000000004),("s5",32.492999999999995),("q7_d",36.3895),("Branche",38.7745),("Familienst.",39.799),("s8",46.189499999999995),("q7_c",50.127500000000005),("g5",56.90350000000001),("g2",64.297),("q6_c",75.984),("q8",77.03299999999999),("q4c1",78.5065),("g1",82.9655),("q6_d",89.227),("g4",96.5375)]
+
+-}
+
+
+allvarvals2 = [(k, nor v) | (k,v) <- allvarvals]
+
+nor x = (x - xmin) / ( xmax - xmin)
+ where vs = map snd allvarvals
+ xmin = minimum vs
+ xmax = maximum vs
+
+{-
+allvarvals2
+
+[("s4",0.0),("q13",4.333990795529258e-3),("q2_f",5.228139381985539e-3),("q7_b",1.1765943458251148e-2),("q4c11",1.1986850756081528e-2),("q4c9",2.3468770545693622e-2),("q10",2.5130834976988824e-2),("q2_e",4.855226824457594e-2),("q4c8",5.8377383300460224e-2),("q6_e2",6.457856673241288e-2),("q2_c",9.125575279421434e-2),("q6_e",0.10178566732412886),("q4c2",0.11502958579881657),("q4c10",0.1152820512820513),("q9",0.14438921761998685),("q7_e",0.14479947403024326),("q5",0.1513846153846154),("q2_a",0.15288362919132148),("s6",0.15296778435239974),("q12",0.15343063773833007),("s10",0.17067718606180143),("q7_f",0.17289677843523998),("q2_d",0.18503616042077575),("q7_a",0.1888862590401052),("q7_g",0.19988428665351743),("Geschlecht",0.21340696909927678),("q4c4",0.2174621959237344),("q6_a",0.2410940170940171),("q2_b",0.24188297172912557),("g3",0.2714687705456936),("q4c3",0.285612097304405),("Alter",0.32280341880341884),("s5",0.3262905982905982),("q7_d",0.36727942143326753),("Branche",0.3923681788297173),("Familienst.",0.4031452991452991),("s8",0.4703694937541091),("q7_c",0.5117948717948718),("g5",0.5830742932281394),("g2",0.6608494411571334),("q6_c",0.7837896120973044),("q8",0.7948244575936882),("q4c1",0.8103247863247864),("g1",0.8572307692307694),("q6_d",0.9230979618671927),("g4",1.0)]
+
+-}
+
+
|
alios/lab
|
bffc2c5590917603c5ef193693fe4da2a4dc81d0
|
fixed pixel2coord
|
diff --git a/game/html/hexmap.pde b/game/html/hexmap.pde
index a01b0dc..ec8e4cb 100644
--- a/game/html/hexmap.pde
+++ b/game/html/hexmap.pde
@@ -1,279 +1,280 @@
Map m;
PVector dragvector = null;
void setup() {
size(800, 600, P3D);
println("h = " + Hexagon.h);
println("r = " + Hexagon.r);
println("a = " + Hexagon.a);
println("b = " + Hexagon.b);
- m = new Map(40,40);
+ m = new Map(100,100);
noLoop();
redraw();
}
void mouseClicked() {
switch (mouseButton) {
case 37:
println(m.point2coord(mouseX, mouseY));
break;
default:
println("unhandled mousePressed(): " + mouseButton);
break;
}
}
void mousePressed() {
switch (mouseButton) {
case 37: // left click
dragvector = new PVector(mouseX, mouseY);
break;
default:
println("unhandled mousePressed(): " + mouseButton);
break;
}
}
void mouseReleased() {
switch (mouseButton) {
case 37: // left click
if (dragvector != null) {
PVector v = new PVector(mouseX, mouseY);
v.sub(dragvector);
v.div(m.ms);
m.scroll(v.x, v.y);
}
dragvector = null;
break;
default:
println("unhandled mouseReleased(): " + mouseButton);
break;
}
}
void keyTyped() {
switch (int(key)) {
case 43: // +
m.incZoom();
break;
case 45: // -
m.decZoom();
break;
case 97: // a
m.scrollLeft();
break;
case 100: // d
m.scrollRight();
break;
case 119: // w
m.scrollUp();
break;
case 115: // s
m.scrollDown();
break;
default:
println("unhandled keyTyped(): " + int(key));
break;
}
}
void draw() {
background(153);
m.display();
}
class Map
{
ArrayList hexagons;
double mx = 0;
double my = 0;
double ms = 16;
Map(int nx, int ny) {
hexagons = new ArrayList();
for (int x = 0; x < nx; ++x) {
for (int y = 0; y < ny; ++y) {
hexagons.add(new Hexagon(x,y));
}
}
}
PVector point2coord (float x, float y) {
-
- double _x = (x/ms) - mx;
- double _y = (y/ms) - my;
-
- int ay = int(_y / Hexagon.b);
- _x = ((ay % 2) == 0) ? _x : _x - Hexagon.r;
- int ax = int(_x / Hexagon.a);
-
- double lx = _x - (ax * Hexagon.a);
- double ly = _y - (ay * Hexagon.b);
+
+ double xpixel = (x/ms) - mx;
+ double ypixel = (y/ms) - my;
- int d = 0;
+ int xsection = int(xpixel / ( 2 * Hexagon.r ));
+ int ysection = int(ypixel / ( Hexagon.h + 1 ));
+
+ double xsectpxl = xpixel - xsection * ( 2 * Hexagon.r );
+ double ysectpxl = ypixel - ysection * ( Hexagon.h + 1 );
- if (lx < Hexagon.r) {
- double _h1 = (Hexagon.r - lx) / Hexagon.h;
- if (ly <= _h1) {
- d = Hexagon.DIR_NW
+ PVector retVal = new PVector(xsection, ysection);
+ double m = Hexagon.h / Hexagon.r;
+
+ if ((ysection % 2) == 0) {
+ if (ysectpxl < (Hexagon.h - xsectpxl * m)) {
+ retVal = new PVector(retVal.x -1 , retVal.y - 1);
}
- if (ly > (Hexagon.b - _h1)) {
- d = Hexagon.DIR_SW;
+ if (ysectpxl < (- Hexagon.h + xsectpxl * m)) {
+ retVal = new PVector(retVal.x , retVal.y - 1);
}
} else {
- double _h2 = (Hexagon.a - lx) / Hexagon.h;
- if (ly <= _h2) {
- d = Hexagon.DIR_NE;
+ if (xsectpxl >= Hexagon.r) {
+ if (ysectpxl < (2 * Hexagon.h - xsectpxl * m)) {
+ retVal = new PVector(retVal.x , retVal.y - 1);
+ }
}
-
- if (ly > (Hexagon.b - _h2)) {
- d = Hexagon.DIR_SE;
- }
- }
-
- PVector retVal = new PVector(ax, ay);
- if (d) {
- retVal = Hexagon.dirCoord(retVal, d);
+ if(xsectpxl < Hexagon.r) {
+ if (ysectpxl < (xsectpxl * m)) {
+ retVal = new PVector(retVal.x, retVal.y - 1);
+ } else {
+ retVal = new PVector(retVal.x -1 , retVal.y);
+ }
+ }
}
-
+
return retVal;
}
-
-
+
+
void scroll(double x, double y) {
mx += x;
my += y;
redraw();
}
void incZoom() {
ms *= 2;
redraw();
}
void decZoom() {
ms /= 2;
redraw();
}
void scrollLeft() {
mx -= 4 * Hexagon.a;
redraw();
}
void scrollRight() {
mx += 4 * Hexagon.a;
redraw();
}
void scrollUp() {
my -= 4 * Hexagon.b;
redraw();
}
void scrollDown() {
my += 4 * Hexagon.b;
redraw();
}
void display() {
pushMatrix();
-
// do zoom
scale(ms);
// translate
translate(mx, my);
-
+
+ mmin = point2coord(0,0);
+ mmax = point2coord(width, height);
+
// draw hexagon
+ int c = 0;
for (int i = 0; i < hexagons.size(); ++i) {
- Hexagon h = (Hexagon) hexagons.get(i);
- h.display();
- }
-
-
+ Hexagon h = (Hexagon) hexagons.get(i);
+ if ((h.hx >= mmin.x) && (h.hx <= mmax.x) &&
+ (h.hy >= mmin.y) && (h.hy <= mmax.y)) {
+ h.display();
+ c++
+ }
+ }
popMatrix();
}
}
class Hexagon
{
static int DIR_NW = 1;
static int DIR_NE = 2;
static int DIR_E = 3;
static int DIR_SE = 4;
static int DIR_SW = 5;
static int DIR_W = 6;
static double h = sin (radians(30));
static double r = cos (radians(30));
static double a = 2 * r;
static double b = 2 * h + 1;
static PVector dirCoord(PVector v, int d)
{
switch (d) {
case DIR_NW:
return new PVector(v.x, v.y -1);
case DIR_NE:
return new PVector(v.x + 1, v.y -1);
case DIR_E:
return new PVector(v.x + 1, v.y);
case DIR_SE:
return new PVector(v.x, v.y + 1);
case DIR_SW:
return new PVector(v.x - 1, v.y + 1);
case DIR_W:
return new PVector(v.x - 1, v.y);
-
default:
return null;
-
}
}
int hx, hy;
double dx, dy;
Hexagon(int x, int y) {
hx = x;
hy = y;
dx = hx * a;
dy = hy * (h + 1);
if (hy % 2 != 0) {
dx += r;
}
}
void display() {
pushMatrix();
translate(dx, dy);
stroke(1);
smooth();
beginShape();
vertex(0, h);
vertex(r, 0);
vertex(a, h);
vertex(a, h + 1);
vertex(r, b);
vertex(0, h + 1);
endShape();
popMatrix();
}
}
|
alios/lab
|
49ca02ab446341247e10f6e01b133cd0f4149383
|
pixel2coord, scrolling, zooming working
|
diff --git a/game/html/chart.html b/game/html/chart.html
index ef6e2cc..dd5c630 100644
--- a/game/html/chart.html
+++ b/game/html/chart.html
@@ -1,68 +1,68 @@
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<script src="js/libs/modernizr-2.0.6.min.js"></script>
<script src="js/jquery-1.7.1.min.js"></script>
<!--
<script src="js/libs/easel.js"></script>
<script src="js/libs/Touch.js"></script>
<script src="js/script.js"></script>
-->
</head>
-<body onload="">
+<body onload="" oncontextmenu="return false;">
<div id="container">
<header>
</header>
<div id="main" role="main" style="background-color: #000000;">
<script src="js/libs/processing-1.3.6.js"></script>
<canvas width="800" height="600" data-processing-sources="hexmap.pde"></canvas>
<!--
<canvas id="map" width="1024" height="768"></canvas>
<div id="infocontainer">
<h2> Info </h2>
<div id="info">
...
</div>
</div>
-->
</div>
<footer>
</footer>
</div> <!--! end of #container -->
<!-- scripts concatenated and minified via ant build script-->
<script src="js/plugins.js"></script>
<!-- end scripts-->
<!--[if lt IE 7 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"></script>
<script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})})</script>
<![endif]-->
</body>
</html>
diff --git a/game/html/hexmap.pde b/game/html/hexmap.pde
index 4c1b65a..a01b0dc 100644
--- a/game/html/hexmap.pde
+++ b/game/html/hexmap.pde
@@ -1,151 +1,279 @@
-
-double h = sin (radians(30));
-double r = cos (radians(30));
-
-double a = 2 * r;
-double b = 2 * h + 1;
-
-
Map m;
+PVector dragvector = null;
void setup() {
- // size(screen.width, screen.height, P3D);
size(800, 600, P3D);
- m = new Map(26,26);
+ println("h = " + Hexagon.h);
+ println("r = " + Hexagon.r);
+ println("a = " + Hexagon.a);
+ println("b = " + Hexagon.b);
+
+ m = new Map(40,40);
noLoop();
redraw();
}
+
+void mouseClicked() {
+ switch (mouseButton) {
+ case 37:
+ println(m.point2coord(mouseX, mouseY));
+ break;
+ default:
+ println("unhandled mousePressed(): " + mouseButton);
+ break;
+ }
+
+}
+
+void mousePressed() {
+ switch (mouseButton) {
+ case 37: // left click
+ dragvector = new PVector(mouseX, mouseY);
+ break;
+
+ default:
+ println("unhandled mousePressed(): " + mouseButton);
+ break;
+ }
+}
+
+void mouseReleased() {
+ switch (mouseButton) {
+ case 37: // left click
+ if (dragvector != null) {
+ PVector v = new PVector(mouseX, mouseY);
+ v.sub(dragvector);
+ v.div(m.ms);
+ m.scroll(v.x, v.y);
+ }
+ dragvector = null;
+ break;
+
+ default:
+ println("unhandled mouseReleased(): " + mouseButton);
+ break;
+ }
+}
+
+
void keyTyped() {
switch (int(key)) {
case 43: // +
m.incZoom();
break;
case 45: // -
m.decZoom();
break;
case 97: // a
m.scrollLeft();
break;
case 100: // d
m.scrollRight();
break;
case 119: // w
m.scrollUp();
break;
case 115: // s
m.scrollDown();
break;
+ default:
+ println("unhandled keyTyped(): " + int(key));
+ break;
}
}
void draw() {
background(153);
m.display();
}
class Map
{
ArrayList hexagons;
double mx = 0;
double my = 0;
- double ms = 1;
+ double ms = 16;
+
Map(int nx, int ny) {
- mx = width / 2 - nx / 2;
- my = height / 2 - ny / 2;
hexagons = new ArrayList();
for (int x = 0; x < nx; ++x) {
for (int y = 0; y < ny; ++y) {
hexagons.add(new Hexagon(x,y));
}
}
}
+
+ PVector point2coord (float x, float y) {
+
+ double _x = (x/ms) - mx;
+ double _y = (y/ms) - my;
+
+ int ay = int(_y / Hexagon.b);
+ _x = ((ay % 2) == 0) ? _x : _x - Hexagon.r;
+ int ax = int(_x / Hexagon.a);
+
+ double lx = _x - (ax * Hexagon.a);
+ double ly = _y - (ay * Hexagon.b);
+
+ int d = 0;
+
+ if (lx < Hexagon.r) {
+ double _h1 = (Hexagon.r - lx) / Hexagon.h;
+ if (ly <= _h1) {
+ d = Hexagon.DIR_NW
+ }
+
+ if (ly > (Hexagon.b - _h1)) {
+ d = Hexagon.DIR_SW;
+ }
+ } else {
+ double _h2 = (Hexagon.a - lx) / Hexagon.h;
+ if (ly <= _h2) {
+ d = Hexagon.DIR_NE;
+ }
+
+ if (ly > (Hexagon.b - _h2)) {
+ d = Hexagon.DIR_SE;
+ }
+ }
+
+ PVector retVal = new PVector(ax, ay);
+
+ if (d) {
+ retVal = Hexagon.dirCoord(retVal, d);
+ }
+
+ return retVal;
+ }
+
+
+ void scroll(double x, double y) {
+ mx += x;
+ my += y;
+ redraw();
+ }
+
void incZoom() {
ms *= 2;
redraw();
}
void decZoom() {
ms /= 2;
redraw();
}
void scrollLeft() {
- mx += 4 * a / ms;
+ mx -= 4 * Hexagon.a;
redraw();
}
void scrollRight() {
- mx -= 4 * a / ms;
+ mx += 4 * Hexagon.a;
redraw();
}
void scrollUp() {
- my += 4 * b / ms;
+ my -= 4 * Hexagon.b;
redraw();
}
void scrollDown() {
- my -= 4 * b / ms;
+ my += 4 * Hexagon.b;
redraw();
}
void display() {
pushMatrix();
// do zoom
- translate(width/2, height/2);
scale(ms);
- translate(width/-2, height/-2);
// translate
translate(mx, my);
// draw hexagon
for (int i = 0; i < hexagons.size(); ++i) {
Hexagon h = (Hexagon) hexagons.get(i);
h.display();
}
+
popMatrix();
}
}
class Hexagon
{
+ static int DIR_NW = 1;
+ static int DIR_NE = 2;
+ static int DIR_E = 3;
+ static int DIR_SE = 4;
+ static int DIR_SW = 5;
+ static int DIR_W = 6;
+
+ static double h = sin (radians(30));
+ static double r = cos (radians(30));
+ static double a = 2 * r;
+ static double b = 2 * h + 1;
+
+
+ static PVector dirCoord(PVector v, int d)
+ {
+ switch (d) {
+ case DIR_NW:
+ return new PVector(v.x, v.y -1);
+ case DIR_NE:
+ return new PVector(v.x + 1, v.y -1);
+ case DIR_E:
+ return new PVector(v.x + 1, v.y);
+ case DIR_SE:
+ return new PVector(v.x, v.y + 1);
+ case DIR_SW:
+ return new PVector(v.x - 1, v.y + 1);
+ case DIR_W:
+ return new PVector(v.x - 1, v.y);
+
+ default:
+ return null;
+
+ }
+ }
+
int hx, hy;
double dx, dy;
Hexagon(int x, int y) {
hx = x;
hy = y;
dx = hx * a;
dy = hy * (h + 1);
if (hy % 2 != 0) {
dx += r;
}
}
void display() {
pushMatrix();
translate(dx, dy);
stroke(1);
smooth();
beginShape();
vertex(0, h);
vertex(r, 0);
vertex(a, h);
vertex(a, h + 1);
vertex(r, b);
vertex(0, h + 1);
endShape();
popMatrix();
}
}
|
alios/lab
|
149f4bd4190dfc3116495745f3a2034e6a16aa18
|
switched to processing.js
|
diff --git a/game/html/chart.html b/game/html/chart.html
index 56c0ebc..ef6e2cc 100644
--- a/game/html/chart.html
+++ b/game/html/chart.html
@@ -1,59 +1,68 @@
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<script src="js/libs/modernizr-2.0.6.min.js"></script>
<script src="js/jquery-1.7.1.min.js"></script>
+
+<!--
<script src="js/libs/easel.js"></script>
<script src="js/libs/Touch.js"></script>
+
<script src="js/script.js"></script>
+-->
</head>
-<body onload="init();">
+<body onload="">
<div id="container">
<header>
</header>
<div id="main" role="main" style="background-color: #000000;">
+ <script src="js/libs/processing-1.3.6.js"></script>
+ <canvas width="800" height="600" data-processing-sources="hexmap.pde"></canvas>
+
+<!--
<canvas id="map" width="1024" height="768"></canvas>
<div id="infocontainer">
<h2> Info </h2>
<div id="info">
...
</div>
</div>
+-->
</div>
<footer>
</footer>
</div> <!--! end of #container -->
<!-- scripts concatenated and minified via ant build script-->
<script src="js/plugins.js"></script>
<!-- end scripts-->
<!--[if lt IE 7 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"></script>
<script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})})</script>
<![endif]-->
</body>
</html>
diff --git a/game/html/hexmap.pde b/game/html/hexmap.pde
new file mode 100644
index 0000000..4c1b65a
--- /dev/null
+++ b/game/html/hexmap.pde
@@ -0,0 +1,151 @@
+
+
+double h = sin (radians(30));
+double r = cos (radians(30));
+
+double a = 2 * r;
+double b = 2 * h + 1;
+
+
+Map m;
+
+void setup() {
+ // size(screen.width, screen.height, P3D);
+ size(800, 600, P3D);
+ m = new Map(26,26);
+ noLoop();
+ redraw();
+}
+
+void keyTyped() {
+ switch (int(key)) {
+ case 43: // +
+ m.incZoom();
+ break;
+ case 45: // -
+ m.decZoom();
+ break;
+ case 97: // a
+ m.scrollLeft();
+ break;
+ case 100: // d
+ m.scrollRight();
+ break;
+ case 119: // w
+ m.scrollUp();
+ break;
+ case 115: // s
+ m.scrollDown();
+ break;
+ }
+}
+
+void draw() {
+ background(153);
+ m.display();
+}
+
+class Map
+{
+ ArrayList hexagons;
+ double mx = 0;
+ double my = 0;
+ double ms = 1;
+
+ Map(int nx, int ny) {
+ mx = width / 2 - nx / 2;
+ my = height / 2 - ny / 2;
+ hexagons = new ArrayList();
+ for (int x = 0; x < nx; ++x) {
+ for (int y = 0; y < ny; ++y) {
+ hexagons.add(new Hexagon(x,y));
+ }
+ }
+ }
+
+ void incZoom() {
+ ms *= 2;
+ redraw();
+ }
+
+ void decZoom() {
+ ms /= 2;
+ redraw();
+ }
+
+ void scrollLeft() {
+ mx += 4 * a / ms;
+ redraw();
+ }
+
+ void scrollRight() {
+ mx -= 4 * a / ms;
+ redraw();
+ }
+
+ void scrollUp() {
+ my += 4 * b / ms;
+ redraw();
+ }
+
+ void scrollDown() {
+ my -= 4 * b / ms;
+ redraw();
+ }
+
+
+ void display() {
+ pushMatrix();
+
+ // do zoom
+ translate(width/2, height/2);
+ scale(ms);
+ translate(width/-2, height/-2);
+
+ // translate
+ translate(mx, my);
+
+ // draw hexagon
+ for (int i = 0; i < hexagons.size(); ++i) {
+ Hexagon h = (Hexagon) hexagons.get(i);
+ h.display();
+ }
+
+ popMatrix();
+ }
+}
+
+class Hexagon
+{
+ int hx, hy;
+ double dx, dy;
+
+ Hexagon(int x, int y) {
+ hx = x;
+ hy = y;
+
+ dx = hx * a;
+ dy = hy * (h + 1);
+
+ if (hy % 2 != 0) {
+ dx += r;
+ }
+ }
+
+ void display() {
+ pushMatrix();
+ translate(dx, dy);
+ stroke(1);
+ smooth();
+ beginShape();
+ vertex(0, h);
+ vertex(r, 0);
+ vertex(a, h);
+ vertex(a, h + 1);
+ vertex(r, b);
+ vertex(0, h + 1);
+ endShape();
+ popMatrix();
+ }
+}
+
|
alios/lab
|
86dad34d3fd22d6790ee79841dd5a06c4de22ed7
|
fixed MPI binary test to user Arbitrary instance of MPI
|
diff --git a/OpenPGPTests.hs b/OpenPGPTests.hs
index b854991..4b68199 100644
--- a/OpenPGPTests.hs
+++ b/OpenPGPTests.hs
@@ -1,137 +1,135 @@
{-# LANGUAGE FlexibleInstances #-}
module Main where
import OpenPGP
import Test.QuickCheck
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString as BS
import qualified Data.Attoparsec as A
import Data.Convertible
import Data.Time (UTCTime(..), secondsToDiffTime, Day (..))
import System.Time (ClockTime(..))
main = do
chk prop_MPIBinary
chk prop_KeyIDParser
chk prop_UTCTimeBinary
chk prop_StringToKeySpecifierBinary
chk prop_SignatureTypeBinary
chk prop_PublicKeyAlgorithmBinary
chk prop_PEKSKPBinary
chk prop_Signature3Binary
return ()
where
chk :: Testable prop => prop -> IO ()
- chk = quickCheck
--- chk = verboseCheck
+ --chk = quickCheck
+ chk = verboseCheck
instance Arbitrary HashAlgorithm where
arbitrary = elements [ MD5,SHA1,RIPEMD160,SHA256,SHA384,SHA512,SHA224 ]
rPut :: Binary t => t -> ByteString
rPut = runPut . put
rGet :: Binary t => ByteString -> t
rGet bs = runGet get bs
rPutGet :: Binary t => t -> t
rPutGet = rGet . rPut
instance Arbitrary MPI where
arbitrary = fmap (MPI . BS.pack) arbitrary
-prop_MPIBinary :: [Word8] -> Property
-prop_MPIBinary bs =
- let mpi = (MPI . BS.pack) bs
- in label "MPI binary test" (mpi == rPutGet mpi)
+prop_MPIBinary :: MPI -> Property
+prop_MPIBinary mpi = label "MPI binary test" (mpi == rPutGet mpi)
prop_KeyIDParser :: KeyID -> Property
prop_KeyIDParser kid =
let ekid = convert $ rPut kid
rdkid = A.maybeResult $ A.parse parseKeyID ekid
dkid = case rdkid of
Nothing -> error "unable to parse KeyID"
Just a -> a
in label "KeyID parser test" (kid == dkid)
instance Arbitrary UTCTime where
arbitrary = do
i <- arbitrary :: Gen Word32
return $ convert $ TOD (abs $ convert i) 0
prop_UTCTimeBinary :: UTCTime -> Property
prop_UTCTimeBinary t =
label "UTCTime binary test" $ t == rPutGet t
instance Arbitrary StringToKeySpecifier where
arbitrary = do
n <- choose (0, 2) :: Gen Int
a <- arbitrary
s <- arbitrary
i <- arbitrary
return $ case n of
0 -> SimpleS2K a
1 -> SaltedS2K a s
2 -> IteratedAndSaltedS2K a s i
prop_StringToKeySpecifierBinary :: StringToKeySpecifier -> Property
prop_StringToKeySpecifierBinary s2k =
label "StringToKeySpecifier binary test" $ s2k == rPutGet s2k
instance Arbitrary SignatureType where
arbitrary = elements $ map fst signatureTypeCoding
prop_SignatureTypeBinary :: SignatureType -> Property
prop_SignatureTypeBinary s =
label "SignatureType binary test" $ s == rPutGet s
instance Arbitrary PublicKeyAlgorithm where
arbitrary = elements $ map fst publicKeyAlgorithmCoding
prop_PublicKeyAlgorithmBinary :: PublicKeyAlgorithm -> Property
prop_PublicKeyAlgorithmBinary a =
label "PublicKeyAlgorithm binary test" $ a == rPutGet a
instance Arbitrary (PacketState PEKSKP) where
arbitrary = do
keyid' <- arbitrary
let keyid = if (keyid' == 0) then Nothing else Just keyid'
a <- arbitrary
b <- arbitrary
n <- choose (0, 2) :: Gen Int
return $ case n of
0 -> MkPEKSKP keyid RSAEncryptOrSign (Left a)
1 -> MkPEKSKP keyid RSAEncryptOrSign (Left a)
2 -> MkPEKSKP keyid ElgamalEncryptOnly (Right (a,b))
prop_PEKSKPBinary :: PacketState PEKSKP -> Property
prop_PEKSKPBinary p =
label "PacketState PEKSKP binary test" $ p == rPutGet p
prop_Signature3Binary :: PacketState Signature3 -> Property
prop_Signature3Binary p =
label "PacketState Signature3 binary test" $ p == rPutGet p
instance Arbitrary (PacketState Signature3) where
arbitrary = do
ty <- arbitrary
t <- arbitrary
k <- arbitrary
a <- elements [ RSAEncryptOrSign, RSASignOnly, DSA ]
h <- arbitrary
f <- arbitrary
d <- case a of
RSAEncryptOrSign -> fmap Left arbitrary
RSASignOnly -> fmap Left arbitrary
DSA -> fmap Right arbitrary
return $ MkSignaturePacket3 ty t k a h f d
|
alios/lab
|
861ab1b7f92353220cd033fc01c3e0398a46546d
|
finalized signature version 3 packets
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index 2a5a96c..cadfa94 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -1,1752 +1,1757 @@
\begin{code}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
module OpenPGP where
{-
( Packet (..)
, PEKSKP (..)
, Signature3 (..)
, Parser
) where
-}
import Data.Enumerator (Iteratee)
import Data.Attoparsec (Parser, (<?>))
import Data.Attoparsec.Enumerator
import qualified Data.Attoparsec as A
import Data.Convertible
import qualified Data.ByteString.Base64 as Base64
import Data.Time (UTCTime)
import Data.Bits
import Data.Word
import Data.Tuple (swap)
import Data.Binary (decode)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy as B
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import System.Time
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
decodeStrictBS bs = (decode . B.fromChunks) [bs]
anyWord16 :: Parser Word16
-anyWord16 = fmap decodeStrictBS (A.take 2 <?> "word16")
+anyWord16 = fmap (\bs -> runGet getWord16be $ convert bs) (A.take 2 <?> "word16")
anyWord32 :: Parser Word32
-anyWord32 = fmap decodeStrictBS (A.take 4 <?> "word32")
+anyWord32 = fmap (\bs -> runGet getWord32be $ convert bs) (A.take 4 <?> "word32")
anyWord64 :: Parser Word64
-anyWord64 = fmap decodeStrictBS (A.take 8 <?> "word64")
+anyWord64 = fmap (\bs -> runGet getWord64be $ convert bs) (A.take 8 <?> "word64")
parserToGet :: Parser t -> Get t
parserToGet p =
let getter = A.parseWith byteGetter p BS.empty
in do res <- getter
handleResult res
where handleResult :: A.Result a -> Get a
handleResult res = case res of
A.Fail bs ctxs err -> fail err
A.Partial f -> do
res' <- fmap f byteGetter
handleResult res'
A.Done bs r -> return r
byteGetter = do
e <- isEmpty
if (e) then return BS.empty else getBytes 1
\end{code}
3. Data Element Formats
This section describes the data elements used by OpenPGP.
3.1. Scalar Numbers
Scalar numbers are unsigned and are always stored in big-endian
format. Using n[k] to refer to the kth octet being interpreted, the
value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a
four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
n[3]).
3.2. Multiprecision Integers
Multiprecision integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used in cryptographic
calculations.
An MPI consists of two pieces: a two-octet scalar that is the length
of the MPI in bits followed by a string of octets that contain the
actual integer.
These octets form a big-endian number; a big-endian number can be
made into an MPI by prefixing it with the appropriate length.
Examples:
(all numbers are in hexadecimal)
The string of octets [00 01 01] forms an MPI with the value 1. The
string [00 09 01 FF] forms an MPI with the value of 511.
Additional rules:
The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
The length field of an MPI describes the length starting from its
most significant non-zero bit. Thus, the MPI [00 02 01] is not
formed correctly. It should be [00 01 01].
Unused bits of an MPI MUST be zero.
Also note that when an MPI is encrypted, the length refers to the
plaintext MPI. It may be ill-formed in its ciphertext.
\begin{code}
newtype MPI = MPI ByteString
deriving (Show, Eq)
instance Binary MPI where
put (MPI bs) = do
putWord16be . convert . BS.length $ bs
putByteString bs
get = parserToGet parseMPI
parseMPI :: Parser MPI
parseMPI = do
ls <- fmap convert anyWord16
bs <- (A.take ls <?> "MPI")
return $ MPI bs
\end{code}
3.3. Key IDs
A Key ID is an eight-octet scalar that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique. The
section "Enhanced Key Formats" below describes how Key IDs are
formed.
\begin{code}
type KeyID = Word64
parseKeyID :: Parser KeyID
parseKeyID = fmap (\bs -> runGet getWord64be $ convert bs) (A.take 8 <?> "KeyID")
\end{code}
3.4. Text
Unless otherwise specified, the character set for text is the UTF-8
[RFC3629] encoding of Unicode [ISO10646].
3.5. Time Fields
A time field is an unsigned four-octet number containing the number
of seconds elapsed since midnight, 1 January 1970 UTC.
\begin{code}
parseTime :: Parser UTCTime
parseTime = do
ts <- anyWord32 <?> "TimeField"
return $ convert $ TOD (convert ts) 0
instance Binary UTCTime where
get = parserToGet parseTime
put t =
let (TOD tod _ ) = convert t
- in putWord32be . convert $ tod
+ in if (tod > convert (maxBound :: Word32) || tod < convert (minBound :: Word32))
+ then fail $ "timestamp is out of bound: " ++ show tod
+ else putWord32be . convert $ tod
\end{code}
3.6. Keyrings
A keyring is a collection of one or more keys in a file or database.
Traditionally, a keyring is simply a sequential list of keys, but may
be any suitable database. It is beyond the scope of this standard to
discuss the details of keyrings or other databases.
3.7. String-to-Key (S2K) Specifiers
String-to-key (S2K) specifiers are used to convert passphrase strings
into symmetric-key encryption/decryption keys. They are used in two
places, currently: to encrypt the secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
symmetrically encrypted messages.
3.7.1. String-to-Key (S2K) Specifier Types
There are three types of S2K specifiers currently supported, and
some reserved values:
ID S2K Type
-- --------
0 Simple S2K
1 Salted S2K
2 Reserved value
3 Iterated and Salted S2K
100 to 110 Private/Experimental S2K
These are described in Sections 3.7.1.1 - 3.7.1.3.
\begin{code}
data StringToKeySpecifier =
SimpleS2K HashAlgorithm |
SaltedS2K HashAlgorithm Word64 |
IteratedAndSaltedS2K HashAlgorithm Word64 Word8
deriving (Eq, Show)
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
instance Binary StringToKeySpecifier where
get = parserToGet parseStringToKeySpecifier
put (SimpleS2K a) = do
putWord8 0x00
put a
put (SaltedS2K a s) = do
putWord8 0x01
put a
put s
put (IteratedAndSaltedS2K a s i) = do
putWord8 0x03
put a
put s
putWord8 i
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
hashAlgo <- parseHashAlgorithm
return $ SimpleS2K hashAlgo
\end{code}
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgorithm
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
\end{code}
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
_ <- A.word8 0x03
hashAlgo <- parseHashAlgorithm
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
5. Packet Types
\begin{code}
class Packet t where
data PacketState t :: *
data PacketTag t :: *
packetTag :: t -> PacketTag t
packetTag' :: (PacketState t) -> PacketTag t
packetTagNum :: PacketTag t -> Word8
bodyParser :: t -> Parser (PacketState t)
isOldPacketTag :: PacketTag t -> Bool
isOldPacketTag = ((<) 16) . packetTagNum
putPacketBody :: PacketState t -> Put
putPacket :: PacketState t -> Put
putPacket st = do
putWord8 $ (packetTagNum . packetTag') st -- TODO: support old packet header format
putPacketBody st
getPacket :: t -> Get (PacketState t, Maybe PacketLength)
getPacket = parserToGet . parsePacket
parsePacket :: t -> Parser (PacketState t, Maybe PacketLength)
parsePacket t =
let n = (packetTagNum . packetTag) t
isOld = (isOldPacketTag . packetTag) t
in do
w <- A.anyWord8
let maskedPacket = w .&. 0x3f
if (w `testBit` 7)
then fail $ "no valid packet header"
else if (maskedPacket /= n) then fail $ "read invalid header tag " ++ show maskedPacket
else if (isOld)
then do
body <- bodyParser t
case (lookupPacketLength $ maskedPacket .&. 0x03) of
Nothing -> fail ""
Just len -> return (body, Just len)
else do
body <- bodyParser t
return (body, Nothing)
\end{code}
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
\begin{code}
data PEKSKP = PEKSKP
instance Eq (PacketState PEKSKP) where
(MkPEKSKP k a d) == (MkPEKSKP k' a' d') = and [k == k', a == a', d == d']
instance Binary (PacketState PEKSKP) where
put = putPacket
get = fmap fst (getPacket PEKSKP)
instance Packet PEKSKP where
data PacketTag PEKSKP = PEKSKPPacketTag
data PacketState PEKSKP = MkPEKSKP {
pekskpKeyID :: Maybe KeyID,
pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
pekskpData :: Either MPI (MPI, MPI)
} deriving (Show)
packetTag _ = PEKSKPPacketTag
packetTag' _ = PEKSKPPacketTag
packetTagNum _ = 0x01
bodyParser PEKSKP = do
_ <- A.word8 3
keyid' <- parseKeyID
let keyid = if (keyid' == 0) then Nothing else Just keyid'
algo <- parsePublicKeyAlgorithm
encKey <- case (algo) of
RSAEncryptOrSign -> parseRSAEncryptedSessionKey
RSAEncryptOnly -> parseRSAEncryptedSessionKey
ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
otherwise -> fail $ "unknown encryption algorithm " ++ show algo
return $ MkPEKSKP keyid algo encKey
where parseRSAEncryptedSessionKey = fmap Left parseMPI
parseElgamalEncryptedSessionKey = do
a <- parseMPI
b <- parseMPI
return $ Right (a, b)
putPacketBody ps = do
putWord8 0x3
putWord64be $ maybe 0 id $ pekskpKeyID ps
putWord8 $ (fromJust . publicKeyAlgorithmToNum . pekskpPublicKeyAlgorithm) ps
either put (\(a,b) -> do put a ; put b) $ pekskpData ps
\end{code}
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
\begin{code}
data SignatureType =
SignatureBinaryDoc |
SignatureCanonicalTextDoc |
StandaloneSignature |
GenericCertificationOfAUserIDAndPublicKeyPacket |
PersonaCertificationOfAUserIDAndPublicKeyPacket |
CasualCertificationOfAUserIDAndPublicKeyPacket |
PositiveCertificationOfAUserIDAndPublicKeyPacket |
SubkeyBindingSignature |
PrimaryKeyBindingSignature |
SignatureDirectlyOnAKey |
KeyRevocationSignature |
SubkeyRevocationSignature |
CertificationRevocationSignature |
TimestampSignature |
ThirdPartyConfirmationSignature
deriving (Show, Read, Eq, Enum)
signatureTypeCoding = [
(SignatureBinaryDoc , 0x00),
(SignatureCanonicalTextDoc , 0x01),
(StandaloneSignature , 0x02),
(GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
(PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
(CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
(PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
(SubkeyBindingSignature , 0x18),
(PrimaryKeyBindingSignature , 0x19),
(SignatureDirectlyOnAKey , 0x1F),
(KeyRevocationSignature , 0x20),
(SubkeyRevocationSignature , 0x28),
(CertificationRevocationSignature , 0x30),
(TimestampSignature , 0x40),
(ThirdPartyConfirmationSignature , 0x50)
]
lookupSignatureType :: Word8 -> Maybe SignatureType
lookupSignatureType i = lookup i $ map swap signatureTypeCoding
signatureTypeToNum :: SignatureType -> Maybe Word8
signatureTypeToNum p = lookup p signatureTypeCoding
parseSignatureType :: Parser SignatureType
parseSignatureType = do
w <- A.anyWord8
case (lookupSignatureType w) of
Nothing -> fail "unknown signature type"
Just a -> return a
instance Binary SignatureType where
get = parserToGet parseSignatureType
put s = case (signatureTypeToNum s) of
Nothing -> fail $ "unknown signature type " ++ show s
Just s' -> putWord8 s'
\end{code}
5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
+ Algorithm-Specific Fields for RSA signatures:
+
+ - multiprecision integer (MPI) of RSA signature value m**d mod n.
+
+ Algorithm-Specific Fields for DSA signatures:
+
+ - MPI of DSA value r.
+
+ - MPI of DSA value s.
+
\begin{code}
instance Eq (PacketState Signature3) where
- (MkSignaturePacket3 ty t k a h d) == (MkSignaturePacket3 ty' t' k' a' h' d') =
- and [ty == ty', t == t', k == k', a == a', h == h', d == d']
+ (MkSignaturePacket3 ty t k a h f d) == (MkSignaturePacket3 ty' t' k' a' h' f' d') =
+ and [ty == ty', t == t', k == k', a == a', h == h', f == f', d == d']
instance Binary (PacketState Signature3) where
put = putPacket
get = fmap fst (getPacket Signature3)
-
-
data Signature3 = Signature3
instance Packet Signature3 where
data PacketTag Signature3 = Signature3PacketTag
data PacketState Signature3 = MkSignaturePacket3 {
sig3Type :: SignatureType,
sig3Time :: UTCTime,
sig3KeyID :: KeyID,
sig3PKAlgorithm :: PublicKeyAlgorithm,
sig3HashAlgorithm :: HashAlgorithm,
- sig3Data :: Either MPI (MPI, MPI)
- }
+ sig3FirstBytes :: Word16,
+ sig3SignatureData :: Either MPI (MPI, MPI)
+ } deriving (Show)
+
packetTag Signature3 = Signature3PacketTag
packetTag' _ = Signature3PacketTag
packetTagNum Signature3PacketTag = 0x02
+
putPacketBody st = do
- putWord8 0x03
- putWord8 0x05
- put $ sig3Type st
- put $ sig3Time st
- putWord64be $ sig3KeyID st
- put $ sig3PKAlgorithm st
- put $ sig3HashAlgorithm st
- case (sig3Data st) of
- Left a -> put a
- Right (a,b) -> do put a; put b
-
+ putWord8 0x03 -- packet version
+ putWord8 0x05 -- fixed packet length of 5
+ put $ sig3Type st -- signature type
+ put $ sig3Time st -- timestamp
+ putWord64be $ sig3KeyID st -- key id
+ let pk = sig3PKAlgorithm st
+ put pk -- publice key algo
+ put $ sig3HashAlgorithm st -- hash algo
+ putWord16be $ sig3FirstBytes st -- fist 2 bytes of hashed data
+ let rsaData = case (sig3SignatureData st) of
+ Left a -> put a
+ Right _ -> error $ "signature data is not RSA Data"
+ let dsaData = case (sig3SignatureData st) of
+ Right (a,b) -> do put a ; put b
+ Left _ -> error $ "signature data is not DSA Data"
+ case pk of
+ RSAEncryptOrSign -> rsaData
+ RSASignOnly -> rsaData
+ DSA -> dsaData
+ otherwise -> error $ "unknown public key algorithm " ++ show pk
+
bodyParser Signature3 = do
_ <- A.word8 3
l <- bodyLenParser OneOctedLength
if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
else do
stype <- parseSignatureType
t <- parseTime
keyid <- parseKeyID
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
- let (MPI firstHash) = case (hashdata) of
- Left h -> h
- Right (h, _) -> h
- if (not $ (convert firstHash) `checkFirstHash` shv)
- then fail "signedHashValue check failed"
- else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
+ otherwise -> fail $ "unknown public key algorithm " ++ show pkAlgo
+ return $ MkSignaturePacket3 stype t keyid pkAlgo hasha shv hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
- checkFirstHash bs v =
- let a = convert (bs `B.index` 0)
- b = convert (bs `B.index` 1)
- v' :: Word16
- v' = (a `shiftL` 8) .|. b
- in v' == v
\end{code}
- Algorithm-Specific Fields for RSA signatures:
-
- - multiprecision integer (MPI) of RSA signature value m**d mod n.
-
- Algorithm-Specific Fields for DSA signatures:
-
- - MPI of DSA value r.
-
- - MPI of DSA value s.
-
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
\begin{code}
data Signature4 = Signature4
instance Packet Signature4 where
data PacketTag Signature4 = Signature4PacketTag
data PacketState Signature4 = MkSignaturePacket4 {
sig4Type :: SignatureType,
sig4Time :: UTCTime,
sig4KeyID :: KeyID,
sig4PKAlgorithm :: PublicKeyAlgorithm,
sig4HashAlgorithm :: HashAlgorithm,
sig4Data :: Either MPI (MPI, MPI)
}
+
packetTag Signature4 = Signature4PacketTag
+ packetTag' _ = Signature4PacketTag
packetTagNum Signature4PacketTag = 0x02
+
bodyParser Signature4 = do
_ <- A.word8 4
stype <- parseSignatureType
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
hashedSubPacketLength <- bodyLenParser TwoOctedLength
hashedSubpacketData <- A.take hashedSubPacketLength
subPacketLength <- bodyLenParser TwoOctedLength
subpacketData <- A.take subPacketLength
-
return undefined
{-
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
-}
\end{code}
5.2.3.1. Signature Subpacket Specification
A subpacket data set consists of zero or more Signature subpackets.
In Signature packets, the subpacket data set is preceded by a two-
octet scalar count of the length in octets of all the subpackets. A
pointer incremented by this number will skip over the subpacket data
set.
Each subpacket consists of a subpacket header and a body. The header
consists of:
- the subpacket length (1, 2, or 5 octets),
- the subpacket type (1 octet),
and is followed by the subpacket-specific data.
The length includes the type octet but not this length. Its format
is similar to the "new" format packet header lengths, but cannot have
Partial Body Lengths. That is:
if the 1st octet < 192, then
lengthOfLength = 1
subpacketLen = 1st_octet
if the 1st octet >= 192 and < 255, then
lengthOfLength = 2
subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
if the 1st octet = 255, then
lengthOfLength = 5
subpacket length = [four-octet scalar starting at 2nd_octet]
\begin{code}
class SignatureSubpacket s where
data SignatureSubpacketState s :: *
\end{code}
The value of the subpacket type octet may be:
0 = Reserved
1 = Reserved
2 = Signature Creation Time
3 = Signature Expiration Time
4 = Exportable Certification
5 = Trust Signature
6 = Regular Expression
7 = Revocable
8 = Reserved
9 = Key Expiration Time
10 = Placeholder for backward compatibility
11 = Preferred Symmetric Algorithms
12 = Revocation Key
13 = Reserved
14 = Reserved
15 = Reserved
16 = Issuer
17 = Reserved
18 = Reserved
19 = Reserved
20 = Notation Data
21 = Preferred Hash Algorithms
22 = Preferred Compression Algorithms
23 = Key Server Preferences
24 = Preferred Key Server
25 = Primary User ID
26 = Policy URI
27 = Key Flags
28 = Signer's User ID
29 = Reason for Revocation
30 = Features
31 = Signature Target
32 = Embedded Signature
100 To 110 = Private or experimental
An implementation SHOULD ignore any subpacket of a type that it does
not recognize.
Bit 7 of the subpacket type is the "critical" bit. If set, it
denotes that the subpacket is one that is critical for the evaluator
of the signature to recognize. If a subpacket is encountered that is
marked critical but is unknown to the evaluating software, the
evaluator SHOULD consider the signature to be in error.
An evaluator may "recognize" a subpacket, but not implement it. The
purpose of the critical bit is to allow the signer to tell an
evaluator that it would prefer a new, unknown feature to generate an
error than be ignored.
Implementations SHOULD implement the three preferred algorithm
subpackets (11, 21, and 22), as well as the "Reason for Revocation"
subpacket. Note, however, that if an implementation chooses not to
implement some of the preferences, it is required to behave in a
polite manner to respect the wishes of those users who do implement
these preferences.
5.2.3.2. Signature Subpacket Types
A number of subpackets are currently defined. Some subpackets apply
to the signature itself and some are attributes of the key.
Subpackets that are found on a self-signature are placed on a
certification made by the key itself. Note that a key may have more
than one User ID, and thus may have more than one self-signature, and
differing subpackets.
A subpacket may be found either in the hashed or unhashed subpacket
sections of a signature. If a subpacket is not hashed, then the
information in it cannot be considered definitive because it is not
part of the signature proper.
5.2.3.3. Notes on Self-Signatures
A self-signature is a binding signature made by the key to which the
signature refers. There are three types of self-signatures, the
certification signatures (types 0x10-0x13), the direct-key signature
(type 0x1F), and the subkey binding signature (type 0x18). For
certification self-signatures, each User ID may have a self-
signature, and thus different subpackets in those self-signatures.
For subkey binding signatures, each subkey in fact has a self-
signature. Subpackets that appear in a certification self-signature
apply to the user name, and subpackets that appear in the subkey
self-signature apply to the subkey. Lastly, subpackets on the
direct-key signature apply to the entire key.
Implementing software should interpret a self-signature's preference
subpackets as narrowly as possible. For example, suppose a key has
two user names, Alice and Bob. Suppose that Alice prefers the
symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the
software locates this key via Alice's name, then the preferred
algorithm is CAST5; if software locates the key via Bob's name, then
the preferred algorithm is IDEA. If the key is located by Key ID,
the algorithm of the primary User ID of the key provides the
preferred symmetric algorithm.
Revoking a self-signature or allowing it to expire has a semantic
meaning that varies with the signature type. Revoking the self-
signature on a User ID effectively retires that user name. The
self-signature is a statement, "My name X is tied to my signing key
K" and is corroborated by other users' certifications. If another
user revokes their certification, they are effectively saying that
they no longer believe that name and that key are tied together.
Similarly, if the users themselves revoke their self-signature, then
the users no longer go by that name, no longer have that email
address, etc. Revoking a binding signature effectively retires that
subkey. Revoking a direct-key signature cancels that signature.
Please see the "Reason for Revocation" subpacket (Section 5.2.3.23)
for more relevant detail.
Since a self-signature contains important information about the key's
use, an implementation SHOULD allow the user to rewrite the self-
signature, and important information in it, such as preferences and
key expiration.
It is good practice to verify that a self-signature imported into an
implementation doesn't advertise features that the implementation
doesn't support, rewriting the signature as appropriate.
An implementation that encounters multiple self-signatures on the
same object may resolve the ambiguity in any way it sees fit, but it
is RECOMMENDED that priority be given to the most recent self-
signature.
5.2.3.4. Signature Creation Time
(4-octet time field)
The time the signature was made.
MUST be present in the hashed area.
5.2.3.5. Issuer
(8-octet Key ID)
The OpenPGP Key ID of the key issuing the signature.
5.2.3.6. Key Expiration Time
(4-octet time field)
The validity period of the key. This is the number of seconds after
the key creation time that the key expires. If this is not present
or has a value of zero, the key never expires. This is found only on
a self-signature.
5.2.3.7. Preferred Symmetric Algorithms
(array of one-octet values)
Symmetric algorithm numbers that indicate which algorithms the key
holder prefers to use. The subpacket body is an ordered list of
octets with the most preferred listed first. It is assumed that only
algorithms listed are supported by the recipient's software.
Algorithm numbers are in Section 9. This is only found on a self-
signature.
5.2.3.8. Preferred Hash Algorithms
(array of one-octet values)
Message digest algorithm numbers that indicate which algorithms the
key holder prefers to receive. Like the preferred symmetric
algorithms, the list is ordered. Algorithm numbers are in Section 9.
This is only found on a self-signature.
5.2.3.9. Preferred Compression Algorithms
(array of one-octet values)
Compression algorithm numbers that indicate which algorithms the key
holder prefers to use. Like the preferred symmetric algorithms, the
list is ordered. Algorithm numbers are in Section 9. If this
subpacket is not included, ZIP is preferred. A zero denotes that
uncompressed data is preferred; the key holder's software might have
no compression software in that implementation. This is only found
on a self-signature.
5.2.3.10. Signature Expiration Time
(4-octet time field)
The validity period of the signature. This is the number of seconds
after the signature creation time that the signature expires. If
this is not present or has a value of zero, it never expires.
5.2.3.11. Exportable Certification
(1 octet of exportability, 0 for not, 1 for exportable)
This subpacket denotes whether a certification signature is
"exportable", to be used by other users than the signature's issuer.
The packet body contains a Boolean flag indicating whether the
signature is exportable. If this packet is not present, the
certification is exportable; it is equivalent to a flag containing a
1.
Non-exportable, or "local", certifications are signatures made by a
user to mark a key as valid within that user's implementation only.
Thus, when an implementation prepares a user's copy of a key for
transport to another user (this is the process of "exporting" the
key), any local certification signatures are deleted from the key.
The receiver of a transported key "imports" it, and likewise trims
any local certifications. In normal operation, there won't be any,
assuming the import is performed on an exported key. However, there
are instances where this can reasonably happen. For example, if an
implementation allows keys to be imported from a key database in
addition to an exported key, then this situation can arise.
Some implementations do not represent the interest of a single user
(for example, a key server). Such implementations always trim local
certifications from any key they handle.
5.2.3.12. Revocable
(1 octet of revocability, 0 for not, 1 for revocable)
Signature's revocability status. The packet body contains a Boolean
flag indicating whether the signature is revocable. Signatures that
are not revocable have any later revocation signatures ignored. They
represent a commitment by the signer that he cannot revoke his
signature for the life of his key. If this packet is not present,
the signature is revocable.
5.2.3.13. Trust Signature
(1 octet "level" (depth), 1 octet of trust amount)
Signer asserts that the key is not only valid but also trustworthy at
the specified level. Level 0 has the same meaning as an ordinary
validity signature. Level 1 means that the signed key is asserted to
be a valid trusted introducer, with the 2nd octet of the body
specifying the degree of trust. Level 2 means that the signed key is
asserted to be trusted to issue level 1 trust signatures, i.e., that
it is a "meta introducer". Generally, a level n trust signature
asserts that a key is trusted to issue level n-1 trust signatures.
The trust amount is in a range from 0-255, interpreted such that
values less than 120 indicate partial trust and values of 120 or
greater indicate complete trust. Implementations SHOULD emit values
of 60 for partial trust and 120 for complete trust.
5.2.3.14. Regular Expression
(null-terminated regular expression)
Used in conjunction with trust Signature packets (of level > 0) to
limit the scope of trust that is extended. Only signatures by the
target key on User IDs that match the regular expression in the body
of this packet have trust extended by the trust Signature subpacket.
The regular expression uses the same syntax as the Henry Spencer's
"almost public domain" regular expression [REGEX] package. A
description of the syntax is found in Section 8 below.
5.2.3.15. Revocation Key
(1 octet of class, 1 octet of public-key algorithm ID, 20 octets of
fingerprint)
Authorizes the specified key to issue revocation signatures for this
key. Class octet must have bit 0x80 set. If the bit 0x40 is set,
then this means that the revocation information is sensitive. Other
bits are for future expansion to other kinds of authorizations. This
is found on a self-signature.
If the "sensitive" flag is set, the keyholder feels this subpacket
contains private trust information that describes a real-world
sensitive relationship. If this flag is set, implementations SHOULD
NOT export this signature to other users except in cases where the
data needs to be available: when the signature is being sent to the
designated revoker, or when it is accompanied by a revocation
signature from that revoker. Note that it may be appropriate to
isolate this subpacket within a separate signature so that it is not
combined with other subpackets that need to be exported.
5.2.3.16. Notation Data
(4 octets of flags, 2 octets of name length (M),
2 octets of value length (N),
M octets of name data,
N octets of value data)
This subpacket describes a "notation" on the signature that the
issuer wishes to make. The notation has a name and a value, each of
which are strings of octets. There may be more than one notation in
a signature. Notations can be used for any extension the issuer of
the signature cares to make. The "flags" field holds four octets of
flags.
All undefined flags MUST be zero. Defined flags are as follows:
First octet: 0x80 = human-readable. This note value is text.
Other octets: none.
Notation names are arbitrary strings encoded in UTF-8. They reside
in two namespaces: The IETF namespace and the user namespace.
The IETF namespace is registered with IANA. These names MUST NOT
contain the "@" character (0x40). This is a tag for the user
namespace.
Names in the user namespace consist of a UTF-8 string tag followed by
"@" followed by a DNS domain name. Note that the tag MUST NOT
contain an "@" character. For example, the "sample" tag used by
Example Corporation could be "[email protected]".
Names in a user space are owned and controlled by the owners of that
domain. Obviously, it's bad form to create a new name in a DNS space
that you don't own.
Since the user namespace is in the form of an email address,
implementers MAY wish to arrange for that address to reach a person
who can be consulted about the use of the named tag. Note that due
to UTF-8 encoding, not all valid user space name tags are valid email
addresses.
If there is a critical notation, the criticality applies to that
specific notation and not to notations in general.
5.2.3.17. Key Server Preferences
(N octets of flags)
This is a list of one-bit flags that indicate preferences that the
key holder has about how the key is handled on a key server. All
undefined flags MUST be zero.
First octet: 0x80 = No-modify
the key holder requests that this key only be modified or updated
by the key holder or an administrator of the key server.
This is found only on a self-signature.
5.2.3.18. Preferred Key Server
(String)
This is a URI of a key server that the key holder prefers be used for
updates. Note that keys with multiple User IDs can have a preferred
key server for each User ID. Note also that since this is a URI, the
key server can actually be a copy of the key retrieved by ftp, http,
finger, etc.
5.2.3.19. Primary User ID
(1 octet, Boolean)
This is a flag in a User ID's self-signature that states whether this
User ID is the main User ID for this key. It is reasonable for an
implementation to resolve ambiguities in preferences, etc. by
referring to the primary User ID. If this flag is absent, its value
is zero. If more than one User ID in a key is marked as primary, the
implementation may resolve the ambiguity in any way it sees fit, but
it is RECOMMENDED that priority be given to the User ID with the most
recent self-signature.
When appearing on a self-signature on a User ID packet, this
subpacket applies only to User ID packets. When appearing on a
self-signature on a User Attribute packet, this subpacket applies
only to User Attribute packets. That is to say, there are two
different and independent "primaries" -- one for User IDs, and one
for User Attributes.
5.2.3.20. Policy URI
(String)
This subpacket contains a URI of a document that describes the policy
under which the signature was issued.
5.2.3.21. Key Flags
(N octets of flags)
This subpacket contains a list of binary flags that hold information
about a key. It is a string of octets, and an implementation MUST
NOT assume a fixed size. This is so it can grow over time. If a
list is shorter than an implementation expects, the unstated flags
are considered to be zero. The defined flags are as follows:
First octet:
0x01 - This key may be used to certify other keys.
0x02 - This key may be used to sign data.
0x04 - This key may be used to encrypt communications.
0x08 - This key may be used to encrypt storage.
0x10 - The private component of this key may have been split
by a secret-sharing mechanism.
0x20 - This key may be used for authentication.
0x80 - The private component of this key may be in the
possession of more than one person.
Usage notes:
The flags in this packet may appear in self-signatures or in
certification signatures. They mean different things depending on
who is making the statement -- for example, a certification signature
that has the "sign data" flag is stating that the certification is
for that use. On the other hand, the "communications encryption"
flag in a self-signature is stating a preference that a given key be
used for communications. Note however, that it is a thorny issue to
determine what is "communications" and what is "storage". This
decision is left wholly up to the implementation; the authors of this
document do not claim any special wisdom on the issue and realize
that accepted opinion may change.
The "split key" (0x10) and "group key" (0x80) flags are placed on a
self-signature only; they are meaningless on a certification
signature. They SHOULD be placed only on a direct-key signature
diff --git a/OpenPGPTests.hs b/OpenPGPTests.hs
index 1dfe399..b854991 100644
--- a/OpenPGPTests.hs
+++ b/OpenPGPTests.hs
@@ -1,116 +1,137 @@
{-# LANGUAGE FlexibleInstances #-}
module Main where
import OpenPGP
import Test.QuickCheck
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString as BS
import qualified Data.Attoparsec as A
import Data.Convertible
-import Data.Time (UTCTime(..), picosecondsToDiffTime)
+import Data.Time (UTCTime(..), secondsToDiffTime, Day (..))
import System.Time (ClockTime(..))
main = do
chk prop_MPIBinary
chk prop_KeyIDParser
chk prop_UTCTimeBinary
chk prop_StringToKeySpecifierBinary
chk prop_SignatureTypeBinary
chk prop_PublicKeyAlgorithmBinary
chk prop_PEKSKPBinary
+ chk prop_Signature3Binary
return ()
where
chk :: Testable prop => prop -> IO ()
chk = quickCheck
-- chk = verboseCheck
instance Arbitrary HashAlgorithm where
arbitrary = elements [ MD5,SHA1,RIPEMD160,SHA256,SHA384,SHA512,SHA224 ]
rPut :: Binary t => t -> ByteString
rPut = runPut . put
rGet :: Binary t => ByteString -> t
rGet bs = runGet get bs
rPutGet :: Binary t => t -> t
rPutGet = rGet . rPut
instance Arbitrary MPI where
arbitrary = fmap (MPI . BS.pack) arbitrary
-
-
prop_MPIBinary :: [Word8] -> Property
prop_MPIBinary bs =
let mpi = (MPI . BS.pack) bs
in label "MPI binary test" (mpi == rPutGet mpi)
prop_KeyIDParser :: KeyID -> Property
prop_KeyIDParser kid =
let ekid = convert $ rPut kid
rdkid = A.maybeResult $ A.parse parseKeyID ekid
dkid = case rdkid of
Nothing -> error "unable to parse KeyID"
Just a -> a
in label "KeyID parser test" (kid == dkid)
-prop_UTCTimeBinary :: Integer -> Property
-prop_UTCTimeBinary i =
- let utc :: UTCTime
- utc = convert $ TOD (abs i) 0
- in label "UTCTime binary test" $ utc == rPutGet utc
+
+instance Arbitrary UTCTime where
+ arbitrary = do
+ i <- arbitrary :: Gen Word32
+ return $ convert $ TOD (abs $ convert i) 0
+
+prop_UTCTimeBinary :: UTCTime -> Property
+prop_UTCTimeBinary t =
+ label "UTCTime binary test" $ t == rPutGet t
instance Arbitrary StringToKeySpecifier where
arbitrary = do
n <- choose (0, 2) :: Gen Int
a <- arbitrary
s <- arbitrary
i <- arbitrary
return $ case n of
0 -> SimpleS2K a
1 -> SaltedS2K a s
2 -> IteratedAndSaltedS2K a s i
prop_StringToKeySpecifierBinary :: StringToKeySpecifier -> Property
prop_StringToKeySpecifierBinary s2k =
label "StringToKeySpecifier binary test" $ s2k == rPutGet s2k
instance Arbitrary SignatureType where
arbitrary = elements $ map fst signatureTypeCoding
prop_SignatureTypeBinary :: SignatureType -> Property
prop_SignatureTypeBinary s =
label "SignatureType binary test" $ s == rPutGet s
instance Arbitrary PublicKeyAlgorithm where
arbitrary = elements $ map fst publicKeyAlgorithmCoding
prop_PublicKeyAlgorithmBinary :: PublicKeyAlgorithm -> Property
prop_PublicKeyAlgorithmBinary a =
label "PublicKeyAlgorithm binary test" $ a == rPutGet a
instance Arbitrary (PacketState PEKSKP) where
arbitrary = do
keyid' <- arbitrary
let keyid = if (keyid' == 0) then Nothing else Just keyid'
a <- arbitrary
b <- arbitrary
n <- choose (0, 2) :: Gen Int
return $ case n of
- 0 -> MkPEKSKP keyid RSAEncryptOrSign (Left a)
- 1 -> MkPEKSKP keyid RSAEncryptOrSign (Left a)
- 2 -> MkPEKSKP keyid ElgamalEncryptOnly (Right (a,b))
+ 0 -> MkPEKSKP keyid RSAEncryptOrSign (Left a)
+ 1 -> MkPEKSKP keyid RSAEncryptOrSign (Left a)
+ 2 -> MkPEKSKP keyid ElgamalEncryptOnly (Right (a,b))
prop_PEKSKPBinary :: PacketState PEKSKP -> Property
prop_PEKSKPBinary p =
label "PacketState PEKSKP binary test" $ p == rPutGet p
+prop_Signature3Binary :: PacketState Signature3 -> Property
+prop_Signature3Binary p =
+ label "PacketState Signature3 binary test" $ p == rPutGet p
+
+instance Arbitrary (PacketState Signature3) where
+ arbitrary = do
+ ty <- arbitrary
+ t <- arbitrary
+ k <- arbitrary
+ a <- elements [ RSAEncryptOrSign, RSASignOnly, DSA ]
+ h <- arbitrary
+ f <- arbitrary
+ d <- case a of
+ RSAEncryptOrSign -> fmap Left arbitrary
+ RSASignOnly -> fmap Left arbitrary
+ DSA -> fmap Right arbitrary
+ return $ MkSignaturePacket3 ty t k a h f d
+
|
alios/lab
|
d2fc84a6852db732b8f9fb1e0476dd0cde26fb57
|
some more Binary instances and tests
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index 7a80088..2a5a96c 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -452,1072 +452,1102 @@ parseIteratedAndSaltedS2K = do
Bits 5-0 -- packet tag
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
5. Packet Types
\begin{code}
class Packet t where
data PacketState t :: *
data PacketTag t :: *
packetTag :: t -> PacketTag t
packetTag' :: (PacketState t) -> PacketTag t
packetTagNum :: PacketTag t -> Word8
bodyParser :: t -> Parser (PacketState t)
isOldPacketTag :: PacketTag t -> Bool
isOldPacketTag = ((<) 16) . packetTagNum
putPacketBody :: PacketState t -> Put
putPacket :: PacketState t -> Put
putPacket st = do
putWord8 $ (packetTagNum . packetTag') st -- TODO: support old packet header format
putPacketBody st
getPacket :: t -> Get (PacketState t, Maybe PacketLength)
getPacket = parserToGet . parsePacket
parsePacket :: t -> Parser (PacketState t, Maybe PacketLength)
parsePacket t =
let n = (packetTagNum . packetTag) t
isOld = (isOldPacketTag . packetTag) t
in do
w <- A.anyWord8
let maskedPacket = w .&. 0x3f
if (w `testBit` 7)
then fail $ "no valid packet header"
else if (maskedPacket /= n) then fail $ "read invalid header tag " ++ show maskedPacket
else if (isOld)
then do
body <- bodyParser t
case (lookupPacketLength $ maskedPacket .&. 0x03) of
Nothing -> fail ""
Just len -> return (body, Just len)
else do
body <- bodyParser t
return (body, Nothing)
\end{code}
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
\begin{code}
data PEKSKP = PEKSKP
instance Eq (PacketState PEKSKP) where
(MkPEKSKP k a d) == (MkPEKSKP k' a' d') = and [k == k', a == a', d == d']
instance Binary (PacketState PEKSKP) where
put = putPacket
get = fmap fst (getPacket PEKSKP)
instance Packet PEKSKP where
data PacketTag PEKSKP = PEKSKPPacketTag
data PacketState PEKSKP = MkPEKSKP {
pekskpKeyID :: Maybe KeyID,
pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
pekskpData :: Either MPI (MPI, MPI)
} deriving (Show)
packetTag _ = PEKSKPPacketTag
packetTag' _ = PEKSKPPacketTag
packetTagNum _ = 0x01
bodyParser PEKSKP = do
_ <- A.word8 3
keyid' <- parseKeyID
let keyid = if (keyid' == 0) then Nothing else Just keyid'
algo <- parsePublicKeyAlgorithm
encKey <- case (algo) of
RSAEncryptOrSign -> parseRSAEncryptedSessionKey
RSAEncryptOnly -> parseRSAEncryptedSessionKey
ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
otherwise -> fail $ "unknown encryption algorithm " ++ show algo
return $ MkPEKSKP keyid algo encKey
where parseRSAEncryptedSessionKey = fmap Left parseMPI
parseElgamalEncryptedSessionKey = do
a <- parseMPI
b <- parseMPI
return $ Right (a, b)
putPacketBody ps = do
putWord8 0x3
putWord64be $ maybe 0 id $ pekskpKeyID ps
putWord8 $ (fromJust . publicKeyAlgorithmToNum . pekskpPublicKeyAlgorithm) ps
either put (\(a,b) -> do put a ; put b) $ pekskpData ps
\end{code}
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
\begin{code}
data SignatureType =
SignatureBinaryDoc |
SignatureCanonicalTextDoc |
StandaloneSignature |
GenericCertificationOfAUserIDAndPublicKeyPacket |
PersonaCertificationOfAUserIDAndPublicKeyPacket |
CasualCertificationOfAUserIDAndPublicKeyPacket |
PositiveCertificationOfAUserIDAndPublicKeyPacket |
SubkeyBindingSignature |
PrimaryKeyBindingSignature |
SignatureDirectlyOnAKey |
KeyRevocationSignature |
SubkeyRevocationSignature |
CertificationRevocationSignature |
TimestampSignature |
ThirdPartyConfirmationSignature
deriving (Show, Read, Eq, Enum)
signatureTypeCoding = [
(SignatureBinaryDoc , 0x00),
(SignatureCanonicalTextDoc , 0x01),
(StandaloneSignature , 0x02),
(GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
(PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
(CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
(PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
(SubkeyBindingSignature , 0x18),
(PrimaryKeyBindingSignature , 0x19),
(SignatureDirectlyOnAKey , 0x1F),
(KeyRevocationSignature , 0x20),
(SubkeyRevocationSignature , 0x28),
(CertificationRevocationSignature , 0x30),
(TimestampSignature , 0x40),
(ThirdPartyConfirmationSignature , 0x50)
]
lookupSignatureType :: Word8 -> Maybe SignatureType
lookupSignatureType i = lookup i $ map swap signatureTypeCoding
signatureTypeToNum :: SignatureType -> Maybe Word8
signatureTypeToNum p = lookup p signatureTypeCoding
parseSignatureType :: Parser SignatureType
parseSignatureType = do
w <- A.anyWord8
case (lookupSignatureType w) of
Nothing -> fail "unknown signature type"
Just a -> return a
+
+instance Binary SignatureType where
+ get = parserToGet parseSignatureType
+ put s = case (signatureTypeToNum s) of
+ Nothing -> fail $ "unknown signature type " ++ show s
+ Just s' -> putWord8 s'
+
\end{code}
5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
\begin{code}
+instance Eq (PacketState Signature3) where
+ (MkSignaturePacket3 ty t k a h d) == (MkSignaturePacket3 ty' t' k' a' h' d') =
+ and [ty == ty', t == t', k == k', a == a', h == h', d == d']
+
+instance Binary (PacketState Signature3) where
+ put = putPacket
+ get = fmap fst (getPacket Signature3)
+
+
+
data Signature3 = Signature3
instance Packet Signature3 where
data PacketTag Signature3 = Signature3PacketTag
data PacketState Signature3 = MkSignaturePacket3 {
sig3Type :: SignatureType,
sig3Time :: UTCTime,
sig3KeyID :: KeyID,
sig3PKAlgorithm :: PublicKeyAlgorithm,
sig3HashAlgorithm :: HashAlgorithm,
sig3Data :: Either MPI (MPI, MPI)
}
packetTag Signature3 = Signature3PacketTag
+ packetTag' _ = Signature3PacketTag
packetTagNum Signature3PacketTag = 0x02
+ putPacketBody st = do
+ putWord8 0x03
+ putWord8 0x05
+ put $ sig3Type st
+ put $ sig3Time st
+ putWord64be $ sig3KeyID st
+ put $ sig3PKAlgorithm st
+ put $ sig3HashAlgorithm st
+ case (sig3Data st) of
+ Left a -> put a
+ Right (a,b) -> do put a; put b
+
bodyParser Signature3 = do
_ <- A.word8 3
l <- bodyLenParser OneOctedLength
if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
else do
stype <- parseSignatureType
t <- parseTime
keyid <- parseKeyID
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
\end{code}
Algorithm-Specific Fields for RSA signatures:
- multiprecision integer (MPI) of RSA signature value m**d mod n.
Algorithm-Specific Fields for DSA signatures:
- MPI of DSA value r.
- MPI of DSA value s.
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
\begin{code}
data Signature4 = Signature4
instance Packet Signature4 where
data PacketTag Signature4 = Signature4PacketTag
data PacketState Signature4 = MkSignaturePacket4 {
sig4Type :: SignatureType,
sig4Time :: UTCTime,
sig4KeyID :: KeyID,
sig4PKAlgorithm :: PublicKeyAlgorithm,
sig4HashAlgorithm :: HashAlgorithm,
sig4Data :: Either MPI (MPI, MPI)
}
packetTag Signature4 = Signature4PacketTag
packetTagNum Signature4PacketTag = 0x02
bodyParser Signature4 = do
_ <- A.word8 4
stype <- parseSignatureType
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
hashedSubPacketLength <- bodyLenParser TwoOctedLength
hashedSubpacketData <- A.take hashedSubPacketLength
subPacketLength <- bodyLenParser TwoOctedLength
subpacketData <- A.take subPacketLength
return undefined
{-
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
-}
\end{code}
5.2.3.1. Signature Subpacket Specification
A subpacket data set consists of zero or more Signature subpackets.
In Signature packets, the subpacket data set is preceded by a two-
octet scalar count of the length in octets of all the subpackets. A
pointer incremented by this number will skip over the subpacket data
set.
Each subpacket consists of a subpacket header and a body. The header
consists of:
- the subpacket length (1, 2, or 5 octets),
- the subpacket type (1 octet),
and is followed by the subpacket-specific data.
The length includes the type octet but not this length. Its format
is similar to the "new" format packet header lengths, but cannot have
Partial Body Lengths. That is:
if the 1st octet < 192, then
lengthOfLength = 1
subpacketLen = 1st_octet
if the 1st octet >= 192 and < 255, then
lengthOfLength = 2
subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
if the 1st octet = 255, then
lengthOfLength = 5
subpacket length = [four-octet scalar starting at 2nd_octet]
\begin{code}
class SignatureSubpacket s where
data SignatureSubpacketState s :: *
\end{code}
The value of the subpacket type octet may be:
0 = Reserved
1 = Reserved
2 = Signature Creation Time
3 = Signature Expiration Time
4 = Exportable Certification
5 = Trust Signature
6 = Regular Expression
7 = Revocable
8 = Reserved
9 = Key Expiration Time
10 = Placeholder for backward compatibility
11 = Preferred Symmetric Algorithms
12 = Revocation Key
13 = Reserved
14 = Reserved
15 = Reserved
16 = Issuer
17 = Reserved
18 = Reserved
19 = Reserved
20 = Notation Data
21 = Preferred Hash Algorithms
22 = Preferred Compression Algorithms
23 = Key Server Preferences
24 = Preferred Key Server
25 = Primary User ID
26 = Policy URI
27 = Key Flags
28 = Signer's User ID
29 = Reason for Revocation
30 = Features
31 = Signature Target
32 = Embedded Signature
100 To 110 = Private or experimental
An implementation SHOULD ignore any subpacket of a type that it does
not recognize.
Bit 7 of the subpacket type is the "critical" bit. If set, it
denotes that the subpacket is one that is critical for the evaluator
of the signature to recognize. If a subpacket is encountered that is
marked critical but is unknown to the evaluating software, the
evaluator SHOULD consider the signature to be in error.
An evaluator may "recognize" a subpacket, but not implement it. The
purpose of the critical bit is to allow the signer to tell an
evaluator that it would prefer a new, unknown feature to generate an
error than be ignored.
Implementations SHOULD implement the three preferred algorithm
subpackets (11, 21, and 22), as well as the "Reason for Revocation"
subpacket. Note, however, that if an implementation chooses not to
implement some of the preferences, it is required to behave in a
polite manner to respect the wishes of those users who do implement
these preferences.
5.2.3.2. Signature Subpacket Types
A number of subpackets are currently defined. Some subpackets apply
to the signature itself and some are attributes of the key.
Subpackets that are found on a self-signature are placed on a
certification made by the key itself. Note that a key may have more
than one User ID, and thus may have more than one self-signature, and
differing subpackets.
A subpacket may be found either in the hashed or unhashed subpacket
sections of a signature. If a subpacket is not hashed, then the
information in it cannot be considered definitive because it is not
part of the signature proper.
5.2.3.3. Notes on Self-Signatures
A self-signature is a binding signature made by the key to which the
signature refers. There are three types of self-signatures, the
certification signatures (types 0x10-0x13), the direct-key signature
(type 0x1F), and the subkey binding signature (type 0x18). For
certification self-signatures, each User ID may have a self-
signature, and thus different subpackets in those self-signatures.
For subkey binding signatures, each subkey in fact has a self-
signature. Subpackets that appear in a certification self-signature
apply to the user name, and subpackets that appear in the subkey
self-signature apply to the subkey. Lastly, subpackets on the
direct-key signature apply to the entire key.
Implementing software should interpret a self-signature's preference
subpackets as narrowly as possible. For example, suppose a key has
two user names, Alice and Bob. Suppose that Alice prefers the
symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the
software locates this key via Alice's name, then the preferred
algorithm is CAST5; if software locates the key via Bob's name, then
the preferred algorithm is IDEA. If the key is located by Key ID,
the algorithm of the primary User ID of the key provides the
preferred symmetric algorithm.
Revoking a self-signature or allowing it to expire has a semantic
meaning that varies with the signature type. Revoking the self-
signature on a User ID effectively retires that user name. The
self-signature is a statement, "My name X is tied to my signing key
K" and is corroborated by other users' certifications. If another
user revokes their certification, they are effectively saying that
they no longer believe that name and that key are tied together.
Similarly, if the users themselves revoke their self-signature, then
the users no longer go by that name, no longer have that email
address, etc. Revoking a binding signature effectively retires that
subkey. Revoking a direct-key signature cancels that signature.
Please see the "Reason for Revocation" subpacket (Section 5.2.3.23)
for more relevant detail.
Since a self-signature contains important information about the key's
use, an implementation SHOULD allow the user to rewrite the self-
signature, and important information in it, such as preferences and
key expiration.
It is good practice to verify that a self-signature imported into an
implementation doesn't advertise features that the implementation
doesn't support, rewriting the signature as appropriate.
An implementation that encounters multiple self-signatures on the
same object may resolve the ambiguity in any way it sees fit, but it
is RECOMMENDED that priority be given to the most recent self-
signature.
5.2.3.4. Signature Creation Time
(4-octet time field)
The time the signature was made.
MUST be present in the hashed area.
5.2.3.5. Issuer
(8-octet Key ID)
The OpenPGP Key ID of the key issuing the signature.
5.2.3.6. Key Expiration Time
(4-octet time field)
The validity period of the key. This is the number of seconds after
the key creation time that the key expires. If this is not present
or has a value of zero, the key never expires. This is found only on
a self-signature.
5.2.3.7. Preferred Symmetric Algorithms
(array of one-octet values)
Symmetric algorithm numbers that indicate which algorithms the key
holder prefers to use. The subpacket body is an ordered list of
octets with the most preferred listed first. It is assumed that only
algorithms listed are supported by the recipient's software.
Algorithm numbers are in Section 9. This is only found on a self-
signature.
5.2.3.8. Preferred Hash Algorithms
(array of one-octet values)
Message digest algorithm numbers that indicate which algorithms the
key holder prefers to receive. Like the preferred symmetric
algorithms, the list is ordered. Algorithm numbers are in Section 9.
This is only found on a self-signature.
5.2.3.9. Preferred Compression Algorithms
(array of one-octet values)
Compression algorithm numbers that indicate which algorithms the key
holder prefers to use. Like the preferred symmetric algorithms, the
list is ordered. Algorithm numbers are in Section 9. If this
subpacket is not included, ZIP is preferred. A zero denotes that
uncompressed data is preferred; the key holder's software might have
no compression software in that implementation. This is only found
on a self-signature.
5.2.3.10. Signature Expiration Time
(4-octet time field)
The validity period of the signature. This is the number of seconds
after the signature creation time that the signature expires. If
this is not present or has a value of zero, it never expires.
5.2.3.11. Exportable Certification
(1 octet of exportability, 0 for not, 1 for exportable)
This subpacket denotes whether a certification signature is
"exportable", to be used by other users than the signature's issuer.
The packet body contains a Boolean flag indicating whether the
signature is exportable. If this packet is not present, the
certification is exportable; it is equivalent to a flag containing a
1.
Non-exportable, or "local", certifications are signatures made by a
user to mark a key as valid within that user's implementation only.
Thus, when an implementation prepares a user's copy of a key for
transport to another user (this is the process of "exporting" the
key), any local certification signatures are deleted from the key.
The receiver of a transported key "imports" it, and likewise trims
any local certifications. In normal operation, there won't be any,
assuming the import is performed on an exported key. However, there
are instances where this can reasonably happen. For example, if an
implementation allows keys to be imported from a key database in
addition to an exported key, then this situation can arise.
Some implementations do not represent the interest of a single user
(for example, a key server). Such implementations always trim local
certifications from any key they handle.
5.2.3.12. Revocable
(1 octet of revocability, 0 for not, 1 for revocable)
Signature's revocability status. The packet body contains a Boolean
flag indicating whether the signature is revocable. Signatures that
are not revocable have any later revocation signatures ignored. They
represent a commitment by the signer that he cannot revoke his
signature for the life of his key. If this packet is not present,
the signature is revocable.
5.2.3.13. Trust Signature
@@ -2597,1024 +2627,1031 @@ class SignatureSubpacket s where
Considerations" for guidance.
5.14. Modification Detection Code Packet (Tag 19)
The Modification Detection Code packet contains a SHA-1 hash of
plaintext data, which is used to detect message modification. It is
only used with a Symmetrically Encrypted Integrity Protected Data
packet. The Modification Detection Code packet MUST be the last
packet in the plaintext data that is encrypted in the Symmetrically
Encrypted Integrity Protected Data packet, and MUST appear in no
other place.
A Modification Detection Code packet MUST have a length of 20 octets.
The body of this packet consists of:
- A 20-octet SHA-1 hash of the preceding plaintext data of the
Symmetrically Encrypted Integrity Protected Data packet,
including prefix data, the tag octet, and length octet of the
Modification Detection Code packet.
Note that the Modification Detection Code packet MUST always use a
new format encoding of the packet tag, and a one-octet encoding of
the packet length. The reason for this is that the hashing rules for
modification detection include a one-octet tag and one-octet length
in the data hash. While this is a bit restrictive, it reduces
complexity.
6. Radix-64 Conversions
As stated in the introduction, OpenPGP's underlying native
representation for objects is a stream of arbitrary octets, and some
systems desire these objects to be immune to damage caused by
character set translation, data conversions, etc.
In principle, any printable encoding scheme that met the requirements
of the unsafe channel would suffice, since it would not change the
underlying binary bit streams of the native OpenPGP data structures.
The OpenPGP standard specifies one such printable encoding scheme to
ensure interoperability.
OpenPGP's Radix-64 encoding is composed of two parts: a base64
encoding of the binary data and a checksum. The base64 encoding is
identical to the MIME base64 content-transfer-encoding [RFC2045].
The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to
four characters of radix-64 encoding by the same MIME base64
transformation, preceded by an equal sign (=). The CRC is computed
by using the generator 0x864CFB and an initialization of 0xB704CE.
The accumulation is done on the data before it is converted to
radix-64, rather than on the converted data. A sample implementation
of this algorithm is in the next section.
The checksum with its leading equal sign MAY appear on the first line
after the base64 encoded data.
Rationale for CRC-24: The size of 24 bits fits evenly into printable
base64. The nonzero initialization can detect more errors than a
zero initialization.
6.1. An Implementation of the CRC-24 in "C"
#define CRC24_INIT 0xB704CEL
#define CRC24_POLY 0x1864CFBL
typedef long crc24;
crc24 crc_octets(unsigned char *octets, size_t len)
{
crc24 crc = CRC24_INIT;
int i;
while (len--) {
crc ^= (*octets++) << 16;
for (i = 0; i < 8; i++) {
crc <<= 1;
if (crc & 0x1000000)
crc ^= CRC24_POLY;
}
}
return crc & 0xFFFFFFL;
}
\begin{code}
crc24_poly :: Word32
crc24_poly = 0x864cfb
crc24_init :: Word32
crc24_init = 0xb704cde
crc24 :: B.ByteString -> Word32
crc24 bs = let crc24' c w = 0xffffff `xor` (cycle $ c `xor` ((convert w) `shiftL` 16))
cycle :: Word32 -> Word32
cycle c = foldl (\c' _ -> let cs = (c' `shiftL` 1)
in if ((cs .&. 0x1000000) /= 0)
then cs `xor` crc24_poly else cs ) c [0..7]
in B.foldl crc24' crc24_init bs
\end{code}
6.2. Forming ASCII Armor
When OpenPGP encodes data into ASCII Armor, it puts specific headers
around the Radix-64 encoded data, so OpenPGP can reconstruct the data
later. An OpenPGP implementation MAY use ASCII armor to protect raw
binary data. OpenPGP informs the user what kind of data is encoded
in the ASCII armor through the use of the headers.
Concatenating the following data creates ASCII Armor:
- An Armor Header Line, appropriate for the type of data
- Armor Headers
- A blank (zero-length, or containing only whitespace) line
- The ASCII-Armored data
- An Armor Checksum
- The Armor Tail, which depends on the Armor Header Line
An Armor Header Line consists of the appropriate header line text
surrounded by five (5) dashes ('-', 0x2D) on either side of the
header line text. The header line text is chosen based upon the type
of data that is being encoded in Armor, and how it is being encoded.
Header line texts include the following strings:
BEGIN PGP MESSAGE
Used for signed, encrypted, or compressed files.
BEGIN PGP PUBLIC KEY BLOCK
Used for armoring public keys.
BEGIN PGP PRIVATE KEY BLOCK
Used for armoring private keys.
BEGIN PGP MESSAGE, PART X/Y
Used for multi-part messages, where the armor is split amongst Y
parts, and this is the Xth part out of Y.
BEGIN PGP MESSAGE, PART X
Used for multi-part messages, where this is the Xth part of an
unspecified number of parts. Requires the MESSAGE-ID Armor
Header to be used.
BEGIN PGP SIGNATURE
Used for detached signatures, OpenPGP/MIME signatures, and
cleartext signatures. Note that PGP 2.x uses BEGIN PGP MESSAGE
for detached signatures.
Note that all these Armor Header Lines are to consist of a complete
line. That is to say, there is always a line ending preceding the
starting five dashes, and following the ending five dashes. The
header lines, therefore, MUST start at the beginning of a line, and
MUST NOT have text other than whitespace following them on the same
line. These line endings are considered a part of the Armor Header
Line for the purposes of determining the content they delimit. This
is particularly important when computing a cleartext signature (see
below).
The Armor Headers are pairs of strings that can give the user or the
receiving OpenPGP implementation some information about how to decode
or use the message. The Armor Headers are a part of the armor, not a
part of the message, and hence are not protected by any signatures
applied to the message.
The format of an Armor Header is that of a key-value pair. A colon
(':' 0x38) and a single space (0x20) separate the key and value.
OpenPGP should consider improperly formatted Armor Headers to be
corruption of the ASCII Armor. Unknown keys should be reported to
the user, but OpenPGP should continue to process the message.
Note that some transport methods are sensitive to line length. While
there is a limit of 76 characters for the Radix-64 data (Section
6.3), there is no limit to the length of Armor Headers. Care should
be taken that the Armor Headers are short enough to survive
transport. One way to do this is to repeat an Armor Header key
multiple times with different values for each so that no one line is
overly long.
Currently defined Armor Header Keys are as follows:
- "Version", which states the OpenPGP implementation and version
used to encode the message.
- "Comment", a user-defined comment. OpenPGP defines all text to
be in UTF-8. A comment may be any UTF-8 string. However, the
whole point of armoring is to provide seven-bit-clean data.
Consequently, if a comment has characters that are outside the
US-ASCII range of UTF, they may very well not survive transport.
- "MessageID", a 32-character string of printable characters. The
string must be the same for all parts of a multi-part message
that uses the "PART X" Armor Header. MessageID strings should be
unique enough that the recipient of the mail can associate all
the parts of a message with each other. A good checksum or
cryptographic hash function is sufficient.
The MessageID SHOULD NOT appear unless it is in a multi-part
message. If it appears at all, it MUST be computed from the
finished (encrypted, signed, etc.) message in a deterministic
fashion, rather than contain a purely random value. This is to
allow the legitimate recipient to determine that the MessageID
cannot serve as a covert means of leaking cryptographic key
information.
- "Hash", a comma-separated list of hash algorithms used in this
message. This is used only in cleartext signed messages.
- "Charset", a description of the character set that the plaintext
is in. Please note that OpenPGP defines text to be in UTF-8. An
implementation will get best results by translating into and out
of UTF-8. However, there are many instances where this is easier
said than done. Also, there are communities of users who have no
need for UTF-8 because they are all happy with a character set
like ISO Latin-5 or a Japanese character set. In such instances,
an implementation MAY override the UTF-8 default by using this
header key. An implementation MAY implement this key and any
translations it cares to; an implementation MAY ignore it and
assume all text is UTF-8.
The Armor Tail Line is composed in the same manner as the Armor
Header Line, except the string "BEGIN" is replaced by the string
"END".
6.3. Encoding Binary in Radix-64
The encoding process represents 24-bit groups of input bits as output
strings of 4 encoded characters. Proceeding from left to right, a
24-bit input group is formed by concatenating three 8-bit input
groups. These 24 bits are then treated as four concatenated 6-bit
groups, each of which is translated into a single digit in the
Radix-64 alphabet. When encoding a bit stream with the Radix-64
encoding, the bit stream must be presumed to be ordered with the most
significant bit first. That is, the first bit in the stream will be
the high-order bit in the first 8-bit octet, and the eighth bit will
be the low-order bit in the first 8-bit octet, and so on.
+--first octet--+-second octet--+--third octet--+
|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
+-----------+---+-------+-------+---+-----------+
|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|
+--1.index--+--2.index--+--3.index--+--4.index--+
Each 6-bit group is used as an index into an array of 64 printable
characters from the table below. The character referenced by the
index is placed in the output string.
Value Encoding Value Encoding Value Encoding Value Encoding
0 A 17 R 34 i 51 z
1 B 18 S 35 j 52 0
2 C 19 T 36 k 53 1
3 D 20 U 37 l 54 2
4 E 21 V 38 m 55 3
5 F 22 W 39 n 56 4
6 G 23 X 40 o 57 5
7 H 24 Y 41 p 58 6
8 I 25 Z 42 q 59 7
9 J 26 a 43 r 60 8
10 K 27 b 44 s 61 9
11 L 28 c 45 t 62 +
12 M 29 d 46 u 63 /
13 N 30 e 47 v
14 O 31 f 48 w (pad) =
15 P 32 g 49 x
16 Q 33 h 50 y
The encoded output stream must be represented in lines of no more
than 76 characters each.
Special processing is performed if fewer than 24 bits are available
at the end of the data being encoded. There are three possibilities:
1. The last data group has 24 bits (3 octets). No special processing
is needed.
2. The last data group has 16 bits (2 octets). The first two 6-bit
groups are processed as above. The third (incomplete) data group
has two zero-value bits added to it, and is processed as above. A
pad character (=) is added to the output.
3. The last data group has 8 bits (1 octet). The first 6-bit group
is processed as above. The second (incomplete) data group has
four zero-value bits added to it, and is processed as above. Two
pad characters (=) are added to the output.
6.4. Decoding Radix-64
In Radix-64 data, characters other than those in the table, line
breaks, and other white space probably indicate a transmission error,
about which a warning message or even a message rejection might be
appropriate under some circumstances. Decoding software must ignore
all white space.
Because it is used only for padding at the end of the data, the
occurrence of any "=" characters may be taken as evidence that the
end of the data has been reached (without truncation in transit). No
such assurance is possible, however, when the number of octets
transmitted was a multiple of three and no "=" characters are
present.
6.5. Examples of Radix-64
Input data: 0x14FB9C03D97E
Hex: 1 4 F B 9 C | 0 3 D 9 7 E
8-bit: 00010100 11111011 10011100 | 00000011 11011001 11111110
6-bit: 000101 001111 101110 011100 | 000000 111101 100111 111110
Decimal: 5 15 46 28 0 61 37 62
Output: F P u c A 9 l +
Input data: 0x14FB9C03D9
Hex: 1 4 F B 9 C | 0 3 D 9
8-bit: 00010100 11111011 10011100 | 00000011 11011001
pad with 00
6-bit: 000101 001111 101110 011100 | 000000 111101 100100
Decimal: 5 15 46 28 0 61 36
pad with =
Output: F P u c A 9 k =
Input data: 0x14FB9C03
Hex: 1 4 F B 9 C | 0 3
8-bit: 00010100 11111011 10011100 | 00000011
pad with 0000
6-bit: 000101 001111 101110 011100 | 000000 110000
Decimal: 5 15 46 28 0 48
pad with = =
Output: F P u c A w = =
6.6. Example of an ASCII Armored Message
-----BEGIN PGP MESSAGE-----
Version: OpenPrivacy 0.99
yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
vBSFjNSiVHsuAA==
=njUN
-----END PGP MESSAGE-----
Note that this example has extra indenting; an actual armored message
would have no leading whitespace.
7. Cleartext Signature Framework
It is desirable to be able to sign a textual octet stream without
ASCII armoring the stream itself, so the signed text is still
readable without special software. In order to bind a signature to
such a cleartext, this framework is used. (Note that this framework
is not intended to be reversible. RFC 3156 [RFC3156] defines another
way to sign cleartext messages for environments that support MIME.)
The cleartext signed message consists of:
- The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a
single line,
- One or more "Hash" Armor Headers,
- Exactly one empty line not included into the message digest,
- The dash-escaped cleartext that is included into the message
digest,
- The ASCII armored signature(s) including the '-----BEGIN PGP
SIGNATURE-----' Armor Header and Armor Tail Lines.
If the "Hash" Armor Header is given, the specified message digest
algorithm(s) are used for the signature. If there are no such
headers, MD5 is used. If MD5 is the only hash used, then an
implementation MAY omit this header for improved V2.x compatibility.
If more than one message digest is used in the signature, the "Hash"
armor header contains a comma-delimited list of used message digests.
Current message digest names are described below with the algorithm
IDs.
An implementation SHOULD add a line break after the cleartext, but
MAY omit it if the cleartext ends with a line break. This is for
visual clarity.
7.1. Dash-Escaped Text
The cleartext content of the message must also be dash-escaped.
Dash-escaped cleartext is the ordinary cleartext where every line
starting with a dash '-' (0x2D) is prefixed by the sequence dash '-'
(0x2D) and space ' ' (0x20). This prevents the parser from
recognizing armor headers of the cleartext itself. An implementation
MAY dash-escape any line, SHOULD dash-escape lines commencing "From"
followed by a space, and MUST dash-escape any line commencing in a
dash. The message digest is computed using the cleartext itself, not
the dash-escaped form.
As with binary signatures on text documents, a cleartext signature is
calculated on the text using canonical <CR><LF> line endings. The
line ending (i.e., the <CR><LF>) before the '-----BEGIN PGP
SIGNATURE-----' line that terminates the signed text is not
considered part of the signed text.
When reversing dash-escaping, an implementation MUST strip the string
"- " if it occurs at the beginning of a line, and SHOULD warn on "-"
and any character other than a space at the beginning of a line.
Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at
the end of any line is removed when the cleartext signature is
generated.
8. Regular Expressions
A regular expression is zero or more branches, separated by '|'. It
matches anything that matches one of the branches.
A branch is zero or more pieces, concatenated. It matches a match
for the first, followed by a match for the second, etc.
A piece is an atom possibly followed by '*', '+', or '?'. An atom
followed by '*' matches a sequence of 0 or more matches of the atom.
An atom followed by '+' matches a sequence of 1 or more matches of
the atom. An atom followed by '?' matches a match of the atom, or
the null string.
An atom is a regular expression in parentheses (matching a match for
the regular expression), a range (see below), '.' (matching any
single character), '^' (matching the null string at the beginning of
the input string), '$' (matching the null string at the end of the
input string), a '\' followed by a single character (matching that
character), or a single character with no other significance
(matching that character).
A range is a sequence of characters enclosed in '[]'. It normally
matches any single character from the sequence. If the sequence
begins with '^', it matches any single character not from the rest of
the sequence. If two characters in the sequence are separated
by '-', this is shorthand for the full list of ASCII characters
between them (e.g., '[0-9]' matches any decimal digit). To include a
literal ']' in the sequence, make it the first character (following a
possible '^'). To include a literal '-', make it the first or last
character.
9. Constants
This section describes the constants used in OpenPGP.
Note that these tables are not exhaustive lists; an implementation
MAY implement an algorithm not on these lists, so long as the
algorithm numbers are chosen from the private or experimental
algorithm range.
See the section "Notes on Algorithms" below for more discussion of
the algorithms.
9.1. Public-Key Algorithms
ID Algorithm
-- ---------
1 - RSA (Encrypt or Sign) [HAC]
2 - RSA Encrypt-Only [HAC]
3 - RSA Sign-Only [HAC]
16 - Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
17 - DSA (Digital Signature Algorithm) [FIPS186] [HAC]
18 - Reserved for Elliptic Curve
19 - Reserved for ECDSA
20 - Reserved (formerly Elgamal Encrypt or Sign)
21 - Reserved for Diffie-Hellman (X9.42,
as defined for IETF-S/MIME)
100 to 110 - Private/Experimental algorithm
Implementations MUST implement DSA for signatures, and Elgamal for
encryption. Implementations SHOULD implement RSA keys (1). RSA
Encrypt-Only (2) and RSA Sign-Only are deprecated and SHOULD NOT be
generated, but may be interpreted. See Section 13.5. See Section
13.8 for notes on Elliptic Curve (18), ECDSA (19), Elgamal Encrypt or
Sign (20), and X9.42 (21). Implementations MAY implement any other
algorithm.
\begin{code}
data PublicKeyAlgorithm =
RSAEncryptOrSign |
RSAEncryptOnly |
RSASignOnly |
ElgamalEncryptOnly |
DSA
deriving (Show, Read, Eq, Enum)
publicKeyAlgorithmCoding = [
(RSAEncryptOrSign, 1),
(RSAEncryptOnly, 2),
(RSASignOnly, 3),
(ElgamalEncryptOnly, 16),
(DSA, 17)
]
lookupPublicKeyAlgorithm :: Word8 -> Maybe PublicKeyAlgorithm
lookupPublicKeyAlgorithm i = lookup i $ map swap publicKeyAlgorithmCoding
publicKeyAlgorithmToNum :: PublicKeyAlgorithm -> Maybe Word8
publicKeyAlgorithmToNum p = lookup p publicKeyAlgorithmCoding
parsePublicKeyAlgorithm :: Parser PublicKeyAlgorithm
parsePublicKeyAlgorithm = do
w <- A.anyWord8
case (lookupPublicKeyAlgorithm w) of
Nothing -> fail "unknown public key algorithm"
Just a -> return a
+
+instance Binary PublicKeyAlgorithm where
+ get = parserToGet parsePublicKeyAlgorithm
+ put a = case (publicKeyAlgorithmToNum a) of
+ Nothing -> fail $ "unknown PublicKeyAlgorithm " ++ show a
+ Just a' -> putWord8 a'
+
\end{code}
9.2. Symmetric-Key Algorithms
ID Algorithm
-- ---------
0 - Plaintext or unencrypted data
1 - IDEA [IDEA]
2 - TripleDES (DES-EDE, [SCHNEIER] [HAC] -
168 bit key derived from 192)
3 - CAST5 (128 bit key, as per [RFC2144])
4 - Blowfish (128 bit key, 16 rounds) [BLOWFISH]
5 - Reserved
6 - Reserved
7 - AES with 128-bit key [AES]
8 - AES with 192-bit key
9 - AES with 256-bit key
10 - Twofish with 256-bit key [TWOFISH]
100 to 110 - Private/Experimental algorithm
Implementations MUST implement TripleDES. Implementations SHOULD
implement AES-128 and CAST5. Implementations that interoperate with
PGP 2.6 or earlier need to support IDEA, as that is the only
symmetric cipher those versions use. Implementations MAY implement
any other algorithm.
9.3. Compression Algorithms
ID Algorithm
-- ---------
0 - Uncompressed
1 - ZIP [RFC1951]
2 - ZLIB [RFC1950]
3 - BZip2 [BZ2]
100 to 110 - Private/Experimental algorithm
Implementations MUST implement uncompressed data. Implementations
SHOULD implement ZIP. Implementations MAY implement any other
algorithm.
9.4. Hash Algorithms
ID Algorithm Text Name
-- --------- ---------
1 - MD5 [HAC] "MD5"
2 - SHA-1 [FIPS180] "SHA1"
3 - RIPE-MD/160 [HAC] "RIPEMD160"
4 - Reserved
5 - Reserved
6 - Reserved
7 - Reserved
8 - SHA256 [FIPS180] "SHA256"
9 - SHA384 [FIPS180] "SHA384"
10 - SHA512 [FIPS180] "SHA512"
11 - SHA224 [FIPS180] "SHA224"
100 to 110 - Private/Experimental algorithm
Implementations MUST implement SHA-1. Implementations MAY implement
other algorithms. MD5 is deprecated.
\begin{code}
data HashAlgorithm =
MD5 |
SHA1 |
RIPEMD160 |
SHA256 |
SHA384 |
SHA512 |
SHA224 |
PrivateHashAlgo Word8
deriving (Show, Read, Eq)
hashAlgorithmCoding = [
(MD5, 1),
(SHA1, 2),
(RIPEMD160, 3),
(SHA256, 8),
(SHA384, 9),
(SHA512, 10),
(SHA224, 11)
]
lookupHashAlgorithm :: Word8 -> Maybe HashAlgorithm
lookupHashAlgorithm h =
if ((h >= 100) && (h <= 100))
then Just $ PrivateHashAlgo h
else lookup h $ map swap hashAlgorithmCoding
hashAlgorithmToNum :: HashAlgorithm -> Maybe Word8
hashAlgorithmToNum (PrivateHashAlgo h) = Just h
hashAlgorithmToNum h = lookup h hashAlgorithmCoding
parseHashAlgorithm :: Parser HashAlgorithm
parseHashAlgorithm = do
w <- A.anyWord8
case (lookupHashAlgorithm w) of
Just a -> return a
Nothing -> fail $ "unknown hash algorithm " ++ show w
instance Binary HashAlgorithm where
get = parserToGet parseHashAlgorithm
put a = case (hashAlgorithmToNum a) of
Nothing -> fail "unable to put unknown hash algorithm"
Just a' -> putWord8 a'
\end{code}
10. IANA Considerations
OpenPGP is highly parameterized, and consequently there are a number
of considerations for allocating parameters for extensions. This
section describes how IANA should look at extensions to the protocol
as described in this document.
10.1. New String-to-Key Specifier Types
OpenPGP S2K specifiers contain a mechanism for new algorithms to turn
a string into a key. This specification creates a registry of S2K
specifier types. The registry includes the S2K type, the name of the
S2K, and a reference to the defining specification. The initial
values for this registry can be found in Section 3.7.1. Adding a new
S2K specifier MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.2. New Packets
Major new features of OpenPGP are defined through new packet types.
This specification creates a registry of packet types. The registry
includes the packet type, the name of the packet, and a reference to
the defining specification. The initial values for this registry can
be found in Section 4.3. Adding a new packet type MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.2.1. User Attribute Types
The User Attribute packet permits an extensible mechanism for other
types of certificate identification. This specification creates a
registry of User Attribute types. The registry includes the User
Attribute type, the name of the User Attribute, and a reference to
the defining specification. The initial values for this registry can
be found in Section 5.12. Adding a new User Attribute type MUST be
done through the IETF CONSENSUS method, as described in [RFC2434].
10.2.1.1. Image Format Subpacket Types
Within User Attribute packets, there is an extensible mechanism for
other types of image-based user attributes. This specification
creates a registry of Image Attribute subpacket types. The registry
includes the Image Attribute subpacket type, the name of the Image
Attribute subpacket, and a reference to the defining specification.
The initial values for this registry can be found in Section 5.12.1.
Adding a new Image Attribute subpacket type MUST be done through the
IETF CONSENSUS method, as described in [RFC2434].
10.2.2. New Signature Subpackets
OpenPGP signatures contain a mechanism for signed (or unsigned) data
to be added to them for a variety of purposes in the Signature
subpackets as discussed in Section 5.2.3.1. This specification
creates a registry of Signature subpacket types. The registry
includes the Signature subpacket type, the name of the subpacket, and
this registry can be found in Section 5.2.3.1. Adding a new
Signature subpacket MUST be done through the IETF CONSENSUS method,
as described in [RFC2434].
10.2.2.1. Signature Notation Data Subpackets
OpenPGP signatures further contain a mechanism for extensions in
signatures. These are the Notation Data subpackets, which contain a
key/value pair. Notations contain a user space that is completely
unmanaged and an IETF space.
This specification creates a registry of Signature Notation Data
types. The registry includes the Signature Notation Data type, the
name of the Signature Notation Data, its allowed values, and a
reference to the defining specification. The initial values for this
registry can be found in Section 5.2.3.16. Adding a new Signature
Notation Data subpacket MUST be done through the EXPERT REVIEW
method, as described in [RFC2434].
10.2.2.2. Key Server Preference Extensions
OpenPGP signatures contain a mechanism for preferences to be
specified about key servers. This specification creates a registry
of key server preferences. The registry includes the key server
preference, the name of the preference, and a reference to the
defining specification. The initial values for this registry can be
found in Section 5.2.3.17. Adding a new key server preference MUST
be done through the IETF CONSENSUS method, as described in [RFC2434].
10.2.2.3. Key Flags Extensions
OpenPGP signatures contain a mechanism for flags to be specified
about key usage. This specification creates a registry of key usage
flags. The registry includes the key flags value, the name of the
flag, and a reference to the defining specification. The initial
values for this registry can be found in Section 5.2.3.21. Adding a
new key usage flag MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.2.2.4. Reason for Revocation Extensions
OpenPGP signatures contain a mechanism for flags to be specified
about why a key was revoked. This specification creates a registry
of "Reason for Revocation" flags. The registry includes the "Reason
for Revocation" flags value, the name of the flag, and a reference to
the defining specification. The initial values for this registry can
be found in Section 5.2.3.23. Adding a new feature flag MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.2.2.5. Implementation Features
OpenPGP signatures contain a mechanism for flags to be specified
stating which optional features an implementation supports. This
specification creates a registry of feature-implementation flags.
The registry includes the feature-implementation flags value, the
name of the flag, and a reference to the defining specification. The
initial values for this registry can be found in Section 5.2.3.24.
Adding a new feature-implementation flag MUST be done through the
IETF CONSENSUS method, as described in [RFC2434].
Also see Section 13.12 for more information about when feature flags
are needed.
10.2.3. New Packet Versions
The core OpenPGP packets all have version numbers, and can be revised
by introducing a new version of an existing packet. This
specification creates a registry of packet types. The registry
includes the packet type, the number of the version, and a reference
to the defining specification. The initial values for this registry
can be found in Section 5. Adding a new packet version MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.3. New Algorithms
Section 9 lists the core algorithms that OpenPGP uses. Adding in a
new algorithm is usually simple. For example, adding in a new
symmetric cipher usually would not need anything more than allocating
a constant for that cipher. If that cipher had other than a 64-bit
or 128-bit block size, there might need to be additional
documentation describing how OpenPGP-CFB mode would be adjusted.
Similarly, when DSA was expanded from a maximum of 1024-bit public
keys to 3072-bit public keys, the revision of FIPS 186 contained
enough information itself to allow implementation. Changes to this
document were made mainly for emphasis.
10.3.1. Public-Key Algorithms
OpenPGP specifies a number of public-key algorithms. This
specification creates a registry of public-key algorithm identifiers.
The registry includes the algorithm name, its key sizes and
parameters, and a reference to the defining specification. The
initial values for this registry can be found in Section 9. Adding a
new public-key algorithm MUST be done through the IETF CONSENSUS
method, as described in [RFC2434].
Callas, et al Standards Track [Page 66]
RFC 4880 OpenPGP Message Format November 2007
10.3.2. Symmetric-Key Algorithms
OpenPGP specifies a number of symmetric-key algorithms. This
specification creates a registry of symmetric-key algorithm
identifiers. The registry includes the algorithm name, its key sizes
and block size, and a reference to the defining specification. The
initial values for this registry can be found in Section 9. Adding a
new symmetric-key algorithm MUST be done through the IETF CONSENSUS
method, as described in [RFC2434].
10.3.3. Hash Algorithms
OpenPGP specifies a number of hash algorithms. This specification
creates a registry of hash algorithm identifiers. The registry
includes the algorithm name, a text representation of that name, its
block size, an OID hash prefix, and a reference to the defining
specification. The initial values for this registry can be found in
Section 9 for the algorithm identifiers and text names, and Section
5.2.2 for the OIDs and expanded signature prefixes. Adding a new
hash algorithm MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.3.4. Compression Algorithms
OpenPGP specifies a number of compression algorithms. This
specification creates a registry of compression algorithm
identifiers. The registry includes the algorithm name and a
reference to the defining specification. The initial values for this
registry can be found in Section 9.3. Adding a new compression key
algorithm MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
11. Packet Composition
OpenPGP packets are assembled into sequences in order to create
messages and to transfer keys. Not all possible packet sequences are
meaningful and correct. This section describes the rules for how
packets should be placed into sequences.
11.1. Transferable Public Keys
OpenPGP users may transfer public keys. The essential elements of a
transferable public key are as follows:
- One Public-Key packet
- Zero or more revocation signatures
- One or more User ID packets
- After each User ID packet, zero or more Signature packets
(certifications)
- Zero or more User Attribute packets
- After each User Attribute packet, zero or more Signature packets
(certifications)
- Zero or more Subkey packets
- After each Subkey packet, one Signature packet, plus optionally a
revocation
The Public-Key packet occurs first. Each of the following User ID
packets provides the identity of the owner of this public key. If
there are multiple User ID packets, this corresponds to multiple
means of identifying the same unique individual user; for example, a
user may have more than one email address, and construct a User ID
for each one.
Immediately following each User ID packet, there are zero or more
Signature packets. Each Signature packet is calculated on the
immediately preceding User ID packet and the initial Public-Key
packet. The signature serves to certify the corresponding public key
and User ID. In effect, the signer is testifying to his or her
belief that this public key belongs to the user identified by this
User ID.
Within the same section as the User ID packets, there are zero or
more User Attribute packets. Like the User ID packets, a User
Attribute packet is followed by zero or more Signature packets
calculated on the immediately preceding User Attribute packet and the
initial Public-Key packet.
User Attribute packets and User ID packets may be freely intermixed
in this section, so long as the signatures that follow them are
maintained on the proper User Attribute or User ID packet.
After the User ID packet or Attribute packet, there may be zero or
more Subkey packets. In general, subkeys are provided in cases where
the top-level public key is a signature-only key. However, any V4
key may have subkeys, and the subkeys may be encryption-only keys,
signature-only keys, or general-purpose keys. V3 keys MUST NOT have
subkeys.
Each Subkey packet MUST be followed by one Signature packet, which
should be a subkey binding signature issued by the top-level key.
For subkeys that can issue signatures, the subkey binding signature
MUST contain an Embedded Signature subpacket with a primary key
binding signature (0x19) issued by the subkey on the top-level key.
Subkey and Key packets may each be followed by a revocation Signature
packet to indicate that the key is revoked. Revocation signatures
are only accepted if they are issued by the key itself, or by a key
that is authorized to issue revocations via a Revocation Key
subpacket in a self-signature by the top-level key.
Transferable public-key packet sequences may be concatenated to allow
transferring multiple public keys in one operation.
11.2. Transferable Secret Keys
OpenPGP users may transfer secret keys. The format of a transferable
secret key is the same as a transferable public key except that
secret-key and secret-subkey packets are used instead of the public
key and public-subkey packets. Implementations SHOULD include self-
signatures on any user IDs and subkeys, as this allows for a complete
public key to be automatically extracted from the transferable secret
key. Implementations MAY choose to omit the self-signatures,
especially if a transferable public key accompanies the transferable
secret key.
11.3. OpenPGP Messages
An OpenPGP message is a packet or sequence of packets that
corresponds to the following grammatical rules (comma represents
sequential composition, and vertical bar separates alternatives):
OpenPGP Message :- Encrypted Message | Signed Message |
Compressed Message | Literal Message.
Compressed Message :- Compressed Data Packet.
Literal Message :- Literal Data Packet.
ESK :- Public-Key Encrypted Session Key Packet |
Symmetric-Key Encrypted Session Key Packet.
ESK Sequence :- ESK | ESK Sequence, ESK.
Encrypted Data :- Symmetrically Encrypted Data Packet |
Symmetrically Encrypted Integrity Protected Data Packet
Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data.
One-Pass Signed Message :- One-Pass Signature Packet,
OpenPGP Message, Corresponding Signature Packet.
Signed Message :- Signature Packet, OpenPGP Message |
One-Pass Signed Message.
In addition, decrypting a Symmetrically Encrypted Data packet or a
Symmetrically Encrypted Integrity Protected Data packet as well as
decompressing a Compressed Data packet must yield a valid OpenPGP
Message.
11.4. Detached Signatures
Some OpenPGP applications use so-called "detached signatures". For
example, a program bundle may contain a file, and with it a second
file that is a detached signature of the first file. These detached
signatures are simply a Signature packet stored separately from the
data for which they are a signature.
12. Enhanced Key Formats
12.1. Key Structures
The format of an OpenPGP V3 key is as follows. Entries in square
brackets are optional and ellipses indicate repetition.
RSA Public Key
[Revocation Self Signature]
User ID [Signature ...]
[User ID [Signature ...] ...]
Each signature certifies the RSA public key and the preceding User
ID. The RSA public key can have many User IDs and each User ID can
have many signatures. V3 keys are deprecated. Implementations MUST
NOT generate new V3 keys, but MAY continue to use existing ones.
The format of an OpenPGP V4 key that uses multiple public keys is
similar except that the other keys are added to the end as "subkeys"
of the primary key.
Primary-Key
[Revocation Self Signature]
[Direct Key Signature...]
User ID [Signature ...]
[User ID [Signature ...] ...]
[User Attribute [Signature ...] ...]
[[Subkey [Binding-Signature-Revocation]
Primary-Key-Binding-Signature] ...]
A subkey always has a single signature after it that is issued using
the primary key to tie the two keys together. This binding signature
may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can
issue signatures MUST have a V4 binding signature due to the REQUIRED
embedded primary key binding signature.
In the above diagram, if the binding signature of a subkey has been
revoked, the revoked key may be removed, leaving only one key.
In a V4 key, the primary key MUST be a key capable of certification.
The subkeys may be keys of any other type. There may be other
constructions of V4 keys, too. For example, there may be a single-
key RSA key in V4 format, a DSA primary key with an RSA encryption
key, or RSA primary key with an Elgamal subkey, etc.
It is also possible to have a signature-only subkey. This permits a
primary key that collects certifications (key signatures), but is
used only for certifying subkeys that are used for encryption and
signatures.
12.2. Key IDs and Fingerprints
diff --git a/OpenPGPTests.hs b/OpenPGPTests.hs
index 68b87d0..1dfe399 100644
--- a/OpenPGPTests.hs
+++ b/OpenPGPTests.hs
@@ -1,100 +1,116 @@
{-# LANGUAGE FlexibleInstances #-}
module Main where
import OpenPGP
import Test.QuickCheck
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString as BS
import qualified Data.Attoparsec as A
import Data.Convertible
import Data.Time (UTCTime(..), picosecondsToDiffTime)
import System.Time (ClockTime(..))
main = do
chk prop_MPIBinary
chk prop_KeyIDParser
chk prop_UTCTimeBinary
chk prop_StringToKeySpecifierBinary
+ chk prop_SignatureTypeBinary
+ chk prop_PublicKeyAlgorithmBinary
chk prop_PEKSKPBinary
return ()
where
chk :: Testable prop => prop -> IO ()
chk = quickCheck
-- chk = verboseCheck
instance Arbitrary HashAlgorithm where
arbitrary = elements [ MD5,SHA1,RIPEMD160,SHA256,SHA384,SHA512,SHA224 ]
rPut :: Binary t => t -> ByteString
rPut = runPut . put
rGet :: Binary t => ByteString -> t
rGet bs = runGet get bs
rPutGet :: Binary t => t -> t
rPutGet = rGet . rPut
instance Arbitrary MPI where
arbitrary = fmap (MPI . BS.pack) arbitrary
prop_MPIBinary :: [Word8] -> Property
prop_MPIBinary bs =
let mpi = (MPI . BS.pack) bs
in label "MPI binary test" (mpi == rPutGet mpi)
prop_KeyIDParser :: KeyID -> Property
prop_KeyIDParser kid =
let ekid = convert $ rPut kid
rdkid = A.maybeResult $ A.parse parseKeyID ekid
dkid = case rdkid of
Nothing -> error "unable to parse KeyID"
Just a -> a
in label "KeyID parser test" (kid == dkid)
prop_UTCTimeBinary :: Integer -> Property
prop_UTCTimeBinary i =
let utc :: UTCTime
utc = convert $ TOD (abs i) 0
in label "UTCTime binary test" $ utc == rPutGet utc
instance Arbitrary StringToKeySpecifier where
arbitrary = do
n <- choose (0, 2) :: Gen Int
a <- arbitrary
s <- arbitrary
i <- arbitrary
return $ case n of
0 -> SimpleS2K a
1 -> SaltedS2K a s
2 -> IteratedAndSaltedS2K a s i
-
prop_StringToKeySpecifierBinary :: StringToKeySpecifier -> Property
prop_StringToKeySpecifierBinary s2k =
label "StringToKeySpecifier binary test" $ s2k == rPutGet s2k
+instance Arbitrary SignatureType where
+ arbitrary = elements $ map fst signatureTypeCoding
+
+prop_SignatureTypeBinary :: SignatureType -> Property
+prop_SignatureTypeBinary s =
+ label "SignatureType binary test" $ s == rPutGet s
+instance Arbitrary PublicKeyAlgorithm where
+ arbitrary = elements $ map fst publicKeyAlgorithmCoding
+
+prop_PublicKeyAlgorithmBinary :: PublicKeyAlgorithm -> Property
+prop_PublicKeyAlgorithmBinary a =
+ label "PublicKeyAlgorithm binary test" $ a == rPutGet a
instance Arbitrary (PacketState PEKSKP) where
arbitrary = do
- keyid <- arbitrary
+ keyid' <- arbitrary
+ let keyid = if (keyid' == 0) then Nothing else Just keyid'
a <- arbitrary
b <- arbitrary
n <- choose (0, 2) :: Gen Int
return $ case n of
0 -> MkPEKSKP keyid RSAEncryptOrSign (Left a)
1 -> MkPEKSKP keyid RSAEncryptOrSign (Left a)
2 -> MkPEKSKP keyid ElgamalEncryptOnly (Right (a,b))
prop_PEKSKPBinary :: PacketState PEKSKP -> Property
prop_PEKSKPBinary p =
- label "PacketState PEKSKP binary test" $ p == rPutGet p
\ No newline at end of file
+ label "PacketState PEKSKP binary test" $ p == rPutGet p
+
+
|
alios/lab
|
6012e9e30b0a110da74d6891d3ab1929b62bf243
|
removed debugging code
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index 87a6e56..7a80088 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -213,1044 +213,1024 @@ data StringToKeySpecifier =
deriving (Eq, Show)
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
instance Binary StringToKeySpecifier where
get = parserToGet parseStringToKeySpecifier
put (SimpleS2K a) = do
putWord8 0x00
put a
put (SaltedS2K a s) = do
putWord8 0x01
put a
put s
put (IteratedAndSaltedS2K a s i) = do
putWord8 0x03
put a
put s
putWord8 i
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
hashAlgo <- parseHashAlgorithm
return $ SimpleS2K hashAlgo
\end{code}
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgorithm
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
\end{code}
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
_ <- A.word8 0x03
hashAlgo <- parseHashAlgorithm
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
5. Packet Types
\begin{code}
class Packet t where
data PacketState t :: *
data PacketTag t :: *
packetTag :: t -> PacketTag t
packetTag' :: (PacketState t) -> PacketTag t
packetTagNum :: PacketTag t -> Word8
bodyParser :: t -> Parser (PacketState t)
isOldPacketTag :: PacketTag t -> Bool
isOldPacketTag = ((<) 16) . packetTagNum
putPacketBody :: PacketState t -> Put
putPacket :: PacketState t -> Put
putPacket st = do
putWord8 $ (packetTagNum . packetTag') st -- TODO: support old packet header format
putPacketBody st
getPacket :: t -> Get (PacketState t, Maybe PacketLength)
getPacket = parserToGet . parsePacket
parsePacket :: t -> Parser (PacketState t, Maybe PacketLength)
parsePacket t =
let n = (packetTagNum . packetTag) t
isOld = (isOldPacketTag . packetTag) t
in do
w <- A.anyWord8
let maskedPacket = w .&. 0x3f
if (w `testBit` 7)
then fail $ "no valid packet header"
else if (maskedPacket /= n) then fail $ "read invalid header tag " ++ show maskedPacket
else if (isOld)
then do
body <- bodyParser t
case (lookupPacketLength $ maskedPacket .&. 0x03) of
Nothing -> fail ""
Just len -> return (body, Just len)
else do
body <- bodyParser t
return (body, Nothing)
\end{code}
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
\begin{code}
data PEKSKP = PEKSKP
-{-
- RSAEncryptOrSign |
- RSAEncryptOnly |
- RSASignOnly |
- ElgamalEncryptOnly |
- DSA
--}
-
-d = [234,34,2,34,34,6,63,3,45,76,32,1,34,6,67,3,2]
-st = MkPEKSKP (Just 0x23) RSAEncryptOrSign (Left . MPI $ BS.pack d)
-
-p = runPut $ putPacket st
-p' = B.unpack p
-
-g :: B.ByteString -> (PacketState PEKSKP, Maybe PacketLength)
-g bs = runGet (getPacket PEKSKP) bs
-
-g' = g p
-
-x = fst g' == st
instance Eq (PacketState PEKSKP) where
(MkPEKSKP k a d) == (MkPEKSKP k' a' d') = and [k == k', a == a', d == d']
instance Binary (PacketState PEKSKP) where
put = putPacket
get = fmap fst (getPacket PEKSKP)
instance Packet PEKSKP where
data PacketTag PEKSKP = PEKSKPPacketTag
data PacketState PEKSKP = MkPEKSKP {
pekskpKeyID :: Maybe KeyID,
pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
pekskpData :: Either MPI (MPI, MPI)
} deriving (Show)
packetTag _ = PEKSKPPacketTag
packetTag' _ = PEKSKPPacketTag
packetTagNum _ = 0x01
bodyParser PEKSKP = do
_ <- A.word8 3
keyid' <- parseKeyID
let keyid = if (keyid' == 0) then Nothing else Just keyid'
algo <- parsePublicKeyAlgorithm
encKey <- case (algo) of
RSAEncryptOrSign -> parseRSAEncryptedSessionKey
RSAEncryptOnly -> parseRSAEncryptedSessionKey
ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
otherwise -> fail $ "unknown encryption algorithm " ++ show algo
return $ MkPEKSKP keyid algo encKey
where parseRSAEncryptedSessionKey = fmap Left parseMPI
parseElgamalEncryptedSessionKey = do
a <- parseMPI
b <- parseMPI
return $ Right (a, b)
putPacketBody ps = do
putWord8 0x3
putWord64be $ maybe 0 id $ pekskpKeyID ps
putWord8 $ (fromJust . publicKeyAlgorithmToNum . pekskpPublicKeyAlgorithm) ps
either put (\(a,b) -> do put a ; put b) $ pekskpData ps
\end{code}
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
\begin{code}
data SignatureType =
SignatureBinaryDoc |
SignatureCanonicalTextDoc |
StandaloneSignature |
GenericCertificationOfAUserIDAndPublicKeyPacket |
PersonaCertificationOfAUserIDAndPublicKeyPacket |
CasualCertificationOfAUserIDAndPublicKeyPacket |
PositiveCertificationOfAUserIDAndPublicKeyPacket |
SubkeyBindingSignature |
PrimaryKeyBindingSignature |
SignatureDirectlyOnAKey |
KeyRevocationSignature |
SubkeyRevocationSignature |
CertificationRevocationSignature |
TimestampSignature |
ThirdPartyConfirmationSignature
deriving (Show, Read, Eq, Enum)
signatureTypeCoding = [
(SignatureBinaryDoc , 0x00),
(SignatureCanonicalTextDoc , 0x01),
(StandaloneSignature , 0x02),
(GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
(PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
(CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
(PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
(SubkeyBindingSignature , 0x18),
(PrimaryKeyBindingSignature , 0x19),
(SignatureDirectlyOnAKey , 0x1F),
(KeyRevocationSignature , 0x20),
(SubkeyRevocationSignature , 0x28),
(CertificationRevocationSignature , 0x30),
(TimestampSignature , 0x40),
(ThirdPartyConfirmationSignature , 0x50)
]
lookupSignatureType :: Word8 -> Maybe SignatureType
lookupSignatureType i = lookup i $ map swap signatureTypeCoding
signatureTypeToNum :: SignatureType -> Maybe Word8
signatureTypeToNum p = lookup p signatureTypeCoding
parseSignatureType :: Parser SignatureType
parseSignatureType = do
w <- A.anyWord8
case (lookupSignatureType w) of
Nothing -> fail "unknown signature type"
Just a -> return a
\end{code}
5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
\begin{code}
data Signature3 = Signature3
instance Packet Signature3 where
data PacketTag Signature3 = Signature3PacketTag
data PacketState Signature3 = MkSignaturePacket3 {
sig3Type :: SignatureType,
sig3Time :: UTCTime,
sig3KeyID :: KeyID,
sig3PKAlgorithm :: PublicKeyAlgorithm,
sig3HashAlgorithm :: HashAlgorithm,
sig3Data :: Either MPI (MPI, MPI)
}
packetTag Signature3 = Signature3PacketTag
packetTagNum Signature3PacketTag = 0x02
bodyParser Signature3 = do
_ <- A.word8 3
l <- bodyLenParser OneOctedLength
if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
else do
stype <- parseSignatureType
t <- parseTime
keyid <- parseKeyID
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
\end{code}
Algorithm-Specific Fields for RSA signatures:
- multiprecision integer (MPI) of RSA signature value m**d mod n.
Algorithm-Specific Fields for DSA signatures:
- MPI of DSA value r.
- MPI of DSA value s.
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
\begin{code}
data Signature4 = Signature4
instance Packet Signature4 where
data PacketTag Signature4 = Signature4PacketTag
data PacketState Signature4 = MkSignaturePacket4 {
sig4Type :: SignatureType,
sig4Time :: UTCTime,
sig4KeyID :: KeyID,
sig4PKAlgorithm :: PublicKeyAlgorithm,
sig4HashAlgorithm :: HashAlgorithm,
sig4Data :: Either MPI (MPI, MPI)
}
packetTag Signature4 = Signature4PacketTag
packetTagNum Signature4PacketTag = 0x02
bodyParser Signature4 = do
_ <- A.word8 4
stype <- parseSignatureType
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
hashedSubPacketLength <- bodyLenParser TwoOctedLength
hashedSubpacketData <- A.take hashedSubPacketLength
subPacketLength <- bodyLenParser TwoOctedLength
subpacketData <- A.take subPacketLength
return undefined
{-
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
-}
|
alios/lab
|
521384cea3311f6f8baca5e7490a80df4c595bac
|
fixed StringToKeySpecifier stuff
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index ecf5c7c..79663d5 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -1,815 +1,831 @@
\begin{code}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeSynonymInstances #-}
module OpenPGP where
{-
( Packet (..)
, PEKSKP (..)
, Signature3 (..)
, Parser
) where
-}
import Data.Enumerator (Iteratee)
import Data.Attoparsec (Parser, (<?>))
import Data.Attoparsec.Enumerator
import qualified Data.Attoparsec as A
import Data.Convertible
import qualified Data.ByteString.Base64 as Base64
import Data.Time (UTCTime)
import Data.Bits
import Data.Word
import Data.Tuple (swap)
import Data.Binary (decode)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy as B
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import System.Time
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
decodeStrictBS bs = (decode . B.fromChunks) [bs]
anyWord16 :: Parser Word16
anyWord16 = fmap decodeStrictBS (A.take 2 <?> "word16")
anyWord32 :: Parser Word32
anyWord32 = fmap decodeStrictBS (A.take 4 <?> "word32")
anyWord64 :: Parser Word64
anyWord64 = fmap decodeStrictBS (A.take 8 <?> "word64")
parserToGet :: Parser t -> Get t
parserToGet p =
let getter = A.parseWith byteGetter p BS.empty
in do res <- getter
handleResult res
where handleResult :: A.Result a -> Get a
handleResult res = case res of
A.Fail bs ctxs err -> fail err
A.Partial f -> do
res' <- fmap f byteGetter
handleResult res'
A.Done bs r -> return r
byteGetter = do
e <- isEmpty
if (e) then return BS.empty else getBytes 1
\end{code}
3. Data Element Formats
This section describes the data elements used by OpenPGP.
3.1. Scalar Numbers
Scalar numbers are unsigned and are always stored in big-endian
format. Using n[k] to refer to the kth octet being interpreted, the
value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a
four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
n[3]).
3.2. Multiprecision Integers
Multiprecision integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used in cryptographic
calculations.
An MPI consists of two pieces: a two-octet scalar that is the length
of the MPI in bits followed by a string of octets that contain the
actual integer.
These octets form a big-endian number; a big-endian number can be
made into an MPI by prefixing it with the appropriate length.
Examples:
(all numbers are in hexadecimal)
The string of octets [00 01 01] forms an MPI with the value 1. The
string [00 09 01 FF] forms an MPI with the value of 511.
Additional rules:
The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
The length field of an MPI describes the length starting from its
most significant non-zero bit. Thus, the MPI [00 02 01] is not
formed correctly. It should be [00 01 01].
Unused bits of an MPI MUST be zero.
Also note that when an MPI is encrypted, the length refers to the
plaintext MPI. It may be ill-formed in its ciphertext.
\begin{code}
newtype MPI = MPI ByteString
deriving (Show, Eq)
instance Binary MPI where
put (MPI bs) = do
putWord16be . convert . BS.length $ bs
putByteString bs
get = parserToGet parseMPI
parseMPI :: Parser MPI
parseMPI = do
ls <- fmap convert anyWord16
bs <- (A.take ls <?> "MPI")
return $ MPI bs
\end{code}
3.3. Key IDs
A Key ID is an eight-octet scalar that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique. The
section "Enhanced Key Formats" below describes how Key IDs are
formed.
\begin{code}
type KeyID = Word64
parseKeyID :: Parser KeyID
parseKeyID = fmap decodeStrictBS (A.take 8 <?> "KeyID")
\end{code}
3.4. Text
Unless otherwise specified, the character set for text is the UTF-8
[RFC3629] encoding of Unicode [ISO10646].
3.5. Time Fields
A time field is an unsigned four-octet number containing the number
of seconds elapsed since midnight, 1 January 1970 UTC.
\begin{code}
parseTime :: Parser UTCTime
parseTime = do
ts <- anyWord32 <?> "TimeField"
return $ convert $ TOD (convert ts) 0
instance Binary UTCTime where
get = parserToGet parseTime
put t =
let (TOD tod _ ) = convert t
in putWord32be . convert $ tod
\end{code}
3.6. Keyrings
A keyring is a collection of one or more keys in a file or database.
Traditionally, a keyring is simply a sequential list of keys, but may
be any suitable database. It is beyond the scope of this standard to
discuss the details of keyrings or other databases.
3.7. String-to-Key (S2K) Specifiers
String-to-key (S2K) specifiers are used to convert passphrase strings
into symmetric-key encryption/decryption keys. They are used in two
places, currently: to encrypt the secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
symmetrically encrypted messages.
3.7.1. String-to-Key (S2K) Specifier Types
There are three types of S2K specifiers currently supported, and
some reserved values:
ID S2K Type
-- --------
0 Simple S2K
1 Salted S2K
2 Reserved value
3 Iterated and Salted S2K
100 to 110 Private/Experimental S2K
These are described in Sections 3.7.1.1 - 3.7.1.3.
\begin{code}
data StringToKeySpecifier =
- SimpleS2K Word8|
- SaltedS2K Word8 Word64 |
- IteratedAndSaltedS2K Word8 Word64 Word8
+ SimpleS2K HashAlgorithm |
+ SaltedS2K HashAlgorithm Word64 |
+ IteratedAndSaltedS2K HashAlgorithm Word64 Word8
+ deriving (Eq, Show)
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
-parseHashAlgo = A.anyWord8 <?> "hash algorithm" -- TODO: Parse hash Algo correctly
+
+instance Binary StringToKeySpecifier where
+ get = parserToGet parseStringToKeySpecifier
+ put (SimpleS2K a) = do
+ putWord8 0x00
+ put a
+ put (SaltedS2K a s) = do
+ putWord8 0x01
+ put a
+ put s
+ put (IteratedAndSaltedS2K a s i) = do
+ putWord8 0x02
+ put a
+ put s
+ putWord8 i
+
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
- hashAlgo <- parseHashAlgo
+ hashAlgo <- parseHashAlgorithm
return $ SimpleS2K hashAlgo
\end{code}
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
- hashAlgo <- parseHashAlgo
+ hashAlgo <- parseHashAlgorithm
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
\end{code}
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
- _ <- A.word8 0x01
- hashAlgo <- parseHashAlgo
+ _ <- A.word8 0x02
+ hashAlgo <- parseHashAlgorithm
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
5. Packet Types
\begin{code}
class Packet t where
data PacketState t :: *
data PacketTag t :: *
packetTag :: t -> PacketTag t
packetTagNum :: PacketTag t -> Word8
bodyParser :: t -> Parser (PacketState t)
isOldPacketTag :: PacketTag t -> Bool
isOldPacketTag = ((<) 16) . packetTagNum
parsePacket :: t -> Parser (PacketState t, Maybe PacketLength)
parsePacket t =
let n = (packetTagNum . packetTag) t
isOld = (isOldPacketTag . packetTag) t
in do
w <- A.anyWord8
let maskedPacket = w .&. 0x3f
if (w `testBit` 7)
then fail $ "no valid packet header"
else if (maskedPacket == n) then fail $ "read invalid header tag " ++ show maskedPacket
else if (isOld)
then do
body <- bodyParser t
case (lookupPacketLength $ maskedPacket .&. 0x03) of
Nothing -> fail ""
Just len -> return (body, Just len)
else do
body <- bodyParser t
return (body, Nothing)
\end{code}
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
\begin{code}
data PEKSKP = PEKSKP
{-
RSAEncryptOrSign |
RSAEncryptOnly |
RSASignOnly |
ElgamalEncryptOnly |
DSA
-}
d = [234,34,2,34,34,6,63,3,45,76,32,1,34,6,67,3,2]
st = MkPEKSKP (Just 0x23) DSA (Right (MPI $ BS.pack d, MPI $ BS.pack d))
p = runPut $ put st
g :: B.ByteString -> PacketState PEKSKP
g = runGet $ get
g' = g p
r = g' == st
instance Eq (PacketState PEKSKP) where
(MkPEKSKP k a d) == (MkPEKSKP k' a' d') = and [k == k', a == a', d == d']
instance Binary (PacketState PEKSKP) where
get = fmap fst $ parserToGet $ parsePacket PEKSKP
put ps = do
putWord8 0x3
putWord64be $ maybe 0 id $ pekskpKeyID ps
putWord8 $ (fromJust . publicKeyAlgorithmToNum . pekskpPublicKeyAlgorithm) ps
either put (\(a,b) -> do put a ; put b) $ pekskpData ps
instance Packet PEKSKP where
data PacketTag PEKSKP = PEKSKPPacketTag
data PacketState PEKSKP = MkPEKSKP {
pekskpKeyID :: Maybe KeyID,
pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
pekskpData :: Either MPI (MPI, MPI)
}
packetTag _ = PEKSKPPacketTag
packetTagNum _ = 0x01
bodyParser PEKSKP = do
_ <- A.word8 3
keyid' <- parseKeyID
let keyid = if (keyid' == 0) then Nothing else Just keyid'
algo <- parsePublicKeyAlgorithm
encKey <- case (algo) of
RSAEncryptOrSign -> parseRSAEncryptedSessionKey
RSAEncryptOnly -> parseRSAEncryptedSessionKey
ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
return $ MkPEKSKP keyid algo encKey
where parseRSAEncryptedSessionKey = fmap Left parseMPI
parseElgamalEncryptedSessionKey = do
a <- parseMPI
b <- parseMPI
return $ Right (a, b)
\end{code}
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
@@ -2687,1024 +2703,1031 @@ crc24 bs = let crc24' c w = 0xffffff `xor` (cycle $ c `xor` ((convert w) `shiftL
When OpenPGP encodes data into ASCII Armor, it puts specific headers
around the Radix-64 encoded data, so OpenPGP can reconstruct the data
later. An OpenPGP implementation MAY use ASCII armor to protect raw
binary data. OpenPGP informs the user what kind of data is encoded
in the ASCII armor through the use of the headers.
Concatenating the following data creates ASCII Armor:
- An Armor Header Line, appropriate for the type of data
- Armor Headers
- A blank (zero-length, or containing only whitespace) line
- The ASCII-Armored data
- An Armor Checksum
- The Armor Tail, which depends on the Armor Header Line
An Armor Header Line consists of the appropriate header line text
surrounded by five (5) dashes ('-', 0x2D) on either side of the
header line text. The header line text is chosen based upon the type
of data that is being encoded in Armor, and how it is being encoded.
Header line texts include the following strings:
BEGIN PGP MESSAGE
Used for signed, encrypted, or compressed files.
BEGIN PGP PUBLIC KEY BLOCK
Used for armoring public keys.
BEGIN PGP PRIVATE KEY BLOCK
Used for armoring private keys.
BEGIN PGP MESSAGE, PART X/Y
Used for multi-part messages, where the armor is split amongst Y
parts, and this is the Xth part out of Y.
BEGIN PGP MESSAGE, PART X
Used for multi-part messages, where this is the Xth part of an
unspecified number of parts. Requires the MESSAGE-ID Armor
Header to be used.
BEGIN PGP SIGNATURE
Used for detached signatures, OpenPGP/MIME signatures, and
cleartext signatures. Note that PGP 2.x uses BEGIN PGP MESSAGE
for detached signatures.
Note that all these Armor Header Lines are to consist of a complete
line. That is to say, there is always a line ending preceding the
starting five dashes, and following the ending five dashes. The
header lines, therefore, MUST start at the beginning of a line, and
MUST NOT have text other than whitespace following them on the same
line. These line endings are considered a part of the Armor Header
Line for the purposes of determining the content they delimit. This
is particularly important when computing a cleartext signature (see
below).
The Armor Headers are pairs of strings that can give the user or the
receiving OpenPGP implementation some information about how to decode
or use the message. The Armor Headers are a part of the armor, not a
part of the message, and hence are not protected by any signatures
applied to the message.
The format of an Armor Header is that of a key-value pair. A colon
(':' 0x38) and a single space (0x20) separate the key and value.
OpenPGP should consider improperly formatted Armor Headers to be
corruption of the ASCII Armor. Unknown keys should be reported to
the user, but OpenPGP should continue to process the message.
Note that some transport methods are sensitive to line length. While
there is a limit of 76 characters for the Radix-64 data (Section
6.3), there is no limit to the length of Armor Headers. Care should
be taken that the Armor Headers are short enough to survive
transport. One way to do this is to repeat an Armor Header key
multiple times with different values for each so that no one line is
overly long.
Currently defined Armor Header Keys are as follows:
- "Version", which states the OpenPGP implementation and version
used to encode the message.
- "Comment", a user-defined comment. OpenPGP defines all text to
be in UTF-8. A comment may be any UTF-8 string. However, the
whole point of armoring is to provide seven-bit-clean data.
Consequently, if a comment has characters that are outside the
US-ASCII range of UTF, they may very well not survive transport.
- "MessageID", a 32-character string of printable characters. The
string must be the same for all parts of a multi-part message
that uses the "PART X" Armor Header. MessageID strings should be
unique enough that the recipient of the mail can associate all
the parts of a message with each other. A good checksum or
cryptographic hash function is sufficient.
The MessageID SHOULD NOT appear unless it is in a multi-part
message. If it appears at all, it MUST be computed from the
finished (encrypted, signed, etc.) message in a deterministic
fashion, rather than contain a purely random value. This is to
allow the legitimate recipient to determine that the MessageID
cannot serve as a covert means of leaking cryptographic key
information.
- "Hash", a comma-separated list of hash algorithms used in this
message. This is used only in cleartext signed messages.
- "Charset", a description of the character set that the plaintext
is in. Please note that OpenPGP defines text to be in UTF-8. An
implementation will get best results by translating into and out
of UTF-8. However, there are many instances where this is easier
said than done. Also, there are communities of users who have no
need for UTF-8 because they are all happy with a character set
like ISO Latin-5 or a Japanese character set. In such instances,
an implementation MAY override the UTF-8 default by using this
header key. An implementation MAY implement this key and any
translations it cares to; an implementation MAY ignore it and
assume all text is UTF-8.
The Armor Tail Line is composed in the same manner as the Armor
Header Line, except the string "BEGIN" is replaced by the string
"END".
6.3. Encoding Binary in Radix-64
The encoding process represents 24-bit groups of input bits as output
strings of 4 encoded characters. Proceeding from left to right, a
24-bit input group is formed by concatenating three 8-bit input
groups. These 24 bits are then treated as four concatenated 6-bit
groups, each of which is translated into a single digit in the
Radix-64 alphabet. When encoding a bit stream with the Radix-64
encoding, the bit stream must be presumed to be ordered with the most
significant bit first. That is, the first bit in the stream will be
the high-order bit in the first 8-bit octet, and the eighth bit will
be the low-order bit in the first 8-bit octet, and so on.
+--first octet--+-second octet--+--third octet--+
|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
+-----------+---+-------+-------+---+-----------+
|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|
+--1.index--+--2.index--+--3.index--+--4.index--+
Each 6-bit group is used as an index into an array of 64 printable
characters from the table below. The character referenced by the
index is placed in the output string.
Value Encoding Value Encoding Value Encoding Value Encoding
0 A 17 R 34 i 51 z
1 B 18 S 35 j 52 0
2 C 19 T 36 k 53 1
3 D 20 U 37 l 54 2
4 E 21 V 38 m 55 3
5 F 22 W 39 n 56 4
6 G 23 X 40 o 57 5
7 H 24 Y 41 p 58 6
8 I 25 Z 42 q 59 7
9 J 26 a 43 r 60 8
10 K 27 b 44 s 61 9
11 L 28 c 45 t 62 +
12 M 29 d 46 u 63 /
13 N 30 e 47 v
14 O 31 f 48 w (pad) =
15 P 32 g 49 x
16 Q 33 h 50 y
The encoded output stream must be represented in lines of no more
than 76 characters each.
Special processing is performed if fewer than 24 bits are available
at the end of the data being encoded. There are three possibilities:
1. The last data group has 24 bits (3 octets). No special processing
is needed.
2. The last data group has 16 bits (2 octets). The first two 6-bit
groups are processed as above. The third (incomplete) data group
has two zero-value bits added to it, and is processed as above. A
pad character (=) is added to the output.
3. The last data group has 8 bits (1 octet). The first 6-bit group
is processed as above. The second (incomplete) data group has
four zero-value bits added to it, and is processed as above. Two
pad characters (=) are added to the output.
6.4. Decoding Radix-64
In Radix-64 data, characters other than those in the table, line
breaks, and other white space probably indicate a transmission error,
about which a warning message or even a message rejection might be
appropriate under some circumstances. Decoding software must ignore
all white space.
Because it is used only for padding at the end of the data, the
occurrence of any "=" characters may be taken as evidence that the
end of the data has been reached (without truncation in transit). No
such assurance is possible, however, when the number of octets
transmitted was a multiple of three and no "=" characters are
present.
6.5. Examples of Radix-64
Input data: 0x14FB9C03D97E
Hex: 1 4 F B 9 C | 0 3 D 9 7 E
8-bit: 00010100 11111011 10011100 | 00000011 11011001 11111110
6-bit: 000101 001111 101110 011100 | 000000 111101 100111 111110
Decimal: 5 15 46 28 0 61 37 62
Output: F P u c A 9 l +
Input data: 0x14FB9C03D9
Hex: 1 4 F B 9 C | 0 3 D 9
8-bit: 00010100 11111011 10011100 | 00000011 11011001
pad with 00
6-bit: 000101 001111 101110 011100 | 000000 111101 100100
Decimal: 5 15 46 28 0 61 36
pad with =
Output: F P u c A 9 k =
Input data: 0x14FB9C03
Hex: 1 4 F B 9 C | 0 3
8-bit: 00010100 11111011 10011100 | 00000011
pad with 0000
6-bit: 000101 001111 101110 011100 | 000000 110000
Decimal: 5 15 46 28 0 48
pad with = =
Output: F P u c A w = =
6.6. Example of an ASCII Armored Message
-----BEGIN PGP MESSAGE-----
Version: OpenPrivacy 0.99
yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
vBSFjNSiVHsuAA==
=njUN
-----END PGP MESSAGE-----
Note that this example has extra indenting; an actual armored message
would have no leading whitespace.
7. Cleartext Signature Framework
It is desirable to be able to sign a textual octet stream without
ASCII armoring the stream itself, so the signed text is still
readable without special software. In order to bind a signature to
such a cleartext, this framework is used. (Note that this framework
is not intended to be reversible. RFC 3156 [RFC3156] defines another
way to sign cleartext messages for environments that support MIME.)
The cleartext signed message consists of:
- The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a
single line,
- One or more "Hash" Armor Headers,
- Exactly one empty line not included into the message digest,
- The dash-escaped cleartext that is included into the message
digest,
- The ASCII armored signature(s) including the '-----BEGIN PGP
SIGNATURE-----' Armor Header and Armor Tail Lines.
If the "Hash" Armor Header is given, the specified message digest
algorithm(s) are used for the signature. If there are no such
headers, MD5 is used. If MD5 is the only hash used, then an
implementation MAY omit this header for improved V2.x compatibility.
If more than one message digest is used in the signature, the "Hash"
armor header contains a comma-delimited list of used message digests.
Current message digest names are described below with the algorithm
IDs.
An implementation SHOULD add a line break after the cleartext, but
MAY omit it if the cleartext ends with a line break. This is for
visual clarity.
7.1. Dash-Escaped Text
The cleartext content of the message must also be dash-escaped.
Dash-escaped cleartext is the ordinary cleartext where every line
starting with a dash '-' (0x2D) is prefixed by the sequence dash '-'
(0x2D) and space ' ' (0x20). This prevents the parser from
recognizing armor headers of the cleartext itself. An implementation
MAY dash-escape any line, SHOULD dash-escape lines commencing "From"
followed by a space, and MUST dash-escape any line commencing in a
dash. The message digest is computed using the cleartext itself, not
the dash-escaped form.
As with binary signatures on text documents, a cleartext signature is
calculated on the text using canonical <CR><LF> line endings. The
line ending (i.e., the <CR><LF>) before the '-----BEGIN PGP
SIGNATURE-----' line that terminates the signed text is not
considered part of the signed text.
When reversing dash-escaping, an implementation MUST strip the string
"- " if it occurs at the beginning of a line, and SHOULD warn on "-"
and any character other than a space at the beginning of a line.
Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at
the end of any line is removed when the cleartext signature is
generated.
8. Regular Expressions
A regular expression is zero or more branches, separated by '|'. It
matches anything that matches one of the branches.
A branch is zero or more pieces, concatenated. It matches a match
for the first, followed by a match for the second, etc.
A piece is an atom possibly followed by '*', '+', or '?'. An atom
followed by '*' matches a sequence of 0 or more matches of the atom.
An atom followed by '+' matches a sequence of 1 or more matches of
the atom. An atom followed by '?' matches a match of the atom, or
the null string.
An atom is a regular expression in parentheses (matching a match for
the regular expression), a range (see below), '.' (matching any
single character), '^' (matching the null string at the beginning of
the input string), '$' (matching the null string at the end of the
input string), a '\' followed by a single character (matching that
character), or a single character with no other significance
(matching that character).
A range is a sequence of characters enclosed in '[]'. It normally
matches any single character from the sequence. If the sequence
begins with '^', it matches any single character not from the rest of
the sequence. If two characters in the sequence are separated
by '-', this is shorthand for the full list of ASCII characters
between them (e.g., '[0-9]' matches any decimal digit). To include a
literal ']' in the sequence, make it the first character (following a
possible '^'). To include a literal '-', make it the first or last
character.
9. Constants
This section describes the constants used in OpenPGP.
Note that these tables are not exhaustive lists; an implementation
MAY implement an algorithm not on these lists, so long as the
algorithm numbers are chosen from the private or experimental
algorithm range.
See the section "Notes on Algorithms" below for more discussion of
the algorithms.
9.1. Public-Key Algorithms
ID Algorithm
-- ---------
1 - RSA (Encrypt or Sign) [HAC]
2 - RSA Encrypt-Only [HAC]
3 - RSA Sign-Only [HAC]
16 - Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
17 - DSA (Digital Signature Algorithm) [FIPS186] [HAC]
18 - Reserved for Elliptic Curve
19 - Reserved for ECDSA
20 - Reserved (formerly Elgamal Encrypt or Sign)
21 - Reserved for Diffie-Hellman (X9.42,
as defined for IETF-S/MIME)
100 to 110 - Private/Experimental algorithm
Implementations MUST implement DSA for signatures, and Elgamal for
encryption. Implementations SHOULD implement RSA keys (1). RSA
Encrypt-Only (2) and RSA Sign-Only are deprecated and SHOULD NOT be
generated, but may be interpreted. See Section 13.5. See Section
13.8 for notes on Elliptic Curve (18), ECDSA (19), Elgamal Encrypt or
Sign (20), and X9.42 (21). Implementations MAY implement any other
algorithm.
\begin{code}
data PublicKeyAlgorithm =
RSAEncryptOrSign |
RSAEncryptOnly |
RSASignOnly |
ElgamalEncryptOnly |
DSA
deriving (Show, Read, Eq, Enum)
publicKeyAlgorithmCoding = [
(RSAEncryptOrSign, 1),
(RSAEncryptOnly, 2),
(RSASignOnly, 3),
(ElgamalEncryptOnly, 16),
(DSA, 17)
]
lookupPublicKeyAlgorithm :: Word8 -> Maybe PublicKeyAlgorithm
lookupPublicKeyAlgorithm i = lookup i $ map swap publicKeyAlgorithmCoding
publicKeyAlgorithmToNum :: PublicKeyAlgorithm -> Maybe Word8
publicKeyAlgorithmToNum p = lookup p publicKeyAlgorithmCoding
parsePublicKeyAlgorithm :: Parser PublicKeyAlgorithm
parsePublicKeyAlgorithm = do
w <- A.anyWord8
case (lookupPublicKeyAlgorithm w) of
Nothing -> fail "unknown public key algorithm"
Just a -> return a
\end{code}
9.2. Symmetric-Key Algorithms
ID Algorithm
-- ---------
0 - Plaintext or unencrypted data
1 - IDEA [IDEA]
2 - TripleDES (DES-EDE, [SCHNEIER] [HAC] -
168 bit key derived from 192)
3 - CAST5 (128 bit key, as per [RFC2144])
4 - Blowfish (128 bit key, 16 rounds) [BLOWFISH]
5 - Reserved
6 - Reserved
7 - AES with 128-bit key [AES]
8 - AES with 192-bit key
9 - AES with 256-bit key
10 - Twofish with 256-bit key [TWOFISH]
100 to 110 - Private/Experimental algorithm
Implementations MUST implement TripleDES. Implementations SHOULD
implement AES-128 and CAST5. Implementations that interoperate with
PGP 2.6 or earlier need to support IDEA, as that is the only
symmetric cipher those versions use. Implementations MAY implement
any other algorithm.
9.3. Compression Algorithms
ID Algorithm
-- ---------
0 - Uncompressed
1 - ZIP [RFC1951]
2 - ZLIB [RFC1950]
3 - BZip2 [BZ2]
100 to 110 - Private/Experimental algorithm
Implementations MUST implement uncompressed data. Implementations
SHOULD implement ZIP. Implementations MAY implement any other
algorithm.
9.4. Hash Algorithms
ID Algorithm Text Name
-- --------- ---------
1 - MD5 [HAC] "MD5"
2 - SHA-1 [FIPS180] "SHA1"
3 - RIPE-MD/160 [HAC] "RIPEMD160"
4 - Reserved
5 - Reserved
6 - Reserved
7 - Reserved
8 - SHA256 [FIPS180] "SHA256"
9 - SHA384 [FIPS180] "SHA384"
10 - SHA512 [FIPS180] "SHA512"
11 - SHA224 [FIPS180] "SHA224"
100 to 110 - Private/Experimental algorithm
Implementations MUST implement SHA-1. Implementations MAY implement
other algorithms. MD5 is deprecated.
\begin{code}
data HashAlgorithm =
MD5 |
SHA1 |
RIPEMD160 |
SHA256 |
SHA384 |
SHA512 |
SHA224 |
PrivateHashAlgo Word8
deriving (Show, Read, Eq)
hashAlgorithmCoding = [
(MD5, 1),
(SHA1, 2),
(RIPEMD160, 3),
(SHA256, 8),
(SHA384, 9),
(SHA512, 10),
(SHA224, 11)
]
lookupHashAlgorithm :: Word8 -> Maybe HashAlgorithm
lookupHashAlgorithm h =
if ((h >= 100) && (h <= 100))
then Just $ PrivateHashAlgo h
else lookup h $ map swap hashAlgorithmCoding
hashAlgorithmToNum :: HashAlgorithm -> Maybe Word8
hashAlgorithmToNum (PrivateHashAlgo h) = Just h
hashAlgorithmToNum h = lookup h hashAlgorithmCoding
parseHashAlgorithm :: Parser HashAlgorithm
parseHashAlgorithm = do
w <- A.anyWord8
case (lookupHashAlgorithm w) of
Just a -> return a
Nothing -> fail $ "unknown hash algorithm " ++ show w
+
+instance Binary HashAlgorithm where
+ get = parserToGet parseHashAlgorithm
+ put a = case (hashAlgorithmToNum a) of
+ Nothing -> fail "unable to put unknown hash algorithm"
+ Just a' -> putWord8 a'
+
\end{code}
10. IANA Considerations
OpenPGP is highly parameterized, and consequently there are a number
of considerations for allocating parameters for extensions. This
section describes how IANA should look at extensions to the protocol
as described in this document.
10.1. New String-to-Key Specifier Types
OpenPGP S2K specifiers contain a mechanism for new algorithms to turn
a string into a key. This specification creates a registry of S2K
specifier types. The registry includes the S2K type, the name of the
S2K, and a reference to the defining specification. The initial
values for this registry can be found in Section 3.7.1. Adding a new
S2K specifier MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.2. New Packets
Major new features of OpenPGP are defined through new packet types.
This specification creates a registry of packet types. The registry
includes the packet type, the name of the packet, and a reference to
the defining specification. The initial values for this registry can
be found in Section 4.3. Adding a new packet type MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.2.1. User Attribute Types
The User Attribute packet permits an extensible mechanism for other
types of certificate identification. This specification creates a
registry of User Attribute types. The registry includes the User
Attribute type, the name of the User Attribute, and a reference to
the defining specification. The initial values for this registry can
be found in Section 5.12. Adding a new User Attribute type MUST be
done through the IETF CONSENSUS method, as described in [RFC2434].
10.2.1.1. Image Format Subpacket Types
Within User Attribute packets, there is an extensible mechanism for
other types of image-based user attributes. This specification
creates a registry of Image Attribute subpacket types. The registry
includes the Image Attribute subpacket type, the name of the Image
Attribute subpacket, and a reference to the defining specification.
The initial values for this registry can be found in Section 5.12.1.
Adding a new Image Attribute subpacket type MUST be done through the
IETF CONSENSUS method, as described in [RFC2434].
10.2.2. New Signature Subpackets
OpenPGP signatures contain a mechanism for signed (or unsigned) data
to be added to them for a variety of purposes in the Signature
subpackets as discussed in Section 5.2.3.1. This specification
creates a registry of Signature subpacket types. The registry
includes the Signature subpacket type, the name of the subpacket, and
this registry can be found in Section 5.2.3.1. Adding a new
Signature subpacket MUST be done through the IETF CONSENSUS method,
as described in [RFC2434].
10.2.2.1. Signature Notation Data Subpackets
OpenPGP signatures further contain a mechanism for extensions in
signatures. These are the Notation Data subpackets, which contain a
key/value pair. Notations contain a user space that is completely
unmanaged and an IETF space.
This specification creates a registry of Signature Notation Data
types. The registry includes the Signature Notation Data type, the
name of the Signature Notation Data, its allowed values, and a
reference to the defining specification. The initial values for this
registry can be found in Section 5.2.3.16. Adding a new Signature
Notation Data subpacket MUST be done through the EXPERT REVIEW
method, as described in [RFC2434].
10.2.2.2. Key Server Preference Extensions
OpenPGP signatures contain a mechanism for preferences to be
specified about key servers. This specification creates a registry
of key server preferences. The registry includes the key server
preference, the name of the preference, and a reference to the
defining specification. The initial values for this registry can be
found in Section 5.2.3.17. Adding a new key server preference MUST
be done through the IETF CONSENSUS method, as described in [RFC2434].
10.2.2.3. Key Flags Extensions
OpenPGP signatures contain a mechanism for flags to be specified
about key usage. This specification creates a registry of key usage
flags. The registry includes the key flags value, the name of the
flag, and a reference to the defining specification. The initial
values for this registry can be found in Section 5.2.3.21. Adding a
new key usage flag MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.2.2.4. Reason for Revocation Extensions
OpenPGP signatures contain a mechanism for flags to be specified
about why a key was revoked. This specification creates a registry
of "Reason for Revocation" flags. The registry includes the "Reason
for Revocation" flags value, the name of the flag, and a reference to
the defining specification. The initial values for this registry can
be found in Section 5.2.3.23. Adding a new feature flag MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.2.2.5. Implementation Features
OpenPGP signatures contain a mechanism for flags to be specified
stating which optional features an implementation supports. This
specification creates a registry of feature-implementation flags.
The registry includes the feature-implementation flags value, the
name of the flag, and a reference to the defining specification. The
initial values for this registry can be found in Section 5.2.3.24.
Adding a new feature-implementation flag MUST be done through the
IETF CONSENSUS method, as described in [RFC2434].
Also see Section 13.12 for more information about when feature flags
are needed.
10.2.3. New Packet Versions
The core OpenPGP packets all have version numbers, and can be revised
by introducing a new version of an existing packet. This
specification creates a registry of packet types. The registry
includes the packet type, the number of the version, and a reference
to the defining specification. The initial values for this registry
can be found in Section 5. Adding a new packet version MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.3. New Algorithms
Section 9 lists the core algorithms that OpenPGP uses. Adding in a
new algorithm is usually simple. For example, adding in a new
symmetric cipher usually would not need anything more than allocating
a constant for that cipher. If that cipher had other than a 64-bit
or 128-bit block size, there might need to be additional
documentation describing how OpenPGP-CFB mode would be adjusted.
Similarly, when DSA was expanded from a maximum of 1024-bit public
keys to 3072-bit public keys, the revision of FIPS 186 contained
enough information itself to allow implementation. Changes to this
document were made mainly for emphasis.
10.3.1. Public-Key Algorithms
OpenPGP specifies a number of public-key algorithms. This
specification creates a registry of public-key algorithm identifiers.
The registry includes the algorithm name, its key sizes and
parameters, and a reference to the defining specification. The
initial values for this registry can be found in Section 9. Adding a
new public-key algorithm MUST be done through the IETF CONSENSUS
method, as described in [RFC2434].
Callas, et al Standards Track [Page 66]
RFC 4880 OpenPGP Message Format November 2007
10.3.2. Symmetric-Key Algorithms
OpenPGP specifies a number of symmetric-key algorithms. This
specification creates a registry of symmetric-key algorithm
identifiers. The registry includes the algorithm name, its key sizes
and block size, and a reference to the defining specification. The
initial values for this registry can be found in Section 9. Adding a
new symmetric-key algorithm MUST be done through the IETF CONSENSUS
method, as described in [RFC2434].
10.3.3. Hash Algorithms
OpenPGP specifies a number of hash algorithms. This specification
creates a registry of hash algorithm identifiers. The registry
includes the algorithm name, a text representation of that name, its
block size, an OID hash prefix, and a reference to the defining
specification. The initial values for this registry can be found in
Section 9 for the algorithm identifiers and text names, and Section
5.2.2 for the OIDs and expanded signature prefixes. Adding a new
hash algorithm MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.3.4. Compression Algorithms
OpenPGP specifies a number of compression algorithms. This
specification creates a registry of compression algorithm
identifiers. The registry includes the algorithm name and a
reference to the defining specification. The initial values for this
registry can be found in Section 9.3. Adding a new compression key
algorithm MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
11. Packet Composition
OpenPGP packets are assembled into sequences in order to create
messages and to transfer keys. Not all possible packet sequences are
meaningful and correct. This section describes the rules for how
packets should be placed into sequences.
11.1. Transferable Public Keys
OpenPGP users may transfer public keys. The essential elements of a
transferable public key are as follows:
- One Public-Key packet
- Zero or more revocation signatures
- One or more User ID packets
- After each User ID packet, zero or more Signature packets
(certifications)
- Zero or more User Attribute packets
- After each User Attribute packet, zero or more Signature packets
(certifications)
- Zero or more Subkey packets
- After each Subkey packet, one Signature packet, plus optionally a
revocation
The Public-Key packet occurs first. Each of the following User ID
packets provides the identity of the owner of this public key. If
there are multiple User ID packets, this corresponds to multiple
means of identifying the same unique individual user; for example, a
user may have more than one email address, and construct a User ID
for each one.
Immediately following each User ID packet, there are zero or more
Signature packets. Each Signature packet is calculated on the
immediately preceding User ID packet and the initial Public-Key
packet. The signature serves to certify the corresponding public key
and User ID. In effect, the signer is testifying to his or her
belief that this public key belongs to the user identified by this
User ID.
Within the same section as the User ID packets, there are zero or
more User Attribute packets. Like the User ID packets, a User
Attribute packet is followed by zero or more Signature packets
calculated on the immediately preceding User Attribute packet and the
initial Public-Key packet.
User Attribute packets and User ID packets may be freely intermixed
in this section, so long as the signatures that follow them are
maintained on the proper User Attribute or User ID packet.
After the User ID packet or Attribute packet, there may be zero or
more Subkey packets. In general, subkeys are provided in cases where
the top-level public key is a signature-only key. However, any V4
key may have subkeys, and the subkeys may be encryption-only keys,
signature-only keys, or general-purpose keys. V3 keys MUST NOT have
subkeys.
Each Subkey packet MUST be followed by one Signature packet, which
should be a subkey binding signature issued by the top-level key.
For subkeys that can issue signatures, the subkey binding signature
MUST contain an Embedded Signature subpacket with a primary key
binding signature (0x19) issued by the subkey on the top-level key.
Subkey and Key packets may each be followed by a revocation Signature
packet to indicate that the key is revoked. Revocation signatures
are only accepted if they are issued by the key itself, or by a key
that is authorized to issue revocations via a Revocation Key
subpacket in a self-signature by the top-level key.
Transferable public-key packet sequences may be concatenated to allow
transferring multiple public keys in one operation.
11.2. Transferable Secret Keys
OpenPGP users may transfer secret keys. The format of a transferable
secret key is the same as a transferable public key except that
secret-key and secret-subkey packets are used instead of the public
key and public-subkey packets. Implementations SHOULD include self-
signatures on any user IDs and subkeys, as this allows for a complete
public key to be automatically extracted from the transferable secret
key. Implementations MAY choose to omit the self-signatures,
especially if a transferable public key accompanies the transferable
secret key.
11.3. OpenPGP Messages
An OpenPGP message is a packet or sequence of packets that
corresponds to the following grammatical rules (comma represents
sequential composition, and vertical bar separates alternatives):
OpenPGP Message :- Encrypted Message | Signed Message |
Compressed Message | Literal Message.
Compressed Message :- Compressed Data Packet.
Literal Message :- Literal Data Packet.
ESK :- Public-Key Encrypted Session Key Packet |
Symmetric-Key Encrypted Session Key Packet.
ESK Sequence :- ESK | ESK Sequence, ESK.
Encrypted Data :- Symmetrically Encrypted Data Packet |
Symmetrically Encrypted Integrity Protected Data Packet
Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data.
One-Pass Signed Message :- One-Pass Signature Packet,
OpenPGP Message, Corresponding Signature Packet.
Signed Message :- Signature Packet, OpenPGP Message |
One-Pass Signed Message.
In addition, decrypting a Symmetrically Encrypted Data packet or a
Symmetrically Encrypted Integrity Protected Data packet as well as
decompressing a Compressed Data packet must yield a valid OpenPGP
Message.
11.4. Detached Signatures
Some OpenPGP applications use so-called "detached signatures". For
example, a program bundle may contain a file, and with it a second
file that is a detached signature of the first file. These detached
signatures are simply a Signature packet stored separately from the
data for which they are a signature.
12. Enhanced Key Formats
12.1. Key Structures
The format of an OpenPGP V3 key is as follows. Entries in square
brackets are optional and ellipses indicate repetition.
RSA Public Key
[Revocation Self Signature]
User ID [Signature ...]
[User ID [Signature ...] ...]
Each signature certifies the RSA public key and the preceding User
ID. The RSA public key can have many User IDs and each User ID can
have many signatures. V3 keys are deprecated. Implementations MUST
NOT generate new V3 keys, but MAY continue to use existing ones.
The format of an OpenPGP V4 key that uses multiple public keys is
similar except that the other keys are added to the end as "subkeys"
of the primary key.
Primary-Key
[Revocation Self Signature]
[Direct Key Signature...]
User ID [Signature ...]
[User ID [Signature ...] ...]
[User Attribute [Signature ...] ...]
[[Subkey [Binding-Signature-Revocation]
Primary-Key-Binding-Signature] ...]
A subkey always has a single signature after it that is issued using
the primary key to tie the two keys together. This binding signature
may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can
issue signatures MUST have a V4 binding signature due to the REQUIRED
embedded primary key binding signature.
In the above diagram, if the binding signature of a subkey has been
revoked, the revoked key may be removed, leaving only one key.
In a V4 key, the primary key MUST be a key capable of certification.
The subkeys may be keys of any other type. There may be other
constructions of V4 keys, too. For example, there may be a single-
key RSA key in V4 format, a DSA primary key with an RSA encryption
key, or RSA primary key with an Elgamal subkey, etc.
It is also possible to have a signature-only subkey. This permits a
primary key that collects certifications (key signatures), but is
used only for certifying subkeys that are used for encryption and
signatures.
12.2. Key IDs and Fingerprints
For a V3 key, the eight-octet Key ID consists of the low 64 bits of
the public modulus of the RSA key.
The fingerprint of a V3 key is formed by hashing the body (but not
the two-octet length) of the MPIs that form the key material (public
modulus n, followed by exponent e) with MD5. Note that both V3 keys
and MD5 are deprecated.
A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99,
followed by the two-octet packet length, followed by the entire
Public-Key packet starting with the version field. The Key ID is the
low-order 64 bits of the fingerprint. Here are the fields of the
hash material, with the example of a DSA key:
a.1) 0x99 (1 octet)
a.2) high-order length octet of (b)-(e) (1 octet)
a.3) low-order length octet of (b)-(e) (1 octet)
b) version number = 4 (1 octet);
c) timestamp of key creation (4 octets);
d) algorithm (1 octet): 17 = DSA (example);
e) Algorithm-specific fields.
Algorithm-Specific Fields for DSA keys (example):
e.1) MPI of DSA prime p;
e.2) MPI of DSA group order q (q is a prime divisor of p-1);
e.3) MPI of DSA group generator g;
e.4) MPI of DSA public-key value y (= g**x mod p where x is secret).
Note that it is possible for there to be collisions of Key IDs -- two
different keys with the same Key ID. Note that there is a much
smaller, but still non-zero, probability that two different keys have
the same fingerprint.
Also note that if V3 and V4 format keys share the same RSA key
material, they will have different Key IDs as well as different
fingerprints.
Finally, the Key ID and fingerprint of a subkey are calculated in the
same way as for a primary key, including the 0x99 as the first octet
(even though this is not a valid packet ID for a public subkey).
13. Notes on Algorithms
13.1. PKCS#1 Encoding in OpenPGP
This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and
EMSA-PKCS1-v1_5. However, the calling conventions of these functions
has changed in the past. To avoid potential confusion and
interoperability problems, we are including local copies in this
document, adapted from those in PKCS#1 v2.1 [RFC3447]. RFC 3447
should be treated as the ultimate authority on PKCS#1 for OpenPGP.
Nonetheless, we believe that there is value in having a self-
contained document that avoids problems in the future with needed
changes in the conventions.
13.1.1. EME-PKCS1-v1_5-ENCODE
Input:
k = the length in octets of the key modulus
M = message to be encoded, an octet string of length mLen, where
mLen <= k - 11
Output:
EM = encoded message, an octet string of length k
Error: "message too long"
1. Length checking: If mLen > k - 11, output "message too long" and
stop.
2. Generate an octet string PS of length k - mLen - 3 consisting of
pseudo-randomly generated nonzero octets. The length of PS will
be at least eight octets.
3. Concatenate PS, the message M, and other padding to form an
encoded message EM of length k octets as
EM = 0x00 || 0x02 || PS || 0x00 || M.
4. Output EM.
13.1.2. EME-PKCS1-v1_5-DECODE
Input:
EM = encoded message, an octet string
Output:
M = message, an octet string
diff --git a/OpenPGPTests.hs b/OpenPGPTests.hs
index bf59845..7deecc2 100644
--- a/OpenPGPTests.hs
+++ b/OpenPGPTests.hs
@@ -1,55 +1,76 @@
module Main where
import OpenPGP
import Test.QuickCheck
import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString as BS
import qualified Data.Attoparsec as A
import Data.Convertible
import Data.Time (UTCTime(..), picosecondsToDiffTime)
import System.Time (ClockTime(..))
main = do
chk prop_MPIBinary
chk prop_KeyIDParser
chk prop_UTCTimeBinary
+ chk prop_StringToKeySpecifierBinary
return ()
where
chk :: Testable prop => prop -> IO ()
chk = quickCheck
- -- chk = verboseCheck
+-- chk = verboseCheck
+
+instance Arbitrary HashAlgorithm where
+ arbitrary = elements [ MD5,SHA1,RIPEMD160,SHA256,SHA384,SHA512,SHA224 ]
+
+instance Arbitrary StringToKeySpecifier where
+ arbitrary = do
+ n <- choose (0, 2) :: Gen Int
+ a <- arbitrary
+ s <- arbitrary
+ i <- arbitrary
+ return $ case n of
+ 0 -> SimpleS2K a
+ 1 -> SaltedS2K a s
+ 2 -> IteratedAndSaltedS2K a s i
+
rPut :: Binary t => t -> ByteString
rPut = runPut . put
rGet :: Binary t => ByteString -> t
rGet bs = runGet get bs
rPutGet :: Binary t => t -> t
rPutGet = rGet . rPut
prop_MPIBinary :: [Word8] -> Property
prop_MPIBinary bs =
let mpi = (MPI . BS.pack) bs
in label "binary encoding / decoding of MPI" (mpi == rPutGet mpi)
prop_KeyIDParser :: KeyID -> Property
prop_KeyIDParser kid =
let ekid = convert $ rPut kid
rdkid = A.maybeResult $ A.parse parseKeyID ekid
dkid = case rdkid of
Nothing -> error "unable to parse KeyID"
Just a -> a
in label "KeyID parser test" (kid == dkid)
prop_UTCTimeBinary :: Integer -> Property
prop_UTCTimeBinary i =
let utc :: UTCTime
utc = convert $ TOD (abs i) 0
- in label "UTCTime parser test" $ utc == rPutGet utc
+ in label "UTCTime binary test" $ utc == rPutGet utc
+prop_StringToKeySpecifierBinary :: StringToKeySpecifier -> Property
+prop_StringToKeySpecifierBinary s2k =
+ label "StringToKeySpecifier binary test" $ s2k == rPutGet s2k
+
+
\ No newline at end of file
|
alios/lab
|
44d8c310b75534f3b54032f5a1b4c2d8a6590c41
|
added test cases
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index 83f8bd4..ecf5c7c 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -1,1643 +1,1782 @@
\begin{code}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
+{-# LANGUAGE StandaloneDeriving #-}
+{-# LANGUAGE TypeSynonymInstances #-}
-module OpenPGP ( Packet (..)
+module OpenPGP where
+
+{-
+ ( Packet (..)
, PEKSKP (..)
, Signature3 (..)
+ , Parser
) where
+-}
import Data.Enumerator (Iteratee)
import Data.Attoparsec (Parser, (<?>))
import Data.Attoparsec.Enumerator
import qualified Data.Attoparsec as A
import Data.Convertible
import qualified Data.ByteString.Base64 as Base64
import Data.Time (UTCTime)
import Data.Bits
import Data.Word
import Data.Tuple (swap)
import Data.Binary (decode)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy as B
import Data.ByteString (ByteString)
+import qualified Data.ByteString as BS
+
import System.Time
+import Data.Binary
+import Data.Binary.Get
+import Data.Binary.Put
decodeStrictBS bs = (decode . B.fromChunks) [bs]
anyWord16 :: Parser Word16
anyWord16 = fmap decodeStrictBS (A.take 2 <?> "word16")
anyWord32 :: Parser Word32
anyWord32 = fmap decodeStrictBS (A.take 4 <?> "word32")
anyWord64 :: Parser Word64
anyWord64 = fmap decodeStrictBS (A.take 8 <?> "word64")
+parserToGet :: Parser t -> Get t
+parserToGet p =
+ let getter = A.parseWith byteGetter p BS.empty
+ in do res <- getter
+ handleResult res
+ where handleResult :: A.Result a -> Get a
+ handleResult res = case res of
+ A.Fail bs ctxs err -> fail err
+ A.Partial f -> do
+ res' <- fmap f byteGetter
+ handleResult res'
+ A.Done bs r -> return r
+ byteGetter = do
+ e <- isEmpty
+ if (e) then return BS.empty else getBytes 1
\end{code}
3. Data Element Formats
This section describes the data elements used by OpenPGP.
3.1. Scalar Numbers
Scalar numbers are unsigned and are always stored in big-endian
format. Using n[k] to refer to the kth octet being interpreted, the
value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a
four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
n[3]).
3.2. Multiprecision Integers
Multiprecision integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used in cryptographic
calculations.
An MPI consists of two pieces: a two-octet scalar that is the length
of the MPI in bits followed by a string of octets that contain the
actual integer.
These octets form a big-endian number; a big-endian number can be
made into an MPI by prefixing it with the appropriate length.
Examples:
(all numbers are in hexadecimal)
The string of octets [00 01 01] forms an MPI with the value 1. The
string [00 09 01 FF] forms an MPI with the value of 511.
Additional rules:
The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
The length field of an MPI describes the length starting from its
most significant non-zero bit. Thus, the MPI [00 02 01] is not
formed correctly. It should be [00 01 01].
Unused bits of an MPI MUST be zero.
Also note that when an MPI is encrypted, the length refers to the
plaintext MPI. It may be ill-formed in its ciphertext.
\begin{code}
newtype MPI = MPI ByteString
+ deriving (Show, Eq)
+
+instance Binary MPI where
+ put (MPI bs) = do
+ putWord16be . convert . BS.length $ bs
+ putByteString bs
+ get = parserToGet parseMPI
+
parseMPI :: Parser MPI
parseMPI = do
ls <- fmap convert anyWord16
bs <- (A.take ls <?> "MPI")
return $ MPI bs
+
\end{code}
3.3. Key IDs
A Key ID is an eight-octet scalar that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique. The
section "Enhanced Key Formats" below describes how Key IDs are
formed.
\begin{code}
type KeyID = Word64
parseKeyID :: Parser KeyID
parseKeyID = fmap decodeStrictBS (A.take 8 <?> "KeyID")
+
+
\end{code}
3.4. Text
Unless otherwise specified, the character set for text is the UTF-8
[RFC3629] encoding of Unicode [ISO10646].
3.5. Time Fields
A time field is an unsigned four-octet number containing the number
of seconds elapsed since midnight, 1 January 1970 UTC.
\begin{code}
parseTime :: Parser UTCTime
parseTime = do
ts <- anyWord32 <?> "TimeField"
return $ convert $ TOD (convert ts) 0
+
+instance Binary UTCTime where
+ get = parserToGet parseTime
+ put t =
+ let (TOD tod _ ) = convert t
+ in putWord32be . convert $ tod
+
\end{code}
3.6. Keyrings
A keyring is a collection of one or more keys in a file or database.
Traditionally, a keyring is simply a sequential list of keys, but may
be any suitable database. It is beyond the scope of this standard to
discuss the details of keyrings or other databases.
3.7. String-to-Key (S2K) Specifiers
String-to-key (S2K) specifiers are used to convert passphrase strings
into symmetric-key encryption/decryption keys. They are used in two
places, currently: to encrypt the secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
symmetrically encrypted messages.
3.7.1. String-to-Key (S2K) Specifier Types
There are three types of S2K specifiers currently supported, and
some reserved values:
ID S2K Type
-- --------
0 Simple S2K
1 Salted S2K
2 Reserved value
3 Iterated and Salted S2K
100 to 110 Private/Experimental S2K
These are described in Sections 3.7.1.1 - 3.7.1.3.
\begin{code}
data StringToKeySpecifier =
SimpleS2K Word8|
SaltedS2K Word8 Word64 |
IteratedAndSaltedS2K Word8 Word64 Word8
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
parseHashAlgo = A.anyWord8 <?> "hash algorithm" -- TODO: Parse hash Algo correctly
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
hashAlgo <- parseHashAlgo
return $ SimpleS2K hashAlgo
\end{code}
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
\end{code}
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
+
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
5. Packet Types
\begin{code}
class Packet t where
data PacketState t :: *
data PacketTag t :: *
packetTag :: t -> PacketTag t
packetTagNum :: PacketTag t -> Word8
bodyParser :: t -> Parser (PacketState t)
isOldPacketTag :: PacketTag t -> Bool
isOldPacketTag = ((<) 16) . packetTagNum
parsePacket :: t -> Parser (PacketState t, Maybe PacketLength)
parsePacket t =
let n = (packetTagNum . packetTag) t
isOld = (isOldPacketTag . packetTag) t
in do
w <- A.anyWord8
let maskedPacket = w .&. 0x3f
if (w `testBit` 7)
then fail $ "no valid packet header"
else if (maskedPacket == n) then fail $ "read invalid header tag " ++ show maskedPacket
else if (isOld)
then do
body <- bodyParser t
case (lookupPacketLength $ maskedPacket .&. 0x03) of
Nothing -> fail ""
Just len -> return (body, Just len)
else do
body <- bodyParser t
return (body, Nothing)
\end{code}
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
-
-
\begin{code}
data PEKSKP = PEKSKP
+{-
+ RSAEncryptOrSign |
+ RSAEncryptOnly |
+ RSASignOnly |
+ ElgamalEncryptOnly |
+ DSA
+-}
+
+d = [234,34,2,34,34,6,63,3,45,76,32,1,34,6,67,3,2]
+st = MkPEKSKP (Just 0x23) DSA (Right (MPI $ BS.pack d, MPI $ BS.pack d))
+
+p = runPut $ put st
+
+g :: B.ByteString -> PacketState PEKSKP
+g = runGet $ get
+
+g' = g p
+
+r = g' == st
+
+instance Eq (PacketState PEKSKP) where
+ (MkPEKSKP k a d) == (MkPEKSKP k' a' d') = and [k == k', a == a', d == d']
+
+instance Binary (PacketState PEKSKP) where
+ get = fmap fst $ parserToGet $ parsePacket PEKSKP
+ put ps = do
+ putWord8 0x3
+ putWord64be $ maybe 0 id $ pekskpKeyID ps
+ putWord8 $ (fromJust . publicKeyAlgorithmToNum . pekskpPublicKeyAlgorithm) ps
+ either put (\(a,b) -> do put a ; put b) $ pekskpData ps
+
instance Packet PEKSKP where
data PacketTag PEKSKP = PEKSKPPacketTag
data PacketState PEKSKP = MkPEKSKP {
pekskpKeyID :: Maybe KeyID,
pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
pekskpData :: Either MPI (MPI, MPI)
}
packetTag _ = PEKSKPPacketTag
packetTagNum _ = 0x01
bodyParser PEKSKP = do
_ <- A.word8 3
keyid' <- parseKeyID
let keyid = if (keyid' == 0) then Nothing else Just keyid'
algo <- parsePublicKeyAlgorithm
encKey <- case (algo) of
RSAEncryptOrSign -> parseRSAEncryptedSessionKey
RSAEncryptOnly -> parseRSAEncryptedSessionKey
ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
return $ MkPEKSKP keyid algo encKey
where parseRSAEncryptedSessionKey = fmap Left parseMPI
parseElgamalEncryptedSessionKey = do
a <- parseMPI
b <- parseMPI
return $ Right (a, b)
\end{code}
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
\begin{code}
data SignatureType =
SignatureBinaryDoc |
SignatureCanonicalTextDoc |
StandaloneSignature |
GenericCertificationOfAUserIDAndPublicKeyPacket |
PersonaCertificationOfAUserIDAndPublicKeyPacket |
CasualCertificationOfAUserIDAndPublicKeyPacket |
PositiveCertificationOfAUserIDAndPublicKeyPacket |
SubkeyBindingSignature |
PrimaryKeyBindingSignature |
SignatureDirectlyOnAKey |
KeyRevocationSignature |
SubkeyRevocationSignature |
CertificationRevocationSignature |
TimestampSignature |
ThirdPartyConfirmationSignature
deriving (Show, Read, Eq, Enum)
signatureTypeCoding = [
(SignatureBinaryDoc , 0x00),
(SignatureCanonicalTextDoc , 0x01),
(StandaloneSignature , 0x02),
(GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
(PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
(CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
(PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
(SubkeyBindingSignature , 0x18),
(PrimaryKeyBindingSignature , 0x19),
(SignatureDirectlyOnAKey , 0x1F),
(KeyRevocationSignature , 0x20),
(SubkeyRevocationSignature , 0x28),
(CertificationRevocationSignature , 0x30),
(TimestampSignature , 0x40),
(ThirdPartyConfirmationSignature , 0x50)
]
lookupSignatureType :: Word8 -> Maybe SignatureType
lookupSignatureType i = lookup i $ map swap signatureTypeCoding
signatureTypeToNum :: SignatureType -> Maybe Word8
signatureTypeToNum p = lookup p signatureTypeCoding
parseSignatureType :: Parser SignatureType
parseSignatureType = do
w <- A.anyWord8
case (lookupSignatureType w) of
Nothing -> fail "unknown signature type"
Just a -> return a
\end{code}
5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
\begin{code}
data Signature3 = Signature3
instance Packet Signature3 where
data PacketTag Signature3 = Signature3PacketTag
data PacketState Signature3 = MkSignaturePacket3 {
sig3Type :: SignatureType,
sig3Time :: UTCTime,
sig3KeyID :: KeyID,
sig3PKAlgorithm :: PublicKeyAlgorithm,
sig3HashAlgorithm :: HashAlgorithm,
sig3Data :: Either MPI (MPI, MPI)
}
packetTag Signature3 = Signature3PacketTag
packetTagNum Signature3PacketTag = 0x02
bodyParser Signature3 = do
_ <- A.word8 3
l <- bodyLenParser OneOctedLength
if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
else do
stype <- parseSignatureType
t <- parseTime
keyid <- parseKeyID
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
\end{code}
Algorithm-Specific Fields for RSA signatures:
- multiprecision integer (MPI) of RSA signature value m**d mod n.
Algorithm-Specific Fields for DSA signatures:
- MPI of DSA value r.
- MPI of DSA value s.
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
-5.2.3.1. Signature Subpacket Specification
+
+\begin{code}
+
+data Signature4 = Signature4
+instance Packet Signature4 where
+ data PacketTag Signature4 = Signature4PacketTag
+ data PacketState Signature4 = MkSignaturePacket4 {
+ sig4Type :: SignatureType,
+ sig4Time :: UTCTime,
+ sig4KeyID :: KeyID,
+ sig4PKAlgorithm :: PublicKeyAlgorithm,
+ sig4HashAlgorithm :: HashAlgorithm,
+ sig4Data :: Either MPI (MPI, MPI)
+ }
+ packetTag Signature4 = Signature4PacketTag
+ packetTagNum Signature4PacketTag = 0x02
+ bodyParser Signature4 = do
+ _ <- A.word8 4
+ stype <- parseSignatureType
+ pkAlgo <- parsePublicKeyAlgorithm
+ hasha <- parseHashAlgorithm
+ hashedSubPacketLength <- bodyLenParser TwoOctedLength
+ hashedSubpacketData <- A.take hashedSubPacketLength
+ subPacketLength <- bodyLenParser TwoOctedLength
+ subpacketData <- A.take subPacketLength
+
+ return undefined
+
+{-
+ shv <- anyWord16
+ hashdata <- case (pkAlgo) of
+ RSAEncryptOrSign -> parseRSAMPI
+ RSASignOnly -> parseRSAMPI
+ DSA -> parseDSAMPI
+ let (MPI firstHash) = case (hashdata) of
+ Left h -> h
+ Right (h, _) -> h
+ if (not $ (convert firstHash) `checkFirstHash` shv)
+ then fail "signedHashValue check failed"
+ else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
+ where parseRSAMPI = fmap Left parseMPI
+ parseDSAMPI = do
+ r <- parseMPI
+ s <- parseMPI
+ return $ Right (r,s)
+ checkFirstHash bs v =
+ let a = convert (bs `B.index` 0)
+ b = convert (bs `B.index` 1)
+ v' :: Word16
+ v' = (a `shiftL` 8) .|. b
+ in v' == v
+-}
+\end{code}
+
+5.2.3.1. Signature Subpacket Specification
+
A subpacket data set consists of zero or more Signature subpackets.
In Signature packets, the subpacket data set is preceded by a two-
octet scalar count of the length in octets of all the subpackets. A
pointer incremented by this number will skip over the subpacket data
set.
Each subpacket consists of a subpacket header and a body. The header
consists of:
- the subpacket length (1, 2, or 5 octets),
- the subpacket type (1 octet),
and is followed by the subpacket-specific data.
The length includes the type octet but not this length. Its format
is similar to the "new" format packet header lengths, but cannot have
Partial Body Lengths. That is:
if the 1st octet < 192, then
lengthOfLength = 1
subpacketLen = 1st_octet
if the 1st octet >= 192 and < 255, then
lengthOfLength = 2
subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
if the 1st octet = 255, then
lengthOfLength = 5
subpacket length = [four-octet scalar starting at 2nd_octet]
+\begin{code}
+class SignatureSubpacket s where
+ data SignatureSubpacketState s :: *
+
+
+\end{code}
+
+
+
The value of the subpacket type octet may be:
0 = Reserved
1 = Reserved
2 = Signature Creation Time
3 = Signature Expiration Time
4 = Exportable Certification
5 = Trust Signature
6 = Regular Expression
7 = Revocable
8 = Reserved
9 = Key Expiration Time
10 = Placeholder for backward compatibility
11 = Preferred Symmetric Algorithms
12 = Revocation Key
13 = Reserved
14 = Reserved
15 = Reserved
16 = Issuer
17 = Reserved
18 = Reserved
19 = Reserved
20 = Notation Data
21 = Preferred Hash Algorithms
22 = Preferred Compression Algorithms
23 = Key Server Preferences
24 = Preferred Key Server
25 = Primary User ID
26 = Policy URI
27 = Key Flags
28 = Signer's User ID
29 = Reason for Revocation
30 = Features
31 = Signature Target
32 = Embedded Signature
100 To 110 = Private or experimental
An implementation SHOULD ignore any subpacket of a type that it does
not recognize.
Bit 7 of the subpacket type is the "critical" bit. If set, it
denotes that the subpacket is one that is critical for the evaluator
of the signature to recognize. If a subpacket is encountered that is
marked critical but is unknown to the evaluating software, the
evaluator SHOULD consider the signature to be in error.
An evaluator may "recognize" a subpacket, but not implement it. The
purpose of the critical bit is to allow the signer to tell an
evaluator that it would prefer a new, unknown feature to generate an
error than be ignored.
Implementations SHOULD implement the three preferred algorithm
subpackets (11, 21, and 22), as well as the "Reason for Revocation"
subpacket. Note, however, that if an implementation chooses not to
implement some of the preferences, it is required to behave in a
polite manner to respect the wishes of those users who do implement
these preferences.
5.2.3.2. Signature Subpacket Types
A number of subpackets are currently defined. Some subpackets apply
to the signature itself and some are attributes of the key.
Subpackets that are found on a self-signature are placed on a
certification made by the key itself. Note that a key may have more
than one User ID, and thus may have more than one self-signature, and
differing subpackets.
A subpacket may be found either in the hashed or unhashed subpacket
sections of a signature. If a subpacket is not hashed, then the
information in it cannot be considered definitive because it is not
part of the signature proper.
5.2.3.3. Notes on Self-Signatures
A self-signature is a binding signature made by the key to which the
signature refers. There are three types of self-signatures, the
certification signatures (types 0x10-0x13), the direct-key signature
(type 0x1F), and the subkey binding signature (type 0x18). For
certification self-signatures, each User ID may have a self-
signature, and thus different subpackets in those self-signatures.
For subkey binding signatures, each subkey in fact has a self-
signature. Subpackets that appear in a certification self-signature
apply to the user name, and subpackets that appear in the subkey
self-signature apply to the subkey. Lastly, subpackets on the
direct-key signature apply to the entire key.
Implementing software should interpret a self-signature's preference
subpackets as narrowly as possible. For example, suppose a key has
two user names, Alice and Bob. Suppose that Alice prefers the
symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the
software locates this key via Alice's name, then the preferred
algorithm is CAST5; if software locates the key via Bob's name, then
the preferred algorithm is IDEA. If the key is located by Key ID,
the algorithm of the primary User ID of the key provides the
preferred symmetric algorithm.
Revoking a self-signature or allowing it to expire has a semantic
meaning that varies with the signature type. Revoking the self-
signature on a User ID effectively retires that user name. The
self-signature is a statement, "My name X is tied to my signing key
K" and is corroborated by other users' certifications. If another
user revokes their certification, they are effectively saying that
they no longer believe that name and that key are tied together.
Similarly, if the users themselves revoke their self-signature, then
the users no longer go by that name, no longer have that email
address, etc. Revoking a binding signature effectively retires that
subkey. Revoking a direct-key signature cancels that signature.
Please see the "Reason for Revocation" subpacket (Section 5.2.3.23)
for more relevant detail.
Since a self-signature contains important information about the key's
use, an implementation SHOULD allow the user to rewrite the self-
signature, and important information in it, such as preferences and
key expiration.
It is good practice to verify that a self-signature imported into an
implementation doesn't advertise features that the implementation
doesn't support, rewriting the signature as appropriate.
An implementation that encounters multiple self-signatures on the
same object may resolve the ambiguity in any way it sees fit, but it
is RECOMMENDED that priority be given to the most recent self-
signature.
5.2.3.4. Signature Creation Time
(4-octet time field)
The time the signature was made.
MUST be present in the hashed area.
5.2.3.5. Issuer
(8-octet Key ID)
The OpenPGP Key ID of the key issuing the signature.
5.2.3.6. Key Expiration Time
(4-octet time field)
The validity period of the key. This is the number of seconds after
the key creation time that the key expires. If this is not present
or has a value of zero, the key never expires. This is found only on
a self-signature.
5.2.3.7. Preferred Symmetric Algorithms
(array of one-octet values)
Symmetric algorithm numbers that indicate which algorithms the key
holder prefers to use. The subpacket body is an ordered list of
octets with the most preferred listed first. It is assumed that only
algorithms listed are supported by the recipient's software.
Algorithm numbers are in Section 9. This is only found on a self-
signature.
5.2.3.8. Preferred Hash Algorithms
(array of one-octet values)
Message digest algorithm numbers that indicate which algorithms the
key holder prefers to receive. Like the preferred symmetric
algorithms, the list is ordered. Algorithm numbers are in Section 9.
This is only found on a self-signature.
5.2.3.9. Preferred Compression Algorithms
(array of one-octet values)
Compression algorithm numbers that indicate which algorithms the key
holder prefers to use. Like the preferred symmetric algorithms, the
list is ordered. Algorithm numbers are in Section 9. If this
subpacket is not included, ZIP is preferred. A zero denotes that
uncompressed data is preferred; the key holder's software might have
no compression software in that implementation. This is only found
on a self-signature.
5.2.3.10. Signature Expiration Time
(4-octet time field)
The validity period of the signature. This is the number of seconds
after the signature creation time that the signature expires. If
this is not present or has a value of zero, it never expires.
5.2.3.11. Exportable Certification
(1 octet of exportability, 0 for not, 1 for exportable)
This subpacket denotes whether a certification signature is
"exportable", to be used by other users than the signature's issuer.
The packet body contains a Boolean flag indicating whether the
signature is exportable. If this packet is not present, the
certification is exportable; it is equivalent to a flag containing a
1.
Non-exportable, or "local", certifications are signatures made by a
user to mark a key as valid within that user's implementation only.
Thus, when an implementation prepares a user's copy of a key for
transport to another user (this is the process of "exporting" the
key), any local certification signatures are deleted from the key.
The receiver of a transported key "imports" it, and likewise trims
any local certifications. In normal operation, there won't be any,
assuming the import is performed on an exported key. However, there
are instances where this can reasonably happen. For example, if an
implementation allows keys to be imported from a key database in
addition to an exported key, then this situation can arise.
Some implementations do not represent the interest of a single user
(for example, a key server). Such implementations always trim local
certifications from any key they handle.
5.2.3.12. Revocable
(1 octet of revocability, 0 for not, 1 for revocable)
Signature's revocability status. The packet body contains a Boolean
flag indicating whether the signature is revocable. Signatures that
are not revocable have any later revocation signatures ignored. They
represent a commitment by the signer that he cannot revoke his
signature for the life of his key. If this packet is not present,
the signature is revocable.
5.2.3.13. Trust Signature
(1 octet "level" (depth), 1 octet of trust amount)
Signer asserts that the key is not only valid but also trustworthy at
the specified level. Level 0 has the same meaning as an ordinary
validity signature. Level 1 means that the signed key is asserted to
be a valid trusted introducer, with the 2nd octet of the body
specifying the degree of trust. Level 2 means that the signed key is
asserted to be trusted to issue level 1 trust signatures, i.e., that
it is a "meta introducer". Generally, a level n trust signature
asserts that a key is trusted to issue level n-1 trust signatures.
The trust amount is in a range from 0-255, interpreted such that
values less than 120 indicate partial trust and values of 120 or
greater indicate complete trust. Implementations SHOULD emit values
of 60 for partial trust and 120 for complete trust.
5.2.3.14. Regular Expression
(null-terminated regular expression)
Used in conjunction with trust Signature packets (of level > 0) to
limit the scope of trust that is extended. Only signatures by the
target key on User IDs that match the regular expression in the body
of this packet have trust extended by the trust Signature subpacket.
The regular expression uses the same syntax as the Henry Spencer's
"almost public domain" regular expression [REGEX] package. A
description of the syntax is found in Section 8 below.
5.2.3.15. Revocation Key
(1 octet of class, 1 octet of public-key algorithm ID, 20 octets of
fingerprint)
Authorizes the specified key to issue revocation signatures for this
key. Class octet must have bit 0x80 set. If the bit 0x40 is set,
then this means that the revocation information is sensitive. Other
bits are for future expansion to other kinds of authorizations. This
is found on a self-signature.
If the "sensitive" flag is set, the keyholder feels this subpacket
contains private trust information that describes a real-world
sensitive relationship. If this flag is set, implementations SHOULD
NOT export this signature to other users except in cases where the
data needs to be available: when the signature is being sent to the
designated revoker, or when it is accompanied by a revocation
signature from that revoker. Note that it may be appropriate to
isolate this subpacket within a separate signature so that it is not
combined with other subpackets that need to be exported.
5.2.3.16. Notation Data
(4 octets of flags, 2 octets of name length (M),
2 octets of value length (N),
M octets of name data,
N octets of value data)
This subpacket describes a "notation" on the signature that the
issuer wishes to make. The notation has a name and a value, each of
which are strings of octets. There may be more than one notation in
a signature. Notations can be used for any extension the issuer of
the signature cares to make. The "flags" field holds four octets of
flags.
All undefined flags MUST be zero. Defined flags are as follows:
First octet: 0x80 = human-readable. This note value is text.
Other octets: none.
Notation names are arbitrary strings encoded in UTF-8. They reside
in two namespaces: The IETF namespace and the user namespace.
The IETF namespace is registered with IANA. These names MUST NOT
contain the "@" character (0x40). This is a tag for the user
namespace.
Names in the user namespace consist of a UTF-8 string tag followed by
"@" followed by a DNS domain name. Note that the tag MUST NOT
contain an "@" character. For example, the "sample" tag used by
Example Corporation could be "[email protected]".
Names in a user space are owned and controlled by the owners of that
domain. Obviously, it's bad form to create a new name in a DNS space
that you don't own.
Since the user namespace is in the form of an email address,
implementers MAY wish to arrange for that address to reach a person
who can be consulted about the use of the named tag. Note that due
to UTF-8 encoding, not all valid user space name tags are valid email
addresses.
If there is a critical notation, the criticality applies to that
specific notation and not to notations in general.
5.2.3.17. Key Server Preferences
(N octets of flags)
This is a list of one-bit flags that indicate preferences that the
key holder has about how the key is handled on a key server. All
undefined flags MUST be zero.
First octet: 0x80 = No-modify
the key holder requests that this key only be modified or updated
by the key holder or an administrator of the key server.
This is found only on a self-signature.
5.2.3.18. Preferred Key Server
(String)
This is a URI of a key server that the key holder prefers be used for
updates. Note that keys with multiple User IDs can have a preferred
key server for each User ID. Note also that since this is a URI, the
key server can actually be a copy of the key retrieved by ftp, http,
finger, etc.
5.2.3.19. Primary User ID
(1 octet, Boolean)
This is a flag in a User ID's self-signature that states whether this
User ID is the main User ID for this key. It is reasonable for an
implementation to resolve ambiguities in preferences, etc. by
referring to the primary User ID. If this flag is absent, its value
is zero. If more than one User ID in a key is marked as primary, the
implementation may resolve the ambiguity in any way it sees fit, but
it is RECOMMENDED that priority be given to the User ID with the most
recent self-signature.
When appearing on a self-signature on a User ID packet, this
subpacket applies only to User ID packets. When appearing on a
self-signature on a User Attribute packet, this subpacket applies
only to User Attribute packets. That is to say, there are two
different and independent "primaries" -- one for User IDs, and one
for User Attributes.
5.2.3.20. Policy URI
(String)
This subpacket contains a URI of a document that describes the policy
under which the signature was issued.
5.2.3.21. Key Flags
(N octets of flags)
This subpacket contains a list of binary flags that hold information
about a key. It is a string of octets, and an implementation MUST
NOT assume a fixed size. This is so it can grow over time. If a
list is shorter than an implementation expects, the unstated flags
are considered to be zero. The defined flags are as follows:
First octet:
0x01 - This key may be used to certify other keys.
0x02 - This key may be used to sign data.
0x04 - This key may be used to encrypt communications.
0x08 - This key may be used to encrypt storage.
0x10 - The private component of this key may have been split
by a secret-sharing mechanism.
0x20 - This key may be used for authentication.
0x80 - The private component of this key may be in the
possession of more than one person.
Usage notes:
The flags in this packet may appear in self-signatures or in
certification signatures. They mean different things depending on
who is making the statement -- for example, a certification signature
that has the "sign data" flag is stating that the certification is
for that use. On the other hand, the "communications encryption"
flag in a self-signature is stating a preference that a given key be
used for communications. Note however, that it is a thorny issue to
determine what is "communications" and what is "storage". This
decision is left wholly up to the implementation; the authors of this
document do not claim any special wisdom on the issue and realize
that accepted opinion may change.
The "split key" (0x10) and "group key" (0x80) flags are placed on a
self-signature only; they are meaningless on a certification
signature. They SHOULD be placed only on a direct-key signature
(type 0x1F) or a subkey signature (type 0x18), one that refers to the
key the flag applies to.
5.2.3.22. Signer's User ID
(String)
This subpacket allows a keyholder to state which User ID is
responsible for the signing. Many keyholders use a single key for
different purposes, such as business communications as well as
personal communications. This subpacket allows such a keyholder to
state which of their roles is making a signature.
This subpacket is not appropriate to use to refer to a User Attribute
packet.
5.2.3.23. Reason for Revocation
(1 octet of revocation code, N octets of reason string)
This subpacket is used only in key revocation and certification
revocation signatures. It describes the reason why the key or
certificate was revoked.
The first octet contains a machine-readable code that denotes the
reason for the revocation:
0 - No reason specified (key revocations or cert revocations)
1 - Key is superseded (key revocations)
2 - Key material has been compromised (key revocations)
3 - Key is retired and no longer used (key revocations)
32 - User ID information is no longer valid (cert revocations)
100-110 - Private Use
Following the revocation code is a string of octets that gives
information about the Reason for Revocation in human-readable form
(UTF-8). The string may be null, that is, of zero length. The
length of the subpacket is the length of the reason string plus one.
An implementation SHOULD implement this subpacket, include it in all
revocation signatures, and interpret revocations appropriately.
There are important semantic differences between the reasons, and
there are thus important reasons for revoking signatures.
If a key has been revoked because of a compromise, all signatures
created by that key are suspect. However, if it was merely
superseded or retired, old signatures are still valid. If the
revoked signature is the self-signature for certifying a User ID, a
revocation denotes that that user name is no longer in use. Such a
revocation SHOULD include a 0x20 code.
Note that any signature may be revoked, including a certification on
some other person's key. There are many good reasons for revoking a
certification signature, such as the case where the keyholder leaves
the employ of a business with an email address. A revoked
certification is no longer a part of validity calculations.
5.2.3.24. Features
(N octets of flags)
The Features subpacket denotes which advanced OpenPGP features a
user's implementation supports. This is so that as features are
added to OpenPGP that cannot be backwards-compatible, a user can
state that they can use that feature. The flags are single bits that
indicate that a given feature is supported.
This subpacket is similar to a preferences subpacket, and only
appears in a self-signature.
diff --git a/OpenPGPTests.hs b/OpenPGPTests.hs
new file mode 100644
index 0000000..e200a09
--- /dev/null
+++ b/OpenPGPTests.hs
@@ -0,0 +1,63 @@
+
+module Main where
+
+import OpenPGP
+import Test.QuickCheck
+import Data.Binary
+import Data.Binary.Get
+import Data.Binary.Put
+import Data.ByteString.Lazy (ByteString)
+import qualified Data.ByteString as BS
+import qualified Data.Attoparsec as A
+import Data.Convertible
+import Data.Time (UTCTime(..), picosecondsToDiffTime)
+import System.Time (ClockTime(..))
+
+main = do
+ chk prop_MPIBinary
+ chk prop_KeyIDParser
+ chk prop_UTCTimeParser
+ return ()
+ where
+ chk :: Testable prop => prop -> IO ()
+ chk = quickCheck
+ -- chk = verboseCheck
+
+rPut :: (Binary t) => t -> ByteString
+rPut = runPut . put
+
+rGet :: Binary t => ByteString -> t
+rGet bs = runGet get bs
+
+prop_MPIBinary :: [Word8] -> Property
+prop_MPIBinary bs =
+ let mpi = (MPI . BS.pack) bs
+ empi = rPut mpi
+ dmpi = rGet empi
+ in label "binary encoding / decoding of MPI" (mpi == dmpi)
+
+
+prop_KeyIDParser :: KeyID -> Property
+prop_KeyIDParser kid =
+ let ekid = convert $ rPut kid
+ rdkid = A.maybeResult $ A.parse parseKeyID ekid
+ dkid = case rdkid of
+ Nothing -> error "unable to parse KeyID"
+ Just a -> a
+ in label "KeyID parser test" (kid == dkid)
+
+prop_UTCTimeParser :: Integer -> Property
+prop_UTCTimeParser i =
+ let utc :: UTCTime
+ utc = convert $ TOD (abs i) 0
+ in label "UTCTime parser test" $
+ case (A.maybeResult $ A.parse parseTime (convert $ rPut utc)) of
+ Nothing -> error "unable to parse Time"
+ Just utc' -> utc == utc'
+
+{-
+instance Arbitrary UTCTime where
+ arbitrary = do
+ offset <- choose (0, 20000) :: Gen Float
+ return . fromMJD' $ offset + fromRational startOfTimeMJD
+-}
\ No newline at end of file
|
alios/lab
|
bb23995680b82643dbddf8e3092c20cec5beb264
|
some more code cleanup
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index f26a169..83f8bd4 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -1,1163 +1,1152 @@
\begin{code}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
+module OpenPGP ( Packet (..)
+ , PEKSKP (..)
+ , Signature3 (..)
+ ) where
+
import Data.Enumerator (Iteratee)
import Data.Attoparsec (Parser, (<?>))
import Data.Attoparsec.Enumerator
import qualified Data.Attoparsec as A
import Data.Convertible
import qualified Data.ByteString.Base64 as Base64
import Data.Time (UTCTime)
import Data.Bits
import Data.Word
import Data.Tuple (swap)
import Data.Binary (decode)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy as B
import Data.ByteString (ByteString)
import System.Time
decodeStrictBS bs = (decode . B.fromChunks) [bs]
anyWord16 :: Parser Word16
anyWord16 = fmap decodeStrictBS (A.take 2 <?> "word16")
anyWord32 :: Parser Word32
anyWord32 = fmap decodeStrictBS (A.take 4 <?> "word32")
anyWord64 :: Parser Word64
anyWord64 = fmap decodeStrictBS (A.take 8 <?> "word64")
\end{code}
3. Data Element Formats
This section describes the data elements used by OpenPGP.
3.1. Scalar Numbers
Scalar numbers are unsigned and are always stored in big-endian
format. Using n[k] to refer to the kth octet being interpreted, the
value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a
four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
n[3]).
3.2. Multiprecision Integers
Multiprecision integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used in cryptographic
calculations.
An MPI consists of two pieces: a two-octet scalar that is the length
of the MPI in bits followed by a string of octets that contain the
actual integer.
These octets form a big-endian number; a big-endian number can be
made into an MPI by prefixing it with the appropriate length.
Examples:
(all numbers are in hexadecimal)
The string of octets [00 01 01] forms an MPI with the value 1. The
string [00 09 01 FF] forms an MPI with the value of 511.
Additional rules:
The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
The length field of an MPI describes the length starting from its
most significant non-zero bit. Thus, the MPI [00 02 01] is not
formed correctly. It should be [00 01 01].
Unused bits of an MPI MUST be zero.
Also note that when an MPI is encrypted, the length refers to the
plaintext MPI. It may be ill-formed in its ciphertext.
\begin{code}
newtype MPI = MPI ByteString
parseMPI :: Parser MPI
parseMPI = do
ls <- fmap convert anyWord16
bs <- (A.take ls <?> "MPI")
return $ MPI bs
\end{code}
3.3. Key IDs
A Key ID is an eight-octet scalar that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique. The
section "Enhanced Key Formats" below describes how Key IDs are
formed.
\begin{code}
type KeyID = Word64
parseKeyID :: Parser KeyID
parseKeyID = fmap decodeStrictBS (A.take 8 <?> "KeyID")
\end{code}
3.4. Text
Unless otherwise specified, the character set for text is the UTF-8
[RFC3629] encoding of Unicode [ISO10646].
3.5. Time Fields
A time field is an unsigned four-octet number containing the number
of seconds elapsed since midnight, 1 January 1970 UTC.
\begin{code}
parseTime :: Parser UTCTime
parseTime = do
ts <- anyWord32 <?> "TimeField"
return $ convert $ TOD (convert ts) 0
\end{code}
3.6. Keyrings
A keyring is a collection of one or more keys in a file or database.
Traditionally, a keyring is simply a sequential list of keys, but may
be any suitable database. It is beyond the scope of this standard to
discuss the details of keyrings or other databases.
3.7. String-to-Key (S2K) Specifiers
String-to-key (S2K) specifiers are used to convert passphrase strings
into symmetric-key encryption/decryption keys. They are used in two
places, currently: to encrypt the secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
symmetrically encrypted messages.
3.7.1. String-to-Key (S2K) Specifier Types
There are three types of S2K specifiers currently supported, and
some reserved values:
ID S2K Type
-- --------
0 Simple S2K
1 Salted S2K
2 Reserved value
3 Iterated and Salted S2K
100 to 110 Private/Experimental S2K
These are described in Sections 3.7.1.1 - 3.7.1.3.
\begin{code}
data StringToKeySpecifier =
SimpleS2K Word8|
SaltedS2K Word8 Word64 |
IteratedAndSaltedS2K Word8 Word64 Word8
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
-
parseHashAlgo = A.anyWord8 <?> "hash algorithm" -- TODO: Parse hash Algo correctly
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
+
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
hashAlgo <- parseHashAlgo
return $ SimpleS2K hashAlgo
+
\end{code}
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
+
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
+
\end{code}
+
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
+
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
+
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
+
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
-
\end{code}
+
+
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
+
\begin{code}
+
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
+
\end{code}
+
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
+
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
+
\end{code}
+
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
+
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
+
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
+
\end{code}
+
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
+
5. Packet Types
\begin{code}
class Packet t where
data PacketState t :: *
data PacketTag t :: *
packetTag :: t -> PacketTag t
packetTagNum :: PacketTag t -> Word8
bodyParser :: t -> Parser (PacketState t)
isOldPacketTag :: PacketTag t -> Bool
isOldPacketTag = ((<) 16) . packetTagNum
+ parsePacket :: t -> Parser (PacketState t, Maybe PacketLength)
+ parsePacket t =
+ let n = (packetTagNum . packetTag) t
+ isOld = (isOldPacketTag . packetTag) t
+ in do
+ w <- A.anyWord8
+ let maskedPacket = w .&. 0x3f
+ if (w `testBit` 7)
+ then fail $ "no valid packet header"
+ else if (maskedPacket == n) then fail $ "read invalid header tag " ++ show maskedPacket
+ else if (isOld)
+ then do
+ body <- bodyParser t
+ case (lookupPacketLength $ maskedPacket .&. 0x03) of
+ Nothing -> fail ""
+ Just len -> return (body, Just len)
+ else do
+ body <- bodyParser t
+ return (body, Nothing)
-parsePacket' :: Packet t => [t] -> Parser (PacketState t, Maybe PacketLength)
-parsePacket' ts =
- let validPacketTags = [( (packetTagNum . packetTag) t, (t, (isOldPacketTag . packetTag) t)) | t <- ts]
- in do
- w <- A.anyWord8
- let maskedPacket = w .&. 0x3f
- if (w `testBit` 7)
- then fail $ "no valid packet header"
- else case (lookup maskedPacket validPacketTags) of
- Nothing -> fail $ "unknown old packet header tag " ++ show maskedPacket
- Just (t, False) -> do
- body <- bodyParser t
- return (body, Nothing)
- Just (t, True) -> do
- body <- bodyParser t
- case (lookupPacketLength $ maskedPacket .&. 0x03) of
- Nothing -> fail ""
- Just len -> return (body, Just len)
-
\end{code}
-data PacketHeaderT =
- OldPacketHeader PacketTag PacketLength |
- NewPacketHeader PacketTag
-
-class PacketHeader h where
- packetHeaderTag :: h -> PacketTag
-
-instance PacketHeader PacketHeaderT where
- packetHeaderTag (OldPacketHeader t _) = t
- packetHeaderTag (NewPacketHeader t) = t
-
-
-parsePacketHeader :: Parser PacketHeaderT
-parsePacketHeader = do
- w <- A.try A.anyWord8
- let valid = w `testBit` 7
- if (not valid) then fail "is not a valid packet header"
- else do
- let newPacket = w `testBit` 6
- let maskedPacket = w .&. 0x3f
- if (newPacket) then do
- case (lookupPacketTag maskedPacket) of
- Nothing -> fail "unknown new packet header tag"
- Just t -> return $ NewPacketHeader t
- else do
- let tag = lookupPacketTag $ maskedPacket `shiftR` 2
- let len = maskedPacket .&. 0x03
- case (lookupPacketLength len) of
- Nothing -> fail "unknown old packet header length field"
- Just l -> case (tag) of
- Nothing -> fail "unknown old packet header tag"
- Just t -> if (not $ isValidOldTag t) then fail "unknown old packet header tag"
- else return $ OldPacketHeader t l
-
-headerIteratee :: Monad m => Iteratee ByteString m PacketHeaderT
-headerIteratee = iterParser parsePacketHeader
-
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
-\begin{code}
+
+\begin{code}
data PEKSKP = PEKSKP
instance Packet PEKSKP where
data PacketTag PEKSKP = PEKSKPPacketTag
data PacketState PEKSKP = MkPEKSKP {
pekskpKeyID :: Maybe KeyID,
pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
pekskpData :: Either MPI (MPI, MPI)
}
packetTag _ = PEKSKPPacketTag
packetTagNum _ = 0x01
bodyParser PEKSKP = do
_ <- A.word8 3
keyid' <- parseKeyID
let keyid = if (keyid' == 0) then Nothing else Just keyid'
algo <- parsePublicKeyAlgorithm
encKey <- case (algo) of
RSAEncryptOrSign -> parseRSAEncryptedSessionKey
RSAEncryptOnly -> parseRSAEncryptedSessionKey
ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
return $ MkPEKSKP keyid algo encKey
where parseRSAEncryptedSessionKey = fmap Left parseMPI
parseElgamalEncryptedSessionKey = do
a <- parseMPI
b <- parseMPI
return $ Right (a, b)
\end{code}
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
\begin{code}
data SignatureType =
SignatureBinaryDoc |
SignatureCanonicalTextDoc |
StandaloneSignature |
GenericCertificationOfAUserIDAndPublicKeyPacket |
PersonaCertificationOfAUserIDAndPublicKeyPacket |
CasualCertificationOfAUserIDAndPublicKeyPacket |
PositiveCertificationOfAUserIDAndPublicKeyPacket |
SubkeyBindingSignature |
PrimaryKeyBindingSignature |
SignatureDirectlyOnAKey |
KeyRevocationSignature |
SubkeyRevocationSignature |
CertificationRevocationSignature |
TimestampSignature |
ThirdPartyConfirmationSignature
deriving (Show, Read, Eq, Enum)
signatureTypeCoding = [
(SignatureBinaryDoc , 0x00),
(SignatureCanonicalTextDoc , 0x01),
(StandaloneSignature , 0x02),
(GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
(PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
(CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
(PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
(SubkeyBindingSignature , 0x18),
(PrimaryKeyBindingSignature , 0x19),
(SignatureDirectlyOnAKey , 0x1F),
(KeyRevocationSignature , 0x20),
(SubkeyRevocationSignature , 0x28),
(CertificationRevocationSignature , 0x30),
(TimestampSignature , 0x40),
(ThirdPartyConfirmationSignature , 0x50)
]
lookupSignatureType :: Word8 -> Maybe SignatureType
lookupSignatureType i = lookup i $ map swap signatureTypeCoding
signatureTypeToNum :: SignatureType -> Maybe Word8
signatureTypeToNum p = lookup p signatureTypeCoding
parseSignatureType :: Parser SignatureType
parseSignatureType = do
w <- A.anyWord8
case (lookupSignatureType w) of
Nothing -> fail "unknown signature type"
Just a -> return a
\end{code}
5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
\begin{code}
data Signature3 = Signature3
instance Packet Signature3 where
data PacketTag Signature3 = Signature3PacketTag
data PacketState Signature3 = MkSignaturePacket3 {
sig3Type :: SignatureType,
sig3Time :: UTCTime,
sig3KeyID :: KeyID,
sig3PKAlgorithm :: PublicKeyAlgorithm,
sig3HashAlgorithm :: HashAlgorithm,
sig3Data :: Either MPI (MPI, MPI)
}
packetTag Signature3 = Signature3PacketTag
packetTagNum Signature3PacketTag = 0x02
bodyParser Signature3 = do
_ <- A.word8 3
l <- bodyLenParser OneOctedLength
if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
else do
stype <- parseSignatureType
t <- parseTime
keyid <- parseKeyID
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
\end{code}
Algorithm-Specific Fields for RSA signatures:
- multiprecision integer (MPI) of RSA signature value m**d mod n.
Algorithm-Specific Fields for DSA signatures:
- MPI of DSA value r.
- MPI of DSA value s.
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
5.2.3.1. Signature Subpacket Specification
A subpacket data set consists of zero or more Signature subpackets.
In Signature packets, the subpacket data set is preceded by a two-
octet scalar count of the length in octets of all the subpackets. A
pointer incremented by this number will skip over the subpacket data
set.
Each subpacket consists of a subpacket header and a body. The header
consists of:
- the subpacket length (1, 2, or 5 octets),
- the subpacket type (1 octet),
and is followed by the subpacket-specific data.
The length includes the type octet but not this length. Its format
is similar to the "new" format packet header lengths, but cannot have
Partial Body Lengths. That is:
if the 1st octet < 192, then
lengthOfLength = 1
subpacketLen = 1st_octet
if the 1st octet >= 192 and < 255, then
lengthOfLength = 2
subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
if the 1st octet = 255, then
lengthOfLength = 5
subpacket length = [four-octet scalar starting at 2nd_octet]
The value of the subpacket type octet may be:
0 = Reserved
1 = Reserved
2 = Signature Creation Time
3 = Signature Expiration Time
4 = Exportable Certification
5 = Trust Signature
6 = Regular Expression
7 = Revocable
8 = Reserved
9 = Key Expiration Time
10 = Placeholder for backward compatibility
11 = Preferred Symmetric Algorithms
12 = Revocation Key
13 = Reserved
14 = Reserved
15 = Reserved
16 = Issuer
17 = Reserved
18 = Reserved
|
alios/lab
|
8366ccdf9aecce78e5c92673f717dd4f3c962396
|
refactored the Packet data types to use type family classes
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index f19a327..f26a169 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -1,1507 +1,1480 @@
\begin{code}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
import Data.Enumerator (Iteratee)
import Data.Attoparsec (Parser, (<?>))
import Data.Attoparsec.Enumerator
import qualified Data.Attoparsec as A
import Data.Convertible
import qualified Data.ByteString.Base64 as Base64
import Data.Time (UTCTime)
import Data.Bits
import Data.Word
import Data.Tuple (swap)
import Data.Binary (decode)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy as B
import Data.ByteString (ByteString)
import System.Time
decodeStrictBS bs = (decode . B.fromChunks) [bs]
anyWord16 :: Parser Word16
anyWord16 = fmap decodeStrictBS (A.take 2 <?> "word16")
anyWord32 :: Parser Word32
anyWord32 = fmap decodeStrictBS (A.take 4 <?> "word32")
anyWord64 :: Parser Word64
anyWord64 = fmap decodeStrictBS (A.take 8 <?> "word64")
\end{code}
3. Data Element Formats
This section describes the data elements used by OpenPGP.
3.1. Scalar Numbers
Scalar numbers are unsigned and are always stored in big-endian
format. Using n[k] to refer to the kth octet being interpreted, the
value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a
four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
n[3]).
3.2. Multiprecision Integers
Multiprecision integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used in cryptographic
calculations.
An MPI consists of two pieces: a two-octet scalar that is the length
of the MPI in bits followed by a string of octets that contain the
actual integer.
These octets form a big-endian number; a big-endian number can be
made into an MPI by prefixing it with the appropriate length.
Examples:
(all numbers are in hexadecimal)
The string of octets [00 01 01] forms an MPI with the value 1. The
string [00 09 01 FF] forms an MPI with the value of 511.
Additional rules:
The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
The length field of an MPI describes the length starting from its
most significant non-zero bit. Thus, the MPI [00 02 01] is not
formed correctly. It should be [00 01 01].
Unused bits of an MPI MUST be zero.
Also note that when an MPI is encrypted, the length refers to the
plaintext MPI. It may be ill-formed in its ciphertext.
\begin{code}
newtype MPI = MPI ByteString
parseMPI :: Parser MPI
parseMPI = do
ls <- fmap convert anyWord16
bs <- (A.take ls <?> "MPI")
return $ MPI bs
\end{code}
3.3. Key IDs
A Key ID is an eight-octet scalar that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique. The
section "Enhanced Key Formats" below describes how Key IDs are
formed.
\begin{code}
type KeyID = Word64
parseKeyID :: Parser KeyID
parseKeyID = fmap decodeStrictBS (A.take 8 <?> "KeyID")
\end{code}
3.4. Text
Unless otherwise specified, the character set for text is the UTF-8
[RFC3629] encoding of Unicode [ISO10646].
3.5. Time Fields
A time field is an unsigned four-octet number containing the number
of seconds elapsed since midnight, 1 January 1970 UTC.
\begin{code}
parseTime :: Parser UTCTime
parseTime = do
ts <- anyWord32 <?> "TimeField"
return $ convert $ TOD (convert ts) 0
\end{code}
3.6. Keyrings
A keyring is a collection of one or more keys in a file or database.
Traditionally, a keyring is simply a sequential list of keys, but may
be any suitable database. It is beyond the scope of this standard to
discuss the details of keyrings or other databases.
3.7. String-to-Key (S2K) Specifiers
String-to-key (S2K) specifiers are used to convert passphrase strings
into symmetric-key encryption/decryption keys. They are used in two
places, currently: to encrypt the secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
symmetrically encrypted messages.
3.7.1. String-to-Key (S2K) Specifier Types
There are three types of S2K specifiers currently supported, and
some reserved values:
ID S2K Type
-- --------
0 Simple S2K
1 Salted S2K
2 Reserved value
3 Iterated and Salted S2K
100 to 110 Private/Experimental S2K
These are described in Sections 3.7.1.1 - 3.7.1.3.
\begin{code}
data StringToKeySpecifier =
SimpleS2K Word8|
SaltedS2K Word8 Word64 |
IteratedAndSaltedS2K Word8 Word64 Word8
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
parseHashAlgo = A.anyWord8 <?> "hash algorithm" -- TODO: Parse hash Algo correctly
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
hashAlgo <- parseHashAlgo
return $ SimpleS2K hashAlgo
\end{code}
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
\end{code}
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
-\begin{code}
-data PacketHeaderT =
- OldPacketHeader PacketTag PacketLength |
- NewPacketHeader PacketTag
-
-class PacketHeader h where
- packetHeaderTag :: h -> PacketTag
-
-instance PacketHeader PacketHeaderT where
- packetHeaderTag (OldPacketHeader t _) = t
- packetHeaderTag (NewPacketHeader t) = t
-
-parsePacketHeader :: Parser PacketHeaderT
-parsePacketHeader = do
- w <- A.try A.anyWord8
- let valid = w `testBit` 7
- if (not valid) then fail "is not a valid packet header"
- else do
- let newPacket = w `testBit` 6
- let maskedPacket = w .&. 0x3f
- if (newPacket) then do
- case (lookupPacketTag maskedPacket) of
- Nothing -> fail "unknown new packet header tag"
- Just t -> return $ NewPacketHeader t
- else do
- let tag = lookupPacketTag $ maskedPacket `shiftR` 2
- let len = maskedPacket .&. 0x03
- case (lookupPacketLength len) of
- Nothing -> fail "unknown old packet header length field"
- Just l -> case (tag) of
- Nothing -> fail "unknown old packet header tag"
- Just t -> if (not $ isValidOldTag t) then fail "unknown old packet header tag"
- else return $ OldPacketHeader t l
-
-headerIteratee :: Monad m => Iteratee ByteString m PacketHeaderT
-headerIteratee = iterParser parsePacketHeader
-
-\end{code}
-
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
+5. Packet Types
+
\begin{code}
-data PacketTag =
- PublicKeyEncryptedSessionKeyPacket |
- SignaturePacket |
- SymmetricKeyEncryptedSessionKeyPacket |
- OnePassSignaturePacket |
- SecretKeyPacket |
- PublicKeyPacket |
- SecretSubkeyPacket |
- CompressedDataPacket |
- SymmetricallyEncryptedPacket |
- MarkerPacket |
- LiteralDataPacket |
- TrustPacket |
- UserIDPacket |
- PublicSubkeyPacket |
- UserAttributePacket |
- SymEncryptedAndIntegrityProtectedDataPacket |
- ModificationDetectionCodePacket
- deriving (Show, Read, Eq)
-
-packetTagCoding = [
- (PublicKeyEncryptedSessionKeyPacket, 1),
- (SignaturePacket, 2),
- (SymmetricKeyEncryptedSessionKeyPacket, 3),
- (OnePassSignaturePacket, 4),
- (SecretKeyPacket, 5),
- (PublicKeyPacket, 6),
- (SecretSubkeyPacket, 7),
- (CompressedDataPacket, 8),
- (SymmetricallyEncryptedPacket, 9),
- (MarkerPacket, 10),
- (LiteralDataPacket, 11),
- (TrustPacket, 12),
- (UserIDPacket, 13),
- (PublicSubkeyPacket, 14),
- (UserAttributePacket, 17),
- (SymEncryptedAndIntegrityProtectedDataPacket, 18),
- (ModificationDetectionCodePacket, 19)
- ]
-isValidOldTag :: PacketTag -> Bool
-isValidOldTag t = case (packetTagToNum t) of
- Nothing -> False
- Just t' -> t' < 16
-
-isValidOldTagNum :: Word8 -> Bool
-isValidOldTagNum i = case (lookupPacketTag i) of
- Nothing -> False
- Just _ -> (i > 0) && (i < 16)
+class Packet t where
+ data PacketState t :: *
+ data PacketTag t :: *
+ packetTag :: t -> PacketTag t
+ packetTagNum :: PacketTag t -> Word8
+ bodyParser :: t -> Parser (PacketState t)
+ isOldPacketTag :: PacketTag t -> Bool
+ isOldPacketTag = ((<) 16) . packetTagNum
+
+parsePacket' :: Packet t => [t] -> Parser (PacketState t, Maybe PacketLength)
+parsePacket' ts =
+ let validPacketTags = [( (packetTagNum . packetTag) t, (t, (isOldPacketTag . packetTag) t)) | t <- ts]
+ in do
+ w <- A.anyWord8
+ let maskedPacket = w .&. 0x3f
+ if (w `testBit` 7)
+ then fail $ "no valid packet header"
+ else case (lookup maskedPacket validPacketTags) of
+ Nothing -> fail $ "unknown old packet header tag " ++ show maskedPacket
+ Just (t, False) -> do
+ body <- bodyParser t
+ return (body, Nothing)
+ Just (t, True) -> do
+ body <- bodyParser t
+ case (lookupPacketLength $ maskedPacket .&. 0x03) of
+ Nothing -> fail ""
+ Just len -> return (body, Just len)
+
+\end{code}
+
+data PacketHeaderT =
+ OldPacketHeader PacketTag PacketLength |
+ NewPacketHeader PacketTag
-packetTagToNum :: PacketTag -> Maybe Word8
-packetTagToNum t = lookup t packetTagCoding
-lookupPacketTag :: Word8 -> Maybe PacketTag
-lookupPacketTag i = lookup i $ map swap packetTagCoding
+class PacketHeader h where
+ packetHeaderTag :: h -> PacketTag
-\end{code}
+instance PacketHeader PacketHeaderT where
+ packetHeaderTag (OldPacketHeader t _) = t
+ packetHeaderTag (NewPacketHeader t) = t
+
-5. Packet Types
+parsePacketHeader :: Parser PacketHeaderT
+parsePacketHeader = do
+ w <- A.try A.anyWord8
+ let valid = w `testBit` 7
+ if (not valid) then fail "is not a valid packet header"
+ else do
+ let newPacket = w `testBit` 6
+ let maskedPacket = w .&. 0x3f
+ if (newPacket) then do
+ case (lookupPacketTag maskedPacket) of
+ Nothing -> fail "unknown new packet header tag"
+ Just t -> return $ NewPacketHeader t
+ else do
+ let tag = lookupPacketTag $ maskedPacket `shiftR` 2
+ let len = maskedPacket .&. 0x03
+ case (lookupPacketLength len) of
+ Nothing -> fail "unknown old packet header length field"
+ Just l -> case (tag) of
+ Nothing -> fail "unknown old packet header tag"
+ Just t -> if (not $ isValidOldTag t) then fail "unknown old packet header tag"
+ else return $ OldPacketHeader t l
-\begin{code}
-data Packet =
- MkPEKSKP {
- pekskpKeyID :: Maybe KeyID,
- pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
- pekskpData :: Either MPI (MPI, MPI)
- } |
- MkSignaturePacket3 {
- sig3Type :: SignatureType,
- sig3Time :: UTCTime,
- sig3KeyID :: KeyID,
- sig3PKAlgorithm :: PublicKeyAlgorithm,
- sig3HashAlgorithm :: HashAlgorithm,
- sig3Data :: Either MPI (MPI, MPI)
- }
-
-parsePacket = do
- tag <- fmap packetHeaderTag parsePacketHeader
- case tag of
- PublicKeyEncryptedSessionKeyPacket -> parsePEKSKPBody
- SignaturePacket -> parseSignaturePBody3
-
-\end{code}
+headerIteratee :: Monad m => Iteratee ByteString m PacketHeaderT
+headerIteratee = iterParser parsePacketHeader
+
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
-\begin{code}
+\begin{code}
-parsePEKSKPBody :: Parser Packet
-parsePEKSKPBody = do
- _ <- A.word8 3
- keyid' <- parseKeyID
- let keyid = if (keyid' == 0) then Nothing else Just keyid'
- algo <- parsePublicKeyAlgorithm
- encKey <- case (algo) of
- RSAEncryptOrSign -> parseRSAEncryptedSessionKey
- RSAEncryptOnly -> parseRSAEncryptedSessionKey
- ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
- return $ MkPEKSKP keyid algo encKey
- where parseRSAEncryptedSessionKey = fmap Left parseMPI
- parseElgamalEncryptedSessionKey = do
- a <- parseMPI
- b <- parseMPI
- return $ Right (a, b)
+data PEKSKP = PEKSKP
+
+instance Packet PEKSKP where
+ data PacketTag PEKSKP = PEKSKPPacketTag
+ data PacketState PEKSKP = MkPEKSKP {
+ pekskpKeyID :: Maybe KeyID,
+ pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
+ pekskpData :: Either MPI (MPI, MPI)
+ }
+ packetTag _ = PEKSKPPacketTag
+ packetTagNum _ = 0x01
+ bodyParser PEKSKP = do
+ _ <- A.word8 3
+ keyid' <- parseKeyID
+ let keyid = if (keyid' == 0) then Nothing else Just keyid'
+ algo <- parsePublicKeyAlgorithm
+ encKey <- case (algo) of
+ RSAEncryptOrSign -> parseRSAEncryptedSessionKey
+ RSAEncryptOnly -> parseRSAEncryptedSessionKey
+ ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
+ return $ MkPEKSKP keyid algo encKey
+ where parseRSAEncryptedSessionKey = fmap Left parseMPI
+ parseElgamalEncryptedSessionKey = do
+ a <- parseMPI
+ b <- parseMPI
+ return $ Right (a, b)
\end{code}
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
\begin{code}
data SignatureType =
SignatureBinaryDoc |
SignatureCanonicalTextDoc |
StandaloneSignature |
GenericCertificationOfAUserIDAndPublicKeyPacket |
PersonaCertificationOfAUserIDAndPublicKeyPacket |
CasualCertificationOfAUserIDAndPublicKeyPacket |
PositiveCertificationOfAUserIDAndPublicKeyPacket |
SubkeyBindingSignature |
PrimaryKeyBindingSignature |
SignatureDirectlyOnAKey |
KeyRevocationSignature |
SubkeyRevocationSignature |
CertificationRevocationSignature |
TimestampSignature |
ThirdPartyConfirmationSignature
deriving (Show, Read, Eq, Enum)
signatureTypeCoding = [
(SignatureBinaryDoc , 0x00),
(SignatureCanonicalTextDoc , 0x01),
(StandaloneSignature , 0x02),
(GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
(PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
(CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
(PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
(SubkeyBindingSignature , 0x18),
(PrimaryKeyBindingSignature , 0x19),
(SignatureDirectlyOnAKey , 0x1F),
(KeyRevocationSignature , 0x20),
(SubkeyRevocationSignature , 0x28),
(CertificationRevocationSignature , 0x30),
(TimestampSignature , 0x40),
(ThirdPartyConfirmationSignature , 0x50)
]
lookupSignatureType :: Word8 -> Maybe SignatureType
lookupSignatureType i = lookup i $ map swap signatureTypeCoding
signatureTypeToNum :: SignatureType -> Maybe Word8
signatureTypeToNum p = lookup p signatureTypeCoding
parseSignatureType :: Parser SignatureType
parseSignatureType = do
w <- A.anyWord8
case (lookupSignatureType w) of
Nothing -> fail "unknown signature type"
Just a -> return a
\end{code}
5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
\begin{code}
-parseSignaturePBody3 :: Parser Packet
-parseSignaturePBody3 = do
+
+data Signature3 = Signature3
+instance Packet Signature3 where
+ data PacketTag Signature3 = Signature3PacketTag
+ data PacketState Signature3 = MkSignaturePacket3 {
+ sig3Type :: SignatureType,
+ sig3Time :: UTCTime,
+ sig3KeyID :: KeyID,
+ sig3PKAlgorithm :: PublicKeyAlgorithm,
+ sig3HashAlgorithm :: HashAlgorithm,
+ sig3Data :: Either MPI (MPI, MPI)
+ }
+ packetTag Signature3 = Signature3PacketTag
+ packetTagNum Signature3PacketTag = 0x02
+ bodyParser Signature3 = do
_ <- A.word8 3
l <- bodyLenParser OneOctedLength
if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
else do
stype <- parseSignatureType
t <- parseTime
keyid <- parseKeyID
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
+
\end{code}
Algorithm-Specific Fields for RSA signatures:
- multiprecision integer (MPI) of RSA signature value m**d mod n.
Algorithm-Specific Fields for DSA signatures:
- MPI of DSA value r.
- MPI of DSA value s.
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
5.2.3.1. Signature Subpacket Specification
A subpacket data set consists of zero or more Signature subpackets.
In Signature packets, the subpacket data set is preceded by a two-
octet scalar count of the length in octets of all the subpackets. A
pointer incremented by this number will skip over the subpacket data
set.
Each subpacket consists of a subpacket header and a body. The header
consists of:
- the subpacket length (1, 2, or 5 octets),
- the subpacket type (1 octet),
and is followed by the subpacket-specific data.
The length includes the type octet but not this length. Its format
is similar to the "new" format packet header lengths, but cannot have
Partial Body Lengths. That is:
if the 1st octet < 192, then
lengthOfLength = 1
subpacketLen = 1st_octet
if the 1st octet >= 192 and < 255, then
lengthOfLength = 2
subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
if the 1st octet = 255, then
lengthOfLength = 5
subpacket length = [four-octet scalar starting at 2nd_octet]
The value of the subpacket type octet may be:
0 = Reserved
1 = Reserved
2 = Signature Creation Time
3 = Signature Expiration Time
4 = Exportable Certification
5 = Trust Signature
6 = Regular Expression
7 = Revocable
8 = Reserved
9 = Key Expiration Time
10 = Placeholder for backward compatibility
11 = Preferred Symmetric Algorithms
12 = Revocation Key
13 = Reserved
14 = Reserved
15 = Reserved
16 = Issuer
17 = Reserved
18 = Reserved
19 = Reserved
20 = Notation Data
21 = Preferred Hash Algorithms
22 = Preferred Compression Algorithms
23 = Key Server Preferences
24 = Preferred Key Server
25 = Primary User ID
26 = Policy URI
27 = Key Flags
28 = Signer's User ID
29 = Reason for Revocation
30 = Features
31 = Signature Target
32 = Embedded Signature
100 To 110 = Private or experimental
An implementation SHOULD ignore any subpacket of a type that it does
not recognize.
Bit 7 of the subpacket type is the "critical" bit. If set, it
denotes that the subpacket is one that is critical for the evaluator
of the signature to recognize. If a subpacket is encountered that is
marked critical but is unknown to the evaluating software, the
evaluator SHOULD consider the signature to be in error.
An evaluator may "recognize" a subpacket, but not implement it. The
purpose of the critical bit is to allow the signer to tell an
evaluator that it would prefer a new, unknown feature to generate an
error than be ignored.
Implementations SHOULD implement the three preferred algorithm
subpackets (11, 21, and 22), as well as the "Reason for Revocation"
subpacket. Note, however, that if an implementation chooses not to
implement some of the preferences, it is required to behave in a
polite manner to respect the wishes of those users who do implement
these preferences.
5.2.3.2. Signature Subpacket Types
A number of subpackets are currently defined. Some subpackets apply
to the signature itself and some are attributes of the key.
Subpackets that are found on a self-signature are placed on a
certification made by the key itself. Note that a key may have more
than one User ID, and thus may have more than one self-signature, and
differing subpackets.
A subpacket may be found either in the hashed or unhashed subpacket
sections of a signature. If a subpacket is not hashed, then the
information in it cannot be considered definitive because it is not
part of the signature proper.
5.2.3.3. Notes on Self-Signatures
A self-signature is a binding signature made by the key to which the
signature refers. There are three types of self-signatures, the
certification signatures (types 0x10-0x13), the direct-key signature
(type 0x1F), and the subkey binding signature (type 0x18). For
certification self-signatures, each User ID may have a self-
signature, and thus different subpackets in those self-signatures.
For subkey binding signatures, each subkey in fact has a self-
signature. Subpackets that appear in a certification self-signature
apply to the user name, and subpackets that appear in the subkey
self-signature apply to the subkey. Lastly, subpackets on the
direct-key signature apply to the entire key.
Implementing software should interpret a self-signature's preference
subpackets as narrowly as possible. For example, suppose a key has
two user names, Alice and Bob. Suppose that Alice prefers the
symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the
software locates this key via Alice's name, then the preferred
algorithm is CAST5; if software locates the key via Bob's name, then
the preferred algorithm is IDEA. If the key is located by Key ID,
the algorithm of the primary User ID of the key provides the
preferred symmetric algorithm.
Revoking a self-signature or allowing it to expire has a semantic
meaning that varies with the signature type. Revoking the self-
signature on a User ID effectively retires that user name. The
self-signature is a statement, "My name X is tied to my signing key
K" and is corroborated by other users' certifications. If another
user revokes their certification, they are effectively saying that
they no longer believe that name and that key are tied together.
Similarly, if the users themselves revoke their self-signature, then
the users no longer go by that name, no longer have that email
address, etc. Revoking a binding signature effectively retires that
subkey. Revoking a direct-key signature cancels that signature.
Please see the "Reason for Revocation" subpacket (Section 5.2.3.23)
for more relevant detail.
Since a self-signature contains important information about the key's
use, an implementation SHOULD allow the user to rewrite the self-
signature, and important information in it, such as preferences and
key expiration.
It is good practice to verify that a self-signature imported into an
implementation doesn't advertise features that the implementation
doesn't support, rewriting the signature as appropriate.
An implementation that encounters multiple self-signatures on the
same object may resolve the ambiguity in any way it sees fit, but it
is RECOMMENDED that priority be given to the most recent self-
signature.
5.2.3.4. Signature Creation Time
(4-octet time field)
The time the signature was made.
MUST be present in the hashed area.
5.2.3.5. Issuer
(8-octet Key ID)
The OpenPGP Key ID of the key issuing the signature.
5.2.3.6. Key Expiration Time
(4-octet time field)
The validity period of the key. This is the number of seconds after
the key creation time that the key expires. If this is not present
or has a value of zero, the key never expires. This is found only on
a self-signature.
5.2.3.7. Preferred Symmetric Algorithms
(array of one-octet values)
Symmetric algorithm numbers that indicate which algorithms the key
holder prefers to use. The subpacket body is an ordered list of
octets with the most preferred listed first. It is assumed that only
algorithms listed are supported by the recipient's software.
Algorithm numbers are in Section 9. This is only found on a self-
signature.
5.2.3.8. Preferred Hash Algorithms
(array of one-octet values)
Message digest algorithm numbers that indicate which algorithms the
key holder prefers to receive. Like the preferred symmetric
algorithms, the list is ordered. Algorithm numbers are in Section 9.
This is only found on a self-signature.
5.2.3.9. Preferred Compression Algorithms
(array of one-octet values)
Compression algorithm numbers that indicate which algorithms the key
holder prefers to use. Like the preferred symmetric algorithms, the
list is ordered. Algorithm numbers are in Section 9. If this
subpacket is not included, ZIP is preferred. A zero denotes that
uncompressed data is preferred; the key holder's software might have
no compression software in that implementation. This is only found
on a self-signature.
5.2.3.10. Signature Expiration Time
(4-octet time field)
The validity period of the signature. This is the number of seconds
after the signature creation time that the signature expires. If
this is not present or has a value of zero, it never expires.
5.2.3.11. Exportable Certification
(1 octet of exportability, 0 for not, 1 for exportable)
This subpacket denotes whether a certification signature is
"exportable", to be used by other users than the signature's issuer.
The packet body contains a Boolean flag indicating whether the
signature is exportable. If this packet is not present, the
certification is exportable; it is equivalent to a flag containing a
1.
Non-exportable, or "local", certifications are signatures made by a
user to mark a key as valid within that user's implementation only.
Thus, when an implementation prepares a user's copy of a key for
transport to another user (this is the process of "exporting" the
key), any local certification signatures are deleted from the key.
The receiver of a transported key "imports" it, and likewise trims
any local certifications. In normal operation, there won't be any,
assuming the import is performed on an exported key. However, there
are instances where this can reasonably happen. For example, if an
implementation allows keys to be imported from a key database in
addition to an exported key, then this situation can arise.
Some implementations do not represent the interest of a single user
(for example, a key server). Such implementations always trim local
certifications from any key they handle.
5.2.3.12. Revocable
(1 octet of revocability, 0 for not, 1 for revocable)
Signature's revocability status. The packet body contains a Boolean
flag indicating whether the signature is revocable. Signatures that
are not revocable have any later revocation signatures ignored. They
represent a commitment by the signer that he cannot revoke his
signature for the life of his key. If this packet is not present,
the signature is revocable.
5.2.3.13. Trust Signature
(1 octet "level" (depth), 1 octet of trust amount)
Signer asserts that the key is not only valid but also trustworthy at
the specified level. Level 0 has the same meaning as an ordinary
validity signature. Level 1 means that the signed key is asserted to
be a valid trusted introducer, with the 2nd octet of the body
specifying the degree of trust. Level 2 means that the signed key is
asserted to be trusted to issue level 1 trust signatures, i.e., that
it is a "meta introducer". Generally, a level n trust signature
asserts that a key is trusted to issue level n-1 trust signatures.
The trust amount is in a range from 0-255, interpreted such that
values less than 120 indicate partial trust and values of 120 or
greater indicate complete trust. Implementations SHOULD emit values
of 60 for partial trust and 120 for complete trust.
5.2.3.14. Regular Expression
(null-terminated regular expression)
Used in conjunction with trust Signature packets (of level > 0) to
limit the scope of trust that is extended. Only signatures by the
target key on User IDs that match the regular expression in the body
of this packet have trust extended by the trust Signature subpacket.
The regular expression uses the same syntax as the Henry Spencer's
"almost public domain" regular expression [REGEX] package. A
description of the syntax is found in Section 8 below.
5.2.3.15. Revocation Key
(1 octet of class, 1 octet of public-key algorithm ID, 20 octets of
fingerprint)
Authorizes the specified key to issue revocation signatures for this
key. Class octet must have bit 0x80 set. If the bit 0x40 is set,
then this means that the revocation information is sensitive. Other
bits are for future expansion to other kinds of authorizations. This
is found on a self-signature.
If the "sensitive" flag is set, the keyholder feels this subpacket
contains private trust information that describes a real-world
sensitive relationship. If this flag is set, implementations SHOULD
NOT export this signature to other users except in cases where the
data needs to be available: when the signature is being sent to the
designated revoker, or when it is accompanied by a revocation
signature from that revoker. Note that it may be appropriate to
isolate this subpacket within a separate signature so that it is not
combined with other subpackets that need to be exported.
5.2.3.16. Notation Data
(4 octets of flags, 2 octets of name length (M),
2 octets of value length (N),
M octets of name data,
N octets of value data)
This subpacket describes a "notation" on the signature that the
issuer wishes to make. The notation has a name and a value, each of
which are strings of octets. There may be more than one notation in
a signature. Notations can be used for any extension the issuer of
the signature cares to make. The "flags" field holds four octets of
flags.
All undefined flags MUST be zero. Defined flags are as follows:
First octet: 0x80 = human-readable. This note value is text.
Other octets: none.
Notation names are arbitrary strings encoded in UTF-8. They reside
in two namespaces: The IETF namespace and the user namespace.
The IETF namespace is registered with IANA. These names MUST NOT
contain the "@" character (0x40). This is a tag for the user
namespace.
Names in the user namespace consist of a UTF-8 string tag followed by
"@" followed by a DNS domain name. Note that the tag MUST NOT
contain an "@" character. For example, the "sample" tag used by
Example Corporation could be "[email protected]".
Names in a user space are owned and controlled by the owners of that
domain. Obviously, it's bad form to create a new name in a DNS space
that you don't own.
Since the user namespace is in the form of an email address,
implementers MAY wish to arrange for that address to reach a person
who can be consulted about the use of the named tag. Note that due
to UTF-8 encoding, not all valid user space name tags are valid email
addresses.
If there is a critical notation, the criticality applies to that
specific notation and not to notations in general.
|
alios/lab
|
7809a9d1a8bd5ce673620a3114e42e140069dfb5
|
addded parsePacket function
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index 4010ecd..f19a327 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -150,1322 +150,1327 @@ parseTime = do
1 Salted S2K
2 Reserved value
3 Iterated and Salted S2K
100 to 110 Private/Experimental S2K
These are described in Sections 3.7.1.1 - 3.7.1.3.
\begin{code}
data StringToKeySpecifier =
SimpleS2K Word8|
SaltedS2K Word8 Word64 |
IteratedAndSaltedS2K Word8 Word64 Word8
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
parseHashAlgo = A.anyWord8 <?> "hash algorithm" -- TODO: Parse hash Algo correctly
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
hashAlgo <- parseHashAlgo
return $ SimpleS2K hashAlgo
\end{code}
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
\end{code}
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
\begin{code}
data PacketHeaderT =
OldPacketHeader PacketTag PacketLength |
NewPacketHeader PacketTag
class PacketHeader h where
packetHeaderTag :: h -> PacketTag
instance PacketHeader PacketHeaderT where
packetHeaderTag (OldPacketHeader t _) = t
packetHeaderTag (NewPacketHeader t) = t
parsePacketHeader :: Parser PacketHeaderT
parsePacketHeader = do
w <- A.try A.anyWord8
let valid = w `testBit` 7
if (not valid) then fail "is not a valid packet header"
else do
let newPacket = w `testBit` 6
let maskedPacket = w .&. 0x3f
if (newPacket) then do
case (lookupPacketTag maskedPacket) of
Nothing -> fail "unknown new packet header tag"
Just t -> return $ NewPacketHeader t
else do
let tag = lookupPacketTag $ maskedPacket `shiftR` 2
let len = maskedPacket .&. 0x03
case (lookupPacketLength len) of
Nothing -> fail "unknown old packet header length field"
Just l -> case (tag) of
Nothing -> fail "unknown old packet header tag"
Just t -> if (not $ isValidOldTag t) then fail "unknown old packet header tag"
else return $ OldPacketHeader t l
headerIteratee :: Monad m => Iteratee ByteString m PacketHeaderT
headerIteratee = iterParser parsePacketHeader
\end{code}
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
\begin{code}
data PacketTag =
PublicKeyEncryptedSessionKeyPacket |
SignaturePacket |
SymmetricKeyEncryptedSessionKeyPacket |
OnePassSignaturePacket |
SecretKeyPacket |
PublicKeyPacket |
SecretSubkeyPacket |
CompressedDataPacket |
SymmetricallyEncryptedPacket |
MarkerPacket |
LiteralDataPacket |
TrustPacket |
UserIDPacket |
PublicSubkeyPacket |
UserAttributePacket |
SymEncryptedAndIntegrityProtectedDataPacket |
ModificationDetectionCodePacket
deriving (Show, Read, Eq)
packetTagCoding = [
(PublicKeyEncryptedSessionKeyPacket, 1),
(SignaturePacket, 2),
(SymmetricKeyEncryptedSessionKeyPacket, 3),
(OnePassSignaturePacket, 4),
(SecretKeyPacket, 5),
(PublicKeyPacket, 6),
(SecretSubkeyPacket, 7),
(CompressedDataPacket, 8),
(SymmetricallyEncryptedPacket, 9),
(MarkerPacket, 10),
(LiteralDataPacket, 11),
(TrustPacket, 12),
(UserIDPacket, 13),
(PublicSubkeyPacket, 14),
(UserAttributePacket, 17),
(SymEncryptedAndIntegrityProtectedDataPacket, 18),
(ModificationDetectionCodePacket, 19)
]
isValidOldTag :: PacketTag -> Bool
isValidOldTag t = case (packetTagToNum t) of
Nothing -> False
Just t' -> t' < 16
isValidOldTagNum :: Word8 -> Bool
isValidOldTagNum i = case (lookupPacketTag i) of
Nothing -> False
Just _ -> (i > 0) && (i < 16)
packetTagToNum :: PacketTag -> Maybe Word8
packetTagToNum t = lookup t packetTagCoding
lookupPacketTag :: Word8 -> Maybe PacketTag
lookupPacketTag i = lookup i $ map swap packetTagCoding
\end{code}
5. Packet Types
\begin{code}
data Packet =
MkPEKSKP {
pekskpKeyID :: Maybe KeyID,
pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
pekskpData :: Either MPI (MPI, MPI)
} |
MkSignaturePacket3 {
sig3Type :: SignatureType,
sig3Time :: UTCTime,
sig3KeyID :: KeyID,
sig3PKAlgorithm :: PublicKeyAlgorithm,
sig3HashAlgorithm :: HashAlgorithm,
sig3Data :: Either MPI (MPI, MPI)
}
-
+parsePacket = do
+ tag <- fmap packetHeaderTag parsePacketHeader
+ case tag of
+ PublicKeyEncryptedSessionKeyPacket -> parsePEKSKPBody
+ SignaturePacket -> parseSignaturePBody3
+
\end{code}
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
\begin{code}
parsePEKSKPBody :: Parser Packet
parsePEKSKPBody = do
_ <- A.word8 3
keyid' <- parseKeyID
let keyid = if (keyid' == 0) then Nothing else Just keyid'
algo <- parsePublicKeyAlgorithm
encKey <- case (algo) of
RSAEncryptOrSign -> parseRSAEncryptedSessionKey
RSAEncryptOnly -> parseRSAEncryptedSessionKey
ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
return $ MkPEKSKP keyid algo encKey
where parseRSAEncryptedSessionKey = fmap Left parseMPI
parseElgamalEncryptedSessionKey = do
a <- parseMPI
b <- parseMPI
return $ Right (a, b)
\end{code}
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
\begin{code}
data SignatureType =
SignatureBinaryDoc |
SignatureCanonicalTextDoc |
StandaloneSignature |
GenericCertificationOfAUserIDAndPublicKeyPacket |
PersonaCertificationOfAUserIDAndPublicKeyPacket |
CasualCertificationOfAUserIDAndPublicKeyPacket |
PositiveCertificationOfAUserIDAndPublicKeyPacket |
SubkeyBindingSignature |
PrimaryKeyBindingSignature |
SignatureDirectlyOnAKey |
KeyRevocationSignature |
SubkeyRevocationSignature |
CertificationRevocationSignature |
TimestampSignature |
ThirdPartyConfirmationSignature
deriving (Show, Read, Eq, Enum)
signatureTypeCoding = [
(SignatureBinaryDoc , 0x00),
(SignatureCanonicalTextDoc , 0x01),
(StandaloneSignature , 0x02),
(GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
(PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
(CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
(PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
(SubkeyBindingSignature , 0x18),
(PrimaryKeyBindingSignature , 0x19),
(SignatureDirectlyOnAKey , 0x1F),
(KeyRevocationSignature , 0x20),
(SubkeyRevocationSignature , 0x28),
(CertificationRevocationSignature , 0x30),
(TimestampSignature , 0x40),
(ThirdPartyConfirmationSignature , 0x50)
]
lookupSignatureType :: Word8 -> Maybe SignatureType
lookupSignatureType i = lookup i $ map swap signatureTypeCoding
signatureTypeToNum :: SignatureType -> Maybe Word8
signatureTypeToNum p = lookup p signatureTypeCoding
parseSignatureType :: Parser SignatureType
parseSignatureType = do
w <- A.anyWord8
case (lookupSignatureType w) of
Nothing -> fail "unknown signature type"
Just a -> return a
\end{code}
5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
\begin{code}
-parseSignaturePacket3 :: Parser Packet
-parseSignaturePacket3 = do
+parseSignaturePBody3 :: Parser Packet
+parseSignaturePBody3 = do
_ <- A.word8 3
l <- bodyLenParser OneOctedLength
if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
else do
stype <- parseSignatureType
t <- parseTime
keyid <- parseKeyID
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
\end{code}
Algorithm-Specific Fields for RSA signatures:
- multiprecision integer (MPI) of RSA signature value m**d mod n.
Algorithm-Specific Fields for DSA signatures:
- MPI of DSA value r.
- MPI of DSA value s.
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
5.2.3.1. Signature Subpacket Specification
A subpacket data set consists of zero or more Signature subpackets.
In Signature packets, the subpacket data set is preceded by a two-
octet scalar count of the length in octets of all the subpackets. A
pointer incremented by this number will skip over the subpacket data
set.
Each subpacket consists of a subpacket header and a body. The header
consists of:
- the subpacket length (1, 2, or 5 octets),
- the subpacket type (1 octet),
and is followed by the subpacket-specific data.
The length includes the type octet but not this length. Its format
is similar to the "new" format packet header lengths, but cannot have
Partial Body Lengths. That is:
if the 1st octet < 192, then
lengthOfLength = 1
subpacketLen = 1st_octet
if the 1st octet >= 192 and < 255, then
lengthOfLength = 2
subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
if the 1st octet = 255, then
lengthOfLength = 5
subpacket length = [four-octet scalar starting at 2nd_octet]
The value of the subpacket type octet may be:
0 = Reserved
1 = Reserved
2 = Signature Creation Time
3 = Signature Expiration Time
4 = Exportable Certification
5 = Trust Signature
6 = Regular Expression
7 = Revocable
8 = Reserved
9 = Key Expiration Time
10 = Placeholder for backward compatibility
11 = Preferred Symmetric Algorithms
12 = Revocation Key
13 = Reserved
14 = Reserved
15 = Reserved
16 = Issuer
17 = Reserved
18 = Reserved
19 = Reserved
20 = Notation Data
21 = Preferred Hash Algorithms
22 = Preferred Compression Algorithms
23 = Key Server Preferences
24 = Preferred Key Server
25 = Primary User ID
26 = Policy URI
27 = Key Flags
28 = Signer's User ID
29 = Reason for Revocation
30 = Features
31 = Signature Target
32 = Embedded Signature
100 To 110 = Private or experimental
An implementation SHOULD ignore any subpacket of a type that it does
not recognize.
Bit 7 of the subpacket type is the "critical" bit. If set, it
denotes that the subpacket is one that is critical for the evaluator
of the signature to recognize. If a subpacket is encountered that is
marked critical but is unknown to the evaluating software, the
evaluator SHOULD consider the signature to be in error.
An evaluator may "recognize" a subpacket, but not implement it. The
purpose of the critical bit is to allow the signer to tell an
evaluator that it would prefer a new, unknown feature to generate an
error than be ignored.
Implementations SHOULD implement the three preferred algorithm
subpackets (11, 21, and 22), as well as the "Reason for Revocation"
subpacket. Note, however, that if an implementation chooses not to
implement some of the preferences, it is required to behave in a
polite manner to respect the wishes of those users who do implement
these preferences.
5.2.3.2. Signature Subpacket Types
A number of subpackets are currently defined. Some subpackets apply
to the signature itself and some are attributes of the key.
Subpackets that are found on a self-signature are placed on a
certification made by the key itself. Note that a key may have more
than one User ID, and thus may have more than one self-signature, and
differing subpackets.
A subpacket may be found either in the hashed or unhashed subpacket
sections of a signature. If a subpacket is not hashed, then the
information in it cannot be considered definitive because it is not
part of the signature proper.
5.2.3.3. Notes on Self-Signatures
A self-signature is a binding signature made by the key to which the
signature refers. There are three types of self-signatures, the
certification signatures (types 0x10-0x13), the direct-key signature
(type 0x1F), and the subkey binding signature (type 0x18). For
certification self-signatures, each User ID may have a self-
signature, and thus different subpackets in those self-signatures.
For subkey binding signatures, each subkey in fact has a self-
signature. Subpackets that appear in a certification self-signature
apply to the user name, and subpackets that appear in the subkey
self-signature apply to the subkey. Lastly, subpackets on the
direct-key signature apply to the entire key.
Implementing software should interpret a self-signature's preference
subpackets as narrowly as possible. For example, suppose a key has
two user names, Alice and Bob. Suppose that Alice prefers the
symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the
software locates this key via Alice's name, then the preferred
algorithm is CAST5; if software locates the key via Bob's name, then
the preferred algorithm is IDEA. If the key is located by Key ID,
the algorithm of the primary User ID of the key provides the
preferred symmetric algorithm.
Revoking a self-signature or allowing it to expire has a semantic
meaning that varies with the signature type. Revoking the self-
signature on a User ID effectively retires that user name. The
self-signature is a statement, "My name X is tied to my signing key
K" and is corroborated by other users' certifications. If another
user revokes their certification, they are effectively saying that
they no longer believe that name and that key are tied together.
Similarly, if the users themselves revoke their self-signature, then
the users no longer go by that name, no longer have that email
address, etc. Revoking a binding signature effectively retires that
subkey. Revoking a direct-key signature cancels that signature.
Please see the "Reason for Revocation" subpacket (Section 5.2.3.23)
for more relevant detail.
Since a self-signature contains important information about the key's
use, an implementation SHOULD allow the user to rewrite the self-
signature, and important information in it, such as preferences and
key expiration.
It is good practice to verify that a self-signature imported into an
implementation doesn't advertise features that the implementation
doesn't support, rewriting the signature as appropriate.
An implementation that encounters multiple self-signatures on the
same object may resolve the ambiguity in any way it sees fit, but it
is RECOMMENDED that priority be given to the most recent self-
signature.
5.2.3.4. Signature Creation Time
(4-octet time field)
The time the signature was made.
MUST be present in the hashed area.
5.2.3.5. Issuer
(8-octet Key ID)
The OpenPGP Key ID of the key issuing the signature.
5.2.3.6. Key Expiration Time
(4-octet time field)
The validity period of the key. This is the number of seconds after
the key creation time that the key expires. If this is not present
or has a value of zero, the key never expires. This is found only on
a self-signature.
5.2.3.7. Preferred Symmetric Algorithms
(array of one-octet values)
Symmetric algorithm numbers that indicate which algorithms the key
holder prefers to use. The subpacket body is an ordered list of
octets with the most preferred listed first. It is assumed that only
algorithms listed are supported by the recipient's software.
Algorithm numbers are in Section 9. This is only found on a self-
signature.
5.2.3.8. Preferred Hash Algorithms
(array of one-octet values)
Message digest algorithm numbers that indicate which algorithms the
key holder prefers to receive. Like the preferred symmetric
algorithms, the list is ordered. Algorithm numbers are in Section 9.
This is only found on a self-signature.
5.2.3.9. Preferred Compression Algorithms
(array of one-octet values)
Compression algorithm numbers that indicate which algorithms the key
holder prefers to use. Like the preferred symmetric algorithms, the
list is ordered. Algorithm numbers are in Section 9. If this
subpacket is not included, ZIP is preferred. A zero denotes that
uncompressed data is preferred; the key holder's software might have
no compression software in that implementation. This is only found
on a self-signature.
5.2.3.10. Signature Expiration Time
(4-octet time field)
The validity period of the signature. This is the number of seconds
after the signature creation time that the signature expires. If
this is not present or has a value of zero, it never expires.
5.2.3.11. Exportable Certification
(1 octet of exportability, 0 for not, 1 for exportable)
This subpacket denotes whether a certification signature is
"exportable", to be used by other users than the signature's issuer.
The packet body contains a Boolean flag indicating whether the
signature is exportable. If this packet is not present, the
certification is exportable; it is equivalent to a flag containing a
1.
Non-exportable, or "local", certifications are signatures made by a
user to mark a key as valid within that user's implementation only.
Thus, when an implementation prepares a user's copy of a key for
transport to another user (this is the process of "exporting" the
key), any local certification signatures are deleted from the key.
The receiver of a transported key "imports" it, and likewise trims
any local certifications. In normal operation, there won't be any,
assuming the import is performed on an exported key. However, there
are instances where this can reasonably happen. For example, if an
implementation allows keys to be imported from a key database in
addition to an exported key, then this situation can arise.
Some implementations do not represent the interest of a single user
(for example, a key server). Such implementations always trim local
certifications from any key they handle.
5.2.3.12. Revocable
(1 octet of revocability, 0 for not, 1 for revocable)
Signature's revocability status. The packet body contains a Boolean
flag indicating whether the signature is revocable. Signatures that
are not revocable have any later revocation signatures ignored. They
represent a commitment by the signer that he cannot revoke his
signature for the life of his key. If this packet is not present,
the signature is revocable.
5.2.3.13. Trust Signature
(1 octet "level" (depth), 1 octet of trust amount)
Signer asserts that the key is not only valid but also trustworthy at
the specified level. Level 0 has the same meaning as an ordinary
validity signature. Level 1 means that the signed key is asserted to
be a valid trusted introducer, with the 2nd octet of the body
specifying the degree of trust. Level 2 means that the signed key is
asserted to be trusted to issue level 1 trust signatures, i.e., that
it is a "meta introducer". Generally, a level n trust signature
asserts that a key is trusted to issue level n-1 trust signatures.
The trust amount is in a range from 0-255, interpreted such that
values less than 120 indicate partial trust and values of 120 or
greater indicate complete trust. Implementations SHOULD emit values
of 60 for partial trust and 120 for complete trust.
5.2.3.14. Regular Expression
(null-terminated regular expression)
Used in conjunction with trust Signature packets (of level > 0) to
limit the scope of trust that is extended. Only signatures by the
target key on User IDs that match the regular expression in the body
of this packet have trust extended by the trust Signature subpacket.
The regular expression uses the same syntax as the Henry Spencer's
"almost public domain" regular expression [REGEX] package. A
description of the syntax is found in Section 8 below.
5.2.3.15. Revocation Key
(1 octet of class, 1 octet of public-key algorithm ID, 20 octets of
fingerprint)
Authorizes the specified key to issue revocation signatures for this
key. Class octet must have bit 0x80 set. If the bit 0x40 is set,
then this means that the revocation information is sensitive. Other
bits are for future expansion to other kinds of authorizations. This
is found on a self-signature.
If the "sensitive" flag is set, the keyholder feels this subpacket
contains private trust information that describes a real-world
sensitive relationship. If this flag is set, implementations SHOULD
NOT export this signature to other users except in cases where the
data needs to be available: when the signature is being sent to the
designated revoker, or when it is accompanied by a revocation
signature from that revoker. Note that it may be appropriate to
isolate this subpacket within a separate signature so that it is not
combined with other subpackets that need to be exported.
5.2.3.16. Notation Data
(4 octets of flags, 2 octets of name length (M),
2 octets of value length (N),
M octets of name data,
N octets of value data)
This subpacket describes a "notation" on the signature that the
issuer wishes to make. The notation has a name and a value, each of
which are strings of octets. There may be more than one notation in
a signature. Notations can be used for any extension the issuer of
the signature cares to make. The "flags" field holds four octets of
flags.
|
alios/lab
|
4457fd2f90443d9288cf59f2094d59638c1f00a2
|
introduced Packet data type
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index fb87e87..4010ecd 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -1,1468 +1,1491 @@
\begin{code}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
import Data.Enumerator (Iteratee)
import Data.Attoparsec (Parser, (<?>))
import Data.Attoparsec.Enumerator
import qualified Data.Attoparsec as A
import Data.Convertible
import qualified Data.ByteString.Base64 as Base64
import Data.Time (UTCTime)
import Data.Bits
import Data.Word
import Data.Tuple (swap)
import Data.Binary (decode)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy as B
import Data.ByteString (ByteString)
import System.Time
decodeStrictBS bs = (decode . B.fromChunks) [bs]
anyWord16 :: Parser Word16
anyWord16 = fmap decodeStrictBS (A.take 2 <?> "word16")
anyWord32 :: Parser Word32
anyWord32 = fmap decodeStrictBS (A.take 4 <?> "word32")
anyWord64 :: Parser Word64
anyWord64 = fmap decodeStrictBS (A.take 8 <?> "word64")
\end{code}
3. Data Element Formats
This section describes the data elements used by OpenPGP.
3.1. Scalar Numbers
Scalar numbers are unsigned and are always stored in big-endian
format. Using n[k] to refer to the kth octet being interpreted, the
value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a
four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
n[3]).
3.2. Multiprecision Integers
Multiprecision integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used in cryptographic
calculations.
An MPI consists of two pieces: a two-octet scalar that is the length
of the MPI in bits followed by a string of octets that contain the
actual integer.
These octets form a big-endian number; a big-endian number can be
made into an MPI by prefixing it with the appropriate length.
Examples:
(all numbers are in hexadecimal)
The string of octets [00 01 01] forms an MPI with the value 1. The
string [00 09 01 FF] forms an MPI with the value of 511.
Additional rules:
The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
The length field of an MPI describes the length starting from its
most significant non-zero bit. Thus, the MPI [00 02 01] is not
formed correctly. It should be [00 01 01].
Unused bits of an MPI MUST be zero.
Also note that when an MPI is encrypted, the length refers to the
plaintext MPI. It may be ill-formed in its ciphertext.
\begin{code}
newtype MPI = MPI ByteString
parseMPI :: Parser MPI
parseMPI = do
ls <- fmap convert anyWord16
bs <- (A.take ls <?> "MPI")
return $ MPI bs
\end{code}
3.3. Key IDs
A Key ID is an eight-octet scalar that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique. The
section "Enhanced Key Formats" below describes how Key IDs are
formed.
\begin{code}
type KeyID = Word64
parseKeyID :: Parser KeyID
parseKeyID = fmap decodeStrictBS (A.take 8 <?> "KeyID")
\end{code}
3.4. Text
Unless otherwise specified, the character set for text is the UTF-8
[RFC3629] encoding of Unicode [ISO10646].
3.5. Time Fields
A time field is an unsigned four-octet number containing the number
of seconds elapsed since midnight, 1 January 1970 UTC.
\begin{code}
parseTime :: Parser UTCTime
parseTime = do
ts <- anyWord32 <?> "TimeField"
return $ convert $ TOD (convert ts) 0
\end{code}
3.6. Keyrings
A keyring is a collection of one or more keys in a file or database.
Traditionally, a keyring is simply a sequential list of keys, but may
be any suitable database. It is beyond the scope of this standard to
discuss the details of keyrings or other databases.
3.7. String-to-Key (S2K) Specifiers
String-to-key (S2K) specifiers are used to convert passphrase strings
into symmetric-key encryption/decryption keys. They are used in two
places, currently: to encrypt the secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
symmetrically encrypted messages.
3.7.1. String-to-Key (S2K) Specifier Types
There are three types of S2K specifiers currently supported, and
some reserved values:
ID S2K Type
-- --------
0 Simple S2K
1 Salted S2K
2 Reserved value
3 Iterated and Salted S2K
100 to 110 Private/Experimental S2K
These are described in Sections 3.7.1.1 - 3.7.1.3.
\begin{code}
data StringToKeySpecifier =
SimpleS2K Word8|
SaltedS2K Word8 Word64 |
IteratedAndSaltedS2K Word8 Word64 Word8
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
parseHashAlgo = A.anyWord8 <?> "hash algorithm" -- TODO: Parse hash Algo correctly
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
hashAlgo <- parseHashAlgo
return $ SimpleS2K hashAlgo
\end{code}
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
\end{code}
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
\begin{code}
data PacketHeaderT =
OldPacketHeader PacketTag PacketLength |
NewPacketHeader PacketTag
class PacketHeader h where
packetHeaderTag :: h -> PacketTag
instance PacketHeader PacketHeaderT where
packetHeaderTag (OldPacketHeader t _) = t
packetHeaderTag (NewPacketHeader t) = t
parsePacketHeader :: Parser PacketHeaderT
parsePacketHeader = do
w <- A.try A.anyWord8
let valid = w `testBit` 7
if (not valid) then fail "is not a valid packet header"
else do
let newPacket = w `testBit` 6
let maskedPacket = w .&. 0x3f
if (newPacket) then do
case (lookupPacketTag maskedPacket) of
Nothing -> fail "unknown new packet header tag"
Just t -> return $ NewPacketHeader t
else do
let tag = lookupPacketTag $ maskedPacket `shiftR` 2
let len = maskedPacket .&. 0x03
case (lookupPacketLength len) of
Nothing -> fail "unknown old packet header length field"
Just l -> case (tag) of
Nothing -> fail "unknown old packet header tag"
Just t -> if (not $ isValidOldTag t) then fail "unknown old packet header tag"
else return $ OldPacketHeader t l
headerIteratee :: Monad m => Iteratee ByteString m PacketHeaderT
headerIteratee = iterParser parsePacketHeader
\end{code}
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
a' :: Word32
a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
\begin{code}
data PacketTag =
PublicKeyEncryptedSessionKeyPacket |
SignaturePacket |
SymmetricKeyEncryptedSessionKeyPacket |
OnePassSignaturePacket |
SecretKeyPacket |
PublicKeyPacket |
SecretSubkeyPacket |
CompressedDataPacket |
SymmetricallyEncryptedPacket |
MarkerPacket |
LiteralDataPacket |
TrustPacket |
UserIDPacket |
PublicSubkeyPacket |
UserAttributePacket |
SymEncryptedAndIntegrityProtectedDataPacket |
ModificationDetectionCodePacket
deriving (Show, Read, Eq)
packetTagCoding = [
(PublicKeyEncryptedSessionKeyPacket, 1),
(SignaturePacket, 2),
(SymmetricKeyEncryptedSessionKeyPacket, 3),
(OnePassSignaturePacket, 4),
(SecretKeyPacket, 5),
(PublicKeyPacket, 6),
(SecretSubkeyPacket, 7),
(CompressedDataPacket, 8),
(SymmetricallyEncryptedPacket, 9),
(MarkerPacket, 10),
(LiteralDataPacket, 11),
(TrustPacket, 12),
(UserIDPacket, 13),
(PublicSubkeyPacket, 14),
(UserAttributePacket, 17),
(SymEncryptedAndIntegrityProtectedDataPacket, 18),
(ModificationDetectionCodePacket, 19)
]
isValidOldTag :: PacketTag -> Bool
isValidOldTag t = case (packetTagToNum t) of
Nothing -> False
Just t' -> t' < 16
isValidOldTagNum :: Word8 -> Bool
isValidOldTagNum i = case (lookupPacketTag i) of
Nothing -> False
Just _ -> (i > 0) && (i < 16)
packetTagToNum :: PacketTag -> Maybe Word8
packetTagToNum t = lookup t packetTagCoding
lookupPacketTag :: Word8 -> Maybe PacketTag
lookupPacketTag i = lookup i $ map swap packetTagCoding
\end{code}
5. Packet Types
+\begin{code}
+data Packet =
+ MkPEKSKP {
+ pekskpKeyID :: Maybe KeyID,
+ pekskpPublicKeyAlgorithm :: PublicKeyAlgorithm,
+ pekskpData :: Either MPI (MPI, MPI)
+ } |
+ MkSignaturePacket3 {
+ sig3Type :: SignatureType,
+ sig3Time :: UTCTime,
+ sig3KeyID :: KeyID,
+ sig3PKAlgorithm :: PublicKeyAlgorithm,
+ sig3HashAlgorithm :: HashAlgorithm,
+ sig3Data :: Either MPI (MPI, MPI)
+ }
+
+
+\end{code}
+
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
\begin{code}
-parsePEKSKPBody :: Parser (Maybe KeyID, PublicKeyAlgorithm, Either MPI (MPI, MPI))
+
+parsePEKSKPBody :: Parser Packet
parsePEKSKPBody = do
_ <- A.word8 3
keyid' <- parseKeyID
let keyid = if (keyid' == 0) then Nothing else Just keyid'
algo <- parsePublicKeyAlgorithm
encKey <- case (algo) of
RSAEncryptOrSign -> parseRSAEncryptedSessionKey
RSAEncryptOnly -> parseRSAEncryptedSessionKey
ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
- return (keyid, algo, encKey)
+ return $ MkPEKSKP keyid algo encKey
where parseRSAEncryptedSessionKey = fmap Left parseMPI
parseElgamalEncryptedSessionKey = do
a <- parseMPI
b <- parseMPI
return $ Right (a, b)
\end{code}
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
\begin{code}
data SignatureType =
SignatureBinaryDoc |
SignatureCanonicalTextDoc |
StandaloneSignature |
GenericCertificationOfAUserIDAndPublicKeyPacket |
PersonaCertificationOfAUserIDAndPublicKeyPacket |
CasualCertificationOfAUserIDAndPublicKeyPacket |
PositiveCertificationOfAUserIDAndPublicKeyPacket |
SubkeyBindingSignature |
PrimaryKeyBindingSignature |
SignatureDirectlyOnAKey |
KeyRevocationSignature |
SubkeyRevocationSignature |
CertificationRevocationSignature |
TimestampSignature |
ThirdPartyConfirmationSignature
deriving (Show, Read, Eq, Enum)
signatureTypeCoding = [
(SignatureBinaryDoc , 0x00),
(SignatureCanonicalTextDoc , 0x01),
(StandaloneSignature , 0x02),
(GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
(PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
(CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
(PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
(SubkeyBindingSignature , 0x18),
(PrimaryKeyBindingSignature , 0x19),
(SignatureDirectlyOnAKey , 0x1F),
(KeyRevocationSignature , 0x20),
(SubkeyRevocationSignature , 0x28),
(CertificationRevocationSignature , 0x30),
(TimestampSignature , 0x40),
(ThirdPartyConfirmationSignature , 0x50)
]
lookupSignatureType :: Word8 -> Maybe SignatureType
lookupSignatureType i = lookup i $ map swap signatureTypeCoding
signatureTypeToNum :: SignatureType -> Maybe Word8
signatureTypeToNum p = lookup p signatureTypeCoding
parseSignatureType :: Parser SignatureType
parseSignatureType = do
w <- A.anyWord8
case (lookupSignatureType w) of
Nothing -> fail "unknown signature type"
Just a -> return a
\end{code}
5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
\begin{code}
+parseSignaturePacket3 :: Parser Packet
parseSignaturePacket3 = do
_ <- A.word8 3
l <- bodyLenParser OneOctedLength
if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
else do
stype <- parseSignatureType
t <- parseTime
keyid <- parseKeyID
pkAlgo <- parsePublicKeyAlgorithm
hasha <- parseHashAlgorithm
shv <- anyWord16
hashdata <- case (pkAlgo) of
RSAEncryptOrSign -> parseRSAMPI
RSASignOnly -> parseRSAMPI
DSA -> parseDSAMPI
let (MPI firstHash) = case (hashdata) of
Left h -> h
Right (h, _) -> h
if (not $ (convert firstHash) `checkFirstHash` shv)
then fail "signedHashValue check failed"
- else return (stype, t , keyid, pkAlgo, hasha, hashdata)
+ else return $ MkSignaturePacket3 stype t keyid pkAlgo hasha hashdata
where parseRSAMPI = fmap Left parseMPI
parseDSAMPI = do
r <- parseMPI
s <- parseMPI
return $ Right (r,s)
checkFirstHash bs v =
let a = convert (bs `B.index` 0)
b = convert (bs `B.index` 1)
v' :: Word16
v' = (a `shiftL` 8) .|. b
in v' == v
\end{code}
Algorithm-Specific Fields for RSA signatures:
- multiprecision integer (MPI) of RSA signature value m**d mod n.
Algorithm-Specific Fields for DSA signatures:
- MPI of DSA value r.
- MPI of DSA value s.
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
5.2.3.1. Signature Subpacket Specification
A subpacket data set consists of zero or more Signature subpackets.
In Signature packets, the subpacket data set is preceded by a two-
octet scalar count of the length in octets of all the subpackets. A
pointer incremented by this number will skip over the subpacket data
set.
Each subpacket consists of a subpacket header and a body. The header
consists of:
- the subpacket length (1, 2, or 5 octets),
- the subpacket type (1 octet),
and is followed by the subpacket-specific data.
The length includes the type octet but not this length. Its format
is similar to the "new" format packet header lengths, but cannot have
Partial Body Lengths. That is:
if the 1st octet < 192, then
lengthOfLength = 1
subpacketLen = 1st_octet
if the 1st octet >= 192 and < 255, then
lengthOfLength = 2
subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
if the 1st octet = 255, then
lengthOfLength = 5
subpacket length = [four-octet scalar starting at 2nd_octet]
The value of the subpacket type octet may be:
0 = Reserved
1 = Reserved
2 = Signature Creation Time
3 = Signature Expiration Time
4 = Exportable Certification
5 = Trust Signature
6 = Regular Expression
7 = Revocable
8 = Reserved
9 = Key Expiration Time
10 = Placeholder for backward compatibility
11 = Preferred Symmetric Algorithms
12 = Revocation Key
13 = Reserved
14 = Reserved
15 = Reserved
16 = Issuer
17 = Reserved
18 = Reserved
19 = Reserved
20 = Notation Data
21 = Preferred Hash Algorithms
22 = Preferred Compression Algorithms
23 = Key Server Preferences
24 = Preferred Key Server
25 = Primary User ID
26 = Policy URI
27 = Key Flags
28 = Signer's User ID
29 = Reason for Revocation
30 = Features
31 = Signature Target
32 = Embedded Signature
100 To 110 = Private or experimental
An implementation SHOULD ignore any subpacket of a type that it does
not recognize.
Bit 7 of the subpacket type is the "critical" bit. If set, it
denotes that the subpacket is one that is critical for the evaluator
of the signature to recognize. If a subpacket is encountered that is
marked critical but is unknown to the evaluating software, the
evaluator SHOULD consider the signature to be in error.
An evaluator may "recognize" a subpacket, but not implement it. The
purpose of the critical bit is to allow the signer to tell an
evaluator that it would prefer a new, unknown feature to generate an
error than be ignored.
Implementations SHOULD implement the three preferred algorithm
subpackets (11, 21, and 22), as well as the "Reason for Revocation"
subpacket. Note, however, that if an implementation chooses not to
implement some of the preferences, it is required to behave in a
polite manner to respect the wishes of those users who do implement
these preferences.
5.2.3.2. Signature Subpacket Types
A number of subpackets are currently defined. Some subpackets apply
to the signature itself and some are attributes of the key.
Subpackets that are found on a self-signature are placed on a
certification made by the key itself. Note that a key may have more
than one User ID, and thus may have more than one self-signature, and
differing subpackets.
A subpacket may be found either in the hashed or unhashed subpacket
sections of a signature. If a subpacket is not hashed, then the
information in it cannot be considered definitive because it is not
part of the signature proper.
5.2.3.3. Notes on Self-Signatures
A self-signature is a binding signature made by the key to which the
signature refers. There are three types of self-signatures, the
certification signatures (types 0x10-0x13), the direct-key signature
(type 0x1F), and the subkey binding signature (type 0x18). For
certification self-signatures, each User ID may have a self-
signature, and thus different subpackets in those self-signatures.
For subkey binding signatures, each subkey in fact has a self-
signature. Subpackets that appear in a certification self-signature
apply to the user name, and subpackets that appear in the subkey
self-signature apply to the subkey. Lastly, subpackets on the
direct-key signature apply to the entire key.
Implementing software should interpret a self-signature's preference
subpackets as narrowly as possible. For example, suppose a key has
two user names, Alice and Bob. Suppose that Alice prefers the
symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the
software locates this key via Alice's name, then the preferred
algorithm is CAST5; if software locates the key via Bob's name, then
the preferred algorithm is IDEA. If the key is located by Key ID,
the algorithm of the primary User ID of the key provides the
preferred symmetric algorithm.
Revoking a self-signature or allowing it to expire has a semantic
meaning that varies with the signature type. Revoking the self-
signature on a User ID effectively retires that user name. The
self-signature is a statement, "My name X is tied to my signing key
K" and is corroborated by other users' certifications. If another
user revokes their certification, they are effectively saying that
they no longer believe that name and that key are tied together.
Similarly, if the users themselves revoke their self-signature, then
the users no longer go by that name, no longer have that email
address, etc. Revoking a binding signature effectively retires that
subkey. Revoking a direct-key signature cancels that signature.
Please see the "Reason for Revocation" subpacket (Section 5.2.3.23)
for more relevant detail.
Since a self-signature contains important information about the key's
use, an implementation SHOULD allow the user to rewrite the self-
signature, and important information in it, such as preferences and
key expiration.
It is good practice to verify that a self-signature imported into an
implementation doesn't advertise features that the implementation
doesn't support, rewriting the signature as appropriate.
An implementation that encounters multiple self-signatures on the
same object may resolve the ambiguity in any way it sees fit, but it
is RECOMMENDED that priority be given to the most recent self-
signature.
5.2.3.4. Signature Creation Time
(4-octet time field)
The time the signature was made.
MUST be present in the hashed area.
5.2.3.5. Issuer
(8-octet Key ID)
The OpenPGP Key ID of the key issuing the signature.
5.2.3.6. Key Expiration Time
(4-octet time field)
The validity period of the key. This is the number of seconds after
the key creation time that the key expires. If this is not present
or has a value of zero, the key never expires. This is found only on
a self-signature.
5.2.3.7. Preferred Symmetric Algorithms
(array of one-octet values)
Symmetric algorithm numbers that indicate which algorithms the key
holder prefers to use. The subpacket body is an ordered list of
octets with the most preferred listed first. It is assumed that only
algorithms listed are supported by the recipient's software.
Algorithm numbers are in Section 9. This is only found on a self-
signature.
5.2.3.8. Preferred Hash Algorithms
(array of one-octet values)
Message digest algorithm numbers that indicate which algorithms the
key holder prefers to receive. Like the preferred symmetric
algorithms, the list is ordered. Algorithm numbers are in Section 9.
This is only found on a self-signature.
5.2.3.9. Preferred Compression Algorithms
(array of one-octet values)
Compression algorithm numbers that indicate which algorithms the key
holder prefers to use. Like the preferred symmetric algorithms, the
list is ordered. Algorithm numbers are in Section 9. If this
subpacket is not included, ZIP is preferred. A zero denotes that
uncompressed data is preferred; the key holder's software might have
no compression software in that implementation. This is only found
on a self-signature.
5.2.3.10. Signature Expiration Time
(4-octet time field)
The validity period of the signature. This is the number of seconds
after the signature creation time that the signature expires. If
this is not present or has a value of zero, it never expires.
5.2.3.11. Exportable Certification
(1 octet of exportability, 0 for not, 1 for exportable)
This subpacket denotes whether a certification signature is
"exportable", to be used by other users than the signature's issuer.
The packet body contains a Boolean flag indicating whether the
signature is exportable. If this packet is not present, the
certification is exportable; it is equivalent to a flag containing a
1.
Non-exportable, or "local", certifications are signatures made by a
user to mark a key as valid within that user's implementation only.
Thus, when an implementation prepares a user's copy of a key for
transport to another user (this is the process of "exporting" the
key), any local certification signatures are deleted from the key.
The receiver of a transported key "imports" it, and likewise trims
any local certifications. In normal operation, there won't be any,
assuming the import is performed on an exported key. However, there
are instances where this can reasonably happen. For example, if an
implementation allows keys to be imported from a key database in
addition to an exported key, then this situation can arise.
Some implementations do not represent the interest of a single user
(for example, a key server). Such implementations always trim local
certifications from any key they handle.
5.2.3.12. Revocable
(1 octet of revocability, 0 for not, 1 for revocable)
Signature's revocability status. The packet body contains a Boolean
flag indicating whether the signature is revocable. Signatures that
are not revocable have any later revocation signatures ignored. They
represent a commitment by the signer that he cannot revoke his
signature for the life of his key. If this packet is not present,
the signature is revocable.
5.2.3.13. Trust Signature
(1 octet "level" (depth), 1 octet of trust amount)
Signer asserts that the key is not only valid but also trustworthy at
the specified level. Level 0 has the same meaning as an ordinary
validity signature. Level 1 means that the signed key is asserted to
be a valid trusted introducer, with the 2nd octet of the body
specifying the degree of trust. Level 2 means that the signed key is
asserted to be trusted to issue level 1 trust signatures, i.e., that
it is a "meta introducer". Generally, a level n trust signature
asserts that a key is trusted to issue level n-1 trust signatures.
The trust amount is in a range from 0-255, interpreted such that
values less than 120 indicate partial trust and values of 120 or
greater indicate complete trust. Implementations SHOULD emit values
of 60 for partial trust and 120 for complete trust.
5.2.3.14. Regular Expression
(null-terminated regular expression)
Used in conjunction with trust Signature packets (of level > 0) to
limit the scope of trust that is extended. Only signatures by the
target key on User IDs that match the regular expression in the body
of this packet have trust extended by the trust Signature subpacket.
The regular expression uses the same syntax as the Henry Spencer's
"almost public domain" regular expression [REGEX] package. A
description of the syntax is found in Section 8 below.
5.2.3.15. Revocation Key
(1 octet of class, 1 octet of public-key algorithm ID, 20 octets of
fingerprint)
Authorizes the specified key to issue revocation signatures for this
key. Class octet must have bit 0x80 set. If the bit 0x40 is set,
then this means that the revocation information is sensitive. Other
bits are for future expansion to other kinds of authorizations. This
is found on a self-signature.
If the "sensitive" flag is set, the keyholder feels this subpacket
contains private trust information that describes a real-world
sensitive relationship. If this flag is set, implementations SHOULD
NOT export this signature to other users except in cases where the
data needs to be available: when the signature is being sent to the
designated revoker, or when it is accompanied by a revocation
signature from that revoker. Note that it may be appropriate to
isolate this subpacket within a separate signature so that it is not
combined with other subpackets that need to be exported.
5.2.3.16. Notation Data
(4 octets of flags, 2 octets of name length (M),
2 octets of value length (N),
M octets of name data,
N octets of value data)
This subpacket describes a "notation" on the signature that the
issuer wishes to make. The notation has a name and a value, each of
which are strings of octets. There may be more than one notation in
a signature. Notations can be used for any extension the issuer of
the signature cares to make. The "flags" field holds four octets of
flags.
All undefined flags MUST be zero. Defined flags are as follows:
First octet: 0x80 = human-readable. This note value is text.
Other octets: none.
Notation names are arbitrary strings encoded in UTF-8. They reside
in two namespaces: The IETF namespace and the user namespace.
The IETF namespace is registered with IANA. These names MUST NOT
contain the "@" character (0x40). This is a tag for the user
namespace.
Names in the user namespace consist of a UTF-8 string tag followed by
"@" followed by a DNS domain name. Note that the tag MUST NOT
contain an "@" character. For example, the "sample" tag used by
Example Corporation could be "[email protected]".
Names in a user space are owned and controlled by the owners of that
domain. Obviously, it's bad form to create a new name in a DNS space
|
alios/lab
|
68904a98e43f355b7f4cb0b4a3ca3450f4e1e790
|
implemented signature v3 packet type parser
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
index a77a738..fb87e87 100644
--- a/OpenPGP.lhs
+++ b/OpenPGP.lhs
@@ -1,1410 +1,1517 @@
\begin{code}
{-# LANGUAGE NoMonomorphismRestriction #-}
import Data.Enumerator (Iteratee)
import Data.Attoparsec (Parser, (<?>))
import Data.Attoparsec.Enumerator
import qualified Data.Attoparsec as A
import Data.Convertible
import qualified Data.ByteString.Base64 as Base64
-import Data.Time
+import Data.Time (UTCTime)
import Data.Bits
import Data.Word
import Data.Tuple (swap)
import Data.Binary (decode)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy as B
import Data.ByteString (ByteString)
import System.Time
decodeStrictBS bs = (decode . B.fromChunks) [bs]
anyWord16 :: Parser Word16
anyWord16 = fmap decodeStrictBS (A.take 2 <?> "word16")
anyWord32 :: Parser Word32
anyWord32 = fmap decodeStrictBS (A.take 4 <?> "word32")
anyWord64 :: Parser Word64
anyWord64 = fmap decodeStrictBS (A.take 8 <?> "word64")
\end{code}
3. Data Element Formats
This section describes the data elements used by OpenPGP.
3.1. Scalar Numbers
Scalar numbers are unsigned and are always stored in big-endian
format. Using n[k] to refer to the kth octet being interpreted, the
value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a
four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
n[3]).
3.2. Multiprecision Integers
Multiprecision integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used in cryptographic
calculations.
An MPI consists of two pieces: a two-octet scalar that is the length
of the MPI in bits followed by a string of octets that contain the
actual integer.
These octets form a big-endian number; a big-endian number can be
made into an MPI by prefixing it with the appropriate length.
Examples:
(all numbers are in hexadecimal)
The string of octets [00 01 01] forms an MPI with the value 1. The
string [00 09 01 FF] forms an MPI with the value of 511.
Additional rules:
The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
The length field of an MPI describes the length starting from its
most significant non-zero bit. Thus, the MPI [00 02 01] is not
formed correctly. It should be [00 01 01].
Unused bits of an MPI MUST be zero.
Also note that when an MPI is encrypted, the length refers to the
plaintext MPI. It may be ill-formed in its ciphertext.
\begin{code}
newtype MPI = MPI ByteString
parseMPI :: Parser MPI
parseMPI = do
ls <- fmap convert anyWord16
bs <- (A.take ls <?> "MPI")
return $ MPI bs
\end{code}
3.3. Key IDs
A Key ID is an eight-octet scalar that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique. The
section "Enhanced Key Formats" below describes how Key IDs are
formed.
\begin{code}
type KeyID = Word64
parseKeyID :: Parser KeyID
parseKeyID = fmap decodeStrictBS (A.take 8 <?> "KeyID")
\end{code}
3.4. Text
Unless otherwise specified, the character set for text is the UTF-8
[RFC3629] encoding of Unicode [ISO10646].
3.5. Time Fields
A time field is an unsigned four-octet number containing the number
of seconds elapsed since midnight, 1 January 1970 UTC.
\begin{code}
parseTime :: Parser UTCTime
parseTime = do
ts <- anyWord32 <?> "TimeField"
return $ convert $ TOD (convert ts) 0
\end{code}
3.6. Keyrings
A keyring is a collection of one or more keys in a file or database.
Traditionally, a keyring is simply a sequential list of keys, but may
be any suitable database. It is beyond the scope of this standard to
discuss the details of keyrings or other databases.
3.7. String-to-Key (S2K) Specifiers
String-to-key (S2K) specifiers are used to convert passphrase strings
into symmetric-key encryption/decryption keys. They are used in two
places, currently: to encrypt the secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
symmetrically encrypted messages.
3.7.1. String-to-Key (S2K) Specifier Types
There are three types of S2K specifiers currently supported, and
some reserved values:
ID S2K Type
-- --------
0 Simple S2K
1 Salted S2K
2 Reserved value
3 Iterated and Salted S2K
100 to 110 Private/Experimental S2K
These are described in Sections 3.7.1.1 - 3.7.1.3.
\begin{code}
data StringToKeySpecifier =
SimpleS2K Word8|
SaltedS2K Word8 Word64 |
IteratedAndSaltedS2K Word8 Word64 Word8
parseStringToKeySpecifier :: Parser StringToKeySpecifier
parseStringToKeySpecifier = A.choice [parseSimpleS2K, parseSaltedS2K, parseIteratedAndSaltedS2K]
parseHashAlgo = A.anyWord8 <?> "hash algorithm" -- TODO: Parse hash Algo correctly
\end{code}
3.7.1.1. Simple S2K
This directly hashes the string to produce the key data. See below
for how this hashing is done.
Octet 0: 0x00
Octet 1: hash algorithm
Simple S2K hashes the passphrase to produce the session key. The
manner in which this is done depends on the size of the session key
(which will depend on the cipher used) and the size of the hash
algorithm's output. If the hash size is greater than the session key
size, the high-order (leftmost) octets of the hash are used as the
key.
If the hash size is less than the key size, multiple instances of the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two
octets of zeros, and so forth).
As the data is hashed, it is given independently to each hash
context. Since the contexts have been initialized differently, they
will each produce different hash output. Once the passphrase is
hashed, the output data from the multiple hashes is concatenated,
first hash leftmost, to produce the key data, with any excess octets
on the right discarded.
\begin{code}
parseSimpleS2K :: Parser StringToKeySpecifier
parseSimpleS2K = do
_ <- A.word8 0x00
hashAlgo <- parseHashAlgo
return $ SimpleS2K hashAlgo
\end{code}
+
3.7.1.2. Salted S2K
This includes a "salt" value in the S2K specifier -- some arbitrary
data -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.
Octet 0: 0x01
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the passphrase.
\begin{code}
parseSaltedS2K :: Parser StringToKeySpecifier
parseSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
return $ SaltedS2K hashAlgo saltValue
\end{code}
3.7.1.3. Iterated and Salted S2K
This includes both a salt and an octet count. The salt is combined
with the passphrase and the resulting value is hashed repeatedly.
This further increases the amount of work an attacker must do to try
dictionary attacks.
Octet 0: 0x03
Octet 1: hash algorithm
Octets 2-9: 8-octet salt value
Octet 10: count, a one-octet, coded value
\begin{code}
parseIteratedAndSaltedS2K :: Parser StringToKeySpecifier
parseIteratedAndSaltedS2K = do
_ <- A.word8 0x01
hashAlgo <- parseHashAlgo
saltValue <- anyWord64
cnt <- A.anyWord8
return $ IteratedAndSaltedS2K hashAlgo saltValue cnt
\end{code}
The count is coded into a one-octet number using the following
formula:
#define EXPBIAS 6
count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
Iterated-Salted S2K hashes the passphrase and salt data multiple
times. The total number of octets to be hashed is specified in the
encoded count in the S2K specifier. Note that the resulting count
value is an octet count of how many octets will be hashed, not an
iteration count.
Initially, one or more hash contexts are set up as with the other S2K
algorithms, depending on how many octets of key data are needed.
Then the salt, followed by the passphrase data, is repeatedly hashed
until the number of octets specified by the octet count has been
hashed. The one exception is that if the octet count is less than
the size of the salt plus passphrase, the full salt plus passphrase
will be hashed even though that is greater than the octet count.
After the hashing is done, the data is unloaded from the hash
context(s) as with the other S2K algorithms.
3.7.2. String-to-Key Usage
Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are more vulnerable to
dictionary attacks.
3.7.2.1. Secret-Key Encryption
An S2K specifier can be stored in the secret keyring to specify how
to convert the passphrase to a key that unlocks the secret data.
Older versions of PGP just stored a cipher algorithm octet preceding
the secret data or a zero to indicate that the secret data was
unencrypted. The MD5 hash function was always used to convert the
passphrase to a key for the specified cipher algorithm.
For compatibility, when an S2K specifier is used, the special value
254 or 255 is stored in the position where the hash algorithm octet
would have been in the old data structure. This is then followed
immediately by a one-octet algorithm identifier, and then by the S2K
specifier as encoded above.
Therefore, preceding the secret data there will be one of these
possibilities:
0: secret data is unencrypted (no passphrase)
255 or 254: followed by algorithm octet and S2K specifier
Cipher alg: use Simple S2K algorithm using MD5 hash
This last possibility, the cipher algorithm number with an implicit
use of MD5 and IDEA, is provided for backward compatibility; it MAY
be understood, but SHOULD NOT be generated, and is deprecated.
These are followed by an Initial Vector of the same length as the
block size of the cipher for the decryption of the secret values, if
they are encrypted, and then the secret-key values themselves.
3.7.2.2. Symmetric-Key Message Encryption
OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
at the front of a message. This is used to allow S2K specifiers to
be used for the passphrase conversion or to create messages with a
mix of symmetric-key ESKs and public-key ESKs. This allows a message
to be decrypted either with a passphrase or a public-key pair.
PGP 2.X always used IDEA with Simple string-to-key conversion when
encrypting a message with a symmetric algorithm. This is deprecated,
but MAY be used for backward-compatibility.
4. Packet Syntax
This section describes the packets used by OpenPGP.
4.1. Overview
An OpenPGP message is constructed from a number of records that are
traditionally called packets. A packet is a chunk of data that has a
tag specifying its meaning. An OpenPGP message, keyring,
certificate, and so forth consists of a number of packets. Some of
those packets may contain other OpenPGP packets (for example, a
compressed data packet, when uncompressed, contains OpenPGP packets).
Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.
4.2. Packet Headers
The first octet of the packet header is called the "Packet Tag". It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.
Note that the most significant bit is the leftmost bit, called bit 7.
A mask for this bit is 0x80 in hexadecimal.
+---------------+
PTag |7 6 5 4 3 2 1 0|
+---------------+
Bit 7 -- Always one
Bit 6 -- New packet format if set
PGP 2.6.x only uses old format packets. Thus, software that
interoperates with those versions of PGP must only use old format
packets. If interoperability is not an issue, the new packet format
is RECOMMENDED. Note that old format packets have four bits of
packet tags, and new format packets have six; some features cannot be
used and still be backward-compatible.
Also note that packets with a tag greater than or equal to 16 MUST
use new format packets. The old format packets can only express tags
less than or equal to 15.
Old format packets contain:
Bits 5-2 -- packet tag
Bits 1-0 -- length-type
New format packets contain:
Bits 5-0 -- packet tag
\begin{code}
data PacketHeaderT =
OldPacketHeader PacketTag PacketLength |
NewPacketHeader PacketTag
class PacketHeader h where
packetHeaderTag :: h -> PacketTag
instance PacketHeader PacketHeaderT where
packetHeaderTag (OldPacketHeader t _) = t
packetHeaderTag (NewPacketHeader t) = t
parsePacketHeader :: Parser PacketHeaderT
parsePacketHeader = do
w <- A.try A.anyWord8
let valid = w `testBit` 7
if (not valid) then fail "is not a valid packet header"
else do
let newPacket = w `testBit` 6
let maskedPacket = w .&. 0x3f
if (newPacket) then do
case (lookupPacketTag maskedPacket) of
Nothing -> fail "unknown new packet header tag"
Just t -> return $ NewPacketHeader t
else do
let tag = lookupPacketTag $ maskedPacket `shiftR` 2
let len = maskedPacket .&. 0x03
case (lookupPacketLength len) of
Nothing -> fail "unknown old packet header length field"
Just l -> case (tag) of
Nothing -> fail "unknown old packet header tag"
Just t -> if (not $ isValidOldTag t) then fail "unknown old packet header tag"
else return $ OldPacketHeader t l
headerIteratee :: Monad m => Iteratee ByteString m PacketHeaderT
headerIteratee = iterParser parsePacketHeader
\end{code}
4.2.1. Old Format Packet Lengths
The meaning of the length-type in old format packets is:
0 - The packet has a one-octet length. The header is 2 octets long.
1 - The packet has a two-octet length. The header is 3 octets long.
2 - The packet has a four-octet length. The header is 5 octets long.
3 - The packet is of indeterminate length. The header is 1 octet
long, and the implementation must determine how long the packet
is. If the packet is in a file, this means that the packet
extends until the end of the file. In general, an implementation
SHOULD NOT use indeterminate-length packets except where the end
of the data will be clear from the context, and even then it is
better to use a definite length, or a new format header. The new
format headers described below have a mechanism for precisely
encoding data of indeterminate length.
\begin{code}
data PacketLength =
OneOctedLength |
TwoOctedLength |
FiveOctedLength |
PartialBodyLength
deriving (Show, Read, Eq, Enum)
packetLengthCoding = [
(OneOctedLength, 0),
(TwoOctedLength, 1),
(FiveOctedLength, 2),
(PartialBodyLength, 3)
]
lookupPacketLength :: Word8 -> Maybe PacketLength
lookupPacketLength i = lookup i $ map swap packetLengthCoding
packetLengthToNum :: PacketLength -> Maybe Word8
packetLengthToNum p = lookup p packetLengthCoding
\end{code}
4.2.2.1. One-Octet Lengths
A one-octet Body Length header encodes a length of 0 to 191 octets.
This type of length header is recognized because the one octet value
is less than 192. The body length is equal to:
bodyLen = 1st_octet;
\begin{code}
bodyLenParser :: Num b => PacketLength -> Parser b
bodyLenParser OneOctedLength = fmap (fromInteger . convert) A.anyWord8
\end{code}
4.2.2.2. Two-Octet Lengths
A two-octet Body Length header encodes a length of 192 to 8383
octets. It is recognized because its first octet is in the range 192
to 223. The body length is equal to:
bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
\begin{code}
bodyLenParser TwoOctedLength = fmap (fromInteger . convert) $ do
o1' <- fmap ((-) 192) A.anyWord8
let o1 :: Word16
o1 = convert o1'
o2 <- fmap ((-) 192) A.anyWord8
return ((o1 `shiftL` 8) + (convert o2) + 192)
\end{code}
4.2.2.3. Five-Octet Lengths
A five-octet Body Length header consists of a single octet holding
the value 255, followed by a four-octet scalar. The body length is
equal to:
bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
(4th_octet << 8) | 5th_octet
This basic set of one, two, and five-octet lengths is also used
internally to some packets.
\begin{code}
bodyLenParser FiveOctedLength = fmap (fromInteger . convert) $ do
_ <- A.word8 255
o2' <- A.anyWord8
o3' <- A.anyWord8
o4' <- A.anyWord8
o5' <- A.anyWord8
let o2,o3,o4,o5 :: Word32
o2 = (convert o2') `shiftL` 24
o3 = (convert o3') `shiftL` 16
o4 = (convert o4') `shiftL` 8
o5 = convert o5'
return $ o2 .|. o3 .|. o4 .|. o5
\end{code}
4.2.2.4. Partial Body Lengths
A Partial Body Length header is one octet long and encodes the length
of only part of the data packet. This length is a power of 2, from 1
to 1,073,741,824 (2 to the 30th power). It is recognized by its one
octet value that is greater than or equal to 224, and less than 255.
The Partial Body Length is equal to:
partialBodyLen = 1 << (1st_octet & 0x1F);
Each Partial Body Length header is followed by a portion of the
packet body data. The Partial Body Length header specifies this
portion's length. Another length header (one octet, two-octet,
five-octet, or partial) follows that portion. The last length header
in the packet MUST NOT be a Partial Body Length header. Partial Body
Length headers may only be used for the non-final parts of the
packet.
Note also that the last Body Length header can be a zero-length
header.
An implementation MAY use Partial Body Lengths for data packets, be
they literal, compressed, or encrypted. The first partial length
MUST be at least 512 octets long. Partial Body Lengths MUST NOT be
used for any other packet types.
\begin{code}
-{-
+
bodyLenParser PartialBodyLength = fmap (fromInteger . convert) $ do
a <- A.anyWord8
let n = a .&. 0x1f
- a' = undefined
+ a' :: Word32
+ a' = 1 `shiftL` (convert n)
if (not (a >= 224 && a < 255)) then fail "partial bodylength must encode between 224 and 255"
else return a'
--}
\end{code}
4.3. Packet Tags
The packet tag denotes what type of packet the body holds. Note that
old format headers can only have tags less than 16, whereas new
format headers can have tags as great as 63. The defined tags (in
decimal) are as follows:
0 -- Reserved - a packet tag MUST NOT have this value
1 -- Public-Key Encrypted Session Key Packet
2 -- Signature Packet
3 -- Symmetric-Key Encrypted Session Key Packet
4 -- One-Pass Signature Packet
5 -- Secret-Key Packet
6 -- Public-Key Packet
7 -- Secret-Subkey Packet
8 -- Compressed Data Packet
9 -- Symmetrically Encrypted Data Packet
10 -- Marker Packet
11 -- Literal Data Packet
12 -- Trust Packet
13 -- User ID Packet
14 -- Public-Subkey Packet
17 -- User Attribute Packet
18 -- Sym. Encrypted and Integrity Protected Data Packet
19 -- Modification Detection Code Packet
60 to 63 -- Private or Experimental Values
\begin{code}
data PacketTag =
PublicKeyEncryptedSessionKeyPacket |
SignaturePacket |
SymmetricKeyEncryptedSessionKeyPacket |
OnePassSignaturePacket |
SecretKeyPacket |
PublicKeyPacket |
SecretSubkeyPacket |
CompressedDataPacket |
SymmetricallyEncryptedPacket |
MarkerPacket |
LiteralDataPacket |
TrustPacket |
UserIDPacket |
PublicSubkeyPacket |
UserAttributePacket |
SymEncryptedAndIntegrityProtectedDataPacket |
ModificationDetectionCodePacket
deriving (Show, Read, Eq)
packetTagCoding = [
(PublicKeyEncryptedSessionKeyPacket, 1),
(SignaturePacket, 2),
(SymmetricKeyEncryptedSessionKeyPacket, 3),
(OnePassSignaturePacket, 4),
(SecretKeyPacket, 5),
(PublicKeyPacket, 6),
(SecretSubkeyPacket, 7),
(CompressedDataPacket, 8),
(SymmetricallyEncryptedPacket, 9),
(MarkerPacket, 10),
(LiteralDataPacket, 11),
(TrustPacket, 12),
(UserIDPacket, 13),
(PublicSubkeyPacket, 14),
(UserAttributePacket, 17),
(SymEncryptedAndIntegrityProtectedDataPacket, 18),
(ModificationDetectionCodePacket, 19)
]
isValidOldTag :: PacketTag -> Bool
isValidOldTag t = case (packetTagToNum t) of
Nothing -> False
Just t' -> t' < 16
isValidOldTagNum :: Word8 -> Bool
isValidOldTagNum i = case (lookupPacketTag i) of
Nothing -> False
Just _ -> (i > 0) && (i < 16)
packetTagToNum :: PacketTag -> Maybe Word8
packetTagToNum t = lookup t packetTagCoding
lookupPacketTag :: Word8 -> Maybe PacketTag
lookupPacketTag i = lookup i $ map swap packetTagCoding
\end{code}
5. Packet Types
5.1. Public-Key Encrypted Session Key Packets (Tag 1)
A Public-Key Encrypted Session Key packet holds the session key used
to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may
precede a Symmetrically Encrypted Data Packet, which holds an
encrypted message. The message is encrypted with the session key,
and the session key is itself encrypted and stored in the Encrypted
Session Key packet(s). The Symmetrically Encrypted Data Packet is
preceded by one Public-Key Encrypted Session Key packet for each
OpenPGP key to which the message is encrypted. The recipient of the
message finds a session key that is encrypted to their public key,
decrypts the session key, and then uses the session key to decrypt
the message.
The body of this packet consists of:
- A one-octet number giving the version number of the packet type.
The currently defined value for packet version is 3.
- An eight-octet number that gives the Key ID of the public key to
which the session key is encrypted. If the session key is
encrypted to a subkey, then the Key ID of this subkey is used
here instead of the Key ID of the primary key.
- A one-octet number giving the public-key algorithm used.
- A string of octets that is the encrypted session key. This
string takes up the remainder of the packet, and its contents are
dependent on the public-key algorithm used.
+
+\begin{code}
+parsePEKSKPBody :: Parser (Maybe KeyID, PublicKeyAlgorithm, Either MPI (MPI, MPI))
+parsePEKSKPBody = do
+ _ <- A.word8 3
+ keyid' <- parseKeyID
+ let keyid = if (keyid' == 0) then Nothing else Just keyid'
+ algo <- parsePublicKeyAlgorithm
+ encKey <- case (algo) of
+ RSAEncryptOrSign -> parseRSAEncryptedSessionKey
+ RSAEncryptOnly -> parseRSAEncryptedSessionKey
+ ElgamalEncryptOnly -> parseElgamalEncryptedSessionKey
+ return (keyid, algo, encKey)
+ where parseRSAEncryptedSessionKey = fmap Left parseMPI
+ parseElgamalEncryptedSessionKey = do
+ a <- parseMPI
+ b <- parseMPI
+ return $ Right (a, b)
+\end{code}
+
Algorithm Specific Fields for RSA encryption
- multiprecision integer (MPI) of RSA encrypted value m**e mod n.
Algorithm Specific Fields for Elgamal encryption:
- MPI of Elgamal (Diffie-Hellman) value g**k mod p.
- MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
The value "m" in the above formulas is derived from the session key
as follows. First, the session key is prefixed with a one-octet
algorithm identifier that specifies the symmetric encryption
algorithm used to encrypt the following Symmetrically Encrypted Data
Packet. Then a two-octet checksum is appended, which is equal to the
sum of the preceding session key octets, not including the algorithm
identifier, modulo 65536. This value is then encoded as described in
PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to
form the "m" value used in the formulas above. See Section 13.1 of
this document for notes on OpenPGP's use of PKCS#1.
Note that when an implementation forms several PKESKs with one
session key, forming a message that can be decrypted by several keys,
the implementation MUST make a new PKCS#1 encoding for each key.
An implementation MAY accept or use a Key ID of zero as a "wild card"
or "speculative" Key ID. In this case, the receiving implementation
would try all available private keys, checking for a valid decrypted
session key. This format helps reduce traffic analysis of messages.
5.2. Signature Packet (Tag 2)
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
Two versions of Signature packets are defined. Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about the
signature. PGP 2.6.x only accepts version 3 signatures.
Implementations SHOULD accept V3 signatures. Implementations SHOULD
generate V4 signatures.
Note that if an implementation is creating an encrypted and signed
message that is encrypted to a V3 key, it is reasonable to create a
V3 signature.
5.2.1. Signature Types
There are a number of possible meanings for a signature, which are
indicated in a signature type octet in any given signature. Please
note that the vagueness of these meanings is not a flaw, but a
feature of the system. Because OpenPGP places final authority for
validity upon the receiver of a signature, it may be that one
signer's casual act might be more rigorous than some other
authority's positive act. See Section 5.2.4, "Computing Signatures",
for detailed information on how to compute and verify signatures of
each type.
These meanings are as follows:
0x00: Signature of a binary document.
This means the signer owns it, created it, or certifies that it
has not been modified.
0x01: Signature of a canonical text document.
This means the signer owns it, created it, or certifies that it
has not been modified. The signature is calculated over the text
data with its line endings converted to <CR><LF>.
0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.
It is calculated identically to a signature over a zero-length
binary document. Note that it doesn't make sense to have a V3
standalone signature.
0x10: Generic certification of a User ID and Public-Key packet.
The issuer of this certification does not make any particular
assertion as to how well the certifier has checked that the owner
of the key is in fact the person described by the User ID.
0x11: Persona certification of a User ID and Public-Key packet.
The issuer of this certification has not done any verification of
the claim that the owner of this key is the User ID specified.
0x12: Casual certification of a User ID and Public-Key packet.
The issuer of this certification has done some casual
verification of the claim of identity.
0x13: Positive certification of a User ID and Public-Key packet.
The issuer of this certification has done substantial
verification of the claim of identity.
Most OpenPGP implementations make their "key signatures" as 0x10
certifications. Some implementations can issue 0x11-0x13
certifications, but few differentiate between the types.
0x18: Subkey Binding Signature
This signature is a statement by the top-level signing key that
indicates that it owns the subkey. This signature is calculated
directly on the primary key and subkey, and not on any User ID or
other packets. A signature that binds a signing subkey MUST have
an Embedded Signature subpacket in this binding signature that
contains a 0x19 signature made by the signing subkey on the
primary key and subkey.
0x19: Primary Key Binding Signature
This signature is a statement by a signing subkey, indicating
that it is owned by the primary key and subkey. This signature
is calculated the same way as a 0x18 signature: directly on the
primary key and subkey, and not on any User ID or other packets.
0x1F: Signature directly on a key
This signature is calculated directly on a key. It binds the
information in the Signature subpackets to the key, and is
appropriate to be used for subpackets that provide information
about the key, such as the Revocation Key subpacket. It is also
appropriate for statements that non-self certifiers want to make
about the key itself, rather than the binding between a key and a
name.
0x20: Key revocation signature
The signature is calculated directly on the key being revoked. A
revoked key is not to be used. Only revocation signatures by the
key being revoked, or by an authorized revocation key, should be
considered valid revocation signatures.
0x28: Subkey revocation signature
The signature is calculated directly on the subkey being revoked.
A revoked subkey is not to be used. Only revocation signatures
by the top-level signature key that is bound to this subkey, or
by an authorized revocation key, should be considered valid
revocation signatures.
0x30: Certification revocation signature
This signature revokes an earlier User ID certification signature
(signature class 0x10 through 0x13) or direct-key signature
(0x1F). It should be issued by the same key that issued the
revoked signature or an authorized revocation key. The signature
is computed over the same data as the certificate that it
revokes, and should have a later creation date than that
certificate.
0x40: Timestamp signature.
This signature is only meaningful for the timestamp contained in
it.
0x50: Third-Party Confirmation signature.
This signature is a signature over some other OpenPGP Signature
packet(s). It is analogous to a notary seal on the signed data.
A third-party signature SHOULD include Signature Target
subpacket(s) to give easy identification. Note that we really do
mean SHOULD. There are plausible uses for this (such as a blind
party that only sees the signature, not the key or source
document) that cannot include a target subpacket.
-5.2.2. Version 3 Signature Packet Format
+\begin{code}
+data SignatureType =
+ SignatureBinaryDoc |
+ SignatureCanonicalTextDoc |
+ StandaloneSignature |
+ GenericCertificationOfAUserIDAndPublicKeyPacket |
+ PersonaCertificationOfAUserIDAndPublicKeyPacket |
+ CasualCertificationOfAUserIDAndPublicKeyPacket |
+ PositiveCertificationOfAUserIDAndPublicKeyPacket |
+ SubkeyBindingSignature |
+ PrimaryKeyBindingSignature |
+ SignatureDirectlyOnAKey |
+ KeyRevocationSignature |
+ SubkeyRevocationSignature |
+ CertificationRevocationSignature |
+ TimestampSignature |
+ ThirdPartyConfirmationSignature
+ deriving (Show, Read, Eq, Enum)
+
+signatureTypeCoding = [
+ (SignatureBinaryDoc , 0x00),
+ (SignatureCanonicalTextDoc , 0x01),
+ (StandaloneSignature , 0x02),
+ (GenericCertificationOfAUserIDAndPublicKeyPacket , 0x10),
+ (PersonaCertificationOfAUserIDAndPublicKeyPacket , 0x11),
+ (CasualCertificationOfAUserIDAndPublicKeyPacket , 0x12),
+ (PositiveCertificationOfAUserIDAndPublicKeyPacket , 0x13),
+ (SubkeyBindingSignature , 0x18),
+ (PrimaryKeyBindingSignature , 0x19),
+ (SignatureDirectlyOnAKey , 0x1F),
+ (KeyRevocationSignature , 0x20),
+ (SubkeyRevocationSignature , 0x28),
+ (CertificationRevocationSignature , 0x30),
+ (TimestampSignature , 0x40),
+ (ThirdPartyConfirmationSignature , 0x50)
+ ]
+
+lookupSignatureType :: Word8 -> Maybe SignatureType
+lookupSignatureType i = lookup i $ map swap signatureTypeCoding
+signatureTypeToNum :: SignatureType -> Maybe Word8
+signatureTypeToNum p = lookup p signatureTypeCoding
+parseSignatureType :: Parser SignatureType
+parseSignatureType = do
+ w <- A.anyWord8
+ case (lookupSignatureType w) of
+ Nothing -> fail "unknown signature type"
+ Just a -> return a
+\end{code}
+
+5.2.2. Version 3 Signature Packet Format
The body of a version 3 Signature Packet contains:
- One-octet version number (3).
- One-octet length of following hashed material. MUST be 5.
- One-octet signature type.
- Four-octet creation time.
- Eight-octet Key ID of signer.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet field holding left 16 bits of signed hash value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described below.
The concatenation of the data to be signed, the signature type, and
creation time from the Signature packet (5 additional octets) is
hashed. The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the
Signature packet to provide a quick test to reject some invalid
signatures.
+
+\begin{code}
+parseSignaturePacket3 = do
+ _ <- A.word8 3
+ l <- bodyLenParser OneOctedLength
+ if (l /= 5) then fail $ "v3 signature packet must have a length of 5 but has " ++ show l
+ else do
+ stype <- parseSignatureType
+ t <- parseTime
+ keyid <- parseKeyID
+ pkAlgo <- parsePublicKeyAlgorithm
+ hasha <- parseHashAlgorithm
+ shv <- anyWord16
+ hashdata <- case (pkAlgo) of
+ RSAEncryptOrSign -> parseRSAMPI
+ RSASignOnly -> parseRSAMPI
+ DSA -> parseDSAMPI
+ let (MPI firstHash) = case (hashdata) of
+ Left h -> h
+ Right (h, _) -> h
+ if (not $ (convert firstHash) `checkFirstHash` shv)
+ then fail "signedHashValue check failed"
+ else return (stype, t , keyid, pkAlgo, hasha, hashdata)
+ where parseRSAMPI = fmap Left parseMPI
+ parseDSAMPI = do
+ r <- parseMPI
+ s <- parseMPI
+ return $ Right (r,s)
+ checkFirstHash bs v =
+ let a = convert (bs `B.index` 0)
+ b = convert (bs `B.index` 1)
+ v' :: Word16
+ v' = (a `shiftL` 8) .|. b
+ in v' == v
+\end{code}
+
Algorithm-Specific Fields for RSA signatures:
- multiprecision integer (MPI) of RSA signature value m**d mod n.
Algorithm-Specific Fields for DSA signatures:
- MPI of DSA value r.
- MPI of DSA value s.
The signature calculation is based on a hash of the signed data, as
described above. The details of the calculation are different for
DSA signatures than for RSA signatures.
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows:
- MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
- RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
- SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
- SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04
- SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01
- SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02
- SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03
+
The ASN.1 Object Identifiers (OIDs) are as follows:
- MD5: 1.2.840.113549.2.5
- RIPEMD-160: 1.3.36.3.2.1
- SHA-1: 1.3.14.3.2.26
- SHA224: 2.16.840.1.101.3.4.2.4
- SHA256: 2.16.840.1.101.3.4.2.1
- SHA384: 2.16.840.1.101.3.4.2.2
- SHA512: 2.16.840.1.101.3.4.2.3
The full hash prefixes for these are as follows:
MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10
RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05,
0x00, 0x04, 0x1C
SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20
SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30
SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40
DSA signatures MUST use hashes that are equal in size to the number
of bits of q, the group generated by the DSA key's generator value.
If the output size of the chosen hash is larger than the number of
bits of q, the hash result is truncated to fit by taking the number
of leftmost bits equal to the number of bits of q. This (possibly
truncated) hash function result is treated as a number and used
directly in the DSA signature algorithm.
5.2.3. Version 4 Signature Packet Format
The body of a version 4 Signature packet contains:
- One-octet version number (4).
- One-octet signature type.
- One-octet public-key algorithm.
- One-octet hash algorithm.
- Two-octet scalar octet count for following hashed subpacket data.
Note that this is the length in octets of all of the hashed
subpackets; a pointer incremented by this number will skip over
the hashed subpackets.
- Hashed subpacket data set (zero or more subpackets).
- Two-octet scalar octet count for the following unhashed subpacket
data. Note that this is the length in octets of all of the
unhashed subpackets; a pointer incremented by this number will
skip over the unhashed subpackets.
- Unhashed subpacket data set (zero or more subpackets).
- Two-octet field holding the left 16 bits of the signed hash
value.
- One or more multiprecision integers comprising the signature.
This portion is algorithm specific, as described above.
The concatenation of the data being signed and the signature data
from the version number through the hashed subpacket data (inclusive)
is hashed. The resulting hash value is what is signed. The left 16
bits of the hash are included in the Signature packet to provide a
quick test to reject some invalid signatures.
There are two fields consisting of Signature subpackets. The first
field is hashed with the rest of the signature data, while the second
is unhashed. The second set of subpackets is not cryptographically
protected by the signature and should include only advisory
information.
The algorithms for converting the hash function result to a signature
are described in a section below.
5.2.3.1. Signature Subpacket Specification
A subpacket data set consists of zero or more Signature subpackets.
In Signature packets, the subpacket data set is preceded by a two-
octet scalar count of the length in octets of all the subpackets. A
pointer incremented by this number will skip over the subpacket data
set.
Each subpacket consists of a subpacket header and a body. The header
consists of:
- the subpacket length (1, 2, or 5 octets),
- the subpacket type (1 octet),
and is followed by the subpacket-specific data.
The length includes the type octet but not this length. Its format
is similar to the "new" format packet header lengths, but cannot have
Partial Body Lengths. That is:
if the 1st octet < 192, then
lengthOfLength = 1
subpacketLen = 1st_octet
if the 1st octet >= 192 and < 255, then
lengthOfLength = 2
subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
if the 1st octet = 255, then
lengthOfLength = 5
subpacket length = [four-octet scalar starting at 2nd_octet]
The value of the subpacket type octet may be:
0 = Reserved
1 = Reserved
2 = Signature Creation Time
3 = Signature Expiration Time
4 = Exportable Certification
5 = Trust Signature
6 = Regular Expression
7 = Revocable
8 = Reserved
9 = Key Expiration Time
10 = Placeholder for backward compatibility
11 = Preferred Symmetric Algorithms
12 = Revocation Key
13 = Reserved
14 = Reserved
15 = Reserved
16 = Issuer
17 = Reserved
18 = Reserved
19 = Reserved
20 = Notation Data
21 = Preferred Hash Algorithms
22 = Preferred Compression Algorithms
23 = Key Server Preferences
24 = Preferred Key Server
25 = Primary User ID
26 = Policy URI
27 = Key Flags
28 = Signer's User ID
29 = Reason for Revocation
30 = Features
31 = Signature Target
32 = Embedded Signature
100 To 110 = Private or experimental
An implementation SHOULD ignore any subpacket of a type that it does
not recognize.
Bit 7 of the subpacket type is the "critical" bit. If set, it
denotes that the subpacket is one that is critical for the evaluator
of the signature to recognize. If a subpacket is encountered that is
marked critical but is unknown to the evaluating software, the
evaluator SHOULD consider the signature to be in error.
An evaluator may "recognize" a subpacket, but not implement it. The
purpose of the critical bit is to allow the signer to tell an
evaluator that it would prefer a new, unknown feature to generate an
error than be ignored.
Implementations SHOULD implement the three preferred algorithm
subpackets (11, 21, and 22), as well as the "Reason for Revocation"
subpacket. Note, however, that if an implementation chooses not to
implement some of the preferences, it is required to behave in a
polite manner to respect the wishes of those users who do implement
these preferences.
5.2.3.2. Signature Subpacket Types
A number of subpackets are currently defined. Some subpackets apply
to the signature itself and some are attributes of the key.
Subpackets that are found on a self-signature are placed on a
certification made by the key itself. Note that a key may have more
than one User ID, and thus may have more than one self-signature, and
differing subpackets.
A subpacket may be found either in the hashed or unhashed subpacket
sections of a signature. If a subpacket is not hashed, then the
information in it cannot be considered definitive because it is not
part of the signature proper.
5.2.3.3. Notes on Self-Signatures
A self-signature is a binding signature made by the key to which the
signature refers. There are three types of self-signatures, the
certification signatures (types 0x10-0x13), the direct-key signature
(type 0x1F), and the subkey binding signature (type 0x18). For
certification self-signatures, each User ID may have a self-
signature, and thus different subpackets in those self-signatures.
For subkey binding signatures, each subkey in fact has a self-
signature. Subpackets that appear in a certification self-signature
apply to the user name, and subpackets that appear in the subkey
self-signature apply to the subkey. Lastly, subpackets on the
direct-key signature apply to the entire key.
Implementing software should interpret a self-signature's preference
subpackets as narrowly as possible. For example, suppose a key has
two user names, Alice and Bob. Suppose that Alice prefers the
symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the
software locates this key via Alice's name, then the preferred
algorithm is CAST5; if software locates the key via Bob's name, then
the preferred algorithm is IDEA. If the key is located by Key ID,
the algorithm of the primary User ID of the key provides the
preferred symmetric algorithm.
Revoking a self-signature or allowing it to expire has a semantic
meaning that varies with the signature type. Revoking the self-
signature on a User ID effectively retires that user name. The
self-signature is a statement, "My name X is tied to my signing key
K" and is corroborated by other users' certifications. If another
user revokes their certification, they are effectively saying that
they no longer believe that name and that key are tied together.
Similarly, if the users themselves revoke their self-signature, then
the users no longer go by that name, no longer have that email
address, etc. Revoking a binding signature effectively retires that
subkey. Revoking a direct-key signature cancels that signature.
Please see the "Reason for Revocation" subpacket (Section 5.2.3.23)
for more relevant detail.
Since a self-signature contains important information about the key's
use, an implementation SHOULD allow the user to rewrite the self-
signature, and important information in it, such as preferences and
key expiration.
It is good practice to verify that a self-signature imported into an
implementation doesn't advertise features that the implementation
doesn't support, rewriting the signature as appropriate.
An implementation that encounters multiple self-signatures on the
same object may resolve the ambiguity in any way it sees fit, but it
is RECOMMENDED that priority be given to the most recent self-
signature.
5.2.3.4. Signature Creation Time
(4-octet time field)
The time the signature was made.
MUST be present in the hashed area.
5.2.3.5. Issuer
(8-octet Key ID)
The OpenPGP Key ID of the key issuing the signature.
5.2.3.6. Key Expiration Time
(4-octet time field)
The validity period of the key. This is the number of seconds after
the key creation time that the key expires. If this is not present
or has a value of zero, the key never expires. This is found only on
a self-signature.
5.2.3.7. Preferred Symmetric Algorithms
(array of one-octet values)
Symmetric algorithm numbers that indicate which algorithms the key
holder prefers to use. The subpacket body is an ordered list of
octets with the most preferred listed first. It is assumed that only
algorithms listed are supported by the recipient's software.
Algorithm numbers are in Section 9. This is only found on a self-
signature.
5.2.3.8. Preferred Hash Algorithms
(array of one-octet values)
Message digest algorithm numbers that indicate which algorithms the
key holder prefers to receive. Like the preferred symmetric
algorithms, the list is ordered. Algorithm numbers are in Section 9.
This is only found on a self-signature.
5.2.3.9. Preferred Compression Algorithms
(array of one-octet values)
Compression algorithm numbers that indicate which algorithms the key
holder prefers to use. Like the preferred symmetric algorithms, the
list is ordered. Algorithm numbers are in Section 9. If this
subpacket is not included, ZIP is preferred. A zero denotes that
uncompressed data is preferred; the key holder's software might have
no compression software in that implementation. This is only found
on a self-signature.
5.2.3.10. Signature Expiration Time
(4-octet time field)
The validity period of the signature. This is the number of seconds
after the signature creation time that the signature expires. If
this is not present or has a value of zero, it never expires.
5.2.3.11. Exportable Certification
(1 octet of exportability, 0 for not, 1 for exportable)
This subpacket denotes whether a certification signature is
"exportable", to be used by other users than the signature's issuer.
The packet body contains a Boolean flag indicating whether the
signature is exportable. If this packet is not present, the
certification is exportable; it is equivalent to a flag containing a
1.
Non-exportable, or "local", certifications are signatures made by a
user to mark a key as valid within that user's implementation only.
Thus, when an implementation prepares a user's copy of a key for
transport to another user (this is the process of "exporting" the
key), any local certification signatures are deleted from the key.
The receiver of a transported key "imports" it, and likewise trims
any local certifications. In normal operation, there won't be any,
assuming the import is performed on an exported key. However, there
are instances where this can reasonably happen. For example, if an
implementation allows keys to be imported from a key database in
addition to an exported key, then this situation can arise.
Some implementations do not represent the interest of a single user
(for example, a key server). Such implementations always trim local
certifications from any key they handle.
5.2.3.12. Revocable
(1 octet of revocability, 0 for not, 1 for revocable)
Signature's revocability status. The packet body contains a Boolean
flag indicating whether the signature is revocable. Signatures that
are not revocable have any later revocation signatures ignored. They
represent a commitment by the signer that he cannot revoke his
signature for the life of his key. If this packet is not present,
the signature is revocable.
5.2.3.13. Trust Signature
(1 octet "level" (depth), 1 octet of trust amount)
Signer asserts that the key is not only valid but also trustworthy at
the specified level. Level 0 has the same meaning as an ordinary
validity signature. Level 1 means that the signed key is asserted to
be a valid trusted introducer, with the 2nd octet of the body
specifying the degree of trust. Level 2 means that the signed key is
asserted to be trusted to issue level 1 trust signatures, i.e., that
it is a "meta introducer". Generally, a level n trust signature
asserts that a key is trusted to issue level n-1 trust signatures.
The trust amount is in a range from 0-255, interpreted such that
values less than 120 indicate partial trust and values of 120 or
greater indicate complete trust. Implementations SHOULD emit values
of 60 for partial trust and 120 for complete trust.
5.2.3.14. Regular Expression
(null-terminated regular expression)
Used in conjunction with trust Signature packets (of level > 0) to
limit the scope of trust that is extended. Only signatures by the
target key on User IDs that match the regular expression in the body
of this packet have trust extended by the trust Signature subpacket.
The regular expression uses the same syntax as the Henry Spencer's
"almost public domain" regular expression [REGEX] package. A
description of the syntax is found in Section 8 below.
5.2.3.15. Revocation Key
(1 octet of class, 1 octet of public-key algorithm ID, 20 octets of
fingerprint)
Authorizes the specified key to issue revocation signatures for this
key. Class octet must have bit 0x80 set. If the bit 0x40 is set,
then this means that the revocation information is sensitive. Other
bits are for future expansion to other kinds of authorizations. This
is found on a self-signature.
If the "sensitive" flag is set, the keyholder feels this subpacket
contains private trust information that describes a real-world
sensitive relationship. If this flag is set, implementations SHOULD
NOT export this signature to other users except in cases where the
data needs to be available: when the signature is being sent to the
designated revoker, or when it is accompanied by a revocation
signature from that revoker. Note that it may be appropriate to
isolate this subpacket within a separate signature so that it is not
combined with other subpackets that need to be exported.
5.2.3.16. Notation Data
(4 octets of flags, 2 octets of name length (M),
2 octets of value length (N),
M octets of name data,
N octets of value data)
This subpacket describes a "notation" on the signature that the
issuer wishes to make. The notation has a name and a value, each of
which are strings of octets. There may be more than one notation in
a signature. Notations can be used for any extension the issuer of
the signature cares to make. The "flags" field holds four octets of
flags.
All undefined flags MUST be zero. Defined flags are as follows:
First octet: 0x80 = human-readable. This note value is text.
Other octets: none.
Notation names are arbitrary strings encoded in UTF-8. They reside
in two namespaces: The IETF namespace and the user namespace.
The IETF namespace is registered with IANA. These names MUST NOT
contain the "@" character (0x40). This is a tag for the user
namespace.
Names in the user namespace consist of a UTF-8 string tag followed by
"@" followed by a DNS domain name. Note that the tag MUST NOT
contain an "@" character. For example, the "sample" tag used by
Example Corporation could be "[email protected]".
Names in a user space are owned and controlled by the owners of that
domain. Obviously, it's bad form to create a new name in a DNS space
that you don't own.
Since the user namespace is in the form of an email address,
implementers MAY wish to arrange for that address to reach a person
who can be consulted about the use of the named tag. Note that due
to UTF-8 encoding, not all valid user space name tags are valid email
addresses.
If there is a critical notation, the criticality applies to that
specific notation and not to notations in general.
5.2.3.17. Key Server Preferences
(N octets of flags)
This is a list of one-bit flags that indicate preferences that the
key holder has about how the key is handled on a key server. All
undefined flags MUST be zero.
First octet: 0x80 = No-modify
the key holder requests that this key only be modified or updated
by the key holder or an administrator of the key server.
This is found only on a self-signature.
5.2.3.18. Preferred Key Server
(String)
This is a URI of a key server that the key holder prefers be used for
updates. Note that keys with multiple User IDs can have a preferred
key server for each User ID. Note also that since this is a URI, the
key server can actually be a copy of the key retrieved by ftp, http,
finger, etc.
5.2.3.19. Primary User ID
(1 octet, Boolean)
This is a flag in a User ID's self-signature that states whether this
User ID is the main User ID for this key. It is reasonable for an
implementation to resolve ambiguities in preferences, etc. by
referring to the primary User ID. If this flag is absent, its value
is zero. If more than one User ID in a key is marked as primary, the
implementation may resolve the ambiguity in any way it sees fit, but
@@ -2413,1024 +2520,1064 @@ lookupPacketTag i = lookup i $ map swap packetTagCoding
#define CRC24_INIT 0xB704CEL
#define CRC24_POLY 0x1864CFBL
typedef long crc24;
crc24 crc_octets(unsigned char *octets, size_t len)
{
crc24 crc = CRC24_INIT;
int i;
while (len--) {
crc ^= (*octets++) << 16;
for (i = 0; i < 8; i++) {
crc <<= 1;
if (crc & 0x1000000)
crc ^= CRC24_POLY;
}
}
return crc & 0xFFFFFFL;
}
\begin{code}
crc24_poly :: Word32
crc24_poly = 0x864cfb
crc24_init :: Word32
crc24_init = 0xb704cde
crc24 :: B.ByteString -> Word32
crc24 bs = let crc24' c w = 0xffffff `xor` (cycle $ c `xor` ((convert w) `shiftL` 16))
cycle :: Word32 -> Word32
cycle c = foldl (\c' _ -> let cs = (c' `shiftL` 1)
in if ((cs .&. 0x1000000) /= 0)
then cs `xor` crc24_poly else cs ) c [0..7]
in B.foldl crc24' crc24_init bs
\end{code}
6.2. Forming ASCII Armor
When OpenPGP encodes data into ASCII Armor, it puts specific headers
around the Radix-64 encoded data, so OpenPGP can reconstruct the data
later. An OpenPGP implementation MAY use ASCII armor to protect raw
binary data. OpenPGP informs the user what kind of data is encoded
in the ASCII armor through the use of the headers.
Concatenating the following data creates ASCII Armor:
- An Armor Header Line, appropriate for the type of data
- Armor Headers
- A blank (zero-length, or containing only whitespace) line
- The ASCII-Armored data
- An Armor Checksum
- The Armor Tail, which depends on the Armor Header Line
An Armor Header Line consists of the appropriate header line text
surrounded by five (5) dashes ('-', 0x2D) on either side of the
header line text. The header line text is chosen based upon the type
of data that is being encoded in Armor, and how it is being encoded.
Header line texts include the following strings:
BEGIN PGP MESSAGE
Used for signed, encrypted, or compressed files.
BEGIN PGP PUBLIC KEY BLOCK
Used for armoring public keys.
BEGIN PGP PRIVATE KEY BLOCK
Used for armoring private keys.
BEGIN PGP MESSAGE, PART X/Y
Used for multi-part messages, where the armor is split amongst Y
parts, and this is the Xth part out of Y.
BEGIN PGP MESSAGE, PART X
Used for multi-part messages, where this is the Xth part of an
unspecified number of parts. Requires the MESSAGE-ID Armor
Header to be used.
BEGIN PGP SIGNATURE
Used for detached signatures, OpenPGP/MIME signatures, and
cleartext signatures. Note that PGP 2.x uses BEGIN PGP MESSAGE
for detached signatures.
Note that all these Armor Header Lines are to consist of a complete
line. That is to say, there is always a line ending preceding the
starting five dashes, and following the ending five dashes. The
header lines, therefore, MUST start at the beginning of a line, and
MUST NOT have text other than whitespace following them on the same
line. These line endings are considered a part of the Armor Header
Line for the purposes of determining the content they delimit. This
is particularly important when computing a cleartext signature (see
below).
The Armor Headers are pairs of strings that can give the user or the
receiving OpenPGP implementation some information about how to decode
or use the message. The Armor Headers are a part of the armor, not a
part of the message, and hence are not protected by any signatures
applied to the message.
The format of an Armor Header is that of a key-value pair. A colon
(':' 0x38) and a single space (0x20) separate the key and value.
OpenPGP should consider improperly formatted Armor Headers to be
corruption of the ASCII Armor. Unknown keys should be reported to
the user, but OpenPGP should continue to process the message.
Note that some transport methods are sensitive to line length. While
there is a limit of 76 characters for the Radix-64 data (Section
6.3), there is no limit to the length of Armor Headers. Care should
be taken that the Armor Headers are short enough to survive
transport. One way to do this is to repeat an Armor Header key
multiple times with different values for each so that no one line is
overly long.
Currently defined Armor Header Keys are as follows:
- "Version", which states the OpenPGP implementation and version
used to encode the message.
- "Comment", a user-defined comment. OpenPGP defines all text to
be in UTF-8. A comment may be any UTF-8 string. However, the
whole point of armoring is to provide seven-bit-clean data.
Consequently, if a comment has characters that are outside the
US-ASCII range of UTF, they may very well not survive transport.
- "MessageID", a 32-character string of printable characters. The
string must be the same for all parts of a multi-part message
that uses the "PART X" Armor Header. MessageID strings should be
unique enough that the recipient of the mail can associate all
the parts of a message with each other. A good checksum or
cryptographic hash function is sufficient.
The MessageID SHOULD NOT appear unless it is in a multi-part
message. If it appears at all, it MUST be computed from the
finished (encrypted, signed, etc.) message in a deterministic
fashion, rather than contain a purely random value. This is to
allow the legitimate recipient to determine that the MessageID
cannot serve as a covert means of leaking cryptographic key
information.
- "Hash", a comma-separated list of hash algorithms used in this
message. This is used only in cleartext signed messages.
- "Charset", a description of the character set that the plaintext
is in. Please note that OpenPGP defines text to be in UTF-8. An
implementation will get best results by translating into and out
of UTF-8. However, there are many instances where this is easier
said than done. Also, there are communities of users who have no
need for UTF-8 because they are all happy with a character set
like ISO Latin-5 or a Japanese character set. In such instances,
an implementation MAY override the UTF-8 default by using this
header key. An implementation MAY implement this key and any
translations it cares to; an implementation MAY ignore it and
assume all text is UTF-8.
The Armor Tail Line is composed in the same manner as the Armor
Header Line, except the string "BEGIN" is replaced by the string
"END".
6.3. Encoding Binary in Radix-64
The encoding process represents 24-bit groups of input bits as output
strings of 4 encoded characters. Proceeding from left to right, a
24-bit input group is formed by concatenating three 8-bit input
groups. These 24 bits are then treated as four concatenated 6-bit
groups, each of which is translated into a single digit in the
Radix-64 alphabet. When encoding a bit stream with the Radix-64
encoding, the bit stream must be presumed to be ordered with the most
significant bit first. That is, the first bit in the stream will be
the high-order bit in the first 8-bit octet, and the eighth bit will
be the low-order bit in the first 8-bit octet, and so on.
+--first octet--+-second octet--+--third octet--+
|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
+-----------+---+-------+-------+---+-----------+
|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|
+--1.index--+--2.index--+--3.index--+--4.index--+
Each 6-bit group is used as an index into an array of 64 printable
characters from the table below. The character referenced by the
index is placed in the output string.
Value Encoding Value Encoding Value Encoding Value Encoding
0 A 17 R 34 i 51 z
1 B 18 S 35 j 52 0
2 C 19 T 36 k 53 1
3 D 20 U 37 l 54 2
4 E 21 V 38 m 55 3
5 F 22 W 39 n 56 4
6 G 23 X 40 o 57 5
7 H 24 Y 41 p 58 6
8 I 25 Z 42 q 59 7
9 J 26 a 43 r 60 8
10 K 27 b 44 s 61 9
11 L 28 c 45 t 62 +
12 M 29 d 46 u 63 /
13 N 30 e 47 v
14 O 31 f 48 w (pad) =
15 P 32 g 49 x
16 Q 33 h 50 y
The encoded output stream must be represented in lines of no more
than 76 characters each.
Special processing is performed if fewer than 24 bits are available
at the end of the data being encoded. There are three possibilities:
1. The last data group has 24 bits (3 octets). No special processing
is needed.
2. The last data group has 16 bits (2 octets). The first two 6-bit
groups are processed as above. The third (incomplete) data group
has two zero-value bits added to it, and is processed as above. A
pad character (=) is added to the output.
3. The last data group has 8 bits (1 octet). The first 6-bit group
is processed as above. The second (incomplete) data group has
four zero-value bits added to it, and is processed as above. Two
pad characters (=) are added to the output.
6.4. Decoding Radix-64
In Radix-64 data, characters other than those in the table, line
breaks, and other white space probably indicate a transmission error,
about which a warning message or even a message rejection might be
appropriate under some circumstances. Decoding software must ignore
all white space.
Because it is used only for padding at the end of the data, the
occurrence of any "=" characters may be taken as evidence that the
end of the data has been reached (without truncation in transit). No
such assurance is possible, however, when the number of octets
transmitted was a multiple of three and no "=" characters are
present.
6.5. Examples of Radix-64
Input data: 0x14FB9C03D97E
Hex: 1 4 F B 9 C | 0 3 D 9 7 E
8-bit: 00010100 11111011 10011100 | 00000011 11011001 11111110
6-bit: 000101 001111 101110 011100 | 000000 111101 100111 111110
Decimal: 5 15 46 28 0 61 37 62
Output: F P u c A 9 l +
Input data: 0x14FB9C03D9
Hex: 1 4 F B 9 C | 0 3 D 9
8-bit: 00010100 11111011 10011100 | 00000011 11011001
pad with 00
6-bit: 000101 001111 101110 011100 | 000000 111101 100100
Decimal: 5 15 46 28 0 61 36
pad with =
Output: F P u c A 9 k =
Input data: 0x14FB9C03
Hex: 1 4 F B 9 C | 0 3
8-bit: 00010100 11111011 10011100 | 00000011
pad with 0000
6-bit: 000101 001111 101110 011100 | 000000 110000
Decimal: 5 15 46 28 0 48
pad with = =
Output: F P u c A w = =
6.6. Example of an ASCII Armored Message
-----BEGIN PGP MESSAGE-----
Version: OpenPrivacy 0.99
yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
vBSFjNSiVHsuAA==
=njUN
-----END PGP MESSAGE-----
Note that this example has extra indenting; an actual armored message
would have no leading whitespace.
7. Cleartext Signature Framework
It is desirable to be able to sign a textual octet stream without
ASCII armoring the stream itself, so the signed text is still
readable without special software. In order to bind a signature to
such a cleartext, this framework is used. (Note that this framework
is not intended to be reversible. RFC 3156 [RFC3156] defines another
way to sign cleartext messages for environments that support MIME.)
The cleartext signed message consists of:
- The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a
single line,
- One or more "Hash" Armor Headers,
- Exactly one empty line not included into the message digest,
- The dash-escaped cleartext that is included into the message
digest,
- The ASCII armored signature(s) including the '-----BEGIN PGP
SIGNATURE-----' Armor Header and Armor Tail Lines.
If the "Hash" Armor Header is given, the specified message digest
algorithm(s) are used for the signature. If there are no such
headers, MD5 is used. If MD5 is the only hash used, then an
implementation MAY omit this header for improved V2.x compatibility.
If more than one message digest is used in the signature, the "Hash"
armor header contains a comma-delimited list of used message digests.
Current message digest names are described below with the algorithm
IDs.
An implementation SHOULD add a line break after the cleartext, but
MAY omit it if the cleartext ends with a line break. This is for
visual clarity.
7.1. Dash-Escaped Text
The cleartext content of the message must also be dash-escaped.
Dash-escaped cleartext is the ordinary cleartext where every line
starting with a dash '-' (0x2D) is prefixed by the sequence dash '-'
(0x2D) and space ' ' (0x20). This prevents the parser from
recognizing armor headers of the cleartext itself. An implementation
MAY dash-escape any line, SHOULD dash-escape lines commencing "From"
followed by a space, and MUST dash-escape any line commencing in a
dash. The message digest is computed using the cleartext itself, not
the dash-escaped form.
As with binary signatures on text documents, a cleartext signature is
calculated on the text using canonical <CR><LF> line endings. The
line ending (i.e., the <CR><LF>) before the '-----BEGIN PGP
SIGNATURE-----' line that terminates the signed text is not
considered part of the signed text.
When reversing dash-escaping, an implementation MUST strip the string
"- " if it occurs at the beginning of a line, and SHOULD warn on "-"
and any character other than a space at the beginning of a line.
Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at
the end of any line is removed when the cleartext signature is
generated.
8. Regular Expressions
A regular expression is zero or more branches, separated by '|'. It
matches anything that matches one of the branches.
A branch is zero or more pieces, concatenated. It matches a match
for the first, followed by a match for the second, etc.
A piece is an atom possibly followed by '*', '+', or '?'. An atom
followed by '*' matches a sequence of 0 or more matches of the atom.
An atom followed by '+' matches a sequence of 1 or more matches of
the atom. An atom followed by '?' matches a match of the atom, or
the null string.
An atom is a regular expression in parentheses (matching a match for
the regular expression), a range (see below), '.' (matching any
single character), '^' (matching the null string at the beginning of
the input string), '$' (matching the null string at the end of the
input string), a '\' followed by a single character (matching that
character), or a single character with no other significance
(matching that character).
A range is a sequence of characters enclosed in '[]'. It normally
matches any single character from the sequence. If the sequence
begins with '^', it matches any single character not from the rest of
the sequence. If two characters in the sequence are separated
by '-', this is shorthand for the full list of ASCII characters
between them (e.g., '[0-9]' matches any decimal digit). To include a
literal ']' in the sequence, make it the first character (following a
possible '^'). To include a literal '-', make it the first or last
character.
9. Constants
This section describes the constants used in OpenPGP.
Note that these tables are not exhaustive lists; an implementation
MAY implement an algorithm not on these lists, so long as the
algorithm numbers are chosen from the private or experimental
algorithm range.
See the section "Notes on Algorithms" below for more discussion of
the algorithms.
9.1. Public-Key Algorithms
ID Algorithm
-- ---------
1 - RSA (Encrypt or Sign) [HAC]
2 - RSA Encrypt-Only [HAC]
3 - RSA Sign-Only [HAC]
16 - Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
17 - DSA (Digital Signature Algorithm) [FIPS186] [HAC]
18 - Reserved for Elliptic Curve
19 - Reserved for ECDSA
20 - Reserved (formerly Elgamal Encrypt or Sign)
21 - Reserved for Diffie-Hellman (X9.42,
as defined for IETF-S/MIME)
100 to 110 - Private/Experimental algorithm
Implementations MUST implement DSA for signatures, and Elgamal for
encryption. Implementations SHOULD implement RSA keys (1). RSA
Encrypt-Only (2) and RSA Sign-Only are deprecated and SHOULD NOT be
generated, but may be interpreted. See Section 13.5. See Section
13.8 for notes on Elliptic Curve (18), ECDSA (19), Elgamal Encrypt or
Sign (20), and X9.42 (21). Implementations MAY implement any other
algorithm.
\begin{code}
data PublicKeyAlgorithm =
RSAEncryptOrSign |
RSAEncryptOnly |
RSASignOnly |
ElgamalEncryptOnly |
DSA
deriving (Show, Read, Eq, Enum)
publicKeyAlgorithmCoding = [
(RSAEncryptOrSign, 1),
(RSAEncryptOnly, 2),
(RSASignOnly, 3),
(ElgamalEncryptOnly, 16),
(DSA, 17)
]
lookupPublicKeyAlgorithm :: Word8 -> Maybe PublicKeyAlgorithm
lookupPublicKeyAlgorithm i = lookup i $ map swap publicKeyAlgorithmCoding
publicKeyAlgorithmToNum :: PublicKeyAlgorithm -> Maybe Word8
publicKeyAlgorithmToNum p = lookup p publicKeyAlgorithmCoding
parsePublicKeyAlgorithm :: Parser PublicKeyAlgorithm
parsePublicKeyAlgorithm = do
w <- A.anyWord8
case (lookupPublicKeyAlgorithm w) of
Nothing -> fail "unknown public key algorithm"
Just a -> return a
\end{code}
9.2. Symmetric-Key Algorithms
ID Algorithm
-- ---------
0 - Plaintext or unencrypted data
1 - IDEA [IDEA]
2 - TripleDES (DES-EDE, [SCHNEIER] [HAC] -
168 bit key derived from 192)
3 - CAST5 (128 bit key, as per [RFC2144])
4 - Blowfish (128 bit key, 16 rounds) [BLOWFISH]
5 - Reserved
6 - Reserved
7 - AES with 128-bit key [AES]
8 - AES with 192-bit key
9 - AES with 256-bit key
10 - Twofish with 256-bit key [TWOFISH]
100 to 110 - Private/Experimental algorithm
Implementations MUST implement TripleDES. Implementations SHOULD
implement AES-128 and CAST5. Implementations that interoperate with
PGP 2.6 or earlier need to support IDEA, as that is the only
symmetric cipher those versions use. Implementations MAY implement
any other algorithm.
9.3. Compression Algorithms
ID Algorithm
-- ---------
0 - Uncompressed
1 - ZIP [RFC1951]
2 - ZLIB [RFC1950]
3 - BZip2 [BZ2]
100 to 110 - Private/Experimental algorithm
Implementations MUST implement uncompressed data. Implementations
SHOULD implement ZIP. Implementations MAY implement any other
algorithm.
9.4. Hash Algorithms
ID Algorithm Text Name
-- --------- ---------
1 - MD5 [HAC] "MD5"
2 - SHA-1 [FIPS180] "SHA1"
3 - RIPE-MD/160 [HAC] "RIPEMD160"
4 - Reserved
5 - Reserved
6 - Reserved
7 - Reserved
8 - SHA256 [FIPS180] "SHA256"
9 - SHA384 [FIPS180] "SHA384"
10 - SHA512 [FIPS180] "SHA512"
11 - SHA224 [FIPS180] "SHA224"
100 to 110 - Private/Experimental algorithm
Implementations MUST implement SHA-1. Implementations MAY implement
other algorithms. MD5 is deprecated.
+\begin{code}
+data HashAlgorithm =
+ MD5 |
+ SHA1 |
+ RIPEMD160 |
+ SHA256 |
+ SHA384 |
+ SHA512 |
+ SHA224 |
+ PrivateHashAlgo Word8
+ deriving (Show, Read, Eq)
+
+hashAlgorithmCoding = [
+ (MD5, 1),
+ (SHA1, 2),
+ (RIPEMD160, 3),
+ (SHA256, 8),
+ (SHA384, 9),
+ (SHA512, 10),
+ (SHA224, 11)
+ ]
+
+lookupHashAlgorithm :: Word8 -> Maybe HashAlgorithm
+lookupHashAlgorithm h =
+ if ((h >= 100) && (h <= 100))
+ then Just $ PrivateHashAlgo h
+ else lookup h $ map swap hashAlgorithmCoding
+
+hashAlgorithmToNum :: HashAlgorithm -> Maybe Word8
+hashAlgorithmToNum (PrivateHashAlgo h) = Just h
+hashAlgorithmToNum h = lookup h hashAlgorithmCoding
+
+parseHashAlgorithm :: Parser HashAlgorithm
+parseHashAlgorithm = do
+ w <- A.anyWord8
+ case (lookupHashAlgorithm w) of
+ Just a -> return a
+ Nothing -> fail $ "unknown hash algorithm " ++ show w
+\end{code}
+
10. IANA Considerations
OpenPGP is highly parameterized, and consequently there are a number
of considerations for allocating parameters for extensions. This
section describes how IANA should look at extensions to the protocol
as described in this document.
10.1. New String-to-Key Specifier Types
OpenPGP S2K specifiers contain a mechanism for new algorithms to turn
a string into a key. This specification creates a registry of S2K
specifier types. The registry includes the S2K type, the name of the
S2K, and a reference to the defining specification. The initial
values for this registry can be found in Section 3.7.1. Adding a new
S2K specifier MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.2. New Packets
Major new features of OpenPGP are defined through new packet types.
This specification creates a registry of packet types. The registry
includes the packet type, the name of the packet, and a reference to
the defining specification. The initial values for this registry can
be found in Section 4.3. Adding a new packet type MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.2.1. User Attribute Types
The User Attribute packet permits an extensible mechanism for other
types of certificate identification. This specification creates a
registry of User Attribute types. The registry includes the User
Attribute type, the name of the User Attribute, and a reference to
the defining specification. The initial values for this registry can
be found in Section 5.12. Adding a new User Attribute type MUST be
done through the IETF CONSENSUS method, as described in [RFC2434].
10.2.1.1. Image Format Subpacket Types
Within User Attribute packets, there is an extensible mechanism for
other types of image-based user attributes. This specification
creates a registry of Image Attribute subpacket types. The registry
includes the Image Attribute subpacket type, the name of the Image
Attribute subpacket, and a reference to the defining specification.
The initial values for this registry can be found in Section 5.12.1.
Adding a new Image Attribute subpacket type MUST be done through the
IETF CONSENSUS method, as described in [RFC2434].
10.2.2. New Signature Subpackets
OpenPGP signatures contain a mechanism for signed (or unsigned) data
to be added to them for a variety of purposes in the Signature
subpackets as discussed in Section 5.2.3.1. This specification
creates a registry of Signature subpacket types. The registry
includes the Signature subpacket type, the name of the subpacket, and
this registry can be found in Section 5.2.3.1. Adding a new
Signature subpacket MUST be done through the IETF CONSENSUS method,
as described in [RFC2434].
10.2.2.1. Signature Notation Data Subpackets
OpenPGP signatures further contain a mechanism for extensions in
signatures. These are the Notation Data subpackets, which contain a
key/value pair. Notations contain a user space that is completely
unmanaged and an IETF space.
This specification creates a registry of Signature Notation Data
types. The registry includes the Signature Notation Data type, the
name of the Signature Notation Data, its allowed values, and a
reference to the defining specification. The initial values for this
registry can be found in Section 5.2.3.16. Adding a new Signature
Notation Data subpacket MUST be done through the EXPERT REVIEW
method, as described in [RFC2434].
10.2.2.2. Key Server Preference Extensions
OpenPGP signatures contain a mechanism for preferences to be
specified about key servers. This specification creates a registry
of key server preferences. The registry includes the key server
preference, the name of the preference, and a reference to the
defining specification. The initial values for this registry can be
found in Section 5.2.3.17. Adding a new key server preference MUST
be done through the IETF CONSENSUS method, as described in [RFC2434].
10.2.2.3. Key Flags Extensions
OpenPGP signatures contain a mechanism for flags to be specified
about key usage. This specification creates a registry of key usage
flags. The registry includes the key flags value, the name of the
flag, and a reference to the defining specification. The initial
values for this registry can be found in Section 5.2.3.21. Adding a
new key usage flag MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.2.2.4. Reason for Revocation Extensions
OpenPGP signatures contain a mechanism for flags to be specified
about why a key was revoked. This specification creates a registry
of "Reason for Revocation" flags. The registry includes the "Reason
for Revocation" flags value, the name of the flag, and a reference to
the defining specification. The initial values for this registry can
be found in Section 5.2.3.23. Adding a new feature flag MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.2.2.5. Implementation Features
OpenPGP signatures contain a mechanism for flags to be specified
stating which optional features an implementation supports. This
specification creates a registry of feature-implementation flags.
The registry includes the feature-implementation flags value, the
name of the flag, and a reference to the defining specification. The
initial values for this registry can be found in Section 5.2.3.24.
Adding a new feature-implementation flag MUST be done through the
IETF CONSENSUS method, as described in [RFC2434].
Also see Section 13.12 for more information about when feature flags
are needed.
10.2.3. New Packet Versions
The core OpenPGP packets all have version numbers, and can be revised
by introducing a new version of an existing packet. This
specification creates a registry of packet types. The registry
includes the packet type, the number of the version, and a reference
to the defining specification. The initial values for this registry
can be found in Section 5. Adding a new packet version MUST be done
through the IETF CONSENSUS method, as described in [RFC2434].
10.3. New Algorithms
Section 9 lists the core algorithms that OpenPGP uses. Adding in a
new algorithm is usually simple. For example, adding in a new
symmetric cipher usually would not need anything more than allocating
a constant for that cipher. If that cipher had other than a 64-bit
or 128-bit block size, there might need to be additional
documentation describing how OpenPGP-CFB mode would be adjusted.
Similarly, when DSA was expanded from a maximum of 1024-bit public
keys to 3072-bit public keys, the revision of FIPS 186 contained
enough information itself to allow implementation. Changes to this
document were made mainly for emphasis.
10.3.1. Public-Key Algorithms
OpenPGP specifies a number of public-key algorithms. This
specification creates a registry of public-key algorithm identifiers.
The registry includes the algorithm name, its key sizes and
parameters, and a reference to the defining specification. The
initial values for this registry can be found in Section 9. Adding a
new public-key algorithm MUST be done through the IETF CONSENSUS
method, as described in [RFC2434].
Callas, et al Standards Track [Page 66]
RFC 4880 OpenPGP Message Format November 2007
10.3.2. Symmetric-Key Algorithms
OpenPGP specifies a number of symmetric-key algorithms. This
specification creates a registry of symmetric-key algorithm
identifiers. The registry includes the algorithm name, its key sizes
and block size, and a reference to the defining specification. The
initial values for this registry can be found in Section 9. Adding a
new symmetric-key algorithm MUST be done through the IETF CONSENSUS
method, as described in [RFC2434].
10.3.3. Hash Algorithms
OpenPGP specifies a number of hash algorithms. This specification
creates a registry of hash algorithm identifiers. The registry
includes the algorithm name, a text representation of that name, its
block size, an OID hash prefix, and a reference to the defining
specification. The initial values for this registry can be found in
Section 9 for the algorithm identifiers and text names, and Section
5.2.2 for the OIDs and expanded signature prefixes. Adding a new
hash algorithm MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
10.3.4. Compression Algorithms
OpenPGP specifies a number of compression algorithms. This
specification creates a registry of compression algorithm
identifiers. The registry includes the algorithm name and a
reference to the defining specification. The initial values for this
registry can be found in Section 9.3. Adding a new compression key
algorithm MUST be done through the IETF CONSENSUS method, as
described in [RFC2434].
11. Packet Composition
OpenPGP packets are assembled into sequences in order to create
messages and to transfer keys. Not all possible packet sequences are
meaningful and correct. This section describes the rules for how
packets should be placed into sequences.
11.1. Transferable Public Keys
OpenPGP users may transfer public keys. The essential elements of a
transferable public key are as follows:
- One Public-Key packet
- Zero or more revocation signatures
- One or more User ID packets
- After each User ID packet, zero or more Signature packets
(certifications)
- Zero or more User Attribute packets
- After each User Attribute packet, zero or more Signature packets
(certifications)
- Zero or more Subkey packets
- After each Subkey packet, one Signature packet, plus optionally a
revocation
The Public-Key packet occurs first. Each of the following User ID
packets provides the identity of the owner of this public key. If
there are multiple User ID packets, this corresponds to multiple
means of identifying the same unique individual user; for example, a
user may have more than one email address, and construct a User ID
for each one.
Immediately following each User ID packet, there are zero or more
Signature packets. Each Signature packet is calculated on the
immediately preceding User ID packet and the initial Public-Key
packet. The signature serves to certify the corresponding public key
and User ID. In effect, the signer is testifying to his or her
belief that this public key belongs to the user identified by this
User ID.
Within the same section as the User ID packets, there are zero or
more User Attribute packets. Like the User ID packets, a User
Attribute packet is followed by zero or more Signature packets
calculated on the immediately preceding User Attribute packet and the
initial Public-Key packet.
User Attribute packets and User ID packets may be freely intermixed
in this section, so long as the signatures that follow them are
maintained on the proper User Attribute or User ID packet.
After the User ID packet or Attribute packet, there may be zero or
more Subkey packets. In general, subkeys are provided in cases where
the top-level public key is a signature-only key. However, any V4
key may have subkeys, and the subkeys may be encryption-only keys,
signature-only keys, or general-purpose keys. V3 keys MUST NOT have
subkeys.
Each Subkey packet MUST be followed by one Signature packet, which
should be a subkey binding signature issued by the top-level key.
For subkeys that can issue signatures, the subkey binding signature
MUST contain an Embedded Signature subpacket with a primary key
binding signature (0x19) issued by the subkey on the top-level key.
Subkey and Key packets may each be followed by a revocation Signature
packet to indicate that the key is revoked. Revocation signatures
are only accepted if they are issued by the key itself, or by a key
that is authorized to issue revocations via a Revocation Key
subpacket in a self-signature by the top-level key.
Transferable public-key packet sequences may be concatenated to allow
transferring multiple public keys in one operation.
11.2. Transferable Secret Keys
OpenPGP users may transfer secret keys. The format of a transferable
secret key is the same as a transferable public key except that
secret-key and secret-subkey packets are used instead of the public
key and public-subkey packets. Implementations SHOULD include self-
signatures on any user IDs and subkeys, as this allows for a complete
public key to be automatically extracted from the transferable secret
key. Implementations MAY choose to omit the self-signatures,
especially if a transferable public key accompanies the transferable
secret key.
11.3. OpenPGP Messages
An OpenPGP message is a packet or sequence of packets that
corresponds to the following grammatical rules (comma represents
sequential composition, and vertical bar separates alternatives):
OpenPGP Message :- Encrypted Message | Signed Message |
Compressed Message | Literal Message.
Compressed Message :- Compressed Data Packet.
Literal Message :- Literal Data Packet.
ESK :- Public-Key Encrypted Session Key Packet |
Symmetric-Key Encrypted Session Key Packet.
ESK Sequence :- ESK | ESK Sequence, ESK.
Encrypted Data :- Symmetrically Encrypted Data Packet |
Symmetrically Encrypted Integrity Protected Data Packet
Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data.
One-Pass Signed Message :- One-Pass Signature Packet,
OpenPGP Message, Corresponding Signature Packet.
Signed Message :- Signature Packet, OpenPGP Message |
One-Pass Signed Message.
In addition, decrypting a Symmetrically Encrypted Data packet or a
Symmetrically Encrypted Integrity Protected Data packet as well as
decompressing a Compressed Data packet must yield a valid OpenPGP
Message.
11.4. Detached Signatures
Some OpenPGP applications use so-called "detached signatures". For
example, a program bundle may contain a file, and with it a second
file that is a detached signature of the first file. These detached
signatures are simply a Signature packet stored separately from the
data for which they are a signature.
12. Enhanced Key Formats
12.1. Key Structures
The format of an OpenPGP V3 key is as follows. Entries in square
brackets are optional and ellipses indicate repetition.
RSA Public Key
[Revocation Self Signature]
User ID [Signature ...]
[User ID [Signature ...] ...]
Each signature certifies the RSA public key and the preceding User
ID. The RSA public key can have many User IDs and each User ID can
have many signatures. V3 keys are deprecated. Implementations MUST
NOT generate new V3 keys, but MAY continue to use existing ones.
The format of an OpenPGP V4 key that uses multiple public keys is
similar except that the other keys are added to the end as "subkeys"
of the primary key.
Primary-Key
[Revocation Self Signature]
[Direct Key Signature...]
User ID [Signature ...]
[User ID [Signature ...] ...]
[User Attribute [Signature ...] ...]
[[Subkey [Binding-Signature-Revocation]
Primary-Key-Binding-Signature] ...]
A subkey always has a single signature after it that is issued using
the primary key to tie the two keys together. This binding signature
may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can
issue signatures MUST have a V4 binding signature due to the REQUIRED
embedded primary key binding signature.
In the above diagram, if the binding signature of a subkey has been
revoked, the revoked key may be removed, leaving only one key.
In a V4 key, the primary key MUST be a key capable of certification.
The subkeys may be keys of any other type. There may be other
constructions of V4 keys, too. For example, there may be a single-
key RSA key in V4 format, a DSA primary key with an RSA encryption
key, or RSA primary key with an Elgamal subkey, etc.
It is also possible to have a signature-only subkey. This permits a
primary key that collects certifications (key signatures), but is
used only for certifying subkeys that are used for encryption and
signatures.
12.2. Key IDs and Fingerprints
For a V3 key, the eight-octet Key ID consists of the low 64 bits of
the public modulus of the RSA key.
The fingerprint of a V3 key is formed by hashing the body (but not
the two-octet length) of the MPIs that form the key material (public
modulus n, followed by exponent e) with MD5. Note that both V3 keys
and MD5 are deprecated.
A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99,
followed by the two-octet packet length, followed by the entire
Public-Key packet starting with the version field. The Key ID is the
low-order 64 bits of the fingerprint. Here are the fields of the
hash material, with the example of a DSA key:
a.1) 0x99 (1 octet)
a.2) high-order length octet of (b)-(e) (1 octet)
a.3) low-order length octet of (b)-(e) (1 octet)
b) version number = 4 (1 octet);
c) timestamp of key creation (4 octets);
d) algorithm (1 octet): 17 = DSA (example);
e) Algorithm-specific fields.
Algorithm-Specific Fields for DSA keys (example):
e.1) MPI of DSA prime p;
e.2) MPI of DSA group order q (q is a prime divisor of p-1);
e.3) MPI of DSA group generator g;
e.4) MPI of DSA public-key value y (= g**x mod p where x is secret).
Note that it is possible for there to be collisions of Key IDs -- two
different keys with the same Key ID. Note that there is a much
smaller, but still non-zero, probability that two different keys have
the same fingerprint.
Also note that if V3 and V4 format keys share the same RSA key
material, they will have different Key IDs as well as different
fingerprints.
Finally, the Key ID and fingerprint of a subkey are calculated in the
same way as for a primary key, including the 0x99 as the first octet
(even though this is not a valid packet ID for a public subkey).
13. Notes on Algorithms
13.1. PKCS#1 Encoding in OpenPGP
This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and
EMSA-PKCS1-v1_5. However, the calling conventions of these functions
has changed in the past. To avoid potential confusion and
interoperability problems, we are including local copies in this
document, adapted from those in PKCS#1 v2.1 [RFC3447]. RFC 3447
should be treated as the ultimate authority on PKCS#1 for OpenPGP.
Nonetheless, we believe that there is value in having a self-
contained document that avoids problems in the future with needed
changes in the conventions.
13.1.1. EME-PKCS1-v1_5-ENCODE
Input:
k = the length in octets of the key modulus
M = message to be encoded, an octet string of length mLen, where
mLen <= k - 11
Output:
EM = encoded message, an octet string of length k
Error: "message too long"
1. Length checking: If mLen > k - 11, output "message too long" and
stop.
2. Generate an octet string PS of length k - mLen - 3 consisting of
pseudo-randomly generated nonzero octets. The length of PS will
be at least eight octets.
3. Concatenate PS, the message M, and other padding to form an
encoded message EM of length k octets as
EM = 0x00 || 0x02 || PS || 0x00 || M.
4. Output EM.
13.1.2. EME-PKCS1-v1_5-DECODE
Input:
EM = encoded message, an octet string
Output:
M = message, an octet string
Error: "decryption error"
|
alios/lab
|
2bdc295517df9c668eea9d8ac0d9f04147001cd3
|
added OpenPGP module
|
diff --git a/OpenPGP.lhs b/OpenPGP.lhs
new file mode 100644
index 0000000..80644f0
--- /dev/null
+++ b/OpenPGP.lhs
@@ -0,0 +1,343 @@
+
+\begin{code}
+module OpenPGP where
+import Data.Binary
+import Data.Bits
+import Data.Word
+import Data.Tuple
+import Data.ByteString.Lazy (ByteString)
+import qualified Data.ByteString.Lazy as B
+
+\end{code}
+
+3.2. Multiprecision Integers
+
+ Multiprecision integers (also called MPIs) are unsigned integers used
+ to hold large integers such as the ones used in cryptographic
+ calculations.
+
+ An MPI consists of two pieces: a two-octet scalar that is the length
+ of the MPI in bits followed by a string of octets that contain the
+ actual integer.
+
+\begin{code}
+newtype MPI = MPI (Word16, ByteString)
+ deriving (Show, Eq)
+
+\end{code}
+
+ These octets form a big-endian number; a big-endian number can be
+ made into an MPI by prefixing it with the appropriate length.
+
+ Examples:
+
+ (all numbers are in hexadecimal)
+
+ The string of octets [00 01 01] forms an MPI with the value 1. The
+ string [00 09 01 FF] forms an MPI with the value of 511.
+
+ Additional rules:
+
+ The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
+
+ The length field of an MPI describes the length starting from its
+ most significant non-zero bit. Thus, the MPI [00 02 01] is not
+ formed correctly. It should be [00 01 01].
+
+ Unused bits of an MPI MUST be zero.
+
+ Also note that when an MPI is encrypted, the length refers to the
+ plaintext MPI. It may be ill-formed in its ciphertext.
+
+\begin{code}
+toMPI :: Integer -> MPI
+toMPI i =
+ let x = encode i
+ l' = B.length x
+ maxL = 65535
+ l = if (l' * 8 <= maxL) then
+ 8 * ((fromInteger.toInteger) l')
+ else
+ error $ show i ++ " has " ++ show (l' * 8) ++ " bits but only " ++ show maxL ++ " are allowed"
+ in MPI (l, x)
+
+fromMPI :: MPI -> Integer
+fromMPI (MPI (l, bs')) =
+ let bs = B.take ((fromInteger.toInteger) l) bs'
+ in decode bs
+
+
+prop_mpiA i = i == (fromMPI.toMPI) i
+\end{code}
+
+3.3. Key IDs
+
+ A Key ID is an eight-octet scalar that identifies a key.
+ Implementations SHOULD NOT assume that Key IDs are unique. The
+ section "Enhanced Key Formats" below describes how Key IDs are
+ formed.
+
+
+\begin{code}
+type KeyID = Word64
+\end{code}
+
+3.4. Text
+ Unless otherwise specified, the character set for text is the UTF-8
+ [RFC3629] encoding of Unicode [ISO10646].
+
+
+3.5. Time Fields
+
+ A time field is an unsigned four-octet number containing the number
+ of seconds elapsed since midnight, 1 January 1970 UTC.
+
+3.6. Keyrings
+
+ A keyring is a collection of one or more keys in a file or database.
+ Traditionally, a keyring is simply a sequential list of keys, but may
+ be any suitable database. It is beyond the scope of this standard to
+ discuss the details of keyrings or other databases.
+
+
+3.7. String-to-Key (S2K) Specifiers
+
+ String-to-key (S2K) specifiers are used to convert passphrase strings
+ into symmetric-key encryption/decryption keys. They are used in two
+ places, currently: to encrypt the secret part of private keys in the
+ private keyring, and to convert passphrases to encryption keys for
+ symmetrically encrypted messages.
+
+3.7.1. String-to-Key (S2K) Specifier Types
+
+ There are three types of S2K specifiers currently supported, and
+ some reserved values:
+
+ ID S2K Type
+ -- --------
+ 0 Simple S2K
+ 1 Salted S2K
+ 2 Reserved value
+ 3 Iterated and Salted S2K
+ 100 to 110 Private/Experimental S2K
+
+ These are described in Sections 3.7.1.1 - 3.7.1.3.
+
+\begin{code}
+data S2KSpecifierType = SimpleS2K | SaltedS2K | ReservedS2K | IteratedAndSaltedS2K
+ deriving (Read, Show, Enum, Eq)
+\end{code}
+
+4.2. Packet Headers
+
+ The first octet of the packet header is called the "Packet Tag". It
+ determines the format of the header and denotes the packet contents.
+ The remainder of the packet header is the length of the packet.
+
+ Note that the most significant bit is the leftmost bit, called bit 7.
+ A mask for this bit is 0x80 in hexadecimal.
+
+ +---------------+
+ PTag |7 6 5 4 3 2 1 0|
+ +---------------+
+ Bit 7 -- Always one
+ Bit 6 -- New packet format if set
+
+ PGP 2.6.x only uses old format packets. Thus, software that
+ interoperates with those versions of PGP must only use old format
+ packets. If interoperability is not an issue, the new packet format
+ is RECOMMENDED. Note that old format packets have four bits of
+ packet tags, and new format packets have six; some features cannot be
+ used and still be backward-compatible.
+
+ Also note that packets with a tag greater than or equal to 16 MUST
+ use new format packets. The old format packets can only express tags
+ less than or equal to 15.
+
+ Old format packets contain:
+
+ Bits 5-2 -- packet tag
+ Bits 1-0 -- length-type
+
+ New format packets contain:
+
+ Bits 5-0 -- packet tag
+
+\begin{code}
+
+data PacketHeader =
+ NewPacketHeader PacketTag |
+ OldPacketHeader PacketTag PacketLength
+
+instance Binary PacketHeader where
+ put (NewPacketHeader t) =
+ case (packetTagToNum t) of
+ Nothing -> fail $ "unable to lookup tag " ++ show t
+ Just p -> putWord8 $ (p `setBit` 6) `setBit` 7
+
+ put (OldPacketHeader t l) =
+ if (not $ isValidOldTag t) then
+ fail $ "packet is old packet but has invalid tag: " ++ show t
+ else
+ case (packetTagToNum t) of
+ Nothing -> fail $ "unable to lookup tag " ++ show t
+ Just p ->
+ case (packetLengthToNum l) of
+ Nothing -> fail $ ""
+ Just l' -> putWord8 $ ((p `shiftR` 2) .|. l' )`setBit` 7
+
+ get = do
+ w <- getWord8
+ if (not $ testBit w 7)
+ then fail "unable to parse packet header - bit 7 not set"
+ else if (testBit w 6)
+ then let t = w .&. 0x3F
+ in case (lookupPacketTag t) of
+ Nothing -> fail $ "unknown packet tag " ++ show t
+ Just t' -> return $ NewPacketHeader t'
+
+ else let t = (w `shiftL` 2) .&. 0x0F
+ l = w .&. 0x3;
+ in if (not $ isValidOldTagNum t) then
+ fail $ "invalid tag for old packet " ++ show t
+ else
+ case (lookupPacketTag t) of
+ Nothing -> fail $ "unknown packet tag " ++ show t
+ Just t'-> case (lookupPacketLength l) of
+ Nothing -> fail $ "unknown packet length " ++ show l
+ Just l' -> return $ OldPacketHeader t' l'
+
+\end{code}
+
+
+ 4.2.1. Old Format Packet Lengths
+
+ The meaning of the length-type in old format packets is:
+
+ 0 - The packet has a one-octet length. The header is 2 octets long.
+
+ 1 - The packet has a two-octet length. The header is 3 octets long.
+
+ 2 - The packet has a four-octet length. The header is 5 octets long.
+
+ 3 - The packet is of indeterminate length. The header is 1 octet
+ long, and the implementation must determine how long the packet
+ is. If the packet is in a file, this means that the packet
+ extends until the end of the file. In general, an implementation
+ SHOULD NOT use indeterminate-length packets except where the end
+ of the data will be clear from the context, and even then it is
+ better to use a definite length, or a new format header. The new
+ format headers described below have a mechanism for precisely
+ encoding data of indeterminate length.
+
+\begin{code}
+
+data PacketLength =
+ OneOctedLength |
+ TwoOctedLength |
+ FourOctedLength |
+ IndeterminateLength
+ deriving (Show, Read, Eq, Enum)
+
+packetLengthCoding = [
+ (OneOctedLength, 0),
+ (TwoOctedLength, 1),
+ (FourOctedLength, 2),
+ (IndeterminateLength, 3)
+ ]
+
+lookupPacketLength :: Word8 -> Maybe PacketLength
+lookupPacketLength i = lookup i $ map swap packetLengthCoding
+packetLengthToNum :: PacketLength -> Maybe Word8
+packetLengthToNum p = lookup p packetLengthCoding
+
+
+\end{code}
+
+ The packet tag denotes what type of packet the body holds. Note that
+ old format headers can only have tags less than 16, whereas new
+ format headers can have tags as great as 63. The defined tags (in
+ decimal) are as follows:
+
+ 0 -- Reserved - a packet tag MUST NOT have this value
+ 1 -- Public-Key Encrypted Session Key Packet
+ 2 -- Signature Packet
+ 3 -- Symmetric-Key Encrypted Session Key Packet
+ 4 -- One-Pass Signature Packet
+ 5 -- Secret-Key Packet
+ 6 -- Public-Key Packet
+ 7 -- Secret-Subkey Packet
+ 8 -- Compressed Data Packet
+ 9 -- Symmetrically Encrypted Data Packet
+ 10 -- Marker Packet
+ 11 -- Literal Data Packet
+ 12 -- Trust Packet
+ 13 -- User ID Packet
+ 14 -- Public-Subkey Packet
+ 17 -- User Attribute Packet
+ 18 -- Sym. Encrypted and Integrity Protected Data Packet
+ 19 -- Modification Detection Code Packet
+ 60 to 63 -- Private or Experimental Values
+
+\begin{code}
+data PacketTag =
+ PublicKeyEncryptedSessionKeyPacket |
+ SignaturePacket |
+ SymmetricKeyEncryptedSessionKeyPacket |
+ OnePassSignaturePacket |
+ SecretKeyPacket |
+ PublicKeyPacket |
+ SecretSubkeyPacket |
+ CompressedDataPacket |
+ SymmetricallyEncryptedPacket |
+ MarkerPacket |
+ LiteralDataPacket |
+ TrustPacket |
+ UserIDPacket |
+ PublicSubkeyPacket |
+ UserAttributePacket |
+ SymEncryptedAndIntegrityProtectedDataPacket |
+ ModificationDetectionCodePacket
+ deriving (Show, Read, Eq)
+
+packetTagCoding = [
+ (PublicKeyEncryptedSessionKeyPacket, 1),
+ (SignaturePacket, 2),
+ (SymmetricKeyEncryptedSessionKeyPacket, 3),
+ (OnePassSignaturePacket, 4),
+ (SecretKeyPacket, 5),
+ (PublicKeyPacket, 6),
+ (SecretSubkeyPacket, 7),
+ (CompressedDataPacket, 8),
+ (SymmetricallyEncryptedPacket, 9),
+ (MarkerPacket, 10),
+ (LiteralDataPacket, 11),
+ (TrustPacket, 12),
+ (UserIDPacket, 13),
+ (PublicSubkeyPacket, 14),
+ (UserAttributePacket, 17),
+ (SymEncryptedAndIntegrityProtectedDataPacket, 18),
+ (ModificationDetectionCodePacket, 19)
+ ]
+
+isValidOldTag :: PacketTag -> Bool
+isValidOldTag t = case (packetTagToNum t) of
+ Nothing -> False
+ Just t' -> t' < 16
+
+isValidOldTagNum :: Word8 -> Bool
+isValidOldTagNum i = case (lookupPacketTag i) of
+ Nothing -> False
+ Just _ -> (i > 0) && (i < 16)
+
+packetTagToNum :: PacketTag -> Maybe Word8
+packetTagToNum t = lookup t packetTagCoding
+lookupPacketTag :: Word8 -> Maybe PacketTag
+lookupPacketTag i = lookup i $ map swap packetTagCoding
+
+
+
+
+
+
+\end{code}
|
alios/lab
|
0bddccaec23ab8a9b3cb405cbaea73faa492dedc
|
some type system reorganization
|
diff --git a/MilSymb.lhs b/MilSymb.lhs
index 0aa25ee..d26bd3a 100644
--- a/MilSymb.lhs
+++ b/MilSymb.lhs
@@ -1,137 +1,166 @@
\begin{code}
-{-# LANGUAGE GADTs #-}
+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-}
+{-# LANGUAGE GADTs #-}
module MilSymb where
import Data.Text (Text)
\end{code}
\subsection{Composition of tactical symbols}
A fully displayed tactical symbol is composed of a \emph{frame}, \emph{fill}, and \empfh{icon}
and may include text and/or graphic modifiers that provide additional information (see figure 1).
The frame attributes (i.e., standard identity, battle dimension, and FRAME COLOR FILL
status) determine the type of frame for a given symbol. Fill color is a redundant indication of
ICON the symbolâs standard identity.
-\begin{code}
-class BattleDimensionClass d where
- aboveSurface :: d -> Bool
- ground :: d -> Bool
- surface :: d -> Bool
class (HasColor d, HasCharAbbrev d) => Descriptor d
class HasColor c where
color :: c -> Color
class HasCharAbbrev a where
charAbbrev :: a -> Char
class ModifierField f where
fieldId :: f -> Text
fieldTitle :: f -> Text
fieldDescription :: f -> Text
fieldApplications :: f -> [FieldApplication]
-data Symbol dim desc where
- Symbol :: (BattleDimensionClass dim) => dim -> desc -> Symbol dim desc
-
-data BattleDimension = UnknownDim
- | SpaceDim
- | AirDim
- | UnitsDim
- | EquipmentDim
- | InstallationsDim
- | SeaSurfaceDim
- | SubsurfaceDim
- | SOFDim
- deriving (Show, Read, Eq, Enum)
-
-data StdIdentity = PendingIdentity
- | UnknownIdentity
- | FriendIdentity
- | NeutralIdentity
- | HostileIdentity
- | AssumedFriendIdentity
- | SuspectIdentity
- deriving (Show, Read, Eq, Enum)
+\begin{code}
+
+class BattleDimension d
+
+data UnknownDim = UnkownDim
+data SpaceDim = SpaceDim
+data AirDim = AirDim
+data UnitsDim = UnitsDim
+data EquipmentDim = EquipmentDim
+data InstallationsDim = InstallationsDim
+data SeaSurfaceDim = SeaSurfaceDim
+data SubsurfaceDim = SubsurfaceDim
+data SOFDim = SOFDim
+
+data PendingIdentity
+data UnknownIdentity
+data FriendIdentity
+data NeutralIdentity
+data HostileIdentity
+data AssumedFriendIdentity
+data SuspectIdentity
-data ExerciseAmplifyingDescriptor = ExercisePending
- | ExerciseUnknown
- | ExerciseFriend
- | ExerciseNeutral
- | ExerciseAssumedFriend
- | Joker
- | Faker
- deriving (Show, Read, Eq, Enum)
+data ExercisePending
+data ExerciseUnknown
+data ExerciseFriend
+data ExerciseNeutral
+data ExerciseAssumedFriend
+data Joker
+data Faker
+
+class StandardIdentity i
+instance StandardIdentity PendingIdentity
+instance StandardIdentity UnknownIdentity
+instance StandardIdentity FriendIdentity
+instance StandardIdentity NeutralIdentity
+instance StandardIdentity HostileIdentity
+instance StandardIdentity AssumedFriendIdentity
+instance StandardIdentity SuspectIdentity
+
+class ExerciseAmplifyingDescriptor d
+instance ExerciseAmplifyingDescriptor ExercisePending
+instance ExerciseAmplifyingDescriptor ExerciseUnknown
+instance ExerciseAmplifyingDescriptor ExerciseFriend
+instance ExerciseAmplifyingDescriptor ExerciseNeutral
+instance ExerciseAmplifyingDescriptor ExerciseAssumedFriend
+instance ExerciseAmplifyingDescriptor Joker
+instance ExerciseAmplifyingDescriptor Faker
+
+class Descriptor d
+instance (StandardIdentity d) => Descriptor d
+
+data Symbol dim desc where
+ Symbol :: (BattleDimension dim, Descriptor desc) => dim -> desc -> [FieldApplication] -> Symbol dim desc
+
+class HasColor t where
+ color :: t -> Color
+
+instance HasColor PendingIdentity where color _ = Yellow
+instance HasColor UnknownIdentity where color _ = Yellow
+instance HasColor FriendIdentity where color _ = Cyan
+instance HasColor NeutralIdentity where color _ = Green
+instance HasColor HostileIdentity where color _ = Red
+instance HasColor AssumedFriendIdentity where color _ = Cyan
+instance HasColor SuspectIdentity where color _ = Red
+
+instance HasColor ExercisePending where color _ = Yellow
+instance HasColor ExerciseUnknown where color _ = Yellow
+instance HasColor ExerciseFriend where color _ = Cyan
+instance HasColor ExerciseNeutral where color _ = Green
+instance HasColor ExerciseAssumedFriend where color _ = Cyan
+instance HasColor Joker where color _ = Red
+instance HasColor Faker where color _ = Red
+
+instance (HasColor desc) => HasColor (Symbol dim desc) where
+ color (Symbol _ desc _) = color desc
data FieldApplication = GraphicModifier
| TextModifier Integer
| GraphicTextModifier Integer
data Color = Yellow
| Cyan
| Green
| Red
deriving (Show, Read, Eq, Enum)
+\end{code}
-instance BattleDimensionClass BattleDimension where
+instance (BattleDimension d) => BattleDimensionClass d where
aboveSurface d = d `elem` [SpaceDim, AirDim]
ground d = d `elem` [UnitsDim, EquipmentDim, InstallationsDim]
surface d = or [ d == SeaSurfaceDim , ground d ]
+
+
instance HasCharAbbrev BattleDimension where
charAbbrev UnknownDim = 'Z'
charAbbrev SpaceDim = 'P'
charAbbrev AirDim = 'A'
charAbbrev UnitsDim = 'G'
charAbbrev EquipmentDim = 'G'
charAbbrev InstallationsDim = 'G'
charAbbrev SeaSurfaceDim = 'S'
charAbbrev SubsurfaceDim = 'U'
charAbbrev SOFDim = 'F'
instance Descriptor StdIdentity
instance Descriptor ExerciseAmplifyingDescriptor
-instance HasColor StdIdentity where
- color PendingIdentity = Yellow
- color UnknownIdentity = Yellow
- color FriendIdentity = Cyan
- color NeutralIdentity = Green
- color HostileIdentity = Red
- color AssumedFriendIdentity = Cyan
- color SuspectIdentity = Red
-
-instance HasColor ExerciseAmplifyingDescriptor where
- color ExercisePending = Yellow
- color ExerciseUnknown = Yellow
- color ExerciseFriend = Cyan
- color ExerciseNeutral = Green
- color ExerciseAssumedFriend = Cyan
- color Joker = Red
- color Faker = Red
instance HasCharAbbrev StdIdentity where
charAbbrev PendingIdentity = 'P'
charAbbrev UnknownIdentity = 'U'
charAbbrev FriendIdentity = 'F'
charAbbrev NeutralIdentity = 'N'
charAbbrev HostileIdentity = 'H'
charAbbrev AssumedFriendIdentity = 'A'
charAbbrev SuspectIdentity = 'S'
instance HasCharAbbrev ExerciseAmplifyingDescriptor where
charAbbrev ExercisePending = 'G'
charAbbrev ExerciseUnknown = 'W'
charAbbrev ExerciseFriend = 'D'
charAbbrev ExerciseNeutral = 'L'
charAbbrev ExerciseAssumedFriend = 'M'
charAbbrev Joker = 'J'
charAbbrev Faker = 'K'
-\end{code}
+
+
+
+symbolDim = (1000, 710)
|
alios/lab
|
0fad9fb351428bd785d5ef2d36fc53c19f287959
|
added MilSymbol
|
diff --git a/MilSymb.lhs b/MilSymb.lhs
new file mode 100644
index 0000000..0aa25ee
--- /dev/null
+++ b/MilSymb.lhs
@@ -0,0 +1,137 @@
+
+\begin{code}
+{-# LANGUAGE GADTs #-}
+
+module MilSymb where
+
+import Data.Text (Text)
+\end{code}
+
+\subsection{Composition of tactical symbols}
+A fully displayed tactical symbol is composed of a \emph{frame}, \emph{fill}, and \empfh{icon}
+and may include text and/or graphic modifiers that provide additional information (see figure 1).
+The frame attributes (i.e., standard identity, battle dimension, and FRAME COLOR FILL
+status) determine the type of frame for a given symbol. Fill color is a redundant indication of
+ICON the symbolâs standard identity.
+
+
+\begin{code}
+
+class BattleDimensionClass d where
+ aboveSurface :: d -> Bool
+ ground :: d -> Bool
+ surface :: d -> Bool
+
+class (HasColor d, HasCharAbbrev d) => Descriptor d
+
+class HasColor c where
+ color :: c -> Color
+
+class HasCharAbbrev a where
+ charAbbrev :: a -> Char
+
+class ModifierField f where
+ fieldId :: f -> Text
+ fieldTitle :: f -> Text
+ fieldDescription :: f -> Text
+ fieldApplications :: f -> [FieldApplication]
+
+data Symbol dim desc where
+ Symbol :: (BattleDimensionClass dim) => dim -> desc -> Symbol dim desc
+
+data BattleDimension = UnknownDim
+ | SpaceDim
+ | AirDim
+ | UnitsDim
+ | EquipmentDim
+ | InstallationsDim
+ | SeaSurfaceDim
+ | SubsurfaceDim
+ | SOFDim
+ deriving (Show, Read, Eq, Enum)
+
+data StdIdentity = PendingIdentity
+ | UnknownIdentity
+ | FriendIdentity
+ | NeutralIdentity
+ | HostileIdentity
+ | AssumedFriendIdentity
+ | SuspectIdentity
+ deriving (Show, Read, Eq, Enum)
+
+data ExerciseAmplifyingDescriptor = ExercisePending
+ | ExerciseUnknown
+ | ExerciseFriend
+ | ExerciseNeutral
+ | ExerciseAssumedFriend
+ | Joker
+ | Faker
+ deriving (Show, Read, Eq, Enum)
+
+
+data FieldApplication = GraphicModifier
+ | TextModifier Integer
+ | GraphicTextModifier Integer
+
+data Color = Yellow
+ | Cyan
+ | Green
+ | Red
+ deriving (Show, Read, Eq, Enum)
+
+instance BattleDimensionClass BattleDimension where
+ aboveSurface d = d `elem` [SpaceDim, AirDim]
+ ground d = d `elem` [UnitsDim, EquipmentDim, InstallationsDim]
+ surface d = or [ d == SeaSurfaceDim , ground d ]
+
+instance HasCharAbbrev BattleDimension where
+ charAbbrev UnknownDim = 'Z'
+ charAbbrev SpaceDim = 'P'
+ charAbbrev AirDim = 'A'
+ charAbbrev UnitsDim = 'G'
+ charAbbrev EquipmentDim = 'G'
+ charAbbrev InstallationsDim = 'G'
+ charAbbrev SeaSurfaceDim = 'S'
+ charAbbrev SubsurfaceDim = 'U'
+ charAbbrev SOFDim = 'F'
+
+instance Descriptor StdIdentity
+instance Descriptor ExerciseAmplifyingDescriptor
+
+instance HasColor StdIdentity where
+ color PendingIdentity = Yellow
+ color UnknownIdentity = Yellow
+ color FriendIdentity = Cyan
+ color NeutralIdentity = Green
+ color HostileIdentity = Red
+ color AssumedFriendIdentity = Cyan
+ color SuspectIdentity = Red
+
+instance HasColor ExerciseAmplifyingDescriptor where
+ color ExercisePending = Yellow
+ color ExerciseUnknown = Yellow
+ color ExerciseFriend = Cyan
+ color ExerciseNeutral = Green
+ color ExerciseAssumedFriend = Cyan
+ color Joker = Red
+ color Faker = Red
+
+instance HasCharAbbrev StdIdentity where
+ charAbbrev PendingIdentity = 'P'
+ charAbbrev UnknownIdentity = 'U'
+ charAbbrev FriendIdentity = 'F'
+ charAbbrev NeutralIdentity = 'N'
+ charAbbrev HostileIdentity = 'H'
+ charAbbrev AssumedFriendIdentity = 'A'
+ charAbbrev SuspectIdentity = 'S'
+
+instance HasCharAbbrev ExerciseAmplifyingDescriptor where
+ charAbbrev ExercisePending = 'G'
+ charAbbrev ExerciseUnknown = 'W'
+ charAbbrev ExerciseFriend = 'D'
+ charAbbrev ExerciseNeutral = 'L'
+ charAbbrev ExerciseAssumedFriend = 'M'
+ charAbbrev Joker = 'J'
+ charAbbrev Faker = 'K'
+
+\end{code}
|
alios/lab
|
8810bfb6fe01f95ef24484bd802d8f2c115042e9
|
added GoogleTTS
|
diff --git a/GoogleTTS.hs b/GoogleTTS.hs
new file mode 100644
index 0000000..fea7665
--- /dev/null
+++ b/GoogleTTS.hs
@@ -0,0 +1,32 @@
+
+import qualified Data.Text as T
+
+import Data.Maybe (fromJust)
+import Network.URI (parseURI)
+import Network.HTTP
+import Network.Browser
+import qualified Data.ByteString.Lazy as B
+import System.IO
+
+baseuri s =
+ let q = urlEncodeVars [("tl", "de"), ("q", s)]
+ in fromJust $ parseURI $ "http://translate.google.com/translate_tts?" ++ q
+
+isPunct c = or [ c == c' | c' <- ".?!"]
+
+ba :: String -> BrowserAction (HandleStream B.ByteString) [B.ByteString]
+ba s = do
+ setAllowRedirects True
+ rsps <- sequence $ map req $ t2s s
+ return $ map (rspBody.snd) rsps
+
+req s = request $ Request (baseuri s) GET [] B.empty
+
+t2s :: String -> [String]
+t2s s = map T.unpack $ T.split isPunct $ T.pack s
+
+main = do
+ t <- getContents
+ ds <- fmap B.concat $ browse $ ba t
+ B.writeFile "/tmp/out.mp3" ds
+
\ No newline at end of file
|
alios/lab
|
974b18dd33676f73733cdc0a173d3dbcf08829fd
|
added Fractus
|
diff --git a/Fractus b/Fractus
new file mode 160000
index 0000000..de4e6c6
--- /dev/null
+++ b/Fractus
@@ -0,0 +1 @@
+Subproject commit de4e6c6182b19919f54348fde3800db3c4946730
|
alios/lab
|
de4e6c6182b19919f54348fde3800db3c4946730
|
some more tex stuff
|
diff --git a/fractus.lhs b/fractus.lhs
index c718415..17e68d6 100644
--- a/fractus.lhs
+++ b/fractus.lhs
@@ -1,27 +1,39 @@
-\documentclass[a4paper]{scrartcl}
+\documentclass[a4paper]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
-\usepackage[ngerman]{babel}
+\usepackage[english]{babel}
+\usepackage{fancyhdr}
\usepackage{listings}
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small}}{}
\begin{document}
-\include{abstract}
+
+\chapter{Introduction}
+Looking at some of the acronyms and buzz words of the last two centuries
+like OOP\footnote{{\sc Object Oriented Programming}},
+RMI\footnote{{\sc Remote Method Invocation}},
+peer to peer networks, SOA\footnote{{\sc Service Oriented Architectures}} or
+cloud computing in chronological order it shows a clear trend twords a
+highly interconnected world where data and code is distributed over a
+huge {\it span} of different devices.
+
+In the world of functional programming a function is a first class object.
+
\begin{code}
data Foo = Bar
\end{code}
\end{document}
% ----- Configure Emacs -----
%
% Local Variables: ***
% mode: latex ***
% mmm-classes: literate-haskell-latex ***
% End: ***
|
alios/lab
|
a9ad429e6208a192c49d52a965eb1e979a60efeb
|
trie now works implemented quick check properties
|
diff --git a/Trie.hs b/Trie.hs
index b259de8..9174ac9 100644
--- a/Trie.hs
+++ b/Trie.hs
@@ -1,42 +1,49 @@
{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleInstances #-}
module Trie where
+import Data.Maybe (isJust, fromJust, fromMaybe)
import qualified Data.Map as M
+import Test.QuickCheck
-
-class Tries k v where
+class (Ord k) => Tries k v where
data Trie k v
tempty :: Trie k v
tlookup :: Trie k v -> [k] -> Maybe v
tbind :: [k] -> v -> Trie k v -> Trie k v
- tshow :: (Show k, Show v) => Trie k v -> String
+ tfromList :: [([k], v)] -> Trie k v
+ tfromList = foldl (\t (k, v) -> tbind k v t) tempty
+instance (Show v, Show k) => Show (Trie k v) where
+ show (Trie m v) = show v ++ ": " ++ show m
+
instance (Ord k) => Tries k v where
data Trie k v = Trie (M.Map k (Trie k v)) (Maybe v)
tempty = Trie M.empty Nothing
tlookup (Trie _ v) [] = v
tlookup (Trie edges v) (k:ks) =
case (M.lookup k edges) of
Nothing -> Nothing
Just t -> tlookup t ks
tbind [] v (Trie edges _) = Trie edges $ Just v
tbind (k:ks) nv (Trie edges v) =
- let t = case (M.lookup k edges) of
- Nothing -> tempty
- Just t' -> tbind ks nv t'
- newedges = M.insert k t edges
+ let t = fromMaybe tempty $ M.lookup k edges
+ newedges = M.insert k (tbind ks nv t) edges
in (Trie newedges v)
- tshow (Trie edges v) =
- let cs = M.toList edges
- a = concat [ "(" ++ show k ++ ", " ++ tshow ts ++ ")" | (k, ts) <- cs]
- in "(" ++ show v ++ ": [" ++ a ++ "])"
-
-a = tbind "car" 30 $ tempty
-x = tbind "cocktail" 10 $ tbind "cart" 20 $ a
-
-y = tbind "" 23 $ tempty
\ No newline at end of file
+prop_bind :: (Ord k, Eq v) => [k] -> v -> Bool
+prop_bind k v =
+ let t = tbind k v tempty
+ v' = tlookup t k
+ in isJust v' && (fromJust v') == v
+
+prop_fromList :: (Ord k, Eq v) => [([k], v)] -> Bool
+prop_fromList m =
+ let map = M.fromList m
+ lst = M.toList map
+ trie = tfromList lst
+ in and [ (tlookup trie k) == (Just v) | (k,v) <- lst ]
+
|
alios/lab
|
b000ee4ae4634190fbed1edd1c8ed27d37ebc5db
|
introduced Trie
|
diff --git a/Trie.hs b/Trie.hs
new file mode 100644
index 0000000..b259de8
--- /dev/null
+++ b/Trie.hs
@@ -0,0 +1,42 @@
+{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleInstances #-}
+
+module Trie where
+
+import qualified Data.Map as M
+
+
+class Tries k v where
+ data Trie k v
+ tempty :: Trie k v
+ tlookup :: Trie k v -> [k] -> Maybe v
+ tbind :: [k] -> v -> Trie k v -> Trie k v
+ tshow :: (Show k, Show v) => Trie k v -> String
+
+instance (Ord k) => Tries k v where
+ data Trie k v = Trie (M.Map k (Trie k v)) (Maybe v)
+
+ tempty = Trie M.empty Nothing
+
+ tlookup (Trie _ v) [] = v
+ tlookup (Trie edges v) (k:ks) =
+ case (M.lookup k edges) of
+ Nothing -> Nothing
+ Just t -> tlookup t ks
+
+ tbind [] v (Trie edges _) = Trie edges $ Just v
+ tbind (k:ks) nv (Trie edges v) =
+ let t = case (M.lookup k edges) of
+ Nothing -> tempty
+ Just t' -> tbind ks nv t'
+ newedges = M.insert k t edges
+ in (Trie newedges v)
+
+ tshow (Trie edges v) =
+ let cs = M.toList edges
+ a = concat [ "(" ++ show k ++ ", " ++ tshow ts ++ ")" | (k, ts) <- cs]
+ in "(" ++ show v ++ ": [" ++ a ++ "])"
+
+a = tbind "car" 30 $ tempty
+x = tbind "cocktail" 10 $ tbind "cart" 20 $ a
+
+y = tbind "" 23 $ tempty
\ No newline at end of file
|
alios/lab
|
4a1b8df7abbdf5a7bb7a9c8afa29911bb23dbe03
|
added MemWorld
|
diff --git a/MemWorld/LICENSE b/MemWorld/LICENSE
new file mode 100644
index 0000000..c14b8f7
--- /dev/null
+++ b/MemWorld/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c)2011, Markus Barenhoff
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of Markus Barenhoff nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/MemWorld/MemWorld.cabal b/MemWorld/MemWorld.cabal
new file mode 100644
index 0000000..a3e3a35
--- /dev/null
+++ b/MemWorld/MemWorld.cabal
@@ -0,0 +1,54 @@
+Name: MemWorld
+
+-- The package version. See the Haskell package versioning policy
+-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
+-- standards guiding when and how versions should be incremented.
+Version: 0.1
+
+-- A short (one-line) description of the package.
+-- Synopsis:
+
+-- A longer description of the package.
+-- Description:
+
+-- The license under which the package is released.
+License: BSD3
+
+-- The file containing the license text.
+License-file: LICENSE
+
+-- The package author(s).
+Author: Markus Barenhoff
+
+-- An email address to which users can send suggestions, bug reports,
+-- and patches.
+Maintainer: [email protected]
+
+-- A copyright notice.
+-- Copyright:
+
+Category: Web
+
+Build-type: Simple
+
+-- Extra files to be distributed with the package, such as examples or
+-- a README.
+-- Extra-source-files:
+
+-- Constraint on the version of Cabal needed to build this package.
+Cabal-version: >=1.2
+
+
+Library
+ -- Modules exported by the library.
+ Exposed-modules: MemWorld
+
+ -- Packages needed in order to build this package.
+ Build-depends: base, Graphalyze
+
+ -- Modules not exported by this package.
+ -- Other-modules:
+
+ -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
+ -- Build-tools:
+
diff --git a/MemWorld/MemWorld.hs b/MemWorld/MemWorld.hs
new file mode 100644
index 0000000..2d86f2f
--- /dev/null
+++ b/MemWorld/MemWorld.hs
@@ -0,0 +1,58 @@
+{-# LANGUAGE MultiParamTypeClasses,
+ FunctionalDependencies,
+ TypeSynonymInstances,
+ Rank2Types
+ #-}
+
+--
+-- requires the Graphalyze package. for installation execute:
+-- cabal update; cabal install Graphalyze
+--
+
+-- | 'MemWorld' is a visualization tool for mems in sozial network 'Streams'
+module MemWorld where
+
+import Data.Graph.Analysis.Types
+--data AGr e w = AGr e w
+
+-- | 'SocialStreams' represents a source of 'Mems' of type 'm'
+class (Streams s, Mems m) => SocialStreams s m | s -> m where
+ -- | 'stream' evaluates to a time ordered list of 'Mems' of type 't' where
+ -- the first element of the list represents the
+ stream :: s -> [(m, TimeStamp)]
+
+
+type TimeStamp = Integer
+
+
+-- | 'Streams' is an abstraction for a source of 'Mems' like users
+-- twitter timeline (or the global one), facebook or soup.io.
+class Streams s
+
+-- | 'Mems' represent mindunits like hashtags (Strings), videos, pictures
+class Mems m
+
+-- | a 'String' can be a mem f.e.
+instance Mems String
+
+-- | A mem also represents a node in a 'MemGraph' with weighted
+-- edges to all other 'Mems'. The weights minimum represents
+-- no "memetic" connection between two 'Mems' whereas the weights
+-- maximum represents that two 'Mems' are the same - f.e. a image which
+-- also has a representation as a hash tag.
+type MemGraph mem w = (Mems mem, Bounded w, Ord w) => AGr m w
+
+-- | 'Analyzers' map 'MemGraphs' on a ordered Lists of 'Mems' - Weight
+-- - tupel, which can be used as starting point for visualization
+-- together with the weighted graph structure itself
+class (Ord wmem) => Analyzers wedge wmem where
+ -- | do the anlysis.
+ analyze :: MemGraph mem wedge -> [(mem, wmem)]
+
+
+-- with a lambda kiss... whatever it is
+
+
+
+
+-- -*- indent-tabs-mode: nil -*-
diff --git a/MemWorld/Setup.hs b/MemWorld/Setup.hs
new file mode 100644
index 0000000..9a994af
--- /dev/null
+++ b/MemWorld/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.