- TI-Utils: CLI tools for manipulating calc files on your PC
- 29 Aug 2010 09:27:48 pm
- Last edited by TheStorm on 11 Feb 2011 09:54:45 pm; edited 3 times in total
A conversation in #ti got me thinking about how there is a lack of tools for working with the different TI file types from the command line. The libti libraries have so many fuctions that could help TI-Basic and ASM programmers alike that it seems like a waste that they are not accessible to userspace for scripting and basic file management.
Ti-Utils is a suit of simple single purpose programs to change this.
The first utility I'm starting on is tigroup/untigroup. I plan for it to be an equivalent to tar but for tigroup files, allowing you to create, modify and extract group files in both the .**g and .tig forms.
Below is the current code, keep in mind this is the first C program I have ever written from scratch, and besides my work on TiLP I have absolutely no C experience. If you have any suggestions or comments please post them here.
Code:
Ti-Utils is a suit of simple single purpose programs to change this.
The first utility I'm starting on is tigroup/untigroup. I plan for it to be an equivalent to tar but for tigroup files, allowing you to create, modify and extract group files in both the .**g and .tig forms.
Below is the current code, keep in mind this is the first C program I have ever written from scratch, and besides my work on TiLP I have absolutely no C experience. If you have any suggestions or comments please post them here.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <tilp2/tifiles.h>
int
main(int argc, char *argv[])
{
int c;
int digit_optind = 0;
static struct option long_options[] = {
{"help", 1, 0, 'h'},
{"version", 0, 0, 'V'},
{0, 0, 0, 0}
};
char *ofile, *ifile;
int this_option_optind = optind ? optind : 1;
int option_index = 0;
while ((c = getopt_long(argc, argv, ":hVf:o:", long_options, &option_index)) != -1) {
switch (c) {
case 'V':
printf("This is a test.\n");
break;
case 'h':
printf("This will be help text someday.\n");
break;
case 'f':
ifile = optarg;
break;
case 'o':
ofile = optarg;
break;
case ':': /* -f or -o without operand */
fprintf(stderr,
"Option -%c requires an operand\n", optopt);
//errflg++;
break;
case '?':
fprintf(stderr,
"Unrecognised option: -%c\n", optopt);
//errflg++;
}
}
if (!tifiles_ungroup_file(ifile, NULL)) {
exit(0);
}
return 0;
}