void Player::playStream(const String& item, const xbmcgui::ListItem* plistitem, bool windowed) { XBMC_TRACE; DelayedCallGuard dc(languageHook); if (!item.empty()) { // set fullscreen or windowed CMediaSettings::Get().SetVideoStartWindowed(windowed); // force a playercore before playing g_application.m_eForcedNextPlayer = playerCore; const AddonClass::Ref<xbmcgui::ListItem> listitem(plistitem); if (listitem.isSet()) { // set m_strPath to the passed url listitem->item->SetPath(item.c_str()); CApplicationMessenger::Get().PlayFile((const CFileItem)(*(listitem->item)), false); } else { CFileItem nextitem(item, false); CApplicationMessenger::Get().MediaPlay(nextitem.GetPath()); } } else playCurrent(windowed); }
int default_action(int msg) { switch(msg) { case NEXT:deselectitem();nextitem();selectitem();break; case PREV:deselectitem();previtem();selectitem();break; case FORW:deselectitem();rightitem();selectitem();break; case BACK:deselectitem();leftitem();selectitem();break; case 'e': case '\n': case '\r': do_ok(msg);break; case 0x1b:deselectitem();setup_flag=-1;break; case UPDATE: default_update();break; case UPDATE1: default_update1();break; case TIMER: case CLEAN: printmenu();break; default: if(msg>='1' && msg <= '9')default_digital(msg); else return 0; break; } return 1; }
/* * netclear() * * We are about to do a TELNET SYNCH operation. Clear * the path to the network. * * Things are a bit tricky since we may have sent the first * byte or so of a previous TELNET command into the network. * So, we have to scan the network buffer from the beginning * until we are up to where we want to be. * * A side effect of what we do, just to keep things * simple, is to clear the urgent data pointer. The principal * caller should be setting the urgent data pointer AFTER calling * us in any case. */ void netclear(void) { char *thisitem, *next; char *good; #define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \ ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL)) #ifdef ENCRYPTION thisitem = nclearto > netobuf ? nclearto : netobuf; #else /* ENCRYPTION */ thisitem = netobuf; #endif /* ENCRYPTION */ while ((next = nextitem(thisitem)) <= nbackp) { thisitem = next; } /* Now, thisitem is first before/at boundary. */ #ifdef ENCRYPTION good = nclearto > netobuf ? nclearto : netobuf; #else /* ENCRYPTION */ good = netobuf; /* where the good bytes go */ #endif /* ENCRYPTION */ while (nfrontp > thisitem) { if (wewant(thisitem)) { int length; next = thisitem; do { next = nextitem(next); } while (wewant(next) && (nfrontp > next)); length = next-thisitem; memmove(good, thisitem, length); good += length; thisitem = next; } else { thisitem = nextitem(thisitem); } } nbackp = netobuf; nfrontp = good; /* next byte to be sent */ neturg = 0; } /* end of netclear */
int mydict::query(const char *word) { if (!working) return 0; int i; long index; const char *tmp; char item1[512],item2[30],item3[512]; tmp=word; if(tmp==NULL) return 0; for(i=0;i<indexnum;i++) { if(strcasecmp(tmp,indexitem[i])<=0) break; } if(i==indexnum) i--; if(offset!=indexoffset[i]) { offset=indexoffset[i]; fseek(f1,offset,0); fread(buf,MAXLEN,1,f1); } cont=0; nextitem(item1,item2,item3); previtem(item1,item2,item3); while(1) { if(strcasecmp(tmp,item1)<=0) break; index=nextitem(item1,item2,item3); if(index<=0) break; } previtem(nearEnglishItem[0],nearMarkItem[0],nearChineseItem[0]); for(i=1;i<10;i++) { index=nextitem(nearEnglishItem[i],nearMarkItem[i],nearChineseItem[i]); if(index<=0) break; } nearNum=i; for(;i>1;i--) { index=previtem(item1,item2,item3); if(index<=0) break; } return nearNum; }
void tojson(BYTE* buffer, int level, int isarray) { int i = 0; printf ((isarray) ? "[" : "{"); if (*buffer) { do { if (i>0) printf(","); printf ("\n"); addtabs(level); if (!isarray) { printf("\"%s\": ", getkey(buffer)); } switch (gettype(buffer)) { case BT_INT32BIT: printf("%d", asint(getvalue(buffer))); break; case BT_FLOP64BIT: printf("%lf", asdouble(getvalue(buffer))); break; case BT_BOOLFALSETRUE: printf("%s", (asboolean(getvalue(buffer)) ? "true" : "false")); break; case BT_UTF8STRING: printf("\"%s\"", asstring(getvalue(buffer))); break; case BT_EMBEDEDDOC: tojson(opendoc(getvalue(buffer), 0), level + 1, 0); break; case BT_ARRAY: tojson(opendoc(getvalue(buffer), 0), level + 1, 1); break; default: printf(" \"(0x%X) __NOTIMPLEMENTED__\"", gettype(buffer)); } i++; //getchar(); } while (*(buffer = nextitem(buffer))); printf ("\n"); addtabs(level - 1); } printf ((isarray) ? "]" : "}"); if (errorno) printf ("ERROR #%d\n", errorno); }
static void netclear() { #if 0 /* XXX */ char *thisitem, *next; char *good; #define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \ ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL)) thisitem = netobuf; while ((next = nextitem(thisitem)) <= netobuf.send) { thisitem = next; } /* Now, thisitem is first before/at boundary. */ good = netobuf; /* where the good bytes go */ while (netoring.add > thisitem) { if (wewant(thisitem)) { int length; next = thisitem; do { next = nextitem(next); } while (wewant(next) && (nfrontp > next)); length = next-thisitem; memmove(good, thisitem, length); good += length; thisitem = next; } else { thisitem = nextitem(thisitem); } } #endif /* 0 */ }
element lookup(value buffer, char* key, int n) { /* returns pointer to the beginning of the field with key = key */ /* buffer points to a doc/array value */ do { #ifdef DEBUG printf("0X%x\r\n", type); printf("key=%s\r\n", getkey(buffer)); printf("search=%s\r\n", key); printf("n=%d\r\n", n); #endif if (strncmp(getkey(buffer), key, n) == 0) { #ifdef DEBUG printf("A\r\n"); #endif return buffer; } } while (*(buffer = nextitem(buffer))); return 0; }
int main(int argc,char *argv[]) { int i; FILE *file; char dem_description[81]; int coord_sys,coord_zone,coord_datum; int coord_units,scaling_units; float coord_SW_x,coord_SW_y; float coord_NW_x,coord_NW_y; float coord_NE_x,coord_NE_y; float coord_SE_x,coord_SE_y; float cell_size_x,cell_size_y; float vertical_scaling; int missing_value; char *comment; unsigned char *image; int width,height, row,column; int elev; if (argc!=3 && argc!=4) { printf("usage: %s <input.dem> <output.pgm> [<missing value>]\n",argv[0]); printf("note: guaranteed to work for USGS 1:250,000 DEM quads only\n"); exit(1); } if ((file=fopen(argv[1],"rb"))==NULL) exit(1); // DEM descriptor for (i=0; i<80; i++) dem_description[i]=fgetc(file); dem_description[80]='\0'; for (i=0; i<29; i++) fgetc(file); // skip blank filler for (i=0; i<26; i++) fgetc(file); // skip geographic corner for (i=0; i<2; i++) fgetc(file); // skip process code for (i=0; i<3; i++) fgetc(file); // skip sectional indicator for (i=0; i<4; i++) fgetc(file); // skip origin code for (i=0; i<6; i++) fgetc(file); // skip DEM level code for (i=0; i<6; i++) fgetc(file); // skip elevation pattern // reference coordinate system coord_sys=ftrc(nextitem(file)); coord_zone=ftrc(nextitem(file)); coord_datum=0; if (coord_sys!=0) exit(1); // only 0=lat/lon supported for (i=0; i<15; i++) nextitem(file); // skip projection // reference units coord_units=ftrc(nextitem(file)); scaling_units=ftrc(nextitem(file)); // check units if (coord_units<0 || coord_units>3) exit(1); if (scaling_units<1 || scaling_units>2) exit(1); if (coord_units==3) coord_units=4; nextitem(file); // skip polygon sides // coordinates of corners coord_SW_x=nextitem(file); coord_SW_y=nextitem(file); coord_NW_x=nextitem(file); coord_NW_y=nextitem(file); coord_NE_x=nextitem(file); coord_NE_y=nextitem(file); coord_SE_x=nextitem(file); coord_SE_y=nextitem(file); nextitem(file); // skip minimum elevation nextitem(file); // skip maximum elevation // spatial resolution fseek(file,817,SEEK_SET); cell_size_x=nextitem(file); cell_size_y=nextitem(file); vertical_scaling=nextitem(file); // missing value missing_value=-9999; if (argc==4) if (sscanf(argv[3],"%d",&missing_value)!=1) exit(1); // DEM width if (ftrc(nextitem(file))!=1) exit(1); width=ftrc(nextitem(file)); // actual row/column/height of DEM profile row=ftrc(nextitem(file)); column=ftrc(nextitem(file)); height=ftrc(nextitem(file)); if ((image=(unsigned char *)malloc(2*width*height))==NULL) exit(1); while (row==1 && column>0 && column<=width) { for (i=0; i<6; i++) nextitem(file); // skip profile position // read elevations while (row++<=height) { elev=ftrc(nextitem(file)); if (elev<0) elev=65536+elev; image[2*(column-1+(height-row+1)*height)]=elev/256; image[2*(column-1+(height-row+1)*height)+1]=elev%256; } // next profile row=ftrc(nextitem(file)); column=ftrc(nextitem(file)); nextitem(file); // ignore number of samples } fclose(file); comment=putPNMparams(dem_description, coord_sys,coord_zone,coord_datum, coord_units, coord_SW_x,coord_SW_y, coord_NW_x,coord_NW_y, coord_NE_x,coord_NE_y, coord_SE_x,coord_SE_y, cell_size_x,cell_size_y, scaling_units, vertical_scaling, missing_value); writePNMimage(argv[2],image, width,height,2, comment); free(comment); return(0); }