Print this page
4378 Clean up %C in *time() functions
438 need documentation for strftime %s flag


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*


  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include <limits.h>
  28 #include <stdio.h>
  29 #include <stdlib.h>
  30 #include <string.h>
  31 #include <libintl.h>
  32 #include <libfru.h>
  33 #include <errno.h>
  34 #include <math.h>
  35 #include <alloca.h>
  36 #include <assert.h>
  37 #include <sys/systeminfo.h>
  38 
  39 #define NUM_OF_SEGMENT  1
  40 #define SEGMENT_NAME_SIZE       2
  41 
  42 #define FD_SEGMENT_SIZE 2949


 155                                         (void) printf("0");
 156                                 }
 157                         }
 158                         return;
 159                 }
 160                 case FDISP_Octal:
 161                 {
 162                         (void) printf("%llo", lldata);
 163                         return;
 164                 }
 165                 case FDISP_Decimal:
 166                 {
 167                         (void) printf("%lld", lldata);
 168                         return;
 169                 }
 170                 case FDISP_Time:
 171                 {
 172                         char buffer[PATH_MAX];
 173                         time_t time;
 174                         time = (time_t)lldata;
 175                         (void) strftime(buffer, PATH_MAX, "%C",
 176                             localtime(&time));
 177                         (void) printf("%s", buffer);
 178                         return;
 179                 }
 180         }
 181 }
 182 
 183 static void
 184 displayBAasBinary(unsigned char *data, size_t length)
 185 {
 186         int i;
 187         unsigned char mask;
 188 
 189         for (i = 0; i < length; i++) {
 190                 /*
 191                  * make a mask for the high order bit and adjust down through
 192                  * all the bits.
 193                  */
 194                 for (mask = 0x80; mask > 0; mask /= 2) {
 195                         if ((data[i] & mask) != 0) /* bit must be on */




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2014 Gary Mills
  24  *
  25  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.
  27  */
  28 
  29 #include <limits.h>
  30 #include <stdio.h>
  31 #include <stdlib.h>
  32 #include <string.h>
  33 #include <libintl.h>
  34 #include <libfru.h>
  35 #include <errno.h>
  36 #include <math.h>
  37 #include <alloca.h>
  38 #include <assert.h>
  39 #include <sys/systeminfo.h>
  40 
  41 #define NUM_OF_SEGMENT  1
  42 #define SEGMENT_NAME_SIZE       2
  43 
  44 #define FD_SEGMENT_SIZE 2949


 157                                         (void) printf("0");
 158                                 }
 159                         }
 160                         return;
 161                 }
 162                 case FDISP_Octal:
 163                 {
 164                         (void) printf("%llo", lldata);
 165                         return;
 166                 }
 167                 case FDISP_Decimal:
 168                 {
 169                         (void) printf("%lld", lldata);
 170                         return;
 171                 }
 172                 case FDISP_Time:
 173                 {
 174                         char buffer[PATH_MAX];
 175                         time_t time;
 176                         time = (time_t)lldata;
 177                         (void) strftime(buffer, PATH_MAX, "%+",
 178                             localtime(&time));
 179                         (void) printf("%s", buffer);
 180                         return;
 181                 }
 182         }
 183 }
 184 
 185 static void
 186 displayBAasBinary(unsigned char *data, size_t length)
 187 {
 188         int i;
 189         unsigned char mask;
 190 
 191         for (i = 0; i < length; i++) {
 192                 /*
 193                  * make a mask for the high order bit and adjust down through
 194                  * all the bits.
 195                  */
 196                 for (mask = 0x80; mask > 0; mask /= 2) {
 197                         if ((data[i] & mask) != 0) /* bit must be on */