source: trunk/athena/bin/neos/uncollect.c @ 19063

Revision 19063, 2.4 KB checked in by ghudson, 22 years ago (diff)
errno.h, not sys/errno.h.
Line 
1/**********************************************************************
2 * File Exchange uncollect client
3 *
4 * $Id: uncollect.c,v 1.2 2003-03-20 07:31:36 ghudson Exp $
5 *
6 * Copyright 1989, 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_uncollect_c[] = "$Id: uncollect.c,v 1.2 2003-03-20 07:31:36 ghudson 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 <errno.h>
24#include <sys/types.h>
25#include <sys/stat.h>
26#include "fxmain.h"
27
28/*
29 * do_uncollect -- dumps papers into files
30 */
31
32long
33do_uncollect(fxp, criterion, flags, user)
34     FX *fxp;
35     Paper *criterion;
36     int flags;
37     char *user;
38{
39  long code;
40  Paperlist_res *plist;
41  Paperlist l;
42  PaperType newtype;
43  Paper newp;
44
45  newtype = criterion->type;
46  criterion->type = TAKEN;
47  criterion->author = user;
48  /******** get list of papers from server ********/
49  code = fx_list(fxp, criterion, &plist);
50  criterion->type = newtype;
51  if (code) {
52    strcpy(fxmain_error_context, "while retrieving list");
53    return(code);
54  }
55
56  /******** main loop through list ********/
57  for (l = plist->Paperlist_res_u.list; l != NULL; l = l->next) {
58
59    /******* Skip papers not in time range ********/
60    if (l->p.modified.tv_sec < criterion->created.tv_sec ||
61        l->p.modified.tv_sec > criterion->modified.tv_sec) continue;
62
63    paper_copy(&(l->p), &newp);
64    newp.type = newtype;
65    if (flags & VERBOSE) {
66      /******** print information about file ********/
67      printf("%5d %-9s %9d  %-16.16s  %s\n", newp.assignment,
68             newp.owner, newp.size, ctime(&(newp.created.tv_sec)),
69             newp.filename);
70    }
71    if (!(flags & LISTONLY)) {
72      code = fx_move(fxp, &(l->p), &newp);
73      if (code) {
74        sprintf(fxmain_error_context, "while restoring %s by %s",
75                l->p.filename, l->p.author);
76        goto DO_UNCOLLECT_ABORT;
77      }
78    }
79  }
80
81DO_UNCOLLECT_ABORT:
82  fx_list_destroy(&plist);
83  return(code);
84}
85
86/*
87 * main uncollect procedure
88 */
89
90main(argc, argv)
91  int argc;
92  char *argv[];
93{
94  Paper p;
95
96  paper_clear(&p);
97  p.type = TURNEDIN;
98
99  if (fxmain(argc, argv,
100             "Usage: %s [options] [assignment] [username ...]\n",
101             &p, NULL, do_uncollect)) exit(1);
102  exit(0);
103}
Note: See TracBrowser for help on using the repository browser.