~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Brian Aker
  • Date: 2010-07-15 23:18:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1661.
  • Revision ID: brian@gaz-20100715231811-c5erivy1nvwf6bii
Merge in move identifier work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2010 Vijay Samuel
5
4
 *  Copyright (C) 2008 MySQL
6
5
 *
7
6
 *  This program is free software; you can redistribute it and/or modify
61
60
#include <cassert>
62
61
#include <stdarg.h>
63
62
#include <math.h>
64
 
#include <memory>
65
63
#include "client/linebuffer.h"
66
64
#include <signal.h>
67
65
#include <sys/ioctl.h>
68
66
#include <drizzled/configmake.h>
69
67
#include "drizzled/utf8/utf8.h"
70
 
#include <cstdlib>
71
68
 
72
69
#if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H)
73
70
#include <curses.h>
159
156
#define vidattr(A) {}      // Can't get this to work
160
157
#endif
161
158
#include <boost/program_options.hpp>
162
 
#include <boost/scoped_ptr.hpp>
163
 
#include "drizzled/program_options/config_file.h"
164
159
 
165
160
using namespace std;
166
161
namespace po=boost::program_options;
167
 
namespace dpo=drizzled::program_options;
168
162
 
 
163
const string VER("14.14");
169
164
/* Don't try to make a nice table if the data is too big */
170
165
const uint32_t MAX_COLUMN_LENGTH= 1024;
171
166
 
180
175
 
181
176
  Status(int in_exit_status, 
182
177
         uint32_t in_query_start_line,
183
 
         char *in_file_name,
 
178
         char *in_file_name,
184
179
         LineBuffer *in_line_buff,
185
 
         bool in_batch,
186
 
         bool in_add_to_history)
 
180
         bool in_batch,
 
181
         bool in_add_to_history)
187
182
    :
188
183
    exit_status(in_exit_status),
189
184
    query_start_line(in_query_start_line),
193
188
    add_to_history(in_add_to_history)
194
189
    {}
195
190
 
196
 
  Status() :
197
 
    exit_status(0),
198
 
    query_start_line(0),
199
 
    file_name(NULL),
200
 
    line_buff(NULL),
201
 
    batch(false),        
202
 
    add_to_history(false)
203
 
  {}
 
191
  Status()
 
192
    :
 
193
    exit_status(),
 
194
    query_start_line(),
 
195
    file_name(),
 
196
    line_buff(),
 
197
    batch(),        
 
198
    add_to_history()
 
199
    {}
204
200
  
205
201
  int getExitStatus() const
