return (found) ? NS_OK : NS_ERROR_INVALID_ARG;
return NS_OK;
nsresult NS_MsgGetAttributeFromString(const char *string, PRInt16 *attrib){  NS_ENSURE_ARG_POINTER(string);  NS_ENSURE_ARG_POINTER(attrib);  	PRBool found = PR_FALSE;	for (int idxAttrib = 0; idxAttrib < (int)(sizeof(SearchAttribEntryTable) / sizeof(nsMsgSearchAttribEntry)); idxAttrib++)	{		if (!PL_strcasecmp(string, SearchAttribEntryTable[idxAttrib].attribName))		{			found = PR_TRUE;			*attrib = SearchAttribEntryTable[idxAttrib].attrib;			break;		}	}  	if (!found)  {    nsresult rv;    PRBool goodHdr;    IsRFC822HeaderFieldName(string, &goodHdr);    if (!goodHdr)      return NS_MSG_INVALID_CUSTOM_HEADER;    //49 is for showing customize... in ui, headers start from 50 onwards up until 99.    *attrib = nsMsgSearchAttrib::OtherHeader+1;    nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);    NS_ENSURE_SUCCESS(rv, rv);    nsCOMPtr<nsIPrefBranch> prefBranch;    rv = prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));    NS_ENSURE_SUCCESS(rv, rv);    nsXPIDLCString headers;    prefBranch->GetCharPref(MAILNEWS_CUSTOM_HEADERS, getter_Copies(headers));    if (!headers.IsEmpty())    {      char *headersString = ToNewCString(headers);      nsCAutoString hdrStr;      hdrStr.Adopt(headersString);      hdrStr.StripWhitespace();  //remove whitespace before parsing      char *newStr=nsnull;      char *token = nsCRT::strtok(headersString,":", &newStr);      PRUint32 i=0;      while (token)      {        if (nsCRT::strcasecmp(token, string) == 0)        {          *attrib += i; //we found custom header in the pref          found = PR_TRUE;          break;        }        token = nsCRT::strtok(newStr,":", &newStr);        i++;      }    }  }	return (found) ? NS_OK : NS_ERROR_INVALID_ARG;}