コード例 #1
0
ファイル: main.c プロジェクト: yonganch/fa-nos-simple
void start()
{
	uint32_t temp;
	uint8_t getstr[20];

	GPJ2CON = 0x1111;
	GPJ2DAT = 0x0a;

	uart0_init(115200);
	fimd_init();



	xdev_out(uart0_putc);
	xdev_in(uart0_getc);

	xprintf("FA210 Tester v1\n");

	while(1){

		xputc('>');
		xgets(getstr,15);


	}
}
コード例 #2
0
ファイル: line.cpp プロジェクト: wschweer/qped
bool read_from_script(LineList& ll, const char* script)
      {
      FILE* f = popen(script, "r");
      if (!f)
            return true;
      char buffer[LINMAX];
      int n = 0;
      int len;
      for (;;++n) {
            *buffer = 0;
            if ((len = xgets(buffer, LINMAX, f)) < 0)
                  break;
            //
            //    Backstep filtern
            //
            buffer[len] = 0;
            char* s = buffer;
            char* d = buffer;
            while (*s) {
                  if (*s == 0x8) {
                        if (d != buffer) {
                              --d;
                              len-=2;
                              }
                        }
                  else {
                        *d++ = *s;
                        }
                  ++s;
                  }
            ll.push_back(new Line(buffer, len));
            }
      pclose(f);
      return (len == -2);
      }
コード例 #3
0
ファイル: main.c プロジェクト: Ensase/FatUARTloggerGPS.X
int main(void)
{
  uint16_t i;
  FRESULT rc;

  map_io();
  init_port();

  InitRTCC();

  uart2_init();
  xdev_out(uart2_put);
  xdev_in(uart2_get);

  dbg_printf("$" PROJECT_NAME "\n");
  dbg_printf("$" __DATE__ " " __TIME__ "\n");

  rc = f_mount(&fatfs, "", 1);
  dbg_printf("$FF,f_mount,%s\n", get_rc(rc));

  OpenTimer1(T1_PS_1_256 & T1_GATE_OFF & T1_SOURCE_INT & T1_IDLE_CON &
    T1_ON & T1_SYNC_EXT_OFF, 0xFFFF);
  ConfigIntTimer1(T1_INT_ON & T1_INT_PRIOR_1);
  OpenCapture1(IC_IDLE_STOP & IC_TIMER1_SRC & IC_INT_1CAPTURE & IC_EVERY_RISE_EDGE,
    IC_CASCADE_DISABLE & IC_TRIGGER_ENABLE & IC_UNTRIGGER_TIMER & IC_SYNC_TRIG_IN_DISABLE);
  ConfigIntCapture1(IC_INT_ON & IC_INT_PRIOR_5);
  _IC1IF = 0;
  

  while (1) {
    while (_RTCSYNC == 0);
    while (_RTCSYNC == 1);
    if (gps_pr > 0) {
      _T1IE = 0;
      float f = (float) TMR1 / gps_pr;
      _T1IE = 1;
      xprintf("%u\n", (uint16_t) (f * 1000));
    }
    if (ngpslines > 0) {
      ngpslines--;
      if (xgets(gps_line, 128)) {
        xprintf("$GPS%s\n", gps_line);
      }
    }
  }

  while (0) {
    while (_RTCSYNC == 0);
    while (_RTCSYNC == 1);
    if (gps_pr > 0) {
      _T1IE = 0;
      float f = (float) TMR1 / gps_pr;
      _T1IE = 1;
      xprintf("%u\n", (uint16_t) (f * 1000));
    }
  }

  return (EXIT_SUCCESS);
}
コード例 #4
0
ファイル: xfile.c プロジェクト: nyuichi/xfile
int main()
{
  char buf[256];

  xgets(buf);

  xprintf("%s\n", buf);
  xprintf("hello\n");
  xprintf("hello\n");
  //  xfflush(0);
}
コード例 #5
0
ファイル: systems.c プロジェクト: AhmadTux/DragonFlyBSD
static int
ReadSystem(struct bundle *bundle, const char *name, const char *file,
           struct prompt *prompt, struct datalink *cx, int how)
{
  FILE *fp;
  char *cp;
  int n, len;
  char line[LINE_LEN];
  char filename[PATH_MAX];
  int linenum;
  int argc;
  char *argv[MAXARGS];
  int allowcmd;
  int indent;
  char arg[LINE_LEN];
  struct prompt *op;

  if (*file == '/')
    snprintf(filename, sizeof filename, "%s", file);
  else
    snprintf(filename, sizeof filename, "%s/%s", PPP_CONFDIR, file);
  fp = ID0fopen(filename, "r");
  if (fp == NULL) {
    log_Printf(LogDEBUG, "ReadSystem: Can't open %s.\n", filename);
    return -2;
  }
  log_Printf(LogDEBUG, "ReadSystem: Checking %s (%s).\n", name, filename);

