コード例 #1
0
ファイル: myftp.c プロジェクト: bradsherman/FTPapp
int main(int argc, char *argv[]) {
    char buf[NET_BUF];
    int s, len, port;
    char *server_name;

    if(argc != 3) {
        printf("usage: ./myftp <server> <port>\n");
        return 0;
    }
    server_name = argv[1];
    port = atoi(argv[2]);

    s = get_client_socket(argv[1], port);    

    char line[BUF_SIZE];
    help();
    while(1) {
        printf("myftp>>> ");
        read_line(line);

        if (strcmp(line, "DWLD") == 0) {
            dwld(s);
        } else if (strcmp(line, "UPLD") == 0) {
            upld(s);
        } else if (strcmp(line, "LIST") == 0) {
            list(s);
        } else if (strcmp(line, "MDIR") == 0) {
            mdir(s);
        } else if (strcmp(line, "RDIR") == 0) {
            rdir(s);
        } else if (strcmp(line, "CDIR") == 0) {
            cdir(s);
        } else if (strcmp(line, "DELF") == 0) {
            delf(s);
        } else if (strcmp(line, "HELP") == 0) {
            help();
        } else if (strcmp(line, "QUIT") == 0) {
            printf("goodbye\n");
            quit(s);
            close(s);
            break;
        } else {
            printf("Unrecognized command: %s\n", line);
        }
        
    }
    return 0;
}
コード例 #2
0
bool Directory::create( std::string dir )
{
  Directory rdir( dir );
  if( rdir.exist() )
  {
    Logger::warning( "Directory %s also exist", dir.c_str() );
    return false;
  }

  int result=0;
#ifdef CAESARIA_PLATFORM_WIN
  CreateDirectoryA( rdir.removeEndSlash().toString().c_str(), NULL );
#elif defined(CAESARIA_PLATFORM_UNIX)
  result = ::mkdir( rdir.toString().c_str(), S_IRWXU|S_IRWXG|S_IRWXO );
#endif

  if( result < 0 )
  {
    Logger::warning( "Cannot create directory %s error=%d", dir.c_str(), result );
  }
  return (result == 0);
}
コード例 #3
0
ファイル: rendermodel.cpp プロジェクト: acidbarrel/Torment
void rendermodel(vec &color, vec &dir, const char *mdl, int anim, int varseed, int tex, float x, float y, float z, float yaw, float pitch, float speed, int basetime, dynent *d, int cull, const char *vwepmdl)
{
    model *m = loadmodel(mdl); 
    if(!m) return;
    if(cull)
    {
        vec center;
        float radius = m->boundsphere(0/*frame*/, center);   // FIXME
        center.add(vec(x, y, z));
        if((cull&MDL_CULL_DIST) && center.dist(camera1->o)/radius>maxmodelradiusdistance) return;
        if(cull&MDL_CULL_VFC)
        {
            if(refracting)
            {
                if(center.z+radius<refracting-waterfog || center.z-radius>=refracting) return;
            }
            else if(reflecting && center.z+radius<=reflecting) return;
            if((reflecting || refracting) && center.dist(camera1->o)-radius>reflectdist) return;
            if(isvisiblesphere(radius, center) >= VFC_FOGGED) return;
        };
        if((cull&MDL_CULL_OCCLUDED) && modeloccluded(center, radius)) return;
    };
    if(showboundingbox)
    {
        if(d) render3dbox(d->o, d->eyeheight, d->aboveeye, d->radius);
        else if((anim&ANIM_INDEX)!=ANIM_GUNSHOOT && (anim&ANIM_INDEX)!=ANIM_GUNIDLE)
        {
            vec center, radius;
            if(showboundingbox==1) m->collisionbox(0, center, radius);
            else m->boundbox(0, center, radius);
            rotatebb(center, radius, int(yaw));
            center.add(vec(x, y, z));
            render3dbox(center, radius.z, radius.z, radius.x, radius.y);
        };
    };

    if(d) lightreaching(d->o, color, dir);
    m->setskin(tex);  
    glColor3fv(color.v);
    m->setshader();
    if(renderpath!=R_FIXEDFUNCTION)
    {
        vec rdir(dir);
        rdir.rotate_around_z((-yaw-180.0f)*RAD);
        rdir.rotate_around_y(-pitch*RAD);
        glProgramEnvParameter4f_(GL_VERTEX_PROGRAM_ARB, 0, rdir.x, rdir.y, rdir.z, 0);

        vec camerapos = vec(player->o).sub(vec(x, y, z));
        camerapos.rotate_around_z((-yaw-180.0f)*RAD);
        camerapos.rotate_around_y(-pitch*RAD);
        glProgramEnvParameter4f_(GL_VERTEX_PROGRAM_ARB, 1, camerapos.x, camerapos.y, camerapos.z, 1);

        if(refracting) setfogplane(1, refracting - z);
    };

    model *vwep = NULL;
    if(vwepmdl)
    {
        vwep = loadmodel(vwepmdl);
        if(vwep->type()!=m->type()) vwep = NULL;
    };

    if(!m->cullface) glDisable(GL_CULL_FACE);
    m->render(anim, varseed, speed, basetime, x, y, z, yaw, pitch, d, vwep);
    if(!m->cullface) glEnable(GL_CULL_FACE);
};
コード例 #4
0
ファイル: MainWindow.cpp プロジェクト: autoscatto/retroshare
void openFile(std::string path)
{
	bool isAbs = true;
	QString surl("file://");

#if defined(Q_OS_WIN)
	/* check that it is an absolute path */
	if (path.size() < 4)
	{
		std::cerr << "[WIN] openPath() Very Small path ignoring: " << path;
		std::cerr << std::endl;
		return;
	}

	if ((path[1] == ':') && ((path[2] == '\\') || (path[2] == '/')))
	{
		isAbs = true;
	}
#else

	/* check that it is an absolute path */
	if (path.size() < 1)
	{
		std::cerr << "[UNIX] openPath() Very Small path ignoring: " << path;
		std::cerr << std::endl;
		return;
	}

	if (path[0] == '/')
	{
		isAbs = true;
	}
#endif

	if (!isAbs)
	{

#define ROOT_PATH_SIZE 1024

		char rootdir[ROOT_PATH_SIZE];
		if (NULL == getcwd(rootdir, ROOT_PATH_SIZE))
		{
			std::cerr << "openPath() get Abs Failed: " << path;
			std::cerr << std::endl;
			return;
		}

		std::string rdir(rootdir);
		surl += QString::fromStdString(rdir);
		surl += '/';
	}

	surl += QString::fromStdString(path);
	std::cerr << "openPath() opening AbsPath Url: " << surl.toStdString();
	std::cerr << std::endl;

	QUrl url(surl);
	QDesktopServices::openUrl(url);

	return;
}