What should I name this project?
tisfk (Ti Swiss File Knife)
 22%  [ 2 ]
tiutils
 44%  [ 4 ]
tigrp/tigroup
 0%  [ 0 ]
tifileutils (Ti File Utils)
 33%  [ 3 ]
Other (please specify in thread)
 0%  [ 0 ]
Total Votes : 9

Kllrnohj wrote:
TheStorm wrote:

Code:

    enum modes {MODE_NONE, MODE_HELP, MODE_EX, MODE_LS, MODE_CREATE, MODE_ADD, MODE_DEL} curmode;


What the hell is that?

You had it correct with your enum at the top of the file. Whatever the hell that is, don't do it.

Ok, I'll change it back and see if I can figure out why I was having issues with it when it was at the top of the file.

EDIT: Wow, I was being dumb, that part works now and yeah having it at the top of the file helps readability a lot.
Quote:

Quote:

Code:
    if (curmode==MODE_HELP || curmode==MODE_NONE) printf("insert help text here\n");


You should probably quit if you don't have something to do. Sure, you won't execute any other code with your ifs, but that can change. It is easier to follow if you simply exit after printing your help.
Good to know, I'll keep that in mind.
Quote:

Quote:

Code:
    if (curmode==MODE_EX){
        int err = 0;
        //printf("%x [%s]\n",(void*)ifile,ifile);
        if (tifiles_file_is_group(ifile))
            tifiles_ungroup_file(ifile, NULL);
       else if(tifiles_file_is_tigroup(ifile))
            tifiles_untigroup_file(ifile, NULL);
        else
            fprintf(stderr, "invalid filetype");
    }
    if (curmode==MODE_LS){
        int err = 0;
        //printf("%x [%s]\n",(void*)ifile,ifile);
        if (tifiles_file_is_group(ifile))
            tifiles_file_display(ifile);
       else if(tifiles_file_is_tigroup(ifile))
            tifiles_file_display_tigroup(ifile);
        else
            fprintf(stderr, "invalid filetype");
    }


    return 0;
}


Still aren't checking if ifile is null Smile
I check to make sure optargs is not null, as well as the fact that getopts will error if there is not an arg after o, f, or l, though another check wouldn't hurt.
Quote:
I check to make sure optargs is not null, as well as the fact that getopts will error if there is not an arg after o, f, or l, though another check wouldn't hurt.


Yes, it will, but you aren't exiting on error ('?'), you are continuing to run. With the way your code is structured, you could very easily end up using ifile or ofile while they are still NULL.
Kllrnohj wrote:
Quote:
I check to make sure optargs is not null, as well as the fact that getopts will error if there is not an arg after o, f, or l, though another check wouldn't hurt.


Yes, it will, but you aren't exiting on error ('?'), you are continuing to run. With the way your code is structured, you could very easily end up using ifile or ofile while they are still NULL.
Ah yes, I meant to mention that too. Also, perror() can be your friend.
I was just looking through the unix files on ticalc and it seem ben moody beat me to most of the features I wanted this to have. TITools
TheStorm wrote:
I was just looking through the unix files on ticalc and it seem ben moody beat me to most of the features I wanted this to have. TITools
Not bad; what kind of license is it released under? If it's something fairly open, you could implement the additional things you were envisioning as expansions to his code rather than something completely new.
KermMartian wrote:
TheStorm wrote:
I was just looking through the unix files on ticalc and it seem ben moody beat me to most of the features I wanted this to have. TITools
Not bad; what kind of license is it released under? If it's something fairly open, you could implement the additional things you were envisioning as expansions to his code rather than something completely new.
Its GPL so I might just do that, I'll of course still ask his permission first before I make any releases and such.
Of course, that goes without saying. Maybe he'd even be interested in working with you on it, although I'd tend to assume without any other reference that he's probably quite busy with his Mimas project.
I have missed the release of those tools as well, I definitely don't check up the new uploads to ticalc on a daily basis...
Anyhow, great news Smile
Lionel Debroux wrote:
I have missed the release of those tools as well, I definitely don't check up the new uploads to ticalc on a daily basis...
Anyhow, great news Smile
For sure! Jonimus, did you get to shoot him an email yet to see what his thoughts on collaboration are?
I did some more work on this tonight and it now can rename files within a group as well as single files. My next plan is to attack creating group files and modifying attributes such as locked and archived. The attribute code should be pretty easy to do once I figure out a good way for the user to specify attributes. I may just steal from ben moody's GPL'd ti tools here because from what I saw he has some nice code to do this and that way the programs will accept the same formats.

