Пример #1
0
int main()
{
	int C, i;
	char input_buf[81] = { '\0', };
	char output_buf[81] = { '\0', };

	fscanf(stdin, "%d", &C);
	
	
	for (i = 0; i < C; i++)
	{
		fscanf(stdin, "%s", input_buf);
		decode_percent_encoding(output_buf, input_buf);
		fprintf(stdout, "%s\n", output_buf);
	}


	return 0;
}
/**
 * Decodes the percent-encoded character array element into
 * a non-percent-encoded character array element.
 *
 * @param p0 the destination model (Hand over as reference!)
 * @param p1 the destination model count
 * @param p2 the destination model size
 * @param p3 the source current position (Hand over as reference!)
 * @param p4 the source remaining count
 */
void decode_percent_encoding_vector_element(void* p0, void* p1, void* p2, void* p3, void* p4) {

    if (p4 != *NULL_POINTER_MEMORY_MODEL) {

        int* rem = (int*) p4;

        if (p3 != *NULL_POINTER_MEMORY_MODEL) {

            void** pos = (void**) p3;

            log_terminated_message((void*) DEBUG_LEVEL_LOG_MODEL, (void*) L"Decode percent-encoding vector element.");

            // The unreserved characters.
            void* u = *pos;
            int uc = *NUMBER_0_INTEGER_MEMORY_MODEL;

            // The break flag.
            int b = *NUMBER_0_INTEGER_MEMORY_MODEL;

            while (*NUMBER_1_INTEGER_MEMORY_MODEL) {

                if (*rem <= *NUMBER_0_INTEGER_MEMORY_MODEL) {

                    break;
                }

                select_percent_encoding_vector_element(p0, p1, p2, (void*) &b, p3, p4);

                if (b != *NUMBER_0_INTEGER_MEMORY_MODEL) {

                    break;

                } else {

                    // Increment unreserved characters count.
                    uc++;
                }
            }

            // Append any unreserved characters found up to here,
            // no matter whether an unreserved character follows
            // or no unreserved character at all was found.
            append(p0, p1, p2, u, (void*) &uc, (void*) CHARACTER_MEMORY_ABSTRACTION, (void*) CHARACTER_MEMORY_ABSTRACTION_COUNT);

            if (b != *NUMBER_0_INTEGER_MEMORY_MODEL) {

                // A % sign was found that indicates a reserved character.
                decode_percent_encoding(p0, p1, p2, p3, p4);

                // Process further characters by calling decode function recursively.
                //
                // CAUTION! Only call this function if a reserved character was found.
                // Otherwise, the loop was left due to no more remaining characters,
                // so that nothing is left to be processed here.
                decode_percent_encoding_vector_element(p0, p1, p2, p3, p4);
            }

        } else {

            log_terminated_message((void*) ERROR_LEVEL_LOG_MODEL, (void*) L"Could not decode percent-encoding vector element. The current position is null.");
        }

    } else {

        log_terminated_message((void*) ERROR_LEVEL_LOG_MODEL, (void*) L"Could not decode percent-encoding vector element. The remaining count is null.");
    }
}