~ted/ubuntu-app-launch/lp1575990-more-tollerant-stop

« back to all changes in this revision

Viewing changes to tools/ubuntu-app-triplet.cpp

  • Committer: CI Train Bot
  • Author(s): Ted Gould
  • Date: 2016-04-21 19:47:02 UTC
  • mfrom: (208.7.4 libpam-cgfs-lp1535058)
  • Revision ID: ci-train-bot@canonical.com-20160421194702-dbxi7v2s9qmud390
Add dependency on libpam-cgfs on Xenial so that cgroups work properly in Upstart Fixes: #1535058
Approved by: Charles Kerr

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright © 2014 Canonical Ltd.
 
2
 * Copyright © 2016 Canonical Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify it
5
5
 * under the terms of the GNU General Public License version 3, as published
17
17
 *     Ted Gould <ted.gould@canonical.com>
18
18
 */
19
19
 
20
 
#include "libubuntu-app-launch/ubuntu-app-launch.h"
21
 
 
22
 
int
23
 
main (int argc, gchar * argv[]) {
24
 
 
25
 
        if (argc > 4 || argc == 1) {
26
 
                g_printerr("Usage: %s <package> [application] [version]\n", argv[0]);
27
 
                return 1;
28
 
        }
29
 
 
30
 
        gchar * pkg = argv[1];
31
 
        gchar * app = NULL;
32
 
        gchar * ver = NULL;
33
 
 
34
 
        if (argc > 2) {
35
 
                app = argv[2];
36
 
        }
37
 
 
38
 
        if (argc > 3) {
39
 
                app = argv[3];
40
 
        }
41
 
 
42
 
        gchar * appid = ubuntu_app_launch_triplet_to_app_id(pkg, app, ver);
43
 
        if (appid == NULL) {
44
 
                return -1;
45
 
        }
46
 
 
47
 
        g_print("%s\n", appid);
48
 
        g_free(appid);
49
 
 
50
 
        return 0;
 
20
#include <iostream>
 
21
#include "libubuntu-app-launch/application.h"
 
22
 
 
23
int main(int argc, char* argv[])
 
24
{
 
25
    ubuntu::app_launch::AppID appid;
 
26
 
 
27
    switch (argc)
 
28
    {
 
29
        case 2:
 
30
            appid = ubuntu::app_launch::AppID::discover(argv[1]);
 
31
            break;
 
32
        case 3:
 
33
            appid = ubuntu::app_launch::AppID::discover(argv[1], argv[2]);
 
34
            break;
 
35
        case 4:
 
36
            appid = ubuntu::app_launch::AppID::discover(argv[1], argv[2], argv[3]);
 
37
            break;
 
38
        default:
 
39
            std::cerr << "Usage: " << argv[0] << " <package> [application] [version]" << std::endl;
 
40
            return 1;
 
41
    }
 
42
 
 
43
    std::cout << (std::string)appid << std::endl;
 
44
    return 0;
51
45
}