commit a7d38b71ca9ec77756344d71651925791547464b
parent 9d796535afe0e1f628525d7d5d71151b3a96738f
Author: ByteProject <stefan.vogt@byteproject.net>
Date: Sat, 24 Dec 2011 03:49:45 +0100
code now properly in main function
Diffstat:
M | ansilove/main.c | | | 228 | +++++++++++++++++++++++++++++++++++++++---------------------------------------- |
1 file changed, 113 insertions(+), 115 deletions(-)
diff --git a/ansilove/main.c b/ansilove/main.c
@@ -48,123 +48,121 @@ void show_usage(void)
return EXIT_SUCCESS;
}
-// main
-printf("--------------------------------------------------\n");
-printf("AnsiLove/C %s - copyright (C) 2011 Stefan Vogt\n", VERSION);
-printf("--------------------------------------------------\n");
-
-char columns, font, bits, icecolors;
-
-input = argv[1];
-output = argv[1].".png";
-
-// check input parameters
-input_file_extension=strtolower(substr(input,strlen(input)-4,4));
-
-if (argc == 1)
-{
- show_usage();
-}
-
-if (input_file_extension == '.bin')
-{
- if (isset(argv[2]))
- {
- columns = argv[2];
- }
- if (isset(argv[3]))
- {
- font = argv[3];
- }
- if (isset(argv[4]))
- {
- bits = argv[4];
- }
- if (isset(argv[5]))
- {
- icecolors = argv[5];
- }
-}
-else
-{
- if (isset(argv[2]))
- {
- font = argv[2];
- }
- if (isset(argv[3]))
- {
- bits = argv[3];
- }
- if (isset(argv[3]))
- {
- icecolors = argv[4];
- }
-}
-
-if (strtolower(substr(input,strlen(input)-3,3))=='.xb')
-{
- input_file_extension='.xb';
-}
-
-if (bits=='thumbnail')
-{
- output=argv[1].THUMBNAILS_TAG.".png";
- bits='thumbnail';
-}
-
-printf("Input File: input\n");
-printf("Output File: output\n");
-printf("Columns (.BIN only): columns\n");
-printf("Font (.ANS/.BIN only): font\n");
-printf("Bits (.ANS/.BIN only): bits\n");
-printf("iCE Colors (.ANS/.BIN only): icecolors\n\n");
-
-// create output file
-switch (input_file_extension)
-{
-case '.pcb':
- load_pcboard(input,output,font,bits,icecolors);
- break;
-
-case '.bin':
- load_binary(input,output,columns,font,bits,icecolors);
- break;
-
-case '.adf':
- load_adf(input,output,bits);
- break;
-
-case '.idf':
- load_idf(input,output,bits);
- break;
-
-case '.tnd':
- load_tundra(input,output,font,bits);
- break;
-
-case '.xb':
- load_xbin(input,output,bits);
- break;
-
-default:
- load_ansi(input,output,font,bits,icecolors);
-}
-
-// display sauce informations
-input_file_sauce=load_sauce(input);
-
-if (input_file_sauce != NULL)
-{
- printf("Title: input_file_sauce[Title]\n");
- printf("Author: input_file_sauce[Author]\n");
- printf("Group: input_file_sauce[Group]\n");
- printf("Date: input_file_sauce[Date]\n");
- printf("Comment: input_file_sauce[Comment]\n\n");
-}
-
-
int main(int argc, char *argv[])
{
+ printf("--------------------------------------------------\n");
+ printf("AnsiLove/C %s - copyright (C) 2011 Stefan Vogt\n", VERSION);
+ printf("--------------------------------------------------\n");
+
+ char columns[], font[], bits[], icecolors[];
+ char input[] = argv[1];
+ char outext[] = ".png";
+ char output[] = strcat(argv[1], outext);
+
+ // check input parameters
+ input_file_extension=strtolower(substr(input,strlen(input)-4,4));
+
+ if (argc == 1)
+ {
+ show_usage();
+ }
+
+ if (input_file_extension == '.bin')
+ {
+ if (isset(argv[2]))
+ {
+ columns = argv[2];
+ }
+ if (isset(argv[3]))
+ {
+ font = argv[3];
+ }
+ if (isset(argv[4]))
+ {
+ bits = argv[4];
+ }
+ if (isset(argv[5]))
+ {
+ icecolors = argv[5];
+ }
+ }
+ else
+ {
+ if (isset(argv[2]))
+ {
+ font = argv[2];
+ }
+ if (isset(argv[3]))
+ {
+ bits = argv[3];
+ }
+ if (isset(argv[3]))
+ {
+ icecolors = argv[4];
+ }
+ }
+
+ if (strtolower(substr(input,strlen(input)-3,3))=='.xb')
+ {
+ input_file_extension='.xb';
+ }
+
+ if (bits=='thumbnail')
+ {
+ output=argv[1].THUMBNAILS_TAG.".png";
+ bits='thumbnail';
+ }
+
+ printf("Input File: input\n");
+ printf("Output File: output\n");
+ printf("Columns (.BIN only): columns\n");
+ printf("Font (.ANS/.BIN only): font\n");
+ printf("Bits (.ANS/.BIN only): bits\n");
+ printf("iCE Colors (.ANS/.BIN only): icecolors\n\n");
+
+ // create output file
+ switch (input_file_extension)
+ {
+ case '.pcb':
+ load_pcboard(input,output,font,bits,icecolors);
+ break;
+
+ case '.bin':
+ load_binary(input,output,columns,font,bits,icecolors);
+ break;
+
+ case '.adf':
+ load_adf(input,output,bits);
+ break;
+
+ case '.idf':
+ load_idf(input,output,bits);
+ break;
+
+ case '.tnd':
+ load_tundra(input,output,font,bits);
+ break;
+
+ case '.xb':
+ load_xbin(input,output,bits);
+ break;
+
+ default:
+ load_ansi(input,output,font,bits,icecolors);
+ }
+
+ // display sauce informations
+ input_file_sauce=load_sauce(input);
+
+ if (input_file_sauce != NULL)
+ {
+ printf("Title: input_file_sauce[Title]\n");
+ printf("Author: input_file_sauce[Author]\n");
+ printf("Group: input_file_sauce[Group]\n");
+ printf("Date: input_file_sauce[Date]\n");
+ printf("Comment: input_file_sauce[Comment]\n\n");
+ }
+
// terminate program
printf("Successfully created output file\n\n");