Esempio n. 1
0
bool removeFile(const std::string& filePath) {
    if (!fileExists(filePath)) {
        ACSDK_WARN(LX("removeFileFailed").d("reason", "File does not exist."));
        return false;
    }

    int result = std::remove(filePath.c_str());
    if (result != 0) {
        ACSDK_ERROR(LX("removeFileFailed").d("reason", "could not remove file.").d("result", result));
        return false;
    }

    return true;
}
Esempio n. 2
0
bool CCBuffer::isReadable() const
{
	BEGIN_IF(LE(_u_content_size, 0))
	DO_RETURN_FLASE;
	END_IF
	DO_RETURN_R(LX(_u_read_pos, _u_content_size));
}
void AlexaClientSDKInit::uninitialize() {
    if (0 == g_isInitialized) {
        ACSDK_ERROR(LX("initializeError").d("reason", "notInitialized"));
        return;
    }
    g_isInitialized--;
    curl_global_cleanup();
    utils::configuration::ConfigurationNode::uninitialize();
}
Esempio n. 4
0
bool Normalizer::normalize(const double& unnormalizedInput, double* normalizedOutput) {
    if (!normalizedOutput) {
        ACSDK_ERROR(LX("normalizeFailed").d("reason", "nullNormalizedOutput"));
        return false;
    }

    if (unnormalizedInput < m_sourceMin || unnormalizedInput > m_sourceMax) {
        ACSDK_ERROR(LX("normalizeFailed")
                        .d("reason", "outOfBounds")
                        .d("input", unnormalizedInput)
                        .d("sourceMin", m_sourceMin)
                        .d("sourceMax", m_sourceMax));
        return false;
    }

    *normalizedOutput = (unnormalizedInput - m_sourceMin) * m_scaleFactor + m_normalizedMin;

    return true;
}
bool AlexaClientSDKInit::initialize(const std::vector<std::istream*>& jsonStreams) {
    if (!(curl_version_info(CURLVERSION_NOW)->features & CURL_VERSION_HTTP2)) {
        ACSDK_ERROR(LX("initializeFailed").d("reason", "curlDoesNotSupportHTTP2"));
        return false;
    }

    if (!utils::configuration::ConfigurationNode::initialize(jsonStreams)) {
        ACSDK_ERROR(LX("initializeFailed").d("reason", "ConfigurationNode::initializeFailed"));
        return false;
    }

    if (CURLE_OK != curl_global_init(CURL_GLOBAL_ALL)) {
        ACSDK_ERROR(LX("initializeFailed").d("reason", "curl_global_initFailed"));
        utils::configuration::ConfigurationNode::uninitialize();
        return false;
    }

    g_isInitialized++;
    return true;
}
Esempio n. 6
0
std::unique_ptr<Normalizer> Normalizer::create(
    const double& sourceMin,
    const double& sourceMax,
    const double& normalizedMin,
    const double& normalizedMax) {
    if (sourceMin >= sourceMax) {
        ACSDK_ERROR(LX("createFailed")
                        .d("reason", "sourceMinGreaterEqThanMax")
                        .d("sourceMin", sourceMin)
                        .d("sourceMax", sourceMax));
        return nullptr;
    } else if (normalizedMin > normalizedMax) {
        ACSDK_ERROR(LX("createFailed")
                        .d("reason", "normalizedMinGreaterThanMax")
                        .d("normalizedMin", normalizedMin)
                        .d("normalizedMax", normalizedMax));
        return nullptr;
    }

    return std::unique_ptr<Normalizer>(new Normalizer(sourceMin, sourceMax, normalizedMin, normalizedMax));
}
Esempio n. 7
0
Werkstuck::Werkstuck(Handle_AIS_InteractiveContext VC, QObject *parent) :
    QObject(parent)
{
    firstRun=true;
    VC1=VC;
    Xstart=0;
    Ystart=0;
    Zstart=0;
    Xf=0.15;
    Yf=0.15;
    Zf=0.15;
    Xwz=0;
    Ywz=0;
    Zwz=0;
    Rundtisch=0;

    BulkForm(0,0,0,150,150,50);

    LX(75,10,50);
    LY(75,10,50);
    LZ(25,10,50);
    LX(25,10,50,2);
    LY(35,10,50,2);

    LZ(55,10,50);
    LX(0,10,50);
    LY(0,10,50);
    LZ(49,10,50);
    /* for (int i=0;i<10;i++) {
         LX(150,10,50);
         LY(150,10,50);
         LX(0,10,50);
         LY(0,10,50);
         LIZ(-1,10,50);
     }*/

    Einbau();
}
static void
init_chown (void)
{
    int i;
    struct passwd *l_pass;
    struct group *l_grp;

    do_refresh ();
    end_chown = need_update = current_file = 0;
    single_set = (cpanel->marked < 2) ? 3 : 0;    

    ch_dlg = create_dlg (0, 0, 18, 74, dialog_colors, chown_callback,
			 "[Chown]", "chown", DLG_CENTER);

#define XTRACT(i) BY+chown_but[i].y, BX+chown_but[i].x, chown_but[i].ret_cmd, chown_but[i].flags, _(chown_but[i].text), 0, 0, NULL

    for (i = 0; i < BUTTONS-single_set; i++)
	add_widget (ch_dlg, button_new (XTRACT (i)));

    /* Add the widgets for the file information */
#define LX(i) chown_label [i].y, chown_label [i].x, "", NULL
    for (i = 0; i < LABELS; i++){
	chown_label [i].l = label_new (LX (i));
	add_widget (ch_dlg, chown_label [i].l);
    }

    /* get new listboxes */
    l_user = listbox_new (UY + 1, UX + 1, 19, 10, 0, l_call, NULL);
    l_group = listbox_new (GY + 1, GX + 1, 19, 10, 0, l_call, NULL);

    listbox_add_item (l_user, 0, 0, _("<Unknown user>"), NULL);	/* add fields for unknown names (numbers) */
    listbox_add_item (l_group, 0, 0, _("<Unknown group>"), NULL);

    setpwent ();		/* get and put user names in the listbox */
    while ((l_pass = getpwent ())) {
	listbox_add_item (l_user, 0, 0, l_pass->pw_name, NULL);
    }
    endpwent ();
    
    setgrent ();		/* get and put group names in the listbox */
    while ((l_grp = getgrent ())) {
	listbox_add_item (l_group, 0, 0, l_grp->gr_name, NULL);
    }
    endgrent ();
    
    add_widget (ch_dlg, l_group);
    add_widget (ch_dlg, l_user);	/* add listboxes to the dialogs */
}
Esempio n. 9
0
void main (int argc,  char **argv)
{
    #if 0
    //for (int argi = 1; argi < argc; argi++)
    //{
        kFile *     pFile = NULL;

        try
        {
            pFile = new kFile(argv[0]);
            kFileLX LX(pFile);
            char achPage[0x1004];
            int rc = LX.pageGet(&achPage[0], 0x1B000);
            if (!rc)
            {
                if (memcmp(achPage, (void*)0x1B000, 0x1000))
                    kFile::StdOut.printf("compare failed!\r\n");
                else
                    kFile::StdOut.printf("compare successfull!\r\n");
            }
            else
                kFile::StdOut.printf("failed to read page! rc=%d\r\n", rc);

            rc = LX.pageGet(&achPage[0], 0x10000);
            if (!rc)
            {
                if (memcmp(achPage, (void*)0x10000, 0x1000))
                    kFile::StdOut.printf("compare failed!\r\n");
                else
                    kFile::StdOut.printf("compare successfull!\r\n");
            }
            else
                kFile::StdOut.printf("failed to read page! rc=%d\r\n", rc);
        }
        catch (kError err)
        {
            if (!pFile)
            {
                kFile::StdOut.printf("Failed to open %s. err=%d\r\n",
                                     argv[0],
                                     err.getErrno());
            }
        }
    //} /* for */
    #else
    for (int argi = 1; argi < argc; argi++)
    {
        kFile *     pFile = NULL;

        try
        {
            kFileLX LX(new kFile(argv[argi]));
            int     cObjs = LX.getObjectCount();
            for (int iObj = 0; iObj < cObjs; iObj++)
            {
                char                achPage[0x1004];
                struct o32_obj *    pObj = LX.getObject(iObj);

                for (int iPage = 0; iPage < pObj->o32_mapsize; iPage++)
                {
                    printf("iObj=%2d  iPage=%2d\n", iObj, iPage);
                    int rc = LX.pageGet(&achPage[0], iObj, iPage * 0x1000);
                    if (rc)
                        printf("pageGet -> rc=%d\n", rc);
                    #if 1
                    rc = LX.pagePut(&achPage[0], iObj, iPage * 0x1000);
                    if (rc)
                        printf("pagePut -> rc=%d\n", rc);
                    #else
                    hexdump(&achPage[0], 0x1000, pObj->o32_base + iPage*0x1000);
                    #endif
                }
            }

            #if 1
            kRelocEntry reloc;
            KBOOL       fRc;

            fRc = LX.relocFindFirst(0, 0, &reloc);
            while (fRc)
            {
                if (reloc.isName())
                    printf("%04x:%08x %2d/%d  flags=%08x  %s.%s %d\n",
                           reloc.ulSegment,
                           reloc.offSegment,
                           reloc.offSegment / 0x1000,
                           reloc.ulSegment,
                           reloc.fFlags,
                           reloc.Info.Name.pszModule ? reloc.Info.Name.pszModule : "<NULL>",
                           reloc.Info.Name.pszName ? reloc.Info.Name.pszName : "<NULL>",
                           reloc.Info.Name.ulOrdinal);
                else
                    printf("%04x:%08x %2d/%d  flags=%08x  %04x:%08x\n",
                           reloc.ulSegment,
                           reloc.offSegment,
                           reloc.offSegment / 0x1000,
                           reloc.ulSegment,
                           reloc.fFlags,
                           reloc.Info.Internal.ulSegment,
                           reloc.Info.Internal.offSegment);

                /* next */
                fRc = LX.relocFindNext(&reloc);
            }

            LX.relocFindClose(&reloc);

            #endif
            flushall();
        }
        catch (kError err)
        {
            if (!pFile)
            {
                kFile::StdOut.printf("Failed to open %s. err=%d\r\n",
                                     argv[argi],
                                     err.getErrno());
            }
            flushall();
        }
    } /* for */

    #endif
}
Esempio n. 10
0
void Werkstuck::LIX(float dX, float Rwz, float Lwz)
// фрезерование прямое в инкрементах
{
    LX(Xwz+dX,Rwz, Lwz);
}