Small change lost in the void: search in common addons dir too.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39152 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -11,9 +11,9 @@
|
|||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
image_id addon;
|
image_id addon = -1;
|
||||||
char *transport;
|
char *transport;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
printf("Usage: %s <transport add-on name> [<file to print>]\n", argv[0]);
|
printf("Usage: %s <transport add-on name> [<file to print>]\n", argv[0]);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -23,40 +23,40 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
transport = argv[1];
|
transport = argv[1];
|
||||||
|
|
||||||
printf("Looking for %s transport addon:", transport);
|
printf("Looking for %s transport addon:\n", transport);
|
||||||
|
|
||||||
// try first in user add-ons directory
|
|
||||||
printf("In user add-ons directory...\n");
|
|
||||||
|
|
||||||
|
directory_which which[] = {
|
||||||
|
B_USER_ADDONS_DIRECTORY,
|
||||||
|
B_COMMON_ADDONS_DIRECTORY,
|
||||||
|
B_SYSTEM_ADDONS_DIRECTORY
|
||||||
|
};
|
||||||
BPath path;
|
BPath path;
|
||||||
find_directory(B_USER_ADDONS_DIRECTORY, &path);
|
for (uint32 i = 0; i <sizeof(which) / sizeof(which[0]); i++) {
|
||||||
path.Append("Print/transport");
|
if (find_directory(which[i], &path, false) != B_OK)
|
||||||
path.Append(transport);
|
continue;
|
||||||
|
|
||||||
addon = load_add_on(path.Path());
|
|
||||||
if (addon < 0) {
|
|
||||||
// on failure try in system add-ons directory
|
|
||||||
|
|
||||||
printf("In system add-ons directory...\n");
|
|
||||||
find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
|
|
||||||
path.Append("Print/transport");
|
path.Append("Print/transport");
|
||||||
path.Append(transport);
|
path.Append(transport);
|
||||||
|
|
||||||
|
printf("\t%s ?\n", path.Path());
|
||||||
addon = load_add_on(path.Path());
|
addon = load_add_on(path.Path());
|
||||||
|
if (addon >= B_OK)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addon < 0) {
|
if (addon == B_ERROR) {
|
||||||
// failed to load transport add-on
|
// failed to load transport add-on
|
||||||
printf("Failed to load %s print transport add-on!\n", transport);
|
printf("Failed to load \"%s\" print transport add-on!\n", transport);
|
||||||
return B_ERROR;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Loaded from %s\n", path.Path());
|
printf("Add-on %d = \"%s\" loaded from %s.\n", (int) addon,
|
||||||
|
transport, path.Path());
|
||||||
|
|
||||||
// get init & exit proc
|
// get init & exit proc
|
||||||
BDataIO* (*init_proc)(BMessage*);
|
BDataIO* (*init_proc)(BMessage*);
|
||||||
void (*exit_proc)(void);
|
void (*exit_proc)(void);
|
||||||
|
|
||||||
get_image_symbol(addon, "init_transport", B_SYMBOL_TYPE_TEXT, (void **) &init_proc);
|
get_image_symbol(addon, "init_transport", B_SYMBOL_TYPE_TEXT, (void **) &init_proc);
|
||||||
get_image_symbol(addon, "exit_transport", B_SYMBOL_TYPE_TEXT, (void **) &exit_proc);
|
get_image_symbol(addon, "exit_transport", B_SYMBOL_TYPE_TEXT, (void **) &exit_proc);
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ int main (int argc, char *argv[])
|
|||||||
// TODO: create on the fly a temporary printer folder for testing purpose only
|
// 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);
|
||||||
|
|
||||||
if (io) {
|
if (io) {
|
||||||
printf("done.\nTransport parameters msg =>\n");
|
printf("done.\nTransport parameters msg =>\n");
|
||||||
msg.PrintToStream();
|
msg.PrintToStream();
|
||||||
@@ -89,7 +89,7 @@ int main (int argc, char *argv[])
|
|||||||
uint8 buffer[B_PAGE_SIZE];
|
uint8 buffer[B_PAGE_SIZE];
|
||||||
ssize_t total = 0;
|
ssize_t total = 0;
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
|
|
||||||
printf("Sending data read from %s file...\n", argv[2]);
|
printf("Sending data read from %s file...\n", argv[2]);
|
||||||
while((sz = data.Read(buffer, sizeof(buffer))) > 0) {
|
while((sz = data.Read(buffer, sizeof(buffer))) > 0) {
|
||||||
if (io->Write(buffer, sz) < 0) {
|
if (io->Write(buffer, sz) < 0) {
|
||||||
@@ -101,14 +101,14 @@ int main (int argc, char *argv[])
|
|||||||
printf("%ld data bytes sent.\n", total);
|
printf("%ld data bytes sent.\n", total);
|
||||||
} // data valid file
|
} // data valid file
|
||||||
} // optional data file
|
} // optional data file
|
||||||
|
|
||||||
if (exit_proc) {
|
if (exit_proc) {
|
||||||
printf("Exiting %s...\n", transport);
|
printf("Exiting %s...\n", transport);
|
||||||
(*exit_proc)();
|
(*exit_proc)();
|
||||||
}
|
}
|
||||||
|
|
||||||
unload_add_on(addon);
|
unload_add_on(addon);
|
||||||
printf("%s unloaded.\n", transport);
|
printf("%s unloaded.\n", transport);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user