Beispiel #1
0
int main(void)
{
	cmd_system("cp ./graph.csv.bak ./graph.csv");

	FILE *fin = fopen("./graph.csv", "r");
	FILE *fout = fopen("./new_graph.csv", "w");

	int total_time = atoi(cmd_system("tail -1 ./mobility.csv | cut -d , -f 3"));
	total_time = total_time/4;

	char *line = NULL;
	size_t len = 0;
	ssize_t read;

	srand(seed);

	while((read = getline(&line, &len, fin)) != -1) {
		int n, i, j, time, rtime;
		sscanf(line, "%d,%d,%d", &i, &j, &time);
		for(n=0; n<3; n++) {
			rtime = (total_time + rand()%RANGE) * n;
			time += rtime;
			fprintf(fout, "%d,%d,%d\r\n", i, j, time);
		}
	}

	fclose(fin);
	fclose(fout);
	free(line);

	cmd_system("sort -t, -k1,1n -k2,2n -k3,3n ./new_graph.csv -o ./new_graph.csv.bak; mv ./new_graph.csv.bak ./new_graph.csv");
	cmd_system("sort -t, -k3,3n ./new_graph.csv -o ./new_mobility.csv");

	return 0;
}
Beispiel #2
0
static int red_cmd(char *cmd) {
    char *arg = cmd+1;
    SKIPSPACES(arg);
    switch(*cmd) {
    case 'q':
        return 0;
    case ';':
    case '#':
        break; // comment
    case '>':
        return cmd_dump(arg);
        break;
    case '<':
        return cmd_load(arg);
        break;
    case '.':
        return red_interpret(arg);
        break;
    case 's':
        return cmd_seek(arg);
        break;
    case 'b':
        return cmd_bsize(arg);
        break;
    case '/':
        return cmd_search(arg);
        break;
    case 'd':
        return cmd_system ("echo X | ired -n $BLOCK | rasm2 -o $OFFSET -D - |head -n $(($LINES-1))");
    case 'p':
        return cmd_print(arg);
        break;
    case 'r':
        return cmd_resize(arg);
        break;
    case 'x':
        return cmd_hexdump(arg);
        break;
    case 'X':
        return cmd_bytedump(arg);
        break;
    case 'w':
        return cmd_write(arg);
        break;
    case '!':
        return cmd_system(arg);
        break;
    case 'V':
        return cmd_system("vired $FILE");
        break;
    case '?':
        return cmd_help(arg);
        break;
    default:
        fprintf(stderr, "? %s\n", cmd);
    }
    return 1;
}
Beispiel #3
0
int getusbcount()
{
    char* result="";
    result =cmd_system("lsusb");
    int number=count_char(result,'\n');
    return number;
}
Beispiel #4
0
int main(int argc, char *argv[]){

	if(argc < 7)return 0;
	char *model = argv[1];
	char *firmware = argv[2];
	char *mac = argv[3];
	char *sn = argv[4];
	char *time = argv[5];
	char *noncestr = argv[6];
	char *data = "";
	if(argc >= 8) data = argv[7];	

    char command1[128];
    char command2[128];
    char command3[256];
    char command4[256];
    char *result1 = (char*)malloc(500*sizeof(char));
    char *result2 = (char*)malloc(500*sizeof(char));
    char *result3 = (char*)malloc(500*sizeof(char));
    char *s = (char*)malloc(1000*sizeof(char));

    sprintf(command1, "echo -n '%s%s%s%s%s'|md5sum|cut -d ' ' -f1", model, firmware, mac, sn, time);
    strcpy(result1, cmd_system(command1));
    trim(result1);

    sprintf(command2, "echo -n '%s%s%s'|md5sum|cut -d ' ' -f1", data, noncestr, time);
    strcpy(result2, cmd_system(command2));
    trim(result2);

    strcat(s, result1);
    strcat(s, result2);

    sprintf(command3, "echo -n '%s'|md5sum|cut -d ' ' -f1", s);
    strcpy(result3, cmd_system(command3));
    trim(result3);

    sprintf(command4, "echo -n '%s'|md5sum|cut -d ' ' -f1", result3);
    system(command4);

    free(result1);
    free(result2);
    free(result3);
    free(s);

	return 0;
}