[haiku-commits] r33558 - haiku/trunk/src/add-ons/print/transports/lpr

  • From: michael.w.pfeiffer@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 12 Oct 2009 20:48:47 +0200 (CEST)

Author: laplace
Date: 2009-10-12 20:48:47 +0200 (Mon, 12 Oct 2009)
New Revision: 33558
Changeset: http://dev.haiku-os.org/changeset/33558/haiku

Modified:
   haiku/trunk/src/add-ons/print/transports/lpr/Lpr.cpp
   haiku/trunk/src/add-ons/print/transports/lpr/LprSetupDlg.cpp
   haiku/trunk/src/add-ons/print/transports/lpr/LprSetupDlg.h
   haiku/trunk/src/add-ons/print/transports/lpr/LprTransport.cpp
   haiku/trunk/src/add-ons/print/transports/lpr/LprTransport.h
   haiku/trunk/src/add-ons/print/transports/lpr/LpsClient.cpp
   haiku/trunk/src/add-ons/print/transports/lpr/LpsClient.h
Log:
Fixed style issues.


Modified: haiku/trunk/src/add-ons/print/transports/lpr/Lpr.cpp
===================================================================
--- haiku/trunk/src/add-ons/print/transports/lpr/Lpr.cpp        2009-10-12 
17:17:25 UTC (rev 33557)
+++ haiku/trunk/src/add-ons/print/transports/lpr/Lpr.cpp        2009-10-12 
18:48:47 UTC (rev 33558)
@@ -4,25 +4,28 @@
 #include "LprTransport.h"
 #include "DbgMsg.h"
 
-LprTransport *transport = NULL;
 
-extern "C" _EXPORT void exit_transport()
+static LprTransport *gTransport = NULL;
+
+
+extern "C" void
+exit_transport()
 {
        DBGMSG(("> exit_transport\n"));
-       if (transport) {
-               delete transport;
-               transport = NULL;
-       }
+       delete gTransport;
+       gTransport = NULL;
        DBGMSG(("< exit_transport\n"));
 }
 
-extern "C" _EXPORT BDataIO *init_transport(BMessage *msg)
+
+extern "C" BDataIO *
+init_transport(BMessage *msg)
 {
        DBGMSG(("> init_transport\n"));
 
-       transport = new LprTransport(msg);
+       gTransport = new LprTransport(msg);
 
-       if (transport->fail()) {
+       if (gTransport->fail()) {
                exit_transport();
        }
 
@@ -30,5 +33,5 @@
                msg->what = 'okok';
 
        DBGMSG(("< init_transport\n"));
-       return transport;
+       return gTransport;
 }

Modified: haiku/trunk/src/add-ons/print/transports/lpr/LprSetupDlg.cpp
===================================================================
--- haiku/trunk/src/add-ons/print/transports/lpr/LprSetupDlg.cpp        
2009-10-12 17:17:25 UTC (rev 33557)
+++ haiku/trunk/src/add-ons/print/transports/lpr/LprSetupDlg.cpp        
2009-10-12 18:48:47 UTC (rev 33558)
@@ -16,6 +16,7 @@
 #include "LprDefs.h"
 #include "DbgMsg.h"
 
+
 #define        DLG_WIDTH               370
 #define DLG_HEIGHT             100
 
@@ -74,44 +75,51 @@
 
 class LprSetupView : public BView {
 public:
-       LprSetupView(BRect, BDirectory *);
-       ~LprSetupView() {}
-       virtual void AttachedToWindow();
-       bool UpdateViewData();
+                                       LprSetupView(BRect, BDirectory *);
+                                       ~LprSetupView() {}
+       virtual void    AttachedToWindow();
+                       bool    UpdateViewData();
 
 private:
-       BTextControl *server;
-       BTextControl *queue;
-       BDirectory   *dir;
+       BTextControl*   fServer;
+       BTextControl*   fQueue;
+       BDirectory*             fDir;
 };
 
+
 LprSetupView::LprSetupView(BRect frame, BDirectory *d)
-       : BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW), dir(d)
+       :
+       BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW), fDir(d)
 {
        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 }
 
