aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2019-04-25 10:12:40 +0200
committerGravatar jonas <himself@jonasgunz.de> 2019-04-25 10:12:40 +0200
commita2465bb8393f216ecb7a72604180cd9ec21c6fdb (patch)
treed5e9be0b6603209253049b465e060be46af05387
parentd95895df8df4022b70a59f390da5bec6351fc3d8 (diff)
downloadheadstripper-a2465bb8393f216ecb7a72604180cd9ec21c6fdb.tar.gz
Changed filename string generation
-rw-r--r--src/main.c46
1 files changed, 14 insertions, 32 deletions
diff --git a/src/main.c b/src/main.c
index 1f33825..75fc2de 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,6 +54,8 @@ int strip_png(char *_filename);
int strip_tiff(char *_filename);
+char* strcmb(char *_str1, char *_str2);
+
int main(int argc, char* argv[])
{
FILE *image;
@@ -111,11 +113,7 @@ int strip_jpg(char *_filename)
FILE *in;
FILE *out;
- int f__outfile_len = strlen(_filename);
- char *f__outfile = malloc(f__outfile_len + 8);
-
- strncpy( f__outfile, "strip.", 6);
- strcpy(&f__outfile[6], _filename);
+ char *f__outfile = strcmb("strip.", _filename);
in = fopen(_filename, "r");
out = fopen(f__outfile, "w");
@@ -183,15 +181,12 @@ int strip_png(char *_filename)
FILE *in;
FILE *out;
- int f__outfile_len = strlen(_filename);
- char *f__outfile = malloc(f__outfile_len + 8);
-
- strncpy( f__outfile, "strip.", 6);
- strcpy(&f__outfile[6], _filename);
+ char *f__outfile = strcmb("strip.", _filename);
in = fopen(_filename, "r");
out = fopen(f__outfile, "w");
+
if(!in)
return 1;
if(!out) {
@@ -271,30 +266,17 @@ int strip_png(char *_filename)
int strip_tiff(char *_filename)
{
- FILE *in;
- FILE *out;
-
- int f__outfile_len = strlen(_filename);
- char *f__outfile = malloc(f__outfile_len + 8);
-
- strncpy( f__outfile, "strip.", 6);
- strcpy(&f__outfile[6], _filename);
-
- in = fopen(_filename, "r");
- out = fopen(f__outfile, "w");
+ printf("TIFF Unimplemented.\n");
+ return 1;
- if(!in)
- return 1;
- if(!out) {
- printf("Unable to open for writing %s: %i\n", f__outfile, errno);
- return 1;
- }
+}
- printf("Unimplemented\n");
+char* strcmb(char *_str1, char *_str2)
+{
+ char *f__return = malloc(strlen(_str1) + strlen(_str2) + 1);
- fclose(in);
- fclose(out);
- free(f__outfile);
+ strcpy( f__return, _str1);
+ strcpy(&f__return[ strlen(_str1) ], _str2);
- return 1;
+ return f__return;
}