📄 cli.c
字号:
/* cli.c - command line interface implementation */#include "cvstags.h"CVSTAG(cli, "$Id: cli.c,v 1.11 2005/05/10 16:42:19 knilch Exp $")/* Ramdefrag Command Line Interface * (c) 2004, 2005 Tobias 'knilch' Jordan <knilch@users.sourceforge.net> * * Setting Orange, the 50th day of Chaos in the YOLD 3170 * (Celebrate Chaoflux!) * * 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include "cli.h"#include <stdio.h>#ifdef HAVE_CONFIG_H#include "config.h"#endif#ifdef HAVE_STDLIB_H# include <stdlib.h>#endif#ifdef HAVE_STRING_H# include <string.h>#else# ifdef HAVE_STRINGS_H# include <strings.h># endif#endif#include "msgs.h"#include "dstates.h"#include "timings.h"/* * WARNING: * this is work in progress! */#include <unistd.h>voidcli_main(struct cli_parm o){ /* Been Dazed and Confused for so long it's not true. */ /* Wanted a woman, never bargained for you. */ /* Lots of people talk and few of them know, */ /* soul of a woman was created below. */ int i, j, x; char *a; char *b = ""; char t[STAT_MAX]; switch (o.t) { case 'a': /* analyze only */ if (o.s) printf("%s\n", getphase(-23)); for (i = 0; i < 50; i++) { if (o.p) printf("#"); fflush(stdout); usleep(TM_DEEP_ALG * (2 + 3) * 23); } /* You hurt and abuse tellin' all of your lies. */ /* Run around sweet baby, Lord how they hypnotize. */ /* Sweet little baby, I don't know where you've been. */ /* Gonna love you baby, here I come again. */ printf("\n"); if (o.f) printf("%s\n", analyze(t, o.b)); return; case 's': x = TM_STD_ALG; break; case 'o': x = TM_OPT_ALG; break; case 'd': x = TM_DEEP_ALG; break; default: /* this should not happen. */ x = 1111; /* Every day I work so hard, bringin' home my hard earned pay */ /* Try to love you baby, but you push me away. */ /* Don't know where you're goin', only know just where you've been, */ /* Sweet little baby, I want you again. */ } for (i = 0; i < 100; i++) { a = b; b = getphase(i); if (strcmp(a, b)) { if (o.p && o.s) printf("\n"); if (o.s) printf("%s\n", b); if (o.p && o.s) for (j = 0; j < i; j++) if (j % 2) printf("#"); } if ((o.p) && (i % 2)) printf("#"); fflush(stdout); usleep(x * 1000); } /* Been dazed and confused for so long, it's not true. */ /* Wanted a woman, never bargained for you. */ /* Take it easy baby, let them say what they will. */ /* Will your tongue wag so much when I send you the bill? */ printf("\n"); a = getstatus(i, t, o.b); if (o.f) printf("%s\n", a); printf(ST_DEFRAG_DONE); printf(ST_PROGRAM_QUIT);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -