In [27]:
from PyQt5 import QtCore
import re
import os
import sys

In [17]:
FILE_PATH = "stdio.h"
INCLUDE_PATH = "/usr/include"

In [3]:
file = open(FILE_PATH, 'r')
lines = file.readlines()
file.close()

In [4]:
lines


Out[4]:
['/* Define ISO C stdio on top of C++ iostreams.\n',
 '   Copyright (C) 1991-2018 Free Software Foundation, Inc.\n',
 '   This file is part of the GNU C Library.\n',
 '\n',
 '   The GNU C Library is free software; you can redistribute it and/or\n',
 '   modify it under the terms of the GNU Lesser General Public\n',
 '   License as published by the Free Software Foundation; either\n',
 '   version 2.1 of the License, or (at your option) any later version.\n',
 '\n',
 '   The GNU C Library is distributed in the hope that it will be useful,\n',
 '   but WITHOUT ANY WARRANTY; without even the implied warranty of\n',
 '   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n',
 '   Lesser General Public License for more details.\n',
 '\n',
 '   You should have received a copy of the GNU Lesser General Public\n',
 '   License along with the GNU C Library; if not, see\n',
 '   <http://www.gnu.org/licenses/>.  */\n',
 '\n',
 '/*\n',
 ' *\tISO C99 Standard: 7.19 Input/output\t<stdio.h>\n',
 ' */\n',
 '\n',
 '#ifndef _STDIO_H\n',
 '#define _STDIO_H\t1\n',
 '\n',
 '#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n',
 '#include <bits/libc-header-start.h>\n',
 '\n',
 '__BEGIN_DECLS\n',
 '\n',
 '#define __need_size_t\n',
 '#define __need_NULL\n',
 '#include <stddef.h>\n',
 '\n',
 '#include <bits/types.h>\n',
 '#include <bits/types/__FILE.h>\n',
 '#include <bits/types/FILE.h>\n',
 '\n',
 '#define _STDIO_USES_IOSTREAM\n',
 '\n',
 '#include <bits/libio.h>\n',
 '\n',
 '#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n',
 '# ifdef __GNUC__\n',
 '#  ifndef _VA_LIST_DEFINED\n',
 'typedef _G_va_list va_list;\n',
 '#   define _VA_LIST_DEFINED\n',
 '#  endif\n',
 '# else\n',
 '#  include <stdarg.h>\n',
 '# endif\n',
 '#endif\n',
 '\n',
 '#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n',
 '# ifndef __off_t_defined\n',
 '# ifndef __USE_FILE_OFFSET64\n',
 'typedef __off_t off_t;\n',
 '# else\n',
 'typedef __off64_t off_t;\n',
 '# endif\n',
 '# define __off_t_defined\n',
 '# endif\n',
 '# if defined __USE_LARGEFILE64 && !defined __off64_t_defined\n',
 'typedef __off64_t off64_t;\n',
 '# define __off64_t_defined\n',
 '# endif\n',
 '#endif\n',
 '\n',
 '#ifdef __USE_XOPEN2K8\n',
 '# ifndef __ssize_t_defined\n',
 'typedef __ssize_t ssize_t;\n',
 '# define __ssize_t_defined\n',
 '# endif\n',
 '#endif\n',
 '\n',
 "/* The type of the second argument to `fgetpos' and `fsetpos'.  */\n",
 '#ifndef __USE_FILE_OFFSET64\n',
 'typedef _G_fpos_t fpos_t;\n',
 '#else\n',
 'typedef _G_fpos64_t fpos_t;\n',
 '#endif\n',
 '#ifdef __USE_LARGEFILE64\n',
 'typedef _G_fpos64_t fpos64_t;\n',
 '#endif\n',
 '\n',
 "/* The possibilities for the third argument to `setvbuf'.  */\n",
 '#define _IOFBF 0\t\t/* Fully buffered.  */\n',
 '#define _IOLBF 1\t\t/* Line buffered.  */\n',
 '#define _IONBF 2\t\t/* No buffering.  */\n',
 '\n',
 '\n',
 '/* Default buffer size.  */\n',
 '#ifndef BUFSIZ\n',
 '# define BUFSIZ _IO_BUFSIZ\n',
 '#endif\n',
 '\n',
 '\n',
 '/* End of file character.\n',
 '   Some things throughout the library rely on this being -1.  */\n',
 '#ifndef EOF\n',
 '# define EOF (-1)\n',
 '#endif\n',
 '\n',
 '\n',
 "/* The possibilities for the third argument to `fseek'.\n",
 '   These values should not be changed.  */\n',
 '#define SEEK_SET\t0\t/* Seek from beginning of file.  */\n',
 '#define SEEK_CUR\t1\t/* Seek from current position.  */\n',
 '#define SEEK_END\t2\t/* Seek from end of file.  */\n',
 '#ifdef __USE_GNU\n',
 '# define SEEK_DATA\t3\t/* Seek to next data.  */\n',
 '# define SEEK_HOLE\t4\t/* Seek to next hole.  */\n',
 '#endif\n',
 '\n',
 '\n',
 '#if defined __USE_MISC || defined __USE_XOPEN\n',
 "/* Default path prefix for `tempnam' and `tmpnam'.  */\n",
 '# define P_tmpdir\t"/tmp"\n',
 '#endif\n',
 '\n',
 '\n',
 '/* Get the values:\n',
 "   L_tmpnam\tHow long an array of chars must be to be passed to `tmpnam'.\n",
 '   TMP_MAX\tThe minimum number of unique filenames generated by tmpnam\n',
 "\t\t(and tempnam when it uses tmpnam's name space),\n",
 '\t\tor tempnam (the two are separate).\n',
 "   L_ctermid\tHow long an array to pass to `ctermid'.\n",
 "   L_cuserid\tHow long an array to pass to `cuserid'.\n",
 '   FOPEN_MAX\tMinimum number of files that can be open at once.\n',
 '   FILENAME_MAX\tMaximum length of a filename.  */\n',
 '#include <bits/stdio_lim.h>\n',
 '\n',
 '\n',
 '/* Standard streams.  */\n',
 'extern struct _IO_FILE *stdin;\t\t/* Standard input stream.  */\n',
 'extern struct _IO_FILE *stdout;\t\t/* Standard output stream.  */\n',
 'extern struct _IO_FILE *stderr;\t\t/* Standard error output stream.  */\n',
 "/* C89/C99 say they're macros.  Make them happy.  */\n",
 '#define stdin stdin\n',
 '#define stdout stdout\n',
 '#define stderr stderr\n',
 '\n',
 '/* Remove file FILENAME.  */\n',
 'extern int remove (const char *__filename) __THROW;\n',
 '/* Rename file OLD to NEW.  */\n',
 'extern int rename (const char *__old, const char *__new) __THROW;\n',
 '\n',
 '#ifdef __USE_ATFILE\n',
 '/* Rename file OLD relative to OLDFD to NEW relative to NEWFD.  */\n',
 'extern int renameat (int __oldfd, const char *__old, int __newfd,\n',
 '\t\t     const char *__new) __THROW;\n',
 '#endif\n',
 '\n',
 '/* Create a temporary file and open it read/write.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 '#ifndef __USE_FILE_OFFSET64\n',
 'extern FILE *tmpfile (void) __wur;\n',
 '#else\n',
 '# ifdef __REDIRECT\n',
 'extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;\n',
 '# else\n',
 '#  define tmpfile tmpfile64\n',
 '# endif\n',
 '#endif\n',
 '\n',
 '#ifdef __USE_LARGEFILE64\n',
 'extern FILE *tmpfile64 (void) __wur;\n',
 '#endif\n',
 '\n',
 '/* Generate a temporary filename.  */\n',
 'extern char *tmpnam (char *__s) __THROW __wur;\n',
 '\n',
 '#ifdef __USE_MISC\n',
 "/* This is the reentrant variant of `tmpnam'.  The only difference is\n",
 '   that it does not allow S to be NULL.  */\n',
 'extern char *tmpnam_r (char *__s) __THROW __wur;\n',
 '#endif\n',
 '\n',
 '\n',
 '#if defined __USE_MISC || defined __USE_XOPEN\n',
 '/* Generate a unique temporary filename using up to five characters of PFX\n',
 '   if it is not NULL.  The directory to put this file in is searched for\n',
 '   as follows: First the environment variable "TMPDIR" is checked.\n',
 '   If it contains the name of a writable directory, that directory is used.\n',
 '   If not and if DIR is not NULL, that value is checked.  If that fails,\n',
 '   P_tmpdir is tried and finally "/tmp".  The storage for the filename\n',
 "   is allocated by `malloc'.  */\n",
 'extern char *tempnam (const char *__dir, const char *__pfx)\n',
 '     __THROW __attribute_malloc__ __wur;\n',
 '#endif\n',
 '\n',
 '\n',
 '/* Close STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fclose (FILE *__stream);\n',
 '/* Flush STREAM, or all streams if STREAM is NULL.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fflush (FILE *__stream);\n',
 '\n',
 '#ifdef __USE_MISC\n',
 '/* Faster versions when locking is not required.\n',
 '\n',
 '   This function is not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation it is a cancellation point and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern int fflush_unlocked (FILE *__stream);\n',
 '#endif\n',
 '\n',
 '#ifdef __USE_GNU\n',
 '/* Close all streams.\n',
 '\n',
 '   This function is not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation it is a cancellation point and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern int fcloseall (void);\n',
 '#endif\n',
 '\n',
 '\n',
 '#ifndef __USE_FILE_OFFSET64\n',
 '/* Open a file and create a new stream for it.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern FILE *fopen (const char *__restrict __filename,\n',
 '\t\t    const char *__restrict __modes) __wur;\n',
 '/* Open a file, replacing an existing stream with it.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern FILE *freopen (const char *__restrict __filename,\n',
 '\t\t      const char *__restrict __modes,\n',
 '\t\t      FILE *__restrict __stream) __wur;\n',
 '#else\n',
 '# ifdef __REDIRECT\n',
 'extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,\n',
 '\t\t\t\t const char *__restrict __modes), fopen64)\n',
 '  __wur;\n',
 'extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,\n',
 '\t\t\t\t   const char *__restrict __modes,\n',
 '\t\t\t\t   FILE *__restrict __stream), freopen64)\n',
 '  __wur;\n',
 '# else\n',
 '#  define fopen fopen64\n',
 '#  define freopen freopen64\n',
 '# endif\n',
 '#endif\n',
 '#ifdef __USE_LARGEFILE64\n',
 'extern FILE *fopen64 (const char *__restrict __filename,\n',
 '\t\t      const char *__restrict __modes) __wur;\n',
 'extern FILE *freopen64 (const char *__restrict __filename,\n',
 '\t\t\tconst char *__restrict __modes,\n',
 '\t\t\tFILE *__restrict __stream) __wur;\n',
 '#endif\n',
 '\n',
 '#ifdef\t__USE_POSIX\n',
 '/* Create a new stream that refers to an existing system file descriptor.  */\n',
 'extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;\n',
 '#endif\n',
 '\n',
 '#ifdef\t__USE_GNU\n',
 '/* Create a new stream that refers to the given magic cookie,\n',
 '   and uses the given functions for input and output.  */\n',
 'extern FILE *fopencookie (void *__restrict __magic_cookie,\n',
 '\t\t\t  const char *__restrict __modes,\n',
 '\t\t\t  _IO_cookie_io_functions_t __io_funcs) __THROW __wur;\n',
 '#endif\n',
 '\n',
 '#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)\n',
 '/* Create a new stream that refers to a memory buffer.  */\n',
 'extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)\n',
 '  __THROW __wur;\n',
 '\n',
 "/* Open a stream that writes into a malloc'd buffer that is expanded as\n",
 "   necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location\n",
 '   and the number of characters written on fflush or fclose.  */\n',
 'extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;\n',
 '#endif\n',
 '\n',
 '\n',
 '/* If BUF is NULL, make STREAM unbuffered.\n',
 '   Else make it use buffer BUF, of size BUFSIZ.  */\n',
 'extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;\n',
 '/* Make STREAM use buffering mode MODE.\n',
 '   If BUF is not NULL, use N bytes of it for buffering;\n',
 '   else allocate an internal buffer N bytes long.  */\n',
 'extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,\n',
 '\t\t    int __modes, size_t __n) __THROW;\n',
 '\n',
 '#ifdef\t__USE_MISC\n',
 '/* If BUF is NULL, make STREAM unbuffered.\n',
 '   Else make it use SIZE bytes of BUF for buffering.  */\n',
 'extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,\n',
 '\t\t       size_t __size) __THROW;\n',
 '\n',
 '/* Make STREAM line-buffered.  */\n',
 'extern void setlinebuf (FILE *__stream) __THROW;\n',
 '#endif\n',
 '\n',
 '\n',
 '/* Write formatted output to STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fprintf (FILE *__restrict __stream,\n',
 '\t\t    const char *__restrict __format, ...);\n',
 '/* Write formatted output to stdout.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int printf (const char *__restrict __format, ...);\n',
 '/* Write formatted output to S.  */\n',
 'extern int sprintf (char *__restrict __s,\n',
 '\t\t    const char *__restrict __format, ...) __THROWNL;\n',
 '\n',
 '/* Write formatted output to S from argument list ARG.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,\n',
 '\t\t     _G_va_list __arg);\n',
 '/* Write formatted output to stdout from argument list ARG.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int vprintf (const char *__restrict __format, _G_va_list __arg);\n',
 '/* Write formatted output to S from argument list ARG.  */\n',
 'extern int vsprintf (char *__restrict __s, const char *__restrict __format,\n',
 '\t\t     _G_va_list __arg) __THROWNL;\n',
 '\n',
 '#if defined __USE_ISOC99 || defined __USE_UNIX98\n',
 '/* Maximum chars of output to write in MAXLEN.  */\n',
 'extern int snprintf (char *__restrict __s, size_t __maxlen,\n',
 '\t\t     const char *__restrict __format, ...)\n',
 '     __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));\n',
 '\n',
 'extern int vsnprintf (char *__restrict __s, size_t __maxlen,\n',
 '\t\t      const char *__restrict __format, _G_va_list __arg)\n',
 '     __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));\n',
 '#endif\n',
 '\n',
 '#if __GLIBC_USE (LIB_EXT2)\n',
 "/* Write formatted output to a string dynamically allocated with `malloc'.\n",
 '   Store the address of the string in *PTR.  */\n',
 'extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,\n',
 '\t\t      _G_va_list __arg)\n',
 '     __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;\n',
 'extern int __asprintf (char **__restrict __ptr,\n',
 '\t\t       const char *__restrict __fmt, ...)\n',
 '     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;\n',
 'extern int asprintf (char **__restrict __ptr,\n',
 '\t\t     const char *__restrict __fmt, ...)\n',
 '     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;\n',
 '#endif\n',
 '\n',
 '#ifdef __USE_XOPEN2K8\n',
 '/* Write formatted output to a file descriptor.  */\n',
 'extern int vdprintf (int __fd, const char *__restrict __fmt,\n',
 '\t\t     _G_va_list __arg)\n',
 '     __attribute__ ((__format__ (__printf__, 2, 0)));\n',
 'extern int dprintf (int __fd, const char *__restrict __fmt, ...)\n',
 '     __attribute__ ((__format__ (__printf__, 2, 3)));\n',
 '#endif\n',
 '\n',
 '\n',
 '/* Read formatted input from STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fscanf (FILE *__restrict __stream,\n',
 '\t\t   const char *__restrict __format, ...) __wur;\n',
 '/* Read formatted input from stdin.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int scanf (const char *__restrict __format, ...) __wur;\n',
 '/* Read formatted input from S.  */\n',
 'extern int sscanf (const char *__restrict __s,\n',
 '\t\t   const char *__restrict __format, ...) __THROW;\n',
 '\n',
 '#if defined __USE_ISOC99 && !defined __USE_GNU \\\n',
 '    && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n',
 '    && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n',
 '# ifdef __REDIRECT\n',
 '/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n',
 '   GNU extension which conflicts with valid %a followed by letter\n',
 '   s, S or [.  */\n',
 'extern int __REDIRECT (fscanf, (FILE *__restrict __stream,\n',
 '\t\t\t\tconst char *__restrict __format, ...),\n',
 '\t\t       __isoc99_fscanf) __wur;\n',
 'extern int __REDIRECT (scanf, (const char *__restrict __format, ...),\n',
 '\t\t       __isoc99_scanf) __wur;\n',
 'extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,\n',
 '\t\t\t\t    const char *__restrict __format, ...),\n',
 '\t\t\t   __isoc99_sscanf);\n',
 '# else\n',
 'extern int __isoc99_fscanf (FILE *__restrict __stream,\n',
 '\t\t\t    const char *__restrict __format, ...) __wur;\n',
 'extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;\n',
 'extern int __isoc99_sscanf (const char *__restrict __s,\n',
 '\t\t\t    const char *__restrict __format, ...) __THROW;\n',
 '#  define fscanf __isoc99_fscanf\n',
 '#  define scanf __isoc99_scanf\n',
 '#  define sscanf __isoc99_sscanf\n',
 '# endif\n',
 '#endif\n',
 '\n',
 '#ifdef\t__USE_ISOC99\n',
 '/* Read formatted input from S into argument list ARG.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,\n',
 '\t\t    _G_va_list __arg)\n',
 '     __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;\n',
 '\n',
 '/* Read formatted input from stdin into argument list ARG.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int vscanf (const char *__restrict __format, _G_va_list __arg)\n',
 '     __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;\n',
 '\n',
 '/* Read formatted input from S into argument list ARG.  */\n',
 'extern int vsscanf (const char *__restrict __s,\n',
 '\t\t    const char *__restrict __format, _G_va_list __arg)\n',
 '     __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));\n',
 '\n',
 '# if !defined __USE_GNU \\\n',
 '     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n',
 '     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n',
 '#  ifdef __REDIRECT\n',
 '/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n',
 '   GNU extension which conflicts with valid %a followed by letter\n',
 '   s, S or [.  */\n',
 'extern int __REDIRECT (vfscanf,\n',
 '\t\t       (FILE *__restrict __s,\n',
 '\t\t\tconst char *__restrict __format, _G_va_list __arg),\n',
 '\t\t       __isoc99_vfscanf)\n',
 '     __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;\n',
 'extern int __REDIRECT (vscanf, (const char *__restrict __format,\n',
 '\t\t\t\t_G_va_list __arg), __isoc99_vscanf)\n',
 '     __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;\n',
 'extern int __REDIRECT_NTH (vsscanf,\n',
 '\t\t\t   (const char *__restrict __s,\n',
 '\t\t\t    const char *__restrict __format,\n',
 '\t\t\t    _G_va_list __arg), __isoc99_vsscanf)\n',
 '     __attribute__ ((__format__ (__scanf__, 2, 0)));\n',
 '#  else\n',
 'extern int __isoc99_vfscanf (FILE *__restrict __s,\n',
 '\t\t\t     const char *__restrict __format,\n',
 '\t\t\t     _G_va_list __arg) __wur;\n',
 'extern int __isoc99_vscanf (const char *__restrict __format,\n',
 '\t\t\t    _G_va_list __arg) __wur;\n',
 'extern int __isoc99_vsscanf (const char *__restrict __s,\n',
 '\t\t\t     const char *__restrict __format,\n',
 '\t\t\t     _G_va_list __arg) __THROW;\n',
 '#   define vfscanf __isoc99_vfscanf\n',
 '#   define vscanf __isoc99_vscanf\n',
 '#   define vsscanf __isoc99_vsscanf\n',
 '#  endif\n',
 '# endif\n',
 '#endif /* Use ISO C9x.  */\n',
 '\n',
 '\n',
 '/* Read a character from STREAM.\n',
 '\n',
 '   These functions are possible cancellation points and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fgetc (FILE *__stream);\n',
 'extern int getc (FILE *__stream);\n',
 '\n',
 '/* Read a character from stdin.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int getchar (void);\n',
 '\n',
 '/* The C standard explicitly says this is a macro, so we always do the\n',
 '   optimization for it.  */\n',
 '#define getc(_fp) _IO_getc (_fp)\n',
 '\n',
 '#ifdef __USE_POSIX199506\n',
 '/* These are defined in POSIX.1:1996.\n',
 '\n',
 '   These functions are possible cancellation points and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int getc_unlocked (FILE *__stream);\n',
 'extern int getchar_unlocked (void);\n',
 '#endif /* Use POSIX.  */\n',
 '\n',
 '#ifdef __USE_MISC\n',
 '/* Faster version when locking is not necessary.\n',
 '\n',
 '   This function is not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation it is a cancellation point and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern int fgetc_unlocked (FILE *__stream);\n',
 '#endif /* Use MISC.  */\n',
 '\n',
 '\n',
 '/* Write a character to STREAM.\n',
 '\n',
 '   These functions are possible cancellation points and therefore not\n',
 '   marked with __THROW.\n',
 '\n',
 '   These functions is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fputc (int __c, FILE *__stream);\n',
 'extern int putc (int __c, FILE *__stream);\n',
 '\n',
 '/* Write a character to stdout.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int putchar (int __c);\n',
 '\n',
 '/* The C standard explicitly says this can be a macro,\n',
 '   so we always do the optimization for it.  */\n',
 '#define putc(_ch, _fp) _IO_putc (_ch, _fp)\n',
 '\n',
 '#ifdef __USE_MISC\n',
 '/* Faster version when locking is not necessary.\n',
 '\n',
 '   This function is not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation it is a cancellation point and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern int fputc_unlocked (int __c, FILE *__stream);\n',
 '#endif /* Use MISC.  */\n',
 '\n',
 '#ifdef __USE_POSIX199506\n',
 '/* These are defined in POSIX.1:1996.\n',
 '\n',
 '   These functions are possible cancellation points and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int putc_unlocked (int __c, FILE *__stream);\n',
 'extern int putchar_unlocked (int __c);\n',
 '#endif /* Use POSIX.  */\n',
 '\n',
 '\n',
 '#if defined __USE_MISC \\\n',
 '    || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n',
 '/* Get a word (int) from STREAM.  */\n',
 'extern int getw (FILE *__stream);\n',
 '\n',
 '/* Write a word (int) to STREAM.  */\n',
 'extern int putw (int __w, FILE *__stream);\n',
 '#endif\n',
 '\n',
 '\n',
 '/* Get a newline-terminated string of finite length from STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)\n',
 '     __wur;\n',
 '\n',
 '#if __GLIBC_USE (DEPRECATED_GETS)\n',
 '/* Get a newline-terminated string from stdin, removing the newline.\n',
 '\n',
 '   This function is impossible to use safely.  It has been officially\n',
 '   removed from ISO C11 and ISO C++14, and we have also removed it\n',
 '   from the _GNU_SOURCE feature list.  It remains available when\n',
 '   explicitly using an old ISO C, Unix, or POSIX standard.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern char *gets (char *__s) __wur __attribute_deprecated__;\n',
 '#endif\n',
 '\n',
 '#ifdef __USE_GNU\n',
 "/* This function does the same as `fgets' but does not lock the stream.\n",
 '\n',
 '   This function is not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation it is a cancellation point and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern char *fgets_unlocked (char *__restrict __s, int __n,\n',
 '\t\t\t     FILE *__restrict __stream) __wur;\n',
 '#endif\n',
 '\n',
 '\n',
 '#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)\n',
 '/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR\n',
 '   (and null-terminate it). *LINEPTR is a pointer returned from malloc (or\n',
 "   NULL), pointing to *N characters of space.  It is realloc'd as\n",
 '   necessary.  Returns the number of characters read (not including the\n',
 '   null terminator), or -1 on error or EOF.\n',
 '\n',
 '   These functions are not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation they are cancellation points and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern _IO_ssize_t __getdelim (char **__restrict __lineptr,\n',
 '\t\t\t       size_t *__restrict __n, int __delimiter,\n',
 '\t\t\t       FILE *__restrict __stream) __wur;\n',
 'extern _IO_ssize_t getdelim (char **__restrict __lineptr,\n',
 '\t\t\t     size_t *__restrict __n, int __delimiter,\n',
 '\t\t\t     FILE *__restrict __stream) __wur;\n',
 '\n',
 "/* Like `getdelim', but reads up to a newline.\n",
 '\n',
 '   This function is not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation it is a cancellation point and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern _IO_ssize_t getline (char **__restrict __lineptr,\n',
 '\t\t\t    size_t *__restrict __n,\n',
 '\t\t\t    FILE *__restrict __stream) __wur;\n',
 '#endif\n',
 '\n',
 '\n',
 '/* Write a string to STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fputs (const char *__restrict __s, FILE *__restrict __stream);\n',
 '\n',
 '/* Write a string, followed by a newline, to stdout.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int puts (const char *__s);\n',
 '\n',
 '\n',
 '/* Push a character back onto the input buffer of STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int ungetc (int __c, FILE *__stream);\n',
 '\n',
 '\n',
 '/* Read chunks of generic data from STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern size_t fread (void *__restrict __ptr, size_t __size,\n',
 '\t\t     size_t __n, FILE *__restrict __stream) __wur;\n',
 '/* Write chunks of generic data to STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern size_t fwrite (const void *__restrict __ptr, size_t __size,\n',
 '\t\t      size_t __n, FILE *__restrict __s);\n',
 '\n',
 '#ifdef __USE_GNU\n',
 "/* This function does the same as `fputs' but does not lock the stream.\n",
 '\n',
 '   This function is not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation it is a cancellation point and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern int fputs_unlocked (const char *__restrict __s,\n',
 '\t\t\t   FILE *__restrict __stream);\n',
 '#endif\n',
 '\n',
 '#ifdef __USE_MISC\n',
 '/* Faster versions when locking is not necessary.\n',
 '\n',
 '   These functions are not part of POSIX and therefore no official\n',
 '   cancellation point.  But due to similarity with an POSIX interface\n',
 '   or due to the implementation they are cancellation points and\n',
 '   therefore not marked with __THROW.  */\n',
 'extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,\n',
 '\t\t\t      size_t __n, FILE *__restrict __stream) __wur;\n',
 'extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,\n',
 '\t\t\t       size_t __n, FILE *__restrict __stream);\n',
 '#endif\n',
 '\n',
 '\n',
 '/* Seek to a certain position on STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fseek (FILE *__stream, long int __off, int __whence);\n',
 '/* Return the current position of STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern long int ftell (FILE *__stream) __wur;\n',
 '/* Rewind to the beginning of STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern void rewind (FILE *__stream);\n',
 '\n',
 '/* The Single Unix Specification, Version 2, specifies an alternative,\n',
 '   more adequate interface for the two functions above which deal with\n',
 "   file offset.  `long int' is not the right type.  These definitions\n",
 '   are originally defined in the Large File Support API.  */\n',
 '\n',
 '#if defined __USE_LARGEFILE || defined __USE_XOPEN2K\n',
 '# ifndef __USE_FILE_OFFSET64\n',
 '/* Seek to a certain position on STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fseeko (FILE *__stream, __off_t __off, int __whence);\n',
 '/* Return the current position of STREAM.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern __off_t ftello (FILE *__stream) __wur;\n',
 '# else\n',
 '#  ifdef __REDIRECT\n',
 'extern int __REDIRECT (fseeko,\n',
 '\t\t       (FILE *__stream, __off64_t __off, int __whence),\n',
 '\t\t       fseeko64);\n',
 'extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);\n',
 '#  else\n',
 '#   define fseeko fseeko64\n',
 '#   define ftello ftello64\n',
 '#  endif\n',
 '# endif\n',
 '#endif\n',
 '\n',
 '#ifndef __USE_FILE_OFFSET64\n',
 "/* Get STREAM's position.\n",
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);\n',
 "/* Set STREAM's position.\n",
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int fsetpos (FILE *__stream, const fpos_t *__pos);\n',
 '#else\n',
 '# ifdef __REDIRECT\n',
 'extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,\n',
 '\t\t\t\t fpos_t *__restrict __pos), fgetpos64);\n',
 'extern int __REDIRECT (fsetpos,\n',
 '\t\t       (FILE *__stream, const fpos_t *__pos), fsetpos64);\n',
 '# else\n',
 '#  define fgetpos fgetpos64\n',
 '#  define fsetpos fsetpos64\n',
 '# endif\n',
 '#endif\n',
 '\n',
 '#ifdef __USE_LARGEFILE64\n',
 'extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);\n',
 'extern __off64_t ftello64 (FILE *__stream) __wur;\n',
 'extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);\n',
 'extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);\n',
 '#endif\n',
 '\n',
 '/* Clear the error and EOF indicators for STREAM.  */\n',
 'extern void clearerr (FILE *__stream) __THROW;\n',
 '/* Return the EOF indicator for STREAM.  */\n',
 'extern int feof (FILE *__stream) __THROW __wur;\n',
 '/* Return the error indicator for STREAM.  */\n',
 'extern int ferror (FILE *__stream) __THROW __wur;\n',
 '\n',
 '#ifdef __USE_MISC\n',
 '/* Faster versions when locking is not required.  */\n',
 'extern void clearerr_unlocked (FILE *__stream) __THROW;\n',
 'extern int feof_unlocked (FILE *__stream) __THROW __wur;\n',
 'extern int ferror_unlocked (FILE *__stream) __THROW __wur;\n',
 '#endif\n',
 '\n',
 '\n',
 '/* Print a message describing the meaning of the value of errno.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern void perror (const char *__s);\n',
 '\n',
 "/* Provide the declarations for `sys_errlist' and `sys_nerr' if they\n",
 '   are available on this system.  Even if available, these variables\n',
 "   should not be used directly.  The `strerror' function provides\n",
 '   all the necessary functionality.  */\n',
 '#include <bits/sys_errlist.h>\n',
 '\n',
 '\n',
 '#ifdef\t__USE_POSIX\n',
 '/* Return the system file descriptor for STREAM.  */\n',
 'extern int fileno (FILE *__stream) __THROW __wur;\n',
 '#endif /* Use POSIX.  */\n',
 '\n',
 '#ifdef __USE_MISC\n',
 '/* Faster version when locking is not required.  */\n',
 'extern int fileno_unlocked (FILE *__stream) __THROW __wur;\n',
 '#endif\n',
 '\n',
 '\n',
 '#ifdef __USE_POSIX2\n',
 '/* Create a new stream connected to a pipe running the given command.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern FILE *popen (const char *__command, const char *__modes) __wur;\n',
 '\n',
 '/* Close a stream opened by popen and return the status of its child.\n',
 '\n',
 '   This function is a possible cancellation point and therefore not\n',
 '   marked with __THROW.  */\n',
 'extern int pclose (FILE *__stream);\n',
 '#endif\n',
 '\n',
 '\n',
 '#ifdef\t__USE_POSIX\n',
 '/* Return the name of the controlling terminal.  */\n',
 'extern char *ctermid (char *__s) __THROW;\n',
 '#endif /* Use POSIX.  */\n',
 '\n',
 '\n',
 '#if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU\n',
 '/* Return the name of the current user.  */\n',
 'extern char *cuserid (char *__s);\n',
 '#endif /* Use X/Open, but not issue 6.  */\n',
 '\n',
 '\n',
 '#ifdef\t__USE_GNU\n',
 'struct obstack;\t\t\t/* See <obstack.h>.  */\n',
 '\n',
 '/* Write formatted output to an obstack.  */\n',
 'extern int obstack_printf (struct obstack *__restrict __obstack,\n',
 '\t\t\t   const char *__restrict __format, ...)\n',
 '     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));\n',
 'extern int obstack_vprintf (struct obstack *__restrict __obstack,\n',
 '\t\t\t    const char *__restrict __format,\n',
 '\t\t\t    _G_va_list __args)\n',
 '     __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));\n',
 '#endif /* Use GNU.  */\n',
 '\n',
 '\n',
 '#ifdef __USE_POSIX199506\n',
 '/* These are defined in POSIX.1:1996.  */\n',
 '\n',
 '/* Acquire ownership of STREAM.  */\n',
 'extern void flockfile (FILE *__stream) __THROW;\n',
 '\n',
 '/* Try to acquire ownership of STREAM but do not block if it is not\n',
 '   possible.  */\n',
 'extern int ftrylockfile (FILE *__stream) __THROW __wur;\n',
 '\n',
 '/* Relinquish the ownership granted for STREAM.  */\n',
 'extern void funlockfile (FILE *__stream) __THROW;\n',
 '#endif /* POSIX */\n',
 '\n',
 '#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU\n',
 '/*  X/Open Issues 1-5 required getopt to be declared in this\n',
 '   header.  It was removed in Issue 6.  GNU follows Issue 6.  */\n',
 '# include <bits/getopt_posix.h>\n',
 '#endif\n',
 '\n',
 '/* If we are compiling with optimizing read this file.  It contains\n',
 '   several optimizing inline functions and macros.  */\n',
 '#ifdef __USE_EXTERN_INLINES\n',
 '# include <bits/stdio.h>\n',
 '#endif\n',
 '#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n',
 '# include <bits/stdio2.h>\n',
 '#endif\n',
 '#ifdef __LDBL_COMPAT\n',
 '# include <bits/stdio-ldbl.h>\n',
 '#endif\n',
 '\n',
 '__END_DECLS\n',
 '\n',
 '#endif /* <stdio.h> included.  */\n']

