Skip to content

Commit

Permalink
maint: Rename some source files
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Nov 2, 2024
1 parent f3f6feb commit ceb5921
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif

#include "btrfs.h"
#include "messages_rmw.h"
#include "messages.h"

bool
is_btrfs(const char *path)
Expand Down
3 changes: 1 addition & 2 deletions src/config_rmw.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "btrfs.h"
#include "config_rmw.h"
#include "utils_rmw.h"
#include "strings_rmw.h"
#include "utils.h"
#include "main.h"

// #include <sys/sysmacros.h> // for major() and minor()
Expand Down
4 changes: 2 additions & 2 deletions src/config_rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#pragma once

#include "trashinfo_rmw.h"
#include "trashinfo.h"
#include "parse_cli_options.h"
#include "messages_rmw.h"
#include "messages.h"
#include "canfigger.h"
#include "main.h"

Expand Down
3 changes: 3 additions & 0 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "strings_rmw.h"

#ifdef ENABLE_NLS
#include <locale.h>
Expand Down
71 changes: 67 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,76 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "globals.h"
#include "main.h"
#include "utils_rmw.h"
#include "restore_rmw.h"
#include "utils.h"
#include "restore.h"
#include "config_rmw.h"
#include "purging_rmw.h"
#include "purging.h"
#include "strings_rmw.h"
#include "messages_rmw.h"
#include "messages.h"
#include "btrfs.h"
#include "trashinfo.h"


/*!
* Assigns a time string to *tm_str based on the format requested
*/
static void
set_time_string(char *tm_str, const size_t len, const char *format,
time_t time_t_now)
{
struct tm result;
if (localtime_r(&time_t_now, &result) == NULL)
{
fputs
("Error: localtime_r() failed for time_t value beyond 32-bit limit.\n",
stderr);
exit(EXIT_FAILURE);
}
strftime(tm_str, len, format, &result);
trim_whitespace(tm_str);

return;
}

/*!
* Returns a formatted string based on whether or not
* a fake year is requested at runtime. If a fake-year is not requested,
* the returned string will be based on the local-time of the user's system.
*/
static void
set_which_deletion_date(char *format)
{
char *fake_year = getenv("RMW_FAKE_YEAR");
bool valid_value = false;
if (fake_year != NULL)
{
valid_value = strcasecmp(fake_year, "true") == 0;
puts("RMW_FAKE_YEAR:true");
}
sn_check(snprintf
(format, LEN_MAX_DELETION_DATE, "%s",
valid_value ? "1999-%m-%dT%T" : "%FT%T"), LEN_MAX_DELETION_DATE);

return;
}


void
init_time_vars(st_time *x)
{
x->now = time(NULL);
// x->now = 0x80000000;

set_which_deletion_date(x->t_fmt);

set_time_string(x->deletion_date, LEN_MAX_DELETION_DATE, x->t_fmt, x->now);

set_time_string(x->suffix_added_dup_exists,
LEN_MAX_TIME_STR_SUFFIX, "_%H%M%S-%y%m%d", x->now);

return;
}


