From b858046eda80207440bfaa57a257c2bec358521d Mon Sep 17 00:00:00 2001 From: joshholtrop Date: Wed, 29 Jul 2009 19:08:48 +0000 Subject: [PATCH] added pport module git-svn-id: http://apu.dw.local/svnusers/JoshHoltrop/pppc/trunk@35 8131a0b2-b21c-1c47-bd6a-f003126495bd --- Makefile | 9 ++++++--- pport.cc | 29 +++++++++++++++++++++++++++++ pport.h | 7 +++++++ pppc.cc | 2 ++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 pport.cc create mode 100644 pport.h diff --git a/Makefile b/Makefile index f56c8f9..a1b4a17 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,18 @@ TARGET := pppc.exe -OBJS := pppc.o session_notification.o resources.o +OBJS := pppc.o session_notification.o resources.o pport.o CXXFLAGS := -O2 -Wall all: $(TARGET) $(TARGET): $(OBJS) - $(CXX) -o $@ $^ $(LDFLAGS) + $(CXX) -o $@ $(LDFLAGS) $^ %.o: %.rc windres $< $@ %.o: %.cc - $(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) + $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< + +clean: + -$(RM) -f *.o *~ *.exe diff --git a/pport.cc b/pport.cc new file mode 100644 index 0000000..3d80498 --- /dev/null +++ b/pport.cc @@ -0,0 +1,29 @@ + +#include +#include +#include "pport.h" +using namespace std; + +static HANDLE ppfd = NULL; + +void pport_write(unsigned char val) +{ + if (ppfd == NULL) + { + ppfd = CreateFile("LPT1", + GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (ppfd == NULL) + { + cerr << "Couldn't open LPT1!" << endl; + exit(4); + } + } + + DWORD bytes_written = 0; + WriteFile(ppfd, &val, 1, &bytes_written, NULL); +} diff --git a/pport.h b/pport.h new file mode 100644 index 0000000..27fca91 --- /dev/null +++ b/pport.h @@ -0,0 +1,7 @@ + +#ifndef PPORT_H +#define PPORT_H + +void pport_write(unsigned char val); + +#endif diff --git a/pppc.cc b/pppc.cc index cdcb4cb..aa45be0 100644 --- a/pppc.cc +++ b/pppc.cc @@ -1,6 +1,8 @@ #include #include +#include "session_notification.h" +#include "pport.h" using namespace std; int WinMain(