Browse Source

More progress

master
Grant Montgomery 2 years ago
parent
commit
d13ea31eab
  1. 71
      columnar.c
  2. 2
      in
  3. 2
      inout
  4. 2
      out

71
columnar.c

@ -69,7 +69,7 @@ int dump_buffer(char *buffer, unsigned int bufsize,
/* open the output or quit on error */
FILE *OUTPUT;
if ((OUTPUT = fopen(output, "w+")) == NULL) {
if ((OUTPUT = fopen(output, "a+")) == NULL) {
printf("Problem truncating output file '%s'; errno: %d\n", output, errno);
return 1;
}
@ -90,8 +90,6 @@ int dump_buffer(char *buffer, unsigned int bufsize,
int pad_buffer(char *buffer, unsigned int bufsize, unsigned int rbuf_index) {
/* pad_buffer pads the empty space in a buffer
* buffer -- pointer to buffer
* bufsize -- size of 'buffer'
@ -101,8 +99,10 @@ int pad_buffer(char *buffer, unsigned int bufsize, unsigned int rbuf_index) {
*/
int padded = 0;
buffer[rbuf_index] = 'X';
printf("%d : X\n", rbuf_index);
for(int g = rbuf_index+1; g < bufsize; g++) {
buffer[g] = 'Y';
printf("%d : Y\n", g);
padded++;
}
return padded;
@ -133,8 +133,6 @@ int unpad_buffer(char *buffer, unsigned int bufsize) {
}
int main(int argc, char *argv[]) {
// int i = 0; /* iterator we'll reuse */
printf("main\n");
if (argc < 4) {
printf("Missing arguments!\n\n");
@ -213,31 +211,48 @@ int main(int argc, char *argv[]) {
******************/
printf("Do stuff here\n");
char dataByte;
for(int l = 0; l < blocks; l++) {
//Fill block from filesize
printf("----------\nBlock %d\n----------\n", l);
for(int f = 0; f < dim*dim; f++) {
dataByte = fgetc(INPUT);
if(dataByte != EOF) {
read_buf[f] = dataByte;
if(dataByte == '\n') {
printf("%d : \\n\n", f);
}
else {
printf("%d : %c\n", f, dataByte);
}
}
}
if(MODE != ENCODE) {
int f;
for(int l = 0; l <= blocks; l++) {
//Fill block from filesize
printf("----------\nBlock %d\n----------\n", l);
for(f = 0; f < dim*dim; f++) {
dataByte = fgetc(INPUT);
if(dataByte != EOF) {
read_buf[f] = dataByte;
if(dataByte == '\n') {
printf("%d : \\n\n", f);
}
else {
printf("%d : %c\n", f, dataByte);
}
}
else break;
}
if(MODE != ENCODE) {
//Transpose Block
printf("Decode Block");
transpose_buffer(write_buf, read_buf, dim);
if(blocks - l == 1) {
//Remove Padding of final block
//Dump final block to output file
}
else {
//Transpose block
printf("Depad Block\n");
}
//Dump final block to output file
printf("Dump Decode Block");
}
else {
if(f < dim*dim) {
if(TRANSMODE == TRANS) {
//Transpose block
printf("Encode Block\n");
transpose_buffer(write_buf, read_buf, dim);
}
//Dump Block to output file
}
}
printf("Dump Encode Block\n");
dump_buffer(write_buf, bufsize, bufsize, output);
}
}
fclose(INPUT);

2
in

@ -1 +1 @@
hello friends.!!!
hello friends.!!!gh

2
inout

@ -0,0 +1,2 @@
hello friends.!!!gh
XYYYYYYXYYYYYYYY

2
out

@ -0,0 +1,2 @@
hlfeorl ies!n.!d!ghYY
YYXYY
Loading…
Cancel
Save