⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsmpb.cc

📁 对各种手机进行编程的工具包源码gsmlib 1.9版本。
💻 CC
📖 第 1 页 / 共 2 页
字号:
    string phonebook;    SortedPhonebookRef sourcePhonebook, destPhonebook;    bool verbose = false;    bool indexed = false;    string initString = DEFAULT_INIT_STRING;    bool swHandshake = false;    string charSet;    Ref<MeTa> sourceMeTa, destMeTa;    int opt;    int dummy;    while((opt = getopt_long(argc, argv, "I:p:s:d:b:cyhvViD:S:Xt:", longOpts,                             &dummy))          != -1)      switch (opt)      {      case 'X':        swHandshake = true;        break;      case 'I':        initString = optarg;        break;      case 'V':        verbose = true;        break;      case 'p':        phonebook = optarg;        break;      case 'd':        destination = optarg;        break;      case 's':        source = optarg;        break;      case 'D':        destinationBackend = optarg;        break;      case 'S':        sourceBackend = optarg;        break;      case 'b':        baudrate = optarg;        break;      case 't':        charSet = optarg;        break;      case 'c':        doSynchronize = false;        break;      case 'i':        indexed = true;        break;      case 'y':        doSynchronize = true;        break;      case 'v':        cerr << argv[0] << stringPrintf(_(": version %s [compiled %s]"),                                        VERSION, __DATE__) << endl;        exit(0);        break;      case 'h':        cerr << argv[0] << _(": [-b baudrate][-c][-d device or file][-h]"                             "[-I init string]\n"                             "  [-p phonebook name][-s device or file]"                             "[-t charset][-v]"                             "[-V][-y][-X]") << endl             << endl             << _("  -b, --baudrate    baudrate to use for device "                  "(default: 38400)")             << endl             << _("  -c, --copy        copy source entries to destination")             << endl             << _("  -d, --destination sets the destination device to "                  "connect \n"                  "                    to, or the file to write") << endl             << _("  -D, --destination-backend sets the destination backend")             << endl             << _("  -h, --help        prints this message") << endl             << _("  -i, --index       takes index positions into account")             << endl             << _("  -I, --init        device AT init sequence") << endl             << _("  -p, --phonebook   name of phonebook to use") << endl             << _("  -s, --source      sets the source device to connect to,\n"                  "                    or the file to read") << endl             << _("  -t, --charset     sets the character set to use for\n"                  "                    phonebook entries") << endl             << _("  -S, --source-backend sets the source backend")             << endl             << _("  -v, --version     prints version and exits") << endl             << _("  -V, --verbose     print detailed progress messages")             << endl             << _("  -X, --xonxoff     switch on software handshake") << endl             << _("  -y, --synchronize synchronize destination with source\n"                  "                    entries (destination is overwritten)\n"                  "                    (see gsmpb(1) for details)")             << endl << endl;        exit(0);        break;      case '?':        throw GsmException(_("unknown option"), ParameterError);        break;      }    // check if all parameters all present    if (destination == "" || source == "")      throw GsmException(_("both source and destination must be given"),                         ParameterError);    // start accessing source mobile phone or file    if (sourceBackend != "")      sourcePhonebook =        CustomPhonebookRegistry::createPhonebook(sourceBackend, source);    else if (source == "-")      sourcePhonebook = new SortedPhonebook(true, indexed);    else if (isFile(source))      sourcePhonebook = new SortedPhonebook(source, indexed);    else    {      if (phonebook == "")        throw GsmException(_("phonebook name must be given"), ParameterError);      sourceMeTa = new MeTa(new#ifdef WIN32                            Win32SerialPort#else                            UnixSerialPort#endif                            (source,                             baudrate == "" ? DEFAULT_BAUD_RATE :                             baudRateStrToSpeed(baudrate), initString,                             swHandshake));      if (charSet != "")        sourceMeTa->setCharSet(charSet);      sourcePhonebook =        new SortedPhonebook(sourceMeTa->getPhonebook(phonebook));    }    // make sure destination.c_str file exists	if (destination != "")	{      try	  {        ofstream f(destination.c_str(), ios::out | ios::app);	  }      catch (exception)	  {	  }	}    // start accessing destination mobile phone or file    if (destinationBackend != "")      destPhonebook =        CustomPhonebookRegistry::createPhonebook(destinationBackend,                                                 destination);    else if (destination == "-")      destPhonebook = new SortedPhonebook(false, indexed);    else if (isFile(destination))      destPhonebook = new SortedPhonebook(destination, indexed);    else    {      if (phonebook == "")        throw GsmException(_("phonebook name must be given"), ParameterError);      destMeTa = new MeTa(new #ifdef WIN32                          Win32SerialPort#else                          UnixSerialPort#endif                          (destination,                           baudrate == "" ? DEFAULT_BAUD_RATE :                           baudRateStrToSpeed(baudrate), initString,                           swHandshake));      if (charSet != "")        destMeTa->setCharSet(charSet);      PhonebookRef destPb = destMeTa->getPhonebook(phonebook);      // check maximum lengths of source text and phonenumber when writing to      // mobile phone      unsigned int maxTextLen = destPb->getMaxTextLen();      unsigned int maxTelLen = destPb->getMaxTelephoneLen();      for (SortedPhonebookBase::iterator i = sourcePhonebook->begin();           i != sourcePhonebook->end(); ++i)        if (i->text().length() > maxTextLen)          throw GsmException(            stringPrintf(_("text '%s' is too large to fit into destination "                           "(maximum size %d characters)"),                         i->text().c_str(), maxTextLen),            ParameterError);        else if (i->telephone().length() > maxTelLen)          throw GsmException(            stringPrintf(_("phone number '%s' is too large to fit into "                           "destination (maximum size %d characters)"),                         i->telephone().c_str(), maxTelLen),            ParameterError);      // read phonebook      destPhonebook = new SortedPhonebook(destPb);          }    // now do the actual work    if (doSynchronize)    {                           // synchronizing      if (indexed)      {        sourcePhonebook->setSortOrder(ByIndex);        destPhonebook->setSortOrder(ByIndex);        // for an explanation see below        updateEntriesIndexed(sourcePhonebook, destPhonebook, verbose);        deleteNotPresent(sourcePhonebook, destPhonebook, true, verbose);        insertNotPresent(sourcePhonebook, destPhonebook, true, verbose);      }      else      {        sourcePhonebook->setSortOrder(ByText);        destPhonebook->setSortOrder(ByText);        // the following is done to avoid superfluous writes to the TA        // (that takes time) and keep updated (ie. telephone number changed)        // entries at the same place        // 1. update entries in place where just the number changed        updateEntries(sourcePhonebook, destPhonebook, verbose);        // 2. delete those that are not present anymore        deleteNotPresent(sourcePhonebook, destPhonebook, false, verbose);        // 3. insert the new ones        insertNotPresent(sourcePhonebook, destPhonebook, false, verbose);      }    }    else    {                           // copying      destPhonebook->clear();      for (SortedPhonebookBase::iterator i = sourcePhonebook->begin();           i != sourcePhonebook->end(); ++i)      {        if (verbose)        {          cout << stringPrintf(_("inserting '%s' tel# %s"),                               i->text().c_str(), i->telephone().c_str());          if (indexed)            cout << stringPrintf(_(" (index #%d)"), i->index());          cout << endl;        }        destPhonebook->insert(*i);      }    }  }  catch (GsmException &ge)  {    cerr << argv[0] << _("[ERROR]: ") << ge.what() << endl;    return 1;  }  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -