[go: up one dir, main page]

File: io.c

package info (click to toggle)
linpopup 0.9.3.pre4-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 440 kB
  • ctags: 151
  • sloc: ansic: 2,102; sh: 197; makefile: 171
file content (55 lines) | stat: -rw-r--r-- 1,609 bytes parent folder | download
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
/* LinPopUp - A Linux enhanced port of Winpopup, running over Samba.
 * By Jean-Marc Jacquet <littleigloo@chez.com> 
 * Copyright (C) 1998 Little Igloo Org  http://www.chez.com/littleigloo
 *
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "protos.h"



void
fatal_error (int code, char *data)
{
  char error_message[250];
  char buf[128];
  switch (code)
    {
    case 1:
      sprintf (error_message, "Can't read file %s", data);
      break;
    case 2:
      sprintf (error_message, "Can't get Environment Variable %s", data);
      break;
    default:
      strcpy (error_message, "Unknown error");
    }
  printf ("\n== %s FATAL ERROR ==\n%s\nExit code (%i).\n\n", what_is_this_stupid_programm_that_have_crashed (buf), error_message, code);
  exit (code);
}



void
vital_check_for_read_access (char *filename)
{
  if (access (filename, R_OK))
    fatal_error (1, filename);
}