/[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.4 - (show annotations)
Tue Jan 1 21:03:23 2002 UTC (15 years, 9 months ago) by bertho
Branch: MAIN
CVS Tags: REL_1_2_0, REL_1_4_0, REL_1_4_1, REL_1_3_0, REL_1_5_1, REL_1_5_0, REL_1_5_2
Changes since 1.3: +4 -3 lines
File MIME type: text/plain
Major code update to enable some more features. The new formatting scheme is
not yet 100%. This should be close to version 1.2.0.
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 "utils.h"
28 #include "readconf.h"
29
30 const char *input_file;
31 int quiet; /* Set if warnings should be suppressed */
32
33 void *xmalloc(size_t s)
34 {
35 void *p = malloc(s);
36 if(!p)
37 {
38 printf("Out of memory");
39 exit(1);
40 }
41 memset(p, 0, s);
42 return p;
43 }
44
45 void *xrealloc(void *a, size_t s)
46 {
47 void *p;
48 if(!a)
49 return malloc(s);
50 p = realloc(a, s);
51 if(!p)
52 {
53 printf("Out of memory");
54 exit(1);
55 }
56 return p;
57 }
58
59 char *xstrdup(const char *s)
60 {
61 char *c;
62 if(!s)
63 s = "";
64 c = xmalloc(strlen(s)+1);
65 strcpy(c, s);
66 return c;
67 }
68
69 void xfree(void *p)
70 {
71 if(p)
72 free(p);
73 }
74
75 static int do_msg(const char *type, const char *fmt, va_list va)
76 {
77 fprintf(stderr, "%s: ", input_file);
78 if(line_number)
79 fprintf(stderr, "%d: ", line_number);
80 if(type)
81 fprintf(stderr, "%s: ", type);
82 vfprintf(stderr, fmt, va);
83 fprintf(stderr, "\n");
84 return 0;
85 }
86
87 int yyerror(const char *fmt, ...)
88 {
89 va_list va;
90 va_start(va, fmt);
91 do_msg(NULL, fmt, va);
92 va_end(va);
93 exit(2);
94 return 0;
95 }
96
97 int yywarning(const char *fmt, ...)
98 {
99 va_list va;
100 if(!quiet)
101 {
102 va_start(va, fmt);
103 do_msg("warning", fmt, va);
104 va_end(va);
105 }
106 return 0;
107 }
108
109 int rcserror(const char *fmt, ...)
110 {
111 va_list va;
112 va_start(va, fmt);
113 do_msg(NULL, fmt, va);
114 va_end(va);
115 exit(2);
116 return 0;
117 }

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0