static void image_ttf_face__names(INT32 args) { int ns,res; TT_UShort i; TT_Face face=THISf->face; pop_n_elems(args); if ((ns=TT_Get_Name_Count(face))==-1) Pike_error("Image.TTF.Face->names(): Illegal face handler\n"); for (i=0; i<ns; i++) { unsigned short platformID,encodingID,languageID,nameID; TT_UShort length; char *stringPtr; if ((res=TT_Get_Name_ID(face,i, &platformID,&encodingID,&languageID,&nameID))) my_tt_error("Image.TTF.Face->names()","TT_Get_Name_ID: ",res); push_int(platformID); push_int(encodingID); push_int(languageID); push_int(nameID); if ((res=TT_Get_Name_String(face,i,&stringPtr,&length))) my_tt_error("Image.TTF.Face->names()","TT_Get_Name_String: ",res); push_string(make_shared_binary_string(stringPtr,length)); f_aggregate(5); } f_aggregate(ns); }
/*! @decl array(array(string)|string) tokenize(string code) *! *! Tokenize a string of Pike tokens. *! *! @returns *! Returns an array with Pike-level tokens and the remainder (a *! partial token), if any. */ static void f_tokenize( INT32 args ) { struct array *res; struct pike_string *left_s = NULL; /* Make gcc happy. */ struct pike_string *data; int left; ONERROR tmp; get_all_args("tokenize", args, "%W", &data); if(!data->len) { pop_n_elems(args); push_empty_array(); push_empty_string(); f_aggregate(2); return; } res = allocate_array_no_init( 0, 128 ); SET_ONERROR(tmp, do_free_arrayptr, &res); switch(data->size_shift) { case 0: left = tokenize0(&res, STR0(data), data->len); left_s = make_shared_binary_string0(STR0(data)+left, data->len-left); break; case 1: left = tokenize1(&res, STR1(data), data->len); left_s = make_shared_binary_string1(STR1(data)+left, data->len-left); break; case 2: left = tokenize2(&res,STR2(data), data->len); left_s = make_shared_binary_string2(STR2(data)+left, data->len-left); break; #ifdef PIKE_DEBUG default: Pike_error("Unknown shift size %d.\n", data->size_shift); #endif } UNSET_ONERROR(tmp); pop_n_elems(args); if (!res->size) { free_array(res); push_empty_array(); } else push_array(res); push_string( left_s ); f_aggregate( 2 ); }
void f_aap_log_as_array(INT32 args) { struct log_entry *le; struct log *l = LTHIS->log; int n = 0; pop_n_elems(args); mt_lock( &l->log_lock ); le = l->log_head; l->log_head = l->log_tail = 0; mt_unlock( &l->log_lock ); while(le) { struct log_entry *l; n++; push_log_entry(le); l = le->next; free_log_entry(le); le = l; } { f_aggregate(n); } }
static void image_ilbm___decode(INT32 args) { unsigned char *s; ptrdiff_t len; struct pike_string *str; struct mapping *m; int n; extern void parse_iff(char *, unsigned char *, ptrdiff_t, struct mapping *, char *); get_all_args("__decode", args, "%S", &str); s = (unsigned char *)str->str; len = str->len; pop_n_elems(args-1); for(n=0; n<5; n++) push_int(0); push_mapping(m = allocate_mapping(4)); parse_iff("ILBM", s, len, m, "BODY"); mapping_index_no_free(sp-5, m, &string_[string_BMHD]); mapping_index_no_free(sp-4, m, &string_[string_CMAP]); mapping_index_no_free(sp-3, m, &string_[string_CAMG]); mapping_index_no_free(sp-2, m, &string_[string_BODY]); map_delete(m, &string_[string_BMHD]); map_delete(m, &string_[string_CMAP]); map_delete(m, &string_[string_CAMG]); map_delete(m, &string_[string_BODY]); if(sp[-5].type != T_STRING) Pike_error("Missing BMHD chunk\n"); if(sp[-2].type != T_STRING) Pike_error("Missing BODY chunk\n"); /* Extract image size from BMHD */ s = (unsigned char *)STR0(sp[-5].u.string); len = sp[-5].u.string->len; if(len<20) Pike_error("Short BMHD chunk\n"); free_svalue(sp-7); sp[-7].u.integer = (s[0]<<8)|s[1]; sp[-7].type = T_INT; sp[-7].subtype = NUMBER_NUMBER; sp[-6].u.integer = (s[2]<<8)|s[3]; sp[-6].type = T_INT; sp[-6].subtype = NUMBER_NUMBER; f_aggregate(7); }
static void f_nbio_status(INT32 args) { pop_n_elems(args); push_int(noutputs); push_int(ninputs); push_int(nstrings); push_int(nobjects); push_nbio_int(mmapped); push_int(nbuffers); push_int(sbuffers); f_aggregate(7); }
void f__pipe_debug(INT32 args) { pop_n_elems(args); push_int(DO_NOT_WARN(noutputs)); push_int(DO_NOT_WARN(ninputs)); push_int(DO_NOT_WARN(nstrings)); push_int(DO_NOT_WARN(nobjects)); push_int(DO_NOT_WARN(mmapped)); push_int(DO_NOT_WARN(nbuffers)); push_int(DO_NOT_WARN(sbuffers)); f_aggregate(7); }
void image_orient4(INT32 args) { struct object *o[5]; struct image *img[5]; CHECK_INIT(); pop_n_elems(args); _image_orient(THIS,o,img); pop_n_elems(1); f_aggregate(4); }
static void tokenize( struct pike_string *s ) { int in_string = 0; unsigned int ts=0, i, len=s->len; const char *data = s->str; struct svalue *osp = Pike_sp; push_array( allocate_array_no_init( 0, 100 ) ); for( i=0; i<len; i++ ) { if( in_string ) { if( (data[i]=='@') ) { if( data[i+1]!='@' ) { push_token( data, ts, i-1 ); in_string=0; ts=i+1; } else i++; } } else { switch( data[i] ) { case '@': ts=i+1; in_string=1; break; case ':': case ' ': case '\t': case '\n': case '\r': if( ts < i ) push_token( data, ts, i-1 ); ts=i+1; break; case ';': if( ts < i ) push_token( data, ts, i-1 ); ts=i+1; push_array( allocate_array_no_init( 0, 10 ) ); break; } } } if( ts < len ) push_token( data, ts, len-1 ); f_aggregate( Pike_sp-osp ); }
/*! @decl int match(string str) *! *! Returns 1 if @[str] matches the regexp bound to the regexp object. *! Zero otherwise. *! *! @decl array(string) match(array(string) strs) *! *! Returns an array containing strings in @[strs] that match the *! regexp bound to the regexp object. *! *! @bugs *! The current implementation doesn't support searching *! in strings containing the NUL character or any *! wide character. *! *! @seealso *! @[split] */ static void regexp_match(INT32 args) { int i; struct regexp *regexp = THIS->regexp; if(args < 1) SIMPLE_TOO_FEW_ARGS_ERROR("Regexp.SimpleRegexp->match", 1); if(Pike_sp[-args].type == T_STRING) { if(Pike_sp[-args].u.string->size_shift) SIMPLE_BAD_ARG_ERROR("Regexp.SimpleRegexp->match", 1, "Expected string (8bit)"); i = pike_regexec(regexp, (char *)STR0(Pike_sp[-args].u.string)); pop_n_elems(args); push_int(i); return; } else if(Pike_sp[-args].type == T_ARRAY) { struct array *arr; int i, n; arr = Pike_sp[-args].u.array; for(i = n = 0; i < arr->size; i++) { struct svalue *sv = ITEM(arr) + i; if(sv->type != T_STRING || sv->u.string->size_shift) SIMPLE_BAD_ARG_ERROR("Regexp.SimpleRegexp->match", 1, "Expected string (8bit)"); if(pike_regexec(regexp, (char *)STR0(sv->u.string))) { ref_push_string(sv->u.string); n++; } } f_aggregate(n); stack_pop_n_elems_keep_top(args); return; } else SIMPLE_BAD_ARG_ERROR("Regexp.SimpleRegexp->match", 1, "string|array(string)"); }
/* array get_date() */ static void f_get_date(INT32 args) { int year, month, day; GET_PIKE_SEARCH(); if (args) Pike_error("Too many arguments to Search->get_date()\n"); THREADS_ALLOW(); avs_search_getdate(search->handle, &year, &month, &day); THREADS_DISALLOW(); push_int(year); push_int(month); push_int(day); f_aggregate(3); }
/* array get_term(int term_num) */ static void f_get_term(INT32 args) { int n, term_num; long count; char *term; GET_PIKE_SEARCH(); get_all_args("Search->get_term()", args, "%i", &term_num); THREADS_ALLOW(); n = avs_getsearchterms(search->handle, term_num, &term, &count); THREADS_DISALLOW(); if (n != AVS_OK) Pike_error("Search->get_term(): %s\n", avs_errmsg(n)); pop_n_elems(args); push_text(term); push_int(count); f_aggregate(2); }
static void f_ultraparse( INT32 args ) { FD f = -1; int lines=0, cls, c=0, my_fd=1, tzs=0, state=0, next; unsigned char *char_pointer=0; /* array with offsets for fields in the string buffer */ int buf_points[16]; INT32 v=0, offs0=0, len=0, bytes=0, gotdate=0; INT32 last_hour=0, last_date=0, last_year=0, last_month=0, this_date=0, broken_lines=0, tmpinteger=0, field_position=0; time_t start; unsigned char *read_buf; struct svalue *statfun, *daily, *pagexts=0, *file, *refsval, *log_format; unsigned char *buf; char *field_buf; #ifdef BROKEN_LINE_DEBUG INT32 broken_line_pos=0; unsigned char *broken_line; #endif INT32 *state_list, *save_field_num, *field_endings, num_states; char *notref = 0; INT32 state_pos=0, bufpos=0, i, fieldnum=0; struct pike_string *url_str = 0, *ref_str = 0, *rfc_str = 0, *hst_str = 0, *tmpagent = 0; struct svalue *url_sval; ONERROR unwind_protect; unsigned INT32 hits_per_hour[24]; unsigned INT32 hosts_per_hour[24]; unsigned INT32 pages_per_hour[24]; unsigned INT32 sessions_per_hour[24]; double kb_per_hour[24]; unsigned INT32 session_length[24]; /* struct mapping *unique_per_hour = allocate_mapping(1);*/ struct mapping *hits_per_error = allocate_mapping(10); struct mapping *error_urls = allocate_mapping(10); struct mapping *error_refs = allocate_mapping(10); struct mapping *user_agents = allocate_mapping(10); struct mapping *directories = allocate_mapping(20); struct mapping *referrers = allocate_mapping(1); struct mapping *refsites = allocate_mapping(1); struct mapping *referredto = allocate_mapping(1); struct mapping *pages = allocate_mapping(1); struct mapping *hosts = allocate_mapping(1); struct mapping *hits = allocate_mapping(1); struct mapping *session_start = allocate_mapping(1); struct mapping *session_end = allocate_mapping(1); struct mapping *hits20x = allocate_mapping(300); struct mapping *hits302 = allocate_mapping(2); struct mapping *sites = allocate_mapping(1); struct mapping *domains = allocate_mapping(1); struct mapping *topdomains = allocate_mapping(1); struct mapping *tmpdest = NULL; /* struct mapping *hits30x = allocate_mapping(2);*/ if(args>6 && sp[-1].type == T_INT) { offs0 = sp[-1].u.integer; pop_n_elems(1); --args; } if(args>5 && sp[-1].type == T_STRING) { notref = sp[-1].u.string->str; pop_n_elems(1); --args; } lmu = 0; get_all_args("UltraLog.ultraparse", args, "%*%*%*%*%*", &log_format, &statfun, &daily, &file, &pagexts); if(log_format->type != T_STRING) Pike_error("Bad argument 1 to Ultraparse.ultraparse, expected string.\n"); if(statfun->type != T_FUNCTION) Pike_error("Bad argument 2 to Ultraparse.ultraparse, expected function.\n"); if(daily->type != T_FUNCTION) Pike_error("Bad argument 3 to Ultraparse.ultraparse, expected function.\n"); if(pagexts->type != T_MULTISET) Pike_error("Bad argument 5 to Ultraparse.ultraparse, expected multiset.\n"); if(file->type == T_OBJECT) { f = fd_from_object(file->u.object); if(f == -1) Pike_error("UltraLog.ultraparse: File is not open.\n"); my_fd = 0; } else if(file->type == T_STRING && file->u.string->size_shift == 0) { do { f=fd_open(file->u.string->str, fd_RDONLY, 0); } while(f < 0 && errno == EINTR); if(errno < 0) Pike_error("UltraLog.ultraparse(): Failed to open file for reading (errno=%d).\n", errno); } else Pike_error("Bad argument 4 to UltraLog.ultraparse, expected string or object .\n"); state_list = malloc((log_format->u.string->len +3) * sizeof(INT32)); save_field_num = malloc((log_format->u.string->len +3) * sizeof(INT32)); field_endings = malloc((log_format->u.string->len +3) * sizeof(INT32)); num_states = parse_log_format(log_format->u.string, state_list, field_endings, save_field_num); if(num_states < 1) { free(state_list); free(save_field_num); free(field_endings); Pike_error("UltraLog.ultraparse(): Failed to parse log format.\n"); } fd_lseek(f, offs0, SEEK_SET); read_buf = malloc(READ_BLOCK_SIZE+1); buf = malloc(MAX_LINE_LEN+2); #ifdef BROKEN_LINE_DEBUG broken_line = malloc(MAX_LINE_LEN*10); #endif MEMSET(hits_per_hour, 0, sizeof(hits_per_hour)); MEMSET(hosts_per_hour, 0, sizeof(hosts_per_hour)); MEMSET(session_length, 0, sizeof(session_length)); MEMSET(pages_per_hour, 0, sizeof(pages_per_hour)); MEMSET(sessions_per_hour, 0, sizeof(sessions_per_hour)); MEMSET(kb_per_hour, 0, sizeof(kb_per_hour)); /*url_sval.u.type = TYPE_STRING;*/ BUFSET(0); field_position = bufpos; buf_points[0] = buf_points[1] = buf_points[2] = buf_points[3] = buf_points[4] = buf_points[5] = buf_points[6] = buf_points[7] = buf_points[8] = buf_points[9] = buf_points[10] = buf_points[11] = buf_points[12] = buf_points[13] = buf_points[14] = buf_points[15] = 0; while(1) { /* THREADS_ALLOW();*/ do { len = fd_read(f, read_buf, READ_BLOCK_SIZE); } while(len < 0 && errno == EINTR); /* THREADS_DISALLOW();*/ if(len <= 0) break; /* nothing more to read or error. */ offs0 += len; char_pointer = read_buf+len - 1; while(len--) { c = char_pointer[-len]; cls = char_class[c]; #if 0 fprintf(stdout, "DFA(%d:%d): '%c' (%d) ", state, state_pos, c, (int)c); switch(cls) { case CLS_WSPACE: fprintf(stdout, "CLS_WSPACE\n"); break; case CLS_CRLF: fprintf(stdout, "CLS_CRLF\n"); break; case CLS_TOKEN: fprintf(stdout, "CLS_TOKEN\n"); break; case CLS_DIGIT: fprintf(stdout, "CLS_DIGIT\n"); break; case CLS_QUOTE: fprintf(stdout, "CLS_QUOTE\n"); break; case CLS_LBRACK: fprintf(stdout, "CLS_LBRACK\n"); break; case CLS_RBRACK: fprintf(stdout, "CLS_RBRACK\n"); break; case CLS_SLASH: fprintf(stdout, "CLS_SLASH\n"); break; case CLS_COLON: fprintf(stdout, "CLS_COLON\n"); break; case CLS_HYPHEN: fprintf(stdout, "CLS_HYPHEN/CLS_MINUS\n"); break; case CLS_PLUS: fprintf(stdout, "CLS_PLUS\n"); break; default: fprintf(stdout, "??? %d ???\n", cls); } #endif #ifdef BROKEN_LINE_DEBUG broken_line[broken_line_pos++] = c; #endif if(cls == field_endings[state_pos]) { /* Field is done. Nullify. */ process_field: /* printf("Processing field %d of %d\n", state_pos, num_states);*/ switch(save_field_num[state_pos]) { case DATE: case HOUR: case MINUTE: case UP_SEC: case CODE: /* BUFSET(0);*/ tmpinteger = 0; for(v = field_position; v < bufpos; v++) { if(char_class[buf[v]] == CLS_DIGIT) tmpinteger = tmpinteger*10 + (buf[v]&0xf); else { goto skip; } } BUFPOINT = tmpinteger; break; case YEAR: tmpinteger = 0; for(v = field_position; v < bufpos; v++) { if(char_class[buf[v]] == CLS_DIGIT) tmpinteger = tmpinteger*10 + (buf[v]&0xf); else { goto skip; } } if(tmpinteger < 100) { if(tmpinteger < 60) tmpinteger += 2000; else tmpinteger += 1900; } BUFPOINT = tmpinteger; break; case BYTES: v = field_position; switch(char_class[buf[v++]]) { case CLS_QUESTION: case CLS_HYPHEN: if(v == bufpos) tmpinteger = 0; else { goto skip; } break; case CLS_DIGIT: tmpinteger = (buf[field_position]&0xf); for(; v < bufpos; v++) { if(char_class[buf[v]] == CLS_DIGIT) tmpinteger = tmpinteger*10 + (buf[v]&0xf); else { goto skip; } } /* printf("Digit: %d\n", tmpinteger);*/ break; default: goto skip; } BUFPOINT = tmpinteger; /* bufpos++;*/ break; case MONTH: /* Month */ /* BUFSET(0);*/ /* field_buf = buf + field_positions[state_pos];*/ switch(bufpos - field_position) { case 2: tmpinteger = 0; for(v = field_position; v < bufpos; v++) { if(char_class[buf[v]] == CLS_DIGIT) tmpinteger = tmpinteger*10 + (buf[v]&0xf); else { goto skip; } } break; case 3: switch(((buf[field_position]|0x20)<<16)|((buf[field_position+1]|0x20)<<8)| (buf[field_position+2]|0x20)) { case ('j'<<16)|('a'<<8)|'n': tmpinteger = 1; break; case ('f'<<16)|('e'<<8)|'b': tmpinteger = 2; break; case ('m'<<16)|('a'<<8)|'r': tmpinteger = 3; break; case ('a'<<16)|('p'<<8)|'r': tmpinteger = 4; break; case ('m'<<16)|('a'<<8)|'y': tmpinteger = 5; break; case ('j'<<16)|('u'<<8)|'n': tmpinteger = 6; break; case ('j'<<16)|('u'<<8)|'l': tmpinteger = 7; break; case ('a'<<16)|('u'<<8)|'g': tmpinteger = 8; break; case ('s'<<16)|('e'<<8)|'p': tmpinteger = 9; break; case ('o'<<16)|('c'<<8)|'t': tmpinteger = 10; break; case ('n'<<16)|('o'<<8)|'v': tmpinteger = 11; break; case ('d'<<16)|('e'<<8)|'c': tmpinteger = 12; break; } break; default: goto skip; } /*printf("Month: %0d\n", mm);*/ if(tmpinteger < 1 || tmpinteger > 12) goto skip; /* Broken Month */ BUFPOINT = tmpinteger; /* bufpos++;*/ break; case ADDR: case REFER: case AGENT: case TZ: case METHOD: case URL: case RFC: case PROTO: BUFSET(0); SETPOINT(); /* printf("Field %d, pos %d, %s\n", save_field_num[state_pos],BUFPOINT,*/ /* buf + BUFPOINT); */ break; } state_pos++; field_position = bufpos; if(cls != CLS_CRLF) continue; } else if(cls != CLS_CRLF) { BUFSET(c); continue; } else { /* printf("Processing last field (%d).\n", state_pos);*/ goto process_field; /* End of line - process what we got */ } /* printf("%d %d\n", state_pos, num_states);*/ /* buf_points[8] = buf_points[9] = buf_points[10] = buf_points[11] = buf;*/ /* buf_points[12] = buf_points[13] = buf_points[14] = buf_points[15] = buf;*/ #if 0 if(!((lines+broken_lines)%100000)) { push_int(lines+broken_lines); push_int((int)((float)offs0/1024.0/1024.0)); apply_svalue(statfun, 2); pop_stack(); /*printf("%5dk lines, %5d MB\n", lines/1000, (int)((float)offs0/1024.0/1024.0));*/ } #endif if(state_pos < num_states) { #ifdef BROKEN_LINE_DEBUG broken_line[broken_line_pos] = 0; printf("too few states (pos=%d): %s\n", state_pos, broken_line); #endif broken_lines++; goto ok; } #define yy buf_points[YEAR] #define mm buf_points[MONTH] #define dd buf_points[DATE] #define h buf_points[HOUR] #define m buf_points[MINUTE] #define s buf_points[UP_SEC] #define v buf_points[CODE] #define bytes buf_points[BYTES] this_date = (yy*10000) + (mm*100) + dd; if(!this_date) { broken_lines++; goto ok; } #if 1 if(!last_date) { /* First loop w/o a value.*/ last_date = this_date; last_hour = h; } else { if(last_hour != h || last_date != this_date) { pages_per_hour[last_hour] += hourly_page_hits(hits20x, pages, hits, pagexts->u.multiset, 200); /* pages_per_hour[last_hour] +=*/ /* hourly_page_hits(hits304, pages, hits, pagexts->u.multiset, 300);*/ /* printf("%5d %5d for %d %02d:00\n",*/ /* pages_per_hour[last_hour], hits_per_hour[last_hour],*/ /*last_date, last_hour);*/ if(m_sizeof(session_start)) { summarize_sessions(last_hour, sessions_per_hour, session_length, session_start, session_end); free_mapping(session_start); free_mapping(session_end); session_start = allocate_mapping(1); session_end = allocate_mapping(1); } hosts_per_hour[last_hour] += m_sizeof(sites); do_map_addition(hosts, sites); free_mapping(sites); sites = allocate_mapping(100); last_hour = h; free_mapping(hits20x); /* Reset this one */ /* free_mapping(hits304); Reset this one */ /* hits304 = allocate_mapping(2);*/ hits20x = allocate_mapping(2); } #if 1 if(last_date != this_date) { /* printf("%d %d\n", last_date, this_date);*/ tmpdest = allocate_mapping(1); summarize_refsites(refsites, referrers, tmpdest); free_mapping(referrers); referrers = tmpdest; tmpdest = allocate_mapping(1); clean_refto(referredto, tmpdest, pagexts->u.multiset); free_mapping(referredto); referredto = tmpdest; summarize_directories(directories, pages); summarize_directories(directories, hits); tmpdest = allocate_mapping(1); http_decode_mapping(user_agents, tmpdest); free_mapping(user_agents); user_agents = tmpdest; tmpdest = allocate_mapping(1); summarize_hosts(hosts, domains, topdomains, tmpdest); free_mapping(hosts); hosts = tmpdest; #if 1 push_int(last_date / 10000); push_int((last_date % 10000)/100); push_int((last_date % 10000)%100); push_mapping(pages); push_mapping(hits); push_mapping(hits302); push_mapping(hits_per_error); push_mapping(error_urls); push_mapping(error_refs); push_mapping(referredto); push_mapping(refsites); push_mapping(referrers); push_mapping(directories); push_mapping(user_agents); push_mapping(hosts); push_mapping(domains); push_mapping(topdomains); for(i = 0; i < 24; i++) { push_int(sessions_per_hour[i]); } f_aggregate(24); for(i = 0; i < 24; i++) { push_int(hits_per_hour[i]); hits_per_hour[i] = 0; } f_aggregate(24); for(i = 0; i < 24; i++) { push_int(pages_per_hour[i]); pages_per_hour[i] = 0; } f_aggregate(24); for(i = 0; i < 24; i++) { /* KB per hour.*/ push_float(kb_per_hour[i]); kb_per_hour[i] = 0.0; } f_aggregate(24); for(i = 0; i < 24; i++) { push_float(sessions_per_hour[i] ? ((float)session_length[i] / (float)sessions_per_hour[i]) / 60.0 : 0.0); sessions_per_hour[i] = 0; session_length[i] = 0; } f_aggregate(24); for(i = 0; i < 24; i++) { push_int(hosts_per_hour[i]); hosts_per_hour[i] = 0; } f_aggregate(24); apply_svalue(daily, 23); pop_stack(); #else free_mapping(error_refs); free_mapping(referredto); free_mapping(refsites); free_mapping(directories); free_mapping(error_urls); free_mapping(hits); free_mapping(hits_per_error); free_mapping(pages); free_mapping(hosts); free_mapping(domains); free_mapping(topdomains); free_mapping(referrers); free_mapping(hits302); #endif user_agents = allocate_mapping(10); hits302 = allocate_mapping(1); hits_per_error = allocate_mapping(10); error_urls = allocate_mapping(10); error_refs = allocate_mapping(10); directories = allocate_mapping(20); referrers = allocate_mapping(1); referredto = allocate_mapping(1); refsites = allocate_mapping(1); pages = allocate_mapping(1); hits = allocate_mapping(1); sites = allocate_mapping(1); hosts = allocate_mapping(1); domains = allocate_mapping(1); topdomains = allocate_mapping(1); last_date = this_date; } #endif } #endif #if 1 process_session(buf+buf_points[ADDR], h*3600+m*60+s, h, sessions_per_hour, session_length, session_start, session_end, sites); url_str = make_shared_binary_string((char *)(buf + buf_points[URL]), strlen((char *)(buf + buf_points[URL]))); #if 1 switch(v) { /* Do error-code specific logging. Error urls that are specially treated do not include auth required, service unavailable etc. They are only included in the return code summary. */ case 200: case 201: case 202: case 203: case 204: case 205: case 206: case 207: case 304: mapaddstr(hits20x, url_str); DO_REFERRER(); break; case 300: case 301: case 302: case 303: case 305: mapaddstr(hits302, url_str); DO_REFERRER(); break; case 400: case 404: case 405: case 406: case 408: case 409: case 410: case 411: case 412: case 413: case 414: case 415: case 416: case 500: case 501: DO_ERREF(); map2addint(error_urls, v, url_str); break; } /*rfc_str = http_decode_string(buf + buf_points[RFC]);*/ /*hst_str = make_shared_binary_string(buf, strlen(buf));*/ #endif free_string(url_str); mapaddint(hits_per_error, v); kb_per_hour[h] += (float)bytes / 1024.0; hits_per_hour[h]++; /*#endif*/ if(strlen((char *)(buf + buf_points[AGENT]))>1) { /* Got User Agent */ tmpagent = make_shared_string((char *)(buf + buf_points[AGENT])); mapaddstr(user_agents, tmpagent); free_string(tmpagent); } #endif lines++; #if 0 printf("%s %s %s\n%s %s %s\n%04d-%02d-%02d %02d:%02d:%02d \n%d %d\n", buf + buf_points[ADDR], buf + buf_points[REFER], buf + buf_points[ RFC ], buf + buf_points[METHOD], buf + buf_points[ URL ], buf + buf_points[PROTO], yy, mm, dd, h, m, s, v, bytes); /* if(lines > 10) exit(0);*/ #endif ok: gotdate = /* v = bytes =h = m = s = tz = tzs = dd = mm = yy = */ buf_points[0] = buf_points[1] = buf_points[2] = buf_points[3] = buf_points[4] = buf_points[5] = buf_points[6] = buf_points[7] = /*buf_points[8] = buf_points[9] = buf_points[10] =*/ buf_points[11] = buf_points[12] = buf_points[13] = buf_points[14] = buf_points[15] = bufpos = state_pos = 0; field_position = 1; #ifdef BROKEN_LINE_DEBUG broken_line_pos = 0; #endif BUFSET(0); } } cleanup: free(save_field_num); free(state_list); free(field_endings); free(buf); push_int(lines); push_int((int)((float)offs0 / 1024.0/1024.0)); push_int(1); apply_svalue(statfun, 3); pop_stack(); free(read_buf); #ifdef BROKEN_LINE_DEBUG free(broken_line); #endif if(my_fd) /* If my_fd == 0, the second argument was an object and thus we don't * want to free it. */ fd_close(f); /* push_int(offs0); */ /* printf("Done: %d %d %d ", yy, mm, dd);*/ if(yy && mm && dd) { /* printf("\nLast Summary for %d-%02d-%02d %02d:%02d\n", yy, mm, dd, h, m);*/ pages_per_hour[last_hour] += hourly_page_hits(hits20x, pages, hits, pagexts->u.multiset, 200); if(m_sizeof(session_start)) { summarize_sessions(last_hour, sessions_per_hour, session_length, session_start, session_end); } hosts_per_hour[last_hour] += m_sizeof(sites); do_map_addition(hosts, sites); free_mapping(sites); tmpdest = allocate_mapping(1); summarize_refsites(refsites, referrers, tmpdest); free_mapping(referrers); referrers = tmpdest; summarize_directories(directories, pages); summarize_directories(directories, hits); tmpdest = allocate_mapping(1); clean_refto(referredto, tmpdest, pagexts->u.multiset); free_mapping(referredto); referredto = tmpdest; tmpdest = allocate_mapping(1); http_decode_mapping(user_agents, tmpdest); free_mapping(user_agents); user_agents = tmpdest; tmpdest = allocate_mapping(1); summarize_hosts(hosts, domains, topdomains, tmpdest); free_mapping(hosts); hosts = tmpdest; push_int(yy); push_int(mm); push_int(dd); push_mapping(pages); push_mapping(hits); push_mapping(hits302); push_mapping(hits_per_error); push_mapping(error_urls); push_mapping(error_refs); push_mapping(referredto); push_mapping(refsites); push_mapping(referrers); push_mapping(directories); push_mapping(user_agents); push_mapping(hosts); push_mapping(domains); push_mapping(topdomains); for(i = 0; i < 24; i++) { push_int(sessions_per_hour[i]); } f_aggregate(24); for(i = 0; i < 24; i++) { push_int(hits_per_hour[i]); } f_aggregate(24); for(i = 0; i < 24; i++) { push_int(pages_per_hour[i]); } f_aggregate(24); for(i = 0; i < 24; i++) { push_float(kb_per_hour[i]); } f_aggregate(24); for(i = 0; i < 24; i++) { push_float(sessions_per_hour[i] ? ((float)session_length[i] / (float)sessions_per_hour[i]) / 60.0 : 0.0); } f_aggregate(24); for(i = 0; i < 24; i++) { push_int(hosts_per_hour[i]); hosts_per_hour[i] = 0; } f_aggregate(24); apply_svalue(daily, 23); pop_stack(); } else { free_mapping(error_refs); free_mapping(referredto); free_mapping(refsites); free_mapping(directories); free_mapping(error_urls); free_mapping(hits); free_mapping(hits_per_error); free_mapping(pages); free_mapping(referrers); free_mapping(hits302); free_mapping(user_agents); free_mapping(hosts); free_mapping(domains); free_mapping(topdomains); } free_mapping(hits20x); free_mapping(session_start); free_mapping(session_end); /* free_mapping(hits30x); */ printf("\nTotal lines: %d, broken lines: %d, mapping lookups: %d\n\n", lines, broken_lines, lmu); fflush(stdout); pop_n_elems(args); push_int(offs0); return; skip: broken_lines++; while(1) { while(len--) { #ifdef BROKEN_LINE_DEBUG broken_line[broken_line_pos] = char_pointer[-len]; #endif if(char_class[char_pointer[-len]] == CLS_CRLF) { #ifdef BROKEN_LINE_DEBUG broken_line[broken_line_pos] = 0; printf("Broken Line (pos=%d): %s\n", state_pos, broken_line); #endif goto ok; } } do { len = fd_read(f, read_buf, READ_BLOCK_SIZE); } while(len < 0 && errno == EINTR); if(len <= 0) break; /* nothing more to read. */ offs0 += len; char_pointer = read_buf+len - 1; } goto cleanup; }
GdkImage *gdkimage_from_pikeimage(struct object *img, int fast, GdkImage *i) { GdkColormap *col=gdk_colormap_get_system(); GdkVisual *vis=gdk_visual_get_system(); struct image *img_data; INT_TYPE x,y; TIMER_INIT("Getting extents"); img_data=(struct image*)get_storage(img, image_program); /* 1a: create the actual image... */ x = img_data->xsize; y = img_data->ysize; if (x==0 || y==0) Pike_error("Size of image must be > 0x0\n"); if (i) { if ((i->width!=x) || (i->height!=y)) { gdk_image_destroy((void *)i); i=NULL; } } if (!i) { PFTIME("Create"); i=(void *)gdk_image_new(fast,vis,x,y); } if (!i) Pike_error("Failed to create gdkimage\n"); /* 1b: do the work.. */ if (vis->type==GDK_VISUAL_TRUE_COLOR || vis->type==GDK_VISUAL_STATIC_GRAY) /* no colormap.. */ { int pad=0; int native_byteorder; PFTIME("Convert"); if (vis->type==GDK_VISUAL_STATIC_GRAY) pgtk2_encode_grey(img_data,i->mem,i->bpp,i->bpl); else { if (i->bpl!=(i->bpp*x)) switch(i->bpl & 3) { case 0: pad = 4; break; case 1: pad = 1; break; case 2: pad = 2; break; case 3: pad = 1; break; } else pad=0; pgtk2_encode_truecolor_masks(img_data,i->bpp*8,pad*8, (i->byte_order!=1),vis->red_mask, vis->green_mask,vis->blue_mask, i->mem, i->bpl*y); } } else { static int colors_allocated=0; static struct object *pike_cmap; /* I hate this... colormaps, here we come.. */ /* This is rather complicated, but: 1/ build an array of the colors in the colormap 2/ use that array to build a pike X-image colormap. 3/ call Image.X.encode_pseudocolor( img, bpp, lpad, depth, colormp ) 4/ copy the actual data to the image.. */ if (!colors_allocated) { #define COLORMAP_SIZE 256 char allocated[COLORMAP_SIZE]; int j,i,r,g,b; PFTIME("Creating colormap"); colors_allocated=1; MEMSET(allocated,0,sizeof(allocated)); for (r=0; r<3; r++) for (g=0; g<4; g++) for (b=0; b<3; b++) { GdkColor color; color.red = (guint16)(r * (65535/2.0)); color.green = (guint16)(g * (65535/3.0)); color.blue = (guint16)(b * (65535/2.0)); color.pixel = 0; if (gdk_color_alloc(col,&color)) if (color.pixel<COLORMAP_SIZE) allocated[color.pixel]=1; } for (r=0; r<6; r++) for (g=0; g<7; g++) for (b=0; b<6; b++) { GdkColor color; color.red=(guint16)(r*(65535/5.0)); color.green=(guint16)(g*(65535/6.0)); color.blue=(guint16)(b*(65535/5.0)); color.pixel=0; if (gdk_color_alloc(col,&color)) if (color.pixel<COLORMAP_SIZE) allocated[color.pixel]=1; } for (i=0; i<COLORMAP_SIZE; i++) { if (allocated[i]) { push_int(col->colors[i].red>>8); push_int(col->colors[i].green>>8); push_int(col->colors[i].blue>>8); f_aggregate(3); } else push_int(0); } f_aggregate(256); /* now on stack: the array with colors. */ pgtk2_get_image_module(); pgtk2_index_stack("colortable"); /* on stack: array function */ Pike_sp[0]=Pike_sp[-1]; Pike_sp[-1]=Pike_sp[-2]; Pike_sp[-2]=Pike_sp[0]; /* on stack: function array */ PFTIME("Creating colormap obj"); apply_svalue(Pike_sp-2,1); /* on stack: function cmap */ get_all_args("internal",1,"%o",&pike_cmap); pike_cmap->refs+=100; /* lets keep this one.. :-) */ push_int(8); push_int(8); push_int(8); apply(pike_cmap,"rigid",3); pop_stack(); apply(pike_cmap,"ordered",0); pop_stack(); pop_stack(); }
/*! @decl mapping _decode(string data) *! Low level decoding of the NEO file contents in @[data]. *! @returns *! @mapping *! @member Image.Image "image" *! The decoded bitmap *! @member array(Image.Image) "images" *! Coler cycled images. *! @member string "filename" *! The filename stored into the file. *! @member int(0..15) "right_limit" *! @member int(0..15) "left_limit" *! The palette color range to be color cycled. *! @member int(0..255) "speed" *! The animation speed, expressed as the number of VBLs *! per animation frame. *! @member string "direction" *! Color cycling direction. Can be either @expr{"left"@} *! or @expr{"right"@}. *! @member array(array(int(0..255))) "palette" *! The palette to be used for color cycling. *! @endmapping */ void image_neo_f__decode(INT32 args) { unsigned int i, res, size = 0; struct atari_palette *pal=0; struct object *img; struct pike_string *s, *fn; unsigned char *q; ONERROR err; get_all_args( "decode", args, "%S", &s ); if(s->len!=32128) Pike_error("This is not a NEO file (wrong file size).\n"); q = (unsigned char *)s->str; res = q[3]; if(q[2]!=0 || (res!=0 && res!=1 && res!=2)) Pike_error("This is not a NEO file (invalid resolution).\n"); /* Checks done... */ add_ref(s); pop_n_elems(args); if(res==0) pal = decode_atari_palette(q+4, 16); else if(res==1) pal = decode_atari_palette(q+4, 4); SET_ONERROR(err, free_atari_palette, pal); push_constant_text("palette"); for( i=0; i<pal->size; i++ ) { push_int(pal->colors[i].r); push_int(pal->colors[i].g); push_int(pal->colors[i].b); f_aggregate(3); } f_aggregate(pal->size); size += 2; img = decode_atari_screendump(q+128, res, pal); push_constant_text("image"); push_object(img); size += 2; if(q[48]&128) { int rl, ll, i; rl = q[49]&0xf; ll = (q[49]&0xf0)>>4; push_constant_text("right_limit"); push_int( rl ); push_constant_text("left_limit"); push_int( ll ); push_constant_text("speed"); push_int( q[51] ); push_constant_text("direction"); if( q[50]&128 ) push_constant_text("right"); else push_constant_text("left"); push_constant_text("images"); for(i=0; i<rl-ll+1; i++) { if( q[50]&128 ) rotate_atari_palette(pal, ll, rl); else rotate_atari_palette(pal, rl, ll); img = decode_atari_screendump(q+128, res, pal); push_object(img); } f_aggregate(rl-ll+1); size += 10; }
static void f_read( INT32 args ) { char *read_buf; struct svalue *logfun, *file; FD f = -1; int cls, c, my_fd=1, state=0, tzs=0; char *char_pointer; INT32 v=0, yy=0, mm=0, dd=0, h=0, m=0, s=0, tz=0; ptrdiff_t offs0=0, len=0; struct svalue *old_sp; /* #define DYNAMIC_BUF */ #ifdef DYNAMIC_BUF dynamic_buffer buf; #else #define BUFSET(X) do { if(bufpos == bufsize) { bufsize *= 2; buf = realloc(buf, bufsize+1); } buf[bufpos++] = c; } while(0) #define PUSHBUF() do { push_string( make_shared_binary_string( buf,bufpos ) ); bufpos=0; } while(0) char *buf; int bufsize=CLF_BLOCK_SIZE, bufpos=0; #endif if(args>2 && sp[-1].type == T_INT) { offs0 = sp[-1].u.integer; pop_n_elems(1); --args; } old_sp = sp; get_all_args("CommonLog.read", args, "%*%*", &logfun, &file); if(logfun->type != T_FUNCTION) SIMPLE_BAD_ARG_ERROR("CommonLog.read", 1, "function"); if(file->type == T_OBJECT) { f = fd_from_object(file->u.object); if(f == -1) Pike_error("CommonLog.read: File is not open.\n"); my_fd = 0; } else if(file->type == T_STRING && file->u.string->size_shift == 0) { #ifdef PIKE_SECURITY if(!CHECK_SECURITY(SECURITY_BIT_SECURITY)) { if(!CHECK_SECURITY(SECURITY_BIT_CONDITIONAL_IO)) Pike_error("Permission denied.\n"); push_text("read"); push_int(0); ref_push_string(file->u.string); push_text("r"); push_int(00666); safe_apply(OBJ2CREDS(CURRENT_CREDS)->user,"valid_open",5); switch(Pike_sp[-1].type) { case PIKE_T_INT: switch(Pike_sp[-1].u.integer) { case 0: /* return 0 */ errno=EPERM; Pike_error("CommonLog.read(): Failed to open file for reading (errno=%d).\n", errno); case 2: /* ok */ pop_stack(); break; case 3: /* permission denied */ Pike_error("CommonLog.read: permission denied.\n"); default: Pike_error("Error in user->valid_open, wrong return value.\n"); } break; default: Pike_error("Error in user->valid_open, wrong return type.\n"); case PIKE_T_STRING: /* if(Pike_sp[-1].u.string->shift_size) */ /* file=Pike_sp[-1]; */ pop_stack(); } } #endif do { THREADS_ALLOW(); f=fd_open((char *)STR0(file->u.string), fd_RDONLY, 0); THREADS_DISALLOW(); if (f >= 0 || errno != EINTR) break; check_threads_etc(); } while (1); if(f < 0) Pike_error("CommonLog.read(): Failed to open file for reading (errno=%d).\n", errno); } else SIMPLE_BAD_ARG_ERROR("CommonLog.read", 2, "string|Stdio.File"); #ifdef HAVE_LSEEK64 lseek64(f, offs0, SEEK_SET); #else fd_lseek(f, offs0, SEEK_SET); #endif read_buf = malloc(CLF_BLOCK_SIZE+1); #ifndef DYNAMIC_BUF buf = malloc(bufsize); #endif while(1) { do { THREADS_ALLOW(); len = fd_read(f, read_buf, CLF_BLOCK_SIZE); THREADS_DISALLOW(); if (len >= 0 || errno != EINTR) break; check_threads_etc(); } while (1); if(len == 0) break; /* nothing more to read. */ if(len < 0) break; char_pointer = read_buf; while(len--) { offs0++; c = char_pointer[0] & 0xff; char_pointer ++; cls = char_class[c]; #ifdef TRACE_DFA fprintf(stderr, "DFA(%d): '%c' ", state, (c<32? '.':c)); switch(cls) { case CLS_WSPACE: fprintf(stderr, "CLS_WSPACE"); break; case CLS_CRLF: fprintf(stderr, "CLS_CRLF"); break; case CLS_TOKEN: fprintf(stderr, "CLS_TOKEN"); break; case CLS_DIGIT: fprintf(stderr, "CLS_DIGIT"); break; case CLS_QUOTE: fprintf(stderr, "CLS_QUOTE"); break; case CLS_LBRACK: fprintf(stderr, "CLS_LBRACK"); break; case CLS_RBRACK: fprintf(stderr, "CLS_RBRACK"); break; case CLS_SLASH: fprintf(stderr, "CLS_SLASH"); break; case CLS_COLON: fprintf(stderr, "CLS_COLON"); break; case CLS_HYPHEN: fprintf(stderr, "CLS_HYPHEN"); break; case CLS_PLUS: fprintf(stderr, "CLS_PLUS"); break; default: fprintf(stderr, "???"); } fprintf(stderr, " %d items on stack\n", sp-old_sp); #endif switch(state) { case 0: if(sp != old_sp) { if(sp == old_sp+15) { f_aggregate(15); push_int64(offs0); apply_svalue(logfun, 2); pop_stack(); } else pop_n_elems(sp-old_sp); } if(cls > CLS_CRLF) { if(cls == CLS_HYPHEN) { push_int(0); state = 2; break; } #ifdef DYNAMIC_BUF buf.s.str = NULL; initialize_buf( &buf ); low_my_putchar( c, &buf ); #else bufpos = 0; BUFSET(c); #endif state=1; } break; case 1: if(cls > CLS_CRLF) { #ifdef DYNAMIC_BUF low_my_putchar( c, &buf ); #else BUFSET(c); #endif break; } #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); /* remotehost */ #else PUSHBUF(); #endif state = (cls == CLS_WSPACE? 2:0); break; case 2: if(cls > CLS_CRLF) { if(cls == CLS_HYPHEN) { push_int(0); state = 4; break; } #ifdef DYNAMIC_BUF buf.s.str = NULL; initialize_buf( &buf ); low_my_putchar( c, &buf ); #else bufpos = 0; BUFSET(c); #endif state=3; } else if(cls == CLS_CRLF) state=0; break; case 3: if(cls > CLS_CRLF) { #ifdef DYNAMIC_BUF low_my_putchar( c, &buf ); #else BUFSET(c); #endif break; } #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); /* rfc931 */ #else PUSHBUF(); /* rfc931 */ #endif state = (cls == CLS_WSPACE? 4:0); break; case 4: if(cls > CLS_CRLF) { if(cls == CLS_HYPHEN) { push_int(0); state = 6; break; } #ifdef DYNAMIC_BUF buf.s.str = NULL; initialize_buf( &buf ); low_my_putchar( c, &buf ); #else bufpos = 0; BUFSET(c); #endif state=5; } else if(cls == CLS_CRLF) state=0; break; case 5: if(cls > CLS_CRLF) { #ifdef DYNAMIC_BUF low_my_putchar( c, &buf ); #else BUFSET(c); #endif break; } #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); /* authuser */ #else PUSHBUF(); /* authuser */ #endif state = (cls == CLS_WSPACE? 6:0); break; case 6: if(cls == CLS_LBRACK) state = 15; else if(cls == CLS_CRLF) state = 0; else if(cls == CLS_HYPHEN) { push_int(0); push_int(0); push_int(0); state = 7; } break; case 7: if(cls == CLS_QUOTE) { #ifdef DYNAMIC_BUF buf.s.str = NULL; initialize_buf( &buf ); #else bufpos = 0; #endif state = 31; } else if(cls == CLS_CRLF) state = 0; else if(cls == CLS_HYPHEN) { push_int(0); push_int(0); push_int(0); state = 10; } break; case 8: if(cls == CLS_QUOTE) state = 9; else if(cls == CLS_CRLF) { #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); #else PUSHBUF(); #endif state = 0; } else #ifdef DYNAMIC_BUF low_my_putchar( c, &buf ); #else BUFSET(c); #endif break; case 9: if(cls > CLS_CRLF) { #ifdef DYNAMIC_BUF low_my_putchar( '"', &buf); low_my_putchar( c, &buf); #else BUFSET('"'); BUFSET(c); #endif state = 8; break; } #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); /* protocol */ #else PUSHBUF(); /* protoocl */ #endif state = (cls == CLS_CRLF? 0 : 10); break; case 10: if(cls == CLS_DIGIT) { v = c&0xf; state = 11; } else if(cls == CLS_CRLF) state = 0; else if(cls == CLS_HYPHEN) { push_int(0); state = 12; } break; case 11: if(cls == CLS_DIGIT) v = v*10+(c&0xf); else if(cls == CLS_WSPACE) { push_int(v); /* status */ state = 12; } else state = 0; break; case 12: if(cls == CLS_DIGIT) { v = c&0xf; state = 13; } else if(cls == CLS_CRLF) state = 0; else if(cls == CLS_HYPHEN) { push_int(0); state = 14; } break; case 13: if(cls == CLS_DIGIT) v = v*10+(c&0xf); else { push_int(v); /* bytes */ state = (cls == CLS_CRLF? 0:14); } break; case 14: if(cls == CLS_CRLF) state = 0; break; case 15: if(cls == CLS_DIGIT) { dd = c&0xf; state = 16; } else state = (cls == CLS_CRLF? 0:14); break; case 16: /* getting day */ if(cls == CLS_DIGIT) dd = dd*10+(c&0xf); else if(cls == CLS_SLASH) state = 17; else state = (cls == CLS_CRLF? 0:14); break; case 17: if(cls == CLS_DIGIT) { mm = c&0xf; state = 18; } else if(cls == CLS_TOKEN) { mm = c|0x20; state = 21; } else state = (cls == CLS_CRLF? 0:14); break; case 18: /* getting numeric month */ if(cls == CLS_DIGIT) mm = mm*10+(c&0xf); else if(cls == CLS_SLASH) state = 19; else state = (cls == CLS_CRLF? 0:14); break; case 19: if(cls == CLS_DIGIT) { yy = c&0xf; state = 20; } else state = (cls == CLS_CRLF? 0:14); break; case 20: /* getting year */ if(cls == CLS_DIGIT) yy = yy*10+(c&0xf); else if(cls == CLS_COLON) state = 22; else state = (cls == CLS_CRLF? 0:14); break; case 21: /* getting textual month */ if(cls == CLS_TOKEN) mm = (mm<<8)|c|0x20; else if(cls == CLS_SLASH) { state = 19; switch(mm) { case ('j'<<16)|('a'<<8)|'n': mm=1; break; case ('f'<<16)|('e'<<8)|'b': mm=2; break; case ('m'<<16)|('a'<<8)|'r': mm=3; break; case ('a'<<16)|('p'<<8)|'r': mm=4; break; case ('m'<<16)|('a'<<8)|'y': mm=5; break; case ('j'<<16)|('u'<<8)|'n': mm=6; break; case ('j'<<16)|('u'<<8)|'l': mm=7; break; case ('a'<<16)|('u'<<8)|'g': mm=8; break; case ('s'<<16)|('e'<<8)|'p': mm=9; break; case ('o'<<16)|('c'<<8)|'t': mm=10; break; case ('n'<<16)|('o'<<8)|'v': mm=11; break; case ('d'<<16)|('e'<<8)|'c': mm=12; break; default: state = 14; } } break; case 22: if(cls == CLS_DIGIT) { h = c&0xf; state = 23; } else state = (cls == CLS_CRLF? 0:14); break; case 23: /* getting hour */ if(cls == CLS_DIGIT) h = h*10+(c&0xf); else if(cls == CLS_COLON) state = 24; else state = (cls == CLS_CRLF? 0:14); break; case 24: if(cls == CLS_DIGIT) { m = c&0xf; state = 25; } else state = (cls == CLS_CRLF? 0:14); break; case 25: /* getting minute */ if(cls == CLS_DIGIT) m = m*10+(c&0xf); else if(cls == CLS_COLON) state = 26; else state = (cls == CLS_CRLF? 0:14); break; case 26: if(cls == CLS_DIGIT) { s = c&0xf; state = 27; } else state = (cls == CLS_CRLF? 0:14); break; case 27: /* getting second */ if(cls == CLS_DIGIT) s = s*10+(c&0xf); else if(cls == CLS_WSPACE) state = 28; else state = (cls == CLS_CRLF? 0:14); break; case 28: if(cls>=CLS_HYPHEN) { state = 29; tzs = cls!=CLS_PLUS; tz = 0; } else if(cls == CLS_DIGIT) { state = 29; tzs = 0; tz = c&0xf; } else if(cls==CLS_CRLF) state = 0; break; case 29: /* getting timezone */ if(cls == CLS_DIGIT) tz = tz*10+(c&0xf); else { if(tzs) tz = -tz; push_int(yy); push_int(mm); push_int(dd); push_int(h); push_int(m); push_int(s); push_int(tz); if(cls == CLS_RBRACK) state = 7; else state = (cls == CLS_CRLF? 0 : 30); } break; case 30: if(cls == CLS_RBRACK) state = 7; else if(cls == CLS_CRLF) state = 0; break; case 31: if(cls == CLS_QUOTE) { #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); #else PUSHBUF(); #endif push_int(0); push_int(0); state = 10; } else if(cls >= CLS_TOKEN) #ifdef DYNAMIC_BUF low_my_putchar( c, &buf ); #else BUFSET(c); #endif else { #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); /* method */ #else PUSHBUF(); /* method */ #endif state = (cls == CLS_CRLF? 0 : 32); } break; case 32: if(cls == CLS_QUOTE) { push_int(0); push_int(0); state = 10; } else if(cls >= CLS_TOKEN) { #ifdef DYNAMIC_BUF buf.s.str = NULL; initialize_buf( &buf ); low_my_putchar( c, &buf ); #else bufpos = 0; BUFSET(c); #endif state = 33; } else if(cls == CLS_CRLF) state = 0; break; case 33: if(cls == CLS_QUOTE) state = 34; else if(cls == CLS_CRLF) { #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); #else PUSHBUF(); #endif state = 0; } else if(cls == CLS_WSPACE) { #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); /* path */ #else PUSHBUF(); /* path */ #endif state = 35; } else #ifdef DYNAMIC_BUF low_my_putchar( c, &buf ); #else BUFSET(c); #endif break; case 34: if(cls >= CLS_TOKEN) { #ifdef DYNAMIC_BUF low_my_putchar( '"', &buf ); low_my_putchar( c, &buf ); #else BUFSET('"'); BUFSET(c); #endif state = 33; } else if(cls == CLS_CRLF) { #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); #else PUSHBUF(); #endif state = 0; } else { #ifdef DYNAMIC_BUF push_string( low_free_buf( &buf ) ); #else PUSHBUF(); #endif push_text("HTTP/0.9"); state = 10; } break; case 35: if(cls == CLS_QUOTE) { push_text("HTTP/0.9"); state = 10; } else if(cls >= CLS_TOKEN) { #ifdef DYNAMIC_BUF buf.s.str = NULL; initialize_buf( &buf ); low_my_putchar( c, &buf ); #else bufpos = 0; BUFSET(c); #endif state = 8; } else if(cls == CLS_CRLF) state = 0; break; } } }
static void make_colors(void) { static struct color { int r,g,b; char *name; struct pike_string *pname; } c[]={ #define COLOR(name,R,G,B) \ {R,G,B,name,NULL}, #include "colors.h" #undef COLOR }; int i; const int n=sizeof(c)/sizeof(c[0]); for (i=0; (size_t)i<sizeof(html_color)/sizeof(html_color[0]); i++) html_color[i].pname=make_shared_string(html_color[i].name); for (i=0;i<n;i++) { struct color_struct *cs; push_text(c[i].name); copy_shared_string(c[i].pname,sp[-1].u.string); push_object(clone_object(image_color_program,0)); cs=get_storage(sp[-1].u.object,image_color_program); cs->rgb.r=(COLORTYPE)c[i].r; cs->rgb.g=(COLORTYPE)c[i].g; cs->rgb.b=(COLORTYPE)c[i].b; RGB_TO_RGBL(cs->rgbl,cs->rgb); copy_shared_string(cs->name,c[i].pname); } f_aggregate_mapping(n*2); colors=sp[-1].u.mapping; sp--; dmalloc_touch_svalue(sp); for (i=0;i<n;i++) { push_int(c[i].r); push_int(c[i].g); push_int(c[i].b); f_aggregate(3); } f_aggregate(n); colortable=clone_object(image_colortable_program,1); if (!colortable) Pike_fatal("couldn't create colortable\n"); push_int(12); push_int(12); push_int(12); push_int(1); safe_apply(colortable,"cubicles",4); pop_stack(); for (i=0;i<n;i++) push_string(c[i].pname); f_aggregate(n); colornames=sp[-1].u.array; sp--; dmalloc_touch_svalue(sp); }
static void image_xbm__decode( INT32 args ) { struct array *fg = NULL; struct array *bg = NULL; int invert=0, ele; struct pike_string *data; struct object *i=NULL, *a; get_all_args( "Image.XBM.decode", args, "%S", &data ); if (args>1) { if (Pike_sp[1-args].type!=PIKE_T_MAPPING) Pike_error("Image.XBM._decode: illegal argument 2\n"); push_svalue(Pike_sp+1-args); ref_push_string(param_fg); f_index(2); if(!UNSAFE_IS_ZERO(Pike_sp-1)) { if(Pike_sp[-1].type != PIKE_T_ARRAY || Pike_sp[-1].u.array->size != 3) Pike_error("Wrong type for foreground. Should be array(int(0..255))" " with 3 elements\n"); for(ele=0; ele<3; ele++) if(Pike_sp[-1].u.array->item[ele].type != PIKE_T_INT ||Pike_sp[-1].u.array->item[ele].u.integer < 0 ||Pike_sp[-1].u.array->item[ele].u.integer > 255) Pike_error("Wrong type for foreground. Should be array(int(0..255))" " with 3 elements\n"); fg = Pike_sp[-1].u.array; } Pike_sp--; push_svalue(Pike_sp+1-args); ref_push_string(param_bg); f_index(2); if(!UNSAFE_IS_ZERO(Pike_sp-1)) { if(Pike_sp[-1].type != PIKE_T_ARRAY || Pike_sp[-1].u.array->size != 3) Pike_error("Wrong type for background. Should be array(int(0..255))" " with 3 elements\n"); for(ele=0; ele<3; ele++) if(Pike_sp[-1].u.array->item[ele].type != PIKE_T_INT ||Pike_sp[-1].u.array->item[ele].u.integer < 0 ||Pike_sp[-1].u.array->item[ele].u.integer > 255) Pike_error("Wrong type for background. Should be array(int(0..255))" " with 3 elements\n"); bg = Pike_sp[-1].u.array; } Pike_sp--; push_svalue(Pike_sp+1-args); ref_push_string(param_invert); f_index(2); invert = !UNSAFE_IS_ZERO(Pike_sp-1); Pike_sp--; } a = load_xbm( data ); if(!fg) { if(invert) { apply(a, "invert", 0); i = (struct object *)debug_malloc_pass(Pike_sp[-1].u.object); Pike_sp--; } else { i = a; add_ref(a); } } else { if(!bg) { push_int(255); push_int(255); push_int(255); f_aggregate(3); bg = (struct array *)debug_malloc_pass(Pike_sp[-1].u.array); Pike_sp--; } if(invert) { struct array *tmp = fg; fg = bg; bg = fg; } apply(a, "xsize", 0); apply(a, "ysize", 0); push_int( bg->item[0].u.integer ); push_int( bg->item[1].u.integer ); push_int( bg->item[2].u.integer ); i = clone_object( image_program, 5 ); ref_push_object( i ); push_int( fg->item[0].u.integer ); push_int( fg->item[1].u.integer ); push_int( fg->item[2].u.integer ); apply( i, "paste_alpha_color", 4 ); } pop_n_elems(args); push_constant_text( "alpha" ); push_object( a ); push_constant_text( "image" ); if(i) push_object( i ); else push_int( 0 ); f_aggregate_mapping(4); }
static void image_ttf_face_properties(INT32 args) { int res; TT_Face_Properties prop; pop_n_elems(args); res=TT_Get_Face_Properties(THISf->face,&prop); if (res) my_tt_error("Image.TTF.Face->properties()","",res); push_text("num_Glyphs"); push_int(prop.num_Glyphs); push_text("max_Points"); push_int(prop.max_Points); push_text("max_Contours"); push_int(prop.max_Contours); push_text("num_Faces"); push_int(prop.num_Faces); push_text("header"); if (prop.header) { push_text("Table_Version"); push_int(prop.header->Table_Version); push_text("Font_Revision"); push_int(prop.header->Font_Revision); push_text("CheckSum_Adjust"); push_int(prop.header->CheckSum_Adjust); push_text("Magic_Number"); push_int(prop.header->Magic_Number); push_text("Flags"); push_int(prop.header->Flags); push_text("Units_Per_EM"); push_int(prop.header->Units_Per_EM); push_text("Created"); push_int(prop.header->Created[0]); push_int(prop.header->Created[1]); f_aggregate(2); push_text("Modified"); push_int(prop.header->Modified[0]); push_int(prop.header->Modified[1]); f_aggregate(2); push_text("xMin"); push_int(prop.header->xMin); push_text("yMin"); push_int(prop.header->yMin); push_text("xMax"); push_int(prop.header->xMax); push_text("yMax"); push_int(prop.header->yMax); push_text("Mac_Style"); push_int(prop.header->Mac_Style); push_text("Lowest_Rec_PPEM"); push_int(prop.header->Lowest_Rec_PPEM); push_text("Font_Direction"); push_int(prop.header->Font_Direction); push_text("Index_To_Loc_Format"); push_int(prop.header->Index_To_Loc_Format); push_text("Glyph_Data_Format"); push_int(prop.header->Glyph_Data_Format); f_aggregate_mapping(17*2); } else push_int(0); push_text("horizontal"); if (prop.horizontal) { push_text("Version"); push_int(prop.horizontal->Version); push_text("Ascender"); push_int(prop.horizontal->Ascender); push_text("Descender"); push_int(prop.horizontal->Descender); push_text("Line_Gap"); push_int(prop.horizontal->Line_Gap); push_text("advance_Width_Max"); push_int(prop.horizontal->advance_Width_Max); push_text("min_Left_Side_Bearing"); push_int(prop.horizontal->min_Left_Side_Bearing); push_text("min_Right_Side_Bearing"); push_int(prop.horizontal->min_Right_Side_Bearing); push_text("xMax_Extent"); push_int(prop.horizontal->xMax_Extent); push_text("caret_Slope_Rise"); push_int(prop.horizontal->caret_Slope_Rise); push_text("caret_Slope_Run"); push_int(prop.horizontal->caret_Slope_Run); push_text("metric_Data_Format"); push_int(prop.horizontal->metric_Data_Format); push_text("number_Of_HMetrics"); push_int(prop.horizontal->number_Of_HMetrics); f_aggregate_mapping(13*2); } else push_int(0); push_text("os2"); if (prop.os2) { push_text("version"); push_int(prop.os2->version); push_text("xAvgCharWidth"); push_int(prop.os2->xAvgCharWidth); push_text("usWeightClass"); push_int(prop.os2->usWeightClass); push_text("usWidthClass"); push_int(prop.os2->usWidthClass); push_text("fsType"); push_int(prop.os2->fsType); push_text("ySubscriptXSize"); push_int(prop.os2->ySubscriptXSize); push_text("ySubscriptYSize"); push_int(prop.os2->ySubscriptYSize); push_text("ySubscriptXOffset"); push_int(prop.os2->ySubscriptXOffset); push_text("ySubscriptYOffset"); push_int(prop.os2->ySubscriptYOffset); push_text("ySuperscriptXSize"); push_int(prop.os2->ySuperscriptXSize); push_text("ySuperscriptYSize"); push_int(prop.os2->ySuperscriptYSize); push_text("ySuperscriptXOffset"); push_int(prop.os2->ySuperscriptXOffset); push_text("ySuperscriptYOffset"); push_int(prop.os2->ySuperscriptYOffset); push_text("yStrikeoutSize"); push_int(prop.os2->yStrikeoutSize); push_text("yStrikeoutPosition"); push_int(prop.os2->yStrikeoutPosition); push_text("sFamilyClass"); push_int(prop.os2->sFamilyClass); push_text("panose"); push_string(make_shared_binary_string(prop.os2->panose,10)); push_text("ulUnicodeRange1"); push_int(prop.os2->ulUnicodeRange1); push_text("ulUnicodeRange2"); push_int(prop.os2->ulUnicodeRange2); push_text("ulUnicodeRange3"); push_int(prop.os2->ulUnicodeRange3); push_text("ulUnicodeRange4"); push_int(prop.os2->ulUnicodeRange4); push_text("achVendID"); push_string(make_shared_binary_string(prop.os2->achVendID,4)); push_text("fsSelection"); push_int(prop.os2->fsSelection); push_text("usFirstCharIndex"); push_int(prop.os2->usFirstCharIndex); push_text("usLastCharIndex"); push_int(prop.os2->usLastCharIndex); push_text("sTypoAscender"); push_int(prop.os2->sTypoAscender); push_text("sTypoDescender"); push_int(prop.os2->sTypoDescender); push_text("sTypoLineGap"); push_int(prop.os2->sTypoLineGap); push_text("usWinAscent"); push_int(prop.os2->usWinAscent); push_text("usWinDescent"); push_int(prop.os2->usWinDescent); push_text("ulCodePageRange1"); push_int(prop.os2->ulCodePageRange1); push_text("ulCodePageRange2"); push_int(prop.os2->ulCodePageRange2); f_aggregate_mapping(32*2); } else push_int(0); push_text("postscript"); if (prop.postscript) { push_text("FormatType"); push_int(prop.postscript->FormatType); push_text("italicAngle"); push_int(prop.postscript->italicAngle); push_text("underlinePosition"); push_int(prop.postscript->underlinePosition); push_text("underlineThickness"); push_int(prop.postscript->underlineThickness); push_text("isFixedPitch"); push_int(prop.postscript->isFixedPitch); push_text("minMemType42"); push_int(prop.postscript->minMemType42); push_text("maxMemType42"); push_int(prop.postscript->maxMemType42); push_text("minMemType1"); push_int(prop.postscript->minMemType1); push_text("maxMemType1"); push_int(prop.postscript->maxMemType1); f_aggregate_mapping(9*2); } else push_int(0); push_text("hdmx"); if (prop.hdmx) { int i; push_text("version"); push_int(prop.hdmx->version); push_text("num_records"); push_int(prop.hdmx->num_records); push_text("records"); for (i=0; i<prop.hdmx->num_records; i++) { push_text("ppem"); push_int(prop.hdmx->records[i].ppem); push_text("max_width"); push_int(prop.hdmx->records[i].max_width); /* push_text("widths"); push_int(prop.hdmx->records[i].widths);*/ f_aggregate_mapping(2*2); } f_aggregate(prop.hdmx->num_records); f_aggregate_mapping(3*2); } else push_int(0); f_aggregate_mapping(9*2); }
static void f_glGet(INT32 args) { INT32 arg1; GLint i, i2[4]; GLboolean b[4]; GLfloat f[16]; check_all_args("glGet", args, BIT_INT, 0); arg1=Pike_sp[0-args].u.integer; pop_n_elems(args); switch(arg1) { case GL_ACCUM_ALPHA_BITS: case GL_ACCUM_BLUE_BITS: case GL_ACCUM_GREEN_BITS: case GL_ACCUM_RED_BITS: case GL_ALPHA_BITS: case GL_ALPHA_TEST_FUNC: case GL_ATTRIB_STACK_DEPTH: case GL_AUX_BUFFERS: case GL_BLEND_DST: case GL_BLEND_SRC: case GL_BLUE_BITS: case GL_CLIENT_ATTRIB_STACK_DEPTH: case GL_COLOR_ARRAY_SIZE: case GL_COLOR_ARRAY_STRIDE: case GL_COLOR_ARRAY_TYPE: case GL_COLOR_MATERIAL_FACE: case GL_COLOR_MATERIAL_PARAMETER: case GL_CULL_FACE_MODE: case GL_DEPTH_BITS: case GL_DEPTH_FUNC: case GL_DRAW_BUFFER: case GL_EDGE_FLAG_ARRAY_STRIDE: case GL_FOG_HINT: case GL_FOG_MODE: case GL_FRONT_FACE: case GL_GREEN_BITS: case GL_INDEX_ARRAY_STRIDE: case GL_INDEX_ARRAY_TYPE: case GL_INDEX_BITS: case GL_INDEX_OFFSET: case GL_INDEX_SHIFT: case GL_INDEX_WRITEMASK: case GL_LINE_SMOOTH_HINT: case GL_LINE_STIPPLE_PATTERN: case GL_LINE_STIPPLE_REPEAT: case GL_LIST_BASE: case GL_LIST_INDEX: case GL_LIST_MODE: case GL_LOGIC_OP_MODE: case GL_MAP1_GRID_SEGMENTS: case GL_MATRIX_MODE: case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: case GL_MAX_ATTRIB_STACK_DEPTH: case GL_MAX_CLIP_PLANES: case GL_MAX_EVAL_ORDER: case GL_MAX_LIGHTS: case GL_MAX_LIST_NESTING: case GL_MAX_MODELVIEW_STACK_DEPTH: case GL_MAX_NAME_STACK_DEPTH: case GL_MAX_PIXEL_MAP_TABLE: case GL_MAX_PROJECTION_STACK_DEPTH: case GL_MAX_TEXTURE_SIZE: case GL_MAX_TEXTURE_STACK_DEPTH: case GL_MODELVIEW_STACK_DEPTH: case GL_NAME_STACK_DEPTH: case GL_NORMAL_ARRAY_STRIDE: case GL_NORMAL_ARRAY_TYPE: case GL_PACK_ALIGNMENT: case GL_PACK_ROW_LENGTH: case GL_PACK_SKIP_PIXELS: case GL_PACK_SKIP_ROWS: case GL_PERSPECTIVE_CORRECTION_HINT: case GL_PIXEL_MAP_A_TO_A_SIZE: case GL_PIXEL_MAP_B_TO_B_SIZE: case GL_PIXEL_MAP_G_TO_G_SIZE: case GL_PIXEL_MAP_I_TO_A_SIZE: case GL_PIXEL_MAP_I_TO_B_SIZE: case GL_PIXEL_MAP_I_TO_G_SIZE: case GL_PIXEL_MAP_I_TO_I_SIZE: case GL_PIXEL_MAP_I_TO_R_SIZE: case GL_PIXEL_MAP_R_TO_R_SIZE: case GL_PIXEL_MAP_S_TO_S_SIZE: case GL_POINT_SMOOTH_HINT: case GL_POLYGON_MODE: case GL_POLYGON_SMOOTH_HINT: case GL_PROJECTION_STACK_DEPTH: case GL_READ_BUFFER: case GL_RED_BITS: case GL_RENDER_MODE: case GL_SHADE_MODEL: case GL_STENCIL_BITS: case GL_STENCIL_CLEAR_VALUE: case GL_STENCIL_FAIL: case GL_STENCIL_FUNC: case GL_STENCIL_PASS_DEPTH_FAIL: case GL_STENCIL_PASS_DEPTH_PASS: case GL_STENCIL_REF: case GL_STENCIL_VALUE_MASK: case GL_STENCIL_WRITEMASK: case GL_SUBPIXEL_BITS: case GL_TEXTURE_BINDING_1D: case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_COORD_ARRAY_SIZE: case GL_TEXTURE_COORD_ARRAY_STRIDE: case GL_TEXTURE_COORD_ARRAY_TYPE: case GL_TEXTURE_STACK_DEPTH: case GL_UNPACK_ALIGNMENT: case GL_UNPACK_ROW_LENGTH: case GL_UNPACK_SKIP_PIXELS: case GL_UNPACK_SKIP_ROWS: case GL_VERTEX_ARRAY_SIZE: case GL_VERTEX_ARRAY_STRIDE: case GL_VERTEX_ARRAY_TYPE: glGetIntegerv(arg1, &i); push_int(i); break; case GL_MAP2_GRID_SEGMENTS: case GL_MAX_VIEWPORT_DIMS: glGetIntegerv(arg1, i2); push_int(i2[0]); push_int(i2[1]); f_aggregate(2); break; case GL_SCISSOR_BOX: case GL_VIEWPORT: glGetIntegerv(arg1, i2); push_int(i2[0]); push_int(i2[1]); push_int(i2[2]); push_int(i2[3]); f_aggregate(4); break; case GL_ALPHA_TEST: case GL_AUTO_NORMAL: case GL_BLEND: case GL_CLIP_PLANE0: case GL_CLIP_PLANE1: case GL_CLIP_PLANE2: case GL_CLIP_PLANE3: case GL_CLIP_PLANE4: case GL_CLIP_PLANE5: case GL_COLOR_ARRAY: case GL_COLOR_LOGIC_OP: case GL_COLOR_MATERIAL: case GL_CULL_FACE: case GL_CURRENT_RASTER_POSITION_VALID: case GL_DEPTH_TEST: case GL_DEPTH_WRITEMASK: case GL_DITHER: case GL_DOUBLEBUFFER: case GL_EDGE_FLAG: case GL_EDGE_FLAG_ARRAY: case GL_FOG: case GL_INDEX_ARRAY: case GL_INDEX_LOGIC_OP: case GL_INDEX_MODE: case GL_LIGHT0: case GL_LIGHT1: case GL_LIGHT2: case GL_LIGHT3: case GL_LIGHT4: case GL_LIGHT5: case GL_LIGHT6: case GL_LIGHT7: case GL_LIGHTING: case GL_LIGHT_MODEL_LOCAL_VIEWER: case GL_LIGHT_MODEL_TWO_SIDE: case GL_LINE_SMOOTH: case GL_LINE_STIPPLE: case GL_MAP1_COLOR_4: case GL_MAP1_INDEX: case GL_MAP1_NORMAL: case GL_MAP1_TEXTURE_COORD_1: case GL_MAP1_TEXTURE_COORD_2: case GL_MAP1_TEXTURE_COORD_3: case GL_MAP1_TEXTURE_COORD_4: case GL_MAP1_VERTEX_3: case GL_MAP1_VERTEX_4: case GL_MAP2_COLOR_4: case GL_MAP2_INDEX: case GL_MAP2_NORMAL: case GL_MAP2_TEXTURE_COORD_1: case GL_MAP2_TEXTURE_COORD_2: case GL_MAP2_TEXTURE_COORD_3: case GL_MAP2_TEXTURE_COORD_4: case GL_MAP2_VERTEX_3: case GL_MAP2_VERTEX_4: case GL_MAP_COLOR: case GL_MAP_STENCIL: case GL_NORMAL_ARRAY: case GL_NORMALIZE: case GL_PACK_LSB_FIRST: case GL_PACK_SWAP_BYTES: case GL_POINT_SMOOTH: case GL_POLYGON_OFFSET_FILL: case GL_POLYGON_OFFSET_LINE: case GL_POLYGON_OFFSET_POINT: case GL_POLYGON_SMOOTH: case GL_POLYGON_STIPPLE: case GL_RGBA_MODE: case GL_SCISSOR_TEST: case GL_STENCIL_TEST: case GL_STEREO: case GL_TEXTURE_1D: case GL_TEXTURE_2D: case GL_TEXTURE_COORD_ARRAY: case GL_TEXTURE_GEN_Q: case GL_TEXTURE_GEN_R: case GL_TEXTURE_GEN_S: case GL_TEXTURE_GEN_T: case GL_UNPACK_LSB_FIRST: case GL_UNPACK_SWAP_BYTES: case GL_VERTEX_ARRAY: glGetBooleanv(arg1, b); push_int(b[0]); break; case GL_ALPHA_BIAS: case GL_ALPHA_SCALE: case GL_ALPHA_TEST_REF: case GL_BLUE_BIAS: case GL_BLUE_SCALE: case GL_CURRENT_INDEX: case GL_CURRENT_RASTER_DISTANCE: case GL_CURRENT_RASTER_INDEX: case GL_DEPTH_BIAS: case GL_DEPTH_CLEAR_VALUE: case GL_DEPTH_SCALE: case GL_FOG_DENSITY: case GL_FOG_END: case GL_FOG_INDEX: case GL_FOG_START: case GL_GREEN_BIAS: case GL_GREEN_SCALE: case GL_INDEX_CLEAR_VALUE: case GL_LINE_WIDTH: case GL_LINE_WIDTH_GRANULARITY: case GL_POINT_SIZE: case GL_POINT_SIZE_GRANULARITY: case GL_POLYGON_OFFSET_FACTOR: case GL_POLYGON_OFFSET_UNITS: case GL_RED_BIAS: case GL_RED_SCALE: case GL_ZOOM_X: case GL_ZOOM_Y: glGetFloatv(arg1, f); push_float(f[0]); break; case GL_DEPTH_RANGE: case GL_LINE_WIDTH_RANGE: case GL_MAP1_GRID_DOMAIN: case GL_POINT_SIZE_RANGE: glGetFloatv(arg1, f); push_float(f[0]); push_float(f[1]); f_aggregate(2); break; case GL_CURRENT_NORMAL: glGetFloatv(arg1, f); push_float(f[0]); push_float(f[1]); push_float(f[2]); f_aggregate(3); break; case GL_ACCUM_CLEAR_VALUE: case GL_COLOR_CLEAR_VALUE: case GL_CURRENT_COLOR: case GL_CURRENT_RASTER_COLOR: case GL_CURRENT_RASTER_POSITION: case GL_CURRENT_RASTER_TEXTURE_COORDS: case GL_CURRENT_TEXTURE_COORDS: case GL_FOG_COLOR: case GL_LIGHT_MODEL_AMBIENT: case GL_MAP2_GRID_DOMAIN: glGetFloatv(arg1, f); push_float(f[0]); push_float(f[1]); push_float(f[2]); push_float(f[3]); f_aggregate(4); break; case GL_COLOR_WRITEMASK: glGetBooleanv(arg1, b); push_int(b[0]); push_int(b[1]); push_int(b[2]); push_int(b[3]); f_aggregate(4); break; case GL_MODELVIEW_MATRIX: case GL_PROJECTION_MATRIX: case GL_TEXTURE_MATRIX: glGetFloatv(arg1, f); push_float(f[0]); push_float(f[1]); push_float(f[2]); push_float(f[3]); push_float(f[4]); push_float(f[5]); push_float(f[6]); push_float(f[7]); push_float(f[8]); push_float(f[9]); push_float(f[10]); push_float(f[11]); push_float(f[12]); push_float(f[13]); push_float(f[14]); push_float(f[15]); f_aggregate(16); break; default: Pike_error("glGet: Unsupported parameter name\n"); } }