Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Base 6 4 In this assignment, you will write a simple base 6 4 encoding utility to familiarize yourself with the basics of C programming.

Base64
In this assignment, you will write a simple base64 encoding utility to familiarize yourself with the basics of C programming. You will be using, exclusively, a small subset of the C standard library to accomplish this task. You will practice:
Parsing command-line arguments
Using the standard io library features
Handling errors
Manipulating data and working with arrays
Learning Outcomes
How to write a C program to solve a problem? (Module 1 MLO 4)
How can programs invoke OS services using system calls? (Module 1 MLO 5)
How do you interact with the user in C programs? (Module 1 MLO 6)
How are C programs transformed into an executable form? (Module 1 MLO 7)
Specification
NAME
base64- Base64 encode data and print to standard output
SYNOPSIS
base64[FILE]
DESCRIPTION
Base64 encode FILE, or standard input, and output to standard output.
With no FILE, or if FILE is -, read from standard input.
Encoded lines are wrapped every 76 characters.
The data are encoded according to the standard algorithm and standard base64 alphabet described in RFC 4648.
STDIN
The standard input shall be used only if no FILE operand is specified, or if the FILE operand is -.
STDOUT
The standard output shall contain the base64 encoded output, wrapped to 76 characters.
STDERR
The standard error shall be used only for error reporting. All errors must be reported to standard error.
EXIT STATUS
0, if successful.
>0, if an error occurs.
Additional Requirements
Your program may not use Variable Length Arrays (VLAs), which are declared with a non-constant expression as the array size (e.g. char input[n]). The compiler option -Werror=vla will prevent compilation with VLAs.
Your program must compile against the c99 standard, using the compiler option -std=c99.
In other words,
gcc -std=c99-Werror=vla -o base64...
The provided makefile compiles with the appropriate options, and you do not need to modify it,
$ make -B release
gcc -std=c99-Wall -Werror=vla -Werror -O3-c -o build/release/base64.o src/base64.c
gcc -o build/release/base64 build/release/base64.o
$ make -B debug
gcc -std=c99-Wall -Werror=vla -g -c -o build/debug/base64.o src/base64.c
gcc -o build/debug/base64 build/debug/base64.o
Gradescope will compile your program using its own copy of the makefile; you need only to upload your *.c source files and nothing else.
Additionally, your program must run in constant space complexity while accepting input of any arbitrary length. In other words, you may not dynamically allocate memory. The idea is that your program will process input in small chunks, until reaching end of input. Do not attempt to buffer the entire input before encoding it. If found to violate this requirement, you will receive a 0.
When exiting due to an error, your program must print an informative error message to the standard error stream, stderr and exit with a non-zero exit status. You are encouraged to use the convenience function err(int exit_val, char const *fmt,...) exposed by the header file, which both exits the program and prints an informative error message in a single operation. On the same note, you must not print to stderr and must exit with 0 or EXIT_SUCCESS if you don't encounter any errors.
Your program must not have any memory leaks; since you are prohibited from dynamically allocating space for input, the only place you should worry about encountering a memory leak is with opened files. See the advice below for ensuring you meet this requirement.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

7. Understand the challenges of multilingualism.

Answered: 1 week ago

Question

5. Give examples of variations in contextual rules.

Answered: 1 week ago