In [5]:
fun_re = "(\w*)\((\s*\w*\s*\))"

var_re = "(\w*)\s=\s"
for i, line in enumerate(lines):
    result = re.findall(var_re, line)
    if result:
        print(i, result[0])

In [6]:
#         ret_type space class::function()
fun_re = "(\w+)\s+(:+)(\w+)\(\s*\w*\s*\)"
fun_re = "(\w+)\s+(\w+)(\s*\:+)(\s*\w+)(\((\w*\W*\w*)\))\s*"
fun_re = "((\w+)\s+)+(\w+\s*\((\s*\w*\s*)*)"
for line in lines:
    results = re.search(fun_re, line)
    if results:
        print(results[0])


define EOF (
or tempnam (the two are separate
extern int remove (const char 
extern int rename (const char 
extern int renameat (int __oldfd
extern int fclose (FILE 
extern int fflush (FILE 
extern int fflush_unlocked (FILE 
extern int fcloseall (void
extern void setbuf (FILE 
extern int setvbuf (FILE 
extern void setbuffer (FILE 
extern void setlinebuf (FILE 
extern int fprintf (FILE 
extern int printf (const char 
extern int sprintf (char 
extern int vfprintf (FILE 
extern int vprintf (const char 
extern int vsprintf (char 
extern int snprintf (char 
__THROWNL __attribute__ (
extern int vsnprintf (char 
__THROWNL __attribute__ (
if __GLIBC_USE (LIB_EXT2
extern int vasprintf (char 
__THROWNL __attribute__ (
extern int __asprintf (char 
__THROWNL __attribute__ (
extern int asprintf (char 
__THROWNL __attribute__ (
extern int vdprintf (int __fd
extern int dprintf (int __fd
extern int fscanf (FILE 
extern int scanf (const char 
extern int sscanf (const char 
extern int __REDIRECT (fscanf
extern int __REDIRECT (scanf
extern int __REDIRECT_NTH (sscanf
extern int __isoc99_fscanf (FILE 
extern int __isoc99_scanf (const char 
extern int __isoc99_sscanf (const char 
extern int vfscanf (FILE 
extern int vscanf (const char 
extern int vsscanf (const char 
__THROW __attribute__ (
extern int __REDIRECT (vfscanf
extern int __REDIRECT (vscanf
extern int __REDIRECT_NTH (vsscanf
extern int __isoc99_vfscanf (FILE 
extern int __isoc99_vscanf (const char 
extern int __isoc99_vsscanf (const char 
extern int fgetc (FILE 
extern int getc (FILE 
extern int getchar (void
define getc(_fp
extern int getc_unlocked (FILE 
extern int getchar_unlocked (void
extern int fgetc_unlocked (FILE 
extern int fputc (int __c
extern int putc (int __c
extern int putchar (int __c
define putc(_ch
extern int fputc_unlocked (int __c
extern int putc_unlocked (int __c
extern int putchar_unlocked (int __c
Get a word (int
extern int getw (FILE 
Write a word (int
extern int putw (int __w
if __GLIBC_USE (DEPRECATED_GETS
Read up to (and including
LINEPTR is a pointer returned from malloc (or

Returns the number of characters read (not including the

extern _IO_ssize_t __getdelim (char 
extern _IO_ssize_t getdelim (char 
extern _IO_ssize_t getline (char 
extern int fputs (const char 
extern int puts (const char 
extern int ungetc (int __c
extern size_t fread (void 
extern size_t fwrite (const void 
extern int fputs_unlocked (const char 
extern size_t fread_unlocked (void 
extern size_t fwrite_unlocked (const void 
extern int fseek (FILE 
extern long int ftell (FILE 
extern void rewind (FILE 
extern int fseeko (FILE 
extern __off_t ftello (FILE 
extern int __REDIRECT (fseeko
extern __off64_t __REDIRECT (ftello
extern int fgetpos (FILE 
extern int fsetpos (FILE 
extern int __REDIRECT (fgetpos
extern int __REDIRECT (fsetpos
extern int fseeko64 (FILE 
extern __off64_t ftello64 (FILE 
extern int fgetpos64 (FILE 
extern int fsetpos64 (FILE 
extern void clearerr (FILE 
extern int feof (FILE 
extern int ferror (FILE 
extern void clearerr_unlocked (FILE 
extern int feof_unlocked (FILE 
extern int ferror_unlocked (FILE 
extern void perror (const char 
extern int fileno (FILE 
extern int fileno_unlocked (FILE 
extern int pclose (FILE 
extern int obstack_printf (struct obstack 
__THROWNL __attribute__ (
extern int obstack_vprintf (struct obstack 
__THROWNL __attribute__ (
extern void flockfile (FILE 
extern int ftrylockfile (FILE 
extern void funlockfile (FILE 

In [7]:
for result in results:
    print(result[3])


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-c1d3a539e878> in <module>
----> 1 for result in results:
      2     print(result[3])

TypeError: 'NoneType' object is not iterable

In [12]:
content = "\n".join(lines)
content


Out[12]:
'/* Define ISO C stdio on top of C++ iostreams.\n\n   Copyright (C) 1991-2018 Free Software Foundation, Inc.\n\n   This file is part of the GNU C Library.\n\n\n\n   The GNU C Library is free software; you can redistribute it and/or\n\n   modify it under the terms of the GNU Lesser General Public\n\n   License as published by the Free Software Foundation; either\n\n   version 2.1 of the License, or (at your option) any later version.\n\n\n\n   The GNU C Library is distributed in the hope that it will be useful,\n\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n\n   Lesser General Public License for more details.\n\n\n\n   You should have received a copy of the GNU Lesser General Public\n\n   License along with the GNU C Library; if not, see\n\n   <http://www.gnu.org/licenses/>.  */\n\n\n\n/*\n\n *\tISO C99 Standard: 7.19 Input/output\t<stdio.h>\n\n */\n\n\n\n#ifndef _STDIO_H\n\n#define _STDIO_H\t1\n\n\n\n#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n\n#include <bits/libc-header-start.h>\n\n\n\n__BEGIN_DECLS\n\n\n\n#define __need_size_t\n\n#define __need_NULL\n\n#include <stddef.h>\n\n\n\n#include <bits/types.h>\n\n#include <bits/types/__FILE.h>\n\n#include <bits/types/FILE.h>\n\n\n\n#define _STDIO_USES_IOSTREAM\n\n\n\n#include <bits/libio.h>\n\n\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n\n# ifdef __GNUC__\n\n#  ifndef _VA_LIST_DEFINED\n\ntypedef _G_va_list va_list;\n\n#   define _VA_LIST_DEFINED\n\n#  endif\n\n# else\n\n#  include <stdarg.h>\n\n# endif\n\n#endif\n\n\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n\n# ifndef __off_t_defined\n\n# ifndef __USE_FILE_OFFSET64\n\ntypedef __off_t off_t;\n\n# else\n\ntypedef __off64_t off_t;\n\n# endif\n\n# define __off_t_defined\n\n# endif\n\n# if defined __USE_LARGEFILE64 && !defined __off64_t_defined\n\ntypedef __off64_t off64_t;\n\n# define __off64_t_defined\n\n# endif\n\n#endif\n\n\n\n#ifdef __USE_XOPEN2K8\n\n# ifndef __ssize_t_defined\n\ntypedef __ssize_t ssize_t;\n\n# define __ssize_t_defined\n\n# endif\n\n#endif\n\n\n\n/* The type of the second argument to `fgetpos\' and `fsetpos\'.  */\n\n#ifndef __USE_FILE_OFFSET64\n\ntypedef _G_fpos_t fpos_t;\n\n#else\n\ntypedef _G_fpos64_t fpos_t;\n\n#endif\n\n#ifdef __USE_LARGEFILE64\n\ntypedef _G_fpos64_t fpos64_t;\n\n#endif\n\n\n\n/* The possibilities for the third argument to `setvbuf\'.  */\n\n#define _IOFBF 0\t\t/* Fully buffered.  */\n\n#define _IOLBF 1\t\t/* Line buffered.  */\n\n#define _IONBF 2\t\t/* No buffering.  */\n\n\n\n\n\n/* Default buffer size.  */\n\n#ifndef BUFSIZ\n\n# define BUFSIZ _IO_BUFSIZ\n\n#endif\n\n\n\n\n\n/* End of file character.\n\n   Some things throughout the library rely on this being -1.  */\n\n#ifndef EOF\n\n# define EOF (-1)\n\n#endif\n\n\n\n\n\n/* The possibilities for the third argument to `fseek\'.\n\n   These values should not be changed.  */\n\n#define SEEK_SET\t0\t/* Seek from beginning of file.  */\n\n#define SEEK_CUR\t1\t/* Seek from current position.  */\n\n#define SEEK_END\t2\t/* Seek from end of file.  */\n\n#ifdef __USE_GNU\n\n# define SEEK_DATA\t3\t/* Seek to next data.  */\n\n# define SEEK_HOLE\t4\t/* Seek to next hole.  */\n\n#endif\n\n\n\n\n\n#if defined __USE_MISC || defined __USE_XOPEN\n\n/* Default path prefix for `tempnam\' and `tmpnam\'.  */\n\n# define P_tmpdir\t"/tmp"\n\n#endif\n\n\n\n\n\n/* Get the values:\n\n   L_tmpnam\tHow long an array of chars must be to be passed to `tmpnam\'.\n\n   TMP_MAX\tThe minimum number of unique filenames generated by tmpnam\n\n\t\t(and tempnam when it uses tmpnam\'s name space),\n\n\t\tor tempnam (the two are separate).\n\n   L_ctermid\tHow long an array to pass to `ctermid\'.\n\n   L_cuserid\tHow long an array to pass to `cuserid\'.\n\n   FOPEN_MAX\tMinimum number of files that can be open at once.\n\n   FILENAME_MAX\tMaximum length of a filename.  */\n\n#include <bits/stdio_lim.h>\n\n\n\n\n\n/* Standard streams.  */\n\nextern struct _IO_FILE *stdin;\t\t/* Standard input stream.  */\n\nextern struct _IO_FILE *stdout;\t\t/* Standard output stream.  */\n\nextern struct _IO_FILE *stderr;\t\t/* Standard error output stream.  */\n\n/* C89/C99 say they\'re macros.  Make them happy.  */\n\n#define stdin stdin\n\n#define stdout stdout\n\n#define stderr stderr\n\n\n\n/* Remove file FILENAME.  */\n\nextern int remove (const char *__filename) __THROW;\n\n/* Rename file OLD to NEW.  */\n\nextern int rename (const char *__old, const char *__new) __THROW;\n\n\n\n#ifdef __USE_ATFILE\n\n/* Rename file OLD relative to OLDFD to NEW relative to NEWFD.  */\n\nextern int renameat (int __oldfd, const char *__old, int __newfd,\n\n\t\t     const char *__new) __THROW;\n\n#endif\n\n\n\n/* Create a temporary file and open it read/write.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\n#ifndef __USE_FILE_OFFSET64\n\nextern FILE *tmpfile (void) __wur;\n\n#else\n\n# ifdef __REDIRECT\n\nextern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;\n\n# else\n\n#  define tmpfile tmpfile64\n\n# endif\n\n#endif\n\n\n\n#ifdef __USE_LARGEFILE64\n\nextern FILE *tmpfile64 (void) __wur;\n\n#endif\n\n\n\n/* Generate a temporary filename.  */\n\nextern char *tmpnam (char *__s) __THROW __wur;\n\n\n\n#ifdef __USE_MISC\n\n/* This is the reentrant variant of `tmpnam\'.  The only difference is\n\n   that it does not allow S to be NULL.  */\n\nextern char *tmpnam_r (char *__s) __THROW __wur;\n\n#endif\n\n\n\n\n\n#if defined __USE_MISC || defined __USE_XOPEN\n\n/* Generate a unique temporary filename using up to five characters of PFX\n\n   if it is not NULL.  The directory to put this file in is searched for\n\n   as follows: First the environment variable "TMPDIR" is checked.\n\n   If it contains the name of a writable directory, that directory is used.\n\n   If not and if DIR is not NULL, that value is checked.  If that fails,\n\n   P_tmpdir is tried and finally "/tmp".  The storage for the filename\n\n   is allocated by `malloc\'.  */\n\nextern char *tempnam (const char *__dir, const char *__pfx)\n\n     __THROW __attribute_malloc__ __wur;\n\n#endif\n\n\n\n\n\n/* Close STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fclose (FILE *__stream);\n\n/* Flush STREAM, or all streams if STREAM is NULL.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fflush (FILE *__stream);\n\n\n\n#ifdef __USE_MISC\n\n/* Faster versions when locking is not required.\n\n\n\n   This function is not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation it is a cancellation point and\n\n   therefore not marked with __THROW.  */\n\nextern int fflush_unlocked (FILE *__stream);\n\n#endif\n\n\n\n#ifdef __USE_GNU\n\n/* Close all streams.\n\n\n\n   This function is not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation it is a cancellation point and\n\n   therefore not marked with __THROW.  */\n\nextern int fcloseall (void);\n\n#endif\n\n\n\n\n\n#ifndef __USE_FILE_OFFSET64\n\n/* Open a file and create a new stream for it.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern FILE *fopen (const char *__restrict __filename,\n\n\t\t    const char *__restrict __modes) __wur;\n\n/* Open a file, replacing an existing stream with it.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern FILE *freopen (const char *__restrict __filename,\n\n\t\t      const char *__restrict __modes,\n\n\t\t      FILE *__restrict __stream) __wur;\n\n#else\n\n# ifdef __REDIRECT\n\nextern FILE *__REDIRECT (fopen, (const char *__restrict __filename,\n\n\t\t\t\t const char *__restrict __modes), fopen64)\n\n  __wur;\n\nextern FILE *__REDIRECT (freopen, (const char *__restrict __filename,\n\n\t\t\t\t   const char *__restrict __modes,\n\n\t\t\t\t   FILE *__restrict __stream), freopen64)\n\n  __wur;\n\n# else\n\n#  define fopen fopen64\n\n#  define freopen freopen64\n\n# endif\n\n#endif\n\n#ifdef __USE_LARGEFILE64\n\nextern FILE *fopen64 (const char *__restrict __filename,\n\n\t\t      const char *__restrict __modes) __wur;\n\nextern FILE *freopen64 (const char *__restrict __filename,\n\n\t\t\tconst char *__restrict __modes,\n\n\t\t\tFILE *__restrict __stream) __wur;\n\n#endif\n\n\n\n#ifdef\t__USE_POSIX\n\n/* Create a new stream that refers to an existing system file descriptor.  */\n\nextern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;\n\n#endif\n\n\n\n#ifdef\t__USE_GNU\n\n/* Create a new stream that refers to the given magic cookie,\n\n   and uses the given functions for input and output.  */\n\nextern FILE *fopencookie (void *__restrict __magic_cookie,\n\n\t\t\t  const char *__restrict __modes,\n\n\t\t\t  _IO_cookie_io_functions_t __io_funcs) __THROW __wur;\n\n#endif\n\n\n\n#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)\n\n/* Create a new stream that refers to a memory buffer.  */\n\nextern FILE *fmemopen (void *__s, size_t __len, const char *__modes)\n\n  __THROW __wur;\n\n\n\n/* Open a stream that writes into a malloc\'d buffer that is expanded as\n\n   necessary.  *BUFLOC and *SIZELOC are updated with the buffer\'s location\n\n   and the number of characters written on fflush or fclose.  */\n\nextern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;\n\n#endif\n\n\n\n\n\n/* If BUF is NULL, make STREAM unbuffered.\n\n   Else make it use buffer BUF, of size BUFSIZ.  */\n\nextern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;\n\n/* Make STREAM use buffering mode MODE.\n\n   If BUF is not NULL, use N bytes of it for buffering;\n\n   else allocate an internal buffer N bytes long.  */\n\nextern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,\n\n\t\t    int __modes, size_t __n) __THROW;\n\n\n\n#ifdef\t__USE_MISC\n\n/* If BUF is NULL, make STREAM unbuffered.\n\n   Else make it use SIZE bytes of BUF for buffering.  */\n\nextern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,\n\n\t\t       size_t __size) __THROW;\n\n\n\n/* Make STREAM line-buffered.  */\n\nextern void setlinebuf (FILE *__stream) __THROW;\n\n#endif\n\n\n\n\n\n/* Write formatted output to STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fprintf (FILE *__restrict __stream,\n\n\t\t    const char *__restrict __format, ...);\n\n/* Write formatted output to stdout.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int printf (const char *__restrict __format, ...);\n\n/* Write formatted output to S.  */\n\nextern int sprintf (char *__restrict __s,\n\n\t\t    const char *__restrict __format, ...) __THROWNL;\n\n\n\n/* Write formatted output to S from argument list ARG.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int vfprintf (FILE *__restrict __s, const char *__restrict __format,\n\n\t\t     _G_va_list __arg);\n\n/* Write formatted output to stdout from argument list ARG.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int vprintf (const char *__restrict __format, _G_va_list __arg);\n\n/* Write formatted output to S from argument list ARG.  */\n\nextern int vsprintf (char *__restrict __s, const char *__restrict __format,\n\n\t\t     _G_va_list __arg) __THROWNL;\n\n\n\n#if defined __USE_ISOC99 || defined __USE_UNIX98\n\n/* Maximum chars of output to write in MAXLEN.  */\n\nextern int snprintf (char *__restrict __s, size_t __maxlen,\n\n\t\t     const char *__restrict __format, ...)\n\n     __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));\n\n\n\nextern int vsnprintf (char *__restrict __s, size_t __maxlen,\n\n\t\t      const char *__restrict __format, _G_va_list __arg)\n\n     __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));\n\n#endif\n\n\n\n#if __GLIBC_USE (LIB_EXT2)\n\n/* Write formatted output to a string dynamically allocated with `malloc\'.\n\n   Store the address of the string in *PTR.  */\n\nextern int vasprintf (char **__restrict __ptr, const char *__restrict __f,\n\n\t\t      _G_va_list __arg)\n\n     __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;\n\nextern int __asprintf (char **__restrict __ptr,\n\n\t\t       const char *__restrict __fmt, ...)\n\n     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;\n\nextern int asprintf (char **__restrict __ptr,\n\n\t\t     const char *__restrict __fmt, ...)\n\n     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;\n\n#endif\n\n\n\n#ifdef __USE_XOPEN2K8\n\n/* Write formatted output to a file descriptor.  */\n\nextern int vdprintf (int __fd, const char *__restrict __fmt,\n\n\t\t     _G_va_list __arg)\n\n     __attribute__ ((__format__ (__printf__, 2, 0)));\n\nextern int dprintf (int __fd, const char *__restrict __fmt, ...)\n\n     __attribute__ ((__format__ (__printf__, 2, 3)));\n\n#endif\n\n\n\n\n\n/* Read formatted input from STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fscanf (FILE *__restrict __stream,\n\n\t\t   const char *__restrict __format, ...) __wur;\n\n/* Read formatted input from stdin.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int scanf (const char *__restrict __format, ...) __wur;\n\n/* Read formatted input from S.  */\n\nextern int sscanf (const char *__restrict __s,\n\n\t\t   const char *__restrict __format, ...) __THROW;\n\n\n\n#if defined __USE_ISOC99 && !defined __USE_GNU \\\n\n    && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n\n    && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n\n# ifdef __REDIRECT\n\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n\n   GNU extension which conflicts with valid %a followed by letter\n\n   s, S or [.  */\n\nextern int __REDIRECT (fscanf, (FILE *__restrict __stream,\n\n\t\t\t\tconst char *__restrict __format, ...),\n\n\t\t       __isoc99_fscanf) __wur;\n\nextern int __REDIRECT (scanf, (const char *__restrict __format, ...),\n\n\t\t       __isoc99_scanf) __wur;\n\nextern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,\n\n\t\t\t\t    const char *__restrict __format, ...),\n\n\t\t\t   __isoc99_sscanf);\n\n# else\n\nextern int __isoc99_fscanf (FILE *__restrict __stream,\n\n\t\t\t    const char *__restrict __format, ...) __wur;\n\nextern int __isoc99_scanf (const char *__restrict __format, ...) __wur;\n\nextern int __isoc99_sscanf (const char *__restrict __s,\n\n\t\t\t    const char *__restrict __format, ...) __THROW;\n\n#  define fscanf __isoc99_fscanf\n\n#  define scanf __isoc99_scanf\n\n#  define sscanf __isoc99_sscanf\n\n# endif\n\n#endif\n\n\n\n#ifdef\t__USE_ISOC99\n\n/* Read formatted input from S into argument list ARG.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int vfscanf (FILE *__restrict __s, const char *__restrict __format,\n\n\t\t    _G_va_list __arg)\n\n     __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;\n\n\n\n/* Read formatted input from stdin into argument list ARG.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int vscanf (const char *__restrict __format, _G_va_list __arg)\n\n     __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;\n\n\n\n/* Read formatted input from S into argument list ARG.  */\n\nextern int vsscanf (const char *__restrict __s,\n\n\t\t    const char *__restrict __format, _G_va_list __arg)\n\n     __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));\n\n\n\n# if !defined __USE_GNU \\\n\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n\n#  ifdef __REDIRECT\n\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n\n   GNU extension which conflicts with valid %a followed by letter\n\n   s, S or [.  */\n\nextern int __REDIRECT (vfscanf,\n\n\t\t       (FILE *__restrict __s,\n\n\t\t\tconst char *__restrict __format, _G_va_list __arg),\n\n\t\t       __isoc99_vfscanf)\n\n     __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;\n\nextern int __REDIRECT (vscanf, (const char *__restrict __format,\n\n\t\t\t\t_G_va_list __arg), __isoc99_vscanf)\n\n     __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;\n\nextern int __REDIRECT_NTH (vsscanf,\n\n\t\t\t   (const char *__restrict __s,\n\n\t\t\t    const char *__restrict __format,\n\n\t\t\t    _G_va_list __arg), __isoc99_vsscanf)\n\n     __attribute__ ((__format__ (__scanf__, 2, 0)));\n\n#  else\n\nextern int __isoc99_vfscanf (FILE *__restrict __s,\n\n\t\t\t     const char *__restrict __format,\n\n\t\t\t     _G_va_list __arg) __wur;\n\nextern int __isoc99_vscanf (const char *__restrict __format,\n\n\t\t\t    _G_va_list __arg) __wur;\n\nextern int __isoc99_vsscanf (const char *__restrict __s,\n\n\t\t\t     const char *__restrict __format,\n\n\t\t\t     _G_va_list __arg) __THROW;\n\n#   define vfscanf __isoc99_vfscanf\n\n#   define vscanf __isoc99_vscanf\n\n#   define vsscanf __isoc99_vsscanf\n\n#  endif\n\n# endif\n\n#endif /* Use ISO C9x.  */\n\n\n\n\n\n/* Read a character from STREAM.\n\n\n\n   These functions are possible cancellation points and therefore not\n\n   marked with __THROW.  */\n\nextern int fgetc (FILE *__stream);\n\nextern int getc (FILE *__stream);\n\n\n\n/* Read a character from stdin.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int getchar (void);\n\n\n\n/* The C standard explicitly says this is a macro, so we always do the\n\n   optimization for it.  */\n\n#define getc(_fp) _IO_getc (_fp)\n\n\n\n#ifdef __USE_POSIX199506\n\n/* These are defined in POSIX.1:1996.\n\n\n\n   These functions are possible cancellation points and therefore not\n\n   marked with __THROW.  */\n\nextern int getc_unlocked (FILE *__stream);\n\nextern int getchar_unlocked (void);\n\n#endif /* Use POSIX.  */\n\n\n\n#ifdef __USE_MISC\n\n/* Faster version when locking is not necessary.\n\n\n\n   This function is not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation it is a cancellation point and\n\n   therefore not marked with __THROW.  */\n\nextern int fgetc_unlocked (FILE *__stream);\n\n#endif /* Use MISC.  */\n\n\n\n\n\n/* Write a character to STREAM.\n\n\n\n   These functions are possible cancellation points and therefore not\n\n   marked with __THROW.\n\n\n\n   These functions is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fputc (int __c, FILE *__stream);\n\nextern int putc (int __c, FILE *__stream);\n\n\n\n/* Write a character to stdout.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int putchar (int __c);\n\n\n\n/* The C standard explicitly says this can be a macro,\n\n   so we always do the optimization for it.  */\n\n#define putc(_ch, _fp) _IO_putc (_ch, _fp)\n\n\n\n#ifdef __USE_MISC\n\n/* Faster version when locking is not necessary.\n\n\n\n   This function is not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation it is a cancellation point and\n\n   therefore not marked with __THROW.  */\n\nextern int fputc_unlocked (int __c, FILE *__stream);\n\n#endif /* Use MISC.  */\n\n\n\n#ifdef __USE_POSIX199506\n\n/* These are defined in POSIX.1:1996.\n\n\n\n   These functions are possible cancellation points and therefore not\n\n   marked with __THROW.  */\n\nextern int putc_unlocked (int __c, FILE *__stream);\n\nextern int putchar_unlocked (int __c);\n\n#endif /* Use POSIX.  */\n\n\n\n\n\n#if defined __USE_MISC \\\n\n    || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n\n/* Get a word (int) from STREAM.  */\n\nextern int getw (FILE *__stream);\n\n\n\n/* Write a word (int) to STREAM.  */\n\nextern int putw (int __w, FILE *__stream);\n\n#endif\n\n\n\n\n\n/* Get a newline-terminated string of finite length from STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)\n\n     __wur;\n\n\n\n#if __GLIBC_USE (DEPRECATED_GETS)\n\n/* Get a newline-terminated string from stdin, removing the newline.\n\n\n\n   This function is impossible to use safely.  It has been officially\n\n   removed from ISO C11 and ISO C++14, and we have also removed it\n\n   from the _GNU_SOURCE feature list.  It remains available when\n\n   explicitly using an old ISO C, Unix, or POSIX standard.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern char *gets (char *__s) __wur __attribute_deprecated__;\n\n#endif\n\n\n\n#ifdef __USE_GNU\n\n/* This function does the same as `fgets\' but does not lock the stream.\n\n\n\n   This function is not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation it is a cancellation point and\n\n   therefore not marked with __THROW.  */\n\nextern char *fgets_unlocked (char *__restrict __s, int __n,\n\n\t\t\t     FILE *__restrict __stream) __wur;\n\n#endif\n\n\n\n\n\n#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)\n\n/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR\n\n   (and null-terminate it). *LINEPTR is a pointer returned from malloc (or\n\n   NULL), pointing to *N characters of space.  It is realloc\'d as\n\n   necessary.  Returns the number of characters read (not including the\n\n   null terminator), or -1 on error or EOF.\n\n\n\n   These functions are not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation they are cancellation points and\n\n   therefore not marked with __THROW.  */\n\nextern _IO_ssize_t __getdelim (char **__restrict __lineptr,\n\n\t\t\t       size_t *__restrict __n, int __delimiter,\n\n\t\t\t       FILE *__restrict __stream) __wur;\n\nextern _IO_ssize_t getdelim (char **__restrict __lineptr,\n\n\t\t\t     size_t *__restrict __n, int __delimiter,\n\n\t\t\t     FILE *__restrict __stream) __wur;\n\n\n\n/* Like `getdelim\', but reads up to a newline.\n\n\n\n   This function is not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation it is a cancellation point and\n\n   therefore not marked with __THROW.  */\n\nextern _IO_ssize_t getline (char **__restrict __lineptr,\n\n\t\t\t    size_t *__restrict __n,\n\n\t\t\t    FILE *__restrict __stream) __wur;\n\n#endif\n\n\n\n\n\n/* Write a string to STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fputs (const char *__restrict __s, FILE *__restrict __stream);\n\n\n\n/* Write a string, followed by a newline, to stdout.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int puts (const char *__s);\n\n\n\n\n\n/* Push a character back onto the input buffer of STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int ungetc (int __c, FILE *__stream);\n\n\n\n\n\n/* Read chunks of generic data from STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern size_t fread (void *__restrict __ptr, size_t __size,\n\n\t\t     size_t __n, FILE *__restrict __stream) __wur;\n\n/* Write chunks of generic data to STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern size_t fwrite (const void *__restrict __ptr, size_t __size,\n\n\t\t      size_t __n, FILE *__restrict __s);\n\n\n\n#ifdef __USE_GNU\n\n/* This function does the same as `fputs\' but does not lock the stream.\n\n\n\n   This function is not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation it is a cancellation point and\n\n   therefore not marked with __THROW.  */\n\nextern int fputs_unlocked (const char *__restrict __s,\n\n\t\t\t   FILE *__restrict __stream);\n\n#endif\n\n\n\n#ifdef __USE_MISC\n\n/* Faster versions when locking is not necessary.\n\n\n\n   These functions are not part of POSIX and therefore no official\n\n   cancellation point.  But due to similarity with an POSIX interface\n\n   or due to the implementation they are cancellation points and\n\n   therefore not marked with __THROW.  */\n\nextern size_t fread_unlocked (void *__restrict __ptr, size_t __size,\n\n\t\t\t      size_t __n, FILE *__restrict __stream) __wur;\n\nextern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,\n\n\t\t\t       size_t __n, FILE *__restrict __stream);\n\n#endif\n\n\n\n\n\n/* Seek to a certain position on STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fseek (FILE *__stream, long int __off, int __whence);\n\n/* Return the current position of STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern long int ftell (FILE *__stream) __wur;\n\n/* Rewind to the beginning of STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern void rewind (FILE *__stream);\n\n\n\n/* The Single Unix Specification, Version 2, specifies an alternative,\n\n   more adequate interface for the two functions above which deal with\n\n   file offset.  `long int\' is not the right type.  These definitions\n\n   are originally defined in the Large File Support API.  */\n\n\n\n#if defined __USE_LARGEFILE || defined __USE_XOPEN2K\n\n# ifndef __USE_FILE_OFFSET64\n\n/* Seek to a certain position on STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fseeko (FILE *__stream, __off_t __off, int __whence);\n\n/* Return the current position of STREAM.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern __off_t ftello (FILE *__stream) __wur;\n\n# else\n\n#  ifdef __REDIRECT\n\nextern int __REDIRECT (fseeko,\n\n\t\t       (FILE *__stream, __off64_t __off, int __whence),\n\n\t\t       fseeko64);\n\nextern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);\n\n#  else\n\n#   define fseeko fseeko64\n\n#   define ftello ftello64\n\n#  endif\n\n# endif\n\n#endif\n\n\n\n#ifndef __USE_FILE_OFFSET64\n\n/* Get STREAM\'s position.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);\n\n/* Set STREAM\'s position.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int fsetpos (FILE *__stream, const fpos_t *__pos);\n\n#else\n\n# ifdef __REDIRECT\n\nextern int __REDIRECT (fgetpos, (FILE *__restrict __stream,\n\n\t\t\t\t fpos_t *__restrict __pos), fgetpos64);\n\nextern int __REDIRECT (fsetpos,\n\n\t\t       (FILE *__stream, const fpos_t *__pos), fsetpos64);\n\n# else\n\n#  define fgetpos fgetpos64\n\n#  define fsetpos fsetpos64\n\n# endif\n\n#endif\n\n\n\n#ifdef __USE_LARGEFILE64\n\nextern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);\n\nextern __off64_t ftello64 (FILE *__stream) __wur;\n\nextern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);\n\nextern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);\n\n#endif\n\n\n\n/* Clear the error and EOF indicators for STREAM.  */\n\nextern void clearerr (FILE *__stream) __THROW;\n\n/* Return the EOF indicator for STREAM.  */\n\nextern int feof (FILE *__stream) __THROW __wur;\n\n/* Return the error indicator for STREAM.  */\n\nextern int ferror (FILE *__stream) __THROW __wur;\n\n\n\n#ifdef __USE_MISC\n\n/* Faster versions when locking is not required.  */\n\nextern void clearerr_unlocked (FILE *__stream) __THROW;\n\nextern int feof_unlocked (FILE *__stream) __THROW __wur;\n\nextern int ferror_unlocked (FILE *__stream) __THROW __wur;\n\n#endif\n\n\n\n\n\n/* Print a message describing the meaning of the value of errno.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern void perror (const char *__s);\n\n\n\n/* Provide the declarations for `sys_errlist\' and `sys_nerr\' if they\n\n   are available on this system.  Even if available, these variables\n\n   should not be used directly.  The `strerror\' function provides\n\n   all the necessary functionality.  */\n\n#include <bits/sys_errlist.h>\n\n\n\n\n\n#ifdef\t__USE_POSIX\n\n/* Return the system file descriptor for STREAM.  */\n\nextern int fileno (FILE *__stream) __THROW __wur;\n\n#endif /* Use POSIX.  */\n\n\n\n#ifdef __USE_MISC\n\n/* Faster version when locking is not required.  */\n\nextern int fileno_unlocked (FILE *__stream) __THROW __wur;\n\n#endif\n\n\n\n\n\n#ifdef __USE_POSIX2\n\n/* Create a new stream connected to a pipe running the given command.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern FILE *popen (const char *__command, const char *__modes) __wur;\n\n\n\n/* Close a stream opened by popen and return the status of its child.\n\n\n\n   This function is a possible cancellation point and therefore not\n\n   marked with __THROW.  */\n\nextern int pclose (FILE *__stream);\n\n#endif\n\n\n\n\n\n#ifdef\t__USE_POSIX\n\n/* Return the name of the controlling terminal.  */\n\nextern char *ctermid (char *__s) __THROW;\n\n#endif /* Use POSIX.  */\n\n\n\n\n\n#if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU\n\n/* Return the name of the current user.  */\n\nextern char *cuserid (char *__s);\n\n#endif /* Use X/Open, but not issue 6.  */\n\n\n\n\n\n#ifdef\t__USE_GNU\n\nstruct obstack;\t\t\t/* See <obstack.h>.  */\n\n\n\n/* Write formatted output to an obstack.  */\n\nextern int obstack_printf (struct obstack *__restrict __obstack,\n\n\t\t\t   const char *__restrict __format, ...)\n\n     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));\n\nextern int obstack_vprintf (struct obstack *__restrict __obstack,\n\n\t\t\t    const char *__restrict __format,\n\n\t\t\t    _G_va_list __args)\n\n     __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));\n\n#endif /* Use GNU.  */\n\n\n\n\n\n#ifdef __USE_POSIX199506\n\n/* These are defined in POSIX.1:1996.  */\n\n\n\n/* Acquire ownership of STREAM.  */\n\nextern void flockfile (FILE *__stream) __THROW;\n\n\n\n/* Try to acquire ownership of STREAM but do not block if it is not\n\n   possible.  */\n\nextern int ftrylockfile (FILE *__stream) __THROW __wur;\n\n\n\n/* Relinquish the ownership granted for STREAM.  */\n\nextern void funlockfile (FILE *__stream) __THROW;\n\n#endif /* POSIX */\n\n\n\n#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU\n\n/*  X/Open Issues 1-5 required getopt to be declared in this\n\n   header.  It was removed in Issue 6.  GNU follows Issue 6.  */\n\n# include <bits/getopt_posix.h>\n\n#endif\n\n\n\n/* If we are compiling with optimizing read this file.  It contains\n\n   several optimizing inline functions and macros.  */\n\n#ifdef __USE_EXTERN_INLINES\n\n# include <bits/stdio.h>\n\n#endif\n\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n\n# include <bits/stdio2.h>\n\n#endif\n\n#ifdef __LDBL_COMPAT\n\n# include <bits/stdio-ldbl.h>\n\n#endif\n\n\n\n__END_DECLS\n\n\n\n#endif /* <stdio.h> included.  */\n'

In [62]:
# get the macros
macros = {}
"(<(\w+\/*\w*(\.h)?)*\>)" # ez a <stdio.h> és <valami/valami.h>
includes_re = "#\s*include (\"(\w+\/*\w*)*\") | (<(\w+\/*\w*(\.h)?)*\>)"
macro_re = "#\s*define\s+([A-Za-z]\w*)\s"
for i, line in enumerate(lines):
    result = re.search(macro_re, line)
    if result:
        print(i, result.group(1))
        try:
            macros[result.group(1)] = {"line": i, "pos": result.span()}
        except:
            print(result[0], "duplicated")


93 BUFSIZ
100 EOF
106 SEEK_SET
107 SEEK_CUR
108 SEEK_END
110 SEEK_DATA
111 SEEK_HOLE
117 P_tmpdir
138 stdin
139 stdout
140 stderr
163 tmpfile
250 fopen
251 freopen
408 fscanf
409 scanf
410 sscanf
464 vfscanf
465 vscanf
466 vsscanf
719 fseeko
720 ftello
743 fgetpos
744 fsetpos

Get the include files


In [69]:
def get_header_path(include_path, header_file):
    min_length = 5000
    best = ""
    for root, dirs, files in os.walk(include_path, topdown=False):
        for name in files:
            file = os.path.join(root, name)
            if header_file in file:
                if len(file) < min_length:
                    min_length = len(file)
                    best = file
    print(best)
    return best

def get_includes(file_content):
    # get the macros
    lines = file_content.split("\n")
    includes = {}
    includes_re = "#\s*include (\"(\w+\/*\w*)*\") | (<(\w+\/*\w*(\.h)?)*\>)"
    for i, line in enumerate(lines):
        result = re.search(macro_re, line)
        include = re.search(includes_re, line)
        if include:
            header_file = include.group(4)
            if header_file not in includes:
                includes[header_file] = get_header_path(INCLUDE_PATH, header_file=header_file)
    return includes

In [70]:
# get the macros
includes = {}
"(<(\w+\/*\w*(\.h)?)*\>)" # ez a <stdio.h> és <valami/valami.h>
includes_re = "#\s*include (\"(\w+\/*\w*)*\") | (<(\w+\/*\w*(\.h)?)*\>)"
for i, line in enumerate(lines):
    result = re.search(macro_re, line)
    include = re.search(includes_re, line)
    if include:
        header_file = include.group(4)
        if header_file not in includes:
            includes[header_file] = get_header_path(INCLUDE_PATH, header_file=header_file)


/usr/include/linux/stddef.h
/usr/include/i386-linux-gnu/bits/types.h
/usr/include/i386-linux-gnu/bits/types/__FILE.h
/usr/include/i386-linux-gnu/bits/types/FILE.h
/usr/include/i386-linux-gnu/bits/libio.h
/usr/include/c++/7/tr1/stdarg.h
/usr/include/i386-linux-gnu/bits/stdio_lim.h
/usr/include/i386-linux-gnu/bits/sys_errlist.h
/usr/include/obstack.h
/usr/include/i386-linux-gnu/bits/getopt_posix.h
/usr/include/i386-linux-gnu/bits/stdio.h
/usr/include/i386-linux-gnu/bits/stdio2.h
/usr/include/stdio.h

In [47]:
header_file


Out[47]:
'stdio.h'

In [54]:
min_length = 5000
best = ""
for root, dirs, files in os.walk(INCLUDE_PATH, topdown=False):
    for name in files:
        file = os.path.join(root, name)
        if "/" + "stdio.h" in file:
            if len(file) < min_length:
                min_length = len(file)
                best = file
print(best)


/usr/include/stdio.h

In [55]:


In [57]:
includes


Out[57]:
{'stddef.h': '/usr/include/linux/stddef.h',
 'bits/types.h': '/usr/include/i386-linux-gnu/bits/types.h',
 's/__FILE.h': '/usr/include/i386-linux-gnu/bits/types/__FILE.h',
 's/FILE.h': '/usr/include/i386-linux-gnu/bits/types/FILE.h',
 'bits/libio.h': '/usr/include/i386-linux-gnu/bits/libio.h',
 'stdarg.h': '/usr/include/c++/7/tr1/stdarg.h',
 'bits/stdio_lim.h': '/usr/include/i386-linux-gnu/bits/stdio_lim.h',
 'bits/sys_errlist.h': '/usr/include/i386-linux-gnu/bits/sys_errlist.h',
 'obstack.h': '/usr/include/obstack.h',
 'bits/getopt_posix.h': '/usr/include/i386-linux-gnu/bits/getopt_posix.h',
 'bits/stdio.h': '/usr/include/i386-linux-gnu/bits/stdio.h',
 'bits/stdio2.h': '/usr/include/i386-linux-gnu/bits/stdio2.h',
 'stdio.h': '/usr/include/stdio.h'}

Get the functions


In [95]:
py_re = "(def)\s+((\w*)\s*(\(.*\)))" # group 2 
c_re = "((\w+\s+\w*\s*)((\((\w+\W+\w+)\W*\))))" # group 1

In [90]:
f = open("hello.c", "r")
example = f.read()
f.close()

In [91]:
example


Out[91]:
'#include <stdio.h>\n\nint main() {\n    printf("Hello world\\n");\n\n    retrun 0;\n}'

In [92]:
headers = get_includes(example)


/usr/include/stdio.h

In [96]:
# open header and find functions
functions = []
for header in headers:
    # open header and read all the content
    header_file = open(headers[header], "r")
    content = header_file.read()
    header_file.close()
    
    lines = content.split("\n")
    # find functions:
    for line in lines:
#         print(line)
        function = re.search(c_re, line)
        if function is not None:
            functions.append(function)

In [125]:
for function in functions:
    if "define" in function.group(0):
        print(function)

# remove the wrong values
functions = [func for func in functions if "define" not in func.group(0)]
functions = [func for func in functions if func.group(1).count(")") == func.group(1).count("(")]

In [126]:
functions


Out[126]:
[<_sre.SRE_Match object; span=(13, 31), match='tmpnam (char *__s)'>,
 <_sre.SRE_Match object; span=(13, 33), match='tmpnam_r (char *__s)'>,
 <_sre.SRE_Match object; span=(7, 34), match='int fclose (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 34), match='int fflush (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 43), match='int fflush_unlocked (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 39), match='void setlinebuf (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 33), match='int fgetc (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 32), match='int getc (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 41), match='int getc_unlocked (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 42), match='int fgetc_unlocked (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 28), match='int putchar (int __c)'>,
 <_sre.SRE_Match object; span=(7, 37), match='int putchar_unlocked (int __c)'>,
 <_sre.SRE_Match object; span=(7, 32), match='int getw (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(13, 29), match='gets (char *__s)'>,
 <_sre.SRE_Match object; span=(8, 29), match='up to (and including)'>,
 <_sre.SRE_Match object; span=(12, 38), match='int ftell (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 35), match='void rewind (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 38), match='__off_t ftello (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 42), match='__off64_t ftello64 (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 37), match='void clearerr (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 32), match='int feof (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 34), match='int ferror (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 46), match='void clearerr_unlocked (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 41), match='int feof_unlocked (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 43), match='int ferror_unlocked (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 34), match='int fileno (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 43), match='int fileno_unlocked (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 34), match='int pclose (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(13, 32), match='ctermid (char *__s)'>,
 <_sre.SRE_Match object; span=(13, 32), match='cuserid (char *__s)'>,
 <_sre.SRE_Match object; span=(7, 38), match='void flockfile (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 40), match='int ftrylockfile (FILE *__stream)'>,
 <_sre.SRE_Match object; span=(7, 40), match='void funlockfile (FILE *__stream)'>]

In [79]:
functions = []
lines = example.split("\n")
for line in lines:
    print(line)
    function = re.search(c_re, line)
    functions.append(function)


#include <stdio.h>

int main() {
    printf("Hello world\n");

    retrun 0;
}

In [124]:
functions[0].group(1).count(")")


Out[124]:
1

In [ ]:


In [ ]: