int crypto_hashblocks(unsigned char *r,const unsigned char *b,unsigned long long blen) { unsigned char state[64]; unsigned char positions[128]; int i; column v,t; for (i = 0;i < 64;++i) state[i] = r[i]; while (blen >= 48) { for(i=0;i<64;i++) positions[i] = state[i]; for(i=64;i<112;i++) positions[i] = b[i-64]; column_load(&v, positions[0]); for(i=1;i<112;i++) { column_mulx128(&v); column_load(&t, positions[i]); column_add(&v, &t); column_modx509(&v); } for(i=0;i<8;i++) store_littleendian(state + 8*i,v.x[i]); b += 48; blen -= 48; } for (i = 0;i < 64;++i) r[i] = state[i]; return blen; }
static void add_sample(size_t sample_no, char *sample) { const char *label = strtok(sample, "\t"); if (!label) die("unexpected error"); uint32_t label_no = find_label(label); if (label_no == INVALID_LABEL) die("unexpected error"); g_data.samples_labels[sample_no] = label_no; for (size_t feat_no = 0; feat_no < g_data.num_features; feat_no++) { const char *feat = strtok(NULL, "\t"); if (!feat) die_loc("not enough features (expected %zu, found only %zu), maybe there is an empty field?", g_data.num_features, feat_no); column_add(&g_data.columns[feat_no], sample_no, feat); } if (strtok(NULL, "\t")) die_loc("excess features (expected merely %zu)", g_data.num_features); }
/* find a column in a table referenced in a result */ column_ref_t *column_find(char* str, result_t *r) { char* tbl = NULL; char* col; char* rdup; char* tmp; char* c; nvp_t *n; int t_i = 0; int r_i = 0; table_ref_t *t = NULL; table_t *tab = NULL; int l; column_ref_t *ret = NULL; column_ref_t *cl; if (!str || !r) { error(r,CSVDB_ERROR_COLUMNREF,str); return NULL; } l = strlen(str); rdup = alloca(l+1); strcpy(rdup,str); if ((col = strchr(rdup,'.'))) { *col = 0; col++; tbl = rdup; }else{ col = rdup; } if (!col || !col[0]) { error(r,CSVDB_ERROR_COLUMNREF,str); return NULL; } if (tbl) { if (tbl[0] == '`' && (tmp = strchr(tbl+1,'`')) && !tmp[1]) { tbl++; *tmp = 0; } t = r->table; if (strcasecmp(tbl,"FILE")) { while (t) { if (!strcmp(tbl,t->alias) || nvp_search(t->t->name,tbl)) break; t_i++; t = t->next; } } if (!t) { error(r,CSVDB_ERROR_TABLEREF,str); return NULL; } } if (col[0] == '`' && (tmp = strchr(col+1,'`')) && !tmp[1]) { col++; *tmp = 0; } if (!strcmp(col,"*")) { if (t) { tab = t->t; n = tab->columns; while (n) { cl = column_add(&ret,n->value,NULL,tab); cl->r_index = r_i++; cl->t_index = t_i; n = n->next; } }else{ t = r->table; t_i = 0; while (t) { n = t->t->columns; r_i = 0; while (n) { cl = column_add(&ret,n->value,NULL,t->t); cl->r_index = r_i++; cl->t_index = t_i; n = n->next; } t_i++; t = t->next; } } return ret; } if (!t) { t = r->table; t_i = 0; while (t) { if (nvp_searchi(t->t->columns,col) > -1) { tab = t->t; break; } t_i++; t = t->next; } }else{ t_i = 0; tab = t->t; } if (tab) { l = nvp_searchi(tab->columns,col); if (l < 0) { if ((tmp = strchr(col,'('))) { *tmp = 0; if (!strcasecmp(col,"COLUMN")) { *tmp = '('; c = strchr(tmp+1,')'); if (c) { *c = 0; l = atoi(tmp+1); *c = ')'; l--; if (t) { n = nvp_grabi(t->t->columns,l); if (!n) { char bf[50]; sprintf(bf,"COLUMN(%d)",l); error(r,CSVDB_ERROR_OUTOFRANGE,bf); return NULL; } return column_find(n->value,r); }else if (!r->table->next) { n = nvp_grabi(r->table->t->columns,l); if (!n) { char bf[50]; sprintf(bf,"COLUMN(%d)",l); error(r,CSVDB_ERROR_OUTOFRANGE,bf); return NULL; } return column_find(n->value,r); } } } *tmp = '('; } } if (l > -1) { n = nvp_grabi(tab->columns,l); ret = column_create(n->value,NULL,tab); ret->t_index = t_i; ret->r_index = l; return ret; } } error(r,CSVDB_ERROR_COLUMNREF,str); return NULL; }