-void LprSetupView::AttachedToWindow()
+
+void
+LprSetupView::AttachedToWindow()
 {
        float width = max(StringWidth(SERVER_TEXT), StringWidth(QUEUE_TEXT)) + 
10;
 
        /* server name box */
 
     // TODO remember previous value
-       server = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "192.168.0.0", 
NULL);
-       AddChild(server);
-       server->SetDivider(width);
+       fServer = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "192.168.0.0",
+               NULL);
+       AddChild(fServer);
+       fServer->SetDivider(width);
 
        /* queue name box */
 
     // TODO remember previous value
-       queue = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "LPT1_PASSTHRU", 
NULL);
-       AddChild(queue);
-       queue->SetDivider(width);
+       fQueue = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "LPT1_PASSTHRU",
+               NULL);
+       AddChild(fQueue);
+       fQueue->SetDivider(width);
 
        /* cancel */
 
-       BButton *button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new 
BMessage(M_CANCEL));
+       BButton *button = new BButton(CANCEL_RECT, "", CANCEL_TEXT,
+               new BMessage(M_CANCEL));
        AddChild(button);
 
        /* ok */
@@ -121,12 +129,14 @@
        button->MakeDefault(true);
 }
 
-bool LprSetupView::UpdateViewData()
+
+bool
+LprSetupView::UpdateViewData()
 {
-       if (*server->Text() && *queue->Text()) {
+       if (*fServer->Text() && *fQueue->Text()) {
 
                try {
-                       LpsClient lpr(server->Text());
+                       LpsClient lpr(fServer->Text());
                        lpr.connect();
                }
 
@@ -136,8 +146,8 @@
                        return false;
                }
 
-               dir->WriteAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, 
server->Text(), strlen(server->Text()) + 1);
-               dir->WriteAttr(LPR_QUEUE_NAME,  B_STRING_TYPE, 0, 
queue->Text(),  strlen(queue->Text())  + 1);
+               fDir->WriteAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, 
fServer->Text(), strlen(fServer->Text()) + 1);
+               fDir->WriteAttr(LPR_QUEUE_NAME,  B_STRING_TYPE, 0, 
fQueue->Text(),  strlen(fQueue->Text())  + 1);
                return true;
        }
 
@@ -146,60 +156,68 @@
        return false;
 }
 
+
 LprSetupDlg::LprSetupDlg(BDirectory *dir)
