GCOBOL(3)

πŸ“¦
version 16.2.1+r23+gd564253eb6c8 Β· 2 versions
  • 16.2.1+r23+gd564253eb6c8 Β· arch rolling, fedora 43, fedora 44, ubuntu questing, ubuntu resolute (latest)
  • ubuntu stonking
, in arch rolling, fedora 43, fedora 44, ubuntu questing, ubuntu resolute

GCOBOL(3) πŸ’–βœ¨

okay bestie, sit down, we're doing the GCC COBOL Compiler front-end I/O function API and honestly? it's giving interface design, it's giving plug me in, it's giving "the library isn't implemented yet but the vibes are immaculate". let's go 🫢


✨ NAME ✨

gcobol β€” the GCC COBOL Front-end I/O function API πŸŽ€


πŸ“š LIBRARY πŸ“š

libgcobol πŸ’…


✨ SYNOPSIS ✨

#include <symbols.h>
#include <io.h>
#include <gcobolio.h>

gcobol_io_t
gcobol_fileops();

class gcobol_io_t {
public:
  static const char constexpr marquee[64];
  typedef void (open_t)( cblc_file_t *file,
                         char *filename,
                         int mode_char,
                         int is_quoted );
  typedef void (close_t)( cblc_file_t *file,
                          int how );
  typedef void (start_t)( cblc_file_t *file,
                          int relop, // needs enum
                          int first_last_key,
                          size_t length );
  typedef void (read_t)( cblc_file_t *file,
                         int where );
  typedef void (write_t)( cblc_file_t *file,
                          unsigned char  *data,
                          size_t length,
                          int after,
                          int lines,
                          int is_random );
  typedef void (rewrite_t)( cblc_file_t *file,
                            size_t length, bool is_random );
  typedef void (delete_t)( cblc_file_t *file,
                          bool is_random );
  open_t      *Open;
  close_t     *Close;
  start_t     *Start;
  read_t      *Read;
  write_t     *Write;
  rewrite_t   *Rewrite;
  delete_t    *Delete;
  ...
};

like look at that struct. she's structured. she's typed. she has a marquee. iconic behavior only. πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

okay so here's the tea, bestie: gcobol supplies replaceable I/O functionality via gcobol_fileops(). that function returns a pointer to a structure of C function pointers, and those pointers implement sequential, relative, and indexed file operations over files whose On Disk Format (ODF) is defined by gcobol. πŸ”₯

so like, if you're a user and you want to use another library that does the same stuff over a different ODF? totally valid, go off. you just have to supply a different implementation of gcobol_fileops(), plus 7 functions, as described in this document. that's it, that's the deal, no cap. ✨

the pointers to those user-implemented functions get placed in a C++ object of type gcobol_io_t, and an instantiation of that type is what gcobol_fileops() returns. the compiled program initializes I/O operations by calling that function the first time any file is opened. first-open energy, main character energy, periodt. πŸ’…


πŸ¦‹ about cblc_file_t πŸ¦‹

every single function takes as its first argument a pointer to a cblc_file_t object, which is analogous to a FILE object used in the C stdio functions. yes bestie, it's that kind of relationship. πŸ’œ

