Clean-up.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35690 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+26
-39
@@ -32,26 +32,18 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
//
|
#include "Utilities.h"
|
||||||
// Utilities.cpp
|
|
||||||
//
|
#include <fs_attr.h>
|
||||||
//--------------------------------------------------------------------
|
#include <Node.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TypeConstants.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Node.h>
|
|
||||||
#include <TypeConstants.h>
|
|
||||||
#include <fs_attr.h>
|
|
||||||
|
|
||||||
#include <MailMessage.h>
|
|
||||||
|
|
||||||
#include "Utilities.h"
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
WriteAttrString(BNode* node, const char* attr, const char* value)
|
WriteAttrString(BNode* node, const char* attr, const char* value)
|
||||||
@@ -59,7 +51,8 @@ WriteAttrString(BNode *node, const char *attr, const char *value)
|
|||||||
if (!value)
|
if (!value)
|
||||||
value = B_EMPTY_STRING;
|
value = B_EMPTY_STRING;
|
||||||
|
|
||||||
ssize_t size = node->WriteAttr(attr, B_STRING_TYPE, 0, value, strlen(value) + 1);
|
ssize_t size = node->WriteAttr(attr, B_STRING_TYPE, 0, value,
|
||||||
|
strlen(value) + 1);
|
||||||
|
|
||||||
return size >= 0 ? B_OK : size;
|
return size >= 0 ? B_OK : size;
|
||||||
}
|
}
|
||||||
@@ -75,7 +68,9 @@ ReadAttrString(BNode *node, const char *attr, BString *value)
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
ssize_t size = node->ReadAttr(attr, B_STRING_TYPE, 0, value->LockBuffer(attrInfo.size + 1), attrInfo.size);
|
ssize_t size = node->ReadAttr(attr, B_STRING_TYPE, 0,
|
||||||
|
value->LockBuffer(attrInfo.size + 1), attrInfo.size);
|
||||||
|
|
||||||
value->UnlockBuffer();
|
value->UnlockBuffer();
|
||||||
|
|
||||||
return size >= 0 ? B_OK : size;
|
return size >= 0 ? B_OK : size;
|
||||||
@@ -95,22 +90,20 @@ cistrcmp(const char *str1, const char *str2)
|
|||||||
int32 loop;
|
int32 loop;
|
||||||
|
|
||||||
len = strlen(str1) + 1;
|
len = strlen(str1) + 1;
|
||||||
for (loop = 0; loop < len; loop++)
|
for (loop = 0; loop < len; loop++) {
|
||||||
{
|
|
||||||
c1 = str1[loop];
|
c1 = str1[loop];
|
||||||
if (c1 >= 'A' && c1 <= 'Z')
|
if (c1 >= 'A' && c1 <= 'Z')
|
||||||
c1 += 'a' - 'A';
|
c1 += 'a' - 'A';
|
||||||
c2 = str2[loop];
|
c2 = str2[loop];
|
||||||
if (c2 >= 'A' && c2 <= 'Z')
|
if (c2 >= 'A' && c2 <= 'Z')
|
||||||
c2 += 'a' - 'A';
|
c2 += 'a' - 'A';
|
||||||
if (c1 == c2)
|
if (c1 == c2) {
|
||||||
{
|
} else if (c1 < c2) {
|
||||||
}
|
|
||||||
else if (c1 < c2)
|
|
||||||
return -1;
|
return -1;
|
||||||
else if (c1 > c2 || !c2)
|
} else if (c1 > c2 || !c2) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,22 +119,20 @@ cistrncmp(const char *str1, const char *str2, int32 max)
|
|||||||
char c2;
|
char c2;
|
||||||
int32 loop;
|
int32 loop;
|
||||||
|
|
||||||
for (loop = 0; loop < max; loop++)
|
for (loop = 0; loop < max; loop++) {
|
||||||
{
|
|
||||||
c1 = *str1++;
|
c1 = *str1++;
|
||||||
if (c1 >= 'A' && c1 <= 'Z')
|
if (c1 >= 'A' && c1 <= 'Z')
|
||||||
c1 += 'a' - 'A';
|
c1 += 'a' - 'A';
|
||||||
c2 = *str2++;
|
c2 = *str2++;
|
||||||
if (c2 >= 'A' && c2 <= 'Z')
|
if (c2 >= 'A' && c2 <= 'Z')
|
||||||
c2 += 'a' - 'A';
|
c2 += 'a' - 'A';
|
||||||
if (c1 == c2)
|
if (c1 == c2) {
|
||||||
{
|
} else if (c1 < c2) {
|
||||||
}
|
|
||||||
else if (c1 < c2)
|
|
||||||
return -1;
|
return -1;
|
||||||
else if (c1 > c2 || !c2)
|
} else if (c1 > c2 || !c2) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,13 +153,11 @@ cistrstr(const char *cs, const char *ct)
|
|||||||
|
|
||||||
cs_len = strlen(cs);
|
cs_len = strlen(cs);
|
||||||
ct_len = strlen(ct);
|
ct_len = strlen(ct);
|
||||||
for (loop1 = 0; loop1 < cs_len; loop1++)
|
for (loop1 = 0; loop1 < cs_len; loop1++) {
|
||||||
{
|
|
||||||
if (cs_len - loop1 < ct_len)
|
if (cs_len - loop1 < ct_len)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (loop2 = 0; loop2 < ct_len; loop2++)
|
for (loop2 = 0; loop2 < ct_len; loop2++) {
|
||||||
{
|
|
||||||
c1 = cs[loop1 + loop2];
|
c1 = cs[loop1 + loop2];
|
||||||
if ((c1 >= 'A') && (c1 <= 'Z'))
|
if ((c1 >= 'A') && (c1 <= 'Z'))
|
||||||
c1 += ('a' - 'A');
|
c1 += ('a' - 'A');
|
||||||
@@ -196,10 +185,8 @@ linelen(char *str, int32 len, bool header)
|
|||||||
{
|
{
|
||||||
int32 loop;
|
int32 loop;
|
||||||
|
|
||||||
for (loop = 0; loop < len; loop++)
|
for (loop = 0; loop < len; loop++) {
|
||||||
{
|
if (str[loop] == '\n') {
|
||||||
if (str[loop] == '\n')
|
|
||||||
{
|
|
||||||
if (!header || loop < 2
|
if (!header || loop < 2
|
||||||
|| (header && str[loop + 1] != ' ' && str[loop + 1] != '\t'))
|
|| (header && str[loop + 1] != ' ' && str[loop + 1] != '\t'))
|
||||||
return loop + 1;
|
return loop + 1;
|
||||||
|
|||||||
@@ -31,40 +31,27 @@ of Be Incorporated in the United States and other countries. Other brand product
|
|||||||
names are registered trademarks or trademarks of their respective holders.
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Utilities.h
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _UTILITIES_H
|
#ifndef _UTILITIES_H
|
||||||
#define _UTILITIES_H
|
#define _UTILITIES_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
class BEmailMessage;
|
|
||||||
|
|
||||||
//====================================================================
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
class BNode;
|
class BNode;
|
||||||
extern status_t WriteAttrString(BNode *node, const char *attr, const char *value);
|
class BString;
|
||||||
|
|
||||||
|
|
||||||
|
extern status_t WriteAttrString(BNode* node, const char* attr,
|
||||||
|
const char* value);
|
||||||
extern status_t ReadAttrString(BNode* node, const char* attr, BString* value);
|
extern status_t ReadAttrString(BNode* node, const char* attr, BString* value);
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32 cistrcmp(const char*, const char*);
|
int32 cistrcmp(const char*, const char*);
|
||||||
int32 cistrncmp(const char*, const char*, int32);
|
int32 cistrncmp(const char*, const char*, int32);
|
||||||
char* cistrstr(const char*, const char*);
|
char* cistrstr(const char*, const char*);
|
||||||
int32 linelen(char*, int32, bool);
|
int32 linelen(char*, int32, bool);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // #ifndef _UTILITIES_H
|
#endif // #ifndef _UTILITIES_H
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user