summaryrefslogtreecommitdiff
path: root/backend/utils.h
blob: b3976b8bbdcc7b88dfd2b37bab9260d14c2645dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */
#pragma once

#include <curl/curl.h>
#include <sqlite3.h>

namespace katja
{
enum class Info
{
    // Error.
    unknown,
    // Installed in the same version.
    installed,
    // A different version is installed.
    updating,
    // Available, but not installed.
    installing,
    // Available.
    available
};

struct JobData
{
    sqlite3 *db;
    CURL *curl;

    virtual void package(Info info, const char *package_id, const char *summary) = 0;
    virtual void files(char **) = 0;
    virtual void details(char *package_id,
            const char *group, const char *description, const char *homepage, int uncompressed) = 0;
    virtual void set_percentage(double) = 0;
};

CURLcode get_file(CURL **curl, char *source_url, char *dest);

char **split_package_name(const char *pkg_filename);

Info is_installed(const char *pkg_fullname);

int cmp_repo(const void *a, const void *b);

}