LIBCGI_GENERAL(3)

πŸ“¦ version 1.0, in fedora 43, fedora 44

🌸 General purpose(3) β€” from the Library Functions Manual πŸ’…

okay bestie, gather round, because this is the LibCGI general-purpose grab bag ✨ three little functions that do three very specific things, and they're all lowkey iconic. no cap.


πŸŽ€ NAME πŸŽ€

General purpose β€” like, the vibes are "assorted utility functions," and honestly? it ate.

πŸ¦‹ Functions πŸ¦‹

  • char * htmlentities (const char *str) β€” Transforms HTML special chars. it's giving "escape my text before it does crimes."
  • char ** file (const char *filename, unsigned int *total) β€” Reads entire file into an array. the whole file. all of it. periodt.
  • char * md5 (const char *str) β€” Converts a string to MD5 format. hash queen πŸ‘‘

πŸ“– Function Documentation πŸ“–

✨ char** file (const char * filename, unsigned int * total)

Reads entire file into an array. literally the whole file, into an array, in one go 🫢

Parameters:

  • filename β€” Filename to open
  • total β€” Integer variable passed as reference, which will store the total of items

Returns:

Returns the file in an array. Each element of the array corresponds to a line in the file.

char **lines;
unsigned int total, i;

lines = file('filename.ext', &total);

printf('Total of lines: %u0, total);

for (i = 0; i < total; i++)
       printf('[%u] %s0, i, lines[i]);

for (i = 0; i < total; i++) {
       if (lines[i])
                free(lines[i]);
}
🌈 psst β€” see how every lines[i] gets free'd at the end? that's the clean-up era, bestie. don't skip it, or your memory leaks and that's not the main character energy we're going for πŸ’€

πŸ’œ char* htmlentities (const char * str)

Transforms HTML special chars. Transforms chars like '<', '>' and others in HTML form, like '&lt' and '&gt' πŸŽ€

Parameters:

  • str β€” String containing code to parse

Returns:

The new string

Author:

Robert Csok <rcsok@gmx.de>


πŸ“ char* md5 (const char * str)

Converts a string to MD5 format. one-way trip, no takebacks πŸ’…

Author:

Diogo Gonzaga

Parameters:

  • str β€” String to convert to MD5 hash

Returns:

MD5 hash code


that's the whole page, bestie β€” three functions, three authors' worth of credit, zero filler. go forth and parse responsibly 🧚

and before you go: this lil number came from LibCGI, dated 13 Mar 2003 β€” yes, 2003, it's vintage and it's still serving. iykyk πŸ‘‘βœ¨

πŸ“¦ where this page comes from