Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 771521a885992795ee9a5ee5707dfe89907c0df3
  • develop par défaut protégée
  • implement-discord-markdown-update
  • matrix-attachments-order-fix
  • fix-oversized-file-transfer
  • matrix-attachment-order-fix
  • matrix-answer-modified-fix
  • cherry-pick-moise
8 résultats

matrixeventprocessor.ts

Blame
  • Bifurcation depuis ARISE / matrix-appservice-discord
    Le projet source a une visibilité limitée.
    utils.c 1,62 Kio
    #include <p2c/p2c.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    #include <p2c/strings.h>
    #include "log.h"
    #include "logglobals.h"
    #include "utils.h"
    
    /**
     * Reserved for future use.
     */
    void working()
    {
    }
    
    void getword(char *buf, char *wrd)
    {
    	char STR1[256];
    	char STR2[256];
    
    	strcpy(STR1, strltrim(strrtrim(strcpy(STR2, buf))));
    	strcpy(buf, STR1);
    	if (*buf == '"')
    		strwordx(buf, wrd);
    	else
    	{
    		strwordx(buf, wrd);
    		strupper(wrd, wrd);
    	}
    }
    
    /* char *strcpy_overlap(char *dst, char *src) */
    /* { */
    /*	size_t i = 0; */
    
    /*	do { */
    /*		dst[i] = src[i]; */
    /*		if (src[i++] == '\0') */
    /*			break; */
    /*	} while (1); */
    /*	return dst; */
    /* } */
    
    
    void stamp(long *i)
    {
    	gg.curstamp++;
    	*i = gg.curstamp;
    }
    
    void dounits(char *s, double *r)
    {
    	char ch;
    
    	if (*s == '\0')
    		return;
    	ch = s[0];
    	if (ch >= 'a')
    		ch -= 32;
    	if (ch == 'F')
    	{
    		*r *= 1e-15;
    		return;
    	}
    	if (ch == 'P')
    	{
    		*r *= 1e-12;
    		return;
    	}
    	if (ch == 'N')
    	{
    		*r *= 1e-9;
    		return;
    	}
    	if (ch == 'U')
    	{
    		*r *= 1e-6;
    		return;
    	}
    	if (ch == 'K')
    	{
    		*r *= 1e3;
    		return;
    	}
    	if (ch == 'G')
    	{
    		*r *= 1e9;
    		return;
    	}
    	if (ch == 'T')
    	{
    		*r *= 1e12;
    		return;
    	}
    	if (ch != 'M')
    		return;
    	if (strlen(s) >= 3 && (s[1] == 'E' || s[1] == 'e') &&
    			(s[2] == 'G' || s[2] == 'g'))
    		*r *= 1e6;
    	else
    		*r *= 1e-3;
    }
    
    
    void readreal(char s_[], double *r)
    {
    	char s[256];
    	long i;
    	char *STR1;
    	char STR2[256];
    
    	strcpy(s, s_);
    	if (!(*s != '\0' && (s[0] == '.' || s[0] == '+' || s[0] == '-' || isdigit(s[0]))))
    		return;
    	*r = strtod(s, &STR1);
    	i = STR1 - s + 1;
    	strcpy_overlap(s, s + i - 1);
    	strcpy(STR2, strltrim(s));
    	strcpy(s, STR2);
    	dounits(s, r);
    }