Introduction

This chapter introduces ProFrame’s utilities and APIs and describes header files required to use them.

1. Overview

ProFrame has the following 6 utilities depending on the data type to process.

  • Date utility

    Processes date and time data expressed as a string or number. This utility includes APIs that get, calculate, compare, and convert date and time information.

  • Number utility

    The basic numeric data type of the C language has too few significant digits or an issue with precision. To overcome the limitations, ProFrame provides the PfmNumber data type that has 38 significant digits with high precision. The data type has the following structure.

    typedef struct {
       unsigned char size;
       unsigned char signexp;
       unsigned char coef[NUMBER_MAX_LEN];
    } PfmNumber;

    Handles number (PfmNumber data) processing such as various calculation, comparison, and conversion.

  • String utility

    Handles string processing such as conversion and comparison.

  • Long utility

    Handles Long data processing such as rounding off, up, and down.

  • Error handling and debugging utility

    Processes error handling and debugging.

  • Other APIs

    Other APIs than the ones described in previous chapters.

When developing services or application modules by using ProFrame, use the previous appropriate utilities.

2. Header Files

To use each utility and API, add the following to source code.

#include <pfmUtility.h>

To use the date, number, and error handling and debugging utilities, additionally add the following to source code.

Utility Header File

Date

#include <pfmDateUtilily.h>

Number

#include <pfmNumber.h>

Error handling and debugging

#include <pfmLogMacro.h>

3. API List

The following briefly describes APIs for each utility.

3.1. Date Utility

The following are APIs related to date and time processing.

API Description

pfmIsValidDate

Checks the validity of an input date.

pfmIsValidTime

Checks the validity of an input time.

pfmIsInYyyymmdd

Checks the format of an input date.

pfmDateCmp

Compares the order of two input dates.

pfmGetDate

Gets the current system date in the format of yyyymmdd.

pfmGetTime

Gets the current system time in the format of hhmmss.

pfmGetUTime

Gets the current system time in the format of hhmmssuuuuuu.

pfmGetNTime

Gets the current system time in the format of hhmmssnnnnnnnnn.

pfmGetDateTime

Gets the current system date and time in the format of yyyymmddhhmmss.

pfmGetDateUTime

Gets the current system date and time in the format of yyyymmddhhmmssuuuuuu.

pfmGetDateNTime

Gets the current system date and time in the format of yyyymmddhhmmssnnnnnnnnn.

pfmGetLastDayOfFebruary

Returns the number of days in February of the input year.

pfmIsLeapYear

Checks whether the input year is a leap year.

pfmGetWeekDay

Gets the day of the week of the input date.

pfmWeekDayToDate

Gets the date that corresponds to the input day of the input week.

pfmDateFormat

Converts a date to a string in a desired format.

pfmDateJulianToGregorian

Converts a date from Julian to Gregorian.

pfmDateGregorianToJulian

Converts a date from Gregorian to Julian.

pfmDateSolarToLunar

Converts a solar date to a lunar date.

pfmDateLunarToSolar

Converts a lunar date to a solar date.

pfmCountDays

Calculates the number of days and months between a start date and an end date.

pfmCalcDate

Calculates the end date if a start date is given or the start date if an end date is given.

pfmDateCalcQuarterStart DateEndDate

Gets an input date’s quarter information and the start and end dates of the quarter.

pfmDateGetErrorMsg

Returns a date utility error message.

3.2. Number Utility

The following are APIs related to number processing.

API Description

pfmNumAssign

Assigns a PfmNumber parameter to another PfmNumber parameter.

pfmNumToLong

Converts a PfmNumber value to a Long value.

pfmNumGetFromLong

Converts a Long value to a PfmNumber value.

pfmNumToDouble

Converts a PfmNumber value to a Double value.

pfmNumGetFromDouble

Converts a Double value to a PfmNumber value.

pfmNumGetFromDouble2

Rounds off a Double value and then converts it to a PfmNumber value.

pfmNumGetFromStr

Converts a value expressed as a NULL-terminated string to a PfmNumber value.

