home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / config / bsdecho.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  1.7 KB  |  78 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*
  19. ** This is a feeble attempt at creating a BSD-style echo command
  20. ** for use on platforms that have only a Sys-V echo.  This version
  21. ** supports the '-n' flag, and will not interpret '\c', etc.  As
  22. ** of this writing this is only needed on HP-UX and AIX 4.1.
  23. ** --briano.
  24. */
  25.  
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #if !defined(XP_OS2)
  30. #include <unistd.h>
  31. #endif
  32.  
  33. #ifdef SUNOS4
  34. #include "sunos4.h"
  35. #endif
  36.  
  37. void main(int argc, char **argv)
  38. {
  39.     short numargs = argc;
  40.     short newline = 1;
  41.  
  42.     if (numargs == 1)
  43.     {
  44.         exit(0);
  45.     }
  46.  
  47.     if (strcmp(*++argv, "-n") == 0)
  48.     {
  49.         if (numargs == 2)
  50.         {
  51.             exit(0);
  52.         }
  53.         else
  54.         {
  55.             newline = 0;
  56.             numargs--;
  57.             argv++;
  58.         }
  59.     }
  60.  
  61.     while (numargs > 1)
  62.     {
  63.         fprintf(stdout, "%s", *argv++);
  64.         numargs--;
  65.         if (numargs > 1)
  66.         {
  67.             fprintf(stdout, " ");
  68.         }
  69.     }
  70.  
  71.     if (newline == 1)
  72.     {
  73.         fprintf(stdout, "\n");
  74.     }
  75.  
  76.     exit(0);
  77. }
  78.