-       : BWindow(BRect(100, 100, 100 + DLG_WIDTH, 100 + DLG_HEIGHT),
+       :
+       BWindow(BRect(100, 100, 100 + DLG_WIDTH, 100 + DLG_HEIGHT),
                "LPR Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
                B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE)
 {
-       result = 0;
+       fResult = 0;
 
        Lock();
        LprSetupView *view = new LprSetupView(Bounds(), dir);
        AddChild(view);
        Unlock();
 
-       semaphore = create_sem(0, "lprSetupSem");
+       fExitSemaphore = create_sem(0, "lprSetupSem");
 }
 
-bool LprSetupDlg::QuitRequested()
+
+bool
+LprSetupDlg::QuitRequested()
 {
-       result = B_ERROR;
-       release_sem(semaphore);
+       fResult = B_ERROR;
+       release_sem(fExitSemaphore);
        return true;
 }
 
-void LprSetupDlg::MessageReceived(BMessage *msg)
+
+void
+LprSetupDlg::MessageReceived(BMessage *msg)
 {
        bool success;
 
        switch (msg->what) {
-       case M_OK:
-               Lock();
-               success = ((LprSetupView *)ChildAt(0))->UpdateViewData();
-               Unlock();
-               if (success) {
-                       result = B_NO_ERROR;
-                       release_sem(semaphore);
-               }
-               break;
+               case M_OK:
+                       Lock();
+                       success = ((LprSetupView 
*)ChildAt(0))->UpdateViewData();
+                       Unlock();
+                       if (success) {
+                               fResult = B_NO_ERROR;
+                               release_sem(fExitSemaphore);
+                       }
+                       break;
 
-       case M_CANCEL:
-               result = B_ERROR;
-               release_sem(semaphore);
-               break;
+               case M_CANCEL:
+                       fResult = B_ERROR;
+                       release_sem(fExitSemaphore);
+                       break;
 
-       default:
-               BWindow::MessageReceived(msg);
-               break;
+               default:
+                       BWindow::MessageReceived(msg);
+                       break;
        }
 }
 
-int LprSetupDlg::Go()
+
+int
+LprSetupDlg::Go()
 {
        Show();
-       acquire_sem(semaphore);
-       delete_sem(semaphore);
-       int value = result;
+       acquire_sem(fExitSemaphore);
+       delete_sem(fExitSemaphore);
+       int value = fResult;
        Lock();
        Quit();
        return value;

Modified: haiku/trunk/src/add-ons/print/transports/lpr/LprSetupDlg.h
===================================================================
--- haiku/trunk/src/add-ons/print/transports/lpr/LprSetupDlg.h  2009-10-12 
17:17:25 UTC (rev 33557)
+++ haiku/trunk/src/add-ons/print/transports/lpr/LprSetupDlg.h  2009-10-12 
18:48:47 UTC (rev 33558)
@@ -1,24 +1,24 @@
-// Sun, 18 Jun 2000
-// Y.Takagi
-
-#ifndef __LprSetupDlg_H
-#define __LprSetupDlg_H
-
-#include <Window.h>
-
-class BDirectory;
-
-class LprSetupDlg : public BWindow {
-public:
-       LprSetupDlg(BDirectory *);
-       ~LprSetupDlg() {}
-       virtual bool QuitRequested();
-       virtual void MessageReceived(BMessage *message);
-       int Go();
-
-private:
-       int  result;
-       long semaphore;
-};
-
-#endif // __LprSetupDlg_H
+// Sun, 18 Jun 2000
+// Y.Takagi
+
+#ifndef __LprSetupDlg_H
+#define __LprSetupDlg_H
+
+#include <Window.h>
+
+class BDirectory;
+
+class LprSetupDlg : public BWindow {
+public:
+                                       LprSetupDlg(BDirectory *);
+                                       ~LprSetupDlg() {}
+       virtual bool    QuitRequested();
+       virtual void    MessageReceived(BMessage *message);
+                       int     Go();
+
+private:
+       int    fResult;
+       sem_id fExitSemaphore;
+};
+
+#endif // __LprSetupDlg_H

Modified: haiku/trunk/src/add-ons/print/transports/lpr/LprTransport.cpp
===================================================================
--- haiku/trunk/src/add-ons/print/transports/lpr/LprTransport.cpp       
2009-10-12 17:17:25 UTC (rev 33557)
+++ haiku/trunk/src/add-ons/print/transports/lpr/LprTransport.cpp       
2009-10-12 18:48:47 UTC (rev 33558)
@@ -20,27 +20,23 @@
 #include "LprDefs.h"
 #include "DbgMsg.h"
 
-#if (!__MWERKS__)
-using namespace std;
-#else 
-#define std
-#endif
 
 LprTransport::LprTransport(BMessage *msg)
-       : BDataIO()
+       :
+       BDataIO()
 {
-       __server[0] = '\0';
-       __queue[0]  = '\0';
-       __file[0]   = '\0';
-       __user[0]   = '\0';
-       __jobid     = 0;
-       __error     = false;
+       fServer[0] = '\0';
+       fQueue[0]  = '\0';
+       fFile[0]   = '\0';
+       fUser[0]   = '\0';
+       fJobId     = 0;
+       fError     = false;
 
        struct passwd *pwd = getpwuid(geteuid());
        if (pwd != NULL && pwd->pw_name != NULL && pwd->pw_name[0])
-               strcpy(__user, pwd->pw_name);
+               strcpy(fUser, pwd->pw_name);
        else
-               strcpy(__user, "baron");
+               strcpy(fUser, "baron");
 
        DUMP_BMESSAGE(msg);
 
@@ -49,68 +45,69 @@
                BDirectory dir(spool_path);
                DUMP_BDIRECTORY(&dir);
 
-               dir.ReadAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, __server, 
sizeof(__server));
-               if (__server[0] == '\0') {
+               dir.ReadAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, fServer, 
sizeof(fServer));
+               if (fServer[0] == '\0') {
                        LprSetupDlg *dlg = new LprSetupDlg(&dir);
                        if (dlg->Go() == B_ERROR) {
-                               __error = true;
+                               fError = true;
                                return;
                        }
                }
 
-               dir.ReadAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, __server, 
sizeof(__server));
-               dir.ReadAttr(LPR_QUEUE_NAME,  B_STRING_TYPE, 0, __queue,  
sizeof(__queue));
-               dir.ReadAttr(LPR_JOB_ID,      B_INT32_TYPE,  0, &__jobid, 
sizeof(__jobid));
-               __jobid++;
-               if (__jobid > 255) {
-                       __jobid = 1;
+               dir.ReadAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, fServer, 
sizeof(fServer));
+               dir.ReadAttr(LPR_QUEUE_NAME,  B_STRING_TYPE, 0, fQueue,  
sizeof(fQueue));
+               dir.ReadAttr(LPR_JOB_ID,      B_INT32_TYPE,  0, &fJobId, 
sizeof(fJobId));
+               fJobId++;
+               if (fJobId > 255) {
+                       fJobId = 1;
                }
-               dir.WriteAttr(LPR_JOB_ID, B_INT32_TYPE, 0, &__jobid, 
sizeof(__jobid));
+               dir.WriteAttr(LPR_JOB_ID, B_INT32_TYPE, 0, &fJobId, 
sizeof(fJobId));
 
-               sprintf(__file, "%s/%s@ipp.%ld", spool_path, __user, __jobid);
+               sprintf(fFile, "%s/%s@ipp.%ld", spool_path, fUser, fJobId);
 
-               __fs.open(__file, ios::in | ios::out | ios::binary | 
ios::trunc);
-               if (__fs.good()) {
-                       DBGMSG(("spool_file: %s\n", __file));
+               fStream.open(fFile, ios::in | ios::out | ios::binary | 
ios::trunc);
+               if (fStream.good()) {
+                       DBGMSG(("spool_file: %s\n", fFile));
                        return;
                }
        }
-       __error = true;
+       fError = true;
 }
 