206
202
  {
290
286
  connected= false, opt_raw_data= false, unbuffered= false,
291
287
  output_tables= false, opt_rehash= true, skip_updates= false,
292
288
  safe_updates= false, one_database= false,
293
 
  opt_shutdown= false, opt_ping= false,
 
289
  opt_compress= false, opt_shutdown= false, opt_ping= false,
294
290
  vertical= false, line_numbers= true, column_names= true,
295
291
  opt_nopager= true, opt_outfile= false, named_cmds= false,
296
292
  opt_nobeep= false, opt_reconnect= true,
298
294
  default_pager_set= false, opt_sigint_ignore= false,
299
295
  auto_vertical_output= false,
300
296
  show_warnings= false, executing_query= false, interrupted_query= false,
301
 
  use_drizzle_protocol= false, opt_local_infile;
 
297
  opt_mysql= false, opt_local_infile;
302
298
static uint32_t show_progress_size= 0;
303
299
static bool column_types_flag;
304
300
static bool preserve_comments= false;
323
319
  current_user,
324
320
  opt_verbose,
325
321
  current_password,
326
 
  opt_password,
327
 
  opt_protocol;
 
322
  opt_password;
328
323
// TODO: Need to i18n these
329
324
static const char *day_names[]= {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
330
325
static const char *month_names[]= {"Jan","Feb","Mar","Apr","May","Jun","Jul",
341
336
static uint32_t delimiter_length= 1;
342
337
unsigned short terminal_width= 80;
343
338
 
344
 
int drizzleclient_real_query_for_lazy(const char *buf, size_t length,
 
339
int drizzleclient_real_query_for_lazy(const char *buf, int length,
345
340
                                      drizzle_result_st *result,
346
341
                                      uint32_t *error_code);
347
342
int drizzleclient_store_result_for_lazy(drizzle_result_st *result);
360
355
  com_help(string *str,const char*), com_clear(string *str,const char*),
361
356
  com_connect(string *str,const char*), com_status(string *str,const char*),
362
357
  com_use(string *str,const char*), com_source(string *str, const char*),
363
 
  com_shutdown(string *str,const char*),
364
358
  com_rehash(string *str, const char*), com_tee(string *str, const char*),
365
359
  com_notee(string *str, const char*),
366
360
  com_prompt(string *str, const char*), com_delimiter(string *str, const char*),
492
486
    N_("Set outfile [to_outfile]. Append everything into given outfile.") ),
493
487
  Commands( "use",    'u', com_use,    1,
494
488
    N_("Use another database. Takes database name as argument.") ),
495
 
  Commands( "shutdown",    'u', com_shutdown,    1,
496
 
    N_("Shutdown the instance you are connected too.") ),
497
489
  Commands( "warnings", 'W', com_warnings,  0,
498
490
    N_("Show warnings after every statement.") ),
499
491
  Commands( "nowarning", 'w', com_nowarnings, 0,
529
521
  Commands( "AUTO_INCREMENT", 0, 0, 0, ""),
530
522
  Commands( "AVG", 0, 0, 0, ""),
531
523
  Commands( "AVG_ROW_LENGTH", 0, 0, 0, ""),
 
524
  Commands( "BACKUP", 0, 0, 0, ""),
 
525
  Commands( "BDB", 0, 0, 0, ""),
532
526
  Commands( "BEFORE", 0, 0, 0, ""),
533
527
  Commands( "BEGIN", 0, 0, 0, ""),
 
528
  Commands( "BERKELEYDB", 0, 0, 0, ""),
534
529
  Commands( "BETWEEN", 0, 0, 0, ""),
535
530
  Commands( "BIGINT", 0, 0, 0, ""),
536
531
  Commands( "BINARY", 0, 0, 0, ""),
 
532
  Commands( "BINLOG", 0, 0, 0, ""),
537
533
  Commands( "BIT", 0, 0, 0, ""),
538
534
  Commands( "BLOB", 0, 0, 0, ""),
539
535
  Commands( "BOOL", 0, 0, 0, ""),
552
548
  Commands( "CHANGED", 0, 0, 0, ""),
553
549
  Commands( "CHAR", 0, 0, 0, ""),
554
550
  Commands( "CHARACTER", 0, 0, 0, ""),
 
551
  Commands( "CHARSET", 0, 0, 0, ""),
555
552
  Commands( "CHECK", 0, 0, 0, ""),
556
553
  Commands( "CHECKSUM", 0, 0, 0, ""),
 
554
  Commands( "CIPHER", 0, 0, 0, ""),
557
555
  Commands( "CLIENT", 0, 0, 0, ""),
558
556
  Commands( "CLOSE", 0, 0, 0, ""),
 
557
  Commands( "CODE", 0, 0, 0, ""),
559
558
  Commands( "COLLATE", 0, 0, 0, ""),
560
559
  Commands( "COLLATION", 0, 0, 0, ""),
561
560
  Commands( "COLUMN", 0, 0, 0, ""),
597
596
  Commands( "DEFAULT", 0, 0, 0, ""),
598
597
  Commands( "DEFINER", 0, 0, 0, ""),
599
598
  Commands( "DELAYED", 0, 0, 0, ""),
 
599
  Commands( "DELAY_KEY_WRITE", 0, 0, 0, ""),
600
600
  Commands( "DELETE", 0, 0, 0, ""),
601
601
  Commands( "DESC", 0, 0, 0, ""),
602
602
  Commands( "DESCRIBE", 0, 0, 0, ""),
 
603
  Commands( "DES_KEY_FILE", 0, 0, 0, ""),
603
604
  Commands( "DETERMINISTIC", 0, 0, 0, ""),
 
605
  Commands( "DIRECTORY", 0, 0, 0, ""),
604
606
  Commands( "DISABLE", 0, 0, 0, ""),
605
607
  Commands( "DISCARD", 0, 0, 0, ""),
606
608
  Commands( "DISTINCT", 0, 0, 0, ""),
607
609
  Commands( "DISTINCTROW", 0, 0, 0, ""),
608
610
  Commands( "DIV", 0, 0, 0, ""),
 
611
  Commands( "DO", 0, 0, 0, ""),
609
612
  Commands( "DOUBLE", 0, 0, 0, ""),
610
613
  Commands( "DROP", 0, 0, 0, ""),
 
614
  Commands( "DUAL", 0, 0, 0, ""),
611
615
  Commands( "DUMPFILE", 0, 0, 0, ""),
612
616
  Commands( "DUPLICATE", 0, 0, 0, ""),
613
617
  Commands( "DYNAMIC", 0, 0, 0, ""),
623
627
  Commands( "ERRORS", 0, 0, 0, ""),
624
628
  Commands( "ESCAPE", 0, 0, 0, ""),
625
629
  Commands( "ESCAPED", 0, 0, 0, ""),
 
630
  Commands( "EVENTS", 0, 0, 0, ""),
 
631
  Commands( "EXECUTE", 0, 0, 0, ""),
626
632
  Commands( "EXISTS", 0, 0, 0, ""),
627
633
  Commands( "EXIT", 0, 0, 0, ""),
 
634
  Commands( "EXPANSION", 0, 0, 0, ""),
628
635
  Commands( "EXPLAIN", 0, 0, 0, ""),
629
636
  Commands( "EXTENDED", 0, 0, 0, ""),
630
637
  Commands( "FALSE", 0, 0, 0, ""),
645
652
  Commands( "FRAC_SECOND", 0, 0, 0, ""),
646
653
  Commands( "FROM", 0, 0, 0, ""),
647
654
  Commands( "FULL", 0, 0, 0, ""),
 
655
  Commands( "FULLTEXT", 0, 0, 0, ""),
648
656
  Commands( "FUNCTION", 0, 0, 0, ""),
649
657
  Commands( "GLOBAL", 0, 0, 0, ""),
650
658
  Commands( "GRANT", 0, 0, 0, ""),
712
720
  Commands( "LOCKS", 0, 0, 0, ""),
713
721
  Commands( "LOGS", 0, 0, 0, ""),
714
722
  Commands( "LONG", 0, 0, 0, ""),
 
723
  Commands( "LONGTEXT", 0, 0, 0, ""),
715
724
  Commands( "LOOP", 0, 0, 0, ""),
 
725
  Commands( "LOW_PRIORITY", 0, 0, 0, ""),
 
726
  Commands( "MASTER", 0, 0, 0, ""),
 
727
  Commands( "MASTER_CONNECT_RETRY", 0, 0, 0, ""),
 
728
  Commands( "MASTER_HOST", 0, 0, 0, ""),
 
729
  Commands( "MASTER_LOG_FILE", 0, 0, 0, ""),
 
730
  Commands( "MASTER_LOG_POS", 0, 0, 0, ""),
 
731
  Commands( "MASTER_PASSWORD", 0, 0, 0, ""),
 
732
  Commands( "MASTER_PORT", 0, 0, 0, ""),
 
733
  Commands( "MASTER_SERVER_ID", 0, 0, 0, ""),
 
734
  Commands( "MASTER_SSL", 0, 0, 0, ""),
 
735
  Commands( "MASTER_SSL_CA", 0, 0, 0, ""),
 
736
  Commands( "MASTER_SSL_CAPATH", 0, 0, 0, ""),
 
737
  Commands( "MASTER_SSL_CERT", 0, 0, 0, ""),
 
738
  Commands( "MASTER_SSL_CIPHER", 0, 0, 0, ""),
 
739
  Commands( "MASTER_SSL_KEY", 0, 0, 0, ""),
 
740
  Commands( "MASTER_USER", 0, 0, 0, ""),
716
741
  Commands( "MATCH", 0, 0, 0, ""),
717
742
  Commands( "MAX_CONNECTIONS_PER_HOUR", 0, 0, 0, ""),
718
743
  Commands( "MAX_QUERIES_PER_HOUR", 0, 0, 0, ""),
720
745
  Commands( "MAX_UPDATES_PER_HOUR", 0, 0, 0, ""),
721
746
  Commands( "MAX_USER_CONNECTIONS", 0, 0, 0, ""),
722
747
  Commands( "MEDIUM", 0, 0, 0, ""),
 
748
  Commands( "MEDIUMTEXT", 0, 0, 0, ""),
723
749
  Commands( "MERGE", 0, 0, 0, ""),
724
750
  Commands( "MICROSECOND", 0, 0, 0, ""),
 
751
  Commands( "MIDDLEINT", 0, 0, 0, ""),
725
752
  Commands( "MIGRATE", 0, 0, 0, ""),
726
753
  Commands( "MINUTE", 0, 0, 0, ""),
727
754
  Commands( "MINUTE_MICROSECOND", 0, 0, 0, ""),
740
767
  Commands( "NAMES", 0, 0, 0, ""),
741
768
  Commands( "NATIONAL", 0, 0, 0, ""),
742
769
  Commands( "NATURAL", 0, 0, 0, ""),
 
770
  Commands( "NDB", 0, 0, 0, ""),
 
771
  Commands( "NDBCLUSTER", 0, 0, 0, ""),
743
772
  Commands( "NCHAR", 0, 0, 0, ""),
744
773
  Commands( "NEW", 0, 0, 0, ""),
745
774
  Commands( "NEXT", 0, 0, 0, ""),
746
775
  Commands( "NO", 0, 0, 0, ""),
747
776
  Commands( "NONE", 0, 0, 0, ""),
748
777
  Commands( "NOT", 0, 0, 0, ""),
 
778
  Commands( "NO_WRITE_TO_BINLOG", 0, 0, 0, ""),
749
779
  Commands( "NULL", 0, 0, 0, ""),
750
780
  Commands( "NUMERIC", 0, 0, 0, ""),
751
781
  Commands( "NVARCHAR", 0, 0, 0, ""),
752
782
  Commands( "OFFSET", 0, 0, 0, ""),
 
783
  Commands( "OLD_PASSWORD", 0, 0, 0, ""),
753
784
  Commands( "ON", 0, 0, 0, ""),
754
785
  Commands( "ONE", 0, 0, 0, ""),
755
786
  Commands( "ONE_SHOT", 0, 0, 0, ""),
766
797
  Commands( "PARTIAL", 0, 0, 0, ""),
767
798
  Commands( "PASSWORD", 0, 0, 0, ""),
768
799
  Commands( "PHASE", 0, 0, 0, ""),
 
800
  Commands( "POINT", 0, 0, 0, ""),
 
801
  Commands( "POLYGON", 0, 0, 0, ""),
769
802
  Commands( "PRECISION", 0, 0, 0, ""),
770
803
  Commands( "PREPARE", 0, 0, 0, ""),
771
804
  Commands( "PREV", 0, 0, 0, ""),
785
818
  Commands( "REDUNDANT", 0, 0, 0, ""),
786
819
  Commands( "REFERENCES", 0, 0, 0, ""),
787
820
  Commands( "REGEXP", 0, 0, 0, ""),
 
821
  Commands( "RELAY_LOG_FILE", 0, 0, 0, ""),
 
822
  Commands( "RELAY_LOG_POS", 0, 0, 0, ""),
 
823
  Commands( "RELAY_THREAD", 0, 0, 0, ""),
788
824
  Commands( "RELEASE", 0, 0, 0, ""),
789
825
  Commands( "RELOAD", 0, 0, 0, ""),
790
826
  Commands( "RENAME", 0, 0, 0, ""),
791
827
  Commands( "REPAIR", 0, 0, 0, ""),
792
828
  Commands( "REPEATABLE", 0, 0, 0, ""),
793
829
  Commands( "REPLACE", 0, 0, 0, ""),
 
830
  Commands( "REPLICATION", 0, 0, 0, ""),
794
831
  Commands( "REPEAT", 0, 0, 0, ""),
795
832
  Commands( "REQUIRE", 0, 0, 0, ""),
796
833
  Commands( "RESET", 0, 0, 0, ""),
829
866
  Commands( "SIMPLE", 0, 0, 0, ""),
830
867
  Commands( "SLAVE", 0, 0, 0, ""),
831
868
  Commands( "SNAPSHOT", 0, 0, 0, ""),
 
869
  Commands( "SMALLINT", 0, 0, 0, ""),
832
870
  Commands( "SOME", 0, 0, 0, ""),
833
871
  Commands( "SONAME", 0, 0, 0, ""),
834
872
  Commands( "SOUNDS", 0, 0, 0, ""),
877
915
  Commands( "TIMESTAMP", 0, 0, 0, ""),
878
916
  Commands( "TIMESTAMPADD", 0, 0, 0, ""),
879
917
  Commands( "TIMESTAMPDIFF", 0, 0, 0, ""),
 
918
  Commands( "TINYTEXT", 0, 0, 0, ""),
880
919
  Commands( "TO", 0, 0, 0, ""),
881
920
  Commands( "TRAILING", 0, 0, 0, ""),
882
921
  Commands( "TRANSACTION", 0, 0, 0, ""),
 
922
  Commands( "TRIGGER", 0, 0, 0, ""),
 
923
  Commands( "TRIGGERS", 0, 0, 0, ""),
883
924
  Commands( "TRUE", 0, 0, 0, ""),
884
925
  Commands( "TRUNCATE", 0, 0, 0, ""),
885
926
  Commands( "TYPE", 0, 0, 0, ""),
892
933
  Commands( "UNIQUE", 0, 0, 0, ""),
893
934
  Commands( "UNKNOWN", 0, 0, 0, ""),
894
935
  Commands( "UNLOCK", 0, 0, 0, ""),
 
936
  Commands( "UNSIGNED", 0, 0, 0, ""),
895
937
  Commands( "UNTIL", 0, 0, 0, ""),
896
938
  Commands( "UPDATE", 0, 0, 0, ""),
897
939
  Commands( "UPGRADE", 0, 0, 0, ""),
899
941
  Commands( "USE", 0, 0, 0, ""),
900
942
  Commands( "USER", 0, 0, 0, ""),
901
943
  Commands( "USER_RESOURCES", 0, 0, 0, ""),
 
944
  Commands( "USE_FRM", 0, 0, 0, ""),
902
945
  Commands( "USING", 0, 0, 0, ""),
903
946
  Commands( "UTC_DATE", 0, 0, 0, ""),
904
947
  Commands( "UTC_TIMESTAMP", 0, 0, 0, ""),
918
961
  Commands( "WITH", 0, 0, 0, ""),
919
962
  Commands( "WORK", 0, 0, 0, ""),
920
963
  Commands( "WRITE", 0, 0, 0, ""),
 
964
  Commands( "X509", 0, 0, 0, ""),
921
965
  Commands( "XOR", 0, 0, 0, ""),
922
966
  Commands( "XA", 0, 0, 0, ""),
923
967
  Commands( "YEAR", 0, 0, 0, ""),
926
970
  Commands( "ABS", 0, 0, 0, ""),
927
971
  Commands( "ACOS", 0, 0, 0, ""),
928
972
  Commands( "ADDDATE", 0, 0, 0, ""),
 
973
  Commands( "AES_ENCRYPT", 0, 0, 0, ""),
 
974
  Commands( "AES_DECRYPT", 0, 0, 0, ""),
929
975
  Commands( "AREA", 0, 0, 0, ""),
930
976
  Commands( "ASIN", 0, 0, 0, ""),
931
977
  Commands( "ASBINARY", 0, 0, 0, ""),
932
978
  Commands( "ASTEXT", 0, 0, 0, ""),
 
979
  Commands( "ASWKB", 0, 0, 0, ""),
 
980
  Commands( "ASWKT", 0, 0, 0, ""),
933
981
  Commands( "ATAN", 0, 0, 0, ""),
934
982
  Commands( "ATAN2", 0, 0, 0, ""),
935
983
  Commands( "BENCHMARK", 0, 0, 0, ""),
995
1043
  Commands( "GROUP_UNIQUE_USERS", 0, 0, 0, ""),
996
1044
  Commands( "HEX", 0, 0, 0, ""),
997
1045
  Commands( "IFNULL", 0, 0, 0, ""),
 
1046
  Commands( "INET_ATON", 0, 0, 0, ""),
 
1047
  Commands( "INET_NTOA", 0, 0, 0, ""),
998
1048
  Commands( "INSTR", 0, 0, 0, ""),
999
1049
  Commands( "INTERIORRINGN", 0, 0, 0, ""),
1000
1050
  Commands( "INTERSECTS", 0, 0, 0, ""),
1010
1060
  Commands( "LEAST", 0, 0, 0, ""),
1011
1061
  Commands( "LENGTH", 0, 0, 0, ""),
1012
1062
  Commands( "LN", 0, 0, 0, ""),
 
1063
  Commands( "LINEFROMTEXT", 0, 0, 0, ""),
 
1064
  Commands( "LINEFROMWKB", 0, 0, 0, ""),
 
1065
  Commands( "LINESTRINGFROMTEXT", 0, 0, 0, ""),
 
1066
  Commands( "LINESTRINGFROMWKB", 0, 0, 0, ""),
1013
1067
  Commands( "LOAD_FILE", 0, 0, 0, ""),
1014
1068
  Commands( "LOCATE", 0, 0, 0, ""),
1015
1069
  Commands( "LOG", 0, 0, 0, ""),
1032
1086
  Commands( "MD5", 0, 0, 0, ""),
1033
1087
  Commands( "MID", 0, 0, 0, ""),
1034
1088
  Commands( "MIN", 0, 0, 0, ""),
 
1089
  Commands( "MLINEFROMTEXT", 0, 0, 0, ""),
 
1090
  Commands( "MLINEFROMWKB", 0, 0, 0, ""),
 
1091
  Commands( "MPOINTFROMTEXT", 0, 0, 0, ""),
 
1092
  Commands( "MPOINTFROMWKB", 0, 0, 0, ""),
 
1093
  Commands( "MPOLYFROMTEXT", 0, 0, 0, ""),
 
1094
  Commands( "MPOLYFROMWKB", 0, 0, 0, ""),
1035
1095
  Commands( "MONTHNAME", 0, 0, 0, ""),
 
1096
  Commands( "MULTILINESTRINGFROMTEXT", 0, 0, 0, ""),
 
1097
  Commands( "MULTILINESTRINGFROMWKB", 0, 0, 0, ""),
 
1098
  Commands( "MULTIPOINTFROMTEXT", 0, 0, 0, ""),
 
1099
  Commands( "MULTIPOINTFROMWKB", 0, 0, 0, ""),
 
1100
  Commands( "MULTIPOLYGONFROMTEXT", 0, 0, 0, ""),
 
1101
  Commands( "MULTIPOLYGONFROMWKB", 0, 0, 0, ""),
1036
1102
  Commands( "NAME_CONST", 0, 0, 0, ""),
1037
1103
  Commands( "NOW", 0, 0, 0, ""),
1038
1104
  Commands( "NULLIF", 0, 0, 0, ""),
 
1105
  Commands( "NUMINTERIORRINGS", 0, 0, 0, ""),
1039
1106
  Commands( "NUMPOINTS", 0, 0, 0, ""),
1040
1107
  Commands( "OCTET_LENGTH", 0, 0, 0, ""),
1041
1108
  Commands( "OCT", 0, 0, 0, ""),
1044
1111
  Commands( "PERIOD_ADD", 0, 0, 0, ""),
1045
1112
  Commands( "PERIOD_DIFF", 0, 0, 0, ""),
1046
1113
  Commands( "PI", 0, 0, 0, ""),
 
1114
  Commands( "POINTFROMTEXT", 0, 0, 0, ""),
 
1115
  Commands( "POINTFROMWKB", 0, 0, 0, ""),
1047
1116
  Commands( "POINTN", 0, 0, 0, ""),
 
1117
  Commands( "POLYFROMTEXT", 0, 0, 0, ""),
 
1118
  Commands( "POLYFROMWKB", 0, 0, 0, ""),
 
1119
  Commands( "POLYGONFROMTEXT", 0, 0, 0, ""),
 
1120
  Commands( "POLYGONFROMWKB", 0, 0, 0, ""),
1048
1121
  Commands( "POSITION", 0, 0, 0, ""),
1049
1122
  Commands( "POW", 0, 0, 0, ""),
1050
1123
  Commands( "POWER", 0, 0, 0, ""),
1147
1220
 
1148
1221
  if (verbose)
1149
1222
  {
1150
 
    printf(_("shutting down drizzled"));
 
1223
    printf("shutting down drizzled");
1151
1224
    if (opt_drizzle_port > 0)
1152
 
      printf(_(" on port %d"), opt_drizzle_port);
 
1225
      printf(" on port %d", opt_drizzle_port);
1153
1226
    printf("... ");
1154
1227
  }
1155
1228
 
1158
1231
  {
1159
1232
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
1160
1233
    {
1161
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
 
1234
      fprintf(stderr, "shutdown failed; error: '%s'",
1162
1235
              drizzle_result_error(&result));
1163
1236
      drizzle_result_free(&result);
1164
1237
    }
1165
1238
    else
1166
1239
    {
1167
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
 
1240
      fprintf(stderr, "shutdown failed; error: '%s'",
1168
1241
              drizzle_con_error(&con));
1169
1242
    }
1170
1243
    return false;
1173
1246
  drizzle_result_free(&result);
1174
1247
 
1175
1248
  if (verbose)
1176
 
    printf(_("done\n"));
 
1249
    printf("done\n");
1177
1250
 
1178
1251
  return true;
1179
1252
}
1194
1267
  if (drizzle_ping(&con, &result, &ret) != NULL && ret == DRIZZLE_RETURN_OK)
1195
1268
  {
1196
1269
    if (opt_silent < 2)
1197
 
      printf(_("drizzled is alive\n"));
 
1270
      printf("drizzled is alive\n");
1198
1271
  }
1199
1272
  else
1200
1273
  {
1201
1274
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
1202
1275
    {
1203
 
      fprintf(stderr, _("ping failed; error: '%s'"),
 
1276
      fprintf(stderr, "ping failed; error: '%s'",
1204
1277
              drizzle_result_error(&result));
1205
1278
      drizzle_result_free(&result);
1206
1279
    }
1207
1280
    else
1208
1281
    {
1209
 
      fprintf(stderr, _("drizzled won't answer to ping, error: '%s'"),
 
1282
      fprintf(stderr, "drizzled won't answer to ping, error: '%s'",
1210
1283
              drizzle_con_error(&con));
1211
1284
    }
1212
1285
    return false;
1255
1328
  opt_connect_timeout= 0;
1256
1329
  if (in_connect_timeout > 3600*12)
1257
1330
  {
1258
 
    cout << _("Error: Invalid Value for connect_timeout"); 
 
1331
    cout<<N_("Error: Invalid Value for connect_timeout"); 
1259
1332
    exit(-1);
1260
1333
  }
1261
1334
  opt_connect_timeout= in_connect_timeout;
1264
1337
static void check_max_input_line(uint32_t in_max_input_line)
1265
1338
{
1266
1339
  opt_max_input_line= 0;
1267
 
  if (in_max_input_line < 4096 || in_max_input_line > (int64_t)2*1024L*1024L*1024L)
 
1340
  if (in_max_input_line<4096 || in_max_input_line>(int64_t)2*1024L*1024L*1024L)
1268
1341
  {
1269
 
    cout << _("Error: Invalid Value for max_input_line");
 
1342
    cout<<N_("Error: Invalid Value for max_input_line");
1270
1343
    exit(-1);
1271
1344
  }
1272
 
  opt_max_input_line= in_max_input_line - (in_max_input_line % 1024);
 
1345
  opt_max_input_line= in_max_input_line/1024;
 
1346
  opt_max_input_line*=1024;
1273
1347
}
1274
1348
 
1275
1349
int main(int argc,char *argv[])
1276
1350
{
1277
1351
try
1278
1352
{
1279
 
 
1280
1353
#if defined(ENABLE_NLS)
1281
1354
# if defined(HAVE_LOCALE_H)
1282
1355
  setlocale(LC_ALL, "");
1285
1358
  textdomain("drizzle");
1286
1359
#endif
1287
1360
 
1288
 
  po::options_description commandline_options(N_("Options used only in command line"));
 
1361
  po::options_description commandline_options("Options used only in command line");
1289
1362
  commandline_options.add_options()
1290
1363
  ("help,?",N_("Displays this help and exit."))
1291
1364
  ("batch,B",N_("Don't use history file. Disable interactive behavior. (Enables --silent)"))
1293
1366
  N_("Display column type information."))
1294
1367
  ("comments,c", po::value<bool>(&preserve_comments)->default_value(false)->zero_tokens(),
1295
1368
  N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"))
 
1369
  ("compress,C", po::value<bool>(&opt_compress)->default_value(false)->zero_tokens(),
 
1370
  N_("Use compression in server/client protocol."))  
1296
1371
  ("vertical,E", po::value<bool>(&vertical)->default_value(false)->zero_tokens(),
1297
1372
  N_("Print the output of a query (rows) vertically."))
1298
1373
  ("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
1299
1374
  N_("Continue even if we get an sql error."))
1300
1375
  ("named-commands,G", po::value<bool>(&named_cmds)->default_value(false)->zero_tokens(),
1301
 
  N_("Enable named commands. Named commands mean this program's internal commands; see drizzle> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter."))
 
1376
  N_("Enable named commands. Named commands mean this program's internal commands; see drizzle> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default."))
 
1377
  ("no-named-commands,g",
 
1378
  N_("Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead."))
 
1379
  ("ignore-spaces,i", N_("Ignore space after function names."))
1302
1380
  ("no-beep,b", po::value<bool>(&opt_nobeep)->default_value(false)->zero_tokens(),
1303
1381
  N_("Turn off beep on error."))
1304
 
  ("disable-line-numbers", N_("Do not write line numbers for errors."))
1305
 
  ("disable-column-names", N_("Do not write column names in results."))
 
1382
  ("line-numbers", po::value<bool>(&line_numbers)->default_value(true)->zero_tokens(),
 
1383
  N_("Write line numbers for errors."))
 
1384
  ("skip-line-numbers,L", 
 
1385
  N_("Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead."))
 
1386
  ("column-name", po::value<bool>(&column_names)->default_value(true)->zero_tokens(),
 
1387
  N_("Write column names in results."))
1306
1388
  ("skip-column-names,N", 
1307
1389
  N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."))
1308
1390
  ("set-variable,O", po::value<string>(),
1309
1391
  N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."))
1310
1392
  ("table,t", po::value<bool>(&output_tables)->default_value(false)->zero_tokens(),
1311
1393
  N_("Output in table format.")) 
1312
 
  ("safe-updates,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
 
1394
  ("safe-updates,U", po::value<bool>(&safe_updates)->default_value(0)->zero_tokens(),
1313
1395
  N_("Only allow UPDATE and DELETE that uses keys."))
1314
 
  ("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
 
1396
  ("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(0)->zero_tokens(),
1315
1397
  N_("Synonym for option --safe-updates, -U."))
1316
1398
  ("verbose,v", po::value<string>(&opt_verbose)->default_value(""),
1317
1399
  N_("-v vvv implies that verbose= 3, Used to specify verbose"))
1328
1410
  N_("Configuration file defaults are not used if no-defaults is set"))
1329
1411
  ;
1330
1412
 
1331
 
  po::options_description drizzle_options(N_("Options specific to the drizzle client"));
 
1413
  po::options_description drizzle_options("Options specific to the drizzle client");
1332
1414
  drizzle_options.add_options()
1333
 
  ("disable-auto-rehash,A",
1334
 
  N_("Disable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time."))
 
1415
  ("auto-rehash", po::value<bool>(&opt_rehash)->default_value(true)->zero_tokens(),
 
1416
  N_("Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash."))
 
1417
  ("no-auto-rehash,A",N_("No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of drizzle_st and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead."))
1335
1418
  ("auto-vertical-output", po::value<bool>(&auto_vertical_output)->default_value(false)->zero_tokens(),
1336
1419
  N_("Automatically switch to vertical output mode if the result is wider than the terminal width."))
1337
1420
  ("database,D", po::value<string>(&current_db)->default_value(""),
1343
1426
  ("execute,e", po::value<string>(),
1344
1427
  N_("Execute command and quit. (Disables --force and history file)"))
1345
1428
  ("local-infile", po::value<bool>(&opt_local_infile)->default_value(false)->zero_tokens(),
1346
 
  N_("Enable LOAD DATA LOCAL INFILE."))
 
1429
  N_("Enable/disable LOAD DATA LOCAL INFILE."))
1347
1430
  ("unbuffered,n", po::value<bool>(&unbuffered)->default_value(false)->zero_tokens(),
1348
1431
  N_("Flush buffer after each query."))
1349
1432
  ("sigint-ignore", po::value<bool>(&opt_sigint_ignore)->default_value(false)->zero_tokens(),
1360
1443
  N_("Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file."))
1361
1444
  ("raw,r", po::value<bool>(&opt_raw_data)->default_value(false)->zero_tokens(),
1362
1445
  N_("Write fields without conversion. Used with --batch.")) 
1363
 
  ("disable-reconnect", N_("Do not reconnect if the connection is lost."))
1364
 
  ("shutdown", po::value<bool>()->zero_tokens(),
 
1446
  ("reconnect", po::value<bool>(&opt_reconnect)->default_value(true)->zero_tokens(),
 
1447
  N_("Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default."))
 
1448
  ("shutdown", po::value<bool>(&opt_shutdown)->default_value(false)->zero_tokens(),
1365
1449
  N_("Shutdown the server"))
1366
1450
  ("silent,s", N_("Be more silent. Print results with a tab as separator, each row on new line."))
1367
1451
  ("tee", po::value<string>(),
1368
1452
  N_("Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default."))
1369
1453
  ("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(), 
1370
1454
  N_("Disable outfile. See interactive help (\\h) also."))
1371
 
  ("connect-timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value),
 
1455
  ("wait,w", N_("Wait and retry if connection is down."))
 
1456
  ("connect_timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value),
1372
1457
  N_("Number of seconds before connection timeout."))
1373
 
  ("max-input-line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line),
 
1458
  ("max_input_line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line),
1374
1459
  N_("Max length of input line"))
1375
 
  ("select-limit", po::value<uint32_t>(&select_limit)->default_value(1000L),
 
1460
  ("select_limit", po::value<uint32_t>(&select_limit)->default_value(1000L),
1376
1461
  N_("Automatic limit for SELECT when using --safe-updates"))
1377
 
  ("max-join-size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
 
1462
  ("max_join_size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
1378
1463
  N_("Automatic limit for rows in a join when using --safe-updates"))
1379
1464
  ;
1380
1465
 
1381
 
  po::options_description client_options(N_("Options specific to the client"));
 
1466
  po::options_description client_options("Options specific to the client");
1382
1467
  client_options.add_options()
 
1468
  ("mysql,m", po::value<bool>(&opt_mysql)->default_value(true)->zero_tokens(),
 
1469
  N_("Use MySQL Protocol."))
1383
1470
  ("host,h", po::value<string>(&current_host)->default_value("localhost"),
1384
1471
  N_("Connect to host"))
1385
1472
  ("password,P", po::value<string>(&current_password)->default_value(PASSWORD_SENTINEL),
1386
1473
  N_("Password to use when connecting to server. If password is not given it's asked from the tty."))
1387
1474
  ("port,p", po::value<uint32_t>()->default_value(0),
1388
1475
  N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
1389
 
#ifdef DRIZZLE_ADMIN_TOOL
1390
 
  ("user,u", po::value<string>(&current_user)->default_value("root"),
1391
 
#else
1392
1476
  ("user,u", po::value<string>(&current_user)->default_value(""),
1393
 
#endif
1394
1477
  N_("User for login if not current user."))
1395
 
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
1396
 
  N_("The protocol of connection (mysql or drizzle)."))
 
1478
  ("protocol",po::value<string>(),
 
1479
  N_("The protocol of connection (tcp,socket,pipe,memory)."))
1397
1480
  ;
1398
1481
 
1399
 
  po::options_description long_options(N_("Allowed Options"));
 
1482
  po::options_description long_options("Allowed Options");
1400
1483
  long_options.add(commandline_options).add(drizzle_options).add(client_options);
1401
1484
 
1402
1485
  std::string system_config_dir_drizzle(SYSCONFDIR); 
1405
1488
  std::string system_config_dir_client(SYSCONFDIR); 
1406
1489
  system_config_dir_client.append("/drizzle/client.cnf");
1407
1490
 
1408
 
  std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
1409
 
 
1410
 
  if (user_config_dir.compare(0, 2, "~/") == 0)
1411
 
  {
1412
 
    char *homedir;
1413
 
    homedir= getenv("HOME");
1414
 
    if (homedir != NULL)
1415
 
      user_config_dir.replace(0, 1, homedir);
1416
 
  }
1417
 
 
1418
1491
  po::variables_map vm;
1419
1492
 
1420
1493
  po::positional_options_description p;
1421
1494
  p.add("database", 1);
1422
1495
 
1423
 
  // Disable allow_guessing
1424
 
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1425
 
 
1426
1496
  po::store(po::command_line_parser(argc, argv).options(long_options).
1427
 
            style(style).positional(p).extra_parser(parse_password_arg).run(),
1428
 
            vm);
 
1497
            positional(p).extra_parser(parse_password_arg).run(), vm);
1429
1498
 
1430
1499
  if (! vm["no-defaults"].as<bool>())
1431
1500
  {
1432
 
    std::string user_config_dir_drizzle(user_config_dir);
1433
 
    user_config_dir_drizzle.append("/drizzle/drizzle.cnf"); 
1434
 
 
1435
 
    std::string user_config_dir_client(user_config_dir);
1436
 
    user_config_dir_client.append("/drizzle/client.cnf");
1437
 
 
1438
 
    ifstream user_drizzle_ifs(user_config_dir_drizzle.c_str());
1439
 
    po::store(dpo::parse_config_file(user_drizzle_ifs, drizzle_options), vm);
1440
 
 
1441
 
    ifstream user_client_ifs(user_config_dir_client.c_str());
1442
 
    po::store(dpo::parse_config_file(user_client_ifs, client_options), vm);
1443
 
 
 
1501
    ifstream user_drizzle_ifs("~/.drizzle/drizzle.cnf");
 
1502
    po::store(parse_config_file(user_drizzle_ifs, drizzle_options), vm);
 
1503
 
1444
1504
    ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str());
1445
 
    store(dpo::parse_config_file(system_drizzle_ifs, drizzle_options), vm);
 
1505
    store(parse_config_file(system_drizzle_ifs, drizzle_options), vm);
 
1506
 
 
1507
    ifstream user_client_ifs("~/.drizzle/client.cnf");
 
1508
    po::store(parse_config_file(user_client_ifs, client_options), vm);
1446
1509
 
1447
1510
    ifstream system_client_ifs(system_config_dir_client.c_str());
1448
 
    po::store(dpo::parse_config_file(system_client_ifs, client_options), vm);
 
1511
    po::store(parse_config_file(system_client_ifs, client_options), vm);
1449
1512
  }
1450
1513
 
1451
1514
  po::notify(vm);
1452
1515
 
1453
 
#ifdef DRIZZLE_ADMIN_TOOL
1454
 
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1455
 
                         getenv("DRIZZLE_PS1") :
1456
 
                         "drizzleadmin> ");
1457
 
#else
1458
1516
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1459
1517
                         getenv("DRIZZLE_PS1") :
1460
1518
                         "drizzle> ");
1461
 
#endif
1462
1519
  if (default_prompt == NULL)
1463
1520
  {
1464
1521
    fprintf(stderr, _("Memory allocation error while constructing initial "
1510
1567
      close(stdout_fileno_copy);             /* Clean up dup(). */
1511
1568
  }
1512
1569
 
1513
 
  /* Inverted Booleans */
1514
 
 
1515
 
  line_numbers= (vm.count("disable-line-numbers")) ? false : true;
1516
 
  column_names= (vm.count("disable-column-names")) ? false : true;
1517
 
  opt_rehash= (vm.count("disable-auto-rehash")) ? false : true;
1518
 
  opt_reconnect= (vm.count("disable-reconnect")) ? false : true;
1519
 
 
1520
 
  /* Don't rehash with --shutdown */
1521
 
  if (vm.count("shutdown"))
1522
 
  {
1523
 
    opt_rehash= false;
1524
 
    opt_shutdown= true;
1525
 
  }
1526
 
 
1527
1570
  if (vm.count("delimiter"))
1528
1571
  {
1529
1572
    /* Check that delimiter does not contain a backslash */
1600
1643
 
1601
1644
  if (one_database)
1602
1645
    skip_updates= true;
1603
 
 
1604
 
  if (vm.count("protocol"))
1605
 
  {
1606
 
    std::transform(opt_protocol.begin(), opt_protocol.end(), 
1607
 
      opt_protocol.begin(), ::tolower);
1608
 
 
1609
 
    if (not opt_protocol.compare("mysql"))
1610
 
      use_drizzle_protocol=false;
1611
 
    else if (not opt_protocol.compare("drizzle"))
1612
 
      use_drizzle_protocol=true;
1613
 
    else
1614
 
    {
1615
 
      cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
1616
 
      exit(-1);
1617
 
    }
1618
 
  }
1619
 
 
 
1646
  
1620
1647
  if (vm.count("port"))
1621
1648
  {
1622
1649
    opt_drizzle_port= vm["port"].as<uint32_t>();
1669
1696
  {
1670
1697
    opt_silent++;
1671
1698
  }
 
1699
  if (vm.count("version"))
 
1700
  {
 
1701
    printf(_("drizzle  Ver %s Distrib %s, for %s-%s (%s) using readline %s\n"),
 
1702
           VER.c_str(), drizzle_version(),
 
1703
           HOST_VENDOR, HOST_OS, HOST_CPU,
 
1704
           rl_library_version);
 
1705
 
 
1706
    exit(0);
 
1707
  }
1672
1708
  
1673
 
  if (vm.count("help") || vm.count("version"))
 
1709
  if (vm.count("help"))
1674
1710
  {
1675
 
    printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
1676
 
           drizzle_version(), VERSION,
 
1711
    printf(_("drizzle  Ver %s Distrib %s, for %s-%s (%s) using readline %s\n"),
 
1712
           VER.c_str(), drizzle_version(),
1677
1713
           HOST_VENDOR, HOST_OS, HOST_CPU,
1678
1714
           rl_library_version);
1679
 
    if (vm.count("version"))
1680
 
      exit(0);
1681
1715
    printf(_("Copyright (C) 2008 Sun Microsystems\n"
1682
1716
           "This software comes with ABSOLUTELY NO WARRANTY. "
1683
1717
           "This is free software,\n"
1684
1718
           "and you are welcome to modify and redistribute it "
1685
1719
           "under the GPL license\n"));
1686
1720
    printf(_("Usage: drizzle [OPTIONS] [database]\n"));
1687
 
    cout << long_options;
 
1721
    cout<<long_options;
1688
1722
    exit(0);
1689
1723
  }
1690
1724
 
1733
1767
  /* call the SIGWINCH handler to get the default term width */
1734
1768
  window_resize(0);
1735
1769
#endif
1736
 
  std::vector<char> output_buff;
1737
 
  output_buff.resize(512);
1738
 
 
1739
 
  snprintf(&output_buff[0], output_buff.size(), 
1740
 
           _("Welcome to the Drizzle client..  Commands end with %s or \\g."), 
1741
 
           delimiter);
1742
 
 
1743
 
  put_info(&output_buff[0], INFO_INFO, 0, 0);
 
1770
 
 
1771
  put_info(_("Welcome to the Drizzle client..  Commands end with ; or \\g."),
 
1772
           INFO_INFO,0,0);
1744
1773
 
1745
1774
  glob_buffer= new string();
1746
1775
  glob_buffer->reserve(512);
1747
1776
 
1748
 
  snprintf(&output_buff[0], output_buff.size(),
1749
 
          _("Your Drizzle connection id is %u\nConnection protocol: %s\nServer version: %s\n"),
 
1777
  char * output_buff= (char *)malloc(512);
 
1778
  memset(output_buff, '\0', 512);
 
1779
 
 
1780
  sprintf(output_buff,
 
1781
          _("Your Drizzle connection id is %u\nServer version: %s\n"),
1750
1782
          drizzle_con_thread_id(&con),
1751
 
          opt_protocol.c_str(),
1752
1783
          server_version_string(&con));
1753
 
  put_info(&output_buff[0], INFO_INFO, 0, 0);
1754
 
 
 
1784
  put_info(output_buff, INFO_INFO, 0, 0);
1755
1785
 
1756
1786
  initialize_readline((char *)current_prompt.c_str());
1757
1787
  if (!status.getBatch() && !quick)
1801
1831
 
1802
1832
  catch(exception &err)
1803
1833
  {
1804
 
    cerr << _("Error:") << err.what() << endl;
 
1834
  cerr<<"Error:"<<err.what()<<endl;
1805
1835
  }
1806
1836
  return(0);        // Keep compiler happy
1807
1837
}
1823
1853
 
1824
1854
  if (sig >= 0)
1825
1855
    put_info(sig ? _("Aborted") : _("Bye"), INFO_RESULT,0,0);
1826
 
  delete glob_buffer;
1827
 
  delete processed_prompt;
 
1856
  if (glob_buffer)
 
1857
    delete glob_buffer;
 
1858
  if (processed_prompt)
 
1859
    delete processed_prompt;
1828
1860
  opt_password.erase();
1829
1861
  free(histfile);
1830
1862
  free(histfile_tmp);
1848
1880
void handle_sigint(int sig)
1849
1881
{
1850
1882
  char kill_buffer[40];
1851
 
  boost::scoped_ptr<drizzle_con_st> kill_drizzle(new drizzle_con_st);
 
1883
  drizzle_con_st kill_drizzle;
1852
1884
  drizzle_result_st res;
1853
1885
  drizzle_return_t ret;
1854
1886
 
1857
1889
    goto err;
1858
1890
  }
1859
1891
 
1860
 
  if (drizzle_con_add_tcp(&drizzle, kill_drizzle.get(), current_host.c_str(),
1861
 
    opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL,
1862
 
    use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
 
1892
  if (drizzle_con_add_tcp(&drizzle, &kill_drizzle, current_host.c_str(),
 
1893
                          opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL,
 
1894
                          opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
1863
1895
  {
1864
1896
    goto err;
1865
1897
  }
1868
1900
  sprintf(kill_buffer, "KILL /*!50000 QUERY */ %u",
1869
1901
          drizzle_con_thread_id(&con));
1870
1902
 
1871
 
  if (drizzle_query_str(kill_drizzle.get(), &res, kill_buffer, &ret) != NULL)
 
1903
  if (drizzle_query_str(&kill_drizzle, &res, kill_buffer, &ret) != NULL)
1872
1904
    drizzle_result_free(&res);
1873
1905
 
1874
 
  drizzle_con_free(kill_drizzle.get());
 
1906
  drizzle_con_free(&kill_drizzle);
1875
1907
  tee_fprintf(stdout, _("Query aborted by Ctrl+C\n"));
1876
1908
 
1877
1909
  interrupted_query= 1;
2342
2374
  {
2343
2375
    *out++='\n';
2344
2376
    uint32_t length=(uint32_t) (out-line);
2345
 
    if ((buffer->length() + length) > opt_max_input_line)
2346
 
    {
2347
 
      status.setExitStatus(1);
2348
 
      put_info(_("Not found a delimiter within max_input_line of input"), INFO_ERROR, 0, 0);
2349
 
      return 1;
2350
 
    }
2351
2377
    if ((!*ml_comment || preserve_comments))
2352
2378
      buffer->append(line, length);
2353
2379
  }
2623
2649
  {
2624
2650
    string query;
2625
2651
 
2626
 
    query.append("show fields in `");
 
2652
    query.append("show fields in '");
2627
2653
    query.append(table_row[0]);
2628
 
    query.append("`");
 
2654
    query.append("'");
2629
2655
    
2630
2656
    if (drizzle_query(&con, &fields, query.c_str(), query.length(),
2631
2657
                      &ret) != NULL)
2695
2721
 The different commands
2696
2722
***************************************************************************/
2697
2723
 
2698
 
int drizzleclient_real_query_for_lazy(const char *buf, size_t length,
 
2724
int drizzleclient_real_query_for_lazy(const char *buf, int length,
2699
2725
                                      drizzle_result_st *result,
2700
2726
                                      uint32_t *error_code)
2701
2727
{
2734
2760
    return 0;
2735
2761
 
2736
2762
  if (drizzle_con_error(&con)[0])
2737
 
  {
2738
 
    int ret= put_error(&con, result);
2739
 
    drizzle_result_free(result);
2740
 
    return ret;
2741
 
  }
 
2763
    return put_error(&con, result);
2742
2764
  return 0;
2743
2765
}
2744
2766
 
2747
2769
{
2748
2770
  register int i, j;
2749
2771
  char buff[32], *end;
2750
 
  std::vector<char> output_buff;
2751
 
  output_buff.resize(512);
2752
2772
 
2753
2773
  put_info(_("List of all Drizzle commands:"), INFO_INFO,0,0);
2754
2774
  if (!named_cmds)
2755
 
  {
2756
 
    snprintf(&output_buff[0], output_buff.size(),
2757
 
             _("Note that all text commands must be first on line and end with '%s' or \\g"),
2758
 
             delimiter);
2759
 
    put_info(&output_buff[0], INFO_INFO, 0, 0);
2760
 
  }
 
2775
    put_info(_("Note that all text commands must be first on line and end with ';'"),INFO_INFO,0,0);
2761
2776
  for (i = 0; commands[i].getName(); i++)
2762
2777
  {
2763
2778
    end= strcpy(buff, commands[i].getName());
2973
2988
  {
2974
2989
    if (!(PAGER= popen(pager.c_str(), "w")))
2975
2990
    {
2976
 
      tee_fprintf(stdout,_( "popen() failed! defaulting PAGER to stdout!\n"));
 
2991
      tee_fprintf(stdout, "popen() failed! defaulting PAGER to stdout!\n");
2977
2992
      PAGER= stdout;
2978
2993
    }
2979
2994
  }
2995
3010
    end_tee();
2996
3011
  if (!(new_outfile= fopen(file_name, "a")))
2997
3012
  {
2998
 
    tee_fprintf(stdout, _("Error logging to file '%s'\n"), file_name);
 
3013
    tee_fprintf(stdout, "Error logging to file '%s'\n", file_name);
2999
3014
    return;
3000
3015
  }
3001
3016
  OUTFILE = new_outfile;
3002
3017
  outfile.assign(file_name);
3003
 
  tee_fprintf(stdout, _("Logging to file '%s'\n"), file_name);
 
3018
  tee_fprintf(stdout, "Logging to file '%s'\n", file_name);
3004
3019
  opt_outfile= 1;
3005
3020
 
3006
3021
  return;
3084
3099
 
3085
3100
  while ((field = drizzle_column_next(result)))
3086
3101
  {
3087
 
    tee_fprintf(PAGER, _("Field %3u:  `%s`\n"
 
3102
    tee_fprintf(PAGER, "Field %3u:  `%s`\n"
3088
3103
                "Catalog:    `%s`\n"
3089
3104
                "Database:   `%s`\n"
3090
3105
                "Table:      `%s`\n"
3094
3109
                "Length:     %lu\n"
3095
3110
                "Max_length: %lu\n"
3096
3111
                "Decimals:   %u\n"
3097
 
                "Flags:      %s\n\n"),
 
3112
                "Flags:      %s\n\n",
3098
3113
                ++i,
3099
3114
                drizzle_column_name(field), drizzle_column_catalog(field),
3100
3115
                drizzle_column_db(field), drizzle_column_table(field),
3113
3128
  drizzle_row_t cur;
3114
3129
  drizzle_return_t ret;
3115
3130
  drizzle_column_st *field;
3116
 
  std::vector<bool> num_flag;
 
3131
  bool *num_flag;
3117
3132
  string separator;
3118
3133
 
3119
3134
  separator.reserve(256);
3120
3135
 
3121
 
  num_flag.resize(drizzle_result_column_count(result));
 
3136
  num_flag=(bool*) malloc(sizeof(bool)*drizzle_result_column_count(result));
3122
3137
  if (column_types_flag)
3123
3138
  {
3124
3139
    print_field_types(result);
3259
3274
      drizzle_row_free(result, cur);
3260
3275
  }
3261
3276
  tee_puts(separator.c_str(), PAGER);
 
3277
  free(num_flag);
3262
3278
}
3263
3279
 
3264
3280
/**
3551
3567
  {
3552
3568
    if (outfile.empty())
3553
3569
    {
3554
 
      printf(_("No previous outfile available, you must give a filename!\n"));
 
3570
      printf("No previous outfile available, you must give a filename!\n");
3555
3571
      return 0;
3556
3572
    }
3557
3573
    else if (opt_outfile)
3558
3574
    {
3559
 
      tee_fprintf(stdout, _("Currently logging to file '%s'\n"), outfile.c_str());
 
3575
      tee_fprintf(stdout, "Currently logging to file '%s'\n", outfile.c_str());
3560
3576
      return 0;
3561
3577
    }
3562
3578
    else
3576
3592
  end[0]= 0;
3577
3593
  if (end == file_name)
3578
3594
  {
3579
 
    printf(_("No outfile specified!\n"));
 
3595
    printf("No outfile specified!\n");
3580
3596
    return 0;
3581
3597
  }
3582
3598
  init_tee(file_name);
3589
3605
{
3590
3606
  if (opt_outfile)
3591
3607
    end_tee();
3592
 
  tee_fprintf(stdout, _("Outfile disabled.\n"));
 
3608
  tee_fprintf(stdout, "Outfile disabled.\n");
3593
3609
  return 0;
3594
3610
}
3595
3611
 
3612
3628
  /* Skip the spaces between the command and the argument */
3613
3629
  while (param && isspace(*param))
3614
3630
    param++;
3615
 
  if (!param || (*param == '\0')) // if pager was not given, use the default
 
3631
  if (!param || !strlen(param)) // if pager was not given, use the default
3616
3632
  {
3617
3633
    if (!default_pager_set)
3618
3634
    {
3619
 
      tee_fprintf(stdout, _("Default pager wasn't set, using stdout.\n"));
 
3635
      tee_fprintf(stdout, "Default pager wasn't set, using stdout.\n");
3620
3636
      opt_nopager=1;
3621
3637
      pager.assign("stdout");
3622
3638
      PAGER= stdout;
3636
3652
    default_pager.assign(pager_name);
3637
3653
  }
3638
3654
  opt_nopager=0;
3639
 
  tee_fprintf(stdout, _("PAGER set to '%s'\n"), pager.c_str());
 
3655
  tee_fprintf(stdout, "PAGER set to '%s'\n", pager.c_str());
3640
3656
  return 0;
3641
3657
}
3642
3658
 
3647
3663
  pager.assign("stdout");
3648
3664
  opt_nopager=1;
3649
3665
  PAGER= stdout;
3650
 
  tee_fprintf(stdout, _("PAGER set to stdout\n"));
 
3666
  tee_fprintf(stdout, "PAGER set to stdout\n");
3651
3667
  return 0;
3652
3668
}
3653
3669
 
3730
3746
 
3731
3747
  if (connected)
3732
3748
  {
3733
 
    sprintf(buff, _("Connection id:    %u"), drizzle_con_thread_id(&con));
 
3749
    sprintf(buff,"Connection id:    %u",drizzle_con_thread_id(&con));
3734
3750
    put_info(buff,INFO_INFO,0,0);
3735
 
    sprintf(buff, _("Current database: %.128s\n"),
3736
 
            !current_db.empty() ? current_db.c_str() : _("*** NONE ***"));
 
3751
    sprintf(buff,"Current database: %.128s\n",
 
3752
            !current_db.empty() ? current_db.c_str() : "*** NONE ***");
3737
3753
    put_info(buff,INFO_INFO,0,0);
3738
3754
  }
3739
3755
  return error;
3753
3769
  while (isspace(*line))
3754
3770
    line++;
3755
3771
  if (!(param = strchr(line, ' ')))    // Skip command name
3756
 
    return put_info(_("Usage: \\. <filename> | source <filename>"),
 
3772
    return put_info("Usage: \\. <filename> | source <filename>",
3757
3773
                    INFO_ERROR, 0,0);
3758
3774
  while (isspace(*param))
3759
3775
    param++;
3768
3784
  if (!(sql_file = fopen(source_name, "r")))
3769
3785
  {
3770
3786
    char buff[FN_REFLEN+60];
3771
 
    sprintf(buff, _("Failed to open file '%s', error: %d"), source_name,errno);
 
3787
    sprintf(buff,"Failed to open file '%s', error: %d", source_name,errno);
3772
3788
    return put_info(buff, INFO_ERROR, 0 ,0);
3773
3789
  }
3774
3790
 
3776
3792
  if (line_buff == NULL)
3777
3793
  {
3778
3794
    fclose(sql_file);
3779
 
    return put_info(_("Can't initialize LineBuffer"), INFO_ERROR, 0, 0);
 
3795
    return put_info("Can't initialize LineBuffer", INFO_ERROR, 0, 0);
3780
3796
  }
3781
3797
 
3782
3798
  /* Save old status */
3812
3828
 
3813
3829
  if (!tmp || !*tmp)
3814
3830
  {
3815
 
    put_info(_("DELIMITER must be followed by a 'delimiter' character or string"),
 
3831
    put_info("DELIMITER must be followed by a 'delimiter' character or string",
3816
3832
             INFO_ERROR, 0, 0);
3817
3833
    return 0;
3818
3834
  }
3820
3836
  {
3821
3837
    if (strstr(tmp, "\\"))
3822
3838
    {
3823
 
      put_info(_("DELIMITER cannot contain a backslash character"),
 
3839
      put_info("DELIMITER cannot contain a backslash character",
3824
3840
               INFO_ERROR, 0, 0);
3825
3841
      return 0;
3826
3842
    }
3845
3861
  tmp= get_arg(buff, 0);
3846
3862
  if (!tmp || !*tmp)
3847
3863
  {
3848
 
    put_info(_("USE must be followed by a database name"), INFO_ERROR, 0, 0);
 
3864
    put_info("USE must be followed by a database name", INFO_ERROR, 0, 0);
3849
3865
    return 0;
3850
3866
  }
3851
3867
  /*
3913
3929
      build_completion_hash(opt_rehash, 1);
3914
3930
  }
3915
3931
 
3916
 
  put_info(_("Database changed"),INFO_INFO, 0, 0);
 
3932
  put_info("Database changed",INFO_INFO, 0, 0);
3917
3933
  return 0;
3918
3934
}
3919
3935
 
3920
 
static int com_shutdown(string *, const char *)
3921
 
{
3922
 
  drizzle_result_st result;
3923
 
  drizzle_return_t ret;
3924
 
 
3925
 
  if (verbose)
3926
 
  {
3927
 
    printf(_("shutting down drizzled"));
3928
 
    if (opt_drizzle_port > 0)
3929
 
      printf(_(" on port %d"), opt_drizzle_port);
3930
 
    printf("... ");
3931
 
  }
3932
 
 
3933
 
  if (drizzle_shutdown(&con, &result, DRIZZLE_SHUTDOWN_DEFAULT,
3934
 
                       &ret) == NULL || ret != DRIZZLE_RETURN_OK)
3935
 
  {
3936
 
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
3937
 
    {
3938
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
3939
 
              drizzle_result_error(&result));
3940
 
      drizzle_result_free(&result);
3941
 
    }
3942
 
    else
3943
 
    {
3944
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
3945
 
              drizzle_con_error(&con));
3946
 
    }
3947
 
    return false;
3948
 
  }
3949
 
 
3950
 
  drizzle_result_free(&result);
3951
 
 
3952
 
  if (verbose)
3953
 
    printf(_("done\n"));
3954
 
 
3955
 
  return false;
3956
 
}
3957
 
 
3958
3936
static int
3959
3937
com_warnings(string *, const char *)
3960
3938
{
3961
3939
  show_warnings = 1;
3962
 
  put_info(_("Show warnings enabled."),INFO_INFO, 0, 0);
 
3940
  put_info("Show warnings enabled.",INFO_INFO, 0, 0);
3963
3941
  return 0;
3964
3942
}
3965
3943
 
3967
3945
com_nowarnings(string *, const char *)
3968
3946
{
3969
3947
  show_warnings = 0;
3970
 
  put_info(_("Show warnings disabled."),INFO_INFO, 0, 0);
 
3948
  put_info("Show warnings disabled.",INFO_INFO, 0, 0);
3971
3949
  return 0;
3972
3950
}
3973
3951
 
4045
4023
    drizzle_free(&drizzle);
4046
4024
  }
4047
4025
  drizzle_create(&drizzle);
4048
 
 
4049
 
#ifdef DRIZZLE_ADMIN_TOOL
4050
 
  drizzle_con_options_t options= (drizzle_con_options_t) (DRIZZLE_CON_ADMIN | (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL));
4051
 
#else
4052
 
  drizzle_con_options_t options= (drizzle_con_options_t) (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
4053
 
#endif
4054
 
 
4055
 
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(),
4056
 
    opt_drizzle_port, (char *)user.c_str(),
4057
 
    (char *)password.c_str(), (char *)database.c_str(),
4058
 
    options) == NULL)
 
4026
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(), opt_drizzle_port, (char *)user.c_str(),
 
4027
                          (char *)password.c_str(), (char *)database.c_str(), opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
4059
4028
  {
4060
4029
    (void) put_error(&con, NULL);
4061
4030
    (void) fflush(stdout);
4111
4080
  drizzle_return_t ret;
4112
4081
 
4113
4082
  tee_puts("--------------", stdout);
4114
 
  printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
4115
 
         drizzle_version(), VERSION,
4116
 
         HOST_VENDOR, HOST_OS, HOST_CPU,
4117
 
         rl_library_version);
 
4083
  printf(_("drizzle  Ver %s Distrib %s, for %s-%s (%s) using readline %s\n"),
 
4084
  VER.c_str(), drizzle_version(),
 
4085
  HOST_VENDOR, HOST_OS, HOST_CPU,
 
4086
  rl_library_version);          /* Print version */
 
4087
 
4118
4088
 
4119
4089
  if (connected)
4120
4090
  {
4121
 
    tee_fprintf(stdout, _("\nConnection id:\t\t%lu\n"),drizzle_con_thread_id(&con));
 
4091
    tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",drizzle_con_thread_id(&con));
4122
4092
    /*
4123
4093
      Don't remove "limit 1",
4124
4094
      it is protection againts SQL_SELECT_LIMIT=0
4130
4100
      drizzle_row_t cur=drizzle_row_next(&result);
4131
4101
      if (cur)
4132
4102
      {
4133
 
        tee_fprintf(stdout, _("Current database:\t%s\n"), cur[0] ? cur[0] : "");
4134
 
        tee_fprintf(stdout, _("Current user:\t\t%s\n"), cur[1]);
 
4103
        tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
 
4104
        tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
4135
4105
      }
4136
4106
      drizzle_result_free(&result);
4137
4107
    }
4138
4108
    else if (ret == DRIZZLE_RETURN_ERROR_CODE)
4139
4109
      drizzle_result_free(&result);
4140
 
    tee_puts(_("SSL:\t\t\tNot in use"), stdout);
 
4110
    tee_puts("SSL:\t\t\tNot in use", stdout);
4141
4111
  }
4142
4112
  else
4143
4113
  {
4144
4114
    vidattr(A_BOLD);
4145
 
    tee_fprintf(stdout, _("\nNo connection\n"));
 
4115
    tee_fprintf(stdout, "\nNo connection\n");
4146
4116
    vidattr(A_NORMAL);
4147
4117
    return 0;
4148
4118
  }
4149
4119
  if (skip_updates)
4150
4120
  {
4151
4121
    vidattr(A_BOLD);
4152
 
    tee_fprintf(stdout, _("\nAll updates ignored to this database\n"));
 
4122
    tee_fprintf(stdout, "\nAll updates ignored to this database\n");
4153
4123
    vidattr(A_NORMAL);
4154
4124
  }
4155
 
  tee_fprintf(stdout, _("Current pager:\t\t%s\n"), pager.c_str());
4156
 
  tee_fprintf(stdout, _("Using outfile:\t\t'%s'\n"), opt_outfile ? outfile.c_str() : "");
4157
 
  tee_fprintf(stdout, _("Using delimiter:\t%s\n"), delimiter);
4158
 
  tee_fprintf(stdout, _("Server version:\t\t%s\n"), server_version_string(&con));
4159
 
  tee_fprintf(stdout, _("Protocol:\t\t%s\n"), opt_protocol.c_str());
4160
 
  tee_fprintf(stdout, _("Protocol version:\t%d\n"), drizzle_con_protocol_version(&con));
4161
 
  tee_fprintf(stdout, _("Connection:\t\t%s\n"), drizzle_con_host(&con));
 
4125
  tee_fprintf(stdout, "Current pager:\t\t%s\n", pager.c_str());
 
4126
  tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile.c_str() : "");
 
4127
  tee_fprintf(stdout, "Using delimiter:\t%s\n", delimiter);
 
4128
  tee_fprintf(stdout, "Server version:\t\t%s\n", server_version_string(&con));
 
4129
  tee_fprintf(stdout, "Protocol version:\t%d\n", drizzle_con_protocol_version(&con));
 
4130
  tee_fprintf(stdout, "Connection:\t\t%s\n", drizzle_con_host(&con));
4162
4131
/* XXX need to save this from result
4163
4132
  if ((id= drizzleclient_insert_id(&drizzle)))
4164
4133
    tee_fprintf(stdout, "Insert id:\t\t%s\n", internal::llstr(id, buff));
4165
4134
*/
4166
4135
 
4167
4136
  if (drizzle_con_uds(&con))
4168
 
    tee_fprintf(stdout, _("UNIX socket:\t\t%s\n"), drizzle_con_uds(&con));
 
4137
    tee_fprintf(stdout, "UNIX socket:\t\t%s\n", drizzle_con_uds(&con));
4169
4138
  else
4170
 
    tee_fprintf(stdout, _("TCP port:\t\t%d\n"), drizzle_con_port(&con));
 
4139
    tee_fprintf(stdout, "TCP port:\t\t%d\n", drizzle_con_port(&con));
4171
4140
 
4172
4141
  if (safe_updates)
4173
4142
  {
4174
4143
    vidattr(A_BOLD);
4175
 
    tee_fprintf(stdout, _("\nNote that you are running in safe_update_mode:\n"));
 
4144
    tee_fprintf(stdout, "\nNote that you are running in safe_update_mode:\n");
4176
4145
    vidattr(A_NORMAL);
4177
 
    tee_fprintf(stdout, _("\
 
4146
    tee_fprintf(stdout, "\
4178
4147
UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\
4179
4148
(One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n \
4180
4149
SELECT has an automatic 'LIMIT %lu' if LIMIT is not used.\n             \
4181
 
Max number of examined row combination in a join is set to: %lu\n\n"),
 
4150
Max number of examined row combination in a join is set to: %lu\n\n",
4182
4151
                select_limit, max_join_size);
4183
4152
  }
4184
4153
  tee_puts("--------------\n", stdout);
4236
4205
    if (info_type == INFO_ERROR)
4237
4206
    {
4238
4207
      (void) fflush(file);
4239
 
      fprintf(file,_("ERROR"));
 
4208
      fprintf(file,"ERROR");
4240
4209
      if (error)
4241
4210
      {
4242
4211
        if (sqlstate)
4279
4248
      if (error)
4280
4249
      {
4281
4250
        if (sqlstate)
4282
 
          (void) tee_fprintf(file, _("ERROR %d (%s): "), error, sqlstate);
 
4251
          (void) tee_fprintf(file, "ERROR %d (%s): ", error, sqlstate);
4283
4252
        else
4284
 
          (void) tee_fprintf(file, _("ERROR %d: "), error);
 
4253
          (void) tee_fprintf(file, "ERROR %d: ", error);
4285
4254
      }
4286
4255
      else
4287
 
        tee_puts(_("ERROR: "), file);
 
4256
        tee_puts("ERROR: ", file);
4288
4257
    }
4289
4258
    else
4290
4259
      vidattr(A_BOLD);
4417
4386
    tmp_buff_str << tmp;
4418
4387
 
4419
4388
    if (tmp > 1)
4420
 
      tmp_buff_str << _(" hours ");
 
4389
      tmp_buff_str << " hours ";
4421
4390
    else
4422
 
      tmp_buff_str << _(" hour ");
 
4391
      tmp_buff_str << " hour ";
4423
4392
  }
4424
4393
  if (sec >= 60.0)
4425
4394
  {
4426
4395
    tmp=(uint32_t) floor(sec/60.0);
4427
4396
    sec-=60.0*tmp;
4428
 
    tmp_buff_str << tmp << _(" min ");
 
4397
    tmp_buff_str << tmp << " min ";
4429
4398
  }
4430
4399
  if (part_second)
4431
4400
    tmp_buff_str.precision(2);
4432
4401
  else
4433
4402
    tmp_buff_str.precision(0);
4434
 
  tmp_buff_str << sec << _(" sec");
 
4403
  tmp_buff_str << sec << " sec";
4435
4404
  strcpy(buff, tmp_buff_str.str().c_str());
4436
4405
}
4437
4406
 
4532
4501
        if (!full_username)
4533
4502
          init_username();
4534
4503
        processed_prompt->append(part_username ? part_username :
4535
 
                                 (!current_user.empty() ?  current_user : _("(unknown)")));
 
4504
                                 (!current_user.empty() ?  current_user : "(unknown)"));
4536
4505
        break;
4537
4506
      case PROMPT_CHAR:
4538
4507
        {
4652
4621
{
4653
4622
  const char *ptr=strchr(line, ' ');
4654
4623
  if (ptr == NULL)
4655
 
    tee_fprintf(stdout, _("Returning to default PROMPT of %s\n"),
 
4624
    tee_fprintf(stdout, "Returning to default PROMPT of %s\n",
4656
4625
                default_prompt);
4657
4626
  prompt_counter = 0;
4658
4627
  char * tmpptr= strdup(ptr ? ptr+1 : default_prompt);
4659
4628
  if (tmpptr == NULL)
4660
 
    tee_fprintf(stdout, _("Memory allocation error. Not changing prompt\n"));
 
4629
    tee_fprintf(stdout, "Memory allocation error. Not changing prompt\n");
4661
4630
  else
4662
4631
  {
4663
4632
    current_prompt.erase();
4664
4633
    current_prompt= tmpptr;
4665
 
    tee_fprintf(stdout, _("PROMPT set to '%s'\n"), current_prompt.c_str());
 
4634
    tee_fprintf(stdout, "PROMPT set to '%s'\n", current_prompt.c_str());
4666
4635
  }
4667
4636
  return 0;
4668
4637
}