Skip to content

Commit

Permalink
Merge branch 'schedule'
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-speller committed Apr 11, 2023
2 parents e896950 + 73cfcbe commit a75b771
Show file tree
Hide file tree
Showing 49 changed files with 2,493 additions and 62 deletions.
5 changes: 3 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"name": "default",
"includePath": [
"src",
"3rd-party/cron/include",
"3rd-party/optparse/include",
"3rd-party/yaml-cpp/include"
],
"intelliSenseMode": "linux-gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17"
"cStandard": "c17",
"cppStandard": "c++17"
}
],
"version": 4
Expand Down
76 changes: 75 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"configurations": [
{
"name": "Atone: Debug",
"preLaunchTask": "Atone: Build (debug)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/debug/bin/atone",
Expand All @@ -23,10 +24,83 @@
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set the output of numbers to hexadecimal",
"text": "set output-radix 16"
}
],
"preLaunchTask": "Atone: Build (debug)",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "Atone: Debug In Container (Debian)",
"preLaunchTask": "Atone: Build (debug in container - Debian)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/debug-docker/debian/debug/bin/atone",
"cwd": "${workspaceFolder}",
"args": [
"--config=${workspaceFolder}/sample/config-file/atone.yaml"
],
"stopAtEntry": false,
"environment": [],
"externalConsole": true,
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "docker",
"pipeArgs": [
"run",
"--privileged",
"-v", "${workspaceFolder}:${workspaceFolder}",
"--name", "atone_debug_debian",
"--rm",
"-w", "${workspaceFolder}",
"-i", "atone_debug_debian",
"sh", "-c"
],
"pipeCwd": "${workspaceRoot}"
},
"MIMode": "gdb",
"setupCommands": [{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}],
},
{
"name": "Atone: Debug In Container (Alpine)",
"preLaunchTask": "Atone: Build (debug in container - Alpine)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/debug-docker/alpine/debug/bin/atone",
"cwd": "${workspaceFolder}",
"args": [
"--config=${workspaceFolder}/sample/config-file/atone.yaml"
],
"stopAtEntry": false,
"environment": [],
"externalConsole": true,
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "docker",
"pipeArgs": [
"run",
"--privileged",
"-v", "${workspaceFolder}:${workspaceFolder}",
"--name", "atone_debug_alpine",
"--rm",
"-w", "${workspaceFolder}",
"-i", "atone_debug_alpine",
"sh", "-c"
],
"pipeCwd": "${workspaceRoot}"
},
"MIMode": "gdb",
"setupCommands": [{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}],
}
]
}
152 changes: 152 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,158 @@
"kind": "build",
"isDefault": true
},
},
// Debian
{
"label": "Atone: Build (debug in container - Debian)",
"dependsOn": [ "Atone: Build Debug Container Image (Debian)" ],
"type": "shell",
"command": "docker",
"args": [
// docker
"run",
"--privileged",
"--volume", "${workspaceFolder}:${workspaceFolder}",
"atone_debug_debian",
// make
"make",
"-C", "${workspaceFolder}",
"DEBUG=1",
"ATONE_DEVELOPMENT_MODE=1",
"BUILDDIR=build/debug-docker/debian"
],
"group": {
"kind": "build",
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
},
{
"label": "Atone: Clean (debug in container - Debian)",
"dependsOn": [ "Atone: Build Debug Container Image (Debian)" ],
"type": "shell",
"command": "docker",
"args": [
// docker
"run",
"--privileged",
"--volume", "${workspaceFolder}:${workspaceFolder}",
"atone_debug_debian",
// make
"make",
"-C", "${workspaceFolder}",
"DEBUG=1",
"BUILDDIR=build/debug-docker/debian",
"clean-all"
],
"group": {
"kind": "none",
},
},
{
"label": "Atone: Build Debug Container Image (Debian)",
"type": "shell",
"command": "docker",
"args": [
// docker
"build",
"--tag", "atone_debug_debian",
"-",
"<",
"${workspaceFolder}/Dockerfile.debug-debian"
],
"group": {
"kind": "build",
}
},
// Alpine
{
"label": "Atone: Build (debug in container - Alpine)",
"dependsOn": [ "Atone: Build Debug Container Image (Alpine)" ],
"type": "shell",
"command": "docker",
"args": [
// docker
"run",
"--privileged",
"--volume", "${workspaceFolder}:${workspaceFolder}",
"atone_debug_alpine",
// make
"make",
"-C", "${workspaceFolder}",
"DEBUG=1",
"ATONE_DEVELOPMENT_MODE=1",
"BUILDDIR=build/debug-docker/alpine"
],
"group": {
"kind": "build",
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
},
{
"label": "Atone: Clean (debug in container - Alpine)",
"dependsOn": [ "Atone: Build Debug Container Image (Alpine)" ],
"type": "shell",
"command": "docker",
"args": [
// docker
"run",
"--privileged",
"--volume", "${workspaceFolder}:${workspaceFolder}",
"atone_debug_alpine",
// make
"make",
"-C", "${workspaceFolder}",
"DEBUG=1",
"BUILDDIR=build/debug-docker/alpine",
"clean-all"
],
"group": {
"kind": "none",
},
},
{
"label": "Atone: Build Debug Container Image (Alpine)",
"type": "shell",
"command": "docker",
"args": [
// docker
"build",
"--tag", "atone_debug_alpine",
"-",
"<",
"${workspaceFolder}/Dockerfile.debug-alpine"
],
"group": {
"kind": "build",
}
}
],
"version": "2.0.0"
Expand Down
1 change: 1 addition & 0 deletions 3rd-party/cron/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
108 changes: 108 additions & 0 deletions 3rd-party/cron/include/cronutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright (c) Rodrigo Speller. All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

#ifndef CRONUTILS_H
#define CRONUTILS_H

#ifndef CRON_API_EXPORT

#ifdef __cplusplus
#define CRON_API_EXPORT extern "C"
#else
#define CRON_API_EXPORT
#endif

#endif

#include <time.h>

/**
* Cron expression state.
*
* This struct is opaque and should not be accessed directly.
*/
typedef struct cron_expr_t {
void *expr_st_ptr;
} cron_expr_t;

/**
* Cron time state.
*
* This struct is opaque and should not be accessed directly.
*/
typedef struct cron_time_t {
void *time_st_ptr;
} cron_time_t;

/**
* Allocate a new cron expression state.
*/
CRON_API_EXPORT
cron_expr_t *cron_expr_alloc(const cron_expr_t *const clone_expr_ptr);

/**
* Free a cron expression state.
*/
CRON_API_EXPORT
void cron_expr_free(cron_expr_t *expr_ptr);

/**
* Parse a cron expression string into a cron expression state. If an
* error occurs, the error_func is called with the error cause message.
*/
CRON_API_EXPORT
void cron_expr_parse(
char const *expr_str,
cron_expr_t *expr_ptr,
void (*error_func)(const char *));

/**
* Match a cron expression state against a cron time state to determine
* if the time matches the expression.
*/
CRON_API_EXPORT
int cron_expr_match(
const cron_expr_t *expr_ptr,
const cron_time_t *time_ptr);

/**
* Match a cron expression state to determine if that expression matches
* the "@reboot" expression. This is a special expression that matches
* only once, when the cron is started.
*/
CRON_API_EXPORT
int cron_expr_match_reboot(const cron_expr_t *expr_ptr);

/**
* Allocate a new cron time state. If 'clone_time_ptr' is not NULL, the
* new cron time state will be initialized as a clone of the given cron
* time state.
*/
CRON_API_EXPORT
cron_time_t *cron_time_alloc(const cron_time_t *const clone_time_ptr);

/**
* Free a cron time state.
*/
CRON_API_EXPORT
void cron_time_free(cron_time_t *time_ptr);

/**
* Set the time of a cron time state.
*/
CRON_API_EXPORT
void cron_time_set(cron_time_t *time_ptr, const time_t *timer);

/**
* Compare two cron time states.
*/
CRON_API_EXPORT
int cron_time_cmp(const cron_time_t *const a, const cron_time_t *const b);

/**
* Increment a cron time state by one minute.
*/
CRON_API_EXPORT
void cron_time_inc(cron_time_t *const cron_time);

#endif
Loading

0 comments on commit a75b771

Please sign in to comment.