Exemplo n.º 1
0
int	NavHelp::help_index( navh_eHelpFile file_type, const char *file_name)
{
  FILE	*file;
  char	line[200];
  char	include_file[80];
  char	subject[80];
  int 	sts;
  char  *s;
  lng_eCoding coding = lng_eCoding_ISO8859_1;

  // Open file
  file = navhelp_open_file( this, file_type, file_name);
  if ( !file) return NAV__NOFILE;

  sts = dcli_read_line( line, sizeof( line), file);
  while ( ODD(sts))
  {
    if ( cdh_NoCaseStrncmp( line, "<coding>", 8) == 0) {      
      char codingstr[40];

      help_remove_spaces( &line[8], codingstr);
      if ( cdh_NoCaseStrcmp( codingstr, "ISO8859-1") == 0) {
	coding = lng_eCoding_ISO8859_1;
      }
      else if ( cdh_NoCaseStrcmp( codingstr, "UTF-8") == 0) {
	coding = lng_eCoding_UTF_8;
      }
    }
    else if ( cdh_NoCaseStrncmp( line, "<include>", 9) == 0)
    {
      help_remove_spaces( &line[9], include_file);
      sts = help_index( navh_eHelpFile_Other, include_file);
    }
    else if ( cdh_NoCaseStrncmp( line, "<topic>", 7) == 0)
    {
      if ( (s = strstr( line, "<style>")) || (s = strstr( line, "<STYLE>")))
	*s = 0;
      help_remove_spaces( &line[7], subject);

      (insert_cb)( parent_ctx, navh_eItemType_HelpBold,
		   subject,  "", "", subject, 
		   "", file_name, file_type, 0, NULL, coding);
    }
    sts = dcli_read_line( line, sizeof( line), file);
  }
  fclose( file);
  return NAV__SUCCESS;
}
Exemplo n.º 2
0
static int find_symbol( char *name, char *value)
{
  static int loaded = 0;
  static char sym_vect[MAXSYMBOLS][80];
  static char value_vect[MAXSYMBOLS][80];
  static int vect_cnt;
  int nr;
  char elemv[3][80];
  int j;
  int		found;

  // Read the file
  if ( !loaded) {
    FILE *fp;
    char line[200];
    pwr_tFileName fname;

    vect_cnt = 0;

    sprintf( fname, "$pwrp_db/pwrp_cnf_websymbols.dat");
    dcli_translate_filename( fname, fname);

    fp = fopen( fname, "r");
    if ( !fp)
      return 0;


    while ( dcli_read_line( line, sizeof( line), fp)) {
      nr = dcli_parse( line, " ", "", (char *)elemv, sizeof( elemv) / sizeof( elemv[0]), 
		       sizeof( elemv[0]), 0);
      if ( nr != 3)
	continue;
      strcpy( sym_vect[vect_cnt], elemv[1]);
      strcpy( value_vect[vect_cnt], elemv[2]);
      vect_cnt++;
    }
    fclose( fp);
    loaded = 1;
  }

  if ( !vect_cnt)
    return 0;

  for ( j = 0; j < vect_cnt; j++) {
    if ( cdh_NoCaseStrcmp( name, sym_vect[j]) == 0) {
      strcpy( value, value_vect[j]);
      found = 1;
      break;
    }
  }
  if ( !found) 
    return 0;

  return 1;
}
Exemplo n.º 3
0
int sev_db::get_systemname(char* name)
{
  FILE* file;
  pwr_tFileName fname;
  char nodename[40];
  char* bus_str;
  int bus;
  char line[200];
  pwr_tStatus sts;
  static char system_name[80] = "";

  if (streq(system_name, "")) {
    syi_NodeName(&sts, nodename, sizeof(nodename));
    if (EVEN(sts))
      return 0;

    bus_str = getenv("PWR_BUS_ID");
    if (!bus_str)
      return 0;
    if (sscanf(bus_str, "%d", &bus) != 1)
      return 0;

    sprintf(fname, pwr_cNameBoot, load_cDirectory, cdh_Low(nodename), bus);
    dcli_translate_filename(fname, fname);
    file = fopen(fname, "r");
    if (file == 0) {
      printf("In %s row %d:\n", __FILE__, __LINE__);
      printf("** Warning, systemname not found\n");
      return 0;
    }

    if (!dcli_read_line(line, sizeof(line), file))
      return 0;
    if (!dcli_read_line(line, sizeof(line), file))
      return 0;

    strcpy(system_name, line);
  }
  strcpy(name, system_name);
  return 1;
}
Exemplo n.º 4
0
static void get_config( char *name, unsigned int *lk_max_locks, 
			unsigned int *lk_max_objects)
{
  pwr_tFileName fname;
  FILE *fp;
  char line[200];
  char	line_elem[2][100];
  unsigned int max_locks;
  unsigned int max_objects;
  int nr;

  *lk_max_locks = 50000;
  *lk_max_objects = 20000;

  strcpy( fname, name);
  strcat( fname, ".cnf");
  dcli_translate_filename( fname, fname);

  fp = fopen( fname, "r");
  if ( !fp)
    return;

  while ( dcli_read_line( line, sizeof(line), fp)) {
    dcli_trim( line, line);
    if ( line[0] == '#')
      continue;
    if ( strcmp( line, "") == 0)
      continue;
    
    nr = dcli_parse( line, " 	", "",
		(char *) line_elem, sizeof( line_elem)/sizeof( line_elem[0]), 
		sizeof( line_elem[0]), 1);
    if ( nr != 2)
      continue;

    if ( cdh_NoCaseStrcmp( line_elem[0], "lk_max_locks") == 0) {
      nr = sscanf( line_elem[1], "%d", &max_locks);
      if ( nr == 1) {
	*lk_max_locks = max_locks;
	printf( "lk_max_locks.........%d\n", max_locks);
      }
    }
    else if ( cdh_NoCaseStrcmp( line_elem[0], "lk_max_objects") == 0) {
      nr = sscanf( line_elem[1], "%d", &max_objects);
      if ( nr == 1) {
	*lk_max_objects = max_objects;
	printf( "lk_max_objects.......%d\n", max_objects);
      }
    }
  }
  fclose( fp);
}
Exemplo n.º 5
0
char *cnf_get_value( const char *name, char *value, int size)
{
  FILE *fp;
  char line[400];
  char item_str[2][200];
  static char ret_value[200];
  int nr;  
  int i;


  fp = fopen( cnf_cFile, "r");

  if ( fp) {

    while ( dcli_read_line( line, sizeof( line), fp)) {
      if ( line[0] == '#')
        continue;

      nr = dcli_parse( line, " 	", "", (char *)item_str, 
		sizeof( item_str) / sizeof( item_str[0]), sizeof( item_str[0]), 0);
      if ( nr < 2)
        continue;
    
      if ( cdh_NoCaseStrcmp( name, item_str[0]) == 0) {
        strcpy( ret_value, item_str[1]);
        if ( value)
          strncpy( value, ret_value, size);
        fclose( fp);
        return ret_value;
      }
    }
    fclose( fp);
  }

  /* Find default value */
  for ( i = 0; i < sizeof(default_values)/sizeof(default_values[0]); i++) {
    if ( strcmp( name, default_values[i][0]) == 0) {
      strcpy( ret_value, default_values[i][1]);
      if ( value)
        strncpy( value, ret_value, size);
      return ret_value;
    }
  }
  return NULL;
}
Exemplo n.º 6
0
static int graph_get_applet_size(char* graphname, int* width, int* height)
{
  char fname[200];
  FILE* file;
  int w = 0, h = 0;
  int width_found = 0;
  int height_found = 0;
  char* s;
  char line[400];

  sprintf(fname, "$pwrp_web/%s.html", graphname);
  dcli_translate_filename(fname, fname);

  file = fopen(fname, "r");
  if (!file)
    return GE__NOFILE;

  while (dcli_read_line(line, sizeof(line), file)) {
    if (width_found && height_found)
      break;
    if ((s = strstr(line, "width="))) {
      if (sscanf(s + 6, "%d", &w) == 1)
        width_found = 1;
      continue;
    }
    if ((s = strstr(line, "height="))) {
      if (sscanf(s + 7, "%d", &h) == 1)
        height_found = 1;
      continue;
    }
  }
  fclose(file);
  if (width_found && height_found) {
    *width = w;
    *height = h;
    return GE__SUCCESS;
  }
  return GE__NOSIZE;
}
Exemplo n.º 7
0
void CLogNav::read(int* pos_list, int pos_cnt)
{
  char line[400];
  errh_eSeverity severity = errh_eSeverity_Null;
  pwr_tTime time;
  pwr_tTime ztime = { 0, 0 };
  char time_str[40];
  char logger[40];
  int pid;
  int sts;
  FILE* fp;
  char filename[200];
  CLogMsg* msg;
  char tmpfile[200] = "/tmp/clog.tmp";
  int found;

  msg_list.clear();

  current_pos_low = file_list.size();
  current_pos_high = 0;
  for (int i = file_list.size() - 1; i >= 0; i--) {
    found = 0;
    for (int j = 0; j < pos_cnt; j++) {
      if (pos_list[j] - 1 == i) {
        found = 1;
        break;
      }
    }
    if (!found)
      continue;

    if (i + 1 > current_pos_high)
      current_pos_high = i + 1;
    if (i + 1 < current_pos_low)
      current_pos_low = i + 1;

    if (i == 0) {
      strcpy(filename, file_list[0].name);
      if (streq(filename, ""))
        continue;
    } else {
      // Unzip the file
      char cmd[300];

      sprintf(cmd, "zcat %s > %s", file_list[i].name, tmpfile);
      system(cmd);
      strcpy(filename, tmpfile);
    }

    fp = fopen(filename, "r");
    if (!fp)
      return;

    while (1) {
      sts = dcli_read_line(line, sizeof(line), fp);
      if (!sts)
        break;

      if (line[1] == ' ' && line[27] == ' '
          && (line[0] == 'S' || line[0] == 'I' || line[0] == 'W'
                 || line[0] == 'E' || line[0] == 'F')) {
        switch (line[0]) {
        case 'S':
          severity = errh_eSeverity_Success;
          break;
        case 'I':
          severity = errh_eSeverity_Info;
          break;
        case 'W':
          severity = errh_eSeverity_Warning;
          break;
        case 'E':
          severity = errh_eSeverity_Error;
          break;
        case 'F':
          severity = errh_eSeverity_Fatal;
          break;
        default:;
        }
        strncpy(logger, &line[2], 18);
        logger[18] = 0;

        sts = sscanf(&line[22], "%d", &pid);
        if (sts != 1)
          pid = 0;

        strncpy(&time_str[2], &line[28], 20);
        time_str[0] = '2';
        time_str[1] = '0';
        time_str[22] = 0;
        time_FormAsciiToA(time_str, HUNDRED, GB, &time);

        msg = new CLogMsg(severity, logger, pid, time, &line[49]);
        msg_list.push_back(*msg);
        delete msg;
      } else {
        str_trim(line, line);
        msg = new CLogMsg(errh_eSeverity_Null, "", 0, ztime, line);
        msg_list.push_back(*msg);
        delete msg;
      }
    }
    fclose(fp);
    if (i != 0)
      unlink(filename);
  }
  draw();
}
Exemplo n.º 8
0
void wb_build::webbrowserconfig( pwr_tOid oid)
{
  pwr_tTime	modtime;
  pwr_tFileName fname;
  pwr_tTime 	ftime;
  pwr_tStatus   fsts;
  FILE 		*fp;
  int		i, j;
  int		found;
  char		line[200];
  pwr_tObjName  vname;

  strncpy( vname, m_session.name(), sizeof(vname));

  wb_object o = m_session.object(oid);
  if ( !o) {
    m_sts = o.sts();
    return;
  }

  modtime = o.modTime();

  sprintf( fname, "$pwrp_db/pwrp_cnf_websymbols.dat");
  dcli_translate_filename( fname, fname);
  fsts = dcli_file_time( fname, &ftime);

  m_sts = PWRB__NOBUILT;
  if ( opt.force || EVEN(fsts) || time_Acomp( &modtime, &ftime) == 1) {
    pwr_sClass_WebBrowserConfig body;
    int url_symbols_size = sizeof(body.URL_Symbols)/sizeof(body.URL_Symbols[0]);
    char sym_vect[MAXSYMBOLS][80];
    char value_vect[MAXSYMBOLS][80];
    char volume_vect[MAXSYMBOLS][80];
    int vect_cnt;
    int nr;
    char elemv[3][80];
    
    wb_attribute a = m_session.attribute( oid, "RtBody", "URL_Symbols");
    if ( !a) {
      m_sts = a.sts();
      return;
    }
    a.value( body.URL_Symbols);
    if ( !a) {
      m_sts = a.sts();
      return;
    }

    // Read the file and merge the symbols of this volume with other symbols in the project
    vect_cnt = 0;
    fp = fopen( fname, "r");
    if ( fp) {
      while ( dcli_read_line( line, sizeof( line), fp)) {
	nr = dcli_parse( line, " ", "", (char *)elemv, sizeof( elemv) / sizeof( elemv[0]), 
			 sizeof( elemv[0]), 0);
	if ( nr != 3)
	  continue;

	// Skip old symbols from this volume
	if ( cdh_NoCaseStrcmp( vname, elemv[0]) == 0)
	  continue;

	strcpy( volume_vect[vect_cnt], elemv[0]);
	strcpy( sym_vect[vect_cnt], elemv[1]);
	strcpy( value_vect[vect_cnt], elemv[2]);
	vect_cnt++;
      }
      fclose( fp);
    }

    for ( i = 0; i < url_symbols_size; i++) {
      nr = dcli_parse( body.URL_Symbols[i], " ", "", (char *)elemv, sizeof( elemv) / sizeof( elemv[0]), 
		       sizeof( elemv[0]), 0);
      if ( nr != 2)
	continue;
      
      found = 0;
      for ( j = 0; j < vect_cnt; j++) {
	if ( cdh_NoCaseStrcmp( elemv[0], sym_vect[j]) == 0) {
	  strcpy( value_vect[j], elemv[1]);
	  found = 1;
	  break;
	}
      }
      if ( !found) {
	// Insert first
	for ( j = MIN(vect_cnt,MAXSYMBOLS-1); j > 0; j--) {
	  strcpy( volume_vect[j], volume_vect[j-1]);
	  strcpy( sym_vect[j], sym_vect[j-1]);
	  strcpy( value_vect[j], value_vect[j-1]);
	}
	strcpy( volume_vect[0], vname);
	strcpy( sym_vect[0], elemv[0]);
	strcpy( value_vect[0], elemv[1]);	
	vect_cnt++;
	if ( vect_cnt > MAXSYMBOLS)
	  vect_cnt = MAXSYMBOLS;
      }
    }

    // Write the file
    fp = fopen( fname, "w");
    if ( !fp) {
      char msg[200];
      sprintf( msg, "Build:    Unable to open file %s", fname);
      MsgWindow::message( 'E', msg, msgw_ePop_No, oid);
      return;
    }

    for ( i = 0; i < vect_cnt; i++)
      fprintf( fp, "%s %s %s\n", volume_vect[i], sym_vect[i], value_vect[i]);
    fclose( fp);
  }
}
Exemplo n.º 9
0
int XttFast::read_export( char *filename)
{
  pwr_tFileName fname;
  FILE *fp;
  char line[200];
  int idx = -1;
  int rowcnt = 0;
  pwr_tStatus sts;
  char line_part[40][20];

  dcli_translate_filename( fname, filename);

  fp = fopen( fname, "r");
  if ( !fp)
    return 0;

  gcd = new GeCurveData( curve_eDataType_DsTrend);

  while( 1) {
    sts = dcli_read_line( line, sizeof(line), fp);
    if ( !sts)
      break;

    if ( line[0] == '#') {
      if ( strncmp( &line[2], "Attribute", 9) == 0) {
	// New attribute
	idx++;
	strncpy( gcd->y_name[idx], &line[12], sizeof(gcd->y_name[idx]));
	gcd->y_data[idx] = (double *) calloc( 1, 8 * max_points);
	gcd->y_axis_type[idx] = curve_eAxis_y;
      }
      else if ( strncmp( &line[2], "Rows", 4) == 0) {
	sscanf( &line[7], "%d", &max_points);
	gcd->rows[0] = max_points;
	gcd->x_data[0] = (double *) calloc( 1, 8 * max_points);
      }
      else if ( strncmp( &line[2], "Columns", 4) == 0) {
	sscanf( &line[10], "%d", &fast_cnt);
      }
    }
    else {
      if ( idx < 0 || fast_cnt != idx + 1)
	continue;

      if ( rowcnt >= max_points)
	continue;

      int nr = dcli_parse( line, " 	", "",
	     (char *) line_part, sizeof( line_part)/sizeof( line_part[0]), 
	     sizeof( line_part[0]), 0);
      if ( nr < fast_cnt + 1)
	return 0;

      sscanf( line_part[0], "%lf", &gcd->x_data[0][rowcnt]);
      for ( int i = 0; i < fast_cnt; i++)
	sscanf( line_part[i+1], "%lf", &gcd->y_data[i][rowcnt]);

      rowcnt++;
    }
  }
  if ( fast_cnt == 0)
    return 0;

  for ( int i = 0; i < fast_cnt; i++)
    gcd->rows[i] = max_points;
  gcd->cols = fast_cnt;
  strcpy( gcd->x_name, "Time");
  gcd->x_axis_type[0] = curve_eAxis_x;

  fclose(fp);

  gcd->select_color( 0);
  gcd->get_borders();
  gcd->get_default_axis();
  
  return 1;
}
Exemplo n.º 10
0
static pwr_tStatus generate_viewer_data(device_sCtx* ctx)
{
  pwr_tOid controller;
  pwr_tCid ccid;
  FILE* fp;
  FILE* ofp;
  pwr_tFileName fname;
  char line[500];
  char elemv[3][200];
  int nr;
  char device_text[200];
  char device_name[80];
  char ip_address[80];
  char mac_address[80];
  unsigned int vendor_id = 0;
  unsigned int device_id = 0;
  char* s;
  pwr_tStatus sts;
  pwr_tOid oid;
  char* ethernet_device;
  int size;

  sts = ldh_GetParent(ctx->ldhses, ctx->aref.Objid, &controller);
  if (EVEN(sts))
    return sts;

  sts = ldh_GetObjectClass(ctx->ldhses, controller, &ccid);
  if (ODD(sts) && ccid == pwr_cClass_PnControllerSoftingPNAK) {
    sts = ldh_GetObjectPar(ctx->ldhses, controller, "RtBody", "EthernetDevice",
        (char**)&ethernet_device, &size);
    if (EVEN(sts))
      return sts;

    str_trim(ethernet_device, ethernet_device);
    str_ToLower(ethernet_device, ethernet_device);
    sprintf(fname, "$pwrp_load/pwr_pnviewer_%s.dat", ethernet_device);
    free(ethernet_device);
    dcli_translate_filename(fname, fname);
    ofp = fopen(fname, "w");
    if (!ofp)
      return 0;

    for (sts = ldh_GetChild(ctx->ldhses, controller, &oid); ODD(sts);
         sts = ldh_GetNextSibling(ctx->ldhses, oid, &oid)) {
      sprintf(fname, "$pwrp_load/pwr_pn_%s.xml", cdh_ObjidToFnString(0, oid));
      dcli_translate_filename(fname, fname);

      fp = fopen(fname, "r");
      if (!fp)
        return 0;

      while (dcli_read_line(line, sizeof(line), fp)) {
        str_trim(line, line);
        nr = dcli_parse(line, "=", "", (char*)elemv,
            sizeof(elemv) / sizeof(elemv[0]), sizeof(elemv[0]), 0);
        if (nr != 2)
          continue;

        if (streq(elemv[0], "DeviceText")) {
          strncpy(device_text, elemv[1], sizeof(device_text));
        } else if (streq(elemv[0], "VendorId")) {
          sscanf(elemv[1], "%d", &vendor_id);
        } else if (streq(elemv[0], "DeviceId")) {
          sscanf(elemv[1], "%d", &device_id);
        } else if (streq(elemv[0], "DeviceName")) {
          strncpy(device_name, elemv[1], sizeof(device_name));
        } else if (streq(elemv[0], "IP_Address")) {
          strncpy(ip_address, elemv[1], sizeof(ip_address));
        } else if (streq(elemv[0], "MAC_Address")) {
          strncpy(mac_address, elemv[1], sizeof(mac_address));
          if ((s = strchr(mac_address, '/')))
            *s = 0;
          str_trim(mac_address, mac_address);
          break;
        }
      }
      fclose(fp);

      fprintf(ofp, "\"%s\" \"%s\" \"%s\" \"%s\" %d %d\n", device_text,
          device_name, ip_address, mac_address, vendor_id, device_id);
    }
    fclose(ofp);
  }
  return 1;
}
Exemplo n.º 11
0
int	NavHelp::get_previous_key( const char *help_key, navh_eHelpFile file_type, const char *file_name,
				   bool strict, char *prev_key)
{
  FILE	*file;
  char	line[200];
  char	key[80];
  char	key_part[4][40];
  char	include_file[80];
  char	subject[80];
  char	subject_part[4][40];
  int	key_nr;
  int	subject_nr;
  int	hit = 0;
  int 	sts;
  int	i;  
  char	*s;
  char  prev[80] = "";

  if ( help_key) {
    cdh_ToLower( key, help_key);
  }

  // Open file
  file = navhelp_open_file( this, file_type, file_name);
  if ( !file) return NAV__NOFILE;

  key_nr = dcli_parse( key, " 	", "", (char *)key_part,
		       sizeof( key_part) / sizeof( key_part[0]), 
		       sizeof( key_part[0]), 0);


  sts = dcli_read_line( line, sizeof( line), file);
  while ( ODD(sts)) {
    if ( cdh_NoCaseStrncmp( line, "<include>", 9) == 0) {      
      help_remove_spaces( &line[9], include_file);
      // Replace symbol for language
      if ( strncmp( include_file, "$pwr_lang/", 10) == 0) {
        char lng_include_file[200];

	sprintf( lng_include_file, "$pwr_exe/%s/%s", Lng::get_language_str(),
		 &include_file[10]);
	strcpy( include_file, lng_include_file);
      }

      if ( !noprop) {
	sts = get_next_key( help_key, navh_eHelpFile_Other, 
			    include_file, strict, prev_key);
	if ( ODD(sts)) {
	  fclose( file);
	  return sts;
	}
      }
      hit = 0;
    }
    if ( cdh_NoCaseStrncmp( line, "<topic>", 7) == 0) {
      if ( (s = strstr( line, "<style>")) || (s = strstr( line, "<STYLE>"))) {
	*s = 0;
      }

      help_remove_spaces( &line[7], subject);
      cdh_ToLower( subject, subject);
      subject_nr = dcli_parse( subject, " 	", "", (char *)subject_part,
                	sizeof( subject_part) / sizeof( subject_part[0]),
			sizeof( subject_part[0]), 0);
      if ( key_nr == subject_nr ) {
	for ( i = 0; i < key_nr; i++) {
	  if ( (!strict && strncmp( subject_part[i], key_part[i], strlen(key_part[i])) == 0) ||
	       (strict && strcmp( subject_part[i], key_part[i]) == 0)) {
	    if ( i == key_nr - 1) {
	      hit = 1;
	      strcpy( prev_key, prev);
	    }
	  }
	  else
	    break;
	}
      }
      if ( hit) 
	break;

      strcpy( prev, subject);
    }
    sts = dcli_read_line( line, sizeof( line), file);
  }
  fclose( file);

  if ( !hit || strcmp( prev, "") == 0)
    return NAV__TOPICNOTFOUND;
  return NAV__SUCCESS;
}
Exemplo n.º 12
0
int	NavHelp::help( const char *help_key, const char *help_bookmark, 
		       navh_eHelpFile file_type, const char *file_name, void **book_mark,
		       bool strict)
{
  FILE	*file;
  char	line[200];
  char	text1[200];
  char	text2[200];
  char	text3[200];
  char	key[80];
  char	key_part[4][40];
  char	include_file[80];
  char	subject[80];
  char	subject_part[4][40];
  int	key_nr;
  int	subject_nr;
  int	hit = 0;
  int 	sts;
  int	i;  
  char	link[200];
  char	link_bookmark[80];
  char	link_filename[80];
  char	*link_filename_p;
  int	link_nr;
  char	link_part[4][200];
  char	bookmark[80];
  char	search_bookmark[80];
  char	*s;
  int	header1;
  int	header2;
  int	bold;
  int	code;
  int	horizontal_line;
  int	style = 0;
  char  style_str[80];
  int   image;
  char  imagefile[80];
  int	register_bookmark = 0;
  int	bookmark_found = 0;
  void  *bookmark_node = 0;
  int   index_link;
  void  *node;
  int   print_all;
  char  *bookmark_p;
  lng_eCoding coding = lng_eCoding_ISO8859_1;

  print_all = (help_key == NULL);
  if ( help_key) {
    cdh_ToLower( key, help_key);
    cdh_ToLower( search_bookmark, help_bookmark);
  }

  // Open file
  file = navhelp_open_file( this, file_type, file_name);
  if ( !file) return NAV__NOFILE;
	
  if ( !print_all)
    key_nr = dcli_parse( key, " 	", "", (char *)key_part,
			 sizeof( key_part) / sizeof( key_part[0]), 
			 sizeof( key_part[0]), 0);


  sts = dcli_read_line( line, sizeof( line), file);
  while ( ODD(sts)) {
    if ( cdh_NoCaseStrncmp( line, "<coding>", 8) == 0) {      
      char codingstr[40];

      help_remove_spaces( &line[8], codingstr);
      if ( cdh_NoCaseStrcmp( codingstr, "ISO8859-1") == 0) {
	coding = lng_eCoding_ISO8859_1;
      }
      else if ( cdh_NoCaseStrcmp( codingstr, "UTF-8") == 0) {
	coding = lng_eCoding_UTF_8;
      }
    }
    else if ( cdh_NoCaseStrncmp( line, "<include>", 9) == 0) {      
      help_remove_spaces( &line[9], include_file);

      if ( !noprop || strstr( include_file, "$pwr_lang") == 0) {
	sts = help( help_key, help_bookmark, navh_eHelpFile_Other, 
		    include_file, book_mark, strict);
	if ( ODD(sts) && !print_all) {
	  fclose( file);
	  return sts;
	}
      }

      hit = 0;
    }
    else if ( cdh_NoCaseStrncmp( line, "<chapter>", 9) == 0) {      
      (insert_cb)( parent_ctx, navh_eItemType_Chapter, "",
		   NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
    }
    else if ( cdh_NoCaseStrncmp( line, "</chapter>", 10) == 0) {
      (insert_cb)( parent_ctx, navh_eItemType_EndChapter, "",
		   NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
    }
    else if ( cdh_NoCaseStrncmp( line, "<headerlevel>", 13) == 0) {
      (insert_cb)( parent_ctx, navh_eItemType_HeaderLevel, "",
		   NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
    }
    else if ( cdh_NoCaseStrncmp( line, "</headerlevel>", 14) == 0) {
      (insert_cb)( parent_ctx, navh_eItemType_EndHeaderLevel, "",
		   NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
    }
    else if ( cdh_NoCaseStrncmp( line, "<pagebreak>", 11) == 0) {
      (insert_cb)( parent_ctx, navh_eItemType_PageBreak, "",
		   NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
    }
    else if ( cdh_NoCaseStrncmp( line, "<option>", 8) == 0) {
      char option[80];

      help_remove_spaces( &line[8], option);
      cdh_ToLower( option, option);
      (insert_cb)( parent_ctx, navh_eItemType_Option, option,
		   NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
    }
    else if ( cdh_NoCaseStrncmp( line, "<topic>", 7) == 0) {
      if ( (s = strstr( line, "<style>")) || (s = strstr( line, "<STYLE>"))) {
	style = 1;
	help_remove_spaces( s + 7, style_str);
	*s = 0;
      }

      help_remove_spaces( &line[7], subject);
      cdh_ToLower( subject, subject);
      subject_nr = dcli_parse( subject, " 	", "", (char *)subject_part,
                	sizeof( subject_part) / sizeof( subject_part[0]),
			sizeof( subject_part[0]), 0);
      hit = 0;
      if ( !print_all) {
        if ( key_nr == subject_nr ) {
          for ( i = 0; i < key_nr; i++) {
            if ( (!strict && strncmp( subject_part[i], key_part[i], strlen(key_part[i])) == 0) ||
		 (strict && strcmp( subject_part[i], key_part[i]) == 0)) {
              if ( i == key_nr - 1)
                hit = 1;
            }
            else
              break;
          }
        }
      }
      else {
	if ( cdh_NoCaseStrcmp( subject_part[0], "__documenttitlepage") == 0)
	  (insert_cb)( parent_ctx, navh_eItemType_DocTitlePage, subject,
		       NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
	else if ( cdh_NoCaseStrcmp( subject_part[0], "__documentinfopage") == 0)
	  (insert_cb)( parent_ctx, navh_eItemType_DocInfoPage, subject,
		       NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
	else
	  (insert_cb)( parent_ctx, navh_eItemType_Topic, subject,
		       NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
	if ( style)
	  node = (insert_cb)( parent_ctx, navh_eItemType_Style, style_str,
		      NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
        hit = 1;
      }
    }
    if ( hit)
    {
      sts = dcli_read_line( line, sizeof( line), file);
      (insert_cb)( parent_ctx, navh_eItemType_HelpHeader, line, NULL, NULL, 
		 NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
      sts = dcli_read_line( line, sizeof( line), file);
      while( ODD(sts))
      {
        bookmark_p = 0;

        if ( strncmp( line, "</topic>", 8) == 0 ||
             strncmp( line, "</TOPIC>", 8) == 0) {
          if ( print_all)
            (insert_cb)( parent_ctx, navh_eItemType_EndTopic, subject,
		      NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
          break;
        }

	// Ignore all other tags
        if ( (s = strstr( line, "<ib>")) || (s = strstr( line, "<IB>"))) {
	  strcpy( text1, s + 4);
          (insert_cb)( parent_ctx, navh_eItemType_HelpBold, 
			    text1,  "", "", "", "", NULL, file_type, 0, NULL, coding);
          sts = dcli_read_line( line, sizeof( line), file);
          continue;
	}
        if ( (s = strstr( line, "<i>")) || (s = strstr( line, "<I>"))) {
	  strcpy( text1, s + 3);
          (insert_cb)( parent_ctx, navh_eItemType_Help, text1,  "", "", "", 
		"", NULL, file_type, 0, bookmark_p, coding);
          sts = dcli_read_line( line, sizeof( line), file);
          continue;
	}
	if ( cdh_NoCaseStrncmp( line, "<option>", 8) == 0) {
	  char option[80];

	  help_remove_spaces( &line[8], option);
	  cdh_ToLower( option, option);
	  (insert_cb)( parent_ctx, navh_eItemType_Option, option,
		      NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
          sts = dcli_read_line( line, sizeof( line), file);
          continue;
	}

        if ( (s = strstr( line, "<link>")) || (s = strstr( line, "<LINK>")))
	{
          help_remove_spaces( s + 6, link);
	  *s = 0;

          link_nr = dcli_parse( link, ",", "", (char *)link_part,
                	sizeof( link_part) / sizeof( link_part[0]),
			sizeof( link_part[0]), 0);
          if ( link_nr == 1)
	  {
	    help_remove_spaces( link_part[0], link);
            strcpy( link_bookmark, "");
            link_filename_p = (char *)file_name;
	  }
          else if ( link_nr == 2)
	  {
	    help_remove_spaces( link_part[0], link);
	    help_remove_spaces( link_part[1], link_bookmark);
            link_filename_p = (char *)file_name;
          }
          else if ( link_nr > 2)
	  {
	    help_remove_spaces( link_part[0], link);
	    help_remove_spaces( link_part[1], link_bookmark);
	    help_remove_spaces( link_part[2], link_filename);
            link_filename_p = link_filename;
          }
	}
        else if ( (s = strstr( line, "<weblink>")) || (s = strstr( line, "<WEBLINK>")))
	{
          help_remove_spaces( s + 9, link);
	  *s = 0;

          link_nr = dcli_parse( link, ",", "", (char *)link_part,
                	sizeof( link_part) / sizeof( link_part[0]),
			sizeof( link_part[0]), 0);
          if ( link_nr == 1)
	  {
	    strcpy( link, "$web:");
	    help_remove_spaces( link_part[0], &link[5]);
            strcpy( link_bookmark, "");
            link_filename_p = (char *)file_name;
	  }
          else if ( link_nr == 2)
	  {
	    strcpy( link, "$web:");
	    help_remove_spaces( link_part[0], &link[5]);
	    help_remove_spaces( link_part[1], link_bookmark);
            link_filename_p = (char *)file_name;
          }
          else if ( link_nr > 2)
	  {
	    strcpy( link, "$web:");
	    help_remove_spaces( link_part[0], &link[5]);
	    help_remove_spaces( link_part[1], link_bookmark);
	    help_remove_spaces( link_part[2], link_filename);
            link_filename_p = link_filename;
          }
	}
        else if ( (s = strstr( line, "<classlink>")) || (s = strstr( line, "<CLASSLINK>")))
	{
          help_remove_spaces( s + 11, link);
	  *s = 0;

          link_nr = dcli_parse( link, ",", "", (char *)link_part,
                	sizeof( link_part) / sizeof( link_part[0]),
			sizeof( link_part[0]), 0);
          if ( link_nr == 1)
	  {
	    strcpy( link, "$class:");
	    help_remove_spaces( link_part[0], &link[7]);
            strcpy( link_bookmark, "");
            link_filename_p = (char *)file_name;
	  }
          else if ( link_nr == 2)
	  {
	    strcpy( link, "$class:");
	    help_remove_spaces( link_part[0], &link[7]);
	    help_remove_spaces( link_part[1], link_bookmark);
            link_filename_p = (char *)file_name;
          }
          else if ( link_nr > 2)
	  {
	    strcpy( link, "$class:");
	    help_remove_spaces( link_part[0], &link[7]);
	    help_remove_spaces( link_part[1], link_bookmark);
	    help_remove_spaces( link_part[2], link_filename);
            link_filename_p = link_filename;
          }
	}
        else
	{
          strcpy( link, "");
          strcpy( link_bookmark, "");
          link_filename_p = link_filename;
	}

        if ( (s = strstr( line, "<bookmark>")) || (s = strstr( line, "<BOOKMARK>")))
	{
          help_remove_spaces( s + 10, bookmark);
	  *s = 0;
	  cdh_ToLower( bookmark, bookmark);
          if ( !bookmark_found && !print_all &&
	       strcmp( search_bookmark, bookmark) == 0)
	  {
            bookmark_found = 1;
	    register_bookmark = 1;
	  }
          if ( print_all)
	    bookmark_p = bookmark;
	}

        if ( (s = strstr( line, "<index>")) || (s = strstr( line, "<INDEX>")))
        {
	  index_link = 1;
          *s = 0;
	}
        else
          index_link = 0;

	image = 0;
        header1 = 0;
        header2 = 0;
        bold = 0;
	code = 0;
	horizontal_line = 0;
	style = 0;
        if ( (s = strstr( line, "<h1>")) || (s = strstr( line, "<H1>")))
        {
          header1 = 1;
          strcpy( text1, s + 4);
        }
        else if ( (s = strstr( line, "<h2>")) || (s = strstr( line, "<H2>")))
        {
          header2 = 1;
          strcpy( text1, s + 4);
        }
        else if ( (s = strstr( line, "<b>")) || (s = strstr( line, "<B>")))
        {
          bold = 1;
          strcpy( text1, s + 3);
        }
        else if ( (s = strstr( line, "<c>")) || (s = strstr( line, "<C>")))
        {
          code = 1;
          strcpy( text1, s + 3);
        }
        else if ( (s = strstr( line, "<hr>")) || (s = strstr( line, "<HR>")))
        {
          horizontal_line = 1;
        }
        else if ( (s = strstr( line, "<image>")) || (s = strstr( line, "<IMAGE>")))
	{
          help_remove_spaces( s + 7, imagefile);
          image = 1;
	}

        else
        {
          strcpy( text1, line);
        }

        if ( (s = strstr( text1, "<t>")) || (s = strstr( text1, "<T>")) )
	{
          strcpy( text2, s + 3);
	  *s = 0;
          if ( (s = strstr( text2, "<t>")) || (s = strstr( text2, "<T>")) )
	  {
            strcpy( text3, s + 3);
	    *s = 0;
	  }
          else
            strcpy( text3, "");
	}
        else
        {
          strcpy( text2, "");
          strcpy( text3, "");
        }
        if ( header1)
	{
          node = (insert_cb)( parent_ctx, navh_eItemType_HeaderLarge,
			      text1, NULL, NULL, NULL, NULL, NULL,
			      navh_eHelpFile_, 0, bookmark_p, coding);
	  if ( register_bookmark)
	  {
	    bookmark_node = node;
	    register_bookmark = 0;
	  }
	}
        else if ( header2)
	{
          node = (insert_cb)( parent_ctx, navh_eItemType_Header, text1,
			      NULL, NULL, NULL, NULL, NULL, 
			      navh_eHelpFile_, 0, bookmark_p, coding);
	  if ( register_bookmark)
	  {
	    bookmark_node = node;
	    register_bookmark = 0;
	  }
	}
	else if ( bold)
	{
          node = (insert_cb)( parent_ctx, navh_eItemType_HelpBold, text1, 
		text2, text3, link, 
		link_bookmark, link_filename_p, file_type, index_link,
		bookmark_p, coding);
	  if ( register_bookmark)
	  {
	    bookmark_node = node;
	    register_bookmark = 0;
	  }
	}
	else if ( code)
	{
          node = (insert_cb)( parent_ctx, navh_eItemType_HelpCode, text1, 
		text2, text3, link, 
		link_bookmark, link_filename_p, file_type, index_link,
		bookmark_p, coding);
	  if ( register_bookmark)
	  {
	    bookmark_node = node;
	    register_bookmark = 0;
	  }
	}
	else if ( horizontal_line) {
	  node = (insert_cb)( parent_ctx, navh_eItemType_HorizontalLine, NULL,
		      NULL, NULL, NULL, NULL, NULL, navh_eHelpFile_, 0, NULL, coding);
	}
        else if ( image)
	{
          node = (insert_cb)( parent_ctx, navh_eItemType_Image,
			      imagefile, NULL, NULL, link, 
			      link_bookmark, link_filename_p, file_type, index_link,
			      bookmark_p, coding);
	  if ( register_bookmark)
	  {
	    bookmark_node = node;
	    register_bookmark = 0;
	  }
	}
	else
	{
          node = (insert_cb)( parent_ctx, navh_eItemType_Help, text1,  text2,
		text3, link, 
		link_bookmark, link_filename_p, file_type, index_link,
		bookmark_p, coding);
	  if ( register_bookmark)
	  {
	    bookmark_node = node;
	    register_bookmark = 0;
	  }
	}
        sts = dcli_read_line( line, sizeof( line), file);
      }

      if ( bookmark_found)
        *book_mark = bookmark_node;
      else
        *book_mark = 0;
      if ( !print_all)
        break;
      else
        hit = 0;
    }
    sts = dcli_read_line( line, sizeof( line), file);
  }
  fclose( file);

  if ( !print_all && !hit)
    return NAV__TOPICNOTFOUND;
  return NAV__SUCCESS;
}
Exemplo n.º 13
0
int main(  int argc, char *argv[])
{
  pwr_tFileName filespec;
  pwr_tFileName outfile;
  pwr_tFileName found_file;
  merge_eMtype mtype;
  FILE *fp;
  FILE *outfp;
  char line[200];
  int sts;
  char mtab[1000][32];
  int mtabcnt = 0;
  int i;
  int idx;
  pwr_tCmd cmd;
  pwr_tFileName incdir;
  pwr_tFileName cfile;
  pwr_tFileName ofile;
  char pwre_cc[250];
  char pwre_cxx[250];
  char pwre_ar[250];
  char *s;
  int arg_keep = 0;
  int arg_verbose = 0;
  int in_if = 0;
#if defined OS_LINUX
  char os[] = "OS_LINUX";
  char dos[] = "-DOS_LINUX -DOS_POSIX";
  char cflags[] = "";
#elif defined OS_MACOS
  char os[] = "OS_MACOS";
  char dos[] = "-DOS_MACOS -DOS_POSIX";
  char cflags[] = "";
#elif defined OS_FREEBSD
  char os[] = "OS_FREEBSD";
  char dos[] = "-DOS_FREEBSD -DOS_POSIX";
  char cflags[] = "";
#elif defined OS_OPENBSD
  char os[] = "OS_OPENBSD";
  char dos[] = "-DOS_OPENBSD -DOS_POSIX";
  char cflags[] = "";
#elif defined OS_CYGWIN
  char os[] = "OS_CYGWIN";
  char dos[] = "-DOS_CYGWIN -DOS_POSIX";
  char cflags[] = "-I/usr/include/tirpc";
#endif
  if ( argc < 4) {
    usage();
    exit(1);
  }

  if ( (s = getenv( "pwre_cc")))
    strncpy( pwre_cc, s, sizeof(pwre_cc));
  else
    strncpy( pwre_cc, "gcc", sizeof(pwre_cc));
  if ( (s = getenv( "pwre_cxx")))
    strncpy( pwre_cxx, s, sizeof(pwre_cxx));
  else
    strncpy( pwre_cxx, "g++", sizeof(pwre_cxx));
  if ( (s = getenv( "pwre_ar")))
    strncpy( pwre_ar, s, sizeof(pwre_ar));
  else
    strncpy( pwre_ar, "ar", sizeof(pwre_ar));


  idx = 0;
  for ( i = 1; i < argc; i++) {
    if ( strcmp( argv[i], "-k") == 0)
      arg_keep = 1;
    else if ( strcmp( argv[i], "-v") == 0)
      arg_verbose = 1;
    else {
      switch ( idx) {
	case 0:
	  if ( strcmp( argv[i], "io_base") == 0)
   	    mtype = merge_eMtype_IoBase;
  	  else if ( strcmp( argv[i], "wb_base") == 0)
    	    mtype = merge_eMtype_WbBase;
  	  else if ( strcmp( argv[i], "xtt_base") == 0)
    	    mtype = merge_eMtype_XttBase;
  	  else {
    	   usage();
    	   exit(1);
  	  }
	  idx++;
	  break;
	case 1:
	  strncpy( filespec, argv[i], sizeof(filespec));
	  idx++;
	  break;
	case 2:
	  strncpy( outfile, argv[i], sizeof(filespec));
	  idx++;
	  break;
      }
    }
  }
  sts = dcli_search_file( filespec, found_file, DCLI_DIR_SEARCH_INIT);
  while ( ODD(sts)) {
    fp = fopen( found_file, "r");
    if ( !fp) {
      printf( "Unable to open file %s\n", found_file);
      exit(1);
    }

    while( dcli_read_line( line, sizeof(line), fp)) {
      dcli_trim( line, line);
      if ( strncmp( line, "#if" , 3) == 0) {
        in_if = ! check_os( &line[4], os);
        continue;
      }
      else if ( in_if) {
        if ( strncmp( line, "#endif", 6) == 0) {
          if ( in_if)
	    in_if = 0;
	  continue;
        }
        continue;
      }
      else if ( line[0] == 0 || line[0] == '#')
	continue;
      strncpy( mtab[mtabcnt++], line, sizeof(mtab[0]));
      if ( mtabcnt > (int) sizeof(mtab)/sizeof(mtab[0]) - 1)
	break;
    }    

    fclose( fp);
    sts = dcli_search_file( filespec, found_file, DCLI_DIR_SEARCH_NEXT);
  }
  dcli_search_file( filespec, found_file, DCLI_DIR_SEARCH_END);

  switch ( mtype) {
  case merge_eMtype_IoBase: {
    strncpy( cfile, "/tmp/rt_io_base_methods.c", sizeof(cfile));
    strncpy( ofile, "/tmp/rt_io_base_methods.o", sizeof(cfile));

    outfp = fopen( cfile, "w");
    if ( !outfp) {
      printf( "Unable to open file %s\n", outfile);
      exit(1);
    }

    fprintf( outfp, "#include \"rt_io_base.h\"\n");
    for ( i = 0; i < mtabcnt; i++) {
      fprintf( outfp, "pwr_dImport pwr_BindIoMethods(%s);\n", mtab[i]);
    }
  
    fprintf( outfp, "pwr_BindIoClasses(Base) = {\n");
    for ( i = 0; i < mtabcnt; i++) {
      fprintf( outfp, "  pwr_BindIoClass(%s),\n", mtab[i]);    
    }
    fprintf( outfp, "  pwr_NullClass};\n");    
    fclose( outfp);
    break;
  }
  case merge_eMtype_WbBase: {
    strncpy( cfile, "/tmp/wb_i_base_methods.cpp", sizeof(cfile));
    strncpy( ofile, "/tmp/wb_i_base_methods.o", sizeof(cfile));

    outfp = fopen( cfile, "w");
    if ( !outfp) {
      printf( "Unable to open file %s\n", outfile);
      exit(1);
    }

    fprintf( outfp, "#include \"wb_pwrs.h\"\n");
    for ( i = 0; i < mtabcnt; i++) {
      fprintf( outfp, "pwr_dImport pwr_BindMethods(%s);\n", mtab[i]);
    }
  
    fprintf( outfp, "pwr_BindClasses(Base) = {\n");
    for ( i = 0; i < mtabcnt; i++) {
      fprintf( outfp, "  pwr_BindClass(%s),\n", mtab[i]);    
    }
    fprintf( outfp, "  pwr_NullClass};\n");    
    fclose( outfp);
    break;
  }
  case merge_eMtype_XttBase: {
    strncpy( cfile, "/tmp/xtt_i_methods.c", sizeof(cfile));
    strncpy( ofile, "/tmp/xtt_i_methods.o", sizeof(cfile));

    outfp = fopen( cfile, "w");
    if ( !outfp) {
      printf( "Unable to open file %s\n", outfile);
      exit(1);
    }

    fprintf( outfp, "#include \"xtt_menu.h\"\n");
    for ( i = 0; i < mtabcnt; i++) {
      fprintf( outfp, "pwr_dImport pwr_BindXttMethods(%s);\n", mtab[i]);
    }
  
    fprintf( outfp, "pwr_BindXttClasses(Base) = {\n");
    for ( i = 0; i < mtabcnt; i++) {
      fprintf( outfp, "  pwr_BindXttClass(%s),\n", mtab[i]);    
    }
    fprintf( outfp, "  pwr_NullClass};\n");    
    fclose( outfp);
    break;
  }
  }

  dcli_translate_filename( incdir, "$pwr_einc");
  switch ( mtype) {
  case merge_eMtype_WbBase:
    snprintf( cmd, sizeof(cmd), "%s -c %s -I%s %s -o %s %s", pwre_cxx, cflags, incdir, dos, ofile, cfile);
    break;
  default:
    snprintf( cmd, sizeof(cmd), "%s -c %s -I%s %s -o %s %s", pwre_cc, cflags, incdir, dos, ofile, cfile);
  }
  if ( arg_verbose)
    printf( "co_merge: %s\n", cmd);
  system( cmd);
  snprintf( cmd, sizeof(cmd), "%s r %s %s", pwre_ar, outfile, ofile);
  if ( arg_verbose)
    printf( "co_merge: %s\n", cmd);
  system(cmd);
  snprintf( cmd, sizeof(cmd), "rm %s", ofile);
  system(cmd);
  if ( !arg_keep) {
    snprintf( cmd, sizeof(cmd), "rm %s", cfile);
    system(cmd);
  }
  return 1;
}
Exemplo n.º 14
0
int XttHotkey::read_file()
{
  FILE *fp;
  char line[200];
  int row = 0;
  char p1[2][200];
  char p2[10][200];
  int i, n;
  char *s;

  dcli_translate_filename( m_filename, m_filename);
  fp = fopen( m_filename, "r");
  if ( !fp)
    return 0;

  while ( dcli_read_line( line, sizeof(line), fp)) {
    int mod = 0;
    int keysym;
    char keystr[20] = "";
    char action_arg[200];
    char action_name[200];

    row++;

    dcli_trim( line, line);
    if ( line[0] == 0 || line[0] == '#')
      continue;

    n = dcli_parse( line, ":", "", (char *)p1, 
		    sizeof( p1) / sizeof( p1[0]), sizeof( p1[0]), 0);
    if ( n != 2) {
      printf( "Syntax error, %s, row %d\n", m_filename, row);
      continue;
    }
    dcli_trim( p1[0], p1[0]);
    dcli_trim( p1[1], p1[1]);

    n = dcli_parse(  p1[0], " 	", "", (char *)p2, 
		    sizeof( p2) / sizeof( p2[0]), sizeof( p2[0]), 0);
    if ( n < 1) {
      printf( "Syntax error, %s, row %d\n", m_filename, row);
      continue;
    }
    for ( i = 0; i < n; i++) {
      if ( cdh_NoCaseStrcmp( p2[i], "Control") == 0)
	mod |= ControlMask;
      else if ( cdh_NoCaseStrcmp( p2[i], "Shift") == 0)
	mod |= ShiftMask; 
      else if ( cdh_NoCaseStrcmp( p2[i], "Alt") == 0)
	mod |= Mod1Mask; 
      else if ( cdh_NoCaseStrncmp( p2[i], "<key>", 5) == 0) {
	strcpy( keystr, &p2[i][5]);
      	dcli_trim( keystr, keystr);
      }
      else {
	printf( "Syntax error, %s, row %d\n", m_filename, row);
	break;
      }
    }

    n = dcli_parse(  p1[1], "(", "", (char *)p2, 
		     sizeof( p2) / sizeof( p2[0]), sizeof( p2[0]), 0);
    if ( n < 2) {
      printf( "Syntax error, %s, row %d\n", m_filename, row);
      continue;
    }
    strcpy( action_name, p2[0]);
    dcli_trim( action_name, action_name);
    strcpy( action_arg, p2[1]);
    if ( (s = strrchr( action_arg, ')')))
      *s = 0;
    else {
      printf( "Syntax error, %s, row %d\n", m_filename, row);
      continue;
    }
    keysym = XStringToKeysym( keystr);
    if ( !keysym) {
      printf( "Syntax error, %s, row %d\n", m_filename, row);
      continue;
    }

    HotkeyKey key( mod, keysym, action_name, action_arg);
    m_keys.push_back( key);
  }

  fclose( fp);

  for ( i = 0; i < (int)m_keys.size(); i++) {
    grab_key( m_keys[i].m_keysym, m_keys[i].m_mod);
  }

  return 1;
}