Path: blob/main/crypto/krb5/src/util/ss/request_tbl.c
34889 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/*2* Copyright 1987, 1988 by MIT Student Information Processing Board3*4* For copyright information, see copyright.h.5*/67#include "copyright.h"8#include "ss_internal.h"910#define ssrt ss_request_table /* for some readable code... */1112void13ss_add_request_table(int sci_idx, ssrt *rqtbl_ptr, int position, int *code_ptr)14{15ss_data *info;16int i, size;1718info = ss_info(sci_idx);19for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++)20;21/* size == C subscript of NULL == #elements */22size += 2; /* new element, and NULL */23info->rqt_tables = (ssrt **)realloc(info->rqt_tables,24size*sizeof(ssrt *));25if (info->rqt_tables == (ssrt **)NULL) {26*code_ptr = errno;27return;28}29if (position > size - 2)30position = size - 2;3132if (size > 1)33for (i = size - 2; i >= position; i--)34info->rqt_tables[i+1] = info->rqt_tables[i];3536info->rqt_tables[position] = rqtbl_ptr;37info->rqt_tables[size-1] = (ssrt *)NULL;38*code_ptr = 0;39}4041void42ss_delete_request_table(int sci_idx, ssrt *rqtbl_ptr, int *code_ptr)43{44ss_data *info;45ssrt **rt1, **rt2;4647*code_ptr = SS_ET_TABLE_NOT_FOUND;48info = ss_info(sci_idx);49rt1 = info->rqt_tables;50for (rt2 = rt1; *rt1; rt1++) {51if (*rt1 != rqtbl_ptr) {52*rt2++ = *rt1;53*code_ptr = 0;54}55}56*rt2 = (ssrt *)NULL;57return;58}596061