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