#!/bin/csh -f

# Search FLTK's source code for the "Large File Support" related
# functions and datatypes.
#
# This program is not perfect, but is maybe a good starting point
# for identifying areas of code to check.
#
# It is advised to do a 'make clean' in $fltkdir before running this script
# to avoid grepping binaries.
#

set fltkdir = /usr/local/src/fltk-1.1.x         # fltk main directory
set subdirs = ( src FL test )                   # fltk subdirs to test

echo ''; echo '*** FUNCTIONS:'
set search = "aio_cancel\(|aio_error\(|aio_fsync\(|aio_read\(|aio_return\(|aio_suspend\("
set search = "$search|aio_write\(|lio_listio\(|fgetpos\(|fopen\(|freopen\(|fseeko\(|fsetpos\("
set search = "$search|ftello\(|tmpfile\(|creat\(|fstat\(|fstatvfs\(|ftruncate\(|ftw\("
set search = "$search|getrlimit\(|lockf\(|lseek\(|lstat\(|mmap\(|nftw\(|open\(|readdir\("
set search = "$search|setrlimit\(|stat\(|statvfs\(|truncate\("
foreach subdir ( $subdirs )
    echo "    -- $subdir --"
    ( cd $fltkdir; find $subdir -type f -exec egrep -n "$search" {} /dev/null \; | \
            egrep -v "fileopen\(|winopen\(|freopen\(|fopen\(|fontopen\(|^[^:]*:[ ]*//" )
end

echo '' ; echo '*** DATATYPES:'
set search = "blkcnt_t|fsblkcnt_t|fsfilcnt_t|fpos_t|ino_t|off_t|rlim_t"
set search = "$search|struct[ \t]*dirent|struct[ \t]*flock|struct[ \t]*rlimit"
set search = "$search|struct[ \t]*stat|struct[ \t]*statvfs"
set search = "$search|F_GETLK|F_SETLK|F_SETLKW|RLIM_INFINITY|RLIM_SAVED_MAX|RLIM_SAVED_CUR"
foreach subdir ( $subdirs )
    echo "    -- $subdir --"
    ( cd $fltkdir; find $subdir -type f -exec egrep -n "$search" {} /dev/null \; )
end
