added pport module

git-svn-id: http://apu.dw.local/svnusers/JoshHoltrop/pppc/trunk@35 8131a0b2-b21c-1c47-bd6a-f003126495bd
This commit is contained in:
joshholtrop 2009-07-29 19:08:48 +00:00
parent 8b2a5b71ec
commit b858046eda
4 changed files with 44 additions and 3 deletions

View File

@ -1,15 +1,18 @@
TARGET := pppc.exe TARGET := pppc.exe
OBJS := pppc.o session_notification.o resources.o OBJS := pppc.o session_notification.o resources.o pport.o
CXXFLAGS := -O2 -Wall CXXFLAGS := -O2 -Wall
all: $(TARGET) all: $(TARGET)
$(TARGET): $(OBJS) $(TARGET): $(OBJS)
$(CXX) -o $@ $^ $(LDFLAGS) $(CXX) -o $@ $(LDFLAGS) $^
%.o: %.rc %.o: %.rc
windres $< $@ windres $< $@
%.o: %.cc %.o: %.cc
$(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<
clean:
-$(RM) -f *.o *~ *.exe

29
pport.cc Normal file
View File

@ -0,0 +1,29 @@
#include <windows.h>
#include <iostream>
#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);
}

7
pport.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef PPORT_H
#define PPORT_H
void pport_write(unsigned char val);
#endif

View File

@ -1,6 +1,8 @@
#include <windows.h> #include <windows.h>
#include <iostream> #include <iostream>
#include "session_notification.h"
#include "pport.h"
using namespace std; using namespace std;
int WinMain( int WinMain(