Edit: Here's the code so far.

Code:
/*
 * tifile
 *
 * Copyright (c) 2010 Jon Sturm
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */



#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <tilp2/tifiles.h>

/* Flag set by ‘--verbose’. */
static int verbose_flag;

enum modes {MODE_NONE, MODE_HELP, MODE_EX, MODE_LS, MODE_CREATE, MODE_ADD, MODE_DEL, MODE_MOD};


int
main(int argc, char *argv[])
{
    char c;
    int curmode=MODE_NONE;
    static struct option long_options[] = {
        {"help", 0, 0, 'h'},
        {"version", 0, 0, 'V'},
        {"entry", required_argument, 0, 'e'},
        {"rename", required_argument, 0, 'r'},
        {"list", required_argument, 0, 'l'},
        {"extract", required_argument, 0, 'x'},
        {"verbose", 0, &verbose_flag, 'v'},
        {0, 0, 0, 0}
    };
    char *ofile=NULL, *ifile=NULL;
    int option_index = 0;
    int entry=0;
    char *newname=NULL;
    FileContent *regular;
    CalcModel model;



    while ((c = getopt_long(argc, argv, ":hVvl:x:r:e:", long_options, &option_index)) != -1) {
    switch (c) {
        case 'V':
            printf("Insert Verison Text here\n");
            break;
        default:
        case 'h':
            curmode=MODE_NONE;
            break;
        case 'x':
            if (curmode==MODE_NONE && optarg){
                curmode = MODE_EX;
                ifile=optarg;
            }
            else {
                curmode = MODE_HELP;
            }
            break;
        case 'e':
            if (optarg)
                entry= (int)strtol(optarg, NULL, 10);
            break;
        case 'r':
            if ((curmode==MODE_NONE || curmode==MODE_MOD) && optarg){
                curmode = MODE_MOD;
                newname=optarg;
            }
            else {
                curmode = MODE_HELP;
            }
            break;
        case 'l':
            if (curmode==MODE_NONE && optarg){
                curmode = MODE_LS;
                ifile=optarg;
            }
            else {
                curmode = MODE_HELP;
            };
            break;
        case ':':       /* -f or -o without operand */
            fprintf(stderr,
                    "Option -%c requires an operand\n", optopt);
            curmode=MODE_HELP;
            break;
        case '?':
            fprintf(stderr,
                    "Unrecognised option: -%c\n", optopt);
            curmode=MODE_HELP;
        case 'v':
            verbose_flag++;
            break;
        }
    }
   
    // if (optind < argc)
         // {
           // printf ("non-option ARGV-elements: ");
           // while (optind < argc)
             // printf ("%s ", argv[optind++]);
           // putchar ('\n');
    // }

   
    if (curmode==MODE_MOD)
        ifile=argv[optind++];
       
   
   
    if (curmode==MODE_HELP || curmode==MODE_NONE) printf("insert help text here\n");
   
    tifiles_library_init();
   
    if (curmode==MODE_EX){
        int err = 0;
        //printf("%x [%s]\n",(void*)ifile,ifile);
        if (tifiles_file_is_group(ifile))
            tifiles_ungroup_file(ifile, NULL);
       else if(tifiles_file_is_tigroup(ifile))
            tifiles_untigroup_file(ifile, NULL);
        else
            fprintf(stderr, "invalid filetype");
    }
   
    if (curmode==MODE_MOD){
        //printf("%x [%s]\n",(void*)ifile,ifile);
        if (tifiles_file_is_regular(ifile)){
            CalcModel model = tifiles_file_get_model(ifile);
            regular = tifiles_content_create_regular(model);
            tifiles_file_read_regular(ifile, regular);
            if (entry > regular->num_entries || entry <0) {
                fprintf(stderr, "invalid entry specified");
                return 0;
            }
           
            if(newname!=NULL){
                char *str;
                str = ticonv_varname_tokenize(model, newname, regular->entries[entry]->type);
                if(strlen(str) > 8)
                    str[8] = '\0';
               
                strcpy(regular->entries[entry]->name, str);
            }
           
            tifiles_file_write_regular(ifile, regular, NULL);
        }else
            fprintf(stderr, "invalid filetype");
       
    }
   
    if (curmode==MODE_LS){
        int err = 0;
        //printf("%x [%s]\n",(void*)ifile,ifile);
        if (tifiles_file_is_regular(ifile))
            tifiles_file_display(ifile);
       else if(tifiles_file_is_tigroup(ifile))
            tifiles_file_display_tigroup(ifile);
        else
            fprintf(stderr, "invalid filetype");
    }
   
    tifiles_library_exit();

    return 0;
}
Looks great, Jonimus; keep up the good work. Smile
Well I separated the group functions from the file modification stuff since they seemed to make more sense separate and uploaded it so if anyone wants to try it out go right ahead. Once I have more features added to the group side of things I think I will be ready to release a 0.1 version.