+
 LprTransport::~LprTransport()
 {
        char hostname[128];
        gethostname(hostname, sizeof(hostname));
 
        ostringstream cfname;
-       cfname << "cfA" << setw(3) << setfill('0') << __jobid << hostname;
+       cfname << "cfA" << setw(3) << setfill('0') << fJobId << hostname;
 
        ostringstream dfname;
-       dfname << "dfA" << setw(3) << setfill('0') << __jobid << hostname;
+       dfname << "dfA" << setw(3) << setfill('0') << fJobId << hostname;
 
        ostringstream cf;
        cf << 'H' << hostname     << '\n';
-       cf << 'P' << __user << '\n';
+       cf << 'P' << fUser << '\n';
        cf << 'l' << dfname.str() << '\n';
        cf << 'U' << dfname.str() << '\n';
 
        long cfsize = cf.str().length();
-       long dfsize = __fs.tellg();
-       __fs.seekg(0, ios::beg);
+       long dfsize = fStream.tellg();
+       fStream.seekg(0, ios::beg);
 
        try {
-               LpsClient lpr(__server);
+               LpsClient lpr(fServer);
 
                lpr.connect();
-               lpr.receiveJob(__queue);
+               lpr.receiveJob(fQueue);
 
                lpr.receiveControlFile(cfsize, cfname.str().c_str());
                lpr.transferData(cf.str().c_str(), cfsize);
                lpr.endTransfer();
 
                lpr.receiveDataFile(dfsize, dfname.str().c_str());
-               lpr.transferData(__fs, dfsize);
+               lpr.transferData(fStream, dfsize);
                lpr.endTransfer();
        }
 
@@ -120,21 +117,23 @@
                alert->Go();
        }
 
-       unlink(__file);
+       unlink(fFile);
 }
 
-ssize_t LprTransport::Read(void *, size_t)
+
+ssize_t
+LprTransport::Read(void *, size_t)
 {
        return 0;
 }
 
