Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Migration to C Language #14

Draft
wants to merge 17 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/workflows/baseshift-develop.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
name: baseshift (develop)
name: BaseShift (develop)

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21.1'
- name: Build
run: go build -v ./...
run: make build
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Kent Louise Tonino
Copyright (c) 2023 Kent Tonino

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build:
gcc -g -o bin/baseshift src/main.c -lm

debug:
make build
gdb bin/baseshift

baseshift:
make build
bin/baseshift
Binary file added bin/baseshift
Binary file not shown.
14 changes: 0 additions & 14 deletions docs/guide-deployment.md

This file was deleted.

31 changes: 0 additions & 31 deletions docs/guide-number-system-binary.md

This file was deleted.

Binary file removed docs/image-system-design.gif
Binary file not shown.
Binary file removed docs/image-table-binary-number.jpg
Binary file not shown.
3 changes: 0 additions & 3 deletions go.mod

This file was deleted.

1 change: 0 additions & 1 deletion main.go

This file was deleted.

3 changes: 3 additions & 0 deletions run-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

make build
3 changes: 3 additions & 0 deletions run-debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

make debug
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

go run main.go
make baseshift
6 changes: 6 additions & 0 deletions src/displays/ansi_color.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define BLUE "\e[0;34m"
#define GREEN "\e[0;32m"
#define YELLOW "\e[0;33m"
#define RED "\e[0;31m"
#define WHITE "\e[0;37m"
#define RESET "\e[0m"
18 changes: 18 additions & 0 deletions src/displays/app_description.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "ansi_color.h"
#include "escape_sequence.h"

void app_description(void) {
printf("%-15s--------------------------------------------------------%s",
BLUE, RESET);
add_new_line();
add_new_line();
printf("%-38sBaseShift%s", GREEN, RESET);
add_new_line();
add_new_line();
printf("%-17sA CLI tool that converts a number system to another.%s", WHITE,
RESET);
add_new_line();
add_new_line();
printf("%-15s--------------------------------------------------------%s",
BLUE, RESET);
}
18 changes: 0 additions & 18 deletions src/displays/app_description.go

This file was deleted.

7 changes: 7 additions & 0 deletions src/displays/app_description.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef APP_DESCRIPTION_H
#define APP_DESCRIPTION_H
#include "app_description.c"

extern void app_description(void);

#endif
26 changes: 26 additions & 0 deletions src/displays/app_options.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "ansi_color.h"
#include "escape_sequence.h"
#include <stdlib.h>

char *format_option(int num) {
char *formatted_option = malloc(sizeof(char) * 50);

// Write the formatted output in formatted_option variable.
sprintf(formatted_option, "%-16s[%s %s%d%s %s]%s", BLUE, RESET, GREEN, num,
RESET, BLUE, RESET);

return formatted_option;
}

void app_options(void) {
printf("%s Convert Binary", format_option(1));
add_new_line();
printf("%s Convert Decimal", format_option(2));
add_new_line();
printf("%s Convert Octal", format_option(3));
add_new_line();
printf("%s Convert Hexadecimal", format_option(4));
add_new_line();
printf("%s Exit", format_option(5));
add_new_line();
}
31 changes: 0 additions & 31 deletions src/displays/app_options.go

This file was deleted.

7 changes: 7 additions & 0 deletions src/displays/app_options.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef APP_OPTIONS_H
#define APP_OPTIONS_H
#include "app_options.c"

extern void app_options(void);

#endif
3 changes: 3 additions & 0 deletions src/displays/clear_terminal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <stdlib.h>

void clear_terminal(void) { system("clear"); }
7 changes: 7 additions & 0 deletions src/displays/clear_terminal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef CLEAR_TERMINAL_H
#define CLEAR_TERMINAL_H
#include "clear_terminal.c"

extern void clear_terminal(void);

#endif
4 changes: 4 additions & 0 deletions src/displays/error_message.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "ansi_color.h"
#include <stdio.h>

void error_message(char *message) { printf("%-16s%s%s", RED, message, RESET); }
7 changes: 7 additions & 0 deletions src/displays/error_message.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef ERROR_MESSAGE_H
#define ERROR_MESSAGE_H
#include "error_message.c"

extern void error_message(char *message);

#endif
4 changes: 4 additions & 0 deletions src/displays/escape_sequence.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <stdio.h>

void add_new_line(void) { printf("\n"); }
void add_new_tab(void) { printf("\t"); }
8 changes: 8 additions & 0 deletions src/displays/escape_sequence.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef ESCAPE_SEQUENCE_H
#define ESCAPE_SEQUENCE_H
#include "escape_sequence.c"

extern void add_new_line(void);
extern void add_new_tab(void);

#endif
103 changes: 0 additions & 103 deletions src/displays/options_description.go

This file was deleted.

11 changes: 0 additions & 11 deletions src/displays/options_instruction.go

This file was deleted.

11 changes: 0 additions & 11 deletions src/errors/invalid_option.go

This file was deleted.

Loading