home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 May / pcp151c.iso / misc / src / install / modutils / insmod / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-06  |  1.5 KB  |  48 lines

  1. /* Main dispatch switch for running a combined executable.
  2.    Copyright 1996, 1997 Linux International.
  3.  
  4.    Contributed by Richard Henderson <rth@tamu.edu>
  5.  
  6.    This file is part of the Linux modutils.
  7.  
  8.    This program is free software; you can redistribute it and/or modify it
  9.    under the terms of the GNU General Public License as published by the
  10.    Free Software Foundation; either version 2 of the License, or (at your
  11.    option) any later version.
  12.  
  13.    This program is distributed in the hope that it will be useful, but
  14.    WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with this program; if not, write to the Free Software Foundation,
  20.    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  21.  
  22. #ident "$Id: main.c,v 1.1.1.1 1998/01/06 20:51:07 ewt Exp $"
  23.  
  24. #include <string.h>
  25. #include "logger.h"
  26.  
  27.  
  28. extern int insmod_main(int argc, char **argv);
  29. extern int rmmod_main(int argc, char **argv);
  30.  
  31. int
  32. main(int argc, char **argv)
  33. {
  34.   char *p = strrchr(argv[0], '/');
  35.   p = p ? p+1 : argv[0];
  36.  
  37.   if (strcmp(p, "insmod") == 0)
  38.     return insmod_main(argc, argv);
  39.   else if (strcmp(p, "rmmod") == 0)
  40.     return rmmod_main(argc, argv);
  41.   else
  42.     {
  43.       error("The insmod/rmmod combined binary is having an identity crisis.\n"
  44.         "Please give it a proper name.");
  45.       return 1;
  46.     }
  47. }
  48.