MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink / Utility / qhexvalidator.cpp
blobff1a9ac71ebc629defdbf3a0400e077b18a2658e
1 /*
2 ***************************************************************************
3 * Ralink Tech Inc.
4 * 4F, No. 2 Technology 5th Rd.
5 * Science-based Industrial Park
6 * Hsin-chu, Taiwan, R.O.C.
8 * (c) Copyright 2002, Ralink Technology, Inc.
10 * All rights reserved. Ralink's source code is an unpublished work and the
11 * use of a copyright notice does not imply otherwise. This source code
12 * contains confidential trade secret material of Ralink Tech. Any attemp
13 * or participation in deciphering, decoding, reverse engineering or in any
14 * way altering the source code is stricitly prohibited, unless the prior
15 * written consent of Ralink Technology, Inc. is obtained.
16 ***************************************************************************
18 Module Name:
19 qhexvalidator.cpp
21 Abstract:
22 Implement hex validator for WEP security.
24 Revision History:
25 Who When What
26 -------- ---------- ----------------------------------------------
27 Paul Wu 01-22-2003 created
32 #include <qvalidator.h>
33 #include <qwidget.h>
34 #include <malloc.h>
36 #include "qhexvalidator.h"
38 QHexValidator::QHexValidator ( QWidget * parent, const char * name )
39 : QValidator(parent, name)
44 QHexValidator::~QHexValidator()
47 QValidator::State QHexValidator::validate ( QString &str, int &pos ) const
49 char *tmp;
50 char ch;
51 unsigned int i;
52 bool ok=FALSE;
54 if(str.length() == 0)
55 return QValidator::Acceptable;
57 tmp = (char *)malloc(str.length()+1);
58 if(!tmp)
59 return QValidator::Invalid;
60 strcpy(tmp, str.data());
61 for(i=0; i<str.length(); i++)
63 ch = *(tmp+i);
64 if( ((ch >= 'a') && (ch <= 'f')) || ((ch >= 'A') && (ch <= 'F')) ||
65 ((ch >= '0') && (ch <= '9')) )
67 ok=TRUE;
69 else
71 ok=FALSE;
72 break;
76 //free(tmp);
77 if(ok)
79 return QValidator::Acceptable;
81 else
83 return QValidator::Invalid;
85 pos=0; //avoid compile warning