Added feature: allow to send data from a file (think "Print To File" output) thru
the loaded print transport add-on. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11121 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <File.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
@@ -14,7 +15,7 @@ int main (int argc, char *argv[])
|
|||||||
char *transport;
|
char *transport;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
printf("Usage: %s <transport add-on name>\n", argv[0]);
|
printf("Usage: %s <transport add-on name> [<file to print>]\n", argv[0]);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ int main (int argc, char *argv[])
|
|||||||
// now, initialize the transport add-on
|
// now, initialize the transport add-on
|
||||||
// request BDataIO object from transport add-on
|
// request BDataIO object from transport add-on
|
||||||
BMessage msg('TRIN');
|
BMessage msg('TRIN');
|
||||||
|
// TODO: create on the fly a temporary printer folder for testing purpose only
|
||||||
msg.AddString("printer_file", "/boot/home/config/settings/printers/test");
|
msg.AddString("printer_file", "/boot/home/config/settings/printers/test");
|
||||||
BDataIO *io = (*init_proc)(&msg);
|
BDataIO *io = (*init_proc)(&msg);
|
||||||
|
|
||||||
@@ -80,6 +82,26 @@ int main (int argc, char *argv[])
|
|||||||
} else
|
} else
|
||||||
printf("failed!\n");
|
printf("failed!\n");
|
||||||
|
|
||||||
|
|
||||||
|
if (argc > 2) {
|
||||||
|
BFile data(argv[2], B_READ_ONLY);
|
||||||
|
if (data.InitCheck() == B_OK) {
|
||||||
|
uint8 buffer[B_PAGE_SIZE];
|
||||||
|
ssize_t total = 0;
|
||||||
|
ssize_t sz;
|
||||||
|
|
||||||
|
printf("Sending data read from %s file...\n", argv[2]);
|
||||||
|
while((sz = data.Read(buffer, sizeof(buffer))) > 0) {
|
||||||
|
if (io->Write(buffer, sz) < 0) {
|
||||||
|
printf("Error writting on the print transport stream!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
total += sz;
|
||||||
|
} // while
|
||||||
|
printf("%ld data bytes sent.\n", total);
|
||||||
|
} // data valid file
|
||||||
|
} // optional data file
|
||||||
|
|
||||||
if (exit_proc) {
|
if (exit_proc) {
|
||||||
printf("Exiting %s...\n", transport);
|
printf("Exiting %s...\n", transport);
|
||||||
(*exit_proc)();
|
(*exit_proc)();
|
||||||
|
|||||||
Reference in New Issue
Block a user