home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libpref / l10n / un-obscure.c < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  1.6 KB  |  62 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. /**********************************************************************
  20.  un-obscure.c
  21.  
  22.  Prints a netscape.cfg file in plaintext.
  23.  
  24.  Usage:
  25.         un-obscure netscape.cfg
  26. **********************************************************************/
  27.  
  28. #include <stdio.h>
  29. #include <errno.h>
  30.  
  31.  
  32. /*
  33.  * main
  34.  */
  35. int
  36. main(int argc, char* argv[])
  37. {
  38.     int i, n;
  39.     FILE* file;
  40.     unsigned char buf[1024];
  41.  
  42.     if ( argc != 2 ) {
  43.         fprintf(stderr, "Usage: %s filename\n", argv[0]);
  44.     }
  45.  
  46.     if ( (file = fopen(argv[1], "r")) == NULL ) {
  47.         perror(argv[1]);
  48.         exit(errno);
  49.     }
  50.  
  51.     while ( (n = fread(buf, sizeof(char), sizeof(buf), file)) > 0 ) {
  52.         for ( i = 0; i < n; i++ ) {
  53.             buf[i]-= 7;
  54.         }
  55.         fwrite(buf, sizeof(char), n, stdout);
  56.     }
  57.  
  58.     return 0;
  59. }
  60.  
  61.  
  62.