Change this program example to suit your needs for setting the clock on your Coprocessor.
/*-------------------------------------------------------------------*/ /* Set the clock on the card, based on a string from */ /* the command line. The command line string must be of */ /* form YYYYMMDDHHMMSSWW, where WW is the day of week (01 */ /* means Sunday and 07 means Saturday). */ /* */ /* */ /* COPYRIGHT 5769-SS1 (C) IBM CORP. 1999 */ /* */ /* This material contains programming source code for your */ /* consideration. These examples have not been thoroughly */ /* tested under all conditions. IBM, therefore, cannot */ /* guarantee or imply reliability, serviceability, or function */ /* of these program. All programs contained herein are */ /* provided to you "AS IS". THE IMPLIED WARRANTIES OF */ /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ /* ARE EXPRESSLY DISCLAIMED. IBM provides no program services for */ /* these programs and files. */ /* */ /* */ /* Note: Input format is more fully described in Chapter 2 of */ /* IBM CCA Basic Services Reference and Guide */ /* (SC31-8609) publication. */ /* */ /* Parameters: */ /* char * new time 16 characters */ /* */ /* Example: */ /* CALL PGM(SETCLOCK) PARM('1999021011375204') */ /* */ /* */ /* Note: This program assumes the device to use is */ /* already identified either by defaulting to the CRP01 */ /* device or by being explicitly named using the */ /* Cryptographic_Resource_Allocate verb. Also this */ /* device must be varied on and you must be authorized */ /* to use this device description. */ /* */ /* Use these commands to compile this program on the system: */ /* ADDLIBLE LIB(QCCA) */ /* CRTCMOD MODULE(SETCLOCK) SRCFILE(SAMPLE) */ /* CRTPGM PGM(SETCLOCK) MODULE(SETCLOCK) */ /* BNDSRVPGM(QCCA/CSUACFC) */ /* */ /* Note: Authority to the CSUACFC service program in the */ /* QCCA library is assumed. */ /* */ /* The Common Cryptographic Architecture (CCA) verb used is */ /* Cryptographic_Facilities_Control (CSUACFC). */ /* */ /*-------------------------------------------------------------------*/ #include "csucincl.h" /* header file for CCA Cryptographic */ /* Service Provider */ #include <stdio.h> #include <string.h> #include <stdlib.h> /*-------------------------------------------------------------------*/ /* standard return codes */ /*-------------------------------------------------------------------*/ #define ERROR -1 #define OK 0 #define WARNING 4 void help(void) { printf("\n\nThis program loads the time and date into the card.\n"); printf("It requires a single command line parameter containing the \n"); printf("new date and time in the form YYYYMMDDHHMMSSWW, where WW is the\n"); printf("day of the week, 01 meaning Sunday and 07 meaning Saturday.\n\n"); } int main(int argc, char *argv[]) { /*-------------------------------------------------------------------*/ /* standard CCA parameters */ /*-------------------------------------------------------------------*/ long return_code = 0; long reason_code = 0; long exit_data_length = 2; char exit_data[4]; char rule_array[2][8]; long rule_array_count = 2; /*-------------------------------------------------------------------*/ /* fields unique to this sample program */ /*-------------------------------------------------------------------*/ long verb_data_length; char * verb_data; if (argc != 2) { help(); return(ERROR); } if (strlen(argv[1]) != 16) { printf("Your input string is not the right length."); help(); return(ERROR); } /* set keywords in the rule array */ memcpy(rule_array,"ADAPTER1SETCLOCK",16); verb_data_length = 16; /* copy keyboard input for new time */ verb_data = argv[1]; /* Set the clock to the time the user gave us */ CSUACFC( &return_code, &reason_code, &exit_data_length, exit_data, &rule_array_count, (char *)rule_array, &verb_data_length, verb_data); if ( (return_code == OK) | (return_code == WARNING) ) { printf("Clock was successfully set.\nReturn/"); printf("reason codes %ld/%ld\n\n", return_code, reason_code); return(OK); } else { printf("An error occurred while setting the clock.\nReturn"); printf("/reason codes %ld/%ld\n\n", return_code, reason_code); return(ERROR); } }