Example #1
0
unsigned
handle_nbtstat_rr(struct Output *out, const unsigned char *px, unsigned length, unsigned ip_them, unsigned port_them)
{
    unsigned char banner[65536];
    unsigned banner_length = 0;
    unsigned offset = 0;
    unsigned name_count;

    if (offset >= length)
        return 0;
    name_count = px[offset++];

    while (offset + 18 <= length && name_count) {
        append_name(banner, sizeof(banner), &banner_length, &px[offset]);
        offset += 18;
        name_count--;
    }

    {
        unsigned i;

        for (i=0; i<6; i++) {
            if (offset + i < length) {
                unsigned char c = px[offset];
                append_char(banner, sizeof(banner), &banner_length, "0123456789ABCDEF"[c>>4]);
                append_char(banner, sizeof(banner), &banner_length, "0123456789ABCDEF"[c&0xF]);
                if (i < 5)
                append_char(banner, sizeof(banner), &banner_length, '-');
            }
        }
    }
Example #2
0
/* sec 0048 */
void append_lc_hex (ASCII_code c)
{
  if (c < 10)
    append_char(c + '0');
  else
    append_char(c - 10 + 'a');
}
Example #3
0
mp_string mp_chop_string(MP mp,mp_string s,integer a,integer b){
integer l;
integer k;
boolean reversed;
if(a<=b)
reversed= false;
else{
reversed= true;
k= a;
a= b;
b= k;
}
l= (integer)s->len;
if(a<0){
a= 0;
if(b<0)
b= 0;
}
if(b> l){
b= l;
if(a> l)
a= l;
}
str_room((size_t)(b-a));
if(reversed){
for(k= b-1;k>=a;k--){
append_char(*(s->str+k));
}
}else{
for(k= a;k<b;k++){
append_char(*(s->str+k));
}
}
return mp_make_string(mp);
}
Example #4
0
/* Represent c as a character within a quoted string, and append it to buf. */
static void tty_append_printable_char(struct string_buf *buf, unsigned char c)
{
	if (c < 0x20 || c > 0x7E) {
		append_char(buf, '\\');
		append_char(buf, '0' + ((c >> 6) & 07));
		append_char(buf, '0' + ((c >> 3) & 07));
		append_char(buf, '0' + (c & 07));
	} else {
Example #5
0
/* Reading the pattern itself */
static int
lex_pattern(usenet_parser_t self, int ch)
{
    /* Watch for EOF or linefeed */
    if (ch == EOF || ch == '\n') {
        /* Null-terminate the token */
        if (append_char(self, '\0') < 0) {
            return -1;
        }

        /* Do something interesting with the expression */
        if (accept_expression(self, self->field, self->operator,
                              self->token) < 0) {
            return -1;
        }

        /* This is also the end of the group entry */
        if (accept_group(self, self->has_not, self->group) < 0) {
            return -1;
        }

        free(self->group);

        /* Let the start state deal with the EOF or linefeed */
        return lex_start(self, ch);
    }

    /* Watch for the escape character */
    if (ch == '\\') {
        self->state = lex_pattern_esc;
        return 0;
    }

    /* Watch for other whitespace */
    if (isspace(ch)) {
        /* Record the position of the whitespace for later trimming */
        self->token_mark = self->token_pointer;
        self->state = lex_pattern_ws;
        return append_char(self, ch);
    }

    /* Watch for a separator */
    if (ch == '/') {
        /* Null-terminate the token */
        if (append_char(self, '\0') < 0) {
            return -1;
        }

        /* Do something interesting with the expression */
        self->token_pointer = self->token;
        self->state = lex_field_start;
        return accept_expression(self, self->field, self->operator,
                                 self->token);
    }

    /* Anything else is part of the pattern */
    return append_char(self, ch);
}
Example #6
0
/*----------------------------------------------------------------------------
Write character to Serial Port
*----------------------------------------------------------------------------*/
int sendchar( int c ) {

	if ( c == '\r' || c == '\n' )  {
		append_char('\n');
	} else {
		append_char(c);
	}

	return c;
}
Example #7
0
static void
append_name(unsigned char *banner, size_t banner_max, unsigned *banner_length, const unsigned char *name)
{
    unsigned i;
    unsigned char c;

    for (i=0; i<15; i++) {
        c = name[i];

        if (c == 0x20 || c == '\0')
            append_char(banner, banner_max, banner_length, ' ');
        else if (isalnum(c) || ispunct(c))
            append_char(banner, banner_max, banner_length, c);
        else {
            append_char(banner, banner_max, banner_length, '<');
            append_char(banner, banner_max, banner_length, "0123456789ABCDEF"[c>>4]);
            append_char(banner, banner_max, banner_length, "0123456789ABCDEF"[c&0xF]);
            append_char(banner, banner_max, banner_length, '>');
        }
    }

    c = name[i];
    append_char(banner, banner_max, banner_length, '<');
    append_char(banner, banner_max, banner_length, "0123456789ABCDEF"[c>>4]);
    append_char(banner, banner_max, banner_length, "0123456789ABCDEF"[c&0xF]);
    append_char(banner, banner_max, banner_length, '>');
    append_char(banner, banner_max, banner_length, '\n');
}
Example #8
0
/** Print formated file name. If fmt is NULL the default format %a - %t will used
 *
 * %% the % sign
 * %a author of song
 * %t song title
 * %y year
 * %f song from
 * %T Tracker
 * %C Comment
 * %s stereo type (ABC, BCA, ...)
 * %l 'looped' or 'non-looped'
 * %c chip type: 'AY' or 'YM'
 * %F chip Freq
 * %P player freq
 */
void ayemu_vtx_sprintname (const ayemu_vtx_t *vtx, char *const buf, const int sz, const char *fmt)
{
  static char *stereo_types[] = { "MONO", "ABC", "ACB", "BAC", "BCA", "CAB", "CBA" };

  if (fmt == NULL)
    fmt = "%a - %t";

  buf[0] = '\0';

  while (*fmt != '\0') {
    if (*fmt == '%') {
      switch(*++fmt) {
      case 'a':
	append_string(buf, sz, vtx->hdr.author);
	break;
      case 't':
	append_string(buf, sz, vtx->hdr.title);
	break;
      case 'y':
	append_number(buf, sz, vtx->hdr.year);
	break;
      case 'f':
	append_string(buf, sz, vtx->hdr.from);
	break;
      case 'T':
	append_string(buf, sz, vtx->hdr.tracker);
	break;
      case 'C':
	append_string(buf, sz, vtx->hdr.comment);
	break;
      case 's':
	append_string(buf, sz, stereo_types[vtx->hdr.stereo]);
	break;
      case 'l':
	append_string(buf, sz, (vtx->hdr.loop)? "looped" : "non-looped" );
	break;
      case 'c':
	append_string(buf, sz, (vtx->hdr.chiptype == AYEMU_AY)? "AY" : "YM" );
	break;
      case 'F':
	append_number(buf, sz, vtx->hdr.chipFreq);
	break;
      case 'P':
	append_number(buf, sz, vtx->hdr.playerFreq);
	break;
      default:
	append_char(buf, sz, *fmt);
      }
      fmt++;
    } else {
      append_char(buf, sz, *fmt++);
    }
  }
}
Example #9
0
void read_string(std::istream& in, char* &buffer, int sz) {
  int c, pos=0;
  skip_comment_line(in);

  while ( (c = in.get()) != EOF ) {
    if ( c == ' ' || c == '\t' || c == '\n' || c == '#')
      break;
    else
      append_char(buffer, sz, pos++, c);
  }
  append_char(buffer, sz, pos, '\0');
}
Example #10
0
    void end_argument ()
    {
        assert(arg_writing);

        int j;
        for (j = cmdline_len - 1; cmdline[j] == '\\'; j--) {
            append_char('\\');
        }
        append_char('"');

        arg_writing = 0;
    }
Example #11
0
/* Reading trailing whitespace after a pattern */
static int
lex_pattern_ws(usenet_parser_t self, int ch)
{
    /* Watch for EOF and newline */
    if (ch == EOF || ch == '\n') {
        /* Trim off the trailing whitespace */
        *self->token_mark = '\0';

        /* Do something interesting with the expression */
        if (accept_expression(self, self->field, self->operator,
                              self->token) < 0) {
            return -1;
        }

        /* This is also the end of the group entry */
        if (accept_group(self, self->has_not, self->group) < 0) {
            return -1;
        }

        free(self->group);

        /* Let the start state deal with the EOF or newline */
        return lex_start(self, ch);
    }

    /* Skip any other whitespace */
    if (isspace(ch)) {
        return append_char(self, ch);
    }

    /* Watch for an escape character */
    if (ch == '\\') {
        self->state = lex_pattern_esc;
        return 0;
    }

    /* Watch for a separator */
    if (ch == '/') {
        /* Trim off the trailing whitespace */
        *self->token_mark = '\0';

        /* Do something interesting with the expression */
        self->token_pointer = self->token;
        self->state = lex_field_start;
        return accept_expression(self, self->field, self->operator,
                                 self->token);
    }

    /* Anything else is more of the pattern */
    self->state = lex_pattern;
    return append_char(self, ch);
}
Example #12
0
/* We're reading the field portion of an expression */
static int
lex_field(usenet_parser_t self, int ch)
{
    /* Watch for EOF or LF in the middle of the field */
    if (ch == EOF || ch == '\n') {
        parse_error(self, "unexpected end of line");
        return -1;
    }

    /* Watch for an escape character */
    if (ch == '\\') {
        self->state = lex_field_esc;
        return 0;
    }

    /* Watch for a stray separator */
    if (ch == '/') {
        parse_error(self, "incomplete expression");
        return -1;
    }

    /* Watch for whitespace */
    if (isspace(ch)) {
        /* Null-terminate the token */
        if (append_char(self, '\0') < 0) {
            return -1;
        }

        /* Look up the field */
        self->field = translate_field(self->token);
        if (self->field == F_NONE) {
            char *buffer =
                malloc(strlen(FIELD_ERROR_MSG) + strlen(self->token) - 1);

            if (buffer != NULL) {
                sprintf(buffer, FIELD_ERROR_MSG, self->token);
                parse_error(self, buffer);
                free(buffer);
            }

            return -1;
        }

        self->token_pointer = self->token;
        self->state = lex_op_start;
        return 0;
    }

    /* Anything else is part of the field name */
    return append_char(self, ch);
}
Example #13
0
File: json.c Project: AmesianX/wine
/* ECMA-262 5.1 Edition    15.12.3 (abstract operation JA) */
static HRESULT stringify_array(stringify_ctx_t *ctx, jsdisp_t *obj)
{
    unsigned length, i, j;
    jsval_t val;
    HRESULT hres;

    if(is_on_stack(ctx, obj)) {
        FIXME("Found a cycle\n");
        return E_FAIL;
    }

    if(!stringify_push_obj(ctx, obj))
        return E_OUTOFMEMORY;

    if(!append_char(ctx, '['))
        return E_OUTOFMEMORY;

    length = array_get_length(obj);

    for(i=0; i < length; i++) {
        if(i && !append_char(ctx, ','))
            return E_OUTOFMEMORY;

        if(*ctx->gap) {
            if(!append_char(ctx, '\n'))
                return E_OUTOFMEMORY;

            for(j=0; j < ctx->stack_top; j++) {
                if(!append_string(ctx, ctx->gap))
                    return E_OUTOFMEMORY;
            }
        }

        hres = jsdisp_get_idx(obj, i, &val);
        if(FAILED(hres))
            return hres;

        hres = stringify(ctx, val);
        if(FAILED(hres))
            return hres;

        if(hres == S_FALSE && !append_string(ctx, nullW))
            return E_OUTOFMEMORY;
    }

    if((length && *ctx->gap && !append_char(ctx, '\n')) || !append_char(ctx, ']'))
        return E_OUTOFMEMORY;

    stringify_pop_obj(ctx);
    return S_OK;
}
Example #14
0
/* Reading the group (or its preceding `not') */
static int
lex_group(usenet_parser_t self, int ch)
{
    /* Watch for EOF or newline */
    if (ch == EOF || ch == '\n') {
        /* Null-terminate the token */
        if (append_char(self, '\0') < 0) {
            return -1;
        }

        /* This is a nice, short group entry */
        if (accept_group(self, self->has_not, self->token) < 0) {
            return -1;
        }

        return lex_start(self, ch);
    }

    /* Watch for other whitespace */
    if (isspace(ch)) {
        self->state = lex_group_ws;

        /* Null-terminate the token */
        return append_char(self, '\0');
    }

    /* Watch for an escape character */
    if (ch == '\\') {
        self->state = lex_group_esc;
        return 0;
    }

    /* Watch for the separator character */
    if (ch == '/') {
        /* Null-terminate the token */
        if (append_char(self, '\0') < 0) {
            return -1;
        }

        /* Record the group name for later use */
        self->group = strdup(self->token);
        self->token_pointer = self->token;
        self->state = lex_field_start;
        return 0;
    }

    /* Anything else is part of the group pattern */
    return append_char(self, ch);
}
Example #15
0
File: json.c Project: AmesianX/wine
/* ECMA-262 5.1 Edition    15.12.3 (abstract operation Quote) */
static HRESULT json_quote(stringify_ctx_t *ctx, const WCHAR *ptr, size_t len)
{
    if(!ptr || !append_char(ctx, '"'))
        return E_OUTOFMEMORY;

    while(len--) {
        switch(*ptr) {
        case '"':
        case '\\':
            if(!append_simple_quote(ctx, *ptr))
                return E_OUTOFMEMORY;
            break;
        case '\b':
            if(!append_simple_quote(ctx, 'b'))
                return E_OUTOFMEMORY;
            break;
        case '\f':
            if(!append_simple_quote(ctx, 'f'))
                return E_OUTOFMEMORY;
            break;
        case '\n':
            if(!append_simple_quote(ctx, 'n'))
                return E_OUTOFMEMORY;
            break;
        case '\r':
            if(!append_simple_quote(ctx, 'r'))
                return E_OUTOFMEMORY;
            break;
        case '\t':
            if(!append_simple_quote(ctx, 't'))
                return E_OUTOFMEMORY;
            break;
        default:
            if(*ptr < ' ') {
                const WCHAR formatW[] = {'\\','u','%','0','4','x',0};
                WCHAR buf[7];
                sprintfW(buf, formatW, *ptr);
                if(!append_string(ctx, buf))
                    return E_OUTOFMEMORY;
            }else {
                if(!append_char(ctx, *ptr))
                    return E_OUTOFMEMORY;
            }
        }
        ptr++;
    }

    return append_char(ctx, '"') ? S_OK : E_OUTOFMEMORY;
}
Example #16
0
void
http_request(http_t *ctx,
    const char *verb, const char *host, uint16_t port, const char *uri)
{
  http_log(ctx, "%s: host=\"%s\" uri=\"%s\"", __func__, host, uri);
  http_send_str(ctx, verb);
  http_send_str(ctx, " ");
  http_send_str(ctx, uri);
  http_send_line(ctx, " HTTP/1.1");

  http_send_str(ctx, "Host: ");
  http_send_str(ctx, host);
  if (port != HTTP_DEFAULT_PORT) {
    char buf[32], *p = buf;
    size_t size = sizeof buf;
    
    p = append_char(p, &size, ':');
    p = append_uint(p, &size, port);
    http_send_str(ctx, buf);
  }
  http_send_str(ctx, "\r\n");
  http_send_str(ctx, http_useragent_header);
  http_send_line(ctx, http_connection_header(ctx));
  http_send_extra_headers(ctx);
}
Example #17
0
File: bits.c Project: ec429/spiffy
void append_str(string *s, const char *str)
{
	while(str && *str) // not the most tremendously efficient implementation, but conceptually simple at least
	{
		append_char(s, *str++);
	}
}
Example #18
0
File: bits.c Project: ec429/spiffy
void append_char(string *s, char c)
{
	if(s->buf)
	{
		s->buf[s->i++]=c;
	}
	else
	{
		*s=init_string();
		append_char(s, c);
	}
	char *nbuf=s->buf;
	if(s->i>=s->l)
	{
		if(s->i)
			s->l=s->i*2;
		else
			s->l=80;
		nbuf=(char *)realloc(s->buf, s->l);
	}
	if(nbuf)
	{
		s->buf=nbuf;
		s->buf[s->i]=0;
	}
	else
	{
		free(s->buf);
		*s=init_string();
	}
}
Example #19
0
 std::pair<size_t, bool> StreamWriter<StreamType>::append_value(const Value& v)
 {
     std::pair<size_t, bool> k(0, false);
     if(v.isNull())
         k = append_null();
     else if(v.isBool())
         k = append_bool(v);
     else if(v.isChar())
         k = append_char(v);
     else if(v.isSignedInteger())
         k = append_signedInt(v);
     else if(v.isUnsignedInteger())
         k = append_unsignedInt(v);
     else if(v.isFloat())
         k = append_float(v);
     else if(v.isString())
         k = append_string(v);
     //else if(v.isBinary())
     //    k = append_binary(v); //currently not supported
     else if(v.isArray())
         k = append_array(v);
     else if(v.isObject())
         k = append_object(v);
     return k;
 }
Example #20
0
int
http_send_status_line(http_t *ctx, unsigned int code, const char *msg)
{
  char buf[256], *p = buf;
  size_t size = sizeof buf;

  RUNTIME_ASSERT(code >= 100 && code <= 999);
  ACCLOG_SET(ctx->acclog, code, code);

  p = append_string(p, &size, "HTTP/1.1 ");
  p = append_uint(p, &size, code);
  p = append_char(p, &size, ' ');
  p = append_string(p, &size, msg);

#if 0
  DBUG("Sending HTTP response \"%s\"", buf);
#endif

  p = APPEND_CRLF(p, &size);
  
  p = APPEND_STATIC_CHARS(p, &size, "Date: ");
  p = append_date(p, &size, compat_mono_time(NULL));
  p = APPEND_CRLF(p, &size);

  if (
    0 != http_send(ctx, buf, sizeof buf - size) ||
    0 != http_send_str(ctx, http_server_header)
  )
    return -1;

  return 0;
}
Example #21
0
void print_text(uint8_t *str_ptr, uint32_t str_len) {
	size_t i;

	for ( i = 0; i < str_len; ++i ) {
		append_char(str_ptr[i]);
  }
}//end of fun
Example #22
0
static void escape_arg(struct buffer *result, const char *arg)
{
    struct buffer buf;
    int quote, j;

    init(&buf);

    quote = arg[0] == '\0' || strchr(arg, ' ') || strchr(arg, '\t');

    if (quote)
	append_char(result, '\"');

    for (j = 0; arg[j]; j++) {
	int c = arg[j];
	int k;

	switch (c) {
	case '\\':
	    append_char(&buf, '\\');
	    break;
	case '\"':
	    for (k = 0; k < buf.len; k++)
		append(result, "\\\\");
	    clear(&buf);
	    append(result, "\\\"");
	    break;
	default:
	    if (buf.len > 0) {
		append(result, buf.str);
		clear(&buf);
	    }
	    append_char(result, c);
	}
    }

    if (buf.len > 0)
	append(result, buf.str);

    if (quote) {
	append(result, buf.str);
	append_char(result, '\"');
    }

    finish(&buf);
}
Example #23
0
/*
 *	init_mach_macros(void)
 *
 *	Set the magic macros TARGET_MACH, HOST_MACH,
 *
 *	Parameters:
 *
 *	Global variables used:
 * 	                        host_mach   Property for magic macro HOST_MACH
 * 	                        target_mach Property for magic macro TARGET_MACH
 *
 *	Return value:
 *				The function does not return a value, but can
 *				call fatal() in case of error.
 */
static void
init_mach_macros(void)
{
	FILE *pipe;
	name_t *value;
	const char *mach_command = NOCATGETS("/bin/mach");
	string_t str;
	wchar_t buf[STRING_BUFFER_LENGTH];
	char fgetsbuf[100];
	boolean_t set_host = B_FALSE, set_target = B_FALSE;
	name_t *host_mach, *target_mach;

	/*
	 * Skip out if we've already done this:
	 */
	if (init_mach_done == B_TRUE)
		return;
	init_mach_done = B_TRUE;

	host_mach = _internal_get_magic_macro(MMI_HOST_MACH);
	target_mach = _internal_get_magic_macro(MMI_TARGET_MACH);

	/*
	 * If both have been set already, don't proceed any further:
	 */
	if (set_host == B_FALSE && set_target == B_FALSE)
		return;

	if (get_prop(host_mach->n_prop, PT_MACRO) == NULL)
		set_host = B_TRUE;
	if (get_prop(target_mach->n_prop, PT_MACRO) == NULL)
		set_target = B_TRUE;

	INIT_STRING_FROM_STACK(str, buf);
	append_char(L'-', &str);

	if ((pipe = popen(mach_command, "r")) == NULL) {
		fatal_mksh(catgets(libmksdmsi18n_catd, 1, 183,
		    "Execute of %s failed"), mach_command);
	}
	while (fgets(fgetsbuf, sizeof (fgetsbuf), pipe) != NULL)
		append_string(fgetsbuf, &str, FIND_LENGTH);
	if (pclose(pipe) != 0) {
		fatal_mksh(catgets(libmksdmsi18n_catd, 1, 184, "Execute of %s "
		    "failed"), mach_command);
	}

	value = GETNAME(str.str_buf_start, FIND_LENGTH);
	if (set_host == B_TRUE) {
		(void) setvar_daemon(host_mach, value, B_FALSE,
		    DN_NO_DAEMON, B_TRUE, 0);
	}
	if (set_target == B_TRUE) {
		(void) setvar_daemon(target_mach, value, B_FALSE,
		    DN_NO_DAEMON, B_TRUE, 0);
	}
}
Example #24
0
bool to_string_core(expr const & e, std::string & r) {
    if (e == *g_empty || e == *g_list_nil_char) {
        return true;
    } else if (is_string_macro(e)) {
        r = to_string_macro(e).get_value();
        return true;
    } else {
        buffer<expr> args;
        expr const & fn = get_app_args(e, args);
        if (fn == *g_str && args.size() == 2) {
            return to_string_core(args[1], r) && append_char(args[0], r);
        } else if (fn == *g_list_cons && args.size() == 3 && args[0] == *g_char) {
            return to_string_core(args[2], r) && append_char(args[1], r);
        } else {
            return false;
        }
    }
}
Example #25
0
int main (int argc, char **argv)
{
    char *cl_cmd = getenv(CMD_ENVVAR);
    if (!cl_cmd) {
        fail(CMD_ENVVAR" not set");
    }

    #ifndef WINTEST
    LPWSTR (*CDECL wine_get_dos_file_name_ptr)(LPCSTR);
    wine_get_dos_file_name_ptr = (void *)GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_dos_file_name");
    if (!wine_get_dos_file_name_ptr) {
        fail("cannot get wine_get_dos_file_name");
    }
    #endif

    WCHAR cmdline[CMDLINE_BUF_LEN];
    int cmdline_len = 0;

    void append_char (WCHAR c)
    {
        if (1 > MAX_CMDLINE_LEN - cmdline_len) {
            fail("out of command line buffer");
        }

        cmdline[cmdline_len] = c;
        cmdline_len++;
    }

    int arg_writing = 0;

    void start_argument ()
    {
        assert(!arg_writing);

        if (cmdline_len == 0) {
            append_char('"');
        } else {
            append_char(' ');
            append_char('"');
        }

        arg_writing = 1;
    }
Example #26
0
    void write_argument_w (WCHAR *data, int len)
    {
        assert(arg_writing);
        assert(len >= 0);

        int i;
        for (i = 0; i < len; i++) {
            if (data[i] == '"') {
                int j;
                for (j = cmdline_len - 1; cmdline[j] == '\\'; j--) {
                    append_char('\\');
                }
                append_char('\\');
                append_char(data[i]);
            } else {
                append_char(data[i]);
            }
        }
    }
Example #27
0
/* We've got some whitespace in the group pattern.  It could mean that
 * the "not" keyword was used or it could mean that we've just got
 * some space between the pattern and the separator character */
static int
lex_group_ws(usenet_parser_t self, int ch)
{
    /* Watch for EOF or newline */
    if (ch == EOF || ch == '\n') {
        /* This is a nice, short group entry */
        if (accept_group(self, self->has_not, self->token) < 0) {
            return -1;
        }

        return lex_start(self, ch);
    }

    /* Skip additional whitespace */
    if (isspace(ch)) {
        return 0;
    }

    /* Watch for an escape character */
    if (ch == '\\') {
        self->state = lex_group_esc;
        return 0;
    }

    /* Watch for the separator character */
    if (ch == '/') {
        /* Record the group name for later */
        self->group = strdup(self->token);
        self->token_pointer = self->token;
        self->state = lex_field_start;
        return 0;
    }

    /* Anything else wants to be part of the pattern.  Make sure that
     * the token we've already read is "not" and that we're not doing
     * the double-negative thing */
    if (strcmp(self->token, T_NOT) != 0) {
        parse_error(self, "expected '/' or newline");
        return -1;
    }

    /* Watch for double-negative */
    if (self->has_not) {
        parse_error(self, "double negative not permitted");
        return -1;
    }

    /* This is a negated group pattern */
    self->has_not = 1;
    self->token_pointer = self->token;

    /* Anything else is part of the group pattern */
    self->state = lex_group;
    return append_char(self, ch);
}
Example #28
0
char  *my_longlongtoa_base(long long int n, int base,
    const char *charset)
{
  char buffer[ITOA_BUFFER_SIZE];

  buffer[0] = '\0';
  if (n < 0)
    append_char(buffer, '-');
  _my_longlongtoa_base(n, base, charset, buffer);
  return (my_strnew(buffer));
}
Example #29
0
#include "lib.h"

#define ITOA_BUFFER_SIZE 300 

#include <stdio.h>/* DEBUG */
void _my_longlongtoa_base(long long int n, int base,
    const char *charset, char *str)
{
  long long int num;

  num = n % base;
  n = n / base;
  if (n != 0)
    _my_longlongtoa_base(n, base, charset, str);
  append_char(str, charset[ABS(num)]);
}
Example #30
0
void _my_longlongunsignedtoa_base(long long unsigned int n, int base,
    const char *charset, char *str)
{
  long long unsigned int num;

  num = n % base;
  n = n / base;
  if (n > 0)
    _my_longlongunsignedtoa_base(n, base, charset, str);
  append_char(str, charset[num]);
}