Top
Systemwalker Operation Manager  Reference Guide
FUJITSU Software

16.1.2 Calendar Registration API (Mp_AddCalendar2)

This section explains the calendar registration API (Mp_AddCalendar2).

Synopsis

int Mp_AddCalendar2 (char *APL_name,
            char *cal_name,
            CALENDAR_WDAT2 *cal_dat2) ;

Description

The Mp_AddCalendar2 function registers new calendars.

Holidays and substitute holidays for which the date changes from year to year can also be registered. Past dates can not be set.

Parameters

APL_name

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

Specify NULL at the end of the requested source application name. Do not use names that begin with "Mp_" or "_CAL_."

cal_name

Specify the storage area address for the calendar name to be registered. Specify the calendar name with up to 24 bytes and set NULL at the end.

cal_dat2

Specify the address of the calendar update information structure (CALENDAR_WDAT2).

Return Values

Return Value

Meaning

Action

0

Normal termination.

-

-2

Same calendar name already exists.

Change the specified calendar name.

-5

SYSTEM_CALENDAR specified.

Specify something other than "SYSTEM_CALENDAR".

-6

Not system administrator (a user in the Administrators group on Windows or a superuser on UNIX).

Execute as a system administrator (a member of the Administrators group or the superuser).

-8

Error in calendar information.

Review the specified calendar information (the calendar update information structure "CALENDAR_WDAT2").

-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.

-15

Unspecifiable character specified for calendar name.

Do not use invalid characters in the calendar name.

Calendar names cannot contain spaces, user-defined characters, or any of the following characters:

? \ * " < > | / : , ;

-16

Error in file operation (write 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.

Remarks

Past dates are all set as working days.

If quoting the calendar in Jobscheduler, the relevant day is calculated as a working day.

Format of Calendar Update Information Structure (CALENDAR_WDAT2)

[32-bit version]


typedef struct CALENDAR_WDAT2_TAG {

short year ; // This year in 4 digits

short sub_holiday ; // Specify whether to enable or disable substitute

// holiday

unsigned char holiday_w[12] ; // Each years
' day of the week information (for 12
// months)

unsigned long holiday_d[12] ; // Each years
' date information (for 12
// months)

unsigned char holiday_m[12][6] ; // Each years
' week information (for 12 months x 6
// weeks)

short cal_dat[3][12][31] ; // 3 years
' (from year) calendar information

}CALENDAR_WDAT2 ;

[64-bit version]


typedef struct CALENDAR_WDAT2_TAG {

short year ; // This year in 4 digits

short sub_holiday ; // Specify whether to enable or disable substitute

// holiday

unsigned char holiday_w[12] ; // Each years' day of the week information (for 12

// months)
unsigned
int holiday_d[12] ; // Each years' date information (for 12
// months)

unsigned char holiday_m[12][6] ; // Each years' week information (for 12 months x 6

// weeks)

short cal_dat[3][12][31] ; // 3 years' (from year) calendar information


}CALENDAR_WDAT2 ;

year

The standard year (first of the 3 years) in the Western calendar is set, with 4 digits, with 3 years' calendar information.

sub_holiday

Specify whether or not the substitute holiday is enabled. Specify the following values:

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). Specify the day(s) of the week of every year's holidays. 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). Specify the date(s) of every year's holidays. 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, 6 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

This is a three-year calendar from the year specified in year. It reflects annual holiday information. Specify the following values:

Value

Calendar information

0

Impossible dates (February 30, etc.)

1

Holiday

2

Working day

Program Example

Below is an example program of the calendar registration API:

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

#include <f3crhcap.h>

extern  void set_cal_dat2( CALENDAR_WDAT2 *) ;

void main() {

        int ret ;
        int count ;
        CALENDAR_WDAT2 cal_dat2 ;

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

        /*.......... calendar information setting ..........*/
        /* this year's settings */
        cal_dat2.year = 2000 ;

        /* enable substitute holiday */
        cal_dat2.sub_holiday = 1 ;

        /* make Saturday every week a holiday */
        for ( count = 0 ; count < 12 ; count++ ) {
                cal_dat2.holiday_w[count] = (unsigned char)0x82 ;
        }

        /* set calendar information for 3 years */
        set_cal_dat2( &cal_dat2 ) ;

        /* calendar registration */
        ret = Mp_AddCalendar2( "Test Pro", "calendar_1", &cal_dat2 ) ;

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

        exit ( 0 ) ;

}