int main() { welcom(); tty_mode(0);//储存TTY的模式 initscr(); crmode(); noecho(); clear(); box(stdscr,'|','-'); mvaddch(pos_x,pos_y,BALL); bpos_x=LINES-4; bpos_y=4; mvaddstr(bpos_x,bpos_y,BAN); move(LINES-1,COLS-1); //移动光标到右下角 refresh(); signal(SIGALRM,jmove); delay=50; //200ms=0.2s if(set_ticker(delay) == -1) perror("set_ticker"); else while(1) { ndelay = 0; c=getch(); if(c=='Q') break; if(c=='f' && delay > 2) ndelay = delay/2; if(c=='s') ndelay = delay*2; if(c==' ') bdir_y=-bdir_y; if(ndelay > 0) set_ticker (delay = ndelay); //重置定时器 } }
int main () { mot* tabtet[26]; char name [30],mot_tr[30],cont; int num; int a; welcom(); printf(" Donnez Le nom de Fichier ===> :"); scanf("%s",name); creat_index(tabtet,name); skip: menu(); do { scanf("%d",&a); if (a<1 || a > 6) { printf("\n\n Entrez un nombre Correct SVP 1 <= nombre <= 6 |:"); } } while(a<1 || a > 6); switch (a){ case 1 : afficher(tabtet); break ; case 2 : printf("\n\n Donnez le MOT ==> :"); scanf("%s",mot_tr); index_mot(tabtet,mot_tr); break ; case 3 : printf("#################################################\n"); printf("\n Donnez la chain a Ajouter ==>|:"); scanf(" %s",mot_tr); printf("\n Donnez la page ==> |:"); scanf("%d",&num); printf("\n\n#################################################\n"); ajout_mot(tabtet,mot_tr,num); break ; case 4 : printf("#################################################\n"); printf("\n Donnez la chain a enlever ==>|:"); scanf(" %s",mot_tr); printf("\n Donnez la page ==> |:"); scanf("%d",&num); printf("\n\n#################################################\n"); enlever(tabtet,mot_tr,num); break ; case 5: printf("#################################################\n"); printf("\n Donnez le Nom de Fichier a Creer ==>|:"); scanf(" %s",mot_tr); printf("\n\n#################################################\n"); write_to_file(mot_tr,tabtet); break ; case 6 : printf("\n\n ##################### GOOD Bye ... !! #######################\n\n"); exit(1); break ; } printf("voulez vous continuez (aller au menu principale) (y/n)"); scanf(" %c",&cont); if (tolower(cont)=='y'){ goto skip; } else { exit(1) ; }; system ("PAUSSE"); return 0 ; }
/* * Main program for daemon. */ int main (int argc, char **argv) { int opt; int result = -1; struct stat st; /* check options.chroot_directory */ FILE *fd; /* Check *.pem files */ char *command = NULL; char *cat = NULL; char *server = NULL; char buf[SIZE]; char **c = NULL; int i = 0; char **arg = NULL; /* Use when creuvux is run with option from command line */ int arg_inc = 0; int mode_script = -1; /* if mode_script = 1, script mode is enable */ char *zErrMsg = 0; int rc = -1; /* Ensure that standart files descriptor 0, 1 and 2 are open or directed to /dev/null */ crv_sanitise_stdfd(); /* Initialize configuration options to their default values. */ initialize_client_options(&options); while ((opt = getopt(argc, argv, "f:c:hv")) != -1) { switch(opt) { case 'h': /* Print Help */ fprintf(stdout, "%s\n", "Help:"); usage (NULL); exit(EXIT_SUCCESS); case 'v': /* Print version */ fprintf (stderr, "%s%s\n", "creuvux version ", CREUVUX_VERSION); fprintf (stderr, "%s\n", "Before reporting bugs ([email protected]) please check " "the development CHANGELOG to make sure it hasn't already " "been fixed in devel."); exit(1); case 'f': /* Config File */ crv_free(options.config); options.config = crv_strdup(optarg); break; case 'c': /* Get command */ mode_script = 1; if (NULL == (c = malloc (SIZE * sizeof *c))) exit(EXIT_FAILURE); for (i = 2; argv[i]; i++) c[i-2] = crv_strdup(argv[i]); for (i = 0; c[i]; i++) printf("-> %s\n", c[i]); break; case '?': default: usage(NULL); exit(EXIT_FAILURE); } } argc -= optind; argv += optind; /* Read configuration file and set options */ result = read_client_conf (options.config); if (result == -1) return (-1); /* Check if passphrase isn't NULL */ if (options.passphrase == NULL) { fprintf(stdout, "%s", "Enter your passphrase:"); fflush(stdin); get_passwd (); fprintf(stdout, "%s", "\n"); } /* if (optind < argc) { fprintf( stderr, "%s%s\n", "Extra argument ", argv[optind]); exit(1); } */ /* * Check Configuration */ /* Check upload_directory */ if ((stat(options.download_directory, &st) == -1) || (S_ISDIR(st.st_mode) == 0)) { fprintf( stderr, "Missing download directory: %s\n", options.download_directory); exit(1); } /* Check config directory */ if ((stat(options.path, &st) == -1) || (S_ISDIR(st.st_mode) == 0)) { fprintf( stderr, "Option CREUVUX_PATH is missing: %s\n", options.path); exit(1); } result = crv_chdir(options.path); if (result == -1) { fprintf( stderr, "%s%s%s\n", "main(): crv_chdir(", options.path,") failed"); exit(1); } /* Check existence of tmp directory */ if ((stat( "./tmp", &st) == -1) || (S_ISDIR(st.st_mode) == 0)) { fprintf( stderr, "Directory %stmp/ is missing\n", options.tmp_directory); exit(1); } /* Check server.pem */ fd = crv_fopen("client.pem", "r"); if (fd == NULL) { fprintf( stderr, "%s\n", "Missing server.pem."); return (-1); } fclose(fd); /* Check rootcert.pem */ fd = crv_fopen("rootcert.pem", "r"); if (fd == NULL) { fprintf( stderr, "%s\n", "Missing rootcert.pem"); return (-1); } fclose(fd); /* ignore SIGPIPE */ signal (SIGPIPE, SIG_IGN); options.gui = 0; welcom(); if (options.debug == 1) { fprintf(stderr, "%s\n", "#################"); fprintf(stderr, "%s\n", "# MODE DEBUG ON #"); fprintf(stderr, "%s\n", "#################"); fprintf(stderr, "# | \n"); fprintf(stderr, "# |-> CREUVUX_PATH :'%s'\n", options.path); fprintf(stderr, "# |-> CREUVUX_SEC :'%d'\n", options.sec); fprintf(stderr, "# |-> CREUVUX_PWD :'%s'\n", options.passphrase); fprintf(stderr, "# |-> CREUVUX_DATA :'%s'\n", options.download_directory); fprintf(stderr, "# |-> LISTING_DIR :'%s'\n", options.listing_directory); fprintf(stderr, "# |-> TMP_DIR :'%s'\n", options.tmp_directory); if ( options.address_family == AF_INET) fprintf(stderr, "%s", "# |-> CREUVUX_ADDR :'IPv4'\n"); else if ( options.address_family == AF_INET6) fprintf(stderr, "%s", "# |-> CREUVUX_ADDR :'IPv6'\n"); if (options.compression == 1) fprintf(stderr, "%s", "# |-> CREUVUX_COMPRESSION :'Yes'\n"); else if (options.compression == -1) fprintf(stderr, "%s", "# |-> CREUVUX_COMPRESSION :'No'\n"); fprintf(stderr, "%s\n\n", "#################"); } /* * Deux fonctions: * -> Envoie de fichiers * -> Téléchargement de fichiers */ // Download /* fprintf(stdout, "File: %s\n", c[i]); char *sha1 = NULL; sha1 = crv_sha1(c[i]); printf("Sha1 (%s) = %s\n", c[i], sha1); upload(c[i]); //Get("/home/creuvard/file.crv"); */ server = give_server(); if (server == NULL) { fprintf(stderr, "%s\n", "You must choose server id"); return; } cat = choice_cat(); if (cat == NULL) { fprintf(stderr, "%s", "Creuvux fail to fetch categories list"); return (-1); } fprintf(stdout, "Catégorie: %s\n", cat); for (i = 0; c[i]; i++) { printf("-> %s\n", c[i]); upload(c[i], cat, server); printf("DEBUG avant fin loop\n"); } printf("DEBUG (avant fin main function\n"); // Send //upload(c[i]); Free_options(); return (0); }