Print this page
8485 Remove set but unused variables in usr/src/cmd
   1 #pragma ident   "%Z%%M% %I%     %E% SMI"
   2 
   3 /*
   4  * kadmin/ldap_util/kdb5_ldap_list.c
   5  */
   6 
   7 /* Copyright (c) 2004-2005, Novell, Inc.
   8  * All rights reserved.
   9  *
  10  * Redistribution and use in source and binary forms, with or without
  11  * modification, are permitted provided that the following conditions are met:
  12  *
  13  *   * Redistributions of source code must retain the above copyright notice,
  14  *       this list of conditions and the following disclaimer.
  15  *   * Redistributions in binary form must reproduce the above copyright
  16  *       notice, this list of conditions and the following disclaimer in the
  17  *       documentation and/or other materials provided with the distribution.
  18  *   * The copyright holder's name is not used to endorse or promote products
  19  *       derived from this software without specific prior written permission.
  20  *
  21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE


 147     int mi1 = *(const int *)m1;
 148     int mi2 = *(const int *)m2;
 149 
 150     return (mi1 - mi2);
 151 }
 152 
 153 
 154 /*
 155  * Modifies the destination list to contain or not to contain the
 156  * entries present in the source list, depending on the mode
 157  * (ADD or DELETE).
 158  */
 159 void list_modify_str_array(destlist, sourcelist, mode)
 160     char ***destlist;
 161     const char **sourcelist;
 162     int mode;
 163 {
 164     char **dlist = NULL, **tmplist = NULL;
 165     const char **slist = NULL;
 166     int dcount = 0, scount = 0, copycount = 0;
 167     int found = 0;
 168 
 169     if ((destlist == NULL) || (*destlist == NULL) || (sourcelist == NULL))
 170         return;
 171 
 172     /* We need to add every entry present in the source list to
 173      * the destination list */
 174     if (mode == LIST_MODE_ADD) {
 175         /* Traverse throught the end of destlist for appending */
 176         for (dlist = *destlist, dcount = 0; *dlist != NULL;
 177              dlist++, dcount++) {
 178             ;   /* NULL statement */
 179         }
 180         /* Count the number of entries in the source list */
 181         for (slist = sourcelist, scount = 0; *slist != NULL;
 182              slist++, scount++) {
 183             ;   /* NULL statement */
 184         }
 185         /* Reset the slist pointer to the start of source list */
 186         slist = sourcelist;
 187 
 188         /* Now append the source list to the existing destlist */
 189         if ((dcount + scount) < MAX_LIST_ENTRIES)
 190             copycount = scount;
 191         else
 192             /* Leave the last entry for list terminator(=NULL) */
 193             copycount = (MAX_LIST_ENTRIES -1) - dcount;
 194 
 195         memcpy(dlist, slist, (sizeof(char *) * copycount));
 196         dlist += copycount;
 197         *dlist = NULL;
 198     } else if (mode == LIST_MODE_DELETE) {
 199         /* We need to delete every entry present in the source list
 200          * from the destination list */
 201         for (slist = sourcelist; *slist != NULL; slist++) {
 202             for (dlist = *destlist; *dlist != NULL; dlist++) {
 203                 found = 0; /* value not found */
 204                 /* DN is case insensitive string */
 205                 if (strcasecmp(*dlist, *slist) == 0) {
 206                     found = 1;
 207                     free(*dlist);
 208                     /* Advance the rest of the entries by one */
 209                     for (tmplist = dlist; *tmplist != NULL; tmplist++) {
 210                         *tmplist = *(tmplist+1);
 211                     }
 212                     break;
 213                 }
 214             }
 215         }
 216     }
 217 
 218     return;
 219 }
 220 
 221 
 222 /*
 223  * Modifies the destination list to contain or not to contain the
 224  * entries present in the source list, depending on the mode
 225  * (ADD or DELETE). where the list is array of integers.
 226  */




   1 /*
   2  * kadmin/ldap_util/kdb5_ldap_list.c
   3  */
   4 
   5 /* Copyright (c) 2004-2005, Novell, Inc.
   6  * All rights reserved.
   7  *
   8  * Redistribution and use in source and binary forms, with or without
   9  * modification, are permitted provided that the following conditions are met:
  10  *
  11  *   * Redistributions of source code must retain the above copyright notice,
  12  *       this list of conditions and the following disclaimer.
  13  *   * Redistributions in binary form must reproduce the above copyright
  14  *       notice, this list of conditions and the following disclaimer in the
  15  *       documentation and/or other materials provided with the distribution.
  16  *   * The copyright holder's name is not used to endorse or promote products
  17  *       derived from this software without specific prior written permission.
  18  *
  19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE


 145     int mi1 = *(const int *)m1;
 146     int mi2 = *(const int *)m2;
 147 
 148     return (mi1 - mi2);
 149 }
 150 
 151 
 152 /*
 153  * Modifies the destination list to contain or not to contain the
 154  * entries present in the source list, depending on the mode
 155  * (ADD or DELETE).
 156  */
 157 void list_modify_str_array(destlist, sourcelist, mode)
 158     char ***destlist;
 159     const char **sourcelist;
 160     int mode;
 161 {
 162     char **dlist = NULL, **tmplist = NULL;
 163     const char **slist = NULL;
 164     int dcount = 0, scount = 0, copycount = 0;

 165 
 166     if ((destlist == NULL) || (*destlist == NULL) || (sourcelist == NULL))
 167         return;
 168 
 169     /* We need to add every entry present in the source list to
 170      * the destination list */
 171     if (mode == LIST_MODE_ADD) {
 172         /* Traverse throught the end of destlist for appending */
 173         for (dlist = *destlist, dcount = 0; *dlist != NULL;
 174              dlist++, dcount++) {
 175             ;   /* NULL statement */
 176         }
 177         /* Count the number of entries in the source list */
 178         for (slist = sourcelist, scount = 0; *slist != NULL;
 179              slist++, scount++) {
 180             ;   /* NULL statement */
 181         }
 182         /* Reset the slist pointer to the start of source list */
 183         slist = sourcelist;
 184 
 185         /* Now append the source list to the existing destlist */
 186         if ((dcount + scount) < MAX_LIST_ENTRIES)
 187             copycount = scount;
 188         else
 189             /* Leave the last entry for list terminator(=NULL) */
 190             copycount = (MAX_LIST_ENTRIES -1) - dcount;
 191 
 192         memcpy(dlist, slist, (sizeof(char *) * copycount));
 193         dlist += copycount;
 194         *dlist = NULL;
 195     } else if (mode == LIST_MODE_DELETE) {
 196         /* We need to delete every entry present in the source list
 197          * from the destination list */
 198         for (slist = sourcelist; *slist != NULL; slist++) {
 199             for (dlist = *destlist; *dlist != NULL; dlist++) {

 200                 /* DN is case insensitive string */
 201                 if (strcasecmp(*dlist, *slist) == 0) {

 202                     free(*dlist);
 203                     /* Advance the rest of the entries by one */
 204                     for (tmplist = dlist; *tmplist != NULL; tmplist++) {
 205                         *tmplist = *(tmplist+1);
 206                     }
 207                     break;
 208                 }
 209             }
 210         }
 211     }
 212 
 213     return;
 214 }
 215 
 216 
 217 /*
 218  * Modifies the destination list to contain or not to contain the
 219  * entries present in the source list, depending on the mode
 220  * (ADD or DELETE). where the list is array of integers.
 221  */