int main(void) { LONG result = RETURN_OK; do { dt.dat_Stamp.ds_Days = days; dt.dat_Format = FORMAT_DOS; dt.dat_StrDate = s; DateToStr(&dt); dt.dat_Stamp.ds_Days = -1; StrToDate(&dt); //printf("date \"%s\" day = %ld\n", s, days); if (dt.dat_Stamp.ds_Days != days) { printf("Bad results for date \"%s\" (day #%ld). " "StrToDate thought it was day #%ld\n", s, (long)days, (long)dt.dat_Stamp.ds_Days); result = RETURN_ERROR; } days++; } while (!CheckSignal(SIGBREAKF_CTRL_C) && (days < 36525)); /* 2078-01-01: same as 1978 in FORMAT_DOS */ return result; }
int lib_dos_f_CheckSignal_2(emumsg_syscall_t *msg) { /* Make real syscall */ msg->arg[0]._ulong = CheckSignal(msg->arg[0]._ulong); return HOOK_DONE; }
void ChaseSignals(void) { struct signal *signalPointer; for (signalPointer = lastSignal; signalPointer != NULL_STRUCT(signal); signalPointer = signalPointer -> next) (void) CheckSignal(signalPointer); } /* end ChaseSignals */
static void CheckSignal_Signal(int unused) { #if defined(AFS_PTHREAD_ENV) CheckSignal(0); #else IOMGR_SoftSig(CheckSignal, 0); #endif }
void SPIListener::Run() { Setup(); CheckRun(); // Run until terminated while (1) { // Let the thread sleep for 1/10th of a second. usleep(LISTENER_SLEEP_DELAY); // Check each bus for a signal ResetBuffer(); CheckSignal(SPI_BUS_CAR); ResetBuffer(); CheckSignal(SPI_BUS_RF); } }
int checkcharbuffer(void) { char tecken; ULONG conreadsig = 1L << conreadport->mp_SigBit; while(CheckSignal(conreadsig) & conreadsig) { tecken=congettkn(); if(tecken && typeaheadbuftkn<50) { typeaheadbuf[typeaheadbuftkn++]=tecken; typeaheadbuf[typeaheadbuftkn]=0; } } return typeaheadbuftkn; }
IPTR Ascii__DTM_ASYNCLAYOUT(Class *cl, Object *o, struct gpLayout *gpl) { struct DTSpecialInfo *si = (struct DTSpecialInfo *) G (o)->SpecialInfo; struct AsciiData *data = INST_DATA (cl, o); ULONG visible = 0, total = 0; struct RastPort trp; ULONG hunit = 1; ULONG bsig = 0; /* Switches */ BOOL linefeed = FALSE; BOOL newseg = FALSE; BOOL abort = FALSE; /* Attributes obtained from super-class */ struct TextAttr *tattr; struct TextFont *font; struct List *linelist; struct IBox *domain; IPTR wrap = FALSE; IPTR bufferlen; STRPTR buffer; STRPTR title; /* Line information */ ULONG num, offset, swidth; ULONG anchor = 0, newanchor; ULONG style = FS_NORMAL; struct Line *line; ULONG yoffset = 0; ULONG linelength, max_linelength = 0; UBYTE fgpen = 1; UBYTE bgpen = 0; ULONG tabspace; ULONG numtabs; ULONG i; ULONG nomwidth, nomheight; D(bug("AsciiDataType_AsyncLayout\n")); /* Get all the attributes that we are going to need for a successful layout */ if (GetDTAttrs (o, DTA_TextAttr , (IPTR) &tattr , DTA_TextFont , (IPTR) &font , DTA_Domain , (IPTR) &domain , DTA_ObjName , (IPTR) &title , TDTA_Buffer , (IPTR) &buffer , TDTA_BufferLen , (IPTR) &bufferlen , TDTA_LineList , (IPTR) &linelist , TDTA_WordWrap , (IPTR) &wrap , TAG_DONE) == 8) { D(bug("AsciiDataType_AsyncLayout: Got all attrs\n")); /* Lock the global object data so that nobody else can manipulate it */ ObtainSemaphore (&(si->si_Lock)); /* Make sure we have a buffer */ if (buffer) { D(bug("AsciiDataType_AsyncLayout: Got buffer\n")); /* Initialize the temporary RastPort */ InitRastPort (&trp); SetFont (&trp, font); D(bug("AsciiDataType_AsyncLayout: Temp RastPort initialized\n")); /* Calculate the nominal size */ nomheight = (ULONG) (24 * font->tf_YSize); nomwidth = (ULONG) (80 * font->tf_XSize); /* Calculate the tab space */ tabspace = font->tf_XSize * 8; /* We only need to perform layout if we are doing word wrap, or this * is the initial layout call */ D(bug("AsciiDataType_AsyncLayout: Checking if layout is needed\n")); if (wrap || gpl->gpl_Initial) { D(bug("AsciiDataType_AsyncLayout: Layout IS needed. Freeing old LineList\n")); /* Delete the old line list */ while ((line = (struct Line *) RemHead (linelist))) FreePooled (data->Pool, line, sizeof (struct Line)); D(bug("AsciiDataType_AsyncLayout. Old LineList freed\n")); /* Step through the text buffer */ for (i = offset = num = numtabs = 0; (i < bufferlen) && (bsig == 0) && !abort; i++) { /* Convert DOS and Mac line endings */ if (buffer[i] == '\r') { if (buffer[i + 1] == '\n') i++; else buffer[i] = '\n'; } /* Check for end of line */ if (buffer[i] == '\n') { newseg = linefeed = TRUE; newanchor = i + 1; } /* Check for end of page */ else if (buffer[i] == 12) { newseg = linefeed = TRUE; newanchor = i + 1; } /* Check for tab */ else if (buffer[i] == '\t') { /* See if we need to terminate a line segment */ if ((numtabs == 0) && num) { newseg = TRUE; } numtabs++; } else { /* See if we have any TABs that we need to finish out */ if (numtabs) { offset += (((offset / tabspace) + 1) * tabspace) - offset; num = numtabs = 0; anchor = i; } /* Compute the width of the line. */ swidth = TextLength(&trp, &buffer[anchor], num + 1); num++; } if (i == bufferlen - 1) newseg = TRUE; /* Time for a new text segment yet? */ if (newseg) { /* Allocate a new line segment from our memory pool */ if ((line = AllocPooled(data->Pool, sizeof(struct Line)))) { swidth = TextLength(&trp, &buffer[anchor], num); line->ln_Text = &buffer[anchor]; line->ln_TextLen = num; line->ln_XOffset = offset; line->ln_YOffset = yoffset + font->tf_Baseline; line->ln_Width = swidth; line->ln_Height = font->tf_YSize; line->ln_Flags = (linefeed) ? LNF_LF : 0; line->ln_FgPen = fgpen; line->ln_BgPen = bgpen; line->ln_Style = style; line->ln_Data = NULL; linelength = line->ln_Width + line->ln_XOffset; if (linelength > max_linelength) { max_linelength = linelength; } /* Add the line to the list */ AddTail(linelist, (struct Node *) line); /* Increment the line count */ if (linefeed) { yoffset += font->tf_YSize; offset = 0; total++; } else { /* Increment the offset */ offset += swidth; } } else { abort = TRUE; } /* Clear the variables */ newseg = linefeed = FALSE; anchor = newanchor; num = 0; /* Check to see if layout has been aborted */ bsig = CheckSignal (SIGBREAKF_CTRL_C); } /* if (newseg) */ } /* * check for last line */ D(bug("AsciiDataType_AsyncLayout: end textloop, anchor %ld\n",anchor)); #if 0 if (buffer[anchor]) { linefeed=TRUE; D(bug("AsciiDataType_AsyncLayout: add last line <%s>\n", &buffer[anchor])); /* Allocate a new line segment from our memory pool */ if ((line = AllocPooled(data->Pool, sizeof(struct Line)))) { swidth = TextLength(&trp, &buffer[anchor], num); line->ln_Text = &buffer[anchor]; line->ln_TextLen = num; line->ln_XOffset = offset; line->ln_YOffset = yoffset + font->tf_Baseline; line->ln_Width = swidth; line->ln_Height = font->tf_YSize; line->ln_Flags = (linefeed) ? LNF_LF : 0; line->ln_FgPen = fgpen; line->ln_BgPen = bgpen; line->ln_Style = style; line->ln_Data = NULL; linelength = line->ln_Width + line->ln_XOffset; if (linelength > max_linelength) { max_linelength = linelength; } /* Add the line to the list */ AddTail(linelist, (struct Node *) line); /* Increment the line count */ if (linefeed) { yoffset += font->tf_YSize; offset = 0; total++; } else { /* Increment the offset */ offset += swidth; } } else { abort = TRUE; } } #endif } /* if (wrap || gpl->gpl_Initial) */ else { /* No layout to perform */ total = si->si_TotVert; max_linelength = si->si_TotHoriz * si->si_HorizUnit; } DeinitRastPort(&trp); } /* if (buffer) */ /* Compute the lines and columns type information */ si->si_VertUnit = font->tf_YSize; si->si_VisVert = visible = domain->Height / si->si_VertUnit; si->si_TotVert = total; /* si->si_HorizUnit = hunit = 1; si->si_VisHoriz = (LONG) domain->Width / hunit; si->si_TotHoriz = domain->Width;*/ si->si_HorizUnit = hunit = font->tf_XSize; si->si_VisHoriz = domain->Width / hunit; si->si_TotHoriz = max_linelength / hunit; /* Release the global data lock */ ReleaseSemaphore (&si->si_Lock); /* Were we aborted? */ if (bsig == 0) { /* Not aborted, so tell the world of our newest attributes */ NotifyAttrChanges (o, gpl->gpl_GInfo, 0, GA_ID , G(o)->GadgetID, DTA_VisibleVert , visible , DTA_TotalVert , total , DTA_NominalVert , nomheight , DTA_VertUnit , font->tf_YSize , /* DTA_TopVert , si->si_TopVert , */ DTA_VisibleHoriz , (domain->Width / hunit) , DTA_TotalHoriz , max_linelength / hunit , DTA_NominalHoriz , nomwidth , DTA_HorizUnit , hunit , DTA_TopHoriz , si->si_TopHoriz , DTA_Title , (IPTR)title , DTA_Busy , FALSE , DTA_Sync , TRUE , TAG_DONE); } /* if (bsig == 0) */ } /* if GetDTAttrs(... */ D(bug("AsciiDataType_AsyncLayout: Done. Returning %d\n", total)); return (IPTR)total; }