Beispiel #1
0
APIModVersion::APIModVersion(CharString versionstr){ // discards name split from ':', only keeps version number
    major = minor = submajor = subminor = 0;
    atleastver = false;
    
    // forget modname if it is still in the string
    if(versionstr.contains(":")){
        LinkedList<CharString> vsplit = versionstr.split(":");
        versionstr = vsplit[1];
    }
    
    this->versionstring = versionstr; // keep original string
    
    if(versionstr.startsWith(">")){
        atleastver = true;
        versionstr.shiftLeft(1);
    }
    
    if(versionstr.startsWith("v")) versionstr.shiftLeft(1);
    
    if(versionstr.contains(".")){
        LinkedList<CharString> vsplit = versionstr.split(".");
        if(vsplit[0].isValidNumber()) major = vsplit[0].getInt();
        if(vsplit[1].isValidNumber()) minor = vsplit[1].getInt();
        if(vsplit.size() >= 3 && vsplit[2].isValidNumber()) submajor = vsplit[2].getInt();
        if(vsplit.size() >= 4 && vsplit[3].isValidNumber()) subminor = vsplit[3].getInt();
    }else{
        // what? Single version number?
        if(versionstr.isValidNumber()){
            major = versionstr.getInt();
        }else{
            // dunno...
            cout << "API Mod Version could not figure out the version for " << versionstring << endl;
        }
    }
}
void _msgClientHandler_ANY_recv(MSGServer *serv, MSGClient* cli, CharString dataIn, CharString &dataOut){
    // handles any message type.
    
    if(dataIn.startsWith("channel:publish:")){ // channel publish data (to here!)
        // channel:publish:CHANNAME:DATA
        LinkedList<CharString> c = dataIn.split(":");
        // +":id" when sent to other channels
        MSGClientChannel* chan = serv->getMSGChannel(c[2]);
        if(chan != 0x0){
            CharString pack = dataIn;
            pack += ":";
            pack += cli->identity;
            chan->distributemessagepacket(pack); // send out the goods
        }
        
    }else if(dataIn.startsWith("channel:subscribe:")){ // client subscribes to channel
        // channel:subscribe:CHANNAME
    }else if(dataIn.startsWith("channel:unsubscribe:")){ // client unsubscribes from channel
        // channel:unsubscribe:CHANNAME
    }else   if(cli->isbserver) { // Is another broadcast server???
        
        if(dataIn.startsWith("newid:")){ // sent from other server
            // newid:IP:ID
        }else if(dataIn.startsWith("newchannel:")){ // new messaging channel
            // newchannel:NAME
        }else  if(dataIn.startsWith("newsubscriber:")){ // new subscriber for the channel
            // newsubscriber:NAME:ID
        }else  if(dataIn.startsWith("unsubscriber:")){ // channel unsub
            // unsubscriber:NAME:ID
        }
    }
}
Beispiel #3
0
/* Returns the name of the end point.
*  Input: String location
*  Output: Very ending of string after last "/"
 */
CharString FileSystem::getNameFromString(CharString location) {
    // gets the name of the last "/dir/dir2/name", even if it ends with "/".
    if(location.get()[location.getSize()-1] == '/') {
        // remove trailing "/".
        location.get()[location.getSize()-1] = '\0';
        location.setSize(location.getSize()-1);
    }

    CharString result = CharString("");
    // split all by "/".
    if(location.contains("/")) {
        // get the very last result of the split.
        LinkedList<CharString>* sresult = location.split('/','`');
        result = *sresult->get(sresult->size()-1);
    } else {
        result = location;
    }

    return result;
}
Beispiel #4
0
// LinkedList<LinkedList<CharString>> lines = SimpleParseFile(file, '\n');
void APIMod::loadProperties(){ // , CharString name, CharString language, CharString version
    if(propertiesloaded) return;

    LinkedList<LinkedList<CharString>> lines = SimpleParseString(getModFileData("mod.properties"), '=');

    CharString depvers = "";
    LinkedListIterator<LinkedList<CharString>> lineit = lines.getIterator();
    while(lineit.hasNext()){
        LinkedList<CharString> p = lineit.next();
        CharString pname = p[0];
        if(pname.compare(CharString("name")))
            this->name = p[1];
        else if(pname.compare(CharString("unixname")))
            this->unixname = p[1];
        else if(pname.compare(CharString("language"))) // c++, java, etc.
            this->language = p[1];
        else if(pname.compare(CharString("version"))){
            this->versionstr = p[1];
            this->version = APIModVersion(p[1]);
        }else if(pname.compare(CharString("dependency_versions")))
            depvers = p[1];
    }

    this->modcwdloc = unixname; // relative folder location for mod
    
    // load dependency versioning information
    //      this->dependencyversions.add("mod1:v12938");
    if(depvers.getSize() > 3){
        if(depvers.contains(", ")){
            depvers.replace(" ", "");
            LinkedList<CharString> v = depvers.split(",");
            this->dependencyversions.addAll(v);
        }else{
            this->dependencyversions.add(depvers);
        }
    }


    propertiesloaded=true;
}
Beispiel #5
0
bool APIMod::compareVersionString(CharString verstr){
    LinkedList<CharString> spl = verstr.split(":");
    CharString name = spl[0];
    CharString ver = spl[1];
}