Top
Systemwalker Operation Manager  Reference Guide
FUJITSU Software

16.1.5 Calendar Information Acquisition API

This section explains the calendar information acquisition API (Mp_GetCalendar2).

Synopsis

int Mp_GetCalendar2 (char *APL_name,
             char *cal_name,
             short mode,
             CALENDAR_RDAT2 *cal_dat2) ;

Description

The Mp_GetCalendar2 function acquires calendar information. Holidays and substitute holidays which change from year to year can also be acquired.

When acquiring the information on SYSTEM_CALENDAR on Windows, you can specify whether operation pattern type is included or only information on working days or holidays is acquired. [Windows]

Parameters

APL_name

Specify the storage area address for the requested source application name (64 bytes or less).

Specify NULL at the end. Do not use names that begin with "Mp_" or "_CAL_."

cal_name

Specify the calendar name storage area address for the calendar information to be acquired. Specify the calendar name within 24 bytes and set NULL at the end.

mode

[Windows]

Specify whether or not you acquire the pattern type as follows (this is valid when you acquire the SYSTEM_CALENDAR information).

0:

The pattern type is not acquired.

1:

The pattern type is acquired.

[UNIX]

Specify 0.

cal_dat2

Specify the address of the calendar reference information structure (CALENDAR_RDAT2).

Return Values

Return Value

Meaning

Action

0

Normal termination.

-

-1

Calendar does not exist.

Specify the name of an existing calendar.

-10

Calendar service/daemon is not running.

Start the calendar service or daemon.

-11

There is not enough memory.

Use one of the following methods to increase the amount of available memory:

  • Close other applications.

  • Add more physical memory.

-16

Error in file operation (read error).

Check that there is enough space available on the hard disk and that the hard disk is functioning normally.

-17

Illegal calendar name length.

Calendar names can be no more than 24 bytes long.

Format of Calendar Reference Information Structure (CALENDAR_RDAT2)

[32-bit version]

typedef struct CALENDAR_RDAT2_TAG {
 short year ;                      // This year in 4 digits
 short sub_holiday ;               //  Specify whether to enable substitute holiday
 unsigned char holiday_w[12] ;     // Each year's day of the week information (for 12
                                   // months)
 unsigned long holiday_d[12] ;     // Each year's date information (for 12 months)
 unsigned char holiday_m[12][6] ;  // Each year's week information (for 12 months x 6
                                   // weeks)
 short cal_dat[4][12][31] ;        // 4 year's (from year-1) calendar information
} CALENDAR_RDAT2 ;

[64-bit version]

typedef struct CALENDAR_RDAT2_TAG {
 short year ;                      // This year in 4 digits
 short sub_holiday ;               //  Specify whether to enable substitute holiday
 unsigned char holiday_w[12] ;     // Each year's day of the week information (for 12
                                   // months)
 unsigned int holiday_d[12] ;     // Each year's date information (for 12 months)
 unsigned char holiday_m[12][6] ;  // Each year's week information (for 12 months x 6
                                   // weeks)
 short cal_dat[4][12][31] ;        // 4 year's (from year-1) calendar information
} CALENDAR_RDAT2 ;

year

The standard year (the second of the 4 years) for the set 4 years calendar information is set in Western calendar with 4 digits. Normally, this year is set as the standard.

sub_holiday

Sets whether or not substitute holidays are enabled. The following values are set:

Value

Substitute holiday valid/invalid

0

Invalid

1

Valid

holiday_w

This is the days of the week information for each year (12 month array). Each year's holidays' day(s) of the week are set. Set the first bit for Sunday, the second for Monday, and the third through seventh bits for Tuesday through Saturday respectively. Of the months specified in the array, the days of the week whose bits are set to ON will be holidays.

holiday_d

This is the date information for each year (12 month array). Each year's holiday's dates are set. From the top, specify the first bit for the first day, the second bit for the second day, and the third through thirty first bits for the third through thirty first days respectively. Every year, of the months specified in the array, the dates whose bits are set to ON will be holidays.

holiday_m

This is the weekly information for each year (an array of 12 months x 6 weeks). Specify the holidays for which the date changes every year. The first array specifies the month (1 to 12), the second array specifies the week number (1 to 5 is first to fifth week, n6 is the last week). Set the first bit for Sunday, the second for Monday, and the third through seventh bits for Tuesday through Saturday respectively. Every year, the days of the week whose bits are set to ON of the week specified in the second array of the month specified in the first array will be holidays.

cal_dat

A four-year calendar from the year before year is set. The information to be set is shown below:

[Windows]

Value

Calendar information

0

Impossible dates (February 30, etc.)

1

Holiday

2

Working day (when the specified mode is 0)

3

Standard pattern (when the specified mode is 1)

4

Non-standard pattern 1 (when the specified mode is 1)

5

Non-standard pattern 2 (when the specified mode is 1)

6

Non-standard pattern 3 (when the specified mode is 1)

7

Non-standard pattern 4 (when the specified mode is 1)

8

Non-standard pattern 5 (when the specified mode is 1)

9

Non-standard pattern 6 (when the specified mode is 1)

10

Non-standard pattern 7 (when the specified mode is 1)

11

Non-standard pattern 8 (when the specified mode is 1)

12

Separate 1 (when the specified mode is 1)

11+n

Separate n (when the specified mode is 1)

2xxx

Holiday/Separate (when the specified mode is 1). xxx corresponds to the Separate ID.

[UNIX]

Value

Calendar information

0

Impossible dates (February 30, etc.)

1

Holiday

2

Working day

Program Example

Below is an example program of the calendar information acquisition API

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>

#include <f3crhcap.h>

extern  void put_cal_dat2( CALENDAR_RDAT2*) ;

void main() {

        int ret ;
        CALENDAR_RDAT2 cal_dat2 ;

        /*.......... initialization............*/
        memset( &cal_dat2, 0x00, sizeof( CALENDAR_RDAT2) ) ;

        /* calendar information acquisition */
        ret = Mp_GetCalendar2( "Test Pro", "calendar_1", 0, &cal_dat2 ) ;

        printf( "ret= %d\n", ret ) ;

        if ( ret == 0 )
                put_cal_dat2( &cal_dat2 ) ;

        exit ( 0 ) ;
}