/[CvsGraph]/cvsgraph/utils.c
ViewVC logotype

Annotate of /cvsgraph/utils.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations)
Tue Jun 21 00:02:48 2005 UTC (12 years, 4 months ago) by bertho
Branch: MAIN
CVS Tags: merge_automake_dev1_20080521, source_automake_dev1_20080521, merge_head_20080521, REL_1_6_1, REL_1_6_2, REL_1_6_0, REL_1_7_0, source_head_20080521, HEAD
Branch point for: svn-integration, automake-dev1
Changes since 1.4: +3 -0 lines
File MIME type: text/plain
Change color management to reduce used colors. This will help future
color extensions with color changes based on context/content. The
default setup uses 10 colors now instead of 14.
1 /*
2 * CvsGraph graphical representation generator of brances and revisions
3 * of a file in cvs/rcs.
4 *
5 * Copyright (C) 2001 B. Stultiens
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <stdarg.h>
25 #include <string.h>
26
27 #include <gd.h>
28
29 #include "utils.h"
30 #include "cvsgraph.h"
31 #include "readconf.h"
32
33 const char *input_file;
34 int quiet; /* Set if warnings should be suppressed */
35
36 void *xmalloc(size_t s)
37 {
38 void *p = malloc(s);
39 if(!p)
40 {
41 printf("Out of memory");
42 exit(1);
43 }
44 memset(p, 0, s);
45 return p;
46 }
47
48 void *xrealloc(void *a, size_t s)
49 {
50 void *p;
51 if(!a)
52 return malloc(s);
53 p = realloc(a, s);
54 if(!p)
55 {
56 printf("Out of memory");
57 exit(1);
58 }
59 return p;
60 }
61
62 char *xstrdup(const char *s)
63 {
64 char *c;
65 if(!s)
66 s = "";
67 c = xmalloc(strlen(s)+1);
68 strcpy(c, s);
69 return c;
70 }
71
72 void xfree(void *p)
73 {
74 if(p)
75 free(p);
76 }
77
78 static int do_msg(const char *type, const char *fmt, va_list va)
79 {
80 fprintf(stderr, "%s: ", input_file);
81 if(line_number)
82 fprintf(stderr, "%d: ", line_number);
83 if(type)
84 fprintf(stderr, "%s: ", type);
85 vfprintf(stderr, fmt, va);
86 fprintf(stderr, "\n");
87 return 0;
88 }
89
90 int yyerror(const char *fmt, ...)
91 {
92 va_list va;
93 va_start(va, fmt);
94 do_msg(NULL, fmt, va);
95 va_end(va);
96 exit(2);
97 return 0;
98 }
99
100 int yywarning(const char *fmt, ...)
101 {
102 va_list va;
103 if(!quiet)
104 {
105 va_start(va, fmt);
106 do_msg("warning", fmt, va);
107 va_end(va);
108 }
109 return 0;
110 }
111
112 int rcserror(const char *fmt, ...)
113 {
114 va_list va;
115 va_start(va, fmt);
116 do_msg(NULL, fmt, va);
117 va_end(va);
118 exit(2);
119 return 0;
120 }

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0