cleanup, license

This commit is contained in:
stacksmith 2022-02-04 14:01:41 -05:00
parent daa9fee4c4
commit ef93a77a37
2 changed files with 34 additions and 5 deletions

29
LICENSE Normal file
View File

@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2022, entity known as stacksmith
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -3,7 +3,7 @@
#include <ctype.h>
#include <termios.h>
#include <unistd.h>
//https://gist.github.com/ibaned/41481b2fdddbb61a4291
#include "eleven.h"
const char* tochar(int val){
@ -61,14 +61,14 @@ int read_move(void){
static struct termios backup;
static struct termios current;
void take_stdin(void){
void term_start(void){
tcgetattr(STDIN_FILENO, &backup);
current = backup;
current.c_lflag &= (~ICANON & ~ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &current);
}
void give_stdin(void){
void term_end(void){
tcsetattr(STDIN_FILENO, TCSANOW, &backup);
}
@ -80,7 +80,7 @@ int main(){
srand(time(0));
init(tiles);
print(tiles);
take_stdin();
term_init();
while ((c = read_move()) != EOF) {
if(move(tiles, c)){
moves++;
@ -93,7 +93,7 @@ int main(){
}
}
printf("%d moves\n",moves);
give_stdin();
term_end();
return 0;
}