diff --git a/Makefile b/Makefile index 7317f6d..976e885 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile for pastebincl (command-line pastebin) by BASTIAN Théophile (aka Tobast) -ENC_KEY=`./genkey.py` +ENC_KEY=`python genkey.py` CXX=g++ CXXFLAGS=-Wall -Werror -O2 @@ -8,15 +8,20 @@ CXXLIBS=-lcurl TARGET=pastebincl OBJS=CurlPost.o func.o main.o ParameterRead.o ConfigRead.o -all: checkdevcode $(TARGET) +all: inputdevcode checkdevcode $(TARGET) + cp $(TARGET) ../ -#checkdevcode: -# @if [[ ! -f data_devcode.h ]]; then echo -e "\nERROR: No 'data_devcode.h' file (common error). Please read \"COMPILE.txt\" for more help.\n" ; false ; fi -# @if (( `cat data_devcode.h | grep -c '#define DEVELOPPER_CODE ""'` != 0 )); then echo -e "\nERROR: 'DEVELOPPER_CODE' undefined (common error). Please read \"COMPILE.txt\" for more help.\n" ; false ; fi +inputdevcode: + @if [[ ! -f data_devcode.h ]]; then cp data_devcode_default.h data_devcode.h; fi + @if (( `cat data_devcode.h | grep -c '#define DEVELOPPER_CODE ""'` != 0 )); then echo -e "\n" ; bash input_devcode.sh; fi + +checkdevcode: + @if [[ ! -f data_devcode.h ]]; then echo -e "\nERROR: No 'data_devcode.h' file (common error). Please read \"COMPILE.txt\" for more help.\n" ; false ; fi + @if (( `cat data_devcode.h | grep -c '#define DEVELOPPER_CODE ""'` != 0 )); then echo -e "\nERROR: 'DEVELOPPER_CODE' undefined (common error). Please read \"COMPILE.txt\" for more help.\n" ; false ; fi #### Useful while developping. To enable it, uncomment and add it as a dependence of 'all' #### -makeuser: - ./pastebincl --usergen < userinput &> /dev/null +#makeuser: +# ./pastebincl --usergen < userinput &> /dev/null $(TARGET): $(OBJS) $(CXX) $(CXXLIBS) $^ $(CXXFLAGS) -o $@ diff --git a/input_devcode.sh b/input_devcode.sh new file mode 100755 index 0000000..f92cab0 --- /dev/null +++ b/input_devcode.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +while true; do + + echo "Enter your Pastebin Developper API Key (see http://pastebin.com/api), or leave blank to use the default one (may not work):" + read input + + if [ -z $input ] ; then + input=`wget -qO - http://tobast.fr/ressources/pastebin_devkey` + + if (( ! `echo $input | grep -ce "[0-9a-f]\{32\}"` > 0 )) ; then + echo -e "\nERROR: Cannot obtain the default Developper API Key ! Please re-try with your API key.\n" + else + break + fi + else + if (( ! `echo $input | grep -ce "[0-9a-f]\{32\}"` > 0 )) ; then + echo -e "\nERROR: Wrong API key, please re-try.\n" + else + break + fi + fi +done + +sed -ire "49s/\"\".*$/\"${input}\"/" data_devcode.h +echo "Success!" +