~ubuntu-branches/ubuntu/precise/netatalk/precise

« back to all changes in this revision

Viewing changes to bin/nbp/nbpunrgstr.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Rittau
  • Date: 2004-01-19 12:43:49 UTC
  • Revision ID: james.westby@ubuntu.com-20040119124349-es563jbp0hk0ae51
Tags: upstream-1.6.4
ImportĀ upstreamĀ versionĀ 1.6.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: nbpunrgstr.c,v 1.5 2001/07/31 19:49:02 srittau Exp $
 
3
 *
 
4
 * Copyright (c) 1990,1991 Regents of The University of Michigan.
 
5
 * All Rights Reserved.
 
6
 *
 
7
 * Permission to use, copy, modify, and distribute this software and
 
8
 * its documentation for any purpose and without fee is hereby granted,
 
9
 * provided that the above copyright notice appears in all copies and
 
10
 * that both that copyright notice and this permission notice appear
 
11
 * in supporting documentation, and that the name of The University
 
12
 * of Michigan not be used in advertising or publicity pertaining to
 
13
 * distribution of the software without specific, written prior
 
14
 * permission. This software is supplied as is without expressed or
 
15
 * implied warranties of any kind.
 
16
 *
 
17
 *      Research Systems Unix Group
 
18
 *      The University of Michigan
 
19
 *      c/o Mike Clark
 
20
 *      535 W. William Street
 
21
 *      Ann Arbor, Michigan
 
22
 *      +1-313-763-0525
 
23
 *      netatalk@itd.umich.edu
 
24
 */
 
25
 
 
26
#ifdef HAVE_CONFIG_H
 
27
#include "config.h"
 
28
#endif /* HAVE_CONFIG_H */
 
29
 
 
30
#include <sys/types.h>
 
31
#include <stdio.h>
 
32
#include <string.h>
 
33
#include <stdlib.h>
 
34
#ifdef HAVE_UNISTD_H
 
35
#include <unistd.h>
 
36
#endif /* HAVE_UNISTD_H */
 
37
#include <netatalk/endian.h>
 
38
#include <netatalk/at.h>
 
39
#include <atalk/util.h>
 
40
#include <atalk/nbp.h>
 
41
 
 
42
void Usage( av0 )
 
43
    char        *av0;
 
44
{
 
45
    char        *p;
 
46
 
 
47
    if (( p = strrchr( av0, '/' )) == 0 ) {
 
48
        p = av0;
 
49
    } else {
 
50
        p++;
 
51
    }
 
52
 
 
53
    fprintf( stderr, "Usage: %s [ -A address ] obj:type@zone\n", p );
 
54
    exit( 1 );
 
55
}
 
56
 
 
57
int main( ac, av )
 
58
    int         ac;
 
59
    char        **av;
 
60
{
 
61
    char                *Obj = 0, *Type = 0, *Zone = 0;
 
62
    struct at_addr      addr;
 
63
    int                 c;
 
64
 
 
65
    extern char         *optarg;
 
66
    extern int          optind;
 
67
    
 
68
    memset(&addr, 0, sizeof(addr));
 
69
    while ((c = getopt(ac, av, "A:")) != EOF) {
 
70
      switch (c) {
 
71
      case 'A':
 
72
        if (!atalk_aton(optarg, &addr)) {
 
73
          fprintf(stderr, "Bad address.\n");
 
74
          exit(1);
 
75
        }
 
76
        break;
 
77
      default:
 
78
        Usage(av[0]);
 
79
        break;
 
80
      }
 
81
    }
 
82
 
 
83
    if (ac - optind != 1) {
 
84
        Usage( av[ 0 ] );
 
85
    }
 
86
 
 
87
    /*
 
88
     * Get the name. If Type or Obj aren't specified, error.
 
89
     */
 
90
    if ( nbp_name( av[optind], &Obj, &Type, &Zone ) || !Obj || !Type ) {
 
91
        Usage( av[ 0 ] );
 
92
    }
 
93
 
 
94
    if ( nbp_unrgstr( Obj, Type, Zone, &addr ) < 0 ) {
 
95
        fprintf( stderr, "Can't unregister %s:%s@%s\n", Obj, Type,
 
96
                Zone ? Zone : "*" );
 
97
        exit( 1 );
 
98
    }
 
99
 
 
100
    return 0;
 
101
}