* More style fixes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36136 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -38,13 +38,14 @@ public:
|
|||||||
status_t ListPorts(BMessage *msg);
|
status_t ListPorts(BMessage *msg);
|
||||||
status_t Listen();
|
status_t Listen();
|
||||||
private:
|
private:
|
||||||
char *parseString(BString& outStr, char*& pos);
|
char *_parseString(BString& outStr, char*& pos);
|
||||||
|
|
||||||
static status_t ippListeningThread(void *cookie);
|
static status_t _ippListeningThread(void *cookie);
|
||||||
|
|
||||||
typedef HashMap<HashString,IPPPrinter*> IPPPrinterMap;
|
typedef HashMap<HashString,IPPPrinter*> IPPPrinterMap;
|
||||||
IPPPrinterMap fPrinters;
|
IPPPrinterMap fPrinters;
|
||||||
BNetEndpoint *fEndpt;
|
BNetEndpoint *fEndpoint;
|
||||||
|
thread_id fListenThreadID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -53,32 +54,30 @@ static IPPPrinterRoster gRoster;
|
|||||||
|
|
||||||
IPPPrinterRoster::IPPPrinterRoster()
|
IPPPrinterRoster::IPPPrinterRoster()
|
||||||
{
|
{
|
||||||
thread_id thid;
|
|
||||||
|
|
||||||
// Setup our (UDP) listening endpoint
|
// Setup our (UDP) listening endpoint
|
||||||
fEndpt = new BNetEndpoint(SOCK_DGRAM);
|
fEndpoint = new BNetEndpoint(SOCK_DGRAM);
|
||||||
if (!fEndpt)
|
if (!fEndpoint)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fEndpt->InitCheck() != B_OK)
|
if (fEndpoint->InitCheck() != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fEndpt->Bind(BNetAddress(INADDR_ANY, 631)) != B_OK)
|
if (fEndpoint->Bind(BNetAddress(INADDR_ANY, 631)) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Now create thread for listening
|
// Now create thread for listening
|
||||||
thid = spawn_thread(ippListeningThread, "IPPListener", B_LOW_PRIORITY, this);
|
fListenThreadID = spawn_thread(_ippListeningThread, "IPPListener", B_LOW_PRIORITY, this);
|
||||||
if (thid <= 0)
|
if (fListenThreadID <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
resume_thread(thid);
|
resume_thread(fListenThreadID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IPPPrinterRoster::~IPPPrinterRoster()
|
IPPPrinterRoster::~IPPPrinterRoster()
|
||||||
{
|
{
|
||||||
if (fEndpt)
|
kill_thread(fListenThreadID);
|
||||||
delete fEndpt;
|
delete fEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -92,7 +91,7 @@ IPPPrinterRoster::Listen()
|
|||||||
char* pos;
|
char* pos;
|
||||||
int32 len;
|
int32 len;
|
||||||
|
|
||||||
while((len=fEndpt->ReceiveFrom(packet, sizeof(packet) -1, srcAddress)) > 0) {
|
while ((len=fEndpoint->ReceiveFrom(packet, sizeof(packet) -1, srcAddress)) > 0) {
|
||||||
packet[len] = '\0';
|
packet[len] = '\0';
|
||||||
|
|
||||||
// Verify packet format
|
// Verify packet format
|
||||||
@@ -108,11 +107,11 @@ IPPPrinterRoster::Listen()
|
|||||||
// Check for option parameters
|
// Check for option parameters
|
||||||
if ((pos=strchr(packet, '"')) != NULL) {
|
if ((pos=strchr(packet, '"')) != NULL) {
|
||||||
BString str;
|
BString str;
|
||||||
if (parseString(str, pos))
|
if (_parseString(str, pos))
|
||||||
printer->fLocation = str;
|
printer->fLocation = str;
|
||||||
if (pos && parseString(str, pos))
|
if (pos && _parseString(str, pos))
|
||||||
printer->fInfo = str;
|
printer->fInfo = str;
|
||||||
if (pos && parseString(str, pos))
|
if (pos && _parseString(str, pos))
|
||||||
printer->fMakeModel = str;
|
printer->fMakeModel = str;
|
||||||
|
|
||||||
if (pos)
|
if (pos)
|
||||||
@@ -151,7 +150,7 @@ status_t IPPPrinterRoster::ListPorts(BMessage* msg)
|
|||||||
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
IPPPrinterRoster::parseString(BString& outStr, char*& pos)
|
IPPPrinterRoster::_parseString(BString& outStr, char*& pos)
|
||||||
{
|
{
|
||||||
outStr = "";
|
outStr = "";
|
||||||
|
|
||||||
@@ -175,7 +174,7 @@ IPPPrinterRoster::parseString(BString& outStr, char*& pos)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
IPPPrinterRoster::ippListeningThread(void *cookie)
|
IPPPrinterRoster::_ippListeningThread(void *cookie)
|
||||||
{
|
{
|
||||||
return ((IPPPrinterRoster*)cookie)->Listen();
|
return ((IPPPrinterRoster*)cookie)->Listen();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user