pfmNumGetFromStrn

Reads a given length of an input string and then converts it to a PfmNumber value.

pfmNumGetStrLPadZeroN

Converts a PfmNumber value to a Char value and then aligns it to the right. Blanks created during the alignment are padded with 0.

pfmNumToStr

Converts a PfmNumber value to a Char string.

pfmNumToStrn

Converts a PfmNumber value to a Char string with a given length.

pfmNumCmp

Compares two PfmNumber values.

pfmNumCmpAbs

Compares absolute values of two PfmNumber values.

pfmNumIsInteger

Checks whether the input value is an integer.

pfmNumCmpLong

Compares a PfmNumber value and a Long value.

pfmNumCmpStr

Compares a PfmNumber value and a Char string.

pfmNumCmpStrn

Compares a PfmNumber value and a Char string with a given length.

pfmNumNegate

Gets a negative value of a PfmNumber value.

pfmNumAbs

Gets an absolute value of a PfmNumber value.

pfmNumAdd

Adds two PfmNumber values.

pfmNumSub

Subtracts the second PfmNumber value from the first PfmNumber value.

pfmNumMul

Multiplies two PfmNumber values.

pfmNumDiv

Divides the first PfmNumber value by the second PfmNumber value.

pfmNumIntDiv

Divides the first PfmNumber value by the second PfmNumber value and then converts the result value to an integer.

pfmNumMod

Finds the remainder of dividing the first PfmNumber value by the second PfmNumber value.

pfmNumModDiv

Finds the quotient and remainder of dividing the first PfmNumber value by the second PfmNumber value.

pfmNumTruncAt

Rounds down a PfmNumber value to a given position.

pfmNumRoundAt

Rounds off a PfmNumber value to a given position of decimal places.

pfmNumTrunc

Rounds down the fraction part of a PfmNumber value.

pfmNumRound

Rounds off a PfmNumber value to one digit.

pfmNumSqr

Raises a PfmNumber value to a power.

pfmNumPower

Raises the first PfmNumber value to the power of the second PfmNumber value.

pfmNumInc

Adds two PfmNumber values and then assigns the result to the first PfmNumber value.

pfmNumDec

Subtracts the second PfmNumber value from the first PfmNumber value and then assigns the result to the first PfmNumber value.

pfmNumAddStr

Converts a string to a number and then adds it to a PfmNumber value.

pfmNumSubStr

Converts a string to a number and then subtract it from a PfmNumber value.

pfmNumMulStr

Converts a string to a number and then multiples it and a PfmNumber value.

pfmNumDivString

Converts a string to a number and then divides a PfmNumber value by it.

pfmNumAddStrn

Converts a fixed-size string to a number and then adds it to a PfmNumber value.

pfmNumSubStrn

Converts a fixed-length string to a number and then subtract it from a PfmNumber value.

pfmNumMulStrn

Converts a fixed-length string to a number and then multiples it and a PfmNumber value.

pfmNumDivStrn

Converts a fixed-length string to a number and then divides a PfmNumber value by it.

pfmNumAddLong

Adds a PfmNumber value and a Long value.

pfmNumSubLong

Subtracts a Long value from a PfmNumber value.

pfmNumMulLong

Multiplies a PfmNumber value and a Long value.

pfmNumDivLong

Divides a PfmNumber value by a Long value.

pfmNumModDivLong

Finds the quotient and remainder of dividing the PfmNumber value by a Long value.

pfmNumAddN

Adds up an input value as many times as an input count.

pfmNumMulN

Multiplies an input value as many times as an input count.

pfmNumPowLong

Multiplies an input value y times.

pfmNumRound

Rounds off a PfmNumber value to a given position of decimal places and then assigns the result value to the first parameter.

pfmNumRoundUp

Rounds up a PfmNumber value to a given position of decimal places and then assigns the result value to the first parameter.

pfmNumCalc

Calculates arithmetic operations and outputs the result as PfmNumber values.

pfmNumCalcLong

