]> git.saurik.com Git - apt.git/blob - apt-private/private-main.cc
Japanese program translation update
[apt.git] / apt-private / private-main.cc
1 #include <config.h>
2
3 #include <apt-pkg/cmndline.h>
4 #include <apt-pkg/configuration.h>
5 #include <apt-pkg/fileutl.h>
6
7 #include <apt-private/private-main.h>
8
9 #include <iostream>
10 #include <locale>
11
12 #include <string.h>
13 #include <unistd.h>
14 #include <signal.h>
15
16 #include <apti18n.h>
17
18
19 void InitLocale(APT_CMD const binary) /*{{{*/
20 {
21 try {
22 std::locale::global(std::locale(""));
23 } catch (...) {
24 setlocale(LC_ALL, "");
25 }
26 switch(binary)
27 {
28 case APT_CMD::APT:
29 case APT_CMD::APT_CACHE:
30 case APT_CMD::APT_CDROM:
31 case APT_CMD::APT_CONFIG:
32 case APT_CMD::APT_HELPER:
33 case APT_CMD::APT_GET:
34 case APT_CMD::APT_MARK:
35 textdomain("apt");
36 break;
37 case APT_CMD::APT_EXTRACTTEMPLATES:
38 case APT_CMD::APT_FTPARCHIVE:
39 case APT_CMD::APT_INTERNAL_SOLVER:
40 case APT_CMD::APT_SORTPKG:
41 textdomain("apt-utils");
42 break;
43 }
44 }
45 void InitLocale() {}
46 /*}}}*/
47 void InitSignals() /*{{{*/
48 {
49 signal(SIGPIPE,SIG_IGN);
50 }
51 /*}}}*/
52 void CheckIfSimulateMode(CommandLine &CmdL) /*{{{*/
53 {
54 // disable locking in simulation, but show the message only for users
55 // as root hasn't the same problems like unreadable files which can heavily
56 // distort the simulation.
57 if (_config->FindB("APT::Get::Simulate") == true &&
58 (CmdL.FileSize() == 0 ||
59 (strcmp(CmdL.FileList[0], "source") != 0 && strcmp(CmdL.FileList[0], "download") != 0 &&
60 strcmp(CmdL.FileList[0], "changelog") != 0)))
61 {
62 if (getuid() != 0 && _config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
63 std::cout << _("NOTE: This is only a simulation!\n"
64 " apt-get needs root privileges for real execution.\n"
65 " Keep also in mind that locking is deactivated,\n"
66 " so don't depend on the relevance to the real current situation!"
67 ) << std::endl;
68 _config->Set("Debug::NoLocking",true);
69 }
70 }
71 /*}}}*/
72 void CheckIfCalledByScript(int argc, const char *argv[]) /*{{{*/
73 {
74 if (unlikely(argc < 1)) return;
75
76 if(!isatty(STDOUT_FILENO) &&
77 _config->FindB("Apt::Cmd::Disable-Script-Warning", false) == false)
78 {
79 std::cerr << std::endl
80 << "WARNING: " << flNotDir(argv[0]) << " "
81 << "does not have a stable CLI interface. "
82 << "Use with caution in scripts."
83 << std::endl
84 << std::endl;
85 }
86 }
87 /*}}}*/