Skip to content

Commit

Permalink
add snap build
Browse files Browse the repository at this point in the history
  • Loading branch information
Joker2770 committed Aug 12, 2019
1 parent ee6d387 commit 5285b9e
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 14 deletions.
17 changes: 17 additions & 0 deletions SnapBuild/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: morse-encode-and-decode # you probably want to 'snapcraft register <name>'
version: '0.2' # just for humans, typically '1.2+git' or '1.3.2'
summary: Coding or decoding with morse # 79 char long summary
description: |
A simple command-line tool, create by Joker2770<https://github.com/Joker2770/morse-encode-and-decode>.
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
morse-encode-and-decode:
command: bin/morse-encode-and-decode

parts:
morse-encode-and-decode:
# See 'snapcraft plugins'
plugin: dump
75 changes: 61 additions & 14 deletions src/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,77 @@ Public License instead of this License.
#define BUF_LEN 300


int main() {
int main(int argc, char **argv) {

if(argc < 2)
{
printf(
"\n--list (-l) List command."
"\n--encode (-e) Encode string. e.g, MorseCodeTest -e \"Hello world!\""
"\n--decode (-d) Decode Morse code. e.g, MorseCodeTest -d \".- -... -.-. \""
"\n\n");
exit(0);
}

char *mystr = "abcdefghijklmnopqrstuvwxyz0123456789.:,;?='/!-_\"()$&@";
char mor[BUF_LEN];
char str[BUF_LEN];
char out[BUF_LEN];
memset(out, 0, BUF_LEN);
memset(mor, 0, BUF_LEN);
memset(str, 0, BUF_LEN);

printf("base string:\n%s\n", mystr);
if(strcmp(*(argv+1), "-l") == 0 || strcmp(*(argv+1), "--list") == 0)
{

//TO LOWCASE
str2lowcase(mystr, out, BUF_LEN);
char *mystr = "abcdefghijklmnopqrstuvwxyz0123456789.:,;?='/!-_\"()$&@";
memset(out, 0, BUF_LEN);
memset(mor, 0, BUF_LEN);
memset(str, 0, BUF_LEN);

printf("base string:\n%s\n", mystr);

//TO LOWCASE
str2lowcase(mystr, out, BUF_LEN);

//TO MORSE STRING
String2MorseString(out , mor, BUF_LEN);
printf("\nget morse code string:\n%s\n" , mor);
//TO MORSE STRING
String2MorseString(out , mor, BUF_LEN);
printf("\nget morse code string:\n%s\n" , mor);


//TO NORMAL STRING
MorseString2String(mor, str, BUF_LEN);
printf("\nget decode string:\n%s\n", str);
//TO NORMAL STRING
MorseString2String(mor, str, BUF_LEN);
printf("\nget decode string:\n%s\n", str);
}

if(strcmp(*(argv+1), "--encode") == 0 || strcmp(*(argv+1), "-e") == 0)
{
memset(out, 0, BUF_LEN);
memset(mor, 0, BUF_LEN);
memset(str, 0, BUF_LEN);

printf("base string:\n%s\n", *(argv+2));

//TO LOWCASE
str2lowcase(*(argv+2), out, BUF_LEN);

//TO MORSE STRING
String2MorseString(out , mor, BUF_LEN);
printf("\nget morse code string:\n%s\n" , mor);

}

if(strcmp(*(argv+1), "--decode") == 0 || strcmp(*(argv+1), "-d") == 0)
{
memset(out, 0, BUF_LEN);
memset(mor, 0, BUF_LEN);
memset(str, 0, BUF_LEN);

printf("base string:\n%s\n", *(argv+2));

//TO NORMAL STRING
MorseString2String(*(argv+2), str, BUF_LEN);
printf("\nget decode string:\n%s\n", str);

}


return 0;
}

0 comments on commit 5285b9e

Please sign in to comment.