.TH GREPC 1 2022-05-09 grepc "User commands" .SH NAME grepc \- find C declarations, definitions, and uses in source code .SH SYNOPSIS .B grepc .RI [ option\~ .\|.\|.\&] .I pattern .RI [ file\~ .\|.\|.] .SH DESCRIPTION .MR grepc 1 searches for C declarations, definitions, and/or uses of .I pattern in each .IR file . .PP .I pattern is a PCRE pattern. It normally represents a C identifier, and word boundaries are implicitly added to it in most cases. .PP If .I file is a directory, the search is recursive within that directory. If .I file doesn't match a certain extension, it is skipped (see .B \-x in OPTIONS). If no .I file is given, the working directory is searched. .SS Types of code This program can search for several types of code. The following arguments can be passed to the .B \-t option to select the types of code that will be searched. .TP .B e enum constant definitions. .TP .B f Function prototypes and definitions. This can be further subdivided into: .RS .TP .B fp Function prototypes. .TP .B fd Function definitions. .TP .B fs Linux kernel system calls. This can be further subdivided into: .RS .TP .B fsp Linux kernel system call prototypes. .TP .B fsd Linux kernel system call definitions. .RE .TP .B fg Glibc internal names of libc functions. This can be further subdivided into: .RS .TP .B fgp Glibc prototypes. .TP .B fgd Glibc definitions. .RE .RE .TP .B m Macro definitions. .TP .B t Type definitions. .TP .B u Uses. Searches occurences of .I pattern within enums, function bodies, macro replacements, and type definitions, and prints the whole enum, function, macro, and/or type definitions. In this case there are no word boundaries set by default, so if .I pattern is .BR open , .B fopen will also be found; that's to allow searching for patterns containing any sequence of characters. .IP This can be further subdivided into: .RS .TP .B ue Uses within enum definitions (except as an enum constant). .TP .B uf Uses within function definition bodies. .TP .B um Uses within macro replacements. .TP .B ut Uses within type definitions (except enum; that is: typedef, struct, or union). .RE .SH OPTIONS .TP .B \-c Surround the matched strings with escape sequences to display them in color on the terminal. Only uses .RB ( u\fI*\fP ) are highlighted. .TP .B \-g Restrict the search to files tracked by git. .TP .B \-h Output a help message and exit. .TP .B \-i Ignore case distinctions in .IR pattern . .TP .B \-k Compact (kurz) output. Don't print extra newlines (the header is printed in the same line as the first line of a match). .TP .B \-l Suppress normal output; instead print the name of each input file from which output would normally have been printed. Each file is only printed once. .TP .BI \-t " type" Restrict the search to a specific .I type of code (see Types of code under DESCRIPTION). This option can be passed multiple times to search for various types of code. Default: .BR "e f m t" . .TP .BI \-x " extension" Restrict the search to files ending with .IR extension . It is interpreted as a PCRE pattern. Default: .BR \e.[ch]$ . .SH EXAMPLES .EX .RB \(ti/src/nginx/unit$ " grepc nxt_sprintf;" \&./src/nxt_sprintf.h:15: NXT_EXPORT u_char *nxt_cdecl nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...); \& \& \&./src/nxt_sprintf.c:58: u_char * nxt_cdecl nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...) { u_char *p; va_list args; va_start(args, fmt); p = nxt_vsprintf(buf, end, fmt, args); va_end(args); return p; } .EE .SH AUTHORS Originally written by .MT alx.manpages@gmail.com Alejandro Colomar .ME . .SH SEE ALSO .MR git-ls-files 1 , .MR pcregrep 1 , .MR pcresyntax 3 , .MR pcrepattern 3 .PP Homepage: .UR http://www.alejandro-colomar.es/\:src/\:alx/\:alx/\:grepc.git .UE