void handleFatalSignal(int signum, siginfo_t *si, void *ctx) { ucontext_t *uc = (ucontext_t*)ctx; eDebug("KILLED BY signal %d", signum); #ifndef NO_OOPS_SUPPORT oops(uc->uc_mcontext, signum == SIGSEGV || signum == SIGABRT); #endif eDebug("-------"); bsodFatal("enigma2, signal"); }
void lock_operation(int fd,int op) { struct flock lock; lock.l_whence=SEEK_SET;//start of the file lock.l_start=lock.l_len=0; lock.l_pid=getpid(); lock.l_type=op; if(fcntl(fd,F_SETLK,&lock)==-1) oops("lock operation",1); return; }
static int get_compress_version(struct compress *compress) { int version = 0; if (ioctl(compress->fd, SNDRV_COMPRESS_IOCTL_VERSION, &version)) { oops(compress, errno, "cant read version"); return -1; } return version; }
void CheckedFile::open( int access, int permission ) //-------------------------------------------------- { CheckedFile * closeIt; // file to be closed when out of handles if( !_isOpen ) { _openAccess = access; _openPermission = permission; while( _openFiles->size() >= MaxOpenReadFiles ) { closeIt = _openFiles->back(); closeIt->privClose(); removeOpenFile( closeIt ); } _handle = ::open( _fileName, _openAccess, _openPermission ); while( _handle == -1 && errno == EMFILE ) { if( _openFiles->size() == 0 ) { FileExcept oops( FileExcept::Open, errno, _fileName ); throw( oops ); } closeIt = _openFiles->back(); closeIt->privClose(); removeOpenFile( closeIt ); _handle = ::open( _fileName, _openAccess, _openPermission ); } if( _handle == -1 ) { // error other than out of handles FileExcept oops( FileExcept::Open, errno, _fileName ); throw( oops ); } _isOpen = TRUE; _logOpen = TRUE; _currOffset = 0; if( !( _openAccess & O_WRONLY ) ) { addOpenFile( this ); } } }
void Expr::Substitute(hParam oldh, hParam newh) { if(op == PARAM_PTR) oops(); if(op == PARAM && parh.v == oldh.v) { parh = newh; } int c = Children(); if(c >= 1) a->Substitute(oldh, newh); if(c >= 2) b->Substitute(oldh, newh); }
int Expr::Precedence(Expr *e) { if(e->op == ALL_RESOLVED) return -1; // never want to reduce this marker if(e->op != BINARY_OP && e->op != UNARY_OP) oops(); switch(e->c) { case 'q': case 's': case 'c': case 'n': return 30; case '*': case '/': return 20; case '+': case '-': return 10; default: oops(); } }
void handleFatalSignal(int signum, siginfo_t *si, void *ctx) { #ifndef NO_OOPS_SUPPORT ucontext_t *uc = (ucontext_t*)ctx; oops(uc->uc_mcontext); #endif print_backtrace(); eDebug("-------FATAL SIGNAL (%d)", signum); bsodFatal("enigma2, signal"); }
static inline void fetch_Single (Single_Item *item) { int i; FT_UShort val; item->coverage = mycalloc (1, sizeof(Coverage_Item)); GSUB_ptr = item->ptr; need(6); item->format = get_UShort(); item->coverage->ptr = item->ptr + get_UShort(); switch (item->format) { case 1: val = get_Short(); item->data.delta = mycalloc (1, sizeof(FT_UShort)); *item->data.delta = val; #ifdef DEBUG warning("Single Substitution Format=1 with Delta=%d at 0x%04x.", val, item->ptr); #endif fetch_Coverage (item->coverage); break; case 2: val = get_UShort(); need(2 * val); item->data.array = mycalloc (1, sizeof(Glyph_Array)); item->data.array->count = val; item->data.array->glyphs = mycalloc (val, sizeof(FT_UShort)); for (i = 0; i < val; i++) item->data.array->glyphs[i] = get_UShort(); #ifdef DEBUG warning("Single Substitution Format=2 with %d Glyphs at 0x%04x.", val, item->ptr); #endif val = fetch_Coverage (item->coverage); if (val != item->data.array->count) oops("Coverage at 0x%04x: covers %d glyphs (should be %d).", item->ptr, val, item->data.array->count); break; default: oops("Single Substitution at 0x%04x: bad Format=%d.", item->ptr, item->format); } add_Single (item); }
void TextWindow::MakeColorTable(const Color *in, float *out) { int i; for(i = 0; in[i].c != 0; i++) { int c = in[i].c; if(c < 0 || c > 255) oops(); out[c*3 + 0] = REDf(in[i].color); out[c*3 + 1] = GREENf(in[i].color); out[c*3 + 2] = BLUEf(in[i].color); } }
static int setup_socket() { int socket_fd = socket(PF_INET, SOCK_STREAM, 0); if(socket_fd == -1) oops("socket initiating error..."); struct sockaddr_in address; bzero((void *)&address, sizeof(address)); address.sin_family = AF_INET; address.sin_addr.s_addr = inet_addr(SERVER_IP); address.sin_port = htons(PORT); int bind_return = bind(socket_fd, (struct sockaddr *)&address, sizeof(address)); if(bind_return == -1) oops("bind error..."); int listen_return = listen(socket_fd, 1); if(listen_return == -1) oops("listen error..."); return socket_fd; }
release_lock(int semset_id) { struct sembuf actions[1]; actions[0].sem_num = 1; actions[0].sem_flg = SEM_UNDO; actions[0].sem_op = -1; if (semop(semset_id, actions, 1) == -1) oops("semop: unlocking", 10); }
void GraphicsWindow::MenuClipboard(int id) { if(id != MNU_DELETE && !SS.GW.LockedInWorkplane()) { Error("Cut, paste, and copy work only in a workplane.\n\n" "Select one with Sketch -> In Workplane."); return; } switch(id) { case MNU_PASTE: { SS.UndoRemember(); Vector trans = SS.GW.projRight.ScaledBy(80/SS.GW.scale).Plus( SS.GW.projUp .ScaledBy(40/SS.GW.scale)); SS.GW.ClearSelection(); SS.GW.PasteClipboard(trans, 0, 1); break; } case MNU_PASTE_TRANSFORM: { if(SS.clipboard.r.n == 0) { Error("Clipboard is empty; nothing to paste."); break; } Entity *wrkpl = SK.GetEntity(SS.GW.ActiveWorkplane()); Vector p = SK.GetEntity(wrkpl->point[0])->PointGetNum(); SS.TW.shown.paste.times = 1; SS.TW.shown.paste.trans = Vector::From(0, 0, 0); SS.TW.shown.paste.theta = 0; SS.TW.shown.paste.origin = p; SS.TW.shown.paste.scale = 1; SS.TW.GoToScreen(TextWindow::SCREEN_PASTE_TRANSFORMED); SS.GW.ForceTextWindowShown(); SS.later.showTW = true; break; } case MNU_COPY: SS.GW.CopySelection(); SS.GW.ClearSelection(); break; case MNU_CUT: SS.UndoRemember(); SS.GW.CopySelection(); SS.GW.DeleteSelection(); break; case MNU_DELETE: SS.UndoRemember(); SS.GW.DeleteSelection(); break; default: oops(); } }
static bool _is_codec_supported(struct compress *compress, struct compr_config *config, const struct snd_compr_caps *caps) { bool codec = false; unsigned int i; for (i = 0; i < caps->num_codecs; i++) { if (caps->codecs[i] == config->codec->id) { /* found the codec */ codec = true; break; } } if (codec == false) { oops(compress, ENXIO, "this codec is not supported"); return false; } if (config->fragment_size < caps->min_fragment_size) { oops(compress, EINVAL, "requested fragment size %d is below min supported %d", config->fragment_size, caps->min_fragment_size); return false; } if (config->fragment_size > caps->max_fragment_size) { oops(compress, EINVAL, "requested fragment size %d is above max supported %d", config->fragment_size, caps->max_fragment_size); return false; } if (config->fragments < caps->min_fragments) { oops(compress, EINVAL, "requested fragments %d are below min supported %d", config->fragments, caps->min_fragments); return false; } if (config->fragments > caps->max_fragments) { oops(compress, EINVAL, "requested fragments %d are above max supported %d", config->fragments, caps->max_fragments); return false; } /* TODO: match the codec properties */ return true; }
int main(int argc,char **argv) { uint16 u16; if (!*argv) usage(); if (!*++argv) usage(); if (!parsetype(*argv,type)) usage(); if (!*++argv) usage(); if (!dns_domain_fromdot(&q,*argv,str_len(*argv))) oops(); if (*++argv) { if (!ip4_scan(*argv,ip)) usage(); } if (!stralloc_copys(&out,"")) oops(); /* uint16_unpack_big(type,&u16); if (!stralloc_catulong0(&out,u16,0)) oops(); if (!stralloc_cats(&out," ")) oops(); if (!dns_domain_todot_cat(&out,q)) oops(); if (!stralloc_cats(&out,":\n")) oops(); */ if (!response_query(q,type,DNS_C_IN)) oops(); response[3] &= ~128; response[2] &= ~1; response[2] |= 4; case_lowerb(q,dns_domain_length(q)); if (byte_equal(type,2,DNS_T_AXFR)) { response[3] &= ~15; response[3] |= 4; } else if (!respond(q,type,ip)) goto DONE; if (!printpacket_cat(&out,response,response_len)) oops(); DONE: buffer_putflush(buffer_1,out.s,out.len); _exit(0); }
void SSurface::SplitInHalf(bool byU, SSurface *sa, SSurface *sb) { sa->degm = sb->degm = degm; sa->degn = sb->degn = degn; // by de Casteljau's algorithm in a projective space; so we must work // on points (w*x, w*y, w*z, w) WeightControlPoints(); switch(byU ? degm : degn) { case 1: sa->CopyRowOrCol (byU, 0, this, 0); sb->CopyRowOrCol (byU, 1, this, 1); sa->BlendRowOrCol(byU, 1, this, 0, this, 1); sb->BlendRowOrCol(byU, 0, this, 0, this, 1); break; case 2: sa->CopyRowOrCol (byU, 0, this, 0); sb->CopyRowOrCol (byU, 2, this, 2); sa->BlendRowOrCol(byU, 1, this, 0, this, 1); sb->BlendRowOrCol(byU, 1, this, 1, this, 2); sa->BlendRowOrCol(byU, 2, sa, 1, sb, 1); sb->BlendRowOrCol(byU, 0, sa, 1, sb, 1); break; case 3: { SSurface st; st.degm = degm; st.degn = degn; sa->CopyRowOrCol (byU, 0, this, 0); sb->CopyRowOrCol (byU, 3, this, 3); sa->BlendRowOrCol(byU, 1, this, 0, this, 1); sb->BlendRowOrCol(byU, 2, this, 2, this, 3); st. BlendRowOrCol(byU, 0, this, 1, this, 2); // scratch var sa->BlendRowOrCol(byU, 2, sa, 1, &st, 0); sb->BlendRowOrCol(byU, 1, sb, 2, &st, 0); sa->BlendRowOrCol(byU, 3, sa, 2, sb, 1); sb->BlendRowOrCol(byU, 0, sa, 2, sb, 1); break; } default: oops(); } sa->UnWeightControlPoints(); sb->UnWeightControlPoints(); UnWeightControlPoints(); }
main() { int seg_id; char *mem_ptr, *ctime(); long now; int n; seg_id = shmget(TIME_MEM_KEY, SEG_SIZE, IPC_CREAT|0777); if( seg_id == -1 ) oops("shmget", 1); mem_ptr = shmat(seg_id, NULL, 0); if (mem_ptr == (void *) -1) oops("shmat", 2); for (n = 0; n < 60; n++) { time(&now); strcpy(mem_ptr, ctime(&now)); sleep(1); } shmctl(seg_id, IPC_RMID, NULL); }
/* attr ::= '@' text ';' text is 'a' integer (alignment) 'p' integer (pointer class) 'P' (packed type) 's' integer (size of type in bits) 'S' (string instead of array of chars) */ static int parseattr(char *p, char **text, char **pp) { if(*p != '@') return -1; *text = p+1; if((p = strchr(p, ';')) == nil) oops(); *pp = p+1; return 0; }
Vector EntityBase::EndpointFinish() { if(type == LINE_SEGMENT) { return SK.GetEntity(point[1])->PointGetNum(); } else if(type == CUBIC) { return CubicGetFinishNum(); } else if(type == ARC_OF_CIRCLE) { return SK.GetEntity(point[2])->PointGetNum(); } else { oops(); } }
int compress_get_hpointer(struct compress *compress, unsigned int *avail, struct timespec *tstamp) { struct snd_compr_avail kavail; __u64 time; if (!is_compress_ready(compress)) return oops(compress, ENODEV, "device not ready"); if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &kavail)) return oops(compress, errno, "cannot get avail"); if (0 == kavail.tstamp.sampling_rate) return oops(compress, ENODATA, "sample rate unknown"); *avail = (unsigned int)kavail.avail; time = kavail.tstamp.pcm_io_frames / kavail.tstamp.sampling_rate; tstamp->tv_sec = time; time = kavail.tstamp.pcm_io_frames % kavail.tstamp.sampling_rate; tstamp->tv_nsec = time * 1000000000 / kavail.tstamp.sampling_rate; return 0; }
Quaternion EntityBase::PointGetQuaternion(void) { Quaternion q; if(type == POINT_N_ROT_AA) { q = GetAxisAngleQuaternion(3); } else if(type == POINT_N_ROT_TRANS) { q = Quaternion::From(param[3], param[4], param[5], param[6]); } else oops(); return q; }
int main(int argc, char const *argv[]) { /* code */ int pipefd[2]; int len; char buf[BUFFSIZE]; int read_len; if (pipe(pipefd) == -1) oops("cannot get a pipe", 1); switch (fork()) { case -1: oops("cannot fork", 2); case 0://child len = strlen(CHILD_MESS); while (1) { if (write(pipefd[1], CHILD_MESS, len) != len) oops("child write error", 3); sleep(5); } default://parent len = strlen(PAR_MESS); while (1) { if (write(pipefd[1], PAR_MESS, len) != len) oops("parent write error", 4); sleep(1); read_len = read(pipefd[0], buf, BUFFSIZE); if (read_len <= 0) //finish read break; write(1, buf, read_len); } } return 0; }
void nested_try(void) { try { try { try_something(); } catch(int e) { throw 't'; } } catch (char e) { oops(); } catch (...) { oops(); } }
/** drop a mailbox */ int db_dropmbox (char *mbox) { char buf[BUFSIZ]; PGresult *res; snprintf (buf, BUFSIZ, "delete from mbox where name=%s", mbox); res = PQexec (conn, buf); if (res == NULL) oops ("Whoa, critical error", "res was returned as null"); return GEMS_TRUE; }
/** delete all entries in a table */ int db_flush (char *table) { char buf[BUFSIZ]; PGresult *res; snprintf (buf, BUFSIZ, "delete from %s", table); res = PQexec (conn, buf); if (res == NULL) oops ("Whoa, critical error", "res was returned as null"); return GEMS_TRUE; }
void SolveSpace::LoadUsingTable(char *key, char *val) { int i; for(i = 0; SAVED[i].type != 0; i++) { if(strcmp(SAVED[i].desc, key)==0) { union SAVEDptr *p = (union SAVEDptr *)SAVED[i].ptr; unsigned int u = 0; switch(SAVED[i].fmt) { case 'N': p->N.strcpy(val); break; case 'b': p->b = (atoi(val) != 0); break; case 'd': p->d = atoi(val); break; case 'f': p->f = atof(val); break; case 'x': sscanf(val, "%x", &u); p->x = u; break; case 'c': sscanf(val, "%x", &u); p->c = RgbColor::FromPackedInt(u); break; case 'P': if(strlen(val)+1 < MAX_PATH) strcpy(&(p->P), val); break; case 'M': { // Don't clear this list! When the group gets added, it // makes a shallow copy, so that would result in us // freeing memory that we want to keep around. Just // zero it out so that new memory is allocated. memset(&(p->M), 0, sizeof(p->M)); for(;;) { EntityMap em; char line2[1024]; if (fgets(line2, (int)sizeof(line2), fh) == NULL) break; if(sscanf(line2, "%d %x %d", &(em.h.v), &(em.input.v), &(em.copyNumber)) == 3) { p->M.Add(&em); } else { break; } } break; } default: oops(); } break; } } if(SAVED[i].type == 0) { fileLoadError = true; } }
void * myrealloc(void *oldp, size_t len) { void *p; #ifdef SMALLMALLOC if (len > 65500L) oops("Cannot allocate more than 64kByte."); #endif if (len) p = realloc(oldp, len); else p = realloc(oldp, 1); if (p == NULL) oops("Out of memory."); return p; }
static inline void fetch_Glyphs (FT_UShort count, FT_UShort *glyphs) { int i; need(2 * count); for (i = 0; i < count; i++) glyphs[i] = get_UShort(); for (i = 1; i < count; i++) if (glyphs[i] <= glyphs[i - 1]) oops("Glyph[%d]=%d and Glyph[%d]=%d: out of order.", i - 1, glyphs[i - 1], i, glyphs[i]); }
/* * setup: get pid, socket, and address of license server * IN no args * RET nothing, dies on error * notes: assumes server is on same host as client */ setup() { char hostname[BUFSIZ]; pid = getpid(); /* for ticks and msgs */ sd = make_dgram_client_socket(); /* to talk to server */ if ( sd == -1 ) oops("Cannot create socket"); gethostname(hostname, HOSTLEN); /* server on same host */ make_internet_address(hostname, SERVER_PORTNUM, &serv_addr); serv_alen = sizeof(serv_addr); }
void lock_operation(int fd, int op) { struct flock lock; lock.l_whence = SEEK_SET; lock.l_start = lock.l_len = 0; lock.l_pid = getpid(); lock.l_type = op; if (fcntl(fd, F_SETLKW, &lock) == -1) oops("lock operation", 6); }
void showdata(char *fname, int fd) { char buf[BUFSIZ]; int n; printf("%s: ", fname); fflush(stdout); n = read(fd, buf, BUFSIZ); if (n == -1) oops(fname, 5); write(1, buf, n); write(1, "\n", 1); }