コード例 #1
0
ファイル: ncbistr.c プロジェクト: fbtestrepo/hw
NLM_EXTERN Nlm_Int4 LIBCALL BreakString(char FAR *theString, Nlm_CharPtr PNTR Words)
/* Breaks up a string at each occurrence of one or more spaces, placing
   each substring obtained into the array Words and returning the 
   number of substrings obtained. 
   */
{
  Nlm_CharPtr Start, Stop, *WordPtr;

  Start = SkipSpaces(theString);
  WordPtr = Words;

  while (*Start)
    {
      Stop = SkipToSpace(Start);
      StrCpyPtr(*WordPtr++,Start,Stop);
      Start = SkipSpaces(Stop);
    }

  return((Nlm_Int4) (WordPtr - Words) );
}
コード例 #2
0
ファイル: specifics.cpp プロジェクト: kevinr2763/gmsh
/* Version 2 */
void Parse_Specifics_File_v2(FILE *fp)
{
    char line[1024], *lp;
    FrameSpecList *current, *newf;
    char typ;
    int fnum, snum, bnum, qs, newqs;
    int num_scanned, fx=0, fy=0, sx=0, sy=0;
    char kind[100];
    Block_Specifics *new_blk;
    boolean relative;

    fsl = MakeFslEntry();
    current = fsl;

    while ((fgets(line,1023,fp))!=NULL) {
        lp = &line[0];
        while ((*lp == ' ') || (*lp == '\t')) lp++;
        if (( *lp == '#' ) || (*lp=='\n')) {
            continue;
        }

        switch (my_upper(*lp)) {
        case 'F':
            lp += 6;
            sscanf(lp,"%d %c %d", &fnum, &typ, &qs);
            newf = MakeFslEntry();
            if (current->framenum != -1) {
                current->next = newf;
                current = newf;
            }
            current->framenum = fnum;
            current->frametype = CvtType(typ);
            if (qs <= 0) qs = -1;
            current->qscale = qs;
            break;
        case 'S':
            lp += 6;
            sscanf(lp,"%d %d", &snum, &newqs);
            if (qs == newqs) break;
            qs = newqs;
            AddSlc(current, snum, qs);
            break;
        case 'B':
            lp += 6;
            num_scanned = 0;
            bnum = atoi(lp);
            SkipToSpace(lp);
            while ((*lp != '-') && (*lp != '+') &&
                    ((*lp < '0') || (*lp > '9'))) lp++;
            relative = ((*lp == '-') || (*lp == '+'));
            newqs = atoi(lp);
            SkipToSpace(lp);
            if (EndString(lp)) {
                num_scanned = 2;
            } else {
                num_scanned = 2+sscanf(lp, "%s %d %d %d %d", kind, &fx, &fy, &sx, &sy);
            }

            qs = newqs;
            new_blk = AddBs(current, bnum, relative, qs);
            if (num_scanned > 2) {
                BlockMV *tmp;
                tmp = (BlockMV *) malloc(sizeof(BlockMV));
                switch (num_scanned) {
                case 7:
                    tmp->typ = TYP_BOTH;
                    tmp->fx = fx;
                    tmp->fy = fy;
                    tmp->bx = sx;
                    tmp->by = sy;
                    new_blk->mv = tmp;
                    break;
                case 3:
                    tmp->typ = TYP_SKIP;
                    new_blk->mv = tmp;
                    break;
                case 5:
                    if (my_upper(kind[0]) == 'B') {
                        tmp->typ = TYP_BACK;
                        tmp->bx = fx;
                        tmp->by = fy;
                    } else {
                        tmp->typ = TYP_FORW;
                        tmp->fx = fx;
                        tmp->fy = fy;
                    }
                    new_blk->mv = tmp;
                    break;
                default:
                    fprintf(stderr,
                            "Bug in specifics file!  Skipping short/long entry: %s\n",line);
                    break;
                }
            } else {
                new_blk->mv = (BlockMV *) NULL;
            }

            break;
        case 'V':
            fprintf(stderr,
                    "Cannot specify version twice!  Taking first (%d).\n",
                    version);
            break;
        default:
            printf("What? *%s*\n",line);
            break;
        }
    }

}