PROC omit_entry_points, omiep (
  module m: name = $required
  keep k: list of name
  keep_all ka: list of name
  number n: integer 1 .. 5000 = 5000
  status)

"----------------------------------------------------------------------"
" OMIT_ENTRY_POINTS
"
" PURPOSE:
"
"  Generate commands to omit all entry points from a module except
" those specified by the Keep parameter.  Must be called from inside
" CREATE_OBJECT_LIBRARY.
"
" PARAMETERS:
"
" Module: Name of module to be changed.  Required.
" Keep: List of entry_points to keep.
" Keep_All: List of names, where all entry_points beginning with
"  each of the names are kept.  Example: ka=SMP$.
" Number: Ususally defaulted to 5000.  Max number of entry points to
"  omit.
"----------------------------------------------------------------------"

  create_variable ignore_status kind=status
  commands = $unique
  set_file_attributes $fname(commands) fc=legible pf=continuous
  display_new_library $value(module) o=$fname(commands) do=ep
  create_variable discard_output kind=string value=$unique
  EDIT_FILE $fname(commands) o=$fname(discard_output)
    put_message 'Omit entry points from '//$string($value(module))//' keeping:'
    create_variable ignore_status kind=status
    create_variable entry_point_found kind=status
    set_verify_option echo=off
    delete_lines n=7
    change_text 'GATED' n=all status=ignore_status
    change_text 'RETAINED' n=all status=ignore_status
    FOR i = 1 TO $set_count(keep) DO
      put_message '    '//$string($value(keep i))
      search_backward n=all status=ignore_status
      search_forward $string($value(keep i)) us=yes status=entry_point_found
      IF entry_point_found.normal THEN
        delete_lines n=1
      IFEND
    FOREND
    FOR i = 1 TO $set_count(keep_all) DO
      put_message '    '//$string($value(keep_all i))//'*'
      set_search_margins 3..$strlen($string($value(keep_all i)))+2
      delete_lines $string($value(keep_all i)) all first..last status=ignore_status
    FOREND
    set_search_margins
    search_backward n=all status=ignore_status
    search_forward 'starting procedure:' status=entry_point_found
    IF NOT entry_point_found.normal THEN
      search_forward line=last
    ELSE
      search_backward n=1
    IFEND
    delete_lines n=all
    search_backward n=all status=ignore_status
    create_variable last_status kind=status
    FOR i = 1 TO $value(number) DO
      i p=before nt='change_module_attributes '//$string($value(module))//' o='
      search_forward n=1 status=last_status
      EXIT WHEN NOT last_status.normal
    FOREND
    search_backward n=all status=ignore_status
    change_text 'o=' 'o=...' n=all
  END
  include_file $fname(commands)
  detach_file $fname(discard_output)
  detach_file $fname(commands)

PROCEND omit_entry_points
