aboutsummaryrefslogtreecommitdiff
path: root/sfmain.c
diff options
context:
space:
mode:
Diffstat (limited to 'sfmain.c')
-rw-r--r--sfmain.c129
1 files changed, 67 insertions, 62 deletions
diff --git a/sfmain.c b/sfmain.c
index 0bedbea..9b85da5 100644
--- a/sfmain.c
+++ b/sfmain.c
@@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <ctype.h>
+#include "kitten.h"
#include "version.h"
#include "dlog.h"
#include "vboxshfl.h"
@@ -34,6 +35,8 @@
#include "unicode.h"
#include "lfn.h"
+nl_catd cat;
+
static char get_drive_letter(const char *path) {
if (!path || path[0] == '\0') return '\0';
if (path[1] == '\0' || (path[1] == ':' && path[2] == '\0')) {
@@ -68,7 +71,7 @@ static int list_folders(LPTSRDATA data)
unsigned num_maps = sizeof(maps) / sizeof(SHFLMAPPING);
unsigned i;
- printf("Mounted drives:\n");
+ printf(kittengets(1, 0, "Mounted drives:\n"));
for (i = 0; i < NUM_DRIVES; i++) {
if (data->drives[i].root == SHFL_ROOT_NIL) {
@@ -78,26 +81,26 @@ static int list_folders(LPTSRDATA data)
err = vbox_shfl_query_map_name(&data->vb, data->hgcm_client_id, data->drives[i].root, &str.shflstr);
if (err) {
- printf("Error on Query Map Name, err=%ld\n", err);
+ printf(kittengets(3, 0, "Error on Query Map Name, err=%ld\n"), err);
continue;
}
(void)utf8_to_local(data, str.buf, str.buf, NULL);
- printf(" %s on %c:\n", str.buf, drive_index_to_letter(i));
+ printf(kittengets(1, 1, " %s on %c:\n"), str.buf, drive_index_to_letter(i));
}
err = vbox_shfl_query_mappings(&data->vb, data->hgcm_client_id, 0, &num_maps, maps);
if (err) {
- printf("Error on Query Mappings, err=%ld\n", err);
+ printf(kittengets(3, 1, "Error on Query Mappings, err=%ld\n"), err);
return err;
}
- printf("Available shared folders:\n");
+ printf(kittengets(1, 2, "Available shared folders:\n"));
for (i = 0 ; i < num_maps; i++) {
err = vbox_shfl_query_map_name(&data->vb, data->hgcm_client_id, maps[i].root, &str.shflstr);
if (err) {
- printf("Error on Query Map Name, err=%ld\n", err);
+ printf(kittengets(3, 0, "Error on Query Map Name, err=%ld\n"), err);
continue;
}
@@ -133,7 +136,7 @@ static void close_openfiles(LPTSRDATA data, int drive)
err = vbox_shfl_close(&data->vb, data->hgcm_client_id, data->files[i].root, data->files[i].handle);
if (err) {
- printf("Error on Close File, err=%ld\n", err);
+ printf(kittengets(3, 2, "Error on Close File, err=%ld\n"), err);
// Ignore it
}
@@ -153,7 +156,7 @@ static int mount_shfl(LPTSRDATA data, int drive, const char *folder)
err = vbox_shfl_map_folder(&data->vb, data->hgcm_client_id, &str.shflstr, &root);
if (err) {
- fprintf(stderr, "Cannot mount shared folder '%s', err=%d\n", folder, err);
+ fprintf(stderr, kittengets(3, 3, "Cannot mount shared folder '%s', err=%d\n"), folder, err);
return -1;
}
@@ -162,7 +165,7 @@ static int mount_shfl(LPTSRDATA data, int drive, const char *folder)
err = vbox_shfl_query_map_info(&data->vb, data->hgcm_client_id, root,
&str.shflstr, &str.shflstr, &flags, &version);
if (err) {
- printf("Error on Query Map Info for mounted drive, err=%ld\n", err);
+ printf(kittengets(3, 4, "Error on Query Map Info for mounted drive, err=%ld\n"), err);
return -1;
}
@@ -181,7 +184,7 @@ static int unmount_shfl(LPTSRDATA data, int drive)
err = vbox_shfl_unmap_folder(&data->vb, data->hgcm_client_id,
data->drives[drive].root);
if (err) {
- fprintf(stderr, "Cannot unmount shared folder, err=%d\n", err);
+ fprintf(stderr, kittengets(3, 5, "Cannot unmount shared folder, err=%d\n"), err);
return -1;
}
@@ -197,29 +200,29 @@ static int mount(LPTSRDATA data, char *folder, char drive_letter)
DOSCDS __far *cds;
if (drive < 0) {
- fprintf(stderr, "Invalid drive %c:\n", drive_letter);
+ fprintf(stderr, kittengets(3, 6, "Invalid drive %c:\n"), drive_letter);
return EXIT_FAILURE;
}
if (drive >= lol->last_drive || drive >= NUM_DRIVES) {
- fprintf(stderr, "Drive %c: is after LASTDRIVE\n", drive_letter);
+ fprintf(stderr, kittengets(3, 7, "Drive %c: is after LASTDRIVE\n"), drive_letter);
return EXIT_FAILURE;
}
if (data->drives[drive].root != SHFL_ROOT_NIL) {
- fprintf(stderr, "Drive %c already mounted\n", drive_letter);
+ fprintf(stderr, kittengets(3, 8, "Drive %c already mounted\n"), drive_letter);
return EXIT_FAILURE;
}
cds = &lol->cds[drive];
if (cds->flags) {
- fprintf(stderr, "Drive %c: already exists\n", drive_letter);
+ fprintf(stderr, kittengets(3, 9, "Drive %c: already exists\n"), drive_letter);
return EXIT_FAILURE;
}
if (mount_shfl(data, drive, folder) != 0) {
- fprintf(stderr, "Cannot mount drive %c:\n", drive_letter);
+ fprintf(stderr, kittengets(3, 10, "Cannot mount drive %c:\n"), drive_letter);
return EXIT_FAILURE;
}
@@ -228,7 +231,7 @@ static int mount(LPTSRDATA data, char *folder, char drive_letter)
cds->flags = DOS_CDS_FLAG_NETWORK | DOS_CDS_FLAG_PHYSICAL;
(void)utf8_to_local(data, folder, folder, NULL);
- printf("Shared folder '%s' mounted as drive %c:\n", folder, drive_letter);
+ printf(kittengets(1, 3, "Shared folder '%s' mounted as drive %c:\n"), folder, drive_letter);
return EXIT_SUCCESS;
}
@@ -240,19 +243,19 @@ static int unmount(LPTSRDATA data, char drive_letter)
DOSCDS __far *cds;
if (drive < 0) {
- fprintf(stderr, "Invalid drive %c:\n", drive_letter);
+ fprintf(stderr, kittengets(3, 6, "Invalid drive %c:\n"), drive_letter);
return EXIT_FAILURE;
}
if (drive >= lol->last_drive || drive >= NUM_DRIVES) {
- fprintf(stderr, "Drive %c: is after LASTDRIVE\n", drive_letter);
+ fprintf(stderr, kittengets(3, 7, "Drive %c: is after LASTDRIVE\n"), drive_letter);
return EXIT_FAILURE;
}
cds = &lol->cds[drive];
if (data->drives[drive].root == SHFL_ROOT_NIL) {
- fprintf(stderr, "Drive %c not mounted\n", drive_letter);
+ fprintf(stderr, kittengets(3, 11, "Drive %c not mounted\n"), drive_letter);
return EXIT_FAILURE;
}
@@ -265,7 +268,7 @@ static int unmount(LPTSRDATA data, char drive_letter)
// TODO Clear current directory ?
- printf("Drive %c: unmounted\n", drive_letter);
+ printf(kittengets(1, 4, "Drive %c: unmounted\n"), drive_letter);
return EXIT_SUCCESS;
}
@@ -283,7 +286,7 @@ static int automount(LPTSRDATA data)
err = vbox_shfl_query_mappings(&data->vb, data->hgcm_client_id,
SHFL_MF_AUTOMOUNT, &num_maps, maps);
if (err) {
- printf("Error on Query Mappings, err=%ld\n", err);
+ printf(kittengets(3, 1, "Error on Query Mappings, err=%ld\n"), err);
return err;
}
@@ -294,7 +297,7 @@ static int automount(LPTSRDATA data)
err = vbox_shfl_query_map_info(&data->vb, data->hgcm_client_id, maps[i].root,
&name.shflstr, &mountPoint.shflstr, &flags, &version);
if (err) {
- printf("Error on Query Map Info, err=%ld\n", err);
+ printf(kittengets(3, 12, "Error on Query Map Info, err=%ld\n"), err);
continue;
}
@@ -418,7 +421,7 @@ static void load_unicode_table(uint16_t far *unicode_table)
if (r.x.cflag) {
// Can't get codepage. Use ASCII only
//
- fputs("Warning: Active code page not found", stderr);
+ fputs(kittengets(2, 0, "Warning: Active code page not found"), stderr);
goto error;
}
@@ -426,31 +429,31 @@ static void load_unicode_table(uint16_t far *unicode_table)
_searchenv(filename, "PATH", fullpath);
if ( '\0' == fullpath[0] ) {
- fprintf(stderr, "Warning: Can't find Unicode table: %s", filename);
+ fprintf(stderr, kittengets(2, 1, "Warning: Can't find Unicode table: %s"), filename);
goto error;
}
f = fopen(fullpath, "rb");
if ( NULL == f ) {
- fprintf(stderr, "Warning: Can't load Unicode table: %s", filename);
+ fprintf(stderr, kittengets(2, 2, "Warning: Can't load Unicode table: %s"), filename);
goto error;
}
if ( EOF == fscanf_s(f, "Unicode (%s)", buffer, sizeof(buffer)) ) {
- fprintf(stderr, "Warning: Invalid file format: %s", filename);
+ fprintf(stderr, kittengets(2, 3, "Warning: Invalid file format: %s"), filename);
goto close;
}
ret = fread(buffer, 1, 3, f);
if ( ret != 3 || buffer[0] != '\r' || buffer[1] != '\n' || buffer[2] != 1 ) {
- fprintf(stderr, "Warning: Invalid file format: %s", filename);
+ fprintf(stderr, kittengets(2, 3, "Warning: Invalid file format: %s"), filename);
goto close;
}
if ( 256 != (ret = fread( buffer, 1, 256, f )) ) {
- fprintf(stderr, "Warning: Can't load Unicode table: %s", filename);
+ fprintf(stderr, kittengets(2, 2, "Warning: Can't load Unicode table: %s"), filename);
goto close;
}
@@ -461,7 +464,7 @@ static void load_unicode_table(uint16_t far *unicode_table)
close:
fclose(f);
error:
- fputs( ". Defaulting to cp437\n", stderr );
+ fputs(kittengets(2, 4, ". Defaulting to cp437\n"), stderr );
}
@@ -488,7 +491,7 @@ static int configure_driver(LPTSRDATA data, bool short_fnames, uint8_t hash_char
// Get the current timezone offset
if (getenv("TZ")) {
tzset();
- printf("Using timezone from TZ variable (%s)\n", tzname[0]);
+ printf(kittengets(1, 5, "Using timezone from TZ variable (%s)\n"), tzname[0]);
data->tz_offset = timezone / 2;
} else {
data->tz_offset = 0;
@@ -497,7 +500,7 @@ static int configure_driver(LPTSRDATA data, bool short_fnames, uint8_t hash_char
// Get uppercase and valid file char tables
err = get_nls(&data->file_upper_case, &data->file_char);
if (err) {
- puts("Cannot get the NLS tables.");
+ puts(kittengets(3, 13, "Cannot get the NLS tables"));
return -1;
}
@@ -510,37 +513,37 @@ static int configure_driver(LPTSRDATA data, bool short_fnames, uint8_t hash_char
// Now try to initialize VirtualBox communication
err = vbox_init_device(&data->vb);
if (err) {
- fprintf(stderr, "Cannot find VirtualBox PCI device, err=%ld\n", err);
+ fprintf(stderr, kittengets(3, 14, "Cannot find VirtualBox PCI device, err=%ld\n"), err);
return -1;
}
err = vbox_init_buffer(&data->vb, VBOX_BUFFER_SIZE);
if (err) {
- fprintf(stderr, "Cannot lock buffer used for VirtualBox communication, err=%ld\n", err);
+ fprintf(stderr, kittengets(3, 15, "Cannot lock buffer used for VirtualBox communication, err=%ld\n"), err);
return -1;
}
err = vbox_report_guest_info(&data->vb, VBOXOSTYPE_DOS);
if (err) {
- fprintf(stderr, "VirtualBox communication is not working, err=%ld\n", err);
+ fprintf(stderr, kittengets(3, 16, "VirtualBox communication is not working, err=%ld\n"), err);
return -1;
}
err = vbox_hgcm_connect_existing(&data->vb, "VBoxSharedFolders", &data->hgcm_client_id);
if (err) {
- printf("Cannot connect to shared folder service, err=%ld\n", err);
+ printf(kittengets(3, 17, "Cannot connect to shared folder service, err=%ld\n"), err);
return -1;
}
err = vbox_shfl_set_utf8(&data->vb, data->hgcm_client_id);
if (err) {
- printf("Cannot configure UTF-8 on shared folder service, err=%ld\n", err);
+ printf(kittengets(3, 18, "Cannot configure UTF-8 on shared folder service, err=%ld\n"), err);
return -1;
}
load_unicode_table( &data->unicode_table);
- printf("Connected to VirtualBox shared folder service\n");
+ printf(kittengets(1, 6, "Connected to VirtualBox shared folder service\n"));
return 0;
}
@@ -570,7 +573,7 @@ static __declspec(aborts) int install_driver(LPTSRDATA data, bool high)
data->prev_int2f_handler = _dos_getvect(0x2f);
_dos_setvect(0x2f, data:>int2f_isr);
- printf("Driver installed\n");
+ printf(kittengets(1, 7, "Driver installed\n"));
// If we reallocated ourselves to UMB,
// it's time to free our initial conventional memory allocation
@@ -578,6 +581,7 @@ static __declspec(aborts) int install_driver(LPTSRDATA data, bool high)
finish_reallocation(_psp, FP_SEG(data));
}
+ kittenclose();
_dos_keep(EXIT_SUCCESS, get_paragraphs(resident_size));
// Shouldn't reach this part
@@ -591,7 +595,7 @@ static bool check_if_driver_uninstallable(LPTSRDATA data)
// Compare the segment of the installed handler to see if its ours
// or someone else's
if (FP_SEG(cur_int2f_handler) != FP_SEG(data)) {
- fprintf(stderr, "INT2F has been hooked by someone else, cannot safely remove\n");
+ fprintf(stderr, kittengets(3, 19, "INT2F has been hooked by someone else, cannot safely remove\n"));
return false;
}
@@ -618,48 +622,47 @@ static int uninstall_driver(LPTSRDATA data)
// it is always 256 bytes (16 paragraphs) before the TSR segment
dos_free(FP_SEG(data) - (DOS_PSP_SIZE/16));
- printf("Driver uninstalled\n");
+ printf(kittengets(1, 8, "Driver uninstalled\n"));
return 0;
}
static int driver_not_found(void)
{
- fprintf(stderr, "Driver data not found (driver not installed?)\n");
+ fprintf(stderr, kittengets(3, 20, "Driver data not found (driver not installed?)\n"));
return EXIT_FAILURE;
}
static void print_help(void)
{
- printf("\n"
- "Usage: \n"
- " VBSF <ACTION> <ARGS..>\n\n"
- "Supported actions:\n"
- " install install the driver (default)\n"
- " low install in conventional memory (otherwise UMB)\n"
- " short use short file names from windows hosts\n"
- " hash <n> number of hash generated chars following the '~'\n"
- " for generating DOS valid files\n"
- " (%d min, %d max, %d default)\n"
- " uninstall uninstall the driver from memory\n"
- " list list available shared folders\n"
- " mount <FOLD> <X:> mount a shared folder into drive X:\n"
- " umount <X:> unmount shared folder from drive X:\n"
- " rescan unmount everything and recreate automounts\n",
- MIN_HASH_CHARS, MAX_HASH_CHARS, DEF_HASH_CHARS
- );
+ puts(kittengets(0, 0, "\n"
+ "Usage: "));
+ puts(kittengets(0, 1, " VBSF <ACTION> <ARGS..>\n"));
+ puts(kittengets(0, 2, "Supported actions:"));
+ puts(kittengets(0, 3, " install install the driver (default)"));
+ puts(kittengets(0, 4, " low install in conventional memory (otherwise UMB)"));
+ puts(kittengets(0, 5, " short use short file names from windows hosts"));
+ puts(kittengets(0, 6, " hash <n> number of hash generated chars following the '~'"));
+ puts(kittengets(0, 7, " for generating DOS valid files"));
+ printf(kittengets(0, 8, " (%d min, %d max, %d default)\n"),
+ MIN_HASH_CHARS, MAX_HASH_CHARS, DEF_HASH_CHARS);
+ puts(kittengets(0, 9, " uninstall uninstall the driver from memory"));
+ puts(kittengets(0, 10, " list list available shared folders"));
+ puts(kittengets(0, 11, " mount <FOLD> <X:> mount a shared folder into drive X:"));
+ puts(kittengets(0, 12, " umount <X:> unmount shared folder from drive X:"));
+ puts(kittengets(0, 13, " rescan unmount everything and recreate automounts"));
}
static int invalid_arg(const char *s)
{
- fprintf(stderr, "Invalid argument '%s'\n", s);
+ fprintf(stderr, kittengets(3, 21, "Invalid argument '%s'\n"), s);
print_help();
return EXIT_FAILURE;
}
static int arg_required(const char *s)
{
- fprintf(stderr, "Argument required for '%s'\n", s);
+ fprintf(stderr, kittengets(3, 22, "Argument required for '%s'\n"), s);
print_help();
return EXIT_FAILURE;
}
@@ -692,6 +695,8 @@ int main(int argc, const char *argv[])
int err, argi = 1;
SHFLSTRING_WITH_BUF(utf8name, SHFL_MAX_LEN);
+ cat = kittenopen("vbsf");
+
if (argi >= argc || stricmp(argv[argi], "install") == 0) {
uint8_t hash_chars = DEF_HASH_CHARS;
bool high = true;
@@ -717,10 +722,10 @@ int main(int argc, const char *argv[])
}
}
- printf("\nVBSharedFolders %x.%x\n", VERSION_MAJOR, VERSION_MINOR);
+ printf(kittengets(1, 9, "\nVBSharedFolders %x.%x\n"), VERSION_MAJOR, VERSION_MINOR);
if (data) {
- printf("VBSF already installed\n");
+ printf(kittengets(1, 10, "VBSF already installed\n"));
print_help();
return EXIT_SUCCESS;
}