示例#1
0
//
// BuildChain - Builds the chain (linked list)
//
void BuildChain()
{
    self->s.v.goalentity = EDICT_TO_PROG( MakeLink() );
    PROG_TO_EDICT( self->s.v.goalentity )->s.v.think = (func_t) UpdateChain;
    PROG_TO_EDICT( self->s.v.goalentity )->s.v.nextthink = g_globalvars.time + 0.1;
    PROG_TO_EDICT( self->s.v.goalentity )->s.v.owner = self->s.v.owner;
    PROG_TO_EDICT( self->s.v.goalentity )->s.v.goalentity = EDICT_TO_PROG( MakeLink() );
    PROG_TO_EDICT( PROG_TO_EDICT( self->s.v.goalentity )->s.v.goalentity)->s.v.goalentity = EDICT_TO_PROG( MakeLink() );
}
示例#2
0
文件: main.cpp 项目: CCJY/coliru
int main()
{
    int k = 10;

    auto link = MakeLink(Utils::MakeLink(k));

    std::cout << link << std::endl;
    std::cout << Utils::RemoveLinks(link) << std::endl;
}
示例#3
0
Value Compiler::ExeLinkVarField1::Eval(ExeContext& x) const
{
	LTIMING("ExeLinkVarField");
	Vector<Value> v;
	v.Add(x.stack[var_index][id]);
	StringBuffer r;
	r << "\"";
	MakeLink(r, *part, v);
	r << "\"";
	return Raw(r);
}
示例#4
0
Value Compiler::ExeLink::Eval(ExeContext& x) const
{
	LTIMING("ExeLink");
	Vector<Value> v;
	v.SetCount(arg.GetCount());
	for(int i = 0; i < arg.GetCount(); i++) {
		LTIMING("arg eval");
		v[i] = arg[i]->Eval(x);
	}
	StringBuffer r;
	r << "\"";
	MakeLink(r, *part, v);
	r << "\"";
	return Raw(r);
}
示例#5
0
int FileMcIDAS::Close(int channel){
  if (Bin[channel]) { 
    bufFlush(channel);
    
    if(GlobalComment)
      write(Doc[channel],GlobalComment,strlen(GlobalComment));

    if(ChannelComment[channel])
      write(Doc[channel],ChannelComment[channel],strlen(ChannelComment[channel]));

    close(Bin[channel]);
    close(Doc[channel]);
    
    rename(tmpName(FileName(channel)), FileName(channel));
    if(linkLatest()) MakeLink(channel);
  }
  return(0);
}
示例#6
0
文件: files_links.c 项目: baptr/core
PromiseResult VerifyLink(EvalContext *ctx, char *destination, const char *source, Attributes attr, const Promise *pp)
{
    char to[CF_BUFSIZE], linkbuf[CF_BUFSIZE], absto[CF_BUFSIZE];
    struct stat sb;

    memset(to, 0, CF_BUFSIZE);

    if ((!IsAbsoluteFileName(source)) && (*source != '.'))        /* links without a directory reference */
    {
        snprintf(to, CF_BUFSIZE - 1, "./%s", source);
    }
    else
    {
        strncpy(to, source, CF_BUFSIZE - 1);
    }

    if (!IsAbsoluteFileName(to))        /* relative path, must still check if exists */
    {
        Log(LOG_LEVEL_DEBUG, "Relative link destination detected '%s'", to);
        strcpy(absto, AbsLinkPath(destination, to));
        Log(LOG_LEVEL_DEBUG, "Absolute path to relative link '%s', '%s'", absto, destination);
    }
    else
    {
        strcpy(absto, to);
    }

    bool source_file_exists = true;

    if (stat(absto, &sb) == -1)
    {
        Log(LOG_LEVEL_DEBUG, "No source file");
        source_file_exists = false;
    }

    if ((!source_file_exists) && (attr.link.when_no_file != cfa_force) && (attr.link.when_no_file != cfa_delete))
    {
        Log(LOG_LEVEL_INFO, "Source %s for linking is absent", absto);
        cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_FAIL, pp, attr, "Unable to create link %s -> %s, no source", destination, to);
        return PROMISE_RESULT_WARN;
    }

    if ((!source_file_exists) && (attr.link.when_no_file == cfa_delete))
    {
        KillGhostLink(ctx, destination, attr, pp);
        return PROMISE_RESULT_CHANGE;
    }

    memset(linkbuf, 0, CF_BUFSIZE);

    if (readlink(destination, linkbuf, CF_BUFSIZE - 1) == -1)
    {

        if (!MakeParentDirectory2(destination, attr.move_obstructions, EnforcePromise(attr.transaction.action)))
        {
            cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, attr, "Unable to create parent directory of link %s -> %s (enforce=%d)",
                 destination, to, EnforcePromise(attr.transaction.action));
            return PROMISE_RESULT_FAIL;
        }
        else
        {
            if (!MoveObstruction(ctx, destination, attr, pp))
            {
                cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_FAIL, pp, attr, "Unable to create link %s -> %s", destination, to);
                return PROMISE_RESULT_FAIL;
            }

            return MakeLink(ctx, destination, source, attr, pp) ? PROMISE_RESULT_CHANGE : PROMISE_RESULT_FAIL;
        }
    }
    else
    {
        int ok = false;

        if ((attr.link.link_type == FILE_LINK_TYPE_SYMLINK) && (strcmp(linkbuf, to) != 0) && (strcmp(linkbuf, source) != 0))
        {
            ok = true;
        }
        else if (strcmp(linkbuf, source) != 0)
        {
            ok = true;
        }

        if (ok)
        {
            if (attr.move_obstructions)
            {
                if (!DONTDO)
                {
                    cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, attr, "Overriding incorrect link %s\n", destination);

                    if (unlink(destination) == -1)
                    {
                        cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_FAIL, pp, attr, "Link %s points to %s not %s - error removing link",
                             destination, linkbuf, to);
                        return PROMISE_RESULT_FAIL;
                    }

                    return MakeLink(ctx, destination, source, attr, pp);
                }
                else
                {
                    Log(LOG_LEVEL_ERR, "Must remove incorrect link %s", destination);
                    return PROMISE_RESULT_NOOP;
                }
            }
            else
            {
                cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_FAIL, pp, attr, "Link %s points to %s not %s - not authorized to override",
                     destination, linkbuf, to);
                return true;
            }
        }
        else
        {
            cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, attr, "Link %s points to %s - promise kept", destination, source);
            return PROMISE_RESULT_NOOP;
        }
    }
}
示例#7
0
void sparabrev(void) {
        BPTR fh,lock=NULL;
        struct EditLine *elpek;
        char bugbuf[100],orgfilename[50],*motstr;
        int till,nr,mot;
        Servermem->inne[nodnr].skrivit++;
        Servermem->info.skrivna++;
        Statstr.write++;
        till=atoi(brevspar.to);
        if((nr=updatenextletter(till))==-1) {
                freeeditlist();
                return;
        }
        sprintf(orgfilename,"NiKom:Users/%d/%d/%d.letter",till/100,till,nr);
        if(!(fh=Open(orgfilename,MODE_NEWFILE))) {
                puttekn("\n\n\rKunde inte öppna brevet\n\r",-1);
                freeeditlist();
                return;
        }
        strcpy(bugbuf,"System-ID: NiKom\n");
        FPuts(fh,bugbuf);
        sprintf(bugbuf,"From: %d\n",inloggad);
        FPuts(fh,bugbuf);
        sprintf(bugbuf,"To: %s\n",brevspar.to);
        FPuts(fh,bugbuf);
        if(brevspar.reply[0]) {
                sprintf(bugbuf,"Reply: %s\n",brevspar.reply);
                FPuts(fh,bugbuf);
        }
        sprintf(bugbuf,"Date: %s\n",brevspar.date);
        FPuts(fh,bugbuf);
        sprintf(bugbuf,"Subject: %s\n",brevspar.subject);
        FPuts(fh,bugbuf);
        for(elpek=(struct EditLine *)edit_list.mlh_Head;elpek->line_node.mln_Succ;elpek=(struct EditLine *)elpek->line_node.mln_Succ) {
                if(FPuts(fh,elpek->text)==-1) {
                        puttekn("\n\n\rFel vid skrivandet av brevet\n\r",-1);
                        break;
                }
                FPutC(fh,'\n');
        }
        Close(fh);
        freeeditlist();
        sprintf(outbuffer,"\r\nBrevet fick nummer %d hos %s\r\n",nr,getusername(till));
        puttekn(outbuffer,-1);
        if(Servermem->cfg.logmask & LOG_BREV) {
                strcpy(bugbuf,getusername(inloggad));
                sprintf(outbuffer,"%s skickar brev %d till %s",bugbuf,nr,getusername(till));
                logevent(outbuffer);
        }
        motstr=hittaefter(brevspar.to);
        if(motstr[0]) {
                if(!(lock=Lock(orgfilename,ACCESS_READ))) {
                        puttekn("\n\n\rKunde inte få ett lock för brevet\n\r",-1);
                        return;
                }
        }
        while(motstr[0]) {
                mot=atoi(motstr);
                if((nr=updatenextletter(mot))==-1) {
                        UnLock(lock);
                        return;
                }
                sprintf(bugbuf,"NiKom:Users/%d/%d/%d.letter",mot/100,mot,nr);
                if(!MakeLink(bugbuf,lock,FALSE)) {
                        puttekn("\n\n\rKunde inte skapa länk till brevet\n\r",-1);
                        UnLock(lock);
                        return;
                }
                sprintf(outbuffer,"\r\nBrevet fick nummer %d hos %s\r\n",nr,getusername(mot));
                puttekn(outbuffer,-1);
                if(Servermem->cfg.logmask & LOG_BREV) {
                        strcpy(bugbuf,getusername(inloggad));
                        sprintf(outbuffer,"%s skickar brev %d till %s",bugbuf,nr,getusername(mot));
                        logevent(outbuffer);
                }
                motstr=hittaefter(motstr);
        }
        if(lock) UnLock(lock);
}
示例#8
0
/* virtual */
string FormatterLatex::makeLink(const string &strIdentifier,
                                const string *pstrAnchor,
                                const string &strTitle)
{
    return MakeLink(strIdentifier, strTitle);
}