Click here to try it out.

EDIT: I have uploaded it to github here

Right now its *nix only and assumes you have libtifiles2 installed properly, if its installed to /usr/local/ you will have to modify the makefile.
After some tinkering I have group file creation done and I think I am almost ready for a 0.1 beta 1 release but I still have yet to decide on a official tittle for this project so I have created a poll in the original post with some options. TiSFK was suggested by BrandonW and the rest were ideas I came up with while discussing this earlier with others on IRC.
My initial reaction would be "tisfk (Ti Swiss File Knife)", but if you say it aloud as tis-fk, it sounds quite unfortunate. How about TI Swiss Calculator Knife, tisck, or something along those lines?
Hmm, I'll think about that, but I'm not sold on the whole Swiss File Knife reference because frankly I hadn't really heard of it until BrandonW mentioned it. Not to mention that your version removes the word files which is what these utilities are aimed at.
TheStorm wrote:
Hmm, I'll think about that, but I'm not sold on the whole Swiss File Knife reference because frankly I hadn't really heard of it until BrandonW mentioned it. Not to mention that your version removes the word files which is what these utilities are aimed at.
Well, it's a spin on Swiss Army Knife, implying that your program is all-purpose, no? I was trying to make the acronym a bit less awkward, but you of course don't have to take my opinion. Smile
KermMartian wrote:
TheStorm wrote:
Hmm, I'll think about that, but I'm not sold on the whole Swiss File Knife reference because frankly I hadn't really heard of it until BrandonW mentioned it. Not to mention that your version removes the word files which is what these utilities are aimed at.
Well, it's a spin on Swiss Army Knife, implying that your program is all-purpose, no? I was trying to make the acronym a bit less awkward, but you of course don't have to take my opinion. Smile
Oh, I got that part of the reference that wasn't my point. The issue is your attempt to make it less awkward causes the reference loses some of its appeal as my utilities after all do modify files.
TheStorm wrote:
KermMartian wrote:
TheStorm wrote:
Hmm, I'll think about that, but I'm not sold on the whole Swiss File Knife reference because frankly I hadn't really heard of it until BrandonW mentioned it. Not to mention that your version removes the word files which is what these utilities are aimed at.
Well, it's a spin on Swiss Army Knife, implying that your program is all-purpose, no? I was trying to make the acronym a bit less awkward, but you of course don't have to take my opinion. Smile
Oh, I got that part of the reference that wasn't my point. The issue is your attempt to make it less awkward causes the reference loses some of its appeal as my utilities after all do modify files.
Gotcha, that certainly makes sense. Do you have any names that you happen to be leaning towards?
Well the Poll so far has been pretty close to what I was feeling. I like tiutils for a short name and then Ti File Utils as a full name but I wanted some community input on that.
TheStorm wrote:
Well the Poll so far has been pretty close to what I was feeling. I like tiutils for a short name and then Ti File Utils as a full name but I wanted some community input on that.
It's simple and descriptive; I guess there's no necessity for a cutesy name. I like those too.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 3
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement