Skip to content
Snippets Groups Projects
Select Git revision
  • 6a3e549f53edce82c0f817db3aec8e2c803a1e59
  • master default
2 results

test_parser.py

Blame
  • Forked from finesse / pykat
    Source project has a limited visibility.
    ataprint.cpp 30.96 KiB
    /*
     * ataprint.c
     *
     * Home page of code is: http://smartmontools.sourceforge.net
     *
     * Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
     * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org>
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2, or (at your option)
     * any later version.
     *
     * You should have received a copy of the GNU General Public License
     * (for example COPYING); if not, write to the Free
     * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     *
     * This code was originally developed as a Senior Thesis by Michael Cornwell
     * at the Concurrent Systems Laboratory (now part of the Storage Systems
     * Research Center), Jack Baskin School of Engineering, University of
     * California, Santa Cruz. http://ssrc.soe.ucsc.edu/
     *
     */
    
    #include <ctype.h>
    #include <stdio.h>
    #include "atacmds.h"
    #include "ataprint.h"
    #include "smartctl.h"
    #include "extern.h"
    
    const char *CVSid2="$Id: ataprint.cpp,v 1.41 2002/10/31 17:40:08 ballen4705 Exp $"
    CVSID1 CVSID2 CVSID3 CVSID6;
    
    // for passing global control variables
    extern atamainctrl *con;
    
    // Function for printing ASCII byte-swapped strings, skipping white
    // space. This is needed on little-endian architectures, eg Intel,
    // Alpha. If someone wants to run this on SPARC they'll need to test
    // for the Endian-ness and skip the byte swapping if it's big-endian.
    void printswap(char *in, unsigned int n){
      unsigned int i;
      char out[64];
    
      // swap bytes
      for (i=0;i<n;i+=2){
        unsigned int j=i+1;
        out[i]=in[j];
        out[j]=in[i];
      }
    
      // find the end of the white space
      for (i=0;i<n && isspace(out[i]);i++);
    
      // and do the printing starting from first non-white space
      if (n-i)
        pout("%.*s\n",(int)(n-i),out+i);
      else
        pout("[No Information Found]\n");
    
      return;
    }
    
    
    void ataPrintDriveInfo (struct hd_driveid *drive){
      int version;
      const char *description;
      char unknown[64];
      unsigned short minorrev;