#include <string>
#include "common/step/step.h"
+#include "utils/macros.h"
namespace common_installer {
pkgmgr_installer* pi_;
static State state_;
- // TODO(t.iwanek): use DISALLOW_COPY_AND_ASSIGN
- PkgmgrSignal(const PkgmgrSignal&) = delete;
- PkgmgrSignal& operator=(const PkgmgrSignal&) = delete;
+ DISALLOW_COPY_AND_ASSIGN(PkgmgrSignal);
};
} // namespace common_installer
// found in the LICENSE file.
/*
- A step is made of 3 functions (that can be defined or NULL)
+ A step is made of 3 functions (that can be defined or null)
and one data pointer.
The functions are:
return Step::Status::ERROR;
}
- xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
+ xmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr);
xmlTextWriterSetIndent(writer, 1);
#include <cstring>
#include <string>
+#include "utils/byte_size_literals.h"
#include "utils/file_util.h"
-#define ZIPBUFSIZE 8192
-#define ZIPMAXPATH 256
+namespace {
+
+unsigned kZipBufSize = 8_kB;
+unsigned kZipMaxPath = 256;
+
+}
namespace bf = boost::filesystem;
namespace bs = boost::system;
unz_global_info info;
unz_file_info64 raw_file_info;
- char raw_file_name_in_zip[ZIPMAXPATH];
+ char raw_file_name_in_zip[kZipMaxPath];
unzFile* zip_file = static_cast<unzFile*>(unzOpen(path.string().c_str()));
if (zip_file == nullptr) {
for (uLong i = 0; i < info.number_entry; i++) {
if (unzGetCurrentFileInfo64(zip_file, &raw_file_info, raw_file_name_in_zip,
- sizeof(raw_file_name_in_zip), NULL, 0, NULL, 0) != UNZ_OK) {
+ sizeof(raw_file_name_in_zip), nullptr, 0, nullptr, 0) != UNZ_OK) {
LOG(ERROR) << "Failed to read file info";
return -1;
}
}
unz_global_info info;
- char read_buffer[ZIPBUFSIZE];
+ char read_buffer[kZipBufSize];
unz_file_info raw_file_info;
- char raw_file_name_in_zip[ZIPMAXPATH];
+ char raw_file_name_in_zip[kZipMaxPath];
current_path(tmp_dir);
unzFile* zip_file = static_cast<unzFile*>(unzOpen(src));
- if (zip_file == NULL) {
+ if (!zip_file) {
LOG(ERROR) << "Failed to open the source dir: " << src;
return Step::Status::ERROR;
}
for (uLong i = 0; i < info.number_entry; i++) {
if (unzGetCurrentFileInfo(zip_file, &raw_file_info, raw_file_name_in_zip,
- sizeof(raw_file_name_in_zip), NULL, 0, NULL, 0) != UNZ_OK) {
+ sizeof(raw_file_name_in_zip), nullptr, 0, nullptr, 0) != UNZ_OK) {
LOG(ERROR) << "Failed to read file info";
unzClose(zip_file);
return Step::Status::ERROR;
int ret = UNZ_OK;
do {
- ret = unzReadCurrentFile(zip_file, read_buffer, ZIPBUFSIZE);
+ ret = unzReadCurrentFile(zip_file, read_buffer, kZipBufSize);
if (ret < 0) {
LOG(ERROR) << "Failed to read data: " << ret;
unzCloseCurrentFile(zip_file);
#include "signature/signature_data.h"
#include "signature/signature_parser.h"
#include "signature/signature_xmlsec_adaptor.h"
+#include "utils/byte_size_literals.h"
namespace bf = boost::filesystem;
namespace {
-const int kXMLLogSize = 1024;
+const int kXMLLogSize = 1_kB;
const char kAuthorSignatureName[] = "author-signature.xml";
const char kTokenRoleAuthorURI[] =
using Step::Step;
Status process() override;
- Status clean() override { return Status::OK; };
- Status undo() override { return Status::OK; };
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
Status precheck() override { return Status::OK; }
-
private:
boost::filesystem::path* GetManifestFilePath(
const boost::filesystem::path& dir);
namespace ci = common_installer;
namespace {
- const char kPkgType[] = "tpk";
+
+const char kPkgType[] = "tpk";
+
} // namespace
namespace tpk {
bool Init(int argc, char** argv);
bool Run();
-
private:
int Install();
int Uninstall();
}; // class Task
} // namespace tpk
+
#endif // TPK_TASK_H_
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef UTILS_BYTE_SIZE_LITERALS_H_
+#define UTILS_BYTE_SIZE_LITERALS_H_
+
+constexpr unsigned long long operator"" _kB(unsigned long long v) { // NOLINT
+ return v * (1 << 10);
+}
+
+constexpr unsigned long long operator"" _MB(unsigned long long v) { // NOLINT
+ return v * (1 << 20);
+}
+
+constexpr unsigned long long operator"" _GB(unsigned long long v) { // NOLINT
+ return v * (1 << 30);
+}
+
+#endif // UTILS_BYTE_SIZE_LITERALS_H_
+
char str[3] = {"\0", };
str[0] = input[i + 1];
str[1] = input[i + 2];
- int result = strtol(str, NULL, 16);
+ int result = strtol(str, nullptr, 16);
// RFC 1738 - octets 80 to FF are not allowed
if (result >= 128)
return std::string();
new WidgetHandler
};
- std::unique_ptr<parser::ManifestHandlerRegistry> registry;
- registry.reset(new parser::ManifestHandlerRegistry(handlers));
+ std::unique_ptr<parser::ManifestHandlerRegistry> registry(
+ new parser::ManifestHandlerRegistry(handlers));
parser_.reset(new parser::ManifestParser(std::move(registry)));
if (!parser_->ParseManifest(config_)) {
LIBXML_TEST_VERSION
XmlTree* t = nullptr;
- xmlDocPtr doc = xmlReadFile(xmlFilePath, NULL, 0);
+ xmlDocPtr doc = xmlReadFile(xmlFilePath, nullptr, 0);
if (doc) {
t = new XmlTree(doc);
} else {
XmlParser();
~XmlParser();
XmlTree* ParseAndGetNewTree(const char* xmlFilePath = "");
-
- private:
};
} // namespace xml_parser