int DGifGetLineByte(GifFileType *GifFile, GifPixelType *Line, int LineLen) { GifPixelType LineBuf[240]; CopyLine(LineBuf, Line, LineLen); int result = DGifGetLine(GifFile, LineBuf, LineLen); CopyLine(Line, LineBuf, LineLen); return result; }
/*Funcao auxiliar que imprime apenas um registro. Recebe como parametros o stream do arquivo e a posicao inicial do registro e retorna o tamanho do registro. Retorna -1 se o registro estiver vazio ou se input = NULL.*/ int PrintRegister(FILE *input,int initialPosition) { char *registro; int byteSize=-1; registro = (char *)malloc(sizeof(char)*600); if((feof(input)==0)&&(input!=NULL)){ byteSize = CopyLine(input,registro); if(byteSize==0){ return -1; } printf("\n"); fputs(registro,stdout); printf(Translate(RegisterInit), initialPosition); printf(Translate(RegisterSize), byteSize); if(VerifyRegister()) { printf(Translate(ValidRegister)); } else { printf(Translate(RemovedRegister)); } } free(registro); return byteSize; }
ExtFunc void InsertJunk(int scr, int count, int column) { int y, x; for (y = boardHeight[scr] - count - 1; y >= 0; --y) CopyLine(scr, y, y + count); for (y = 0; y < count; ++y) for (x = 0; x < boardWidth[scr]; ++x) SetBlock(scr, y, x, (x == column) ? BT_none : BT_white); curY[scr] += count; }
ExtFunc int ClearFullLines(int scr) { int from, to; from = to = 0; while (to < boardHeight[scr]) { while (LineIsFull(scr, from)) ++from; CopyLine(scr, from++, to++); } return from - to; }
int wow_interrupt(void) { int res=ignore_interrupt(); int Direction; CurrentScan++; if (CurrentScan == Machine->drv->cpu[0].vblank_interrupts_per_frame) { CurrentScan = 0; /* * Seawolf2 needs to emulate rotary ports * * Checked each flyback, takes 1 second to traverse screen */ Direction = input_port_0_r(0); if ((Direction & 2) && (Controller1 > 0)) Controller1--; if ((Direction & 1) && (Controller1 < 63)) Controller1++; Direction = input_port_1_r(0); if ((Direction & 2) && (Controller2 > 0)) Controller2--; if ((Direction & 1) && (Controller2 < 63)) Controller2++; } if (CurrentScan < 204) CopyLine(CurrentScan); /* Scanline interrupt enabled ? */ if ((InterruptFlag & 0x08) && (CurrentScan == NextScanInt)) res = interrupt(); return res; }
/* --------------------------------------------------------------------------- * pastes the contents of the buffer to the layout. Only visible objects * are handled by the routine. */ bool CopyPastebufferToLayout (Coord X, Coord Y) { Cardinal i; bool changed = false; #ifdef DEBUG printf("Entering CopyPastebufferToLayout.....\n"); #endif /* set movement vector */ DeltaX = X - PASTEBUFFER->X, DeltaY = Y - PASTEBUFFER->Y; /* paste all layers */ for (i = 0; i < max_copper_layer + 2; i++) { LayerType *sourcelayer = &PASTEBUFFER->Data->Layer[i]; LayerType *destlayer = LAYER_PTR (i); if (destlayer->On) { changed = changed || (sourcelayer->LineN != 0) || (sourcelayer->ArcN != 0) || (sourcelayer->PolygonN != 0) || (sourcelayer->TextN != 0); LINE_LOOP (sourcelayer); { CopyLine (destlayer, line); } END_LOOP; ARC_LOOP (sourcelayer); { CopyArc (destlayer, arc); } END_LOOP; TEXT_LOOP (sourcelayer); { CopyText (destlayer, text); } END_LOOP; POLYGON_LOOP (sourcelayer); { CopyPolygon (destlayer, polygon); } END_LOOP; } } /* paste elements */ if (PCB->PinOn && PCB->ElementOn) { ELEMENT_LOOP (PASTEBUFFER->Data); { #ifdef DEBUG printf("In CopyPastebufferToLayout, pasting element %s\n", element->Name[1].TextString); #endif if (FRONT (element) || PCB->InvisibleObjectsOn) { CopyElement (element); changed = true; } } END_LOOP; } /* finally the vias */ if (PCB->ViaOn) { changed |= (PASTEBUFFER->Data->ViaN != 0); VIA_LOOP (PASTEBUFFER->Data); { CopyVia (via); } END_LOOP; } if (changed) { Draw (); IncrementUndoSerialNumber (); } #ifdef DEBUG printf(" .... Leaving CopyPastebufferToLayout.\n"); #endif return (changed); }
int FtpCommandParse(const char *input, FtpCommand *cmd) { int i, len, match; FtpCommand tmp; int c; const char *optional_number; assert(input != NULL); assert(cmd != NULL); /* see if our input starts with a valid command */ match = -1; for (i = 0; (i < kCommandNum) && (match == -1); ++i) { len = strlen(command_def[i].name); if (strncasecmp(input, command_def[i].name, len) == 0) { match = i; } } /* if we didn't find a match, return error */ if (match == -1) { return COMMAND_UNRECOGNIZED; } assert(match >= 0); assert(match < kCommandNum); /* copy our command */ strcpy(tmp.command, command_def[match].name); /* advance input past the command */ input += strlen(command_def[match].name); /* now act based on the command */ switch (command_def[match].arg_type) { case ARG_NONE: tmp.num_arg = 0; break; case ARG_STRING: if (*input != ' ') { goto Parameter_Error; } ++input; input = CopyLine(tmp.arg[0].string, input); tmp.num_arg = 1; break; case ARG_OPTIONAL_STRING: if (*input == ' ') { ++input; input = CopyLine(tmp.arg[0].string, input); tmp.num_arg = 1; } else { tmp.num_arg = 0; } break; case ARG_HOST_PORT: if (*input != ' ') { goto Parameter_Error; } input++; /* parse the host & port information (if any) */ input = ParseHostPort(&tmp.arg[0].host_port, input); if (input == NULL) { goto Parameter_Error; } tmp.num_arg = 1; break; case ARG_TYPE: if (*input != ' ') { goto Parameter_Error; } input++; c = toupper(*input); if ((c == 'A') || (c == 'E')) { tmp.arg[0].string[0] = c; tmp.arg[0].string[1] = '\0'; input++; if (*input == ' ') { input++; c = toupper(*input); if ((c != 'N') && (c != 'T') && (c != 'C')) { goto Parameter_Error; } tmp.arg[1].string[0] = c; tmp.arg[1].string[1] = '\0'; input++; tmp.num_arg = 2; } else { tmp.num_arg = 1; } } else if (c == 'I') { tmp.arg[0].string[0] = 'I'; tmp.arg[0].string[1] = '\0'; input++; tmp.num_arg = 1; } else if (c == 'L') { tmp.arg[0].string[0] = 'L'; tmp.arg[0].string[1] = '\0'; input++; input = ParseNumber(&tmp.arg[1].num, input, 255); if (input == NULL) { goto Parameter_Error; } tmp.num_arg = 2; } else { goto Parameter_Error; } break; case ARG_STRUCTURE: if (*input != ' ') { goto Parameter_Error; } input++; c = toupper(*input); if ((c != 'F') && (c != 'R') && (c != 'P')) { goto Parameter_Error; } input++; tmp.arg[0].string[0] = c; tmp.arg[0].string[1] = '\0'; tmp.num_arg = 1; break; case ARG_MODE: if (*input != ' ') { goto Parameter_Error; } input++; c = toupper(*input); if ((c != 'S') && (c != 'B') && (c != 'C')) { goto Parameter_Error; } input++; tmp.arg[0].string[0] = c; tmp.arg[0].string[1] = '\0'; tmp.num_arg = 1; break; case ARG_OFFSET: if (*input != ' ') { goto Parameter_Error; } input++; input = ParseOffset(&tmp.arg[0].offset, input); if (input == NULL) { goto Parameter_Error; } tmp.num_arg = 1; break; default: assert(0); } /* check for our ending newline */ if (*input != '\n') { Parameter_Error: return COMMAND_PARAMETERS_ERROR; } /* return our result */ *cmd = tmp; return 0; }
/*** zPrint - <print> editor function * * Prints file(s) or designated area * * Input: * NOARG Print current file * TEXTARG List of files to print * STREAMARG Print designated area * BOXARG Print designated area * LINEARG Print designated area * * Output: * Returns TRUE if the printing has been successful, FALSE otherwise * *************************************************************************/ flagType zPrint ( CMDDATA argData, ARG * pArg, flagType fMeta ) { flagType fOK; /* Holds the return value */ PFILE pFile; /* general file pointer */ /* * The following is used only when we scan a list of files (TEXTARG) */ flagType fNewFile; /* Did we open a new file ? */ buffer pNameList; /* Holds the list of file names */ char *pName, *pEndName; /* Begining and end of file names */ flagType fDone = FALSE; /* Did we finish with the list ? */ /* * If we can flush the files, that's the moment */ AutoSave (); switch (pArg->argType) { case NOARG: return (DoPrint (pFileHead, FALSE)); case TEXTARG: /* * Get the list in a buffer */ strcpy ((char *) pNameList, pArg->arg.textarg.pText); /* * Empty list = no work */ if (!*(pName = whiteskip (pNameList))) { return FALSE; } /* * For each name: * - pName points at the begining * - Make pEndName pointing just past its ends * - If it's already the end of the string * then we're done with the list * else put a zero terminator there * - Do the job with the name we've found : * . Get the file handle (if it doen't exist yet, * create one and switch fNewFile on * . Call DoPrint * - Let pName point to the next name */ fOK = TRUE; do { pEndName = whitescan (pName); if (*pEndName) { *pEndName = 0; } else { fDone = TRUE; } if ((pFile = FileNameToHandle (pName, pName)) == NULL) { pFile = AddFile (pName); FileRead (pName, pFile, FALSE); fNewFile = TRUE; } else { fNewFile = FALSE; } fOK &= DoPrint (pFile, FALSE); if (fNewFile) { RemoveFile (pFile); } pName = whiteskip (++pEndName); } while (!fDone && *pName); /* * Just in case we would change the behaviour to stopping all * things at the first error : * * } while (fOK && !fDone && *pName); */ return (fOK); case STREAMARG: case BOXARG: case LINEARG: /* * If we print an area, we'll put the text in a temporary file, * call DoPrint with this file and then destroy it. */ pFile = GetTmpFile (); switch (pArg->argType) { case STREAMARG: CopyStream (pFileHead, pFile, pArg->arg.streamarg.xStart, pArg->arg.streamarg.yStart, pArg->arg.streamarg.xEnd, pArg->arg.streamarg.yEnd, 0L,0L); break; case BOXARG: CopyBox (pFileHead, pFile, pArg->arg.boxarg.xLeft, pArg->arg.boxarg.yTop, pArg->arg.boxarg.xRight, pArg->arg.boxarg.yBottom, 0L,0L); break; case LINEARG: CopyLine (pFileHead, pFile, pArg->arg.linearg.yStart, pArg->arg.linearg.yEnd, 0L); break; } /* * If we have to spawn a print command, then we need to make a real * disk file */ if (pPrintCmd && (!FileWrite (pFile->pName, pFile))) { fOK = FALSE; } else { fOK = DoPrint (pFile, TRUE); } RemoveFile (pFile); return (fOK); } argData; fMeta; }