"Fossies" - the Fresh Open Source Software Archive

Member "ncc-2.8/nccnav/pathremover.c" (10 Jan 2003, 718 Bytes) of package /linux/privat/old/ncc-2.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2     Very useful program to remove root path dir.
    3     Root path dir is bad because filenames are very long
    4     and you only get two columns of display in nccnav.
    5 
    6     Sample Usage:
    7 find . -name \*.nccout | xargs cat | pathremover /mnt/sources/hacks/linux-2.40.2/ > Code.map
    8 
    9     the path argument must end in '/' to do it right.
   10 */
   11 #include <stdio.h>
   12 #include <string.h>
   13 
   14 int main (int argc, char **argv)
   15 {
   16     char *cwd, line [10240];
   17     int cwdl;
   18     FILE *in;
   19 
   20     if (argc != 2) return 1;
   21 
   22     cwdl = strlen (cwd = argv [1]);
   23     in = stdin;
   24 
   25     while (fgets (line, 10240, in))
   26         if (line [0] == 'P' && !strncmp (line + 3, cwd, cwdl))
   27         {
   28             fputs ("P: ", stdout);
   29             fputs (line + 3 + cwdl, stdout);
   30         } else fputs (line, stdout);
   31 
   32     return 0;
   33 }