~ubuntu-branches/ubuntu/raring/maradns/raring

« back to all changes in this revision

Viewing changes to libs/JsStrOS.c

  • Committer: Bazaar Package Importer
  • Author(s): Kai Hendry
  • Date: 2010-01-24 12:17:40 UTC
  • mfrom: (1.1.13 upstream) (10.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100124121740-a4e1fjobwaouz443
Tags: 1.4.02-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <stdio.h>
22
22
#include <string.h>
23
23
#include <sys/stat.h>
24
 
#include <sys/types.h>
25
24
#include <fcntl.h>
26
25
#include <sys/file.h>
27
26
#include <limits.h>
866
865
                 in big-endian format, where the js->unit_size is one.
867
866
   input: pointer to js_string object, number to add
868
867
   output: JS_ERROR on error, JS_SUCCESS on success
869
 
   (This is in OS because of the dependency on u_int32_t
 
868
   (This is in OS because of the dependency on uint32_t
870
869
*/
871
870
 
872
 
int js_adduint32(js_string *js, u_int32_t number) {
 
871
int js_adduint32(js_string *js, uint32_t number) {
873
872
 
874
873
    /* sanity checks */
875
874
    if(js_has_sanity(js) == JS_ERROR)
896
895
          of string (0 is beginning of string, 1 second byte, etc.)
897
896
   output: JS_ERROR on error, value of uint32 on success
898
897
           (Hack: 0xffffffff is the same as -1 in comparisons)
899
 
   (This is in OS because of the dependency on u_int32_t)
 
898
   (This is in OS because of the dependency on uint32_t)
900
899
*/
901
900
 
902
 
u_int32_t js_readuint32(js_string *js, unsigned int offset) {
 
901
uint32_t js_readuint32(js_string *js, unsigned int offset) {
903
902
 
904
 
    u_int32_t ret;
 
903
    uint32_t ret;
905
904
    /* sanity checks */
906
905
    if(js_has_sanity(js) == JS_ERROR)
907
906
        return 0xffffffff;
927
926
 * to the length determined by the limit.  This is here because strnlen
928
927
 * is, alas, not a portable string library call.  This call is originally
929
928
 * by Matthew T. Russotto */
930
 
int js_strnlen(char *s, u_int32_t limit) {
931
 
        u_int32_t len;
 
929
int js_strnlen(char *s, uint32_t limit) {
 
930
        uint32_t len;
932
931
        if(limit > 2147483600 || limit < 0) { /* Just under 2 ** 31 */
933
932
                return JS_ERROR;
934
933
        }