source: trunk/athena/bin/neos/purge.c @ 13635

Revision 13635, 2.4 KB checked in by danw, 25 years ago (diff)
NEOS clients, from athena/lib/neos/clients
Line 
1/**********************************************************************
2 * File Exchange purge module
3 *
4 * $Id: purge.c,v 1.1 1999-09-28 22:10:59 danw Exp $
5 *
6 * Copyright 1990 by the Massachusetts Institute of Technology.
7 *
8 * For copying and distribution information, please see the file
9 * <mit-copyright.h>.
10 **********************************************************************/
11
12#include <mit-copyright.h>
13
14#ifndef lint
15static char rcsid_collect_c[] = "$Id: purge.c,v 1.1 1999-09-28 22:10:59 danw Exp $";
16#endif /* lint */
17
18#include <stdio.h>
19#include <sys/time.h>
20#include <fx/memory.h>
21#include <ctype.h>
22#include <string.h>
23#include <sys/errno.h>
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <sys/file.h>
27#include "fxmain.h"
28
29/*** Global variables ***/
30Paper **paperv;
31char *full_name();
32char purge_err_context[1024];
33int compar();
34long prep_paper();
35
36/*
37 * do_dump -- dumps papers into files
38 */
39
40long
41do_purge(fxp, criterion, flags, user)
42     FX *fxp;
43     Paper *criterion;
44     int flags;
45     char *user;
46{
47  long code;
48  Paperlist_res *plist;
49  int count, i, found = 0;
50
51  criterion->author = user;
52  /******** get list of papers from server ********/
53  code = fx_list(fxp, criterion, &plist);
54  if (code) {
55    strcpy(purge_err_context, "while retrieving list");
56    return(code);
57  }
58
59  count = get_array(plist->Paperlist_res_u.list, &paperv);
60
61  /******** deal with empty list ********/
62  if (count == 0) {
63    if (flags & VERBOSE)
64      empty_list(criterion);
65    return(0L);
66  }
67
68  /******** main loop through list ********/
69  for (i=0; i<count; i++) {
70
71    /******* Skip papers not in time range ********/
72    if (paperv[i]->modified.tv_sec < criterion->created.tv_sec ||
73        paperv[i]->modified.tv_sec > criterion->modified.tv_sec) continue;
74
75    found = 1;
76
77    prep_paper(paperv[i], flags);
78
79    if (flags & VERBOSE) {
80      /******** print information about file ********/
81      printf("%5d %-9s %9d  %-16.16s  %s\n", paperv[i]->assignment,
82             paperv[i]->owner, paperv[i]->size,
83             ctime(&(paperv[i]->modified.tv_sec)), paperv[i]->filename);
84    }
85
86    if (!(flags & LISTONLY)) {
87      /******** delete file from server ********/
88      code = fx_delete(fxp, paperv[i]);
89      if (code) {
90        strcpy(purge_err_context, "while deleting.");
91        return(code);
92      }
93    }
94  }
95
96  /******** clean up ********/
97  if (!found && (flags & VERBOSE)) empty_list(criterion);
98  fx_list_destroy(&plist);
99  free((char *) paperv);
100  return(0L);
101}
Note: See TracBrowser for help on using the repository browser.