Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 233843 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/gcc-id.c (+42 lines)
Lines 66-71 char* dcc_get_gcc_machine(char *s, size_t nbytes) { Link Here
66
    return read_string_from_popen("cc -dumpmachine", s, nbytes);
66
    return read_string_from_popen("cc -dumpmachine", s, nbytes);
67
}
67
}
68
68
69
char* dcc_get_gcc_profile(char *s, size_t nbytes) {
70
    static FILE *p = NULL;
71
    char *cmdline = "gcc-config -l | cut -d ' ' -f 3 | sed -e '/^$/d'";
72
    char **ret = NULL;
73
74
    errno = 0;
75
    if (p == NULL && !(p = popen(cmdline, "r"))) {
76
        rs_log_warning("Failed to get gcc profiles, not registering DNS-SD service subtype!");
77
        goto fail;
78
    }
79
80
    if (!fgets(s, (int) nbytes, p)) {
81
        goto fail;
82
    }
83
84
    s[nbytes-1] = 0;
85
    s[strcspn(s, " \t\n\r")] = 0;
86
87
    ret = s;
88
89
    return ret;
90
91
fail:
92
93
    if (p)
94
        pclose(p);
95
96
    return ret;
97
}
98
99
char* dcc_get_gcc_machine_from_profile(char *s, size_t nbytes, char *profile) {
100
	char cmdline[128];
101
	snprintf(cmdline, sizeof(cmdline), "gcc-config -S %s | cut -d ' ' -f 1", profile);
102
    return read_string_from_popen(cmdline, s, nbytes);
103
}
104
105
char* dcc_get_gcc_version_from_profile(char *s, size_t nbytes, char *profile) {
106
	char cmdline[128];
107
	snprintf(cmdline, sizeof(cmdline), "gcc-config -S %s | cut -d ' ' -f 2", profile);
108
    return read_string_from_popen(cmdline, s, nbytes);
109
}
110
69
char* dcc_make_dnssd_subtype(char *stype, size_t nbytes, const char *v, const char *m) {
111
char* dcc_make_dnssd_subtype(char *stype, size_t nbytes, const char *v, const char *m) {
70
    char version[64], machine[64];
112
    char version[64], machine[64];
71
113
(-)a/src/zeroconf-reg.c (-20 / +25 lines)
Lines 48-54 static void register_stuff(struct context *ctx) { Link Here
48
    }
48
    }
49
49
50
    if (avahi_entry_group_is_empty(ctx->group)) {
50
    if (avahi_entry_group_is_empty(ctx->group)) {
51
        char cpus[32], machine[64] = "cc_machine=", version[64] = "cc_version=", *m, *v;
51
        char profile[128], cpus[32], machine[64] = "cc_machine=", version[64] = "cc_version=", *m, *v;
52
52
53
        snprintf(cpus, sizeof(cpus), "cpus=%i", ctx->n_cpus);
53
        snprintf(cpus, sizeof(cpus), "cpus=%i", ctx->n_cpus);
54
        v = dcc_get_gcc_version(version+11, sizeof(version)-11);
54
        v = dcc_get_gcc_version(version+11, sizeof(version)-11);
Lines 77-101 static void register_stuff(struct context *ctx) { Link Here
77
            goto fail;
77
            goto fail;
78
        }
78
        }
79
79
80
        if (v && m) {
80
        while (dcc_get_gcc_profile(profile, sizeof(profile))) {
81
            char stype[128];
81
            v = dcc_get_gcc_version_from_profile(version+11, sizeof(version)-11, profile);
82
82
            m = dcc_get_gcc_machine_from_profile(machine+11, sizeof(machine)-11, profile);
83
            dcc_make_dnssd_subtype(stype, sizeof(stype), v, m);
83
84
84
            if (v && m) {
85
            if (avahi_entry_group_add_service_subtype(
85
                char stype[128];
86
                        ctx->group,
86
87
                        AVAHI_IF_UNSPEC,
87
                dcc_make_dnssd_subtype(stype, sizeof(stype), v, m);
88
                        AVAHI_PROTO_UNSPEC,
88
89
                        0,
89
                if (avahi_entry_group_add_service_subtype(
90
                        ctx->name,
90
                            ctx->group,
91
                        DCC_DNS_SERVICE_TYPE,
91
                            AVAHI_IF_UNSPEC,
92
                        NULL,
92
                            AVAHI_PROTO_UNSPEC,
93
                        stype) < 0) {
93
                            0,
94
                rs_log_crit("Failed to add service: %s\n", avahi_strerror(avahi_client_errno(ctx->client)));
94
                            ctx->name,
95
                goto fail;
95
                            DCC_DNS_SERVICE_TYPE,
96
            }
96
                            NULL,
97
        } else
97
                            stype) < 0) {
98
            rs_log_warning("Failed to determine CC version, not registering DNS-SD service subtype!");
98
                    rs_log_crit("Failed to add service: %s\n", avahi_strerror(avahi_client_errno(ctx->client)));
99
                    goto fail;
100
                }
101
            } else
102
                rs_log_warning("Failed to get cc machine and version, not registering DNS-SD service subtype for profile: %s!", profile);
103
        }
99
104
100
        if (avahi_entry_group_commit(ctx->group) < 0) {
105
        if (avahi_entry_group_commit(ctx->group) < 0) {
101
            rs_log_crit("Failed to commit entry group: %s\n", avahi_strerror(avahi_client_errno(ctx->client)));
106
            rs_log_crit("Failed to commit entry group: %s\n", avahi_strerror(avahi_client_errno(ctx->client)));
(-)a/src/zeroconf.h (+3 lines)
Lines 10-15 int dcc_zeroconf_unregister(void*); Link Here
10
10
11
char* dcc_get_gcc_version(char *s, size_t nbytes);
11
char* dcc_get_gcc_version(char *s, size_t nbytes);
12
char* dcc_get_gcc_machine(char *s, size_t nbytes);
12
char* dcc_get_gcc_machine(char *s, size_t nbytes);
13
char* dcc_get_gcc_profile(char *s, size_t nbytes);
14
char* dcc_get_gcc_machine_from_profile(char *s, size_t nbytes, char *profile);
15
char* dcc_get_gcc_version_from_profile(char *s, size_t nbytes, char *profile);
13
16
14
char* dcc_make_dnssd_subtype(char *stype, size_t nbytes, const char *v, const char *m);
17
char* dcc_make_dnssd_subtype(char *stype, size_t nbytes, const char *v, const char *m);
15
18

Return to bug 233843