Calculates arithmetic operations and outputs the result as Long values.

pfmNumToCommaStrN

Converts a PfmNumber number to a string including commas.

pfmNumToInFmtStrN

Converts a PfmNumber number to a string in a specific format.

pfmNumPrint

Converts a PfmNumber value to a temporary string for a message.

pfmNumPrintComma

Converts a PfmNumber value to a temporary string for a message and adds thousands separators.

pfmNumFindLocationOfLeast SignificantDigit

Finds the number of decimal places in a PfmNumber value.

pfmNumDump

Converts a PfmNumber value to a Hex string.

pfmNumGetErrorMsg

Returns an error message when a Number utility error occurs.

3.3. String Utility

The following are APIs related to string processing.

API Description

pfmStrIsLower

Checks whether all characters in a null-terminated string are lowercase.

pfmStrnIsLower

Checks whether all characters in a fixed-length string are lowercase.

pfmStrIsUpper

Checks whether all characters in a null-terminated string are uppercase.

pfmStrnIsUpper

Checks whether all characters in a fixed-length string are uppercase.

pfmStrIsAlpha

Checks whether all characters in a null-terminated string are alphabet.

pfmStrnIsAlpha

Checks whether all characters in a fixed-length string are alphabet.

pfmStrIsAlphaNumeric

Checks whether all characters in a null-terminated string are alphabet or digits.

pfmStrnIsAlphaNumeric

Checks whether all characters in a fixed-length string are alphabet or digits.

pfmStrIsNull

Checks whether the first character of a string is null ('\0').

pfmStrnIsNull

Checks whether all characters in a string are null ('\0').

pfmStrIsNumber

Checks whether all characters in a null-terminated string are digits.

pfmStrnIsNumber

Checks whether all characters in a fixed-length string are digits.

pfmStrIsSpace

Checks whether all characters in a null-terminated string are spaces.

pfmStrnIsSpace

Checks whether all characters in a fixed-length string are spaces.

pfmStrIsSpaceNull

Checks whether all characters in a null-terminated string are spaces or whether the first character is null.

pfmStrnIsSpaceNull

Checks whether all characters in a fixed-length string are spaces or whether the first character is null.

pfmStrIsZero

Checks whether all characters in a null-terminated string are 0.

pfmStrnIsZero

Checks whether all characters in a fixed-length string are 0.

pfmStrIsValidDigit

Checks whether a given registration number or corporate registration number is valid.

pfmStrIsKsc

Checks whether all characters in a null-terminated string are Korean characters.

pfmStrnIsKsc

Checks whether all characters in a fixed-length string are Korean characters.

pfmStrnIsKorean

Checks whether a string has at least one Korean character.

pfmStrLTrim

Trims left spaces of a null-terminated string.

pfmStrnLTrim

Trims left spaces of a fixed-length string.

pfmStrRTrim

Trims right spaces of a null-terminated string.

pfmStrnRTrim

Trims right spaces of a fixed-length string.

pfmStrTrim

Trims left and right spaces of a null-terminated string.

pfmStrnTrim

Trims left and right spaces of a fixed-length string.

pfmStrRemoveSpace

Removes spaces (0x20) from a null-terminated string.

pfmStrnRemoveSpace

Removes spaces (0x20) from a fixed-length string.

pfmStrCmpLTrim

Trims left spaces of two strings and then compares them.

pfmStrCmpRTrim

Trims right spaces of two strings and then compares them.

pfmStrCmpTrim

Trims left and right spaces of two strings and then compares them.

pfmStrCmpRemoveSpace

Removes spaces (0x20) of two strings and then compares them.

pfmStrCpyRPadSpace

Copies a string as long as specified and pads the ending remaining part with spaces (0x20).

pfmStrCpyRPadZero

Copies a string as long as specified, justifies it right, and pads the starting remaining part with 0.

pfmStrCpySkip

Removes a specified character from a string and copies it to another string.

pfmStrExtractDigitN

Extracts digits from a null-terminated string and converts them to an integer string.

pfmStrCmpMulti

