emcmotutil.c
来自「Source code for an Numeric Cmputer」· C语言 代码 · 共 103 行
C
103 行
/********************************************************************* Description: emcmotutil.c* Utility functions shared between motion and other systems** Derived from a work by Fred Proctor & Will Shackleford** Author:* License: GPL Version 2* System: Linux* * Copyright (c) 2004 All rights reserved.** Last change:* $Revision: 1.7 $* $Author: paul_c $* $Date: 2005/05/23 01:54:48 $********************************************************************/#include "emcmotcfg.h" /* EMCMOT_ERROR_NUM,LEN */#include "motion.h" /* these decls */int emcmotErrorInit(emcmot_error_t * errlog){ if (errlog == 0) { return -1; } errlog->head = 0; errlog->start = 0; errlog->end = 0; errlog->num = 0; errlog->tail = 0; return 0;}int emcmotErrorPut(emcmot_error_t * errlog, const char *error){ char *p1; const char *p2; int i; if (errlog == 0 || errlog->num == EMCMOT_ERROR_NUM) { /* full */ return -1; } errlog->head++; // strncpy(errlog->error[errlog->end], error, EMCMOT_ERROR_LEN); // replaced strncpy with manual copy p1 = errlog->error[errlog->end]; p2 = error; i = 0; while (*p2 && i < EMCMOT_ERROR_LEN) { *p1 = *p2; p1++; p2++; i++; } *p1 = 0; errlog->end = (errlog->end + 1) % EMCMOT_ERROR_NUM; errlog->num++; errlog->tail = errlog->head; return 0;}int emcmotErrorGet(emcmot_error_t * errlog, char *error){ char *p1; const char *p2; int i; if (errlog == 0 || errlog->num == 0) { /* empty */ return -1; } errlog->head++; // strncpy(error, errlog->error[errlog->start], EMCMOT_ERROR_LEN); // replaced strncpy with manual copy p1 = error; p2 = errlog->error[errlog->start]; i = 0; while (*p2 && i < EMCMOT_ERROR_LEN) { *p1 = *p2; p1++; p2++; i++; } *p1 = 0; errlog->start = (errlog->start + 1) % EMCMOT_ERROR_NUM; errlog->num--; errlog->tail = errlog->head; return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?