int32 qbs_equal(qbs *str1,qbs *str2){
if (str1->len!=str2->len) return 0;
if (memcmp(str1->chr,str2->chr,str1->len)==0) return -1;
return 0;
}
int32 qbs_notequal(qbs *str1,qbs *str2){
if (str1->len!=str2->len) return -1;
if (memcmp(str1->chr,str2->chr,str1->len)==0) return 0;
return -1;
}
int32 qbs_greaterthan(qbs *str2,qbs *str1){
//same process as for lessthan; we just reverse the string order
int32 i, limit, l1, l2;
l1 = str1->len; l2 = str2->len;
if (!l1) if (l2) return -1; else return 0;
if (l1<=l2) limit = l1; else limit = l2;
i=memcmp(str1->chr,str2->chr,limit);
if (i<0) return -1;
if (i>0) return 0;
if (l1<l2) return -1;
return 0;
}
int32 qbs_lessthan(qbs *str1,qbs *str2){
int32 i, limit, l1, l2;
l1 = str1->len; l2 = str2->len; //no need to get the length of these strings multiple times.
if (!l1) if (l2) return -1; else return 0; //if one is a null string we known the answer already.
if (l1<=l2) limit = l1; else limit = l2; //our limit is going to be the length of the smallest string.
i=memcmp(str1->chr,str2->chr,limit); //check only to the length of the shortest string
if (i<0) return -1; //if the number is smaller by this point, say so
if (i>0) return 0; // if it's larger by this point, say so
//if the number is the same at this point, compare length.
//if the length of the first one is smaller, then the string is smaller. Otherwise the second one is the same string, or longer.
if (l1<l2) return -1;
return 0;
}
int32 qbs_lessorequal(qbs *str1,qbs *str2){
//same process as lessthan, but we check to see if the lengths are equal here also.
int32 i, limit, l1, l2;
l1 = str1->len; l2 = str2->len;
if (!l1) return -1; //if the first string has no length then it HAS to be smaller or equal to the second
if (l1<=l2) limit = l1; else limit = l2;
i=memcmp(str1->chr,str2->chr,limit);
if (i<0) return -1;
if (i>0) return 0;
if (l1<=l2) return -1;
return 0;
}
int32 qbs_greaterorequal(qbs *str2,qbs *str1){
//same process as for lessorequal; we just reverse the string order
int32 i, limit, l1, l2;
l1 = str1->len; l2 = str2->len;
if (!l1) return -1;
if (l1<=l2) limit = l1; else limit = l2;
i=memcmp(str1->chr,str2->chr,limit);
if (i<0) return -1;
if (i>0) return 0;
if (l1<=l2) return -1;
return 0;
}