Compares a string with a base string.

pfmStrGetIndex

Searches a base string from N null-terminated strings.

pfmToLower

Converts a null-terminated string to lowercase regardless of its length.

pfmToLowern

Converts a fixed-length string to lowercase.

pfmUpper

Converts a null-terminated string to uppercase regardless of its length.

pfmToUppern

Converts a fixed-length string to uppercase.

pfmAscToInt

Converts a string to Int type.

pfmAscToLong

Converts a string to Long type.

pfmStrToLong

Converts a null-terminated string to Long type.

pfmStrnToLong

Converts a fixed-length string to Long type.

pfmLongToStrn

Converts a Long number to a string.

pfmLongToStrnLpadZero

Converts a Long number to a string, aligns it to the right, and pads spaces with 0.

pfmStrAddLong

Adds a Long integer to a given string and then converts it to a string.

pfmStrSubLong

Subtracts a Long integer from a given string and then converts it to a string.

pfmStrToHex

Converts a null-terminated string to hexadecimal.

pfmStrAscToEbc

Converts an ASCII string to EBCDIC.

pfmStrEbcToAsc

Converts an EBCDIC string to ASCII.

pfmStrEngToKsc

Converts English code to KSC5601.

pfmStrKscToEng

Converts a KSC5601 string to English code.

pfmStrKscToIbm

Converts a KSC5601 string to IBM 2-byte combination code.

pfmStrIbmToKsc

Converts IBM 2-byte combination code to a KSC5601 string.

pfmStrKscToSosi

Converts a KS 2-byte complete Korean string to IBM SOSI Korean code.

pfmStrSosiToKsc

Converts IBM SOSI Korean code to a KS 2-byte complete Korean string.

pfmStrKscConvEng

Converts a Korean string to an English string.

pfmStrKscToRemoveSpace

Removes spaces from a KSC5601 Korean string.

pfmStrKscToTwoBytes

Converts 1-byte characters included in a string to KSC5601 2-byte characters.

pfmStrKscToOneByte

Converts KSC5601 2-byte characters included in a string to 1-byte characters.

pfmStrnConv

Converts a string with a given conversion method.

pfmStrnCpyConv

Converts a string with a given conversion method and then copies it to another string.

pfmStrRemoveBrokenKorean

Removes broken Korean characters from an input string.

pfmStrIndexOfBrokenKorean

Gets the location of the first broken Korean character in an input string.

pfmStrRemoveBrokenKsc

Removes broken characters from an input string and displays full-width Korean characters. It complements pfmStrRemoveBrokenKorean.

pfmStrTrimKscN

Removes blank or KSC5601 spaces before or after a string.

pfmStrGetErrorMsg

Returns an error message when a String utility error occurs.

3.4. Long Utility

The following are APIs related to Long data processing.

API Description

pfmLongRoundAt

Rounds off an input value to a given position of decimal places.

pfmLongCeilAt

Rounds up an input value to a given position of decimal places.

pfmLongFloorAt

Rounds down an input value to a given position of decimal places.

3.5. Error Handling and Debugging Utility

The following are APIs related to error handling and debugging processing.

API Description

PFM_ERR

Records error information in a log file of the server.

PFM_DBG

Records debugging information in a log file of the server.

PFM_TRY

Records trace log for a function before and after the function is called.

PFM_TRYNJ

Records trace log for a function before and after the function is called.

PFM_HEXDUMP

Records Hexadecimal code log about buffer data.

pfmUtilGetErrorMsg

Returns an error message when a Date, Number, or String utility error occurs.

3.6. Other APIs

The following are other APIs than the ones described previously.

API Description

pfmCalcAge

Gets a resident registration number and calculates the numbers of years, months, and days s/he has lived.

PFM_MIN

Gets two values and returns the smaller one.

PFM_MIN3

Gets three values and returns the smallest one.

PFM_MAX

Gets two values and returns the larger one.

PFM_MAX3

Gets three values and returns the largest one.

PFM_ABS

Returns an absolute value of an input value.