示例#1
0
void            ps1_checker_2(s_ps1                      ps1_st,
                              bool                       *escaped,
                              bool                       *checked)
{
  check_n(ps1_st, escaped, checked);

  check_dollar(ps1_st, escaped, checked);

  check_a(ps1_st, escaped, checked);

  check_e(ps1_st, escaped, checked);

  check_r(ps1_st, escaped, checked);
}
// Check the integrity of tablefile
bool tablecheck(FILE *table) {

	// Check IP vals
	if(!check_ip(table)) {
		// IP vals are invalid
		fprintf(stderr, "ERROR: tablecheck failed for IP (Initial Permutation) values.\n");
		return false;
	}

	// Check E vals
	if(!check_e(table)) {
		// E vals are invalid
		fprintf(stderr, "ERROR: tablecheck failed for E (Expansion) values.\n");
		return false;
	}

	// Check P vals
	if(!check_p(table)) {
		// P vals are invalid
		fprintf(stderr, "ERROR: tablecheck failed for P (Permutation) values.\n");
		return false;
	}
	
	// Check S# vals
	char header[3];
	for(int i=1; i<=8; i++) {
		sprintf(header, "S%d=", i);
		if(!check_s(table, header)) {
			// S# vals are invalid
			fprintf(stderr, "ERROR: tablecheck failed for S%d (Substitution) values.\n", i);
			return false;
		}
	}
	
	// Check V vals
	if(!check_v(table)) {
		// V vals are invalid
		fprintf(stderr, "ERROR: tablecheck failed for V (Circular Rotation) values.\n");
		return false;
	}
	
	// Check PC1 vals
	if(!check_pc1(table)) {
		// PC1 vals are invalid
		fprintf(stderr, "ERROR: tablecheck failed for PC1 (Permutated Choice 1) values.\n");
		return false;
	}
	
	// Check PC2 vals
	if(!check_pc2(table)) {
		// PC2 vals are invalid
		fprintf(stderr, "ERROR: tablecheck failed for PC2 (Permutated Choice 2) values.\n");
		return false;
	}
	
	return true;
	
	// PSEUDO-CODE
	// - Use read_line_vals method to search through file until finds a line starting with header
	// - Read each item in the line into an array of ints, using comma delimiters to separate
	// - Run whatever test is needed on the array to ensure that all the values are valid
	//   - Usually something like counting the instances of each number to ensure correct permutation
	// - Repeat for all headers
}