news.c revision 0d8b53344490faab75b127936edb53a2f1e0dc01
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
news -a prints all news items, latest first
news -n lists names of new items
news -s tells count of new items only
news prints items changed since last news
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <setjmp.h>
#include <signal.h>
#include <dirent.h>
#include <pwd.h>
#include <time.h>
#include <locale.h>
#define INDENT 3
#define DATE_FMT "%a %b %e %H:%M:%S %Y"
/*
* %a abbreviated weekday name
* %b abbreviated month name
* %e day of month
* %H hour (24-hour clock)
* %M minute
* %S second
* %Y year
*/
/*
The following items should not be printed.
*/
char *ignore[] = {
"core",
};
struct n_file {
long n_time;
} *n_list;
int aopt = 0; /* 1 say -a specified */
int n_count; /* number of items in NEWS directory */
int number_read; /* number of items read */
int nopt = 0; /* 1 say -n specified */
int optsw; /* for getopt */
int opt = 0; /* number of options specified */
int sopt = 0; /* 1 says -s specified */
void all_news(void);
int ck_num(void);
void count(char *);
void initialize(void);
void late_news(void(*)(), int);
void notify(char *);
void print_item(char *);
void read_dir(void);
int
{
int i;
initialize();
read_dir();
if (argc <= 1) {
ck_num();
}
switch(optsw) {
case 'a':
aopt++;
opt++;
break;
case 'n':
nopt++;
opt++;
break;
case 's':
sopt++;
opt++;
break;
default:
exit (1);
}
if (opt > 1) {
exit(1);
}
exit(1);
}
if (aopt) {
all_news();
ck_num();
exit(0);
}
if (nopt) {
ck_num();
exit(0);
}
if (sopt) {
exit(0);
}
return (0);
}
/*
* read_dir: get the file names and modification dates for the
*/
void
read_dir(void)
{
int i, j;
/* Open the current directory */
exit (1);
}
/* Read the file names into n_list */
n_count = 0;
register char **p;
p = ignore;
++p;
if (!*p) {
if (n_count++ > 0)
(unsigned)
(sizeof (struct n_file)
* n_count));
else
((unsigned)
(sizeof (struct n_file) *
n_count));
exit (1);
}
}
}
}
/* Sort the elements of n_list in decreasing time order */
for (i=1; i<n_count; i++)
for (j=0; j<i; j++)
}
/* Clean up */
}
void
initialize(void)
{
exit (1);
}
}
void
all_news(void)
{
int i;
for (i=0; i<n_count; i++)
}
void
print_item(char *f)
{
static int firstitem = 1;
void onintr();
if (f == NULL) {
return;
}
else {
if (firstitem) {
firstitem = 0;
putchar ('\n');
}
goto finish;
if (pw)
else
printf (".....");
op = 0;
switch (c) {
case '\r':
case '\n':
putchar (c);
op = 0;
break;
case ' ':
ip++;
break;
case '\b':
ip--;
break;
case '\t':
break;
default:
putchar ('\b');
op--;
}
putchar ('\t');
}
putchar (' ');
op++;
}
putchar (c);
ip++;
op++;
break;
}
}
putchar ('\n');
number_read++;
}
}
void
{
long cutoff;
int i;
int fd;
struct {
} utb;
extern char *getenv();
/* Determine the time when last called */
exit (1);
}
/* Print the recent items */
number_read++;
}
if (update) {
/* Re-create the file and refresh the update time */
}
}
}
void
notify(char *s)
{
static int first = 1;
if (s) {
if (first) {
first = 0;
}
printf (" %.14s", s);
} else if (!first)
putchar ('\n');
}
/*ARGSUSED*/
void
count(char *s)
{
static int nitems = 0;
if (s)
nitems++;
else {
if (nitems) {
if (nitems != 1)
putchar ('s');
printf (".\n");
}
else printf("No news.\n");
}
}
void
onintr()
{
sleep(2);
}
int
ck_num(void)
{
return(0);
}