dev: norm
This commit is contained in:
parent
1c023df1ff
commit
a93af5c48f
4 changed files with 26 additions and 23 deletions
10
dev/norm.sh
10
dev/norm.sh
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Use the norminette but without all these rules that make coding harder.
|
||||
|
||||
norminette | grep -v \
|
||||
norminette $* | grep -v \
|
||||
"INVALID_HEADER
|
||||
VAR_DECL_START_FUNC
|
||||
EMPTY_LINE_FUNCTION
|
||||
|
@ -10,10 +10,10 @@ TOO_MANY_ARGS
|
|||
TOO_MANY_FUNCS
|
||||
TOO_MANY_LINES
|
||||
PREPROC_CONSTANT
|
||||
MACRO_FUNC_FORBIDDEN
|
||||
GLOBAL_VAR_DETECTED
|
||||
WRONG_SCOPE_COMMENT
|
||||
MULT_DECL_LINE
|
||||
GOTO_FBIDDEN
|
||||
LABEL_FBIDDEN
|
||||
TERNARY_FBIDDEN"
|
||||
FORBIDDEN
|
||||
FBIDDEN
|
||||
SPACE_EMPTY_LINE
|
||||
DECL_ASSIGN_LINE"
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
* with embedassets.sh.
|
||||
*/
|
||||
|
||||
#ifndef MLX3DS_ASSETS_H
|
||||
# define MLX3DS_ASSETS_H
|
||||
#ifndef MLX3DS_EMBEDDEDASSETS_H
|
||||
# define MLX3DS_EMBEDDEDASSETS_H
|
||||
|
||||
# include <string.h>
|
||||
|
||||
|
@ -21,12 +21,12 @@ typedef void *t_assetsocket;
|
|||
/// @brief Represents a file embedded with the program.
|
||||
typedef struct s_embeddedasset
|
||||
{
|
||||
/// @brief Path of the file, relative to the assets directory (`.+(/.+)+`).
|
||||
const char *name;
|
||||
/// @brief Size of the file content.
|
||||
size_t size;
|
||||
/// @brief Content of the file. NUL-terminated (data[size] is '\0').
|
||||
const char *data;
|
||||
/// @brief Path of the file, relative to the assets directory (`.+(/.+)+`).
|
||||
const char *name;
|
||||
/// @brief Size of the file content.
|
||||
size_t size;
|
||||
/// @brief Content of the file. NUL-terminated (data[size] is '\0').
|
||||
const char *data;
|
||||
} t_embeddedasset;
|
||||
|
||||
/// @brief Get an reference to the t_embeddedasset from its name.
|
||||
|
|
|
@ -21,32 +21,35 @@ typedef struct s_in_assetsocket
|
|||
// This function is implemented in embedassets.sh
|
||||
const t_embeddedasset *mlx3ds_assets_get(const char *name);
|
||||
|
||||
t_assetsocket mlx3ds_assets_open(const char *name) {
|
||||
t_assetsocket mlx3ds_assets_open(const char *name)
|
||||
{
|
||||
const t_embeddedasset *asset;
|
||||
t_in_assetsocket *r;
|
||||
|
||||
asset = mlx3ds_assets_get(name);
|
||||
if (!asset)
|
||||
return NULL;
|
||||
return (NULL);
|
||||
r = malloc(sizeof(t_in_assetsocket));
|
||||
if (!r)
|
||||
return NULL;
|
||||
return (NULL);
|
||||
r->asset = asset;
|
||||
r->i = 0;
|
||||
return r;
|
||||
return (r);
|
||||
}
|
||||
|
||||
size_t mlx3ds_assets_read(t_assetsocket asset, void *buf, size_t count) {
|
||||
t_in_assetsocket *asset_ = asset;
|
||||
size_t mlx3ds_assets_read(t_assetsocket asset, void *buf, size_t count)
|
||||
{
|
||||
t_in_assetsocket *asset_ = asset;
|
||||
|
||||
if (count > asset_->asset->size - asset_->i)
|
||||
count = asset_->asset->size - asset_->i;
|
||||
|
||||
memcpy(buf, asset_->asset->data + asset_->i, count);
|
||||
asset_->i += count;
|
||||
return count;
|
||||
return (count);
|
||||
}
|
||||
|
||||
void mlx3ds_assets_close(t_assetsocket asset) {
|
||||
void mlx3ds_assets_close(t_assetsocket asset)
|
||||
{
|
||||
free(asset);
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
/// @param msg Message to write. Must use less than 38 colons.
|
||||
void mlx3ds_internal_fatalerror(const char *msg);
|
||||
|
||||
struct s_internal_win;
|
||||
struct s_internal_win;
|
||||
|
||||
/// @brief Content of the mlx connection identifier.
|
||||
typedef struct s_internal_mlx
|
||||
{
|
||||
/// @brief is true after mlx_init() was called, is false before.
|
||||
bool is_init_called;
|
||||
bool is_init_called;
|
||||
/// @brief Window displayed on the top screen.
|
||||
struct s_internal_win *top_window;
|
||||
} t_internal_mlx;
|
||||
|
|
Loading…
Add table
Reference in a new issue