Ejemplo n.º 1
0
//=============================================================================	
int CXListBox::SelectString(int nStartAfter, LPCTSTR lpszItem)
//=============================================================================	
{
	int rc = SearchString(nStartAfter, lpszItem, FALSE);
	if (rc != LB_ERR)
		SetCurSel(rc);
	return rc;
}
Ejemplo n.º 2
0
/*
** Search the help text.  If allSections is true, searches all of the help
** text, otherwise searches only in parentTopic.
*/
static void searchHelpText(Widget parent, int parentTopic,
        const char *searchFor, int allSections, int startPos, int startTopic)
{    
    int topic, beginMatch, endMatch;
    int found = False;
    char * helpText  = NULL;
    
    /* Search for the string */
    for (topic=startTopic; topic<NUM_TOPICS; topic++)
    {
        if (!allSections && topic != parentTopic)
            continue;
        helpText = stitch(parent, HelpText[topic], NULL);

        if (SearchString(helpText, searchFor, SEARCH_FORWARD, SEARCH_LITERAL,
                False, topic == startTopic ? startPos : 0, &beginMatch,
                &endMatch, NULL, NULL, GetPrefDelimiters()))
        {
            found = True;
            XtFree(helpText);
            break;
        }
        XtFree(helpText);
    }

    if (!found)
    {
        if (startPos != 0 || (allSections && startTopic != 0))
        {
            /* Wrap search */
            searchHelpText(parent, parentTopic, searchFor, allSections, 0, 0);
            return;
        }
        DialogF(DF_INF, parent, 1, "String Not Found", "String Not Found", "OK");
        return;
    }
    
    /* update navigation history */  
    if (parentTopic != topic)
    {
        navHistForw[parentTopic]= topic;
        navHistBack[topic]= parentTopic;
    }
    
    /* If the appropriate window is already up, bring it to the top, if not,
       make the parent window become this topic */
    changeTopicOrRaise(parentTopic, topic);
    BufSelect(TextGetBuffer(HelpTextPanes[topic]), beginMatch, endMatch);
    TextSetCursorPos(HelpTextPanes[topic], endMatch);
    
    /* Save the search information for search-again */
    strcpy(LastSearchString, searchFor);
    LastSearchTopic = topic;
    LastSearchPos = endMatch;
    LastSearchWasAllTopics = allSections;
}
Ejemplo n.º 3
0
char GSM_Ini()
{
   char *p;
   p = Cmd_16c450("CSMS=1",0);
   p = Cmd_16c450("CMGF=1",0); 
   p = Cmd_16c450("CSDH=1",0);
   p = Cmd_16c450("CLVL=250",0);

   if(p=SearchString(Cmd_16c450("CPIN?",0),"READY"))  have_sim = 1;//检测是否有SIM卡
   else have_sim = 0;   
   return have_sim;
}
Ejemplo n.º 4
0
int  SetSupGroups(LINACONFIG *lc,int Index) {
   FILE *pf=NULL;
   char buff[2000],*pt,*Pw,*UserName;
   int GroupNo,Ugid,*ipt,count,*array,i;
   Dlink *Glist=NULL;
   pf = popen("cat /etc/group","r");
   if(pf==NULL) return 0;
   Glist=Dopen();
   UserName = GetUserId(lc,Index); 
   Ugid = GetGid(lc,Index);
   while (fgets(buff,1999,pf) != NULL) {
      if( (pt=GetLoginId(buff))==NULL) continue; // Actually Group Name
      Pw = GetUserPasswd(buff);
      if(Pw==NULL) continue;
      if(Pw[0]=='\0') { free(Pw);continue;}
      GroupNo=GetUserNo(buff);
      if(GroupNo==Ugid) {free(Pw);continue;}
      if((i=SearchString(buff,UserName))>= 0) {
        int j=0;
        j =i;
        while((buff[j]>' ') &&(buff[j]!=',')&&(buff[j]!=':')) j++;
        buff[j]='\0';
        if(strcmp(buff+i,UserName)==0) {
          ipt=(int *)malloc(sizeof(int));
          *ipt = GroupNo;
          Dadd(Glist,ipt);
//          printf("%s : %d\n",pt,*ipt);
          printf("%d ",*ipt);
        }
      }
      free(pt);free(Pw);
   }
   count = Dcount(Glist);
   printf("  :Supp group count = %d\n",count);
   fflush(stdout);
   if(count > 0) {
     array = (int *)malloc(sizeof(int)*(count));
     Resetlink(Glist);
     i=0;
     while( (ipt = (int *)Getrecord(Glist))!= NULL) {
      array[i++]=*ipt;
     }
     setgroups(count,array);
     free(array);
   }
   pclose(pf);
   Dempty(Glist);
   return count;
}
Ejemplo n.º 5
0
void read_series(istream& df, const string &name)
{
  char ch;
  vec_convert vc;
  series t;
  while (df)
  {
    t.init();
    vc.clear();
    df >> ws;
    if (df.peek() == '*')
    {
      t.hide = true;
      df.ignore();
    }
    if (hide_series)
      t.hide = true;
    df >> ws;
    ch = get_token(df, t.ID);
    if (isspace(ch))
      ch = skip_until(df);
    if (ch != ',')
      continue;
    df >> ws;
    string str;
    ch = get_token(df, str);
    try
    {
      t.f = FindResidual(str);
    }
    catch (gError) 
    {
      cout << NOEQ << t.ID << " - " << str << " -  series ignored" << endl;
      while (ch = df.get(), ch != ';' &&
                            ch != EOF);
      continue;
    }
    parser p(df, name);
    SGML el;
    if (isspace(ch))
      while (df >> ws, ch = df.peek(), ch == '<')
      {
        p.GetSGML(el);
        el.compare("var");
        str = el.FindString("name");
        if (!str.empty())
        {
          t.vs.push_back(str);
          t.vx.push_back(el.FindDouble("value"));
        }
      }
    if (ch != ',')
      ch = skip_until(df);
    if (ch == ',')
      df.ignore();
    else
      continue;
    while (df >> ws, ch = df.peek(), ch == '<')
    {
      vc.push_back(convert());
      vc.back().read(p.GetSGML(el));
    }
    if (ch == ',')
      df.ignore();
    t.read(df, 0, t.f.NameOfX(), t.f.ScaleOfX());
    if (!t)
      continue;
    if (vc.empty())
      ser.push_back(t);
    else
    {
      series t1;
      t1.hide = t.hide;
      t1.ID = t.ID;
      t1.f = t.f;
      t1.vs = t.vs;
      t1.vx = t.vx;
      t1.set(t.Ntot(), vc.size());
      for (size_t i = 0; i < vc.size(); ++i)
      {
        if (vc[i].name().empty())
          throw gError("read_series: no name while converting");
        else
          t1.name(i) = vc[i].name();
      }
      t1.scale() = t.scale();
      t1.NOfX() = SearchString(t1.names(), t1.f.NameOfX());
      for (size_t i = 0; i < vc.size(); ++i)
        vc[i].SetID(t.names());
      for (size_t i = 0; i < t.Ntot(); ++i)
      {
        t1.atr(i) = t.atr(i);
        for (size_t j = 0; j < vc.size(); ++j)
          t1(i, j) = vc[j](t(i));
      }
      t1.set_av();
      ser.push_back(t1);
    }
    ser.back().f.SetInput(ser.back().names());
    ser.back().f.SetOnceInput(ser.back().vs);
  }
}
Ejemplo n.º 6
0
FILE *
DoSearch(ManpageGlobals * man_globals, int type)
{
    char cmdbuf[BUFSIZ], *mantmp, *manpath;
    char tmp[BUFSIZ], path[BUFSIZ];
    char string_buf[BUFSIZ], cmp_str[BUFSIZ], error_buf[BUFSIZ];
    char *search_string = SearchString(man_globals);
    FILE *file;
    int fd;
    int count;
    Boolean flag;

    if (search_string == NULL)
        return (NULL);

    /* If the string is empty or starts with a space then do not search */

    if (streq(search_string, "")) {
        PopupWarning(man_globals, "Search string is empty.");
        return (NULL);
    }

    if (strlen(search_string) >= BUFSIZ) {
        PopupWarning(man_globals, "Search string too long.");
        return (NULL);
    }
    if (search_string[0] == ' ') {
        PopupWarning(man_globals, "First character cannot be a space.");
        return (NULL);
    }

    if (type == APROPOS) {
        char label[BUFSIZ];

        strlcpy(tmp, MANTEMP, sizeof(tmp));   /* get a temp file. */
        fd = mkstemp(tmp);
        if (fd < 0) {
            PopupWarning(man_globals, "Cant create temp file");
            return NULL;
        }
        mantmp = tmp;

        manpath = getenv("MANPATH");
        if (manpath == NULL || streq(manpath, "")) {
#ifdef MANCONF
            if (!ReadManConfig(path))
#endif
            {
                strlcpy(path, SYSMANPATH, sizeof(path));
#ifdef LOCALMANPATH
                strlcat(path, ":", sizeof(path));
                strlcat(path, LOCALMANPATH, sizeof(path));
#endif
            }
        }
        else {
            strlcpy(path, manpath, sizeof(path));
        }

        snprintf(label, sizeof(label),
                 "Results of apropos search on: %s", search_string);

#ifdef NO_MANPATH_SUPPORT       /* not quite correct, but the best I can do. */
        snprintf(cmdbuf, sizeof(cmdbuf), APROPOS_FORMAT, search_string, mantmp);
#else
        snprintf(cmdbuf, sizeof(cmdbuf), APROPOS_FORMAT, path, search_string,
                 mantmp);
#endif

        if (system(cmdbuf) != 0) {      /* execute search. */
            snprintf(error_buf, sizeof(error_buf),
                     "Something went wrong trying to run %s\n", cmdbuf);
            PopupWarning(man_globals, error_buf);
        }

        if ((file = fdopen(fd, "r")) == NULL)
            PrintError("lost temp file? out of temp space?");

/*
 * Since we keep the FD open we can remove the file safely, this
 * will keep extra files out of /tmp.
 */

        remove(mantmp);

        snprintf(string_buf, sizeof(string_buf), "%s: nothing appropriate",
                 search_string);

        /*
         * Check first LOOKLINES lines for "nothing appropriate".
         */

        count = 0;
        flag = FALSE;
        while ((fgets(cmp_str, BUFSIZ, file) != NULL) && (count < LOOKLINES)) {
            size_t len = strlen(cmp_str);

            if (len > 0 && cmp_str[len - 1] == '\n')  /* strip off the '\n' */
                cmp_str[len - 1] = '\0';

            if (streq(cmp_str, string_buf)) {
                flag = TRUE;
                break;
            }
            count++;
        }

        /*
         * If the file is less than this number of lines then assume that there is
         * nothing appropriate found. This does not confuse the apropos filter.
         */

        if (flag) {
            fclose(file);
            file = NULL;
            ChangeLabel(man_globals->label, string_buf);
            return (NULL);
        }

        snprintf(man_globals->manpage_title, sizeof(man_globals->manpage_title),
                 "%s", label);
        ChangeLabel(man_globals->label, label);
        fseek(file, 0L, SEEK_SET);      /* reset file to point at top. */
    }
    else {                      /* MANUAL SEARCH */
        file = DoManualSearch(man_globals, search_string);
        if (file == NULL) {
            snprintf(string_buf, sizeof(string_buf), "No manual entry for %s.",
                     search_string);
            ChangeLabel(man_globals->label, string_buf);
            if (man_globals->label == NULL)
                PopupWarning(man_globals, string_buf);
            return (NULL);
        }
    }

    if (resources.clear_search_string) {
        Arg arglist[1];
        Widget dialog;

        dialog = XtNameToWidget(man_globals->search_widget, DIALOG);
        if (dialog == NULL)
            PopupWarning(man_globals, "Could not clear the search string.");

        XtSetArg(arglist[0], XtNvalue, "");
        XtSetValues(dialog, arglist, (Cardinal) 1);
    }

    return (file);
}
Ejemplo n.º 7
0
void ReadUsersInfo(LINACONFIG *lc) {
   USERINFO *Usr;
   char *Shell=NULL;
   FILE *pf=NULL,*sf=NULL;
   char buff[500],*pt,*Pw,sbuff[500],*tmp,*tmp1;
   int UserNo;
   system("cat /etc/passwd 2>/tmp/.Junk1 >/tmp/.Junk");
   system("ypcat passwd 2>/tmp/.Junk1 >>/tmp/.Junk");
   pf = fopen("/tmp/.Junk","r");
   if(pf==NULL) return;
   lc->Ulist=Dopen();
   while (fgets(buff,499,pf) != NULL) {
      if( (pt=GetLoginId(buff))==NULL) continue;
      Shell=GetUserShell(buff);
      if(SearchString(Shell,"sh") < 0) { free(Shell);continue;}
      free(Shell);
      Shell = NULL;
#if 1
      Pw = GetUserPasswd(buff);
      if(Pw==NULL) continue;
      if(Pw[0]=='\0') { free(Pw);continue;}
      if((strlen(Pw)==1)&&(strcmp(Pw,"x")!=0)) {free(Pw);continue;}
      if((strlen(Pw)==1)&&(strcmp(Pw,"x")==0)) {
           free(Pw);
//           sf = fopen("/etc/shadow","r");
           system("cat /etc/shadow 2>/tmp/.Junk1 >/tmp/.Sjunk");
           system("ypcat shadow 2>/tmp/.Junk1 >>/tmp/.Sjunk");
           sf = fopen("/tmp/.Sjunk","r");
           if(sf==NULL) {
             fprintf(stderr,"Failed to open /etc/shadow\n");
             continue;
           }
           while (fgets(sbuff,499,sf) != NULL) {
              tmp=strchr(sbuff,':');
              tmp[0]='\0';tmp++;
              if(strcmp(sbuff,pt)!=0) continue;
              tmp1=strchr(tmp,':');
              tmp1[0]='\0';
              Pw=(char *)malloc(strlen(tmp)+1);
              strcpy(Pw,tmp);
              break;
           }
           fclose(sf);
           if((strlen(Pw)==1)&&(strcmp(Pw,"x")!=0)) {free(Pw);continue;}
           if((strlen(Pw)==1)&&(strcmp(Pw,"*")!=0)) {free(Pw);continue;}
           if((strlen(Pw)<=1)) {free(Pw);continue;}
      }
#endif
      UserNo=GetUserNo(buff);
      if(((lc->NoRootLogin!=1) &&(UserNo==0))||(UserNo>=100)){
//      if( (UserNo==0) || (UserNo>=100) ) {
        Usr= InitUserInfo();
        Usr->LoginId=pt;
        Usr->UserNo=UserNo;
        Usr->gid=GetGrpId(buff);
        Usr->Passwd=Pw;
        Usr->Name = GetUserName(buff);
        Usr->Home = GetUserHome(buff);
        Shell=GetUserShell(buff);
        Usr->Shell= Shell;
        MakeUserImages(lc,Usr);
        Dadd(lc->Ulist,Usr);
      }
      else {free(pt);free(Pw);}
   }
   Dsort(lc->Ulist,CompId);
   fclose(pf);
}
Ejemplo n.º 8
0
result_struct *MappedMemorySearch(u32 startaddr, u32 endaddr, int searchtype,
                                  const char *searchstr,
                                  result_struct *prevresults, u32 *maxresults)
{
   u32 i=0;
   result_struct *results;
   u32 numresults=0;
   unsigned long searchval;
   int issigned=0;
   u32 addr;

   if ((results = (result_struct *)malloc(sizeof(result_struct) * maxresults[0])) == NULL)
      return NULL;

   switch (searchtype & 0x70)
   {
      case SEARCHSTRING:
      case SEARCHREL8BIT:
      case SEARCHREL16BIT:
      {
         // String/8-bit relative/16-bit relative search(not supported, yet)
         if (SearchString(startaddr, endaddr,  searchtype, searchstr,
                          results, maxresults) == 0)
         {
            maxresults[0] = 0;
            free(results);
            return NULL;
         }

         return results;
      }
      case SEARCHHEX:         
         sscanf(searchstr, "%08lx", &searchval);
         break;
      case SEARCHUNSIGNED:
         searchval = (unsigned long)strtoul(searchstr, NULL, 10);
         issigned = 0;
         break;
      case SEARCHSIGNED:
         searchval = (unsigned long)strtol(searchstr, NULL, 10);
         issigned = 1;
         break;
   }   

   if (prevresults)
   {
      addr = prevresults[i].addr;
      i++;
   }
   else
      addr = startaddr;

   // Regular value search
   for (;;)
   {
       u32 val=0;
       u32 newaddr;

       // Fetch byte/word/etc.
       switch (searchtype & 0x3)
       {
          case SEARCHBYTE:
             val = MappedMemoryReadByte(addr);
             // sign extend if neccessary
             if (issigned)
                val = (s8)val;

             if (SearchIncrementAndCheckBounds(prevresults, maxresults, numresults, &i, addr+1, &newaddr, endaddr))
                return results;
             break;
          case SEARCHWORD:
             val = MappedMemoryReadWord(addr);
             // sign extend if neccessary
             if (issigned)
                val = (s16)val;

             if (SearchIncrementAndCheckBounds(prevresults, maxresults, numresults, &i, addr+2, &newaddr, endaddr))
                return results;
             break;
          case SEARCHLONG:
             val = MappedMemoryReadLong(addr);

             if (SearchIncrementAndCheckBounds(prevresults, maxresults, numresults, &i, addr+4, &newaddr, endaddr))
                return results;
             break;
          default:
             maxresults[0] = 0; 
             if (results)
                free(results);
             return NULL;
       }

       // Do a comparison
       switch (searchtype & 0xC)
       {
          case SEARCHEXACT:
             if (val == searchval)
                MappedMemoryAddMatch(addr, val, searchtype, results, &numresults);
             break;
          case SEARCHLESSTHAN:
             if ((!issigned && val < searchval) || (issigned && (signed)val < (signed)searchval))
                MappedMemoryAddMatch(addr, val, searchtype, results, &numresults);
             break;
          case SEARCHGREATERTHAN:
             if ((!issigned && val > searchval) || (issigned && (signed)val > (signed)searchval))
                MappedMemoryAddMatch(addr, val, searchtype, results, &numresults);
             break;
          default:
             maxresults[0] = 0;
             if (results)
                free(results);
             return NULL;
       }

       addr = newaddr;
   }

   maxresults[0] = numresults;
   return results;
}
Ejemplo n.º 9
0
static int InitMainDialogBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
	char *Pt;
	char *recv_at=malloc(20);
	//char *str;

	char *str1=malloc(200);
	char *str2=malloc(200);
	int time=0;
	int shijian3=0;
	
    switch (message) 
	{
    case MSG_INITDIALOG:
		//检测GSM
#ifdef _TIMER_UNIT_10MS
			SetTimer ( hDlg,  0,  10 );
#else 
			SetTimer ( hDlg,  0,  1 );
#endif

		if(!GSM_Ini())  SetDlgItemText(hDlg,SMSG_STATE,"\n你SIM卡呢!"); 
		else //显示SIM的信息
		{
			if(SearchString(Cmd_16c450("COPS?",0),"CHN-CUGSM")) 
				sim_info = "\n\t\t\t\t\t\t\t\t\t\t\t\t中国联通";
			else  sim_info = "\n\t\t\t\t\t\t\t\t\t\t\t\t中国移动";
			SetDlgItemText(hDlg,SMSG_STATE,sim_info);
		}
		//*/
		MsgNum = Read_SIM_SMsg_num();
        return 1;
	case MSG_TIMER:
		printf("MSG_TIMER\n");
		if(new_msmsmsg_flag==1)
		{
			time++;
			if(time>shijian)
			{
				time=0;
				new_msmsmsg_flag=0;
				SetDlgItemText(hDlg,SMSG_STATE,"");
			
			}

		}
		// 
		//msgNum=Read_SIM_SMsg_num();   //返回当前SIM 卡中有多少条短信
		//msg_num_itoa(numstring,msgNum+1);
		//if(!SearchString(Cmd_16c450(numstring,9),"ERROR"))
		if(!SearchString(Cmd_16c450(msg_num_itoa(numstring,MsgNum+1),9),"ERROR"))
		{
			printf("NEW SMSMSG\n");
			new_msmsmsg_flag=1;
			SetDlgItemText(hDlg,SMSG_STATE,"NEW SMSMSG");
			//
			//sprintf(P,"%s%s", "\"", phnum);
            //sprintf(P_spr,"%s%s", P,"\"");
            //sprintf(P,"%s%s","CMGR=",P_spr);
			sprintf(recv_at,"%s%s","CMGR=", msg_num_itoa(numstring,MsgNum+1));
			Pt = Cmd_16c450(recv_at,0);
			//sprintf(str,"%s%s","\t", Message_Src( Pt));
			//sprintf(str,"%s%s",Message_Src( Pt), "\n");
			//sprintf(str,"%s%s","\t", Message_Time(Pt));
			//sprintf(str,"%s%s",Message_Time(Pt), "\n");
			//sprintf(str,"%s%s","\t", Message_Content(Pt));

			sprintf(str1,"\n%s\n%s",Message_Src( Pt),Message_Time(Pt));
			sprintf(str2,"%s\n%s",str1,Message_Content(Pt));
			
			//sprintf(str,"%s%s",Message_Content(Pt), "\n");
			//SetDlgItemText(hDlg,SMSG_STATE,Message_Src( Pt));
			//SetDlgItemText(hDlg,SMSG_STATE,Message_Time(Pt));
			//SetDlgItemText(hDlg,SMSG_STATE,Message_Content(Pt));
			SetDlgItemText(hDlg,SMSG_STATE,str2);
			
			MsgNum+=1;
		}
		//{
		//	// printf("有新短信\n");
		//msg_num_itoa(numstring,msgNum+1);
		
		// 
		//}
		return 1; 
    case MSG_COMMAND:
        switch (wParam) 
		{
        case SMSG_SEND:
			//发短信-----处理
			SEND_SMSG(hDlg);
			break;
		case SMSG_OK:
			//查看新短信-----处理
			
			break;
		case SMSG_INBOX:
			//收件箱-----处理
			INBOX_SMSG(hDlg);
			break;
		case SMSG_HELP:
			//帮助-----处理
			HELP_SMSG(hDlg);
			break;
        }
        break;
        
    }
	free(str1);
	free(str2);
	free(recv_at);
    return DefaultDialogProc (hDlg, message, wParam, lParam);
}
bool Preprocessor::IsHex( char in )
{
    return SearchString( HexNumbers, in );
}
bool Preprocessor::IsTrivial( char in )
{
    return SearchString( Trivials, in );
}
bool Preprocessor::IsIdentifierBody( char in )
{
    return SearchString( IdentifierBody, in );
}
bool Preprocessor::IsIdentifierStart( char in )
{
    return SearchString( IdentifierStart, in );
}
bool Preprocessor::IsNumber( char in )
{
    return SearchString( Numbers, in );
}
Ejemplo n.º 15
0
//=============================================================================	
int CXListBox::FindStringExact(int nStartAfter, LPCTSTR lpszItem) const
//=============================================================================	
{
	return SearchString(nStartAfter, lpszItem, TRUE);
}