X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=changer-src%2Fchg-scsi.c;h=46d4801621da68e7c6a0a6cc0b9f25680f3741a5;hb=94a044f90357edefa6f4ae9f0b1d5885b0e34aee;hp=f4b904efd38be9d56385b9c2e6ea32dd2115fd1d;hpb=d3b2175e084f88c8736ad7073eacbf4670147aec;p=debian%2Famanda diff --git a/changer-src/chg-scsi.c b/changer-src/chg-scsi.c index f4b904e..46d4801 100644 --- a/changer-src/chg-scsi.c +++ b/changer-src/chg-scsi.c @@ -189,68 +189,68 @@ dump_changer_struct( { int i; - dbprintf(("Number of configurations: %d\n",chg->number_of_configs)); - dbprintf(("Tapes need eject: %s\n",(chg->eject>0?"Yes":"No"))); - dbprintf (("\traw: %d\n",chg->eject)); - dbprintf(("Inv. auto update: %s\n",(chg->autoinv>0?"Yes":"No"))); - dbprintf (("\traw: %d\n",chg->autoinv)); - dbprintf(("barcode reader : %s\n",(chg->havebarcode>0?"Yes":"No"))); - dbprintf (("\traw: %d\n",chg->havebarcode)); - dbprintf(("Emulate Barcode : %s\n",(chg->emubarcode>0?"Yes":"No"))); - dbprintf (("\traw: %d\n",chg->emubarcode)); + dbprintf(_("Number of configurations: %d\n"), chg->number_of_configs); + dbprintf(_("Tapes need eject: %s\n"), (chg->eject>0 ? _("Yes") : _("No"))); + dbprintf (_("\traw: %d\n"),chg->eject); + dbprintf(_("Inv. auto update: %s\n"), (chg->autoinv>0 ? _("Yes") : _("No"))); + dbprintf (_("\traw: %d\n"),chg->autoinv); + dbprintf(_("barcode reader : %s\n"), (chg->havebarcode>0 ? _("Yes") : _("No"))); + dbprintf (_("\traw: %d\n"),chg->havebarcode); + dbprintf(_("Emulate Barcode : %s\n"), (chg->emubarcode>0 ? _("Yes") : _("No"))); + dbprintf (_("\traw: %d\n"),chg->emubarcode); if (chg->debuglevel != NULL) - dbprintf(("debug level : %s\n", chg->debuglevel)); - dbprintf(("Tapes need sleep: %d seconds\n", (int)chg->sleep)); - dbprintf(("Cleancycles : %d\n",chg->cleanmax)); - dbprintf(("Changerdevice : %s\n",chg->device)); + dbprintf(_("debug level : %s\n"), chg->debuglevel); + dbprintf(_("Tapes need sleep: %ld seconds\n"), (long int)chg->sleep); + dbprintf(_("Clean cycles : %d\n"), chg->cleanmax); + dbprintf(_("Changer device : %s\n"), chg->device); if (chg->labelfile != NULL) - dbprintf(("Labelfile : %s\n", chg->labelfile)); + dbprintf(_("Label file : %s\n"), chg->labelfile); for (i=0; inumber_of_configs; i++){ - dbprintf(("Tapeconfig Nr: %d\n",i)); - dbprintf((" Drivenumber : %d\n",chg->conf[i].drivenum)); - dbprintf((" Startslot : %d\n",chg->conf[i].start)); - dbprintf((" Endslot : %d\n",chg->conf[i].end)); - dbprintf((" Cleanslot : %d\n",chg->conf[i].cleanslot)); + dbprintf(_("Tape config Nr: %d\n"), i); + dbprintf(_(" Drive number : %d\n"), chg->conf[i].drivenum); + dbprintf(_(" Start slot : %d\n"), chg->conf[i].start); + dbprintf(_(" End slot : %d\n"), chg->conf[i].end); + dbprintf(_(" Clean slot : %d\n"), chg->conf[i].cleanslot); if (chg->conf[i].device != NULL) - dbprintf((" Devicename : %s\n",chg->conf[i].device)); + dbprintf(_(" Device name : %s\n"), chg->conf[i].device); else - dbprintf((" Devicename : none\n")); + dbprintf(_(" Device name : none\n")); if (chg->conf[i].changerident != NULL) - dbprintf((" changerident : %s\n",chg->conf[i].changerident)); + dbprintf(_(" changer ident : %s\n"), chg->conf[i].changerident); else - dbprintf((" changerident : none\n")); + dbprintf(_(" changer ident : none\n")); if (chg->conf[i].scsitapedev != NULL) - dbprintf((" SCSITapedev : %s\n",chg->conf[i].scsitapedev)); + dbprintf(_(" SCSI Tape dev : %s\n"), chg->conf[i].scsitapedev); else - dbprintf((" SCSITapedev : none\n")); + dbprintf(_(" SCSI Tape dev : none\n")); if (chg->conf[i].tapeident != NULL) - dbprintf((" tapeident : %s\n",chg->conf[i].tapeident)); + dbprintf(_(" tape ident : %s\n"), chg->conf[i].tapeident); else - dbprintf((" tapeident : none\n")); + dbprintf(_(" tape ident : none\n")); if (chg->conf[i].tapestatfile != NULL) - dbprintf((" statfile : %s\n", chg->conf[i].tapestatfile)); + dbprintf(_(" stat file : %s\n"), chg->conf[i].tapestatfile); else - dbprintf((" statfile : none\n")); + dbprintf(_(" stat file : none\n")); if (chg->conf[i].slotfile != NULL) - dbprintf((" Slotfile : %s\n",chg->conf[i].slotfile)); + dbprintf(_(" Slot file : %s\n"), chg->conf[i].slotfile); else - dbprintf((" Slotfile : none\n")); + dbprintf(_(" Slot file : none\n")); if (chg->conf[i].cleanfile != NULL) - dbprintf((" Cleanfile : %s\n",chg->conf[i].cleanfile)); + dbprintf(_(" Clean file : %s\n"), chg->conf[i].cleanfile); else - dbprintf((" Cleanfile : none\n")); + dbprintf(_(" Clean file : none\n")); if (chg->conf[i].timefile != NULL) - dbprintf((" Usagecount : %s\n",chg->conf[i].timefile)); + dbprintf(_(" Usage count : %s\n"), chg->conf[i].timefile); else - dbprintf((" Usagecount : none\n")); + dbprintf(_(" Usage count : none\n")); } } @@ -351,7 +351,7 @@ read_config( } else { numconf = atoi(value); if (numconf < 1 || numconf > 100) { - fprintf(stderr,"numconf %d is bad\n", numconf); + g_fprintf(stderr,_("numconf %d is bad\n"), numconf); numconf = 1; } init_changer_struct(chg, numconf); @@ -360,8 +360,8 @@ read_config( } switch (token) { case NUMDRIVE: if (atoi(value) != numconf) - fprintf(stderr,"Error: number_drives at wrong place, should be "\ - "first in file\n"); + g_fprintf(stderr,_("Error: number_drives at wrong place, should be " + "first in file\n")); break; case AUTOINV: chg->autoinv = 1; @@ -396,7 +396,7 @@ read_config( case CHANGERIDENT: chg->conf[drivenum].changerident = stralloc(value); if (drivenum < 0 || drivenum > 100) { - fprintf(stderr,"drivenum %d is bad\n", drivenum); + g_fprintf(stderr,_("drivenum %d is bad\n"), drivenum); drivenum = 0; } if (strcmp(chg->conf[drivenum].changerident,"generic_changer") != 0) { @@ -420,10 +420,10 @@ read_config( case DRIVE: drivenum = atoi(value); if (drivenum < 0) { - fprintf(stderr,"Error: drive must be >= 0\n"); + g_fprintf(stderr,_("Error: drive must be >= 0\n")); drivenum = 0; } else if (drivenum >= numconf) { - fprintf(stderr,"Error: drive must be less than number_drives\n"); + g_fprintf(stderr,_("Error: drive must be less than number_drives\n")); drivenum = numconf; } break; @@ -431,68 +431,68 @@ read_config( if (drivenum < numconf){ chg->conf[drivenum].drivenum = atoi(value); } else { - fprintf(stderr,"Error: drive is not less than number_drives"\ - " drivenum ignored\n"); + g_fprintf(stderr,_("Error: drive is not less than number_drives" + " drivenum ignored\n")); } break; case START: if (drivenum < numconf){ chg->conf[drivenum].start = atoi(value); } else { - fprintf(stderr,"Error: drive is not less than number_drives"\ - " startuse ignored\n"); + g_fprintf(stderr,_("Error: drive is not less than number_drives" + " startuse ignored\n")); } break; case END: if (drivenum < numconf){ chg->conf[drivenum].end = atoi(value); } else { - fprintf(stderr,"Error: drive is not less than number_drives"\ - " enduse ignored\n"); + g_fprintf(stderr,_("Error: drive is not less than number_drives" + " enduse ignored\n")); } break; case CLEAN: if (drivenum < numconf){ chg->conf[drivenum].cleanslot = atoi(value); } else { - fprintf(stderr,"Error: drive is not less than number_drives"\ - " cleanslot ignored\n"); + g_fprintf(stderr,_("Error: drive is not less than number_drives" + " cleanslot ignored\n")); } break; case DEVICE: if (drivenum < numconf){ chg->conf[drivenum].device = stralloc(value); } else { - fprintf(stderr,"Error: drive is not less than number_drives"\ - " device ignored\n"); + g_fprintf(stderr,_("Error: drive is not less than number_drives" + " device ignored\n")); } break; case STATFILE: if (drivenum < numconf){ chg->conf[drivenum].slotfile = stralloc(value); } else { - fprintf(stderr,"Error: drive is not less than number_drives"\ - " slotfile ignored\n"); + g_fprintf(stderr,_("Error: drive is not less than number_drives" + " slotfile ignored\n")); } break; case CLEANFILE: if (drivenum < numconf){ chg->conf[drivenum].cleanfile = stralloc(value); } else { - fprintf(stderr,"Error: drive is not less than number_drives"\ - " cleanfile ignored\n"); + g_fprintf(stderr,_("Error: drive is not less than number_drives" + " cleanfile ignored\n")); } break; case USAGECOUNT: if (drivenum < numconf){ chg->conf[drivenum].timefile = stralloc(value); } else { - fprintf(stderr,"Error: drive is not less than number_drives"\ - " usagecount ignored\n"); + g_fprintf(stderr,_("Error: drive is not less than number_drives" + " usagecount ignored\n")); } break; default: - fprintf(stderr,"Error: Unknown token\n"); + g_fprintf(stderr,_("Error: Unknown token\n")); break; } } @@ -518,7 +518,7 @@ get_current_slot( int retval = -1; int ret; /* return value for the fscanf function */ if ((inf=fopen(count_file,"r")) == NULL) { - fprintf(stderr, "%s: unable to open (%s)\n", + g_fprintf(stderr, _("%s: unable to open (%s)\n"), get_pname(), count_file); exit(2); } @@ -552,11 +552,11 @@ put_current_slot( return; if ((inf=fopen(count_file,"w")) == NULL) { - fprintf(stderr, "%s: unable to open current slot file (%s)\n", + g_fprintf(stderr, _("%s: unable to open current slot file (%s)\n"), get_pname(), count_file); exit(2); } - fprintf(inf, "%d\n", slot); + g_fprintf(inf, "%d\n", slot); fclose(inf); } @@ -589,8 +589,8 @@ MapBarCode( long pos; int rc; - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : Parameter\n"); - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"labelfile -> %s, vol -> %s, barcode -> %s, action -> %c, slot -> %d, from -> %d\n", + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : Parameter\n")); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("labelfile -> %s, vol -> %s, barcode -> %s, action -> %c, slot -> %d, from -> %d\n"), labelfile, result->data.voltag, result->data.barcode, @@ -600,47 +600,47 @@ MapBarCode( if (labelfile == NULL) { - DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,"Got empty labelfile (NULL)\n"); - ChgExit("MapBarCode", "MapBarCode name of labelfile is not set\n",FATAL); + DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,_("Got empty labelfile (NULL)\n")); + ChgExit("MapBarCode", _("MapBarCode name of labelfile is not set\n"),FATAL); /*NOTREACHED*/ } if (access(labelfile, F_OK) == -1) { - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE, "MapBarCode : creating %s", labelfile); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE, _("MapBarCode : creating %s"), labelfile); if ((fp = fopen(labelfile, "w+")) == NULL) { - DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE," failed\n"); - ChgExit("MapBarCode", "MapBarCode, creating labelfile failed\n", FATAL); + DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,_(" failed\n")); + ChgExit("MapBarCode", _("MapBarCode, creating labelfile failed\n"), FATAL); /*NOTREACHED*/ } - fprintf(fp,":%d:", LABEL_DB_VERSION); + g_fprintf(fp,":%d:", LABEL_DB_VERSION); fclose(fp); } if ((fp = fopen(labelfile, "r+")) == NULL) { - DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,"MapBarCode : failed to open %s\n", labelfile); - ChgExit("MapBarCode", "MapBarCode, opening labelfile for read/write failed\n", FATAL); + DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,_("MapBarCode : failed to open %s\n"), labelfile); + ChgExit("MapBarCode", _("MapBarCode, opening labelfile for read/write failed\n"), FATAL); /*NOTREACHED*/ } if (fscanf(fp,":%d:", &version) != 1) { - ChgExit("MapBarCode", "MapBarCode, DB Version unreadable.\n", FATAL); + ChgExit("MapBarCode", _("MapBarCode, DB Version unreadable.\n"), FATAL); /*NOTREACHED*/ } - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : DB version %d\n", version); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : DB version %d\n"), version); pos = ftell(fp); if (version != LABEL_DB_VERSION) { - ChgExit("MapBarCode", "MapBarCode, DB Version does not match\n", FATAL); + ChgExit("MapBarCode", _("MapBarCode, DB Version does not match\n"), FATAL); /*NOTREACHED*/ } if (( plabelv2 = (LabelV2_T *)alloc(SIZEOF(LabelV2_T))) == NULL) { - DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,"MapBarCode : alloc failed\n"); - ChgExit("MapBarCode", "MapBarCode alloc failed\n", FATAL); + DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,_("MapBarCode : alloc failed\n")); + ChgExit("MapBarCode", _("MapBarCode alloc failed\n"), FATAL); /*NOTREACHED*/ } @@ -652,7 +652,7 @@ MapBarCode( if (rsize == SIZEOF(LabelV2_T)) { record++; - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : (%d) VolTag \"%s\", BarCode %s, inuse %d, slot %d, from %d, loadcount %d\n",record, + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : (%d) VolTag \"%s\", BarCode %s, inuse %d, slot %d, from %d, loadcount %d\n"),record, plabelv2->voltag, plabelv2->barcode, plabelv2->valid, @@ -665,7 +665,7 @@ MapBarCode( * Only dump the info */ case BARCODE_DUMP: - printf("Slot -> %d, from -> %d, valid -> %d, Tag -> %s, Barcode -> %s, Loadcount %u\n", + g_printf(_("Slot -> %d, from -> %d, valid -> %d, Tag -> %s, Barcode -> %s, Loadcount %u\n"), plabelv2->slot, plabelv2->from, plabelv2->valid, @@ -713,7 +713,7 @@ MapBarCode( if (strcmp(plabelv2->barcode, result->data.barcode) == 0) { - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : update entry\n"); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : update entry\n")); if (fseek(fp, pos, SEEK_SET) == -1) { fclose(fp); amfree(plabelv2); @@ -740,7 +740,7 @@ MapBarCode( case FIND_SLOT: if (strcmp(plabelv2->voltag, result->data.voltag) == 0) { - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode FIND_SLOT : \n"); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode FIND_SLOT : \n")); memcpy(&(result->data), plabelv2, SIZEOF(LabelV2_T)); amfree(plabelv2); return(1); @@ -754,7 +754,7 @@ MapBarCode( case UPDATE_SLOT: if (strcmp(plabelv2->voltag, result->data.voltag) == 0) { - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode UPDATE_SLOT : update entry\n"); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode UPDATE_SLOT : update entry\n")); if (fseek(fp, pos, SEEK_SET) == -1) { fclose(fp); amfree(plabelv2); @@ -781,12 +781,12 @@ MapBarCode( */ case BARCODE_VOL: /* - * DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode: (%d) inside BARCODE_VOL\n", record); - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"file value: %s, searched for value: %s\n", plabelv2->voltag, result->data.voltag); + * DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode: (%d) inside BARCODE_VOL\n"), record); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("file value: %s, searched for value: %s\n"), plabelv2->voltag, result->data.voltag); */ if (strcmp(plabelv2->voltag, result->data.voltag) == 0) { - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : VOL %s match\n", result->data.voltag); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : VOL %s match\n"), result->data.voltag); fclose(fp); memcpy(&(result->data), plabelv2, SIZEOF(LabelV2_T)); @@ -801,7 +801,7 @@ MapBarCode( case BARCODE_BARCODE: if (strcmp(plabelv2->barcode, result->data.barcode) == 0) { - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : BARCODE %s match\n", result->data.barcode); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : BARCODE %s match\n"), result->data.barcode); fclose(fp); memcpy(&(result->data), plabelv2, SIZEOF(LabelV2_T)); @@ -811,13 +811,13 @@ MapBarCode( break; default: - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : unknown action\n"); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : unknown action\n")); break; } pos = ftell(fp); } else { - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : feof (%d)\n", feof(fp)); - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : error in read record expect %d, got %d\n",SIZEOF(LabelV2_T), rsize); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : feof (%d)\n"), feof(fp)); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : error in read record expect %d, got %d\n"),SIZEOF(LabelV2_T), rsize); loop=0; } } @@ -836,7 +836,7 @@ MapBarCode( */ if (unusedpos != 0) { - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : reuse record %d\n", unusedrec); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,_("MapBarCode : reuse record %d\n"), unusedrec); if (fseek(fp, unusedpos, SEEK_SET) == -1) { fclose(fp); amfree(plabelv2); @@ -957,13 +957,13 @@ usage( char *argv[]) { int cnt; - printf("%s: Usage error.\n", argv[0]); + g_printf(_("%s: Usage error.\n"), argv[0]); for (cnt=0; cnt < COMCOUNT; cnt++){ - printf(" %s %s",argv[0],argdefs[cnt].str); + g_printf(" %s %s",argv[0],argdefs[cnt].str); if (argdefs[cnt].takesparam) - printf(" \n"); + g_printf(" \n"); else - printf("\n"); + g_printf("\n"); } exit(2); } @@ -978,7 +978,7 @@ parse_args( int i; for (i=0; i < argc; i++) - dbprintf(("ARG [%d] : %s\n", i, argv[i])); + dbprintf(_("ARG [%d] : %s\n"), i, argv[i]); i = 0; if ((argc<2)||(argc>3)) usage(argv); @@ -1048,7 +1048,7 @@ get_relative_target( default: break; } - printf(" no slot `%s'\n",parameter); + g_printf(_(" no slot `%s'\n"),parameter); close(fd); exit(2); /*NOTREACHED*/ @@ -1096,33 +1096,38 @@ clean_tape( char *mail_cmd = NULL; FILE *mailf = NULL; int mail_pipe_opened = 1; +#ifdef MAILER if(getconf_seen(CNF_MAILTO) && strlen(getconf_str(CNF_MAILTO)) > 0 && validate_mailto(getconf_str(CNF_MAILTO))) { mail_cmd = vstralloc(MAILER, - " -s", " \"", "AMANDA PROBLEM: PLEASE FIX", "\"", + " -s", " \"", _("AMANDA PROBLEM: PLEASE FIX"), "\"", " ", getconf_str(CNF_MAILTO), NULL); if((mailf = popen(mail_cmd, "w")) == NULL){ - printf("Mail failed\n"); - error("could not open pipe to \"%s\": %s", - mail_cmd, strerror(errno)); + g_printf(_("Mail failed\n")); + error(_("could not open pipe to \"%s\": %s"), + mail_cmd, strerror(errno)); /*NOTREACHED*/ } - } - else { + } else { mail_pipe_opened = 0; mailf = stderr; - fprintf(mailf, "\nNo mail recipient specified, output redirected to stderr"); + g_fprintf(mailf, _("\nNo mail recipient specified, output redirected to stderr")); } - fprintf(mailf,"\nThe usage count of your cleaning tape in slot %d", +#else + mail_pipe_opened = 0; + mailf = stderr; + g_fprintf(mailf, _("\nNo mailer specified; output redirected to stderr")); +#endif + g_fprintf(mailf,_("\nThe usage count of your cleaning tape in slot %d"), cleancart); - fprintf(mailf,"\nis more than %d. (cleanmax)",maxclean); - fprintf(mailf,"\nTapedrive %s needs to be cleaned",tapedev); - fprintf(mailf,"\nPlease insert a new cleaning tape and reset"); - fprintf(mailf,"\nthe countingfile %s",cnt_file); + g_fprintf(mailf,_("\nis more than %d. (cleanmax)"),maxclean); + g_fprintf(mailf,_("\nTapedrive %s needs to be cleaned"),tapedev); + g_fprintf(mailf,_("\nPlease insert a new cleaning tape and reset")); + g_fprintf(mailf,_("\nthe countingfile %s"),cnt_file); if(mail_pipe_opened == 1 && pclose(mailf) != 0) { - error("mail command failed: %s", mail_cmd); + error(_("mail command failed: %s"), mail_cmd); /*NOTREACHED*/ } return; @@ -1145,8 +1150,8 @@ clean_tape( int main( - int argc, - char *argv[]) + int argc, + char ** argv) { int loaded; int target, oldtarget; @@ -1190,6 +1195,15 @@ main( int param_index = 0; + /* + * Configure program for internationalization: + * 1) Only set the message locale for now. + * 2) Set textdomain for all amanda related programs to "amanda" + * We don't want to be forced to support dozens of message catalogs. + */ + setlocale(LC_MESSAGES, "C"); + textdomain("amanda"); + changer = alloc(SIZEOF(changer_t)); pbarcoderes = alloc(SIZEOF(MBC_T)); @@ -1202,7 +1216,7 @@ main( changer->labelfile = NULL; changer->conf = NULL; #ifdef CHG_SCSI_STANDALONE - printf("Ups standalone\n"); + g_printf(_("Ups standalone\n")); #else set_pname("chg-scsi"); @@ -1211,7 +1225,7 @@ main( dbopen(DBG_SUBDIR_SERVER); - dbprintf(("chg-scsi: %s\n", rcsid)); + dbprintf("chg-scsi: %s\n", rcsid); ChangerDriverVersion(); if (debug_file == NULL) @@ -1240,13 +1254,9 @@ main( break; } - if(read_conffile(CONFFILE_NAME)) { - perror(CONFFILE_NAME); - exit(1); - /*NOTREACHED*/ - } + config_init(CONFIG_INIT_USE_CWD | CONFIG_INIT_FATAL, NULL); - chg_scsi_conf = getconf_str(CNF_CHNGRFILE); + chg_scsi_conf = getconf_str(CNF_CHANGERFILE); tape_device = getconf_str(CNF_TAPEDEV); /* Get the configuration parameters */ @@ -1255,18 +1265,18 @@ main( if (strlen(tape_device)==1){ if (read_config(chg_scsi_conf, changer) == -1) { - fprintf(stderr, "%s open: of %s failed\n", get_pname(), chg_scsi_conf); + g_fprintf(stderr, _("%s open: of %s failed\n"), get_pname(), chg_scsi_conf); return (2); } confnum=atoi(tape_device); if (changer->number_of_configs == 0) { - fprintf(stderr,"%s: changer->conf[%d] == NULL\n", + g_fprintf(stderr,_("%s: changer->conf[%d] == NULL\n"), get_pname(), confnum); return (2); } if (confnum >= changer->number_of_configs) { - fprintf(stderr,"%s: Configuration %s config # out of range (%d >= %d)\n", + g_fprintf(stderr,_("%s: Configuration %s config # out of range (%d >= %d)\n"), get_pname(), chg_scsi_conf, confnum, changer->number_of_configs); @@ -1328,11 +1338,10 @@ main( if (OpenDevice(INDEX_CHANGER , changer_dev, "changer_dev", changer->conf[confnum].changerident) == 0) { int localerr = errno; - fprintf(stderr, "%s: open: %s: %s\n", get_pname(), + g_fprintf(stderr, _("%s: open: %s: %s\n"), get_pname(), changer_dev, strerror(localerr)); - printf("%s open: %s: %s\n", "", changer_dev, strerror(localerr)); - dbprintf(("%s: open: %s: %s\n", get_pname(), - changer_dev, strerror(localerr))); + g_printf(_("%s open: %s: %s\n"), _(""), changer_dev, strerror(localerr)); + dbprintf(_("open: %s: %s\n"), changer_dev, strerror(localerr)); return 2; } @@ -1348,7 +1357,7 @@ main( { if (OpenDevice(INDEX_TAPE, tape_device, "tape_device", changer->conf[confnum].tapeident) == 0) { - dbprintf(("warning open of %s: failed\n", tape_device)); + dbprintf(_("warning open of %s: failed\n"), tape_device); } } @@ -1359,7 +1368,7 @@ main( { if (OpenDevice(INDEX_TAPECTL, scsitapedevice, "scsitapedevice", changer->conf[confnum].tapeident) == 0) { - dbprintf(("warning open of %s: failed\n", scsitapedevice)); + dbprintf(_("warning open of %s: failed\n"), scsitapedevice); } } @@ -1373,7 +1382,7 @@ main( { if (pDev[INDEX_TAPE].avail == 0 && pDev[INDEX_TAPECTL].avail == 0) { - printf("No device found for tape eject"); + g_printf(_("No device found for tape eject")); return(2); } } @@ -1395,39 +1404,38 @@ main( { if (changer->labelfile == NULL) { - printf("labelfile param not set in your config\n"); + g_printf(_("labelfile param not set in your config\n")); return(2); } } if (slot_file == NULL) { - printf("slotfile param. not set in your config\n"); + g_printf(_("slotfile param. not set in your config\n")); return(2); } if (access(slot_file,R_OK|W_OK) != 0) { - printf("slotfile %s does not exsist or is not read/write\n", slot_file); + g_printf(_("slotfile %s does not exsist or is not read/write\n"), slot_file); return(2); } } else { /* if (strlen(tape_device)==1) */ - printf("please check your config and use a config file for chg-scsi\n"); + g_printf(_("please check your config and use a config file for chg-scsi\n")); return(2); } drivecnt = get_drive_count(fd); if (drive_num > drivecnt) { - printf("%s drive number error (%d > %d)\n", "", + g_printf(_("%s drive number error (%d > %d)\n"), _(""), drive_num, drivecnt); - fprintf(stderr, "%s: requested drive number (%d) greater than " - "number of supported drives (%d)\n", get_pname(), + g_fprintf(stderr, _("%s: requested drive number (%d) greater than " + "number of supported drives (%d)\n"), get_pname(), drive_num, drivecnt); - dbprintf(("%s: requested drive number (%d) greater than " - "number of supported drives (%d)\n", get_pname(), - drive_num, drivecnt)); + dbprintf(_("requested drive number (%d) is greater than " + "number of supported drives (%d)\n"), drive_num, drivecnt); return 2; } @@ -1456,7 +1464,7 @@ main( strncpy(pbarcoderes->data.barcode, pDTE[drive_num].VolTag, SIZEOF(pbarcoderes->data.barcode)); MapBarCode(changer->labelfile, pbarcoderes); - printf("0 0 0\n"); + g_printf("0 0 0\n"); break; /* @@ -1469,9 +1477,9 @@ main( oldtarget = get_current_slot(slot_file); if (oldtarget < 0) { - dbprintf(("COM_INVENTORY: get_current_slot %d\n", oldtarget)); + dbprintf(_("COM_INVENTORY: get_current_slot %d\n"), oldtarget); oldtarget = find_empty(fd, slot_offset, use_slots); - dbprintf(("COM_INVENTORY: find_empty %d\n", oldtarget)); + dbprintf(_("COM_INVENTORY: find_empty %d\n"), oldtarget); } if (need_eject) @@ -1504,7 +1512,7 @@ main( */ if (BarCode(fd) == 1 && emubarcode != 1) { - dbprintf(("search : look for %s\n", com.parameter)); + dbprintf(_("search : look for %s\n"), com.parameter); pbarcoderes->action = BARCODE_VOL; pbarcoderes->data.slot = -1; strncpy(pbarcoderes->data.voltag, com.parameter, @@ -1517,7 +1525,7 @@ main( */ if (pbarcoderes->data.slot == -1 && pbarcoderes->data.barcode == NULL) { - printf("Label %s not found (1)\n",com.parameter); + g_printf(_("Label %s not found (1)\n"),com.parameter); endstatus = 2; close(fd); break; @@ -1535,7 +1543,7 @@ main( { if (strcmp(pSTE[x].VolTag, pbarcoderes->data.barcode) == 0) { - dbprintf(("search : found slot %d\n", x)); + dbprintf(_("search : found slot %d\n"), x); target = x; } } @@ -1549,15 +1557,15 @@ main( { if (strcmp(pDTE[x].VolTag, pbarcoderes->data.barcode) == 0) { - dbprintf(("search : found in tape %d\n", x)); + dbprintf(_("search : found in tape %d\n"), x); /* */ if (x == drive_num) { oldtarget = get_current_slot(slot_file); - printf("%d %s\n", oldtarget - slot_offset, tape_device); + g_printf("%d %s\n", oldtarget - slot_offset, tape_device); return(0); } else { - printf("LABEL in wrong tape Unit\n"); + g_printf(_("LABEL in wrong tape Unit\n")); return(2); } } @@ -1567,7 +1575,7 @@ main( */ if (target == -1) { - printf("Label %s not found (2) \n",com.parameter); + g_printf(_("Label %s not found (2) \n"),com.parameter); close(fd); endstatus = 2; break; @@ -1589,7 +1597,7 @@ main( */ if (target == -1) { - printf("Label %s not found (3)\n",com.parameter); + g_printf(_("Label %s not found (3)\n"),com.parameter); close(fd); endstatus = 2; break; @@ -1604,7 +1612,7 @@ main( */ if (emubarcode == 1 && BarCode(fd) != 1) { - dbprintf(("search : look for %s\n", com.parameter)); + dbprintf(_("search : look for %s\n"), com.parameter); pbarcoderes->action = FIND_SLOT; pbarcoderes->data.slot = -1; strncpy(pbarcoderes->data.voltag, com.parameter, @@ -1616,13 +1624,13 @@ main( { target = pbarcoderes->data.slot; } else { - printf("Barcode DB out of sync \n"); + g_printf(_("Barcode DB out of sync \n")); close(fd); endstatus=2; break; } } else { - printf("Label %s not found \n",com.parameter); + g_printf(_("Label %s not found \n"),com.parameter); close(fd); endstatus = 2; break; @@ -1637,7 +1645,7 @@ main( { if (is_positive_number(com.parameter)) { if ((target = atoi(com.parameter))>=use_slots) { - printf(" no slot `%d'\n",target); + g_printf(_(" no slot `%d'\n"),target); close(fd); endstatus = 2; break; @@ -1663,9 +1671,9 @@ main( oldtarget = get_current_slot(slot_file); if (oldtarget < 0) { - dbprintf(("COM_SLOT: get_current_slot %d\n", oldtarget)); + dbprintf(_("COM_SLOT: get_current_slot %d\n"), oldtarget); oldtarget = find_empty(fd, slot_offset, use_slots); - dbprintf(("COM_SLOT: find_empty %d\n", oldtarget)); + dbprintf(_("COM_SLOT: find_empty %d\n"), oldtarget); } /* @@ -1699,7 +1707,7 @@ main( put_current_slot(slot_file, target); if (!loaded && isempty(fd, target)) { - printf("%d slot %d is empty\n",target - slot_offset, + g_printf(_("%d slot %d is empty\n"),target - slot_offset, target - slot_offset); close(fd); endstatus = 1; @@ -1712,7 +1720,7 @@ main( clean_tape(fd, tape_device, clean_file, drive_num, clean_slot, maxclean, time_file); if (load(fd, drive_num, target) != 0) { - printf("%d slot %d move failed\n",target - slot_offset, + g_printf(_("%d slot %d move failed\n"),target - slot_offset, target - slot_offset); close(fd); endstatus = 2; @@ -1726,21 +1734,21 @@ main( { if (Tape_Ready(INDEX_TAPECTL, need_sleep) == -1) { - printf("tape not ready\n"); + g_printf(_("tape not ready\n")); endstatus = 2; break; } } else { if (Tape_Ready(INDEX_TAPECTL, need_sleep) == -1) { - printf("tape not ready\n"); + g_printf(_("tape not ready\n")); endstatus = 2; break; } } } - printf("%d %s\n", target - slot_offset, tape_device); + g_printf("%d %s\n", target - slot_offset, tape_device); break; case COM_INFO: @@ -1752,13 +1760,13 @@ main( } loaded = loaded - (int)slot_offset; - printf("%d %d 1", loaded, use_slots); + g_printf("%d %d 1", loaded, use_slots); if (BarCode(fd) == 1 || emubarcode == 1) { - printf(" 1\n"); + g_printf(" 1\n"); } else { - printf(" 0\n"); + g_printf(" 0\n"); } break; @@ -1767,9 +1775,9 @@ main( if (target < 0) { - dbprintf(("COM_RESET: get_current_slot %d\n", target)); + dbprintf(_("COM_RESET: get_current_slot %d\n"), target); target = find_empty(fd, slot_offset, use_slots); - dbprintf(("COM_RESET: find_empty %d\n", target)); + dbprintf(_("COM_RESET: find_empty %d\n"), target); } if (loaded) { @@ -1798,14 +1806,14 @@ main( } if (isempty(fd, slot_offset)) { - printf("0 slot 0 is empty\n"); + g_printf(_("0 slot 0 is empty\n")); close(fd); endstatus = 1; break; } if (load(fd, drive_num, slot_offset) != 0) { - printf("%d slot %d move failed\n", + g_printf(_("%d slot %d move failed\n"), drive_num, slot_offset); close(fd); put_current_slot(slot_file, slot_offset); @@ -1821,21 +1829,21 @@ main( { if (Tape_Ready(INDEX_TAPECTL, need_sleep) == -1) { - printf("tape not ready\n"); + g_printf(_("tape not ready\n")); endstatus = 2; break; } } else { if (Tape_Ready(INDEX_TAPECTL, need_sleep) == -1) { - printf("tape not ready\n"); + g_printf(_("tape not ready\n")); endstatus = 2; break; } } } - printf("%d %s\n", slot_offset, tape_device); + g_printf(_("%d %s\n"), slot_offset, tape_device); break; case COM_EJECT: @@ -1843,9 +1851,9 @@ main( target = get_current_slot(slot_file); if (target < 0) { - dbprintf(("COM_EJECT: get_current_slot %d\n", target)); + dbprintf(_("COM_EJECT: get_current_slot %d\n"), target); target = find_empty(fd, slot_offset, use_slots); - dbprintf(("COM_EJECT: find_empty %d\n", target)); + dbprintf(_("COM_EJECT: find_empty %d\n"), target); } if (need_eject) @@ -1863,9 +1871,9 @@ main( if (ask_clean(scsitapedevice)) clean_tape(fd, tape_device, clean_file, drive_num, clean_slot, maxclean, time_file); - printf("%d %s\n", target, tape_device); + g_printf("%d %s\n", target, tape_device); } else { - printf("%d %s\n", target, "drive was not loaded"); + g_printf(_("%d drive was not loaded\n"), target); endstatus = 1; } break; @@ -1874,9 +1882,9 @@ main( target = get_current_slot(slot_file); if (target < 0) { - dbprintf(("COM_CLEAN: get_current_slot %d\n", target)); + dbprintf(_("COM_CLEAN: get_current_slot %d\n"), target); target = find_empty(fd, slot_offset, use_slots); - dbprintf(("COM_CLEAN: find_empty %d\n",target)); + dbprintf(_("COM_CLEAN: find_empty %d\n"),target); } if (need_eject) @@ -1894,7 +1902,7 @@ main( clean_tape(fd, tape_device, clean_file, drive_num, clean_slot, maxclean, time_file); - printf("%s cleaned\n", tape_device); + g_printf(_("%s cleaned\n"), tape_device); break; }; @@ -1914,18 +1922,18 @@ main( { if (changer->autoinv == 1) { - DebugPrint(DEBUG_INFO,SECTION_INFO, "Do an inventory \n"); + DebugPrint(DEBUG_INFO,SECTION_INFO, _("Do an inventory \n")); Inventory(changer->labelfile, drive_num, changer->eject, 0, 0, clean_slot); } else { - DebugPrint(DEBUG_INFO,SECTION_INFO, "Set all entrys in DB to invalid\n"); + DebugPrint(DEBUG_INFO,SECTION_INFO, _("Set all entrys in DB to invalid\n")); memset(pbarcoderes, 0 , SIZEOF(MBC_T)); pbarcoderes->action = RESET_VALID; MapBarCode(changer->labelfile,pbarcoderes); } } - DebugPrint(DEBUG_INFO,SECTION_INFO,"Exit status -> %d\n", endstatus); + DebugPrint(DEBUG_INFO,SECTION_INFO,_("Exit status -> %d\n"), endstatus); dbclose(); return endstatus; }