File: changed.c

package info (click to toggle)
xmotd 1.17.3b-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 572 kB
  • sloc: ansic: 3,683; makefile: 752; sh: 20
file content (68 lines) | stat: -rw-r--r-- 2,062 bytes parent folder | download | duplicates (9)
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
/* Copyright 1993-97  Luis Fernandes <elf@ee.ryerson.ca> 
 *
 * Permission to use, copy, hack, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  This application is presented as is
 * without any implied or written warranty.
 */

/*
 * 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.
 * 
 */
/* changed.c: utility function for checking the times of 2 files
 * $Id: changed.c,v 1.4 1997/06/02 11:28:58 elf Exp $ 
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <X11/Intrinsic.h>

#include "main.h"

extern app_res_t app_res;

/* motdChanged() returns time_t of the motd file: if modification time
 * of motd is greater than the modification time of time-stamp file;
 * else it returns 0.
 * */

time_t 
motdChanged(char *motd, char *stamp)
{
  struct stat motdstat, tsstat;

  stat(motd, &motdstat);

  if(stat(stamp, &tsstat))
    {
     extern int errno;

      if(errno==ENOENT)			/* file does not exist if 1st time */
		return(motdstat.st_mtime);
    }

  if(motdstat.st_mtime <= tsstat.st_mtime) /*Butch Deal*/
    return((time_t) 0);

  if(!motdstat.st_size && !app_res.always)
    return((time_t) 0);

  return(motdstat.st_mtime);
}