the cblc_file_t structure acts as a communication area between the compiled program and the I/O library. any information needed about the file is kept there. and notably: the outcome of any operation is stored in that structure in the file_status member, not as a return code. (not me realizing it's not a return code 😭). information about the operation (as opposed to the file) appears as parameters to the function.

cblc_file_t has one member, not used by gcobol, that is reserved for the user:

void * implementation.

user-supplied I/O functions may assign and dereference implementation. gcobol will preserve the value, but never references it. so it's yours, bestie. a lil pocket of space. do what you want with it, she won't look. πŸ™ˆ


🌈 the 7 function pointers in gcobol_io_t 🌈

Open β€” void open_t(cblc_file_t *file, char *filename, int mode_char, int is_quoted)

parameters:

  • filename β€” is the filename, as known to the OS πŸ“
  • mode_char β€” is one of:
    • 'r' β€” OPEN INPUT: read-only mode
    • 'w' β€” OPEN OUTPUT: create a new file or overwrite an existing one
    • 'a' β€” EXTEND: append to sequential file
    • '+' β€” modify existing file
  • is_quoted β€” If true, filename is taken literally. If false, filename is interpreted as the name of an environment variable, the contents of which, if extant, are taken as the name of the file to be opened. If no such variable exists, then filename is used verbatim.
the way is_quoted does double duty as a secret env-var lookup?? she's clever. she's unhinged. she's both. πŸ’€

Close β€” void close_t(cblc_file_t *file, int how)

parameters:

  • how β€” A value of 0x08 closes a β€œREEL unit”. Because no such thing is supported, the function sets the file status to β€œ07”, meaning not a tape.

Start β€” void start_t(cblc_file_t *file, int relop, int first_last_key, size_t length)

parameters:

  • relop β€” is one of:
    • 0 β€” means '<'
    • 1 β€” means '<='
    • 2 β€” means '='
    • 3 β€” means '!='
    • 4 β€” means '>='
    • 5 β€” means '>'
  • first_last_key β€” is the key number (starting at 1) of the key within the cblc_file_t structure.
  • length β€” is the size of the key (TODO: per the START statement?)

Read β€” void read_t(cblc_file_t *file, int where)

parameters:

  • where
    • -2 β€” PREVIOUS
    • -1 β€” NEXT
    • N β€” represents a key number, starting with 1, in the cblc_file_t structure. The value of that key is used to find the record, and read it.

Write β€” void write_t(cblc_file_t *file, unsigned char *data, size_t length, int after, int lines, int is_random)

parameters:

  • data β€” address of in-memory buffer to write
  • length β€” length of in-memory buffer to write
  • after β€” has the value 1 if the
AFTER ADVANCING n LINES

phrase was present in the WRITE statement, else 0

  • lines β€” may be one of:
    • -666 β€” ADVANCING PAGE
    • -1 β€” no ADVANCING phrase appeared
    • 0 β€” ADVANCING 0 LINES is valid
    • >0 β€” the value of n in ADVANCING n LINES
  • is_random β€” is true if the access mode is RANDOM
-666 bestie. SIX SIX SIX. that's the page-advancing sentinel and i am screaming. 😭πŸ”₯ whoever picked that number was in their villain era and honestly? respect.

Rewrite β€” void rewrite_t(cblc_file_t *file, size_t length, bool is_random)

parameters:

  • length β€” number of bytes to write
  • is_random β€” true if access mode is RANDOM

Delete β€” void delete_t(cblc_file_t *file, bool is_random)

parameters:

  • is_random β€” true if access mode is RANDOM

🧚 the one function the binary calls directly 🧚

the library implements one function that the gcobol-produced binary calls directly:

gcobol_io_t * gcobol_fileops()

This function populates a gcobol_io_t object with the above function pointers. The compiled binary begins by calling gcobol_fileops(), and then uses the supplied pointers to effect I/O. ✨


πŸ’œ RETURN VALUES πŸ’œ

I/O functions return void. gcobol_fileops() returns gcobol_io_t*. that's it, that's the whole vibe check, no surprises here bestie 🫢


🌸 STANDARDS 🌸

The I/O library supplied by gcobol, libgcobolio.so, supports the I/O semantics defined by ISO COBOL. It is not intended to be compatible with any other ODF. That is, libgcobolio.so cannot be used to exchange data with any other COBOL implementation. πŸ’€ (she's exclusive. she doesn't share her ODF. she's a closed circuit. respect.)

The purpose of the gcobol_io_t structure is to allow the use of other I/O implementations with other ODF representations. so like, she won't play nice with others, but she built you a door so you can. that's growth. 🌈


⚠️ CAVEATS ⚠️

The library is not well tested, not least because it is not implemented.

okay so. bestie. hear me. the library is not well tested AND the reason it's not well tested is that it doesn't exist yet. that's not a red flag that's a red banner. that's a whole red parade. 😭 but we're here for the spec, and the spec ate. πŸ’…

πŸ› BUGS πŸ›

The future is yet to come.

and that's not even a bug, that's just poetry. periodt. ✨

this has been gcobol (3) from the GCC COBOL Compiler corner of the universe β€” landing on Linux, dated March 2024, and yes she is still signing her name GCOBOL(3) at the bottom like the icon she is. mwah. πŸ’–πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from
  • arch rolling: gcc-gcobol 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 43: gcc-gcobol 15.2.1-2.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 43: gcc-gcobol 15.3.1-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 43: libstdc++-docs 15.2.1-2.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 43: libstdc++-docs 15.3.1-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: gcc-gcobol 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: gcc-gcobol 16.2.1-2.fc44
  • fedora 44: gcc-gcobol 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • ubuntu questing: gcc-snapshot 1:20250921-1ubuntu1
  • ubuntu resolute: gcc-snapshot 1:20260306-1ubuntu1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms