summaryrefslogtreecommitdiff
path: root/uirc.c
diff options
context:
space:
mode:
authorBryson Steck <steck.bryson@gmail.com>2022-06-20 23:25:44 -0600
committerBryson Steck <steck.bryson@gmail.com>2022-06-20 23:25:44 -0600
commit933a856e05a41ab63dac33ce53da48d91009613f (patch)
tree43da03cfaf3ab303197622e9a5cdd701a96468a2 /uirc.c
parent50fd2f37c3a438f35e8730327f512891a2c8ae8f (diff)
downloaduirc-933a856e05a41ab63dac33ce53da48d91009613f.tar
uirc-933a856e05a41ab63dac33ce53da48d91009613f.tar.gz
uirc-933a856e05a41ab63dac33ce53da48d91009613f.tar.bz2
install man page and other makefile stuff
Diffstat (limited to 'uirc.c')
-rw-r--r--uirc.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/uirc.c b/uirc.c
index 88992c1..59ce560 100644
--- a/uirc.c
+++ b/uirc.c
@@ -39,6 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <curl/curl.h>
#include <curl/easy.h>
#include <unistd.h>
+#include <stdbool.h>
const char *VERSION = "0.1.0";
int rFlag = 1;
@@ -58,6 +59,10 @@ int getBcf(int width, int height) {
return bcf;
}
+bool compare_float(float a, float b) {
+ return fabs(a-b) < 0.0000001;
+}
+
int readFile(char *file, int rFlag, int req, char* url) {
int width, height, channels, factor;
unsigned char *img = stbi_load(file, &width, &height, &channels, 0);
@@ -97,6 +102,8 @@ int readFile(char *file, int rFlag, int req, char* url) {
}
}
+ // see if uneven values equal normal aspect ratios
+
if (factor == 1) {
if (width < height) {
printf("%s > 1:%.2f (uneven)", file, wuneven);
@@ -125,6 +132,7 @@ int download(char *url) {
CURLcode res;
char outfilename[15] = "/tmp/uirc.tmp";
curl = curl_easy_init();
+ long returnCode = 0;
if (curl) {
fp = fopen(outfilename,"wb");
@@ -132,17 +140,19 @@ int download(char *url) {
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, returnCode);
curl_easy_cleanup(curl);
fclose(fp);
}
+ printf("%ld\n", returnCode);
return 0;
}
// end of stack overflow snippet
int handleArg(char *arg) {
- int value, complete;
- char flag, *longFlag, *http, first, firstTwo[3], firstFour[5];
+ int complete;
+ char flag, first, firstTwo[3], firstFour[5];
const char *help;
help = "USAGE: uirc [OPTIONS] IMAGE1 [IMAGE2] [...]\n\n"
@@ -212,7 +222,7 @@ int handleArg(char *arg) {
int main(int argc, char *argv[]) {
char *i, *a;
- int runs;
+ int runs, code, arg_code;
if (argc <= 1) {
printf("uirc: at least one argument is required\n");
@@ -221,7 +231,9 @@ int main(int argc, char *argv[]) {
for (int i = 1; i < argc; i++) {
a = argv[i];
- handleArg(a);
+ arg_code = handleArg(a);
+ if (arg_code > code)
+ code = arg_code;
runs++;
}