-ssize_t LprTransport::Write(const void *buffer, size_t size)
+
+ssize_t
+LprTransport::Write(const void *buffer, size_t size)
 {
-//     DBGMSG(("write: %d\n", size));
-       if (!__fs.write((char *)buffer, size)) {
-               __error = true;
+       if (!fStream.write((char *)buffer, size)) {
+               fError = true;
                return 0;
        }
-//     return __fs.pcount();
        return size;
 }

Modified: haiku/trunk/src/add-ons/print/transports/lpr/LprTransport.h
===================================================================
--- haiku/trunk/src/add-ons/print/transports/lpr/LprTransport.h 2009-10-12 
17:17:25 UTC (rev 33557)
+++ haiku/trunk/src/add-ons/print/transports/lpr/LprTransport.h 2009-10-12 
18:48:47 UTC (rev 33558)
@@ -9,38 +9,37 @@
 #include <fstream>
 #include <string>
 
-#if (!__MWERKS__)
-using namespace std;
-#else 
-#define std
-#endif
 
 class LprTransport : public BDataIO {
 public:
-       LprTransport(BMessage *msg);
-       virtual ~LprTransport();
-       virtual ssize_t Read(void *buffer, size_t size);
+                                       LprTransport(BMessage *msg);
+       virtual                 ~LprTransport();
+       virtual ssize_t Read(void *buffer, size_t size);
        virtual ssize_t Write(const void *buffer, size_t size);
 
-       bool operator !() const;
-       bool fail() const;
+                       bool    operator!() const;
+                       bool    fail() const;
 
 private:
-       char    __server[256];
-       char    __queue[256];
-       char    __file[256];
-       char    __user[256];
-       int32   __jobid;
-       fstream __fs;
-       bool    __error;
+       char    fServer[256];
+       char    fQueue[256];
+       char    fFile[256];
+       char    fUser[256];
+       int32   fJobId;
+       fstream fStream;
+       bool    fError;
 };
 
-inline bool LprTransport::fail() const
+
+inline bool
+LprTransport::fail() const
 {
-       return __error;
+       return fError;
 }
 
-inline bool LprTransport::operator !() const
+
+inline bool
+LprTransport::operator!() const
 {
        return fail();
 }

Modified: haiku/trunk/src/add-ons/print/transports/lpr/LpsClient.cpp
===================================================================
--- haiku/trunk/src/add-ons/print/transports/lpr/LpsClient.cpp  2009-10-12 
17:17:25 UTC (rev 33557)
+++ haiku/trunk/src/add-ons/print/transports/lpr/LpsClient.cpp  2009-10-12 
18:48:47 UTC (rev 33558)
@@ -1,13 +1,8 @@
 // Sun, 18 Jun 2000
 // Y.Takagi
 
-#if defined(__HAIKU__) || defined(HAIKU_TARGET_PLATFORM_BONE)
-#      include <sys/socket.h>
-#      include <netdb.h>
-#else
-#      include <net/socket.h>
-#      include <net/netdb.h>
-#endif
+#include <sys/socket.h>
+#include <netdb.h>
 
 #include <errno.h>
 #include <string.h>
@@ -16,13 +11,7 @@
 #include <algorithm>
 #include "LpsClient.h"
 #include "Socket.h"
-//#include "DbgMsg.h"
 
-#if (!__MWERKS__)
-using namespace std;
-#else 
-#define std
-#endif
 
 #define LPS_SERVER_PORT                515
 #define LPS_CLIENT_PORT_S      721
@@ -50,111 +39,116 @@
 
 
 LpsClient::LpsClient(const char *host)
-       : connected(false), __host(host), __sock(NULL)
+       :
+       fConnected(false),
+       fHost(host),
+       fSock(NULL)
 {
 }
 
+
 LpsClient::~LpsClient()
 {
        close();
 }
 
-void LpsClient::connect() throw(LPSException)
+
+void
+LpsClient::connect() throw(LPSException)
 {
-//     DBGMSG(("connect\n"));
+       for (int localPort = LPS_CLIENT_PORT_S; localPort <=  LPS_CLIENT_PORT_E;
+               localPort++) {
 
-       for (int localPort = LPS_CLIENT_PORT_S ; localPort <=  
LPS_CLIENT_PORT_E ; localPort++) {
-               if (__sock) {
-                       delete __sock;
+               if (fSock) {
+                       delete fSock;
                }
-               __sock = new Socket(__host.c_str(), LPS_SERVER_PORT, localPort);
-               if (__sock->good()) {
-                       __is = &__sock->getInputStream();
-                       __os = &__sock->getOutputStream();
-                       connected = true;
+               fSock = new Socket(fHost.c_str(), LPS_SERVER_PORT, localPort);
+               if (fSock->good()) {
+                       fInput = &fSock->getInputStream();
+                       fOutput = &fSock->getOutputStream();
+                       fConnected = true;
                        return;
                }
        }
 
-       throw(LPSException(__sock->getLastError()));
+       throw(LPSException(fSock->getLastError()));
 }
 
-void LpsClient::close()
-{
-//     DBGMSG(("close\n"));
 
-       connected = false;
-       if (__sock) {
-               delete __sock;
-               __sock = NULL;
+void
+LpsClient::close()
+{
+       fConnected = false;
+       if (fSock) {
+               delete fSock;
+               fSock = NULL;
        }
 }
 
-void LpsClient::receiveJob(const char *printer) throw(LPSException)
-{
-//     DBGMSG(("tell_receive_job\n"));
 
-       if (connected) {
-               *__os << LPS_PRINT_JOB << printer << '\n' << flush;
+void
+LpsClient::receiveJob(const char *printer) throw(LPSException)
+{
+       if (fConnected) {
+               *fOutput << LPS_PRINT_JOB << printer << '\n' << flush;
                checkAck();
        }
 }
 
-void LpsClient::receiveControlFile(int size, const char *name) 
throw(LPSException)
+
+void
+LpsClient::receiveControlFile(int size, const char *name) throw(LPSException)
 {
-//     DBGMSG(("tell_receive_control_file\n"));
+       if (fConnected) {
 
-       if (connected) {
-
                char cfname[32];
                strncpy(cfname, name, sizeof(cfname));
                cfname[sizeof(cfname) - 1] = '\0';
 
-               *__os << LPS_RECEIVE_CONTROL_FILE << size << ' ' << cfname << 
'\n' << flush;
+               *fOutput << LPS_RECEIVE_CONTROL_FILE << size << ' ' << cfname 
<< '\n' << flush;
 
                checkAck();
        }
 }
 
-void LpsClient::receiveDataFile(int size, const char *name) throw(LPSException)
+void
+LpsClient::receiveDataFile(int size, const char *name) throw(LPSException)
 {
-//     DBGMSG(("tell_receive_data_file\n"));
+       if (fConnected) {
 
-       if (connected) {
-
                char dfname[32];
                strncpy(dfname, name, sizeof(dfname));
                dfname[sizeof(dfname) - 1] = '\0';
 
-               *__os << LPS_RECEIVE_DATA_FILE << size << ' ' << dfname << '\n' 
<< flush;
+               *fOutput << LPS_RECEIVE_DATA_FILE << size << ' ' << dfname << 
'\n' << flush;
 
                checkAck();
        }
 }
 
-void LpsClient::transferData(const char *buffer, int size) throw(LPSException)
+
+void
+LpsClient::transferData(const char *buffer, int size) throw(LPSException)
 {
-//     DBGMSG(("send: %d\n", size));
+       if (fConnected) {
 
-       if (connected) {
-
                if (size < 0) {
                        size = strlen(buffer);
                }
 
-               if (!__os->write(buffer, size)) {
+               if (!fOutput->write(buffer, size)) {
                        close();
                        throw(LPSException("error talking to lpd server"));
                }
        }
 }
 
-void LpsClient::transferData(istream &is, int size) throw(LPSException)
+
+void
+LpsClient::transferData(istream &is, int size) throw(LPSException)
 {
-//     DBGMSG(("send: %d\n", size));
+       if (fConnected) {
 
-       if (connected) {
-
                if (size < 0) {
                        is.seekg(0, ios::end);
                        size = is.tellg();
@@ -163,7 +157,7 @@
 
                char c;
                while (is.get(c)) {
-                       if (!__os->put(c)) {
+                       if (!fOutput->put(c)) {
                                close();
                                throw(LPSException("error reading file."));
                                return;
@@ -172,41 +166,41 @@
        }
 }
 
-void LpsClient::endTransfer() throw(LPSException)
-{
-//     DBGMSG(("tell_end_transfer\n"));
 
-       if (connected) {
-               *__os << LPS_END_TRANSFER << flush;
+void
+LpsClient::endTransfer() throw(LPSException)
+{
+       if (fConnected) {
+               *fOutput << LPS_END_TRANSFER << flush;
                checkAck();
        }
 }
 
-void LpsClient::checkAck() throw(LPSException)
+
+void
+LpsClient::checkAck() throw(LPSException)
 {
-//     DBGMSG(("check_ack\n"));
+       if (fConnected) {
 
-       if (connected) {
-
                char c;
 
-               if (!__is->get(c)) {
+               if (!fInput->get(c)) {
                        close();
                        throw(LPSException("server not responding."));
                        return;
                }
 
                switch (c) {
-               case LPS_OK:
-                       break;
-               case LPS_ERROR:
-                       close();
-                       throw(LPSException("server error."));
-                       break;
-               case LPS_NO_SPOOL_SPACE:
-                       close();
-                       throw(LPSException("not enough spool space on 
server."));
-                       break;
+                       case LPS_OK:
+                               break;
+                       case LPS_ERROR:
+                               close();
+                               throw(LPSException("server error."));
+                               break;
+                       case LPS_NO_SPOOL_SPACE:
+                               close();
+                               throw(LPSException("not enough spool space on 
server."));
+                               break;
                }
        }
 }

Modified: haiku/trunk/src/add-ons/print/transports/lpr/LpsClient.h
===================================================================
--- haiku/trunk/src/add-ons/print/transports/lpr/LpsClient.h    2009-10-12 
17:17:25 UTC (rev 33557)
+++ haiku/trunk/src/add-ons/print/transports/lpr/LpsClient.h    2009-10-12 
18:48:47 UTC (rev 33558)
@@ -7,44 +7,54 @@
 #include <iostream>
 #include <string>
 
-#if (!__MWERKS__)
-using namespace std;
-#else 
-#define std
-#endif
 
 class Socket;
 
+
 class LPSException {
+public:
+                                       LPSException(const string& what)
+                                               :
+                                               fWhat(what)
+                                       {
+                                       }
+
+       const char *    what() const
+                                       {
+                                               return fWhat.c_str();
+                                       }
+
 private:
-       string str;
-public:
-       LPSException(const string &what_arg) : str(what_arg) {}
-       const char *what() const { return str.c_str(); }
+       string fWhat;
+
 };
 
+
 class LpsClient {
 public:
-       LpsClient(const char *host);
-       ~LpsClient();
-       void connect() throw(LPSException);
-       void close();
-       void receiveJob(const char *queue) throw(LPSException);
-       void receiveControlFile(int cfsize, const char *cfname) 
throw(LPSException);
-       void receiveDataFile(int dfsize, const char *dfname) 
throw(LPSException);
-       void transferData(const char *buffer, int size = -1) 
throw(LPSException);
-       void transferData(istream &is, int size = -1) throw(LPSException);
-       void endTransfer() throw(LPSException);
-       void checkAck() throw(LPSException);
+                                       LpsClient(const char* host);
+                                       ~LpsClient();
+       void                    connect() throw(LPSException);
+       void                    close();
+       void                    receiveJob(const char* queue) 
throw(LPSException);
+       void                    receiveControlFile(int cfsize, const char* 
cfname)
+                                               throw(LPSException);
+       void                    receiveDataFile(int dfsize, const char* dfname)
+                                               throw(LPSException);
+       void                    transferData(const char* buffer, int size = -1)
+                                               throw(LPSException);
+       void                    transferData(istream& is, int size = -1)
+                                               throw(LPSException);
+       void                    endTransfer() throw(LPSException);
+       void                    checkAck() throw(LPSException);
 
-protected:
-       bool connected;
-
 private:
-       string  __host;
-       Socket  *__sock;
-       istream *__is;
-       ostream *__os;
+       bool            fConnected;
+       string          fHost;
+       Socket*         fSock;
+       istream*        fInput;
+       ostream*        fOutput;
 };
 
+
 #endif /* __LPSCLIENT_H */


Other related posts:

  • » [haiku-commits] r33558 - haiku/trunk/src/add-ons/print/transports/lpr - michael . w . pfeiffer