static int
process_mrl(st_waste *waste_head,
Expand Down
10 changes: 5 additions & 5 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ endif
src = [
'globals.c',
'btrfs.c',
'restore_rmw.c',
'restore.c',
'config_rmw.c',
'parse_cli_options.c',
'strings_rmw.c',
'purging_rmw.c',
'messages_rmw.c',
'purging.c',
'messages.c',
'time_rmw.c',
'trashinfo_rmw.c',
'utils_rmw.c',
'trashinfo.c',
'utils.c',
]

# Used for btrfs functions
Expand Down
2 changes: 1 addition & 1 deletion src/messages_rmw.c → src/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "messages_rmw.h"
#include "messages.h"

void
print_msg_error(void)
Expand Down
3 changes: 2 additions & 1 deletion src/messages_rmw.h → src/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "globals.h"
#include "strings_rmw.h"

#ifndef BUFSIZ
#define BUFSIZ 8192
Expand Down
9 changes: 4 additions & 5 deletions src/purging_rmw.c → src/purging.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "globals.h"
#include "parse_cli_options.h"
#include "purging_rmw.h"
#include "messages_rmw.h"
#include "strings_rmw.h"
#include "utils_rmw.h"
#include "trashinfo_rmw.h"
#include "purging.h"
#include "messages.h"
#include "utils.h"
#include "trashinfo.h"


enum
Expand Down
File renamed without changes.
7 changes: 3 additions & 4 deletions src/restore_rmw.c → src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "parse_cli_options.h"
#include "btrfs.h"
#include "config_rmw.h"
#include "restore_rmw.h"
#include "utils_rmw.h"
#include "messages_rmw.h"
#include "restore.h"
#include "utils.h"
#include "messages.h"

#define MENU_KEY_ENTER '\n'
#define MENU_KEY_ESC 27
Expand Down
4 changes: 3 additions & 1 deletion src/restore_rmw.h → src/restore.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#if defined HAVE_NCURSESW_MENU_H
#include <ncursesw/menu.h>
#elif defined HAVE_NCURSES_MENU_H
Expand All @@ -42,7 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#error "SysV or X/Open-compatible Curses header file required"
#endif

#include "trashinfo_rmw.h"
#include "trashinfo.h"
#include "parse_cli_options.h"

#define CTRLD 4
Expand Down
5 changes: 2 additions & 3 deletions src/strings_rmw.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif

#include <ctype.h>
#include "strings_rmw.h"
#include "messages_rmw.h"
#include "utils_rmw.h"
#include "messages.h"
#include "utils.h"


bool r_buffer_overrun = false;
Expand Down
4 changes: 4 additions & 0 deletions src/strings_rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <ctype.h>
#include <libgen.h>
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
#include <stdbool.h>
#include <sys/types.h>

#define sn_check(a, b) real_sn_check(a, b, __func__, __LINE__)

Expand Down
5 changes: 2 additions & 3 deletions src/time_rmw.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "globals.h"
#include "time_rmw.h"
#include "strings_rmw.h"
#include "trashinfo_rmw.h"
#include "messages_rmw.h"
#include "trashinfo.h"
#include "messages.h"

/*!
* Assigns a time string to *tm_str based on the format requested
Expand Down
6 changes: 3 additions & 3 deletions src/trashinfo_rmw.c → src/trashinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "trashinfo_rmw.h"
#include "utils_rmw.h"
#include "messages_rmw.h"
#include "trashinfo.h"
#include "utils.h"
#include "messages.h"

#define TI_LINE_COUNT 3

Expand Down
File renamed without changes.
7 changes: 3 additions & 4 deletions src/utils_rmw.c → src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "globals.h"
#endif

#include "utils_rmw.h"
#include "strings_rmw.h"
#include "messages_rmw.h"
#include "utils.h"
#include "messages.h"


/*
Expand Down Expand Up @@ -499,7 +498,7 @@ count_chars(const char c, const char *str)
#ifdef TEST_LIB

#include "test.h"
#include "purging_rmw.h"
#include "purging.h"


static void
Expand Down
2 changes: 1 addition & 1 deletion src/utils_rmw.h → src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <sys/stat.h>
#include <unistd.h>

#include "trashinfo_rmw.h"
#include "trashinfo.h"

enum
{
Expand Down
2 changes: 1 addition & 1 deletion test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if faketime.found()
add_test_setup('epochalypse', exe_wrapper: [faketime, '-f', '+14y'])
endif

test_cases = ['strings_rmw', 'utils_rmw', 'trashinfo_rmw', 'restore_rmw']
test_cases = ['strings_rmw', 'utils', 'trashinfo', 'restore']

scripts = ['test_basic.sh', 'test_purging.sh', 'test_restore.sh']

Expand Down

0 comments on commit ceb5921

Please sign in to comment.