xref: /haiku/src/kits/print/PrintTransportAddOn.cpp (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
1 #include "PrintTransportAddOn.h"
2 
3 // We don't support multiple instances of the same transport add-on
4 static BDataIO* gTransport = NULL;
5 
6 extern "C" _EXPORT BDataIO *init_transport(BMessage *msg)
7 {
8 	if (msg == NULL || gTransport != NULL)
9 		return NULL;
10 
11 	const char *spool_path = msg->FindString("printer_file");
12 
13 	if (spool_path && *spool_path != '\0') {
14 		BDirectory printer(spool_path);
15 
16 		if (printer.InitCheck() == B_OK) {
17 			gTransport = instantiate_transport(&printer, msg);
18 			return gTransport;
19 		};
20 	};
21 
22 	return NULL;
23 }
24 
25 extern "C" _EXPORT void exit_transport()
26 {
27 	if (gTransport) {
28 		delete gTransport;
29 		gTransport = NULL;
30 	}
31 }
32 
33