From 4ea499623ef279c0111be85a7c82398aa00add08 Mon Sep 17 00:00:00 2001 From: surtur Date: Thu, 5 Mar 2020 13:35:46 +0100 Subject: [PATCH] added project files and .drone.yml --- .drone.yml | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 5 +++ README.md | 2 +- main.c | 65 +++++++++++++++++++++++++++++++++++++ main.h | 8 +++++ minmax.c | 44 +++++++++++++++++++++++++ minmax.h | 10 ++++++ 7 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 .drone.yml create mode 100644 CMakeLists.txt create mode 100644 main.c create mode 100644 main.h create mode 100644 minmax.c create mode 100644 minmax.h diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..35f06a5 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,87 @@ +--- +kind: pipeline +name: testing-amd64 + +platform: + arch: amd64 + +steps: +- name: build + pull: always + image: immawanderer/archlinux-cdev + commands: + - cmake CMakeLists.txt + - make + + +--- +kind: pipeline +name: notifications + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +trigger: + branch: + - master + - "release/*" + event: + - push + - tag + status: + - success + - failure + +depends_on: + - testing-amd64 + +steps: + - name: discord + pull: always + image: appleboy/drone-discord:1.2.4 + settings: + message: "{{#success build.status}} āœ… Build #{{build.number}} of `{{repo.name}}` succeeded.\n\nšŸ“ Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\nšŸŒ {{ build.link }} {{else}} āŒ Build #{{build.number}} of `{{repo.name}}` failed.\n\nšŸ“ Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\nšŸŒ {{ build.link }} {{/success}}\n" + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + + +--- +kind: pipeline +name: notifications-cronbuild + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +trigger: + event: + - cron + cron: + - hourly + - hourly-build + status: + - success + - failure + +depends_on: + - testing-amd64 + +steps: + - name: discord + pull: always + image: appleboy/drone-discord:1.2.4 + settings: + message: "{{#success build.status}} āœ… Build #{{build.number}} of `{{repo.name}}` succeeded.\n\nšŸ“ Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\nšŸŒ {{ build.link }} {{else}} āŒ Build #{{build.number}} of `{{repo.name}}` failed.\n\nšŸ“ Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\nšŸŒ {{ build.link }} {{/success}}\n" + webhook_id: + from_secret: discord_webhook_hourly_id + webhook_token: + from_secret: discord_webhook_hourly_token diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4fd2c95 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.5) + +project(pjc-0x03 LANGUAGES C) + +add_executable(pjc-0x03 main.c minmax.c minmax.h main.h) diff --git a/README.md b/README.md index 55ab07d..ec3199d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # pjc-0x03 -[![works badge](https://cdn.jsdelivr.net/gh/nikku/works-on-my-machine@v0.2.0/badge.svg)](https://github.com/nikku/works-on-my-machine) +[![Build Status](https://drone.dotya.ml/api/badges/wanderer/PJC-0x03/status.svg?ref=refs/heads/master)](https://drone.dotya.ml/wanderer/PJC-0x03) [![works badge](https://cdn.jsdelivr.net/gh/nikku/works-on-my-machine@v0.2.0/badge.svg)](https://github.com/nikku/works-on-my-machine) sawce of project 0x03 for c programming classes diff --git a/main.c b/main.c new file mode 100644 index 0000000..53057f3 --- /dev/null +++ b/main.c @@ -0,0 +1,65 @@ +#include +#include "main.h" +#include "minmax.h" + +int get_userguess(){ + int x = -1; + int ok = -1; + while( ok != 1){ + ok = scanf("%d", &x); + if(ok == EOF){ + printf("\ncaught Ctrl+D...\n"); + ok = 1; + x = 2; + break; + } + if(ok == 0){ + while (fgetc(stdin) != '\n'){ + } + printf("[*] give me a correct value\n"); + printf("[*] stop gibbering around\n my guess >>> "); + } + } + return x; +} + +int lemmego(){ + printf("[*] you wished to go, quitting...\n"); + return EXIT_SUCCESS; +} + +int main() +{ + int selection, max, min = 0; + + while ( selection != 8 ) { + printf("\npick a choice\n"); + printf("1 - max\n" + "2 - min\n" + "3 - multiplication\n" + "4 - division\n" + "8 - quit\n" + ">> "); + + selection = get_userguess(); + + switch ( selection ) { + case 1: + max = maximum(); + printf("maximum je %d\n", max); + break; + case 2: + min = minimum(); + printf("minumum je %d\n", min); + break; + case 8: + lemmego(); + return 9000; + default: + printf("invalid option\n"); + selection = 0; + break; + } + } + return 0; +} diff --git a/main.h b/main.h new file mode 100644 index 0000000..af17bfa --- /dev/null +++ b/main.h @@ -0,0 +1,8 @@ +#ifndef PJC_0X03_MAIN_H +#define PJC_0X03_MAIN_H + +int get_userguess(); + +int lemmego(); + +#endif //PJC_0X03_MAIN_H diff --git a/minmax.c b/minmax.c new file mode 100644 index 0000000..dd15b60 --- /dev/null +++ b/minmax.c @@ -0,0 +1,44 @@ +#include +#include "minmax.h" +#include "main.h" + +int maximum() +{ + int x, y, z; + printf("Zadejte 3 cisla oddelena mezerou: "); + printf("** printmax **\n"); + + scanf("%d%d%d", &x, &y, &z); + int max = x; + if ( y > max ) { + max = y; + } + if ( z > max ) { + max = z; + } + // pokud je y vetsi, ulozime jej do max + // pokud je z vetsi, ulozime jej do max + return max; +} + +int minimum() +{ + int selection, max, min = 0; + + while ( selection != 8 ) { + int x, y, z; + printf("Zadejte 3 cisla oddelena mezerou: "); + printf("** printmin **\n"); + + scanf("%d%d%d", &x, &y, &z); + int min = x; + + if ( y < min ) { + min = y; + } + if ( z < min ) { + min = z; + } + } + return min; +} \ No newline at end of file diff --git a/minmax.h b/minmax.h new file mode 100644 index 0000000..6c0a0c9 --- /dev/null +++ b/minmax.h @@ -0,0 +1,10 @@ +#ifndef PJC_0X03_MINMAX_H +#define PJC_0X03_MINMAX_H + +//int maximum(int x, int y, int z); +int maximum(); + +//int minimum(int x, int y, int z); +int minimum(); + +#endif //PJC_0X03_MINMAX_H