File: update.c

package info (click to toggle)
gretl 2025a-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 64,792 kB
  • sloc: ansic: 425,462; sh: 4,916; makefile: 3,251; cpp: 2,777; xml: 606; perl: 364
file content (88 lines) | stat: -rw-r--r-- 2,341 bytes parent folder | download | duplicates (4)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 *  gretl -- Gnu Regression, Econometrics and Time-series Library
 *  Copyright (C) 2001 Allin Cottrell and Riccardo "Jack" Lucchetti
 *
 *  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 3 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.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "gretl.h"
#include "gretl_www.h"
#include "version.h"

static void show_update_message (int vserver)
{
    int vclient = gretl_version_number(GRETL_VERSION);
    char latest[16];
    gchar *msg;

    gretl_version_string(latest, vserver);

    if (vserver > vclient) {
	msg = g_strdup_printf(_("You are running gretl %s.\n"
				"Version %s is available at http://gretl.sourceforge.net/\n"),
				GRETL_VERSION, latest);
    } else if (vclient > vserver) {
	msg = g_strdup_printf(_("You are running gretl %s.\n"
				"This seems to be a pre-release; the latest version available at\n"
				"http://gretl.sourceforge.net/ is %s"),
			      GRETL_VERSION, latest);
    } else {
	msg = g_strdup_printf(_("You are running gretl %s.\n"
				"This is the current version."), GRETL_VERSION);
    }

    infobox(msg);
    g_free(msg);
}

static int real_update_query (int verbose)
{
    char *getbuf = NULL;
    int err;

    err = get_update_info(&getbuf, verbose);

    if (err || getbuf == NULL) {
	return 1;
    }

    if (strncmp(getbuf, "server-latest:", 14) == 0) {
	int vserver = atoi(getbuf + 15);

	show_update_message(vserver);
    } else if (strncmp(getbuf, "message:", 8) == 0) {
	infobox(getbuf + 9);
    } else if (verbose) {
	infobox(_("No new files"));
    }

    free(getbuf);

    return err;
}

#if 0
int silent_update_query (void)
{
    /* not used right now, but we may want to reactivate it
       in some form */
    return real_update_query(0);
}
#endif

int update_query (void)
{
    return real_update_query(1);
}