📄 stadev.c
字号:
request.rq_p2.signal = alarm; if (display_text == NULL) request.rq_datafield.outtext = BYTENULL; else { bstring.nbytes = strlen(display_text); bstring.bytes = display_text; request.rq_datafield.outtext = &bstring; } /*-----------------------------------------------------*/ /* Call SCT Interface */ /*-----------------------------------------------------*/ rc = sct_interface(sct_id, command, &request, &response); if (rc < 0) { sca_errno = sct_errno; sca_errmsg = sct_errmsg; err_analyse(sct_id); return (-1); } /*-----------------------------------------------------*/ /* Normal End (Release storage) */ /*-----------------------------------------------------*/ sta_aux_bytestr_free(&response);#ifdef TEST fprintf(stdout, "\n***** Normal end of sca_eject_sc *********************************************\n\n");#endif sct_close(sct_id); return (sca_errno);} /* end sca_eject_sc *//*-------------------------------------------------------------*//* E N D O F P R O C E D U R E sca_eject_sc *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* | GMD *//* +-----*//* PROC sca_display VERSION 1.0 *//* DATE Januar 1992 *//* BY U.Viebeg *//* *//* DESCRIPTION *//* Print text on SCT-display *//* A smartcard is not expected. *//* *//* *//* IN DESCRIPTION *//* sct_id SCT identifier *//* *//* display_text text which shall be *//* displayed on the SCT- *//* display or the NULL-Pointer *//* time_out Time-out in seconds *//* *//* OUT *//* *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k *//* -1 error *//* M_ETIME *//* M_ETEXT *//* *//* CALLED FUNCTIONS *//* check_sct_sc ERROR-Codes *//* ENOCARD *//* ESIDUNK *//* ENOSHELL *//* EOPERR *//* EEMPTY *//* EMEMAVAIL *//* ECLERR *//* ESIDUNK *//* ERDERR *//* EINVARG *//* ETOOLONG *//* sw1/sw2 from SCT response *//* T1 - ERROR *//* *//* sct_interface ERROR-Codes *//* EINVARG *//* ETOOLONG *//* EMEMAVAIL *//* ESIDUNK *//* EPARMISSED *//* INVPAR *//* EINVINS *//* sw1/sw2 from SCT response *//* T1 - ERROR *//* sta_aux_bytestr_free *//* *//* err_analyse ERROR_Codes *//* ENOSHELL *//* EOPERR *//* EEMPTY *//* ECLERR *//* ESIDUNK *//* ERDERR *//* *//* *//* set_errmsg *//* *//*-------------------------------------------------------------*/intsca_display(sct_id, display_text, time_out) int sct_id; char *display_text; int time_out;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ int rc; Bytestring bstring; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ rc = 0; sca_errno = M_NOERR; sca_errmsg = NULL; sc_expect = FALSE; /* this function doesn't need a SC */#ifdef TEST fprintf(stdout, "\n***** STAMOD-Routine sca_display *********************************************\n\n"); fprintf(stdout, "input-parameters:\n"); fprintf(stdout, "sct_id: %d\n", sct_id); fprintf(stdout, "display_text: %s\n", display_text); fprintf(stdout, "time_out(sec): %d\n", time_out); fprintf(stdout, "\n\n");#endif /*-----------------------------------------------------*/ /* call check_sct_sc */ /*-----------------------------------------------------*/ if (check_sct_sc(sct_id, sc_expect) == -1) return (-1); /*-----------------------------------------------------*/ /* Check input parameters */ /*-----------------------------------------------------*/ if (display_text != NULL) { if (strlen(display_text) > MAXL_SCT_DISPLAY) { sca_errno = M_ETEXT; set_errmsg(); return (-1); } } if ((time_out < 0) || (time_out > MAX_TIME)) { sca_errno = M_ETIME; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* Prepare parameters for the SCT Interface */ /*-----------------------------------------------------*/ command = S_DISPLAY; request.rq_p2.time = time_out; if (display_text == NULL) request.rq_datafield.outtext = BYTENULL; else { bstring.nbytes = strlen(display_text); bstring.bytes = display_text; request.rq_datafield.outtext = &bstring; } /*-----------------------------------------------------*/ /* Call SCT Interface */ /*-----------------------------------------------------*/ rc = sct_interface(sct_id, command, &request, &response); if (rc < 0) { sca_errno = sct_errno; sca_errmsg = sct_errmsg; err_analyse(sct_id); return (-1); } /*-----------------------------------------------------*/ /* Normal End (Release storage) */ /*-----------------------------------------------------*/ sta_aux_bytestr_free(&response);#ifdef TEST fprintf(stdout, "\n***** Normal end of sca_display *********************************************\n\n");#endif return (sca_errno);} /* end sca_display *//*-------------------------------------------------------------*//* E N D O F P R O C E D U R E sca_display *//*-------------------------------------------------------------*//*-------------------------------------------------------------*//* | GMD *//* +-----*//* PROC sca_set_mode VERSION 1.0 *//* DATE Juni 1992 *//* BY L.Eckstein *//* *//* DESCRIPTION *//* Set security mode *//* A smartcard is not expected. *//* *//* *//* IN DESCRIPTION *//* sct_id SCT identifier *//* *//* sec_mess security modes *//* *//* OUT *//* *//* *//* *//* RETURN DESCRIPTION *//* 0 o.k *//* -1 error *//* M_ETIME *//* M_ETEXT *//* *//* CALLED FUNCTIONS *//* check_sct_sc ERROR-Codes *//* ENOCARD *//* ESIDUNK *//* ENOSHELL *//* EOPERR *//* EEMPTY *//* EMEMAVAIL *//* ECLERR *//* ESIDUNK *//* ERDERR *//* EINVARG *//* ETOOLONG *//* sw1/sw2 from SCT response *//* T1 - ERROR *//* *//* sct_interface ERROR-Codes *//* EINVARG *//* ETOOLONG *//* EMEMAVAIL *//* ESIDUNK *//* EPARMISSED *//* INVPAR *//* EINVINS *//* sw1/sw2 from SCT response *//* T1 - ERROR *//* sta_aux_bytestr_free *//* *//* err_analyse ERROR_Codes *//* ENOSHELL *//* EOPERR *//* EEMPTY *//* ECLERR *//* ESIDUNK *//* ERDERR *//* *//* *//* set_errmsg *//* *//*-------------------------------------------------------------*/intsca_set_mode(sct_id, sec_mess) int sct_id; SecMess *sec_mess;{ /*----------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------*/ int rc; /*----------------------------------------------------------*/ /* Statements */ /*----------------------------------------------------------*/ rc = 0; sca_errno = M_NOERR; sca_errmsg = NULL; sc_expect = FALSE; /* this function doesn't need a SC */#ifdef TEST fprintf(stdout, "\n***** STAMOD-Routine sca_set_mode *****\n\n"); fprintf(stdout, "TRACE of the input parameters : \n"); fprintf(stdout, "sct_id : %d\n", sct_id); print_secmess(sec_mess);#endif /*-----------------------------------------------------*/ /* call check_sct_sc */ /*-----------------------------------------------------*/ if (check_sct_sc(sct_id, sc_expect) == -1) return (-1); /*-----------------------------------------------------*/ /* Check input parameter sec_mess */ /*-----------------------------------------------------*/ if ((sec_mess->command != SEC_NORMAL) && (sec_mess->command != CONCEALED)) { sca_errno = M_ESECMESS; set_errmsg(); return (-1); } if ((sec_mess->response != SEC_NORMAL) && (sec_mess->response != CONCEALED)) { sca_errno = M_ESECMESS; set_errmsg(); return (-1); } /*-----------------------------------------------------*/ /* if sec_mess = CONCEALED check sessionkey */ /*-----------------------------------------------------*/ if ((sec_mess->command == CONCEALED) || (sec_mess->response == CONCEALED)) { /*----------------------------------------------*/ /* test, if sessionkey available */ /*----------------------------------------------*/ rc = sct_info(sct_id, &sctinfo); if (rc < 0) { sca_errno = sct_errno; sca_errmsg = sct_errmsg; return (-1); } rc = sct_secure(sct_id); if (rc < 0) { sca_errno = sct_errno; sca_errmsg = sct_errmsg; err_analyse(sct_id); return (-1); } } /*-----------------------------------------------------*/ /* Store security mode in port-memory */ /*-----------------------------------------------------*/ rc = sct_setmode(sct_id, sec_mess); if (rc < 0) { sca_errno = sct_errno; sca_errmsg = sct_errmsg; return (-1); }#ifdef TEST fprintf(stdout, "\n***** Normal end of sca_set_mode *****\n\n");#endif return (0);} /* end sca_set_mode *//*-------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -