static int append_ops(var_str * q,const char * name, const db_op_t* op, int n, int * started ) { int i; if( op != NULL) { if( *started ) CHECK(append_const(q,"&"),0,error); CHECK(append_const(q,(char*)name),0,error); CHECK(append_const(q,"="),0,error); for(i=0;i<n;i++) { str tmp; tmp.s = (char*)op[i]; tmp.len = strlen(tmp.s); CHECK(append_str(q,url_encode(tmp)),0,error); if( i < n-1) CHECK(append_const(q,val_delim_s),0,error); } *started = 1; } return 0; error: return -1; }
static int append_values (var_str * q,const char * name, const db_val_t* v, int n, int * started ) { int i; if( v != NULL) { if( *started ) CHECK(append_const(q,"&"),0,error); CHECK(append_const(q,(char*)name),0,error); CHECK(append_const(q,"="),0,error); for(i=0;i<n;i++) { CHECK(append_str(q,url_encode(value_to_string(&v[i]))),0,error); if( i < n-1) CHECK(append_const(q,val_delim_s),0,error); } *started = 1; } return 0; error: return -1; }
/* Assemble code to push a constant on the stack. */ void ax_const_l (struct agent_expr *x, LONGEST l) { static enum agent_op ops[] = {aop_const8, aop_const16, aop_const32, aop_const64}; int size; int op; /* How big is the number? 'op' keeps track of which opcode to use. Notice that we don't really care whether the original number was signed or unsigned; we always reproduce the value exactly, and use the shortest representation. */ for (op = 0, size = 8; size < 64; size *= 2, op++) { LONGEST lim = ((LONGEST) 1) << (size - 1); if (-lim <= l && l <= lim - 1) break; } /* Emit the right opcode... */ ax_simple (x, ops[op]); /* Emit the low SIZE bytes as an unsigned number. We know that sign-extending this will yield l. */ append_const (x, l, size / 8); /* Now, if it was negative, and not full-sized, sign-extend it. */ if (l < 0 && size < 64) ax_ext (x, size); }
void ax_pick (struct agent_expr *x, int depth) { if (depth < 0 || depth > 255) error (_("GDB bug: ax-general.c (ax_pick): stack depth out of range")); ax_simple (x, aop_pick); append_const (x, 1, depth); }
/* * It looks obvious that one CommonPrefixes collection includes many * Prefix elements. This is why it's in plural, right? Not so. * The reference implementation lists one key per collection and * by now some applications depend on it (well, Boto self-test does). */ static GList *bucket_list_pfx(GList *content, GHashTable *common_pfx, const char *delim0) { GList *pfx_list, *tmpl; int cpfx_len; int pfx_len; int delim_len; char *s, *p; char *prefix; char *delim; const static char optag[] = " <CommonPrefixes>\r\n"; const static char edtag[] = " </CommonPrefixes>\r\n"; const static char pfoptag[] = " <Prefix>"; const static char pfedtag[] = "</Prefix>\r\n"; pfx_list = g_hash_table_get_keys(common_pfx); if (!pfx_list) return content; /* At this point delim0 cannot be NULL, since we have a list. */ if ((delim = g_markup_escape_text(delim0, -1)) == NULL) { g_list_free(pfx_list); return content; } delim_len = strlen(delim); cpfx_len = 0; tmpl = pfx_list; while (tmpl) { prefix = g_markup_escape_text((char *) tmpl->data, -1); pfx_len = strlen(prefix); tmpl->data = prefix; cpfx_len += sizeof(optag)-1; cpfx_len += sizeof(pfoptag)-1; cpfx_len += pfx_len; cpfx_len += delim_len; cpfx_len += sizeof(pfedtag)-1; cpfx_len += sizeof(edtag)-1; tmpl = tmpl->next; } cpfx_len += 1; s = malloc(cpfx_len); p = s; #define append_const(buf, c) \ do { memcpy(buf, c, sizeof(c)-1); (buf) += sizeof(c)-1; } while (0) tmpl = pfx_list; while (tmpl) { prefix = (char *) tmpl->data; pfx_len = strlen(prefix); if (p) { append_const(p, optag); append_const(p, pfoptag); memcpy(p, prefix, pfx_len); p += pfx_len; memcpy(p, delim, delim_len); p += delim_len; append_const(p, pfedtag); append_const(p, edtag); } free(prefix); tmpl = tmpl->next; } if (p) *p = 0; free(delim); g_list_free(pfx_list); return s ? g_list_append(content, s) : content; }