root/cond.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. condextend
  2. getcdentry

   1 /*
   2  *   Compound Text word statistics and search report
   3  *
   4  *   cond.c : matching definition table parameter extension
   5  *
   6  *                                           Copyright(c) isao yasuda, 1998 
   7  */
   8 static char *rcs_id = "$Id: cond.c,v 1.3 2008/05/04 13:05:35 isao Exp $";
   9 
  10 #include <stdio.h>
  11 #include <stdlib.h>
  12 #include <string.h>
  13 #include "staslova.h"
  14 #include "table.h"
  15 
  16 int
  17 condextend(unsigned char *ctext)
  18 {
  19   unsigned char **wp;
  20   
  21   if (seno > MAXSELINE) {
  22     fprintf(stderr, "User se command limit over.(condextend)\n");
  23     return 2;
  24   }
  25   if ((lp[seno] = (unsigned char *) malloc(strlen(ctext)+1)) == NULL) {
  26     fprintf(stderr, "User condition allocation failed.(condextend)\n");
  27     exit(1);
  28   }
  29   strcpy(lp[seno], ctext);
  30   G0 = ASCII; G1 = LATIN1;
  31   while (*ctext != '\0' || stock != NULL) {
  32     if ((wp = getcdarray(&ctext)) != NULL) { /* when NULL no word */
  33       if (cdno > MAXCOND) {
  34         fprintf(stderr, "User condition number limit over.(condextend)\n");
  35         return 2;
  36       }
  37       if ((wp = polishbuild(wp)) == NULL) /* reverse polish conversion */
  38         exit(1);
  39       if ((cdtbl[cdno++] = getcdentry(wp, lp[seno])) == NULL)
  40         exit(1);
  41     } 
  42   }
  43   seno++;
  44   return 0;
  45 }
  46 
  47 struct cdent *
  48 getcdentry(unsigned char **wap, unsigned char *text)
  49 {
  50   struct cdent *p;
  51 
  52   if ((p = (struct cdent *) malloc(sizeof(struct cdent))) != NULL) {
  53     p->cdparm = text;
  54     p->cdpolish = wap;
  55     p->tcount = 0;
  56     p->mwdroot = NULL;
  57   } else 
  58     fprintf(stderr, "Condition table entry allocation failed.(getcdentry)\n");
  59   return p;
  60 }
  61         
  62 
  63 
  64 
  65 
  66 

/* [previous][next][first][last][top][bottom][index][help] */