  linenum = 0;
  while ((n = xgets(line, sizeof line, fp))) {
    linenum += n;
    if (issep(*line))
      continue;

    cp = strip(line);

    switch (*cp) {
    case '\0':			/* empty/comment */
      break;

    case '!':
      switch (DecodeCtrlCommand(cp+1, arg, LINE_LEN)) {
      case CTRL_INCLUDE:
        log_Printf(LogCOMMAND, "%s: Including \"%s\"\n", filename, arg);
        n = ReadSystem(bundle, name, arg, prompt, cx, how);
        log_Printf(LogCOMMAND, "%s: Done include of \"%s\"\n", filename, arg);
        if (!n) {
          fclose(fp);
          return 0;	/* got it */
        }
        break;
      default:
        log_Printf(LogWARN, "%s: %s: Invalid command\n", filename, cp);
        break;
      }
      break;

    default:
      if ((cp = GetLabel(cp, filename, linenum)) == NULL)
        continue;

      if (strcmp(cp, name) == 0) {
        /* We're in business */
        if (how == SYSTEM_EXISTS) {
          fclose(fp);
	  return 0;
	}
	while ((n = xgets(line, sizeof line, fp))) {
          linenum += n;
          indent = issep(*line);
          cp = strip(line);

          if (*cp == '\0')			/* empty / comment */
            continue;

          if (!indent) {			/* start of next section */
            if (*cp != '!' && how == SYSTEM_EXEC)
              cp = GetLabel(cp, filename, linenum);
            break;
          }

          len = strlen(cp);
          if ((argc = command_Expand_Interpret(cp, len, argv, cp - line)) < 0)
            log_Printf(LogWARN, "%s: %d: Syntax error\n", filename, linenum);
          else {
            allowcmd = argc > 0 && !strcasecmp(argv[0], "allow");
            if ((how != SYSTEM_EXEC && allowcmd) ||
                (how == SYSTEM_EXEC && !allowcmd)) {
              /*
               * Disable any context so that warnings are given to everyone,
               * including syslog.
               */
              op = log_PromptContext;
              log_PromptContext = NULL;
	      command_Run(bundle, argc, (char const *const *)argv, prompt,
                          name, cx);
              log_PromptContext = op;
            }
          }
        }

	fclose(fp);  /* everything read - get out */
	return 0;
      }
      break;
    }
  }
  fclose(fp);
  return -1;
}
コード例 #6
0
ファイル: jspell.c プロジェクト: gitpan/Lingua-Jspell
/* How to print: 
 * 1 = expansions only 
 * 2 = original line + expansions 
 * 3 = original paired w/ expansions 
 * 4 = add length ratio 
 */
static void expandmode(int option) {
    char           buf[BUFSIZ];
    int            explength;         /* Total length of all expansions */
    register char *flagp;             /* Pointer to next flag char */
    ichar_t        ibuf[BUFSIZ];
    MASKTYPE       mask[MASKSIZE];
    char           origbuf[BUFSIZ];   /* Original contents of buf */
    char           ratiobuf[20];      /* Expansion/root length ratio */
    int            rootlength;        /* Length of root word */
    register int   temp;
    /* char           strg_out[MAXSOLLEN]; */
    
    while (xgets(buf, sizeof buf, stdin) != NULL) {
        rootlength = strlen(buf);
        if (buf[rootlength - 1] == '\n')
            buf[--rootlength] = '\0';
        strcpy(origbuf, buf);
        if ((flagp = index(buf, hashheader.flagmarker)) != NULL) {
            rootlength = flagp - buf;
            *flagp++ = '\0';
        }
        if (option == 2  ||  option == 3  ||  option == 4)
            printf("%s ", origbuf);
        if (flagp != NULL) {
            if (flagp - buf > INPUTWORDLEN)
                buf[INPUTWORDLEN] = '\0';
        }
        else {
            if ((int) strlen(buf) > INPUTWORDLEN - 1)
                buf[INPUTWORDLEN] = '\0';
        }
        fputs(buf, stdout);
        fputc(' ', stdout);
        /* strtoichar(ibuf, buf, sizeof ibuf, 1);
           if (good(ibuf, 0, 0, 0)) {
           get_info(hits[0]);
           sprintf(strg_out, o_form, root, macro(root_class), pre_class,
           macro(suf_class), suf2_class);
           printf("%s ", strg_out);
           }
        */
        if (flagp != NULL) {
            bzero((char *) mask, sizeof(mask));
            while (*flagp != '\0'  &&  *flagp != '\n') {
#if MASKBITS <= 32
                temp = CHARTOBIT(mytoupper(chartoichar(*flagp)));
#else
                temp = CHARTOBIT((unsigned char) *flagp);
#endif
                if (temp >= 0  &&  temp <= LARGESTFLAG)
                    SETMASKBIT (mask, temp);
                flagp++;
                /* Accept old-format dicts with extra slashes */
                if (*flagp == hashheader.flagmarker)
                    flagp++;
            }
            if (strtoichar(ibuf, buf, sizeof ibuf, 1))
                fprintf(stderr, WORD_TOO_LONG(buf));
            explength = expand_pre(origbuf, ibuf, mask, option, "");
            explength += expand_suf(origbuf, ibuf, mask, 0, option, "", "");
            explength += rootlength;
            if (option == 4) {
                sprintf(ratiobuf, " %f",
                        (double) explength / (double) rootlength);
                fputs(ratiobuf, stdout);
                expand_pre(origbuf, ibuf, mask, 3, ratiobuf);
                expand_suf(origbuf, ibuf, mask, 0, 3, ratiobuf, "");
            }
        }
        printf(SEP4);
    }
}