forked from blackav/ejudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copyright.c
70 lines (60 loc) · 2.41 KB
/
copyright.c
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* -*- mode: c -*- */
/* Copyright (C) 2003-2019 Alexander Chernov <[email protected]> */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ejudge/config.h"
#include "ejudge/copyright.h"
#include "ejudge/version.h"
#include "ejudge/xalloc.h"
#include <stdio.h>
#if CONF_HAS_LIBINTL - 0 == 1
#include <libintl.h>
#define _(x) gettext(x)
#else
#define _(x) x
#endif
static void
make_copyright(unsigned char *buf, size_t size)
{
snprintf(buf, size,
_("<p class=\"ejudge_copyright\">This is <a href=\"%s\"><b>ejudge</b></a> contest administration system, version %s, compiled %s.</p>\n"
"<p class=\"ejudge_copyright\">This program is copyright © %s Alexander Chernov.</p>\n"
"<p class=\"ejudge_copyright\">"
"This program is free software; you can redistribute it and/or modify it under the terms of the <a href=\"http://www.gnu.org/licenses/gpl.html\">GNU General Public License</a> as published by the <a href=\"http://www.fsf.org\">Free Software Foundation</a>; either version 2 of the License, or (at your option) any later version.</p>\n"),
"http://www.ejudge.ru",
compile_version, compile_date, "2000-2019");
}
static unsigned char *copyright_str = 0;
static int copyright_locale = 0;
unsigned char *
get_copyright(int locale_id)
{
//fprintf(stderr, "get_copyright: %d, %s, %s\n", locale_id, getenv("LANG"), getenv("LC_ALL"));
if (!copyright_str || locale_id != copyright_locale) {
unsigned char buf[8192];
buf[0] = 0;
make_copyright(buf, sizeof(buf));
xfree(copyright_str);
copyright_str = xstrdup(buf);
copyright_locale = locale_id;
}
return copyright_str;
}
void
write_copyright_short(FILE *out_f)
{
fprintf(out_f,
"<p class=\"ejudge_copyright\"><a href=\"%s\">ejudge %s (%s)</a>.</p>\n"
"<p class=\"ejudge_copyright\">Copyright © %s Alexander Chernov.</p>\n",
"http://www.ejudge.ru",
compile_version, compile_date, "2000-2019");
}