Select Git revision
scsiprint.cpp
ataprint.cpp 57.79 KiB
/*
* ataprint.c
*
* Home page of code is: http://smartmontools.sourceforge.net
*
* Copyright (C) 2002-4 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 <string.h>
#include "atacmdnames.h"
#include "atacmds.h"
#include "ataprint.h"
#include "smartctl.h"
#include "int64.h"
#include "extern.h"
#include "utility.h"
#include "knowndrives.h"
#include "config.h"
const char *ataprint_c_cvsid="$Id: ataprint.cpp,v 1.149 2004/04/02 05:57:40 ballen4705 Exp $"
ATACMDNAMES_H_CVSID ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
// for passing global control variables
extern smartmonctrl *con;
// to hold onto exit code for atexit routine
extern int exitstatus;
// Copies n bytes (or n-1 if n is odd) from in to out, but swaps adjacents
// bytes.
void swapbytes(char *out, const char *in, size_t n)
{
size_t i;
for (i = 0; i < n; i += 2) {
out[i] = in[i+1];
out[i+1] = in[i];
}
}
// Copies in to out, but removes leading and trailing whitespace.
void trim(char *out, const char *in)
{
int i, first, last;
// Find the first non-space character (maybe none).
first = -1;
for (i = 0; in[i]; i++)
if (!isspace((int)in[i])) {
first = i;
break;
}