diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 101 |
1 files changed, 51 insertions, 50 deletions
@@ -20,28 +20,29 @@ #include <time.h> #include <math.h> -// -// Converts the given day count to seconds (multiplies by the number of seconds -// in a day, 86400). -// -// @param days Day count to convert to seconds -// -// @return long Number of total seconds in the given day duration -// + +/** + * Converts the given day count to seconds (multiplies by the number of seconds + * in a day, 86400). + * + * @param days Day count to convert to seconds + * + * @return long Number of total seconds in the given day duration + */ long days_to_seconds(int days) { return days * 86400; } -// -// Converts the given "string integer" to a long datatype. This is useful for -// programs that take command line arguments from the user and they need to -// treats those arguments like actual numbers. -// -// @param intstr Integer string -// -// @return long The integer represented by the given string -// +/** + * Converts the given "string integer" to a long datatype. This is useful for + * programs that take command line arguments from the user and they need to + * treats those arguments like actual numbers. + * + * @param intstr Integer string + * + * @return long The integer represented by the given string + */ long ctoi(char* intstr) { // TODO: This doesn't work yet int i = 0; @@ -60,9 +61,9 @@ long ctoi(char* intstr) { } -// -// -// +/** + * TODO + */ int get_user_home(char* out) { if(getenv("HOME") != NULL) { strcpy(out, getenv("HOME")); @@ -73,13 +74,13 @@ int get_user_home(char* out) { } -// -// Writes the current timestamp to the specified lastlogin file -// -// @param path Path to the lastlogin file -// -// @return int Status of the write operation -// +/** + * Writes the current timestamp to the specified lastlogin file + * + * @param path Path to the lastlogin file + * + * @return int Status of the write operation + */ int write_lastlogin(char* path) { FILE* f = fopen(path, "w+"); @@ -94,14 +95,14 @@ int write_lastlogin(char* path) { } -// -// Gets the time_t value contained in the specified lastlogin file. -// -// @param lastlogin_path Path to the lastlogin file to be read -// @param lastlogin Output time_t variable -// -// @return int Status of reading the lastlogin file -// +/** + * Gets the time_t value contained in the specified lastlogin file. + * + * @param lastlogin_path Path to the lastlogin file to be read + * @param lastlogin Output time_t variable + * + * @return int Status of reading the lastlogin file + */ int get_lastlogin(char* lastlogin_path, time_t* lastlogin) { // File pointer to lastlogin file (used for reading and writing) FILE* lastlogin_file; @@ -123,18 +124,18 @@ int get_lastlogin(char* lastlogin_path, time_t* lastlogin) { } -// -// Executes the specified command, printing the output. -// Note that this does read the calling shell's environmental variables, and so -// absolute paths are not necessary if the command targets an executable in -// PATH. -// -// @param cmd Command to be executed and output to be printed -// -// @return int Execution status of the command -// Note that if the command fails execution at start, -1 is -// returned. -// +/** + * Executes the specified command, printing the output. + * Note that this does read the calling shell's environmental variables, and so + * absolute paths are not necessary if the command targets an executable in + * PATH. + * + * @param cmd Command to be executed and output to be printed + * + * @return int Execution status of the command + * Note that if the command fails execution at start, -1 is + * returned. + */ int exec_cmd(char* cmd) { FILE* p = popen(cmd, "r"); if(p == NULL) { return -1; } @@ -150,9 +151,9 @@ int exec_cmd(char* cmd) { } -// -// Ye olde main function -// +/** + * Ye olde main function + */ int main(int argc, char* argv[]) { char home[128]; int days; |