Logo Search packages:      
Sourcecode: cafix version File versions  Download package

arguments.c

#include "custom.h"
int Pos, *params, positionfn, fileliststart, filelistend, numberfiles;
extern int promptfilenames,transmissionmode;

//extern long taille;



void arguments(int argc, char *argv[]) {
   switch(argc) {
        case 1:
        showhelp();
        return;
        break;
        default:
        //printf("multfiles not yet supported\n");
        break; }



        params = (int*) calloc(argc, sizeof(int)); /* -1 because of the last param \0 */
        printf("param initialized with size: %d\n", (argc*sizeof(int)));


        printf("argc: %d\n", argc);
        for (Pos=0;Pos<argc;Pos++)
                printf("\targ%d: %s", Pos, argv[Pos]);
        printf("\n");


        for (Pos=0;Pos<argc;Pos++)
        {
                if (strcmp("--help",argv[Pos])==0 || strcmp ("-h", argv[Pos])==0) {
                                showhelp();
                                return;}
                if (strcmp("--control",argv[Pos])==0 || strcmp ("-c", argv[Pos])==0) {
                                remotecontrol();
                                return;}
                if (strcmp("--rename",argv[Pos])==0 || strcmp ("-rn", argv[Pos])==0) {
                                *(params+Pos-1) = 1;
                                promptfilenames = 1;
                                printf("renaming... %d\n", promptfilenames); }
                if (strcmp("--send",argv[Pos])==0 || strcmp ("-s", argv[Pos])==0) {
                                *(params+Pos-1) = 1;
                                transmissionmode = 1;
                                printf("sending... \n"); }
                if (strcmp("--receive",argv[Pos])==0 || strcmp ("-r", argv[Pos])==0) {
                                *(params+Pos-1) = 1;
                                transmissionmode = -1;
                                printf("receiving... \n"); }
        }
        for (Pos=0;Pos<argc;Pos++) {
        //printf("%i\n", *(params+dep));
        if (*(params+Pos)==1) { positionfn=positionfn+1; /*printf("\t%i\n", positionfn); fflush(stdout);*/ }
        //         fflush(stdout);
       }
       numberfiles=argc-positionfn-1;
       fileliststart=positionfn+1;
       filelistend=argc-1;
       printf("%d files detected:\n", numberfiles); //one for the null param
       switch(positionfn) {
       case 0:
       printf("\nNo command given, please use ./cafix -h for help\n");
//       fflush(stdout);
       break;
       default:
       printf("Last command detected at %i parameter\n", positionfn);
       printf("File list contains %d file(s) and starts at %d and ends at %d\n", numberfiles, fileliststart, filelistend);
       break;}

       if (transmissionmode==1) { processSend(argv); }
       if (transmissionmode==-1) { processReceive(argv); }
}





Generated by  Doxygen 1.6.0   Back to index