#include <stdio.h>
#include <glib.h>
#include "gcontainer.h"
Go to the source code of this file.
Defines | |
#define | G_LOCK(arg) |
#define | G_UNLOCK(arg) |
#define | LB_REGISTER(ptr, dataSize) |
#define | DBUGOUT(args...) |
Output debugging messages. | |
#define | nnull_g_string_free(ptr, boole) |
call g_string_free on a pointer only if it's not == NULL | |
#define | nnull_g_free(ptr) |
call g_string_free on a pointer only if it's not == NULL | |
#define | TEMP_DIR "/tmp" |
temp directory | |
Functions | |
int | lutil_streq (const char *str1, const char *str2) |
Check if two strings are equal. | |
int | lutil_strcaseeq (const char *str1, const char *str2) |
Check if two strings are equal, ignoring case. | |
char * | lutil_createString (int length) |
Create a new string. | |
char * | lutil_vstrcreate (const char *src1,...) |
Append any number of strings together into one. | |
char * | lutil_mprintf (const char *template,...) |
Like sprintf, but allocate memory for and return the string. | |
char * | lutil_strjoin (const char *delim, const GContainer *strings) |
Join an array of strings together separated by the given delimiter. | |
GContainer * | lutil_gsplit (const char *delim, const char *str) |
Split a string by character delim into a GContainer. | |
char * | lutil_valistToString (const char *template, va_list args) |
gboolean | lutil_findString (const GContainer *array, const char *string) |
See if a string exists in a GContainer of strings (char *). | |
void | lutil_printIndented (int indent, int length, const char *string) |
Print a string to STDOUT indented and limited in per-line length. | |
gboolean | lutil_isCompletelyBlank (const char *input) |
Check if a string is completely whitespace. | |
void | lutil_strToLower (char *str) |
Convert all upper case letters to lower case in a string. | |
void | lutil_strToUpper (char *str) |
gboolean | lutil_containsAlpha (const char *str) |
gboolean | lutil_containsDigit (const char *str) |
GString * | lutil_uncompress (GString *data) |
char * | lutil_getTempFilename (void) |
Create a valid temporary filename. | |
gboolean | lutil_fileExists (const char *path) |
Check if a file exists. | |
gboolean | lutil_isDirectory (const char *path) |
Check if a "file" is actually a directory. | |
gint | lutil_gintCompare (gpointer p1, gpointer p2) |
Compare two gint pointers. | |
int | lutil_intcmp (int i1, int i2) |
Compare two ints. | |
char * | lutil_sizeToString (int size, int sigfig) |
Provides some simple convenience methods that could be applied to any project.
Definition in file util.h.
|
Output debugging messages.
Definition at line 81 of file util.h. Referenced by luau_checkForUpdates(), luau_copyDate(), luau_copyInterface(), luau_copyPackage(), luau_copyProgInfo(), luau_copyUpdate(), luau_downloadUpdate(), luau_getPackageURL(), luau_net_queryServer(), lutil_ftp_downloadToFile(), lutil_ftp_getURL(), lutil_gsplit(), parsePackage(), and parseUpdate(). |
|
Definition at line 61 of file util.h. Referenced by luau_parseUpdateFileXML(). |
|
Definition at line 62 of file util.h. Referenced by luau_parseUpdateFileXML(). |
|
|
|
Value: do { \ if (ptr != NULL) { g_free(ptr); } \ } while (0)
Definition at line 90 of file util.h. Referenced by luau_freeProgInfo(), luau_freeUpdateInfo(), and parsePackage(). |
|
Value: do { \ if (ptr != NULL) { g_string_free(ptr, boole); } \ } while (0)
|
|
temp directory
Definition at line 97 of file util.h. Referenced by lutil_getTempFilename(). |
|
Definition at line 412 of file util.c. Referenced by luau_versioncmp(). |
|
|
|
Create a new string.
Allocate memory for a string of length
Definition at line 85 of file util.c. Referenced by luau_install_deb(), luau_install_rpm(), luau_multPackageTypeString(), lutil_getTempFilename(), lutil_sizeToString(), lutil_strjoin(), and lutil_valistToString(). |
|
Check if a file exists. Use stat(2) to check if the given file exists. Note that this function will return TRUE if the path is actually a directory, but FALSE if an error such as "permission denied" or "too many symlinks" is returned, or if the file in question is a symlink to a non-existent file. Use stat(2) directly if more precision is necessary.
|
|
See if a string exists in a GContainer of strings (char *). Find if a certain string is contained in the given array. Does not ignore case, and does not ignore whitespace (or anything else).
Definition at line 298 of file util.c. References g_container_get_iter(), g_iterator_hasNext(), g_iterator_next(), and lutil_streq(). Referenced by luau_checkKeyword(). |
|
Create a valid temporary filename. Create a temporary filename using the current process ID, max 255 characters long.
Definition at line 511 of file util.c. References lutil_createString(), and TEMP_DIR. Referenced by luau_installUpdate(). |
|
Compare two gint pointers. Compare two gint pointers, returning another gint depending on their relation to one another.
Definition at line 569 of file util.c. References lutil_intcmp(). |
|
Split a string by character delim into a GContainer.
Split a string into an array of strings, separating by
Definition at line 240 of file util.c. References DBUGOUT, g_container_add(), g_container_new(), and GCONT_PTR_ARRAY. Referenced by luau_versioncmp(). |
|
Compare two ints. Compare two integers, return another integer depending on their relation to one another.
Definition at line 583 of file util.c. Referenced by luau_datecmp(), and lutil_gintCompare(). |
|
Check if a string is completely whitespace.
Definition at line 373 of file util.c. Referenced by luau_parseInterface(). |
|
Check if a "file" is actually a directory. Use stat(2) to check if the given pathname is a directory. Also returns false if the file doesn't even exist (see lutil_fileExists).
|
|
Like sprintf, but allocate memory for and return the string. Allocating printf. Takes arguments in same form as printf, but writes them to a newly allocated string, which is then returned. Returned string must be free'd.
Definition at line 139 of file util.c. References lutil_valistToString(). Referenced by luau_dateString(), luau_interfaceString(), and luau_progInfoString(). |
|
Print a string to STDOUT indented and limited in per-line length.
Print a long string to STDOUT using the specified indentation with output no longer than
This function is useful for outputting long strings to the terminal (
|
|
Convert a size (in bytes) to a human readable format, with Example:: lutil_sizeToString(1024*1024, 2) => 1.0M
Definition at line 605 of file util.c. References lutil_createString(). |
|
Check if two strings are equal, ignoring case. Compare two strings for case-insensitive equality using strcasecmp.
Definition at line 72 of file util.c. Referenced by luau_parseQuantDataType(). |
|
Check if two strings are equal. Compare two strings for equality using strcmp.
Definition at line 59 of file util.c. Referenced by luau_getUpdateInfo(), luau_net_downloadUpdate(), luau_net_queryServer(), luau_parsePkgType(), luau_unsetKeyword(), luau_versioncmp(), lutil_findString(), lutil_parse_parseSymbol(), lutil_parse_parseSymbolArray(), and parsePackage(). |
|
Join an array of strings together separated by the given delimiter.
Join an array of strings together with
Definition at line 194 of file util.c. References g_container_get_iter(), g_container_index(), g_iterator_hasNext(), g_iterator_next(), GContainer::len, and lutil_createString(). Referenced by luau_keywordsString(). |
|
Convert all upper case letters to lower case in a string.
Definition at line 394 of file util.c. Referenced by luau_versioncmp(). |
|
|
|
Definition at line 443 of file util.c. References ERROR. Referenced by luau_net_queryServer(). |
|
Take a va_list of what would be passed to a printf function and turn it into a newly allocated string. The resultant string must be free'd. Used by lutil_mprintf
Definition at line 278 of file util.c. References lutil_createString(). Referenced by lutil_error(), and lutil_mprintf(). |
|
Append any number of strings together into one. Take a variable list of strings and append them together into one new string.
Definition at line 99 of file util.c. References ERROR. Referenced by luau_downloadUpdate(). |